diff --git a/openair2/COMMON/s1ap_messages_types.h b/openair2/COMMON/s1ap_messages_types.h index 970674a37bf47cab96fa5aee2247271082e20538..223b69a7bbf11c95dc2151869bfd97b18e5c9fdb 100644 --- a/openair2/COMMON/s1ap_messages_types.h +++ b/openair2/COMMON/s1ap_messages_types.h @@ -19,6 +19,8 @@ #define S1AP_UE_CTXT_MODIFICATION_REQ(mSGpTR) (mSGpTR)->ittiMsg.s1ap_ue_ctxt_modification_req #define S1AP_PAGIND_IND(mSGpTR) (mSGpTR)->ittiMsg.s1ap_paging_ind +#define S1AP_UE_CONTEXT_RELEASE_REQ(mSGpTR) (mSGpTR)->ittiMsg.s1ap_ue_release_req + //-------------------------------------------------------------------------------------------// typedef enum cell_type_e { diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c index 3cbb0797f10376dbc8475db534263a6c4817e6b5..b0e2abfee265b358706a2b9a56cc6761ca10570d 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LITE/rrc_eNB.c @@ -72,15 +72,14 @@ #endif #if defined(ENABLE_USE_MME) +# include "rrc_eNB_S1AP.h" # if defined(ENABLE_ITTI) -# include "s1ap_eNB.h" # else # include "../../S1AP/s1ap_eNB.h" # endif #endif #include "pdcp.h" -#include "rrc_eNB_S1AP.h" #if defined(ENABLE_ITTI) # include "intertask_interface.h" @@ -3102,6 +3101,18 @@ void *rrc_enb_task(void *args_p) { case S1AP_INITIAL_CONTEXT_SETUP_REQ: rrc_eNB_process_S1AP_INITIAL_CONTEXT_SETUP_REQ(msg_p, msg_name, instance); break; + + case S1AP_UE_CTXT_MODIFICATION_REQ: + rrc_eNB_process_S1AP_UE_CTXT_MODIFICATION_REQ(msg_p, msg_name, instance); + break; + + case S1AP_PAGING_IND: + LOG_E(RRC, "Received not yet implemented message %s\n", msg_name); + break; + + case S1AP_UE_CONTEXT_RELEASE_REQ: + rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_REQ(msg_p, msg_name, instance); + break; #endif default: diff --git a/openair2/RRC/LITE/rrc_eNB_S1AP.c b/openair2/RRC/LITE/rrc_eNB_S1AP.c index 31dfe12b288be9319eea7df6c27a0e115ea95bf5..87627f1711aeb2fb0ea4e8def69b13a086d579f8 100644 --- a/openair2/RRC/LITE/rrc_eNB_S1AP.c +++ b/openair2/RRC/LITE/rrc_eNB_S1AP.c @@ -311,25 +311,26 @@ void rrc_eNB_send_S1AP_NAS_FIRST_REQ(uint8_t mod_id, uint8_t ue_index, # if defined(ENABLE_ITTI) /*------------------------------------------------------------------------------*/ int rrc_eNB_process_S1AP_DOWNLINK_NAS(MessageDef *msg_p, const char *msg_name, instance_t instance, mui_t *rrc_eNB_mui) { + uint16_t ue_initial_id; + uint32_t eNB_ue_s1ap_id; uint8_t ue_index; uint32_t length; uint8_t *buffer; - ue_index = get_UE_index_from_s1ap_ids (instance, S1AP_DOWNLINK_NAS (msg_p).ue_initial_id, - S1AP_DOWNLINK_NAS (msg_p).eNB_ue_s1ap_id); + ue_initial_id = S1AP_DOWNLINK_NAS (msg_p).ue_initial_id; + eNB_ue_s1ap_id = S1AP_DOWNLINK_NAS (msg_p).eNB_ue_s1ap_id; + ue_index = get_UE_index_from_s1ap_ids (instance, ue_initial_id, eNB_ue_s1ap_id); - LOG_I(RRC, "Received %s: instance %d, ue_initial_id %d, eNB_ue_s1ap_id %d, ue_index %d\n", msg_name, instance, - S1AP_DOWNLINK_NAS (msg_p).ue_initial_id, S1AP_DOWNLINK_NAS (msg_p).eNB_ue_s1ap_id, ue_index); + LOG_I(RRC, "Received %s: instance %d, ue_initial_id %d, eNB_ue_s1ap_id %d, ue_index %d\n", msg_name, instance, ue_initial_id, eNB_ue_s1ap_id, ue_index); if (ue_index == UE_INDEX_INVALID) { /* Can not associate this message to an UE index, send a failure to S1AP and discard it! */ MessageDef *msg_fail_p; - LOG_W(RRC, "In S1AP_DOWNLINK_NAS: unknown UE from S1AP ids (%d, %d) for eNB %d\n", S1AP_DOWNLINK_NAS (msg_p).ue_initial_id, - S1AP_DOWNLINK_NAS (msg_p).eNB_ue_s1ap_id, instance); + LOG_W(RRC, "In S1AP_DOWNLINK_NAS: unknown UE from S1AP ids (%d, %d) for eNB %d\n", ue_initial_id, eNB_ue_s1ap_id, instance); msg_fail_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_NAS_NON_DELIVERY_IND); - S1AP_NAS_NON_DELIVERY_IND (msg_fail_p).eNB_ue_s1ap_id = S1AP_DOWNLINK_NAS (msg_p).eNB_ue_s1ap_id; + S1AP_NAS_NON_DELIVERY_IND (msg_fail_p).eNB_ue_s1ap_id = eNB_ue_s1ap_id; S1AP_NAS_NON_DELIVERY_IND (msg_fail_p).nas_pdu.length = S1AP_DOWNLINK_NAS (msg_p).nas_pdu.length; S1AP_NAS_NON_DELIVERY_IND (msg_fail_p).nas_pdu.buffer = S1AP_DOWNLINK_NAS (msg_p).nas_pdu.buffer; @@ -355,24 +356,25 @@ int rrc_eNB_process_S1AP_DOWNLINK_NAS(MessageDef *msg_p, const char *msg_name, i /*------------------------------------------------------------------------------*/ int rrc_eNB_process_S1AP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, const char *msg_name, instance_t instance) { + uint16_t ue_initial_id; + uint32_t eNB_ue_s1ap_id; uint8_t ue_index; - ue_index = get_UE_index_from_s1ap_ids (instance, S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).ue_initial_id, - S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).eNB_ue_s1ap_id); + ue_initial_id = S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).ue_initial_id; + eNB_ue_s1ap_id = S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).eNB_ue_s1ap_id; + ue_index = get_UE_index_from_s1ap_ids (instance, ue_initial_id, eNB_ue_s1ap_id); LOG_I(RRC, "Received %s: instance %d, ue_initial_id %d, eNB_ue_s1ap_id %d, nb_of_e_rabs %d, ue_index %d\n", - msg_name, instance, S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).ue_initial_id, - S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).eNB_ue_s1ap_id, S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).nb_of_e_rabs, ue_index); + msg_name, instance, ue_initial_id, eNB_ue_s1ap_id, S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).nb_of_e_rabs, ue_index); if (ue_index == UE_INDEX_INVALID) { /* Can not associate this message to an UE index, send a failure to S1AP and discard it! */ MessageDef *msg_fail_p; - LOG_W(RRC, "In S1AP_INITIAL_CONTEXT_SETUP_REQ: unknown UE from S1AP ids (%d, %d) for eNB %d\n", - S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).ue_initial_id, S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).eNB_ue_s1ap_id, instance); + LOG_W(RRC, "In S1AP_INITIAL_CONTEXT_SETUP_REQ: unknown UE from S1AP ids (%d, %d) for eNB %d\n", ue_initial_id, eNB_ue_s1ap_id, instance); msg_fail_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_INITIAL_CONTEXT_SETUP_FAIL); - S1AP_INITIAL_CONTEXT_SETUP_FAIL (msg_fail_p).eNB_ue_s1ap_id = S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).eNB_ue_s1ap_id; + S1AP_INITIAL_CONTEXT_SETUP_FAIL (msg_fail_p).eNB_ue_s1ap_id = eNB_ue_s1ap_id; // TODO add failure cause when defined! @@ -395,6 +397,14 @@ int rrc_eNB_process_S1AP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, const char } } + /* TODO parameters yet to process ... */ + { + S1AP_INITIAL_CONTEXT_SETUP_REQ(msg_p).ue_ambr; + S1AP_INITIAL_CONTEXT_SETUP_REQ(msg_p).security_capabilities.encryption_algorithms; + S1AP_INITIAL_CONTEXT_SETUP_REQ(msg_p).security_capabilities.integrity_algorithms; + S1AP_INITIAL_CONTEXT_SETUP_REQ(msg_p).security_key; + } + { uint8_t send_security_mode_command = TRUE; @@ -411,5 +421,99 @@ int rrc_eNB_process_S1AP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, const char } } +/*------------------------------------------------------------------------------*/ +int rrc_eNB_process_S1AP_UE_CTXT_MODIFICATION_REQ(MessageDef *msg_p, const char *msg_name, instance_t instance) { + uint32_t eNB_ue_s1ap_id; + uint8_t ue_index; + + eNB_ue_s1ap_id = S1AP_UE_CTXT_MODIFICATION_REQ (msg_p).eNB_ue_s1ap_id; + ue_index = get_UE_index_from_eNB_ue_s1ap_id (instance, eNB_ue_s1ap_id); + + if (ue_index == UE_INDEX_INVALID) { + /* Can not associate this message to an UE index, send a failure to S1AP and discard it! */ + MessageDef *msg_fail_p; + + LOG_W(RRC, "In S1AP_UE_CTXT_MODIFICATION_REQ: unknown UE from eNB_ue_s1ap_id (%d) for eNB %d\n", eNB_ue_s1ap_id, instance); + + msg_fail_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_UE_CTXT_MODIFICATION_FAIL); + S1AP_UE_CTXT_MODIFICATION_FAIL (msg_fail_p).eNB_ue_s1ap_id = eNB_ue_s1ap_id; + + // TODO add failure cause when defined! + + itti_send_msg_to_task (TASK_S1AP, instance, msg_fail_p); + + return (-1); + } + else { + + /* TODO parameters yet to process ... */ + { + if (S1AP_UE_CTXT_MODIFICATION_REQ(msg_p).present & S1AP_UE_CONTEXT_MODIFICATION_SECURITY_KEY) { + S1AP_UE_CTXT_MODIFICATION_REQ(msg_p).security_key; + } + if (S1AP_UE_CTXT_MODIFICATION_REQ(msg_p).present & S1AP_UE_CONTEXT_MODIFICATION_UE_AMBR) { + S1AP_UE_CTXT_MODIFICATION_REQ(msg_p).ue_ambr; + } + if (S1AP_UE_CTXT_MODIFICATION_REQ(msg_p).present & S1AP_UE_CONTEXT_MODIFICATION_UE_SECU_CAP) { + S1AP_UE_CTXT_MODIFICATION_REQ(msg_p).security_capabilities.encryption_algorithms; + S1AP_UE_CTXT_MODIFICATION_REQ(msg_p).security_capabilities.integrity_algorithms; + } + } + + /* Send the response */ + { + MessageDef *msg_resp_p; + + msg_resp_p = itti_alloc_new_message(TASK_RRC_ENB, S1AP_UE_CTXT_MODIFICATION_RESP); + S1AP_UE_CTXT_MODIFICATION_RESP(msg_resp_p).eNB_ue_s1ap_id = eNB_ue_s1ap_id; + + itti_send_msg_to_task(TASK_S1AP, instance, msg_resp_p); + } + + return (0); + } +} + +/*------------------------------------------------------------------------------*/ +int rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_REQ (MessageDef *msg_p, const char *msg_name, instance_t instance) { + uint32_t eNB_ue_s1ap_id; + uint8_t ue_index; + + eNB_ue_s1ap_id = S1AP_UE_CONTEXT_RELEASE_REQ(msg_p).eNB_ue_s1ap_id; + ue_index = get_UE_index_from_eNB_ue_s1ap_id(instance, eNB_ue_s1ap_id); + + if (ue_index == UE_INDEX_INVALID) { + /* Can not associate this message to an UE index, send a failure to S1AP and discard it! */ + MessageDef *msg_fail_p; + + LOG_W(RRC, + "In S1AP_UE_CONTEXT_RELEASE_REQ: unknown UE from eNB_ue_s1ap_id (%d) for eNB %d\n", eNB_ue_s1ap_id, instance); + + msg_fail_p = itti_alloc_new_message(TASK_RRC_ENB, S1AP_UE_CONTEXT_RELEASE_RESP); /* TODO change message ID. */ + S1AP_UE_CONTEXT_RELEASE_RESP(msg_fail_p).eNB_ue_s1ap_id = eNB_ue_s1ap_id; + + // TODO add failure cause when defined! + + itti_send_msg_to_task(TASK_S1AP, instance, msg_fail_p); + + return (-1); + } + else { + /* TODO release context. */ + + /* Send the response */ + { + MessageDef *msg_resp_p; + + msg_resp_p = itti_alloc_new_message(TASK_RRC_ENB, S1AP_UE_CONTEXT_RELEASE_RESP); + S1AP_UE_CONTEXT_RELEASE_RESP(msg_resp_p).eNB_ue_s1ap_id = eNB_ue_s1ap_id; + + itti_send_msg_to_task(TASK_S1AP, instance, msg_resp_p); + } + + return (0); + } +} + # endif /* defined(ENABLE_ITTI) */ #endif /* defined(ENABLE_USE_MME) */ diff --git a/openair2/RRC/LITE/rrc_eNB_S1AP.h b/openair2/RRC/LITE/rrc_eNB_S1AP.h index f84176ad0cb9dde3d7c9a362e6cb3d555d3e56b6..1e5827ee13087f24062a4f461d58cb657a8fb689 100644 --- a/openair2/RRC/LITE/rrc_eNB_S1AP.h +++ b/openair2/RRC/LITE/rrc_eNB_S1AP.h @@ -64,6 +64,25 @@ int rrc_eNB_process_S1AP_DOWNLINK_NAS(MessageDef *msg_p, const char *msg_name, i *\return 0 when successful, -1 if the UE index can not be retrieved. */ int rrc_eNB_process_S1AP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, const char *msg_name, instance_t instance); + +/*! \fn rrc_eNB_process_S1AP_UE_CTXT_MODIFICATION_REQ(MessageDef *msg_p, const char *msg_name, instance_t instance) + *\brief process a S1AP_UE_CTXT_MODIFICATION_REQ message received from S1AP. + *\param msg_p Message received by RRC. + *\param msg_name Message name. + *\param instance Message instance. + *\return 0 when successful, -1 if the UE index can not be retrieved. + */ +int rrc_eNB_process_S1AP_UE_CTXT_MODIFICATION_REQ(MessageDef *msg_p, const char *msg_name, instance_t instance); + +/*! \fn rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_REQ(MessageDef *msg_p, const char *msg_name, instance_t instance) + *\brief process a S1AP_UE_CONTEXT_RELEASE_REQ message received from S1AP. + *\param msg_p Message received by RRC. + *\param msg_name Message name. + *\param instance Message instance. + *\return 0 when successful, -1 if the UE index can not be retrieved. + */ +int rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_REQ (MessageDef *msg_p, const char *msg_name, instance_t instance); + # endif # endif /* defined(ENABLE_USE_MME) */ #endif /* RRC_ENB_S1AP_H_ */