blob: 6279b91e571b478d284e6c18b823ecadf15ebd0d [file] [log] [blame]
Harald Welte90256ba2015-12-23 20:16:36 +01001#pragma once
2
3#include <stdint.h>
4#include <osmocom/core/linuxlist.h>
5
6enum hnbgw_context_map_state {
7 MAP_S_NULL,
8 MAP_S_ACTIVE, /* currently active map */
9 MAP_S_RESERVED1, /* just disconnected, still resrved */
10 MAP_S_RESERVED2, /* still reserved */
Neels Hofmeyr9e17e052017-12-25 00:35:05 +010011 MAP_S_NUM_STATES /* Number of states, keep this at the end */
Harald Welte90256ba2015-12-23 20:16:36 +010012};
13
Neels Hofmeyr9e17e052017-12-25 00:35:05 +010014extern const struct value_string hnbgw_context_map_state_names[];
15static inline const char *hnbgw_context_map_state_name(enum hnbgw_context_map_state val)
16{ return get_value_string(hnbgw_context_map_state_names, val); }
17
Harald Welte90256ba2015-12-23 20:16:36 +010018struct hnb_context;
19struct hnbgw_cnlink;
20
21struct hnbgw_context_map {
22 /* entry in the per-CN list of mappings */
23 struct llist_head cn_list;
24 /* entry in the per-HNB list of mappings */
25 struct llist_head hnb_list;
26 /* pointer to HNB */
27 struct hnb_context *hnb_ctx;
28 /* pointer to CN */
29 struct hnbgw_cnlink *cn_link;
30 /* RUA contxt ID */
31 uint32_t rua_ctx_id;
Neels Hofmeyr0f88c112017-07-03 16:49:43 +020032 /* False for CS, true for PS */
33 bool is_ps;
Harald Welte90256ba2015-12-23 20:16:36 +010034 /* SCCP User SAP connection ID */
35 uint32_t scu_conn_id;
36
37 enum hnbgw_context_map_state state;
38};
39
40
41struct hnbgw_context_map *
42context_map_alloc_by_hnb(struct hnb_context *hnb, uint32_t rua_ctx_id,
Neels Hofmeyr0f88c112017-07-03 16:49:43 +020043 bool is_ps,
Harald Welte90256ba2015-12-23 20:16:36 +010044 struct hnbgw_cnlink *cn_if_new);
45
46struct hnbgw_context_map *
47context_map_by_cn(struct hnbgw_cnlink *cn, uint32_t scu_conn_id);
48
49void context_map_deactivate(struct hnbgw_context_map *map);
50
51int context_map_init(struct hnb_gw *gw);