blob: 69185600b52d52a43c89fa7af4c957c76d8f235b [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 {
13 BDC_E_TCP_UP,
14 BDC_E_TCP_DOWN,
15 BDC_E_CLIENT_CONN_RES,
16};
17
Harald Weltefc0ba942018-10-14 17:47:00 +020018extern struct osmo_fsm remsim_client_bankd_fsm;
19
Harald Welte24173fb2018-08-24 20:37:28 +020020
21enum server_conn_fsm_event {
22 SRVC_E_TCP_UP,
23 SRVC_E_TCP_DOWN,
24 SRVC_E_CLIENT_CONN_RES,
25};
26
Harald Weltef9995a32018-10-14 20:40:05 +020027struct rspro_server_conn;
28
Harald Weltefc0ba942018-10-14 17:47:00 +020029/* representing a client-side connection to a RSPRO server */
30struct rspro_server_conn {
31 /* state */
32 struct ipa_client_conn *conn;
33 struct osmo_fsm_inst *fi;
Harald Weltef9995a32018-10-14 20:40:05 +020034 int (*handle_rx)(struct rspro_server_conn *conn, RsproPDU_t *pdu);
Harald Weltefc0ba942018-10-14 17:47:00 +020035
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 Welte098ef872018-10-14 20:08:50 +020044int server_conn_fsm_alloc(void *ctx, struct rspro_server_conn *srvc);
Harald Welte24173fb2018-08-24 20:37:28 +020045extern struct osmo_fsm remsim_client_server_fsm;
46
47/* main.c */
48
49struct 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 Redon38cd4f72018-10-10 00:36:46 +020062
63 /* client id and slot number */
64 ClientSlot_t *clslot;
Harald Welte24173fb2018-08-24 20:37:28 +020065};
66
Harald Weltef29e0d02018-08-24 21:42:22 +020067void ipa_client_conn_send_rspro(struct ipa_client_conn *ipa, RsproPDU_t *rspro);
Harald Welte24173fb2018-08-24 20:37:28 +020068int bankd_read_cb(struct ipa_client_conn *conn, struct msgb *msg);
69int bankd_conn_fsm_alloc(struct bankd_client *bc);