Commit 4cc1bb54 authored by Cedric Roux's avatar Cedric Roux

nrUE NAS: hotfix for get_msg_type()

The version before this commit is wrong, taking wrong byte for msg_type
in some cases.

I don't have much time to implement a proper NAS PDU parser, so let's go
with hardcoded values.

Some later work will be done to have a cleaner solution. As of now, it's
too much work.
parent 6c42ea62
...@@ -894,30 +894,41 @@ static void generatePduSessionEstablishRequest(nr_ue_nas_t *nas, as_nas_info_t * ...@@ -894,30 +894,41 @@ static void generatePduSessionEstablishRequest(nr_ue_nas_t *nas, as_nas_info_t *
} }
uint8_t get_msg_type(uint8_t *pdu_buffer, uint32_t length) { static uint8_t get_msg_type(uint8_t *pdu_buffer, uint32_t length)
uint8_t msg_type = 0; {
uint8_t offset = 0; if (pdu_buffer == NULL)
goto error;
if ((pdu_buffer != NULL) && (length > 0)) { /* get security header type */
if (((nas_msg_header_t *)(pdu_buffer))->choice.security_protected_nas_msg_header_t.security_header_type > 0) { if (length < 2)
offset += SECURITY_PROTECTED_5GS_NAS_MESSAGE_HEADER_LENGTH; goto error;
if (offset < length) {
msg_type = ((mm_msg_header_t *)(pdu_buffer + offset))->message_type;
if (msg_type == FGS_DOWNLINK_NAS_TRANSPORT) { int security_header_type = pdu_buffer[1];
dl_nas_transport_t tmp;
memcpy(&tmp, pdu_buffer + offset, sizeof(tmp)); if (security_header_type == 0) {
msg_type = tmp.sm_nas_msg_header.message_type; /* plain NAS message */
} if (length < 3)
} goto error;
} else { // plain 5GS NAS message return pdu_buffer[2];
msg_type = ((nas_msg_header_t *)(pdu_buffer))->choice.plain_nas_msg_header.message_type;
} }
} else {
LOG_I(NAS, "[UE] Received invalid downlink message\n"); if (length < 10)
goto error;
int msg_type = pdu_buffer[9];
if (msg_type == FGS_DOWNLINK_NAS_TRANSPORT) {
if (length < 17)
goto error;
msg_type = pdu_buffer[16];
} }
return msg_type; return msg_type;
error:
LOG_E(NAS, "[UE] Received invalid downlink message\n");
return 0;
} }
static void send_nas_uplink_data_req(instance_t instance, const as_nas_info_t *initial_nas_msg) static void send_nas_uplink_data_req(instance_t instance, const as_nas_info_t *initial_nas_msg)
......
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