blob: d85e647f43068c3a1c76f53b74db972f3c03e6ad [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>
5
6#include "rspro_util.h"
Harald Weltea4e0a232018-10-14 17:44:25 +02007#include "debug.h"
Harald Welte24173fb2018-08-24 20:37:28 +02008
9/* fsm.c */
10
11enum bankd_conn_fsm_event {
12 BDC_E_TCP_UP,
13 BDC_E_TCP_DOWN,
14 BDC_E_CLIENT_CONN_RES,
15};
16
Harald Weltefc0ba942018-10-14 17:47:00 +020017extern struct osmo_fsm remsim_client_bankd_fsm;
18
Harald Welte24173fb2018-08-24 20:37:28 +020019
20enum server_conn_fsm_event {
21 SRVC_E_TCP_UP,
22 SRVC_E_TCP_DOWN,
23 SRVC_E_CLIENT_CONN_RES,
24};
25
Harald Weltefc0ba942018-10-14 17:47:00 +020026/* representing a client-side connection to a RSPRO server */
27struct rspro_server_conn {
28 /* state */
29 struct ipa_client_conn *conn;
30 struct osmo_fsm_inst *fi;
31
32 /* our own component ID */
33 struct app_comp_id own_comp_id;
34
35 /* configuration */
36 char *server_host;
37 uint16_t server_port;
38};
39
Harald Welte098ef872018-10-14 20:08:50 +020040int server_conn_fsm_alloc(void *ctx, struct rspro_server_conn *srvc);
Harald Welte24173fb2018-08-24 20:37:28 +020041extern struct osmo_fsm remsim_client_server_fsm;
42
43/* main.c */
44
45struct bankd_client {
46 /* connection to the remsim-server (control) */
47 struct ipa_client_conn *srv_conn;
48 struct osmo_fsm_inst *srv_fi;
49
50 /* our own component ID */
51 struct app_comp_id own_comp_id;
52
53 /* connection to the remsim-bankd */
54 char *bankd_host;
55 uint16_t bankd_port;
56 struct ipa_client_conn *bankd_conn;
57 struct osmo_fsm_inst *bankd_fi;
Kévin Redon38cd4f72018-10-10 00:36:46 +020058
59 /* client id and slot number */
60 ClientSlot_t *clslot;
Harald Welte24173fb2018-08-24 20:37:28 +020061};
62
Harald Weltef29e0d02018-08-24 21:42:22 +020063void ipa_client_conn_send_rspro(struct ipa_client_conn *ipa, RsproPDU_t *rspro);
Harald Welte24173fb2018-08-24 20:37:28 +020064int bankd_read_cb(struct ipa_client_conn *conn, struct msgb *msg);
65int bankd_conn_fsm_alloc(struct bankd_client *bc);