blob: 55fe4a4f2d67202701b4d8503d4ae2b044664992 [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);
James Tavaresb8900182022-11-14 11:04:11 -050029
30 /* index into k_reestablish_delay[] for this connection */
31 size_t reestablish_delay_idx;
32
33 /* timestamp of last re-establish attempt, in milliseconds */
34 int64_t reestablish_last_ms;
35
Harald Welte707c85a2019-03-09 12:56:35 +010036 /* IPA protocol identity */
37 struct ipaccess_unit ipa_dev;
38
39 /* our own component ID */
40 struct app_comp_id own_comp_id;
41 /* remote component ID */
42 struct app_comp_id peer_comp_id;
43
44 /* client id and slot number */
45 ClientSlot_t *clslot;
46
47 /* configuration */
48 char *server_host;
49 uint16_t server_port;
Harald Welte2513d812019-04-01 21:03:02 +020050
Harald Welteb266d502020-02-22 20:53:19 +010051 /* FSM events we are to sent to the parent FSM on connect / disconnect */
52 uint32_t parent_conn_evt;
53 uint32_t parent_disc_evt;
54
Harald Welte2513d812019-04-01 21:03:02 +020055 /* only in case we are representing a bankd client */
56 struct {
57 uint16_t bank_id;
58 uint16_t num_slots;
59 } bankd;
Harald Welte707c85a2019-03-09 12:56:35 +010060};
61
Harald Weltea844bb02019-03-09 13:38:50 +010062int server_conn_send_rspro(struct rspro_server_conn *srvc, RsproPDU_t *rspro);
Harald Welte707c85a2019-03-09 12:56:35 +010063int server_conn_fsm_alloc(void *ctx, struct rspro_server_conn *srvc);