blob: 029fcd97189c5a698d2a6551f1e6f1c6cbaf05c8 [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 Welte16c81ea2020-02-16 14:44:00 +010011 SRVC_E_DISCONNECT, /* instruct SRVC to disconnect TCP connection to bankd */
Harald Welte707c85a2019-03-09 12:56:35 +010012 SRVC_E_TCP_UP,
13 SRVC_E_TCP_DOWN,
14 SRVC_E_KA_TIMEOUT,
Harald Welteb8ec65a2019-12-14 17:16:12 +010015 SRVC_E_KA_TERMINATED,
Harald Welte707c85a2019-03-09 12:56:35 +010016 SRVC_E_CLIENT_CONN_RES,
Harald Weltea3b14d12019-12-02 22:58:34 +010017 SRVC_E_RSPRO_TX /* transmit a RSPRO PDU to the peer */
Harald Welte707c85a2019-03-09 12:56:35 +010018};
19
20struct rspro_server_conn;
21
22/* representing a client-side connection to a RSPRO server */
23struct rspro_server_conn {
24 /* state */
25 struct ipa_client_conn *conn;
26 struct osmo_fsm_inst *fi;
27 struct osmo_fsm_inst *keepalive_fi;
28 int (*handle_rx)(struct rspro_server_conn *conn, const RsproPDU_t *pdu);
29 /* IPA protocol identity */
30 struct ipaccess_unit ipa_dev;
31
32 /* our own component ID */
33 struct app_comp_id own_comp_id;
34 /* remote component ID */
35 struct app_comp_id peer_comp_id;
36
37 /* client id and slot number */
38 ClientSlot_t *clslot;
39
40 /* configuration */
41 char *server_host;
42 uint16_t server_port;
Harald Welte2513d812019-04-01 21:03:02 +020043
Harald Welteb266d502020-02-22 20:53:19 +010044 /* FSM events we are to sent to the parent FSM on connect / disconnect */
45 uint32_t parent_conn_evt;
46 uint32_t parent_disc_evt;
47
Harald Welte2513d812019-04-01 21:03:02 +020048 /* only in case we are representing a bankd client */
49 struct {
50 uint16_t bank_id;
51 uint16_t num_slots;
52 } bankd;
Harald Welte707c85a2019-03-09 12:56:35 +010053};
54
Harald Weltea844bb02019-03-09 13:38:50 +010055int server_conn_send_rspro(struct rspro_server_conn *srvc, RsproPDU_t *rspro);
Harald Welte707c85a2019-03-09 12:56:35 +010056int server_conn_fsm_alloc(void *ctx, struct rspro_server_conn *srvc);