blob: 6dd498eee570e5335b25714f7505916aaa6fd6f8 [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;
Harald Welte4c37f662019-03-31 15:00:00 +020052 /* bankd configuration for this client (if any) */
53 struct {
54 struct bank_slot slot;
55 uint32_t ip;
56 uint16_t port;
57 } bankd;
Harald Weltee5c77732019-03-07 23:58:24 +010058 } client;
Harald Weltef5a0fa32019-03-03 15:44:18 +010059};
60
61struct rspro_server *rspro_server_create(void *ctx, const char *host, uint16_t port);
62void rspro_server_destroy(struct rspro_server *srv);
63int event_fd_cb(struct osmo_fd *ofd, unsigned int what);
64
Harald Weltef30ff9e2019-03-30 19:17:37 +010065struct rspro_client_conn *_client_conn_by_slot(struct rspro_server *srv, const struct client_slot *cslot);
66struct rspro_client_conn *client_conn_by_slot(struct rspro_server *srv, const struct client_slot *cslot);
Harald Weltef5a0fa32019-03-03 15:44:18 +010067struct rspro_client_conn *_bankd_conn_by_id(struct rspro_server *srv, uint16_t bank_id);
68struct rspro_client_conn *bankd_conn_by_id(struct rspro_server *srv, uint16_t bank_id);