Commit 23a7f1bd authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Get PDU Session Status from NAS Message Container if necessary

parent dac9170e
......@@ -601,10 +601,45 @@ void amf_n1::service_request_handle(
// associate SUPI with UC
amf_app_inst->set_supi_2_ue_context(supi, uc);
// get PDU session status
// Get PDU session status from Service Request
uint16_t pdu_session_status = (uint16_t) serReq->getPduSessionStatus();
if (pdu_session_status <
0) { // Get PDU Session Status from NAS Message Container
bstring plain_msg;
if (serReq->getNasMessageContainer(plain_msg)) {
uint8_t* buf_nas = (uint8_t*) bdata(plain_msg);
uint8_t message_type = *(buf_nas + 2);
Logger::amf_n1().debug("NAS message type 0x%x", message_type);
switch (message_type) {
case REGISTRATION_REQUEST: {
Logger::nas_mm().debug(
"NAS Message Container contains a Registration Request, handling "
"...");
} break;
case SERVICE_REQUEST: {
Logger::nas_mm().debug(
"NAS Message Container contains a Service Request, handling ...");
std::unique_ptr<ServiceRequest> serReqNas =
std::make_unique<ServiceRequest>();
serReqNas->decodefrombuffer(
nullptr, (uint8_t*) bdata(plain_msg), blength(plain_msg));
bdestroy(plain_msg);
if (serReqNas->getPduSessionStatus() > 0) {
pdu_session_status = serReqNas->getPduSessionStatus();
}
} break;
default:
Logger::nas_mm().error(
"NAS Message Container, unknown NAS message 0x%x", message_type);
}
}
}
std::vector<uint8_t> pdu_session_to_be_activated = {};
std::bitset<16> pdu_session_status_bits(
(uint16_t) serReq->getPduSessionStatus());
std::bitset<16> pdu_session_status_bits(pdu_session_status);
for (int i = 0; i < 15; i++) {
if (pdu_session_status_bits.test(i)) {
......
......@@ -132,7 +132,8 @@ int _5GSMobilityIdentity::_5g_s_tmsi_encode2buffer(uint8_t* buf, int len) {
int _5GSMobilityIdentity::_5g_s_tmsi_decodefrombuffer(uint8_t* buf, int len) {
int decoded_size = 0;
_5g_s_tmsi = (_5G_S_TMSI_t*) calloc(1, sizeof(_5G_S_TMSI_t));
uint8_t octet = *(buf + decoded_size);
decoded_size++; // type of identity
uint8_t octet = *(buf + decoded_size);
decoded_size++;
_5g_s_tmsi->amf_set_id = 0x0000 | ((uint16_t) octet) << 2;
octet = *(buf + decoded_size);
......
......@@ -202,7 +202,7 @@ int ServiceRequest::decodefrombuffer(
buf + decoded_size, len - decoded_size, false);
uint8_t octet = *(buf + decoded_size);
Logger::nas_mm().debug("First optional IE (0x%x)", octet);
while (!octet) {
while ((octet != 0x0)) {
switch (octet) {
case 0x40: {
Logger::nas_mm().debug("Decoding ie_uplink_data_status (IEI: 0x40)");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment