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 { |
| 13 | BDC_E_TCP_UP, |
| 14 | BDC_E_TCP_DOWN, |
| 15 | BDC_E_CLIENT_CONN_RES, |
| 16 | }; |
| 17 | |
Harald Welte | fc0ba94 | 2018-10-14 17:47:00 +0200 | [diff] [blame] | 18 | extern struct osmo_fsm remsim_client_bankd_fsm; |
| 19 | |
Harald Welte | 24173fb | 2018-08-24 20:37:28 +0200 | [diff] [blame] | 20 | |
| 21 | enum server_conn_fsm_event { |
| 22 | SRVC_E_TCP_UP, |
| 23 | SRVC_E_TCP_DOWN, |
| 24 | SRVC_E_CLIENT_CONN_RES, |
| 25 | }; |
| 26 | |
Harald Welte | f9995a3 | 2018-10-14 20:40:05 +0200 | [diff] [blame] | 27 | struct rspro_server_conn; |
| 28 | |
Harald Welte | fc0ba94 | 2018-10-14 17:47:00 +0200 | [diff] [blame] | 29 | /* representing a client-side connection to a RSPRO server */ |
| 30 | struct rspro_server_conn { |
| 31 | /* state */ |
| 32 | struct ipa_client_conn *conn; |
| 33 | struct osmo_fsm_inst *fi; |
Harald Welte | f9995a3 | 2018-10-14 20:40:05 +0200 | [diff] [blame] | 34 | int (*handle_rx)(struct rspro_server_conn *conn, RsproPDU_t *pdu); |
Harald Welte | fc0ba94 | 2018-10-14 17:47:00 +0200 | [diff] [blame] | 35 | |
| 36 | /* our own component ID */ |
| 37 | struct app_comp_id own_comp_id; |
| 38 | |
| 39 | /* configuration */ |
| 40 | char *server_host; |
| 41 | uint16_t server_port; |
| 42 | }; |
| 43 | |
Harald Welte | 098ef87 | 2018-10-14 20:08:50 +0200 | [diff] [blame] | 44 | int server_conn_fsm_alloc(void *ctx, struct rspro_server_conn *srvc); |
Harald Welte | 24173fb | 2018-08-24 20:37:28 +0200 | [diff] [blame] | 45 | extern struct osmo_fsm remsim_client_server_fsm; |
| 46 | |
| 47 | /* main.c */ |
| 48 | |
| 49 | struct bankd_client { |
| 50 | /* connection to the remsim-server (control) */ |
| 51 | struct ipa_client_conn *srv_conn; |
| 52 | struct osmo_fsm_inst *srv_fi; |
| 53 | |
| 54 | /* our own component ID */ |
| 55 | struct app_comp_id own_comp_id; |
| 56 | |
| 57 | /* connection to the remsim-bankd */ |
| 58 | char *bankd_host; |
| 59 | uint16_t bankd_port; |
| 60 | struct ipa_client_conn *bankd_conn; |
| 61 | struct osmo_fsm_inst *bankd_fi; |
Kévin Redon | 38cd4f7 | 2018-10-10 00:36:46 +0200 | [diff] [blame] | 62 | |
| 63 | /* client id and slot number */ |
| 64 | ClientSlot_t *clslot; |
Harald Welte | 24173fb | 2018-08-24 20:37:28 +0200 | [diff] [blame] | 65 | }; |
| 66 | |
Harald Welte | f29e0d0 | 2018-08-24 21:42:22 +0200 | [diff] [blame] | 67 | 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] | 68 | int bankd_read_cb(struct ipa_client_conn *conn, struct msgb *msg); |
| 69 | int bankd_conn_fsm_alloc(struct bankd_client *bc); |