Commit eecbab92 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Code cleanup NAS

parent 885a66eb
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. * file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -30,37 +30,38 @@ typedef enum { ...@@ -30,37 +30,38 @@ typedef enum {
SECURITY_CTX_TYPE_NOT_AVAILABLE = 0, SECURITY_CTX_TYPE_NOT_AVAILABLE = 0,
SECURITY_CTX_TYPE_PARTIAL_NATIVE, SECURITY_CTX_TYPE_PARTIAL_NATIVE,
SECURITY_CTX_TYPE_FULL_NATIVE, SECURITY_CTX_TYPE_FULL_NATIVE,
SECURITY_CTX_TYPE_MAPPED // UNUSED SECURITY_CTX_TYPE_MAPPED // UNUSED
} fivegmm_sc_type_t; } fivegmm_sc_type_t;
typedef struct fivegmm_security_context_s { typedef struct fivegmm_security_context_s {
fivegmm_sc_type_t sc_type; /* Type of security context */ //33401 fivegmm_sc_type_t sc_type; /* Type of security context */ // 33401
/* state of security context is implicit due to its storage location (current/non-current)*/ /* state of security context is implicit due to its storage location
* (current/non-current)*/
#define EKSI_MAX_VALUE 6 #define EKSI_MAX_VALUE 6
ksi_t ksi; /* NAS key set identifier for E-UTRAN */ ksi_t ksi; /* NAS key set identifier for E-UTRAN */
#define FIVEGMM_SECURITY_VECTOR_INDEX_INVALID (-1) #define FIVEGMM_SECURITY_VECTOR_INDEX_INVALID (-1)
int vector_index; /* Pointer on vector */ int vector_index; /* Pointer on vector */
uint8_t knas_enc[AUTH_KNAS_ENC_SIZE];/* NAS cyphering key */ uint8_t knas_enc[AUTH_KNAS_ENC_SIZE]; /* NAS cyphering key */
uint8_t knas_int[AUTH_KNAS_INT_SIZE];/* NAS integrity key */ uint8_t knas_int[AUTH_KNAS_INT_SIZE]; /* NAS integrity key */
struct count_s { struct count_s {
uint32_t spare :8; uint32_t spare : 8;
uint32_t overflow :16; uint32_t overflow : 16;
uint32_t seq_num :8; uint32_t seq_num : 8;
} dl_count, ul_count; /* Downlink and uplink count parameters */ } dl_count, ul_count; /* Downlink and uplink count parameters */
struct { struct {
uint8_t fivegs_encryption; /* algorithm used for ciphering */ uint8_t fivegs_encryption; /* algorithm used for ciphering */
uint8_t fivegs_integrity; /* algorithm used for integrity protection */ uint8_t fivegs_integrity; /* algorithm used for integrity protection */
uint8_t umts_encryption; /* algorithm used for ciphering */ uint8_t umts_encryption; /* algorithm used for ciphering */
uint8_t umts_integrity; /* algorithm used for integrity protection */ uint8_t umts_integrity; /* algorithm used for integrity protection */
uint8_t gprs_encryption; /* algorithm used for ciphering */ uint8_t gprs_encryption; /* algorithm used for ciphering */
bool umts_present :1; bool umts_present : 1;
bool gprs_present :1; bool gprs_present : 1;
} capability; /* UE network capability */ } capability; /* UE network capability */
struct { struct {
uint8_t encryption :4; /* algorithm used for ciphering */ uint8_t encryption : 4; /* algorithm used for ciphering */
uint8_t integrity :4; /* algorithm used for integrity protection */ uint8_t integrity : 4; /* algorithm used for integrity protection */
} selected_algorithms; /* AMF selected algorithms */ } selected_algorithms; /* AMF selected algorithms */
uint8_t activated; uint8_t activated;
} fivegmm_security_context_t; } fivegmm_security_context_t;
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. * file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -27,14 +27,20 @@ ...@@ -27,14 +27,20 @@
#include "TLVDecoder.h" #include "TLVDecoder.h"
#include "AuthenticationFailure.h" #include "AuthenticationFailure.h"
int decode_authentication_failure(authentication_failure_msg *authentication_failure, uint8_t *buffer, uint32_t len) { int decode_authentication_failure(
uint32_t decoded = 0; authentication_failure_msg* authentication_failure, uint8_t* buffer,
uint32_t len) {
uint32_t decoded = 0;
int decoded_result = 0; int decoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length
CHECK_PDU_POINTER_AND_LENGTH_DECODER(buffer, AUTHENTICATION_FAILURE_MINIMUM_LENGTH, len); // expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER(
buffer, AUTHENTICATION_FAILURE_MINIMUM_LENGTH, len);
if ((decoded_result = decode__5gmm_cause(&authentication_failure->_5gmmcause, 0, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode__5gmm_cause(
&authentication_failure->_5gmmcause, 0, buffer + decoded,
len - decoded)) < 0)
return decoded_result; return decoded_result;
else else
decoded += decoded_result; decoded += decoded_result;
...@@ -44,16 +50,19 @@ int decode_authentication_failure(authentication_failure_msg *authentication_fai ...@@ -44,16 +50,19 @@ int decode_authentication_failure(authentication_failure_msg *authentication_fai
*/ */
while (len - decoded > 0) { while (len - decoded > 0) {
uint8_t ieiDecoded = *(buffer + decoded); uint8_t ieiDecoded = *(buffer + decoded);
if (ieiDecoded == 0) if (ieiDecoded == 0) break;
break;
switch (ieiDecoded) { switch (ieiDecoded) {
case AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_IEI: case AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_IEI:
if ((decoded_result = decode_authentication_failure_parameter(&authentication_failure->authenticationfailureparameter, AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_IEI, buffer + decoded, len - decoded)) <= 0) if ((decoded_result = decode_authentication_failure_parameter(
&authentication_failure->authenticationfailureparameter,
AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_IEI,
buffer + decoded, len - decoded)) <= 0)
return decoded_result; return decoded_result;
else { else {
decoded += decoded_result; decoded += decoded_result;
authentication_failure->presence |= AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_PRESENT; authentication_failure->presence |=
AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_PRESENT;
} }
break; break;
} }
...@@ -62,20 +71,31 @@ int decode_authentication_failure(authentication_failure_msg *authentication_fai ...@@ -62,20 +71,31 @@ int decode_authentication_failure(authentication_failure_msg *authentication_fai
return decoded; return decoded;
} }
int encode_authentication_failure(authentication_failure_msg *authentication_failure, uint8_t *buffer, uint32_t len) { int encode_authentication_failure(
uint32_t encoded = 0; authentication_failure_msg* authentication_failure, uint8_t* buffer,
uint32_t len) {
uint32_t encoded = 0;
int encoded_result = 0; int encoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, AUTHENTICATION_FAILURE_MINIMUM_LENGTH, len); // 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; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
if ((authentication_failure->presence & AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_PRESENT) == AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_PRESENT) { if ((authentication_failure->presence &
if ((encoded_result = encode_authentication_failure_parameter(authentication_failure->authenticationfailureparameter, AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_IEI, buffer + encoded, len - encoded)) < 0) AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_PRESENT) ==
AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_PRESENT) {
if ((encoded_result = encode_authentication_failure_parameter(
authentication_failure->authenticationfailureparameter,
AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_IEI,
buffer + encoded, len - encoded)) < 0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. * file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -31,24 +31,20 @@ ...@@ -31,24 +31,20 @@
#include "AuthenticationFailureParameter.h" #include "AuthenticationFailureParameter.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */ /* Minimum length macro. Formed by minimum length of each mandatory field */
#define AUTHENTICATION_FAILURE_MINIMUM_LENGTH ( \ #define AUTHENTICATION_FAILURE_MINIMUM_LENGTH \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \ (EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
SECURITY_HEADER_TYPE_MINIMUM_LENGTH + \ SECURITY_HEADER_TYPE_MINIMUM_LENGTH + MESSAGE_TYPE_MINIMUM_LENGTH + \
MESSAGE_TYPE_MINIMUM_LENGTH + \ _5GMM_CAUSE_MINIMUM_LENGTH + \
_5GMM_CAUSE_MINIMUM_LENGTH + \ AUTHENTICATION_FAILURE_PARAMETER_MINIMUM_LENGTH + 0)
AUTHENTICATION_FAILURE_PARAMETER_MINIMUM_LENGTH + \
0)
/* Maximum length macro. Formed by maximum length of each field */ /* Maximum length macro. Formed by maximum length of each field */
#define AUTHENTICATION_FAILURE_MAXIMUM_LENGTH ( \ #define AUTHENTICATION_FAILURE_MAXIMUM_LENGTH \
EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \ (EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \
SECURITY_HEADER_TYPE_MAXIMUM_LENGTH + \ SECURITY_HEADER_TYPE_MAXIMUM_LENGTH + MESSAGE_TYPE_MAXIMUM_LENGTH + \
MESSAGE_TYPE_MAXIMUM_LENGTH + \ _5GMM_CAUSE_MAXIMUM_LENGTH + \
_5GMM_CAUSE_MAXIMUM_LENGTH + \ AUTHENTICATION_FAILURE_PARAMETER_MAXIMUM_LENGTH + 0)
AUTHENTICATION_FAILURE_PARAMETER_MAXIMUM_LENGTH + \
0)
#define AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_PRESENT (1<<0) #define AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_PRESENT (1 << 0)
#define AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_IEI 0x21 #define AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_IEI 0x21
typedef struct authentication_failure_msg_tag { typedef struct authentication_failure_msg_tag {
...@@ -60,7 +56,11 @@ typedef struct authentication_failure_msg_tag { ...@@ -60,7 +56,11 @@ typedef struct authentication_failure_msg_tag {
AuthenticationFailureParameter authenticationfailureparameter; AuthenticationFailureParameter authenticationfailureparameter;
} authentication_failure_msg; } authentication_failure_msg;
int decode_authentication_failure(authentication_failure_msg *authenticationfailure, uint8_t *buffer, uint32_t len); int decode_authentication_failure(
int encode_authentication_failure(authentication_failure_msg *authenticationfailure, uint8_t *buffer, uint32_t len); authentication_failure_msg* authenticationfailure, uint8_t* buffer,
uint32_t len);
int encode_authentication_failure(
authentication_failure_msg* authenticationfailure, uint8_t* buffer,
uint32_t len);
#endif #endif
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. * file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -27,40 +27,57 @@ ...@@ -27,40 +27,57 @@
#include "TLVDecoder.h" #include "TLVDecoder.h"
#include "AuthenticationReject.h" #include "AuthenticationReject.h"
int decode_authentication_reject(authentication_reject_msg *authentication_reject, uint8_t *buffer, uint32_t len) { int decode_authentication_reject(
uint32_t decoded = 0; authentication_reject_msg* authentication_reject, uint8_t* buffer,
uint32_t len) {
uint32_t decoded = 0;
int decoded_result = 0; int decoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length
CHECK_PDU_POINTER_AND_LENGTH_DECODER(buffer, AUTHENTICATION_REJECT_MINIMUM_LENGTH, len); // expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER(
buffer, AUTHENTICATION_REJECT_MINIMUM_LENGTH, len);
while (len - decoded > 0) { while (len - decoded > 0) {
uint8_t ieiDecoded = *(buffer + decoded); uint8_t ieiDecoded = *(buffer + decoded);
if (ieiDecoded == 0) if (ieiDecoded == 0) break;
break;
switch (ieiDecoded) { switch (ieiDecoded) {
case AUTHENTICATION_REJECT_EAP_MESSAGE_IEI: case AUTHENTICATION_REJECT_EAP_MESSAGE_IEI:
//if((decoded_result = decode_message_type (&authentication_reject->messagetype, AUTHENTICATION_REJECT_EAP_MESSAGE_IEI, buffer+decoded,len-decoded))<0) // if((decoded_result = decode_message_type
if ((decoded_result = decode_eap_message(&authentication_reject->eapmessage, AUTHENTICATION_REJECT_EAP_MESSAGE_IEI, buffer + decoded, len - decoded)) < 0) { // (&authentication_reject->messagetype,
// AUTHENTICATION_REJECT_EAP_MESSAGE_IEI, buffer+decoded,len-decoded))<0)
if ((decoded_result = decode_eap_message(
&authentication_reject->eapmessage,
AUTHENTICATION_REJECT_EAP_MESSAGE_IEI, buffer + decoded,
len - decoded)) < 0) {
return decoded_result; return decoded_result;
} else { } else {
decoded += decoded_result; decoded += decoded_result;
authentication_reject->presence |= AUTHENTICATION_REJECT_EAP_MESSAGE_PRESENT; authentication_reject->presence |=
AUTHENTICATION_REJECT_EAP_MESSAGE_PRESENT;
} }
} }
} }
return decoded; return decoded;
} }
int encode_authentication_reject(authentication_reject_msg *authentication_reject, uint8_t *buffer, uint32_t len) { int encode_authentication_reject(
uint32_t encoded = 0; authentication_reject_msg* authentication_reject, uint8_t* buffer,
uint32_t len) {
uint32_t encoded = 0;
int encoded_result = 0; int encoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, AUTHENTICATION_REJECT_MINIMUM_LENGTH, len); // 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) == AUTHENTICATION_REJECT_EAP_MESSAGE_PRESENT) { if ((authentication_reject->presence &
if ((encoded_result = encode_eap_message(authentication_reject->eapmessage, AUTHENTICATION_REJECT_EAP_MESSAGE_IEI, buffer + encoded, len - encoded)) < 0) 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; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. * file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -30,23 +30,19 @@ ...@@ -30,23 +30,19 @@
#include "EAPMessage.h" #include "EAPMessage.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */ /* Minimum length macro. Formed by minimum length of each mandatory field */
#define AUTHENTICATION_REJECT_MINIMUM_LENGTH ( \ #define AUTHENTICATION_REJECT_MINIMUM_LENGTH \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \ (EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
SECURITY_HEADER_TYPE_MINIMUM_LENGTH + \ SECURITY_HEADER_TYPE_MINIMUM_LENGTH + MESSAGE_TYPE_MINIMUM_LENGTH + \
MESSAGE_TYPE_MINIMUM_LENGTH + \ EAP_MESSAGE_MINIMUM_LENGTH + 0)
EAP_MESSAGE_MINIMUM_LENGTH + \
0)
/* Maximum length macro. Formed by maximum length of each field */ /* Maximum length macro. Formed by maximum length of each field */
#define AUTHENTICATION_REJECT_MAXIMUM_LENGTH ( \ #define AUTHENTICATION_REJECT_MAXIMUM_LENGTH \
EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \ (EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \
SECURITY_HEADER_TYPE_MAXIMUM_LENGTH + \ SECURITY_HEADER_TYPE_MAXIMUM_LENGTH + MESSAGE_TYPE_MAXIMUM_LENGTH + \
MESSAGE_TYPE_MAXIMUM_LENGTH + \ EAP_MESSAGE_MAXIMUM_LENGTH + 0)
EAP_MESSAGE_MAXIMUM_LENGTH +\
0)
#define AUTHENTICATION_REJECT_EAP_MESSAGE_IEI 0x78 #define AUTHENTICATION_REJECT_EAP_MESSAGE_IEI 0x78
#define AUTHENTICATION_REJECT_EAP_MESSAGE_PRESENT (1<<0) #define AUTHENTICATION_REJECT_EAP_MESSAGE_PRESENT (1 << 0)
typedef struct authentication_reject_msg_tag { typedef struct authentication_reject_msg_tag {
ExtendedProtocolDiscriminator extendedprotocoldiscriminator; ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
...@@ -56,7 +52,11 @@ typedef struct authentication_reject_msg_tag { ...@@ -56,7 +52,11 @@ typedef struct authentication_reject_msg_tag {
EAPMessage eapmessage; EAPMessage eapmessage;
} authentication_reject_msg; } authentication_reject_msg;
int decode_authentication_reject(authentication_reject_msg *authenticationreject, uint8_t *buffer, uint32_t len); int decode_authentication_reject(
int encode_authentication_reject(authentication_reject_msg *authenticationreject, uint8_t *buffer, uint32_t len); authentication_reject_msg* authenticationreject, uint8_t* buffer,
uint32_t len);
int encode_authentication_reject(
authentication_reject_msg* authenticationreject, uint8_t* buffer,
uint32_t len);
#endif #endif
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. * file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -28,54 +28,72 @@ ...@@ -28,54 +28,72 @@
#include "AuthenticationRequest.h" #include "AuthenticationRequest.h"
#include "3gpp_24.501.h" #include "3gpp_24.501.h"
int decode_authentication_request(authentication_request_msg *authentication_request, uint8_t *buffer, uint32_t len) { int decode_authentication_request(
uint32_t decoded = 0; authentication_request_msg* authentication_request, uint8_t* buffer,
uint32_t len) {
uint32_t decoded = 0;
int decoded_result = 0; int decoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length
CHECK_PDU_POINTER_AND_LENGTH_DECODER(buffer, AUTHENTICATION_REQUEST_MINIMUM_LENGTH, len); // expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER(
buffer, AUTHENTICATION_REQUEST_MINIMUM_LENGTH, len);
/* /*
* Decoding mandatory fields * Decoding mandatory fields
*/ */
if ((decoded_result = decode_u8_nas_key_set_identifier(&authentication_request->naskeysetidentifier, 0, *(buffer + decoded) >> 4, len - decoded)) < 0) if ((decoded_result = decode_u8_nas_key_set_identifier(
&authentication_request->naskeysetidentifier, 0,
*(buffer + decoded) >> 4, len - decoded)) < 0)
return decoded_result; return decoded_result;
decoded++; decoded++;
if ((decoded_result = decode_abba(&authentication_request->abba, 0, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_abba(
&authentication_request->abba, 0, buffer + decoded, len - decoded)) <
0)
return decoded_result; return decoded_result;
else else
decoded += decoded_result; decoded += decoded_result;
while (len - decoded > 0) { while (len - decoded > 0) {
uint8_t ieiDecoded = *(buffer + decoded); uint8_t ieiDecoded = *(buffer + decoded);
if (ieiDecoded == 0) if (ieiDecoded == 0) break;
break;
switch (ieiDecoded) { switch (ieiDecoded) {
case AUTHENTICATION_PARAMETER_RAND_IEI: case AUTHENTICATION_PARAMETER_RAND_IEI:
if ((decoded_result = decode_authentication_parameter_rand(&authentication_request->authenticationparameterrand, AUTHENTICATION_PARAMETER_RAND_IEI, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_authentication_parameter_rand(
&authentication_request->authenticationparameterrand,
AUTHENTICATION_PARAMETER_RAND_IEI, buffer + decoded,
len - decoded)) < 0)
return decoded_result; return decoded_result;
else { else {
decoded += decoded_result; decoded += decoded_result;
authentication_request->presence |= AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_RAND_PRESENT; authentication_request->presence |=
AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_RAND_PRESENT;
} }
break; break;
case AUTHENTICATION_PARAMETER_AUTN_IEI: case AUTHENTICATION_PARAMETER_AUTN_IEI:
if ((decoded_result = decode_authentication_parameter_autn(&authentication_request->authenticationparameterautn, AUTHENTICATION_PARAMETER_AUTN_IEI, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_authentication_parameter_autn(
&authentication_request->authenticationparameterautn,
AUTHENTICATION_PARAMETER_AUTN_IEI, buffer + decoded,
len - decoded)) < 0)
return decoded_result; return decoded_result;
else { else {
decoded += decoded_result; decoded += decoded_result;
authentication_request->presence |= AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_AUTN_PRESENT; authentication_request->presence |=
AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_AUTN_PRESENT;
} }
break; break;
case EAP_MESSAGE_IEI: case EAP_MESSAGE_IEI:
if ((decoded_result = decode_eap_message(&authentication_request->eapmessage, EAP_MESSAGE_IEI, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_eap_message(
&authentication_request->eapmessage, EAP_MESSAGE_IEI,
buffer + decoded, len - decoded)) < 0)
return decoded_result; return decoded_result;
else { else {
decoded += decoded_result; decoded += decoded_result;
authentication_request->presence |= AUTHENTICATION_REQUEST_EAP_MESSAGE_PRESENT; authentication_request->presence |=
AUTHENTICATION_REQUEST_EAP_MESSAGE_PRESENT;
} }
break; break;
} }
...@@ -84,35 +102,59 @@ int decode_authentication_request(authentication_request_msg *authentication_req ...@@ -84,35 +102,59 @@ int decode_authentication_request(authentication_request_msg *authentication_req
return decoded; return decoded;
} }
int encode_authentication_request(authentication_request_msg *authentication_request, uint8_t *buffer, uint32_t len) { int encode_authentication_request(
uint32_t encoded = 0; authentication_request_msg* authentication_request, uint8_t* buffer,
uint32_t len) {
uint32_t encoded = 0;
int encoded_result = 0; int encoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, AUTHENTICATION_REQUEST_MINIMUM_LENGTH, len); // expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(
buffer, AUTHENTICATION_REQUEST_MINIMUM_LENGTH, len);
*(buffer + encoded) = ((encode_u8_nas_key_set_identifier(&authentication_request->naskeysetidentifier) & 0x0f) << 4) | 0x00; *(buffer + encoded) = ((encode_u8_nas_key_set_identifier(
&authentication_request->naskeysetidentifier) &
0x0f)
<< 4) |
0x00;
encoded++; encoded++;
if ((encoded_result = encode_abba(authentication_request->abba, 0, buffer + encoded, len - encoded)) < 0) if ((encoded_result = encode_abba(
authentication_request->abba, 0, buffer + encoded, len - encoded)) <
0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
if ((authentication_request->presence & AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_RAND_PRESENT) == AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_RAND_PRESENT) { if ((authentication_request->presence &
if ((encoded_result = encode_authentication_parameter_rand(authentication_request->authenticationparameterrand, AUTHENTICATION_PARAMETER_RAND_IEI, buffer + encoded, len - encoded)) < 0) AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_RAND_PRESENT) ==
AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_RAND_PRESENT) {
if ((encoded_result = encode_authentication_parameter_rand(
authentication_request->authenticationparameterrand,
AUTHENTICATION_PARAMETER_RAND_IEI, buffer + encoded,
len - encoded)) < 0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
} }
if ((authentication_request->presence & AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_AUTN_PRESENT) == AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_AUTN_PRESENT) { if ((authentication_request->presence &
if ((encoded_result = encode_authentication_parameter_autn(authentication_request->authenticationparameterautn, AUTHENTICATION_PARAMETER_AUTN_IEI, buffer + encoded, len - encoded)) < 0) AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_AUTN_PRESENT) ==
AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_AUTN_PRESENT) {
if ((encoded_result = encode_authentication_parameter_autn(
authentication_request->authenticationparameterautn,
AUTHENTICATION_PARAMETER_AUTN_IEI, buffer + encoded,
len - encoded)) < 0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
} }
if ((authentication_request->presence & AUTHENTICATION_REQUEST_EAP_MESSAGE_PRESENT) == AUTHENTICATION_REQUEST_EAP_MESSAGE_PRESENT) { if ((authentication_request->presence &
if ((encoded_result = encode_eap_message(authentication_request->eapmessage, EAP_MESSAGE_IEI, buffer + encoded, len - encoded)) < 0) AUTHENTICATION_REQUEST_EAP_MESSAGE_PRESENT) ==
AUTHENTICATION_REQUEST_EAP_MESSAGE_PRESENT) {
if ((encoded_result = encode_eap_message(
authentication_request->eapmessage, EAP_MESSAGE_IEI,
buffer + encoded, len - encoded)) < 0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. * file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -34,38 +34,33 @@ ...@@ -34,38 +34,33 @@
#include "EAPMessage.h" #include "EAPMessage.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */ /* Minimum length macro. Formed by minimum length of each mandatory field */
#define AUTHENTICATION_REQUEST_MINIMUM_LENGTH ( \ #define AUTHENTICATION_REQUEST_MINIMUM_LENGTH \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \ (EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
SECURITY_HEADER_TYPE_MINIMUM_LENGTH + \ SECURITY_HEADER_TYPE_MINIMUM_LENGTH + MESSAGE_TYPE_MINIMUM_LENGTH + \
MESSAGE_TYPE_MINIMUM_LENGTH + \ ABBA_MINIMUM_LENGTH + NAS_KEY_SET_IDENTIFIER_MINIMUM_LENGTH + 0)
ABBA_MINIMUM_LENGTH +\
NAS_KEY_SET_IDENTIFIER_MINIMUM_LENGTH + \
0)
/* /*
AUTHENTICATION_PARAMETER_RAND_MINIMUM_LENGTH + \ AUTHENTICATION_PARAMETER_RAND_MINIMUM_LENGTH + \
AUTHENTICATION_PARAMETER_AUTN_MINIMUM_LENGTH + \ AUTHENTICATION_PARAMETER_AUTN_MINIMUM_LENGTH + \
EAP_MESSAGE_MINIMUM_LENGTH + EAP_MESSAGE_MINIMUM_LENGTH +
0) 0)
*/ */
/* Maximum length macro. Formed by maximum length of each field */ /* Maximum length macro. Formed by maximum length of each field */
#define AUTHENTICATION_REQUEST_MAXIMUM_LENGTH ( \ #define AUTHENTICATION_REQUEST_MAXIMUM_LENGTH \
EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \ (EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \
SECURITY_HEADER_TYPE_MAXIMUM_LENGTH + \ SECURITY_HEADER_TYPE_MAXIMUM_LENGTH + MESSAGE_TYPE_MAXIMUM_LENGTH + \
MESSAGE_TYPE_MAXIMUM_LENGTH + \ NAS_KEY_SET_IDENTIFIER_MAXIMUM_LENGTH + \
NAS_KEY_SET_IDENTIFIER_MAXIMUM_LENGTH + \ AUTHENTICATION_PARAMETER_RAND_MAXIMUM_LENGTH + \
AUTHENTICATION_PARAMETER_RAND_MAXIMUM_LENGTH + \ AUTHENTICATION_PARAMETER_AUTN_MAXIMUM_LENGTH + EAP_MESSAGE_MAXIMUM_LENGTH + \
AUTHENTICATION_PARAMETER_AUTN_MAXIMUM_LENGTH + \ 0)
EAP_MESSAGE_MAXIMUM_LENGTH + \
0)
#define AUTHENTICATION_PARAMETER_RAND_IEI 0x21 #define AUTHENTICATION_PARAMETER_RAND_IEI 0x21
#define AUTHENTICATION_PARAMETER_AUTN_IEI 0x20 #define AUTHENTICATION_PARAMETER_AUTN_IEI 0x20
#define EAP_MESSAGE_IEI 0x78 #define EAP_MESSAGE_IEI 0x78
#define AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_RAND_PRESENT (1<<0) #define AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_RAND_PRESENT (1 << 0)
#define AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_AUTN_PRESENT (1<<1) #define AUTHENTICATION_REQUEST_AUTHENTICATION_PARAMETER_AUTN_PRESENT (1 << 1)
#define AUTHENTICATION_REQUEST_EAP_MESSAGE_PRESENT (1<<2) #define AUTHENTICATION_REQUEST_EAP_MESSAGE_PRESENT (1 << 2)
typedef struct authentication_request_msg_tag { typedef struct authentication_request_msg_tag {
ExtendedProtocolDiscriminator extendedprotocoldiscriminator; ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
...@@ -79,7 +74,11 @@ typedef struct authentication_request_msg_tag { ...@@ -79,7 +74,11 @@ typedef struct authentication_request_msg_tag {
EAPMessage eapmessage; EAPMessage eapmessage;
} authentication_request_msg; } authentication_request_msg;
int decode_authentication_request(authentication_request_msg *authenticationrequest, uint8_t *buffer, uint32_t len); int decode_authentication_request(
int encode_authentication_request(authentication_request_msg *authenticationrequest, uint8_t *buffer, uint32_t len); authentication_request_msg* authenticationrequest, uint8_t* buffer,
uint32_t len);
int encode_authentication_request(
authentication_request_msg* authenticationrequest, uint8_t* buffer,
uint32_t len);
#endif #endif
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. * file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -27,61 +27,90 @@ ...@@ -27,61 +27,90 @@
#include "TLVDecoder.h" #include "TLVDecoder.h"
#include "AuthenticationResponse.h" #include "AuthenticationResponse.h"
int decode_authentication_response(authentication_response_msg *authentication_response, uint8_t *buffer, uint32_t len) { int decode_authentication_response(
uint32_t decoded = 0; authentication_response_msg* authentication_response, uint8_t* buffer,
uint32_t len) {
uint32_t decoded = 0;
int decoded_result = 0; int decoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length
CHECK_PDU_POINTER_AND_LENGTH_DECODER(buffer, AUTHENTICATION_RESPONSE_MINIMUM_LENGTH, len); // expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER(
buffer, AUTHENTICATION_RESPONSE_MINIMUM_LENGTH, len);
while (len - decoded > 0) { while (len - decoded > 0) {
uint8_t ieiDecoded = *(buffer + decoded); uint8_t ieiDecoded = *(buffer + decoded);
printf("ieiDecoded(%x)\n", ieiDecoded); printf("ieiDecoded(%x)\n", ieiDecoded);
if (ieiDecoded != AUTHENTICATION_RESPONSE_AUTHENTICATION_RESPONSE_PARAMETER_IEI && ieiDecoded != AUTHENTICATION_RESPONSE_EAP_MESSAGE_IEI) if (ieiDecoded !=
AUTHENTICATION_RESPONSE_AUTHENTICATION_RESPONSE_PARAMETER_IEI &&
ieiDecoded != AUTHENTICATION_RESPONSE_EAP_MESSAGE_IEI)
break; break;
switch (ieiDecoded) { switch (ieiDecoded) {
case AUTHENTICATION_RESPONSE_AUTHENTICATION_RESPONSE_PARAMETER_IEI: case AUTHENTICATION_RESPONSE_AUTHENTICATION_RESPONSE_PARAMETER_IEI:
printf("decoding AUTHENTICATION_RESPONSE_AUTHENTICATION_RESPONSE_PARAMETER_IEI\n"); printf(
if ((decoded_result = decode_authentication_response_parameter(&authentication_response->authenticationresponseparameter, AUTHENTICATION_RESPONSE_AUTHENTICATION_RESPONSE_PARAMETER_IEI, buffer + decoded, len - decoded)) < 0) "decoding "
"AUTHENTICATION_RESPONSE_AUTHENTICATION_RESPONSE_PARAMETER_IEI\n");
if ((decoded_result = decode_authentication_response_parameter(
&authentication_response->authenticationresponseparameter,
AUTHENTICATION_RESPONSE_AUTHENTICATION_RESPONSE_PARAMETER_IEI,
buffer + decoded, len - decoded)) < 0)
return decoded_result; return decoded_result;
else { else {
decoded += decoded_result; decoded += decoded_result;
printf("decoded(%d)\n", decoded); printf("decoded(%d)\n", decoded);
authentication_response->presence |= AUTHENTICATION_RESPONSE_AUTNENTICATION_RESPONSE_PARAMETER_PRESENT; authentication_response->presence |=
AUTHENTICATION_RESPONSE_AUTNENTICATION_RESPONSE_PARAMETER_PRESENT;
} }
break; break;
case AUTHENTICATION_RESPONSE_EAP_MESSAGE_IEI: case AUTHENTICATION_RESPONSE_EAP_MESSAGE_IEI:
if ((decoded_result = decode_eap_message(&authentication_response->eapmessage, AUTHENTICATION_RESPONSE_EAP_MESSAGE_IEI, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_eap_message(
&authentication_response->eapmessage,
AUTHENTICATION_RESPONSE_EAP_MESSAGE_IEI, buffer + decoded,
len - decoded)) < 0)
return decoded_result; return decoded_result;
else { else {
decoded += decoded_result; decoded += decoded_result;
authentication_response->presence |= AUTHENTICATION_RESPONSE_EAP_MESSAGE_PRESENT; authentication_response->presence |=
AUTHENTICATION_RESPONSE_EAP_MESSAGE_PRESENT;
} }
break; break;
} }
} }
return decoded; return decoded;
} }
int encode_authentication_response(authentication_response_msg *authentication_response, uint8_t *buffer, uint32_t len) { int encode_authentication_response(
uint32_t encoded = 0; authentication_response_msg* authentication_response, uint8_t* buffer,
uint32_t len) {
uint32_t encoded = 0;
int encoded_result = 0; int encoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, AUTHENTICATION_RESPONSE_MINIMUM_LENGTH, len); // expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(
buffer, AUTHENTICATION_RESPONSE_MINIMUM_LENGTH, len);
if ((authentication_response->presence & AUTHENTICATION_RESPONSE_AUTNENTICATION_RESPONSE_PARAMETER_PRESENT) == AUTHENTICATION_RESPONSE_AUTNENTICATION_RESPONSE_PARAMETER_PRESENT) { if ((authentication_response->presence &
if ((encoded_result = encode_authentication_response_parameter(authentication_response->authenticationresponseparameter, AUTHENTICATION_RESPONSE_AUTHENTICATION_RESPONSE_PARAMETER_IEI, buffer + encoded, len - encoded)) < 0) 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; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
} }
if ((authentication_response->presence & AUTHENTICATION_RESPONSE_EAP_MESSAGE_PRESENT) == AUTHENTICATION_RESPONSE_EAP_MESSAGE_PRESENT) { if ((authentication_response->presence &
if ((encoded_result = encode_eap_message(authentication_response->eapmessage, AUTHENTICATION_RESPONSE_EAP_MESSAGE_IEI, buffer + encoded, len - encoded)) < 0) 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; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. * file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -31,28 +31,25 @@ ...@@ -31,28 +31,25 @@
#include "EAPMessage.h" #include "EAPMessage.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */ /* Minimum length macro. Formed by minimum length of each mandatory field */
#define AUTHENTICATION_RESPONSE_MINIMUM_LENGTH ( \ #define AUTHENTICATION_RESPONSE_MINIMUM_LENGTH \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \ (EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
SECURITY_HEADER_TYPE_MINIMUM_LENGTH + \ SECURITY_HEADER_TYPE_MINIMUM_LENGTH + MESSAGE_TYPE_MINIMUM_LENGTH + \
MESSAGE_TYPE_MINIMUM_LENGTH + \ AUTHENTICATION_RESPONSE_PARAMETER_MINIMUM_LENGTH + \
AUTHENTICATION_RESPONSE_PARAMETER_MINIMUM_LENGTH + \ EAP_MESSAGE_MINIMUM_LENGTH + 0)
EAP_MESSAGE_MINIMUM_LENGTH + \
0)
/* Maximum length macro. Formed by maximum length of each field */ /* Maximum length macro. Formed by maximum length of each field */
#define AUTHENTICATION_RESPONSE_MAXIMUM_LENGTH ( \ #define AUTHENTICATION_RESPONSE_MAXIMUM_LENGTH \
EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \ (EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \
SECURITY_HEADER_TYPE_MAXIMUM_LENGTH + \ SECURITY_HEADER_TYPE_MAXIMUM_LENGTH + MESSAGE_TYPE_MAXIMUM_LENGTH + \
MESSAGE_TYPE_MAXIMUM_LENGTH + \ AUTHENTICATION_RESPONSE_PARAMETER_MAXIMUM_LENGTH + \
AUTHENTICATION_RESPONSE_PARAMETER_MAXIMUM_LENGTH + \ EAP_MESSAGE_MAXIMUM_LENGTH + 0)
EAP_MESSAGE_MAXIMUM_LENGTH + \
0)
#define AUTHENTICATION_RESPONSE_AUTHENTICATION_RESPONSE_PARAMETER_IEI 0x2d #define AUTHENTICATION_RESPONSE_AUTHENTICATION_RESPONSE_PARAMETER_IEI 0x2d
#define AUTHENTICATION_RESPONSE_EAP_MESSAGE_IEI 0x78 #define AUTHENTICATION_RESPONSE_EAP_MESSAGE_IEI 0x78
#define AUTHENTICATION_RESPONSE_AUTNENTICATION_RESPONSE_PARAMETER_PRESENT (1<<0) #define AUTHENTICATION_RESPONSE_AUTNENTICATION_RESPONSE_PARAMETER_PRESENT \
#define AUTHENTICATION_RESPONSE_EAP_MESSAGE_PRESENT (1<<1) (1 << 0)
#define AUTHENTICATION_RESPONSE_EAP_MESSAGE_PRESENT (1 << 1)
typedef struct authentication_response_msg_tag { typedef struct authentication_response_msg_tag {
ExtendedProtocolDiscriminator extendedprotocoldiscriminator; ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
...@@ -63,7 +60,11 @@ typedef struct authentication_response_msg_tag { ...@@ -63,7 +60,11 @@ typedef struct authentication_response_msg_tag {
EAPMessage eapmessage; EAPMessage eapmessage;
} authentication_response_msg; } authentication_response_msg;
int decode_authentication_response(authentication_response_msg *authenticationresponse, uint8_t *buffer, uint32_t len); int decode_authentication_response(
int encode_authentication_response(authentication_response_msg *authenticationresponse, uint8_t *buffer, uint32_t len); authentication_response_msg* authenticationresponse, uint8_t* buffer,
uint32_t len);
int encode_authentication_response(
authentication_response_msg* authenticationresponse, uint8_t* buffer,
uint32_t len);
#endif #endif
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. * file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -27,18 +27,26 @@ ...@@ -27,18 +27,26 @@
#include "TLVDecoder.h" #include "TLVDecoder.h"
#include "AuthenticationResult.h" #include "AuthenticationResult.h"
int decode_authentication_result(authentication_result_msg *authentication_result, uint8_t *buffer, uint32_t len) { int decode_authentication_result(
uint32_t decoded = 0; authentication_result_msg* authentication_result, uint8_t* buffer,
uint32_t len) {
uint32_t decoded = 0;
int decoded_result = 0; int decoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length
CHECK_PDU_POINTER_AND_LENGTH_DECODER(buffer, AUTHENTICATION_RESULT_MINIMUM_LENGTH, len); // expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER(
buffer, AUTHENTICATION_RESULT_MINIMUM_LENGTH, len);
if ((decoded_result = decode_u8_nas_key_set_identifier(&authentication_result->naskeysetidentifier, 0, *(buffer + decoded) >> 4, len - decoded)) < 0) if ((decoded_result = decode_u8_nas_key_set_identifier(
&authentication_result->naskeysetidentifier, 0,
*(buffer + decoded) >> 4, len - decoded)) < 0)
return decoded_result; return decoded_result;
decoded++; decoded++;
if ((decoded_result = decode_eap_message(&authentication_result->eapmessage, 0, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_eap_message(
&authentication_result->eapmessage, 0, buffer + decoded,
len - decoded)) < 0)
return decoded_result; return decoded_result;
else else
decoded += decoded_result; decoded += decoded_result;
...@@ -46,11 +54,12 @@ int decode_authentication_result(authentication_result_msg *authentication_resul ...@@ -46,11 +54,12 @@ int decode_authentication_result(authentication_result_msg *authentication_resul
while (len - decoded > 0) { while (len - decoded > 0) {
uint8_t ieiDecoded = *(buffer + decoded); uint8_t ieiDecoded = *(buffer + decoded);
printf("ieiDecoded:0x%x\n", ieiDecoded); printf("ieiDecoded:0x%x\n", ieiDecoded);
if (ieiDecoded == 0) if (ieiDecoded == 0) break;
break;
switch (ieiDecoded) { switch (ieiDecoded) {
case AUTHENTICATION_RESULT_ABBA_IEI: case AUTHENTICATION_RESULT_ABBA_IEI:
if ((decoded_result = decode_abba(&authentication_result->abba, AUTHENTICATION_RESULT_ABBA_IEI, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_abba(
&authentication_result->abba, AUTHENTICATION_RESULT_ABBA_IEI,
buffer + decoded, len - decoded)) < 0)
return decoded_result; return decoded_result;
else { else {
decoded += decoded_result; decoded += decoded_result;
...@@ -59,39 +68,50 @@ int decode_authentication_result(authentication_result_msg *authentication_resul ...@@ -59,39 +68,50 @@ int decode_authentication_result(authentication_result_msg *authentication_resul
} }
} }
/* /*
if ((decoded_result = decode_abba (&authentication_result->abba,0 , buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_abba (&authentication_result->abba,0 , buffer +
return decoded_result; decoded, len - decoded)) < 0) return decoded_result; else decoded +=
else decoded_result;
decoded += decoded_result;
*/ */
return decoded; return decoded;
} }
int encode_authentication_result(authentication_result_msg *authentication_result, uint8_t *buffer, uint32_t len) { int encode_authentication_result(
uint32_t encoded = 0; authentication_result_msg* authentication_result, uint8_t* buffer,
uint32_t len) {
uint32_t encoded = 0;
int encoded_result = 0; int encoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, AUTHENTICATION_RESULT_MINIMUM_LENGTH, len); // expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(
buffer, AUTHENTICATION_RESULT_MINIMUM_LENGTH, len);
*(buffer + encoded) = ((encode_u8_nas_key_set_identifier(&authentication_result->naskeysetidentifier) & 0x0f) << 4) | 0x00; *(buffer + encoded) = ((encode_u8_nas_key_set_identifier(
&authentication_result->naskeysetidentifier) &
0x0f)
<< 4) |
0x00;
encoded++; encoded++;
if ((encoded_result = encode_eap_message(authentication_result->eapmessage, 0, buffer + encoded, len - encoded)) < 0) if ((encoded_result = encode_eap_message(
authentication_result->eapmessage, 0, buffer + encoded,
len - encoded)) < 0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
if ((authentication_result->presence & AUTHENTICATION_RESULT_ABBA_PRESENT) == AUTHENTICATION_RESULT_ABBA_PRESENT) { if ((authentication_result->presence & AUTHENTICATION_RESULT_ABBA_PRESENT) ==
if ((encoded_result = encode_abba(authentication_result->abba, AUTHENTICATION_RESULT_ABBA_IEI, buffer + encoded, len - encoded)) < 0) AUTHENTICATION_RESULT_ABBA_PRESENT) {
if ((encoded_result = encode_abba(
authentication_result->abba, AUTHENTICATION_RESULT_ABBA_IEI,
buffer + encoded, len - encoded)) < 0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
} }
/* /*
if((encoded_result = encode_abba (authentication_result->abba,0, buffer+encoded,len-encoded))<0) if((encoded_result = encode_abba (authentication_result->abba,0,
return encoded_result; buffer+encoded,len-encoded))<0) return encoded_result; else
else
encoded+=encoded_result; encoded+=encoded_result;
*/ */
return encoded; return encoded;
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. * file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -32,26 +32,20 @@ ...@@ -32,26 +32,20 @@
#include "ABBA.h" #include "ABBA.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */ /* Minimum length macro. Formed by minimum length of each mandatory field */
#define AUTHENTICATION_RESULT_MINIMUM_LENGTH ( \ #define AUTHENTICATION_RESULT_MINIMUM_LENGTH \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \ (EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
SECURITY_HEADER_TYPE_MINIMUM_LENGTH + \ SECURITY_HEADER_TYPE_MINIMUM_LENGTH + MESSAGE_TYPE_MINIMUM_LENGTH + \
MESSAGE_TYPE_MINIMUM_LENGTH + \ NAS_KEY_SET_IDENTIFIER_MINIMUM_LENGTH + EAP_MESSAGE_MINIMUM_LENGTH + \
NAS_KEY_SET_IDENTIFIER_MINIMUM_LENGTH + \ ABBA_MINIMUM_LENGTH + 0)
EAP_MESSAGE_MINIMUM_LENGTH + \
ABBA_MINIMUM_LENGTH + \
0)
/* Maximum length macro. Formed by maximum length of each field */ /* Maximum length macro. Formed by maximum length of each field */
#define AUTHENTICATION_RESULT_MAXIMUM_LENGTH ( \ #define AUTHENTICATION_RESULT_MAXIMUM_LENGTH \
EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \ (EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \
SECURITY_HEADER_TYPE_MAXIMUM_LENGTH + \ SECURITY_HEADER_TYPE_MAXIMUM_LENGTH + MESSAGE_TYPE_MAXIMUM_LENGTH + \
MESSAGE_TYPE_MAXIMUM_LENGTH + \ NAS_KEY_SET_IDENTIFIER_MAXIMUM_LENGTH + EAP_MESSAGE_MAXIMUM_LENGTH + 0)
NAS_KEY_SET_IDENTIFIER_MAXIMUM_LENGTH + \
EAP_MESSAGE_MAXIMUM_LENGTH + \
0)
#define AUTHENTICATION_RESULT_ABBA_IEI 0x38 #define AUTHENTICATION_RESULT_ABBA_IEI 0x38
#define AUTHENTICATION_RESULT_ABBA_PRESENT (1<<0) #define AUTHENTICATION_RESULT_ABBA_PRESENT (1 << 0)
typedef struct authentication_result_msg_tag { typedef struct authentication_result_msg_tag {
ExtendedProtocolDiscriminator extendedprotocoldiscriminator; ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
...@@ -63,7 +57,11 @@ typedef struct authentication_result_msg_tag { ...@@ -63,7 +57,11 @@ typedef struct authentication_result_msg_tag {
ABBA abba; ABBA abba;
} authentication_result_msg; } authentication_result_msg;
int decode_authentication_result(authentication_result_msg *authenticationresult, uint8_t *buffer, uint32_t len); int decode_authentication_result(
int encode_authentication_result(authentication_result_msg *authenticationresult, uint8_t *buffer, uint32_t len); authentication_result_msg* authenticationresult, uint8_t* buffer,
uint32_t len);
int encode_authentication_result(
authentication_result_msg* authenticationresult, uint8_t* buffer,
uint32_t len);
#endif #endif
This diff is collapsed.
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. * file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -44,48 +44,34 @@ ...@@ -44,48 +44,34 @@
#include "SMSIndication.h" #include "SMSIndication.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */ /* Minimum length macro. Formed by minimum length of each mandatory field */
#define CONFIGURATION_UPDATE_COMMAND_MINIMUM_LENGTH ( \ #define CONFIGURATION_UPDATE_COMMAND_MINIMUM_LENGTH \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \ (EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
SECURITY_HEADER_TYPE_MINIMUM_LENGTH + \ SECURITY_HEADER_TYPE_MINIMUM_LENGTH + MESSAGE_TYPE_MINIMUM_LENGTH + \
MESSAGE_TYPE_MINIMUM_LENGTH + \ CONFIGURATION_UPDATE_INDICATION_MINIMUM_LENGTH + \
CONFIGURATION_UPDATE_INDICATION_MINIMUM_LENGTH + \ _5GS_MOBILE_IDENTITY_MINIMUM_LENGTH + \
_5GS_MOBILE_IDENTITY_MINIMUM_LENGTH + \ _5GS_TRACKING_AREA_IDENTITY_LIST_MINIMUM_LENGTH + NSSAI_MINIMUM_LENGTH + \
_5GS_TRACKING_AREA_IDENTITY_LIST_MINIMUM_LENGTH + \ SERVICE_AREA_LIST_MINIMUM_LENGTH + NETWORK_NAME_MINIMUM_LENGTH + \
NSSAI_MINIMUM_LENGTH + \ TIME_ZONE_MINIMUM_LENGTH + TIME_ZONE_AND_TIME_MINIMUM_LENGTH + \
SERVICE_AREA_LIST_MINIMUM_LENGTH + \ DAYLIGHT_SAVING_TIME_MINIMUM_LENGTH + LADN_INFORMATION_MINIMUM_LENGTH + \
NETWORK_NAME_MINIMUM_LENGTH + \ MICO_INDICATION_MINIMUM_LENGTH + \
TIME_ZONE_MINIMUM_LENGTH + \ NETWORK_SLICING_INDICATION_MINIMUM_LENGTH + REJECTED_NSSAI_MINIMUM_LENGTH + \
TIME_ZONE_AND_TIME_MINIMUM_LENGTH + \ OPERATOR_DEFINED_ACCESS_CATEGORY_DEFINITIONS_MINIMUM_LENGTH + \
DAYLIGHT_SAVING_TIME_MINIMUM_LENGTH + \ SMS_INDICATION_MINIMUM_LENGTH + 0)
LADN_INFORMATION_MINIMUM_LENGTH + \
MICO_INDICATION_MINIMUM_LENGTH + \
NETWORK_SLICING_INDICATION_MINIMUM_LENGTH + \
REJECTED_NSSAI_MINIMUM_LENGTH + \
OPERATOR_DEFINED_ACCESS_CATEGORY_DEFINITIONS_MINIMUM_LENGTH + \
SMS_INDICATION_MINIMUM_LENGTH + \
0)
/* Maximum length macro. Formed by maximum length of each field */ /* Maximum length macro. Formed by maximum length of each field */
#define CONFIGURATION_UPDATE_COMMAND_MAXIMUM_LENGTH ( \ #define CONFIGURATION_UPDATE_COMMAND_MAXIMUM_LENGTH \
EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \ (EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \
SECURITY_HEADER_TYPE_MAXIMUM_LENGTH + \ SECURITY_HEADER_TYPE_MAXIMUM_LENGTH + MESSAGE_TYPE_MAXIMUM_LENGTH + \
MESSAGE_TYPE_MAXIMUM_LENGTH + \ CONFIGURATION_UPDATE_INDICATION_MAXIMUM_LENGTH + \
CONFIGURATION_UPDATE_INDICATION_MAXIMUM_LENGTH + \ _5GS_MOBILE_IDENTITY_MAXIMUM_LENGTH + \
_5GS_MOBILE_IDENTITY_MAXIMUM_LENGTH + \ _5GS_TRACKING_AREA_IDENTITY_LIST_MAXIMUM_LENGTH + NSSAI_MAXIMUM_LENGTH + \
_5GS_TRACKING_AREA_IDENTITY_LIST_MAXIMUM_LENGTH + \ SERVICE_AREA_LIST_MAXIMUM_LENGTH + NETWORK_NAME_MAXIMUM_LENGTH + \
NSSAI_MAXIMUM_LENGTH + \ TIME_ZONE_MAXIMUM_LENGTH + TIME_ZONE_AND_TIME_MAXIMUM_LENGTH + \
SERVICE_AREA_LIST_MAXIMUM_LENGTH + \ DAYLIGHT_SAVING_TIME_MAXIMUM_LENGTH + LADN_INFORMATION_MAXIMUM_LENGTH + \
NETWORK_NAME_MAXIMUM_LENGTH + \ MICO_INDICATION_MAXIMUM_LENGTH + \
TIME_ZONE_MAXIMUM_LENGTH + \ NETWORK_SLICING_INDICATION_MAXIMUM_LENGTH + REJECTED_NSSAI_MAXIMUM_LENGTH + \
TIME_ZONE_AND_TIME_MAXIMUM_LENGTH + \ OPERATOR_DEFINED_ACCESS_CATEGORY_DEFINITIONS_MAXIMUM_LENGTH + \
DAYLIGHT_SAVING_TIME_MAXIMUM_LENGTH + \ SMS_INDICATION_MAXIMUM_LENGTH + 0)
LADN_INFORMATION_MAXIMUM_LENGTH + \
MICO_INDICATION_MAXIMUM_LENGTH + \
NETWORK_SLICING_INDICATION_MAXIMUM_LENGTH + \
REJECTED_NSSAI_MAXIMUM_LENGTH + \
OPERATOR_DEFINED_ACCESS_CATEGORY_DEFINITIONS_MAXIMUM_LENGTH + \
SMS_INDICATION_MAXIMUM_LENGTH + \
0)
typedef struct configuration_update_command_msg_tag { typedef struct configuration_update_command_msg_tag {
ExtendedProtocolDiscriminator extendedprotocoldiscriminator; ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
...@@ -104,11 +90,16 @@ typedef struct configuration_update_command_msg_tag { ...@@ -104,11 +90,16 @@ typedef struct configuration_update_command_msg_tag {
MICOIndication micoindication; MICOIndication micoindication;
NetworkSlicingIndication networkslicingindication; NetworkSlicingIndication networkslicingindication;
RejectedNSSAI rejectednssai; RejectedNSSAI rejectednssai;
OperatorDefinedAccessCategoryDefinitions operatordefinedaccesscategorydefinitions; OperatorDefinedAccessCategoryDefinitions
operatordefinedaccesscategorydefinitions;
SMSIndication smsindication; SMSIndication smsindication;
} configuration_update_command_msg; } configuration_update_command_msg;
int decode_configuration_update_command(configuration_update_command_msg *configurationupdatecommand, uint8_t *buffer, uint32_t len); int decode_configuration_update_command(
int encode_configuration_update_command(configuration_update_command_msg *configurationupdatecommand, uint8_t *buffer, uint32_t len); configuration_update_command_msg* configurationupdatecommand,
uint8_t* buffer, uint32_t len);
int encode_configuration_update_command(
configuration_update_command_msg* configurationupdatecommand,
uint8_t* buffer, uint32_t len);
#endif #endif
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. * file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -27,24 +27,34 @@ ...@@ -27,24 +27,34 @@
#include "TLVDecoder.h" #include "TLVDecoder.h"
#include "ConfigurationUpdateComplete.h" #include "ConfigurationUpdateComplete.h"
int decode_configuration_update_complete(configuration_update_complete_msg *configuration_update_complete, uint8_t *buffer, uint32_t len) { int decode_configuration_update_complete(
uint32_t decoded = 0; configuration_update_complete_msg* configuration_update_complete,
uint8_t* buffer, uint32_t len) {
uint32_t decoded = 0;
int decoded_result = 0; int decoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length
CHECK_PDU_POINTER_AND_LENGTH_DECODER(buffer, CONFIGURATION_UPDATE_COMPLETE_MINIMUM_LENGTH, len); // expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER(
buffer, CONFIGURATION_UPDATE_COMPLETE_MINIMUM_LENGTH, len);
if ((decoded_result = decode_extended_protocol_discriminator(&configuration_update_complete->extendedprotocoldiscriminator, 0, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_extended_protocol_discriminator(
&configuration_update_complete->extendedprotocoldiscriminator, 0,
buffer + decoded, len - decoded)) < 0)
return decoded_result; return decoded_result;
else else
decoded += decoded_result; decoded += decoded_result;
if ((decoded_result = decode_security_header_type(&configuration_update_complete->securityheadertype, 0, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_security_header_type(
&configuration_update_complete->securityheadertype, 0,
buffer + decoded, len - decoded)) < 0)
return decoded_result; return decoded_result;
else else
decoded += decoded_result; decoded += decoded_result;
if ((decoded_result = decode_message_type(&configuration_update_complete->messagetype, 0, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_message_type(
&configuration_update_complete->messagetype, 0, buffer + decoded,
len - decoded)) < 0)
return decoded_result; return decoded_result;
else else
decoded += decoded_result; decoded += decoded_result;
...@@ -52,24 +62,34 @@ int decode_configuration_update_complete(configuration_update_complete_msg *conf ...@@ -52,24 +62,34 @@ int decode_configuration_update_complete(configuration_update_complete_msg *conf
return decoded; return decoded;
} }
int encode_configuration_update_complete(configuration_update_complete_msg *configuration_update_complete, uint8_t *buffer, uint32_t len) { int encode_configuration_update_complete(
uint32_t encoded = 0; configuration_update_complete_msg* configuration_update_complete,
uint8_t* buffer, uint32_t len) {
uint32_t encoded = 0;
int encoded_result = 0; int encoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, CONFIGURATION_UPDATE_COMPLETE_MINIMUM_LENGTH, len); // expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(
buffer, CONFIGURATION_UPDATE_COMPLETE_MINIMUM_LENGTH, len);
if ((encoded_result = encode_extended_protocol_discriminator(configuration_update_complete->extendedprotocoldiscriminator, 0, buffer + encoded, len - encoded)) < 0) if ((encoded_result = encode_extended_protocol_discriminator(
configuration_update_complete->extendedprotocoldiscriminator, 0,
buffer + encoded, len - encoded)) < 0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
if ((encoded_result = encode_security_header_type(configuration_update_complete->securityheadertype, 0, buffer + encoded, len - encoded)) < 0) if ((encoded_result = encode_security_header_type(
configuration_update_complete->securityheadertype, 0,
buffer + encoded, len - encoded)) < 0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
if ((encoded_result = encode_message_type(configuration_update_complete->messagetype, 0, buffer + encoded, len - encoded)) < 0) if ((encoded_result = encode_message_type(
configuration_update_complete->messagetype, 0, buffer + encoded,
len - encoded)) < 0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. * file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -29,18 +29,14 @@ ...@@ -29,18 +29,14 @@
#include "MessageType.h" #include "MessageType.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */ /* Minimum length macro. Formed by minimum length of each mandatory field */
#define CONFIGURATION_UPDATE_COMPLETE_MINIMUM_LENGTH ( \ #define CONFIGURATION_UPDATE_COMPLETE_MINIMUM_LENGTH \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \ (EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
SECURITY_HEADER_TYPE_MINIMUM_LENGTH + \ SECURITY_HEADER_TYPE_MINIMUM_LENGTH + MESSAGE_TYPE_MINIMUM_LENGTH + 0)
MESSAGE_TYPE_MINIMUM_LENGTH + \
0)
/* Maximum length macro. Formed by maximum length of each field */ /* Maximum length macro. Formed by maximum length of each field */
#define CONFIGURATION_UPDATE_COMPLETE_MAXIMUM_LENGTH ( \ #define CONFIGURATION_UPDATE_COMPLETE_MAXIMUM_LENGTH \
EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \ (EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \
SECURITY_HEADER_TYPE_MAXIMUM_LENGTH + \ SECURITY_HEADER_TYPE_MAXIMUM_LENGTH + MESSAGE_TYPE_MAXIMUM_LENGTH + 0)
MESSAGE_TYPE_MAXIMUM_LENGTH + \
0)
typedef struct configuration_update_complete_msg_tag { typedef struct configuration_update_complete_msg_tag {
ExtendedProtocolDiscriminator extendedprotocoldiscriminator; ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
...@@ -48,7 +44,11 @@ typedef struct configuration_update_complete_msg_tag { ...@@ -48,7 +44,11 @@ typedef struct configuration_update_complete_msg_tag {
MessageType messagetype; MessageType messagetype;
} configuration_update_complete_msg; } configuration_update_complete_msg;
int decode_configuration_update_complete(configuration_update_complete_msg *configurationupdatecomplete, uint8_t *buffer, uint32_t len); int decode_configuration_update_complete(
int encode_configuration_update_complete(configuration_update_complete_msg *configurationupdatecomplete, uint8_t *buffer, uint32_t len); configuration_update_complete_msg* configurationupdatecomplete,
uint8_t* buffer, uint32_t len);
int encode_configuration_update_complete(
configuration_update_complete_msg* configurationupdatecomplete,
uint8_t* buffer, uint32_t len);
#endif #endif
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. * file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -27,54 +27,75 @@ ...@@ -27,54 +27,75 @@
#include "TLVDecoder.h" #include "TLVDecoder.h"
#include "DLNASTransport.h" #include "DLNASTransport.h"
int decode_dlnas_transport(dlnas_transport_msg *dlnas_transport, uint8_t *buffer, uint32_t len) { int decode_dlnas_transport(
uint32_t decoded = 0; dlnas_transport_msg* dlnas_transport, uint8_t* buffer, uint32_t len) {
uint32_t decoded = 0;
int decoded_result = 0; int decoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length
CHECK_PDU_POINTER_AND_LENGTH_DECODER(buffer, DLNAS_TRANSPORT_MINIMUM_LENGTH, len); // expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER(
buffer, DLNAS_TRANSPORT_MINIMUM_LENGTH, len);
if ((decoded_result = decode_extended_protocol_discriminator(&dlnas_transport->extendedprotocoldiscriminator, 0, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_extended_protocol_discriminator(
&dlnas_transport->extendedprotocoldiscriminator, 0, buffer + decoded,
len - decoded)) < 0)
return decoded_result; return decoded_result;
else else
decoded += decoded_result; decoded += decoded_result;
if ((decoded_result = decode_security_header_type(&dlnas_transport->securityheadertype, 0, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_security_header_type(
&dlnas_transport->securityheadertype, 0, buffer + decoded,
len - decoded)) < 0)
return decoded_result; return decoded_result;
else else
decoded += decoded_result; decoded += decoded_result;
if ((decoded_result = decode_message_type(&dlnas_transport->messagetype, 0, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_message_type(
&dlnas_transport->messagetype, 0, buffer + decoded, len - decoded)) <
0)
return decoded_result; return decoded_result;
else else
decoded += decoded_result; decoded += decoded_result;
if ((decoded_result = decode_payload_container_type(&dlnas_transport->payloadcontainertype, 0, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_payload_container_type(
&dlnas_transport->payloadcontainertype, 0, buffer + decoded,
len - decoded)) < 0)
return decoded_result; return decoded_result;
else else
decoded += decoded_result; decoded += decoded_result;
if ((decoded_result = decode_payload_container(&dlnas_transport->payloadcontainer, 0, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_payload_container(
&dlnas_transport->payloadcontainer, 0, buffer + decoded,
len - decoded)) < 0)
return decoded_result; return decoded_result;
else else
decoded += decoded_result; decoded += decoded_result;
if ((decoded_result = decode_pdu_session_identity2(&dlnas_transport->pdusessionidentity2, 0, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_pdu_session_identity2(
&dlnas_transport->pdusessionidentity2, 0, buffer + decoded,
len - decoded)) < 0)
return decoded_result; return decoded_result;
else else
decoded += decoded_result; decoded += decoded_result;
if ((decoded_result = decode_additional_information(&dlnas_transport->additionalinformation, 0, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_additional_information(
&dlnas_transport->additionalinformation, 0, buffer + decoded,
len - decoded)) < 0)
return decoded_result; return decoded_result;
else else
decoded += decoded_result; decoded += decoded_result;
if ((decoded_result = decode__5gmm_cause(&dlnas_transport->_5gmmcause, 0, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode__5gmm_cause(
&dlnas_transport->_5gmmcause, 0, buffer + decoded, len - decoded)) <
0)
return decoded_result; return decoded_result;
else else
decoded += decoded_result; decoded += decoded_result;
if ((decoded_result = decode_gprs_timer3(&dlnas_transport->gprstimer3, 0, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_gprs_timer3(
&dlnas_transport->gprstimer3, 0, buffer + decoded, len - decoded)) <
0)
return decoded_result; return decoded_result;
else else
decoded += decoded_result; decoded += decoded_result;
...@@ -82,54 +103,75 @@ int decode_dlnas_transport(dlnas_transport_msg *dlnas_transport, uint8_t *buffer ...@@ -82,54 +103,75 @@ int decode_dlnas_transport(dlnas_transport_msg *dlnas_transport, uint8_t *buffer
return decoded; return decoded;
} }
int encode_dlnas_transport(dlnas_transport_msg *dlnas_transport, uint8_t *buffer, uint32_t len) { int encode_dlnas_transport(
uint32_t encoded = 0; dlnas_transport_msg* dlnas_transport, uint8_t* buffer, uint32_t len) {
uint32_t encoded = 0;
int encoded_result = 0; int encoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, DLNAS_TRANSPORT_MINIMUM_LENGTH, len); // expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(
buffer, DLNAS_TRANSPORT_MINIMUM_LENGTH, len);
if ((encoded_result = encode_extended_protocol_discriminator(dlnas_transport->extendedprotocoldiscriminator, 0, buffer + encoded, len - encoded)) < 0) if ((encoded_result = encode_extended_protocol_discriminator(
dlnas_transport->extendedprotocoldiscriminator, 0, buffer + encoded,
len - encoded)) < 0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
if ((encoded_result = encode_security_header_type(dlnas_transport->securityheadertype, 0, buffer + encoded, len - encoded)) < 0) if ((encoded_result = encode_security_header_type(
dlnas_transport->securityheadertype, 0, buffer + encoded,
len - encoded)) < 0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
if ((encoded_result = encode_message_type(dlnas_transport->messagetype, 0, buffer + encoded, len - encoded)) < 0) if ((encoded_result = encode_message_type(
dlnas_transport->messagetype, 0, buffer + encoded, len - encoded)) <
0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
if ((encoded_result = encode_payload_container_type(dlnas_transport->payloadcontainertype, 0, buffer + encoded, len - encoded)) < 0) if ((encoded_result = encode_payload_container_type(
dlnas_transport->payloadcontainertype, 0, buffer + encoded,
len - encoded)) < 0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
if ((encoded_result = encode_payload_container(dlnas_transport->payloadcontainer, 0, buffer + encoded, len - encoded)) < 0) if ((encoded_result = encode_payload_container(
dlnas_transport->payloadcontainer, 0, buffer + encoded,
len - encoded)) < 0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
if ((encoded_result = encode_pdu_session_identity2(dlnas_transport->pdusessionidentity2, 0, buffer + encoded, len - encoded)) < 0) if ((encoded_result = encode_pdu_session_identity2(
dlnas_transport->pdusessionidentity2, 0, buffer + encoded,
len - encoded)) < 0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
if ((encoded_result = encode_additional_information(dlnas_transport->additionalinformation, 0, buffer + encoded, len - encoded)) < 0) if ((encoded_result = encode_additional_information(
dlnas_transport->additionalinformation, 0, buffer + encoded,
len - encoded)) < 0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
if ((encoded_result = encode__5gmm_cause(dlnas_transport->_5gmmcause, 0, buffer + encoded, len - encoded)) < 0) if ((encoded_result = encode__5gmm_cause(
dlnas_transport->_5gmmcause, 0, buffer + encoded, len - encoded)) <
0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
if ((encoded_result = encode_gprs_timer3(dlnas_transport->gprstimer3, 0, buffer + encoded, len - encoded)) < 0) if ((encoded_result = encode_gprs_timer3(
dlnas_transport->gprstimer3, 0, buffer + encoded, len - encoded)) <
0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. * file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -35,30 +35,22 @@ ...@@ -35,30 +35,22 @@
#include "GPRSTimer3.h" #include "GPRSTimer3.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */ /* Minimum length macro. Formed by minimum length of each mandatory field */
#define DLNAS_TRANSPORT_MINIMUM_LENGTH ( \ #define DLNAS_TRANSPORT_MINIMUM_LENGTH \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \ (EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
SECURITY_HEADER_TYPE_MINIMUM_LENGTH + \ SECURITY_HEADER_TYPE_MINIMUM_LENGTH + MESSAGE_TYPE_MINIMUM_LENGTH + \
MESSAGE_TYPE_MINIMUM_LENGTH + \ PAYLOAD_CONTAINER_TYPE_MINIMUM_LENGTH + PAYLOAD_CONTAINER_MINIMUM_LENGTH + \
PAYLOAD_CONTAINER_TYPE_MINIMUM_LENGTH + \ PDU_SESSION_IDENTITY2_MINIMUM_LENGTH + \
PAYLOAD_CONTAINER_MINIMUM_LENGTH + \ ADDITIONAL_INFORMATION_MINIMUM_LENGTH + _5GMM_CAUSE_MINIMUM_LENGTH + \
PDU_SESSION_IDENTITY2_MINIMUM_LENGTH + \ GPRS_TIMER3_MINIMUM_LENGTH + 0)
ADDITIONAL_INFORMATION_MINIMUM_LENGTH + \
_5GMM_CAUSE_MINIMUM_LENGTH + \
GPRS_TIMER3_MINIMUM_LENGTH + \
0)
/* Maximum length macro. Formed by maximum length of each field */ /* Maximum length macro. Formed by maximum length of each field */
#define DLNAS_TRANSPORT_MAXIMUM_LENGTH ( \ #define DLNAS_TRANSPORT_MAXIMUM_LENGTH \
EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \ (EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \
SECURITY_HEADER_TYPE_MAXIMUM_LENGTH + \ SECURITY_HEADER_TYPE_MAXIMUM_LENGTH + MESSAGE_TYPE_MAXIMUM_LENGTH + \
MESSAGE_TYPE_MAXIMUM_LENGTH + \ PAYLOAD_CONTAINER_TYPE_MAXIMUM_LENGTH + PAYLOAD_CONTAINER_MAXIMUM_LENGTH + \
PAYLOAD_CONTAINER_TYPE_MAXIMUM_LENGTH + \ PDU_SESSION_IDENTITY2_MAXIMUM_LENGTH + \
PAYLOAD_CONTAINER_MAXIMUM_LENGTH + \ ADDITIONAL_INFORMATION_MAXIMUM_LENGTH + _5GMM_CAUSE_MAXIMUM_LENGTH + \
PDU_SESSION_IDENTITY2_MAXIMUM_LENGTH + \ GPRS_TIMER3_MAXIMUM_LENGTH + 0)
ADDITIONAL_INFORMATION_MAXIMUM_LENGTH + \
_5GMM_CAUSE_MAXIMUM_LENGTH + \
GPRS_TIMER3_MAXIMUM_LENGTH + \
0)
typedef struct dlnas_transport_msg_tag { typedef struct dlnas_transport_msg_tag {
ExtendedProtocolDiscriminator extendedprotocoldiscriminator; ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
...@@ -72,7 +64,9 @@ typedef struct dlnas_transport_msg_tag { ...@@ -72,7 +64,9 @@ typedef struct dlnas_transport_msg_tag {
GPRSTimer3 gprstimer3; GPRSTimer3 gprstimer3;
} dlnas_transport_msg; } dlnas_transport_msg;
int decode_dlnas_transport(dlnas_transport_msg *dlnastransport, uint8_t *buffer, uint32_t len); int decode_dlnas_transport(
int encode_dlnas_transport(dlnas_transport_msg *dlnastransport, uint8_t *buffer, uint32_t len); dlnas_transport_msg* dlnastransport, uint8_t* buffer, uint32_t len);
int encode_dlnas_transport(
dlnas_transport_msg* dlnastransport, uint8_t* buffer, uint32_t len);
#endif #endif
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. * file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -27,24 +27,34 @@ ...@@ -27,24 +27,34 @@
#include "TLVDecoder.h" #include "TLVDecoder.h"
#include "DeregistrationAccept.h" #include "DeregistrationAccept.h"
int decode_deregistration_accept(deregistration_accept_msg *deregistration_accept, uint8_t *buffer, uint32_t len) { int decode_deregistration_accept(
uint32_t decoded = 0; deregistration_accept_msg* deregistration_accept, uint8_t* buffer,
uint32_t len) {
uint32_t decoded = 0;
int decoded_result = 0; int decoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length
CHECK_PDU_POINTER_AND_LENGTH_DECODER(buffer, DEREGISTRATION_ACCEPT_MINIMUM_LENGTH, len); // expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER(
buffer, DEREGISTRATION_ACCEPT_MINIMUM_LENGTH, len);
if ((decoded_result = decode_extended_protocol_discriminator(&deregistration_accept->extendedprotocoldiscriminator, 0, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_extended_protocol_discriminator(
&deregistration_accept->extendedprotocoldiscriminator, 0,
buffer + decoded, len - decoded)) < 0)
return decoded_result; return decoded_result;
else else
decoded += decoded_result; decoded += decoded_result;
if ((decoded_result = decode_security_header_type(&deregistration_accept->securityheadertype, 0, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_security_header_type(
&deregistration_accept->securityheadertype, 0, buffer + decoded,
len - decoded)) < 0)
return decoded_result; return decoded_result;
else else
decoded += decoded_result; decoded += decoded_result;
if ((decoded_result = decode_message_type(&deregistration_accept->messagetype, 0, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_message_type(
&deregistration_accept->messagetype, 0, buffer + decoded,
len - decoded)) < 0)
return decoded_result; return decoded_result;
else else
decoded += decoded_result; decoded += decoded_result;
...@@ -52,24 +62,34 @@ int decode_deregistration_accept(deregistration_accept_msg *deregistration_accep ...@@ -52,24 +62,34 @@ int decode_deregistration_accept(deregistration_accept_msg *deregistration_accep
return decoded; return decoded;
} }
int encode_deregistration_accept(deregistration_accept_msg *deregistration_accept, uint8_t *buffer, uint32_t len) { int encode_deregistration_accept(
uint32_t encoded = 0; deregistration_accept_msg* deregistration_accept, uint8_t* buffer,
uint32_t len) {
uint32_t encoded = 0;
int encoded_result = 0; int encoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, DEREGISTRATION_ACCEPT_MINIMUM_LENGTH, len); // expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(
buffer, DEREGISTRATION_ACCEPT_MINIMUM_LENGTH, len);
if ((encoded_result = encode_extended_protocol_discriminator(deregistration_accept->extendedprotocoldiscriminator, 0, buffer + encoded, len - encoded)) < 0) if ((encoded_result = encode_extended_protocol_discriminator(
deregistration_accept->extendedprotocoldiscriminator, 0,
buffer + encoded, len - encoded)) < 0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
if ((encoded_result = encode_security_header_type(deregistration_accept->securityheadertype, 0, buffer + encoded, len - encoded)) < 0) if ((encoded_result = encode_security_header_type(
deregistration_accept->securityheadertype, 0, buffer + encoded,
len - encoded)) < 0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
if ((encoded_result = encode_message_type(deregistration_accept->messagetype, 0, buffer + encoded, len - encoded)) < 0) if ((encoded_result = encode_message_type(
deregistration_accept->messagetype, 0, buffer + encoded,
len - encoded)) < 0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. * file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -29,18 +29,14 @@ ...@@ -29,18 +29,14 @@
#include "MessageType.h" #include "MessageType.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */ /* Minimum length macro. Formed by minimum length of each mandatory field */
#define DEREGISTRATION_ACCEPT_MINIMUM_LENGTH ( \ #define DEREGISTRATION_ACCEPT_MINIMUM_LENGTH \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \ (EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
SECURITY_HEADER_TYPE_MINIMUM_LENGTH + \ SECURITY_HEADER_TYPE_MINIMUM_LENGTH + MESSAGE_TYPE_MINIMUM_LENGTH + 0)
MESSAGE_TYPE_MINIMUM_LENGTH + \
0)
/* Maximum length macro. Formed by maximum length of each field */ /* Maximum length macro. Formed by maximum length of each field */
#define DEREGISTRATION_ACCEPT_MAXIMUM_LENGTH ( \ #define DEREGISTRATION_ACCEPT_MAXIMUM_LENGTH \
EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \ (EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \
SECURITY_HEADER_TYPE_MAXIMUM_LENGTH + \ SECURITY_HEADER_TYPE_MAXIMUM_LENGTH + MESSAGE_TYPE_MAXIMUM_LENGTH + 0)
MESSAGE_TYPE_MAXIMUM_LENGTH + \
0)
typedef struct deregistration_accept_msg_tag { typedef struct deregistration_accept_msg_tag {
ExtendedProtocolDiscriminator extendedprotocoldiscriminator; ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
...@@ -48,7 +44,11 @@ typedef struct deregistration_accept_msg_tag { ...@@ -48,7 +44,11 @@ typedef struct deregistration_accept_msg_tag {
MessageType messagetype; MessageType messagetype;
} deregistration_accept_msg; } deregistration_accept_msg;
int decode_deregistration_accept(deregistration_accept_msg *deregistrationaccept, uint8_t *buffer, uint32_t len); int decode_deregistration_accept(
int encode_deregistration_accept(deregistration_accept_msg *deregistrationaccept, uint8_t *buffer, uint32_t len); deregistration_accept_msg* deregistrationaccept, uint8_t* buffer,
uint32_t len);
int encode_deregistration_accept(
deregistration_accept_msg* deregistrationaccept, uint8_t* buffer,
uint32_t len);
#endif #endif
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. * file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -27,83 +27,93 @@ ...@@ -27,83 +27,93 @@
#include "TLVDecoder.h" #include "TLVDecoder.h"
#include "DeregistrationRequest.h" #include "DeregistrationRequest.h"
//TODO: to be implemeted // TODO: to be implemeted
int decode_deregistration_request(deregistration_request_msg *deregistration_request, uint8_t *buffer, uint32_t len) { int decode_deregistration_request(
deregistration_request_msg* deregistration_request, uint8_t* buffer,
uint32_t len) {
uint32_t decoded = 0; uint32_t decoded = 0;
// int decoded_result = 0; // int decoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length
CHECK_PDU_POINTER_AND_LENGTH_DECODER(buffer, DEREGISTRATION_REQUEST_MINIMUM_LENGTH, len); // 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) if((decoded_result = decode_extended_protocol_discriminator
return decoded_result; (&deregistration_request->extendedprotocoldiscriminator, 0,
else buffer+decoded,len-decoded))<0) return decoded_result; else
decoded+=decoded_result; decoded+=decoded_result;
if((decoded_result = decode_security_header_type (&deregistration_request->securityheadertype, 0, buffer+decoded,len-decoded))<0) if((decoded_result = decode_security_header_type
return decoded_result; (&deregistration_request->securityheadertype, 0,
else buffer+decoded,len-decoded))<0) return decoded_result; else
decoded+=decoded_result; decoded+=decoded_result;
if((decoded_result = decode_message_type (&deregistration_request->messagetype, 0, buffer+decoded,len-decoded))<0) if((decoded_result = decode_message_type
(&deregistration_request->messagetype, 0, buffer+decoded,len-decoded))<0)
return decoded_result; return decoded_result;
else else
decoded+=decoded_result; decoded+=decoded_result;
if((decoded_result = decode_deregistration_type (&deregistration_request->deregistrationtype, 0, buffer+decoded,len-decoded))<0) if((decoded_result = decode_deregistration_type
return decoded_result; (&deregistration_request->deregistrationtype, 0,
else buffer+decoded,len-decoded))<0) return decoded_result; else
decoded+=decoded_result; decoded+=decoded_result;
if((decoded_result = decode_nas_key_set_identifier (&deregistration_request->naskeysetidentifier, 0, buffer+decoded,len-decoded))<0) if((decoded_result = decode_nas_key_set_identifier
return decoded_result; (&deregistration_request->naskeysetidentifier, 0,
else buffer+decoded,len-decoded))<0) return decoded_result; else
decoded+=decoded_result; decoded+=decoded_result;
if((decoded_result = decode__5gs_mobile_identity (&deregistration_request->_5gsmobileidentity, 0, buffer+decoded,len-decoded))<0) if((decoded_result = decode__5gs_mobile_identity
return decoded_result; (&deregistration_request->_5gsmobileidentity, 0,
else buffer+decoded,len-decoded))<0) return decoded_result; else
decoded+=decoded_result; decoded+=decoded_result;
*/ */
return decoded; return decoded;
} }
int encode_deregistration_request(deregistration_request_msg *deregistration_request, uint8_t *buffer, uint32_t len) { int encode_deregistration_request(
deregistration_request_msg* deregistration_request, uint8_t* buffer,
uint32_t len) {
uint32_t encoded = 0; uint32_t encoded = 0;
// int encoded_result = 0; // int encoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, DEREGISTRATION_REQUEST_MINIMUM_LENGTH, len); // 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) if((encoded_result = encode_extended_protocol_discriminator
return encoded_result; (deregistration_request->extendedprotocoldiscriminator, 0,
else buffer+encoded,len-encoded))<0) return encoded_result; else
encoded+=encoded_result; encoded+=encoded_result;
if((encoded_result = encode_security_header_type (deregistration_request->securityheadertype, 0, buffer+encoded,len-encoded))<0) if((encoded_result = encode_security_header_type
return encoded_result; (deregistration_request->securityheadertype, 0,
else buffer+encoded,len-encoded))<0) return encoded_result; else
encoded+=encoded_result; encoded+=encoded_result;
if((encoded_result = encode_message_type (deregistration_request->messagetype, 0, buffer+encoded,len-encoded))<0) if((encoded_result = encode_message_type
(deregistration_request->messagetype, 0, buffer+encoded,len-encoded))<0)
return encoded_result; return encoded_result;
else else
encoded+=encoded_result; encoded+=encoded_result;
if((encoded_result = encode_deregistration_type (deregistration_request->deregistrationtype, 0, buffer+encoded,len-encoded))<0) if((encoded_result = encode_deregistration_type
return encoded_result; (deregistration_request->deregistrationtype, 0,
else buffer+encoded,len-encoded))<0) return encoded_result; else
encoded+=encoded_result; encoded+=encoded_result;
if((encoded_result = encode_nas_key_set_identifier (deregistration_request->naskeysetidentifier, 0, buffer+encoded,len-encoded))<0) if((encoded_result = encode_nas_key_set_identifier
return encoded_result; (deregistration_request->naskeysetidentifier, 0,
else buffer+encoded,len-encoded))<0) return encoded_result; else
encoded+=encoded_result; encoded+=encoded_result;
if((encoded_result = encode__5gs_mobile_identity (deregistration_request->_5gsmobileidentity, 0, buffer+encoded,len-encoded))<0) if((encoded_result = encode__5gs_mobile_identity
return encoded_result; (deregistration_request->_5gsmobileidentity, 0,
else buffer+encoded,len-encoded))<0) return encoded_result; else
encoded+=encoded_result; encoded+=encoded_result;
*/ */
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. * file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -32,24 +32,20 @@ ...@@ -32,24 +32,20 @@
#include "_5GSMobileIdentity.h" #include "_5GSMobileIdentity.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */ /* Minimum length macro. Formed by minimum length of each mandatory field */
#define DEREGISTRATION_REQUEST_MINIMUM_LENGTH ( \ #define DEREGISTRATION_REQUEST_MINIMUM_LENGTH \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \ (EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
SECURITY_HEADER_TYPE_MINIMUM_LENGTH + \ SECURITY_HEADER_TYPE_MINIMUM_LENGTH + MESSAGE_TYPE_MINIMUM_LENGTH + \
MESSAGE_TYPE_MINIMUM_LENGTH + \ DEREGISTRATION_TYPE_MINIMUM_LENGTH + \
DEREGISTRATION_TYPE_MINIMUM_LENGTH + \ NAS_KEY_SET_IDENTIFIER_MINIMUM_LENGTH + \
NAS_KEY_SET_IDENTIFIER_MINIMUM_LENGTH + \ _5GS_MOBILE_IDENTITY_MINIMUM_LENGTH + 0)
_5GS_MOBILE_IDENTITY_MINIMUM_LENGTH + \
0)
/* Maximum length macro. Formed by maximum length of each field */ /* Maximum length macro. Formed by maximum length of each field */
#define DEREGISTRATION_REQUEST_MAXIMUM_LENGTH ( \ #define DEREGISTRATION_REQUEST_MAXIMUM_LENGTH \
EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \ (EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \
SECURITY_HEADER_TYPE_MAXIMUM_LENGTH + \ SECURITY_HEADER_TYPE_MAXIMUM_LENGTH + MESSAGE_TYPE_MAXIMUM_LENGTH + \
MESSAGE_TYPE_MAXIMUM_LENGTH + \ DEREGISTRATION_TYPE_MAXIMUM_LENGTH + \
DEREGISTRATION_TYPE_MAXIMUM_LENGTH + \ NAS_KEY_SET_IDENTIFIER_MAXIMUM_LENGTH + \
NAS_KEY_SET_IDENTIFIER_MAXIMUM_LENGTH + \ _5GS_MOBILE_IDENTITY_MAXIMUM_LENGTH + 0)
_5GS_MOBILE_IDENTITY_MAXIMUM_LENGTH + \
0)
typedef struct deregistration_request_msg_tag { typedef struct deregistration_request_msg_tag {
ExtendedProtocolDiscriminator extendedprotocoldiscriminator; ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
...@@ -60,7 +56,11 @@ typedef struct deregistration_request_msg_tag { ...@@ -60,7 +56,11 @@ typedef struct deregistration_request_msg_tag {
_5GSMobileIdentity _5gsmobileidentity; _5GSMobileIdentity _5gsmobileidentity;
} deregistration_request_msg; } deregistration_request_msg;
int decode_deregistration_request(deregistration_request_msg *deregistrationrequest, uint8_t *buffer, uint32_t len); int decode_deregistration_request(
int encode_deregistration_request(deregistration_request_msg *deregistrationrequest, uint8_t *buffer, uint32_t len); deregistration_request_msg* deregistrationrequest, uint8_t* buffer,
uint32_t len);
int encode_deregistration_request(
deregistration_request_msg* deregistrationrequest, uint8_t* buffer,
uint32_t len);
#endif #endif
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. * file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -27,14 +27,19 @@ ...@@ -27,14 +27,19 @@
#include "TLVDecoder.h" #include "TLVDecoder.h"
#include "IdentityRequest.h" #include "IdentityRequest.h"
int decode_identity_request(identity_request_msg *identity_request, uint8_t *buffer, uint32_t len) { int decode_identity_request(
uint32_t decoded = 0; identity_request_msg* identity_request, uint8_t* buffer, uint32_t len) {
uint32_t decoded = 0;
int decoded_result = 0; int decoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length
CHECK_PDU_POINTER_AND_LENGTH_DECODER(buffer, IDENTITY_REQUEST_MINIMUM_LENGTH, len); // expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER(
buffer, IDENTITY_REQUEST_MINIMUM_LENGTH, len);
if ((decoded_result = decode__5gs_identity_type(&identity_request->_5gsidentitytype, 0, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode__5gs_identity_type(
&identity_request->_5gsidentitytype, 0, buffer + decoded,
len - decoded)) < 0)
return decoded_result; return decoded_result;
else else
decoded += decoded_result; decoded += decoded_result;
...@@ -42,14 +47,19 @@ int decode_identity_request(identity_request_msg *identity_request, uint8_t *buf ...@@ -42,14 +47,19 @@ int decode_identity_request(identity_request_msg *identity_request, uint8_t *buf
return decoded; return decoded;
} }
int encode_identity_request(identity_request_msg *identity_request, uint8_t *buffer, uint32_t len) { int encode_identity_request(
uint32_t encoded = 0; identity_request_msg* identity_request, uint8_t* buffer, uint32_t len) {
uint32_t encoded = 0;
int encoded_result = 0; int encoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, IDENTITY_REQUEST_MINIMUM_LENGTH, len); // expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(
buffer, IDENTITY_REQUEST_MINIMUM_LENGTH, len);
if ((encoded_result = encode__5gs_identity_type(identity_request->_5gsidentitytype, 0, buffer + encoded, len - encoded)) < 0) if ((encoded_result = encode__5gs_identity_type(
identity_request->_5gsidentitytype, 0, buffer + encoded,
len - encoded)) < 0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. * file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -30,20 +30,16 @@ ...@@ -30,20 +30,16 @@
#include "_5GSIdentityType.h" #include "_5GSIdentityType.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */ /* Minimum length macro. Formed by minimum length of each mandatory field */
#define IDENTITY_REQUEST_MINIMUM_LENGTH ( \ #define IDENTITY_REQUEST_MINIMUM_LENGTH \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \ (EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
SECURITY_HEADER_TYPE_MINIMUM_LENGTH + \ SECURITY_HEADER_TYPE_MINIMUM_LENGTH + MESSAGE_TYPE_MINIMUM_LENGTH + \
MESSAGE_TYPE_MINIMUM_LENGTH + \ _5GS_IDENTITY_TYPE_MINIMUM_LENGTH + 0)
_5GS_IDENTITY_TYPE_MINIMUM_LENGTH + \
0)
/* Maximum length macro. Formed by maximum length of each field */ /* Maximum length macro. Formed by maximum length of each field */
#define IDENTITY_REQUEST_MAXIMUM_LENGTH ( \ #define IDENTITY_REQUEST_MAXIMUM_LENGTH \
EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \ (EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \
SECURITY_HEADER_TYPE_MAXIMUM_LENGTH + \ SECURITY_HEADER_TYPE_MAXIMUM_LENGTH + MESSAGE_TYPE_MAXIMUM_LENGTH + \
MESSAGE_TYPE_MAXIMUM_LENGTH + \ _5GS_IDENTITY_TYPE_MAXIMUM_LENGTH + 0)
_5GS_IDENTITY_TYPE_MAXIMUM_LENGTH + \
0)
typedef struct identity_request_msg_tag { typedef struct identity_request_msg_tag {
ExtendedProtocolDiscriminator extendedprotocoldiscriminator; ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
...@@ -52,7 +48,9 @@ typedef struct identity_request_msg_tag { ...@@ -52,7 +48,9 @@ typedef struct identity_request_msg_tag {
_5GSIdentityType _5gsidentitytype; _5GSIdentityType _5gsidentitytype;
} identity_request_msg; } identity_request_msg;
int decode_identity_request(identity_request_msg *identityrequest, uint8_t *buffer, uint32_t len); int decode_identity_request(
int encode_identity_request(identity_request_msg *identityrequest, uint8_t *buffer, uint32_t len); identity_request_msg* identityrequest, uint8_t* buffer, uint32_t len);
int encode_identity_request(
identity_request_msg* identityrequest, uint8_t* buffer, uint32_t len);
#endif #endif
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. * file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -27,29 +27,40 @@ ...@@ -27,29 +27,40 @@
#include "TLVDecoder.h" #include "TLVDecoder.h"
#include "IdentityResponse.h" #include "IdentityResponse.h"
int decode_identity_response(identity_response_msg *identity_response, uint8_t *buffer, uint32_t len) { int decode_identity_response(
uint32_t decoded = 0; identity_response_msg* identity_response, uint8_t* buffer, uint32_t len) {
uint32_t decoded = 0;
int decoded_result = 0; int decoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length
CHECK_PDU_POINTER_AND_LENGTH_DECODER(buffer, IDENTITY_RESPONSE_MINIMUM_LENGTH, len); // expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER(
buffer, IDENTITY_RESPONSE_MINIMUM_LENGTH, len);
if ((decoded_result = decode_extended_protocol_discriminator(&identity_response->extendedprotocoldiscriminator, 0, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_extended_protocol_discriminator(
&identity_response->extendedprotocoldiscriminator, 0,
buffer + decoded, len - decoded)) < 0)
return decoded_result; return decoded_result;
else else
decoded += decoded_result; decoded += decoded_result;
if ((decoded_result = decode_security_header_type(&identity_response->securityheadertype, 0, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_security_header_type(
&identity_response->securityheadertype, 0, buffer + decoded,
len - decoded)) < 0)
return decoded_result; return decoded_result;
else else
decoded += decoded_result; decoded += decoded_result;
if ((decoded_result = decode_message_type(&identity_response->messagetype, 0, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_message_type(
&identity_response->messagetype, 0, buffer + decoded,
len - decoded)) < 0)
return decoded_result; return decoded_result;
else else
decoded += decoded_result; decoded += decoded_result;
if ((decoded_result = decode__5gs_mobile_identity(&identity_response->_5gsmobileidentity, 0, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode__5gs_mobile_identity(
&identity_response->_5gsmobileidentity, 0, buffer + decoded,
len - decoded)) < 0)
return decoded_result; return decoded_result;
else else
decoded += decoded_result; decoded += decoded_result;
...@@ -57,29 +68,40 @@ int decode_identity_response(identity_response_msg *identity_response, uint8_t * ...@@ -57,29 +68,40 @@ int decode_identity_response(identity_response_msg *identity_response, uint8_t *
return decoded; return decoded;
} }
int encode_identity_response(identity_response_msg *identity_response, uint8_t *buffer, uint32_t len) { int encode_identity_response(
uint32_t encoded = 0; identity_response_msg* identity_response, uint8_t* buffer, uint32_t len) {
uint32_t encoded = 0;
int encoded_result = 0; int encoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, IDENTITY_RESPONSE_MINIMUM_LENGTH, len); // expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(
buffer, IDENTITY_RESPONSE_MINIMUM_LENGTH, len);
if ((encoded_result = encode_extended_protocol_discriminator(identity_response->extendedprotocoldiscriminator, 0, buffer + encoded, len - encoded)) < 0) if ((encoded_result = encode_extended_protocol_discriminator(
identity_response->extendedprotocoldiscriminator, 0,
buffer + encoded, len - encoded)) < 0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
if ((encoded_result = encode_security_header_type(identity_response->securityheadertype, 0, buffer + encoded, len - encoded)) < 0) if ((encoded_result = encode_security_header_type(
identity_response->securityheadertype, 0, buffer + encoded,
len - encoded)) < 0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
if ((encoded_result = encode_message_type(identity_response->messagetype, 0, buffer + encoded, len - encoded)) < 0) if ((encoded_result = encode_message_type(
identity_response->messagetype, 0, buffer + encoded,
len - encoded)) < 0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
if ((encoded_result = encode__5gs_mobile_identity(identity_response->_5gsmobileidentity, 0, buffer + encoded, len - encoded)) < 0) if ((encoded_result = encode__5gs_mobile_identity(
identity_response->_5gsmobileidentity, 0, buffer + encoded,
len - encoded)) < 0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. * file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -30,20 +30,16 @@ ...@@ -30,20 +30,16 @@
#include "_5GSMobileIdentity.h" #include "_5GSMobileIdentity.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */ /* Minimum length macro. Formed by minimum length of each mandatory field */
#define IDENTITY_RESPONSE_MINIMUM_LENGTH ( \ #define IDENTITY_RESPONSE_MINIMUM_LENGTH \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \ (EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
SECURITY_HEADER_TYPE_MINIMUM_LENGTH + \ SECURITY_HEADER_TYPE_MINIMUM_LENGTH + MESSAGE_TYPE_MINIMUM_LENGTH + \
MESSAGE_TYPE_MINIMUM_LENGTH + \ _5GS_MOBILE_IDENTITY_MINIMUM_LENGTH + 0)
_5GS_MOBILE_IDENTITY_MINIMUM_LENGTH + \
0)
/* Maximum length macro. Formed by maximum length of each field */ /* Maximum length macro. Formed by maximum length of each field */
#define IDENTITY_RESPONSE_MAXIMUM_LENGTH ( \ #define IDENTITY_RESPONSE_MAXIMUM_LENGTH \
EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \ (EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \
SECURITY_HEADER_TYPE_MAXIMUM_LENGTH + \ SECURITY_HEADER_TYPE_MAXIMUM_LENGTH + MESSAGE_TYPE_MAXIMUM_LENGTH + \
MESSAGE_TYPE_MAXIMUM_LENGTH + \ _5GS_MOBILE_IDENTITY_MAXIMUM_LENGTH + 0)
_5GS_MOBILE_IDENTITY_MAXIMUM_LENGTH + \
0)
typedef struct identity_response_msg_tag { typedef struct identity_response_msg_tag {
ExtendedProtocolDiscriminator extendedprotocoldiscriminator; ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
...@@ -52,7 +48,9 @@ typedef struct identity_response_msg_tag { ...@@ -52,7 +48,9 @@ typedef struct identity_response_msg_tag {
_5GSMobileIdentity _5gsmobileidentity; _5GSMobileIdentity _5gsmobileidentity;
} identity_response_msg; } identity_response_msg;
int decode_identity_response(identity_response_msg *identityresponse, uint8_t *buffer, uint32_t len); int decode_identity_response(
int encode_identity_response(identity_response_msg *identityresponse, uint8_t *buffer, uint32_t len); identity_response_msg* identityresponse, uint8_t* buffer, uint32_t len);
int encode_identity_response(
identity_response_msg* identityresponse, uint8_t* buffer, uint32_t len);
#endif #endif
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. * file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -27,29 +27,38 @@ ...@@ -27,29 +27,38 @@
#include "TLVDecoder.h" #include "TLVDecoder.h"
#include "Notification.h" #include "Notification.h"
int decode_notification(notification_msg *notification, uint8_t *buffer, uint32_t len) { int decode_notification(
uint32_t decoded = 0; notification_msg* notification, uint8_t* buffer, uint32_t len) {
uint32_t decoded = 0;
int decoded_result = 0; int decoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length
CHECK_PDU_POINTER_AND_LENGTH_DECODER(buffer, NOTIFICATION_MINIMUM_LENGTH, len); // expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER(
buffer, NOTIFICATION_MINIMUM_LENGTH, len);
if ((decoded_result = decode_extended_protocol_discriminator(&notification->extendedprotocoldiscriminator, 0, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_extended_protocol_discriminator(
&notification->extendedprotocoldiscriminator, 0, buffer + decoded,
len - decoded)) < 0)
return decoded_result; return decoded_result;
else else
decoded += decoded_result; decoded += decoded_result;
if ((decoded_result = decode_security_header_type(&notification->securityheadertype, 0, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_security_header_type(
&notification->securityheadertype, 0, buffer + decoded,
len - decoded)) < 0)
return decoded_result; return decoded_result;
else else
decoded += decoded_result; decoded += decoded_result;
if ((decoded_result = decode_message_type(&notification->messagetype, 0, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_message_type(
&notification->messagetype, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result; return decoded_result;
else else
decoded += decoded_result; decoded += decoded_result;
if ((decoded_result = decode__access_type(&notification->_accesstype, 0, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode__access_type(
&notification->_accesstype, 0, buffer + decoded, len - decoded)) < 0)
return decoded_result; return decoded_result;
else else
decoded += decoded_result; decoded += decoded_result;
...@@ -57,29 +66,38 @@ int decode_notification(notification_msg *notification, uint8_t *buffer, uint32_ ...@@ -57,29 +66,38 @@ int decode_notification(notification_msg *notification, uint8_t *buffer, uint32_
return decoded; return decoded;
} }
int encode_notification(notification_msg *notification, uint8_t *buffer, uint32_t len) { int encode_notification(
uint32_t encoded = 0; notification_msg* notification, uint8_t* buffer, uint32_t len) {
uint32_t encoded = 0;
int encoded_result = 0; int encoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, NOTIFICATION_MINIMUM_LENGTH, len); // expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(
buffer, NOTIFICATION_MINIMUM_LENGTH, len);
if ((encoded_result = encode_extended_protocol_discriminator(notification->extendedprotocoldiscriminator, 0, buffer + encoded, len - encoded)) < 0) if ((encoded_result = encode_extended_protocol_discriminator(
notification->extendedprotocoldiscriminator, 0, buffer + encoded,
len - encoded)) < 0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
if ((encoded_result = encode_security_header_type(notification->securityheadertype, 0, buffer + encoded, len - encoded)) < 0) if ((encoded_result = encode_security_header_type(
notification->securityheadertype, 0, buffer + encoded,
len - encoded)) < 0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
if ((encoded_result = encode_message_type(notification->messagetype, 0, buffer + encoded, len - encoded)) < 0) if ((encoded_result = encode_message_type(
notification->messagetype, 0, buffer + encoded, len - encoded)) < 0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
if ((encoded_result = encode__access_type(notification->_accesstype, 0, buffer + encoded, len - encoded)) < 0) if ((encoded_result = encode__access_type(
notification->_accesstype, 0, buffer + encoded, len - encoded)) < 0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. * file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -30,20 +30,16 @@ ...@@ -30,20 +30,16 @@
#include "_AccessType.h" #include "_AccessType.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */ /* Minimum length macro. Formed by minimum length of each mandatory field */
#define NOTIFICATION_MINIMUM_LENGTH ( \ #define NOTIFICATION_MINIMUM_LENGTH \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \ (EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
SECURITY_HEADER_TYPE_MINIMUM_LENGTH + \ SECURITY_HEADER_TYPE_MINIMUM_LENGTH + MESSAGE_TYPE_MINIMUM_LENGTH + \
MESSAGE_TYPE_MINIMUM_LENGTH + \ _ACCESS_TYPE_MINIMUM_LENGTH + 0)
_ACCESS_TYPE_MINIMUM_LENGTH + \
0)
/* Maximum length macro. Formed by maximum length of each field */ /* Maximum length macro. Formed by maximum length of each field */
#define NOTIFICATION_MAXIMUM_LENGTH ( \ #define NOTIFICATION_MAXIMUM_LENGTH \
EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \ (EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \
SECURITY_HEADER_TYPE_MAXIMUM_LENGTH + \ SECURITY_HEADER_TYPE_MAXIMUM_LENGTH + MESSAGE_TYPE_MAXIMUM_LENGTH + \
MESSAGE_TYPE_MAXIMUM_LENGTH + \ _ACCESS_TYPE_MAXIMUM_LENGTH + 0)
_ACCESS_TYPE_MAXIMUM_LENGTH + \
0)
typedef struct notification_msg_tag { typedef struct notification_msg_tag {
ExtendedProtocolDiscriminator extendedprotocoldiscriminator; ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
...@@ -52,7 +48,9 @@ typedef struct notification_msg_tag { ...@@ -52,7 +48,9 @@ typedef struct notification_msg_tag {
_AccessType _accesstype; _AccessType _accesstype;
} notification_msg; } notification_msg;
int decode_notification(notification_msg *notification, uint8_t *buffer, uint32_t len); int decode_notification(
int encode_notification(notification_msg *notification, uint8_t *buffer, uint32_t len); notification_msg* notification, uint8_t* buffer, uint32_t len);
int encode_notification(
notification_msg* notification, uint8_t* buffer, uint32_t len);
#endif #endif
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. * file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -27,29 +27,41 @@ ...@@ -27,29 +27,41 @@
#include "TLVDecoder.h" #include "TLVDecoder.h"
#include "NotificationResponse.h" #include "NotificationResponse.h"
int decode_notification_response(notification_response_msg *notification_response, uint8_t *buffer, uint32_t len) { int decode_notification_response(
uint32_t decoded = 0; notification_response_msg* notification_response, uint8_t* buffer,
uint32_t len) {
uint32_t decoded = 0;
int decoded_result = 0; int decoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length
CHECK_PDU_POINTER_AND_LENGTH_DECODER(buffer, NOTIFICATION_RESPONSE_MINIMUM_LENGTH, len); // expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER(
buffer, NOTIFICATION_RESPONSE_MINIMUM_LENGTH, len);
if ((decoded_result = decode_extended_protocol_discriminator(&notification_response->extendedprotocoldiscriminator, 0, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_extended_protocol_discriminator(
&notification_response->extendedprotocoldiscriminator, 0,
buffer + decoded, len - decoded)) < 0)
return decoded_result; return decoded_result;
else else
decoded += decoded_result; decoded += decoded_result;
if ((decoded_result = decode_security_header_type(&notification_response->securityheadertype, 0, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_security_header_type(
&notification_response->securityheadertype, 0, buffer + decoded,
len - decoded)) < 0)
return decoded_result; return decoded_result;
else else
decoded += decoded_result; decoded += decoded_result;
if ((decoded_result = decode_message_type(&notification_response->messagetype, 0, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_message_type(
&notification_response->messagetype, 0, buffer + decoded,
len - decoded)) < 0)
return decoded_result; return decoded_result;
else else
decoded += decoded_result; decoded += decoded_result;
if ((decoded_result = decode_pdu_session_status(&notification_response->pdusessionstatus, 0, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_pdu_session_status(
&notification_response->pdusessionstatus, 0, buffer + decoded,
len - decoded)) < 0)
return decoded_result; return decoded_result;
else else
decoded += decoded_result; decoded += decoded_result;
...@@ -57,29 +69,41 @@ int decode_notification_response(notification_response_msg *notification_respons ...@@ -57,29 +69,41 @@ int decode_notification_response(notification_response_msg *notification_respons
return decoded; return decoded;
} }
int encode_notification_response(notification_response_msg *notification_response, uint8_t *buffer, uint32_t len) { int encode_notification_response(
uint32_t encoded = 0; notification_response_msg* notification_response, uint8_t* buffer,
uint32_t len) {
uint32_t encoded = 0;
int encoded_result = 0; int encoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, NOTIFICATION_RESPONSE_MINIMUM_LENGTH, len); // expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(
buffer, NOTIFICATION_RESPONSE_MINIMUM_LENGTH, len);
if ((encoded_result = encode_extended_protocol_discriminator(notification_response->extendedprotocoldiscriminator, 0, buffer + encoded, len - encoded)) < 0) if ((encoded_result = encode_extended_protocol_discriminator(
notification_response->extendedprotocoldiscriminator, 0,
buffer + encoded, len - encoded)) < 0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
if ((encoded_result = encode_security_header_type(notification_response->securityheadertype, 0, buffer + encoded, len - encoded)) < 0) if ((encoded_result = encode_security_header_type(
notification_response->securityheadertype, 0, buffer + encoded,
len - encoded)) < 0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
if ((encoded_result = encode_message_type(notification_response->messagetype, 0, buffer + encoded, len - encoded)) < 0) if ((encoded_result = encode_message_type(
notification_response->messagetype, 0, buffer + encoded,
len - encoded)) < 0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
if ((encoded_result = encode_pdu_session_status(notification_response->pdusessionstatus, 0, buffer + encoded, len - encoded)) < 0) if ((encoded_result = encode_pdu_session_status(
notification_response->pdusessionstatus, 0, buffer + encoded,
len - encoded)) < 0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. * file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -30,20 +30,16 @@ ...@@ -30,20 +30,16 @@
#include "PDUSessionStatus.h" #include "PDUSessionStatus.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */ /* Minimum length macro. Formed by minimum length of each mandatory field */
#define NOTIFICATION_RESPONSE_MINIMUM_LENGTH ( \ #define NOTIFICATION_RESPONSE_MINIMUM_LENGTH \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \ (EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
SECURITY_HEADER_TYPE_MINIMUM_LENGTH + \ SECURITY_HEADER_TYPE_MINIMUM_LENGTH + MESSAGE_TYPE_MINIMUM_LENGTH + \
MESSAGE_TYPE_MINIMUM_LENGTH + \ PDU_SESSION_STATUS_MINIMUM_LENGTH + 0)
PDU_SESSION_STATUS_MINIMUM_LENGTH + \
0)
/* Maximum length macro. Formed by maximum length of each field */ /* Maximum length macro. Formed by maximum length of each field */
#define NOTIFICATION_RESPONSE_MAXIMUM_LENGTH ( \ #define NOTIFICATION_RESPONSE_MAXIMUM_LENGTH \
EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \ (EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \
SECURITY_HEADER_TYPE_MAXIMUM_LENGTH + \ SECURITY_HEADER_TYPE_MAXIMUM_LENGTH + MESSAGE_TYPE_MAXIMUM_LENGTH + \
MESSAGE_TYPE_MAXIMUM_LENGTH + \ PDU_SESSION_STATUS_MAXIMUM_LENGTH + 0)
PDU_SESSION_STATUS_MAXIMUM_LENGTH + \
0)
typedef struct notification_response_msg_tag { typedef struct notification_response_msg_tag {
ExtendedProtocolDiscriminator extendedprotocoldiscriminator; ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
...@@ -52,7 +48,11 @@ typedef struct notification_response_msg_tag { ...@@ -52,7 +48,11 @@ typedef struct notification_response_msg_tag {
PDUSessionStatus pdusessionstatus; PDUSessionStatus pdusessionstatus;
} notification_response_msg; } notification_response_msg;
int decode_notification_response(notification_response_msg *notificationresponse, uint8_t *buffer, uint32_t len); int decode_notification_response(
int encode_notification_response(notification_response_msg *notificationresponse, uint8_t *buffer, uint32_t len); notification_response_msg* notificationresponse, uint8_t* buffer,
uint32_t len);
int encode_notification_response(
notification_response_msg* notificationresponse, uint8_t* buffer,
uint32_t len);
#endif #endif
This diff is collapsed.
This diff is collapsed.
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. * file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -27,29 +27,41 @@ ...@@ -27,29 +27,41 @@
#include "TLVDecoder.h" #include "TLVDecoder.h"
#include "RegistrationComplete.h" #include "RegistrationComplete.h"
int decode_registration_complete(registration_complete_msg *registration_complete, uint8_t *buffer, uint32_t len) { int decode_registration_complete(
uint32_t decoded = 0; registration_complete_msg* registration_complete, uint8_t* buffer,
uint32_t len) {
uint32_t decoded = 0;
int decoded_result = 0; int decoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length
CHECK_PDU_POINTER_AND_LENGTH_DECODER(buffer, REGISTRATION_COMPLETE_MINIMUM_LENGTH, len); // expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER(
buffer, REGISTRATION_COMPLETE_MINIMUM_LENGTH, len);
if ((decoded_result = decode_extended_protocol_discriminator(&registration_complete->extendedprotocoldiscriminator, 0, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_extended_protocol_discriminator(
&registration_complete->extendedprotocoldiscriminator, 0,
buffer + decoded, len - decoded)) < 0)
return decoded_result; return decoded_result;
else else
decoded += decoded_result; decoded += decoded_result;
if ((decoded_result = decode_security_header_type(&registration_complete->securityheadertype, 0, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_security_header_type(
&registration_complete->securityheadertype, 0, buffer + decoded,
len - decoded)) < 0)
return decoded_result; return decoded_result;
else else
decoded += decoded_result; decoded += decoded_result;
if ((decoded_result = decode_message_type(&registration_complete->messagetype, 0, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_message_type(
&registration_complete->messagetype, 0, buffer + decoded,
len - decoded)) < 0)
return decoded_result; return decoded_result;
else else
decoded += decoded_result; decoded += decoded_result;
if ((decoded_result = decode_sor_transparent_container(&registration_complete->sortransparentcontainer, 0, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_sor_transparent_container(
&registration_complete->sortransparentcontainer, 0, buffer + decoded,
len - decoded)) < 0)
return decoded_result; return decoded_result;
else else
decoded += decoded_result; decoded += decoded_result;
...@@ -57,29 +69,41 @@ int decode_registration_complete(registration_complete_msg *registration_complet ...@@ -57,29 +69,41 @@ int decode_registration_complete(registration_complete_msg *registration_complet
return decoded; return decoded;
} }
int encode_registration_complete(registration_complete_msg *registration_complete, uint8_t *buffer, uint32_t len) { int encode_registration_complete(
uint32_t encoded = 0; registration_complete_msg* registration_complete, uint8_t* buffer,
uint32_t len) {
uint32_t encoded = 0;
int encoded_result = 0; int encoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, REGISTRATION_COMPLETE_MINIMUM_LENGTH, len); // expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(
buffer, REGISTRATION_COMPLETE_MINIMUM_LENGTH, len);
if ((encoded_result = encode_extended_protocol_discriminator(registration_complete->extendedprotocoldiscriminator, 0, buffer + encoded, len - encoded)) < 0) if ((encoded_result = encode_extended_protocol_discriminator(
registration_complete->extendedprotocoldiscriminator, 0,
buffer + encoded, len - encoded)) < 0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
if ((encoded_result = encode_security_header_type(registration_complete->securityheadertype, 0, buffer + encoded, len - encoded)) < 0) if ((encoded_result = encode_security_header_type(
registration_complete->securityheadertype, 0, buffer + encoded,
len - encoded)) < 0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
if ((encoded_result = encode_message_type(registration_complete->messagetype, 0, buffer + encoded, len - encoded)) < 0) if ((encoded_result = encode_message_type(
registration_complete->messagetype, 0, buffer + encoded,
len - encoded)) < 0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
if ((encoded_result = encode_sor_transparent_container(registration_complete->sortransparentcontainer, 0, buffer + encoded, len - encoded)) < 0) if ((encoded_result = encode_sor_transparent_container(
registration_complete->sortransparentcontainer, 0, buffer + encoded,
len - encoded)) < 0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. * file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -30,20 +30,16 @@ ...@@ -30,20 +30,16 @@
#include "SORTransparentContainer.h" #include "SORTransparentContainer.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */ /* Minimum length macro. Formed by minimum length of each mandatory field */
#define REGISTRATION_COMPLETE_MINIMUM_LENGTH ( \ #define REGISTRATION_COMPLETE_MINIMUM_LENGTH \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \ (EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
SECURITY_HEADER_TYPE_MINIMUM_LENGTH + \ SECURITY_HEADER_TYPE_MINIMUM_LENGTH + MESSAGE_TYPE_MINIMUM_LENGTH + \
MESSAGE_TYPE_MINIMUM_LENGTH + \ SOR_TRANSPARENT_CONTAINER_MINIMUM_LENGTH + 0)
SOR_TRANSPARENT_CONTAINER_MINIMUM_LENGTH + \
0)
/* Maximum length macro. Formed by maximum length of each field */ /* Maximum length macro. Formed by maximum length of each field */
#define REGISTRATION_COMPLETE_MAXIMUM_LENGTH ( \ #define REGISTRATION_COMPLETE_MAXIMUM_LENGTH \
EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \ (EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \
SECURITY_HEADER_TYPE_MAXIMUM_LENGTH + \ SECURITY_HEADER_TYPE_MAXIMUM_LENGTH + MESSAGE_TYPE_MAXIMUM_LENGTH + \
MESSAGE_TYPE_MAXIMUM_LENGTH + \ SOR_TRANSPARENT_CONTAINER_MAXIMUM_LENGTH + 0)
SOR_TRANSPARENT_CONTAINER_MAXIMUM_LENGTH + \
0)
typedef struct registration_complete_msg_tag { typedef struct registration_complete_msg_tag {
ExtendedProtocolDiscriminator extendedprotocoldiscriminator; ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
...@@ -52,7 +48,11 @@ typedef struct registration_complete_msg_tag { ...@@ -52,7 +48,11 @@ typedef struct registration_complete_msg_tag {
SORTransparentContainer sortransparentcontainer; SORTransparentContainer sortransparentcontainer;
} registration_complete_msg; } registration_complete_msg;
int decode_registration_complete(registration_complete_msg *registrationcomplete, uint8_t *buffer, uint32_t len); int decode_registration_complete(
int encode_registration_complete(registration_complete_msg *registrationcomplete, uint8_t *buffer, uint32_t len); registration_complete_msg* registrationcomplete, uint8_t* buffer,
uint32_t len);
int encode_registration_complete(
registration_complete_msg* registrationcomplete, uint8_t* buffer,
uint32_t len);
#endif #endif
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. * file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -27,45 +27,65 @@ ...@@ -27,45 +27,65 @@
#include "TLVDecoder.h" #include "TLVDecoder.h"
#include "RegistrationReject.h" #include "RegistrationReject.h"
int decode_registration_reject(registration_reject_msg *registration_reject, uint8_t *buffer, uint32_t len) { int decode_registration_reject(
uint32_t decoded = 0; registration_reject_msg* registration_reject, uint8_t* buffer,
uint32_t len) {
uint32_t decoded = 0;
int decoded_result = 0; int decoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length
CHECK_PDU_POINTER_AND_LENGTH_DECODER(buffer, REGISTRATION_REJECT_MINIMUM_LENGTH, len); // expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_DECODER(
buffer, REGISTRATION_REJECT_MINIMUM_LENGTH, len);
if ((decoded_result = decode__5gmm_cause(&registration_reject->_5gmmcause, 0, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode__5gmm_cause(
&registration_reject->_5gmmcause, 0, buffer + decoded,
len - decoded)) < 0)
return decoded_result; return decoded_result;
else else
decoded += decoded_result; decoded += decoded_result;
while (len - decoded > 0) { while (len - decoded > 0) {
uint8_t ieiDecoded = *(buffer + decoded); uint8_t ieiDecoded = *(buffer + decoded);
if ((ieiDecoded != REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_IEI) && (ieiDecoded != REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_IEI) && (ieiDecoded != REGISTRATION_REJECT_EAP_MESSAGE_IEI)) if ((ieiDecoded != REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_IEI) &&
(ieiDecoded != REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_IEI) &&
(ieiDecoded != REGISTRATION_REJECT_EAP_MESSAGE_IEI))
break; break;
switch (ieiDecoded) { switch (ieiDecoded) {
case REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_IEI: case REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_IEI:
if ((decoded_result = decode_gprs_timer2(&registration_reject->t3346, REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_IEI, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_gprs_timer2(
&registration_reject->t3346,
REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_IEI,
buffer + decoded, len - decoded)) < 0)
return decoded_result; return decoded_result;
else { else {
decoded += decoded_result; decoded += decoded_result;
registration_reject->presence |= REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_PRESENT; registration_reject->presence |=
REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_PRESENT;
} }
break; break;
case REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_IEI: case REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_IEI:
if ((decoded_result = decode_gprs_timer2(&registration_reject->t3502, REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_IEI, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_gprs_timer2(
&registration_reject->t3502,
REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_IEI,
buffer + decoded, len - decoded)) < 0)
return decoded_result; return decoded_result;
else { else {
decoded += decoded_result; decoded += decoded_result;
registration_reject->presence |= REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_PRESENT; registration_reject->presence |=
REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_PRESENT;
} }
break; break;
case REGISTRATION_REJECT_EAP_MESSAGE_IEI: case REGISTRATION_REJECT_EAP_MESSAGE_IEI:
if ((decoded_result = decode_eap_message(&registration_reject->eapmessage, REGISTRATION_REJECT_EAP_MESSAGE_IEI, buffer + decoded, len - decoded)) < 0) if ((decoded_result = decode_eap_message(
&registration_reject->eapmessage,
REGISTRATION_REJECT_EAP_MESSAGE_IEI, buffer + decoded,
len - decoded)) < 0)
return decoded_result; return decoded_result;
else { else {
decoded += decoded_result; decoded += decoded_result;
registration_reject->presence |= REGISTRATION_REJECT_EAP_MESSAGE_PRESENT; registration_reject->presence |=
REGISTRATION_REJECT_EAP_MESSAGE_PRESENT;
} }
break; break;
} }
...@@ -74,34 +94,55 @@ int decode_registration_reject(registration_reject_msg *registration_reject, uin ...@@ -74,34 +94,55 @@ int decode_registration_reject(registration_reject_msg *registration_reject, uin
return decoded; return decoded;
} }
int encode_registration_reject(registration_reject_msg *registration_reject, uint8_t *buffer, uint32_t len) { int encode_registration_reject(
uint32_t encoded = 0; registration_reject_msg* registration_reject, uint8_t* buffer,
uint32_t len) {
uint32_t encoded = 0;
int encoded_result = 0; int encoded_result = 0;
// Check if we got a NULL pointer and if buffer length is >= minimum length expected for the message. // Check if we got a NULL pointer and if buffer length is >= minimum length
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, REGISTRATION_REJECT_MINIMUM_LENGTH, len); // expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(
buffer, REGISTRATION_REJECT_MINIMUM_LENGTH, len);
if ((encoded_result = encode__5gmm_cause(registration_reject->_5gmmcause, 0, buffer + encoded, len - encoded)) < 0) if ((encoded_result = encode__5gmm_cause(
registration_reject->_5gmmcause, 0, buffer + encoded,
len - encoded)) < 0)
return encoded_result; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
if ((registration_reject->presence & REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_PRESENT) == REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_PRESENT) { if ((registration_reject->presence &
if ((encoded_result = encode_gprs_timer2(registration_reject->t3346, REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_IEI, buffer + encoded, len - encoded)) < 0) 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; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
} }
if ((registration_reject->presence & REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_PRESENT) == REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_PRESENT) { if ((registration_reject->presence &
if ((encoded_result = encode_gprs_timer2(registration_reject->t3502, REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_IEI, buffer + encoded, len - encoded)) < 0) 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; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
} }
if ((registration_reject->presence & REGISTRATION_REJECT_EAP_MESSAGE_PRESENT) == REGISTRATION_REJECT_EAP_MESSAGE_PRESENT) { if ((registration_reject->presence &
if ((encoded_result = encode_eap_message(registration_reject->eapmessage, REGISTRATION_REJECT_EAP_MESSAGE_IEI, buffer + encoded, len - encoded)) < 0) 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; return encoded_result;
else else
encoded += encoded_result; encoded += encoded_result;
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. * file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -32,33 +32,27 @@ ...@@ -32,33 +32,27 @@
#include "EAPMessage.h" #include "EAPMessage.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */ /* Minimum length macro. Formed by minimum length of each mandatory field */
#define REGISTRATION_REJECT_MINIMUM_LENGTH ( \ #define REGISTRATION_REJECT_MINIMUM_LENGTH \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \ (EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
SECURITY_HEADER_TYPE_MINIMUM_LENGTH + \ SECURITY_HEADER_TYPE_MINIMUM_LENGTH + MESSAGE_TYPE_MINIMUM_LENGTH + \
MESSAGE_TYPE_MINIMUM_LENGTH + \ _5GMM_CAUSE_MINIMUM_LENGTH + GPRS_TIMER2_MINIMUM_LENGTH + \
_5GMM_CAUSE_MINIMUM_LENGTH + \ EAP_MESSAGE_MINIMUM_LENGTH + 0)
GPRS_TIMER2_MINIMUM_LENGTH + \
EAP_MESSAGE_MINIMUM_LENGTH + \
0)
/* Maximum length macro. Formed by maximum length of each field */ /* Maximum length macro. Formed by maximum length of each field */
#define REGISTRATION_REJECT_MAXIMUM_LENGTH ( \ #define REGISTRATION_REJECT_MAXIMUM_LENGTH \
EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \ (EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \
SECURITY_HEADER_TYPE_MAXIMUM_LENGTH + \ SECURITY_HEADER_TYPE_MAXIMUM_LENGTH + MESSAGE_TYPE_MAXIMUM_LENGTH + \
MESSAGE_TYPE_MAXIMUM_LENGTH + \ _5GMM_CAUSE_MAXIMUM_LENGTH + GPRS_TIMER2_MAXIMUM_LENGTH + \
_5GMM_CAUSE_MAXIMUM_LENGTH + \ EAP_MESSAGE_MAXIMUM_LENGTH + 0)
GPRS_TIMER2_MAXIMUM_LENGTH + \
EAP_MESSAGE_MAXIMUM_LENGTH + \
0)
#define REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_IEI 0x5f #define REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_IEI 0x5f
#define REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_PRESENT (1<<0) #define REGISTRATION_REJECT_GPRSTIMER2_T3346_VALUE_PRESENT (1 << 0)
#define REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_IEI 0x16 #define REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_IEI 0x16
#define REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_PRESENT (1<<1) #define REGISTRATION_REJECT_GPRSTIMER2_T3502_VALUE_PRESENT (1 << 1)
#define REGISTRATION_REJECT_EAP_MESSAGE_IEI 0x78 #define REGISTRATION_REJECT_EAP_MESSAGE_IEI 0x78
#define REGISTRATION_REJECT_EAP_MESSAGE_PRESENT (1<<2) #define REGISTRATION_REJECT_EAP_MESSAGE_PRESENT (1 << 2)
typedef struct registration_reject_msg_tag { typedef struct registration_reject_msg_tag {
ExtendedProtocolDiscriminator extendedprotocoldiscriminator; ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
...@@ -72,7 +66,9 @@ typedef struct registration_reject_msg_tag { ...@@ -72,7 +66,9 @@ typedef struct registration_reject_msg_tag {
EAPMessage eapmessage; EAPMessage eapmessage;
} registration_reject_msg; } registration_reject_msg;
int decode_registration_reject(registration_reject_msg *registrationreject, uint8_t *buffer, uint32_t len); int decode_registration_reject(
int encode_registration_reject(registration_reject_msg *registrationreject, uint8_t *buffer, uint32_t len); registration_reject_msg* registrationreject, uint8_t* buffer, uint32_t len);
int encode_registration_reject(
registration_reject_msg* registrationreject, uint8_t* buffer, uint32_t len);
#endif #endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. * file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -38,49 +38,42 @@ ...@@ -38,49 +38,42 @@
#include "S1UESecurityCapability.h" #include "S1UESecurityCapability.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */ /* Minimum length macro. Formed by minimum length of each mandatory field */
#define SECURITY_MODE_COMMAND_MINIMUM_LENGTH ( \ #define SECURITY_MODE_COMMAND_MINIMUM_LENGTH \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \ (EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
SECURITY_HEADER_TYPE_MINIMUM_LENGTH + \ SECURITY_HEADER_TYPE_MINIMUM_LENGTH + MESSAGE_TYPE_MINIMUM_LENGTH + \
MESSAGE_TYPE_MINIMUM_LENGTH + \ NAS_SECURITY_ALGORITHMS_MINIMUM_LENGTH + \
NAS_SECURITY_ALGORITHMS_MINIMUM_LENGTH + \ NAS_KEY_SET_IDENTIFIER_MINIMUM_LENGTH + \
NAS_KEY_SET_IDENTIFIER_MINIMUM_LENGTH + \ UE_SECURITY_CAPABILITY_MINIMUM_LENGTH + IMEISV_REQUEST_MINIMUM_LENGTH + \
UE_SECURITY_CAPABILITY_MINIMUM_LENGTH + \ EPSNAS_SECURITY_ALGORITHMS_MINIMUM_LENGTH + \
IMEISV_REQUEST_MINIMUM_LENGTH + \ ADDITIONAL_5G_SECURITY_INFORMATION_MINIMUM_LENGTH + \
EPSNAS_SECURITY_ALGORITHMS_MINIMUM_LENGTH + \ EAP_MESSAGE_MINIMUM_LENGTH + ABBA_MINIMUM_LENGTH + \
ADDITIONAL_5G_SECURITY_INFORMATION_MINIMUM_LENGTH + \ S1_UE_SECURITY_CAPABILITY_MINIMUM_LENGTH + 0)
EAP_MESSAGE_MINIMUM_LENGTH + \
ABBA_MINIMUM_LENGTH + \
S1_UE_SECURITY_CAPABILITY_MINIMUM_LENGTH + \
0)
/* Maximum length macro. Formed by maximum length of each field */ /* Maximum length macro. Formed by maximum length of each field */
#define SECURITY_MODE_COMMAND_MAXIMUM_LENGTH ( \ #define SECURITY_MODE_COMMAND_MAXIMUM_LENGTH \
EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \ (EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \
SECURITY_HEADER_TYPE_MAXIMUM_LENGTH + \ SECURITY_HEADER_TYPE_MAXIMUM_LENGTH + MESSAGE_TYPE_MAXIMUM_LENGTH + \
MESSAGE_TYPE_MAXIMUM_LENGTH + \ NAS_SECURITY_ALGORITHMS_MAXIMUM_LENGTH + \
NAS_SECURITY_ALGORITHMS_MAXIMUM_LENGTH + \ NAS_KEY_SET_IDENTIFIER_MAXIMUM_LENGTH + \
NAS_KEY_SET_IDENTIFIER_MAXIMUM_LENGTH + \ UE_SECURITY_CAPABILITY_MAXIMUM_LENGTH + IMEISV_REQUEST_MAXIMUM_LENGTH + \
UE_SECURITY_CAPABILITY_MAXIMUM_LENGTH + \ EPSNAS_SECURITY_ALGORITHMS_MAXIMUM_LENGTH + \
IMEISV_REQUEST_MAXIMUM_LENGTH + \ ADDITIONAL_5G_SECURITY_INFORMATION_MAXIMUM_LENGTH + \
EPSNAS_SECURITY_ALGORITHMS_MAXIMUM_LENGTH + \ EAP_MESSAGE_MAXIMUM_LENGTH + ABBA_MAXIMUM_LENGTH + \
ADDITIONAL_5G_SECURITY_INFORMATION_MAXIMUM_LENGTH + \ S1_UE_SECURITY_CAPABILITY_MAXIMUM_LENGTH + 0)
EAP_MESSAGE_MAXIMUM_LENGTH + \
ABBA_MAXIMUM_LENGTH + \
S1_UE_SECURITY_CAPABILITY_MAXIMUM_LENGTH + \
0)
#define SECURITY_MODE_COMMAND_IMEISV_REQUEST_IEI 0xE0 #define SECURITY_MODE_COMMAND_IMEISV_REQUEST_IEI 0xE0
#define SECURITY_MODE_COMMAND_IMEISV_REQUEST_PRESENT (1<<0) #define SECURITY_MODE_COMMAND_IMEISV_REQUEST_PRESENT (1 << 0)
#define SECURITY_MODE_COMMAND_EPS_NAS_SECURITY_ALGORITHMS_IEI 0x57 #define SECURITY_MODE_COMMAND_EPS_NAS_SECURITY_ALGORITHMS_IEI 0x57
#define SECURITY_MODE_COMMAND_EPS_NAS_SECURITY_ALGORITHMS_PRESENT (1<<1) #define SECURITY_MODE_COMMAND_EPS_NAS_SECURITY_ALGORITHMS_PRESENT (1 << 1)
#define SECURITY_MODE_COMMAND_ADDITIONAL_5G_SECURITY_INFORMATION_IEI 0x36 #define SECURITY_MODE_COMMAND_ADDITIONAL_5G_SECURITY_INFORMATION_IEI 0x36
#define SECURITY_MODE_COMMAND_ADDITIONAL_5G_SECURITY_INFORMATION_PRESENT (1<<2) #define SECURITY_MODE_COMMAND_ADDITIONAL_5G_SECURITY_INFORMATION_PRESENT \
(1 << 2)
#define SECURITY_MODE_COMMAND_EAP_MESSAGE_IEI 0x78 #define SECURITY_MODE_COMMAND_EAP_MESSAGE_IEI 0x78
#define SECURITY_MODE_COMMAND_EAP_MESSAGE_PRESENT (1<<3) #define SECURITY_MODE_COMMAND_EAP_MESSAGE_PRESENT (1 << 3)
#define SECURITY_MODE_COMMAND_ABBA_IEI 0x38 #define SECURITY_MODE_COMMAND_ABBA_IEI 0x38
#define SECURITY_MODE_COMMAND_ABBA_PRESENT (1<<4) #define SECURITY_MODE_COMMAND_ABBA_PRESENT (1 << 4)
#define SECURITY_MODE_COMMAND_S1_UE_SECURITY_CAPABILITY_IEI 0x19 #define SECURITY_MODE_COMMAND_S1_UE_SECURITY_CAPABILITY_IEI 0x19
#define SECURITY_MODE_COMMAND_S1_UE_SECURITY_CAPABILITY_PRESENT (1<<5) #define SECURITY_MODE_COMMAND_S1_UE_SECURITY_CAPABILITY_PRESENT (1 << 5)
typedef struct security_mode_command_msg_tag { typedef struct security_mode_command_msg_tag {
ExtendedProtocolDiscriminator extendedprotocoldiscriminator; ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
...@@ -95,10 +88,14 @@ typedef struct security_mode_command_msg_tag { ...@@ -95,10 +88,14 @@ typedef struct security_mode_command_msg_tag {
Additional5GSecurityInformation additional5gsecurityinformation; Additional5GSecurityInformation additional5gsecurityinformation;
EAPMessage eapmessage; EAPMessage eapmessage;
ABBA abba; ABBA abba;
//S1UESecurityCapability s1uesecuritycapability; // S1UESecurityCapability s1uesecuritycapability;
} security_mode_command_msg; } security_mode_command_msg;
int decode_security_mode_command(security_mode_command_msg *securitymodecommand, uint8_t *buffer, uint32_t len); int decode_security_mode_command(
int encode_security_mode_command(security_mode_command_msg *securitymodecommand, uint8_t *buffer, uint32_t len); security_mode_command_msg* securitymodecommand, uint8_t* buffer,
uint32_t len);
int encode_security_mode_command(
security_mode_command_msg* securitymodecommand, uint8_t* buffer,
uint32_t len);
#endif #endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. * file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -30,20 +30,16 @@ ...@@ -30,20 +30,16 @@
#include "_5GMMCause.h" #include "_5GMMCause.h"
/* Minimum length macro. Formed by minimum length of each mandatory field */ /* Minimum length macro. Formed by minimum length of each mandatory field */
#define SECURITY_MODE_REJECT_MINIMUM_LENGTH ( \ #define SECURITY_MODE_REJECT_MINIMUM_LENGTH \
EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \ (EXTENDED_PROTOCOL_DISCRIMINATOR_MINIMUM_LENGTH + \
SECURITY_HEADER_TYPE_MINIMUM_LENGTH + \ SECURITY_HEADER_TYPE_MINIMUM_LENGTH + MESSAGE_TYPE_MINIMUM_LENGTH + \
MESSAGE_TYPE_MINIMUM_LENGTH + \ _5GMM_CAUSE_MINIMUM_LENGTH + 0)
_5GMM_CAUSE_MINIMUM_LENGTH + \
0)
/* Maximum length macro. Formed by maximum length of each field */ /* Maximum length macro. Formed by maximum length of each field */
#define SECURITY_MODE_REJECT_MAXIMUM_LENGTH ( \ #define SECURITY_MODE_REJECT_MAXIMUM_LENGTH \
EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \ (EXTENDED_PROTOCOL_DISCRIMINATOR_MAXIMUM_LENGTH + \
SECURITY_HEADER_TYPE_MAXIMUM_LENGTH + \ SECURITY_HEADER_TYPE_MAXIMUM_LENGTH + MESSAGE_TYPE_MAXIMUM_LENGTH + \
MESSAGE_TYPE_MAXIMUM_LENGTH + \ _5GMM_CAUSE_MAXIMUM_LENGTH + 0)
_5GMM_CAUSE_MAXIMUM_LENGTH + \
0)
typedef struct security_mode_reject_msg_tag { typedef struct security_mode_reject_msg_tag {
ExtendedProtocolDiscriminator extendedprotocoldiscriminator; ExtendedProtocolDiscriminator extendedprotocoldiscriminator;
...@@ -52,7 +48,11 @@ typedef struct security_mode_reject_msg_tag { ...@@ -52,7 +48,11 @@ typedef struct security_mode_reject_msg_tag {
_5GMMCause _5gmmcause; _5GMMCause _5gmmcause;
} security_mode_reject_msg; } security_mode_reject_msg;
int decode_security_mode_reject(security_mode_reject_msg *securitymodereject, uint8_t *buffer, uint32_t len); int decode_security_mode_reject(
int encode_security_mode_reject(security_mode_reject_msg *securitymodereject, uint8_t *buffer, uint32_t len); security_mode_reject_msg* securitymodereject, uint8_t* buffer,
uint32_t len);
int encode_security_mode_reject(
security_mode_reject_msg* securitymodereject, uint8_t* buffer,
uint32_t len);
#endif #endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment