open5gs/src/mme/context.h

139 lines
3.9 KiB
C
Raw Normal View History

2017-03-06 13:47:39 +00:00
#ifndef __MME_CTX_H__
#define __MME_CTX_H__
2017-02-06 06:30:12 +00:00
#include "core_list.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-02-13 04:19:53 +00:00
2017-03-05 14:36:17 +00:00
#include "3gpp_message.h"
2017-02-13 04:19:53 +00:00
#include "sm.h"
2017-02-06 06:30:12 +00:00
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
2017-03-06 23:56:22 +00:00
#define PLMN_ID_LEN 3
2017-02-06 06:30:12 +00:00
#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-03-05 04:03:11 +00:00
typedef list_t ue_list_t;
2017-02-13 04:19:53 +00:00
typedef list_t rab_list_t;
2017-03-06 23:56:22 +00:00
typedef struct _plmn_id_t {
c_uint16_t mcc;
c_uint16_t mnc;
c_uint16_t mnc_len;
} plmn_id_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-02-06 06:30:12 +00:00
plmn_id_t plmn_id[MAX_PLMN_ID];
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-02-06 06:30:12 +00:00
} srvd_gummei_t;
typedef struct _mme_ctx_t {
2017-03-05 04:03:11 +00:00
net_sock_t *enb_s1ap_sock;
c_uint16_t enb_s1ap_port;
2017-02-13 04:19:53 +00:00
c_uint32_t enb_local_addr; /** Network byte order */
2017-03-06 08:55:50 +00:00
msgq_id queue_id;
tm_service_t tm_service;
2017-03-05 07:49:57 +00:00
c_uint32_t mme_ue_s1ap_id;
2017-02-06 06:30:12 +00:00
plmn_id_t plmn_id;
2017-02-13 04:19:53 +00:00
2017-02-14 00:09:01 +00:00
/* S1SetupRequest */
c_uint16_t tracking_area_code;
c_uint16_t default_paging_drx;
/* S1SetupResponse */
srvd_gummei_t srvd_gummei;
2017-02-13 04:19:53 +00:00
c_uint8_t relative_capacity;
2017-02-06 06:30:12 +00:00
} mme_ctx_t;
2017-02-13 04:19:53 +00:00
typedef struct _enb_ctx_t {
lnode_t node; /**< A node of list_t */
2017-03-05 04:03:11 +00:00
c_uint32_t enb_id; /** eNB_ID received from eNB */
enb_s1ap_sm_t s1ap_sm;
net_sock_t *s1ap_sock;
ue_list_t ue_list;
2017-02-13 04:19:53 +00:00
} enb_ctx_t;
typedef struct _ue_ctx_t {
lnode_t node; /**< A node of list_t */
2017-03-06 08:55:50 +00:00
ue_emm_sm_t emm_sm;
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 */
2017-03-05 14:36:17 +00:00
c_uint8_t imsi[MAX_IMSI_LEN+1];
c_uint8_t imsi_len;
2017-02-13 04:19:53 +00:00
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];
c_uint8_t knasenc[SHA256_DIGEST_SIZE];
c_uint8_t knasint[SHA256_DIGEST_SIZE];
2017-03-05 08:36:16 +00:00
2017-02-13 04:19:53 +00:00
rab_list_t rab_list;
enb_ctx_t *enb;
} ue_ctx_t;
/**
* This structure represents RAB */
typedef struct _rab_ctx_t {
lnode_t node; /**< A node of list_t */
2017-03-05 04:03:11 +00:00
c_uint32_t e_rab_id;
2017-02-13 04:19:53 +00:00
ue_ctx_t *ue;
} rab_ctx_t;
2017-03-04 16:05:03 +00:00
CORE_DECLARE(status_t) mme_ctx_init(void);
CORE_DECLARE(status_t) mme_ctx_final(void);
2017-02-06 06:30:12 +00:00
CORE_DECLARE(mme_ctx_t*) mme_self(void);
2017-02-13 04:19:53 +00:00
2017-03-04 16:05:03 +00:00
CORE_DECLARE(enb_ctx_t*) mme_ctx_enb_add(void);
CORE_DECLARE(status_t) mme_ctx_enb_remove(enb_ctx_t *enb);
CORE_DECLARE(status_t) mme_ctx_enb_remove_all(void);
CORE_DECLARE(enb_ctx_t*) mme_ctx_enb_find_by_sock(net_sock_t *sock);
2017-03-05 04:03:11 +00:00
CORE_DECLARE(enb_ctx_t*) mme_ctx_enb_find_by_enb_id(c_uint32_t enb_id);
2017-03-04 16:05:03 +00:00
CORE_DECLARE(enb_ctx_t*) mme_ctx_enb_first(void);
CORE_DECLARE(enb_ctx_t*) mme_ctx_enb_next(enb_ctx_t *enb);
2017-03-05 04:03:11 +00:00
CORE_DECLARE(ue_ctx_t*) mme_ctx_ue_add(enb_ctx_t *enb);
CORE_DECLARE(status_t) mme_ctx_ue_remove(ue_ctx_t *ue);
CORE_DECLARE(status_t) mme_ctx_ue_remove_all(enb_ctx_t *enb);
CORE_DECLARE(ue_ctx_t*) mme_ctx_ue_find_by_enb_ue_s1ap_id(
enb_ctx_t *enb, c_uint32_t enb_ue_s1ap_id);
CORE_DECLARE(ue_ctx_t*) mme_ctx_ue_first(enb_ctx_t *enb);
CORE_DECLARE(ue_ctx_t*) mme_ctx_ue_next(ue_ctx_t *ue);
CORE_DECLARE(rab_ctx_t*) mme_ctx_rab_add(ue_ctx_t *enb);
CORE_DECLARE(status_t) mme_ctx_rab_remove(rab_ctx_t *ue);
CORE_DECLARE(status_t) mme_ctx_rab_remove_all(ue_ctx_t *enb);
CORE_DECLARE(rab_ctx_t*) mme_ctx_rab_find_by_e_rab_id(
ue_ctx_t *ue, c_uint32_t e_rab_id);
CORE_DECLARE(rab_ctx_t*) mme_ctx_rab_first(ue_ctx_t *enb);
CORE_DECLARE(rab_ctx_t*) mme_ctx_rab_next(rab_ctx_t *ue);
2017-02-06 06:30:12 +00:00
#ifdef __cplusplus
}
#endif /* __cplusplus */
2017-03-06 13:47:39 +00:00
#endif /* __MME_CTX_H__ */