Commit a91ae6c8 authored by dukl's avatar dukl

fix bugs: decoding NASMessageConteainer in service request

parent d62a7388
...@@ -604,7 +604,7 @@ void amf_n1::service_request_handle( ...@@ -604,7 +604,7 @@ void amf_n1::service_request_handle(
if(serReq->getNasMessageContainer(nas_container)){ if(serReq->getNasMessageContainer(nas_container)){
Logger::amf_n1().debug("try to get pdu-session-status value from nas message container(length: %d)", blength(nas_container)); Logger::amf_n1().debug("try to get pdu-session-status value from nas message container(length: %d)", blength(nas_container));
uint8_t *buf = (uint8_t*)bdata(nas_container); uint8_t *buf = (uint8_t*)bdata(nas_container);
pdu_session_status = buf[18]<<8 | buf[19]; pdu_session_status = buf[19]<<8 | buf[20];
Logger::amf_n1().debug("Get pdu-session-status value: 0x%x", pdu_session_status); Logger::amf_n1().debug("Get pdu-session-status value: 0x%x", pdu_session_status);
} }
ServiceAccept* serApt = new ServiceAccept(); ServiceAccept* serApt = new ServiceAccept();
......
...@@ -86,30 +86,36 @@ int _5GSMobilityIdentity::_5g_s_tmsi_decodefrombuffer(uint8_t* buf, int len) { ...@@ -86,30 +86,36 @@ int _5GSMobilityIdentity::_5g_s_tmsi_decodefrombuffer(uint8_t* buf, int len) {
int decoded_size = 1; int decoded_size = 1;
_5g_s_tmsi = (_5G_S_TMSI_t*) calloc(1, sizeof(_5G_S_TMSI_t)); _5g_s_tmsi = (_5G_S_TMSI_t*) calloc(1, sizeof(_5G_S_TMSI_t));
uint8_t octet = *(buf + decoded_size); uint8_t octet = *(buf + decoded_size);
Logger::nas_mm().debug("first octet 0x%x",octet);
decoded_size++; decoded_size++;
_5g_s_tmsi->amf_set_id = 0x0000 | ((uint16_t) octet) << 2; _5g_s_tmsi->amf_set_id = 0x0000 | ((uint16_t) octet) << 2;
octet = *(buf + decoded_size); octet = *(buf + decoded_size);
Logger::nas_mm().debug("second octet 0x%x",octet);
decoded_size++; decoded_size++;
_5g_s_tmsi->amf_set_id |= (octet & 0xc0) >> 6; _5g_s_tmsi->amf_set_id |= (octet & 0xc0) >> 6;
_5g_s_tmsi->amf_pointer = octet & 0x3f; _5g_s_tmsi->amf_pointer = octet & 0x3f;
uint32_t tmsi = 0; uint32_t tmsi = 0;
uint8_t digit[4]; uint8_t digit[4];
octet = *(buf + decoded_size); octet = *(buf + decoded_size);
Logger::nas_mm().debug("third octet 0x%x",octet);
decoded_size++; decoded_size++;
Logger::nas_mm().debug("Octet 0x%x", octet); Logger::nas_mm().debug("Octet 0x%x", octet);
digit[0] = octet; digit[0] = octet;
tmsi |= octet; tmsi |= octet;
octet = *(buf + decoded_size); octet = *(buf + decoded_size);
Logger::nas_mm().debug("fourth octet 0x%x",octet);
decoded_size++; decoded_size++;
Logger::nas_mm().debug("Octet 0x%x", octet); Logger::nas_mm().debug("Octet 0x%x", octet);
digit[1] = octet; digit[1] = octet;
tmsi |= octet << 8; tmsi |= octet << 8;
octet = *(buf + decoded_size); octet = *(buf + decoded_size);
Logger::nas_mm().debug("fifth octet 0x%x",octet);
decoded_size++; decoded_size++;
Logger::nas_mm().debug("Octet 0x%x", octet); Logger::nas_mm().debug("Octet 0x%x", octet);
digit[2] = octet; digit[2] = octet;
tmsi |= octet << 16; tmsi |= octet << 16;
octet = *(buf + decoded_size); octet = *(buf + decoded_size);
Logger::nas_mm().debug("sixth octet 0x%x",octet);
decoded_size++; decoded_size++;
Logger::nas_mm().debug("Octet 0x%x", octet); Logger::nas_mm().debug("Octet 0x%x", octet);
digit[3] = octet; digit[3] = octet;
...@@ -497,6 +503,7 @@ int _5GSMobilityIdentity::decodefrombuffer( ...@@ -497,6 +503,7 @@ int _5GSMobilityIdentity::decodefrombuffer(
typeOfIdentity = _5G_S_TMSI; typeOfIdentity = _5G_S_TMSI;
decoded_size += decoded_size +=
_5g_s_tmsi_decodefrombuffer(buf + decoded_size, len - decoded_size); _5g_s_tmsi_decodefrombuffer(buf + decoded_size, len - decoded_size);
Logger::amf_n1().debug("Decoded 5GSMobilityIdentity %d octets",decoded_size);
return decoded_size; return decoded_size;
} break; } break;
} }
......
...@@ -195,7 +195,7 @@ int ServiceRequest::decodefrombuffer( ...@@ -195,7 +195,7 @@ int ServiceRequest::decodefrombuffer(
buf + decoded_size, len - decoded_size, false); buf + decoded_size, len - decoded_size, false);
uint8_t octet = *(buf + decoded_size); uint8_t octet = *(buf + decoded_size);
Logger::nas_mm().debug("First optional IE (0x%x)", octet); Logger::nas_mm().debug("First optional IE (0x%x)", octet);
while (!octet) { while (octet) {
switch (octet) { switch (octet) {
case 0x40: { case 0x40: {
Logger::nas_mm().debug("Decoding ie_uplink_data_status (IEI: 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