2017-04-06 11:10:00 +00:00
|
|
|
#ifndef __MME_CONTEXT__
|
|
|
|
#define __MME_CONTEXT__
|
2017-02-06 06:30:12 +00:00
|
|
|
|
|
|
|
#include "core_list.h"
|
2017-04-10 14:59:59 +00:00
|
|
|
#include "core_index.h"
|
2017-02-06 10:12:10 +00:00
|
|
|
#include "core_errno.h"
|
2017-03-06 12:45:41 +00:00
|
|
|
#include "core_sha2.h"
|
2017-04-06 12:44:30 +00:00
|
|
|
#include "core_hash.h"
|
2017-11-30 11:13:15 +00:00
|
|
|
#include "core_network.h"
|
|
|
|
#include "core_tlv_msg.h"
|
|
|
|
#include "core_fsm.h"
|
|
|
|
#include "core_msgq.h"
|
|
|
|
#include "core_timer.h"
|
2017-02-13 04:19:53 +00:00
|
|
|
|
2017-07-13 01:31:07 +00:00
|
|
|
#include "types.h"
|
2017-09-13 02:57:17 +00:00
|
|
|
#include "s1ap_message.h"
|
2017-07-26 10:40:52 +00:00
|
|
|
#include "nas_message.h"
|
2017-08-25 15:11:46 +00:00
|
|
|
#include "s6a_message.h"
|
2017-03-26 15:48:33 +00:00
|
|
|
|
2017-04-28 04:46:16 +00:00
|
|
|
/* S1AP */
|
|
|
|
#include "S1ap-Cause.h"
|
|
|
|
|
2017-02-06 06:30:12 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
|
|
#define MAX_PLMN_ID 6
|
|
|
|
#define GRP_PER_MME 256 /* According to spec it is 65535 */
|
2017-03-05 04:03:11 +00:00
|
|
|
#define CODE_PER_MME 256 /* According to spec it is 256 */
|
2017-02-13 04:19:53 +00:00
|
|
|
|
2017-07-14 15:27:22 +00:00
|
|
|
#define MAX_NUM_OF_SERVED_TAI 16
|
|
|
|
#define MAX_NUM_OF_SERVED_GUMMEI 8
|
2017-07-14 11:46:15 +00:00
|
|
|
#define MAX_NUM_OF_ALGORITHM 8
|
|
|
|
|
2017-08-04 21:34:52 +00:00
|
|
|
#define MAX_NUM_OF_TAC 256
|
|
|
|
#define MAX_NUM_OF_BPLMN 6
|
|
|
|
|
2017-09-01 15:11:49 +00:00
|
|
|
typedef struct _enb_ue_t enb_ue_t;
|
|
|
|
typedef struct _mme_ue_t mme_ue_t;
|
2017-11-24 15:52:07 +00:00
|
|
|
|
2017-11-30 11:13:15 +00:00
|
|
|
typedef struct _gtp_node_t gtp_node_t;
|
|
|
|
typedef struct _gtp_xact_t gtp_xact_t;
|
|
|
|
|
2017-02-06 06:30:12 +00:00
|
|
|
typedef struct _served_gummei {
|
2017-02-06 10:12:10 +00:00
|
|
|
c_uint32_t num_of_plmn_id;
|
2017-03-24 14:01:44 +00:00
|
|
|
plmn_id_t plmn_id[MAX_PLMN_ID];
|
2017-02-06 06:30:12 +00:00
|
|
|
|
2017-02-13 05:41:20 +00:00
|
|
|
c_uint32_t num_of_mme_gid;
|
|
|
|
c_uint16_t mme_gid[GRP_PER_MME];
|
|
|
|
c_uint32_t num_of_mme_code;
|
|
|
|
c_uint8_t mme_code[CODE_PER_MME];
|
2017-07-14 13:03:10 +00:00
|
|
|
} served_gummei_t;
|
2017-02-06 06:30:12 +00:00
|
|
|
|
2017-04-06 11:10:00 +00:00
|
|
|
typedef struct _mme_context_t {
|
2017-11-08 15:05:18 +00:00
|
|
|
const char *fd_conf_path; /* MME freeDiameter conf path */
|
2017-08-17 05:15:08 +00:00
|
|
|
|
2017-11-30 11:13:15 +00:00
|
|
|
list_t s1ap_list; /* MME S1AP Server List */
|
2017-08-17 05:15:08 +00:00
|
|
|
|
2017-12-01 15:44:07 +00:00
|
|
|
c_uint16_t gtpc_port; /* Default GTPC Port */
|
|
|
|
|
2017-12-03 12:34:39 +00:00
|
|
|
list_t gtpc_list; /* MME GTPC IPv4 Server List */
|
|
|
|
c_sockaddr_t *gtpc_addr; /* MME GTPC IPv4 Address */
|
|
|
|
list_t gtpc_list6; /* MME GTPC IPv6 Server List */
|
|
|
|
c_sockaddr_t *gtpc_addr6; /* MME GTPC IPv6 Address */
|
2017-02-13 04:19:53 +00:00
|
|
|
|
2017-12-02 05:17:32 +00:00
|
|
|
list_t sgw_list; /* SGW GTPC Client List */
|
2017-12-02 06:49:03 +00:00
|
|
|
gtp_node_t *sgw; /* Iterator for SGW round-robin */
|
2017-12-02 05:17:32 +00:00
|
|
|
|
2017-12-03 08:00:11 +00:00
|
|
|
list_t pgw_list; /* PGW GTPC Client List */
|
2017-12-03 12:34:39 +00:00
|
|
|
c_sockaddr_t *pgw_addr; /* First IPv4 Address Selected */
|
|
|
|
c_sockaddr_t *pgw_addr6; /* First IPv6 Address Selected */
|
2017-08-28 12:47:32 +00:00
|
|
|
|
2017-03-28 07:35:57 +00:00
|
|
|
msgq_id queue_id; /* Queue for processing MME control plane */
|
|
|
|
tm_service_t tm_service; /* Timer Service */
|
2017-03-06 08:55:50 +00:00
|
|
|
|
2017-07-23 03:25:01 +00:00
|
|
|
/* Generator for unique identification */
|
2017-08-17 05:15:08 +00:00
|
|
|
c_uint32_t mme_ue_s1ap_id; /* mme_ue_s1ap_id generator */
|
|
|
|
c_uint32_t m_tmsi; /* m_tmsi generator */
|
2017-02-13 04:19:53 +00:00
|
|
|
|
2017-03-07 00:30:12 +00:00
|
|
|
/* defined in 'nas_ies.h'
|
|
|
|
* #define NAS_SECURITY_ALGORITHMS_EIA0 0
|
|
|
|
* #define NAS_SECURITY_ALGORITHMS_128_EEA1 1
|
|
|
|
* #define NAS_SECURITY_ALGORITHMS_128_EEA2 2
|
|
|
|
* #define NAS_SECURITY_ALGORITHMS_128_EEA3 3 */
|
2017-07-14 11:46:15 +00:00
|
|
|
c_uint8_t num_of_ciphering_order;
|
|
|
|
c_uint8_t ciphering_order[MAX_NUM_OF_ALGORITHM];
|
2017-03-07 05:47:17 +00:00
|
|
|
/* defined in 'nas_ies.h'
|
|
|
|
* #define NAS_SECURITY_ALGORITHMS_EIA0 0
|
|
|
|
* #define NAS_SECURITY_ALGORITHMS_128_EIA1 1
|
|
|
|
* #define NAS_SECURITY_ALGORITHMS_128_EIA1 2
|
|
|
|
* #define NAS_SECURITY_ALGORITHMS_128_EIA3 3 */
|
2017-07-14 11:46:15 +00:00
|
|
|
c_uint8_t num_of_integrity_order;
|
|
|
|
c_uint8_t integrity_order[MAX_NUM_OF_ALGORITHM];
|
2017-03-07 00:30:12 +00:00
|
|
|
|
2017-02-14 00:09:01 +00:00
|
|
|
/* S1SetupRequest */
|
2017-07-14 15:27:22 +00:00
|
|
|
c_uint8_t max_num_of_served_tai;
|
|
|
|
tai_t served_tai[MAX_NUM_OF_SERVED_TAI];
|
2017-02-14 00:09:01 +00:00
|
|
|
|
|
|
|
/* S1SetupResponse */
|
2017-07-14 13:03:10 +00:00
|
|
|
c_uint8_t max_num_of_served_gummei;
|
|
|
|
served_gummei_t served_gummei[MAX_NUM_OF_SERVED_GUMMEI];
|
2017-02-13 04:19:53 +00:00
|
|
|
c_uint8_t relative_capacity;
|
2017-04-06 11:58:13 +00:00
|
|
|
|
2017-08-17 05:15:08 +00:00
|
|
|
/* Timer value */
|
2017-08-07 22:58:13 +00:00
|
|
|
c_uint32_t t3413_value; /* Paging retry timer */
|
|
|
|
|
2017-11-24 02:49:37 +00:00
|
|
|
hash_t *enb_sock_hash; /* hash table for ENB Socket */
|
|
|
|
hash_t *enb_addr_hash; /* hash table for ENB Address */
|
2017-10-18 05:05:22 +00:00
|
|
|
hash_t *enb_id_hash; /* hash table for ENB-ID */
|
2017-08-17 05:15:08 +00:00
|
|
|
hash_t *mme_ue_s1ap_id_hash; /* hash table for MME-UE-S1AP-ID */
|
|
|
|
hash_t *imsi_ue_hash; /* hash table (IMSI : MME_UE) */
|
|
|
|
hash_t *guti_ue_hash; /* hash table (GUTI : MME_UE) */
|
2017-04-06 11:10:00 +00:00
|
|
|
} mme_context_t;
|
2017-02-06 06:30:12 +00:00
|
|
|
|
2017-11-24 15:52:07 +00:00
|
|
|
typedef struct _mme_s1ap_t {
|
|
|
|
lnode_t node; /* A node of list_t */
|
|
|
|
|
2017-11-25 14:30:47 +00:00
|
|
|
int family;
|
2017-11-24 15:52:07 +00:00
|
|
|
const char *hostname;
|
|
|
|
c_uint16_t port;
|
|
|
|
|
|
|
|
sock_id sock; /* MME S1AP Socket */
|
|
|
|
} mme_s1ap_t;
|
|
|
|
|
2017-04-06 11:10:00 +00:00
|
|
|
typedef struct _mme_enb_t {
|
2017-08-17 05:15:08 +00:00
|
|
|
lnode_t node; /* A node of list_t */
|
|
|
|
index_t index; /* An index of this node */
|
|
|
|
fsm_t sm; /* A state machine */
|
2017-02-13 04:19:53 +00:00
|
|
|
|
2017-10-18 05:05:22 +00:00
|
|
|
c_uint32_t enb_id; /* eNB_ID received from eNB */
|
2017-11-24 10:03:48 +00:00
|
|
|
int sock_type; /* SOCK_STREAM or SOCK_SEQPACKET */
|
2017-11-23 10:44:49 +00:00
|
|
|
sock_id sock; /* eNB S1AP Socket */
|
2017-11-23 12:05:55 +00:00
|
|
|
c_sockaddr_t *addr; /* eNB S1AP Address */
|
2017-03-05 04:03:11 +00:00
|
|
|
|
2017-08-04 21:34:52 +00:00
|
|
|
c_uint8_t num_of_tai;
|
|
|
|
tai_t tai[MAX_NUM_OF_TAC * MAX_NUM_OF_BPLMN];
|
|
|
|
|
2017-04-28 07:11:45 +00:00
|
|
|
list_t enb_ue_list;
|
2017-02-13 04:19:53 +00:00
|
|
|
|
2017-04-06 11:10:00 +00:00
|
|
|
} mme_enb_t;
|
2017-02-13 04:19:53 +00:00
|
|
|
|
2017-04-28 04:43:42 +00:00
|
|
|
struct _enb_ue_t {
|
2017-08-17 05:15:08 +00:00
|
|
|
lnode_t node; /* A node of list_t */
|
|
|
|
index_t index; /* An index of this node */
|
2017-04-28 04:43:42 +00:00
|
|
|
|
|
|
|
/* UE identity */
|
2017-08-17 05:15:08 +00:00
|
|
|
c_uint32_t enb_ue_s1ap_id; /* eNB-UE-S1AP-ID received from eNB */
|
|
|
|
c_uint32_t mme_ue_s1ap_id; /* MME-UE-S1AP-ID received from MME */
|
2017-04-28 04:43:42 +00:00
|
|
|
|
2017-09-13 12:51:02 +00:00
|
|
|
/* Handover Info */
|
|
|
|
S1ap_HandoverType_t handover_type;
|
2017-09-14 09:01:26 +00:00
|
|
|
enb_ue_t *source_ue;
|
|
|
|
enb_ue_t *target_ue;
|
2017-09-13 12:51:02 +00:00
|
|
|
|
2017-09-14 08:40:01 +00:00
|
|
|
/* Use mme_ue->tai, mme_ue->e_cgi.
|
|
|
|
* Do not access enb_ue->nas.tai enb_ue->nas.e_cgi.
|
|
|
|
*
|
|
|
|
* Save TAI and ECGI. And then, this will copy 'mme_ue_t' context later */
|
|
|
|
struct {
|
|
|
|
tai_t tai;
|
|
|
|
e_cgi_t e_cgi;
|
|
|
|
} nas;
|
2017-04-28 04:43:42 +00:00
|
|
|
|
2017-09-14 08:40:01 +00:00
|
|
|
/* Related Context */
|
2017-04-28 04:43:42 +00:00
|
|
|
mme_enb_t *enb;
|
2017-09-14 08:40:01 +00:00
|
|
|
mme_ue_t *mme_ue;
|
2017-04-28 04:43:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _mme_ue_t {
|
2017-08-17 05:15:08 +00:00
|
|
|
lnode_t node; /* A node of list_t */
|
|
|
|
index_t index; /* An index of this node */
|
|
|
|
fsm_t sm; /* A state machine */
|
2017-03-06 08:55:50 +00:00
|
|
|
|
2017-09-08 07:46:37 +00:00
|
|
|
struct {
|
2017-09-13 15:02:26 +00:00
|
|
|
#define MME_EPS_TYPE_ATTACH_REQUEST 1
|
|
|
|
#define MME_EPS_TYPE_TAU_REQUEST 2
|
|
|
|
#define MME_EPS_TYPE_SERVICE_REQUEST 3
|
2017-09-08 07:46:37 +00:00
|
|
|
c_uint8_t type;
|
|
|
|
union {
|
|
|
|
nas_eps_attach_type_t attach;
|
|
|
|
nas_eps_update_type_t update;
|
|
|
|
};
|
|
|
|
} nas_eps;
|
|
|
|
|
2017-03-07 00:30:12 +00:00
|
|
|
/* UE identity */
|
2017-09-03 15:06:39 +00:00
|
|
|
#define MME_UE_HAVE_IMSI(__mME) \
|
|
|
|
((__mME) && ((__mME)->imsi_len))
|
2017-04-09 15:27:19 +00:00
|
|
|
c_uint8_t imsi[MAX_IMSI_LEN];
|
2017-04-10 02:29:46 +00:00
|
|
|
int imsi_len;
|
|
|
|
c_int8_t imsi_bcd[MAX_IMSI_BCD_LEN+1];
|
2017-04-28 04:43:42 +00:00
|
|
|
guti_t guti;
|
2017-02-13 04:19:53 +00:00
|
|
|
|
2017-12-06 03:28:24 +00:00
|
|
|
c_uint32_t mme_s11_teid; /* MME-S11-TEID is derived from INDEX */
|
|
|
|
c_uint32_t sgw_s11_teid; /* SGW-S11-TEID is received from SGW */
|
2017-09-01 12:35:45 +00:00
|
|
|
|
2017-04-09 11:51:26 +00:00
|
|
|
/* UE Info */
|
2017-04-11 11:44:38 +00:00
|
|
|
tai_t tai;
|
|
|
|
e_cgi_t e_cgi;
|
2017-04-09 11:51:26 +00:00
|
|
|
plmn_id_t visited_plmn_id;
|
|
|
|
|
2017-09-03 15:06:39 +00:00
|
|
|
#define SECURITY_CONTEXT_IS_VALID(__mME) \
|
|
|
|
((__mME) && \
|
|
|
|
((__mME)->security_context_available == 1) && ((__mME)->mac_failed == 0))
|
|
|
|
#define CLEAR_SECURITY_CONTEXT(__mME) \
|
2017-07-30 09:38:37 +00:00
|
|
|
do { \
|
2017-09-03 15:06:39 +00:00
|
|
|
d_assert((__mME), break, "Null param"); \
|
|
|
|
(__mME)->security_context_available = 0; \
|
|
|
|
(__mME)->mac_failed = 0; \
|
2017-07-30 09:38:37 +00:00
|
|
|
} while(0)
|
2017-03-08 14:42:27 +00:00
|
|
|
int security_context_available;
|
2017-07-30 09:38:37 +00:00
|
|
|
int mac_failed;
|
2017-07-28 05:19:43 +00:00
|
|
|
|
2017-07-30 09:38:37 +00:00
|
|
|
/* Security Context */
|
2017-03-07 05:47:17 +00:00
|
|
|
nas_ue_network_capability_t ue_network_capability;
|
|
|
|
nas_ms_network_capability_t ms_network_capability;
|
2017-03-06 08:55:50 +00:00
|
|
|
c_uint8_t xres[MAX_RES_LEN];
|
|
|
|
c_uint8_t xres_len;
|
2017-03-06 12:45:41 +00:00
|
|
|
c_uint8_t kasme[SHA256_DIGEST_SIZE];
|
2017-03-07 00:30:12 +00:00
|
|
|
c_uint8_t knas_int[SHA256_DIGEST_SIZE/2];
|
|
|
|
c_uint8_t knas_enc[SHA256_DIGEST_SIZE/2];
|
2017-03-08 10:10:01 +00:00
|
|
|
c_uint32_t dl_count;
|
2017-03-08 15:09:30 +00:00
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
ED3(c_uint8_t spare;,
|
|
|
|
c_uint16_t overflow;,
|
|
|
|
c_uint8_t sqn;)
|
|
|
|
} __attribute__ ((packed));
|
|
|
|
c_uint32_t i32;
|
|
|
|
} ul_count;
|
2017-09-12 01:41:00 +00:00
|
|
|
c_uint8_t kenb[SHA256_DIGEST_SIZE];
|
|
|
|
|
|
|
|
struct {
|
|
|
|
ED2(c_uint8_t nhcc_spare:5;,
|
|
|
|
c_uint8_t nhcc:3;) /* Next Hop Channing Counter */
|
|
|
|
};
|
|
|
|
c_uint8_t nh[SHA256_DIGEST_SIZE]; /* NH Security Key */
|
2017-03-05 08:36:16 +00:00
|
|
|
|
2017-07-14 12:39:21 +00:00
|
|
|
/* defined in 'nas_ies.h'
|
|
|
|
* #define NAS_SECURITY_ALGORITHMS_EIA0 0
|
|
|
|
* #define NAS_SECURITY_ALGORITHMS_128_EEA1 1
|
|
|
|
* #define NAS_SECURITY_ALGORITHMS_128_EEA2 2
|
|
|
|
* #define NAS_SECURITY_ALGORITHMS_128_EEA3 3 */
|
|
|
|
c_uint8_t selected_enc_algorithm;
|
|
|
|
/* defined in 'nas_ies.h'
|
|
|
|
* #define NAS_SECURITY_ALGORITHMS_EIA0 0
|
|
|
|
* #define NAS_SECURITY_ALGORITHMS_128_EIA1 1
|
|
|
|
* #define NAS_SECURITY_ALGORITHMS_128_EIA1 2
|
|
|
|
* #define NAS_SECURITY_ALGORITHMS_128_EIA3 3 */
|
|
|
|
c_uint8_t selected_int_algorithm;
|
|
|
|
|
2017-04-10 12:05:28 +00:00
|
|
|
/* HSS Info */
|
2017-08-25 15:11:46 +00:00
|
|
|
s6a_subscription_data_t subscription_data;
|
2017-04-10 12:05:28 +00:00
|
|
|
|
2017-04-27 14:06:10 +00:00
|
|
|
/* ESM Info */
|
2017-08-27 07:30:10 +00:00
|
|
|
#define MIN_EPS_BEARER_ID 5
|
|
|
|
#define MAX_EPS_BEARER_ID 15
|
|
|
|
|
2017-09-03 15:06:39 +00:00
|
|
|
#define CLEAR_EPS_BEARER_ID(__mME) \
|
2017-08-27 07:30:10 +00:00
|
|
|
do { \
|
2017-09-03 15:06:39 +00:00
|
|
|
d_assert((__mME), break, "Null param"); \
|
|
|
|
(__mME)->ebi = MIN_EPS_BEARER_ID - 1; \
|
2017-08-27 07:30:10 +00:00
|
|
|
} while(0)
|
2017-08-23 05:25:43 +00:00
|
|
|
c_uint8_t ebi; /* EPS Bearer ID generator */
|
2017-04-27 14:06:10 +00:00
|
|
|
list_t sess_list;
|
|
|
|
|
2017-07-26 08:55:53 +00:00
|
|
|
/* eNB UE context */
|
2017-04-28 05:43:04 +00:00
|
|
|
enb_ue_t *enb_ue;
|
2017-07-26 08:55:53 +00:00
|
|
|
|
2017-09-06 11:29:55 +00:00
|
|
|
/* Save PDN Connectivity Request */
|
|
|
|
nas_esm_message_container_t pdn_connectivity_request;
|
2017-09-03 02:48:41 +00:00
|
|
|
|
2017-08-07 22:58:13 +00:00
|
|
|
/* Paging */
|
2017-09-08 07:46:37 +00:00
|
|
|
#define CLEAR_PAGING_INFO(__mME) \
|
|
|
|
do { \
|
|
|
|
d_assert((__mME), break, "Null param"); \
|
|
|
|
\
|
|
|
|
tm_stop((__mME)->t3413); \
|
|
|
|
if ((__mME)->last_paging_msg) \
|
|
|
|
{ \
|
|
|
|
pkbuf_free((__mME)->last_paging_msg); \
|
|
|
|
(__mME)->last_paging_msg = NULL; \
|
|
|
|
} \
|
|
|
|
(__mME)->max_paging_retry = 0; \
|
|
|
|
} while(0);
|
2017-08-07 22:58:13 +00:00
|
|
|
pkbuf_t *last_paging_msg;
|
|
|
|
tm_block_id t3413;
|
|
|
|
#define MAX_NUM_OF_PAGING 2
|
|
|
|
c_uint32_t max_paging_retry;
|
2017-08-08 19:01:08 +00:00
|
|
|
|
|
|
|
/* UE Radio Capability */
|
|
|
|
void *radio_capa;
|
2017-08-27 07:30:10 +00:00
|
|
|
|
2017-09-03 15:06:39 +00:00
|
|
|
/* Detach Request */
|
2017-08-27 07:30:10 +00:00
|
|
|
nas_detach_type_t detach_type;
|
2017-09-11 15:49:15 +00:00
|
|
|
|
2017-09-13 02:57:17 +00:00
|
|
|
/* S1AP Transparent Container */
|
|
|
|
OCTET_STRING_t container;
|
|
|
|
|
2017-09-13 02:18:17 +00:00
|
|
|
/* GTP Request/Response Counter */
|
|
|
|
#define GTP_COUNTER_INCREMENT(__mME, __tYPE) \
|
|
|
|
do { \
|
|
|
|
d_assert((__mME), break,); \
|
|
|
|
((__mME)->gtp_counter[__tYPE].request)++; \
|
|
|
|
} while(0);
|
2017-09-11 15:49:15 +00:00
|
|
|
|
2017-09-13 02:18:17 +00:00
|
|
|
#define GTP_COUNTER_CHECK(__mME, __tYPE, __eXPR) \
|
2017-09-11 15:49:15 +00:00
|
|
|
do { \
|
|
|
|
d_assert((__mME), break,); \
|
2017-09-13 14:49:31 +00:00
|
|
|
if ((__mME)->gtp_counter[__tYPE].request == 0) break; \
|
2017-09-13 02:18:17 +00:00
|
|
|
((__mME)->gtp_counter[__tYPE].response)++; \
|
|
|
|
if (((__mME)->gtp_counter[__tYPE].request) == \
|
|
|
|
((__mME)->gtp_counter[__tYPE].response)) \
|
|
|
|
{ \
|
|
|
|
((__mME)->gtp_counter[__tYPE].request) = 0; \
|
|
|
|
((__mME)->gtp_counter[__tYPE].response) = 0; \
|
|
|
|
__eXPR \
|
|
|
|
} \
|
2017-09-11 15:49:15 +00:00
|
|
|
} while(0);
|
|
|
|
|
2017-09-15 03:06:26 +00:00
|
|
|
#define MAX_NUM_OF_GTP_COUNTER 16
|
2017-09-13 02:18:17 +00:00
|
|
|
|
2017-09-15 03:06:26 +00:00
|
|
|
#define GTP_COUNTER_DELETE_SESSION 0
|
|
|
|
#define GTP_COUNTER_MODIFY_BEARER_BY_PATH_SWITCH 1
|
|
|
|
#define GTP_COUNTER_MODIFY_BEARER_BY_HANDOVER_NOTIFY 2
|
2017-09-13 02:18:17 +00:00
|
|
|
struct {
|
|
|
|
c_uint8_t request;
|
|
|
|
c_uint8_t response;
|
|
|
|
} gtp_counter[MAX_NUM_OF_GTP_COUNTER];
|
2017-09-14 10:55:21 +00:00
|
|
|
|
|
|
|
#define CONNECT_SGW_GTP_NODE(__mME) \
|
|
|
|
do { \
|
|
|
|
d_assert((__mME), break, "Null param"); \
|
2017-09-14 12:46:56 +00:00
|
|
|
(__mME)->sgw = self.sgw; \
|
|
|
|
d_assert(((__mME)->sgw), break, "Null param"); \
|
2017-12-02 06:49:03 +00:00
|
|
|
self.sgw = list_next((__mME)->sgw); \
|
|
|
|
if (!self.sgw) self.sgw = list_first(&mme_self()->sgw_list); \
|
2017-09-14 12:46:56 +00:00
|
|
|
d_assert(self.sgw, break, "Null param"); \
|
2017-09-14 10:55:21 +00:00
|
|
|
} while(0)
|
2017-12-02 06:49:03 +00:00
|
|
|
gtp_node_t *sgw;
|
2017-04-28 05:43:04 +00:00
|
|
|
};
|
2017-04-27 14:06:10 +00:00
|
|
|
|
2017-09-05 03:37:27 +00:00
|
|
|
#define MME_HAVE_SGW_S1U_PATH(__sESS) \
|
2017-09-04 13:00:51 +00:00
|
|
|
((__sESS) && (mme_bearer_first(__sESS)) && \
|
|
|
|
((mme_default_bearer_in_sess(__sESS)->sgw_s1u_teid) && \
|
|
|
|
(mme_default_bearer_in_sess(__sESS)->sgw_s1u_addr)))
|
|
|
|
|
2017-09-05 03:37:27 +00:00
|
|
|
#define MME_HAVE_SGW_S11_PATH(__mME) \
|
2017-12-06 03:28:24 +00:00
|
|
|
((__mME) && ((__mME)->sgw_s11_teid))
|
2017-09-05 03:37:27 +00:00
|
|
|
|
|
|
|
#define CLEAR_SGW_S11_PATH(__mME) \
|
|
|
|
do { \
|
|
|
|
d_assert((__mME), break, "Null param"); \
|
|
|
|
(__mME)->sgw_s11_teid = 0; \
|
|
|
|
} while(0)
|
2017-04-27 14:06:10 +00:00
|
|
|
typedef struct _mme_sess_t {
|
2017-08-17 05:15:08 +00:00
|
|
|
lnode_t node; /* A node of list_t */
|
|
|
|
index_t index; /* An index of this node */
|
2017-04-27 14:06:10 +00:00
|
|
|
|
2017-09-07 12:28:12 +00:00
|
|
|
c_uint8_t pti; /* Procedure Trasaction Identity */
|
|
|
|
|
2017-04-27 14:06:10 +00:00
|
|
|
/* mme_bearer_first(sess) : Default Bearer Context */
|
2017-04-13 10:15:53 +00:00
|
|
|
list_t bearer_list;
|
2017-04-10 12:05:28 +00:00
|
|
|
|
2017-04-28 03:39:14 +00:00
|
|
|
/* Related Context */
|
2017-04-28 07:11:45 +00:00
|
|
|
mme_ue_t *mme_ue;
|
2017-08-11 11:25:52 +00:00
|
|
|
|
2017-09-03 15:06:39 +00:00
|
|
|
#define MME_UE_HAVE_APN(__mME) \
|
|
|
|
((__mME) && (mme_sess_first(__mME)) && \
|
|
|
|
((mme_sess_first(__mME))->pdn))
|
2017-08-11 11:25:52 +00:00
|
|
|
pdn_t *pdn;
|
2017-08-27 07:30:10 +00:00
|
|
|
|
2017-09-06 11:29:55 +00:00
|
|
|
/* Save Protocol Configuration Options from UE */
|
|
|
|
struct {
|
|
|
|
c_uint8_t length;
|
|
|
|
c_uint8_t *buffer;
|
|
|
|
} ue_pco;
|
|
|
|
|
|
|
|
/* Save Protocol Configuration Options from PGW */
|
|
|
|
tlv_octet_t pgw_pco;
|
2017-04-27 14:06:10 +00:00
|
|
|
} mme_sess_t;
|
2017-04-06 11:10:00 +00:00
|
|
|
|
2017-09-05 03:37:27 +00:00
|
|
|
#define MME_HAVE_ENB_S1U_PATH(__bEARER) \
|
2017-09-04 13:00:51 +00:00
|
|
|
((__bEARER) && ((__bEARER)->enb_s1u_teid) && ((__bEARER)->enb_s1u_addr))
|
2017-09-13 07:22:39 +00:00
|
|
|
|
2017-09-13 14:27:02 +00:00
|
|
|
#define MME_HAVE_ENB_DL_INDIRECT_TUNNEL(__bEARER) \
|
2017-09-13 07:22:39 +00:00
|
|
|
((__bEARER) && ((__bEARER)->enb_dl_teid) && ((__bEARER)->enb_dl_addr))
|
2017-09-13 14:27:02 +00:00
|
|
|
#define MME_HAVE_ENB_UL_INDIRECT_TUNNEL(__bEARER) \
|
2017-09-13 07:22:39 +00:00
|
|
|
((__bEARER) && ((__bEARER)->enb_ul_teid) && ((__bEARER)->enb_ul_addr))
|
2017-09-13 14:27:02 +00:00
|
|
|
#define MME_HAVE_SGW_DL_INDIRECT_TUNNEL(__bEARER) \
|
|
|
|
((__bEARER) && ((__bEARER)->sgw_dl_teid) && ((__bEARER)->sgw_dl_addr))
|
|
|
|
#define MME_HAVE_SGW_UL_INDIRECT_TUNNEL(__bEARER) \
|
|
|
|
((__bEARER) && ((__bEARER)->sgw_ul_teid) && ((__bEARER)->sgw_ul_addr))
|
2017-09-14 05:18:47 +00:00
|
|
|
#define CLEAR_INDIRECT_TUNNEL(__bEARER) \
|
2017-09-13 07:22:39 +00:00
|
|
|
do { \
|
2017-09-14 05:18:47 +00:00
|
|
|
d_assert((__bEARER), break, "Null param"); \
|
|
|
|
(__bEARER)->enb_dl_teid = 0; \
|
|
|
|
(__bEARER)->enb_dl_addr = 0; \
|
|
|
|
(__bEARER)->enb_ul_teid = 0; \
|
|
|
|
(__bEARER)->enb_ul_addr = 0; \
|
|
|
|
(__bEARER)->sgw_dl_teid = 0; \
|
|
|
|
(__bEARER)->sgw_dl_addr = 0; \
|
|
|
|
(__bEARER)->sgw_ul_teid = 0; \
|
|
|
|
(__bEARER)->sgw_ul_addr = 0; \
|
2017-09-13 07:22:39 +00:00
|
|
|
} while(0)
|
2017-04-13 10:15:53 +00:00
|
|
|
typedef struct _mme_bearer_t {
|
2017-09-12 14:07:55 +00:00
|
|
|
lnode_t node; /* A node of list_t */
|
|
|
|
index_t index; /* An index of this node */
|
|
|
|
fsm_t sm; /* State Machine */
|
2017-04-11 14:55:21 +00:00
|
|
|
|
2017-09-12 14:07:55 +00:00
|
|
|
c_uint8_t ebi; /* EPS Bearer ID */
|
2017-09-01 13:21:12 +00:00
|
|
|
|
2017-04-12 12:20:00 +00:00
|
|
|
c_uint32_t enb_s1u_teid;
|
|
|
|
c_uint32_t enb_s1u_addr;
|
|
|
|
c_uint32_t sgw_s1u_teid;
|
|
|
|
c_uint32_t sgw_s1u_addr;
|
2017-04-11 10:14:18 +00:00
|
|
|
|
2017-09-14 02:12:02 +00:00
|
|
|
c_uint32_t target_s1u_teid; /* Target S1U TEID from HO-Req-Ack */
|
|
|
|
c_uint32_t target_s1u_addr; /* Target S1U ADDR from HO-Req-Ack */
|
|
|
|
|
2017-09-12 14:07:55 +00:00
|
|
|
c_uint32_t enb_dl_teid;
|
|
|
|
c_uint32_t enb_dl_addr;
|
|
|
|
c_uint32_t enb_ul_teid;
|
|
|
|
c_uint32_t enb_ul_addr;
|
|
|
|
|
2017-09-13 12:51:02 +00:00
|
|
|
c_uint32_t sgw_dl_teid;
|
|
|
|
c_uint32_t sgw_dl_addr;
|
|
|
|
c_uint32_t sgw_ul_teid;
|
|
|
|
c_uint32_t sgw_ul_addr;
|
|
|
|
|
2017-09-04 13:00:51 +00:00
|
|
|
qos_t qos;
|
2017-09-06 11:29:55 +00:00
|
|
|
tlv_octet_t tft; /* Saved TFT */
|
2017-09-04 13:00:51 +00:00
|
|
|
|
2017-04-28 03:39:14 +00:00
|
|
|
/* Related Context */
|
2017-04-28 07:11:45 +00:00
|
|
|
mme_ue_t *mme_ue;
|
2017-04-27 14:06:10 +00:00
|
|
|
mme_sess_t *sess;
|
2017-09-04 13:00:51 +00:00
|
|
|
gtp_xact_t *xact;
|
2017-04-13 10:15:53 +00:00
|
|
|
} mme_bearer_t;
|
2017-04-08 01:18:48 +00:00
|
|
|
|
2017-04-06 11:10:00 +00:00
|
|
|
CORE_DECLARE(status_t) mme_context_init(void);
|
|
|
|
CORE_DECLARE(status_t) mme_context_final(void);
|
|
|
|
CORE_DECLARE(mme_context_t*) mme_self(void);
|
|
|
|
|
2017-07-30 13:29:27 +00:00
|
|
|
CORE_DECLARE(status_t) mme_context_parse_config(void);
|
2017-07-31 13:35:25 +00:00
|
|
|
CORE_DECLARE(status_t) mme_context_setup_trace_module(void);
|
2017-07-30 13:29:27 +00:00
|
|
|
|
2017-11-24 15:52:07 +00:00
|
|
|
CORE_DECLARE(mme_s1ap_t*) mme_s1ap_add(
|
2017-11-25 14:30:47 +00:00
|
|
|
int family, const char *hostname, c_uint16_t port);
|
2017-11-24 15:52:07 +00:00
|
|
|
CORE_DECLARE(status_t) mme_s1ap_remove(mme_s1ap_t *s1ap);
|
|
|
|
CORE_DECLARE(status_t) mme_s1ap_remove_all(void);
|
|
|
|
CORE_DECLARE(mme_s1ap_t*) mme_s1ap_first(void);
|
|
|
|
CORE_DECLARE(mme_s1ap_t*) mme_s1ap_next(mme_s1ap_t *s1ap);
|
|
|
|
|
2017-11-24 02:49:37 +00:00
|
|
|
CORE_DECLARE(mme_enb_t*) mme_enb_add(sock_id sock, c_sockaddr_t *addr);
|
2017-04-06 11:10:00 +00:00
|
|
|
CORE_DECLARE(status_t) mme_enb_remove(mme_enb_t *enb);
|
|
|
|
CORE_DECLARE(status_t) mme_enb_remove_all(void);
|
2017-04-11 00:19:33 +00:00
|
|
|
CORE_DECLARE(mme_enb_t*) mme_enb_find(index_t index);
|
2017-11-22 12:50:08 +00:00
|
|
|
CORE_DECLARE(mme_enb_t*) mme_enb_find_by_sock(sock_id sock);
|
2017-11-24 02:49:37 +00:00
|
|
|
CORE_DECLARE(mme_enb_t*) mme_enb_find_by_addr(c_sockaddr_t *addr);
|
2017-04-06 11:10:00 +00:00
|
|
|
CORE_DECLARE(mme_enb_t*) mme_enb_find_by_enb_id(c_uint32_t enb_id);
|
2017-10-18 05:05:22 +00:00
|
|
|
CORE_DECLARE(status_t) mme_enb_set_enb_id(
|
|
|
|
mme_enb_t *enb, c_uint32_t enb_id);
|
|
|
|
CORE_DECLARE(hash_index_t *) mme_enb_first();
|
|
|
|
CORE_DECLARE(hash_index_t *) mme_enb_next(hash_index_t *hi);
|
|
|
|
CORE_DECLARE(mme_enb_t *) mme_enb_this(hash_index_t *hi);
|
2017-11-24 10:03:48 +00:00
|
|
|
CORE_DECLARE(int) mme_enb_sock_type(sock_id sock);
|
2017-04-06 11:10:00 +00:00
|
|
|
|
2017-04-28 04:43:42 +00:00
|
|
|
CORE_DECLARE(mme_ue_t*) mme_ue_add(enb_ue_t *enb_ue);
|
2017-04-28 07:11:45 +00:00
|
|
|
CORE_DECLARE(status_t) mme_ue_remove(mme_ue_t *mme_ue);
|
2017-04-06 12:44:30 +00:00
|
|
|
CORE_DECLARE(status_t) mme_ue_remove_all();
|
2017-07-23 03:25:01 +00:00
|
|
|
|
2017-04-10 14:59:59 +00:00
|
|
|
CORE_DECLARE(mme_ue_t*) mme_ue_find(index_t index);
|
2017-07-23 03:25:01 +00:00
|
|
|
CORE_DECLARE(mme_ue_t*) mme_ue_find_by_imsi(c_uint8_t *imsi, int imsi_len);
|
2017-07-23 07:26:40 +00:00
|
|
|
CORE_DECLARE(mme_ue_t*) mme_ue_find_by_imsi_bcd(c_int8_t *imsi_bcd);
|
2017-07-23 03:25:01 +00:00
|
|
|
CORE_DECLARE(mme_ue_t*) mme_ue_find_by_guti(guti_t *guti);
|
2017-09-01 12:35:45 +00:00
|
|
|
CORE_DECLARE(mme_ue_t*) mme_ue_find_by_teid(c_uint32_t teid);
|
2017-07-23 03:25:01 +00:00
|
|
|
|
2017-07-28 05:06:40 +00:00
|
|
|
CORE_DECLARE(mme_ue_t*) mme_ue_find_by_message(nas_message_t *message);
|
2017-07-27 12:50:55 +00:00
|
|
|
CORE_DECLARE(status_t) mme_ue_set_imsi(
|
|
|
|
mme_ue_t *mme_ue, c_int8_t *imsi_bcd);
|
2017-09-14 09:01:26 +00:00
|
|
|
CORE_DECLARE(status_t) mme_ue_associate_enb_ue(
|
2017-07-27 12:50:55 +00:00
|
|
|
mme_ue_t *mme_ue, enb_ue_t *enb_ue);
|
2017-09-18 12:58:33 +00:00
|
|
|
CORE_DECLARE(status_t) mme_ue_deassociate_enb_ue(enb_ue_t *enb_ue);
|
2017-09-18 12:30:04 +00:00
|
|
|
CORE_DECLARE(status_t) source_ue_associate_target_ue(
|
|
|
|
enb_ue_t *source_ue, enb_ue_t *target_ue);
|
|
|
|
CORE_DECLARE(status_t) source_ue_deassociate_target_ue(enb_ue_t *enb_ue);
|
2017-07-27 12:50:55 +00:00
|
|
|
|
2017-04-06 12:44:30 +00:00
|
|
|
CORE_DECLARE(hash_index_t *) mme_ue_first();
|
|
|
|
CORE_DECLARE(hash_index_t *) mme_ue_next(hash_index_t *hi);
|
|
|
|
CORE_DECLARE(mme_ue_t *) mme_ue_this(hash_index_t *hi);
|
2017-07-23 03:25:01 +00:00
|
|
|
|
2017-08-26 09:52:06 +00:00
|
|
|
CORE_DECLARE(mme_sess_t*) mme_sess_add(mme_ue_t *mme_ue, c_uint8_t pti);
|
2017-04-27 14:06:10 +00:00
|
|
|
CORE_DECLARE(status_t ) mme_sess_remove(mme_sess_t *sess);
|
2017-04-28 07:11:45 +00:00
|
|
|
CORE_DECLARE(status_t ) mme_sess_remove_all(mme_ue_t *mme_ue);
|
2017-04-27 14:06:10 +00:00
|
|
|
CORE_DECLARE(mme_sess_t*) mme_sess_find(index_t index);
|
2017-08-26 09:52:06 +00:00
|
|
|
CORE_DECLARE(mme_sess_t*) mme_sess_find_by_pti(
|
|
|
|
mme_ue_t *mme_ue, c_uint8_t pti);
|
2017-04-28 07:11:45 +00:00
|
|
|
CORE_DECLARE(mme_sess_t*) mme_sess_find_by_ebi(
|
|
|
|
mme_ue_t *mme_ue, c_uint8_t ebi);
|
2017-09-21 07:03:42 +00:00
|
|
|
CORE_DECLARE(mme_sess_t*) mme_sess_find_by_apn(
|
|
|
|
mme_ue_t *mme_ue, c_int8_t *apn);
|
2017-04-28 07:11:45 +00:00
|
|
|
CORE_DECLARE(mme_sess_t*) mme_sess_first(mme_ue_t *mme_ue);
|
2017-04-27 14:06:10 +00:00
|
|
|
CORE_DECLARE(mme_sess_t*) mme_sess_next(mme_sess_t *sess);
|
|
|
|
|
2017-09-04 13:00:51 +00:00
|
|
|
CORE_DECLARE(mme_bearer_t*) mme_bearer_add(mme_sess_t *sess);
|
2017-04-13 10:15:53 +00:00
|
|
|
CORE_DECLARE(status_t) mme_bearer_remove(mme_bearer_t *bearer);
|
2017-04-27 14:06:10 +00:00
|
|
|
CORE_DECLARE(status_t) mme_bearer_remove_all(mme_sess_t *sess);
|
2017-04-13 10:15:53 +00:00
|
|
|
CORE_DECLARE(mme_bearer_t*) mme_bearer_find(index_t index);
|
2017-09-01 13:21:12 +00:00
|
|
|
CORE_DECLARE(mme_bearer_t*) mme_bearer_find_by_sess_ebi(
|
|
|
|
mme_sess_t *sess, c_uint8_t ebi);
|
|
|
|
CORE_DECLARE(mme_bearer_t*) mme_bearer_find_by_ue_ebi(
|
|
|
|
mme_ue_t *mme_ue, c_uint8_t ebi);
|
2017-09-21 07:03:42 +00:00
|
|
|
CORE_DECLARE(mme_bearer_t*) mme_bearer_find_or_add_by_message(
|
|
|
|
mme_ue_t *mme_ue, nas_message_t *message);
|
2017-04-27 23:28:04 +00:00
|
|
|
CORE_DECLARE(mme_bearer_t*) mme_default_bearer_in_sess(mme_sess_t *sess);
|
2017-09-04 15:04:05 +00:00
|
|
|
CORE_DECLARE(mme_bearer_t*) mme_linked_bearer(mme_bearer_t *bearer);
|
2017-04-27 14:06:10 +00:00
|
|
|
CORE_DECLARE(mme_bearer_t*) mme_bearer_first(mme_sess_t *sess);
|
2017-04-13 10:15:53 +00:00
|
|
|
CORE_DECLARE(mme_bearer_t*) mme_bearer_next(mme_bearer_t *bearer);
|
2017-04-08 01:18:48 +00:00
|
|
|
|
2017-04-28 07:11:45 +00:00
|
|
|
CORE_DECLARE(pdn_t*) mme_pdn_add(mme_ue_t *mme_ue, c_int8_t *apn);
|
|
|
|
CORE_DECLARE(status_t) mme_pdn_remove_all(mme_ue_t *mme_ue);
|
|
|
|
CORE_DECLARE(pdn_t*) mme_pdn_find_by_apn(
|
|
|
|
mme_ue_t *mme_ue, c_int8_t *apn);
|
2017-04-12 04:45:57 +00:00
|
|
|
|
2017-04-28 04:43:42 +00:00
|
|
|
CORE_DECLARE(enb_ue_t*) enb_ue_add(mme_enb_t *enb);
|
|
|
|
CORE_DECLARE(unsigned int) enb_ue_count();
|
2017-04-28 07:11:45 +00:00
|
|
|
CORE_DECLARE(status_t) enb_ue_remove(enb_ue_t *enb_ue);
|
2017-04-28 04:43:42 +00:00
|
|
|
CORE_DECLARE(status_t) enb_ue_remove_in_enb(mme_enb_t *enb);
|
2017-09-15 21:02:14 +00:00
|
|
|
CORE_DECLARE(status_t) enb_ue_switch_to_enb(enb_ue_t *enb_ue,
|
|
|
|
mme_enb_t *new_enb);
|
2017-04-28 04:43:42 +00:00
|
|
|
CORE_DECLARE(enb_ue_t*) enb_ue_find(index_t index);
|
|
|
|
CORE_DECLARE(enb_ue_t*) enb_ue_find_by_enb_ue_s1ap_id(mme_enb_t *enb,
|
|
|
|
c_uint32_t enb_ue_s1ap_id);
|
|
|
|
CORE_DECLARE(enb_ue_t*) enb_ue_find_by_mme_ue_s1ap_id(c_uint32_t mme_ue_s1ap_id);
|
|
|
|
CORE_DECLARE(enb_ue_t*) enb_ue_first_in_enb(mme_enb_t *enb);
|
2017-04-28 07:11:45 +00:00
|
|
|
CORE_DECLARE(enb_ue_t*) enb_ue_next_in_enb(enb_ue_t *enb_ue);
|
2017-04-28 04:43:42 +00:00
|
|
|
|
2017-02-06 06:30:12 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
2017-04-06 11:10:00 +00:00
|
|
|
#endif /* __MME_CONTEXT__ */
|