blob: 44b0fb9f3d12b41a41c4fade390b458055a18803 [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;
38
39 struct {
40 struct llist_head maps_new;
41 struct llist_head maps_unack;
42 struct llist_head maps_active;
43 struct llist_head maps_delreq;
44 struct llist_head maps_deleting;
45 uint16_t bank_id;
46 uint16_t num_slots;
47 } bank;
Harald Weltee5c77732019-03-07 23:58:24 +010048 struct {
49 struct client_slot slot;
50 } client;
Harald Weltef5a0fa32019-03-03 15:44:18 +010051};
52
53struct rspro_server *rspro_server_create(void *ctx, const char *host, uint16_t port);
54void rspro_server_destroy(struct rspro_server *srv);
55int event_fd_cb(struct osmo_fd *ofd, unsigned int what);
56
57struct rspro_client_conn *_bankd_conn_by_id(struct rspro_server *srv, uint16_t bank_id);
58struct rspro_client_conn *bankd_conn_by_id(struct rspro_server *srv, uint16_t bank_id);