Commit 47faa845 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Code cleanup

parent 96bda27e
......@@ -68,7 +68,7 @@ uint8_t GPRS_Timer_3::getValue() {
//------------------------------------------------------------------------------
int GPRS_Timer_3::encode2buffer(uint8_t *buf, int len) {
Logger::nas_mm().debug("encoding GPRS_Timer_3 iei(0x%x)", _iei);
Logger::nas_mm().debug("Encoding GPRS_Timer_3 IEI (0x%x)", _iei);
if (len < 3) {
Logger::nas_mm().error("len is less than 3");
return 0;
......@@ -83,20 +83,20 @@ int GPRS_Timer_3::encode2buffer(uint8_t *buf, int len) {
encoded_size++;
*(buf + encoded_size) = octet;
encoded_size++;
Logger::nas_mm().debug("encoded GPRS_Timer_3 conent(0x%x)", octet);
Logger::nas_mm().debug("Encoded GPRS_Timer_3 content (0x%x)", octet);
} else {
*(buf + encoded_size) = 1;
encoded_size++;
*(buf + encoded_size) = octet;
encoded_size++;
}
Logger::nas_mm().debug("encoded GPRS_Timer_3 len(%d)", encoded_size);
Logger::nas_mm().debug("Encoded GPRS_Timer_3 len (%d)", encoded_size);
return encoded_size;
}
//------------------------------------------------------------------------------
int GPRS_Timer_3::decodefrombuffer(uint8_t *buf, int len, bool is_option) {
Logger::nas_mm().debug("decoding GPRS_Timer_3 iei(0x%x)", *buf);
Logger::nas_mm().debug("Decoding GPRS_Timer_3 IEI (0x%x)", *buf);
int decoded_size = 0;
if (is_option) {
_iei = *buf;
......@@ -109,8 +109,8 @@ int GPRS_Timer_3::decodefrombuffer(uint8_t *buf, int len, bool is_option) {
decoded_size++;
UNIT = (octet & 0xe0) >> 5;
_value = octet & 0x1f;
Logger::nas_mm().debug("decoded GPRS_Timer_3 conent(0x%x)", octet);
Logger::nas_mm().debug("decoded GPRS_Timer_3 len(%d)", decoded_size);
Logger::nas_mm().debug("Decoded GPRS_Timer_3 content (0x%x)", octet);
Logger::nas_mm().debug("Decoded GPRS_Timer_3 len (%d)", decoded_size);
return decoded_size;
}
......@@ -73,7 +73,7 @@ bool NSSAI::getValue(std::vector<struct SNSSAI_s> &nssai) {
//------------------------------------------------------------------------------
int NSSAI::encode2buffer(uint8_t *buf, int len) {
Logger::nas_mm().debug("encoding NSSAI iei(0x%x)", _iei);
Logger::nas_mm().debug("Encoding NSSAI IEI (0x%x)", _iei);
if (len < length) {
Logger::nas_mm().error("len is less than %d", length);
return 0;
......@@ -94,13 +94,13 @@ int NSSAI::encode2buffer(uint8_t *buf, int len) {
len_s_nssai += 3;
*(buf + encoded_size) = (S_NSSAI.at(i).sd & 0x00ff0000) >> 16;
encoded_size++;
Logger::nas_mm().debug("decoded NSSAI len(%x)", *(buf + encoded_size - 1));
Logger::nas_mm().debug("Encoded NSSAI len (%x)", *(buf + encoded_size - 1));
*(buf + encoded_size) = (S_NSSAI.at(i).sd & 0x0000ff00) >> 8;
encoded_size++;
Logger::nas_mm().debug("decoded NSSAI len(%x)", *(buf + encoded_size - 1));
Logger::nas_mm().debug("Encoded NSSAI len (%x)", *(buf + encoded_size - 1));
*(buf + encoded_size) = S_NSSAI.at(i).sd & 0x000000ff;
encoded_size++;
Logger::nas_mm().debug("decoded NSSAI len(%x)", *(buf + encoded_size - 1));
Logger::nas_mm().debug("Encoded NSSAI len (%x)", *(buf + encoded_size - 1));
}
if (S_NSSAI.at(i).mHplmnSst != -1) {
len_s_nssai += 1;
......@@ -122,13 +122,13 @@ int NSSAI::encode2buffer(uint8_t *buf, int len) {
// *(buf + encoded_size) = length - 1; encoded_size++;
// *(buf + encoded_size) = _value; encoded_size++; encoded_size++;
}
Logger::nas_mm().debug("encoded NSSAI len(%d)", encoded_size);
Logger::nas_mm().debug("Encoded NSSAI len (%d)", encoded_size);
return encoded_size;
}
//------------------------------------------------------------------------------
int NSSAI::decodefrombuffer(uint8_t *buf, int len, bool is_option) {
Logger::nas_mm().debug("decoding NSSAI iei(0x%x)", *buf);
Logger::nas_mm().debug("Decoding NSSAI IEI (0x%x)", *buf);
int decoded_size = 0;
SNSSAI_s a = { 0, 0, 0, 0 };
if (is_option) {
......@@ -136,15 +136,15 @@ int NSSAI::decodefrombuffer(uint8_t *buf, int len, bool is_option) {
}
length = *(buf + decoded_size);
decoded_size++;
int LEAGTH = length;
while (LEAGTH) {
int length_tmp = length;
while (length_tmp) {
switch (*(buf + decoded_size)) {
case 1: {
decoded_size++; //snssai—leagth
LEAGTH--;
length_tmp--;
a.sst = *(buf + decoded_size);
decoded_size++; //无 sd
LEAGTH--;
decoded_size++;
length_tmp--;
a.sd = -1;
a.mHplmnSst = -1;
a.mHplmnSd = -1;
......@@ -152,79 +152,79 @@ int NSSAI::decodefrombuffer(uint8_t *buf, int len, bool is_option) {
break;
case 4: {
decoded_size++;
LEAGTH--;
length_tmp--;
a.sst = *(buf + decoded_size);
decoded_size++;
LEAGTH--;
length_tmp--;
a.sd |= *(buf + decoded_size);
decoded_size++;
LEAGTH--; //有 sd
length_tmp--;
a.sd << 8;
a.sd |= *(buf + decoded_size);
decoded_size++;
LEAGTH--; //有 sd
length_tmp--;
a.sd << 8;
a.sd |= *(buf + decoded_size);
decoded_size++;
LEAGTH--; //有 sd
length_tmp--;
a.mHplmnSst = -1;
a.mHplmnSd = -1;
}
break;
case 5: {
decoded_size++;
LEAGTH--;
length_tmp--;
a.sst = *(buf + decoded_size);
decoded_size++;
LEAGTH--;
length_tmp--;
a.sd |= *(buf + decoded_size);
decoded_size++;
LEAGTH--; //有 sd
length_tmp--;
a.sd << 8;
a.sd |= *(buf + decoded_size);
decoded_size++;
LEAGTH--; //有 sd
length_tmp--;
a.sd << 8;
a.sd |= *(buf + decoded_size);
decoded_size++;
LEAGTH--; //有 sd
length_tmp--;
a.mHplmnSst = *(buf + decoded_size);
decoded_size++;
LEAGTH--;
length_tmp--;
a.mHplmnSd = -1;
}
break;
case 8: {
decoded_size++;
LEAGTH--;
length_tmp--;
a.sst = *(buf + decoded_size);
decoded_size++;
LEAGTH--;
length_tmp--;
a.sd |= *(buf + decoded_size);
decoded_size++;
LEAGTH--; //有 sd
length_tmp--;
a.sd << 8;
a.sd |= *(buf + decoded_size);
decoded_size++;
LEAGTH--; //有 sd
length_tmp--;
a.sd << 8;
a.sd |= *(buf + decoded_size);
decoded_size++;
LEAGTH--; //有 sd
length_tmp--;
a.mHplmnSst = *(buf + decoded_size);
decoded_size++;
LEAGTH--;
length_tmp--;
a.mHplmnSd |= *(buf + decoded_size);
decoded_size++;
LEAGTH--; //有 sd
length_tmp--;
a.mHplmnSd << 16;
a.mHplmnSd |= *(buf + decoded_size);
decoded_size++;
LEAGTH--; //有 sd
length_tmp--;
a.mHplmnSd << 8;
a.mHplmnSd |= *(buf + decoded_size);
decoded_size++;
LEAGTH--; //有 sd
length_tmp--;
}
break;
}
......@@ -234,9 +234,9 @@ int NSSAI::decodefrombuffer(uint8_t *buf, int len, bool is_option) {
}
for (int i = 0; i < S_NSSAI.size(); i++) {
Logger::nas_mm().debug("decoded NSSAI SST(0x%x) SD(0x%x) hplmnSST(0x%x) hplmnSD(%d)", S_NSSAI.at(i).sst, S_NSSAI.at(i).sd, S_NSSAI.at(i).mHplmnSst, S_NSSAI.at(i).mHplmnSd);
Logger::nas_mm().debug("Decoded NSSAI SST (0x%x) SD (0x%x) hplmnSST (0x%x) hplmnSD (%d)", S_NSSAI.at(i).sst, S_NSSAI.at(i).sd, S_NSSAI.at(i).mHplmnSst, S_NSSAI.at(i).mHplmnSd);
}
Logger::nas_mm().debug("decoded NSSAI len(%d)", decoded_size);
Logger::nas_mm().debug("Decoded NSSAI len (%d)", decoded_size);
return decoded_size;
}
......@@ -114,8 +114,7 @@ int UESecurityCapability::decodefrombuffer(uint8_t *buf, int len, bool is_option
decoded_size++;
_5g_IASel = *(buf + decoded_size);
decoded_size++;
Logger::nas_mm().debug("Decoded UESecurityCapability EA 0x%d,IA 0x%d", _5g_EASel, _5g_IASel);
Logger::nas_mm().debug("Decoded UESecurityCapability (len %d)", decoded_size);
Logger::nas_mm().debug("UESecurityCapability EA 0x%d,IA 0x%d", _5g_EASel, _5g_IASel);
return decoded_size;
}
......@@ -61,7 +61,7 @@ uint8_t _5GS_Network_Feature_Support::getValue() {
//------------------------------------------------------------------------------
int _5GS_Network_Feature_Support::encode2buffer(uint8_t *buf, int len) {
Logger::nas_mm().debug("encoding _5GS_Network_Feature_Support iei(0x%x)", _iei);
Logger::nas_mm().debug("Encoding _5GS_Network_Feature_Support IEI (0x%x)", _iei);
if (len < length) {
Logger::nas_mm().error("len is less than %d", length);
return 0;
......@@ -82,13 +82,13 @@ int _5GS_Network_Feature_Support::encode2buffer(uint8_t *buf, int len) {
// *(buf + encoded_size) = _5g_EASel; encoded_size++;
// *(buf + encoded_size) = _5g_IASel; encoded_size++;
}
Logger::nas_mm().debug("encoded _5GS_Network_Feature_Support len(%d)", encoded_size);
Logger::nas_mm().debug("Encoded _5GS_Network_Feature_Support len (%d)", encoded_size);
return encoded_size;
}
//------------------------------------------------------------------------------
int _5GS_Network_Feature_Support::decodefrombuffer(uint8_t *buf, int len, bool is_option) {
Logger::nas_mm().debug("decoding _5GS_Network_Feature_Support iei(0x%x)", *buf);
Logger::nas_mm().debug("Decoding _5GS_Network_Feature_Support IEI (0x%x)", *buf);
int decoded_size = 0;
if (is_option) {
decoded_size++;
......@@ -97,8 +97,8 @@ int _5GS_Network_Feature_Support::decodefrombuffer(uint8_t *buf, int len, bool i
decoded_size++;
_value = *(buf + decoded_size);
decoded_size++;
Logger::nas_mm().debug("decoded _5GS_Network_Feature_Support value(0x%x)", _value);
Logger::nas_mm().debug("decoded _5GS_Network_Feature_Support len(%d)", decoded_size);
Logger::nas_mm().debug("Decoded _5GS_Network_Feature_Support value (0x%x)", _value);
Logger::nas_mm().debug("Decoded _5GS_Network_Feature_Support len (%d)", decoded_size);
return decoded_size;
}
......@@ -82,14 +82,14 @@ int AuthenticationFailure::encode2buffer(uint8_t *buf, int len) {
Logger::nas_mm().debug("encoding AuthenticationFailure message");
int encoded_size = 0;
if (!plain_header) {
Logger::nas_mm().error("Mandontary IE missing Header");
Logger::nas_mm().error("Mandatory IE missing Header");
return 0;
}
if (!(plain_header->encode2buffer(buf, len)))
return 0;
encoded_size += 3;
if (!ie_5gmm_cause) {
Logger::nas_mm().warn("IE ie_5gmm_cause is not avaliable");
Logger::nas_mm().warn("IE ie_5gmm_cause is not available");
} else {
if (int size = ie_5gmm_cause->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......@@ -98,7 +98,7 @@ int AuthenticationFailure::encode2buffer(uint8_t *buf, int len) {
}
}
if (!ie_authentication_failure_parameter) {
Logger::nas_mm().warn("IE ie_authentication_failure_parameter is not avaliable");
Logger::nas_mm().warn("IE ie_authentication_failure_parameter is not available");
} else {
if (int size = ie_authentication_failure_parameter->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......
......@@ -59,14 +59,14 @@ int AuthenticationReject::encode2buffer(uint8_t *buf, int len) {
Logger::nas_mm().debug("encoding AuthenticationReject message");
int encoded_size = 0;
if (!plain_header) {
Logger::nas_mm().error("Mandontary IE missing Header");
Logger::nas_mm().error("Mandatory IE missing Header");
return 0;
}
if (!(plain_header->encode2buffer(buf, len)))
return 0;
encoded_size += 3;
if (!ie_eap_message) {
Logger::nas_mm().warn("IE ie_eap_message is not avaliable");
Logger::nas_mm().warn("IE ie_eap_message is not available");
} else {
if (int size = ie_eap_message->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......
......@@ -85,14 +85,14 @@ int AuthenticationResponse::encode2buffer(uint8_t *buf, int len) {
Logger::nas_mm().debug("encoding AuthenticationResponse message");
int encoded_size = 0;
if (!plain_header) {
Logger::nas_mm().error("Mandontary IE missing Header");
Logger::nas_mm().error("Mandatory IE missing Header");
return 0;
}
if (!(plain_header->encode2buffer(buf, len)))
return 0;
encoded_size += 3;
if (!ie_authentication_response_parameter) {
Logger::nas_mm().warn("IE ie_authentication_response_parameter is not avaliable");
Logger::nas_mm().warn("IE ie_authentication_response_parameter is not available");
} else {
if (int size = ie_authentication_response_parameter->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......@@ -102,7 +102,7 @@ int AuthenticationResponse::encode2buffer(uint8_t *buf, int len) {
}
}
if (!ie_eap_message) {
Logger::nas_mm().warn("IE ie_eap_message is not avaliable");
Logger::nas_mm().warn("IE ie_eap_message is not available");
} else {
if (int size = ie_eap_message->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......
......@@ -71,14 +71,14 @@ int AuthenticationResult::encode2buffer(uint8_t *buf, int len) {
Logger::nas_mm().debug("encoding AuthenticationResult message");
int encoded_size = 0;
if (!plain_header) {
Logger::nas_mm().error("Mandontary IE missing Header");
Logger::nas_mm().error("Mandatory IE missing Header");
return 0;
}
if (!(plain_header->encode2buffer(buf, len)))
return 0;
encoded_size += 3;
if (!ie_ngKSI) {
Logger::nas_mm().warn("IE ie_ngKSI is not avaliable");
Logger::nas_mm().warn("IE ie_ngKSI is not available");
} else {
if (int size = ie_ngKSI->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......@@ -88,7 +88,7 @@ int AuthenticationResult::encode2buffer(uint8_t *buf, int len) {
}
}
if (!ie_eap_message) {
Logger::nas_mm().warn("IE ie_eap_message is not avaliable");
Logger::nas_mm().warn("IE ie_eap_message is not available");
} else {
if (int size = ie_eap_message->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......@@ -98,7 +98,7 @@ int AuthenticationResult::encode2buffer(uint8_t *buf, int len) {
}
}
if (!ie_abba) {
Logger::nas_mm().warn("IE ie_abba is not avaliable");
Logger::nas_mm().warn("IE ie_abba is not available");
} else {
if (int size = ie_abba->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......
......@@ -96,14 +96,14 @@ int DLNASTransport::encode2buffer(uint8_t *buf, int len) {
Logger::nas_mm().debug("encoding DLNASTransport message");
int encoded_size = 0;
if (!plain_header) {
Logger::nas_mm().error("Mandontary IE missing Header");
Logger::nas_mm().error("Mandatory IE missing Header");
return 0;
}
if (!(plain_header->encode2buffer(buf, len)))
return 0;
encoded_size += 3;
if (!ie_payload_container_type) {
Logger::nas_mm().warn("IE ie_payload_container_type is not avaliable");
Logger::nas_mm().warn("IE ie_payload_container_type is not available");
} else {
if (int size = ie_payload_container_type->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......@@ -113,7 +113,7 @@ int DLNASTransport::encode2buffer(uint8_t *buf, int len) {
}
}
if (!ie_payload_container) {
Logger::nas_mm().warn("IE ie_payload_container is not avaliable");
Logger::nas_mm().warn("IE ie_payload_container is not available");
} else {
if (int size = ie_payload_container->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......@@ -123,7 +123,7 @@ int DLNASTransport::encode2buffer(uint8_t *buf, int len) {
}
}
if (!ie_pdu_session_identity_2) {
Logger::nas_mm().warn("IE ie_pdu_session_identity_2 is not avaliable");
Logger::nas_mm().warn("IE ie_pdu_session_identity_2 is not available");
} else {
if (int size = ie_pdu_session_identity_2->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......@@ -134,7 +134,7 @@ int DLNASTransport::encode2buffer(uint8_t *buf, int len) {
}
if (!ie_additional_information) {
Logger::nas_mm().warn("IE ie_additional_information is not avaliable");
Logger::nas_mm().warn("IE ie_additional_information is not available");
} else {
if (int size = ie_additional_information->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......@@ -145,7 +145,7 @@ int DLNASTransport::encode2buffer(uint8_t *buf, int len) {
}
if (!ie_5gmm_cause) {
Logger::nas_mm().warn("IE ie_5gmm_cause is not avaliable");
Logger::nas_mm().warn("IE ie_5gmm_cause is not available");
} else {
if (int size = ie_5gmm_cause->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......@@ -154,7 +154,7 @@ int DLNASTransport::encode2buffer(uint8_t *buf, int len) {
}
}
if (!ie_back_off_timer_value) {
Logger::nas_mm().warn("IE ie_back_off_timer_value is not avaliable");
Logger::nas_mm().warn("IE ie_back_off_timer_value is not available");
} else {
if (int size = ie_back_off_timer_value->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......
......@@ -59,14 +59,14 @@ int IdentityRequest::encode2buffer(uint8_t *buf, int len) {
Logger::nas_mm().debug("encoding IdentityRequest message");
int encoded_size = 0;
if (!plain_header) {
Logger::nas_mm().error("Mandontary IE missing Header");
Logger::nas_mm().error("Mandatory IE missing Header");
return 0;
}
if (!(plain_header->encode2buffer(buf, len)))
return 0;
encoded_size += 3;
if (!_5gs_identity_type) {
Logger::nas_mm().warn("IE _5gs_identity_type is not avaliable");
Logger::nas_mm().warn("IE _5gs_identity_type is not available");
} else {
if (int size = _5gs_identity_type->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......
......@@ -80,14 +80,14 @@ int IdentityResponse::encode2buffer(uint8_t *buf, int len) {
Logger::nas_mm().debug("encoding IdentityResponse message");
int encoded_size = 0;
if (!plain_header) {
Logger::nas_mm().error("Mandontary IE missing Header");
Logger::nas_mm().error("Mandatory IE missing Header");
return 0;
}
if (!(plain_header->encode2buffer(buf, len)))
return 0;
encoded_size += 3;
if (!ie_mobility_id) {
Logger::nas_mm().warn("IE ie_mobility_id is not avaliable");
Logger::nas_mm().warn("IE ie_mobility_id is not available");
} else {
if (int size = ie_mobility_id->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......
This diff is collapsed.
......@@ -59,14 +59,14 @@ int RegistrationComplete::encode2buffer(uint8_t *buf, int len) {
Logger::nas_mm().debug("encoding RegistrationComplete message");
int encoded_size = 0;
if (!plain_header) {
Logger::nas_mm().error("Mandontary IE missing Header");
Logger::nas_mm().error("Mandatory IE missing Header");
return 0;
}
if (!(plain_header->encode2buffer(buf, len)))
return 0;
encoded_size += 3;
if (!ie_sor_transparent_container) {
Logger::nas_mm().warn("IE ie_sor_transparent_container is not avaliable");
Logger::nas_mm().warn("IE ie_sor_transparent_container is not available");
} else {
if (int size = ie_sor_transparent_container->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......
......@@ -83,14 +83,14 @@ int RegistrationReject::encode2buffer(uint8_t *buf, int len) {
Logger::nas_mm().debug("encoding RegistrationReject message");
int encoded_size = 0;
if (!plain_header) {
Logger::nas_mm().error("Mandontary IE missing Header");
Logger::nas_mm().error("Mandatory IE missing Header");
return 0;
}
if (!(plain_header->encode2buffer(buf, len)))
return 0;
encoded_size += 3;
if (!ie_5gmm_cause) {
Logger::nas_mm().warn("IE ie_5gmm_cause is not avaliable");
Logger::nas_mm().warn("IE ie_5gmm_cause is not available");
} else {
if (int size = ie_5gmm_cause->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......@@ -99,7 +99,7 @@ int RegistrationReject::encode2buffer(uint8_t *buf, int len) {
}
}
if (!ie_T3346_value) {
Logger::nas_mm().warn("IE ie_T3346_value is not avaliable");
Logger::nas_mm().warn("IE ie_T3346_value is not available");
} else {
if (int size = ie_T3346_value->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......@@ -109,7 +109,7 @@ int RegistrationReject::encode2buffer(uint8_t *buf, int len) {
}
}
if (!ie_T3502_value) {
Logger::nas_mm().warn("IE ie_T3502_value is not avaliable");
Logger::nas_mm().warn("IE ie_T3502_value is not available");
} else {
if (int size = ie_T3502_value->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......@@ -119,7 +119,7 @@ int RegistrationReject::encode2buffer(uint8_t *buf, int len) {
}
}
if (!ie_eap_message) {
Logger::nas_mm().warn("IE ie_eap_message is not avaliable");
Logger::nas_mm().warn("IE ie_eap_message is not available");
} else {
if (int size = ie_eap_message->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......@@ -129,7 +129,7 @@ int RegistrationReject::encode2buffer(uint8_t *buf, int len) {
}
}
if (!ie_rejected_nssai) {
Logger::nas_mm().warn("IE ie_rejected_nssai is not avaliable");
Logger::nas_mm().warn("IE ie_rejected_nssai is not available");
} else {
if (int size = ie_rejected_nssai->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......
This diff is collapsed.
......@@ -106,14 +106,14 @@ int SecurityModeCommand::encode2buffer(uint8_t *buf, int len) {
Logger::nas_mm().debug("encoding SecurityModeCommand message");
int encoded_size = 0;
if (!plain_header) {
Logger::nas_mm().error("Mandontary IE missing Header");
Logger::nas_mm().error("Mandatory IE missing Header");
return 0;
}
if (!(plain_header->encode2buffer(buf, len)))
return 0;
encoded_size += 3;
if (!ie_selected_nas_security_algorithms) {
Logger::nas_mm().warn("IE ie_selected_nas_security_algorithms is not avaliable");
Logger::nas_mm().warn("IE ie_selected_nas_security_algorithms is not available");
} else {
if (int size = ie_selected_nas_security_algorithms->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......@@ -123,7 +123,7 @@ int SecurityModeCommand::encode2buffer(uint8_t *buf, int len) {
}
}
if (!ie_ngKSI) {
Logger::nas_mm().warn("IE ie_ngKSI is not avaliable");
Logger::nas_mm().warn("IE ie_ngKSI is not available");
} else {
if (int size = ie_ngKSI->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......@@ -133,7 +133,7 @@ int SecurityModeCommand::encode2buffer(uint8_t *buf, int len) {
}
}
if (!ie_ue_security_capability) {
Logger::nas_mm().warn("IE ie_ue_security_capability is not avaliable");
Logger::nas_mm().warn("IE ie_ue_security_capability is not available");
} else {
if (int size = ie_ue_security_capability->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......@@ -143,7 +143,7 @@ int SecurityModeCommand::encode2buffer(uint8_t *buf, int len) {
}
}
if (!ie_imeisv_request) {
Logger::nas_mm().warn("IE ie_imeisv_request is not avaliable");
Logger::nas_mm().warn("IE ie_imeisv_request is not available");
} else {
if (int size = ie_imeisv_request->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......@@ -153,7 +153,7 @@ int SecurityModeCommand::encode2buffer(uint8_t *buf, int len) {
}
}
if (!ie_eps_nas_security_algorithms) {
Logger::nas_mm().warn("IE ie_eps_nas_security_algorithms is not avaliable");
Logger::nas_mm().warn("IE ie_eps_nas_security_algorithms is not available");
} else {
if (int size = ie_eps_nas_security_algorithms->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......@@ -163,7 +163,7 @@ int SecurityModeCommand::encode2buffer(uint8_t *buf, int len) {
}
}
if (!ie_additional_5G_security_information) {
Logger::nas_mm().warn("IE ie_additional_5G_security_information is not avaliable");
Logger::nas_mm().warn("IE ie_additional_5G_security_information is not available");
} else {
if (int size = ie_additional_5G_security_information->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......@@ -173,7 +173,7 @@ int SecurityModeCommand::encode2buffer(uint8_t *buf, int len) {
}
}
if (!ie_eap_message) {
Logger::nas_mm().warn("IE ie_eap_message is not avaliable");
Logger::nas_mm().warn("IE ie_eap_message is not available");
} else {
if (int size = ie_eap_message->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......@@ -183,7 +183,7 @@ int SecurityModeCommand::encode2buffer(uint8_t *buf, int len) {
}
}
if (!ie_abba) {
Logger::nas_mm().warn("IE ie_abba is not avaliable");
Logger::nas_mm().warn("IE ie_abba is not available");
} else {
if (int size = ie_abba->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......@@ -193,7 +193,7 @@ int SecurityModeCommand::encode2buffer(uint8_t *buf, int len) {
}
}
if (!ie_s1_ue_security_capability) {
Logger::nas_mm().warn("IE ie_s1_ue_security_capability is not avaliable");
Logger::nas_mm().warn("IE ie_s1_ue_security_capability is not available");
} else {
if (int size = ie_s1_ue_security_capability->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......
......@@ -106,14 +106,14 @@ int SecurityModeComplete::encode2buffer(uint8_t *buf, int len) {
Logger::nas_mm().debug("encoding SecurityModeComplete message");
int encoded_size = 0;
if (!plain_header) {
Logger::nas_mm().error("Mandontary IE missing Header");
Logger::nas_mm().error("Mandatory IE missing Header");
return 0;
}
if (!(plain_header->encode2buffer(buf, len)))
return 0;
encoded_size += 3;
if (!ie_imeisv) {
Logger::nas_mm().warn("IE ie_imeisv is not avaliable");
Logger::nas_mm().warn("IE ie_imeisv is not available");
} else {
if (int size = ie_imeisv->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......@@ -124,7 +124,7 @@ int SecurityModeComplete::encode2buffer(uint8_t *buf, int len) {
}
if (!ie_nas_message_container) {
Logger::nas_mm().warn("IE ie_nas_message_container is not avaliable");
Logger::nas_mm().warn("IE ie_nas_message_container is not available");
} else {
if (int size = ie_nas_message_container->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......@@ -134,7 +134,7 @@ int SecurityModeComplete::encode2buffer(uint8_t *buf, int len) {
}
}
if (!ie_non_imeisvpei) {
Logger::nas_mm().warn("IE ie_non_imeisvpei is not avaliable");
Logger::nas_mm().warn("IE ie_non_imeisvpei is not available");
} else {
if (int size = ie_non_imeisvpei->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......
......@@ -59,14 +59,14 @@ int SecurityModeReject::encode2buffer(uint8_t *buf, int len) {
Logger::nas_mm().debug("encoding SecurityModeReject message");
int encoded_size = 0;
if (!plain_header) {
Logger::nas_mm().error("Mandontary IE missing Header");
Logger::nas_mm().error("Mandatory IE missing Header");
return 0;
}
if (!(plain_header->encode2buffer(buf, len)))
return 0;
encoded_size += 3;
if (!ie_5gmm_cause) {
Logger::nas_mm().warn("IE ie_5gmm_cause is not avaliable");
Logger::nas_mm().warn("IE ie_5gmm_cause is not available");
} else {
if (int size = ie_5gmm_cause->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......
......@@ -86,19 +86,19 @@ int ServiceRequest::encode2buffer(uint8_t *buf, int len) {
Logger::nas_mm().debug("encoding ServiceRequest message...");
int encoded_size = 0;
if (!plain_header) {
Logger::nas_mm().error("Mandontary IE missing Header");
Logger::nas_mm().error("Mandatory IE missing Header");
return 0;
}
if (!ie_ngKSI) {
Logger::nas_mm().error("Mandontary IE missing ie_ngKSI");
Logger::nas_mm().error("Mandatory IE missing ie_ngKSI");
return 0;
}
if (!ie_service_type) {
Logger::nas_mm().error("Mandontary IE missing ie_service_type");
Logger::nas_mm().error("Mandatory IE missing ie_service_type");
return 0;
}
if (!ie_5g_s_tmsi) {
Logger::nas_mm().error("Mandontary IE missing ie_5g_s_tmsi");
Logger::nas_mm().error("Mandatory IE missing ie_5g_s_tmsi");
return 0;
}
if (!(plain_header->encode2buffer(buf, len)))
......@@ -123,7 +123,7 @@ int ServiceRequest::encode2buffer(uint8_t *buf, int len) {
return 0;
}
if (!ie_uplink_data_status) {
Logger::nas_mm().warn("IE ie_uplink_data_status is not avaliable");
Logger::nas_mm().warn("IE ie_uplink_data_status is not available");
} else {
size = ie_uplink_data_status->encode2buffer(buf + encoded_size, len - encoded_size);
if (size != 0) {
......@@ -134,7 +134,7 @@ int ServiceRequest::encode2buffer(uint8_t *buf, int len) {
}
}
if (!ie_PDU_session_status) {
Logger::nas_mm().warn("IE ie_PDU_session_status is not avaliable");
Logger::nas_mm().warn("IE ie_PDU_session_status is not available");
} else {
size = ie_PDU_session_status->encode2buffer(buf + encoded_size, len - encoded_size);
if (size != 0) {
......@@ -145,7 +145,7 @@ int ServiceRequest::encode2buffer(uint8_t *buf, int len) {
}
}
if (!ie_allowed_PDU_session_status) {
Logger::nas_mm().warn("IE ie_allowed_PDU_session_status is not avaliable");
Logger::nas_mm().warn("IE ie_allowed_PDU_session_status is not available");
} else {
size = ie_allowed_PDU_session_status->encode2buffer(buf + encoded_size, len - encoded_size);
if (size != 0) {
......@@ -156,7 +156,7 @@ int ServiceRequest::encode2buffer(uint8_t *buf, int len) {
}
}
if (!ie_nas_message_container) {
Logger::nas_mm().warn("IE ie_nas_message_container is not avaliable");
Logger::nas_mm().warn("IE ie_nas_message_container is not available");
} else {
size = ie_nas_message_container->encode2buffer(buf + encoded_size, len - encoded_size);
if (size != 0) {
......
......@@ -34,7 +34,6 @@ using namespace nas;
//------------------------------------------------------------------------------
ULNASTransport::ULNASTransport() {
Logger::nas_mm().debug("initiating class ULNASTransport");
plain_header = NULL;
ie_payload_container_type = NULL;
ie_payload_container = NULL;
......@@ -183,14 +182,14 @@ int ULNASTransport::encode2buffer(uint8_t *buf, int len) {
Logger::nas_mm().debug("encoding ULNASTransport message");
int encoded_size = 0;
if (!plain_header) {
Logger::nas_mm().error("Mandontary IE missing Header");
Logger::nas_mm().error("Mandatory IE missing Header");
return 0;
}
if (!(plain_header->encode2buffer(buf, len)))
return 0;
encoded_size += 3;
if (!ie_payload_container_type) {
Logger::nas_mm().warn("IE ie_payload_container_type is not avaliable");
Logger::nas_mm().warn("IE ie_payload_container_type is not available");
} else {
if (int size = ie_payload_container_type->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......@@ -200,7 +199,7 @@ int ULNASTransport::encode2buffer(uint8_t *buf, int len) {
}
}
if (!ie_payload_container) {
Logger::nas_mm().warn("IE ie_payload_container is not avaliable");
Logger::nas_mm().warn("IE ie_payload_container is not available");
} else {
if (int size = ie_payload_container->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......@@ -210,7 +209,7 @@ int ULNASTransport::encode2buffer(uint8_t *buf, int len) {
}
}
if (!ie_pdu_session_identity_2) {
Logger::nas_mm().warn("IE ie_pdu_session_identity_2 is not avaliable");
Logger::nas_mm().warn("IE ie_pdu_session_identity_2 is not available");
} else {
if (int size = ie_pdu_session_identity_2->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......@@ -221,7 +220,7 @@ int ULNASTransport::encode2buffer(uint8_t *buf, int len) {
}
if (!ie_old_pdu_session_identity_2) {
Logger::nas_mm().warn("IE ie_old_pdu_session_identity_2 is not avaliable");
Logger::nas_mm().warn("IE ie_old_pdu_session_identity_2 is not available");
} else {
if (int size = ie_old_pdu_session_identity_2->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......@@ -232,7 +231,7 @@ int ULNASTransport::encode2buffer(uint8_t *buf, int len) {
}
if (!ie_request_type) {
Logger::nas_mm().warn("IE ie_request_type is not avaliable");
Logger::nas_mm().warn("IE ie_request_type is not available");
} else {
if (int size = ie_request_type->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......@@ -243,7 +242,7 @@ int ULNASTransport::encode2buffer(uint8_t *buf, int len) {
}
if (!ie_s_nssai) {
Logger::nas_mm().warn("IE ie_s_nssai is not avaliable");
Logger::nas_mm().warn("IE ie_s_nssai is not available");
} else {
if (int size = ie_s_nssai->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......@@ -254,7 +253,7 @@ int ULNASTransport::encode2buffer(uint8_t *buf, int len) {
}
if (!ie_dnn) {
Logger::nas_mm().warn("IE ie_dnn is not avaliable");
Logger::nas_mm().warn("IE ie_dnn is not available");
} else {
if (int size = ie_dnn->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......@@ -265,7 +264,7 @@ int ULNASTransport::encode2buffer(uint8_t *buf, int len) {
}
if (!ie_additional_information) {
Logger::nas_mm().warn("IE ie_additional_information is not avaliable");
Logger::nas_mm().warn("IE ie_additional_information is not available");
} else {
if (int size = ie_additional_information->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......@@ -276,7 +275,7 @@ int ULNASTransport::encode2buffer(uint8_t *buf, int len) {
}
if (!ie_ma_pdu_session_information) {
Logger::nas_mm().warn("IE ie_ma_pdu_session_information is not avaliable");
Logger::nas_mm().warn("IE ie_ma_pdu_session_information is not available");
} else {
if (int size = ie_ma_pdu_session_information->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......@@ -287,7 +286,7 @@ int ULNASTransport::encode2buffer(uint8_t *buf, int len) {
}
if (!ie_release_assistance_indication) {
Logger::nas_mm().warn("IE ie_release_assistance_indication is not avaliable");
Logger::nas_mm().warn("IE ie_release_assistance_indication is not available");
} else {
if (int size = ie_release_assistance_indication->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
......@@ -303,82 +302,82 @@ int ULNASTransport::encode2buffer(uint8_t *buf, int len) {
//------------------------------------------------------------------------------
int ULNASTransport::decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf, int len) {
Logger::nas_mm().debug("decoding ULNASTransport message");
Logger::nas_mm().debug("Decoding ULNASTransport message");
int decoded_size = 3;
plain_header = header;
ie_payload_container_type = new Payload_Container_Type();
decoded_size += ie_payload_container_type->decodefrombuffer(buf + decoded_size, len - decoded_size, false);
ie_payload_container = new Payload_Container();
decoded_size += ie_payload_container->decodefrombuffer(buf + decoded_size, len - decoded_size, false, ie_payload_container_type->getValue());
Logger::nas_mm().debug("decoded_size(%d)", decoded_size);
Logger::nas_mm().debug("Decoded_size (%d)", decoded_size);
uint8_t octet = *(buf + decoded_size);
Logger::nas_mm().debug("first option iei(0x%x)", octet);
Logger::nas_mm().debug("First option IEI (0x%x)", octet);
while ((octet != 0x0)) {
switch ((octet & 0xf0) >> 4) {
case 0x8: {
Logger::nas_mm().debug("decoding iei(0x8)");
Logger::nas_mm().debug("Decoding IEI (0x8)");
ie_request_type = new Request_Type();
decoded_size += ie_request_type->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("next iei(0x%x)", octet);
Logger::nas_mm().debug("Next IEI (0x%x)", octet);
}
break;
case 0xA: {
Logger::nas_mm().debug("decoding iei(0xA)");
Logger::nas_mm().debug("Decoding IEI (0xA)");
ie_ma_pdu_session_information = new MA_PDU_Session_Information();
decoded_size += ie_ma_pdu_session_information->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("next iei(0x%x)", octet);
Logger::nas_mm().debug("Next IEI (0x%x)", octet);
}
break;
case 0xF: {
Logger::nas_mm().debug("decoding iei(0xF)");
Logger::nas_mm().debug("Decoding IEI (0xF)");
ie_release_assistance_indication = new Release_Assistance_Indication();
decoded_size += ie_release_assistance_indication->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("next iei(0x%x)", octet);
Logger::nas_mm().debug("Next IEI (0x%x)", octet);
}
break;
}
switch (octet) {
case 0x12: {
Logger::nas_mm().debug("decoding iei(0x12)");
Logger::nas_mm().debug("Decoding IEI (0x12)");
ie_pdu_session_identity_2 = new PDU_Session_Identity_2();
decoded_size += ie_pdu_session_identity_2->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("next iei(0x%x)", octet);
Logger::nas_mm().debug("Next IEI (0x%x)", octet);
}
break;
case 0x59: {
Logger::nas_mm().debug("decoding iei(0x59)");
Logger::nas_mm().debug("Decoding IEI (0x59)");
ie_old_pdu_session_identity_2 = new PDU_Session_Identity_2();
decoded_size += ie_old_pdu_session_identity_2->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("next iei(0x%x)", octet);
Logger::nas_mm().debug("Next IEI (0x%x)", octet);
}
break;
case 0x22: {
Logger::nas_mm().debug("decoding iei(0x22)");
Logger::nas_mm().debug("Decoding IEI (0x22)");
ie_s_nssai = new S_NSSAI();
decoded_size += ie_s_nssai->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("next iei(0x%x)", octet);
Logger::nas_mm().debug("Next IEI (0x%x)", octet);
}
break;
case 0x25: {
Logger::nas_mm().debug("decoding iei(0x25)");
Logger::nas_mm().debug("Decoding IEI (0x25)");
ie_dnn = new DNN();
decoded_size += ie_dnn->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("next iei(0x%x)", octet);
Logger::nas_mm().debug("Next IEI (0x%x)", octet);
}
break;
case 0x24: {
Logger::nas_mm().debug("decoding iei(0x24)");
Logger::nas_mm().debug("Decoding IEI (0x24)");
ie_additional_information = new Additional_Information();
decoded_size += ie_additional_information->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("next iei(0x%x)", octet);
Logger::nas_mm().debug("Next IEI (0x%x)", octet);
}
break;
}
......
......@@ -37,7 +37,6 @@ extern "C" {
}
#include <iostream>
using namespace std;
namespace ngap {
......@@ -70,7 +69,7 @@ void InitialContextSetupResponseMsg::setMessageType() {
initialContextSetupResponsePduTypeIE.encode2pdu(initialContextSetupResponsePdu);
initialContextSetupResponseIEs = &(initialContextSetupResponsePdu->choice.successfulOutcome->value.choice.InitialContextSetupResponse);
} else {
cout << "[warning] This information doesn't refer to InitialContextSetupResponse Message!!!" << endl;
std::cout << "[Warning] This information doesn't refer to InitialContextSetupResponse message!" << std::endl;
}
}
......@@ -87,13 +86,13 @@ void InitialContextSetupResponseMsg::setAmfUeNgapId(unsigned long id) {
int ret = amfUeNgapId->encode2AMF_UE_NGAP_ID(ie->value.choice.AMF_UE_NGAP_ID);
if (!ret) {
cout << "encode AMF_UE_NGAP_ID IE error" << endl;
std::cout << "Encode AMF_UE_NGAP_ID IE error" << std::endl;
return;
}
ret = ASN_SEQUENCE_ADD(&initialContextSetupResponseIEs->protocolIEs.list, ie);
if (ret != 0)
cout << "encode AMF_UE_NGAP_ID IE error" << endl;
std::cout << "Encode AMF_UE_NGAP_ID IE error" << std::endl;
}
//------------------------------------------------------------------------------
......@@ -109,13 +108,13 @@ void InitialContextSetupResponseMsg::setRanUeNgapId(uint32_t ran_ue_ngap_id) {
int ret = ranUeNgapId->encode2RAN_UE_NGAP_ID(ie->value.choice.RAN_UE_NGAP_ID);
if (!ret) {
cout << "encode RAN_UE_NGAP_ID IE error" << endl;
std::cout << "Encode RAN_UE_NGAP_ID IE error" << std::endl;
return;
}
ret = ASN_SEQUENCE_ADD(&initialContextSetupResponseIEs->protocolIEs.list, ie);
if (ret != 0)
cout << "encode RAN_UE_NGAP_ID IE error" << endl;
std::cout << "Encode RAN_UE_NGAP_ID IE error" << std::endl;
}
//------------------------------------------------------------------------------
......@@ -141,13 +140,13 @@ void InitialContextSetupResponseMsg::setPduSessionResourceSetupResponseList(std:
int ret = pduSessionResourceSetupResponseList->encode2PDUSessionResourceSetupListCxtRes(&ie->value.choice.PDUSessionResourceSetupListCxtRes);
if (!ret) {
cout << "encode PDUSessionResourceSetupListCxtRes IE error" << endl;
std::cout << "Encode PDUSessionResourceSetupListCxtRes IE error" << std::endl;
return;
}
ret = ASN_SEQUENCE_ADD(&initialContextSetupResponseIEs->protocolIEs.list, ie);
if (ret != 0)
cout << "encode PDUSessionResourceSetupListCxtRes IE error" << endl;
std::cout << "Encode PDUSessionResourceSetupListCxtRes IE error" << std::endl;
}
......@@ -174,13 +173,13 @@ void InitialContextSetupResponseMsg::setPduSessionResourceFailedToSetupList(std:
int ret = pduSessionResourceFailedToSetupResponseList->encode2PDUSessionResourceFailedToSetupListCxtRes(&ie->value.choice.PDUSessionResourceFailedToSetupListCxtRes);
if (!ret) {
cout << "encode PDUSessionResourceFailedToSetupListCxtRes IE error" << endl;
std::cout << "Encode PDUSessionResourceFailedToSetupListCxtRes IE error" << std::endl;
return;
}
ret = ASN_SEQUENCE_ADD(&initialContextSetupResponseIEs->protocolIEs.list, ie);
if (ret != 0)
cout << "encode PDUSessionResourceFailedToSetupListCxtRes IE error" << endl;
std::cout << "Encode PDUSessionResourceFailedToSetupListCxtRes IE error" << std::endl;
}
......@@ -188,7 +187,7 @@ void InitialContextSetupResponseMsg::setPduSessionResourceFailedToSetupList(std:
int InitialContextSetupResponseMsg::encode2buffer(uint8_t *buf, int buf_size) {
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, initialContextSetupResponsePdu);
asn_enc_rval_t er = aper_encode_to_buffer(&asn_DEF_Ngap_NGAP_PDU, NULL, initialContextSetupResponsePdu, buf, buf_size);
cout << "er.encoded(" << er.encoded << ")" << endl;
std::cout << "er.encoded(" << er.encoded << ")" << std::endl;
return er.encoded;
}
......@@ -202,11 +201,11 @@ bool InitialContextSetupResponseMsg::decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu
&& initialContextSetupResponsePdu->choice.successfulOutcome->value.present == Ngap_SuccessfulOutcome__value_PR_InitialContextSetupResponse) {
initialContextSetupResponseIEs = &initialContextSetupResponsePdu->choice.successfulOutcome->value.choice.InitialContextSetupResponse;
} else {
cout << "Check InitialContextSetupResponse message error!!!" << endl;
std::cout << "Check InitialContextSetupResponse message error!" << std::endl;
return false;
}
} else {
cout << "MessageType error!!!" << endl;
std::cout << "MessageType error!" << std::endl;
return false;
}
for (int i = 0; i < initialContextSetupResponseIEs->protocolIEs.list.count; i++) {
......@@ -215,11 +214,11 @@ bool InitialContextSetupResponseMsg::decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu
if (initialContextSetupResponseIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_ignore && initialContextSetupResponseIEs->protocolIEs.list.array[i]->value.present == Ngap_InitialContextSetupResponseIEs__value_PR_AMF_UE_NGAP_ID) {
amfUeNgapId = new AMF_UE_NGAP_ID();
if (!amfUeNgapId->decodefromAMF_UE_NGAP_ID(initialContextSetupResponseIEs->protocolIEs.list.array[i]->value.choice.AMF_UE_NGAP_ID)) {
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl;
std::cout << "Decoded NGAP AMF_UE_NGAP_ID IE error" << std::endl;
return false;
}
} else {
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl;
std::cout << "Decoded NGAP AMF_UE_NGAP_ID IE error" << std::endl;
return false;
}
}
......@@ -228,11 +227,11 @@ bool InitialContextSetupResponseMsg::decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu
if (initialContextSetupResponseIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_ignore && initialContextSetupResponseIEs->protocolIEs.list.array[i]->value.present == Ngap_InitialContextSetupResponseIEs__value_PR_RAN_UE_NGAP_ID) {
ranUeNgapId = new RAN_UE_NGAP_ID();
if (!ranUeNgapId->decodefromRAN_UE_NGAP_ID(initialContextSetupResponseIEs->protocolIEs.list.array[i]->value.choice.RAN_UE_NGAP_ID)) {
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl;
std::cout << "Decoded NGAP RAN_UE_NGAP_ID IE error" << std::endl;
return false;
}
} else {
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl;
std::cout << "Decoded NGAP RAN_UE_NGAP_ID IE error" << std::endl;
return false;
}
}
......@@ -241,11 +240,11 @@ bool InitialContextSetupResponseMsg::decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu
if (initialContextSetupResponseIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_ignore && initialContextSetupResponseIEs->protocolIEs.list.array[i]->value.present == Ngap_InitialContextSetupResponseIEs__value_PR_PDUSessionResourceSetupListCxtRes) {
pduSessionResourceSetupResponseList = new PDUSessionResourceSetupListCxtRes();
if (!pduSessionResourceSetupResponseList->decodefromPDUSessionResourceSetupListCxtRes(&initialContextSetupResponseIEs->protocolIEs.list.array[i]->value.choice.PDUSessionResourceSetupListCxtRes)) {
cout << "decoded ngap PDUSessionResourceSetupListCxtRes IE error" << endl;
std::cout << "Decoded NGAP PDUSessionResourceSetupListCxtRes IE error" << std::endl;
return false;
}
} else {
cout << "decoded ngap PDUSessionResourceSetupListCxtRes IE error" << endl;
std::cout << "Decoded NGAP PDUSessionResourceSetupListCxtRes IE error" << std::endl;
return false;
}
}
......@@ -254,18 +253,18 @@ bool InitialContextSetupResponseMsg::decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu
if (initialContextSetupResponseIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_ignore && initialContextSetupResponseIEs->protocolIEs.list.array[i]->value.present == Ngap_InitialContextSetupResponseIEs__value_PR_PDUSessionResourceFailedToSetupListCxtRes) {
pduSessionResourceFailedToSetupResponseList = new PDUSessionResourceFailedToSetupListCxtRes();
if (!pduSessionResourceFailedToSetupResponseList->decodefromPDUSessionResourceFailedToSetupListCxtRes(&initialContextSetupResponseIEs->protocolIEs.list.array[i]->value.choice.PDUSessionResourceFailedToSetupListCxtRes)) {
cout << "decoded ngap PDUSessionResourceFailedToSetupListCxtRes IE error" << endl;
std::cout << "Decoded NGAP PDUSessionResourceFailedToSetupListCxtRes IE error" << std::endl;
return false;
}
} else {
cout << "decoded ngap PDUSessionResourceFailedToSetupListCxtRes IE error!" << endl;
std::cout << "Decoded NGAP PDUSessionResourceFailedToSetupListCxtRes IE error!" << std::endl;
return false;
}
}
break;
default: {
cout << "decoded ngap message pdu error" << endl;
std::cout << "Decoded NGAP message PDU error" << std::endl;
return false;
}
}
......
......@@ -37,7 +37,6 @@ extern "C" {
}
#include <iostream>
using namespace std;
namespace ngap {
......@@ -70,7 +69,7 @@ void UplinkNASTransportMsg::setMessageType() {
uplinkNASTransportPduTypeIE.encode2pdu(uplinkNASTransportPdu);
uplinkNASTransportIEs = &(uplinkNASTransportPdu->choice.initiatingMessage->value.choice.UplinkNASTransport);
} else {
cout << "[warning] This information doesn't refer to UplinkNASTransport Message!!!" << endl;
std::cout << "[Warning] This information doesn't refer to UplinkNASTransport Message!" << std::endl;
}
}
......@@ -87,13 +86,13 @@ void UplinkNASTransportMsg::setAmfUeNgapId(unsigned long id) {
int ret = amfUeNgapId->encode2AMF_UE_NGAP_ID(ie->value.choice.AMF_UE_NGAP_ID);
if (!ret) {
cout << "encode AMF_UE_NGAP_ID IE error" << endl;
std::cout << "Encode AMF_UE_NGAP_ID IE error" << std::endl;
return;
}
ret = ASN_SEQUENCE_ADD(&uplinkNASTransportIEs->protocolIEs.list, ie);
if (ret != 0)
cout << "encode AMF_UE_NGAP_ID IE error" << endl;
std::cout << "Encode AMF_UE_NGAP_ID IE error" << std::endl;
}
//------------------------------------------------------------------------------
......@@ -109,13 +108,13 @@ void UplinkNASTransportMsg::setRanUeNgapId(uint32_t ran_ue_ngap_id) {
int ret = ranUeNgapId->encode2RAN_UE_NGAP_ID(ie->value.choice.RAN_UE_NGAP_ID);
if (!ret) {
cout << "encode RAN_UE_NGAP_ID IE error" << endl;
std::cout << "Encode RAN_UE_NGAP_ID IE error" << std::endl;
return;
}
ret = ASN_SEQUENCE_ADD(&uplinkNASTransportIEs->protocolIEs.list, ie);
if (ret != 0)
cout << "encode RAN_UE_NGAP_ID IE error" << endl;
std::cout << "Encode RAN_UE_NGAP_ID IE error" << std::endl;
}
//------------------------------------------------------------------------------
......@@ -132,13 +131,13 @@ void UplinkNASTransportMsg::setNasPdu(uint8_t *nas, size_t sizeofnas) {
int ret = nasPdu->encode2octetstring(ie->value.choice.NAS_PDU);
if (!ret) {
cout << "encode NAS_PDU IE error" << endl;
std::cout << "Encode NAS_PDU IE error" << std::endl;
return;
}
ret = ASN_SEQUENCE_ADD(&uplinkNASTransportIEs->protocolIEs.list, ie);
if (ret != 0)
cout << "encode NAS_PDU IE error" << endl;
std::cout << "Encode NAS_PDU IE error" << std::endl;
}
//------------------------------------------------------------------------------
......@@ -171,20 +170,20 @@ void UplinkNASTransportMsg::setUserLocationInfoNR(struct NrCgi_s cig, struct Tai
int ret = userLocationInformation->encodefromUserLocationInformation(&ie->value.choice.UserLocationInformation);
if (!ret) {
cout << "encode UserLocationInformation IE error" << endl;
std::cout << "Encode UserLocationInformation IE error" << std::endl;
return;
}
ret = ASN_SEQUENCE_ADD(&uplinkNASTransportIEs->protocolIEs.list, ie);
if (ret != 0)
cout << "encode UserLocationInformation IE error" << endl;
std::cout << "Encode UserLocationInformation IE error" << std::endl;
}
//------------------------------------------------------------------------------
int UplinkNASTransportMsg::encode2buffer(uint8_t *buf, int buf_size) {
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, uplinkNASTransportPdu);
asn_enc_rval_t er = aper_encode_to_buffer(&asn_DEF_Ngap_NGAP_PDU, NULL, uplinkNASTransportPdu, buf, buf_size);
cout << "er.encoded(" << er.encoded << ")" << endl;
std::cout << "er.encoded(" << er.encoded << ")" << std::endl;
return er.encoded;
}
......@@ -198,11 +197,11 @@ bool UplinkNASTransportMsg::decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu) {
&& uplinkNASTransportPdu->choice.initiatingMessage->value.present == Ngap_InitiatingMessage__value_PR_UplinkNASTransport) {
uplinkNASTransportIEs = &uplinkNASTransportPdu->choice.initiatingMessage->value.choice.UplinkNASTransport;
} else {
cout << "Check UplinkNASTransport message error!!!" << endl;
std::cout << "Check UplinkNASTransport message error!!!" << std::endl;
return false;
}
} else {
cout << "MessageType error!!!" << endl;
std::cout << "MessageType error!!!" << std::endl;
return false;
}
for (int i = 0; i < uplinkNASTransportIEs->protocolIEs.list.count; i++) {
......@@ -211,11 +210,11 @@ bool UplinkNASTransportMsg::decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu) {
if (uplinkNASTransportIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_reject && uplinkNASTransportIEs->protocolIEs.list.array[i]->value.present == Ngap_UplinkNASTransport_IEs__value_PR_AMF_UE_NGAP_ID) {
amfUeNgapId = new AMF_UE_NGAP_ID();
if (!amfUeNgapId->decodefromAMF_UE_NGAP_ID(uplinkNASTransportIEs->protocolIEs.list.array[i]->value.choice.AMF_UE_NGAP_ID)) {
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl;
std::cout << "decoded ngap AMF_UE_NGAP_ID IE error" << std::endl;
return false;
}
} else {
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl;
std::cout << "decoded ngap AMF_UE_NGAP_ID IE error" << std::endl;
return false;
}
}
......@@ -224,11 +223,11 @@ bool UplinkNASTransportMsg::decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu) {
if (uplinkNASTransportIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_reject && uplinkNASTransportIEs->protocolIEs.list.array[i]->value.present == Ngap_UplinkNASTransport_IEs__value_PR_RAN_UE_NGAP_ID) {
ranUeNgapId = new RAN_UE_NGAP_ID();
if (!ranUeNgapId->decodefromRAN_UE_NGAP_ID(uplinkNASTransportIEs->protocolIEs.list.array[i]->value.choice.RAN_UE_NGAP_ID)) {
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl;
std::cout << "decoded ngap RAN_UE_NGAP_ID IE error" << std::endl;
return false;
}
} else {
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl;
std::cout << "decoded ngap RAN_UE_NGAP_ID IE error" << std::endl;
return false;
}
}
......@@ -237,11 +236,11 @@ bool UplinkNASTransportMsg::decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu) {
if (uplinkNASTransportIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_reject && uplinkNASTransportIEs->protocolIEs.list.array[i]->value.present == Ngap_UplinkNASTransport_IEs__value_PR_NAS_PDU) {
nasPdu = new NAS_PDU();
if (!nasPdu->decodefromoctetstring(uplinkNASTransportIEs->protocolIEs.list.array[i]->value.choice.NAS_PDU)) {
cout << "decoded ngap NAS_PDU IE error" << endl;
std::cout << "decoded ngap NAS_PDU IE error" << std::endl;
return false;
}
} else {
cout << "decoded ngap NAS_PDU IE error" << endl;
std::cout << "decoded ngap NAS_PDU IE error" << std::endl;
return false;
}
}
......@@ -250,18 +249,18 @@ bool UplinkNASTransportMsg::decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu) {
if (uplinkNASTransportIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_ignore && uplinkNASTransportIEs->protocolIEs.list.array[i]->value.present == Ngap_UplinkNASTransport_IEs__value_PR_UserLocationInformation) {
userLocationInformation = new UserLocationInformation();
if (!userLocationInformation->decodefromUserLocationInformation(&uplinkNASTransportIEs->protocolIEs.list.array[i]->value.choice.UserLocationInformation)) {
cout << "decoded ngap UserLocationInformation IE error" << endl;
std::cout << "decoded ngap UserLocationInformation IE error" << std::endl;
return false;
}
} else {
cout << "decoded ngap UserLocationInformation IE error" << endl;
std::cout << "decoded ngap UserLocationInformation IE error" << std::endl;
return false;
}
}
break;
default: {
cout << "decoded ngap message pdu error" << endl;
std::cout << "decoded ngap message pdu error" << std::endl;
return false;
}
}
......
......@@ -90,11 +90,11 @@ int ngap_amf_handle_initial_ue_message(const sctp_assoc_id_t assoc_id, const sct
//------------------------------------------------------------------------------
int ngap_amf_handle_uplink_nas_transport(const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream, struct Ngap_NGAP_PDU *message_p) {
Logger::ngap().debug("Sending itti up link nas transport message to TASK_AMF_N2");
Logger::ngap().debug("Sending ITTI Uplink NAS Transport message to TASK_AMF_N2");
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, message_p);
UplinkNASTransportMsg *uplinkNasT = new UplinkNASTransportMsg();
if (!uplinkNasT->decodefrompdu(message_p)) {
Logger::ngap().error("decoding UplinkNasTransport message error");
Logger::ngap().error("Decoding UplinkNasTransport message error");
return -1;
}
itti_ul_nas_transport *itti_ul_nas = new itti_ul_nas_transport(TASK_NGAP, TASK_AMF_N2);
......@@ -110,7 +110,8 @@ int ngap_amf_handle_uplink_nas_transport(const sctp_assoc_id_t assoc_id, const s
//------------------------------------------------------------------------------
int ngap_amf_handle_initial_context_setup_response(const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream, struct Ngap_NGAP_PDU *message_p) {
Logger::ngap().debug("Sending itti initial context setup response to TASK_AMF_N11");
Logger::ngap().debug("Handling Initial Context Setup Response...");
Logger::ngap().debug("Sending ITTI Initial Context Setup Response to TASK_AMF_N11");
InitialContextSetupResponseMsg *initCtxResp = new InitialContextSetupResponseMsg();
if (!initCtxResp->decodefrompdu(message_p)) {
Logger::ngap().error("Decoding InitialContextSetupResponse message error");
......
......@@ -185,7 +185,7 @@ int sctp_server::sctp_read_from_socket(int sd, uint32_t ppid) {
Logger::sctp().error("Received data from peer with unsolicited PPID (%d), expecting (%d)", ntohl(sinfo.sinfo_ppid), association->ppid);
return SCTP_RC_ERROR;
}
Logger::sctp().info("[Assoc_id %d, Socket %d] Received a msg (length %d) from port %d, on stream %d, PPID %d", sinfo.sinfo_assoc_id, sd, n, ntohs(addr.sin6_port), sinfo.sinfo_stream, ntohl(sinfo.sinfo_ppid));
Logger::sctp().info("****[Assoc_id %d, Socket %d] Received a msg (length %d) from port %d, on stream %d, PPID %d ****", sinfo.sinfo_assoc_id, sd, n, ntohs(addr.sin6_port), sinfo.sinfo_stream, ntohl(sinfo.sinfo_ppid));
bstring payload = blk2bstr(buffer, n);
//handle payload
app_->handle_receive(payload, (sctp_assoc_id_t) sinfo.sinfo_assoc_id, sinfo.sinfo_stream, association->instreams, association->outstreams);
......
......@@ -377,7 +377,6 @@ void Authentication_5gaka::derive_knas(algorithm_type_dist_t nas_alg_type, uint8
//memcpy (knas, &out[31 - 16 + 1], 16);
for (int i = 0; i < 16; i++)
knas[i] = out[16 + i];
Logger::amf_n1().debug("derive_knas finished!");
}
//------------------------------------------------------------------------------
......
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