Commit 2128f40f authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

correct format NAS

parent 099ef8f5
......@@ -199,16 +199,8 @@ enum request_type_e {
#ifdef __cplusplus
}
static const std::vector<std::string> request_type_e2str = {
"ERROR",
"INITIAL REQUEST",
"EXISTING_PDU_SESSION",
"INITIAL_EMERGENCY_REQUEST",
"EXISTING_EMERGENCY_PDU_SESSION",
"MODIFICATION_REQUEST",
"MA_PDU_REQUEST",
"RESERVED"
};
static const std::vector<std::string> request_type_e2str = { "ERROR", "INITIAL REQUEST", "EXISTING_PDU_SESSION", "INITIAL_EMERGENCY_REQUEST", "EXISTING_EMERGENCY_PDU_SESSION", "MODIFICATION_REQUEST",
"MA_PDU_REQUEST", "RESERVED" };
enum class cause_value_5gsm_e {
CAUSE_0_UNKNOWN = 0,
......@@ -299,7 +291,7 @@ enum class cause_value_5gsm_e {
enum cause_value_protocol_errors_e {
CAUSE_95_SEMANTICALLY_INCORRECT_MESSAGE = 95
/*
/*
Cause #95 – Semantically incorrect message
Cause #96 – Invalid mandatory information
Cause #97 – Message type non-existent or not implemented
......@@ -308,7 +300,7 @@ enum cause_value_protocol_errors_e {
Cause #100 – Conditional IE error
Cause #101 – Message not compatible with protocol state
Cause #111 – Protocol error, unspecified
*/
*/
};
......@@ -322,12 +314,7 @@ enum class pdu_session_status_e {
PDU_SESSION_ACTIVE = 4
};
static const std::vector<std::string> pdu_session_status_e2str = {
"PDU_SESSION_INACTIVE",
"PDU_SESSION_INACTIVE_PENDING",
"PDU_SESSION_MODIFICATION_PENDING",
"PDU_SESSION_ACTIVE"
};
static const std::vector<std::string> pdu_session_status_e2str = { "PDU_SESSION_INACTIVE", "PDU_SESSION_INACTIVE_PENDING", "PDU_SESSION_MODIFICATION_PENDING", "PDU_SESSION_ACTIVE" };
//see Table 9.11.4.12.1: QoS flow descriptions information element
typedef struct flow_bit_rate_type_s {
......
......@@ -32,6 +32,7 @@ include_directories(${SRC_TOP_DIR}/utils)
include_directories(${SRC_TOP_DIR}/utils/bstr)
include_directories(${SRC_TOP_DIR}/nas/security)
include_directories(${SRC_TOP_DIR}/common)
include_directories(${SRC_TOP_DIR}/common/nas)
include_directories(${SRC_TOP_DIR}/ngap/asn1c)
include_directories(${SRC_TOP_DIR}/ngap/ies)
......
This diff is collapsed.
......@@ -32,7 +32,6 @@
#define DIRECTION__ 1//SECU_DIRECTION_DOWNLINK
#define TEST_MAC_ENCRYPT_DECRYPT__ 0
#define NAS_MESSAGE_SECURITY_HEADER_SIZE 7
/*********************************************************/
......@@ -41,9 +40,9 @@
/* Structure of security protected header */
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:4;
uint8_t spare_half_octet:4;
extended_protocol_discriminator_t extended_protocol_discriminator; //3gpp_24.501.h
uint8_t security_header_type :4;
uint8_t spare_half_octet :4;
#endif
#ifdef __BIG_ENDIAN_BITFIELD
uint8_t spare_half_octet:4;
......@@ -55,11 +54,10 @@ typedef struct nas_message_security_header_s {
/* Structure of plain NAS message */
typedef union {
MM_msg mm; /* NAS MM */
SM_msg sm; /* NAS SM */
MM_msg mm; /* NAS MM */
SM_msg sm; /* NAS SM */
} nas_message_plain_t;
/* Structure of security protected NAS message */
typedef struct nas_message_security_protected_s {
nas_message_security_header_t header;
......@@ -76,24 +74,15 @@ typedef struct {
} nas_message_t;
typedef struct nas_message_decode_status_s {
uint8_t integrity_protected_message:1;
uint8_t ciphered_message:1;
uint8_t mac_matched:1;
uint8_t security_context_available:1;
uint8_t integrity_protected_message :1;
uint8_t ciphered_message :1;
uint8_t mac_matched :1;
uint8_t security_context_available :1;
int fivegmm_cause;
} nas_message_decode_status_t;
int nas_message_encode(
unsigned char *buffer,
const nas_message_t * const msg,
size_t length,
void *security);
int nas_message_encode(unsigned char *buffer, const nas_message_t *const msg, size_t length, void *security);
int nas_message_decode (
const unsigned char *const buffer,
nas_message_t * msg,
size_t length,
void *security,
nas_message_decode_status_t * status);
int nas_message_decode(const unsigned char *const buffer, nas_message_t *msg, size_t length, void *security, nas_message_decode_status_t *status);
#endif
......@@ -20,14 +20,14 @@
*/
/*****************************************************************************
Source networkDef.h
Version 0.1
Date 2019/08/05
Product NAS stack
Subsystem include
Author BUPT
Description Contains network's global definitions
*****************************************************************************/
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__
......
/*
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the FreeBSD Project.
*/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#if !defined(HAVE_UINT128_T)
# include <gmp.h>
#endif
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#if 0
#include "queue.h"
#endif
#ifndef FILE_SECURITY_TYPES_SEEN
#define FILE_SECURITY_TYPES_SEEN
#define RAND_LENGTH_BITS (128)
#define RAND_LENGTH_OCTETS (RAND_LENGTH_BITS/8)
#define AUTH_KEY_LENGTH_BITS (128)
#define AUTH_KEY_LENGTH_OCTETS (AUTH_KEY_LENGTH_BITS/8)
#define KASME_LENGTH_BITS (256)
#define KASME_LENGTH_OCTETS (KASME_LENGTH_BITS/8)
/* In OCTETS */
#define XRES_LENGTH_MIN (4)
#define XRES_LENGTH_MAX (16)
#define AUTN_LENGTH_BITS (128)
#define AUTN_LENGTH_OCTETS (AUTN_LENGTH_BITS/8)
/* Some methods to convert a string to an int64_t */
/*
#define STRING_TO_64BITS(sTRING, cONTAINER) \
sscanf(sTRING, "%" SCN64, cONTAINER)
#define STRING_TO_U64BITS(sTRING, cONTAINER) \
sscanf(sTRING, "%" SCNu64, cONTAINER)
*/
/* Converts a string to 128 bits gmplib integer holder */
# define STRING_TO_XBITS(sTRING, lENGTH, cONTAINER, rET) \
do { \
memcpy(cONTAINER, sTRING, lENGTH); \
rET = 0; \
} while(0)
# define STRING_TO_128BITS(sTRING, cONTAINER, rET) \
STRING_TO_XBITS(sTRING, 16, cONTAINER, rET)
# define STRING_TO_256BITS(sTRING, cONTAINER, rET) \
STRING_TO_XBITS(sTRING, 32, cONTAINER, rET)
# define STRING_TO_RAND STRING_TO_128BITS
# define STRING_TO_AUTH_KEY STRING_TO_128BITS
# define STRING_TO_AUTH_RES STRING_TO_128BITS
# define STRING_TO_AUTN STRING_TO_128BITS
# define STRING_TO_KASME STRING_TO_256BITS
# define STRING_TO_XRES(sTRING, lENGTH, cONTAINER, rET) \
do { \
STRING_TO_XBITS(sTRING, lENGTH, (cONTAINER)->data, rET); \
if (rET != -1) \
(cONTAINER)->size = lENGTH; \
} while(0)
/* RES amd XRES can have a variable length of 4-16 octets */
typedef struct {
uint8_t size;
uint8_t data[XRES_LENGTH_MAX];
} res_t;
#define FORMAT_128BITS "%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x"
#define RAND_FORMAT FORMAT_128BITS
#define AUTN_FORMAT FORMAT_128BITS
#define KASME_FORMAT FORMAT_128BITS
#define DISPLAY_128BITS(bUFFER) \
bUFFER[0], bUFFER[1], bUFFER[2], bUFFER[3], bUFFER[4], bUFFER[5], bUFFER[6], bUFFER[7], \
bUFFER[8], bUFFER[9], bUFFER[10], bUFFER[11], bUFFER[12], bUFFER[13], bUFFER[14], bUFFER[15]
#define DISPLAY_128BITS_2(bUFFER) \
bUFFER[16], bUFFER[17], bUFFER[18], bUFFER[19], bUFFER[20], bUFFER[21], bUFFER[22], bUFFER[23], \
bUFFER[24], bUFFER[25], bUFFER[26], bUFFER[27], bUFFER[28], bUFFER[29], bUFFER[30], bUFFER[31]
#define RAND_DISPLAY(bUFFER) DISPLAY_128BITS(bUFFER)
#define AUTN_DISPLAY(bUFFER) DISPLAY_128BITS(bUFFER)
/* Display only first 128 bits of KASME */
#define KASME_DISPLAY_1(bUFFER) DISPLAY_128BITS(bUFFER)
#define KASME_DISPLAY_2(bUFFER) DISPLAY_128BITS_2(bUFFER)
/* Holds an E-UTRAN authentication vector */
typedef struct eutran_vector_s {
uint8_t rand[RAND_LENGTH_OCTETS];
res_t xres;
uint8_t autn[AUTN_LENGTH_OCTETS];
uint8_t kasme[KASME_LENGTH_OCTETS];
} eutran_vector_t;
#define FC_KASME (0x10)
#define FC_KENB (0x11)
#define FC_NH (0x12)
#define FC_KENB_STAR (0x13)
/* 33401 #A.7 Algorithm for key derivation function.
* This FC should be used for:
* - NAS Encryption algorithm
* - NAS Integrity algorithm
* - RRC Encryption algorithm
* - RRC Integrity algorithm
* - User Plane Encryption algorithm
*/
#define FC_ALG_KEY_DER (0x15)
#define FC_KASME_TO_CK (0x16)
typedef enum {
NAS_ENC_ALG = 0x01,
NAS_INT_ALG = 0x02,
RRC_ENC_ALG = 0x03,
RRC_INT_ALG = 0x04,
UP_ENC_ALG = 0x05,
UP_INT_ALG = 0x06
} algorithm_type_dist_t;
#endif /* FILE_SECURITY_TYPES_SEEN */
......@@ -20,21 +20,21 @@
*/
/*****************************************************************************
Source securityDef.h
Source securityDef.h
Version 0.1
Version 0.1
Date 2013/05/02
Date 2013/05/02
Product NAS stack
Product NAS stack
Subsystem include
Subsystem include
Author Frederic Maurel
Author Frederic Maurel
Description Contains global security definitions
Description Contains global security definitions
*****************************************************************************/
*****************************************************************************/
#ifndef FILE_SECURITYDEF_SEEN
#define FILE_SECURITYDEF_SEEN
......@@ -85,5 +85,4 @@ typedef struct {
uint8_t xres[AUTH_XRES_SIZE];
} auth_vector_t;
#endif /* FILE_SECURITYDEF_SEEN*/
......@@ -6,57 +6,56 @@
#include "TLVDecoder.h"
#include "PDUSessionAuthenticationCommand.h"
int decode_pdu_session_authentication_command( pdu_session_authentication_command_msg *pdu_session_authentication_command, uint8_t *buffer, uint32_t len)
{
int decode_pdu_session_authentication_command(pdu_session_authentication_command_msg *pdu_session_authentication_command, uint8_t *buffer, uint32_t len) {
uint32_t decoded = 0;
int decoded_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_DECODER (buffer, PDU_SESSION_AUTHENTICATION_COMMAND_MINIMUM_LENGTH, len);
CHECK_PDU_POINTER_AND_LENGTH_DECODER(buffer, PDU_SESSION_AUTHENTICATION_COMMAND_MINIMUM_LENGTH, len);
if ((decoded_result = decode_eap_message (&pdu_session_authentication_command->eapmessage, 0, buffer + decoded, len - decoded)) < 0) {
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) {
uint8_t ieiDecoded = *(buffer+decoded);
uint8_t ieiDecoded = *(buffer + decoded);
if (ieiDecoded == 0)
break;
switch (ieiDecoded) {
case PDU_SESSION_AUTHENTICATION_COMMAND_EPCO_IEI:
if ((decoded_result = decode_extended_protocol_configuration_options (&pdu_session_authentication_command->extendedprotocolconfigurationoptions, PDU_SESSION_AUTHENTICATION_COMMAND_EPCO_IEI, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else {
decoded += decoded_result;
pdu_session_authentication_command->presence |= PDU_SESSION_AUTHENTICATION_COMMAND_EPCO_PRESENCE;
}
break;
case PDU_SESSION_AUTHENTICATION_COMMAND_EPCO_IEI:
if ((decoded_result = decode_extended_protocol_configuration_options(&pdu_session_authentication_command->extendedprotocolconfigurationoptions, PDU_SESSION_AUTHENTICATION_COMMAND_EPCO_IEI,
buffer + decoded, len - decoded)) < 0)
return decoded_result;
else {
decoded += decoded_result;
pdu_session_authentication_command->presence |= PDU_SESSION_AUTHENTICATION_COMMAND_EPCO_PRESENCE;
}
break;
}
}
return decoded;
}
int encode_pdu_session_authentication_command( pdu_session_authentication_command_msg *pdu_session_authentication_command, uint8_t *buffer, uint32_t len)
{
int encode_pdu_session_authentication_command(pdu_session_authentication_command_msg *pdu_session_authentication_command, uint8_t *buffer, uint32_t len) {
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_AUTHENTICATION_COMMAND_MINIMUM_LENGTH, len);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, PDU_SESSION_AUTHENTICATION_COMMAND_MINIMUM_LENGTH, len);
if ((encoded_result = encode_eap_message (pdu_session_authentication_command->eapmessage, 0, buffer + encoded, len - encoded)) < 0)
if ((encoded_result = encode_eap_message(pdu_session_authentication_command->eapmessage, 0, buffer + encoded, len - encoded)) < 0)
return encoded_result;
else
encoded += encoded_result;
if ((pdu_session_authentication_command->presence & PDU_SESSION_AUTHENTICATION_COMMAND_EPCO_PRESENCE) == PDU_SESSION_AUTHENTICATION_COMMAND_EPCO_PRESENCE) {
if ((encoded_result = encode_extended_protocol_configuration_options (pdu_session_authentication_command->extendedprotocolconfigurationoptions, PDU_SESSION_AUTHENTICATION_COMMAND_EPCO_IEI, buffer + encoded, len - encoded)) < 0) {
if ((encoded_result = encode_extended_protocol_configuration_options(pdu_session_authentication_command->extendedprotocolconfigurationoptions, PDU_SESSION_AUTHENTICATION_COMMAND_EPCO_IEI,
buffer + encoded, len - encoded)) < 0) {
return encoded_result;
} else {
encoded += encoded_result;
......
......@@ -10,7 +10,6 @@
#include "EAPMessage.h"
#include "ExtendedProtocolConfigurationOptions.h"
#if 0
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define PDU_SESSION_AUTHENTICATION_COMMAND_MINIMUM_LENGTH ( \
......@@ -23,13 +22,11 @@
0)
#endif
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define PDU_SESSION_AUTHENTICATION_COMMAND_MINIMUM_LENGTH ( \
EAP_MESSAGE_MINIMUM_LENGTH_LVE + \
0)
/* Maximum length macro. Formed by maximum length of each field */
#define PDU_SESSION_AUTHENTICATION_COMMAND_MAXIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \
......@@ -40,21 +37,19 @@
EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_MAXIMUM_LENGTH_TLVE + \
0)
#define PDU_SESSION_AUTHENTICATION_COMMAND_EPCO_IEI 0x7B
#define PDU_SESSION_AUTHENTICATION_COMMAND_EPCO_PRESENCE (1<<0)
typedef struct pdu_session_authentication_command_msg_tag {
ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
PDUSessionIdentity pdusessionidentity;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
EAPMessage eapmessage;
uint8_t presence;
ExtendedProtocolConfigurationOptions extendedprotocolconfigurationoptions;
ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
PDUSessionIdentity pdusessionidentity;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
EAPMessage eapmessage;
uint8_t presence;
ExtendedProtocolConfigurationOptions extendedprotocolconfigurationoptions;
} pdu_session_authentication_command_msg;
int decode_pdu_session_authentication_command(pdu_session_authentication_command_msg *pdusessionauthenticationcommand, uint8_t *buffer, uint32_t len);
int encode_pdu_session_authentication_command(pdu_session_authentication_command_msg *pdusessionauthenticationcommand, uint8_t *buffer, uint32_t len);
......
......@@ -6,15 +6,14 @@
#include "TLVDecoder.h"
#include "PDUSessionAuthenticationComplete.h"
int decode_pdu_session_authentication_complete( pdu_session_authentication_complete_msg *pdu_session_authentication_complete, uint8_t *buffer, uint32_t len)
{
int decode_pdu_session_authentication_complete(pdu_session_authentication_complete_msg *pdu_session_authentication_complete, uint8_t *buffer, uint32_t len) {
uint32_t decoded = 0;
int decoded_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_DECODER (buffer, PDU_SESSION_AUTHENTICATION_COMPLETE_MINIMUM_LENGTH, len);
CHECK_PDU_POINTER_AND_LENGTH_DECODER(buffer, PDU_SESSION_AUTHENTICATION_COMPLETE_MINIMUM_LENGTH, len);
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 {
decoded += decoded_result;
......@@ -27,36 +26,36 @@ int decode_pdu_session_authentication_complete( pdu_session_authentication_compl
break;
switch (ieiDecoded) {
case PDU_SESSION_AUTHENTICATION_COMPLETE_EPCO_IEI:
if ((decoded_result = decode_extended_protocol_configuration_options (&pdu_session_authentication_complete->extendedprotocolconfigurationoptions, PDU_SESSION_AUTHENTICATION_COMPLETE_EPCO_IEI, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else {
decoded += decoded_result;
pdu_session_authentication_complete->presence |= PDU_SESSION_AUTHENTICATION_COMPLETE_EPCO_PRESENCE;
}
break;
case PDU_SESSION_AUTHENTICATION_COMPLETE_EPCO_IEI:
if ((decoded_result = decode_extended_protocol_configuration_options(&pdu_session_authentication_complete->extendedprotocolconfigurationoptions, PDU_SESSION_AUTHENTICATION_COMPLETE_EPCO_IEI,
buffer + decoded, len - decoded)) < 0)
return decoded_result;
else {
decoded += decoded_result;
pdu_session_authentication_complete->presence |= PDU_SESSION_AUTHENTICATION_COMPLETE_EPCO_PRESENCE;
}
break;
}
}
return decoded;
}
int encode_pdu_session_authentication_complete( pdu_session_authentication_complete_msg *pdu_session_authentication_complete, uint8_t *buffer, uint32_t len)
{
int encode_pdu_session_authentication_complete(pdu_session_authentication_complete_msg *pdu_session_authentication_complete, uint8_t *buffer, uint32_t len) {
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_AUTHENTICATION_COMPLETE_MINIMUM_LENGTH, len);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, PDU_SESSION_AUTHENTICATION_COMPLETE_MINIMUM_LENGTH, len);
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
encoded += encoded_result;
if ((pdu_session_authentication_complete->presence & PDU_SESSION_AUTHENTICATION_COMPLETE_EPCO_PRESENCE) == PDU_SESSION_AUTHENTICATION_COMPLETE_EPCO_PRESENCE) {
if ((encoded_result = encode_extended_protocol_configuration_options (pdu_session_authentication_complete->extendedprotocolconfigurationoptions, PDU_SESSION_AUTHENTICATION_COMPLETE_EPCO_IEI, buffer + encoded, len - encoded)) < 0) {
if ((encoded_result = encode_extended_protocol_configuration_options(pdu_session_authentication_complete->extendedprotocolconfigurationoptions, PDU_SESSION_AUTHENTICATION_COMPLETE_EPCO_IEI,
buffer + encoded, len - encoded)) < 0) {
return encoded_result;
} else {
encoded += encoded_result;
......
......@@ -10,7 +10,6 @@
#include "EAPMessage.h"
#include "ExtendedProtocolConfigurationOptions.h"
#if 0
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define PDU_SESSION_AUTHENTICATION_COMPLETE_MINIMUM_LENGTH ( \
......@@ -22,7 +21,7 @@
EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_MINIMUM_LENGTH + \
0)
#endif
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define PDU_SESSION_AUTHENTICATION_COMPLETE_MINIMUM_LENGTH ( \
EAP_MESSAGE_MINIMUM_LENGTH_LVE + \
......@@ -42,16 +41,15 @@
#define PDU_SESSION_AUTHENTICATION_COMPLETE_EPCO_PRESENCE (1<<0)
typedef struct pdu_session_authentication_complete_msg_tag {
ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
PDUSessionIdentity pdusessionidentity;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
EAPMessage eapmessage;
uint8_t presence;
ExtendedProtocolConfigurationOptions extendedprotocolconfigurationoptions;
ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
PDUSessionIdentity pdusessionidentity;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
EAPMessage eapmessage;
uint8_t presence;
ExtendedProtocolConfigurationOptions extendedprotocolconfigurationoptions;
} pdu_session_authentication_complete_msg;
int decode_pdu_session_authentication_complete(pdu_session_authentication_complete_msg *pdusessionauthenticationcomplete, uint8_t *buffer, uint32_t len);
int encode_pdu_session_authentication_complete(pdu_session_authentication_complete_msg *pdusessionauthenticationcomplete, uint8_t *buffer, uint32_t len);
......
......@@ -6,61 +6,60 @@
#include "TLVDecoder.h"
#include "PDUSessionAuthenticationResult.h"
int decode_pdu_session_authentication_result( pdu_session_authentication_result_msg *pdu_session_authentication_result, uint8_t *buffer, uint32_t len)
{
int decode_pdu_session_authentication_result(pdu_session_authentication_result_msg *pdu_session_authentication_result, uint8_t *buffer, uint32_t len) {
uint32_t decoded = 0;
int decoded_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_DECODER (buffer, PDU_SESSION_AUTHENTICATION_RESULT_MINIMUM_LENGTH, len);
CHECK_PDU_POINTER_AND_LENGTH_DECODER(buffer, PDU_SESSION_AUTHENTICATION_RESULT_MINIMUM_LENGTH, len);
while(len - decoded > 0) {
while (len - decoded > 0) {
uint8_t ieiDecoded = *(buffer + decoded);
if (ieiDecoded == 0)
break;
switch (ieiDecoded) {
case PDU_SESSION_AUTHENTICATION_RESULT_EAP_MESSAGE_IEI:
if ((decoded_result = decode_eap_message (&pdu_session_authentication_result->eapmessage, PDU_SESSION_AUTHENTICATION_RESULT_EAP_MESSAGE_IEI, buffer+decoded,len-decoded))<0)
return decoded_result;
else {
decoded += decoded_result;
pdu_session_authentication_result->presence |= PDU_SESSION_AUTHENTICATION_RESULT_EAP_MESSAGE_PRESENCE;
}
break;
case PDU_SESSION_AUTHENTICATION_RESULT_EPCO_IEI:
if ((decoded_result = decode_extended_protocol_configuration_options (&pdu_session_authentication_result->extendedprotocolconfigurationoptions, PDU_SESSION_AUTHENTICATION_RESULT_EPCO_IEI, buffer+decoded,len-decoded))<0)
return decoded_result;
else {
decoded += decoded_result;
pdu_session_authentication_result->presence |= PDU_SESSION_AUTHENTICATION_RESULT_EPCO_PRESENCE;
}
break;
case PDU_SESSION_AUTHENTICATION_RESULT_EAP_MESSAGE_IEI:
if ((decoded_result = decode_eap_message(&pdu_session_authentication_result->eapmessage, PDU_SESSION_AUTHENTICATION_RESULT_EAP_MESSAGE_IEI, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else {
decoded += decoded_result;
pdu_session_authentication_result->presence |= PDU_SESSION_AUTHENTICATION_RESULT_EAP_MESSAGE_PRESENCE;
}
break;
case PDU_SESSION_AUTHENTICATION_RESULT_EPCO_IEI:
if ((decoded_result = decode_extended_protocol_configuration_options(&pdu_session_authentication_result->extendedprotocolconfigurationoptions, PDU_SESSION_AUTHENTICATION_RESULT_EPCO_IEI,
buffer + decoded, len - decoded)) < 0)
return decoded_result;
else {
decoded += decoded_result;
pdu_session_authentication_result->presence |= PDU_SESSION_AUTHENTICATION_RESULT_EPCO_PRESENCE;
}
break;
}
}
return decoded;
}
int encode_pdu_session_authentication_result( pdu_session_authentication_result_msg *pdu_session_authentication_result, uint8_t *buffer, uint32_t len)
{
int encode_pdu_session_authentication_result(pdu_session_authentication_result_msg *pdu_session_authentication_result, uint8_t *buffer, uint32_t len) {
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_AUTHENTICATION_RESULT_MINIMUM_LENGTH, len);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, PDU_SESSION_AUTHENTICATION_RESULT_MINIMUM_LENGTH, len);
if ((pdu_session_authentication_result->presence & PDU_SESSION_AUTHENTICATION_RESULT_EAP_MESSAGE_PRESENCE) == PDU_SESSION_AUTHENTICATION_RESULT_EAP_MESSAGE_PRESENCE) {
if((encoded_result = encode_eap_message (pdu_session_authentication_result->eapmessage, PDU_SESSION_AUTHENTICATION_RESULT_EAP_MESSAGE_IEI, buffer + encoded, len - encoded)) < 0)
if ((encoded_result = encode_eap_message(pdu_session_authentication_result->eapmessage, PDU_SESSION_AUTHENTICATION_RESULT_EAP_MESSAGE_IEI, buffer + encoded, len - encoded)) < 0)
return encoded_result;
else
encoded += encoded_result;
}
if((pdu_session_authentication_result->presence & PDU_SESSION_AUTHENTICATION_RESULT_EPCO_PRESENCE) == PDU_SESSION_AUTHENTICATION_RESULT_EPCO_PRESENCE) {
if((encoded_result = encode_extended_protocol_configuration_options (pdu_session_authentication_result->extendedprotocolconfigurationoptions, PDU_SESSION_AUTHENTICATION_RESULT_EPCO_IEI, buffer + encoded, len - encoded)) < 0)
if ((pdu_session_authentication_result->presence & PDU_SESSION_AUTHENTICATION_RESULT_EPCO_PRESENCE) == PDU_SESSION_AUTHENTICATION_RESULT_EPCO_PRESENCE) {
if ((encoded_result = encode_extended_protocol_configuration_options(pdu_session_authentication_result->extendedprotocolconfigurationoptions, PDU_SESSION_AUTHENTICATION_RESULT_EPCO_IEI,
buffer + encoded, len - encoded)) < 0)
return encoded_result;
else
encoded += encoded_result;
......
......@@ -10,7 +10,6 @@
#include "EAPMessage.h"
#include "ExtendedProtocolConfigurationOptions.h"
#if 0
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define PDU_SESSION_AUTHENTICATION_RESULT_MINIMUM_LENGTH ( \
......@@ -26,7 +25,6 @@
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define PDU_SESSION_AUTHENTICATION_RESULT_MINIMUM_LENGTH 0
/* Maximum length macro. Formed by maximum length of each field */
#define PDU_SESSION_AUTHENTICATION_RESULT_MAXIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \
......@@ -44,16 +42,15 @@
#define PDU_SESSION_AUTHENTICATION_RESULT_EPCO_PRESENCE (1<<1)
typedef struct pdu_session_authentication_result_msg_tag {
ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
PDUSessionIdentity pdusessionidentity;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
uint8_t presence;
EAPMessage eapmessage;
ExtendedProtocolConfigurationOptions extendedprotocolconfigurationoptions;
ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
PDUSessionIdentity pdusessionidentity;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
uint8_t presence;
EAPMessage eapmessage;
ExtendedProtocolConfigurationOptions extendedprotocolconfigurationoptions;
} pdu_session_authentication_result_msg;
int decode_pdu_session_authentication_result(pdu_session_authentication_result_msg *pdusessionauthenticationresult, uint8_t *buffer, uint32_t len);
int encode_pdu_session_authentication_result(pdu_session_authentication_result_msg *pdusessionauthenticationresult, uint8_t *buffer, uint32_t len);
......
......@@ -22,7 +22,6 @@
#include "ExtendedProtocolConfigurationOptions.h"
#include "DNN.h"
#if 0
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define PDU_SESSION_ESTABLISHMENT_ACCEPT_MINIMUM_LENGTH ( \
......@@ -55,7 +54,6 @@
SESSION_AMBR_MINIMUM_LENGTH_LV + \
0)
/* Maximum length macro. Formed by maximum length of each field */
#define PDU_SESSION_ESTABLISHMENT_ACCEPT_MAXIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \
......@@ -78,7 +76,6 @@
DNN_MAXIMUM_LENGTH_TLV + \
0)
#define PDU_SESSION_ESTABLISHMENT_ACCEPT__5GSM_CAUSE_IEI 0x59
#define PDU_SESSION_ESTABLISHMENT_ACCEPT_PDU_ADDRESS_IEI 0x29
#define PDU_SESSION_ESTABLISHMENT_ACCEPT_GPRS_TIMER_IEI 0x56
......@@ -102,28 +99,27 @@
#define PDU_SESSION_ESTABLISHMENT_ACCEPT_DNN_PRESENCE (1<<9)
typedef struct pdu_session_establishment_accept_msg_tag {
ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
PDUSessionIdentity pdusessionidentity;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
_PDUSessionType _pdusessiontype;
SSCMode sscmode;
QOSRules qosrules;
SessionAMBR sessionambr;
uint16_t presence;
_5GSMCause _5gsmcause;
PDUAddress pduaddress;
GPRSTimer gprstimer;
SNSSAI snssai;
AlwaysonPDUSessionIndication alwaysonpdusessionindication;
MappedEPSBearerContexts mappedepsbearercontexts;
EAPMessage eapmessage;
QOSFlowDescriptions qosflowdescriptions;
ExtendedProtocolConfigurationOptions extendedprotocolconfigurationoptions;
DNN dnn;
ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
PDUSessionIdentity pdusessionidentity;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
_PDUSessionType _pdusessiontype;
SSCMode sscmode;
QOSRules qosrules;
SessionAMBR sessionambr;
uint16_t presence;
_5GSMCause _5gsmcause;
PDUAddress pduaddress;
GPRSTimer gprstimer;
SNSSAI snssai;
AlwaysonPDUSessionIndication alwaysonpdusessionindication;
MappedEPSBearerContexts mappedepsbearercontexts;
EAPMessage eapmessage;
QOSFlowDescriptions qosflowdescriptions;
ExtendedProtocolConfigurationOptions extendedprotocolconfigurationoptions;
DNN dnn;
} pdu_session_establishment_accept_msg;
int decode_pdu_session_establishment_accept(pdu_session_establishment_accept_msg *pdusessionestablishmentaccept, uint8_t *buffer, uint32_t len);
int encode_pdu_session_establishment_accept(pdu_session_establishment_accept_msg *pdusessionestablishmentaccept, uint8_t *buffer, uint32_t len);
......
......@@ -14,8 +14,6 @@
#include "ExtendedProtocolConfigurationOptions.h"
#include "_5GSMCongestionReattemptIndicator.h"
#if 0
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define PDU_SESSION_ESTABLISHMENT_REJECT_MINIMUM_LENGTH ( \
......@@ -31,13 +29,11 @@
0)
#endif
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define PDU_SESSION_ESTABLISHMENT_REJECT_MINIMUM_LENGTH ( \
_5GSM_CAUSE_MINIMUM_LENGTH_V + \
0)
/* Maximum length macro. Formed by maximum length of each field */
#define PDU_SESSION_ESTABLISHMENT_REJECT_MAXIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \
......@@ -51,7 +47,6 @@
EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_MAXIMUM_LENGTH_TLVE + \
0)
#define PDU_SESSION_ESTABLISHMENT_REJECT_GPRS_TIMER3_IEI 0x37
#define PDU_SESSION_ESTABLISHMENT_REJECT_ALLOWED_SSC_MODE_IEI 0xF0
#define PDU_SESSION_ESTABLISHMENT_REJECT_EAP_MESSAGE_IEI 0x78
......@@ -65,20 +60,19 @@
#define PDU_SESSION_ESTABLISHMENT_REJECT__5GSM_CONGESTION_REATTEMPT_INDICATOR_PRESENCE (1<<4)
typedef struct pdu_session_establishment_reject_msg_tag {
ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
PDUSessionIdentity pdusessionidentity;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
_5GSMCause _5gsmcause;
uint8_t presence;
GPRSTimer3 gprstimer3;
AllowedSSCMode allowedsscmode;
EAPMessage eapmessage;
ExtendedProtocolConfigurationOptions extendedprotocolconfigurationoptions;
_5GSMCongestionReattemptIndicator _5gsmcongestionreattemptindicator;
ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
PDUSessionIdentity pdusessionidentity;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
_5GSMCause _5gsmcause;
uint8_t presence;
GPRSTimer3 gprstimer3;
AllowedSSCMode allowedsscmode;
EAPMessage eapmessage;
ExtendedProtocolConfigurationOptions extendedprotocolconfigurationoptions;
_5GSMCongestionReattemptIndicator _5gsmcongestionreattemptindicator;
} pdu_session_establishment_reject_msg;
int decode_pdu_session_establishment_reject(pdu_session_establishment_reject_msg *pdusessionestablishmentreject, uint8_t *buffer, uint32_t len);
int encode_pdu_session_establishment_reject(pdu_session_establishment_reject_msg *pdusessionestablishmentreject, uint8_t *buffer, uint32_t len);
......
......@@ -16,7 +16,6 @@
#include "SMPDUDNRequestContainer.h"
#include "ExtendedProtocolConfigurationOptions.h"
#if 0
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define PDU_SESSION_ESTABLISHMENT_REQUEST_MINIMUM_LENGTH ( \
......@@ -40,7 +39,6 @@
INTERGRITY_PROTECTION_MAXIMUM_DATA_RATE_MINIMUM_LENGTH_V + \
0)
/* Maximum length macro. Formed by maximum length of each field */
#define PDU_SESSION_ESTABLISHMENT_REQUEST_MAXIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \
......@@ -57,8 +55,6 @@
EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_MAXIMUM_LENGTH_TLVE + \
0)
#define PDU_SESSION_ESTABLISHMENT_REQUEST_PDU_SESSION_TYPE_IEI 0x90
#define PDU_SESSION_ESTABLISHMENT_REQUEST_SSC_MODE_IEI 0xA0
#define PDU_SESSION_ESTABLISHMENT_REQUEST__5GSM_CAPABILITY_IEI 0x28
......@@ -75,21 +71,20 @@
#define PDU_SESSION_ESTABLISHMENT_REQUEST_SMPDUDN_REQUEST_CONTAINER_INFORMATION_PRESENT (1<<5)
#define PDU_SESSION_ESTABLISHMENT_REQUEST_EPCO_PRESENT (1<<6)
typedef struct pdu_session_establishment_request_msg_tag {
ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
PDUSessionIdentity pdusessionidentity;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
IntergrityProtectionMaximumDataRate intergrityprotectionmaximumdatarate;
uint8_t presence;
_PDUSessionType _pdusessiontype;
SSCMode sscmode;
_5GSMCapability _5gsmcapability;
MaximumNumberOfSupportedPacketFilters maximumnumberofsupportedpacketfilters;
AlwaysonPDUSessionRequested alwaysonpdusessionrequested;
SMPDUDNRequestContainer smpdudnrequestcontainer;
ExtendedProtocolConfigurationOptions extendedprotocolconfigurationoptions;
ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
PDUSessionIdentity pdusessionidentity;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
IntergrityProtectionMaximumDataRate intergrityprotectionmaximumdatarate;
uint8_t presence;
_PDUSessionType _pdusessiontype;
SSCMode sscmode;
_5GSMCapability _5gsmcapability;
MaximumNumberOfSupportedPacketFilters maximumnumberofsupportedpacketfilters;
AlwaysonPDUSessionRequested alwaysonpdusessionrequested;
SMPDUDNRequestContainer smpdudnrequestcontainer;
ExtendedProtocolConfigurationOptions extendedprotocolconfigurationoptions;
} pdu_session_establishment_request_msg;
int decode_pdu_session_establishment_request(pdu_session_establishment_request_msg *pdusessionestablishmentrequest, uint8_t *buffer, uint32_t len);
......
......@@ -16,7 +16,6 @@
#include "QOSFlowDescriptions.h"
#include "ExtendedProtocolConfigurationOptions.h"
#if 0
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define PDU_SESSION_MODIFICATION_COMMAND_MINIMUM_LENGTH ( \
......@@ -37,7 +36,6 @@
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define PDU_SESSION_MODIFICATION_COMMAND_MINIMUM_LENGTH 0
/* Maximum length macro. Formed by maximum length of each field */
#define PDU_SESSION_MODIFICATION_COMMAND_MAXIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \
......@@ -54,7 +52,6 @@
EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_MAXIMUM_LENGTH_TLVE + \
0)
#define PDU_SESSION_MODIFICATION_COMMAND__5GSM_CAUSE_IEI 0x59
#define PDU_SESSION_MODIFICATION_COMMAND_SESSION_AMBR_IEI 0x2A
#define PDU_SESSION_MODIFICATION_COMMAND_GPRS_TIMER_IEI 0x56
......@@ -73,7 +70,6 @@
#define PDU_SESSION_MODIFICATION_COMMAND_QOS_FLOW_DESCRIPTIONS_PRESENCE (1<<6)
#define PDU_SESSION_MODIFICATION_COMMAND_E_P_C_O_PRESENCE (1<<7)
typedef struct pdu_session_modification_command_msg_tag {
ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
PDUSessionIdentity pdusessionidentity;
......@@ -90,7 +86,6 @@ typedef struct pdu_session_modification_command_msg_tag {
ExtendedProtocolConfigurationOptions extendedprotocolconfigurationoptions;
} pdu_session_modification_command_msg;
int decode_pdu_session_modification_command(pdu_session_modification_command_msg *pdusessionmodificationcommand, uint8_t *buffer, uint32_t len);
int encode_pdu_session_modification_command(pdu_session_modification_command_msg *pdusessionmodificationcommand, uint8_t *buffer, uint32_t len);
......
......@@ -6,15 +6,14 @@
#include "TLVDecoder.h"
#include "PDUSessionModificationCommandReject.h"
int decode_pdu_session_modification_command_reject( pdu_session_modification_command_reject_msg *pdu_session_modification_command_reject, uint8_t *buffer, uint32_t len)
{
int decode_pdu_session_modification_command_reject(pdu_session_modification_command_reject_msg *pdu_session_modification_command_reject, uint8_t *buffer, uint32_t len) {
uint32_t decoded = 0;
int decoded_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_DECODER (buffer, PDU_SESSION_MODIFICATION_COMMAND_REJECT_MINIMUM_LENGTH, len);
CHECK_PDU_POINTER_AND_LENGTH_DECODER(buffer, PDU_SESSION_MODIFICATION_COMMAND_REJECT_MINIMUM_LENGTH, len);
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 {
decoded += decoded_result;
......@@ -27,37 +26,37 @@ int decode_pdu_session_modification_command_reject( pdu_session_modification_com
break;
switch (ieiDecoded) {
case PDU_SESSION_MODIFICATION_COMMAND_REJECT_E_P_C_O_IEI:
if ((decoded_result = decode_extended_protocol_configuration_options (&pdu_session_modification_command_reject->extendedprotocolconfigurationoptions, PDU_SESSION_MODIFICATION_COMMAND_REJECT_E_P_C_O_IEI, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else {
decoded += decoded_result;
pdu_session_modification_command_reject->presence |= PDU_SESSION_MODIFICATION_COMMAND_REJECT_E_P_C_O_PRESENCE;
}
break;
case PDU_SESSION_MODIFICATION_COMMAND_REJECT_E_P_C_O_IEI:
if ((decoded_result = decode_extended_protocol_configuration_options(&pdu_session_modification_command_reject->extendedprotocolconfigurationoptions,
PDU_SESSION_MODIFICATION_COMMAND_REJECT_E_P_C_O_IEI, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else {
decoded += decoded_result;
pdu_session_modification_command_reject->presence |= PDU_SESSION_MODIFICATION_COMMAND_REJECT_E_P_C_O_PRESENCE;
}
break;
}
}
return decoded;
}
int encode_pdu_session_modification_command_reject( pdu_session_modification_command_reject_msg *pdu_session_modification_command_reject, uint8_t *buffer, uint32_t len)
{
int encode_pdu_session_modification_command_reject(pdu_session_modification_command_reject_msg *pdu_session_modification_command_reject, uint8_t *buffer, uint32_t len) {
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_MODIFICATION_COMMAND_REJECT_MINIMUM_LENGTH, len);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, PDU_SESSION_MODIFICATION_COMMAND_REJECT_MINIMUM_LENGTH, len);
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 {
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 ((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)
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;
......
......@@ -10,7 +10,6 @@
#include "_5GSMCause.h"
#include "ExtendedProtocolConfigurationOptions.h"
#if 0
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define PDU_SESSION_MODIFICATION_COMMAND_REJECT_MINIMUM_LENGTH ( \
......@@ -27,7 +26,6 @@
_5GSM_CAUSE_MINIMUM_LENGTH_V + \
0)
/* Maximum length macro. Formed by maximum length of each field */
#define PDU_SESSION_MODIFICATION_COMMAND_REJECT_MAXIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \
......@@ -38,21 +36,19 @@
EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_MAXIMUM_LENGTH_TLVE + \
0)
#define PDU_SESSION_MODIFICATION_COMMAND_REJECT_E_P_C_O_IEI 0x7B
#define PDU_SESSION_MODIFICATION_COMMAND_REJECT_E_P_C_O_PRESENCE (1<<0)
typedef struct pdu_session_modification_command_reject_msg_tag {
ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
PDUSessionIdentity pdusessionidentity;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
_5GSMCause _5gsmcause;
uint8_t presence;
ExtendedProtocolConfigurationOptions extendedprotocolconfigurationoptions;
ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
PDUSessionIdentity pdusessionidentity;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
_5GSMCause _5gsmcause;
uint8_t presence;
ExtendedProtocolConfigurationOptions extendedprotocolconfigurationoptions;
} pdu_session_modification_command_reject_msg;
int decode_pdu_session_modification_command_reject(pdu_session_modification_command_reject_msg *pdusessionmodificationcommandreject, uint8_t *buffer, uint32_t len);
int encode_pdu_session_modification_command_reject(pdu_session_modification_command_reject_msg *pdusessionmodificationcommandreject, uint8_t *buffer, uint32_t len);
......
......@@ -6,50 +6,49 @@
#include "TLVDecoder.h"
#include "PDUSessionModificationComplete.h"
int decode_pdu_session_modification_complete( pdu_session_modification_complete_msg *pdu_session_modification_complete, uint8_t *buffer, uint32_t len)
{
int decode_pdu_session_modification_complete(pdu_session_modification_complete_msg *pdu_session_modification_complete, uint8_t *buffer, uint32_t len) {
uint32_t decoded = 0;
int decoded_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_DECODER (buffer, PDU_SESSION_MODIFICATION_COMPLETE_MINIMUM_LENGTH, len);
CHECK_PDU_POINTER_AND_LENGTH_DECODER(buffer, PDU_SESSION_MODIFICATION_COMPLETE_MINIMUM_LENGTH, len);
while (len - decoded > 0) {
uint8_t ieiDecoded = *(buffer+decoded);
uint8_t ieiDecoded = *(buffer + decoded);
if (ieiDecoded == 0)
break;
switch (ieiDecoded) {
case PDU_SESSION_MODIFICATION_COMPLETE_E_P_C_O_IEI:
if ((decoded_result = decode_extended_protocol_configuration_options (&pdu_session_modification_complete->extendedprotocolconfigurationoptions, PDU_SESSION_MODIFICATION_COMPLETE_E_P_C_O_IEI, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else {
decoded += decoded_result;
pdu_session_modification_complete->presence |= PDU_SESSION_MODIFICATION_COMPLETE_E_P_C_O_PRESENCE;
}
break;
case PDU_SESSION_MODIFICATION_COMPLETE_E_P_C_O_IEI:
if ((decoded_result = decode_extended_protocol_configuration_options(&pdu_session_modification_complete->extendedprotocolconfigurationoptions, PDU_SESSION_MODIFICATION_COMPLETE_E_P_C_O_IEI,
buffer + decoded, len - decoded)) < 0)
return decoded_result;
else {
decoded += decoded_result;
pdu_session_modification_complete->presence |= PDU_SESSION_MODIFICATION_COMPLETE_E_P_C_O_PRESENCE;
}
break;
}
}
return decoded;
}
int encode_pdu_session_modification_complete( pdu_session_modification_complete_msg *pdu_session_modification_complete, uint8_t *buffer, uint32_t len)
{
int encode_pdu_session_modification_complete(pdu_session_modification_complete_msg *pdu_session_modification_complete, uint8_t *buffer, uint32_t len) {
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_MODIFICATION_COMPLETE_MINIMUM_LENGTH, len);
if ((pdu_session_modification_complete->presence & PDU_SESSION_MODIFICATION_COMPLETE_E_P_C_O_PRESENCE) == PDU_SESSION_MODIFICATION_COMPLETE_E_P_C_O_PRESENCE) {
if ((encoded_result = encode_extended_protocol_configuration_options (pdu_session_modification_complete->extendedprotocolconfigurationoptions, PDU_SESSION_MODIFICATION_COMPLETE_E_P_C_O_IEI, buffer + encoded, len - encoded)) < 0)
return encoded_result;
else
encoded += encoded_result;
}
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, PDU_SESSION_MODIFICATION_COMPLETE_MINIMUM_LENGTH, len);
if ((pdu_session_modification_complete->presence & PDU_SESSION_MODIFICATION_COMPLETE_E_P_C_O_PRESENCE) == PDU_SESSION_MODIFICATION_COMPLETE_E_P_C_O_PRESENCE) {
if ((encoded_result = encode_extended_protocol_configuration_options(pdu_session_modification_complete->extendedprotocolconfigurationoptions, PDU_SESSION_MODIFICATION_COMPLETE_E_P_C_O_IEI,
buffer + encoded, len - encoded)) < 0)
return encoded_result;
else
encoded += encoded_result;
}
return encoded;
return encoded;
}
......@@ -9,7 +9,6 @@
#include "MessageType.h"
#include "ExtendedProtocolConfigurationOptions.h"
#if 0
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define PDU_SESSION_MODIFICATION_COMPLETE_MINIMUM_LENGTH ( \
......@@ -23,7 +22,6 @@
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define PDU_SESSION_MODIFICATION_COMPLETE_MINIMUM_LENGTH 0
/* Maximum length macro. Formed by maximum length of each field */
#define PDU_SESSION_MODIFICATION_COMPLETE_MAXIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \
......@@ -33,20 +31,18 @@
EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_MAXIMUM_LENGTH_TLVE + \
0)
#define PDU_SESSION_MODIFICATION_COMPLETE_E_P_C_O_IEI 0x7B
#define PDU_SESSION_MODIFICATION_COMPLETE_E_P_C_O_PRESENCE (1<<0)
typedef struct pdu_session_modification_complete_msg_tag {
ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
PDUSessionIdentity pdusessionidentity;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
uint8_t presence;
ExtendedProtocolConfigurationOptions extendedprotocolconfigurationoptions;
ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
PDUSessionIdentity pdusessionidentity;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
uint8_t presence;
ExtendedProtocolConfigurationOptions extendedprotocolconfigurationoptions;
} pdu_session_modification_complete_msg;
int decode_pdu_session_modification_complete(pdu_session_modification_complete_msg *pdusessionmodificationcomplete, uint8_t *buffer, uint32_t len);
int encode_pdu_session_modification_complete(pdu_session_modification_complete_msg *pdusessionmodificationcomplete, uint8_t *buffer, uint32_t len);
......
......@@ -6,15 +6,14 @@
#include "TLVDecoder.h"
#include "PDUSessionModificationReject.h"
int decode_pdu_session_modification_reject( pdu_session_modification_reject_msg *pdu_session_modification_reject, uint8_t *buffer, uint32_t len)
{
int decode_pdu_session_modification_reject(pdu_session_modification_reject_msg *pdu_session_modification_reject, uint8_t *buffer, uint32_t len) {
uint32_t decoded = 0;
int decoded_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_DECODER (buffer, PDU_SESSION_MODIFICATION_REJECT_MINIMUM_LENGTH, len);
CHECK_PDU_POINTER_AND_LENGTH_DECODER(buffer, PDU_SESSION_MODIFICATION_REJECT_MINIMUM_LENGTH, len);
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 {
decoded += decoded_result;
......@@ -27,67 +26,70 @@ int decode_pdu_session_modification_reject( pdu_session_modification_reject_msg
break;
switch (ieiDecoded) {
case PDU_SESSION_MODIFICATION_REJECT_GPRS_TIMER3_IEI:
if ((decoded_result = decode_gprs_timer3 (&pdu_session_modification_reject->gprstimer3, PDU_SESSION_MODIFICATION_REJECT_GPRS_TIMER3_IEI, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else {
decoded += decoded_result;
pdu_session_modification_reject->presence |= PDU_SESSION_MODIFICATION_REJECT_GPRS_TIMER3_PRESENCE;
}
break;
case PDU_SESSION_MODIFICATION_REJECT_E_P_C_O_IEI:
if ((decoded_result = decode_extended_protocol_configuration_options (&pdu_session_modification_reject->extendedprotocolconfigurationoptions, PDU_SESSION_MODIFICATION_REJECT_E_P_C_O_IEI, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else {
decoded += decoded_result;
pdu_session_modification_reject->presence |= PDU_SESSION_MODIFICATION_REJECT_E_P_C_O_PRESENCE;
}
break;
case PDU_SESSION_MODIFICATION_REJECT__5GSM_CONGESTION_REATTEMPT_INDICATOR_IEI:
if ((decoded_result = decode__5gsm_congestion_reattempt_indicator (&pdu_session_modification_reject->_5gsmcongestionreattemptindicator, PDU_SESSION_MODIFICATION_REJECT__5GSM_CONGESTION_REATTEMPT_INDICATOR_IEI, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else {
decoded += decoded_result;
pdu_session_modification_reject->presence |= PDU_SESSION_MODIFICATION_REJECT__5GSM_CONGESTION_REATTEMPT_INDICATOR_PRESENCE;
}
break;
case PDU_SESSION_MODIFICATION_REJECT_GPRS_TIMER3_IEI:
if ((decoded_result = decode_gprs_timer3(&pdu_session_modification_reject->gprstimer3, PDU_SESSION_MODIFICATION_REJECT_GPRS_TIMER3_IEI, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else {
decoded += decoded_result;
pdu_session_modification_reject->presence |= PDU_SESSION_MODIFICATION_REJECT_GPRS_TIMER3_PRESENCE;
}
break;
case PDU_SESSION_MODIFICATION_REJECT_E_P_C_O_IEI:
if ((decoded_result = decode_extended_protocol_configuration_options(&pdu_session_modification_reject->extendedprotocolconfigurationoptions, PDU_SESSION_MODIFICATION_REJECT_E_P_C_O_IEI,
buffer + decoded, len - decoded)) < 0)
return decoded_result;
else {
decoded += decoded_result;
pdu_session_modification_reject->presence |= PDU_SESSION_MODIFICATION_REJECT_E_P_C_O_PRESENCE;
}
break;
case PDU_SESSION_MODIFICATION_REJECT__5GSM_CONGESTION_REATTEMPT_INDICATOR_IEI:
if ((decoded_result = decode__5gsm_congestion_reattempt_indicator(&pdu_session_modification_reject->_5gsmcongestionreattemptindicator,
PDU_SESSION_MODIFICATION_REJECT__5GSM_CONGESTION_REATTEMPT_INDICATOR_IEI, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else {
decoded += decoded_result;
pdu_session_modification_reject->presence |= PDU_SESSION_MODIFICATION_REJECT__5GSM_CONGESTION_REATTEMPT_INDICATOR_PRESENCE;
}
break;
}
}
return decoded;
}
int encode_pdu_session_modification_reject( pdu_session_modification_reject_msg *pdu_session_modification_reject, uint8_t *buffer, uint32_t len)
{
int encode_pdu_session_modification_reject(pdu_session_modification_reject_msg *pdu_session_modification_reject, uint8_t *buffer, uint32_t len) {
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_MODIFICATION_REJECT_MINIMUM_LENGTH, len);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, PDU_SESSION_MODIFICATION_REJECT_MINIMUM_LENGTH, len);
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 {
encoded += encoded_result;
}
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)
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;
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((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)
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 ((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)
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;
......
......@@ -12,8 +12,6 @@
#include "ExtendedProtocolConfigurationOptions.h"
#include "_5GSMCongestionReattemptIndicator.h"
#if 0
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define PDU_SESSION_MODIFICATION_REJECT_MINIMUM_LENGTH ( \
......@@ -32,7 +30,6 @@
_5GSM_CAUSE_MINIMUM_LENGTH_V + \
0)
/* Maximum length macro. Formed by maximum length of each field */
#define PDU_SESSION_MODIFICATION_REJECT_MAXIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \
......@@ -44,7 +41,6 @@
EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_MAXIMUM_LENGTH_TLVE + \
0)
#define PDU_SESSION_MODIFICATION_REJECT_GPRS_TIMER3_IEI 0x37
#define PDU_SESSION_MODIFICATION_REJECT_E_P_C_O_IEI 0x7B
#define PDU_SESSION_MODIFICATION_REJECT__5GSM_CONGESTION_REATTEMPT_INDICATOR_IEI 0x61
......@@ -54,18 +50,17 @@
#define PDU_SESSION_MODIFICATION_REJECT__5GSM_CONGESTION_REATTEMPT_INDICATOR_PRESENCE (1<<2)
typedef struct pdu_session_modification_reject_msg_tag {
ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
PDUSessionIdentity pdusessionidentity;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
_5GSMCause _5gsmcause;
uint8_t presence;
GPRSTimer3 gprstimer3;
ExtendedProtocolConfigurationOptions extendedprotocolconfigurationoptions;
_5GSMCongestionReattemptIndicator _5gsmcongestionreattemptindicator;
ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
PDUSessionIdentity pdusessionidentity;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
_5GSMCause _5gsmcause;
uint8_t presence;
GPRSTimer3 gprstimer3;
ExtendedProtocolConfigurationOptions extendedprotocolconfigurationoptions;
_5GSMCongestionReattemptIndicator _5gsmcongestionreattemptindicator;
} pdu_session_modification_reject_msg;
int decode_pdu_session_modification_reject(pdu_session_modification_reject_msg *pdusessionmodificationreject, uint8_t *buffer, uint32_t len);
int encode_pdu_session_modification_reject(pdu_session_modification_reject_msg *pdusessionmodificationreject, uint8_t *buffer, uint32_t len);
......
......@@ -17,7 +17,6 @@
#include "MappedEPSBearerContexts.h"
#include "ExtendedProtocolConfigurationOptions.h"
#if 0
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define PDU_SESSION_MODIFICATION_REQUEST_MINIMUM_LENGTH ( \
......@@ -39,7 +38,6 @@
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define PDU_SESSION_MODIFICATION_REQUEST_MINIMUM_LENGTH 0
/* Maximum length macro. Formed by maximum length of each field */
#define PDU_SESSION_MODIFICATION_REQUEST_MAXIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \
......@@ -57,7 +55,6 @@
EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_MAXIMUM_LENGTH_TLVE + \
0)
#define PDU_SESSION_MODIFICATION_REQUEST__5GSM_CAPABILITY_IEI 0x28
#define PDU_SESSION_MODIFICATION_REQUEST__5GSM_CAUSE_IEI 0x59
#define PDU_SESSION_MODIFICATION_REQUEST_MAXIMUM_NUMBER_OF_SUPPORTED_IEI 0x55
......@@ -68,7 +65,6 @@
#define PDU_SESSION_MODIFICATION_REQUEST_MAPPED_EPS_BEARER_CONTEXTS_IEI 0x75
#define PDU_SESSION_MODIFICATION_REQUEST_E_P_C_O_IEI 0x7B
#define PDU_SESSION_MODIFICATION_REQUEST__5GSM_CAPABILITY_PRESENCE (1<<0)
#define PDU_SESSION_MODIFICATION_REQUEST__5GSM_CAUSE_PRESENCE (1<<1)
#define PDU_SESSION_MODIFICATION_REQUEST_MAXIMUM_NUMBER_OF_SUPPORTED_PRESENCE (1<<2)
......@@ -79,25 +75,23 @@
#define PDU_SESSION_MODIFICATION_REQUEST_MAPPED_EPS_BEARER_CONTEXTS_PRESENCE (1<<7)
#define PDU_SESSION_MODIFICATION_REQUEST_E_P_C_O_PRESENCE (1<<8)
typedef struct pdu_session_modification_request_msg_tag {
ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
PDUSessionIdentity pdusessionidentity;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
uint16_t presence;
_5GSMCapability _5gsmcapability;
_5GSMCause _5gsmcause;
MaximumNumberOfSupportedPacketFilters maximumnumberofsupportedpacketfilters;
AlwaysonPDUSessionRequested alwaysonpdusessionrequested;
IntergrityProtectionMaximumDataRate intergrityprotectionmaximumdatarate;
QOSRules qosrules;
QOSFlowDescriptions qosflowdescriptions;
MappedEPSBearerContexts mappedepsbearercontexts;
ExtendedProtocolConfigurationOptions extendedprotocolconfigurationoptions;
ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
PDUSessionIdentity pdusessionidentity;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
uint16_t presence;
_5GSMCapability _5gsmcapability;
_5GSMCause _5gsmcause;
MaximumNumberOfSupportedPacketFilters maximumnumberofsupportedpacketfilters;
AlwaysonPDUSessionRequested alwaysonpdusessionrequested;
IntergrityProtectionMaximumDataRate intergrityprotectionmaximumdatarate;
QOSRules qosrules;
QOSFlowDescriptions qosflowdescriptions;
MappedEPSBearerContexts mappedepsbearercontexts;
ExtendedProtocolConfigurationOptions extendedprotocolconfigurationoptions;
} pdu_session_modification_request_msg;
int decode_pdu_session_modification_request(pdu_session_modification_request_msg *pdusessionmodificationrequest, uint8_t *buffer, uint32_t len);
int encode_pdu_session_modification_request(pdu_session_modification_request_msg *pdusessionmodificationrequest, uint8_t *buffer, uint32_t len);
......
......@@ -6,15 +6,14 @@
#include "TLVDecoder.h"
#include "PDUSessionReleaseCommand.h"
int decode_pdu_session_release_command( pdu_session_release_command_msg *pdu_session_release_command, uint8_t *buffer, uint32_t len)
{
int decode_pdu_session_release_command(pdu_session_release_command_msg *pdu_session_release_command, uint8_t *buffer, uint32_t len) {
uint32_t decoded = 0;
int decoded_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_DECODER (buffer, PDU_SESSION_RELEASE_COMMAND_MINIMUM_LENGTH, len);
CHECK_PDU_POINTER_AND_LENGTH_DECODER(buffer, PDU_SESSION_RELEASE_COMMAND_MINIMUM_LENGTH, len);
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 {
decoded += decoded_result;
......@@ -27,82 +26,84 @@ int decode_pdu_session_release_command( pdu_session_release_command_msg *pdu_ses
break;
switch (ieiDecoded) {
case PDU_SESSION_RELEASE_COMMAND_GPRS_TIMER3_IEI:
if ((decoded_result = decode_gprs_timer3 (&pdu_session_release_command->gprstimer3, PDU_SESSION_RELEASE_COMMAND_GPRS_TIMER3_IEI, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else {
decoded += decoded_result;
pdu_session_release_command->presence |= PDU_SESSION_RELEASE_COMMAND_GPRS_TIMER3_PRESENCE;
}
break;
case PDU_SESSION_RELEASE_COMMAND_EAP_MESSAGE_IEI:
if ((decoded_result = decode_eap_message (&pdu_session_release_command->eapmessage, PDU_SESSION_RELEASE_COMMAND_EAP_MESSAGE_IEI, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else {
decoded += decoded_result;
pdu_session_release_command->presence |= PDU_SESSION_RELEASE_COMMAND_EAP_MESSAGE_PRESENCE;
}
break;
case PDU_SESSION_RELEASE_COMMAND__5GSM_CONGESTION_REATTEMPT_INDICATOR_IEI:
if ((decoded_result = decode__5gsm_congestion_reattempt_indicator (&pdu_session_release_command->_5gsmcongestionreattemptindicator, PDU_SESSION_RELEASE_COMMAND__5GSM_CONGESTION_REATTEMPT_INDICATOR_IEI, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else {
decoded += decoded_result;
pdu_session_release_command->presence |= PDU_SESSION_RELEASE_COMMAND__5GSM_CONGESTION_REATTEMPT_INDICATOR_PRESENCE;
}
break;
case PDU_SESSION_RELEASE_COMMAND_E_P_C_O_IEI:
if ((decoded_result = decode_extended_protocol_configuration_options (&pdu_session_release_command->extendedprotocolconfigurationoptions, PDU_SESSION_RELEASE_COMMAND_E_P_C_O_IEI, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else {
decoded += decoded_result;
pdu_session_release_command->presence |= PDU_SESSION_RELEASE_COMMAND_E_P_C_O_PRESENCE;
}
break;
case PDU_SESSION_RELEASE_COMMAND_GPRS_TIMER3_IEI:
if ((decoded_result = decode_gprs_timer3(&pdu_session_release_command->gprstimer3, PDU_SESSION_RELEASE_COMMAND_GPRS_TIMER3_IEI, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else {
decoded += decoded_result;
pdu_session_release_command->presence |= PDU_SESSION_RELEASE_COMMAND_GPRS_TIMER3_PRESENCE;
}
break;
case PDU_SESSION_RELEASE_COMMAND_EAP_MESSAGE_IEI:
if ((decoded_result = decode_eap_message(&pdu_session_release_command->eapmessage, PDU_SESSION_RELEASE_COMMAND_EAP_MESSAGE_IEI, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else {
decoded += decoded_result;
pdu_session_release_command->presence |= PDU_SESSION_RELEASE_COMMAND_EAP_MESSAGE_PRESENCE;
}
break;
case PDU_SESSION_RELEASE_COMMAND__5GSM_CONGESTION_REATTEMPT_INDICATOR_IEI:
if ((decoded_result = decode__5gsm_congestion_reattempt_indicator(&pdu_session_release_command->_5gsmcongestionreattemptindicator,
PDU_SESSION_RELEASE_COMMAND__5GSM_CONGESTION_REATTEMPT_INDICATOR_IEI, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else {
decoded += decoded_result;
pdu_session_release_command->presence |= PDU_SESSION_RELEASE_COMMAND__5GSM_CONGESTION_REATTEMPT_INDICATOR_PRESENCE;
}
break;
case PDU_SESSION_RELEASE_COMMAND_E_P_C_O_IEI:
if ((decoded_result = decode_extended_protocol_configuration_options(&pdu_session_release_command->extendedprotocolconfigurationoptions, PDU_SESSION_RELEASE_COMMAND_E_P_C_O_IEI,
buffer + decoded, len - decoded)) < 0)
return decoded_result;
else {
decoded += decoded_result;
pdu_session_release_command->presence |= PDU_SESSION_RELEASE_COMMAND_E_P_C_O_PRESENCE;
}
break;
}
}
return decoded;
}
int encode_pdu_session_release_command( pdu_session_release_command_msg *pdu_session_release_command, uint8_t *buffer, uint32_t len)
{
int encode_pdu_session_release_command(pdu_session_release_command_msg *pdu_session_release_command, uint8_t *buffer, uint32_t len) {
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_RELEASE_COMMAND_MINIMUM_LENGTH, len);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, PDU_SESSION_RELEASE_COMMAND_MINIMUM_LENGTH, len);
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 {
encoded += encoded_result;
}
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)
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 ((encoded_result = encode_eap_message (pdu_session_release_command->eapmessage, PDU_SESSION_RELEASE_COMMAND_EAP_MESSAGE_IEI, buffer + encoded, len - encoded)) < 0)
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 ((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)
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 ((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)
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;
......
......@@ -13,7 +13,6 @@
#include "_5GSMCongestionReattemptIndicator.h"
#include "ExtendedProtocolConfigurationOptions.h"
#if 0
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define PDU_SESSION_RELEASE_COMMAND_MINIMUM_LENGTH ( \
......@@ -32,7 +31,6 @@
_5GSM_CAUSE_MINIMUM_LENGTH_V + \
0)
/* Maximum length macro. Formed by maximum length of each field */
#define PDU_SESSION_RELEASE_COMMAND_MAXIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \
......@@ -46,7 +44,6 @@
EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_MAXIMUM_LENGTH_TLVE + \
0)
#define PDU_SESSION_RELEASE_COMMAND_GPRS_TIMER3_IEI 0x37
#define PDU_SESSION_RELEASE_COMMAND_EAP_MESSAGE_IEI 0x78
#define PDU_SESSION_RELEASE_COMMAND__5GSM_CONGESTION_REATTEMPT_INDICATOR_IEI 0x61
......@@ -58,16 +55,16 @@
#define PDU_SESSION_RELEASE_COMMAND_E_P_C_O_PRESENCE (1<<3)
typedef struct pdu_session_release_command_msg_tag {
ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
PDUSessionIdentity pdusessionidentity;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
_5GSMCause _5gsmcause;
uint8_t presence;
GPRSTimer3 gprstimer3;
EAPMessage eapmessage;
_5GSMCongestionReattemptIndicator _5gsmcongestionreattemptindicator;
ExtendedProtocolConfigurationOptions extendedprotocolconfigurationoptions;
ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
PDUSessionIdentity pdusessionidentity;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
_5GSMCause _5gsmcause;
uint8_t presence;
GPRSTimer3 gprstimer3;
EAPMessage eapmessage;
_5GSMCongestionReattemptIndicator _5gsmcongestionreattemptindicator;
ExtendedProtocolConfigurationOptions extendedprotocolconfigurationoptions;
} pdu_session_release_command_msg;
int decode_pdu_session_release_command(pdu_session_release_command_msg *pdusessionreleasecommand, uint8_t *buffer, uint32_t len);
......
......@@ -6,13 +6,12 @@
#include "TLVDecoder.h"
#include "PDUSessionReleaseComplete.h"
int decode_pdu_session_release_complete( pdu_session_release_complete_msg *pdu_session_release_complete, uint8_t *buffer, uint32_t len)
{
int decode_pdu_session_release_complete(pdu_session_release_complete_msg *pdu_session_release_complete, uint8_t *buffer, uint32_t len) {
uint32_t decoded = 0;
int decoded_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_DECODER (buffer, PDU_SESSION_RELEASE_COMPLETE_MINIMUM_LENGTH, len);
CHECK_PDU_POINTER_AND_LENGTH_DECODER(buffer, PDU_SESSION_RELEASE_COMPLETE_MINIMUM_LENGTH, len);
while (len - decoded > 0) {
uint8_t ieiDecoded = *(buffer + decoded);
......@@ -21,50 +20,50 @@ int decode_pdu_session_release_complete( pdu_session_release_complete_msg *pdu_s
break;
switch (ieiDecoded) {
case PDU_SESSION_RELEASE_COMPLETE__5GSM_CAUSE_IEI:
if ((decoded_result = decode__5gsm_cause (&pdu_session_release_complete->_5gsmcause, PDU_SESSION_RELEASE_COMPLETE__5GSM_CAUSE_IEI, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else {
decoded += decoded_result;
pdu_session_release_complete->presence |= PDU_SESSION_RELEASE_COMPLETE__5GSM_CAUSE_PRESENCE;
}
break;
case PDU_SESSION_RELEASE_COMPLETE_E_P_C_O_IEI:
if ((decoded_result = decode_extended_protocol_configuration_options (&pdu_session_release_complete->extendedprotocolconfigurationoptions, PDU_SESSION_RELEASE_COMPLETE_E_P_C_O_IEI, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else {
decoded += decoded_result;
pdu_session_release_complete->presence |= PDU_SESSION_RELEASE_COMPLETE_E_P_C_O_PRESENCE;
}
break;
case PDU_SESSION_RELEASE_COMPLETE__5GSM_CAUSE_IEI:
if ((decoded_result = decode__5gsm_cause(&pdu_session_release_complete->_5gsmcause, PDU_SESSION_RELEASE_COMPLETE__5GSM_CAUSE_IEI, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else {
decoded += decoded_result;
pdu_session_release_complete->presence |= PDU_SESSION_RELEASE_COMPLETE__5GSM_CAUSE_PRESENCE;
}
break;
case PDU_SESSION_RELEASE_COMPLETE_E_P_C_O_IEI:
if ((decoded_result = decode_extended_protocol_configuration_options(&pdu_session_release_complete->extendedprotocolconfigurationoptions, PDU_SESSION_RELEASE_COMPLETE_E_P_C_O_IEI,
buffer + decoded, len - decoded)) < 0)
return decoded_result;
else {
decoded += decoded_result;
pdu_session_release_complete->presence |= PDU_SESSION_RELEASE_COMPLETE_E_P_C_O_PRESENCE;
}
break;
}
}
return decoded;
}
int encode_pdu_session_release_complete( pdu_session_release_complete_msg *pdu_session_release_complete, uint8_t *buffer, uint32_t len)
{
int encode_pdu_session_release_complete(pdu_session_release_complete_msg *pdu_session_release_complete, uint8_t *buffer, uint32_t len) {
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_RELEASE_COMPLETE_MINIMUM_LENGTH, len);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, PDU_SESSION_RELEASE_COMPLETE_MINIMUM_LENGTH, len);
if ((pdu_session_release_complete->presence & PDU_SESSION_RELEASE_COMPLETE__5GSM_CAUSE_PRESENCE) == PDU_SESSION_RELEASE_COMPLETE__5GSM_CAUSE_PRESENCE) {
if ((encoded_result = encode__5gsm_cause (pdu_session_release_complete->_5gsmcause, PDU_SESSION_RELEASE_COMPLETE__5GSM_CAUSE_IEI, buffer + encoded, len - encoded)) < 0)
return encoded_result;
else
encoded += encoded_result;
}
if ((pdu_session_release_complete->presence & PDU_SESSION_RELEASE_COMPLETE__5GSM_CAUSE_PRESENCE) == PDU_SESSION_RELEASE_COMPLETE__5GSM_CAUSE_PRESENCE) {
if ((encoded_result = encode__5gsm_cause(pdu_session_release_complete->_5gsmcause, PDU_SESSION_RELEASE_COMPLETE__5GSM_CAUSE_IEI, buffer + encoded, len - encoded)) < 0)
return encoded_result;
else
encoded += encoded_result;
}
if ((pdu_session_release_complete->presence & PDU_SESSION_RELEASE_COMPLETE_E_P_C_O_PRESENCE) == PDU_SESSION_RELEASE_COMPLETE_E_P_C_O_PRESENCE) {
if ((encoded_result = encode_extended_protocol_configuration_options (pdu_session_release_complete->extendedprotocolconfigurationoptions, PDU_SESSION_RELEASE_COMPLETE_E_P_C_O_IEI, buffer + encoded, len - encoded)) < 0)
return encoded_result;
else
encoded += encoded_result;
}
if ((pdu_session_release_complete->presence & PDU_SESSION_RELEASE_COMPLETE_E_P_C_O_PRESENCE) == PDU_SESSION_RELEASE_COMPLETE_E_P_C_O_PRESENCE) {
if ((encoded_result = encode_extended_protocol_configuration_options(pdu_session_release_complete->extendedprotocolconfigurationoptions, PDU_SESSION_RELEASE_COMPLETE_E_P_C_O_IEI, buffer + encoded,
len - encoded)) < 0)
return encoded_result;
else
encoded += encoded_result;
}
return encoded;
return encoded;
}
......@@ -10,7 +10,6 @@
#include "_5GSMCause.h"
#include "ExtendedProtocolConfigurationOptions.h"
#if 0
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define PDU_SESSION_RELEASE_COMPLETE_MINIMUM_LENGTH ( \
......@@ -25,7 +24,6 @@
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define PDU_SESSION_RELEASE_COMPLETE_MINIMUM_LENGTH 0
/* Maximum length macro. Formed by maximum length of each field */
#define PDU_SESSION_RELEASE_COMPLETE_MAXIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \
......@@ -36,7 +34,6 @@
EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_MAXIMUM_LENGTH_TLVE + \
0)
#define PDU_SESSION_RELEASE_COMPLETE__5GSM_CAUSE_IEI 0x59
#define PDU_SESSION_RELEASE_COMPLETE_E_P_C_O_IEI 0x7B
......@@ -44,13 +41,13 @@
#define PDU_SESSION_RELEASE_COMPLETE_E_P_C_O_PRESENCE (1<<1)
typedef struct pdu_session_release_complete_msg_tag {
ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
PDUSessionIdentity pdusessionidentity;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
uint8_t presence;
_5GSMCause _5gsmcause;
ExtendedProtocolConfigurationOptions extendedprotocolconfigurationoptions;
ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
PDUSessionIdentity pdusessionidentity;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
uint8_t presence;
_5GSMCause _5gsmcause;
ExtendedProtocolConfigurationOptions extendedprotocolconfigurationoptions;
} pdu_session_release_complete_msg;
int decode_pdu_session_release_complete(pdu_session_release_complete_msg *pdusessionreleasecomplete, uint8_t *buffer, uint32_t len);
......
......@@ -6,15 +6,14 @@
#include "TLVDecoder.h"
#include "PDUSessionReleaseReject.h"
int decode_pdu_session_release_reject( pdu_session_release_reject_msg *pdu_session_release_reject, uint8_t *buffer, uint32_t len)
{
int decode_pdu_session_release_reject(pdu_session_release_reject_msg *pdu_session_release_reject, uint8_t *buffer, uint32_t len) {
uint32_t decoded = 0;
int decoded_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_DECODER (buffer, PDU_SESSION_RELEASE_REJECT_MINIMUM_LENGTH, len);
CHECK_PDU_POINTER_AND_LENGTH_DECODER(buffer, PDU_SESSION_RELEASE_REJECT_MINIMUM_LENGTH, len);
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;
......@@ -27,37 +26,37 @@ int decode_pdu_session_release_reject( pdu_session_release_reject_msg *pdu_sessi
break;
switch (ieiDecoded) {
case PDU_SESSION_RELEASE_REJECT_E_P_C_O_IEI:
if ((decoded_result = decode_extended_protocol_configuration_options (&pdu_session_release_reject->extendedprotocolconfigurationoptions, PDU_SESSION_RELEASE_REJECT_E_P_C_O_IEI, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else {
decoded += decoded_result;
pdu_session_release_reject->presence |= PDU_SESSION_RELEASE_REJECT_E_P_C_O_PRESENCE;
}
break;
case PDU_SESSION_RELEASE_REJECT_E_P_C_O_IEI:
if ((decoded_result = decode_extended_protocol_configuration_options(&pdu_session_release_reject->extendedprotocolconfigurationoptions, PDU_SESSION_RELEASE_REJECT_E_P_C_O_IEI,
buffer + decoded, len - decoded)) < 0)
return decoded_result;
else {
decoded += decoded_result;
pdu_session_release_reject->presence |= PDU_SESSION_RELEASE_REJECT_E_P_C_O_PRESENCE;
}
break;
}
}
return decoded;
}
int encode_pdu_session_release_reject( pdu_session_release_reject_msg *pdu_session_release_reject, uint8_t *buffer, uint32_t len)
{
int encode_pdu_session_release_reject(pdu_session_release_reject_msg *pdu_session_release_reject, uint8_t *buffer, uint32_t len) {
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_RELEASE_REJECT_MINIMUM_LENGTH, len);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, PDU_SESSION_RELEASE_REJECT_MINIMUM_LENGTH, len);
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;
}
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)
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;
......
......@@ -10,7 +10,6 @@
#include "_5GSMCause.h"
#include "ExtendedProtocolConfigurationOptions.h"
#if 0
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define PDU_SESSION_RELEASE_REJECT_MINIMUM_LENGTH ( \
......@@ -27,7 +26,6 @@
_5GSM_CAUSE_MINIMUM_LENGTH_V + \
0)
/* Maximum length macro. Formed by maximum length of each field */
#define PDU_SESSION_RELEASE_REJECT_MAXIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \
......@@ -38,18 +36,17 @@
EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_MAXIMUM_LENGTH_TLVE + \
0)
#define PDU_SESSION_RELEASE_REJECT_E_P_C_O_IEI 0x7B
#define PDU_SESSION_RELEASE_REJECT_E_P_C_O_PRESENCE (1<<0)
typedef struct pdu_session_release_reject_msg_tag {
ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
PDUSessionIdentity pdusessionidentity;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
_5GSMCause _5gsmcause;
uint8_t presence;
ExtendedProtocolConfigurationOptions extendedprotocolconfigurationoptions;
ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
PDUSessionIdentity pdusessionidentity;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
_5GSMCause _5gsmcause;
uint8_t presence;
ExtendedProtocolConfigurationOptions extendedprotocolconfigurationoptions;
} pdu_session_release_reject_msg;
int decode_pdu_session_release_reject(pdu_session_release_reject_msg *pdusessionreleasereject, uint8_t *buffer, uint32_t len);
......
......@@ -6,61 +6,60 @@
#include "TLVDecoder.h"
#include "PDUSessionReleaseRequest.h"
int decode_pdu_session_release_request( pdu_session_release_request_msg *pdu_session_release_request, uint8_t *buffer, uint32_t len)
{
int decode_pdu_session_release_request(pdu_session_release_request_msg *pdu_session_release_request, uint8_t *buffer, uint32_t len) {
uint32_t decoded = 0;
int decoded_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_DECODER (buffer, PDU_SESSION_RELEASE_REQUEST_MINIMUM_LENGTH, len);
CHECK_PDU_POINTER_AND_LENGTH_DECODER(buffer, PDU_SESSION_RELEASE_REQUEST_MINIMUM_LENGTH, len);
while (len - decoded > 0) {
uint8_t ieiDecoded = *(buffer + decoded);
if( ieiDecoded == 0)
if (ieiDecoded == 0)
break;
switch (ieiDecoded) {
case PDU_SESSION_RELEASE_REQUEST__5GSM_CAUSE_IEI:
if ((decoded_result = decode__5gsm_cause (&pdu_session_release_request->_5gsmcause, PDU_SESSION_RELEASE_REQUEST__5GSM_CAUSE_IEI, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else {
decoded += decoded_result;
pdu_session_release_request->presence |= PDU_SESSION_RELEASE_REQUEST__5GSM_CAUSE_PRESENCE;
}
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)
return decoded_result;
else {
decoded += decoded_result;
pdu_session_release_request->presence |= PDU_SESSION_RELEASE_REQUEST_E_P_C_O_PRESENCE;
}
break;
case PDU_SESSION_RELEASE_REQUEST__5GSM_CAUSE_IEI:
if ((decoded_result = decode__5gsm_cause(&pdu_session_release_request->_5gsmcause, PDU_SESSION_RELEASE_REQUEST__5GSM_CAUSE_IEI, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else {
decoded += decoded_result;
pdu_session_release_request->presence |= PDU_SESSION_RELEASE_REQUEST__5GSM_CAUSE_PRESENCE;
}
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)
return decoded_result;
else {
decoded += decoded_result;
pdu_session_release_request->presence |= PDU_SESSION_RELEASE_REQUEST_E_P_C_O_PRESENCE;
}
break;
}
}
return decoded;
}
int encode_pdu_session_release_request( pdu_session_release_request_msg *pdu_session_release_request, uint8_t *buffer, uint32_t len)
{
int encode_pdu_session_release_request(pdu_session_release_request_msg *pdu_session_release_request, uint8_t *buffer, uint32_t len) {
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_RELEASE_REQUEST_MINIMUM_LENGTH, len);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, PDU_SESSION_RELEASE_REQUEST_MINIMUM_LENGTH, len);
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)
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 ((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)
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;
......
......@@ -10,7 +10,6 @@
#include "_5GSMCause.h"
#include "ExtendedProtocolConfigurationOptions.h"
#if 0
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define PDU_SESSION_RELEASE_REQUEST_MINIMUM_LENGTH ( \
......@@ -35,25 +34,22 @@
EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_MAXIMUM_LENGTH_TLVE + \
0)
#define PDU_SESSION_RELEASE_REQUEST__5GSM_CAUSE_IEI 0x59
#define PDU_SESSION_RELEASE_REQUEST_E_P_C_O_IEI 0x7B
#define PDU_SESSION_RELEASE_REQUEST__5GSM_CAUSE_PRESENCE (1<<0)
#define PDU_SESSION_RELEASE_REQUEST_E_P_C_O_PRESENCE (1<<1)
typedef struct pdu_session_release_request_msg_tag {
ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
PDUSessionIdentity pdusessionidentity;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
uint8_t presence;
_5GSMCause _5gsmcause;
ExtendedProtocolConfigurationOptions extendedprotocolconfigurationoptions;
ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
PDUSessionIdentity pdusessionidentity;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
uint8_t presence;
_5GSMCause _5gsmcause;
ExtendedProtocolConfigurationOptions extendedprotocolconfigurationoptions;
} pdu_session_release_request_msg;
int decode_pdu_session_release_request(pdu_session_release_request_msg *pdusessionreleaserequest, uint8_t *buffer, uint32_t len);
int encode_pdu_session_release_request(pdu_session_release_request_msg *pdusessionreleaserequest, uint8_t *buffer, uint32_t len);
......
......@@ -6,15 +6,14 @@
#include "TLVDecoder.h"
#include "_5GSMStatus.h"
int decode__5gsm_status( _5gsm_status_msg *_5gsm_status, uint8_t *buffer, uint32_t len)
{
int decode__5gsm_status(_5gsm_status_msg *_5gsm_status, uint8_t *buffer, uint32_t len) {
uint32_t decoded = 0;
int decoded_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_DECODER (buffer, _5GSM_STATUS_MINIMUM_LENGTH, len);
CHECK_PDU_POINTER_AND_LENGTH_DECODER(buffer, _5GSM_STATUS_MINIMUM_LENGTH, len);
if((decoded_result = decode__5gsm_cause (&_5gsm_status->_5gsmcause, 0, buffer + decoded, len-decoded))<0)
if ((decoded_result = decode__5gsm_cause(&_5gsm_status->_5gsmcause, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result;
else
decoded += decoded_result;
......@@ -22,16 +21,14 @@ int decode__5gsm_status( _5gsm_status_msg *_5gsm_status, uint8_t *buffer, uint32
return decoded;
}
int encode__5gsm_status( _5gsm_status_msg *_5gsm_status, uint8_t *buffer, uint32_t len)
{
int encode__5gsm_status(_5gsm_status_msg *_5gsm_status, uint8_t *buffer, uint32_t len) {
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, _5GSM_STATUS_MINIMUM_LENGTH, len);
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, _5GSM_STATUS_MINIMUM_LENGTH, len);
if((encoded_result = encode__5gsm_cause (_5gsm_status->_5gsmcause, 0, buffer + encoded, len - encoded)) < 0)
if ((encoded_result = encode__5gsm_cause(_5gsm_status->_5gsmcause, 0, buffer + encoded, len - encoded)) < 0)
return encoded_result;
else
encoded += encoded_result;
......
......@@ -9,7 +9,6 @@
#include "MessageType.h"
#include "_5GSMCause.h"
#if 0
/* Minimum length macro. Formed by minimum length of each mandatory field */
#define _5GSM_STATUS_MINIMUM_LENGTH ( \
......@@ -25,7 +24,6 @@
_5GSM_CAUSE_MINIMUM_LENGTH_V + \
0)
/* Maximum length macro. Formed by maximum length of each field */
#define _5GSM_STATUS_MAXIMUM_LENGTH ( \
EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \
......@@ -35,16 +33,14 @@
_5GSM_CAUSE_MAXIMUM_LENGTH_V + \
0)
typedef struct _5gsm_status_msg_tag {
ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
PDUSessionIdentity pdusessionidentity;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
_5GSMCause _5gsmcause;
ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
PDUSessionIdentity pdusessionidentity;
ProcedureTransactionIdentity proceduretransactionidentity;
MessageType messagetype;
_5GSMCause _5gsmcause;
} _5gsm_status_msg;
int decode__5gsm_status(_5gsm_status_msg *_5gsmstatus, uint8_t *buffer, uint32_t len);
int encode__5gsm_status(_5gsm_status_msg *_5gsmstatus, uint8_t *buffer, uint32_t len);
......
......@@ -26,5 +26,5 @@ typedef struct {
uint8_t pdu_session_identity;
uint8_t procedure_transaction_identity;
uint8_t message_type;
} __attribute__((__packed__)) sm_msg_header_t;
}__attribute__((__packed__)) sm_msg_header_t;
This diff is collapsed.
......@@ -68,13 +68,7 @@ typedef union {
_5gsm_status_msg _5gsm_status;
} SM_msg;
int sm_msg_decode (
SM_msg * msg,
uint8_t * buffer,
uint32_t len);
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);
int fivegsm_msg_encode(SM_msg *msg, uint8_t *buffer, uint32_t len);
#endif
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