From f458d58527535d610d4585a4f7caa2fd4ecdd282 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Thu, 20 Sep 2018 11:55:42 +0200 Subject: [PATCH] fixed handling of UE indentity request --- srsue/hdr/upper/nas.h | 2 +- srsue/src/upper/nas.cc | 65 ++++++++++++++++++++++++++---------------- 2 files changed, 42 insertions(+), 25 deletions(-) diff --git a/srsue/hdr/upper/nas.h b/srsue/hdr/upper/nas.h index 70ccbea35..15b9b7da3 100644 --- a/srsue/hdr/upper/nas.h +++ b/srsue/hdr/upper/nas.h @@ -180,7 +180,7 @@ private: void gen_service_request(byte_buffer_t *msg); // Senders - void send_identity_response(); + void send_identity_response(uint32_t lcid, uint8 id_type); void send_service_request(); void send_esm_information_response(const uint8 proc_transaction_id); void send_authentication_response(const uint8_t* res, const size_t res_len, const uint8_t sec_hdr_type); diff --git a/srsue/src/upper/nas.cc b/srsue/src/upper/nas.cc index ee2228ec4..fe07a1be6 100644 --- a/srsue/src/upper/nas.cc +++ b/srsue/src/upper/nas.cc @@ -805,31 +805,15 @@ void nas::parse_identity_request(uint32_t lcid, byte_buffer_t *pdu) { ZERO_OBJECT(id_resp); liblte_mme_unpack_identity_request_msg((LIBLTE_BYTE_MSG_STRUCT *) pdu, &id_req); + + // Deallocate PDU after parsing + pool->deallocate(pdu); + + ctxt.rx_count++; + nas_log->info("Received Identity Request. ID type: %d\n", id_req.id_type); - switch(id_req.id_type) { - case LIBLTE_MME_MOBILE_ID_TYPE_IMSI: - id_resp.mobile_id.type_of_id = LIBLTE_MME_MOBILE_ID_TYPE_IMSI; - usim->get_imsi_vec(id_resp.mobile_id.imsi, 15); - break; - case LIBLTE_MME_MOBILE_ID_TYPE_IMEI: - id_resp.mobile_id.type_of_id = LIBLTE_MME_MOBILE_ID_TYPE_IMEI; - usim->get_imei_vec(id_resp.mobile_id.imei, 15); - break; - default: - nas_log->error("Unhandled ID type: %d\n", id_req.id_type); - pool->deallocate(pdu); - return; - } - - pdu->reset(); - liblte_mme_pack_identity_response_msg(&id_resp, (LIBLTE_BYTE_MSG_STRUCT *) pdu); - - if(pcap != NULL) { - pcap->write_nas(pdu->msg, pdu->N_bytes); - } - - rrc->write_sdu(lcid, pdu); + send_identity_response(lcid, id_req.id_type); } void nas::parse_security_mode_command(uint32_t lcid, byte_buffer_t *pdu) @@ -1329,7 +1313,40 @@ void nas::send_authentication_failure(const uint8_t cause, const uint8_t* auth_f } -void nas::send_identity_response() {} +void nas::send_identity_response(uint32_t lcid, uint8 id_type) +{ + LIBLTE_MME_ID_RESPONSE_MSG_STRUCT id_resp; + ZERO_OBJECT(id_resp); + + switch(id_type) { + case LIBLTE_MME_MOBILE_ID_TYPE_IMSI: + id_resp.mobile_id.type_of_id = LIBLTE_MME_MOBILE_ID_TYPE_IMSI; + usim->get_imsi_vec(id_resp.mobile_id.imsi, 15); + break; + case LIBLTE_MME_MOBILE_ID_TYPE_IMEI: + id_resp.mobile_id.type_of_id = LIBLTE_MME_MOBILE_ID_TYPE_IMEI; + usim->get_imei_vec(id_resp.mobile_id.imei, 15); + break; + default: + nas_log->error("Unhandled ID type: %d\n", id_type); + return; + } + + byte_buffer_t *pdu = pool_allocate_blocking; + if (!pdu) { + nas_log->error("Fatal Error: Couldn't allocate PDU in send_identity_response().\n"); + return; + } + + liblte_mme_pack_identity_response_msg(&id_resp, (LIBLTE_BYTE_MSG_STRUCT *) pdu); + + if(pcap != NULL) { + pcap->write_nas(pdu->msg, pdu->N_bytes); + } + + rrc->write_sdu(lcid, pdu); + ctxt.tx_count++; +} void nas::send_service_request() { byte_buffer_t *msg = pool_allocate_blocking;