Commit 1dbeb565 authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Code cleanup for NAS MM Header

parent ee09cb41
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef FILE_3GPP_24_007_SEEN
#define FILE_3GPP_24_007_SEEN
#include <stdint.h>
// Extended Protocol Discriminator (EPD)
constexpr uint8_t kEpd5gsSessionManagementMessage = 0b00101110;
constexpr uint8_t kEpd5gsMobilityManagementMessage = 0b01111110;
#endif
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
#ifndef _3GPP_TS_24501_H_ #ifndef _3GPP_TS_24501_H_
#define _3GPP_TS_24501_H_ #define _3GPP_TS_24501_H_
#include "3gpp24.007.hpp"
#include <string> #include <string>
#include <vector> #include <vector>
...@@ -185,4 +187,6 @@ static const std::vector<std::string> nas_ciphering_algorithm_list_e2str = { ...@@ -185,4 +187,6 @@ static const std::vector<std::string> nas_ciphering_algorithm_list_e2str = {
#define NAS_MESSAGE_MIN_LENGTH 3 #define NAS_MESSAGE_MIN_LENGTH 3
constexpr uint8_t KEncodeDecodeError = 0;
#endif #endif
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
* contact@openairinterface.org * contact@openairinterface.org
*/ */
#include "NasMmPlainHeader.hpp"
#include "5GMMCapability.hpp" #include "5GMMCapability.hpp"
#include "5GSMobilityIdentity.hpp" #include "5GSMobilityIdentity.hpp"
#include "5GSRegistrationType.hpp" #include "5GSRegistrationType.hpp"
...@@ -78,6 +79,5 @@ ...@@ -78,6 +79,5 @@
#include "_5GS_Registration_Result.hpp" #include "_5GS_Registration_Result.hpp"
#include "_5GS_Tracking_Area_Identity.hpp" #include "_5GS_Tracking_Area_Identity.hpp"
#include "_5GS_Update_Type.hpp" #include "_5GS_Update_Type.hpp"
#include "nas_mm_plain_header.hpp"
#include "struct.hpp" #include "struct.hpp"
#include "Ie_Const.hpp" #include "Ie_Const.hpp"
...@@ -19,26 +19,54 @@ ...@@ -19,26 +19,54 @@
* contact@openairinterface.org * contact@openairinterface.org
*/ */
/*! \file
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "ExtendedProtocolDiscriminator.hpp" #include "ExtendedProtocolDiscriminator.hpp"
#include "3gpp_ts24501.hpp"
#include "common_defs.h"
#include "logger.hpp"
using namespace nas; using namespace nas;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ExtendedProtocolDiscriminator::setValue(const uint8_t epd) { ExtendedProtocolDiscriminator::ExtendedProtocolDiscriminator() {}
m_epd = epd;
//------------------------------------------------------------------------------
ExtendedProtocolDiscriminator::~ExtendedProtocolDiscriminator() {}
//------------------------------------------------------------------------------
void ExtendedProtocolDiscriminator::Set(const uint8_t& epd) {
epd_ = epd;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
uint8_t ExtendedProtocolDiscriminator::getValue() { void ExtendedProtocolDiscriminator::Get(uint8_t& epd) const {
return m_epd; epd = epd_;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ExtendedProtocolDiscriminator::encode2buffer(uint8_t* buf, int len) {} uint8_t ExtendedProtocolDiscriminator::Get() const {
return epd_;
}
//------------------------------------------------------------------------------
uint32_t ExtendedProtocolDiscriminator::Encode(uint8_t* buf, uint32_t len) {
if (len < kEdpIeSize) {
Logger::nas_mm().error("Buffer length is less than %d octet", kEdpIeSize);
return KEncodeDecodeError;
}
uint32_t encoded_size = 0;
ENCODE_U8(buf, epd_, encoded_size);
return encoded_size;
}
//------------------------------------------------------------------------------
uint32_t ExtendedProtocolDiscriminator::Decode(
const uint8_t* const buf, uint32_t len) {
if (len < kEdpIeSize) {
Logger::nas_mm().error("Buffer length is less than %s octet", kEdpIeSize);
return KEncodeDecodeError;
}
uint32_t decoded_size = 0;
DECODE_U8(buf, epd_, decoded_size);
return decoded_size;
}
...@@ -19,28 +19,29 @@ ...@@ -19,28 +19,29 @@
* contact@openairinterface.org * contact@openairinterface.org
*/ */
/*! \file #ifndef EXTENDED_PROTOCOL_DISCRIMINATOR_H_
\brief #define EXTENDED_PROTOCOL_DISCRIMINATOR_H_
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _EPD_H_
#define _EPD_H_
#include <stdint.h> #include <stdint.h>
constexpr uint8_t kEdpIeSize = 1;
namespace nas { namespace nas {
class ExtendedProtocolDiscriminator { class ExtendedProtocolDiscriminator {
public: public:
void encode2buffer(uint8_t* buf, int len); ExtendedProtocolDiscriminator();
void setValue(const uint8_t epd); virtual ~ExtendedProtocolDiscriminator();
uint8_t getValue();
void Set(const uint8_t& epd);
void Get(uint8_t& epd) const;
uint8_t Get() const;
uint32_t Encode(uint8_t* buf, uint32_t len);
uint32_t Decode(const uint8_t* const buf, uint32_t len);
private: private:
uint8_t m_epd; uint8_t epd_;
}; };
} // namespace nas } // namespace nas
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include <vector> #include <vector>
#include "nas_ie_header.hpp" #include "NasIeHeader.hpp"
namespace nas { namespace nas {
......
...@@ -19,23 +19,55 @@ ...@@ -19,23 +19,55 @@
* contact@openairinterface.org * contact@openairinterface.org
*/ */
/*! \file
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "NasMessageType.hpp" #include "NasMessageType.hpp"
#include "3gpp_ts24501.hpp"
#include "common_defs.h"
#include "logger.hpp"
using namespace nas; using namespace nas;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void NasMessageType::setValue(const uint8_t type) { NasMessageType::NasMessageType() {}
m_type = type;
//------------------------------------------------------------------------------
NasMessageType::~NasMessageType() {}
//------------------------------------------------------------------------------
void NasMessageType::Set(const uint8_t& message_type) {
message_type_ = message_type;
}
//------------------------------------------------------------------------------
void NasMessageType::Get(uint8_t& message_type) const {
message_type = message_type_;
}
//------------------------------------------------------------------------------
uint8_t NasMessageType::Get() const {
return message_type_;
}
//------------------------------------------------------------------------------
uint32_t NasMessageType::Encode(uint8_t* buf, uint32_t len) {
if (len < kNasMessageTypeIeSize) {
Logger::nas_mm().error(
"Buffer length is less than %d octet", kNasMessageTypeIeSize);
return KEncodeDecodeError;
}
uint32_t encoded_size = 0;
ENCODE_U8(buf, message_type_, encoded_size);
return encoded_size;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
uint8_t NasMessageType::getValue() { uint32_t NasMessageType::Decode(const uint8_t* const buf, uint32_t len) {
return m_type; if (len < kNasMessageTypeIeSize) {
Logger::nas_mm().error(
"Buffer length is less than %s octet", kNasMessageTypeIeSize);
return KEncodeDecodeError;
}
uint32_t decoded_size = 0;
DECODE_U8(buf, message_type_, decoded_size);
return decoded_size;
} }
...@@ -19,27 +19,29 @@ ...@@ -19,27 +19,29 @@
* contact@openairinterface.org * contact@openairinterface.org
*/ */
/*! \file
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _MESSAGE_TYPE_H_ #ifndef _MESSAGE_TYPE_H_
#define _MESSAGE_TYPE_H_ #define _MESSAGE_TYPE_H_
#include <stdint.h> #include <stdint.h>
constexpr uint8_t kNasMessageTypeIeSize = 1;
namespace nas { namespace nas {
class NasMessageType { class NasMessageType {
public: public:
void setValue(const uint8_t type); NasMessageType();
uint8_t getValue(); virtual ~NasMessageType();
void Set(const uint8_t& message_type);
void Get(uint8_t& message_type) const;
uint8_t Get() const;
uint32_t Encode(uint8_t* buf, uint32_t len);
uint32_t Decode(const uint8_t* const buf, uint32_t len);
private: private:
uint8_t m_type; uint8_t message_type_;
}; };
} // namespace nas } // namespace nas
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include <iostream> #include <iostream>
#include <vector> #include <vector>
#include "nas_ie_header.hpp" #include "NasIeHeader.hpp"
extern "C" { extern "C" {
#include "TLVDecoder.h" #include "TLVDecoder.h"
#include "TLVEncoder.h" #include "TLVEncoder.h"
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include <stdint.h> #include <stdint.h>
#include "nas_ie_header.hpp" #include "NasIeHeader.hpp"
#include <optional> #include <optional>
namespace nas { namespace nas {
......
...@@ -19,23 +19,64 @@ ...@@ -19,23 +19,64 @@
* contact@openairinterface.org * contact@openairinterface.org
*/ */
/*! \file
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "SecurityHeaderType.hpp" #include "SecurityHeaderType.hpp"
#include "3gpp_ts24501.hpp"
#include "common_defs.h"
#include "logger.hpp"
using namespace nas; using namespace nas;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void SecurityHeaderType::setValue(const uint8_t value) { SecurityHeaderType::SecurityHeaderType() {}
secu_header_type = 0x0f & value;
//------------------------------------------------------------------------------
SecurityHeaderType::~SecurityHeaderType() {}
//------------------------------------------------------------------------------
void SecurityHeaderType::Set(
const uint8_t& secu_header_type, const uint8_t& spare) {
secu_header_type_ = 0x0f & secu_header_type;
spare_ = spare & 0xf0;
}
//------------------------------------------------------------------------------
void SecurityHeaderType::Get(uint8_t& secu_header_type) const {
secu_header_type = secu_header_type_ & 0x0f;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
uint8_t SecurityHeaderType::getValue() { uint8_t SecurityHeaderType::Get() const {
return secu_header_type & 0x0f; return (secu_header_type_ & 0x0f);
}
//------------------------------------------------------------------------------
uint32_t SecurityHeaderType::Encode(uint8_t* buf, uint32_t len) {
if (len < kSecurityHeaderIeSize) {
Logger::nas_mm().error(
"Buffer length is less than %d octet", kSecurityHeaderIeSize);
return KEncodeDecodeError;
}
uint8_t value = (secu_header_type_ & 0x0f) | (spare_ & 0xf0);
uint32_t encoded_size = 0;
ENCODE_U8(buf, value, encoded_size);
return encoded_size;
}
//------------------------------------------------------------------------------
uint32_t SecurityHeaderType::Decode(const uint8_t* const buf, uint32_t len) {
if (len < kSecurityHeaderIeSize) {
Logger::nas_mm().error(
"Buffer length is less than %s octet", kSecurityHeaderIeSize);
return KEncodeDecodeError;
}
uint8_t value;
uint32_t decoded_size = 0;
DECODE_U8(buf, value, decoded_size);
secu_header_type_ = 0x0f & value;
spare_ = value & 0xf0;
return decoded_size;
} }
...@@ -19,27 +19,30 @@ ...@@ -19,27 +19,30 @@
* contact@openairinterface.org * contact@openairinterface.org
*/ */
/*! \file
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _SECURITY_HEADER_TYPE_H_ #ifndef _SECURITY_HEADER_TYPE_H_
#define _SECURITY_HEADER_TYPE_H_ #define _SECURITY_HEADER_TYPE_H_
#include <stdint.h> #include <stdint.h>
constexpr uint8_t kSecurityHeaderIeSize = 1;
namespace nas { namespace nas {
class SecurityHeaderType { class SecurityHeaderType {
public: public:
void setValue(const uint8_t value); SecurityHeaderType();
uint8_t getValue(); virtual ~SecurityHeaderType();
void Set(const uint8_t& secu_header_type, const uint8_t& spare = 0);
void Get(uint8_t& secu_header_type) const;
uint8_t Get() const;
uint32_t Encode(uint8_t* buf, uint32_t len);
uint32_t Decode(const uint8_t* const buf, uint32_t len);
private: private:
uint8_t secu_header_type : 4; uint8_t spare_ : 4;
uint8_t secu_header_type_ : 4;
}; };
} // namespace nas } // namespace nas
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#ifndef _AuthenticationFailure_H_ #ifndef _AuthenticationFailure_H_
#define _AuthenticationFailure_H_ #define _AuthenticationFailure_H_
#include "nas_ie_header.hpp" #include "NasIeHeader.hpp"
namespace nas { namespace nas {
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#ifndef _AuthenticationReject_H_ #ifndef _AuthenticationReject_H_
#define _AuthenticationReject_H_ #define _AuthenticationReject_H_
#include "nas_ie_header.hpp" #include "NasIeHeader.hpp"
namespace nas { namespace nas {
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#ifndef _AuthenticationRequest_H_ #ifndef _AuthenticationRequest_H_
#define _AuthenticationRequest_H_ #define _AuthenticationRequest_H_
#include "nas_ie_header.hpp" #include "NasIeHeader.hpp"
namespace nas { namespace nas {
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#ifndef _AuthenticationResponse_H_ #ifndef _AuthenticationResponse_H_
#define _AuthenticationResponse_H_ #define _AuthenticationResponse_H_
#include "nas_ie_header.hpp" #include "NasIeHeader.hpp"
namespace nas { namespace nas {
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#ifndef _AuthenticationResult_H_ #ifndef _AuthenticationResult_H_
#define _AuthenticationResult_H_ #define _AuthenticationResult_H_
#include "nas_ie_header.hpp" #include "NasIeHeader.hpp"
namespace nas { namespace nas {
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#ifndef _DLNASTransport_H_ #ifndef _DLNASTransport_H_
#define _DLNASTransport_H_ #define _DLNASTransport_H_
#include "nas_ie_header.hpp" #include "NasIeHeader.hpp"
namespace nas { namespace nas {
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#ifndef _DEREGISTRATION_ACCEPT_H_ #ifndef _DEREGISTRATION_ACCEPT_H_
#define _DEREGISTRATION_ACCEPT_H_ #define _DEREGISTRATION_ACCEPT_H_
#include "nas_ie_header.hpp" #include "NasIeHeader.hpp"
namespace nas { namespace nas {
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#ifndef _DEREGISTRATION_REQUEST_H_ #ifndef _DEREGISTRATION_REQUEST_H_
#define _DEREGISTRATION_REQUEST_H_ #define _DEREGISTRATION_REQUEST_H_
#include "nas_ie_header.hpp" #include "NasIeHeader.hpp"
using namespace std; using namespace std;
namespace nas { namespace nas {
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#ifndef _IdentityRequest_H_ #ifndef _IdentityRequest_H_
#define _IdentityRequest_H_ #define _IdentityRequest_H_
#include "nas_ie_header.hpp" #include "NasIeHeader.hpp"
namespace nas { namespace nas {
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#ifndef _IdentityResponse_H_ #ifndef _IdentityResponse_H_
#define _IdentityResponse_H_ #define _IdentityResponse_H_
#include "nas_ie_header.hpp" #include "NasIeHeader.hpp"
namespace nas { namespace nas {
......
...@@ -19,85 +19,118 @@ ...@@ -19,85 +19,118 @@
* contact@openairinterface.org * contact@openairinterface.org
*/ */
/*! \file
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "nas_mm_plain_header.hpp"
#include "3gpp_ts24501.hpp" #include "3gpp_ts24501.hpp"
#include "common_defs.h"
#include "logger.hpp" #include "logger.hpp"
#include "NasMmPlainHeader.hpp"
using namespace nas; using namespace nas;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void NasMmPlainHeader::setEpdIE(const uint8_t epd) { void NasMmPlainHeader::SetEpd(const uint8_t epd) {
ie_epd.setValue(epd); epd_.Set(epd);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
uint8_t NasMmPlainHeader::getEpdIE() { uint8_t NasMmPlainHeader::GetEpd() {
return ie_epd.getValue(); return epd_.Get();
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void NasMmPlainHeader::setSecurityHeaderTypeIE(const uint8_t type) { void NasMmPlainHeader::SetSecurityHeaderType(const uint8_t type) {
ie_secu_header_type.setValue(type); secu_header_type_.Set(type);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
uint8_t NasMmPlainHeader::getSecurityHeaderTypeIE() { uint8_t NasMmPlainHeader::GetSecurityHeaderType() {
return ie_secu_header_type.getValue(); return secu_header_type_.Get();
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void NasMmPlainHeader::setMessageTypeIE(const uint8_t type) { void NasMmPlainHeader::SetMessageType(const uint8_t type) {
ie_msg_type.setValue(type); msg_type_.Set(type);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
uint8_t NasMmPlainHeader::getMessageType() { uint8_t NasMmPlainHeader::GetMessageType() {
return msg_type; return msg_type_.Get();
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void NasMmPlainHeader::setHeader( void NasMmPlainHeader::setHeader(
uint8_t epd_, uint8_t security_header_type, uint8_t msg_type_) { const uint8_t& epd, const uint8_t& security_header_type,
epd = epd_; const uint8_t& msg_type) {
secu_header_type = security_header_type; epd_.Set(epd);
msg_type = msg_type_; secu_header_type_.Set(security_header_type);
msg_type_.Set(msg_type);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int NasMmPlainHeader::encode2buffer(uint8_t* buf, int len) { int NasMmPlainHeader::encode2buffer(uint8_t* buf, int len) {
Logger::nas_mm().debug("Encoding NasMmPlainHeader"); Logger::nas_mm().debug("Encoding NasMmPlainHeader");
if (len < 3) { if (len < kNasMmPlainHeaderLength) {
Logger::nas_mm().error("buffer length is less than 3 octets"); Logger::nas_mm().error("buffer length is less than 3 octets");
return 0; return KEncodeDecodeError;
} else { } else {
*(buf++) = epd; uint32_t encoded_size = 0;
*(buf++) = secu_header_type; uint32_t size = 0;
*(buf++) = msg_type; if ((size = epd_.Encode(buf + encoded_size, len - encoded_size)) ==
Logger::nas_mm().debug("Encoded NasMmPlainHeader (len 3 octets)"); KEncodeDecodeError) {
return 3; Logger::nas_mm().error("Encode NAS MM Header IE error");
return KEncodeDecodeError;
}
encoded_size += size;
if ((size = secu_header_type_.Encode(
buf + encoded_size, len - encoded_size)) == KEncodeDecodeError) {
Logger::nas_mm().error("Encode NAS MM Header IE error");
return KEncodeDecodeError;
}
encoded_size += size;
if ((size = msg_type_.Encode(buf + encoded_size, len - encoded_size)) ==
KEncodeDecodeError) {
Logger::nas_mm().error("Encode NAS MM Header IE error");
return KEncodeDecodeError;
}
encoded_size += size;
Logger::nas_mm().debug(
"Encoded NasMmPlainHeader (len %d octets)", encoded_size);
return encoded_size;
} }
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int NasMmPlainHeader::decodefrombuffer(uint8_t* buf, int len) { int NasMmPlainHeader::decodefrombuffer(const uint8_t* const buf, int len) {
Logger::nas_mm().debug("decoding NasMmPlainHeader"); Logger::nas_mm().debug("Decoding NasMmPlainHeader");
if (len < 3) { uint32_t decoded_size = 0;
Logger::nas_mm().error( if (len < kNasMmPlainHeaderLength) {
"[decoding nas mm header error][buffer length is less than 3 octets]"); Logger::nas_mm().error("Buffer length is less than 3 octets");
return 0; return KEncodeDecodeError;
} else { } else {
epd = *(buf++); uint32_t size = 0;
secu_header_type = *(buf++); if ((size = epd_.Decode(buf + decoded_size, len - decoded_size)) ==
msg_type = *(buf++); KEncodeDecodeError) {
Logger::nas_mm().error("Decode NAS MM Header IE error");
return KEncodeDecodeError;
}
decoded_size += size;
if ((size = secu_header_type_.Decode(
buf + decoded_size, len - decoded_size)) == KEncodeDecodeError) {
Logger::nas_mm().error("Decode NAS MM Header IE error");
return KEncodeDecodeError;
}
decoded_size += size;
if ((size = msg_type_.Decode(buf + decoded_size, len - decoded_size)) ==
KEncodeDecodeError) {
Logger::nas_mm().error("Decode NAS MM Header IE error");
return KEncodeDecodeError;
}
decoded_size += size;
} }
Logger::nas_mm().debug("decoded NasMmPlainHeader len(3 octets)"); Logger::nas_mm().debug(
return 3; "decoded NasMmPlainHeader len (%d octets)", decoded_size);
return decoded_size;
} }
...@@ -19,13 +19,6 @@ ...@@ -19,13 +19,6 @@
* contact@openairinterface.org * contact@openairinterface.org
*/ */
/*! \file
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _NAS_MM_PLAIN_HEADER_H_ #ifndef _NAS_MM_PLAIN_HEADER_H_
#define _NAS_MM_PLAIN_HEADER_H_ #define _NAS_MM_PLAIN_HEADER_H_
...@@ -33,27 +26,33 @@ ...@@ -33,27 +26,33 @@
#include "NasMessageType.hpp" #include "NasMessageType.hpp"
#include "SecurityHeaderType.hpp" #include "SecurityHeaderType.hpp"
constexpr uint8_t kNasMmPlainHeaderLength = 3;
namespace nas { namespace nas {
class NasMmPlainHeader { class NasMmPlainHeader {
public: public:
void setHeader(uint8_t epd_, uint8_t security_header_type, uint8_t msg_type_); void setHeader(
const uint8_t& epd, const uint8_t& security_header_type,
const uint8_t& msg_type);
int encode2buffer(uint8_t* buf, int len); int encode2buffer(uint8_t* buf, int len);
int decodefrombuffer(uint8_t* buf, int len); int decodefrombuffer(const uint8_t* const buf, int len);
void setEpdIE(const uint8_t epd);
void setSecurityHeaderTypeIE(const uint8_t type); void SetEpd(const uint8_t epd);
void setMessageTypeIE(const uint8_t type); uint8_t GetEpd();
uint8_t getEpdIE();
uint8_t getSecurityHeaderTypeIE(); void SetSecurityHeaderType(const uint8_t type);
uint8_t getMessageType(); uint8_t GetSecurityHeaderType();
void SetMessageType(const uint8_t type);
uint8_t GetMessageType();
private: private:
ExtendedProtocolDiscriminator ie_epd; ExtendedProtocolDiscriminator epd_; // Mandatory
SecurityHeaderType ie_secu_header_type; // TODO: Spare half octet (1/2 octet)
NasMessageType ie_msg_type; SecurityHeaderType secu_header_type_; // Mandatory (1/2 octet)
uint8_t epd; NasMessageType msg_type_; // Mandatory
uint8_t secu_header_type;
uint8_t msg_type;
}; };
} // namespace nas } // namespace nas
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#ifndef _RegistrationAccept_H_ #ifndef _RegistrationAccept_H_
#define _RegistrationAccept_H_ #define _RegistrationAccept_H_
#include "nas_ie_header.hpp" #include "NasIeHeader.hpp"
namespace nas { namespace nas {
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#ifndef _RegistrationComplete_H_ #ifndef _RegistrationComplete_H_
#define _RegistrationComplete_H_ #define _RegistrationComplete_H_
#include "nas_ie_header.hpp" #include "NasIeHeader.hpp"
namespace nas { namespace nas {
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#ifndef _RegistrationReject_H_ #ifndef _RegistrationReject_H_
#define _RegistrationReject_H_ #define _RegistrationReject_H_
#include "nas_ie_header.hpp" #include "NasIeHeader.hpp"
namespace nas { namespace nas {
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "nas_ie_header.hpp" #include "NasIeHeader.hpp"
using namespace std; using namespace std;
namespace nas { namespace nas {
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#ifndef _SecurityModeCommand_H_ #ifndef _SecurityModeCommand_H_
#define _SecurityModeCommand_H_ #define _SecurityModeCommand_H_
#include "nas_ie_header.hpp" #include "NasIeHeader.hpp"
namespace nas { namespace nas {
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#ifndef _SecurityModeComplete_H_ #ifndef _SecurityModeComplete_H_
#define _SecurityModeComplete_H_ #define _SecurityModeComplete_H_
#include "nas_ie_header.hpp" #include "NasIeHeader.hpp"
namespace nas { namespace nas {
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#ifndef _SecurityModeReject_H_ #ifndef _SecurityModeReject_H_
#define _SecurityModeReject_H_ #define _SecurityModeReject_H_
#include "nas_ie_header.hpp" #include "NasIeHeader.hpp"
namespace nas { namespace nas {
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include <string> #include <string>
#include "nas_ie_header.hpp" #include "NasIeHeader.hpp"
namespace nas { namespace nas {
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include <string> #include <string>
#include "bstrlib.h" #include "bstrlib.h"
#include "nas_ie_header.hpp" #include "NasIeHeader.hpp"
using namespace std; using namespace std;
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#ifndef _ULNASTransport_H_ #ifndef _ULNASTransport_H_
#define _ULNASTransport_H_ #define _ULNASTransport_H_
#include "nas_ie_header.hpp" #include "NasIeHeader.hpp"
namespace nas { namespace nas {
......
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