From 6f0ac49833a0eee5c26b0947211f7e420fb7ca7f Mon Sep 17 00:00:00 2001 From: Cedric Roux <cedric.roux@eurecom.fr> Date: Mon, 9 Dec 2013 12:28:48 +0000 Subject: [PATCH] - Add eNB deregistration between S1AP and NAS layer git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4647 818b1a75-f10b-46b9-bf7c-635c3b92a50f --- openair-cn/COMMON/s1ap_messages_def.h | 4 +- openair-cn/COMMON/s1ap_messages_types.h | 13 +++++ .../NAS/EURECOM-NAS/src/emm/sap/emm_cn.c | 18 ++++++- .../NAS/EURECOM-NAS/src/emm/sap/emm_cnDef.h | 10 +++- .../NAS/EURECOM-NAS/src/emm/sap/emm_sap.h | 1 + openair-cn/NAS/EURECOM-NAS/src/nas_proc.c | 15 ++++++ openair-cn/NAS/EURECOM-NAS/src/nas_proc.h | 2 +- openair-cn/NAS/nas_main.c | 16 +++++++ openair-cn/S1AP/s1ap_mme_handlers.c | 47 ++++++++++++++++--- 9 files changed, 114 insertions(+), 12 deletions(-) diff --git a/openair-cn/COMMON/s1ap_messages_def.h b/openair-cn/COMMON/s1ap_messages_def.h index cf7fd64054..d13a5902f4 100644 --- a/openair-cn/COMMON/s1ap_messages_def.h +++ b/openair-cn/COMMON/s1ap_messages_def.h @@ -1,3 +1,5 @@ //WARNING: Do not include this header directly. Use intertask_interface.h instead. -MESSAGE_DEF(S1AP_UE_CAPABILITIES_IND, MESSAGE_PRIORITY_MED, s1ap_ue_cap_ind_t, s1ap_ue_cap_ind) +MESSAGE_DEF(S1AP_UE_CAPABILITIES_IND, MESSAGE_PRIORITY_MED, s1ap_ue_cap_ind_t, s1ap_ue_cap_ind) +MESSAGE_DEF(S1AP_ENB_DEREGISTERED_IND, MESSAGE_PRIORITY_MED, s1ap_eNB_deregistered_ind_t, s1ap_eNB_deregistered_ind) +MESSAGE_DEF(S1AP_DEREGISTER_UE_REQ, MESSAGE_PRIORITY_MED, s1ap_deregister_ue_req_t, s1ap_deregister_ue_req) diff --git a/openair-cn/COMMON/s1ap_messages_types.h b/openair-cn/COMMON/s1ap_messages_types.h index 1c847188b7..035c00cc7b 100644 --- a/openair-cn/COMMON/s1ap_messages_types.h +++ b/openair-cn/COMMON/s1ap_messages_types.h @@ -1,6 +1,9 @@ #ifndef S1AP_MESSAGES_TYPES_H_ #define S1AP_MESSAGES_TYPES_H_ +#define S1AP_ENB_DEREGISTERED_IND(mSGpTR) (mSGpTR)->ittiMsg.s1ap_eNB_deregistered_ind +#define S1AP_DEREGISTER_UE_REQ(mSGpTR) (mSGpTR)->ittiMsg.s1ap_deregister_ue_req + typedef struct s1ap_initial_ue_message_s { unsigned eNB_ue_s1ap_id:24; uint32_t mme_ue_s1ap_id; @@ -39,4 +42,14 @@ typedef struct s1ap_ue_cap_ind_s { uint32_t radio_capabilities_length; } s1ap_ue_cap_ind_t; +#define S1AP_ITTI_UE_PER_DEREGISTER_MESSAGE 20 +typedef struct s1ap_eNB_deregistered_ind_s { + uint8_t nb_ue_to_deregister; + uint32_t mme_ue_s1ap_id[S1AP_ITTI_UE_PER_DEREGISTER_MESSAGE]; +} s1ap_eNB_deregistered_ind_t; + +typedef struct s1ap_deregister_ue_req_s { + uint32_t mme_ue_s1ap_id; +} s1ap_deregister_ue_req_t; + #endif /* S1AP_MESSAGES_TYPES_H_ */ diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_cn.c b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_cn.c index 090a94584c..21122359e4 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_cn.c +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_cn.c @@ -34,8 +34,9 @@ Description * String representation of EMMCN-SAP primitives */ static const char *_emm_cn_primitive_str[] = { - "EMMCN_AUTHENTICATION_PARAM_RES", - "EMMCN_AUTHENTICATION_PARAM_FAIL", + "EMM_CN_AUTHENTICATION_PARAM_RES", + "EMM_CN_AUTHENTICATION_PARAM_FAIL", + "EMM_CN_DEREGISTER_UE", }; static int _emm_cn_authentication_res(const emm_cn_auth_res_t *msg) @@ -101,6 +102,15 @@ static int _emm_cn_authentication_fail(const emm_cn_auth_fail_t *msg) LOG_FUNC_RETURN (rc); } +static int _emm_cn_deregister_ue(const UInt32_t ue_id) +{ + int rc = RETURNok; + + LOG_FUNC_IN; + + LOG_FUNC_RETURN (rc); +} + int emm_cn_send(const emm_cn_t *msg) { int rc = RETURNerror; @@ -120,6 +130,10 @@ int emm_cn_send(const emm_cn_t *msg) rc = _emm_cn_authentication_fail(msg->u.auth_fail); break; + case EMMCN_DEREGISTER_UE: + rc = _emm_cn_deregister_ue(msg->u.deregister.UEid); + break; + default: /* Other primitives are forwarded to the Access Stratum */ rc = RETURNerror; diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_cnDef.h b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_cnDef.h index 77041967c6..c31454bedc 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_cnDef.h +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_cnDef.h @@ -30,6 +30,7 @@ typedef enum emmcn_primitive_s { #if defined(EPC_BUILD) _EMMCN_AUTHENTICATION_PARAM_RES, _EMMCN_AUTHENTICATION_PARAM_FAIL, + _EMMCN_DEREGISTER_UE, #endif _EMMCN_END } emm_cn_primitive_t; @@ -38,11 +39,16 @@ typedef enum emmcn_primitive_s { typedef nas_auth_param_rsp_t emm_cn_auth_res_t; typedef nas_auth_param_fail_t emm_cn_auth_fail_t; +typedef struct emm_cn_deregister_ue_s { + UInt32_t UEid; +} emm_cn_deregister_ue_t; + typedef struct emm_mme_ul_s { emm_cn_primitive_t primitive; union { - emm_cn_auth_res_t *auth_res; - emm_cn_auth_fail_t *auth_fail; + emm_cn_auth_res_t *auth_res; + emm_cn_auth_fail_t *auth_fail; + emm_cn_deregister_ue_t deregister; } u; } emm_cn_t; #endif diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_sap.h b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_sap.h index e5291572c2..a6d814c2dc 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_sap.h +++ b/openair-cn/NAS/EURECOM-NAS/src/emm/sap/emm_sap.h @@ -109,6 +109,7 @@ typedef enum { #ifdef EPC_BUILD EMMCN_AUTHENTICATION_PARAM_RES = _EMMCN_AUTHENTICATION_PARAM_RES, EMMCN_AUTHENTICATION_PARAM_FAIL = _EMMCN_AUTHENTICATION_PARAM_FAIL, + EMMCN_DEREGISTER_UE = _EMMCN_DEREGISTER_UE #endif } emm_primitive_t; diff --git a/openair-cn/NAS/EURECOM-NAS/src/nas_proc.c b/openair-cn/NAS/EURECOM-NAS/src/nas_proc.c index d4f5fdfd35..f4328bbc78 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/nas_proc.c +++ b/openair-cn/NAS/EURECOM-NAS/src/nas_proc.c @@ -1474,6 +1474,21 @@ int nas_proc_auth_param_fail(emm_cn_auth_fail_t *emm_cn_auth_fail) LOG_FUNC_RETURN (rc); } + +int nas_proc_deregister_ue(UInt32_t ue_id) +{ + int rc = RETURNerror; + emm_sap_t emm_sap; + + LOG_FUNC_IN; + + emm_sap.primitive = EMMCN_DEREGISTER_UE; + emm_sap.u.emm_cn.u.deregister.UEid = ue_id; + + rc = emm_sap_send(&emm_sap); + + LOG_FUNC_RETURN (rc); +} # endif #endif // NAS_MME diff --git a/openair-cn/NAS/EURECOM-NAS/src/nas_proc.h b/openair-cn/NAS/EURECOM-NAS/src/nas_proc.h index 158a8540d5..eea36c4249 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/nas_proc.h +++ b/openair-cn/NAS/EURECOM-NAS/src/nas_proc.h @@ -136,8 +136,8 @@ int nas_proc_ul_transfer_ind(UInt32_t ueid, const Byte_t *data, UInt32_t len); */ #if defined(NAS_MME) && defined(EPC_BUILD) int nas_proc_auth_param_res(emm_cn_auth_res_t *emm_cn_auth_res); - int nas_proc_auth_param_fail(emm_cn_auth_fail_t *emm_cn_auth_fail); +int nas_proc_deregister_ue(UInt32_t ue_id); #endif #endif /* __NAS_PROC_H__*/ diff --git a/openair-cn/NAS/nas_main.c b/openair-cn/NAS/nas_main.c index 521589d179..fc4c93f970 100644 --- a/openair-cn/NAS/nas_main.c +++ b/openair-cn/NAS/nas_main.c @@ -60,6 +60,7 @@ static void *nas_intertask_interface(void *args_p) next_message: itti_receive_msg(TASK_NAS, &received_message_p); + switch (ITTI_MSG_ID(received_message_p)) { case NAS_CONNECTION_ESTABLISHMENT_IND: { @@ -142,6 +143,21 @@ next_message: #endif } break; + case S1AP_ENB_DEREGISTERED_IND: { +#if !defined(DISABLE_USE_NAS) + int i; + for (i = 0; i < S1AP_ENB_DEREGISTERED_IND(received_message_p).nb_ue_to_deregister; i ++) { + nas_proc_deregister_ue(S1AP_ENB_DEREGISTERED_IND(received_message_p).mme_ue_s1ap_id[i]); + } +#endif + } break; + + case S1AP_DEREGISTER_UE_REQ: { +#if !defined(DISABLE_USE_NAS) + nas_proc_deregister_ue(S1AP_DEREGISTER_UE_REQ(received_message_p).mme_ue_s1ap_id); +#endif + } break; + case TERMINATE_MESSAGE: { itti_exit_task(); } break; diff --git a/openair-cn/S1AP/s1ap_mme_handlers.c b/openair-cn/S1AP/s1ap_mme_handlers.c index 8bbc95fa70..599b26f301 100644 --- a/openair-cn/S1AP/s1ap_mme_handlers.c +++ b/openair-cn/S1AP/s1ap_mme_handlers.c @@ -697,20 +697,51 @@ int s1ap_mme_handle_path_switch_request(uint32_t assoc_id, uint32_t stream, return 0; } -//////////////////////////////////////////////////////////////////////////////// -//************************* E-RAB management *********************************// -//////////////////////////////////////////////////////////////////////////////// - int s1ap_handle_sctp_deconnection(uint32_t assoc_id) { + int current_ue_index = 0; + int handled_ues = 0; + int i; + + MessageDef *message_p = NULL; + + ue_description_t *ue_ref = NULL; eNB_description_t *eNB_association; /* Checking that the assoc id has a valid eNB attached to. */ - if ((eNB_association = s1ap_is_eNB_assoc_id_in_list(assoc_id)) == NULL) { - S1AP_DEBUG("No eNB attached to this assoc_id: %d\n", + eNB_association = s1ap_is_eNB_assoc_id_in_list(assoc_id); + if (eNB_association == NULL) { + S1AP_ERROR("No eNB attached to this assoc_id: %d\n", assoc_id); return -1; } + + STAILQ_FOREACH(ue_ref, &eNB_association->ue_list_head, ue_entries) + { + /* Ask for a release of each UE context associated to the eNB */ + if (current_ue_index == 0) { + message_p = itti_alloc_new_message(TASK_S1AP, S1AP_ENB_DEREGISTERED_IND); + } + + S1AP_ENB_DEREGISTERED_IND(message_p).mme_ue_s1ap_id[current_ue_index] = ue_ref->mme_ue_s1ap_id; + + if (current_ue_index == 0 && handled_ues > 0) { + S1AP_ENB_DEREGISTERED_IND(message_p).nb_ue_to_deregister = S1AP_ITTI_UE_PER_DEREGISTER_MESSAGE; + itti_send_msg_to_task(TASK_NAS, INSTANCE_DEFAULT, message_p); + } + + handled_ues++; + current_ue_index = handled_ues % S1AP_ITTI_UE_PER_DEREGISTER_MESSAGE; + } + + if ((handled_ues % S1AP_ITTI_UE_PER_DEREGISTER_MESSAGE) != 0) { + S1AP_ENB_DEREGISTERED_IND(message_p).nb_ue_to_deregister = current_ue_index; + for (i = current_ue_index; i < S1AP_ITTI_UE_PER_DEREGISTER_MESSAGE; i++) { + S1AP_ENB_DEREGISTERED_IND(message_p).mme_ue_s1ap_id[current_ue_index] = 0; + } + itti_send_msg_to_task(TASK_NAS, INSTANCE_DEFAULT, message_p); + } + s1ap_remove_eNB(eNB_association); s1ap_dump_eNB_list(); @@ -756,6 +787,10 @@ int s1ap_handle_new_association(sctp_new_peer_t *sctp_new_peer_p) return 0; } +//////////////////////////////////////////////////////////////////////////////// +//************************* E-RAB management *********************************// +//////////////////////////////////////////////////////////////////////////////// + int s1ap_handle_create_session_response(SgwCreateSessionResponse *session_response_p) { -- GitLab