Commit 8a80517a authored by Robert Schmidt's avatar Robert Schmidt

Merge remote-tracking branch 'origin/fix-pdu-session-accept-cause' into integration_2023_w40

parents 0be397b2 4de550f0
...@@ -855,15 +855,6 @@ void flush_mem_to_file(void) ...@@ -855,15 +855,6 @@ void flush_mem_to_file(void)
} }
} }
const char logmem_log_level[NUM_LOG_LEVEL] = {
[OAILOG_ERR] = 'E',
[OAILOG_WARNING] = 'W',
[OAILOG_ANALYSIS] = 'A',
[OAILOG_INFO] = 'I',
[OAILOG_DEBUG] = 'D',
[OAILOG_TRACE] = 'T',
};
static void log_output_memory(log_component_t *c, const char *file, const char *func, int line, int comp, int level, const char* format,va_list args) static void log_output_memory(log_component_t *c, const char *file, const char *func, int line, int comp, int level, const char* format,va_list args)
{ {
//logRecord_mt(file,func,line, pthread_self(), comp, level, format, ##args) //logRecord_mt(file,func,line, pthread_self(), comp, level, format, ##args)
......
...@@ -27,46 +27,49 @@ ...@@ -27,46 +27,49 @@
extern char *baseNetAddress; extern char *baseNetAddress;
static uint16_t getShort(uint8_t *input)
{
uint16_t tmp16;
memcpy(&tmp16, input, sizeof(tmp16));
return htons(tmp16);
}
void capture_pdu_session_establishment_accept_msg(uint8_t *buffer, uint32_t msg_length) void capture_pdu_session_establishment_accept_msg(uint8_t *buffer, uint32_t msg_length)
{ {
uint8_t offset = 0;
security_protected_nas_5gs_msg_t sec_nas_hdr; security_protected_nas_5gs_msg_t sec_nas_hdr;
security_protected_plain_nas_5gs_msg_t sec_nas_msg; security_protected_plain_nas_5gs_msg_t sec_nas_msg;
pdu_session_establishment_accept_msg_t psea_msg; pdu_session_establishment_accept_msg_t psea_msg;
sec_nas_hdr.epd = *(buffer + (offset++)); uint8_t *curPtr = buffer;
sec_nas_hdr.sht = *(buffer + (offset++)); sec_nas_hdr.epd = *curPtr++;
sec_nas_hdr.sht = *curPtr++;
uint32_t tmp; uint32_t tmp;
memcpy(&tmp, buffer + offset, sizeof(tmp)); memcpy(&tmp, buffer, sizeof(tmp));
sec_nas_hdr.mac = htonl(tmp); sec_nas_hdr.mac = htonl(tmp);
offset+=sizeof(sec_nas_hdr.mac); curPtr += sizeof(sec_nas_hdr.mac);
sec_nas_hdr.sqn = *(buffer + (offset++)); sec_nas_hdr.sqn = *curPtr++;
sec_nas_msg.epd = *(buffer + (offset++)); sec_nas_msg.epd = *curPtr++;
sec_nas_msg.sht = *(buffer + (offset++)); sec_nas_msg.sht = *curPtr++;
sec_nas_msg.msg_type = *(buffer + (offset++)); sec_nas_msg.msg_type = *curPtr++;
sec_nas_msg.payload_type = *(buffer + (offset++)); sec_nas_msg.payload_type = *curPtr++;
uint16_t tmp16; sec_nas_msg.payload_len = getShort(curPtr);
memcpy(&tmp16, buffer + offset, sizeof(tmp16)); curPtr += sizeof(sec_nas_msg.payload_len);
sec_nas_msg.payload_len = htons(tmp16);
offset+=sizeof(sec_nas_msg.payload_len);
/* Mandatory Presence IEs */ /* Mandatory Presence IEs */
psea_msg.epd = *(buffer + (offset++)); psea_msg.epd = *curPtr++;
psea_msg.pdu_id = *(buffer + (offset++)); psea_msg.pdu_id = *curPtr++;
psea_msg.pti = *(buffer + (offset++)); psea_msg.pti = *curPtr++;
psea_msg.msg_type = *(buffer + (offset++)); psea_msg.msg_type = *curPtr++;
psea_msg.pdu_type = *(buffer + offset) & 0x0f; psea_msg.pdu_type = *curPtr & 0x0f;
psea_msg.ssc_mode = (*(buffer + (offset++)) & 0xf0) >> 4; psea_msg.ssc_mode = (*curPtr++ & 0xf0) >> 4;
memcpy(&tmp16, buffer + offset, sizeof(tmp16)); psea_msg.qos_rules.length = getShort(curPtr);
psea_msg.qos_rules.length = htons(tmp16); curPtr += sizeof(psea_msg.qos_rules.length);
offset+=sizeof(psea_msg.qos_rules.length);
/* Supports the capture of only one QoS Rule, it should be changed for multiple QoS Rules */ /* Supports the capture of only one QoS Rule, it should be changed for multiple QoS Rules */
qos_rule_t qos_rule; qos_rule_t qos_rule;
qos_rule.id = *(buffer + (offset++)); qos_rule.id = *curPtr++;
memcpy(&tmp16, buffer + offset, sizeof(tmp16)); qos_rule.length = getShort(curPtr);
qos_rule.length = htons(tmp16); curPtr += sizeof(qos_rule.length);
offset+=sizeof(qos_rule.length); qos_rule.oc = (*(curPtr)&0xE0) >> 5;
qos_rule.oc = (*(buffer + offset) & 0xE0) >> 5; qos_rule.dqr = (*(curPtr)&0x10) >> 4;
qos_rule.dqr = (*(buffer + offset) & 0x10) >> 4; qos_rule.nb_pf = *curPtr++ & 0x0F;
qos_rule.nb_pf = *(buffer + (offset++)) & 0x0F;
if(qos_rule.nb_pf) { if(qos_rule.nb_pf) {
packet_filter_t pf; packet_filter_t pf;
...@@ -74,40 +77,39 @@ void capture_pdu_session_establishment_accept_msg(uint8_t *buffer, uint32_t msg_ ...@@ -74,40 +77,39 @@ void capture_pdu_session_establishment_accept_msg(uint8_t *buffer, uint32_t msg_
if(qos_rule.oc == ROC_CREATE_NEW_QOS_RULE || if(qos_rule.oc == ROC_CREATE_NEW_QOS_RULE ||
qos_rule.oc == ROC_MODIFY_QOS_RULE_ADD_PF || qos_rule.oc == ROC_MODIFY_QOS_RULE_ADD_PF ||
qos_rule.oc == ROC_MODIFY_QOS_RULE_REPLACE_PF) { qos_rule.oc == ROC_MODIFY_QOS_RULE_REPLACE_PF) {
pf.pf_type.type_1.pf_dir = (*(buffer + offset) & 0x30) >> 4; pf.pf_type.type_1.pf_dir = (*curPtr & 0x30) >> 4;
pf.pf_type.type_1.pf_id = *(buffer + offset++) & 0x0F; pf.pf_type.type_1.pf_id = *curPtr++ & 0x0F;
pf.pf_type.type_1.length = *(buffer + offset++); pf.pf_type.type_1.length = *curPtr++;
offset += (qos_rule.nb_pf * pf.pf_type.type_1.length); /* Ommit the Packet filter List */ curPtr += (qos_rule.nb_pf * pf.pf_type.type_1.length); /* Ommit the Packet filter List */
} else if (qos_rule.oc == ROC_MODIFY_QOS_RULE_DELETE_PF) { } else if (qos_rule.oc == ROC_MODIFY_QOS_RULE_DELETE_PF) {
offset += qos_rule.nb_pf; curPtr += qos_rule.nb_pf;
} }
} }
qos_rule.prcd = *(buffer + offset++); qos_rule.prcd = *curPtr++;
qos_rule.qfi = *(buffer + offset++); qos_rule.qfi = *curPtr++;
psea_msg.sess_ambr.length = *(buffer + offset++); psea_msg.sess_ambr.length = *curPtr++;
offset += psea_msg.sess_ambr.length; /* Ommit the Seassion-AMBR */ curPtr += psea_msg.sess_ambr.length; /* Ommit the Seassion-AMBR */
/* Optional Presence IEs */ /* Optional Presence IEs */
uint8_t psea_iei = *(buffer + offset++); while (curPtr < buffer + msg_length) {
uint8_t psea_iei = *curPtr++;
while(offset < msg_length) {
switch (psea_iei) { switch (psea_iei) {
case IEI_5GSM_CAUSE: /* Ommited */ case IEI_5GSM_CAUSE: /* Ommited */
LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received 5GSM Cause IEI\n"); LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received 5GSM Cause IEI\n");
offset++; curPtr++;
break; break;
case IEI_PDU_ADDRESS: case IEI_PDU_ADDRESS:
LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received PDU Address IE\n"); LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received PDU Address IE\n");
psea_msg.pdu_addr_ie.pdu_length = *(buffer + offset++); psea_msg.pdu_addr_ie.pdu_length = *curPtr++;
psea_msg.pdu_addr_ie.pdu_type = *(buffer + offset++); psea_msg.pdu_addr_ie.pdu_type = *curPtr++;
if (psea_msg.pdu_addr_ie.pdu_type == PDU_SESSION_TYPE_IPV4) { if (psea_msg.pdu_addr_ie.pdu_type == PDU_SESSION_TYPE_IPV4) {
psea_msg.pdu_addr_ie.pdu_addr_oct1 = *(buffer + offset++); psea_msg.pdu_addr_ie.pdu_addr_oct1 = *curPtr++;
psea_msg.pdu_addr_ie.pdu_addr_oct2 = *(buffer + offset++); psea_msg.pdu_addr_ie.pdu_addr_oct2 = *curPtr++;
psea_msg.pdu_addr_ie.pdu_addr_oct3 = *(buffer + offset++); psea_msg.pdu_addr_ie.pdu_addr_oct3 = *curPtr++;
psea_msg.pdu_addr_ie.pdu_addr_oct4 = *(buffer + offset++); psea_msg.pdu_addr_ie.pdu_addr_oct4 = *curPtr++;
nas_getparams(); nas_getparams();
sprintf(baseNetAddress, "%d.%d", psea_msg.pdu_addr_ie.pdu_addr_oct1, psea_msg.pdu_addr_ie.pdu_addr_oct2); sprintf(baseNetAddress, "%d.%d", psea_msg.pdu_addr_ie.pdu_addr_oct1, psea_msg.pdu_addr_ie.pdu_addr_oct2);
nas_config(1, psea_msg.pdu_addr_ie.pdu_addr_oct3, psea_msg.pdu_addr_ie.pdu_addr_oct4, "oaitun_ue"); nas_config(1, psea_msg.pdu_addr_ie.pdu_addr_oct3, psea_msg.pdu_addr_ie.pdu_addr_oct4, "oaitun_ue");
...@@ -117,78 +119,68 @@ void capture_pdu_session_establishment_accept_msg(uint8_t *buffer, uint32_t msg_ ...@@ -117,78 +119,68 @@ void capture_pdu_session_establishment_accept_msg(uint8_t *buffer, uint32_t msg_
psea_msg.pdu_addr_ie.pdu_addr_oct3, psea_msg.pdu_addr_ie.pdu_addr_oct3,
psea_msg.pdu_addr_ie.pdu_addr_oct4); psea_msg.pdu_addr_ie.pdu_addr_oct4);
} else { } else {
offset += psea_msg.pdu_addr_ie.pdu_length; curPtr += psea_msg.pdu_addr_ie.pdu_length;
} }
psea_iei = *(buffer + offset++);
break; break;
case IEI_RQ_TIMER_VALUE: /* Ommited */ case IEI_RQ_TIMER_VALUE: /* Ommited */
LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received RQ timer value IE\n"); LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received RQ timer value IE\n");
offset++; /* TS 24.008 10.5.7.3 */ curPtr++; /* TS 24.008 10.5.7.3 */
psea_iei = *(buffer + offset++);
break; break;
case IEI_SNSSAI: /* Ommited */ case IEI_SNSSAI: /* Ommited */
LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received S-NSSAI IE\n"); LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received S-NSSAI IE\n");
uint8_t snssai_length = *(buffer + offset); uint8_t snssai_length = *curPtr;
offset += (snssai_length + sizeof(snssai_length)); curPtr += (snssai_length + sizeof(snssai_length));
psea_iei = *(buffer + offset++);
break; break;
case IEI_ALWAYSON_PDU: /* Ommited */ case IEI_ALWAYSON_PDU: /* Ommited */
LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received Always-on PDU Session indication IE\n"); LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received Always-on PDU Session indication IE\n");
offset++; curPtr++;
psea_iei = *(buffer + offset++);
break; break;
case IEI_MAPPED_EPS: /* Ommited */ case IEI_MAPPED_EPS: /* Ommited */
LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received Mapped EPS bearer context IE\n"); LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received Mapped EPS bearer context IE\n");
uint16_t mapped_eps_length = htons(*(uint16_t *)(buffer + offset)); uint16_t mapped_eps_length = getShort(curPtr);
offset += mapped_eps_length; curPtr += mapped_eps_length;
psea_iei = *(buffer + offset++);
break; break;
case IEI_EAP_MSG: /* Ommited */ case IEI_EAP_MSG: /* Ommited */
LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received EAP message IE\n"); LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received EAP message IE\n");
uint16_t eap_length = htons(*(uint16_t *)(buffer + offset)); uint16_t eap_length = getShort(curPtr);
offset += (eap_length + sizeof(eap_length)); curPtr += (eap_length + sizeof(eap_length));
psea_iei = *(buffer + offset++);
break; break;
case IEI_AUTH_QOS_DESC: /* Ommited */ case IEI_AUTH_QOS_DESC: /* Ommited */
LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received Authorized QoS flow descriptions IE\n"); LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received Authorized QoS flow descriptions IE\n");
psea_msg.qos_fd_ie.length = htons(*(uint16_t *)(buffer + offset)); psea_msg.qos_fd_ie.length = getShort(curPtr);
offset += (psea_msg.qos_fd_ie.length + sizeof(psea_msg.qos_fd_ie.length)); curPtr += (psea_msg.qos_fd_ie.length + sizeof(psea_msg.qos_fd_ie.length));
psea_iei = *(buffer + offset++);
break; break;
case IEI_EXT_CONF_OPT: /* Ommited */ case IEI_EXT_CONF_OPT: /* Ommited */
LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received Extended protocol configuration options IE\n"); LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received Extended protocol configuration options IE\n");
psea_msg.ext_pp_ie.length = htons(*(uint16_t *)(buffer + offset)); psea_msg.ext_pp_ie.length = getShort(curPtr);
offset += (psea_msg.ext_pp_ie.length + sizeof(psea_msg.ext_pp_ie.length )); curPtr += (psea_msg.ext_pp_ie.length + sizeof(psea_msg.ext_pp_ie.length));
psea_iei = *(buffer + offset++);
break; break;
case IEI_DNN: case IEI_DNN:
LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received DNN IE\n"); LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Received DNN IE\n");
psea_msg.dnn_ie.dnn_length = *(buffer + offset++); psea_msg.dnn_ie.dnn_length = *curPtr++;
char apn[APN_MAX_LEN]; char apn[APN_MAX_LEN];
if(psea_msg.dnn_ie.dnn_length <= APN_MAX_LEN && if(psea_msg.dnn_ie.dnn_length <= APN_MAX_LEN &&
psea_msg.dnn_ie.dnn_length >= APN_MIN_LEN) { psea_msg.dnn_ie.dnn_length >= APN_MIN_LEN) {
for (int i = 0 ; i < psea_msg.dnn_ie.dnn_length ; ++i) memcpy(apn, curPtr, psea_msg.dnn_ie.dnn_length);
apn[i] = *(buffer + offset + i);
LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - APN: %s\n", apn); LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - APN: %s\n", apn);
} else } else
LOG_E(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - DNN IE has invalid length\n"); LOG_E(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - DNN IE has invalid length\n");
offset = msg_length; curPtr = buffer + msg_length; // we force stop processing
break; break;
default: default:
LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Not known IE\n"); LOG_T(NAS, "PDU SESSION ESTABLISHMENT ACCEPT - Not known IE\n");
offset = msg_length; curPtr = buffer + msg_length; // we force stop processing
break; break;
} }
} }
......
...@@ -961,7 +961,7 @@ static int Gtpv1uHandleError(int h, ...@@ -961,7 +961,7 @@ static int Gtpv1uHandleError(int h,
uint32_t msgBufLen, uint32_t msgBufLen,
uint16_t peerPort, uint16_t peerPort,
uint32_t peerIp) { uint32_t peerIp) {
LOG_E(GTPU,"Hadle error to be dev\n"); LOG_E(GTPU, "Handle error to be dev\n");
int rc = GTPNOK; int rc = GTPNOK;
return rc; return rc;
} }
......
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