Harald Welte | 24173fb | 2018-08-24 20:37:28 +0200 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <osmocom/core/fsm.h> |
| 4 | #include <osmocom/abis/ipa.h> |
Harald Welte | f9995a3 | 2018-10-14 20:40:05 +0200 | [diff] [blame] | 5 | #include <osmocom/rspro/RsproPDU.h> |
Harald Welte | 24173fb | 2018-08-24 20:37:28 +0200 | [diff] [blame] | 6 | |
| 7 | #include "rspro_util.h" |
Harald Welte | a4e0a23 | 2018-10-14 17:44:25 +0200 | [diff] [blame] | 8 | #include "debug.h" |
Harald Welte | 24173fb | 2018-08-24 20:37:28 +0200 | [diff] [blame] | 9 | |
| 10 | /* fsm.c */ |
| 11 | |
| 12 | enum bankd_conn_fsm_event { |
Harald Welte | e56f2b9 | 2019-03-02 17:02:13 +0100 | [diff] [blame] | 13 | BDC_E_ESTABLISH, /* instruct BDC to (re)etablish TCP connection to bankd */ |
| 14 | BDC_E_TCP_UP, /* notify BDC that TCP connection is up/connected */ |
| 15 | BDC_E_TCP_DOWN, /* notify BDC that TCP connection is down/disconnected */ |
| 16 | BDC_E_CLIENT_CONN_RES, /* notify BDC that ClientConnectRes has been received */ |
Harald Welte | 24173fb | 2018-08-24 20:37:28 +0200 | [diff] [blame] | 17 | }; |
| 18 | |
Harald Welte | fc0ba94 | 2018-10-14 17:47:00 +0200 | [diff] [blame] | 19 | extern struct osmo_fsm remsim_client_bankd_fsm; |
| 20 | |
Harald Welte | 24173fb | 2018-08-24 20:37:28 +0200 | [diff] [blame] | 21 | |
| 22 | enum server_conn_fsm_event { |
| 23 | SRVC_E_TCP_UP, |
| 24 | SRVC_E_TCP_DOWN, |
| 25 | SRVC_E_CLIENT_CONN_RES, |
| 26 | }; |
| 27 | |
Harald Welte | f9995a3 | 2018-10-14 20:40:05 +0200 | [diff] [blame] | 28 | struct rspro_server_conn; |
| 29 | |
Harald Welte | fc0ba94 | 2018-10-14 17:47:00 +0200 | [diff] [blame] | 30 | /* representing a client-side connection to a RSPRO server */ |
| 31 | struct rspro_server_conn { |
| 32 | /* state */ |
| 33 | struct ipa_client_conn *conn; |
| 34 | struct osmo_fsm_inst *fi; |
Harald Welte | e56f2b9 | 2019-03-02 17:02:13 +0100 | [diff] [blame] | 35 | int (*handle_rx)(struct rspro_server_conn *conn, const RsproPDU_t *pdu); |
Harald Welte | fc0ba94 | 2018-10-14 17:47:00 +0200 | [diff] [blame] | 36 | |
| 37 | /* our own component ID */ |
| 38 | struct app_comp_id own_comp_id; |
Harald Welte | e56f2b9 | 2019-03-02 17:02:13 +0100 | [diff] [blame] | 39 | /* remote component ID */ |
| 40 | struct app_comp_id peer_comp_id; |
Harald Welte | fc0ba94 | 2018-10-14 17:47:00 +0200 | [diff] [blame] | 41 | |
| 42 | /* configuration */ |
| 43 | char *server_host; |
| 44 | uint16_t server_port; |
| 45 | }; |
| 46 | |
Harald Welte | 098ef87 | 2018-10-14 20:08:50 +0200 | [diff] [blame] | 47 | int server_conn_fsm_alloc(void *ctx, struct rspro_server_conn *srvc); |
Harald Welte | 24173fb | 2018-08-24 20:37:28 +0200 | [diff] [blame] | 48 | extern struct osmo_fsm remsim_client_server_fsm; |
| 49 | |
| 50 | /* main.c */ |
| 51 | |
| 52 | struct bankd_client { |
| 53 | /* connection to the remsim-server (control) */ |
Harald Welte | e56f2b9 | 2019-03-02 17:02:13 +0100 | [diff] [blame] | 54 | struct rspro_server_conn srv_conn; |
Harald Welte | 24173fb | 2018-08-24 20:37:28 +0200 | [diff] [blame] | 55 | |
Harald Welte | e56f2b9 | 2019-03-02 17:02:13 +0100 | [diff] [blame] | 56 | /* remote component ID */ |
| 57 | struct app_comp_id peer_comp_id; |
Harald Welte | 24173fb | 2018-08-24 20:37:28 +0200 | [diff] [blame] | 58 | |
| 59 | /* connection to the remsim-bankd */ |
| 60 | char *bankd_host; |
| 61 | uint16_t bankd_port; |
| 62 | struct ipa_client_conn *bankd_conn; |
| 63 | struct osmo_fsm_inst *bankd_fi; |
Kévin Redon | 38cd4f7 | 2018-10-10 00:36:46 +0200 | [diff] [blame] | 64 | |
| 65 | /* client id and slot number */ |
| 66 | ClientSlot_t *clslot; |
Harald Welte | 24173fb | 2018-08-24 20:37:28 +0200 | [diff] [blame] | 67 | }; |
| 68 | |
Harald Welte | f29e0d0 | 2018-08-24 21:42:22 +0200 | [diff] [blame] | 69 | void ipa_client_conn_send_rspro(struct ipa_client_conn *ipa, RsproPDU_t *rspro); |
Harald Welte | 24173fb | 2018-08-24 20:37:28 +0200 | [diff] [blame] | 70 | int bankd_read_cb(struct ipa_client_conn *conn, struct msgb *msg); |
| 71 | int bankd_conn_fsm_alloc(struct bankd_client *bc); |