Harald Welte | ba43de4 | 2015-08-29 20:33:16 +0200 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <osmocom/core/select.h> |
| 4 | #include <osmocom/core/linuxlist.h> |
Harald Welte | 3f71256 | 2015-09-07 21:53:25 +0200 | [diff] [blame] | 5 | #include <osmocom/core/write_queue.h> |
Harald Welte | ba43de4 | 2015-08-29 20:33:16 +0200 | [diff] [blame] | 6 | |
Harald Welte | b3dae30 | 2015-08-30 12:20:09 +0200 | [diff] [blame] | 7 | #define DEBUG |
| 8 | #include <osmocom/core/logging.h> |
| 9 | |
| 10 | enum { |
| 11 | DMAIN, |
Daniel Willmann | bded984 | 2015-12-17 11:51:17 +0100 | [diff] [blame] | 12 | DHNBAP, |
Harald Welte | 75a4e65 | 2015-12-22 23:59:24 +0100 | [diff] [blame] | 13 | DSUA, |
Harald Welte | f42317b | 2015-12-23 15:36:31 +0100 | [diff] [blame^] | 14 | DRUA, |
| 15 | DRANAP, |
Harald Welte | b3dae30 | 2015-08-30 12:20:09 +0200 | [diff] [blame] | 16 | }; |
| 17 | |
| 18 | |
Harald Welte | a2e6a7a | 2015-08-29 21:47:39 +0200 | [diff] [blame] | 19 | /* 25.467 Section 7.1 */ |
| 20 | #define IUH_DEFAULT_SCTP_PORT 29169 |
| 21 | #define RNA_DEFAULT_SCTP_PORT 25471 |
| 22 | |
| 23 | #define IUH_PPI_RUA 19 |
| 24 | #define IUH_PPI_HNBAP 20 |
| 25 | #define IUH_PPI_SABP 31 |
| 26 | #define IUH_PPI_RNA 42 |
| 27 | #define IUH_PPI_PUA 55 |
| 28 | |
Harald Welte | b3dae30 | 2015-08-30 12:20:09 +0200 | [diff] [blame] | 29 | #define IUH_MSGB_SIZE 2048 |
Harald Welte | a2e6a7a | 2015-08-29 21:47:39 +0200 | [diff] [blame] | 30 | |
| 31 | struct umts_cell_id { |
| 32 | uint16_t mcc; /*!< Mobile Country Code */ |
| 33 | uint16_t mnc; /*!< Mobile Network Code */ |
| 34 | uint16_t lac; /*!< Locaton Area Code */ |
| 35 | uint16_t rac; /*!< Routing Area Code */ |
| 36 | uint16_t sac; /*!< Service Area Code */ |
| 37 | uint32_t cid; /*!< Cell ID */ |
| 38 | }; |
| 39 | |
| 40 | struct hnb_gw; |
| 41 | |
Harald Welte | ba43de4 | 2015-08-29 20:33:16 +0200 | [diff] [blame] | 42 | struct hnb_context { |
| 43 | /*! Entry in HNB-global list of HNB */ |
| 44 | struct llist_head list; |
Harald Welte | a2e6a7a | 2015-08-29 21:47:39 +0200 | [diff] [blame] | 45 | /*! HNB-GW we are part of */ |
| 46 | struct hnb_gw *gw; |
Harald Welte | 3f71256 | 2015-09-07 21:53:25 +0200 | [diff] [blame] | 47 | /*! SCTP socket + write queue for Iuh to this specific HNB */ |
| 48 | struct osmo_wqueue wqueue; |
Harald Welte | a2e6a7a | 2015-08-29 21:47:39 +0200 | [diff] [blame] | 49 | /*! copied from HNB-Identity-Info IE */ |
| 50 | char identity_info[256]; |
| 51 | /*! copied from Cell Identity IE */ |
| 52 | struct umts_cell_id id; |
Harald Welte | 3f71256 | 2015-09-07 21:53:25 +0200 | [diff] [blame] | 53 | |
| 54 | /*! SCTP stream ID for HNBAP */ |
| 55 | uint16_t hnbap_stream; |
| 56 | /*! SCTP stream ID for RUA */ |
| 57 | uint16_t rua_stream; |
Harald Welte | ba43de4 | 2015-08-29 20:33:16 +0200 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | struct ue_context { |
Harald Welte | a2e6a7a | 2015-08-29 21:47:39 +0200 | [diff] [blame] | 61 | /*! Entry in the HNB-global list of UE */ |
Harald Welte | ba43de4 | 2015-08-29 20:33:16 +0200 | [diff] [blame] | 62 | struct llist_head list; |
Harald Welte | a2e6a7a | 2015-08-29 21:47:39 +0200 | [diff] [blame] | 63 | /*! Unique Context ID for this UE */ |
Harald Welte | ba43de4 | 2015-08-29 20:33:16 +0200 | [diff] [blame] | 64 | uint32_t context_id; |
Harald Welte | b534e5c | 2015-09-11 00:15:16 +0200 | [diff] [blame] | 65 | char imsi[16+1]; |
Harald Welte | a2e6a7a | 2015-08-29 21:47:39 +0200 | [diff] [blame] | 66 | /*! UE is serviced via this HNB */ |
| 67 | struct hnb_context *hnb; |
Harald Welte | ba43de4 | 2015-08-29 20:33:16 +0200 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | struct hnb_gw { |
| 71 | struct { |
| 72 | /*! SCTP port for Iuh listening */ |
| 73 | uint16_t iuh_listen_port; |
Harald Welte | a2e6a7a | 2015-08-29 21:47:39 +0200 | [diff] [blame] | 74 | /*! The UDP port where we receive multiplexed CS user |
| 75 | * plane traffic from HNBs */ |
| 76 | uint16_t iuh_cs_mux_port; |
| 77 | uint16_t rnc_id; |
Harald Welte | ba43de4 | 2015-08-29 20:33:16 +0200 | [diff] [blame] | 78 | } config; |
| 79 | /*! SCTP listen socket for incoming connections */ |
| 80 | struct osmo_fd listen_fd; |
| 81 | struct llist_head hnb_list; |
Harald Welte | b534e5c | 2015-09-11 00:15:16 +0200 | [diff] [blame] | 82 | struct llist_head ue_list; |
| 83 | uint32_t next_ue_ctx_id; |
Harald Welte | ba43de4 | 2015-08-29 20:33:16 +0200 | [diff] [blame] | 84 | }; |
Harald Welte | a2e6a7a | 2015-08-29 21:47:39 +0200 | [diff] [blame] | 85 | |
| 86 | extern struct hnb_gw g_hnb_gw; |
Harald Welte | b534e5c | 2015-09-11 00:15:16 +0200 | [diff] [blame] | 87 | |
| 88 | struct ue_context *ue_context_by_id(uint32_t id); |
| 89 | struct ue_context *ue_context_by_imsi(const char *imsi); |
| 90 | struct ue_context *ue_context_alloc(struct hnb_context *hnb, const char *imsi); |
| 91 | void ue_context_free(struct ue_context *ue); |