nas: add parser and sender for modify EPS bearer context messages

master
Andre Puschmann 6 years ago
parent f357c995fc
commit b2a35f6b5a

@ -170,6 +170,7 @@ private:
void parse_activate_dedicated_eps_bearer_context_request(uint32_t lcid, srslte::unique_byte_buffer_t pdu);
void parse_deactivate_eps_bearer_context_request(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);
void parse_modify_eps_bearer_context_request(srslte::unique_byte_buffer_t pdu);
// Packet generators
void gen_attach_request(srslte::byte_buffer_t* msg);
@ -189,6 +190,7 @@ private:
void send_activate_dedicated_eps_bearer_context_accept(const uint8_t& proc_transaction_id,
const uint8_t& eps_bearer_id);
void send_deactivate_eps_bearer_context_accept(const uint8_t& proc_transaction_id, const uint8_t& eps_bearer_id);
void send_modify_eps_bearer_context_accept(const uint8_t& proc_transaction_id, const uint8_t& eps_bearer_id);
void send_activate_test_mode_complete(const uint8_t sec_hdr_type);
// security context persistence file

@ -429,6 +429,9 @@ void nas::write_pdu(uint32_t lcid, unique_byte_buffer_t pdu)
case LIBLTE_MME_MSG_TYPE_DEACTIVATE_EPS_BEARER_CONTEXT_REQUEST:
parse_deactivate_eps_bearer_context_request(std::move(pdu));
break;
case LIBLTE_MME_MSG_TYPE_MODIFY_EPS_BEARER_CONTEXT_REQUEST:
parse_modify_eps_bearer_context_request(std::move(pdu));
break;
case LIBLTE_MME_MSG_TYPE_ACTIVATE_TEST_MODE:
parse_activate_test_mode(lcid, std::move(pdu), sec_hdr_type);
break;
@ -1175,6 +1178,30 @@ void nas::parse_deactivate_eps_bearer_context_request(unique_byte_buffer_t pdu)
send_deactivate_eps_bearer_context_accept(request.proc_transaction_id, request.eps_bearer_id);
}
void nas::parse_modify_eps_bearer_context_request(srslte::unique_byte_buffer_t pdu)
{
LIBLTE_MME_MODIFY_EPS_BEARER_CONTEXT_REQUEST_MSG_STRUCT request;
liblte_mme_unpack_modify_eps_bearer_context_request_msg((LIBLTE_BYTE_MSG_STRUCT*)pdu.get(), &request);
nas_log->info("Received Modify EPS bearer context request (eps_bearer_id=%d, proc_id=%d)\n",
request.eps_bearer_id,
request.proc_transaction_id);
ctxt.rx_count++;
// check if bearer exists
if (eps_bearer.find(request.eps_bearer_id) == eps_bearer.end()) {
nas_log->error("EPS bearer doesn't exist (eps_bearer_id=%d)\n", request.eps_bearer_id);
// fixme: send proper response
return;
}
// fixme: carry out modification
nas_log->info("Modified EPS bearer context (eps_bearer_id=%d)\n", request.eps_bearer_id);
send_modify_eps_bearer_context_accept(request.proc_transaction_id, request.eps_bearer_id);
}
void nas::parse_activate_test_mode(uint32_t lcid, unique_byte_buffer_t pdu, const uint8_t sec_hdr_type)
{
@ -1886,6 +1913,46 @@ void nas::send_deactivate_eps_bearer_context_accept(const uint8_t& proc_transact
ctxt.tx_count++;
}
void nas::send_modify_eps_bearer_context_accept(const uint8_t& proc_transaction_id, const uint8_t& eps_bearer_id)
{
unique_byte_buffer_t pdu = srslte::allocate_unique_buffer(*pool, true);
LIBLTE_MME_MODIFY_EPS_BEARER_CONTEXT_ACCEPT_MSG_STRUCT accept = {};
accept.eps_bearer_id = eps_bearer_id;
accept.proc_transaction_id = proc_transaction_id;
if (liblte_mme_pack_modify_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 Modify EPS Bearer context accept.\n");
return;
}
if (pcap != NULL) {
pcap->write_nas(pdu->msg, pdu->N_bytes);
}
cipher_encrypt(pdu.get());
if (pdu->N_bytes > 5) {
integrity_generate(
&k_nas_int[16], ctxt.tx_count, SECURITY_DIRECTION_UPLINK, &pdu->msg[5], pdu->N_bytes - 5, &pdu->msg[1]);
} else {
nas_log->error("Invalid PDU size %d\n", pdu->N_bytes);
return;
}
nas_log->info_hex(pdu->msg,
pdu->N_bytes,
"Sending Modify EPS Bearer context accept (eps_bearer_id=%d, proc_id=%d)\n",
accept.eps_bearer_id,
accept.proc_transaction_id);
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);

Loading…
Cancel
Save