Harald Welte | 90256ba | 2015-12-23 20:16:36 +0100 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <stdint.h> |
| 4 | #include <osmocom/core/linuxlist.h> |
| 5 | |
| 6 | enum 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 Hofmeyr | 9e17e05 | 2017-12-25 00:35:05 +0100 | [diff] [blame] | 11 | MAP_S_NUM_STATES /* Number of states, keep this at the end */ |
Harald Welte | 90256ba | 2015-12-23 20:16:36 +0100 | [diff] [blame] | 12 | }; |
| 13 | |
Neels Hofmeyr | 9e17e05 | 2017-12-25 00:35:05 +0100 | [diff] [blame] | 14 | extern const struct value_string hnbgw_context_map_state_names[]; |
| 15 | static 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 Welte | 90256ba | 2015-12-23 20:16:36 +0100 | [diff] [blame] | 18 | struct hnb_context; |
| 19 | struct hnbgw_cnlink; |
| 20 | |
| 21 | struct 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 Hofmeyr | 0f88c11 | 2017-07-03 16:49:43 +0200 | [diff] [blame] | 32 | /* False for CS, true for PS */ |
| 33 | bool is_ps; |
Harald Welte | 90256ba | 2015-12-23 20:16:36 +0100 | [diff] [blame] | 34 | /* SCCP User SAP connection ID */ |
| 35 | uint32_t scu_conn_id; |
| 36 | |
| 37 | enum hnbgw_context_map_state state; |
| 38 | }; |
| 39 | |
| 40 | |
| 41 | struct hnbgw_context_map * |
| 42 | context_map_alloc_by_hnb(struct hnb_context *hnb, uint32_t rua_ctx_id, |
Neels Hofmeyr | 0f88c11 | 2017-07-03 16:49:43 +0200 | [diff] [blame] | 43 | bool is_ps, |
Harald Welte | 90256ba | 2015-12-23 20:16:36 +0100 | [diff] [blame] | 44 | struct hnbgw_cnlink *cn_if_new); |
| 45 | |
| 46 | struct hnbgw_context_map * |
| 47 | context_map_by_cn(struct hnbgw_cnlink *cn, uint32_t scu_conn_id); |
| 48 | |
| 49 | void context_map_deactivate(struct hnbgw_context_map *map); |
| 50 | |
| 51 | int context_map_init(struct hnb_gw *gw); |