Harald Welte | f5a0fa3 | 2019-03-03 15:44:18 +0100 | [diff] [blame] | 1 | #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 | |
| 11 | struct 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 */ |
| 27 | struct 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 Welte | 15b75e1 | 2019-03-08 16:55:46 +0100 | [diff] [blame] | 38 | /* keep-alive handling FSM */ |
| 39 | struct osmo_fsm_inst *keepalive_fi; |
Harald Welte | f5a0fa3 | 2019-03-03 15:44:18 +0100 | [diff] [blame] | 40 | |
| 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 Welte | e5c7773 | 2019-03-07 23:58:24 +0100 | [diff] [blame] | 50 | struct { |
| 51 | struct client_slot slot; |
Harald Welte | 4c37f66 | 2019-03-31 15:00:00 +0200 | [diff] [blame] | 52 | /* 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 Welte | e5c7773 | 2019-03-07 23:58:24 +0100 | [diff] [blame] | 58 | } client; |
Harald Welte | f5a0fa3 | 2019-03-03 15:44:18 +0100 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | struct rspro_server *rspro_server_create(void *ctx, const char *host, uint16_t port); |
| 62 | void rspro_server_destroy(struct rspro_server *srv); |
| 63 | int event_fd_cb(struct osmo_fd *ofd, unsigned int what); |
| 64 | |
Harald Welte | f30ff9e | 2019-03-30 19:17:37 +0100 | [diff] [blame] | 65 | struct rspro_client_conn *_client_conn_by_slot(struct rspro_server *srv, const struct client_slot *cslot); |
| 66 | struct rspro_client_conn *client_conn_by_slot(struct rspro_server *srv, const struct client_slot *cslot); |
Harald Welte | f5a0fa3 | 2019-03-03 15:44:18 +0100 | [diff] [blame] | 67 | struct rspro_client_conn *_bankd_conn_by_id(struct rspro_server *srv, uint16_t bank_id); |
| 68 | struct rspro_client_conn *bankd_conn_by_id(struct rspro_server *srv, uint16_t bank_id); |