blob: ca59c772ef5e09752b42249114e06d58c94a18c4 [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
7enum server_conn_fsm_event {
Harald Welted2192e22019-11-07 18:10:57 +01008 SRVC_E_ESTABLISH, /* instruct SRVC to (re)etablish TCP connection to bankd */
Harald Welte707c85a2019-03-09 12:56:35 +01009 SRVC_E_TCP_UP,
10 SRVC_E_TCP_DOWN,
11 SRVC_E_KA_TIMEOUT,
Harald Welteb8ec65a2019-12-14 17:16:12 +010012 SRVC_E_KA_TERMINATED,
Harald Welte707c85a2019-03-09 12:56:35 +010013 SRVC_E_CLIENT_CONN_RES,
Harald Weltea3b14d12019-12-02 22:58:34 +010014 SRVC_E_RSPRO_TX /* transmit a RSPRO PDU to the peer */
Harald Welte707c85a2019-03-09 12:56:35 +010015};
16
17struct rspro_server_conn;
18
19/* representing a client-side connection to a RSPRO server */
20struct rspro_server_conn {
21 /* state */
22 struct ipa_client_conn *conn;
23 struct osmo_fsm_inst *fi;
24 struct osmo_fsm_inst *keepalive_fi;
25 int (*handle_rx)(struct rspro_server_conn *conn, const RsproPDU_t *pdu);
26 /* IPA protocol identity */
27 struct ipaccess_unit ipa_dev;
28
29 /* our own component ID */
30 struct app_comp_id own_comp_id;
31 /* remote component ID */
32 struct app_comp_id peer_comp_id;
33
34 /* client id and slot number */
35 ClientSlot_t *clslot;
36
37 /* configuration */
38 char *server_host;
39 uint16_t server_port;
Harald Welte2513d812019-04-01 21:03:02 +020040
41 /* only in case we are representing a bankd client */
42 struct {
43 uint16_t bank_id;
44 uint16_t num_slots;
45 } bankd;
Harald Welte707c85a2019-03-09 12:56:35 +010046};
47
Harald Weltea844bb02019-03-09 13:38:50 +010048int server_conn_send_rspro(struct rspro_server_conn *srvc, RsproPDU_t *rspro);
Harald Welte707c85a2019-03-09 12:56:35 +010049int server_conn_fsm_alloc(void *ctx, struct rspro_server_conn *srvc);