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
#define FILE_3GPP_24_501_H_SEEN
#ifdef __cplusplus
......@@ -214,13 +236,48 @@ static const std::vector<std::string> request_type_e2str = {
"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_26_INSUFFICIENT_RESOURCES = 26,
CAUSE_27_MISSING_OR_UNKNOWN_DNN = 27,
CAUSE_28_UNKNOWN_PDU_SESSION_TYPE = 28,
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 #26 – Insufficient resources
......@@ -253,6 +310,15 @@ enum cause_value_5gs_session_management_e {
Cause #83 – Semantic error in the QoS operation
Cause #84 – Syntactical error in the QoS operation
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
*/
};
//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
......@@ -41,7 +41,7 @@ int decode_allowed_ssc_mode ( AllowedSSCMode * allowedsscmode, uint8_t iei, uint
DECODE_U8(buffer+decoded,bitStream,decoded);
if(iei != bitStream&0xf0){
if(iei != (bitStream&0xf0)){
return -1;
}
if(iei > 0){
......
......@@ -32,7 +32,7 @@ int decode_alwayson_pdu_session_requested ( AlwaysonPDUSessionRequested * always
DECODE_U8(buffer+decoded,bitStream,decoded);
if(iei != bitStream&0xf0){
if(iei != (bitStream&0xf0)){
return -1;
}
......
......@@ -8,17 +8,10 @@
int encode_configuration_update_indication ( ConfigurationUpdateIndication configurationupdateindication, uint8_t iei, uint8_t * buffer, uint32_t len )
{
uint8_t *lenPtr;
uint32_t encoded = 0;
int encode_result;
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
......@@ -34,10 +27,6 @@ int decode_configuration_update_indication ( ConfigurationUpdateIndication * con
uint8_t ielen=0;
int decode_result;
if((decode_result = decode_bstring (configurationupdateindication, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
......
......@@ -49,10 +49,11 @@ int decode_dnn ( DNN * dnn, uint8_t iei, uint8_t * buffer, uint32_t len )
CHECK_LENGTH_DECODER (len - decoded, ielen);
if((decode_result = decode_bstring (dnn, ielen, buffer + decoded, len - decoded)) < 0)
{
return decode_result;
else
} else{
decoded += decode_result;
}
return decoded;
}
......@@ -8,17 +8,10 @@
int encode_deregistration_type ( DeregistrationType deregistrationtype, uint8_t iei, uint8_t * buffer, uint32_t len )
{
uint8_t *lenPtr;
uint32_t encoded = 0;
int encode_result;
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
......@@ -34,10 +27,6 @@ int decode_deregistration_type ( DeregistrationType * deregistrationtype, uint8_
uint8_t ielen=0;
int decode_result;
if((decode_result = decode_bstring (deregistrationtype, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
......
......@@ -13,19 +13,16 @@ int encode_extended_protocol_configuration_options ( ExtendedProtocolConfigurati
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);
if( iei >0 )
{
*buffer=iei;
encoded++;
}
lenPtr = (buffer + encoded);
encoded++;
encoded++;
if ((encode_result = encode_bstring (extendedprotocolconfigurationoptions, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
......@@ -51,7 +48,6 @@ int decode_extended_protocol_configuration_options ( ExtendedProtocolConfigurati
decoded++;
}
ielen = *(buffer + decoded);
decoded++;
ielen = ( ielen << 8) + *(buffer + decoded);
......@@ -60,9 +56,13 @@ int decode_extended_protocol_configuration_options ( ExtendedProtocolConfigurati
if((decode_result = decode_bstring (extendedprotocolconfigurationoptions, ielen, buffer + decoded, len - decoded)) < 0)
{
return decode_result;
}
else
{
decoded += decode_result;
}
return decoded;
}
......
......@@ -8,8 +8,7 @@
int encode_extended_protocol_discriminator ( ExtendedProtocolDiscriminator extendedprotocoldiscriminator, uint8_t iei, uint8_t * buffer, uint32_t len )
{
/*
uint8_t *lenPtr;
/*
uint32_t encoded = 0;
int encode_result;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH , len);
......@@ -23,25 +22,23 @@ int encode_extended_protocol_discriminator ( ExtendedProtocolDiscriminator exte
return encoded;
*/
*/
return 0;
}
int decode_extended_protocol_discriminator ( ExtendedProtocolDiscriminator * extendedprotocoldiscriminator, uint8_t iei, uint8_t * buffer, uint32_t len )
{
/*
/*
int decoded=0;
uint8_t ielen=0;
int decode_result;
if((decode_result = decode_bstring (extendedprotocoldiscriminator, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
decoded += decode_result;
return decoded;
*/
*/
return 0;
}
......@@ -8,12 +8,10 @@
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;
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);
if( iei > 0)
{
*buffer=iei;
......@@ -25,7 +23,6 @@ int encode_intergrity_protection_maximum_data_rate ( IntergrityProtectionMaximum
else
encoded += encode_result;
return encoded;
}
......
......@@ -27,7 +27,6 @@ int encode_mico_indication ( MICOIndication micoindication, uint8_t iei, uint8_t
int decode_mico_indication ( MICOIndication * micoindication, uint8_t iei, uint8_t * buffer, uint32_t len )
{
int decoded=0;
uint8_t ielen=0;
uint8_t bitStream;
DECODE_U8(buffer+decoded,bitStream,decoded);
if(iei != (bitStream&0xf0))
......
......@@ -8,23 +8,15 @@
int encode_message_authentication_code ( MessageAuthenticationCode messageauthenticationcode, uint8_t iei, uint8_t * buffer, uint32_t len )
{
uint8_t *lenPtr;
uint32_t encoded = 0;
int encode_result;
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;
}
......@@ -34,10 +26,6 @@ int decode_message_authentication_code ( MessageAuthenticationCode * messageauth
uint8_t ielen=0;
int decode_result;
if((decode_result = decode_bstring (messageauthenticationcode, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
......
......@@ -8,18 +8,12 @@
int encode_message_type ( MessageType messagetype, uint8_t iei, uint8_t * buffer, uint32_t len )
{
/*
/*
uint8_t *lenPtr;
uint32_t encoded = 0;
int encode_result;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,MESSAGE_TYPE_MINIMUM_LENGTH , len);
if ((encode_result = encode_bstring (messagetype, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
......@@ -27,12 +21,12 @@ int encode_message_type ( MessageType messagetype, uint8_t iei, uint8_t * buffer
return encoded;
*/
*/
}
int decode_message_type ( MessageType * messagetype, uint8_t iei, uint8_t * buffer, uint32_t len )
{
/*
/*
int decoded=0;
int decode_result;
......@@ -42,6 +36,6 @@ int decode_message_type ( MessageType * messagetype, uint8_t iei, uint8_t * buff
else
decoded += decode_result;
return decoded;
*/
*/
}
......@@ -10,28 +10,23 @@ int encode_nssai ( NSSAI nssai, uint8_t iei, uint8_t * buffer, uint32_t len )
{
uint8_t *lenPtr;
uint32_t encoded = 0;
int encode_result;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,NSSAI_MINIMUM_LENGTH , len);
if( iei >0 )
{
*buffer=iei;
encoded++;
}
lenPtr = (buffer + encoded);
encoded++;
/*
/*
if ((encode_result = encode_bstring (nssai, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
*/
*/
*lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0);
return encoded;
}
......
......@@ -32,7 +32,7 @@ int decode_network_slicing_indication ( NetworkSlicingIndication * networkslicin
DECODE_U8(buffer+decoded,bitStream,decoded);
if(iei != bitStream&0xf0){
if(iei != (bitStream&0xf0)){
return -1;
}
......
......@@ -8,23 +8,15 @@
int encode_network_slicing_information ( NetworkSlicingInformation networkslicinginformation, uint8_t iei, uint8_t * buffer, uint32_t len )
{
uint8_t *lenPtr;
uint32_t encoded = 0;
int encode_result;
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;
}
......@@ -34,10 +26,6 @@ int decode_network_slicing_information ( NetworkSlicingInformation * networkslic
uint8_t ielen=0;
int decode_result;
if((decode_result = decode_bstring (networkslicinginformation, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
......
......@@ -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);
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;
else
encoded += encode_result;
......
......@@ -12,6 +12,7 @@
#define PDU_ADDRESS_IPV4V6 0x03
typedef struct{
uint8_t spare:5;
uint8_t pdu_session_type_value:3;
bstring pdu_address_information;
}PDUAddress;
......
......@@ -8,23 +8,15 @@
int encode_pdu_session_identity ( PDUSessionIdentity pdusessionidentity, uint8_t iei, uint8_t * buffer, uint32_t len )
{
uint8_t *lenPtr;
uint32_t encoded = 0;
int encode_result;
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;
}
......@@ -34,10 +26,6 @@ int decode_pdu_session_identity ( PDUSessionIdentity * pdusessionidentity, uint8
uint8_t ielen=0;
int decode_result;
if((decode_result = decode_bstring (pdusessionidentity, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
......
......@@ -8,28 +8,20 @@
int encode_pdu_session_identity2 ( PDUSessionIdentity2 pdusessionidentity2, uint8_t iei, uint8_t * buffer, uint32_t len )
{
uint8_t *lenPtr;
uint32_t encoded = 0;
int encode_result;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,PDU_SESSION_IDENTITY2_MINIMUM_LENGTH , len);
if( iei >0 )
{
*buffer=iei;
encoded++;
}
if ((encode_result = encode_bstring (pdusessionidentity2, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
return encoded;
}
......@@ -45,9 +37,6 @@ int decode_pdu_session_identity2 ( PDUSessionIdentity2 * pdusessionidentity2, ui
decoded++;
}
if((decode_result = decode_bstring (pdusessionidentity2, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
......
......@@ -8,23 +8,15 @@
int encode_plain_5gsnas_message ( Plain5GSNASMessage plain5gsnasmessage, uint8_t iei, uint8_t * buffer, uint32_t len )
{
uint8_t *lenPtr;
uint32_t encoded = 0;
int encode_result;
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;
}
......@@ -34,10 +26,6 @@ int decode_plain_5gsnas_message ( Plain5GSNASMessage * plain5gsnasmessage, uint8
uint8_t ielen=0;
int decode_result;
if((decode_result = decode_bstring (plain5gsnasmessage, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
......
......@@ -8,23 +8,15 @@
int encode_procedure_transaction_identity ( ProcedureTransactionIdentity proceduretransactionidentity, uint8_t iei, uint8_t * buffer, uint32_t len )
{
uint8_t *lenPtr;
uint32_t encoded = 0;
int encode_result;
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;
}
......@@ -34,10 +26,6 @@ int decode_procedure_transaction_identity ( ProcedureTransactionIdentity * proce
uint8_t ielen=0;
int decode_result;
if((decode_result = decode_bstring (proceduretransactionidentity, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
......
......@@ -197,3 +197,15 @@ int decode_qos_flow_descriptions ( QOSFlowDescriptions * qosflowdescriptions, ui
return decoded;
}
void free_decode_qos_flow_descriptions(QOSFlowDescriptions * qosflowdescriptions)
{
for(int i=0;i<qosflowdescriptions->qosflowdescriptionsnumber;i++)
{
free(qosflowdescriptions->qosflowdescriptionscontents[i].parameterslist);
qosflowdescriptions->qosflowdescriptionscontents[i].parameterslist = NULL;
}
free(qosflowdescriptions->qosflowdescriptionscontents);
qosflowdescriptions->qosflowdescriptionscontents = NULL;
}
......
......@@ -118,5 +118,6 @@ typedef struct{
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 ) ;
void free_decode_qos_flow_descriptions(QOSFlowDescriptions * qosflowdescriptions);
#endif
......@@ -92,7 +92,6 @@ int decode_qos_rules ( QOSRules * qosrules, uint8_t iei, uint8_t * buffer, uint3
uint16_t ielen=0;
int decode_result = 0;
uint16_t numberrules = 0;
uint8_t *buffer_tmp = NULL;
uint16_t lenqosrule = 0;
uint8_t bitstream = 0;
int i=0,j=0;
......@@ -108,7 +107,6 @@ int decode_qos_rules ( QOSRules * qosrules, uint8_t iei, uint8_t * buffer, uint3
numberrules = ( numberrules << 8)+*(buffer + decoded);
decoded++;
buffer_tmp = buffer + decoded;
for(i=0;i<numberrules;i++)
{
ielen = *(buffer + ielen + 1) + 1;
......@@ -130,7 +128,7 @@ int decode_qos_rules ( QOSRules * qosrules, uint8_t iei, uint8_t * buffer, uint3
lenqosrule = (lenqosrule << 8)+*(buffer + decoded);
decoded++;
lenmoment = encoded;
*/
*/
DECODE_U8(buffer+decoded,bitstream,decoded);
qosrules->qosrulesie[i].ruleoperationcode = (bitstream>>5);
qosrules->qosrulesie[i].dqrbit = (bitstream>>4)&0x01;
......@@ -159,7 +157,7 @@ int decode_qos_rules ( QOSRules * qosrules, uint8_t iei, uint8_t * buffer, uint3
qosrules->qosrulesie[i].packetfilterlist.create_modifyandadd_modifyandreplace[j].packetfilterdirection = (bitstream>>4)&0x03;
qosrules->qosrulesie[i].packetfilterlist.create_modifyandadd_modifyandreplace[j].packetfilteridentifier = bitstream&0x0f;
uint8_t *lenghtofpacketfiltercontents = *(buffer + decoded)-1;
uint8_t *lenghtofpacketfiltercontents = (uint8_t * ) (*(buffer + decoded) - 1);
decoded++;
DECODE_U8(buffer+decoded,bitstream,decoded);
......@@ -185,3 +183,25 @@ int decode_qos_rules ( QOSRules * qosrules, uint8_t iei, uint8_t * buffer, uint3
return decoded;
}
void free_decode_qos_rules(QOSRules * qosrules)
{
int i;
for(i=0;i<qosrules->lengthofqosrulesie;i++)
{
if(qosrules->qosrulesie[i].ruleoperationcode == MODIFY_EXISTING_QOS_RULE_AND_DELETE_PACKET_FILTERS)
{
free(qosrules->qosrulesie[i].packetfilterlist.modifyanddelete);
qosrules->qosrulesie[i].packetfilterlist.modifyanddelete = NULL;
}
else if((qosrules->qosrulesie[i].ruleoperationcode == CREATE_NEW_QOS_RULE) || (qosrules->qosrulesie[i].ruleoperationcode == MODIFY_EXISTING_QOS_RULE_AND_ADD_PACKET_FILTERS) || (qosrules->qosrulesie[i].ruleoperationcode == MODIFY_EXISTING_QOS_RULE_AND_REPLACE_ALL_PACKET_FILTERS))
{
free(qosrules->qosrulesie[i].packetfilterlist.create_modifyandadd_modifyandreplace);
qosrules->qosrulesie[i].packetfilterlist.create_modifyandadd_modifyandreplace = NULL;
}
}
free(qosrules->qosrulesie);
qosrules->qosrulesie = NULL;
}
......@@ -88,7 +88,8 @@ typedef struct{
QOSRulesIE *qosrulesie;
}QOSRules;
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 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);
void free_decode_qos_rules(QOSRules * qosrules);
#endif
......@@ -8,23 +8,15 @@
int encode_request_type ( RequestType requesttype, uint8_t iei, uint8_t * buffer, uint32_t len )
{
uint8_t *lenPtr;
uint32_t encoded = 0;
int encode_result;
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;
}
......@@ -34,10 +26,6 @@ int decode_request_type ( RequestType * requesttype, uint8_t iei, uint8_t * buff
uint8_t ielen=0;
int decode_result;
if((decode_result = decode_bstring (requesttype, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
......
......@@ -10,7 +10,6 @@ int encode_s1_ue_network_capability ( S1UENetworkCapability s1uenetworkcapabilit
{
uint8_t *lenPtr;
uint32_t encoded = 0;
int encode_result;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,S1_UE_NETWORK_CAPABILITY_MINIMUM_LENGTH , len);
if( iei >0 ){
......@@ -32,7 +31,6 @@ int decode_s1_ue_network_capability ( S1UENetworkCapability * s1uenetworkcapabil
{
int decoded=0;
uint8_t ielen=0;
int decode_result;
if (iei > 0)
{
......
......@@ -8,23 +8,15 @@
int encode_sms_indication ( SMSIndication smsindication, uint8_t iei, uint8_t * buffer, uint32_t len )
{
uint8_t *lenPtr;
uint32_t encoded = 0;
int encode_result;
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;
}
......@@ -34,10 +26,6 @@ int decode_sms_indication ( SMSIndication * smsindication, uint8_t iei, uint8_t
uint8_t ielen=0;
int decode_result;
if((decode_result = decode_bstring (smsindication, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
......
......@@ -12,7 +12,6 @@ int encode_ssc_mode ( SSCMode sscmode, uint8_t iei, uint8_t * buffer, uint32_t l
uint8_t bitStream = 0x00;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,SSC_MODE_MINIMUM_LENGTH , len);
if(iei > 0){
bitStream |= (iei & 0xf0);
}
......@@ -20,7 +19,6 @@ int encode_ssc_mode ( SSCMode sscmode, uint8_t iei, uint8_t * buffer, uint32_t l
bitStream |= (sscmode.ssc_mode_value & 0x07);
ENCODE_U8(buffer+encoded,bitStream,encoded);
return encoded;
}
......@@ -29,10 +27,9 @@ int decode_ssc_mode ( SSCMode * sscmode, uint8_t iei, uint8_t * buffer, uint32_t
int decoded=0;
uint8_t bitStream = 0x00;
DECODE_U8(buffer+decoded,bitStream,decoded);
if(iei != bitStream&0xf0){
if(iei != (bitStream&0xf0)){
return -1;
}
......
......@@ -8,23 +8,15 @@
int encode_security_header_type ( SecurityHeaderType securityheadertype, uint8_t iei, uint8_t * buffer, uint32_t len )
{
uint8_t *lenPtr;
uint32_t encoded = 0;
int encode_result;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,SECURITY_HEADER_TYPE_MINIMUM_LENGTH , len);
if ((encode_result = encode_bstring (securityheadertype, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
return encoded;
}
......@@ -34,10 +26,6 @@ int decode_security_header_type ( SecurityHeaderType * securityheadertype, uint8
uint8_t ielen=0;
int decode_result;
if((decode_result = decode_bstring (securityheadertype, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
......
......@@ -8,23 +8,15 @@
int encode_sequence_number ( SequenceNumber sequencenumber, uint8_t iei, uint8_t * buffer, uint32_t len )
{
uint8_t *lenPtr;
uint32_t encoded = 0;
int encode_result;
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;
}
......@@ -34,10 +26,6 @@ int decode_sequence_number ( SequenceNumber * sequencenumber, uint8_t iei, uint8
uint8_t ielen=0;
int decode_result;
if((decode_result = decode_bstring (sequencenumber, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
......
......@@ -8,23 +8,15 @@
int encode_service_type ( ServiceType servicetype, uint8_t iei, uint8_t * buffer, uint32_t len )
{
uint8_t *lenPtr;
uint32_t encoded = 0;
int encode_result;
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;
}
......@@ -34,10 +26,6 @@ int decode_service_type ( ServiceType * servicetype, uint8_t iei, uint8_t * buff
uint8_t ielen=0;
int decode_result;
if((decode_result = decode_bstring (servicetype, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
......
......@@ -10,7 +10,6 @@ int encode_session_ambr ( SessionAMBR sessionambr, uint8_t iei, uint8_t * buffer
{
uint8_t *lenPtr = NULL;
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);
if( iei >0 )
......
......@@ -8,28 +8,21 @@
int encode_time_zone_and_time ( TimeZoneAndTime timezoneandtime, uint8_t iei, uint8_t * buffer, uint32_t len )
{
uint8_t *lenPtr;
uint32_t encoded = 0;
int encode_result;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,TIME_ZONE_AND_TIME_MINIMUM_LENGTH , len);
if( iei >0 )
{
*buffer=iei;
encoded++;
}
if ((encode_result = encode_bstring (timezoneandtime, buffer + encoded, len - encoded)) < 0)//加密,实体,首地址,长度
return encode_result;
else
encoded += encode_result;
return encoded;
}
......@@ -45,9 +38,6 @@ int decode_time_zone_and_time ( TimeZoneAndTime * timezoneandtime, uint8_t iei,
decoded++;
}
if((decode_result = decode_bstring (timezoneandtime, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
......
......@@ -10,7 +10,6 @@ int encode_ue_security_capability ( UESecurityCapability uesecuritycapability, u
{
uint8_t *lenPtr;
uint32_t encoded = 0;
int encode_result;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,UE_SECURITY_CAPABILITY_MINIMUM_LENGTH , len);
if( iei >0 ){
......@@ -32,7 +31,6 @@ int decode_ue_security_capability ( UESecurityCapability * uesecuritycapability,
{
int decoded=0;
uint8_t ielen=0;
int decode_result;
if (iei > 0)
{
......
......@@ -10,7 +10,6 @@ int encode_uplink_data_status ( UplinkDataStatus uplinkdatastatus, uint8_t iei,
{
uint8_t *lenPtr;
uint32_t encoded = 0;
int encode_result;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,UPLINK_DATA_STATUS_MINIMUM_LENGTH , len);
if( iei >0 ){
......@@ -31,7 +30,6 @@ int decode_uplink_data_status ( UplinkDataStatus * uplinkdatastatus, uint8_t iei
{
int decoded=0;
uint8_t ielen=0;
int decode_result;
if (iei > 0)
{
......
......@@ -10,7 +10,6 @@ int encode__5gmm_capability ( _5GMMCapability _5gmmcapability, uint8_t iei, uint
{
uint8_t *lenPtr;
uint32_t encoded = 0;
int encode_result;
uint8_t _5gmmcapability_bits = 0;
......@@ -40,10 +39,8 @@ int decode__5gmm_capability ( _5GMMCapability * _5gmmcapability, uint8_t iei, ui
{
int decoded=0;
uint8_t ielen=0;
int decode_result;
uint8_t _5gmmcapability_bits = 0;
uint8_t otherInformation = 0;
if (iei > 0){
CHECK_IEI_DECODER (iei, *buffer);
......
......@@ -8,9 +8,7 @@
int encode__5gs_tracking_area_identity ( _5GSTrackingAreaIdentity _5gstrackingareaidentity, uint8_t iei, uint8_t * buffer, uint32_t len )
{
uint8_t *lenPtr;
uint32_t encoded = 0;
int encode_result;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,_5GS_TRACKING_AREA_IDENTITY_MINIMUM_LENGTH , len);
if( iei >0 ){
......@@ -29,10 +27,7 @@ int encode__5gs_tracking_area_identity ( _5GSTrackingAreaIdentity _5gstrackingar
int decode__5gs_tracking_area_identity ( _5GSTrackingAreaIdentity * _5gstrackingareaidentity, uint8_t iei, uint8_t * buffer, uint32_t len )
{
int decoded=0;
uint8_t ielen=0;
int decode_result;
uint8_t mcc_mnc_decode = 0;
uint32_t tac_decode = 0;
if (iei > 0)
{
......
......@@ -11,7 +11,6 @@ int encode__5gs_update_type ( _5GSUpdateType _5gsupdatetype, uint8_t iei, uint8_
uint8_t *lenPtr;
uint32_t encoded = 0;
int encode_result;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER (buffer,_5GS_UPDATE_TYPE_MINIMUM_LENGTH , len);
if( iei >0 ){
......@@ -28,27 +27,27 @@ int encode__5gs_update_type ( _5GSUpdateType _5gsupdatetype, uint8_t iei, uint8_
*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 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 ){
if( iei >0 ){
*buffer=iei;
encoded++;
}
}
lenPtr = (buffer + encoded);
encoded++;
lenPtr = (buffer + encoded);
encoded++;
bitStream |= ((_5gsupdatetype.ng_ran_rcu&0x01)<<1);
bitStream |= (_5gsupdatetype.sms_requested&0x01);
ENCODE_U8(buffer+encoded,bitStream,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);
return encoded;
#endif
*lenPtr = encoded - 1 - ((iei > 0) ? 1 : 0);
return encoded;
#endif
}
int decode__5gs_update_type ( _5GSUpdateType * _5gsupdatetype, uint8_t iei, uint8_t * buffer, uint32_t len )
......@@ -56,7 +55,6 @@ int decode__5gs_update_type ( _5GSUpdateType * _5gsupdatetype, uint8_t iei, uint
int decoded=0;
uint8_t ielen=0;
int decode_result;
if (iei > 0)
{
......@@ -72,26 +70,26 @@ int decode__5gs_update_type ( _5GSUpdateType * _5gsupdatetype, uint8_t iei, uint
DECODE_U8(buffer+decoded, _5gsupdatetype->sms_requested, decoded);
return decoded;
#if 0
int decoded=0;
uint8_t ielen=0;
uint8_t bitStream = 0x0;
#if 0
int decoded=0;
uint8_t ielen=0;
uint8_t bitStream = 0x0;
if (iei > 0)
{
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);
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
_5gsupdatetype->ng_ran_rcu = bitStream&0x02;
_5gsupdatetype->sms_requested = bitStream&0x01;
return decoded;
#endif
}
......@@ -8,23 +8,15 @@
int encode__access_type ( _AccessType _accesstype, uint8_t iei, uint8_t * buffer, uint32_t len )
{
uint8_t *lenPtr;
uint32_t encoded = 0;
int encode_result;
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;
}
......@@ -34,10 +26,6 @@ int decode__access_type ( _AccessType * _accesstype, uint8_t iei, uint8_t * buff
uint8_t ielen=0;
int decode_result;
if((decode_result = decode_bstring (_accesstype, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
......
......@@ -31,7 +31,7 @@ int decode__pdu_session_type ( _PDUSessionType * _pdusessiontype, uint8_t iei, u
DECODE_U8(buffer+decoded,bitStream,decoded);
if(iei != bitStream&0xf0){
if(iei != (bitStream&0xf0)){
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
#define FILE_MM_DATA_H_SEEN
......
......@@ -52,7 +52,7 @@ int encode_authentication_failure( authentication_failure_msg *authentication_fa
// 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)
if((encoded_result = encode__5gmm_cause (authentication_failure->_5gmmcause, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
......
......@@ -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_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){
if((encoded_result = encode_eap_message (authentication_reject->eapmessage, AUTHENTICATION_REJECT_EAP_MESSAGE_IEI, buffer+encoded,len-encoded))<0)
return encoded_result;
......
......@@ -66,7 +66,7 @@ int decode_authentication_request( authentication_request_msg *authentication_re
}
break;
}
}
}
return decoded;
}
......
......@@ -14,8 +14,8 @@ int decode_authentication_response( authentication_response_msg *authentication_
// 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);
// uint8_t ieiDecoded = *(buffer+decoded);
// printf("ieiDecoded(%x)\n",ieiDecoded);
// uint8_t ieiDecoded = *(buffer+decoded);
// printf("ieiDecoded(%x)\n",ieiDecoded);
while (len - decoded > 0) {
......@@ -62,7 +62,7 @@ int encode_authentication_response( authentication_response_msg *authentication_
// 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
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;
......@@ -70,7 +70,7 @@ int encode_authentication_response( authentication_response_msg *authentication_
encoded+=encoded_result;
}
if(authentication_response->presence & AUTHENTICATION_RESPONSE_EAP_MESSAGE_PRESENT
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;
......
......@@ -13,7 +13,7 @@ int decode_deregistration_request( deregistration_request_msg *deregistration_re
// 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);
/*
/*
if((decoded_result = decode_extended_protocol_discriminator (&deregistration_request->extendedprotocoldiscriminator, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
......@@ -44,7 +44,7 @@ int decode_deregistration_request( deregistration_request_msg *deregistration_re
else
decoded+=decoded_result;
*/
*/
return decoded;
}
......@@ -56,7 +56,7 @@ int encode_deregistration_request( deregistration_request_msg *deregistration_re
// 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);
/*
/*
if((encoded_result = encode_extended_protocol_discriminator (deregistration_request->extendedprotocoldiscriminator, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
......@@ -87,6 +87,6 @@ int encode_deregistration_request( deregistration_request_msg *deregistration_re
else
encoded+=encoded_result;
*/
*/
return encoded;
}
......@@ -68,7 +68,7 @@ int encode_registration_reject( registration_reject_msg *registration_reject, ui
else
encoded+=encoded_result;
if(registration_reject->presence & REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_PRESENT
if((registration_reject->presence & 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)
return encoded_result;
......@@ -76,7 +76,7 @@ int encode_registration_reject( registration_reject_msg *registration_reject, ui
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){
if((encoded_result = encode_gprs_timer2 (registration_reject->t3502, REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_IEI, buffer+encoded,len-encoded))<0)
return encoded_result;
......@@ -84,7 +84,7 @@ int encode_registration_reject( registration_reject_msg *registration_reject, ui
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){
if((encoded_result = encode_eap_message (registration_reject->eapmessage, REGISTRATION_REJECT_EAP_MESSAGE_IEI, buffer+encoded,len-encoded))<0)
return encoded_result;
......
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 <asm/byteorder.h>
......@@ -5,11 +26,12 @@
typedef struct {
#ifdef __LITTLE_ENDIAN_BITFIELD
uint8_t extended_protocol_discriminator;
uint8_t security_header_type;
uint8_t security_header_type:4;
uint8_t spare_half_octet:4;
#endif
#ifdef __BIG_ENDIAN_BITFIELD
uint8_t security_header_type;
uint8_t extended_protocol_discriminator;
uint8_t spare_half_octet:4;
uint8_t security_header_type:4;
#endif
uint8_t message_type;
} __attribute__((__packed__)) mm_msg_header_t;
/*
* 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 "common_types.h"
#include "mm_msg.h"
//#include "log.h"
#include "TLVDecoder.h"
#include "TLVEncoder.h"
//#include "log.h"
//#include "nas_itti_messaging.h"
/****************************************************************************/
/******************* L O C A L D E F I N I T I O N S *******************/
......@@ -14,12 +33,12 @@ static int _fivegmm_msg_decode_header (
mm_msg_header_t * header,
const uint8_t * buffer,
uint32_t len);
static int _fivegmm_msg_encode_header (
const mm_msg_header_t * header,
uint8_t * buffer,
uint32_t len);
/****************************************************************************
** **
** Name: emm_msg_encode() **
......@@ -67,46 +86,46 @@ fivegmm_msg_encode (
//encode_result = encode_authentication_request(&msg->authentication_request,buffer,len);/* msg define in openair5g-cn/src/amf/nas/mm/msg */
//break;
case AUTHENTICATION_REQUEST:
encode_result = encode_authentication_request(&msg->specific_msg.authentication_request, buffer, len);
encode_result = encode_authentication_request(&msg->authentication_request, buffer, len);
break;
case AUTHENTICATION_RESPONSE:
encode_result = encode_authentication_response(&msg->specific_msg.authentication_response, buffer, len);
encode_result = encode_authentication_response(&msg->authentication_response, buffer, len);
break;
case AUTHENTICATION_RESULT:
encode_result = encode_authentication_result(&msg->specific_msg.authentication_result, buffer, len);
encode_result = encode_authentication_result(&msg->authentication_result, buffer, len);
break;
case AUTHENTICATION_REJECT:
encode_result = encode_authentication_reject(&msg->specific_msg.authentication_reject, buffer, len);
encode_result = encode_authentication_reject(&msg->authentication_reject, buffer, len);
break;
case AUTHENTICATION_FAILURE:
encode_result = encode_authentication_failure(&msg->specific_msg.authentication_failure, buffer, len);
encode_result = encode_authentication_failure(&msg->authentication_failure, buffer, len);
break;
case REGISTRATION_REQUEST:
encode_result = encode_registration_request(&msg->specific_msg.registration_request, buffer, len);
encode_result = encode_registration_request(&msg->registration_request, buffer, len);
break;
case REGISTRATION_ACCEPT:
encode_result = encode_registration_accept(&msg->specific_msg.registration_accept, buffer, len);
encode_result = encode_registration_accept(&msg->registration_accept, buffer, len);
break;
case REGISTRATION_COMPLETE:
encode_result = encode_registration_complete(&msg->specific_msg.registration_complete, buffer, len);
encode_result = encode_registration_complete(&msg->registration_complete, buffer, len);
break;
case REGISTRATION_REJECT:
encode_result = encode_registration_reject(&msg->specific_msg.registration_reject, buffer, len);
encode_result = encode_registration_reject(&msg->registration_reject, buffer, len);
break;
case IDENTITY_REQUEST:
encode_result = encode_identity_request(&msg->specific_msg.identity_request, buffer, len);
encode_result = encode_identity_request(&msg->identity_request, buffer, len);
break;
case IDENTITY_RESPONSE:
encode_result = encode_identity_response(&msg->specific_msg.identity_response, buffer, len);
encode_result = encode_identity_response(&msg->identity_response, buffer, len);
break;
case SECURITY_MODE_COMMAND:
encode_result = encode_security_mode_command(&msg->specific_msg.security_mode_command, buffer, len);
encode_result = encode_security_mode_command(&msg->security_mode_command, buffer, len);
break;
case SECURITY_MODE_COMPLETE:
encode_result = encode_security_mode_complete(&msg->specific_msg.security_mode_complete, buffer, len);
encode_result = encode_security_mode_complete(&msg->security_mode_complete, buffer, len);
break;
case SECURITY_MODE_REJECT:
encode_result = encode_security_mode_reject(&msg->specific_msg.security_mode_reject, buffer, len);
encode_result = encode_security_mode_reject(&msg->security_mode_reject, buffer, len);
break;
}
......@@ -206,46 +225,46 @@ mm_msg_decode (
//OAILOG_INFO (LOG_NAS_EMM, "EMM-MSG - Message Type 0x%02x\n", msg->header.message_type);
switch (msg->header.message_type) {//plain nas message e.g. registrationrequest message
case AUTHENTICATION_REQUEST:
decode_result = decode_authentication_request(&msg->specific_msg.authentication_request, buffer, len);
decode_result = decode_authentication_request(&msg->authentication_request, buffer, len);
break;
case AUTHENTICATION_RESPONSE:
decode_result = decode_authentication_response(&msg->specific_msg.authentication_response, buffer, len);
decode_result = decode_authentication_response(&msg->authentication_response, buffer, len);
break;
case AUTHENTICATION_RESULT:
decode_result = decode_authentication_result(&msg->specific_msg.authentication_result, buffer, len);
decode_result = decode_authentication_result(&msg->authentication_result, buffer, len);
break;
case AUTHENTICATION_REJECT:
decode_result = decode_authentication_reject(&msg->specific_msg.authentication_reject, buffer, len);
decode_result = decode_authentication_reject(&msg->authentication_reject, buffer, len);
break;
case AUTHENTICATION_FAILURE:
decode_result = decode_authentication_failure(&msg->specific_msg.authentication_failure, buffer, len);
decode_result = decode_authentication_failure(&msg->authentication_failure, buffer, len);
break;
case REGISTRATION_REQUEST:
decode_result = decode_registration_request(&msg->specific_msg.registration_request, buffer, len);
decode_result = decode_registration_request(&msg->registration_request, buffer, len);
break;
case REGISTRATION_ACCEPT:
decode_result = decode_registration_accept(&msg->specific_msg.registration_accept, buffer, len);
decode_result = decode_registration_accept(&msg->registration_accept, buffer, len);
break;
case REGISTRATION_COMPLETE:
decode_result = decode_registration_complete(&msg->specific_msg.registration_complete, buffer, len);
decode_result = decode_registration_complete(&msg->registration_complete, buffer, len);
break;
case REGISTRATION_REJECT:
decode_result = decode_registration_reject(&msg->specific_msg.registration_reject, buffer, len);
decode_result = decode_registration_reject(&msg->registration_reject, buffer, len);
break;
case IDENTITY_REQUEST:
decode_result = decode_identity_request(&msg->specific_msg.identity_request, buffer, len);
decode_result = decode_identity_request(&msg->identity_request, buffer, len);
break;
case IDENTITY_RESPONSE:
decode_result = decode_identity_response(&msg->specific_msg.identity_response, buffer, len);
decode_result = decode_identity_response(&msg->identity_response, buffer, len);
break;
case SECURITY_MODE_COMMAND:
decode_result = decode_security_mode_command(&msg->specific_msg.security_mode_command, buffer, len);
decode_result = decode_security_mode_command(&msg->security_mode_command, buffer, len);
break;
case SECURITY_MODE_COMPLETE:
decode_result = decode_security_mode_complete(&msg->specific_msg.security_mode_complete, buffer, len);
decode_result = decode_security_mode_complete(&msg->security_mode_complete, buffer, len);
break;
case SECURITY_MODE_REJECT:
decode_result = decode_security_mode_reject(&msg->specific_msg.security_mode_reject, buffer, len);
decode_result = decode_security_mode_reject(&msg->security_mode_reject, buffer, len);
break;
}
if (decode_result < 0) {
......
/*
* 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 MM_MSG_H_
#define MM_MSG_H_
......@@ -35,9 +57,8 @@
* Structure of EMM plain NAS message
* ----------------------------------
*/
typedef struct {
typedef union {
mm_msg_header_t header;
union {
authentication_request_msg authentication_request;//Done 19/03/2019
authentication_response_msg authentication_response;//Done 19/03/2019
authentication_result_msg authentication_result;
......@@ -67,8 +88,17 @@ typedef struct {
security_mode_reject_msg security_mode_reject;
_5gmm_status_msg _5gmm_status;
}specific_msg;
}MM_msg;
int mm_msg_decode (
MM_msg * msg,
uint8_t * buffer,
uint32_t len);
int fivegmm_msg_encode (
MM_msg * msg,
uint8_t * buffer,
uint32_t len);
#endif
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_
#define NAS_MESSAGE_H_
......@@ -22,11 +43,12 @@
typedef struct nas_message_security_header_s {
#ifdef __LITTLE_ENDIAN_BITFIELD
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
#ifdef __BIG_ENDIAN_BITFIELD
uint8_t security_header_type;
uint8_t extended_protocol_discriminator;
uint8_t spare_half_octet:4;
uint8_t security_header_type:4;
#endif
uint32_t message_authentication_code;
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
Version 0.1
Date 2019/08/05
Product NAS stack
Subsystem include
Author BUPT
Description Contains network's global definitions
*****************************************************************************/
#ifndef __NETWORK_DEF_H__
#define __NETWORK_DEF_H__
......@@ -36,4 +49,3 @@ Description Contains network's global definitions
#define NGAP_RRC_ESTABLISHMENT_CAUSE_MCS_PRIORITY_ACCESS 9
#endif
......@@ -14,7 +14,7 @@ int decode_pdu_session_authentication_command( pdu_session_authentication_comman
// 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, PDU_SESSION_AUTHENTICATION_COMMAND_MINIMUM_LENGTH, len);
#if 0
#if 0
if((decoded_result = decode_extended_protocol_discriminator (&pdu_session_authentication_command->extendedprotocoldiscriminator, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
......@@ -34,19 +34,19 @@ int decode_pdu_session_authentication_command( pdu_session_authentication_comman
return decoded_result;
else
decoded+=decoded_result;
#endif
#endif
if((decoded_result = decode_eap_message (&pdu_session_authentication_command->eapmessage, 0, buffer+decoded,len-decoded))<0)
{
return decoded_result;
}
else
{
decoded+=decoded_result;
}
while(len - decoded > 0)
{
//printf("encoding ies left(%d)\n",len-decoded);
//printf("decoded(%d)\n",decoded);
uint8_t ieiDecoded = *(buffer+decoded);
//printf("ieiDecoded = 0x%x\n",ieiDecoded);
//sleep(1);
if(ieiDecoded == 0)
break;
......@@ -77,7 +77,7 @@ int encode_pdu_session_authentication_command( pdu_session_authentication_comman
// 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, PDU_SESSION_AUTHENTICATION_COMMAND_MINIMUM_LENGTH, len);
#if 0
#if 0
if((encoded_result = encode_extended_protocol_discriminator (pdu_session_authentication_command->extendedprotocoldiscriminator, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
......@@ -97,7 +97,7 @@ int encode_pdu_session_authentication_command( pdu_session_authentication_comman
return encoded_result;
else
encoded+=encoded_result;
#endif
#endif
if((encoded_result = encode_eap_message (pdu_session_authentication_command->eapmessage, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
......@@ -107,10 +107,14 @@ int encode_pdu_session_authentication_command( pdu_session_authentication_comman
if((pdu_session_authentication_command->presence & PDU_SESSION_AUTHENTICATION_COMMAND_E_P_C_O_PRESENCE) == PDU_SESSION_AUTHENTICATION_COMMAND_E_P_C_O_PRESENCE)
{
if((encoded_result = encode_extended_protocol_configuration_options (pdu_session_authentication_command->extendedprotocolconfigurationoptions, PDU_SESSION_AUTHENTICATION_COMMAND_E_P_C_O_IEI, buffer+encoded,len-encoded))<0)
{
return encoded_result;
}
else
{
encoded+=encoded_result;
}
}
return encoded;
......
......@@ -14,7 +14,7 @@ int decode_pdu_session_authentication_complete( pdu_session_authentication_compl
// 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, PDU_SESSION_AUTHENTICATION_COMPLETE_MINIMUM_LENGTH, len);
#if 0
#if 0
if((decoded_result = decode_extended_protocol_discriminator (&pdu_session_authentication_complete->extendedprotocoldiscriminator, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
......@@ -34,20 +34,20 @@ int decode_pdu_session_authentication_complete( pdu_session_authentication_compl
return decoded_result;
else
decoded+=decoded_result;
#endif
#endif
if((decoded_result = decode_eap_message (&pdu_session_authentication_complete->eapmessage, 0, buffer+decoded,len-decoded))<0)
if((decoded_result = decode_eap_message (&pdu_session_authentication_complete->eapmessage, 0, buffer+decoded,len-decoded))<0)
{
return decoded_result;
else
}
else
{
decoded+=decoded_result;
}
while(len - decoded > 0)
{
//printf("encoding ies left(%d)\n",len-decoded);
//printf("decoded(%d)\n",decoded);
while(len - decoded > 0)
{
uint8_t ieiDecoded = *(buffer+decoded);
//printf("ieiDecoded = 0x%x\n",ieiDecoded);
//sleep(1);
if(ieiDecoded == 0)
break;
......@@ -64,9 +64,9 @@ int decode_pdu_session_authentication_complete( pdu_session_authentication_compl
}
break;
}
}
}
return decoded;
return decoded;
}
......@@ -78,7 +78,7 @@ int encode_pdu_session_authentication_complete( pdu_session_authentication_compl
// 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, PDU_SESSION_AUTHENTICATION_COMPLETE_MINIMUM_LENGTH, len);
#if 0
#if 0
if((encoded_result = encode_extended_protocol_discriminator (pdu_session_authentication_complete->extendedprotocoldiscriminator, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
......@@ -98,21 +98,25 @@ int encode_pdu_session_authentication_complete( pdu_session_authentication_compl
return encoded_result;
else
encoded+=encoded_result;
#endif
#endif
if((encoded_result = encode_eap_message (pdu_session_authentication_complete->eapmessage, 0, buffer+encoded,len-encoded))<0)
if((encoded_result = encode_eap_message (pdu_session_authentication_complete->eapmessage, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
else
encoded+=encoded_result;
if((pdu_session_authentication_complete->presence & PDU_SESSION_AUTHENTICATION_COMPLETE_E_P_C_O_PRESENCE) == PDU_SESSION_AUTHENTICATION_COMPLETE_E_P_C_O_PRESENCE)
{
if((pdu_session_authentication_complete->presence & PDU_SESSION_AUTHENTICATION_COMPLETE_E_P_C_O_PRESENCE) == PDU_SESSION_AUTHENTICATION_COMPLETE_E_P_C_O_PRESENCE)
{
if((encoded_result = encode_extended_protocol_configuration_options (pdu_session_authentication_complete->extendedprotocolconfigurationoptions, PDU_SESSION_AUTHENTICATION_COMPLETE_E_P_C_O_IEI, buffer+encoded,len-encoded))<0)
{
return encoded_result;
}
else
{
encoded+=encoded_result;
}
}
return encoded;
return encoded;
}
......@@ -35,33 +35,33 @@ int decode_pdu_session_establishment_accept( pdu_session_establishment_accept_ms
else
decoded+=decoded_result;
#endif
if((decoded_result = decode__pdu_session_type (&pdu_session_establishment_accept->_pdusessiontype, 0, buffer+decoded,len-decoded))<0)
if((decoded_result = decode__pdu_session_type (&pdu_session_establishment_accept->_pdusessiontype, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
else
decoded+=decoded_result;
if((decoded_result = decode_ssc_mode (&pdu_session_establishment_accept->sscmode, 0, buffer+decoded,len-decoded))<0)
if((decoded_result = decode_ssc_mode (&pdu_session_establishment_accept->sscmode, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
else
decoded+=decoded_result;
if((decoded_result = decode_qos_rules (&pdu_session_establishment_accept->qosrules, 0, buffer+decoded,len-decoded))<0)
if((decoded_result = decode_qos_rules (&pdu_session_establishment_accept->qosrules, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
else
decoded+=decoded_result;
if((decoded_result = decode_session_ambr (&pdu_session_establishment_accept->sessionambr, 0, buffer+decoded,len-decoded))<0)
if((decoded_result = decode_session_ambr (&pdu_session_establishment_accept->sessionambr, 0, buffer+decoded,len-decoded))<0)
{
return decoded_result;
else
}
else
{
decoded+=decoded_result;
}
while(len - decoded > 0)
{
//printf("encoding ies left(%d)\n",len-decoded);
//printf("decoded(%d)\n",decoded);
while(len - decoded > 0)
{
uint8_t ieiDecoded = *(buffer+decoded);
//printf("ieiDecoded = 0x%x\n",ieiDecoded);
//sleep(1);
if(ieiDecoded == 0)
break;
......@@ -163,9 +163,9 @@ int decode_pdu_session_establishment_accept( pdu_session_establishment_accept_ms
break;
}
}
}
return decoded;
return decoded;
}
......@@ -174,9 +174,10 @@ int encode_pdu_session_establishment_accept( pdu_session_establishment_accept_ms
uint32_t encoded = 0;
int encoded_result = 0;
printf ("\n******************* encode_pdu_session_establishment_accept*****************\n");
// 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, PDU_SESSION_ESTABLISHMENT_ACCEPT_MINIMUM_LENGTH, len);
/*
#if 0
if((encoded_result = encode_extended_protocol_discriminator (pdu_session_establishment_accept->extendedprotocoldiscriminator, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
......@@ -198,6 +199,8 @@ int encode_pdu_session_establishment_accept( pdu_session_establishment_accept_ms
else
encoded+=encoded_result;
#endif
*/
if((encoded_result = encode__pdu_session_type (pdu_session_establishment_accept->_pdusessiontype, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
......
......@@ -35,18 +35,18 @@ int decode_pdu_session_establishment_reject( pdu_session_establishment_reject_ms
else
decoded+=decoded_result;
#endif
if((decoded_result = decode__5gsm_cause (&pdu_session_establishment_reject->_5gsmcause, 0, buffer+decoded,len-decoded))<0)
if((decoded_result = decode__5gsm_cause (&pdu_session_establishment_reject->_5gsmcause, 0, buffer+decoded,len-decoded))<0)
{
return decoded_result;
else
}
else
{
decoded+=decoded_result;
}
while(len - decoded > 0)
{
//printf("encoding ies left(%d)\n",len-decoded);
//printf("decoded(%d)\n",decoded);
while(len - decoded > 0)
{
uint8_t ieiDecoded = *(buffer+decoded);
//printf("ieiDecoded = 0x%x\n",ieiDecoded);
//sleep(1);
if(ieiDecoded == 0)
break;
......@@ -103,9 +103,9 @@ int decode_pdu_session_establishment_reject( pdu_session_establishment_reject_ms
break;
}
}
}
return decoded;
return decoded;
}
......@@ -117,7 +117,7 @@ int encode_pdu_session_establishment_reject( pdu_session_establishment_reject_ms
// 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, PDU_SESSION_ESTABLISHMENT_REJECT_MINIMUM_LENGTH, len);
#if 0
#if 0
if((encoded_result = encode_extended_protocol_discriminator (pdu_session_establishment_reject->extendedprotocoldiscriminator, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
......@@ -137,52 +137,52 @@ int encode_pdu_session_establishment_reject( pdu_session_establishment_reject_ms
return encoded_result;
else
encoded+=encoded_result;
#endif
#endif
if((encoded_result = encode__5gsm_cause (pdu_session_establishment_reject->_5gsmcause, 0, buffer+encoded,len-encoded))<0)
if((encoded_result = encode__5gsm_cause (pdu_session_establishment_reject->_5gsmcause, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
else
encoded+=encoded_result;
if((pdu_session_establishment_reject->presence & PDU_SESSION_ESTABLISHMENT_REJECT_GPRS_TIMER3_PRESENCE) == PDU_SESSION_ESTABLISHMENT_REJECT_GPRS_TIMER3_PRESENCE)
{
if((pdu_session_establishment_reject->presence & PDU_SESSION_ESTABLISHMENT_REJECT_GPRS_TIMER3_PRESENCE) == PDU_SESSION_ESTABLISHMENT_REJECT_GPRS_TIMER3_PRESENCE)
{
if((encoded_result = encode_gprs_timer3 (pdu_session_establishment_reject->gprstimer3, PDU_SESSION_ESTABLISHMENT_REJECT_GPRS_TIMER3_IEI, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
}
}
if((pdu_session_establishment_reject->presence & PDU_SESSION_ESTABLISHMENT_REJECT_ALLOWED_SSC_MODE_PRESENCE) == PDU_SESSION_ESTABLISHMENT_REJECT_ALLOWED_SSC_MODE_PRESENCE)
{
if((pdu_session_establishment_reject->presence & PDU_SESSION_ESTABLISHMENT_REJECT_ALLOWED_SSC_MODE_PRESENCE) == PDU_SESSION_ESTABLISHMENT_REJECT_ALLOWED_SSC_MODE_PRESENCE)
{
if((encoded_result = encode_allowed_ssc_mode (pdu_session_establishment_reject->allowedsscmode, PDU_SESSION_ESTABLISHMENT_REJECT_ALLOWED_SSC_MODE_IEI, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
}
}
if((pdu_session_establishment_reject->presence & PDU_SESSION_ESTABLISHMENT_REJECT_EAP_MESSAGE_PRESENCE) == PDU_SESSION_ESTABLISHMENT_REJECT_EAP_MESSAGE_PRESENCE)
{
if((pdu_session_establishment_reject->presence & PDU_SESSION_ESTABLISHMENT_REJECT_EAP_MESSAGE_PRESENCE) == PDU_SESSION_ESTABLISHMENT_REJECT_EAP_MESSAGE_PRESENCE)
{
if((encoded_result = encode_eap_message (pdu_session_establishment_reject->eapmessage, PDU_SESSION_ESTABLISHMENT_REJECT_EAP_MESSAGE_IEI, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
}
}
if((pdu_session_establishment_reject->presence & PDU_SESSION_ESTABLISHMENT_REJECT_E_P_C_O_PRESENCE) == PDU_SESSION_ESTABLISHMENT_REJECT_E_P_C_O_PRESENCE)
{
if((pdu_session_establishment_reject->presence & PDU_SESSION_ESTABLISHMENT_REJECT_E_P_C_O_PRESENCE) == PDU_SESSION_ESTABLISHMENT_REJECT_E_P_C_O_PRESENCE)
{
if((encoded_result = encode_extended_protocol_configuration_options (pdu_session_establishment_reject->extendedprotocolconfigurationoptions, PDU_SESSION_ESTABLISHMENT_REJECT_E_P_C_O_IEI, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
}
}
if((pdu_session_establishment_reject->presence & PDU_SESSION_ESTABLISHMENT_REJECT__5GSM_CONGESTION_REATTEMPT_INDICATOR_PRESENCE) == PDU_SESSION_ESTABLISHMENT_REJECT__5GSM_CONGESTION_REATTEMPT_INDICATOR_PRESENCE)
{
if((pdu_session_establishment_reject->presence & PDU_SESSION_ESTABLISHMENT_REJECT__5GSM_CONGESTION_REATTEMPT_INDICATOR_PRESENCE) == PDU_SESSION_ESTABLISHMENT_REJECT__5GSM_CONGESTION_REATTEMPT_INDICATOR_PRESENCE)
{
if((encoded_result = encode__5gsm_congestion_reattempt_indicator (pdu_session_establishment_reject->_5gsmcongestionreattemptindicator, PDU_SESSION_ESTABLISHMENT_REJECT__5GSM_CONGESTION_REATTEMPT_INDICATOR_IEI, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
}
}
return encoded;
return encoded;
}
......@@ -10,11 +10,11 @@ int decode_pdu_session_establishment_request( pdu_session_establishment_request_
{
uint32_t decoded = 0;
int decoded_result = 0;
printf("decode_pdu_session_establishment_request\n");
// 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, PDU_SESSION_ESTABLISHMENT_REQUEST_MINIMUM_LENGTH, len);
#if 0
#if 0
if((decoded_result = decode_extended_protocol_discriminator (&pdu_session_establishment_request->extendedprotocoldiscriminator, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
......@@ -34,20 +34,20 @@ int decode_pdu_session_establishment_request( pdu_session_establishment_request_
return decoded_result;
else
decoded+=decoded_result;
#endif
#endif
if((decoded_result = decode_intergrity_protection_maximum_data_rate (&pdu_session_establishment_request->intergrityprotectionmaximumdatarate, 0, buffer+decoded,len-decoded))<0)
if((decoded_result = decode_intergrity_protection_maximum_data_rate (&pdu_session_establishment_request->intergrityprotectionmaximumdatarate, 0, buffer+decoded,len-decoded))<0)
{
return decoded_result;
else
}
else
{
decoded+=decoded_result;
}
while(len - decoded > 0)
{
//printf("encoding ies left(%d)\n",len-decoded);
//printf("decoded(%d)\n",decoded);
while(len - decoded > 0)
{
uint8_t ieiDecoded = *(buffer+decoded);
//printf("ieiDecoded = 0x%x\n",ieiDecoded);
//sleep(1);
if(ieiDecoded == 0)
break;
......@@ -127,21 +127,20 @@ int decode_pdu_session_establishment_request( pdu_session_establishment_request_
}
break;
}
}
}
return decoded;
return decoded;
}
int encode_pdu_session_establishment_request( pdu_session_establishment_request_msg *pdu_session_establishment_request, uint8_t* buffer, uint32_t len)
{
//printf("encode_pdu_session_establishment_request, start -----------------------\n");
uint32_t encoded = 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, PDU_SESSION_ESTABLISHMENT_REQUEST_MINIMUM_LENGTH, len);
#if 0
/* #if 0
if((encoded_result = encode_extended_protocol_discriminator (pdu_session_establishment_request->extendedprotocoldiscriminator, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
......@@ -162,12 +161,16 @@ int encode_pdu_session_establishment_request( pdu_session_establishment_request_
else
encoded+=encoded_result;
#endif
*/
if((encoded_result = encode_intergrity_protection_maximum_data_rate (pdu_session_establishment_request->intergrityprotectionmaximumdatarate, 0, buffer+encoded,len-encoded))<0)
{
return encoded_result;
}
else
{
encoded+=encoded_result;
}
if((pdu_session_establishment_request->presence & PDU_SESSION_ESTABLISHMENT_REQUEST_PDU_SESSION_TYPE_PRESENT) == PDU_SESSION_ESTABLISHMENT_REQUEST_PDU_SESSION_TYPE_PRESENT)
{
......
......@@ -14,7 +14,7 @@ int decode_pdu_session_modification_command_reject( pdu_session_modification_com
// 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, PDU_SESSION_MODIFICATION_COMMAND_REJECT_MINIMUM_LENGTH, len);
#if 0
#if 0
if((decoded_result = decode_extended_protocol_discriminator (&pdu_session_modification_command_reject->extendedprotocoldiscriminator, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
......@@ -34,20 +34,20 @@ int decode_pdu_session_modification_command_reject( pdu_session_modification_com
return decoded_result;
else
decoded+=decoded_result;
#endif
#endif
if((decoded_result = decode__5gsm_cause (&pdu_session_modification_command_reject->_5gsmcause, 0, buffer+decoded,len-decoded))<0)
if((decoded_result = decode__5gsm_cause (&pdu_session_modification_command_reject->_5gsmcause, 0, buffer+decoded,len-decoded))<0)
{
return decoded_result;
else
}
else
{
decoded+=decoded_result;
}
while(len - decoded > 0)
{
//printf("encoding ies left(%d)\n",len-decoded);
//printf("decoded(%d)\n",decoded);
while(len - decoded > 0)
{
uint8_t ieiDecoded = *(buffer+decoded);
//printf("ieiDecoded = 0x%x\n",ieiDecoded);
//sleep(1);
if(ieiDecoded == 0)
break;
......@@ -64,9 +64,9 @@ int decode_pdu_session_modification_command_reject( pdu_session_modification_com
}
break;
}
}
}
return decoded;
return decoded;
}
......@@ -78,7 +78,7 @@ int encode_pdu_session_modification_command_reject( pdu_session_modification_com
// 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, PDU_SESSION_MODIFICATION_COMMAND_REJECT_MINIMUM_LENGTH, len);
#if 0
#if 0
if((encoded_result = encode_extended_protocol_discriminator (pdu_session_modification_command_reject->extendedprotocoldiscriminator, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
......@@ -98,20 +98,24 @@ int encode_pdu_session_modification_command_reject( pdu_session_modification_com
return encoded_result;
else
encoded+=encoded_result;
#endif
#endif
if((encoded_result = encode__5gsm_cause (pdu_session_modification_command_reject->_5gsmcause, 0, buffer+encoded,len-encoded))<0)
if((encoded_result = encode__5gsm_cause (pdu_session_modification_command_reject->_5gsmcause, 0, buffer+encoded,len-encoded))<0)
{
return encoded_result;
else
}
else
{
encoded+=encoded_result;
}
if((pdu_session_modification_command_reject->presence & PDU_SESSION_MODIFICATION_COMMAND_REJECT_E_P_C_O_PRESENCE) == PDU_SESSION_MODIFICATION_COMMAND_REJECT_E_P_C_O_PRESENCE)
{
if((pdu_session_modification_command_reject->presence & PDU_SESSION_MODIFICATION_COMMAND_REJECT_E_P_C_O_PRESENCE) == PDU_SESSION_MODIFICATION_COMMAND_REJECT_E_P_C_O_PRESENCE)
{
if((encoded_result = encode_extended_protocol_configuration_options (pdu_session_modification_command_reject->extendedprotocolconfigurationoptions, PDU_SESSION_MODIFICATION_COMMAND_REJECT_E_P_C_O_IEI, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
}
}
return encoded;
return encoded;
}
......@@ -14,7 +14,7 @@ int decode_pdu_session_modification_reject( pdu_session_modification_reject_msg
// 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, PDU_SESSION_MODIFICATION_REJECT_MINIMUM_LENGTH, len);
#if 0
#if 0
if((decoded_result = decode_extended_protocol_discriminator (&pdu_session_modification_reject->extendedprotocoldiscriminator, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
......@@ -34,20 +34,20 @@ int decode_pdu_session_modification_reject( pdu_session_modification_reject_msg
return decoded_result;
else
decoded+=decoded_result;
#endif
#endif
if((decoded_result = decode__5gsm_cause (&pdu_session_modification_reject->_5gsmcause, 0, buffer+decoded,len-decoded))<0)
if((decoded_result = decode__5gsm_cause (&pdu_session_modification_reject->_5gsmcause, 0, buffer+decoded,len-decoded))<0)
{
return decoded_result;
else
}
else
{
decoded+=decoded_result;
}
while(len - decoded > 0)
{
//printf("encoding ies left(%d)\n",len-decoded);
//printf("decoded(%d)\n",decoded);
while(len - decoded > 0)
{
uint8_t ieiDecoded = *(buffer+decoded);
//printf("ieiDecoded = 0x%x\n",ieiDecoded);
//sleep(1);
if(ieiDecoded == 0)
break;
......@@ -82,9 +82,9 @@ int decode_pdu_session_modification_reject( pdu_session_modification_reject_msg
}
break;
}
}
}
return decoded;
return decoded;
}
......@@ -96,7 +96,7 @@ int encode_pdu_session_modification_reject( pdu_session_modification_reject_msg
// 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, PDU_SESSION_MODIFICATION_REJECT_MINIMUM_LENGTH, len);
#if 0
#if 0
if((encoded_result = encode_extended_protocol_discriminator (pdu_session_modification_reject->extendedprotocoldiscriminator, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
......@@ -116,36 +116,40 @@ int encode_pdu_session_modification_reject( pdu_session_modification_reject_msg
return encoded_result;
else
encoded+=encoded_result;
#endif
#endif
if((encoded_result = encode__5gsm_cause (pdu_session_modification_reject->_5gsmcause, 0, buffer+encoded,len-encoded))<0)
if((encoded_result = encode__5gsm_cause (pdu_session_modification_reject->_5gsmcause, 0, buffer+encoded,len-encoded))<0)
{
return encoded_result;
else
}
else
{
encoded+=encoded_result;
}
if((pdu_session_modification_reject->presence & PDU_SESSION_MODIFICATION_REJECT_GPRS_TIMER3_PRESENCE) == PDU_SESSION_MODIFICATION_REJECT_GPRS_TIMER3_PRESENCE)
{
if((pdu_session_modification_reject->presence & PDU_SESSION_MODIFICATION_REJECT_GPRS_TIMER3_PRESENCE) == PDU_SESSION_MODIFICATION_REJECT_GPRS_TIMER3_PRESENCE)
{
if((encoded_result = encode_gprs_timer3 (pdu_session_modification_reject->gprstimer3, PDU_SESSION_MODIFICATION_REJECT_GPRS_TIMER3_IEI, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
}
}
if((pdu_session_modification_reject->presence & PDU_SESSION_MODIFICATION_REJECT_E_P_C_O_PRESENCE) == PDU_SESSION_MODIFICATION_REJECT_E_P_C_O_PRESENCE)
{
if((pdu_session_modification_reject->presence & PDU_SESSION_MODIFICATION_REJECT_E_P_C_O_PRESENCE) == PDU_SESSION_MODIFICATION_REJECT_E_P_C_O_PRESENCE)
{
if((encoded_result = encode_extended_protocol_configuration_options (pdu_session_modification_reject->extendedprotocolconfigurationoptions, PDU_SESSION_MODIFICATION_REJECT_E_P_C_O_IEI, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
}
}
if((pdu_session_modification_reject->presence & PDU_SESSION_MODIFICATION_REJECT__5GSM_CONGESTION_REATTEMPT_INDICATOR_PRESENCE) == PDU_SESSION_MODIFICATION_REJECT__5GSM_CONGESTION_REATTEMPT_INDICATOR_PRESENCE)
{
if((pdu_session_modification_reject->presence & PDU_SESSION_MODIFICATION_REJECT__5GSM_CONGESTION_REATTEMPT_INDICATOR_PRESENCE) == PDU_SESSION_MODIFICATION_REJECT__5GSM_CONGESTION_REATTEMPT_INDICATOR_PRESENCE)
{
if((encoded_result = encode__5gsm_congestion_reattempt_indicator (pdu_session_modification_reject->_5gsmcongestionreattemptindicator, PDU_SESSION_MODIFICATION_REJECT__5GSM_CONGESTION_REATTEMPT_INDICATOR_IEI, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
}
}
return encoded;
return encoded;
}
......@@ -14,7 +14,7 @@ int decode_pdu_session_release_command( pdu_session_release_command_msg *pdu_ses
// 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, PDU_SESSION_RELEASE_COMMAND_MINIMUM_LENGTH, len);
#if 0
#if 0
if((decoded_result = decode_extended_protocol_discriminator (&pdu_session_release_command->extendedprotocoldiscriminator, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
......@@ -34,20 +34,20 @@ int decode_pdu_session_release_command( pdu_session_release_command_msg *pdu_ses
return decoded_result;
else
decoded+=decoded_result;
#endif
#endif
if((decoded_result = decode__5gsm_cause (&pdu_session_release_command->_5gsmcause, 0, buffer+decoded,len-decoded))<0)
if((decoded_result = decode__5gsm_cause (&pdu_session_release_command->_5gsmcause, 0, buffer+decoded,len-decoded))<0)
{
return decoded_result;
else
}
else
{
decoded+=decoded_result;
}
while(len - decoded > 0)
{
//printf("encoding ies left(%d)\n",len-decoded);
//printf("decoded(%d)\n",decoded);
while(len - decoded > 0)
{
uint8_t ieiDecoded = *(buffer+decoded);
//printf("ieiDecoded = 0x%x\n",ieiDecoded);
//sleep(1);
if(ieiDecoded == 0)
break;
......@@ -91,9 +91,9 @@ int decode_pdu_session_release_command( pdu_session_release_command_msg *pdu_ses
}
break;
}
}
}
return decoded;
return decoded;
}
......@@ -105,7 +105,7 @@ int encode_pdu_session_release_command( pdu_session_release_command_msg *pdu_ses
// 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, PDU_SESSION_RELEASE_COMMAND_MINIMUM_LENGTH, len);
#if 0
#if 0
if((encoded_result = encode_extended_protocol_discriminator (pdu_session_release_command->extendedprotocoldiscriminator, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
......@@ -125,45 +125,49 @@ int encode_pdu_session_release_command( pdu_session_release_command_msg *pdu_ses
return encoded_result;
else
encoded+=encoded_result;
#endif
#endif
if((encoded_result = encode__5gsm_cause (pdu_session_release_command->_5gsmcause, 0, buffer+encoded,len-encoded))<0)
if((encoded_result = encode__5gsm_cause (pdu_session_release_command->_5gsmcause, 0, buffer+encoded,len-encoded))<0)
{
return encoded_result;
else
}
else
{
encoded+=encoded_result;
}
if((pdu_session_release_command->presence & PDU_SESSION_RELEASE_COMMAND_GPRS_TIMER3_PRESENCE) == PDU_SESSION_RELEASE_COMMAND_GPRS_TIMER3_PRESENCE)
{
if((pdu_session_release_command->presence & PDU_SESSION_RELEASE_COMMAND_GPRS_TIMER3_PRESENCE) == PDU_SESSION_RELEASE_COMMAND_GPRS_TIMER3_PRESENCE)
{
if((encoded_result = encode_gprs_timer3 (pdu_session_release_command->gprstimer3, PDU_SESSION_RELEASE_COMMAND_GPRS_TIMER3_IEI, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
}
}
if((pdu_session_release_command->presence & PDU_SESSION_RELEASE_COMMAND_EAP_MESSAGE_PRESENCE) == PDU_SESSION_RELEASE_COMMAND_EAP_MESSAGE_PRESENCE)
{
if((pdu_session_release_command->presence & PDU_SESSION_RELEASE_COMMAND_EAP_MESSAGE_PRESENCE) == PDU_SESSION_RELEASE_COMMAND_EAP_MESSAGE_PRESENCE)
{
if((encoded_result = encode_eap_message (pdu_session_release_command->eapmessage, PDU_SESSION_RELEASE_COMMAND_EAP_MESSAGE_IEI, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
}
}
if((pdu_session_release_command->presence & PDU_SESSION_RELEASE_COMMAND__5GSM_CONGESTION_REATTEMPT_INDICATOR_PRESENCE) == PDU_SESSION_RELEASE_COMMAND__5GSM_CONGESTION_REATTEMPT_INDICATOR_PRESENCE)
{
if((pdu_session_release_command->presence & PDU_SESSION_RELEASE_COMMAND__5GSM_CONGESTION_REATTEMPT_INDICATOR_PRESENCE) == PDU_SESSION_RELEASE_COMMAND__5GSM_CONGESTION_REATTEMPT_INDICATOR_PRESENCE)
{
if((encoded_result = encode__5gsm_congestion_reattempt_indicator (pdu_session_release_command->_5gsmcongestionreattemptindicator, PDU_SESSION_RELEASE_COMMAND__5GSM_CONGESTION_REATTEMPT_INDICATOR_IEI, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
}
}
if((pdu_session_release_command->presence & PDU_SESSION_RELEASE_COMMAND_E_P_C_O_PRESENCE) == PDU_SESSION_RELEASE_COMMAND_E_P_C_O_PRESENCE)
{
if((pdu_session_release_command->presence & PDU_SESSION_RELEASE_COMMAND_E_P_C_O_PRESENCE) == PDU_SESSION_RELEASE_COMMAND_E_P_C_O_PRESENCE)
{
if((encoded_result = encode_extended_protocol_configuration_options (pdu_session_release_command->extendedprotocolconfigurationoptions, PDU_SESSION_RELEASE_COMMAND_E_P_C_O_IEI, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
}
}
return encoded;
return encoded;
}
......@@ -14,7 +14,7 @@ int decode_pdu_session_release_reject( pdu_session_release_reject_msg *pdu_sessi
// 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, PDU_SESSION_RELEASE_REJECT_MINIMUM_LENGTH, len);
#if 0
#if 0
if((decoded_result = decode_extended_protocol_discriminator (&pdu_session_release_reject->extendedprotocoldiscriminator, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
......@@ -34,20 +34,20 @@ int decode_pdu_session_release_reject( pdu_session_release_reject_msg *pdu_sessi
return decoded_result;
else
decoded+=decoded_result;
#endif
#endif
if((decoded_result = decode__5gsm_cause (&pdu_session_release_reject->_5gsmcause, 0, buffer+decoded,len-decoded))<0)
if((decoded_result = decode__5gsm_cause (&pdu_session_release_reject->_5gsmcause, 0, buffer+decoded,len-decoded))<0)
{
return decoded_result;
else
decoded+=decoded_result;
}
else
{
decoded += decoded_result;
}
while(len - decoded > 0)
{
//printf("encoding ies left(%d)\n",len-decoded);
//printf("decoded(%d)\n",decoded);
while(len - decoded > 0)
{
uint8_t ieiDecoded = *(buffer+decoded);
//printf("ieiDecoded = 0x%x\n",ieiDecoded);
//sleep(1);
if(ieiDecoded == 0)
break;
......@@ -64,9 +64,9 @@ int decode_pdu_session_release_reject( pdu_session_release_reject_msg *pdu_sessi
}
break;
}
}
}
return decoded;
return decoded;
}
......@@ -78,7 +78,7 @@ int encode_pdu_session_release_reject( pdu_session_release_reject_msg *pdu_sessi
// 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, PDU_SESSION_RELEASE_REJECT_MINIMUM_LENGTH, len);
#if 0
#if 0
if((encoded_result = encode_extended_protocol_discriminator (pdu_session_release_reject->extendedprotocoldiscriminator, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
......@@ -98,21 +98,25 @@ int encode_pdu_session_release_reject( pdu_session_release_reject_msg *pdu_sessi
return encoded_result;
else
encoded+=encoded_result;
#endif
#endif
if((encoded_result = encode__5gsm_cause (pdu_session_release_reject->_5gsmcause, 0, buffer+encoded,len-encoded))<0)
if((encoded_result = encode__5gsm_cause (pdu_session_release_reject->_5gsmcause, 0, buffer+encoded,len-encoded))<0)
{
return encoded_result;
else
encoded+=encoded_result;
}
else
{
encoded += encoded_result;
}
if((pdu_session_release_reject->presence & PDU_SESSION_RELEASE_REJECT_E_P_C_O_PRESENCE) == PDU_SESSION_RELEASE_REJECT_E_P_C_O_PRESENCE)
{
if((pdu_session_release_reject->presence & PDU_SESSION_RELEASE_REJECT_E_P_C_O_PRESENCE) == PDU_SESSION_RELEASE_REJECT_E_P_C_O_PRESENCE)
{
if((encoded_result = encode_extended_protocol_configuration_options (pdu_session_release_reject->extendedprotocolconfigurationoptions, PDU_SESSION_RELEASE_REJECT_E_P_C_O_IEI, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
}
}
return encoded;
return encoded;
}
......@@ -14,7 +14,7 @@ int decode_pdu_session_release_request( pdu_session_release_request_msg *pdu_ses
// 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, PDU_SESSION_RELEASE_REQUEST_MINIMUM_LENGTH, len);
#if 0
#if 0
if((decoded_result = decode_extended_protocol_discriminator (&pdu_session_release_request->extendedprotocoldiscriminator, 0, buffer+decoded,len-decoded))<0)
return decoded_result;
else
......@@ -31,18 +31,18 @@ int decode_pdu_session_release_request( pdu_session_release_request_msg *pdu_ses
decoded+=decoded_result;
if((decoded_result = decode_message_type (&pdu_session_release_request->messagetype, 0, buffer+decoded,len-decoded))<0)
{
return decoded_result;
}
else
decoded+=decoded_result;
#endif
while(len - decoded > 0)
{
//printf("encoding ies left(%d)\n",len-decoded);
//printf("decoded(%d)\n",decoded);
decoded += decoded_result;
}
#endif
while(len - decoded > 0)
{
uint8_t ieiDecoded = *(buffer+decoded);
//printf("ieiDecoded = 0x%x\n",ieiDecoded);
//sleep(1);
if(ieiDecoded == 0)
break;
......@@ -59,7 +59,7 @@ int decode_pdu_session_release_request( pdu_session_release_request_msg *pdu_ses
}
break;
case PDU_SESSION_RELEASE_REQUEST_E_P_C_O_IEI:
if(((decoded_result = decode_extended_protocol_configuration_options (&pdu_session_release_request->extendedprotocolconfigurationoptions, PDU_SESSION_RELEASE_REQUEST_E_P_C_O_IEI, buffer+decoded,len-decoded))<0)<0)
if((decoded_result = decode_extended_protocol_configuration_options (&pdu_session_release_request->extendedprotocolconfigurationoptions, PDU_SESSION_RELEASE_REQUEST_E_P_C_O_IEI, buffer+decoded,len-decoded)) < 0)
return decoded_result;
else
{
......@@ -68,7 +68,7 @@ int decode_pdu_session_release_request( pdu_session_release_request_msg *pdu_ses
}
break;
}
}
}
return decoded;
}
......@@ -82,7 +82,7 @@ int encode_pdu_session_release_request( pdu_session_release_request_msg *pdu_ses
// 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, PDU_SESSION_RELEASE_REQUEST_MINIMUM_LENGTH, len);
#if 0
#if 0
if((encoded_result = encode_extended_protocol_discriminator (pdu_session_release_request->extendedprotocoldiscriminator, 0, buffer+encoded,len-encoded))<0)
return encoded_result;
else
......@@ -102,24 +102,24 @@ int encode_pdu_session_release_request( pdu_session_release_request_msg *pdu_ses
return encoded_result;
else
encoded+=encoded_result;
#endif
#endif
if((pdu_session_release_request->presence & PDU_SESSION_RELEASE_REQUEST__5GSM_CAUSE_PRESENCE) == PDU_SESSION_RELEASE_REQUEST__5GSM_CAUSE_PRESENCE)
{
if((pdu_session_release_request->presence & PDU_SESSION_RELEASE_REQUEST__5GSM_CAUSE_PRESENCE) == PDU_SESSION_RELEASE_REQUEST__5GSM_CAUSE_PRESENCE)
{
if((encoded_result = encode__5gsm_cause (pdu_session_release_request->_5gsmcause, PDU_SESSION_RELEASE_REQUEST__5GSM_CAUSE_IEI, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
}
}
if((pdu_session_release_request->presence & PDU_SESSION_RELEASE_REQUEST_E_P_C_O_PRESENCE) == PDU_SESSION_RELEASE_REQUEST_E_P_C_O_PRESENCE)
{
if((pdu_session_release_request->presence & PDU_SESSION_RELEASE_REQUEST_E_P_C_O_PRESENCE) == PDU_SESSION_RELEASE_REQUEST_E_P_C_O_PRESENCE)
{
if((encoded_result = encode_extended_protocol_configuration_options (pdu_session_release_request->extendedprotocolconfigurationoptions, PDU_SESSION_RELEASE_REQUEST_E_P_C_O_IEI, buffer+encoded,len-encoded))<0)
return encoded_result;
else
encoded+=encoded_result;
}
}
return encoded;
return encoded;
}
/*
* 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 <asm/byteorder.h>
typedef struct {
//#ifdef __LITTLE_ENDIAN_BITFIELD
//uint8_t extended_protocol_discriminator:4;
//ebi_t eps_bearer_identity:4;//3gpp_24.007.h
//#endif
//#ifdef __BIG_ENDIAN_BITFIELD
//ebi_t eps_bearer_identity:4;
//uint8_t extended_protocol_discriminator:4;
//#endif
//pti_t procedure_transaction_identity;
uint8_t extended_protocol_discriminator;
uint8_t pdu_session_identity;
uint8_t procedure_transaction_identity;
......
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 SM_MSG_H_
#define SM_MSG_H_
#include "smMsgDef.h"
#include "PDUSessionEstablishmentRequest.h"
#include "PDUSessionEstablishmentAccept.h"
......@@ -20,9 +44,8 @@
#include "_5GSMStatus.h"
typedef struct {
typedef union {
sm_msg_header_t header;
union {
pdu_session_establishment_request_msg pdu_session_establishment_request;
pdu_session_establishment_accept_msg pdu_session_establishment_accept;
pdu_session_establishment_reject_msg pdu_session_establishment_reject;
......@@ -43,5 +66,15 @@ typedef struct {
pdu_session_release_complete_msg pdu_session_release_complete;
_5gsm_status_msg _5gsm_status;
} specific_msg;
}SM_msg;
int sm_msg_decode (
SM_msg * msg,
uint8_t * buffer,
uint32_t len);
int fivegsm_msg_encode (
SM_msg * msg,
uint8_t * buffer,
uint32_t len);
#endif
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