open5gs/src/mme/mme_context.h

346 lines
12 KiB
C
Raw Normal View History

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-02-13 04:19:53 +00:00
#include "core_net.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-02-13 04:19:53 +00:00
2017-07-13 01:31:07 +00:00
#include "types.h"
2017-03-26 06:57:46 +00:00
#include "nas_types.h"
2017-03-28 07:35:57 +00:00
#include "gtp_xact.h"
2017-03-26 15:48:33 +00:00
2017-04-04 01:49:19 +00:00
#include "mme_sm.h"
2017-02-06 06:30:12 +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-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-03-27 04:22:42 +00:00
c_uint32_t s1ap_addr; /* MME S1AP local address */
c_uint16_t s1ap_port; /* MME S1AP local port */
net_sock_t *s1ap_sock; /* MME S1AP local listen socket */
c_uint32_t s11_addr; /* MME S11 local address */
c_uint16_t s11_port; /* MME S11 local port */
net_sock_t *s11_sock; /* MME S11 local listen socket */
2017-02-13 04:19:53 +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 */
gtp_xact_ctx_t gtp_xact_ctx; /* GTP Transaction Context for MME */
2017-03-06 08:55:50 +00:00
2017-07-23 03:25:01 +00:00
/* Generator for unique identification */
2017-03-07 00:30:12 +00:00
c_uint32_t mme_ue_s1ap_id; /** mme_ue_s1ap_id generator */
2017-07-23 03:25:01 +00:00
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
list_t sgw_list;
list_t enb_list;
2017-04-06 12:44:30 +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-04-06 11:10:00 +00:00
typedef struct _mme_sgw_t {
2017-03-27 04:22:42 +00:00
gtp_node_t gnode; /* SGW S11 remote GTPv2-C node */
2017-03-26 15:48:33 +00:00
2017-04-06 11:10:00 +00:00
} mme_sgw_t;
2017-03-26 15:48:33 +00:00
2017-04-06 11:10:00 +00:00
typedef struct _mme_enb_t {
2017-04-11 00:19:33 +00:00
lnode_t node; /**< A node of list_t */
2017-04-11 09:59:10 +00:00
index_t index; /**< An index of this node */
2017-04-11 00:32:34 +00:00
fsm_t sm;
2017-02-13 04:19:53 +00:00
2017-03-05 04:03:11 +00:00
c_uint32_t enb_id; /** eNB_ID received from eNB */
net_sock_t *s1ap_sock;
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
typedef struct _enb_ue_t enb_ue_t;
typedef struct _mme_ue_t mme_ue_t;
struct _enb_ue_t {
lnode_t node; /**< A node of list_t */
index_t index; /**< An index of this node */
fsm_t sm;
/* State Machine */
/* UE identity */
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 */
/* UE Info */
tai_t tai;
e_cgi_t e_cgi;
/* S1AP transactions */
struct {
S1ap_Cause_t cause;
} s1ap;
/* mme_ue_context */
mme_ue_t *mme_ue;
/* Connected enodeB */
mme_enb_t *enb;
2017-04-28 06:01:43 +00:00
/* Last NAS Authentication state */
int mac_failed;
};
struct _mme_ue_t {
2017-04-11 00:19:33 +00:00
lnode_t node; /**< A node of list_t */
2017-04-11 09:59:10 +00:00
index_t index; /**< An index of this node */
2017-04-11 00:32:34 +00:00
fsm_t sm;
2017-02-13 04:19:53 +00:00
2017-03-07 00:30:12 +00:00
/* State Machine */
2017-03-06 08:55:50 +00:00
2017-03-07 00:30:12 +00:00
/* UE identity */
#if 0
2017-03-05 04:03:11 +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 */
#endif
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];
guti_t guti;
2017-02-13 04:19:53 +00:00
2017-04-09 11:51:26 +00:00
/* UE Info */
#if 0
2017-04-11 11:44:38 +00:00
tai_t tai;
e_cgi_t e_cgi;
#endif
2017-04-09 11:51:26 +00:00
plmn_id_t visited_plmn_id;
2017-03-07 00:30:12 +00:00
/* Security Context */
2017-03-08 14:42:27 +00:00
int security_context_available;
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-04-11 02:54:00 +00:00
c_uint8_t rand[RAND_LEN];
c_uint8_t autn[AUTN_LEN];
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-04-13 12:05:30 +00:00
c_uint8_t kenb[SHA256_DIGEST_SIZE];
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-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 */
c_uint32_t ula_flags;
c_uint32_t max_bandwidth_ul; /* bits per seconds */
c_uint32_t max_bandwidth_dl; /* bits per seconds */
2017-04-12 04:45:57 +00:00
list_t pdn_list;
2017-04-10 12:05:28 +00:00
c_uint32_t subscribed_rau_tau_timer; /* seconds */
2017-04-27 14:06:10 +00:00
/* ESM Info */
c_uint8_t ebi; /* EPS Bearer ID generator */
list_t sess_list;
/* enb ue context */
enb_ue_t *enb_ue;
};
2017-04-27 14:06:10 +00:00
typedef struct _mme_sess_t {
lnode_t node; /**< A node of list_t */
index_t index; /**< An index of this node */
2017-04-12 12:20:00 +00:00
/* IMPORTANT!
* MME-S11-TEID is same with an index */
c_uint32_t mme_s11_teid;
c_uint32_t mme_s11_addr;
2017-04-27 14:06:10 +00:00
2017-04-12 12:20:00 +00:00
c_uint32_t sgw_s11_teid;
c_uint32_t sgw_s11_addr;
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 */
mme_ue_t *mme_ue;
2017-04-27 14:06:10 +00:00
} mme_sess_t;
2017-04-06 11:10:00 +00:00
2017-04-13 10:15:53 +00:00
typedef struct _mme_bearer_t {
2017-04-11 00:19:33 +00:00
lnode_t node; /**< A node of list_t */
2017-04-11 09:59:10 +00:00
index_t index; /**< An index of this node */
2017-04-11 00:32:34 +00:00
fsm_t sm;
2017-04-08 01:18:48 +00:00
2017-04-11 14:55:21 +00:00
c_uint8_t pti; /** Procedure Trasaction Identity */
c_uint8_t ebi; /** EPS Bearer ID */
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-04-12 01:05:23 +00:00
/* Protocol Configuration Options */
c_uint8_t ue_pco[MAX_PCO_LEN];
int ue_pco_len;
c_uint8_t pgw_pco[MAX_PCO_LEN];
int pgw_pco_len;
2017-04-08 01:18:48 +00:00
2017-04-28 03:39:14 +00:00
/* Related Context */
2017-04-11 09:59:10 +00:00
mme_sgw_t *sgw;
2017-04-11 12:38:24 +00:00
pdn_t *pdn;
mme_ue_t *mme_ue;
2017-04-27 14:06:10 +00:00
mme_sess_t *sess;
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);
2017-07-14 10:00:26 +00:00
CORE_DECLARE(status_t) mme_context_parse_config(void);
2017-04-06 11:10:00 +00:00
CORE_DECLARE(status_t) mme_context_final(void);
CORE_DECLARE(mme_context_t*) mme_self(void);
CORE_DECLARE(mme_sgw_t*) mme_sgw_add(void);
CORE_DECLARE(status_t) mme_sgw_remove(mme_sgw_t *sgw);
CORE_DECLARE(status_t) mme_sgw_remove_all(void);
CORE_DECLARE(mme_sgw_t*) mme_sgw_find_by_node(gtp_node_t *gnode);
CORE_DECLARE(mme_sgw_t*) mme_sgw_first(void);
CORE_DECLARE(mme_sgw_t*) mme_sgw_next(mme_sgw_t *sgw);
2017-04-08 01:45:48 +00:00
CORE_DECLARE(mme_enb_t*) mme_enb_add(net_sock_t *s1ap_sock);
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-04-06 11:10:00 +00:00
CORE_DECLARE(mme_enb_t*) mme_enb_find_by_sock(net_sock_t *sock);
CORE_DECLARE(mme_enb_t*) mme_enb_find_by_enb_id(c_uint32_t enb_id);
CORE_DECLARE(mme_enb_t*) mme_enb_first(void);
CORE_DECLARE(mme_enb_t*) mme_enb_next(mme_enb_t *enb);
CORE_DECLARE(mme_ue_t*) mme_ue_add(enb_ue_t *enb_ue);
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
CORE_DECLARE(status_t) mme_ue_set_imsi(
mme_ue_t *mme_ue, c_int8_t *imsi_bcd);
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);
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-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
CORE_DECLARE(mme_bearer_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);
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);
CORE_DECLARE(mme_sess_t*) mme_sess_find_by_teid(c_uint32_t teid);
CORE_DECLARE(mme_sess_t*) mme_sess_find_by_ebi(
mme_ue_t *mme_ue, c_uint8_t ebi);
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);
CORE_DECLARE(mme_bearer_t*) mme_bearer_add(mme_sess_t *sess, c_uint8_t pti);
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-04-27 14:06:10 +00:00
CORE_DECLARE(mme_bearer_t*) mme_bearer_find_by_ue_pti(
mme_ue_t *mme_ue, c_uint8_t pti);
2017-04-27 14:06:10 +00:00
CORE_DECLARE(mme_bearer_t*) mme_bearer_find_by_ue_ebi(
mme_ue_t *mme_ue, c_uint8_t ebi);
2017-04-27 14:06:10 +00:00
CORE_DECLARE(mme_bearer_t*) mme_bearer_find_by_sess_ebi(
mme_sess_t *sess, c_uint8_t ebi);
2017-04-27 23:28:04 +00:00
CORE_DECLARE(mme_bearer_t*) mme_default_bearer_in_sess(mme_sess_t *sess);
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
CORE_DECLARE(pdn_t*) mme_pdn_add(mme_ue_t *mme_ue, c_int8_t *apn);
2017-04-12 04:45:57 +00:00
CORE_DECLARE(status_t) mme_pdn_remove(pdn_t *pdn);
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);
CORE_DECLARE(pdn_t*) mme_pdn_first(mme_ue_t *mme_ue);
2017-04-12 04:45:57 +00:00
CORE_DECLARE(pdn_t*) mme_pdn_next(pdn_t *pdn);
CORE_DECLARE(enb_ue_t*) enb_ue_add(mme_enb_t *enb);
CORE_DECLARE(unsigned int) enb_ue_count();
CORE_DECLARE(status_t) enb_ue_remove(enb_ue_t *enb_ue);
CORE_DECLARE(status_t) enb_ue_remove_in_enb(mme_enb_t *enb);
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);
CORE_DECLARE(enb_ue_t*) enb_ue_next_in_enb(enb_ue_t *enb_ue);
2017-02-06 06:30:12 +00:00
#ifdef __cplusplus
}
#endif /* __cplusplus */
2017-04-06 11:10:00 +00:00
#endif /* __MME_CONTEXT__ */