blob: 1703cb5ceb5ef3a9eed98d3405acc0155091cb56 [file] [log] [blame]
Harald Weltef5a0fa32019-03-03 15:44:18 +01001#pragma once
2#include <pthread.h>
3#include <osmocom/core/linuxlist.h>
4#include <osmocom/core/select.h>
5#include <osmocom/core/fsm.h>
6#include <osmocom/abis/ipa.h>
7
8#include "rspro_util.h"
9#include "slotmap.h"
10
11struct rspro_server {
12 struct ipa_server_link *link;
13 /* list of rspro_client_conn */
14 struct llist_head connections;
15 struct llist_head clients;
16 struct llist_head banks;
17 /* rwlock protecting any of the lists above */
18 pthread_rwlock_t rwlock;
19
20 struct slotmaps *slotmaps;
21
22 /* our own (server) component identity */
23 struct app_comp_id comp_id;
24};
25
26/* representing a single client connection to an RSPRO server */
27struct rspro_client_conn {
28 /* global list of connections */
29 struct llist_head list;
30 /* back-pointer to rspro_server */
31 struct rspro_server *srv;
32 /* reference to the underlying IPA server connection */
33 struct ipa_server_conn *peer;
34 /* FSM instance for this connection */
35 struct osmo_fsm_inst *fi;
36 /* remote component identity (after it has been received) */
37 struct app_comp_id comp_id;
Harald Welte15b75e12019-03-08 16:55:46 +010038 /* keep-alive handling FSM */
39 struct osmo_fsm_inst *keepalive_fi;
Harald Weltef5a0fa32019-03-03 15:44:18 +010040
41 struct {
42 struct llist_head maps_new;
43 struct llist_head maps_unack;
44 struct llist_head maps_active;
45 struct llist_head maps_delreq;
46 struct llist_head maps_deleting;
47 uint16_t bank_id;
48 uint16_t num_slots;
49 } bank;
Harald Weltee5c77732019-03-07 23:58:24 +010050 struct {
51 struct client_slot slot;
52 } client;
Harald Weltef5a0fa32019-03-03 15:44:18 +010053};
54
55struct rspro_server *rspro_server_create(void *ctx, const char *host, uint16_t port);
56void rspro_server_destroy(struct rspro_server *srv);
57int event_fd_cb(struct osmo_fd *ofd, unsigned int what);
58
59struct rspro_client_conn *_bankd_conn_by_id(struct rspro_server *srv, uint16_t bank_id);
60struct rspro_client_conn *bankd_conn_by_id(struct rspro_server *srv, uint16_t bank_id);