Commit 4a62d885 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

polish the code for NAS

parent 9c9b9f84
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef FILE_3GPP_24_501_H_SEEN #ifndef FILE_3GPP_24_501_H_SEEN
#define FILE_3GPP_24_501_H_SEEN #define FILE_3GPP_24_501_H_SEEN
#ifdef __cplusplus #ifdef __cplusplus
...@@ -214,13 +236,48 @@ static const std::vector<std::string> request_type_e2str = { ...@@ -214,13 +236,48 @@ static const std::vector<std::string> request_type_e2str = {
"RESERVED" "RESERVED"
}; };
enum cause_value_5gs_session_management_e { enum class cause_value_5gsm_e {
CAUSE_0_UNKNOWN = 0,
CAUSE_8_OPERATOR_DETERMINED_BARRING = 8, CAUSE_8_OPERATOR_DETERMINED_BARRING = 8,
CAUSE_26_INSUFFICIENT_RESOURCES = 26, CAUSE_26_INSUFFICIENT_RESOURCES = 26,
CAUSE_27_MISSING_OR_UNKNOWN_DNN = 27, CAUSE_27_MISSING_OR_UNKNOWN_DNN = 27,
CAUSE_28_UNKNOWN_PDU_SESSION_TYPE = 28, CAUSE_28_UNKNOWN_PDU_SESSION_TYPE = 28,
CAUSE_29_USER_AUTHENTICATION_OR_AUTHORIZATION_FAILED = 29, CAUSE_29_USER_AUTHENTICATION_OR_AUTHORIZATION_FAILED = 29,
CAUSE_54_PDU_SESSION_DOES_NOT_EXIST CAUSE_31_REQUEST_REJECTED_UNSPECIFIED = 31,
CAUSE_32_SERVICE_OPTION_NOT_SUPPORTED = 32,
CAUSE_33_REQUESTED_SERVICE_OPTION_NOT_SUBSCRIBED = 33,
CAUSE_35_PTI_ALREADY_IN_USE = 35,
CAUSE_36_REGULAR_DEACTIVATION = 36,
CAUSE_38_NETWORK_FAILURE = 38,
CAUSE_39_REACTIVATION_REQUESTED = 39,
CAUSE_41_SEMATIC_ERROR_IN_THE_TFT_OPERATION = 41,
CAUSE_42_SYNTACTICAL_ERROR_IN_THE_TFT_OPERATIOIN = 42,
CAUSE_43_INVALID_PDU_SESSION_IDENTITY = 43,
CAUSE_44_SEMANTIC_ERRORS_IN_PACKET_FILTERS = 44,
CAUSE_45_SYNTACTICAL_ERROR_IN_PACKET_FILTERS = 45,
CAUSE_46_OUT_OF_LAND_SERVICE_AREA = 46,
CAUSE_47_PTI_MISMATCH = 47,
CAUSE_50_PDU_SESSION_TYPE_IPV4_ONLY_ALLOWED = 50,
CAUSE_51_PDU_SESSION_TYPE_IPV6_ONLY_ALLOWED = 50,
CAUSE_54_PDU_SESSION_DOES_NOT_EXIST = 54,
CAUSE_67_INSUFFICIENT_RESOURCES_FOR_SPECIFIC_SLICE_AND_DNN =67,
CAUSE_68_NOT_SUPPORTED_SSC_MODE = 68,
CAUSE_69_INSUFFICIENT_RESOURCES_FOR_SPECIFIC_SLICE = 69,
CAUSE_70_MISSING_OR_UNKNOWN_DNN_IN_A_SLICE = 70,
CAUSE_81_INVALID_PTI_VALUE = 81,
CAUSE_82_MAXIMUM_DATA_RATE_PER_UE_FOR_USER_PLANE_INTEGRITY_PROTECTION_IS_TOO_LOW = 82,
CAUSE_83_SEMANTIC_ERROR_IN_THE_QOS_OPERATION =83,
CAUSE_84_SYNTACTICAL_ERROR_IN_THE_QOS_OPERATION = 84,
CAUSE_85_INVALID_MAPPED_EPS_BEARER_IDENTITY = 85,
//Protocol errors
CAUSE_95_SEMANTICALLY_INCORRECT_MESSAGE = 95,
CAUSE_96_INVALID_MANDATORY_INFORMATION = 96,
CAUSE_97_MESSAGE_TYPE_NON_EXISTENT_OR_NOTIMPLEMENTED = 97,
CAUSE_98_MESSAGE_TYPE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE = 98,
CAUSE_99_INFORMATION_ELEMENT_NON_EXISTENT_OR_NOT_IMPLEMENTED = 99,
CAUSE_100_CONDITIONAL_IE_ERROR = 100,
CAUSE_101_MESSAGE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE = 101,
CAUSE_111_PROTOCOL_ERROR_UNSPECIFIED = 111
/* /*
Cause #8 – Operator Determined Barring Cause #8 – Operator Determined Barring
Cause #26 – Insufficient resources Cause #26 – Insufficient resources
...@@ -253,6 +310,15 @@ enum cause_value_5gs_session_management_e { ...@@ -253,6 +310,15 @@ enum cause_value_5gs_session_management_e {
Cause #83 – Semantic error in the QoS operation Cause #83 – Semantic error in the QoS operation
Cause #84 – Syntactical error in the QoS operation Cause #84 – Syntactical error in the QoS operation
Cause #85 – Invalid mapped EPS bearer identity Cause #85 – Invalid mapped EPS bearer identity
//Protocol errors
Cause #95 – Semantically incorrect message
Cause #96 – Invalid mandatory information
Cause #97 – Message type non-existent or not implemented
Cause #98 – Message type not compatible with protocol state
Cause #99 – Information element non-existent or not implemented
Cause #100 – Conditional IE error
Cause #101 – Message not compatible with protocol state
Cause #111 – Protocol error, unspecified
*/ */
}; };
...@@ -272,6 +338,24 @@ Cause #111 – Protocol error, unspecified ...@@ -272,6 +338,24 @@ Cause #111 – Protocol error, unspecified
*/ */
}; };
//The 5GSM sublayer states for PDU session handling in the network
//Section 6.1.3.3 @3GPP TS 24.501 V16.1.0
enum class pdu_session_status_e {
PDU_SESSION_INACTIVE = 0,
PDU_SESSION_INACTIVE_PENDING = 1,
PDU_SESSION_MODIFICATION_PENDING =2,
PDU_SESSION_ACTIVE = 3
};
static const std::vector<std::string> pdu_session_status_e2str = {
"PDU_SESSION_INACTIVE",
"PDU_SESSION_INACTIVE_PENDING",
"PDU_SESSION_MODIFICATION_PENDING",
"PDU_SESSION_ACTIVE"
};
#endif #endif
#endif #endif
...@@ -8,71 +8,71 @@ ...@@ -8,71 +8,71 @@
int encode_allowed_ssc_mode ( AllowedSSCMode allowedsscmode, uint8_t iei, uint8_t * buffer, uint32_t len ) int encode_allowed_ssc_mode ( AllowedSSCMode allowedsscmode, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
uint32_t encoded = 0; uint32_t encoded = 0;
uint8_t bitStream = 0x00; uint8_t bitStream = 0x00;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,ALLOWED_SSC_MODE_MINIMUM_LENGTH , len); CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,ALLOWED_SSC_MODE_MINIMUM_LENGTH , len);
if(iei > 0){
bitStream |= (iei & 0xf0);
}
if(allowedsscmode.is_ssc3_allowed) if(iei > 0){
{ bitStream |= (iei & 0xf0);
bitStream |= 0x04; }
}
if(allowedsscmode.is_ssc2_allowed)
{
bitStream |= 0x02;
}
if(allowedsscmode.is_ssc1_allowed)
{
bitStream |= 0x01;
}
ENCODE_U8(buffer+encoded,bitStream,encoded); if(allowedsscmode.is_ssc3_allowed)
{
return encoded; bitStream |= 0x04;
}
if(allowedsscmode.is_ssc2_allowed)
{
bitStream |= 0x02;
}
if(allowedsscmode.is_ssc1_allowed)
{
bitStream |= 0x01;
}
ENCODE_U8(buffer+encoded,bitStream,encoded);
return encoded;
} }
int decode_allowed_ssc_mode ( AllowedSSCMode * allowedsscmode, uint8_t iei, uint8_t * buffer, uint32_t len ) int decode_allowed_ssc_mode ( AllowedSSCMode * allowedsscmode, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
int decoded=0; int decoded=0;
uint8_t bitStream = 0x00; uint8_t bitStream = 0x00;
DECODE_U8(buffer+decoded,bitStream,decoded);
DECODE_U8(buffer+decoded,bitStream,decoded); if(iei != (bitStream&0xf0)){
return -1;
}
if(iei > 0){
bitStream = (bitStream & 0x07);
}
if(iei != bitStream&0xf0){ if(bitStream & 0x01)
return -1; {
} allowedsscmode->is_ssc1_allowed = true;
if(iei > 0){ }
bitStream = (bitStream & 0x07); else
} {
allowedsscmode->is_ssc1_allowed = false;
}
if(bitStream & 0x02)
{
allowedsscmode->is_ssc2_allowed = true;
}
else
{
allowedsscmode->is_ssc2_allowed = false;
}
if(bitStream & 0x04)
{
allowedsscmode->is_ssc3_allowed = true;
}
else
{
allowedsscmode->is_ssc3_allowed = false;
}
if(bitStream & 0x01) return decoded;
{
allowedsscmode->is_ssc1_allowed = true;
}
else
{
allowedsscmode->is_ssc1_allowed = false;
}
if(bitStream & 0x02)
{
allowedsscmode->is_ssc2_allowed = true;
}
else
{
allowedsscmode->is_ssc2_allowed = false;
}
if(bitStream & 0x04)
{
allowedsscmode->is_ssc3_allowed = true;
}
else
{
allowedsscmode->is_ssc3_allowed = false;
}
return decoded;
} }
...@@ -8,43 +8,43 @@ ...@@ -8,43 +8,43 @@
int encode_alwayson_pdu_session_requested ( AlwaysonPDUSessionRequested alwaysonpdusessionrequested, uint8_t iei, uint8_t * buffer, uint32_t len ) int encode_alwayson_pdu_session_requested ( AlwaysonPDUSessionRequested alwaysonpdusessionrequested, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
uint32_t encoded = 0; uint32_t encoded = 0;
uint8_t bitStream = 0; uint8_t bitStream = 0;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,ALWAYSON_PDU_SESSION_REQUESTED_MINIMUM_LENGTH , len); CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,ALWAYSON_PDU_SESSION_REQUESTED_MINIMUM_LENGTH , len);
if(iei > 0){ if(iei > 0){
bitStream |= (iei & 0xf0); bitStream |= (iei & 0xf0);
} }
if(alwaysonpdusessionrequested.apsr_requested) if(alwaysonpdusessionrequested.apsr_requested)
bitStream |= 0x01; bitStream |= 0x01;
ENCODE_U8(buffer+encoded,bitStream,encoded); ENCODE_U8(buffer+encoded,bitStream,encoded);
return encoded; return encoded;
} }
int decode_alwayson_pdu_session_requested ( AlwaysonPDUSessionRequested * alwaysonpdusessionrequested, uint8_t iei, uint8_t * buffer, uint32_t len ) int decode_alwayson_pdu_session_requested ( AlwaysonPDUSessionRequested * alwaysonpdusessionrequested, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
int decoded=0; int decoded=0;
uint8_t bitStream = 0; uint8_t bitStream = 0;
DECODE_U8(buffer+decoded,bitStream,decoded); DECODE_U8(buffer+decoded,bitStream,decoded);
if(iei != bitStream&0xf0){ if(iei != (bitStream&0xf0)){
return -1; return -1;
} }
if(iei > 0){ if(iei > 0){
bitStream = (bitStream & 0x01); bitStream = (bitStream & 0x01);
} }
if(bitStream) if(bitStream)
alwaysonpdusessionrequested->apsr_requested = true; alwaysonpdusessionrequested->apsr_requested = true;
else else
alwaysonpdusessionrequested->apsr_requested = false; alwaysonpdusessionrequested->apsr_requested = false;
return decoded; return decoded;
} }
...@@ -8,40 +8,29 @@ ...@@ -8,40 +8,29 @@
int encode_configuration_update_indication ( ConfigurationUpdateIndication configurationupdateindication, uint8_t iei, uint8_t * buffer, uint32_t len ) int encode_configuration_update_indication ( ConfigurationUpdateIndication configurationupdateindication, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
uint8_t *lenPtr; uint32_t encoded = 0;
uint32_t encoded = 0; int encode_result;
int encode_result; CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,CONFIGURATION_UPDATE_INDICATION_MINIMUM_LENGTH , len);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,CONFIGURATION_UPDATE_INDICATION_MINIMUM_LENGTH , len);
if ((encode_result = encode_bstring (configurationupdateindication, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
return encoded;
if ((encode_result = encode_bstring (configurationupdateindication, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
return encoded;
} }
int decode_configuration_update_indication ( ConfigurationUpdateIndication * configurationupdateindication, uint8_t iei, uint8_t * buffer, uint32_t len ) int decode_configuration_update_indication ( ConfigurationUpdateIndication * configurationupdateindication, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
int decoded=0; int decoded=0;
uint8_t ielen=0; uint8_t ielen=0;
int decode_result; int decode_result;
if((decode_result = decode_bstring (configurationupdateindication, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
decoded += decode_result;
if((decode_result = decode_bstring (configurationupdateindication, ielen, buffer + decoded, len - decoded)) < 0) return decoded;
return decode_result;
else
decoded += decode_result;
return decoded;
} }
...@@ -8,51 +8,52 @@ ...@@ -8,51 +8,52 @@
int encode_dnn ( DNN dnn, uint8_t iei, uint8_t * buffer, uint32_t len ) int encode_dnn ( DNN dnn, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
uint8_t *lenPtr = NULL; uint8_t *lenPtr = NULL;
uint32_t encoded = 0; uint32_t encoded = 0;
int encode_result = 0; int encode_result = 0;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,((iei > 0) ? DNN_MINIMUM_LENGTH_TLV : DNN_MINIMUM_LENGTH_TLV-1) , len); CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,((iei > 0) ? DNN_MINIMUM_LENGTH_TLV : DNN_MINIMUM_LENGTH_TLV-1) , len);
if( iei > 0 ) if( iei > 0 )
{ {
*buffer=iei; *buffer=iei;
encoded++;
}
lenPtr = (buffer + encoded);
encoded++; encoded++;
}
if ((encode_result = encode_bstring (dnn, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度 lenPtr = (buffer + encoded);
return encode_result; encoded++;
else
encoded += encode_result;
*lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0); if ((encode_result = encode_bstring (dnn, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
return encoded; else
encoded += encode_result;
*lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0);
return encoded;
} }
int decode_dnn ( DNN * dnn, uint8_t iei, uint8_t * buffer, uint32_t len ) int decode_dnn ( DNN * dnn, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
int decoded = 0; int decoded = 0;
uint8_t ielen = 0; uint8_t ielen = 0;
int decode_result = 0; int decode_result = 0;
if (iei > 0)
{
CHECK_IEI_DECODER (iei, *buffer);
decoded++;
}
ielen = *(buffer + decoded); if (iei > 0)
{
CHECK_IEI_DECODER (iei, *buffer);
decoded++; decoded++;
CHECK_LENGTH_DECODER (len - decoded, ielen); }
if((decode_result = decode_bstring (dnn, ielen, buffer + decoded, len - decoded)) < 0) ielen = *(buffer + decoded);
return decode_result; decoded++;
else CHECK_LENGTH_DECODER (len - decoded, ielen);
decoded += decode_result;
if((decode_result = decode_bstring (dnn, ielen, buffer + decoded, len - decoded)) < 0)
return decoded; {
return decode_result;
} else{
decoded += decode_result;
}
return decoded;
} }
...@@ -8,40 +8,29 @@ ...@@ -8,40 +8,29 @@
int encode_deregistration_type ( DeregistrationType deregistrationtype, uint8_t iei, uint8_t * buffer, uint32_t len ) int encode_deregistration_type ( DeregistrationType deregistrationtype, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
uint8_t *lenPtr; uint32_t encoded = 0;
uint32_t encoded = 0; int encode_result;
int encode_result; CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,DEREGISTRATION_TYPE_MINIMUM_LENGTH , len);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,DEREGISTRATION_TYPE_MINIMUM_LENGTH , len);
if ((encode_result = encode_bstring (deregistrationtype, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
return encoded;
if ((encode_result = encode_bstring (deregistrationtype, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
return encoded;
} }
int decode_deregistration_type ( DeregistrationType * deregistrationtype, uint8_t iei, uint8_t * buffer, uint32_t len ) int decode_deregistration_type ( DeregistrationType * deregistrationtype, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
int decoded=0; int decoded=0;
uint8_t ielen=0; uint8_t ielen=0;
int decode_result; int decode_result;
if((decode_result = decode_bstring (deregistrationtype, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
decoded += decode_result;
if((decode_result = decode_bstring (deregistrationtype, ielen, buffer + decoded, len - decoded)) < 0) return decoded;
return decode_result;
else
decoded += decode_result;
return decoded;
} }
...@@ -8,62 +8,62 @@ ...@@ -8,62 +8,62 @@
int encode_extended_protocol_configuration_options ( ExtendedProtocolConfigurationOptions extendedprotocolconfigurationoptions, uint8_t iei, uint8_t * buffer, uint32_t len ) int encode_extended_protocol_configuration_options ( ExtendedProtocolConfigurationOptions extendedprotocolconfigurationoptions, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
uint8_t *lenPtr = NULL; uint8_t *lenPtr = NULL;
uint32_t encoded = 0; uint32_t encoded = 0;
int encode_result = 0; int encode_result = 0;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,((iei > 0) ? EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_MINIMUM_LENGTH_TLVE : EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_MINIMUM_LENGTH_TLVE-1), len); CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,((iei > 0) ? EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_MINIMUM_LENGTH_TLVE : EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_MINIMUM_LENGTH_TLVE-1), len);
if( iei >0 )
if( iei >0 ) {
{ *buffer=iei;
*buffer=iei;
encoded++;
}
lenPtr = (buffer + encoded);
encoded++;
encoded++; encoded++;
}
lenPtr = (buffer + encoded);
encoded++;
encoded++;
if ((encode_result = encode_bstring (extendedprotocolconfigurationoptions, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度 if ((encode_result = encode_bstring (extendedprotocolconfigurationoptions, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result; return encode_result;
else else
encoded += encode_result; encoded += encode_result;
uint32_t res = encoded - 2 - ((iei > 0) ? 1 : 0); uint32_t res = encoded - 2 - ((iei > 0) ? 1 : 0);
*lenPtr =res/(1<<8); *lenPtr =res/(1<<8);
lenPtr++; lenPtr++;
*lenPtr = res%(1<<8); *lenPtr = res%(1<<8);
return encoded; return encoded;
} }
int decode_extended_protocol_configuration_options ( ExtendedProtocolConfigurationOptions * extendedprotocolconfigurationoptions, uint8_t iei, uint8_t * buffer, uint32_t len ) int decode_extended_protocol_configuration_options ( ExtendedProtocolConfigurationOptions * extendedprotocolconfigurationoptions, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
int decoded=0; int decoded=0;
uint32_t ielen=0; uint32_t ielen=0;
int decode_result = 0; int decode_result = 0;
if (iei > 0) if (iei > 0)
{ {
CHECK_IEI_DECODER (iei, *buffer); CHECK_IEI_DECODER (iei, *buffer);
decoded++;
}
ielen = *(buffer + decoded);
decoded++; decoded++;
ielen = ( ielen << 8) + *(buffer + decoded); }
decoded++;
CHECK_LENGTH_DECODER (len - decoded, ielen); ielen = *(buffer + decoded);
decoded++;
ielen = ( ielen << 8) + *(buffer + decoded);
decoded++;
CHECK_LENGTH_DECODER (len - decoded, ielen);
if((decode_result = decode_bstring (extendedprotocolconfigurationoptions, ielen, buffer + decoded, len - decoded)) < 0) if((decode_result = decode_bstring (extendedprotocolconfigurationoptions, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result; {
else return decode_result;
decoded += decode_result; }
else
{
decoded += decode_result;
}
return decoded; return decoded;
} }
...@@ -8,14 +8,13 @@ ...@@ -8,14 +8,13 @@
int encode_extended_protocol_discriminator ( ExtendedProtocolDiscriminator extendedprotocoldiscriminator, uint8_t iei, uint8_t * buffer, uint32_t len ) int encode_extended_protocol_discriminator ( ExtendedProtocolDiscriminator extendedprotocoldiscriminator, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
/* /*
uint8_t *lenPtr;
uint32_t encoded = 0; uint32_t encoded = 0;
int encode_result; int encode_result;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH , len); CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH , len);
ENCODE8 ENCODE8
if ((encode_result = encode_bstring (extendedprotocoldiscriminator, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度 if ((encode_result = encode_bstring (extendedprotocoldiscriminator, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result; return encode_result;
else else
...@@ -23,25 +22,23 @@ int encode_extended_protocol_discriminator ( ExtendedProtocolDiscriminator exte ...@@ -23,25 +22,23 @@ int encode_extended_protocol_discriminator ( ExtendedProtocolDiscriminator exte
return encoded; return encoded;
*/ */
return 0;
} }
int decode_extended_protocol_discriminator ( ExtendedProtocolDiscriminator * extendedprotocoldiscriminator, uint8_t iei, uint8_t * buffer, uint32_t len ) int decode_extended_protocol_discriminator ( ExtendedProtocolDiscriminator * extendedprotocoldiscriminator, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
/* /*
int decoded=0; int decoded=0;
uint8_t ielen=0; uint8_t ielen=0;
int decode_result; int decode_result;
if((decode_result = decode_bstring (extendedprotocoldiscriminator, ielen, buffer + decoded, len - decoded)) < 0) if((decode_result = decode_bstring (extendedprotocoldiscriminator, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result; return decode_result;
else else
decoded += decode_result; decoded += decode_result;
return decoded; return decoded;
*/ */
return 0;
} }
...@@ -8,43 +8,40 @@ ...@@ -8,43 +8,40 @@
int encode_intergrity_protection_maximum_data_rate ( IntergrityProtectionMaximumDataRate intergrityprotectionmaximumdatarate, uint8_t iei, uint8_t * buffer, uint32_t len ) int encode_intergrity_protection_maximum_data_rate ( IntergrityProtectionMaximumDataRate intergrityprotectionmaximumdatarate, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
uint8_t *lenPtr = NULL; uint32_t encoded = 0;
uint32_t encoded = 0; int encode_result = 0;
int encode_result = 0; CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,((iei > 0) ? INTERGRITY_PROTECTION_MAXIMUM_DATA_RATE_MINIMUM_LENGTH_TV : INTERGRITY_PROTECTION_MAXIMUM_DATA_RATE_MINIMUM_LENGTH_V) , len);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,((iei > 0) ? INTERGRITY_PROTECTION_MAXIMUM_DATA_RATE_MINIMUM_LENGTH_TV : INTERGRITY_PROTECTION_MAXIMUM_DATA_RATE_MINIMUM_LENGTH_V) , len);
if( iei > 0)
{
if( iei > 0) *buffer=iei;
{ encoded++;
*buffer=iei; }
encoded++;
} if ((encode_result = encode_bstring (intergrityprotectionmaximumdatarate, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
if ((encode_result = encode_bstring (intergrityprotectionmaximumdatarate, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度 else
return encode_result; encoded += encode_result;
else
encoded += encode_result; return encoded;
return encoded;
} }
int decode_intergrity_protection_maximum_data_rate ( IntergrityProtectionMaximumDataRate * intergrityprotectionmaximumdatarate, uint8_t iei, uint8_t * buffer, uint32_t len ) int decode_intergrity_protection_maximum_data_rate ( IntergrityProtectionMaximumDataRate * intergrityprotectionmaximumdatarate, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
int decoded=0; int decoded=0;
uint8_t ielen=2; uint8_t ielen=2;
int decode_result = 0; int decode_result = 0;
if (iei > 0) if (iei > 0)
{ {
CHECK_IEI_DECODER (iei, *buffer); CHECK_IEI_DECODER (iei, *buffer);
decoded++; decoded++;
} }
if((decode_result = decode_bstring (intergrityprotectionmaximumdatarate, ielen, buffer + decoded, len - decoded)) < 0) if((decode_result = decode_bstring (intergrityprotectionmaximumdatarate, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result; return decode_result;
else else
decoded += decode_result; decoded += decode_result;
return decoded; return decoded;
} }
...@@ -8,33 +8,32 @@ ...@@ -8,33 +8,32 @@
int encode_mico_indication ( MICOIndication micoindication, uint8_t iei, uint8_t * buffer, uint32_t len ) int encode_mico_indication ( MICOIndication micoindication, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
uint32_t encoded = 0; uint32_t encoded = 0;
uint8_t bitStream = 0x0; uint8_t bitStream = 0x0;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,MICO_INDICATION_MINIMUM_LENGTH , len); CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,MICO_INDICATION_MINIMUM_LENGTH , len);
if(iei >0){ if(iei >0){
bitStream |= (iei&0xf0); bitStream |= (iei&0xf0);
} }
if(micoindication.raai){ if(micoindication.raai){
bitStream |= 0x01; bitStream |= 0x01;
} }
ENCODE_U8(buffer+encoded,bitStream,encoded); ENCODE_U8(buffer+encoded,bitStream,encoded);
return encoded; return encoded;
} }
int decode_mico_indication ( MICOIndication * micoindication, uint8_t iei, uint8_t * buffer, uint32_t len ) int decode_mico_indication ( MICOIndication * micoindication, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
int decoded=0; int decoded=0;
uint8_t ielen=0; uint8_t bitStream;
uint8_t bitStream; DECODE_U8(buffer+decoded,bitStream,decoded);
DECODE_U8(buffer+decoded,bitStream,decoded); if(iei != (bitStream&0xf0))
if(iei != (bitStream&0xf0)) return -1;
return -1; if(bitStream&0x01)
if(bitStream&0x01) micoindication->raai = true;
micoindication->raai = true;
return decoded;
return decoded;
} }
...@@ -8,40 +8,28 @@ ...@@ -8,40 +8,28 @@
int encode_message_authentication_code ( MessageAuthenticationCode messageauthenticationcode, uint8_t iei, uint8_t * buffer, uint32_t len ) int encode_message_authentication_code ( MessageAuthenticationCode messageauthenticationcode, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
uint8_t *lenPtr; uint32_t encoded = 0;
uint32_t encoded = 0; int encode_result;
int encode_result; CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,MESSAGE_AUTHENTICATION_CODE_MINIMUM_LENGTH , len);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,MESSAGE_AUTHENTICATION_CODE_MINIMUM_LENGTH , len);
if ((encode_result = encode_bstring (messageauthenticationcode, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
return encoded;
if ((encode_result = encode_bstring (messageauthenticationcode, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
return encoded;
} }
int decode_message_authentication_code ( MessageAuthenticationCode * messageauthenticationcode, uint8_t iei, uint8_t * buffer, uint32_t len ) int decode_message_authentication_code ( MessageAuthenticationCode * messageauthenticationcode, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
int decoded=0; int decoded=0;
uint8_t ielen=0; uint8_t ielen=0;
int decode_result; int decode_result;
if((decode_result = decode_bstring (messageauthenticationcode, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
decoded += decode_result;
if((decode_result = decode_bstring (messageauthenticationcode, ielen, buffer + decoded, len - decoded)) < 0) return decoded;
return decode_result;
else
decoded += decode_result;
return decoded;
} }
...@@ -8,17 +8,11 @@ ...@@ -8,17 +8,11 @@
int encode_message_type ( MessageType messagetype, uint8_t iei, uint8_t * buffer, uint32_t len ) int encode_message_type ( MessageType messagetype, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
/* /*
uint8_t *lenPtr; uint8_t *lenPtr;
uint32_t encoded = 0; uint32_t encoded = 0;
int encode_result; int encode_result;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,MESSAGE_TYPE_MINIMUM_LENGTH , len); CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,MESSAGE_TYPE_MINIMUM_LENGTH , len);
if ((encode_result = encode_bstring (messagetype, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度 if ((encode_result = encode_bstring (messagetype, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result; return encode_result;
...@@ -27,12 +21,12 @@ int encode_message_type ( MessageType messagetype, uint8_t iei, uint8_t * buffer ...@@ -27,12 +21,12 @@ int encode_message_type ( MessageType messagetype, uint8_t iei, uint8_t * buffer
return encoded; return encoded;
*/ */
} }
int decode_message_type ( MessageType * messagetype, uint8_t iei, uint8_t * buffer, uint32_t len ) int decode_message_type ( MessageType * messagetype, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
/* /*
int decoded=0; int decoded=0;
int decode_result; int decode_result;
...@@ -42,6 +36,6 @@ int decode_message_type ( MessageType * messagetype, uint8_t iei, uint8_t * buff ...@@ -42,6 +36,6 @@ int decode_message_type ( MessageType * messagetype, uint8_t iei, uint8_t * buff
else else
decoded += decode_result; decoded += decode_result;
return decoded; return decoded;
*/ */
} }
...@@ -8,56 +8,51 @@ ...@@ -8,56 +8,51 @@
int encode_nssai ( NSSAI nssai, uint8_t iei, uint8_t * buffer, uint32_t len ) int encode_nssai ( NSSAI nssai, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
uint8_t *lenPtr; uint8_t *lenPtr;
uint32_t encoded = 0; uint32_t encoded = 0;
int encode_result; CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,NSSAI_MINIMUM_LENGTH , len);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,NSSAI_MINIMUM_LENGTH , len);
if( iei >0 ) if( iei >0 )
{ {
*buffer=iei; *buffer=iei;
encoded++;
}
lenPtr = (buffer + encoded);
encoded++; encoded++;
}
lenPtr = (buffer + encoded);
encoded++;
/* /*
if ((encode_result = encode_bstring (nssai, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度 if ((encode_result = encode_bstring (nssai, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result; return encode_result;
else else
encoded += encode_result; encoded += encode_result;
*/ */
*lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0); *lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0);
return encoded; return encoded;
} }
int decode_nssai ( NSSAI * nssai, uint8_t iei, uint8_t * buffer, uint32_t len ) int decode_nssai ( NSSAI * nssai, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
int decoded=0; int decoded=0;
uint8_t ielen=0; uint8_t ielen=0;
int decode_result; int decode_result;
if (iei > 0) if (iei > 0)
{ {
CHECK_IEI_DECODER (iei, *buffer); CHECK_IEI_DECODER (iei, *buffer);
decoded++; decoded++;
} }
ielen = *(buffer + decoded); ielen = *(buffer + decoded);
decoded++; decoded++;
CHECK_LENGTH_DECODER (len - decoded, ielen); CHECK_LENGTH_DECODER (len - decoded, ielen);
if((decode_result = decode_bstring (nssai, ielen, buffer + decoded, len - decoded)) < 0) if((decode_result = decode_bstring (nssai, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result; return decode_result;
else else
decoded += decode_result; decoded += decode_result;
return decoded; return decoded;
} }
...@@ -8,43 +8,43 @@ ...@@ -8,43 +8,43 @@
int encode_network_slicing_indication ( NetworkSlicingIndication networkslicingindication, uint8_t iei, uint8_t * buffer, uint32_t len ) int encode_network_slicing_indication ( NetworkSlicingIndication networkslicingindication, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
uint32_t encoded = 0; uint32_t encoded = 0;
uint8_t bitStream = 0x0; uint8_t bitStream = 0x0;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,NETWORK_SLICING_INDICATION_MINIMUM_LENGTH , len); CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,NETWORK_SLICING_INDICATION_MINIMUM_LENGTH , len);
if(iei > 0){ if(iei > 0){
bitStream |= (iei & 0xf0); bitStream |= (iei & 0xf0);
} }
bitStream |= ((networkslicingindication.dcni&0x01)<<1); bitStream |= ((networkslicingindication.dcni&0x01)<<1);
bitStream |= ((networkslicingindication.nssci&0x01)); bitStream |= ((networkslicingindication.nssci&0x01));
ENCODE_U8(buffer+encoded,bitStream,encoded); ENCODE_U8(buffer+encoded,bitStream,encoded);
return encoded; return encoded;
} }
int decode_network_slicing_indication ( NetworkSlicingIndication * networkslicingindication, uint8_t iei, uint8_t * buffer, uint32_t len ) int decode_network_slicing_indication ( NetworkSlicingIndication * networkslicingindication, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
int decoded=0; int decoded=0;
uint8_t bitStream = 0x0; uint8_t bitStream = 0x0;
DECODE_U8(buffer+decoded,bitStream,decoded); DECODE_U8(buffer+decoded,bitStream,decoded);
if(iei != bitStream&0xf0){ if(iei != (bitStream&0xf0)){
return -1; return -1;
} }
if(iei > 0){ if(iei > 0){
bitStream = (bitStream & 0x0f); bitStream = (bitStream & 0x0f);
} }
//networkslicingindication->dcni = bitStream&0x02; //networkslicingindication->dcni = bitStream&0x02;
networkslicingindication->dcni = (bitStream &0x02)>>1; networkslicingindication->dcni = (bitStream &0x02)>>1;
networkslicingindication->nssci = bitStream&0x01; networkslicingindication->nssci = bitStream&0x01;
return decoded; return decoded;
} }
...@@ -8,40 +8,28 @@ ...@@ -8,40 +8,28 @@
int encode_network_slicing_information ( NetworkSlicingInformation networkslicinginformation, uint8_t iei, uint8_t * buffer, uint32_t len ) int encode_network_slicing_information ( NetworkSlicingInformation networkslicinginformation, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
uint8_t *lenPtr; uint32_t encoded = 0;
uint32_t encoded = 0; int encode_result;
int encode_result; CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,NETWORK_SLICING_INFORMATION_MINIMUM_LENGTH , len);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,NETWORK_SLICING_INFORMATION_MINIMUM_LENGTH , len);
if ((encode_result = encode_bstring (networkslicinginformation, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
return encoded;
if ((encode_result = encode_bstring (networkslicinginformation, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
return encoded;
} }
int decode_network_slicing_information ( NetworkSlicingInformation * networkslicinginformation, uint8_t iei, uint8_t * buffer, uint32_t len ) int decode_network_slicing_information ( NetworkSlicingInformation * networkslicinginformation, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
int decoded=0; int decoded=0;
uint8_t ielen=0; uint8_t ielen=0;
int decode_result; int decode_result;
if((decode_result = decode_bstring (networkslicinginformation, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
decoded += decode_result;
if((decode_result = decode_bstring (networkslicinginformation, ielen, buffer + decoded, len - decoded)) < 0) return decoded;
return decode_result;
else
decoded += decode_result;
return decoded;
} }
...@@ -26,7 +26,7 @@ int encode_pdu_address ( PDUAddress pduaddress, uint8_t iei, uint8_t * buffer, u ...@@ -26,7 +26,7 @@ int encode_pdu_address ( PDUAddress pduaddress, uint8_t iei, uint8_t * buffer, u
ENCODE_U8(buffer+encoded,(uint8_t)(pduaddress.pdu_session_type_value&0x07),encoded); ENCODE_U8(buffer+encoded,(uint8_t)(pduaddress.pdu_session_type_value&0x07),encoded);
if ((encode_result = encode_bstring (pduaddress.pdu_address_information, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度 if ((encode_result = encode_bstring (pduaddress.pdu_address_information, buffer + encoded, len - encoded)) < 0)
return encode_result; return encode_result;
else else
encoded += encode_result; encoded += encode_result;
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#define PDU_ADDRESS_IPV4V6 0x03 #define PDU_ADDRESS_IPV4V6 0x03
typedef struct{ typedef struct{
uint8_t spare:5;
uint8_t pdu_session_type_value:3; uint8_t pdu_session_type_value:3;
bstring pdu_address_information; bstring pdu_address_information;
}PDUAddress; }PDUAddress;
......
...@@ -8,40 +8,28 @@ ...@@ -8,40 +8,28 @@
int encode_pdu_session_identity ( PDUSessionIdentity pdusessionidentity, uint8_t iei, uint8_t * buffer, uint32_t len ) int encode_pdu_session_identity ( PDUSessionIdentity pdusessionidentity, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
uint8_t *lenPtr; uint32_t encoded = 0;
uint32_t encoded = 0; int encode_result;
int encode_result; CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,PDU_SESSION_IDENTITY_MINIMUM_LENGTH , len);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,PDU_SESSION_IDENTITY_MINIMUM_LENGTH , len);
if ((encode_result = encode_bstring (pdusessionidentity, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
return encoded;
if ((encode_result = encode_bstring (pdusessionidentity, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
return encoded;
} }
int decode_pdu_session_identity ( PDUSessionIdentity * pdusessionidentity, uint8_t iei, uint8_t * buffer, uint32_t len ) int decode_pdu_session_identity ( PDUSessionIdentity * pdusessionidentity, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
int decoded=0; int decoded=0;
uint8_t ielen=0; uint8_t ielen=0;
int decode_result; int decode_result;
if((decode_result = decode_bstring (pdusessionidentity, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
decoded += decode_result;
if((decode_result = decode_bstring (pdusessionidentity, ielen, buffer + decoded, len - decoded)) < 0) return decoded;
return decode_result;
else
decoded += decode_result;
return decoded;
} }
...@@ -8,50 +8,39 @@ ...@@ -8,50 +8,39 @@
int encode_pdu_session_identity2 ( PDUSessionIdentity2 pdusessionidentity2, uint8_t iei, uint8_t * buffer, uint32_t len ) int encode_pdu_session_identity2 ( PDUSessionIdentity2 pdusessionidentity2, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
uint8_t *lenPtr; uint32_t encoded = 0;
uint32_t encoded = 0; int encode_result;
int encode_result; CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,PDU_SESSION_IDENTITY2_MINIMUM_LENGTH , len);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,PDU_SESSION_IDENTITY2_MINIMUM_LENGTH , len); if( iei >0 )
{
*buffer=iei;
if( iei >0 ) encoded++;
{ }
*buffer=iei;
encoded++; if ((encode_result = encode_bstring (pdusessionidentity2, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
} return encode_result;
else
encoded += encode_result;
return encoded;
if ((encode_result = encode_bstring (pdusessionidentity2, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
return encoded;
} }
int decode_pdu_session_identity2 ( PDUSessionIdentity2 * pdusessionidentity2, uint8_t iei, uint8_t * buffer, uint32_t len ) int decode_pdu_session_identity2 ( PDUSessionIdentity2 * pdusessionidentity2, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
int decoded=0; int decoded=0;
uint8_t ielen=0; uint8_t ielen=0;
int decode_result; int decode_result;
if (iei > 0) if (iei > 0)
{ {
CHECK_IEI_DECODER (iei, *buffer); CHECK_IEI_DECODER (iei, *buffer);
decoded++; decoded++;
} }
if((decode_result = decode_bstring (pdusessionidentity2, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
if((decode_result = decode_bstring (pdusessionidentity2, ielen, buffer + decoded, len - decoded)) < 0) decoded += decode_result;
return decode_result; return decoded;
else
decoded += decode_result;
return decoded;
} }
...@@ -8,40 +8,28 @@ ...@@ -8,40 +8,28 @@
int encode_plain_5gsnas_message ( Plain5GSNASMessage plain5gsnasmessage, uint8_t iei, uint8_t * buffer, uint32_t len ) int encode_plain_5gsnas_message ( Plain5GSNASMessage plain5gsnasmessage, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
uint8_t *lenPtr; uint32_t encoded = 0;
uint32_t encoded = 0; int encode_result;
int encode_result; CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,PLAIN_5GSNAS_MESSAGE_MINIMUM_LENGTH , len);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,PLAIN_5GSNAS_MESSAGE_MINIMUM_LENGTH , len);
if ((encode_result = encode_bstring (plain5gsnasmessage, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
return encoded;
if ((encode_result = encode_bstring (plain5gsnasmessage, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
return encoded;
} }
int decode_plain_5gsnas_message ( Plain5GSNASMessage * plain5gsnasmessage, uint8_t iei, uint8_t * buffer, uint32_t len ) int decode_plain_5gsnas_message ( Plain5GSNASMessage * plain5gsnasmessage, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
int decoded=0; int decoded=0;
uint8_t ielen=0; uint8_t ielen=0;
int decode_result; int decode_result;
if((decode_result = decode_bstring (plain5gsnasmessage, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
decoded += decode_result;
if((decode_result = decode_bstring (plain5gsnasmessage, ielen, buffer + decoded, len - decoded)) < 0) return decoded;
return decode_result;
else
decoded += decode_result;
return decoded;
} }
...@@ -8,40 +8,28 @@ ...@@ -8,40 +8,28 @@
int encode_procedure_transaction_identity ( ProcedureTransactionIdentity proceduretransactionidentity, uint8_t iei, uint8_t * buffer, uint32_t len ) int encode_procedure_transaction_identity ( ProcedureTransactionIdentity proceduretransactionidentity, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
uint8_t *lenPtr; uint32_t encoded = 0;
uint32_t encoded = 0; int encode_result;
int encode_result; CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,PROCEDURE_TRANSACTION_IDENTITY_MINIMUM_LENGTH , len);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,PROCEDURE_TRANSACTION_IDENTITY_MINIMUM_LENGTH , len);
if ((encode_result = encode_bstring (proceduretransactionidentity, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
return encoded;
if ((encode_result = encode_bstring (proceduretransactionidentity, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
return encoded;
} }
int decode_procedure_transaction_identity ( ProcedureTransactionIdentity * proceduretransactionidentity, uint8_t iei, uint8_t * buffer, uint32_t len ) int decode_procedure_transaction_identity ( ProcedureTransactionIdentity * proceduretransactionidentity, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
int decoded=0; int decoded=0;
uint8_t ielen=0; uint8_t ielen=0;
int decode_result; int decode_result;
if((decode_result = decode_bstring (proceduretransactionidentity, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
decoded += decode_result;
if((decode_result = decode_bstring (proceduretransactionidentity, ielen, buffer + decoded, len - decoded)) < 0) return decoded;
return decode_result;
else
decoded += decode_result;
return decoded;
} }
This diff is collapsed.
...@@ -118,5 +118,6 @@ typedef struct{ ...@@ -118,5 +118,6 @@ typedef struct{
int encode_qos_flow_descriptions ( QOSFlowDescriptions qosflowdescriptions, uint8_t iei, uint8_t * buffer, uint32_t len ) ; int encode_qos_flow_descriptions ( QOSFlowDescriptions qosflowdescriptions, uint8_t iei, uint8_t * buffer, uint32_t len ) ;
int decode_qos_flow_descriptions ( QOSFlowDescriptions * qosflowdescriptions, uint8_t iei, uint8_t * buffer, uint32_t len ) ; int decode_qos_flow_descriptions ( QOSFlowDescriptions * qosflowdescriptions, uint8_t iei, uint8_t * buffer, uint32_t len ) ;
void free_decode_qos_flow_descriptions(QOSFlowDescriptions * qosflowdescriptions);
#endif #endif
This diff is collapsed.
...@@ -88,7 +88,8 @@ typedef struct{ ...@@ -88,7 +88,8 @@ typedef struct{
QOSRulesIE *qosrulesie; QOSRulesIE *qosrulesie;
}QOSRules; }QOSRules;
int encode_qos_rules ( QOSRules qosrules, uint8_t iei, uint8_t * buffer, uint32_t len ) ; int encode_qos_rules ( QOSRules qosrules, uint8_t iei, uint8_t * buffer, uint32_t len );
int decode_qos_rules ( QOSRules * qosrules, uint8_t iei, uint8_t * buffer, uint32_t len ) ; int decode_qos_rules ( QOSRules * qosrules, uint8_t iei, uint8_t * buffer, uint32_t len);
void free_decode_qos_rules(QOSRules * qosrules);
#endif #endif
...@@ -8,40 +8,28 @@ ...@@ -8,40 +8,28 @@
int encode_request_type ( RequestType requesttype, uint8_t iei, uint8_t * buffer, uint32_t len ) int encode_request_type ( RequestType requesttype, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
uint8_t *lenPtr; uint32_t encoded = 0;
uint32_t encoded = 0; int encode_result;
int encode_result; CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,REQUEST_TYPE_MINIMUM_LENGTH , len);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,REQUEST_TYPE_MINIMUM_LENGTH , len);
if ((encode_result = encode_bstring (requesttype, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
return encoded;
if ((encode_result = encode_bstring (requesttype, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
return encoded;
} }
int decode_request_type ( RequestType * requesttype, uint8_t iei, uint8_t * buffer, uint32_t len ) int decode_request_type ( RequestType * requesttype, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
int decoded=0; int decoded=0;
uint8_t ielen=0; uint8_t ielen=0;
int decode_result; int decode_result;
if((decode_result = decode_bstring (requesttype, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
decoded += decode_result;
if((decode_result = decode_bstring (requesttype, ielen, buffer + decoded, len - decoded)) < 0) return decoded;
return decode_result;
else
decoded += decode_result;
return decoded;
} }
...@@ -8,45 +8,43 @@ ...@@ -8,45 +8,43 @@
int encode_s1_ue_network_capability ( S1UENetworkCapability s1uenetworkcapability, uint8_t iei, uint8_t * buffer, uint32_t len ) int encode_s1_ue_network_capability ( S1UENetworkCapability s1uenetworkcapability, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
uint8_t *lenPtr; uint8_t *lenPtr;
uint32_t encoded = 0; uint32_t encoded = 0;
int encode_result; CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,S1_UE_NETWORK_CAPABILITY_MINIMUM_LENGTH , len);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,S1_UE_NETWORK_CAPABILITY_MINIMUM_LENGTH , len);
if( iei >0 ){ if( iei >0 ){
*buffer=iei; *buffer=iei;
encoded++;
}
lenPtr = (buffer + encoded);
encoded++; encoded++;
}
lenPtr = (buffer + encoded);
encoded++;
ENCODE_U8(buffer+encoded,s1uenetworkcapability.eea,encoded); ENCODE_U8(buffer+encoded,s1uenetworkcapability.eea,encoded);
ENCODE_U8(buffer+encoded,s1uenetworkcapability.eia,encoded); ENCODE_U8(buffer+encoded,s1uenetworkcapability.eia,encoded);
*lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0); *lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0);
return encoded; return encoded;
} }
int decode_s1_ue_network_capability ( S1UENetworkCapability * s1uenetworkcapability, uint8_t iei, uint8_t * buffer, uint32_t len ) int decode_s1_ue_network_capability ( S1UENetworkCapability * s1uenetworkcapability, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
int decoded=0; int decoded=0;
uint8_t ielen=0; uint8_t ielen=0;
int decode_result;
if (iei > 0) if (iei > 0)
{ {
CHECK_IEI_DECODER (iei, *buffer); CHECK_IEI_DECODER (iei, *buffer);
decoded++;
}
ielen = *(buffer + decoded);
decoded++; decoded++;
CHECK_LENGTH_DECODER (len - decoded, ielen); }
ielen = *(buffer + decoded);
decoded++;
CHECK_LENGTH_DECODER (len - decoded, ielen);
DECODE_U8(buffer+decoded,s1uenetworkcapability->eea,decoded); DECODE_U8(buffer+decoded,s1uenetworkcapability->eea,decoded);
DECODE_U8(buffer+decoded,s1uenetworkcapability->eia,decoded); DECODE_U8(buffer+decoded,s1uenetworkcapability->eia,decoded);
return decoded; return decoded;
} }
...@@ -8,40 +8,28 @@ ...@@ -8,40 +8,28 @@
int encode_sms_indication ( SMSIndication smsindication, uint8_t iei, uint8_t * buffer, uint32_t len ) int encode_sms_indication ( SMSIndication smsindication, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
uint8_t *lenPtr; uint32_t encoded = 0;
uint32_t encoded = 0; int encode_result;
int encode_result; CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,SMS_INDICATION_MINIMUM_LENGTH , len);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,SMS_INDICATION_MINIMUM_LENGTH , len);
if ((encode_result = encode_bstring (smsindication, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
return encoded;
if ((encode_result = encode_bstring (smsindication, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
return encoded;
} }
int decode_sms_indication ( SMSIndication * smsindication, uint8_t iei, uint8_t * buffer, uint32_t len ) int decode_sms_indication ( SMSIndication * smsindication, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
int decoded=0; int decoded=0;
uint8_t ielen=0; uint8_t ielen=0;
int decode_result; int decode_result;
if((decode_result = decode_bstring (smsindication, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
decoded += decode_result;
if((decode_result = decode_bstring (smsindication, ielen, buffer + decoded, len - decoded)) < 0) return decoded;
return decode_result;
else
decoded += decode_result;
return decoded;
} }
...@@ -8,40 +8,37 @@ ...@@ -8,40 +8,37 @@
int encode_ssc_mode ( SSCMode sscmode, uint8_t iei, uint8_t * buffer, uint32_t len ) int encode_ssc_mode ( SSCMode sscmode, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
uint32_t encoded = 0; uint32_t encoded = 0;
uint8_t bitStream = 0x00; uint8_t bitStream = 0x00;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,SSC_MODE_MINIMUM_LENGTH , len); CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,SSC_MODE_MINIMUM_LENGTH , len);
if(iei > 0){
if(iei > 0){ bitStream |= (iei & 0xf0);
bitStream |= (iei & 0xf0); }
}
bitStream |= (sscmode.ssc_mode_value & 0x07);
ENCODE_U8(buffer+encoded,bitStream,encoded);
bitStream |= (sscmode.ssc_mode_value & 0x07);
ENCODE_U8(buffer+encoded,bitStream,encoded);
return encoded; return encoded;
} }
int decode_ssc_mode ( SSCMode * sscmode, uint8_t iei, uint8_t * buffer, uint32_t len ) int decode_ssc_mode ( SSCMode * sscmode, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
int decoded=0; int decoded=0;
uint8_t bitStream = 0x00; uint8_t bitStream = 0x00;
DECODE_U8(buffer+decoded,bitStream,decoded);
DECODE_U8(buffer+decoded,bitStream,decoded);
if(iei != (bitStream&0xf0)){
if(iei != bitStream&0xf0){ return -1;
return -1; }
}
if(iei > 0){
if(iei > 0){ bitStream = (bitStream & 0x07);
bitStream = (bitStream & 0x07); }
}
sscmode->ssc_mode_value = bitStream;
sscmode->ssc_mode_value = bitStream;
return decoded;
return decoded;
} }
...@@ -8,23 +8,15 @@ ...@@ -8,23 +8,15 @@
int encode_security_header_type ( SecurityHeaderType securityheadertype, uint8_t iei, uint8_t * buffer, uint32_t len ) int encode_security_header_type ( SecurityHeaderType securityheadertype, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
uint8_t *lenPtr;
uint32_t encoded = 0; uint32_t encoded = 0;
int encode_result; int encode_result;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,SECURITY_HEADER_TYPE_MINIMUM_LENGTH , len); CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,SECURITY_HEADER_TYPE_MINIMUM_LENGTH , len);
if ((encode_result = encode_bstring (securityheadertype, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度 if ((encode_result = encode_bstring (securityheadertype, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result; return encode_result;
else else
encoded += encode_result; encoded += encode_result;
return encoded; return encoded;
} }
...@@ -34,10 +26,6 @@ int decode_security_header_type ( SecurityHeaderType * securityheadertype, uint8 ...@@ -34,10 +26,6 @@ int decode_security_header_type ( SecurityHeaderType * securityheadertype, uint8
uint8_t ielen=0; uint8_t ielen=0;
int decode_result; int decode_result;
if((decode_result = decode_bstring (securityheadertype, ielen, buffer + decoded, len - decoded)) < 0) if((decode_result = decode_bstring (securityheadertype, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result; return decode_result;
else else
......
...@@ -8,40 +8,28 @@ ...@@ -8,40 +8,28 @@
int encode_sequence_number ( SequenceNumber sequencenumber, uint8_t iei, uint8_t * buffer, uint32_t len ) int encode_sequence_number ( SequenceNumber sequencenumber, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
uint8_t *lenPtr; uint32_t encoded = 0;
uint32_t encoded = 0; int encode_result;
int encode_result; CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,SEQUENCE_NUMBER_MINIMUM_LENGTH , len);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,SEQUENCE_NUMBER_MINIMUM_LENGTH , len);
if ((encode_result = encode_bstring (sequencenumber, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
return encoded;
if ((encode_result = encode_bstring (sequencenumber, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
return encoded;
} }
int decode_sequence_number ( SequenceNumber * sequencenumber, uint8_t iei, uint8_t * buffer, uint32_t len ) int decode_sequence_number ( SequenceNumber * sequencenumber, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
int decoded=0; int decoded=0;
uint8_t ielen=0; uint8_t ielen=0;
int decode_result; int decode_result;
if((decode_result = decode_bstring (sequencenumber, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
decoded += decode_result;
if((decode_result = decode_bstring (sequencenumber, ielen, buffer + decoded, len - decoded)) < 0) return decoded;
return decode_result;
else
decoded += decode_result;
return decoded;
} }
...@@ -8,40 +8,28 @@ ...@@ -8,40 +8,28 @@
int encode_service_type ( ServiceType servicetype, uint8_t iei, uint8_t * buffer, uint32_t len ) int encode_service_type ( ServiceType servicetype, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
uint8_t *lenPtr; uint32_t encoded = 0;
uint32_t encoded = 0; int encode_result;
int encode_result; CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,SERVICE_TYPE_MINIMUM_LENGTH , len);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,SERVICE_TYPE_MINIMUM_LENGTH , len);
if ((encode_result = encode_bstring (servicetype, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
return encoded;
if ((encode_result = encode_bstring (servicetype, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
return encoded;
} }
int decode_service_type ( ServiceType * servicetype, uint8_t iei, uint8_t * buffer, uint32_t len ) int decode_service_type ( ServiceType * servicetype, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
int decoded=0; int decoded=0;
uint8_t ielen=0; uint8_t ielen=0;
int decode_result; int decode_result;
if((decode_result = decode_bstring (servicetype, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
decoded += decode_result;
if((decode_result = decode_bstring (servicetype, ielen, buffer + decoded, len - decoded)) < 0) return decoded;
return decode_result;
else
decoded += decode_result;
return decoded;
} }
...@@ -8,72 +8,71 @@ ...@@ -8,72 +8,71 @@
int encode_session_ambr ( SessionAMBR sessionambr, uint8_t iei, uint8_t * buffer, uint32_t len ) int encode_session_ambr ( SessionAMBR sessionambr, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
uint8_t *lenPtr = NULL; uint8_t *lenPtr = NULL;
uint32_t encoded = 0; uint32_t encoded = 0;
int encode_result; CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,((iei > 0) ? SESSION_AMBR_MINIMUM_LENGTH_TLV : SESSION_AMBR_MINIMUM_LENGTH_LV) , len);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,((iei > 0) ? SESSION_AMBR_MINIMUM_LENGTH_TLV : SESSION_AMBR_MINIMUM_LENGTH_LV) , len);
if( iei >0 )
if( iei >0 ) {
{ *buffer=iei;
*buffer=iei;
encoded++;
}
lenPtr = (buffer + encoded);
encoded++; encoded++;
}
lenPtr = (buffer + encoded);
encoded++;
ENCODE_U8(buffer+encoded,sessionambr.uint_for_session_ambr_for_downlink,encoded);
*(buffer + encoded) = sessionambr.session_ambr_for_downlink/(1<<8);
encoded++;
*(buffer + encoded) = sessionambr.session_ambr_for_downlink%(1<<8);
encoded++;
ENCODE_U8(buffer+encoded,sessionambr.uint_for_session_ambr_for_uplink,encoded);
*(buffer + encoded) = sessionambr.session_ambr_for_uplink/(1<<8);
encoded++;
*(buffer + encoded) = sessionambr.session_ambr_for_uplink%(1<<8);
encoded++;
ENCODE_U8(buffer+encoded,sessionambr.uint_for_session_ambr_for_downlink,encoded); *lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0);
*(buffer + encoded) = sessionambr.session_ambr_for_downlink/(1<<8);
encoded++; return encoded;
*(buffer + encoded) = sessionambr.session_ambr_for_downlink%(1<<8);
encoded++;
ENCODE_U8(buffer+encoded,sessionambr.uint_for_session_ambr_for_uplink,encoded);
*(buffer + encoded) = sessionambr.session_ambr_for_uplink/(1<<8);
encoded++;
*(buffer + encoded) = sessionambr.session_ambr_for_uplink%(1<<8);
encoded++;
*lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0);
return encoded;
} }
int decode_session_ambr ( SessionAMBR * sessionambr, uint8_t iei, uint8_t * buffer, uint32_t len ) int decode_session_ambr ( SessionAMBR * sessionambr, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
int decoded=0; int decoded=0;
uint8_t ielen=0; uint8_t ielen=0;
uint8_t bit8Stream = 0; uint8_t bit8Stream = 0;
uint16_t bit16Stream = 0; uint16_t bit16Stream = 0;
if (iei > 0) if (iei > 0)
{ {
CHECK_IEI_DECODER (iei, *buffer); CHECK_IEI_DECODER (iei, *buffer);
decoded++;
}
ielen = *(buffer + decoded);
decoded++; decoded++;
CHECK_LENGTH_DECODER (len - decoded, ielen); }
ielen = *(buffer + decoded);
decoded++;
CHECK_LENGTH_DECODER (len - decoded, ielen);
DECODE_U8(buffer+decoded,bit8Stream,decoded); DECODE_U8(buffer+decoded,bit8Stream,decoded);
sessionambr->uint_for_session_ambr_for_downlink = bit8Stream; sessionambr->uint_for_session_ambr_for_downlink = bit8Stream;
bit16Stream = *(buffer + decoded); bit16Stream = *(buffer + decoded);
decoded++; decoded++;
bit16Stream = ( bit16Stream << 8)+*(buffer + decoded); bit16Stream = ( bit16Stream << 8)+*(buffer + decoded);
decoded++; decoded++;
sessionambr->session_ambr_for_downlink = bit16Stream; sessionambr->session_ambr_for_downlink = bit16Stream;
DECODE_U8(buffer+decoded,bit8Stream,decoded); DECODE_U8(buffer+decoded,bit8Stream,decoded);
sessionambr->uint_for_session_ambr_for_uplink = bit8Stream; sessionambr->uint_for_session_ambr_for_uplink = bit8Stream;
bit16Stream = *(buffer + decoded); bit16Stream = *(buffer + decoded);
decoded++; decoded++;
bit16Stream = ( bit16Stream << 8)+*(buffer + decoded); bit16Stream = ( bit16Stream << 8)+*(buffer + decoded);
decoded++; decoded++;
sessionambr->session_ambr_for_uplink = bit16Stream; sessionambr->session_ambr_for_uplink = bit16Stream;
return decoded; return decoded;
} }
...@@ -8,50 +8,40 @@ ...@@ -8,50 +8,40 @@
int encode_time_zone_and_time ( TimeZoneAndTime timezoneandtime, uint8_t iei, uint8_t * buffer, uint32_t len ) int encode_time_zone_and_time ( TimeZoneAndTime timezoneandtime, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
uint8_t *lenPtr; uint32_t encoded = 0;
uint32_t encoded = 0; int encode_result;
int encode_result; CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,TIME_ZONE_AND_TIME_MINIMUM_LENGTH , len);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,TIME_ZONE_AND_TIME_MINIMUM_LENGTH , len);
if( iei >0 )
{
if( iei >0 ) *buffer=iei;
{ encoded++;
*buffer=iei; }
encoded++;
} if ((encode_result = encode_bstring (timezoneandtime, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
return encoded;
if ((encode_result = encode_bstring (timezoneandtime, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
return encoded;
} }
int decode_time_zone_and_time ( TimeZoneAndTime * timezoneandtime, uint8_t iei, uint8_t * buffer, uint32_t len ) int decode_time_zone_and_time ( TimeZoneAndTime * timezoneandtime, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
int decoded=0; int decoded=0;
uint8_t ielen=0; uint8_t ielen=0;
int decode_result; int decode_result;
if (iei > 0) if (iei > 0)
{ {
CHECK_IEI_DECODER (iei, *buffer); CHECK_IEI_DECODER (iei, *buffer);
decoded++; decoded++;
} }
if((decode_result = decode_bstring (timezoneandtime, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
if((decode_result = decode_bstring (timezoneandtime, ielen, buffer + decoded, len - decoded)) < 0) decoded += decode_result;
return decode_result; return decoded;
else
decoded += decode_result;
return decoded;
} }
...@@ -8,45 +8,43 @@ ...@@ -8,45 +8,43 @@
int encode_ue_security_capability ( UESecurityCapability uesecuritycapability, uint8_t iei, uint8_t * buffer, uint32_t len ) int encode_ue_security_capability ( UESecurityCapability uesecuritycapability, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
uint8_t *lenPtr; uint8_t *lenPtr;
uint32_t encoded = 0; uint32_t encoded = 0;
int encode_result; CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,UE_SECURITY_CAPABILITY_MINIMUM_LENGTH , len);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,UE_SECURITY_CAPABILITY_MINIMUM_LENGTH , len);
if( iei >0 ){
if( iei >0 ){ *buffer=iei;
*buffer=iei;
encoded++;
}
lenPtr = (buffer + encoded);
encoded++; encoded++;
}
lenPtr = (buffer + encoded);
encoded++;
ENCODE_U8(buffer+encoded, uesecuritycapability.nea, encoded); ENCODE_U8(buffer+encoded, uesecuritycapability.nea, encoded);
ENCODE_U8(buffer+encoded, uesecuritycapability.nia, encoded); ENCODE_U8(buffer+encoded, uesecuritycapability.nia, encoded);
*lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0); *lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0);
return encoded; return encoded;
} }
int decode_ue_security_capability ( UESecurityCapability * uesecuritycapability, uint8_t iei, uint8_t * buffer, uint32_t len ) int decode_ue_security_capability ( UESecurityCapability * uesecuritycapability, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
int decoded=0; int decoded=0;
uint8_t ielen=0; uint8_t ielen=0;
int decode_result;
if (iei > 0) if (iei > 0)
{ {
CHECK_IEI_DECODER (iei, *buffer); CHECK_IEI_DECODER (iei, *buffer);
decoded++;
}
ielen = *(buffer + decoded);
decoded++; decoded++;
CHECK_LENGTH_DECODER (len - decoded, ielen); }
ielen = *(buffer + decoded);
decoded++;
CHECK_LENGTH_DECODER (len - decoded, ielen);
DECODE_U8(buffer+decoded, uesecuritycapability->nea, decoded); DECODE_U8(buffer+decoded, uesecuritycapability->nea, decoded);
DECODE_U8(buffer+decoded, uesecuritycapability->nia, decoded); DECODE_U8(buffer+decoded, uesecuritycapability->nia, decoded);
return decoded; return decoded;
} }
...@@ -8,43 +8,41 @@ ...@@ -8,43 +8,41 @@
int encode_uplink_data_status ( UplinkDataStatus uplinkdatastatus, uint8_t iei, uint8_t * buffer, uint32_t len ) int encode_uplink_data_status ( UplinkDataStatus uplinkdatastatus, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
uint8_t *lenPtr; uint8_t *lenPtr;
uint32_t encoded = 0; uint32_t encoded = 0;
int encode_result; CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,UPLINK_DATA_STATUS_MINIMUM_LENGTH , len);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,UPLINK_DATA_STATUS_MINIMUM_LENGTH , len);
if( iei >0 ){
if( iei >0 ){ *buffer=iei;
*buffer=iei;
encoded++;
}
lenPtr = (buffer + encoded);
encoded++; encoded++;
}
lenPtr = (buffer + encoded);
encoded++;
ENCODE_U16(buffer+encoded, uplinkdatastatus, encoded); ENCODE_U16(buffer+encoded, uplinkdatastatus, encoded);
*lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0); *lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0);
return encoded; return encoded;
} }
int decode_uplink_data_status ( UplinkDataStatus * uplinkdatastatus, uint8_t iei, uint8_t * buffer, uint32_t len ) int decode_uplink_data_status ( UplinkDataStatus * uplinkdatastatus, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
int decoded=0; int decoded=0;
uint8_t ielen=0; uint8_t ielen=0;
int decode_result;
if (iei > 0) if (iei > 0)
{ {
CHECK_IEI_DECODER (iei, *buffer); CHECK_IEI_DECODER (iei, *buffer);
decoded++;
}
ielen = *(buffer + decoded);
decoded++; decoded++;
CHECK_LENGTH_DECODER (len - decoded, ielen); }
ielen = *(buffer + decoded);
decoded++;
CHECK_LENGTH_DECODER (len - decoded, ielen);
DECODE_U16(buffer+decoded, *uplinkdatastatus,decoded); DECODE_U16(buffer+decoded, *uplinkdatastatus,decoded);
return decoded; return decoded;
} }
...@@ -8,68 +8,65 @@ ...@@ -8,68 +8,65 @@
int encode__5gmm_capability ( _5GMMCapability _5gmmcapability, uint8_t iei, uint8_t * buffer, uint32_t len ) int encode__5gmm_capability ( _5GMMCapability _5gmmcapability, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
uint8_t *lenPtr; uint8_t *lenPtr;
uint32_t encoded = 0; uint32_t encoded = 0;
int encode_result;
uint8_t _5gmmcapability_bits = 0;
uint8_t _5gmmcapability_bits = 0;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,_5GMM_CAPABILITY_MINIMUM_LENGTH , len);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,_5GMM_CAPABILITY_MINIMUM_LENGTH , len);
if( iei >0 ){
if( iei >0 ){ *buffer=iei;
*buffer=iei;
encoded++;
}
lenPtr = (buffer + encoded);
encoded++; encoded++;
}
lenPtr = (buffer + encoded);
encoded++;
if(_5gmmcapability.is_LPP_supported) if(_5gmmcapability.is_LPP_supported)
_5gmmcapability_bits |= 0x04; _5gmmcapability_bits |= 0x04;
if(_5gmmcapability.is_HO_supported) if(_5gmmcapability.is_HO_supported)
_5gmmcapability_bits |= 0x02; _5gmmcapability_bits |= 0x02;
if(_5gmmcapability.is_S1_mode_supported) if(_5gmmcapability.is_S1_mode_supported)
_5gmmcapability_bits |= 0x01; _5gmmcapability_bits |= 0x01;
ENCODE_U8(buffer+encoded, _5gmmcapability_bits, encoded); ENCODE_U8(buffer+encoded, _5gmmcapability_bits, encoded);
*lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0); *lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0);
return encoded; return encoded;
} }
int decode__5gmm_capability ( _5GMMCapability * _5gmmcapability, uint8_t iei, uint8_t * buffer, uint32_t len ) int decode__5gmm_capability ( _5GMMCapability * _5gmmcapability, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
int decoded=0; int decoded=0;
uint8_t ielen=0; uint8_t ielen=0;
int decode_result;
uint8_t _5gmmcapability_bits = 0;
uint8_t _5gmmcapability_bits = 0;
uint8_t otherInformation = 0; if (iei > 0){
CHECK_IEI_DECODER (iei, *buffer);
if (iei > 0){
CHECK_IEI_DECODER (iei, *buffer);
decoded++;
}
ielen = *(buffer + decoded);
decoded++; decoded++;
CHECK_LENGTH_DECODER (len - decoded, ielen); }
ielen = *(buffer + decoded);
decoded++;
CHECK_LENGTH_DECODER (len - decoded, ielen);
DECODE_U8(buffer+decoded,_5gmmcapability_bits,decoded); DECODE_U8(buffer+decoded,_5gmmcapability_bits,decoded);
if(_5gmmcapability_bits & 0x04) if(_5gmmcapability_bits & 0x04)
_5gmmcapability->is_LPP_supported = true; _5gmmcapability->is_LPP_supported = true;
else else
_5gmmcapability->is_LPP_supported = false; _5gmmcapability->is_LPP_supported = false;
if(_5gmmcapability_bits & 0x02) if(_5gmmcapability_bits & 0x02)
_5gmmcapability->is_HO_supported = true; _5gmmcapability->is_HO_supported = true;
else else
_5gmmcapability->is_HO_supported = false; _5gmmcapability->is_HO_supported = false;
if(_5gmmcapability_bits & 0x01) if(_5gmmcapability_bits & 0x01)
_5gmmcapability->is_S1_mode_supported = true; _5gmmcapability->is_S1_mode_supported = true;
else else
_5gmmcapability->is_S1_mode_supported = false; _5gmmcapability->is_S1_mode_supported = false;
return decoded; return decoded;
} }
...@@ -8,58 +8,58 @@ ...@@ -8,58 +8,58 @@
int encode__5gs_mobile_identity ( _5GSMobileIdentity _5gsmobileidentity, uint8_t iei, uint8_t * buffer, uint32_t len ) int encode__5gs_mobile_identity ( _5GSMobileIdentity _5gsmobileidentity, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
uint8_t *lenPtr; uint8_t *lenPtr;
uint32_t encoded = 0; uint32_t encoded = 0;
int encode_result; int encode_result;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,_5GS_MOBILE_IDENTITY_MINIMUM_LENGTH , len); CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,_5GS_MOBILE_IDENTITY_MINIMUM_LENGTH , len);
lenPtr = (buffer + encoded);
encoded++;
encoded++;
switch(_5gsmobileidentity.IdentityType){ lenPtr = (buffer + encoded);
case _5G_GUTI: encoded++;
break; encoded++;
case IMEI:
case IMEISV:
break;
case SUCI:
case IMSI:
break;
}
uint32_t res = encoded - 1 - ((iei > 0) ? 1 : 0); switch(_5gsmobileidentity.IdentityType){
*lenPtr =res/(1<<8); case _5G_GUTI:
lenPtr++; break;
*lenPtr = res%(1<<8); case IMEI:
case IMEISV:
break;
case SUCI:
case IMSI:
break;
}
return encoded; uint32_t res = encoded - 1 - ((iei > 0) ? 1 : 0);
*lenPtr =res/(1<<8);
lenPtr++;
*lenPtr = res%(1<<8);
return encoded;
} }
int decode__5gs_mobile_identity ( _5GSMobileIdentity * _5gsmobileidentity, uint8_t iei, uint8_t * buffer, uint32_t len ) int decode__5gs_mobile_identity ( _5GSMobileIdentity * _5gsmobileidentity, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
int decoded=0; int decoded=0;
uint8_t ielen=0; uint8_t ielen=0;
int decode_result; int decode_result;
if (iei > 0) if (iei > 0)
{ {
CHECK_IEI_DECODER (iei, *buffer); CHECK_IEI_DECODER (iei, *buffer);
decoded++; decoded++;
} }
ielen = *(buffer + decoded); ielen = *(buffer + decoded);
decoded++; decoded++;
ielen = ( ielen << 8)+*(buffer + decoded); ielen = ( ielen << 8)+*(buffer + decoded);
decoded++; decoded++;
CHECK_LENGTH_DECODER (len - decoded, ielen); CHECK_LENGTH_DECODER (len - decoded, ielen);
if((decode_result = decode_bstring (_5gsmobileidentity, ielen, buffer + decoded, len - decoded)) < 0) if((decode_result = decode_bstring (_5gsmobileidentity, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result; return decode_result;
else else
decoded += decode_result; decoded += decode_result;
return decoded; return decoded;
} }
...@@ -8,48 +8,43 @@ ...@@ -8,48 +8,43 @@
int encode__5gs_tracking_area_identity ( _5GSTrackingAreaIdentity _5gstrackingareaidentity, uint8_t iei, uint8_t * buffer, uint32_t len ) int encode__5gs_tracking_area_identity ( _5GSTrackingAreaIdentity _5gstrackingareaidentity, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
uint8_t *lenPtr; uint32_t encoded = 0;
uint32_t encoded = 0; CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,_5GS_TRACKING_AREA_IDENTITY_MINIMUM_LENGTH , len);
int encode_result;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,_5GS_TRACKING_AREA_IDENTITY_MINIMUM_LENGTH , len); if( iei >0 ){
*buffer=iei;
if( iei >0 ){ encoded++;
*buffer=iei; }
encoded++;
} ENCODE_U8(buffer+encoded, (uint8_t)(_5gstrackingareaidentity.mcc&0x00ff), encoded);
ENCODE_U8(buffer+encoded, (uint8_t)((_5gstrackingareaidentity.mcc&0x0f00)>>8) | (uint8_t)((_5gstrackingareaidentity.mnc&0x0f00)>>4), encoded);
ENCODE_U8(buffer+encoded, (uint8_t)(_5gstrackingareaidentity.mcc&0x00ff), encoded); ENCODE_U8(buffer+encoded, (uint8_t)(_5gstrackingareaidentity.mnc&0x00ff), encoded);
ENCODE_U8(buffer+encoded, (uint8_t)((_5gstrackingareaidentity.mcc&0x0f00)>>8) | (uint8_t)((_5gstrackingareaidentity.mnc&0x0f00)>>4), encoded); ENCODE_U32(buffer+encoded, _5gstrackingareaidentity.tac&0x00ffffff, encoded);
ENCODE_U8(buffer+encoded, (uint8_t)(_5gstrackingareaidentity.mnc&0x00ff), encoded);
ENCODE_U32(buffer+encoded, _5gstrackingareaidentity.tac&0x00ffffff, encoded); return encoded;
return encoded;
} }
int decode__5gs_tracking_area_identity ( _5GSTrackingAreaIdentity * _5gstrackingareaidentity, uint8_t iei, uint8_t * buffer, uint32_t len ) int decode__5gs_tracking_area_identity ( _5GSTrackingAreaIdentity * _5gstrackingareaidentity, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
int decoded=0; int decoded=0;
uint8_t ielen=0; uint8_t mcc_mnc_decode = 0;
int decode_result;
uint8_t mcc_mnc_decode = 0; if (iei > 0)
uint32_t tac_decode = 0; {
CHECK_IEI_DECODER (iei, *buffer);
if (iei > 0) decoded++;
{ }
CHECK_IEI_DECODER (iei, *buffer);
decoded++; DECODE_U8(buffer+decoded, mcc_mnc_decode, decoded);
} _5gstrackingareaidentity->mcc = 0x0000 | mcc_mnc_decode;
DECODE_U8(buffer+decoded, mcc_mnc_decode, decoded);
DECODE_U8(buffer+decoded, mcc_mnc_decode, decoded); _5gstrackingareaidentity->mcc = _5gstrackingareaidentity->mcc | ((mcc_mnc_decode&0x0f)<<8);
_5gstrackingareaidentity->mcc = 0x0000 | mcc_mnc_decode; _5gstrackingareaidentity->mnc = 0x0000 | ((mcc_mnc_decode&0xf0)<<4);
DECODE_U8(buffer+decoded, mcc_mnc_decode, decoded); DECODE_U8(buffer+decoded, mcc_mnc_decode, decoded);
_5gstrackingareaidentity->mcc = _5gstrackingareaidentity->mcc | ((mcc_mnc_decode&0x0f)<<8); _5gstrackingareaidentity->mnc = _5gstrackingareaidentity->mnc | mcc_mnc_decode;
_5gstrackingareaidentity->mnc = 0x0000 | ((mcc_mnc_decode&0xf0)<<4);
DECODE_U8(buffer+decoded, mcc_mnc_decode, decoded); DECODE_U32(buffer+decoded, _5gstrackingareaidentity->tac, decoded);
_5gstrackingareaidentity->mnc = _5gstrackingareaidentity->mnc | mcc_mnc_decode;
return decoded;
DECODE_U32(buffer+decoded, _5gstrackingareaidentity->tac, decoded);
return decoded;
} }
...@@ -9,89 +9,87 @@ ...@@ -9,89 +9,87 @@
int encode__5gs_update_type ( _5GSUpdateType _5gsupdatetype, uint8_t iei, uint8_t * buffer, uint32_t len ) int encode__5gs_update_type ( _5GSUpdateType _5gsupdatetype, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
uint8_t *lenPtr; uint8_t *lenPtr;
uint32_t encoded = 0; uint32_t encoded = 0;
int encode_result; CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,_5GS_UPDATE_TYPE_MINIMUM_LENGTH , len);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,_5GS_UPDATE_TYPE_MINIMUM_LENGTH , len);
if( iei >0 ){
*buffer=iei;
encoded++;
}
lenPtr = (buffer + encoded);
encoded++;
ENCODE_U8(buffer+encoded, _5gsupdatetype.ng_ran_rcu, encoded); if( iei >0 ){
ENCODE_U8(buffer+encoded, _5gsupdatetype.sms_requested, encoded); *buffer=iei;
*lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0);
return encoded;
#if 0
uint8_t *lenPtr;
uint32_t encoded = 0;
uint8_t bitStream = 0x0;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,_5GS_UPDATE_TYPE_MINIMUM_LENGTH , len);
if( iei >0 ){
*buffer=iei;
encoded++;
}
lenPtr = (buffer + encoded);
encoded++; encoded++;
}
lenPtr = (buffer + encoded);
encoded++;
ENCODE_U8(buffer+encoded, _5gsupdatetype.ng_ran_rcu, encoded);
ENCODE_U8(buffer+encoded, _5gsupdatetype.sms_requested, encoded);
*lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0);
return encoded;
#if 0
uint8_t *lenPtr;
uint32_t encoded = 0;
uint8_t bitStream = 0x0;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,_5GS_UPDATE_TYPE_MINIMUM_LENGTH , len);
bitStream |= ((_5gsupdatetype.ng_ran_rcu&0x01)<<1); if( iei >0 ){
bitStream |= (_5gsupdatetype.sms_requested&0x01); *buffer=iei;
ENCODE_U8(buffer+encoded,bitStream,encoded); encoded++;
}
lenPtr = (buffer + encoded);
encoded++;
bitStream |= ((_5gsupdatetype.ng_ran_rcu&0x01)<<1);
bitStream |= (_5gsupdatetype.sms_requested&0x01);
ENCODE_U8(buffer+encoded,bitStream,encoded);
*lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0); *lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0);
return encoded; return encoded;
#endif #endif
} }
int decode__5gs_update_type ( _5GSUpdateType * _5gsupdatetype, uint8_t iei, uint8_t * buffer, uint32_t len ) int decode__5gs_update_type ( _5GSUpdateType * _5gsupdatetype, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
int decoded=0; int decoded=0;
uint8_t ielen=0; uint8_t ielen=0;
int decode_result;
if (iei > 0) if (iei > 0)
{ {
CHECK_IEI_DECODER (iei, *buffer); CHECK_IEI_DECODER (iei, *buffer);
decoded++;
}
ielen = *(buffer + decoded);
decoded++;
CHECK_LENGTH_DECODER (len - decoded, ielen);
DECODE_U8(buffer+decoded, _5gsupdatetype->ng_ran_rcu, decoded);
DECODE_U8(buffer+decoded, _5gsupdatetype->sms_requested, decoded);
return decoded;
#if 0
int decoded=0;
uint8_t ielen=0;
uint8_t bitStream = 0x0;
if (iei > 0)
{
CHECK_IEI_DECODER (iei, *buffer);
decoded++;
}
ielen = *(buffer + decoded);
decoded++; decoded++;
CHECK_LENGTH_DECODER (len - decoded, ielen); }
DECODE_U8(buffer+decoded,bitStream,decoded);
ielen = *(buffer + decoded);
_5gsupdatetype->ng_ran_rcu = bitStream&0x02; decoded++;
_5gsupdatetype->sms_requested = bitStream&0x01; CHECK_LENGTH_DECODER (len - decoded, ielen);
return decoded;
#endif DECODE_U8(buffer+decoded, _5gsupdatetype->ng_ran_rcu, decoded);
DECODE_U8(buffer+decoded, _5gsupdatetype->sms_requested, decoded);
return decoded;
#if 0
int decoded=0;
uint8_t ielen=0;
uint8_t bitStream = 0x0;
if (iei > 0)
{
CHECK_IEI_DECODER (iei, *buffer);
decoded++;
}
ielen = *(buffer + decoded);
decoded++;
CHECK_LENGTH_DECODER (len - decoded, ielen);
DECODE_U8(buffer+decoded,bitStream,decoded);
_5gsupdatetype->ng_ran_rcu = bitStream&0x02;
_5gsupdatetype->sms_requested = bitStream&0x01;
return decoded;
#endif
} }
...@@ -8,40 +8,28 @@ ...@@ -8,40 +8,28 @@
int encode__access_type ( _AccessType _accesstype, uint8_t iei, uint8_t * buffer, uint32_t len ) int encode__access_type ( _AccessType _accesstype, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
uint8_t *lenPtr; uint32_t encoded = 0;
uint32_t encoded = 0; int encode_result;
int encode_result; CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,_ACCESS_TYPE_MINIMUM_LENGTH , len);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,_ACCESS_TYPE_MINIMUM_LENGTH , len);
if ((encode_result = encode_bstring (_accesstype, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
return encoded;
if ((encode_result = encode_bstring (_accesstype, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
return encoded;
} }
int decode__access_type ( _AccessType * _accesstype, uint8_t iei, uint8_t * buffer, uint32_t len ) int decode__access_type ( _AccessType * _accesstype, uint8_t iei, uint8_t * buffer, uint32_t len )
{ {
int decoded=0; int decoded=0;
uint8_t ielen=0; uint8_t ielen=0;
int decode_result; int decode_result;
if((decode_result = decode_bstring (_accesstype, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
decoded += decode_result;
if((decode_result = decode_bstring (_accesstype, ielen, buffer + decoded, len - decoded)) < 0) return decoded;
return decode_result;
else
decoded += decode_result;
return decoded;
} }
...@@ -31,7 +31,7 @@ int decode__pdu_session_type ( _PDUSessionType * _pdusessiontype, uint8_t iei, u ...@@ -31,7 +31,7 @@ int decode__pdu_session_type ( _PDUSessionType * _pdusessiontype, uint8_t iei, u
DECODE_U8(buffer+decoded,bitStream,decoded); DECODE_U8(buffer+decoded,bitStream,decoded);
if(iei != bitStream&0xf0){ if(iei != (bitStream&0xf0)){
return -1; return -1;
} }
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef FILE_MM_DATA_H_SEEN #ifndef FILE_MM_DATA_H_SEEN
#define FILE_MM_DATA_H_SEEN #define FILE_MM_DATA_H_SEEN
......
...@@ -8,16 +8,16 @@ ...@@ -8,16 +8,16 @@
int decode_authentication_failure( authentication_failure_msg *authentication_failure, uint8_t* buffer, uint32_t len) int decode_authentication_failure( authentication_failure_msg *authentication_failure, uint8_t* buffer, uint32_t len)
{ {
uint32_t decoded = 0; uint32_t decoded = 0;
int decoded_result = 0; int decoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER (buffer, AUTHENTICATION_FAILURE_MINIMUM_LENGTH, len); CHECK_PDU_POINTER_AND_LENGTH_DECODER (buffer, AUTHENTICATION_FAILURE_MINIMUM_LENGTH, len);
if((decoded_result = decode__5gmm_cause (&authentication_failure->_5gmmcause, 0, buffer+decoded,len-decoded))<0) if((decoded_result = decode__5gmm_cause (&authentication_failure->_5gmmcause, 0, buffer+decoded,len-decoded))<0)
return decoded_result; return decoded_result;
else else
decoded+=decoded_result; decoded+=decoded_result;
/* /*
* Decoding optional fields * Decoding optional fields
...@@ -26,7 +26,7 @@ int decode_authentication_failure( authentication_failure_msg *authentication_fa ...@@ -26,7 +26,7 @@ int decode_authentication_failure( authentication_failure_msg *authentication_fa
uint8_t ieiDecoded = *(buffer + decoded); uint8_t ieiDecoded = *(buffer + decoded);
if(ieiDecoded ==0) if(ieiDecoded ==0)
break; break;
switch (ieiDecoded) { switch (ieiDecoded) {
case AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_IEI: case AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_IEI:
if ((decoded_result = decode_authentication_failure_parameter (&authentication_failure->authenticationfailureparameter, AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_IEI, buffer + decoded, len - decoded)) <= 0) if ((decoded_result = decode_authentication_failure_parameter (&authentication_failure->authenticationfailureparameter, AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_IEI, buffer + decoded, len - decoded)) <= 0)
...@@ -40,31 +40,31 @@ int decode_authentication_failure( authentication_failure_msg *authentication_fa ...@@ -40,31 +40,31 @@ int decode_authentication_failure( authentication_failure_msg *authentication_fa
} }
return decoded; return decoded;
} }
int encode_authentication_failure( authentication_failure_msg *authentication_failure, uint8_t* buffer, uint32_t len) int encode_authentication_failure( authentication_failure_msg *authentication_failure, uint8_t* buffer, uint32_t len)
{ {
uint32_t encoded = 0; uint32_t encoded = 0;
int encoded_result = 0; int encoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer, AUTHENTICATION_FAILURE_MINIMUM_LENGTH, len);
if((encoded_result = encode__5gmm_cause (&authentication_failure->_5gmmcause, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if ((authentication_failure->presence & AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_PRESENT) // Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer, AUTHENTICATION_FAILURE_MINIMUM_LENGTH, len);
if((encoded_result = encode__5gmm_cause (authentication_failure->_5gmmcause, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if ((authentication_failure->presence & AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_PRESENT)
== AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_PRESENT) { == AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_PRESENT) {
if ((encoded_result = encode_authentication_failure_parameter (authentication_failure->authenticationfailureparameter, AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_IEI, buffer + encoded, len - encoded)) < 0) if ((encoded_result = encode_authentication_failure_parameter (authentication_failure->authenticationfailureparameter, AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_IEI, buffer + encoded, len - encoded)) < 0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
} }
return encoded; return encoded;
} }
...@@ -44,7 +44,7 @@ int encode_authentication_reject( authentication_reject_msg *authentication_reje ...@@ -44,7 +44,7 @@ int encode_authentication_reject( authentication_reject_msg *authentication_reje
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer, AUTHENTICATION_REJECT_MINIMUM_LENGTH, len); CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer, AUTHENTICATION_REJECT_MINIMUM_LENGTH, len);
if(authentication_reject->presence & AUTHENTICATION_REJECT_EAP_MESSAGE_PRESENT if((authentication_reject->presence & AUTHENTICATION_REJECT_EAP_MESSAGE_PRESENT)
== AUTHENTICATION_REJECT_EAP_MESSAGE_PRESENT){ == AUTHENTICATION_REJECT_EAP_MESSAGE_PRESENT){
if((encoded_result = encode_eap_message (authentication_reject->eapmessage, AUTHENTICATION_REJECT_EAP_MESSAGE_IEI, buffer+encoded,len-encoded))<0) if((encoded_result = encode_eap_message (authentication_reject->eapmessage, AUTHENTICATION_REJECT_EAP_MESSAGE_IEI, buffer+encoded,len-encoded))<0)
return encoded_result; return encoded_result;
......
...@@ -24,14 +24,14 @@ int decode_authentication_request( authentication_request_msg *authentication_re ...@@ -24,14 +24,14 @@ int decode_authentication_request( authentication_request_msg *authentication_re
//printf("naskeysetidentifier decoded_result:%d,tsc:%d\n", decoded_result, authentication_request->naskeysetidentifier.tsc); //printf("naskeysetidentifier decoded_result:%d,tsc:%d\n", decoded_result, authentication_request->naskeysetidentifier.tsc);
decoded++; decoded++;
if ((decoded_result = decode_abba (&authentication_request->abba,0 , buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_abba (&authentication_request->abba,0 , buffer + decoded, len - decoded)) < 0)
return decoded_result; return decoded_result;
else else
decoded += decoded_result; decoded += decoded_result;
while (len - decoded > 0) { while (len - decoded > 0) {
//printf("encoding ies left(%d)\n",len-decoded); //printf("encoding ies left(%d)\n",len-decoded);
//printf("decoded(%d)\n",decoded); //printf("decoded(%d)\n",decoded);
...@@ -40,33 +40,33 @@ int decode_authentication_request( authentication_request_msg *authentication_re ...@@ -40,33 +40,33 @@ int decode_authentication_request( authentication_request_msg *authentication_re
if(ieiDecoded == 0) if(ieiDecoded == 0)
break; break;
switch(ieiDecoded){ switch(ieiDecoded){
case AUTHENTICATION_PARAMETER_RAND_IEI: case AUTHENTICATION_PARAMETER_RAND_IEI:
if ((decoded_result = decode_authentication_parameter_rand (&authentication_request->authenticationparameterrand, AUTHENTICATION_PARAMETER_RAND_IEI, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_authentication_parameter_rand (&authentication_request->authenticationparameterrand, AUTHENTICATION_PARAMETER_RAND_IEI, buffer + decoded, len - decoded)) < 0)
return decoded_result; return decoded_result;
else{ else{
decoded += decoded_result; decoded += decoded_result;
authentication_request->presence |= AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_RAND_PRESENT; authentication_request->presence |= AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_RAND_PRESENT;
} }
break; break;
case AUTHENTICATION_PARAMETER_AUTN_IEI: case AUTHENTICATION_PARAMETER_AUTN_IEI:
if ((decoded_result = decode_authentication_parameter_autn (&authentication_request->authenticationparameterautn, AUTHENTICATION_PARAMETER_AUTN_IEI, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_authentication_parameter_autn (&authentication_request->authenticationparameterautn, AUTHENTICATION_PARAMETER_AUTN_IEI, buffer + decoded, len - decoded)) < 0)
return decoded_result; return decoded_result;
else{ else{
decoded += decoded_result; decoded += decoded_result;
authentication_request->presence |= AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_AUTN_PRESENT; authentication_request->presence |= AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_AUTN_PRESENT;
} }
break; break;
case EAP_MESSAGE_IEI: case EAP_MESSAGE_IEI:
if ((decoded_result = decode_eap_message (&authentication_request->eapmessage, EAP_MESSAGE_IEI, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_eap_message (&authentication_request->eapmessage, EAP_MESSAGE_IEI, buffer + decoded, len - decoded)) < 0)
return decoded_result; return decoded_result;
else{ else{
decoded += decoded_result; decoded += decoded_result;
authentication_request->presence |= AUTHENTICATION_REQUEST_EAP_MESSAGE_PRESENT; authentication_request->presence |= AUTHENTICATION_REQUEST_EAP_MESSAGE_PRESENT;
} }
break; break;
}
} }
}
return decoded; return decoded;
} }
...@@ -74,40 +74,40 @@ int decode_authentication_request( authentication_request_msg *authentication_re ...@@ -74,40 +74,40 @@ int decode_authentication_request( authentication_request_msg *authentication_re
int encode_authentication_request( authentication_request_msg *authentication_request, uint8_t* buffer, uint32_t len) int encode_authentication_request( authentication_request_msg *authentication_request, uint8_t* buffer, uint32_t len)
{ {
uint32_t encoded = 0; uint32_t encoded = 0;
int encoded_result = 0; int encoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer, AUTHENTICATION_REQUEST_MINIMUM_LENGTH, len); CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer, AUTHENTICATION_REQUEST_MINIMUM_LENGTH, len);
*(buffer + encoded) = ((encode_u8_nas_key_set_identifier(&authentication_request->naskeysetidentifier) & 0x0f) << 4) | 0x00; *(buffer + encoded) = ((encode_u8_nas_key_set_identifier(&authentication_request->naskeysetidentifier) & 0x0f) << 4) | 0x00;
encoded ++; encoded ++;
if((encoded_result = encode_abba (authentication_request->abba,0, buffer+encoded,len-encoded))<0) if((encoded_result = encode_abba (authentication_request->abba,0, buffer+encoded,len-encoded))<0)
return encoded_result; return encoded_result;
else
encoded+=encoded_result;
if((authentication_request->presence & AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_RAND_PRESENT)
== AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_RAND_PRESENT){
if((encoded_result = encode_authentication_parameter_rand (authentication_request->authenticationparameterrand, AUTHENTICATION_PARAMETER_RAND_IEI, buffer+encoded,len-encoded))<0)
return encoded_result;
else else
encoded+=encoded_result; encoded+=encoded_result;
}
if((authentication_request->presence & AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_RAND_PRESENT) if((authentication_request->presence & AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_AUTN_PRESENT)
== AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_RAND_PRESENT){ == AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_AUTN_PRESENT){
if((encoded_result = encode_authentication_parameter_rand (authentication_request->authenticationparameterrand, AUTHENTICATION_PARAMETER_RAND_IEI, buffer+encoded,len-encoded))<0) if((encoded_result = encode_authentication_parameter_autn (authentication_request->authenticationparameterautn, AUTHENTICATION_PARAMETER_AUTN_IEI, buffer+encoded,len-encoded))<0)
return encoded_result; return encoded_result;
else else
encoded+=encoded_result; encoded+=encoded_result;
} }
if((authentication_request->presence & AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_AUTN_PRESENT) if((authentication_request->presence & AUTHENTICATION_REQUEST_EAP_MESSAGE_PRESENT)
== AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_AUTN_PRESENT){ == AUTHENTICATION_REQUEST_EAP_MESSAGE_PRESENT){
if((encoded_result = encode_authentication_parameter_autn (authentication_request->authenticationparameterautn, AUTHENTICATION_PARAMETER_AUTN_IEI, buffer+encoded,len-encoded))<0) if((encoded_result = encode_eap_message (authentication_request->eapmessage, EAP_MESSAGE_IEI, buffer+encoded,len-encoded))<0)
return encoded_result; return encoded_result;
else else
encoded+=encoded_result; encoded+=encoded_result;
} }
if((authentication_request->presence & AUTHENTICATION_REQUEST_EAP_MESSAGE_PRESENT) return encoded;
== AUTHENTICATION_REQUEST_EAP_MESSAGE_PRESENT){
if((encoded_result = encode_eap_message (authentication_request->eapmessage, EAP_MESSAGE_IEI, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
}
return encoded;
} }
...@@ -8,16 +8,16 @@ ...@@ -8,16 +8,16 @@
int decode_authentication_response( authentication_response_msg *authentication_response, uint8_t* buffer, uint32_t len) int decode_authentication_response( authentication_response_msg *authentication_response, uint8_t* buffer, uint32_t len)
{ {
uint32_t decoded = 0; uint32_t decoded = 0;
int decoded_result = 0; int decoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER (buffer, AUTHENTICATION_RESPONSE_MINIMUM_LENGTH, len); CHECK_PDU_POINTER_AND_LENGTH_DECODER (buffer, AUTHENTICATION_RESPONSE_MINIMUM_LENGTH, len);
// uint8_t ieiDecoded = *(buffer+decoded);
// printf("ieiDecoded(%x)\n",ieiDecoded);
// uint8_t ieiDecoded = *(buffer+decoded);
// printf("ieiDecoded(%x)\n",ieiDecoded);
while (len - decoded > 0) { while (len - decoded > 0) {
//printf("encoding ies left(%d)\n",len-decoded); //printf("encoding ies left(%d)\n",len-decoded);
//printf("decoded(%d)\n",decoded); //printf("decoded(%d)\n",decoded);
...@@ -27,57 +27,57 @@ int decode_authentication_response( authentication_response_msg *authentication_ ...@@ -27,57 +27,57 @@ int decode_authentication_response( authentication_response_msg *authentication_
break; break;
switch(ieiDecoded){ switch(ieiDecoded){
case AUTHENTICATION_RESPONSE_AUTHENTICATION_RESPONSE_PARAMETER_IEI: case AUTHENTICATION_RESPONSE_AUTHENTICATION_RESPONSE_PARAMETER_IEI:
printf("decoding AUTHENTICATION_RESPONSE_AUTHENTICATION_RESPONSE_PARAMETER_IEI\n"); printf("decoding AUTHENTICATION_RESPONSE_AUTHENTICATION_RESPONSE_PARAMETER_IEI\n");
if((decoded_result = decode_authentication_response_parameter (&authentication_response->authenticationresponseparameter, AUTHENTICATION_RESPONSE_AUTHENTICATION_RESPONSE_PARAMETER_IEI, buffer+decoded,len-decoded))<0) if((decoded_result = decode_authentication_response_parameter (&authentication_response->authenticationresponseparameter, AUTHENTICATION_RESPONSE_AUTHENTICATION_RESPONSE_PARAMETER_IEI, buffer+decoded,len-decoded))<0)
return decoded_result; return decoded_result;
else{ else{
decoded+=decoded_result; decoded+=decoded_result;
printf("decoded(%d)\n",decoded); printf("decoded(%d)\n",decoded);
authentication_response->presence |= AUTHENTICATION_RESPONSE_AUTNENTICATION_RESPONSE_PARAMETER_PRESENT; authentication_response->presence |= AUTHENTICATION_RESPONSE_AUTNENTICATION_RESPONSE_PARAMETER_PRESENT;
} }
break;
case AUTHENTICATION_RESPONSE_EAP_MESSAGE_IEI:
if((decoded_result = decode_eap_message (&authentication_response->eapmessage, AUTHENTICATION_RESPONSE_EAP_MESSAGE_IEI, buffer+decoded,len-decoded))<0)
return decoded_result;
else{
decoded+=decoded_result;
authentication_response->presence |= AUTHENTICATION_RESPONSE_EAP_MESSAGE_PRESENT;
}
break; break;
case AUTHENTICATION_RESPONSE_EAP_MESSAGE_IEI:
if((decoded_result = decode_eap_message (&authentication_response->eapmessage, AUTHENTICATION_RESPONSE_EAP_MESSAGE_IEI, buffer+decoded,len-decoded))<0)
return decoded_result;
else{
decoded+=decoded_result;
authentication_response->presence |= AUTHENTICATION_RESPONSE_EAP_MESSAGE_PRESENT;
}
break;
} }
} }
return decoded; return decoded;
} }
int encode_authentication_response( authentication_response_msg *authentication_response, uint8_t* buffer, uint32_t len) int encode_authentication_response( authentication_response_msg *authentication_response, uint8_t* buffer, uint32_t len)
{ {
uint32_t encoded = 0; uint32_t encoded = 0;
int encoded_result = 0; int encoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer, AUTHENTICATION_RESPONSE_MINIMUM_LENGTH, len);
if(authentication_response->presence & AUTHENTICATION_RESPONSE_AUTNENTICATION_RESPONSE_PARAMETER_PRESENT
== AUTHENTICATION_RESPONSE_AUTNENTICATION_RESPONSE_PARAMETER_PRESENT){
if((encoded_result = encode_authentication_response_parameter (authentication_response->authenticationresponseparameter, AUTHENTICATION_RESPONSE_AUTHENTICATION_RESPONSE_PARAMETER_IEI, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
}
if(authentication_response->presence & AUTHENTICATION_RESPONSE_EAP_MESSAGE_PRESENT // Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
== AUTHENTICATION_RESPONSE_EAP_MESSAGE_PRESENT){ CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer, AUTHENTICATION_RESPONSE_MINIMUM_LENGTH, len);
if((encoded_result = encode_eap_message (authentication_response->eapmessage, AUTHENTICATION_RESPONSE_EAP_MESSAGE_IEI, buffer+encoded,len-encoded))<0)
return encoded_result; if((authentication_response->presence & AUTHENTICATION_RESPONSE_AUTNENTICATION_RESPONSE_PARAMETER_PRESENT)
else == AUTHENTICATION_RESPONSE_AUTNENTICATION_RESPONSE_PARAMETER_PRESENT){
encoded+=encoded_result; if((encoded_result = encode_authentication_response_parameter (authentication_response->authenticationresponseparameter, AUTHENTICATION_RESPONSE_AUTHENTICATION_RESPONSE_PARAMETER_IEI, buffer+encoded,len-encoded))<0)
} return encoded_result;
else
encoded+=encoded_result;
}
if((authentication_response->presence & AUTHENTICATION_RESPONSE_EAP_MESSAGE_PRESENT)
== AUTHENTICATION_RESPONSE_EAP_MESSAGE_PRESENT){
if((encoded_result = encode_eap_message (authentication_response->eapmessage, AUTHENTICATION_RESPONSE_EAP_MESSAGE_IEI, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
}
printf("encoded encode_authentication_response\n"); printf("encoded encode_authentication_response\n");
return encoded; return encoded;
} }
...@@ -8,55 +8,55 @@ ...@@ -8,55 +8,55 @@
int decode_deregistration_accept( deregistration_accept_msg *deregistration_accept, uint8_t* buffer, uint32_t len) int decode_deregistration_accept( deregistration_accept_msg *deregistration_accept, uint8_t* buffer, uint32_t len)
{ {
uint32_t decoded = 0; uint32_t decoded = 0;
int decoded_result = 0; int decoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER (buffer, DEREGISTRATION_ACCEPT_MINIMUM_LENGTH, len); CHECK_PDU_POINTER_AND_LENGTH_DECODER (buffer, DEREGISTRATION_ACCEPT_MINIMUM_LENGTH, len);
if((decoded_result = decode_extended_protocol_discriminator (&deregistration_accept->extendedprotocoldiscriminator, 0, buffer+decoded,len-decoded))<0) if((decoded_result = decode_extended_protocol_discriminator (&deregistration_accept->extendedprotocoldiscriminator, 0, buffer+decoded,len-decoded))<0)
return decoded_result; return decoded_result;
else else
decoded+=decoded_result; decoded+=decoded_result;
if((decoded_result = decode_security_header_type (&deregistration_accept->securityheadertype, 0, buffer+decoded,len-decoded))<0) if((decoded_result = decode_security_header_type (&deregistration_accept->securityheadertype, 0, buffer+decoded,len-decoded))<0)
return decoded_result; return decoded_result;
else else
decoded+=decoded_result; decoded+=decoded_result;
if((decoded_result = decode_message_type (&deregistration_accept->messagetype, 0, buffer+decoded,len-decoded))<0) if((decoded_result = decode_message_type (&deregistration_accept->messagetype, 0, buffer+decoded,len-decoded))<0)
return decoded_result; return decoded_result;
else else
decoded+=decoded_result; decoded+=decoded_result;
return decoded; return decoded;
} }
int encode_deregistration_accept( deregistration_accept_msg *deregistration_accept, uint8_t* buffer, uint32_t len) int encode_deregistration_accept( deregistration_accept_msg *deregistration_accept, uint8_t* buffer, uint32_t len)
{ {
uint32_t encoded = 0; uint32_t encoded = 0;
int encoded_result = 0; int encoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer, DEREGISTRATION_ACCEPT_MINIMUM_LENGTH, len);
if((encoded_result = encode_extended_protocol_discriminator (deregistration_accept->extendedprotocoldiscriminator, 0, buffer+encoded,len-encoded))<0) // Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
return encoded_result; CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer, DEREGISTRATION_ACCEPT_MINIMUM_LENGTH, len);
else
encoded+=encoded_result;
if((encoded_result = encode_security_header_type (deregistration_accept->securityheadertype, 0, buffer+encoded,len-encoded))<0) if((encoded_result = encode_extended_protocol_discriminator (deregistration_accept->extendedprotocoldiscriminator, 0, buffer+encoded,len-encoded))<0)
return encoded_result; return encoded_result;
else else
encoded+=encoded_result; encoded+=encoded_result;
if((encoded_result = encode_message_type (deregistration_accept->messagetype, 0, buffer+encoded,len-encoded))<0) if((encoded_result = encode_security_header_type (deregistration_accept->securityheadertype, 0, buffer+encoded,len-encoded))<0)
return encoded_result; return encoded_result;
else else
encoded+=encoded_result; encoded+=encoded_result;
if((encoded_result = encode_message_type (deregistration_accept->messagetype, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
return encoded;
return encoded;
} }
...@@ -8,12 +8,12 @@ ...@@ -8,12 +8,12 @@
int decode_deregistration_request( deregistration_request_msg *deregistration_request, uint8_t* buffer, uint32_t len) int decode_deregistration_request( deregistration_request_msg *deregistration_request, uint8_t* buffer, uint32_t len)
{ {
uint32_t decoded = 0; uint32_t decoded = 0;
int decoded_result = 0; int decoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER (buffer, DEREGISTRATION_REQUEST_MINIMUM_LENGTH, len); CHECK_PDU_POINTER_AND_LENGTH_DECODER (buffer, DEREGISTRATION_REQUEST_MINIMUM_LENGTH, len);
/* /*
if((decoded_result = decode_extended_protocol_discriminator (&deregistration_request->extendedprotocoldiscriminator, 0, buffer+decoded,len-decoded))<0) if((decoded_result = decode_extended_protocol_discriminator (&deregistration_request->extendedprotocoldiscriminator, 0, buffer+decoded,len-decoded))<0)
return decoded_result; return decoded_result;
else else
...@@ -44,19 +44,19 @@ int decode_deregistration_request( deregistration_request_msg *deregistration_re ...@@ -44,19 +44,19 @@ int decode_deregistration_request( deregistration_request_msg *deregistration_re
else else
decoded+=decoded_result; decoded+=decoded_result;
*/ */
return decoded; return decoded;
} }
int encode_deregistration_request( deregistration_request_msg *deregistration_request, uint8_t* buffer, uint32_t len) int encode_deregistration_request( deregistration_request_msg *deregistration_request, uint8_t* buffer, uint32_t len)
{ {
uint32_t encoded = 0; uint32_t encoded = 0;
int encoded_result = 0; int encoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer, DEREGISTRATION_REQUEST_MINIMUM_LENGTH, len); CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer, DEREGISTRATION_REQUEST_MINIMUM_LENGTH, len);
/* /*
if((encoded_result = encode_extended_protocol_discriminator (deregistration_request->extendedprotocoldiscriminator, 0, buffer+encoded,len-encoded))<0) if((encoded_result = encode_extended_protocol_discriminator (deregistration_request->extendedprotocoldiscriminator, 0, buffer+encoded,len-encoded))<0)
return encoded_result; return encoded_result;
else else
...@@ -87,6 +87,6 @@ int encode_deregistration_request( deregistration_request_msg *deregistration_re ...@@ -87,6 +87,6 @@ int encode_deregistration_request( deregistration_request_msg *deregistration_re
else else
encoded+=encoded_result; encoded+=encoded_result;
*/ */
return encoded; return encoded;
} }
...@@ -8,90 +8,90 @@ ...@@ -8,90 +8,90 @@
int decode_registration_reject( registration_reject_msg *registration_reject, uint8_t* buffer, uint32_t len) int decode_registration_reject( registration_reject_msg *registration_reject, uint8_t* buffer, uint32_t len)
{ {
uint32_t decoded = 0; uint32_t decoded = 0;
int decoded_result = 0; int decoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER (buffer, REGISTRATION_REJECT_MINIMUM_LENGTH, len); CHECK_PDU_POINTER_AND_LENGTH_DECODER (buffer, REGISTRATION_REJECT_MINIMUM_LENGTH, len);
if((decoded_result = decode__5gmm_cause (&registration_reject->_5gmmcause, 0, buffer+decoded,len-decoded))<0) if((decoded_result = decode__5gmm_cause (&registration_reject->_5gmmcause, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
decoded+=decoded_result;
while(len - decoded > 0){
uint8_t ieiDecoded = *(buffer+decoded);
if((ieiDecoded != REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_IEI) && (ieiDecoded != REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_IEI) && (ieiDecoded != REGISTRATION_REJECT_EAP_MESSAGE_IEI))
break;
switch(ieiDecoded){
case REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_IEI:
if((decoded_result = decode_gprs_timer2 (&registration_reject->t3346, REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_IEI, buffer+decoded,len-decoded))<0)
return decoded_result; return decoded_result;
else else{
decoded+=decoded_result; decoded+=decoded_result;
registration_reject->presence |= REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_PRESENT;
while(len - decoded > 0){ }
uint8_t ieiDecoded = *(buffer+decoded);
if((ieiDecoded != REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_IEI) && (ieiDecoded != REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_IEI) && (ieiDecoded != REGISTRATION_REJECT_EAP_MESSAGE_IEI))
break;
switch(ieiDecoded){
case REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_IEI:
if((decoded_result = decode_gprs_timer2 (&registration_reject->t3346, REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_IEI, buffer+decoded,len-decoded))<0)
return decoded_result;
else{
decoded+=decoded_result;
registration_reject->presence |= REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_PRESENT;
}
break;
case REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_IEI:
if((decoded_result = decode_gprs_timer2 (&registration_reject->t3502, REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_IEI, buffer+decoded,len-decoded))<0)
return decoded_result;
else{
decoded+=decoded_result;
registration_reject->presence |= REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_PRESENT;
}
break;
case REGISTRATION_REJECT_EAP_MESSAGE_IEI:
if((decoded_result = decode_eap_message (&registration_reject->eapmessage, REGISTRATION_REJECT_EAP_MESSAGE_IEI, buffer+decoded,len-decoded))<0)
return decoded_result;
else{
decoded+=decoded_result;
registration_reject->presence |= REGISTRATION_REJECT_EAP_MESSAGE_PRESENT;
}
break; break;
case REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_IEI:
if((decoded_result = decode_gprs_timer2 (&registration_reject->t3502, REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_IEI, buffer+decoded,len-decoded))<0)
return decoded_result;
else{
decoded+=decoded_result;
registration_reject->presence |= REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_PRESENT;
}
break;
case REGISTRATION_REJECT_EAP_MESSAGE_IEI:
if((decoded_result = decode_eap_message (&registration_reject->eapmessage, REGISTRATION_REJECT_EAP_MESSAGE_IEI, buffer+decoded,len-decoded))<0)
return decoded_result;
else{
decoded+=decoded_result;
registration_reject->presence |= REGISTRATION_REJECT_EAP_MESSAGE_PRESENT;
} }
break;
} }
}
return decoded; return decoded;
} }
int encode_registration_reject( registration_reject_msg *registration_reject, uint8_t* buffer, uint32_t len) int encode_registration_reject( registration_reject_msg *registration_reject, uint8_t* buffer, uint32_t len)
{ {
uint32_t encoded = 0; uint32_t encoded = 0;
int encoded_result = 0; int encoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer, REGISTRATION_REJECT_MINIMUM_LENGTH, len);
if((encoded_result = encode__5gmm_cause (registration_reject->_5gmmcause, 0, buffer+encoded,len-encoded))<0) // Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message.
return encoded_result; CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer, REGISTRATION_REJECT_MINIMUM_LENGTH, len);
else
encoded+=encoded_result;
if(registration_reject->presence & REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_PRESENT if((encoded_result = encode__5gmm_cause (registration_reject->_5gmmcause, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
if((registration_reject->presence & REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_PRESENT)
== REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_PRESENT){ == REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_PRESENT){
if((encoded_result = encode_gprs_timer2 (registration_reject->t3346, REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_IEI, buffer+encoded,len-encoded))<0) if((encoded_result = encode_gprs_timer2 (registration_reject->t3346, REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_IEI, buffer+encoded,len-encoded))<0)
return encoded_result; return encoded_result;
else else
encoded+=encoded_result; encoded+=encoded_result;
} }
if(registration_reject->presence & REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_PRESENT if((registration_reject->presence & REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_PRESENT)
== REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_PRESENT){ == REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_PRESENT){
if((encoded_result = encode_gprs_timer2 (registration_reject->t3502, REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_IEI, buffer+encoded,len-encoded))<0) if((encoded_result = encode_gprs_timer2 (registration_reject->t3502, REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_IEI, buffer+encoded,len-encoded))<0)
return encoded_result; return encoded_result;
else else
encoded+=encoded_result; encoded+=encoded_result;
} }
if(registration_reject->presence & REGISTRATION_REJECT_EAP_MESSAGE_PRESENT if((registration_reject->presence & REGISTRATION_REJECT_EAP_MESSAGE_PRESENT)
== REGISTRATION_REJECT_EAP_MESSAGE_PRESENT){ == REGISTRATION_REJECT_EAP_MESSAGE_PRESENT){
if((encoded_result = encode_eap_message (registration_reject->eapmessage, REGISTRATION_REJECT_EAP_MESSAGE_IEI, buffer+encoded,len-encoded))<0) if((encoded_result = encode_eap_message (registration_reject->eapmessage, REGISTRATION_REJECT_EAP_MESSAGE_IEI, buffer+encoded,len-encoded))<0)
return encoded_result; return encoded_result;
else else
encoded+=encoded_result; encoded+=encoded_result;
} }
return encoded; return encoded;
} }
This diff is collapsed.
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdint.h> #include <stdint.h>
#include <asm/byteorder.h> #include <asm/byteorder.h>
...@@ -5,11 +26,12 @@ ...@@ -5,11 +26,12 @@
typedef struct { typedef struct {
#ifdef __LITTLE_ENDIAN_BITFIELD #ifdef __LITTLE_ENDIAN_BITFIELD
uint8_t extended_protocol_discriminator; uint8_t extended_protocol_discriminator;
uint8_t security_header_type; uint8_t security_header_type:4;
uint8_t spare_half_octet:4;
#endif #endif
#ifdef __BIG_ENDIAN_BITFIELD #ifdef __BIG_ENDIAN_BITFIELD
uint8_t security_header_type; uint8_t spare_half_octet:4;
uint8_t extended_protocol_discriminator; uint8_t security_header_type:4;
#endif #endif
uint8_t message_type; uint8_t message_type;
} __attribute__((__packed__)) mm_msg_header_t; } __attribute__((__packed__)) mm_msg_header_t;
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef NAS_MESSAGE_H_ #ifndef NAS_MESSAGE_H_
#define NAS_MESSAGE_H_ #define NAS_MESSAGE_H_
...@@ -22,11 +43,12 @@ ...@@ -22,11 +43,12 @@
typedef struct nas_message_security_header_s { typedef struct nas_message_security_header_s {
#ifdef __LITTLE_ENDIAN_BITFIELD #ifdef __LITTLE_ENDIAN_BITFIELD
extended_protocol_discriminator_t extended_protocol_discriminator;//3gpp_24.501.h extended_protocol_discriminator_t extended_protocol_discriminator;//3gpp_24.501.h
uint8_t security_header_type; uint8_t security_header_type:4;
uint8_t spare_half_octet:4;
#endif #endif
#ifdef __BIG_ENDIAN_BITFIELD #ifdef __BIG_ENDIAN_BITFIELD
uint8_t security_header_type; uint8_t spare_half_octet:4;
uint8_t extended_protocol_discriminator; uint8_t security_header_type:4;
#endif #endif
uint32_t message_authentication_code; uint32_t message_authentication_code;
uint8_t sequence_number; uint8_t sequence_number;
......
/***************************************************************************** /*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*****************************************************************************
Source networkDef.h Source networkDef.h
Version 0.1 Version 0.1
Date 2019/08/05 Date 2019/08/05
Product NAS stack Product NAS stack
Subsystem include Subsystem include
Author BUPT Author BUPT
Description Contains network's global definitions Description Contains network's global definitions
*****************************************************************************/ *****************************************************************************/
#ifndef __NETWORK_DEF_H__ #ifndef __NETWORK_DEF_H__
#define __NETWORK_DEF_H__ #define __NETWORK_DEF_H__
...@@ -36,4 +49,3 @@ Description Contains network's global definitions ...@@ -36,4 +49,3 @@ Description Contains network's global definitions
#define NGAP_RRC_ESTABLISHMENT_CAUSE_MCS_PRIORITY_ACCESS 9 #define NGAP_RRC_ESTABLISHMENT_CAUSE_MCS_PRIORITY_ACCESS 9
#endif #endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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