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.
This commit is contained in:
@@ -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 {
|
if (length < 10)
|
||||||
LOG_I(NAS, "[UE] Received invalid downlink message\n");
|
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user