blob: 1917cb5031426479a1ad7a8deccb86c4b0d6535e [file] [log] [blame]
Harald Welte24173fb2018-08-24 20:37:28 +02001#pragma once
2
3#include <osmocom/core/fsm.h>
4#include <osmocom/abis/ipa.h>
Harald Weltef9995a32018-10-14 20:40:05 +02005#include <osmocom/rspro/RsproPDU.h>
Harald Welte24173fb2018-08-24 20:37:28 +02006
7#include "rspro_util.h"
Harald Weltea4e0a232018-10-14 17:44:25 +02008#include "debug.h"
Harald Welte24173fb2018-08-24 20:37:28 +02009
10/* fsm.c */
11
12enum bankd_conn_fsm_event {
Harald Weltee56f2b92019-03-02 17:02:13 +010013 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 Welte24173fb2018-08-24 20:37:28 +020017};
18
Harald Weltefc0ba942018-10-14 17:47:00 +020019extern struct osmo_fsm remsim_client_bankd_fsm;
20
Harald Welte24173fb2018-08-24 20:37:28 +020021
22enum server_conn_fsm_event {
23 SRVC_E_TCP_UP,
24 SRVC_E_TCP_DOWN,
25 SRVC_E_CLIENT_CONN_RES,
26};
27
Harald Weltef9995a32018-10-14 20:40:05 +020028struct rspro_server_conn;
29
Harald Weltefc0ba942018-10-14 17:47:00 +020030/* representing a client-side connection to a RSPRO server */
31struct rspro_server_conn {
32 /* state */
33 struct ipa_client_conn *conn;
34 struct osmo_fsm_inst *fi;
Harald Weltee56f2b92019-03-02 17:02:13 +010035 int (*handle_rx)(struct rspro_server_conn *conn, const RsproPDU_t *pdu);
Harald Weltefc0ba942018-10-14 17:47:00 +020036
37 /* our own component ID */
38 struct app_comp_id own_comp_id;
Harald Weltee56f2b92019-03-02 17:02:13 +010039 /* remote component ID */
40 struct app_comp_id peer_comp_id;
Harald Weltefc0ba942018-10-14 17:47:00 +020041
42 /* configuration */
43 char *server_host;
44 uint16_t server_port;
45};
46
Harald Welte098ef872018-10-14 20:08:50 +020047int server_conn_fsm_alloc(void *ctx, struct rspro_server_conn *srvc);
Harald Welte24173fb2018-08-24 20:37:28 +020048extern struct osmo_fsm remsim_client_server_fsm;
49
50/* main.c */
51
52struct bankd_client {
53 /* connection to the remsim-server (control) */
Harald Weltee56f2b92019-03-02 17:02:13 +010054 struct rspro_server_conn srv_conn;
Harald Welte24173fb2018-08-24 20:37:28 +020055
Harald Weltee56f2b92019-03-02 17:02:13 +010056 /* remote component ID */
57 struct app_comp_id peer_comp_id;
Harald Welte24173fb2018-08-24 20:37:28 +020058
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 Redon38cd4f72018-10-10 00:36:46 +020064
65 /* client id and slot number */
66 ClientSlot_t *clslot;
Harald Welte24173fb2018-08-24 20:37:28 +020067};
68
Harald Weltef29e0d02018-08-24 21:42:22 +020069void ipa_client_conn_send_rspro(struct ipa_client_conn *ipa, RsproPDU_t *rspro);
Harald Welte24173fb2018-08-24 20:37:28 +020070int bankd_read_cb(struct ipa_client_conn *conn, struct msgb *msg);
71int bankd_conn_fsm_alloc(struct bankd_client *bc);