Skip to content

Commit

Permalink
fix(mme): Handling of missing RAN_UE_ID (magma#15278)
Browse files Browse the repository at this point in the history
Changes:
  1. Handling of RAN_UE_ID missing

Testing:
  1. Adding unit testcase for missing ran ue id.

Signed-off-by: Yogesh Pandey <[email protected]>
  • Loading branch information
panyogesh authored Aug 19, 2023
1 parent bd9b026 commit 7e0f50a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lte/gateway/c/core/oai/tasks/s1ap/s1ap_mme_nas_procedures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ status_code_e s1ap_mme_handle_initial_ue_message(oai::S1apState* state,
S1AP_FIND_PROTOCOLIE_BY_ID(S1ap_InitialUEMessage_IEs_t, ie, container,
S1ap_ProtocolIE_ID_id_eNB_UE_S1AP_ID, true);

if (!ie) {
OAILOG_ERROR(LOG_S1AP, "Missing ENB_UE_S1AP_ID\n");
OAILOG_FUNC_RETURN(LOG_S1AP, RETURNerror);
}

OAILOG_INFO(
LOG_S1AP,
"Received S1AP INITIAL_UE_MESSAGE ENB_UE_S1AP_ID " ENB_UE_S1AP_ID_FMT
Expand Down
39 changes: 39 additions & 0 deletions lte/gateway/c/core/oai/test/s1ap_task/test_s1ap_mme_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2392,5 +2392,44 @@ TEST_F(S1apMmeHandlersTest, HandleBigNasPackets) {
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_S1ap_S1AP_PDU, &pdu_s1);
}

TEST_F(S1apMmeHandlersTest, MalformedInitialUEMissingENBUES1APID) {
ASSERT_EQ(task_zmq_ctx_main_s1ap.ready, true);

EXPECT_CALL(*sctp_handler, sctpd_send_dl()).Times(1);

S1ap_S1AP_PDU_t pdu_s1;
memset(&pdu_s1, 0, sizeof(pdu_s1));
ASSERT_EQ(RETURNok, generate_s1_setup_request_pdu(&pdu_s1));
ASSERT_EQ(RETURNok,
s1ap_mme_handle_message(state, assoc_id, stream_id, &pdu_s1));

// State validation
ASSERT_TRUE(is_enb_state_valid(state, assoc_id, oai::S1AP_READY, 0));
ASSERT_TRUE(is_num_enbs_valid(state, 1));

uint8_t initial_ue_bytes[] = {
0x00, 0x0c, 0x40, 0x03, 0x0e, 0x00, 0x00, 0x00, 0x54, 0x40, 0x19, 0xa2,
0xba, 0x8b, 0x00, 0x5f, 0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x02, 0x00,
0x01, 0x00, 0x1a, 0x00, 0x2d, 0x2c, 0x17, 0x6b, 0xf1, 0x10, 0x00, 0x19,
0xb0, 0x10, 0x00, 0x86, 0x40, 0x01, 0x40, 0x00, 0x60, 0xbf, 0x4b, 0x51,
0x01, 0x07, 0x41, 0x01, 0x0b, 0xf6, 0x00, 0xf1, 0x10, 0x00, 0x02, 0x01,
0xf2, 0x00, 0x46, 0x53, 0x07, 0xe0, 0x01, 0x0c, 0x40, 0x01, 0x00, 0x00,
0x00, 0x40, 0x05, 0x01, 0xd0, 0x11, 0xd1, 0x91, 0xe0, 0x6f, 0x04, 0xe0,
0xf2, 0x60, 0x00, 0x00, 0x43, 0x00, 0x06, 0x00, 0x00, 0xf1, 0x10, 0x00,
0x07, 0x00, 0x64, 0x40, 0x08, 0x00, 0x00, 0xf1, 0x10, 0x00, 0x19, 0xb0,
0x10, 0x00, 0x86, 0x02, 0x01, 0xd0, 0x11, 0xd1, 0x91, 0xe0, 0x6f, 0x04,
0xe0, 0x00, 0x06, 0x00, 0x40, 0xf2, 0x00, 0x46, 0x53};

ASSERT_EQ(simulate_pdu_s1_message(initial_ue_bytes, sizeof(initial_ue_bytes),
state, assoc_id, stream_id),
RETURNerror);

// Send SCTP_CLOSE_ASSOCIATION mimicing SCTP task
ASSERT_EQ(send_s1ap_close_sctp_association(assoc_id), RETURNok);

// Freeing pdu and payload data
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_S1ap_S1AP_PDU, &pdu_s1);
}

} // namespace lte
} // namespace magma

0 comments on commit 7e0f50a

Please sign in to comment.