blob: 2f3f7fcd09cf910f7c648fb51546530b62bcd46a [file] [log] [blame]
Harald Welte707c85a2019-03-09 12:56:35 +01001#pragma once
2
3#include <osmocom/core/fsm.h>
4#include <osmocom/abis/ipa.h>
5#include <osmocom/rspro/RsproPDU.h>
6
Harald Weltef7598fe2019-12-16 16:52:45 +01007#include "rspro_util.h"
8
Harald Welte707c85a2019-03-09 12:56:35 +01009enum server_conn_fsm_event {
Harald Welted2192e22019-11-07 18:10:57 +010010 SRVC_E_ESTABLISH, /* instruct SRVC to (re)etablish TCP connection to bankd */
Harald Welte707c85a2019-03-09 12:56:35 +010011 SRVC_E_TCP_UP,
12 SRVC_E_TCP_DOWN,
13 SRVC_E_KA_TIMEOUT,
Harald Welteb8ec65a2019-12-14 17:16:12 +010014 SRVC_E_KA_TERMINATED,
Harald Welte707c85a2019-03-09 12:56:35 +010015 SRVC_E_CLIENT_CONN_RES,
Harald Weltea3b14d12019-12-02 22:58:34 +010016 SRVC_E_RSPRO_TX /* transmit a RSPRO PDU to the peer */
Harald Welte707c85a2019-03-09 12:56:35 +010017};
18
19struct rspro_server_conn;
20
21/* representing a client-side connection to a RSPRO server */
22struct rspro_server_conn {
23 /* state */
24 struct ipa_client_conn *conn;
25 struct osmo_fsm_inst *fi;
26 struct osmo_fsm_inst *keepalive_fi;
27 int (*handle_rx)(struct rspro_server_conn *conn, const RsproPDU_t *pdu);
28 /* IPA protocol identity */
29 struct ipaccess_unit ipa_dev;
30
31 /* our own component ID */
32 struct app_comp_id own_comp_id;
33 /* remote component ID */
34 struct app_comp_id peer_comp_id;
35
36 /* client id and slot number */
37 ClientSlot_t *clslot;
38
39 /* configuration */
40 char *server_host;
41 uint16_t server_port;
Harald Welte2513d812019-04-01 21:03:02 +020042
43 /* only in case we are representing a bankd client */
44 struct {
45 uint16_t bank_id;
46 uint16_t num_slots;
47 } bankd;
Harald Welte707c85a2019-03-09 12:56:35 +010048};
49
Harald Weltea844bb02019-03-09 13:38:50 +010050int server_conn_send_rspro(struct rspro_server_conn *srvc, RsproPDU_t *rspro);
Harald Welte707c85a2019-03-09 12:56:35 +010051int server_conn_fsm_alloc(void *ctx, struct rspro_server_conn *srvc);