Harald Welte | 707c85a | 2019-03-09 12:56:35 +0100 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <osmocom/core/fsm.h> |
| 4 | #include <osmocom/abis/ipa.h> |
| 5 | #include <osmocom/rspro/RsproPDU.h> |
| 6 | |
Harald Welte | f7598fe | 2019-12-16 16:52:45 +0100 | [diff] [blame] | 7 | #include "rspro_util.h" |
| 8 | |
Harald Welte | 707c85a | 2019-03-09 12:56:35 +0100 | [diff] [blame] | 9 | enum server_conn_fsm_event { |
Harald Welte | d2192e2 | 2019-11-07 18:10:57 +0100 | [diff] [blame] | 10 | SRVC_E_ESTABLISH, /* instruct SRVC to (re)etablish TCP connection to bankd */ |
Harald Welte | 16c81ea | 2020-02-16 14:44:00 +0100 | [diff] [blame] | 11 | SRVC_E_DISCONNECT, /* instruct SRVC to disconnect TCP connection to bankd */ |
Harald Welte | 707c85a | 2019-03-09 12:56:35 +0100 | [diff] [blame] | 12 | SRVC_E_TCP_UP, |
| 13 | SRVC_E_TCP_DOWN, |
| 14 | SRVC_E_KA_TIMEOUT, |
Harald Welte | b8ec65a | 2019-12-14 17:16:12 +0100 | [diff] [blame] | 15 | SRVC_E_KA_TERMINATED, |
Harald Welte | 707c85a | 2019-03-09 12:56:35 +0100 | [diff] [blame] | 16 | SRVC_E_CLIENT_CONN_RES, |
Harald Welte | a3b14d1 | 2019-12-02 22:58:34 +0100 | [diff] [blame] | 17 | SRVC_E_RSPRO_TX /* transmit a RSPRO PDU to the peer */ |
Harald Welte | 707c85a | 2019-03-09 12:56:35 +0100 | [diff] [blame] | 18 | }; |
| 19 | |
| 20 | struct rspro_server_conn; |
| 21 | |
| 22 | /* representing a client-side connection to a RSPRO server */ |
| 23 | struct 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 Tavares | b890018 | 2022-11-14 11:04:11 -0500 | [diff] [blame] | 29 | |
| 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 Welte | 707c85a | 2019-03-09 12:56:35 +0100 | [diff] [blame] | 36 | /* 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 Welte | 2513d81 | 2019-04-01 21:03:02 +0200 | [diff] [blame] | 50 | |
Harald Welte | b266d50 | 2020-02-22 20:53:19 +0100 | [diff] [blame] | 51 | /* 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 Welte | 2513d81 | 2019-04-01 21:03:02 +0200 | [diff] [blame] | 55 | /* only in case we are representing a bankd client */ |
| 56 | struct { |
| 57 | uint16_t bank_id; |
| 58 | uint16_t num_slots; |
| 59 | } bankd; |
Harald Welte | 707c85a | 2019-03-09 12:56:35 +0100 | [diff] [blame] | 60 | }; |
| 61 | |
Harald Welte | a844bb0 | 2019-03-09 13:38:50 +0100 | [diff] [blame] | 62 | int server_conn_send_rspro(struct rspro_server_conn *srvc, RsproPDU_t *rspro); |
Harald Welte | 707c85a | 2019-03-09 12:56:35 +0100 | [diff] [blame] | 63 | int server_conn_fsm_alloc(void *ctx, struct rspro_server_conn *srvc); |