diff --git a/srsue/hdr/stack/upper/nas.h b/srsue/hdr/stack/upper/nas.h index 1fd816c1c..f6d507644 100644 --- a/srsue/hdr/stack/upper/nas.h +++ b/srsue/hdr/stack/upper/nas.h @@ -182,6 +182,8 @@ private: void parse_emm_information(uint32_t lcid, srslte::unique_byte_buffer_t pdu); void parse_detach_request(uint32_t lcid, srslte::unique_byte_buffer_t pdu); void parse_emm_status(uint32_t lcid, srslte::unique_byte_buffer_t pdu); + void parse_activate_dedicated_eps_bearer_context_request(uint32_t lcid, srslte::unique_byte_buffer_t pdu); + void parse_activate_test_mode(uint32_t lcid, srslte::unique_byte_buffer_t pdu, const uint8_t sec_hdr_type); // Packet generators void gen_attach_request(srslte::byte_buffer_t* msg); @@ -198,6 +200,8 @@ private: void send_security_mode_reject(uint8_t cause); void send_detach_request(bool switch_off); void send_detach_accept(); + void send_activate_dedicated_eps_bearer_context_accept(); + void send_activate_test_mode_complete(const uint8_t sec_hdr_type); // security context persistence file bool read_ctxt_file(nas_sec_ctxt *ctxt); diff --git a/srsue/src/stack/upper/nas.cc b/srsue/src/stack/upper/nas.cc index 2c94ef6ce..a9c0e2a22 100644 --- a/srsue/src/stack/upper/nas.cc +++ b/srsue/src/stack/upper/nas.cc @@ -406,11 +406,17 @@ void nas::write_pdu(uint32_t lcid, unique_byte_buffer_t pdu) case LIBLTE_MME_MSG_TYPE_EMM_INFORMATION: parse_emm_information(lcid, std::move(pdu)); break; + case LIBLTE_MME_MSG_TYPE_EMM_STATUS: + parse_emm_status(lcid, std::move(pdu)); + break; case LIBLTE_MME_MSG_TYPE_DETACH_REQUEST: parse_detach_request(lcid, std::move(pdu)); break; - case LIBLTE_MME_MSG_TYPE_EMM_STATUS: - parse_emm_status(lcid, std::move(pdu)); + case LIBLTE_MME_MSG_TYPE_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST: + parse_activate_dedicated_eps_bearer_context_request(lcid, std::move(pdu)); + break; + case LIBLTE_MME_MSG_TYPE_ACTIVATE_TEST_MODE: + parse_activate_test_mode(lcid, std::move(pdu), sec_hdr_type); break; default: nas_log->error("Not handling NAS message with MSG_TYPE=%02X\n", msg_type); @@ -955,8 +961,8 @@ void nas::parse_security_mode_command(uint32_t lcid, unique_byte_buffer_t pdu) // TODO: check nonce (not sent by Amari) // Check capabilities replay - if(!check_cap_replay(&sec_mode_cmd.ue_security_cap)) { - nas_log->warning("Sending Security Mode Reject due to security capabilities mismatch\n"); + if (!check_cap_replay(&sec_mode_cmd.ue_security_cap)) { + nas_log->warning("Sending Security Mode Reject due to security capabilities replay mismatch\n"); send_security_mode_reject(LIBLTE_MME_EMM_CAUSE_UE_SECURITY_CAPABILITIES_MISMATCH); return; } @@ -1089,6 +1095,27 @@ void nas::parse_detach_request(uint32_t lcid, unique_byte_buffer_t pdu) } } +void nas::parse_activate_dedicated_eps_bearer_context_request(uint32_t lcid, unique_byte_buffer_t pdu) +{ + nas_log->info("Received Activate Dedicated EPS bearer context request\n"); + + LIBLTE_MME_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_MSG_STRUCT request; + liblte_mme_unpack_activate_dedicated_eps_bearer_context_request_msg((LIBLTE_BYTE_MSG_STRUCT*)pdu.get(), &request); + + ctxt.rx_count++; + + send_activate_dedicated_eps_bearer_context_accept(); +} + +void nas::parse_activate_test_mode(uint32_t lcid, unique_byte_buffer_t pdu, const uint8_t sec_hdr_type) +{ + nas_log->info("Received Activate test mode\n"); + + ctxt.rx_count++; + + send_activate_test_mode_complete(sec_hdr_type); +} + void nas::parse_emm_status(uint32_t lcid, unique_byte_buffer_t pdu) { LIBLTE_MME_EMM_STATUS_MSG_STRUCT emm_status; @@ -1708,6 +1735,49 @@ void nas::send_esm_information_response(const uint8 proc_transaction_id) { chap_id++; } +void nas::send_activate_dedicated_eps_bearer_context_accept() +{ + unique_byte_buffer_t pdu = srslte::allocate_unique_buffer(*pool, true); + + LIBLTE_MME_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_ACCEPT_MSG_STRUCT accept = {}; + if (liblte_mme_pack_activate_dedicated_eps_bearer_context_accept_msg( + &accept, + LIBLTE_MME_SECURITY_HDR_TYPE_INTEGRITY_AND_CIPHERED, + ctxt.tx_count, + (LIBLTE_BYTE_MSG_STRUCT*)pdu.get())) { + nas_log->error("Error packing Activate Dedicated EPS Bearer context accept.\n"); + return; + } + + if (pcap != NULL) { + pcap->write_nas(pdu->msg, pdu->N_bytes); + } + + nas_log->info_hex(pdu->msg, pdu->N_bytes, "Sending Activate Dedicated EPS Bearer context accept\n"); + rrc->write_sdu(std::move(pdu)); + + ctxt.tx_count++; +} + +void nas::send_activate_test_mode_complete(const uint8_t sec_hdr_type) +{ + unique_byte_buffer_t pdu = srslte::allocate_unique_buffer(*pool, true); + + if (liblte_mme_pack_activate_test_mode_complete_msg( + (LIBLTE_BYTE_MSG_STRUCT*)pdu.get(), sec_hdr_type, ctxt.tx_count)) { + nas_log->error("Error packing activate test mode complete.\n"); + return; + } + + if (pcap != NULL) { + pcap->write_nas(pdu->msg, pdu->N_bytes); + } + + nas_log->info_hex(pdu->msg, pdu->N_bytes, "Sending Activate test mode complete\n"); + rrc->write_sdu(std::move(pdu)); + + ctxt.tx_count++; +} /******************************************************************************* * Security context persistence file