Commit f8b1a66e authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Update GetIeName

parent 818c01a7
......@@ -54,6 +54,8 @@ typedef enum {
} status_code_e;
//------------------------------------------------------------------------------
#define DECODE_U8_VALUE(bUFFER, vALUE) vALUE = *(uint8_t*) (bUFFER);
#define DECODE_U8(bUFFER, vALUE, sIZE) \
vALUE = *(uint8_t*) (bUFFER); \
sIZE += sizeof(uint8_t)
......
......@@ -35,7 +35,6 @@ _5GMMCapability::_5GMMCapability(const uint8_t iei, uint8_t octet3)
octet4_ = std::nullopt;
octet5_ = std::nullopt;
SetLengthIndicator(1);
SetIeName(k5gmmCapabilityIeName);
}
//------------------------------------------------------------------------------
......@@ -43,7 +42,6 @@ _5GMMCapability::_5GMMCapability() : Type4NasIe(kIei5gmmCapability) {
octet4_ = std::nullopt;
octet5_ = std::nullopt;
SetLengthIndicator(1);
SetIeName(k5gmmCapabilityIeName);
}
//------------------------------------------------------------------------------
......
......@@ -42,6 +42,8 @@ class _5GMMCapability : public Type4NasIe {
int Encode(uint8_t* buf, int len);
int Decode(uint8_t* buf, int len, bool is_iei = true);
static std::string GetIeName() { return k5gmmCapabilityIeName; }
private:
uint8_t octet3_; // minimum length of 3 octets
std::optional<uint8_t> octet4_;
......
......@@ -35,14 +35,12 @@ using namespace nas;
_5GSMobileIdentity::_5GSMobileIdentity() : Type6NasIe() {
type_of_identity_ = 0;
ClearIe();
SetIeName(k5gsMobileIdentityIeName);
}
//------------------------------------------------------------------------------
_5GSMobileIdentity::_5GSMobileIdentity(uint8_t iei) : Type6NasIe(iei) {
type_of_identity_ = 0;
ClearIe();
SetIeName(k5gsMobileIdentityIeName);
}
//------------------------------------------------------------------------------
......
......@@ -84,6 +84,8 @@ class _5GSMobileIdentity : public Type6NasIe {
_5GSMobileIdentity(uint8_t iei);
~_5GSMobileIdentity();
static std::string GetIeName() { return k5gsMobileIdentityIeName; }
// Common
void ClearIe();
uint8_t GetTypeOfIdentity() const { return type_of_identity_; };
......
......@@ -28,9 +28,7 @@ using namespace nas;
//------------------------------------------------------------------------------
_5GSRegistrationType::_5GSRegistrationType()
: Type1NasIeFormatTv(), follow_on_req_(false), reg_type_(0) {
SetIeName(k5gsRegistrationTypeName);
}
: Type1NasIeFormatTv(), follow_on_req_(false), reg_type_(0) {}
//------------------------------------------------------------------------------
_5GSRegistrationType::_5GSRegistrationType(
......@@ -38,7 +36,6 @@ _5GSRegistrationType::_5GSRegistrationType(
: Type1NasIeFormatTv(), follow_on_req_(follow_on_req) {
if (validateValue(follow_on_req, type)) reg_type_ = type;
setValue();
SetIeName(k5gsRegistrationTypeName);
}
//------------------------------------------------------------------------------
......@@ -48,7 +45,6 @@ _5GSRegistrationType::_5GSRegistrationType(
follow_on_req_ = follow_on_req;
if (validateValue(follow_on_req, type)) reg_type_ = type;
setValue();
SetIeName("5GS Registration Type");
}
//------------------------------------------------------------------------------
......
......@@ -36,6 +36,8 @@ class _5GSRegistrationType : public Type1NasIeFormatTv {
const uint8_t& iei, const bool& follow_on_req, const uint8_t& type);
virtual ~_5GSRegistrationType();
static std::string GetIeName() { return k5gsRegistrationTypeName; }
void setValue();
void getValue();
......
......@@ -29,13 +29,11 @@ using namespace nas;
//------------------------------------------------------------------------------
ABBA::ABBA() : Type4NasIe(), value_() {
SetLengthIndicator(0);
SetIeName(kAbbaIeName);
}
//------------------------------------------------------------------------------
ABBA::ABBA(uint8_t iei) : Type4NasIe(iei), value_() {
SetLengthIndicator(0);
SetIeName(kAbbaIeName);
}
//------------------------------------------------------------------------------
......@@ -44,7 +42,6 @@ ABBA::ABBA(uint8_t length, uint8_t* value) : Type4NasIe() {
this->value_[i] = value[i];
}
SetLengthIndicator(length);
SetIeName(kAbbaIeName);
}
//------------------------------------------------------------------------------
......@@ -53,7 +50,6 @@ ABBA::ABBA(uint8_t iei, uint8_t length, uint8_t* value) : Type4NasIe(iei) {
this->value_[i] = value[i];
}
SetLengthIndicator(length);
SetIeName(kAbbaIeName);
}
//------------------------------------------------------------------------------
......
......@@ -37,6 +37,8 @@ class ABBA : public Type4NasIe {
ABBA(uint8_t iei, uint8_t length, uint8_t* value);
~ABBA();
static std::string GetIeName() { return kAbbaIeName; }
void Set(uint8_t length, uint8_t* value);
void Set(uint8_t iei, uint8_t length, uint8_t* value);
......
......@@ -29,7 +29,6 @@ Additional5gSecurityInformation::Additional5gSecurityInformation()
rinmr_ = false;
hdp_ = false;
SetLengthIndicator(1);
SetIeName(kAdditional5gSecurityInformationIeName);
}
//------------------------------------------------------------------------------
......@@ -39,7 +38,6 @@ Additional5gSecurityInformation::Additional5gSecurityInformation(
rinmr_ = rinmr;
hdp_ = hdp;
SetLengthIndicator(1);
SetIeName(kAdditional5gSecurityInformationIeName);
}
//------------------------------------------------------------------------------
......
......@@ -36,6 +36,10 @@ class Additional5gSecurityInformation : public Type4NasIe {
Additional5gSecurityInformation(bool RINMR, bool HDP);
~Additional5gSecurityInformation();
static std::string GetIeName() {
return kAdditional5gSecurityInformationIeName;
}
int Encode(uint8_t* buf, int len);
int Decode(uint8_t* buf, int len, bool is_iei);
......
......@@ -27,14 +27,12 @@ using namespace nas;
AdditionalInformation::AdditionalInformation()
: Type4NasIe(kIeiAdditionalInformation), value_() {
SetLengthIndicator(1); // Minimum 3 octets (-2 for header)
SetIeName(kAdditionalInformationIeName);
}
//------------------------------------------------------------------------------
AdditionalInformation::AdditionalInformation(const bstring& value) {
value_ = bstrcpy(value);
SetLengthIndicator(blength(value));
SetIeName(kAdditionalInformationIeName);
}
//------------------------------------------------------------------------------
......
......@@ -36,6 +36,8 @@ class AdditionalInformation : public Type4NasIe {
AdditionalInformation(const bstring& value);
~AdditionalInformation();
static std::string GetIeName() { return kAdditionalInformationIeName; }
int Encode(uint8_t* buf, int len);
int Decode(uint8_t* buf, int len, bool is_iei);
......
......@@ -33,7 +33,6 @@ AllowedPDUSessionStatus::AllowedPDUSessionStatus()
: Type4NasIe(kIeiAllowedPduSessionStatus) {
_value = 0;
SetLengthIndicator(2);
SetIeName(kAllowedPDUSessionStatusIeName);
}
//------------------------------------------------------------------------------
......@@ -41,7 +40,6 @@ AllowedPDUSessionStatus::AllowedPDUSessionStatus(uint16_t value)
: Type4NasIe(kIeiAllowedPduSessionStatus) {
_value = value;
SetLengthIndicator(2);
SetIeName(kAllowedPDUSessionStatusIeName);
}
//------------------------------------------------------------------------------
......
......@@ -36,6 +36,8 @@ class AllowedPDUSessionStatus : public Type4NasIe {
AllowedPDUSessionStatus(uint16_t value);
~AllowedPDUSessionStatus();
static std::string GetIeName() { return kAllowedPDUSessionStatusIeName; }
void SetValue(uint16_t value);
uint16_t GetValue() const;
......
......@@ -27,7 +27,6 @@ using namespace nas;
AuthenticationFailureParameter::AuthenticationFailureParameter()
: Type4NasIe(kIeiAuthenticationFailureParameter), value_() {
SetLengthIndicator(kAuthenticationFailureParameterContentLength);
SetIeName(kAuthenticationFailureParameterIeName);
}
//------------------------------------------------------------------------------
......@@ -35,7 +34,6 @@ AuthenticationFailureParameter::AuthenticationFailureParameter(
const bstring& value) {
value_ = bstrcpy(value);
SetLengthIndicator(kAuthenticationFailureParameterContentLength);
SetIeName(kAuthenticationFailureParameterIeName);
}
//------------------------------------------------------------------------------
......
......@@ -27,7 +27,8 @@
constexpr uint8_t kAuthenticationFailureParameterLength = 16;
constexpr uint8_t kAuthenticationFailureParameterContentLength =
kAuthenticationFailureParameterLength - 2;
constexpr auto kAuthenticationFailureParameterIeName = "5GMM Capability";
constexpr auto kAuthenticationFailureParameterIeName =
"Authentication Failure Parameter";
namespace nas {
......@@ -37,6 +38,10 @@ class AuthenticationFailureParameter : public Type4NasIe {
AuthenticationFailureParameter(const bstring& value);
~AuthenticationFailureParameter();
static std::string GetIeName() {
return kAuthenticationFailureParameterIeName;
}
int Encode(uint8_t* buf, int len);
int Decode(uint8_t* buf, int len, bool is_iei);
......
......@@ -28,7 +28,6 @@ using namespace nas;
AuthenticationResponseParameter::AuthenticationResponseParameter()
: Type4NasIe(kIeiAuthenticationResponseParameter), res_or_res_star_() {
SetLengthIndicator(4); // Minimum length for the content (RES or RES*)
SetIeName(kAuthenticationResponseParameterIeName);
}
//------------------------------------------------------------------------------
......@@ -36,7 +35,6 @@ AuthenticationResponseParameter::AuthenticationResponseParameter(bstring para)
: Type4NasIe(kIeiAuthenticationResponseParameter) {
res_or_res_star_ = bstrcpy(para);
SetLengthIndicator(blength(res_or_res_star_));
SetIeName(kAuthenticationResponseParameterIeName);
}
//------------------------------------------------------------------------------
......
......@@ -37,6 +37,10 @@ class AuthenticationResponseParameter : public Type4NasIe {
AuthenticationResponseParameter(bstring para);
~AuthenticationResponseParameter();
static std::string GetIeName() {
return kAuthenticationResponseParameterIeName;
}
int Encode(uint8_t* buf, int len);
int Decode(uint8_t* buf, int len, bool is_iei);
......
......@@ -30,7 +30,6 @@ using namespace nas;
Authentication_Parameter_AUTN::Authentication_Parameter_AUTN(uint8_t iei)
: Type4NasIe(iei), _value() {
SetLengthIndicator(0);
SetIeName(kAuthenticationParameterAutnIeName);
}
//------------------------------------------------------------------------------
......@@ -41,14 +40,12 @@ Authentication_Parameter_AUTN::Authentication_Parameter_AUTN(
this->_value[i] = value[i];
}
SetLengthIndicator(kAuthenticationParameterAutnValueLength);
SetIeName(kAuthenticationParameterAutnIeName);
}
//------------------------------------------------------------------------------
Authentication_Parameter_AUTN::Authentication_Parameter_AUTN()
: Type4NasIe(), _value() {
SetLengthIndicator(0);
SetIeName(kAuthenticationParameterAutnIeName);
}
//------------------------------------------------------------------------------
......
......@@ -40,6 +40,8 @@ class Authentication_Parameter_AUTN : public Type4NasIe {
uint8_t value[kAuthenticationParameterAutnValueLength]);
~Authentication_Parameter_AUTN();
static std::string GetIeName() { return kAuthenticationParameterAutnIeName; }
int Encode(uint8_t* buf, int len);
int Decode(uint8_t* buf, int len, bool is_option);
......
......@@ -27,15 +27,11 @@ using namespace nas;
//------------------------------------------------------------------------------
Authentication_Parameter_RAND::Authentication_Parameter_RAND()
: Type3NasIe(), _value() {
SetIeName(kAuthenticationParameterRandIeName);
}
: Type3NasIe(), _value() {}
//------------------------------------------------------------------------------
Authentication_Parameter_RAND::Authentication_Parameter_RAND(uint8_t iei)
: Type3NasIe(iei), _value() {
SetIeName(kAuthenticationParameterRandIeName);
}
: Type3NasIe(iei), _value() {}
//------------------------------------------------------------------------------
Authentication_Parameter_RAND::Authentication_Parameter_RAND(
......@@ -44,7 +40,6 @@ Authentication_Parameter_RAND::Authentication_Parameter_RAND(
for (int i = 0; i < kAuthenticationParameterRandValueLength; i++) {
this->_value[i] = value[i];
}
SetIeName(kAuthenticationParameterRandIeName);
}
//------------------------------------------------------------------------------
......
......@@ -40,6 +40,8 @@ class Authentication_Parameter_RAND : public Type3NasIe {
uint8_t iei, uint8_t value[kAuthenticationParameterRandValueLength]);
~Authentication_Parameter_RAND();
static std::string GetIeName() { return kAuthenticationParameterRandIeName; }
int Encode(uint8_t* buf, int len);
int Decode(uint8_t* buf, int len, bool is_option);
......
......@@ -27,14 +27,12 @@ using namespace nas;
//------------------------------------------------------------------------------
DNN::DNN() : Type4NasIe(kIeiDnn), _DNN() {
SetLengthIndicator(1);
SetIeName(kDnnIeName);
}
//------------------------------------------------------------------------------
DNN::DNN(bstring dnn) : Type4NasIe(kIeiDnn) {
_DNN = bstrcpy(dnn);
SetLengthIndicator(blength(dnn));
SetIeName(kDnnIeName);
}
//------------------------------------------------------------------------------
......
......@@ -36,6 +36,8 @@ class DNN : public Type4NasIe {
DNN(bstring dnn);
~DNN();
static std::string GetIeName() { return kDnnIeName; }
int Encode(uint8_t* buf, int len);
int Decode(uint8_t* buf, int len, bool is_iei);
......
......@@ -29,15 +29,12 @@ using namespace nas;
//------------------------------------------------------------------------------
EPS_NAS_Message_Container::EPS_NAS_Message_Container()
: Type6NasIe(kIeiEpsNasMessageContainer), _value() {
SetIeName(kEpsNasMessageContainerIeName);
}
: Type6NasIe(kIeiEpsNasMessageContainer), _value() {}
//------------------------------------------------------------------------------
EPS_NAS_Message_Container::EPS_NAS_Message_Container(bstring value)
: Type6NasIe(kIeiEpsNasMessageContainer) {
_value = bstrcpy(value);
SetIeName(kEpsNasMessageContainerIeName);
SetLengthIndicator(blength(_value));
}
......
......@@ -34,6 +34,8 @@ class EPS_NAS_Message_Container : Type6NasIe {
EPS_NAS_Message_Container(bstring value);
~EPS_NAS_Message_Container();
static std::string GetIeName() { return kEpsNasMessageContainerIeName; }
// TODO: SetValue(const bstring& value)
void getValue(bstring& value) const;
......
......@@ -29,20 +29,17 @@ using namespace nas;
//------------------------------------------------------------------------------
EapMessage::EapMessage() : Type6NasIe(), eap_() {
SetLengthIndicator(0);
SetIeName(kEapMessageIeName);
}
//------------------------------------------------------------------------------
EapMessage::EapMessage(uint8_t iei) : Type6NasIe(iei), eap_() {
SetLengthIndicator(0);
SetIeName(kEapMessageIeName);
}
//------------------------------------------------------------------------------
EapMessage::EapMessage(const uint8_t iei, bstring eap) : Type6NasIe(iei) {
eap_ = bstrcpy(eap);
SetLengthIndicator(blength(eap));
SetIeName(kEapMessageIeName);
}
//------------------------------------------------------------------------------
......
......@@ -30,7 +30,7 @@ constexpr auto kEapMessageIeName = "EAP Message";
namespace nas {
class EapMessage : Type6NasIe {
class EapMessage : public Type6NasIe {
public:
EapMessage();
EapMessage(uint8_t iei);
......@@ -38,6 +38,8 @@ class EapMessage : Type6NasIe {
EapMessage(uint8_t iei, bstring eap);
~EapMessage();
static std::string GetIeName() { return kEapMessageIeName; }
int Encode(uint8_t* buf, int len);
int Decode(uint8_t* buf, int len, bool is_iei);
......
......@@ -32,14 +32,12 @@ EpsBearerContextStatus::EpsBearerContextStatus()
: Type4NasIe(kIeiEpsBearerContextStatus) {
value_ = 0;
SetLengthIndicator(2);
SetIeName(kEpsBearerContextStatusIeName);
}
//------------------------------------------------------------------------------
EpsBearerContextStatus::EpsBearerContextStatus(uint16_t value) {
value_ = value;
SetLengthIndicator(2);
SetIeName(kEpsBearerContextStatusIeName);
}
//------------------------------------------------------------------------------
......
......@@ -35,6 +35,8 @@ class EpsBearerContextStatus : public Type4NasIe {
EpsBearerContextStatus(uint16_t value);
~EpsBearerContextStatus();
static std::string GetIeName() { return kEpsBearerContextStatusIeName; }
void SetValue(uint16_t value);
uint16_t GetValue() const;
......
......@@ -27,9 +27,7 @@ using namespace nas;
EpsNasSecurityAlgorithms::EpsNasSecurityAlgorithms()
: Type3NasIe(kIeiEpsNasSecurityAlgorithms),
type_of_ciphering_algorithm_(),
type_of_integrity_protection_algorithm_() {
SetIeName(kEpsNasSecurityAlgorithmsIeName);
}
type_of_integrity_protection_algorithm_() {}
//------------------------------------------------------------------------------
EpsNasSecurityAlgorithms::EpsNasSecurityAlgorithms(
......@@ -37,7 +35,6 @@ EpsNasSecurityAlgorithms::EpsNasSecurityAlgorithms(
: Type3NasIe(kIeiEpsNasSecurityAlgorithms) {
type_of_ciphering_algorithm_ = ciphering & 0x07;
type_of_integrity_protection_algorithm_ = integrity_protection & 0x07;
SetIeName(kEpsNasSecurityAlgorithmsIeName);
}
//------------------------------------------------------------------------------
......
......@@ -35,6 +35,8 @@ class EpsNasSecurityAlgorithms : public Type3NasIe {
EpsNasSecurityAlgorithms(uint8_t ciphering, uint8_t integrity_protection);
~EpsNasSecurityAlgorithms();
static std::string GetIeName() { return kEpsNasSecurityAlgorithmsIeName; }
void SetTypeOfCipheringAlgorithm(uint8_t value);
uint8_t GetTypeOfCipheringAlgorithm() const;
......
......@@ -25,6 +25,8 @@
#include "NasIe.hpp"
constexpr uint8_t kExtendedProtocolDiscriminatorLength = 1;
constexpr auto kExtendedProtocolDiscriminatorIeName =
"Extended Protocol Discriminator";
namespace nas {
......@@ -34,6 +36,10 @@ class ExtendedProtocolDiscriminator : public NasIe {
ExtendedProtocolDiscriminator(const uint8_t& epd);
virtual ~ExtendedProtocolDiscriminator();
static std::string GetIeName() {
return kExtendedProtocolDiscriminatorIeName;
}
bool Validate(const int& len) const override;
void Set(const uint8_t& epd);
void Get(uint8_t& epd) const;
......
......@@ -28,7 +28,6 @@ using namespace nas;
Extended_DRX_Parameters::Extended_DRX_Parameters()
: Type4NasIe(kIeiExtendedDrxParameters), paging_time_(), e_drx_value_() {
SetLengthIndicator(1);
SetIeName(kExtendedDrxParametersIeName);
}
//------------------------------------------------------------------------------
......@@ -38,7 +37,6 @@ Extended_DRX_Parameters::Extended_DRX_Parameters(
paging_time_ = paging_time & 0x0F;
e_drx_value_ = value & 0x0F;
SetLengthIndicator(1);
SetIeName(kExtendedDrxParametersIeName);
}
//------------------------------------------------------------------------------
......
......@@ -35,6 +35,8 @@ class Extended_DRX_Parameters : public Type4NasIe {
Extended_DRX_Parameters(uint8_t paging_time, uint8_t value);
~Extended_DRX_Parameters();
static std::string GetIeName() { return kExtendedDrxParametersIeName; }
int Encode(uint8_t* buf, int len);
int Decode(uint8_t* buf, int len, bool is_iei);
......
......@@ -26,14 +26,12 @@ using namespace nas;
//------------------------------------------------------------------------------
GprsTimer2::GprsTimer2(uint8_t iei) : Type4NasIe(iei), value_() {
SetLengthIndicator(1);
SetIeName(kGprsTimer2IeName);
}
//------------------------------------------------------------------------------
GprsTimer2::GprsTimer2(const uint8_t iei, uint8_t value) : Type4NasIe(iei) {
value_ = value;
SetLengthIndicator(1);
SetIeName(kGprsTimer2IeName);
}
//------------------------------------------------------------------------------
......
......@@ -35,6 +35,8 @@ class GprsTimer2 : public Type4NasIe {
GprsTimer2(const uint8_t iei, uint8_t value);
~GprsTimer2();
static std::string GetIeName() { return kGprsTimer2IeName; }
int Encode(uint8_t* buf, int len);
int Decode(uint8_t* buf, int len, bool is_iei);
......
......@@ -26,7 +26,6 @@ using namespace nas;
//------------------------------------------------------------------------------
GprsTimer3::GprsTimer3(uint8_t iei) : Type4NasIe(iei), unit_(), value_() {
SetLengthIndicator(1);
SetIeName(kGprsTimer3IeName);
}
//------------------------------------------------------------------------------
......@@ -35,7 +34,6 @@ GprsTimer3::GprsTimer3(const uint8_t iei, uint8_t unit, uint8_t value)
unit_ = unit;
value_ = value;
SetLengthIndicator(1);
SetIeName(kGprsTimer3IeName);
}
//------------------------------------------------------------------------------
......
......@@ -35,6 +35,8 @@ class GprsTimer3 : public Type4NasIe {
GprsTimer3(uint8_t iei, uint8_t unit, uint8_t value);
~GprsTimer3();
static std::string GetIeName() { return kGprsTimer3IeName; }
int Encode(uint8_t* buf, int len);
int Decode(uint8_t* buf, int len, bool is_option);
......
......@@ -24,15 +24,12 @@
using namespace nas;
//------------------------------------------------------------------------------
ImeisvRequest::ImeisvRequest() : Type1NasIeFormatTv(kIeiImeisvRequest) {
SetIeName(kImeisvRequestIeName);
}
ImeisvRequest::ImeisvRequest() : Type1NasIeFormatTv(kIeiImeisvRequest) {}
//------------------------------------------------------------------------------
ImeisvRequest::ImeisvRequest(uint8_t value)
: Type1NasIeFormatTv(kIeiImeisvRequest) {
SetValue(value & 0x07);
SetIeName(kImeisvRequestIeName);
}
//------------------------------------------------------------------------------
......
......@@ -34,6 +34,8 @@ class ImeisvRequest : public Type1NasIeFormatTv {
ImeisvRequest(uint8_t value);
~ImeisvRequest();
static std::string GetIeName() { return kImeisvRequestIeName; }
void Set(uint8_t value);
uint8_t Get() const;
......
......@@ -31,7 +31,6 @@ using namespace nas;
//------------------------------------------------------------------------------
LadnIndication::LadnIndication() : Type6NasIe(kIeiLadnIndication) {
LADN = {};
SetIeName(kLadnIndicationIeName);
}
//------------------------------------------------------------------------------
......
......@@ -24,8 +24,6 @@
#include "Type6NasIe.hpp"
using namespace std;
constexpr uint8_t kLadnIndicationMinimumLength = 3;
constexpr uint16_t kLadnIndicationMaximumLength = 1715;
constexpr auto kLadnIndicationIeName = "LADN Indication";
......@@ -38,6 +36,8 @@ class LadnIndication : Type6NasIe {
LadnIndication(const std::vector<bstring>& ladn);
~LadnIndication();
static std::string GetIeName() { return kLadnIndicationIeName; }
// void SetValue(const std::vector<bstring>& ladn);
void GetValue(std::vector<bstring>& ladn);
......
......@@ -33,14 +33,12 @@ MicoIndication::MicoIndication(bool sprti, bool raai)
: Type1NasIeFormatTv(kIeiMicoIndication) {
raai_ = raai;
sprti_ = sprti;
SetIeName(kMicoIndicationIeName);
}
//------------------------------------------------------------------------------
MicoIndication::MicoIndication() : Type1NasIeFormatTv(kIeiMicoIndication) {
raai_ = false;
sprti_ = false;
SetIeName(kMicoIndicationIeName);
}
//------------------------------------------------------------------------------
......
......@@ -36,6 +36,8 @@ class MicoIndication : public Type1NasIeFormatTv {
MicoIndication(bool sprti, bool raai);
~MicoIndication();
static std::string GetIeName() { return kMicoIndicationIeName; }
int Encode(uint8_t* buf, int len);
int Decode(uint8_t* buf, int len, bool is_option);
......
......@@ -25,15 +25,12 @@ using namespace nas;
//------------------------------------------------------------------------------
MaPduSessionInformation::MaPduSessionInformation()
: Type1NasIeFormatTv(kIeiMaPduSessionInformation) {
SetIeName(kMaPduSessionInformationIeName);
}
: Type1NasIeFormatTv(kIeiMaPduSessionInformation) {}
//------------------------------------------------------------------------------
MaPduSessionInformation::MaPduSessionInformation(uint8_t value)
: Type1NasIeFormatTv(kIeiMaPduSessionInformation) {
SetValue(value & 0x0f);
SetIeName(kMaPduSessionInformationIeName);
}
//------------------------------------------------------------------------------
......
......@@ -34,6 +34,8 @@ class MaPduSessionInformation : public Type1NasIeFormatTv {
MaPduSessionInformation(uint8_t value);
~MaPduSessionInformation();
static std::string GetIeName() { return kMaPduSessionInformationIeName; }
void Set(uint8_t value);
uint8_t Get() const;
......
......@@ -32,7 +32,6 @@ using namespace nas;
//------------------------------------------------------------------------------
NSSAI::NSSAI(uint8_t iei) : Type4NasIe(iei) {
SetLengthIndicator(0);
SetIeName(kNssaiIeName);
}
//------------------------------------------------------------------------------
......@@ -44,13 +43,10 @@ NSSAI::NSSAI(uint8_t iei, const std::vector<struct SNSSAI_s>& nssai)
length += (1 + nssai[i].length); // 1 for length IE
}
SetLengthIndicator(length);
SetIeName(kNssaiIeName);
}
//------------------------------------------------------------------------------
NSSAI::NSSAI() : Type4NasIe(), S_NSSAIs() {
SetIeName(kNssaiIeName);
}
NSSAI::NSSAI() : Type4NasIe(), S_NSSAIs() {}
//------------------------------------------------------------------------------
NSSAI::~NSSAI() {}
......
......@@ -38,6 +38,8 @@ class NSSAI : public Type4NasIe {
NSSAI(uint8_t iei, const std::vector<struct SNSSAI_s>& nssai);
~NSSAI();
static std::string GetIeName() { return kNssaiIeName; }
int Encode(uint8_t* buf, int len);
int Decode(uint8_t* buf, int len, bool is_iei);
......
......@@ -29,12 +29,12 @@ using namespace nas;
//------------------------------------------------------------------------------
NasIe::NasIe() {
ie_name_ = {};
// ie_name_ = {};
}
//------------------------------------------------------------------------------
NasIe::~NasIe() {}
/*
//------------------------------------------------------------------------------
void NasIe::SetIeName(const std::string& name) {
ie_name_ = name;
......@@ -49,3 +49,4 @@ std::string NasIe::GetIeName() const {
void NasIe::GetIeName(std::string& name) const {
name = ie_name_;
}
*/
......@@ -46,16 +46,17 @@ class NasIe {
virtual bool Validate(const int& len) const = 0;
void SetIeName(const std::string& name);
std::string GetIeName() const;
void GetIeName(std::string& name) const;
/* void SetIeName(const std::string& name);
std::string GetIeName() const;
void GetIeName(std::string& name) const;
*/
virtual int Encode(uint8_t* buf, const int& len) = 0;
virtual int Decode(
const uint8_t* const buf, const int& len, bool is_option = false) = 0;
protected:
std::string ie_name_;
// std::string ie_name_;
};
} // namespace nas
......
......@@ -38,7 +38,6 @@ NasKeySetIdentifier::NasKeySetIdentifier(
tsc_ = 0x01 & tsc;
key_id_ = 0x07 & key_id;
SetValue();
SetIeName(kNasKeySetIdentifierName);
}
//------------------------------------------------------------------------------
......@@ -47,7 +46,6 @@ NasKeySetIdentifier::NasKeySetIdentifier(const bool& tsc, const uint8_t& key_id)
tsc_ = 0x01 & tsc;
key_id_ = 0x07 & key_id;
SetValue();
SetIeName(kNasKeySetIdentifierName);
}
//------------------------------------------------------------------------------
......
......@@ -25,6 +25,7 @@
#include "Type1NasIe.hpp"
constexpr auto kNasKeySetIdentifierName = "NAS Key Set Identifier";
namespace nas {
class NasKeySetIdentifier : public Type1NasIe {
......@@ -34,9 +35,10 @@ class NasKeySetIdentifier : public Type1NasIe {
const uint8_t& iei, const bool& tsc, const uint8_t& key_id);
NasKeySetIdentifier(
const bool& tsc, const uint8_t& key_id); // Default: low position
~NasKeySetIdentifier();
static std::string GetIeName() { return kNasKeySetIdentifierName; }
void Set(const bool& high_pos);
// void Set(const bool& tsc, const uint8_t& key_id);
// void Set(const bool& tsc, const uint8_t& key_id, const uint8_t& iei);
......
......@@ -32,7 +32,6 @@ using namespace nas;
NasMessageContainer::NasMessageContainer()
: Type6NasIe(kIeiNasMessageContainer), value_() {
SetLengthIndicator(0);
SetIeName(kNasMessageContainerIeName);
}
//------------------------------------------------------------------------------
......@@ -40,7 +39,6 @@ NasMessageContainer::NasMessageContainer(bstring value)
: Type6NasIe(kIeiNasMessageContainer) {
value_ = bstrcpy(value);
SetLengthIndicator(blength(value));
SetIeName(kNasMessageContainerIeName);
}
//------------------------------------------------------------------------------
......
......@@ -36,6 +36,8 @@ class NasMessageContainer : Type6NasIe {
NasMessageContainer(bstring value);
~NasMessageContainer();
static std::string GetIeName() { return kNasMessageContainerIeName; }
void GetValue(bstring& value) const;
int Encode(uint8_t* buf, int len);
......
......@@ -25,6 +25,7 @@
#include "NasIe.hpp"
constexpr uint8_t kNasMessageTypeIeSize = 1;
constexpr auto kNasMessageTypeIeName = "Nas Message Type";
namespace nas {
......@@ -34,6 +35,8 @@ class NasMessageType : public NasIe {
NasMessageType(const uint8_t& message_type);
virtual ~NasMessageType();
static std::string GetIeName() { return kNasMessageTypeIeName; }
bool Validate(const int& len) const override;
void Set(const uint8_t& message_type);
......
......@@ -29,17 +29,13 @@ using namespace nas;
NasSecurityAlgorithms::NasSecurityAlgorithms()
: Type3NasIe(),
type_of_ciphering_algorithm_(),
type_of_integrity_protection_algorithm_() {
SetIeName(kNasSecurityAlgorithmsIeName);
}
type_of_integrity_protection_algorithm_() {}
//------------------------------------------------------------------------------
NasSecurityAlgorithms::NasSecurityAlgorithms(uint8_t iei)
: Type3NasIe(iei),
type_of_ciphering_algorithm_(),
type_of_integrity_protection_algorithm_() {
SetIeName(kNasSecurityAlgorithmsIeName);
}
type_of_integrity_protection_algorithm_() {}
//------------------------------------------------------------------------------
NasSecurityAlgorithms::~NasSecurityAlgorithms() {}
......@@ -50,7 +46,6 @@ NasSecurityAlgorithms::NasSecurityAlgorithms(
: Type3NasIe() {
type_of_ciphering_algorithm_ = ciphering & 0x0f;
type_of_integrity_protection_algorithm_ = integrity_protection & 0x0f;
SetIeName(kNasSecurityAlgorithmsIeName);
}
//------------------------------------------------------------------------------
......
......@@ -38,6 +38,8 @@ class NasSecurityAlgorithms : public Type3NasIe {
uint8_t iei, uint8_t ciphering, uint8_t integrity_protection);
~NasSecurityAlgorithms();
static std::string GetIeName() { return kNasSecurityAlgorithmsIeName; }
void SetTypeOfCipheringAlgorithm(uint8_t value);
uint8_t GetTypeOfCipheringAlgorithm() const;
......
......@@ -27,6 +27,7 @@
#include <string>
constexpr uint8_t kNetworkNameMinimumLength = 3;
constexpr auto kNetworkNameIeName = "Network Name";
namespace nas {
......@@ -36,6 +37,8 @@ class NetworkName {
NetworkName(const uint8_t& iei);
~NetworkName();
static std::string GetIeName() { return kNetworkNameIeName; }
void setIEI(const uint8_t& iei);
void setCodingScheme(const uint8_t& value);
// TODO: getCodingScheme
......
......@@ -29,16 +29,13 @@ using namespace nas;
//------------------------------------------------------------------------------
NetworkSlicingIndication::NetworkSlicingIndication()
: Type1NasIeFormatTv(), dcni_(), nssci_() {
SetIeName(kNetworkSlicingIndicationIeName);
}
: Type1NasIeFormatTv(), dcni_(), nssci_() {}
//------------------------------------------------------------------------------
NetworkSlicingIndication::NetworkSlicingIndication(uint8_t iei)
: Type1NasIeFormatTv(iei) {
dcni_ = false;
nssci_ = false;
SetIeName(kNetworkSlicingIndicationIeName);
}
//------------------------------------------------------------------------------
......@@ -46,7 +43,6 @@ NetworkSlicingIndication::NetworkSlicingIndication(bool dcni, bool nssci)
: Type1NasIeFormatTv() {
dcni_ = dcni;
nssci_ = nssci;
SetIeName(kNetworkSlicingIndicationIeName);
}
//------------------------------------------------------------------------------
......@@ -55,7 +51,6 @@ NetworkSlicingIndication::NetworkSlicingIndication(
: Type1NasIeFormatTv(iei) {
dcni_ = dcni;
nssci_ = nssci;
SetIeName(kNetworkSlicingIndicationIeName);
}
//------------------------------------------------------------------------------
......
......@@ -37,6 +37,8 @@ class NetworkSlicingIndication : Type1NasIeFormatTv {
NetworkSlicingIndication(bool dcni, bool nssci);
~NetworkSlicingIndication();
static std::string GetIeName() { return kNetworkSlicingIndicationIeName; }
int Encode(uint8_t* buf, int len);
int Decode(uint8_t* buf, int len, bool is_iei);
......
......@@ -28,14 +28,11 @@ using namespace nas;
Non_3GPP_NW_Provided_Policies::Non_3GPP_NW_Provided_Policies(uint8_t value)
: Type1NasIeFormatTv(kIeiNon3gppNwProvidedPolicies) {
SetValue(value & 0x01);
SetIeName(kNon3gppNwProvidedPoliciesIeName);
}
//------------------------------------------------------------------------------
Non_3GPP_NW_Provided_Policies::Non_3GPP_NW_Provided_Policies()
: Type1NasIeFormatTv(kIeiNon3gppNwProvidedPolicies) {
SetIeName(kNon3gppNwProvidedPoliciesIeName);
}
: Type1NasIeFormatTv(kIeiNon3gppNwProvidedPolicies) {}
//------------------------------------------------------------------------------
Non_3GPP_NW_Provided_Policies::~Non_3GPP_NW_Provided_Policies(){};
......
......@@ -36,6 +36,8 @@ class Non_3GPP_NW_Provided_Policies : public Type1NasIeFormatTv {
Non_3GPP_NW_Provided_Policies(uint8_t value);
~Non_3GPP_NW_Provided_Policies();
static std::string GetIeName() { return kNon3gppNwProvidedPoliciesIeName; }
// int Encode(uint8_t* buf, int len);
// int Decode(uint8_t* buf, int len, bool is_iei);
......
......@@ -33,15 +33,12 @@ using namespace nas;
//------------------------------------------------------------------------------
NssaiInclusionMode::NssaiInclusionMode()
: Type1NasIeFormatTv(kIeiNssaiInclusionMode) {
SetIeName(kNssaiInclusionModeIeName);
}
: Type1NasIeFormatTv(kIeiNssaiInclusionMode) {}
//------------------------------------------------------------------------------
NssaiInclusionMode::NssaiInclusionMode(uint8_t value)
: Type1NasIeFormatTv(kIeiNssaiInclusionMode) {
SetValue(value);
SetIeName(kNssaiInclusionModeIeName);
}
//------------------------------------------------------------------------------
......
......@@ -35,6 +35,8 @@ class NssaiInclusionMode : public Type1NasIeFormatTv {
NssaiInclusionMode(uint8_t value);
~NssaiInclusionMode();
static std::string GetIeName() { return kNssaiInclusionModeIeName; }
// int Encode(uint8_t* buf, int len);
// int Decode(uint8_t* buf, int len, bool is_iei);
......
......@@ -32,7 +32,6 @@ using namespace nas;
PDUSessionStatus::PDUSessionStatus() : Type4NasIe(kIeiPduSessionStatus) {
_value = 0;
SetLengthIndicator(2);
SetIeName(kPduSessionStatusIeName);
}
//------------------------------------------------------------------------------
......@@ -40,7 +39,6 @@ PDUSessionStatus::PDUSessionStatus(uint16_t value)
: Type4NasIe(kIeiPduSessionStatus) {
_value = value;
SetLengthIndicator(2);
SetIeName(kPduSessionStatusIeName);
}
//------------------------------------------------------------------------------
......
......@@ -30,12 +30,14 @@ constexpr auto kPduSessionStatusIeName = "PDU Session Status";
namespace nas {
class PDUSessionStatus : Type4NasIe {
class PDUSessionStatus : public Type4NasIe {
public:
PDUSessionStatus();
PDUSessionStatus(uint16_t value);
~PDUSessionStatus();
static std::string GetIeName() { return kPduSessionStatusIeName; }
void SetValue(uint16_t value);
uint16_t GetValue() const;
......
......@@ -31,7 +31,6 @@ using namespace nas;
PDU_Session_Reactivation_Result::PDU_Session_Reactivation_Result()
: Type4NasIe(kIeiPduSessionReactivationResult) {
SetLengthIndicator(2);
SetIeName(kPduSessionReactivationResultIeName);
}
//------------------------------------------------------------------------------
......@@ -39,7 +38,6 @@ PDU_Session_Reactivation_Result::PDU_Session_Reactivation_Result(uint16_t value)
: Type4NasIe(kIeiPduSessionReactivationResult) {
_value = value;
SetLengthIndicator(2);
SetIeName(kPduSessionReactivationResultIeName);
}
//------------------------------------------------------------------------------
......
......@@ -36,6 +36,8 @@ class PDU_Session_Reactivation_Result : public Type4NasIe {
PDU_Session_Reactivation_Result(uint16_t value);
~PDU_Session_Reactivation_Result();
static std::string GetIeName() { return kPduSessionReactivationResultIeName; }
void setValue(uint16_t value);
uint16_t getValue() const;
......
......@@ -36,7 +36,6 @@ PDU_Session_Reactivation_Result_Error_Cause::
pdu_session_id_cause_value_pair.push_back(value);
SetLengthIndicator(
2); // Minimum length with 1 pair (PDU Session ID, Cause Value)
SetIeName(kPduSessionReactivationResultErrorCauseIeName);
}
//------------------------------------------------------------------------------
......@@ -48,7 +47,6 @@ PDU_Session_Reactivation_Result_Error_Cause::
pdu_session_id_cause_value_pair.push_back(value);
SetLengthIndicator(
2); // Minimum length with 1 pair (PDU Session ID, Cause Value)
SetIeName(kPduSessionReactivationResultErrorCauseIeName);
}
//------------------------------------------------------------------------------
......
......@@ -31,13 +31,17 @@ constexpr auto kPduSessionReactivationResultErrorCauseIeName =
namespace nas {
class PDU_Session_Reactivation_Result_Error_Cause : Type6NasIe {
class PDU_Session_Reactivation_Result_Error_Cause : public Type6NasIe {
public:
PDU_Session_Reactivation_Result_Error_Cause();
PDU_Session_Reactivation_Result_Error_Cause(
uint8_t session_id, uint8_t value);
~PDU_Session_Reactivation_Result_Error_Cause();
static std::string GetIeName() {
return kPduSessionReactivationResultErrorCauseIeName;
}
void setValue(uint8_t session_id, uint8_t cause);
std::pair<uint8_t, uint8_t> getValue() const;
......
......@@ -31,13 +31,11 @@ using namespace nas;
//------------------------------------------------------------------------------
PlmnList::PlmnList(uint8_t iei) : Type4NasIe(iei) {
SetLengthIndicator(0);
SetIeName(kPlmnListIeName);
}
//------------------------------------------------------------------------------
PlmnList::PlmnList() : Type4NasIe() {
SetLengthIndicator(0);
SetIeName(kPlmnListIeName);
}
//------------------------------------------------------------------------------
......
......@@ -37,6 +37,8 @@ class PlmnList : public Type4NasIe {
PlmnList(uint8_t iei);
~PlmnList();
static std::string GetIeName() { return kPlmnListIeName; }
int Encode(uint8_t* buf, int len);
int Decode(uint8_t* buf, int len, bool is_option);
......
......@@ -27,22 +27,18 @@
using namespace nas;
//------------------------------------------------------------------------------
PayloadContainerType::PayloadContainerType() : Type1NasIeFormatTv() {
SetIeName(kPayloadContainerTypeIeName);
}
PayloadContainerType::PayloadContainerType() : Type1NasIeFormatTv() {}
//------------------------------------------------------------------------------
PayloadContainerType::PayloadContainerType(uint8_t value)
: Type1NasIeFormatTv() {
SetValue(value & 0x0f);
SetIeName(kPayloadContainerTypeIeName);
}
//------------------------------------------------------------------------------
PayloadContainerType::PayloadContainerType(const uint8_t iei, uint8_t value)
: Type1NasIeFormatTv(iei) {
SetValue(value & 0x0f);
SetIeName(kPayloadContainerTypeIeName);
}
//------------------------------------------------------------------------------
......
......@@ -36,6 +36,8 @@ class PayloadContainerType : public Type1NasIeFormatTv {
PayloadContainerType(const uint8_t iei, uint8_t value);
~PayloadContainerType();
static std::string GetIeName() { return kPayloadContainerTypeIeName; }
private:
};
......
......@@ -31,7 +31,6 @@ Payload_Container::Payload_Container() : Type6NasIe() {
content = std::nullopt;
CONTENT = std::nullopt;
SetLengthIndicator(0);
SetIeName(kPayloadContainerIeName);
}
//------------------------------------------------------------------------------
......@@ -39,7 +38,6 @@ Payload_Container::Payload_Container(uint8_t iei) : Type6NasIe(iei) {
content = std::nullopt;
CONTENT = std::nullopt;
SetLengthIndicator(0);
SetIeName(kPayloadContainerIeName);
}
//------------------------------------------------------------------------------
......@@ -47,7 +45,6 @@ Payload_Container::Payload_Container(const bstring& b) : Type6NasIe() {
content = std::optional<bstring>(b);
CONTENT = std::nullopt;
SetLengthIndicator(blength(b));
SetIeName(kPayloadContainerIeName);
}
//------------------------------------------------------------------------------
......@@ -56,7 +53,6 @@ Payload_Container::Payload_Container(uint8_t iei, const bstring& b)
content = std::optional<bstring>(b);
CONTENT = std::nullopt;
SetLengthIndicator(blength(b));
SetIeName(kPayloadContainerIeName);
}
//------------------------------------------------------------------------------
......@@ -73,7 +69,6 @@ Payload_Container::Payload_Container(
contents.at(i).length; // 2 for Length of Payload container entry
}
SetLengthIndicator(length);
SetIeName(kPayloadContainerIeName);
}
//------------------------------------------------------------------------------
......@@ -90,7 +85,6 @@ Payload_Container::Payload_Container(
contents.at(i).length; // 2 for Length of Payload container entry
}
SetLengthIndicator(length);
SetIeName(kPayloadContainerIeName);
}
//------------------------------------------------------------------------------
......
......@@ -41,6 +41,8 @@ class Payload_Container : Type6NasIe {
const uint8_t iei, const std::vector<PayloadContainerEntry>& content);
~Payload_Container();
static std::string GetIeName() { return kPayloadContainerIeName; }
// void setValue(uint8_t iei, uint8_t value);
int Encode(uint8_t* buf, int len, uint8_t type);
int Decode(uint8_t* buf, int len, bool is_iei, uint8_t type);
......
......@@ -27,20 +27,17 @@ using namespace nas;
//------------------------------------------------------------------------------
PduSessionIdentity2::PduSessionIdentity2(uint8_t iei) : Type3NasIe(iei) {
value_ = 0;
SetIeName(kPduSessionIdentity2IeName);
}
//------------------------------------------------------------------------------
PduSessionIdentity2::PduSessionIdentity2(const uint8_t iei, uint8_t value)
: Type3NasIe(iei) {
value_ = value;
SetIeName(kPduSessionIdentity2IeName);
}
//------------------------------------------------------------------------------
PduSessionIdentity2::PduSessionIdentity2() : Type3NasIe() {
value_ = 0;
SetIeName(kPduSessionIdentity2IeName);
}
//------------------------------------------------------------------------------
......
......@@ -36,6 +36,8 @@ class PduSessionIdentity2 : public Type3NasIe {
PduSessionIdentity2(const uint8_t iei, uint8_t value);
~PduSessionIdentity2();
static std::string GetIeName() { return kPduSessionIdentity2IeName; }
int Encode(uint8_t* buf, int len);
int Decode(uint8_t* buf, int len, bool is_option);
......
......@@ -21,102 +21,96 @@
#include "Rejected_NSSAI.hpp"
#include "3gpp_24.501.hpp"
#include "common_defs.h"
#include "logger.hpp"
using namespace nas;
//------------------------------------------------------------------------------
Rejected_NSSAI::Rejected_NSSAI(uint8_t iei) {
_iei = iei;
length = 0;
}
//------------------------------------------------------------------------------
Rejected_NSSAI::Rejected_NSSAI() {
_iei = 0;
length = 0;
Rejected_NSSAI::Rejected_NSSAI(uint8_t iei) : Type4NasIe(iei) {
SetLengthIndicator(2); // 1 for Length/Cause and 1 for SST of the 1st S-NSSAI
}
//------------------------------------------------------------------------------
Rejected_NSSAI::~Rejected_NSSAI() {}
//------------------------------------------------------------------------------
void Rejected_NSSAI::setRejectedSNSSAIs(
void Rejected_NSSAI::SetRejectedSNssais(
const std::vector<Rejected_SNSSAI>& nssais) {
rejected_nssais = nssais;
uint8_t length = 0;
rejected_nssais_ = nssais;
for (auto n : nssais) {
length += n.getLength();
}
SetLengthIndicator(length);
}
//------------------------------------------------------------------------------
void Rejected_NSSAI::getRejectedSNSSAIs(std::vector<Rejected_SNSSAI>& nssais) {
nssais = rejected_nssais;
void Rejected_NSSAI::GetRejectedSNssais(std::vector<Rejected_SNSSAI>& nssais) {
nssais = rejected_nssais_;
}
//------------------------------------------------------------------------------
int Rejected_NSSAI::Encode(uint8_t* buf, int len) {
Logger::nas_mm().debug("Encoding Rejected_NSSAI");
uint8_t ie_len = 0;
if (_iei) {
ie_len = length + 2;
} else {
ie_len = length + 1;
}
Logger::nas_mm().debug("Encoding %s", GetIeName().c_str());
int ie_len = GetIeLength();
if (len < ie_len) {
Logger::nas_mm().error("len is less than %d", ie_len);
return 0;
Logger::nas_mm().error("Len is less than %d", ie_len);
return KEncodeDecodeError;
}
int encoded_size = 0;
if (_iei) {
ENCODE_U8(buf + encoded_size, _iei, encoded_size);
}
// IEI and Length
int encoded_header_size = Type4NasIe::Encode(buf + encoded_size, len);
if (encoded_header_size == KEncodeDecodeError) return KEncodeDecodeError;
encoded_size += encoded_header_size;
// Skip Length for now
uint8_t len_pos = encoded_size;
encoded_size++;
uint8_t payload_len = 0;
for (auto n : rejected_nssais) {
for (auto n : rejected_nssais_) {
int size = n.Encode(buf + encoded_size, len - encoded_size);
if (size != KEncodeDecodeError) {
encoded_size += size;
payload_len += size;
} else {
return KEncodeDecodeError;
}
}
// Length
uint8_t encoded_size_length = 0;
ENCODE_U8(buf + len_pos, payload_len, encoded_size_length);
Logger::nas_mm().debug("Encoded Rejected_NSSAI (len %d)", encoded_size);
Logger::nas_mm().debug(
"Encoded %s, len (%d)", GetIeName().c_str(), encoded_size);
return encoded_size;
}
//------------------------------------------------------------------------------
int Rejected_NSSAI::Decode(uint8_t* buf, int len, bool is_option) {
Logger::nas_mm().debug("Decoding Rejected_NSSAI");
int decoded_size = 0;
if (is_option) {
DECODE_U8(buf + decoded_size, _iei, decoded_size);
int Rejected_NSSAI::Decode(uint8_t* buf, int len, bool is_iei) {
if (len < kRejectedNssaiMinimumLength) {
Logger::nas_mm().error(
"Buffer length is less than the minimum length of this IE (%d octet)",
kRejectedNssaiMinimumLength);
return KEncodeDecodeError;
}
DECODE_U8(buf + decoded_size, length, decoded_size);
int ie_len = length;
uint8_t decoded_size = 0;
uint8_t octet = 0;
Logger::nas_mm().debug("Decoding %s", GetIeName().c_str());
// IEI and Length
int decoded_header_size = Type4NasIe::Decode(buf + decoded_size, len, is_iei);
// decoded_size += Type4NasIe::Decode(buf + decoded_size, len, is_iei);
if (decoded_header_size == KEncodeDecodeError) return KEncodeDecodeError;
decoded_size += decoded_header_size;
int ie_len = GetLengthIndicator();
while (ie_len > 0) {
Rejected_SNSSAI snssai = {};
int size = snssai.decodefrombuffer(buf + decoded_size, len - decoded_size);
int size = snssai.Decode(buf + decoded_size, len - decoded_size);
if (size != KEncodeDecodeError) {
decoded_size += size;
ie_len -= size;
rejected_nssais.push_back(snssai);
rejected_nssais_.push_back(snssai);
} else {
return KEncodeDecodeError;
}
}
Logger::nas_mm().debug("Decoded Rejected_NSSAI (len %d)", decoded_size);
Logger::nas_mm().debug(
"Decoded %s, len (%d)", GetIeName().c_str(), decoded_size);
return decoded_size;
}
......@@ -23,26 +23,29 @@
#define _REJECTED_NSSAI_H_
#include <Rejected_SNSSAI.hpp>
#include "Type4NasIe.hpp"
#include <stdint.h>
#include <vector>
constexpr uint8_t kRejectedNssaiMinimumLength = 4;
constexpr uint8_t kRejectedNssaiMaximumLength = 42;
constexpr auto kRejectedNssaiIeName = "Rejected NSSAI";
namespace nas {
class Rejected_NSSAI {
class Rejected_NSSAI : public Type4NasIe {
public:
Rejected_NSSAI();
Rejected_NSSAI(uint8_t iei);
~Rejected_NSSAI();
static std::string GetIeName() { return kRejectedNssaiIeName; }
int Encode(uint8_t* buf, int len);
int Decode(uint8_t* buf, int len, bool is_option);
void setRejectedSNSSAIs(const std::vector<Rejected_SNSSAI>& nssais);
void getRejectedSNSSAIs(std::vector<Rejected_SNSSAI>& nssais);
int Decode(uint8_t* buf, int len, bool is_iei);
void SetRejectedSNssais(const std::vector<Rejected_SNSSAI>& nssais);
void GetRejectedSNssais(std::vector<Rejected_SNSSAI>& nssais);
private:
uint8_t _iei;
uint8_t length;
std::vector<Rejected_SNSSAI> rejected_nssais;
std::vector<Rejected_SNSSAI> rejected_nssais_;
};
} // namespace nas
......
......@@ -55,8 +55,8 @@ uint8_t Rejected_SNSSAI::getLength() {
//------------------------------------------------------------------------------
void Rejected_SNSSAI::setSST(const uint8_t& sst) {
sst_ = sst;
length_ = 1;
sst_ = sst;
// length_ = 1;
}
//------------------------------------------------------------------------------
......@@ -121,35 +121,44 @@ int Rejected_SNSSAI::Encode(uint8_t* buf, int len) {
} else {
length_ = 1;
}
// Length + Cause
octet = (length_ << 4) | (0x0f & cause_);
ENCODE_U8(buf + encoded_size, octet, encoded_size);
// SST
ENCODE_U8(buf + encoded_size, sst_, encoded_size);
Logger::nas_mm().debug("SST %d", sst_);
// SD
if (sd_.has_value()) {
ENCODE_U24(buf + encoded_size, sd_.value(), encoded_size);
Logger::nas_mm().debug("SD 0x%x", sd_.value());
}
Logger::nas_mm().debug("Encoded Rejected_SNSSAI (len %d)", encoded_size);
return encoded_size;
}
//------------------------------------------------------------------------------
int Rejected_SNSSAI::decodefrombuffer(uint8_t* buf, int len) {
int Rejected_SNSSAI::Decode(uint8_t* buf, int len) {
Logger::nas_mm().debug("Decoding Rejected_SNSSAI");
int decoded_size = 0;
uint8_t octet = 0;
// Length and Cause
DECODE_U8(buf + decoded_size, octet, decoded_size);
length_ = (octet >> 4) & 0x0f;
cause_ = octet & 0x0f;
// SST
DECODE_U8(buf + decoded_size, sst_, decoded_size);
if (length_ == 1) {
Logger::nas_mm().debug(
"Decoded Rejected_SNSSAI length 0x%x,cause 0x%x, SST 0x%x", length_,
cause_, sst_);
} else if (length_ == 4) {
// SD
uint32_t sd = 0;
DECODE_U24(buf + decoded_size, sd, decoded_size);
sd_ = std::optional<uint32_t>(sd);
......
......@@ -48,7 +48,7 @@ class Rejected_SNSSAI {
void getCause(uint8_t& cause);
int Encode(uint8_t* buf, int len);
int decodefrombuffer(uint8_t* buf, int len);
int Decode(uint8_t* buf, int len);
private:
uint8_t length_;
......
......@@ -25,15 +25,12 @@ using namespace nas;
//------------------------------------------------------------------------------
ReleaseAssistanceIndication::ReleaseAssistanceIndication()
: Type1NasIeFormatTv(kIeiReleaseAssistanceIndication) {
SetIeName(kReleaseAssistanceIndicationIeName);
}
: Type1NasIeFormatTv(kIeiReleaseAssistanceIndication) {}
//------------------------------------------------------------------------------
ReleaseAssistanceIndication::ReleaseAssistanceIndication(uint8_t value)
: Type1NasIeFormatTv(kIeiReleaseAssistanceIndication) {
SetValue(value & 0x03);
SetIeName(kReleaseAssistanceIndicationIeName);
}
//------------------------------------------------------------------------------
......
......@@ -35,6 +35,8 @@ class ReleaseAssistanceIndication : public Type1NasIeFormatTv {
ReleaseAssistanceIndication(uint8_t value);
~ReleaseAssistanceIndication();
static std::string GetIeName() { return kReleaseAssistanceIndicationIeName; }
void Set(uint8_t value);
uint8_t Get() const;
......
......@@ -34,13 +34,11 @@ using namespace nas;
//------------------------------------------------------------------------------
RequestType::RequestType() : Type1NasIeFormatTv(kIeiRequestType) {
value_ = 0;
SetIeName(kRequestTypeIeName);
}
//------------------------------------------------------------------------------
RequestType::RequestType(uint8_t value) : Type1NasIeFormatTv(kIeiRequestType) {
value_ = value;
SetIeName(kRequestTypeIeName);
}
//------------------------------------------------------------------------------
......
......@@ -35,6 +35,8 @@ class RequestType : public Type1NasIeFormatTv {
RequestType(uint8_t value);
~RequestType();
static std::string GetIeName() { return kRequestTypeIeName; }
void SetValue(uint8_t value);
uint8_t GetValue() const;
......
......@@ -35,7 +35,6 @@ S1UeSecurityCapability::S1UeSecurityCapability() : Type4NasIe() {
uia_ = std::nullopt;
gea_ = std::nullopt;
SetLengthIndicator(2);
SetIeName(kS1UeSecurityCapabilityIeName);
}
//------------------------------------------------------------------------------
......@@ -46,7 +45,6 @@ S1UeSecurityCapability::S1UeSecurityCapability(uint8_t iei) : Type4NasIe(iei) {
uia_ = std::nullopt;
gea_ = std::nullopt;
SetLengthIndicator(2);
SetIeName(kS1UeSecurityCapabilityIeName);
}
//------------------------------------------------------------------------------
......@@ -55,7 +53,6 @@ S1UeSecurityCapability::S1UeSecurityCapability(
eea_ = eea;
eia_ = eia;
SetLengthIndicator(2);
SetIeName(kS1UeSecurityCapabilityIeName);
}
//------------------------------------------------------------------------------
......@@ -66,7 +63,6 @@ S1UeSecurityCapability::S1UeSecurityCapability(
uea_ = std::optional<uint8_t>(uea);
uia_ = std::optional<uint8_t>(uia);
SetLengthIndicator(4);
SetIeName(kS1UeSecurityCapabilityIeName);
}
//------------------------------------------------------------------------------
S1UeSecurityCapability::~S1UeSecurityCapability() {}
......
......@@ -37,9 +37,10 @@ class S1UeSecurityCapability : public Type4NasIe {
S1UeSecurityCapability(const uint8_t iei, uint8_t eea, uint8_t eia);
S1UeSecurityCapability(
const uint8_t iei, uint8_t eea, uint8_t eia, uint8_t uea, uint8_t uia);
~S1UeSecurityCapability();
static std::string GetIeName() { return kS1UeSecurityCapabilityIeName; }
void SetEea(uint8_t sel);
uint8_t GetEea() const;
......
......@@ -35,7 +35,6 @@ S_NSSAI::S_NSSAI(std::optional<uint8_t> iei) : Type4NasIe() {
mapped_hplmn_sst_ = std::nullopt;
mapped_hplmn_sd_ = std::nullopt;
SetLengthIndicator(1); // SST
SetIeName(kSNssaiIeName);
}
//------------------------------------------------------------------------------
......@@ -76,7 +75,6 @@ S_NSSAI::S_NSSAI(std::optional<uint8_t> iei, SNSSAI_s snssai) {
}
SetLengthIndicator(snssai.length);
SetIeName(kSNssaiIeName);
}
//------------------------------------------------------------------------------
......
......@@ -37,6 +37,8 @@ class S_NSSAI : public Type4NasIe {
S_NSSAI(std::optional<uint8_t> iei, SNSSAI_s snssai);
~S_NSSAI();
static std::string GetIeName() { return kSNssaiIeName; }
// void SetSNssai(SNSSAI_s snssai);
int Encode(uint8_t* buf, int len);
int Decode(uint8_t* buf, int len, const bool is_option = true);
......
......@@ -25,6 +25,7 @@
#include "NasIe.hpp"
constexpr uint8_t kSecurityHeaderTypeLength = 1;
constexpr auto kSecurityHeaderTypeIeName = "Security Header Type";
namespace nas {
......@@ -33,6 +34,8 @@ class SecurityHeaderType : public NasIe {
SecurityHeaderType();
virtual ~SecurityHeaderType();
static std::string GetIeName() { return kSecurityHeaderTypeIeName; }
bool Validate(const int& len) const override;
void Set(const uint8_t& secu_header_type, const uint8_t& spare = 0);
......
......@@ -23,9 +23,7 @@
using namespace nas;
//------------------------------------------------------------------------------
ServiceType::ServiceType() : Type1NasIe(true), service_type_value_() {
SetIeName(kServiceTypeIeName);
}
ServiceType::ServiceType() : Type1NasIe(true), service_type_value_() {}
//------------------------------------------------------------------------------
ServiceType::ServiceType(uint8_t value) : Type1NasIe(true) {
......
......@@ -34,6 +34,8 @@ class ServiceType : public Type1NasIe {
ServiceType(uint8_t value);
~ServiceType();
static std::string GetIeName() { return kServiceTypeIeName; }
// int Encode(uint8_t* buf, int len);
// int Decode(uint8_t* nuf, int len, bool is_iei, bool is_high);
......
......@@ -28,7 +28,6 @@ using namespace nas;
SorTransparentContainer::SorTransparentContainer()
: Type6NasIe(kIeiSorTransparentContainer), header_(), sor_mac_i_() {
SetLengthIndicator(kSorTransparentContainerIeMinimumLength);
SetIeName(kSorTransparentContainerIeName);
}
//------------------------------------------------------------------------------
......@@ -39,7 +38,6 @@ SorTransparentContainer::SorTransparentContainer(
this->sor_mac_i_[i] = value[i];
}
SetLengthIndicator(kSorTransparentContainerIeMinimumLength);
SetIeName(kSorTransparentContainerIeName);
}
//------------------------------------------------------------------------------
......
......@@ -35,6 +35,8 @@ class SorTransparentContainer : Type6NasIe {
SorTransparentContainer(uint8_t header, const uint8_t (&value)[16]);
~SorTransparentContainer();
static std::string GetIeName() { return kSorTransparentContainerIeName; }
int Encode(uint8_t* buf, int len);
int Decode(uint8_t* buf, int len, bool is_iei);
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include "StandardL3NasIe.hpp"
#include "3gpp_24.501.hpp"
#include "common_defs.h"
#include "logger.hpp"
using namespace nas;
//------------------------------------------------------------------------------
StandardL3NasIe::StandardL3NasIe() : NasIe() {
iei_ = std::nullopt;
}
//------------------------------------------------------------------------------
StandardL3NasIe::StandardL3NasIe(const uint8_t& iei) : NasIe() {
iei_ = std::optional<uint8_t>(iei);
}
//------------------------------------------------------------------------------
StandardL3NasIe::~StandardL3NasIe() {}
//------------------------------------------------------------------------------
void StandardL3NasIe::SetIei(const uint8_t& iei) {
iei_ = std::optional<uint8_t>(iei);
}
//------------------------------------------------------------------------------
bool StandardL3NasIe::Validate(const int& len) const {
int ie_len = GetIeLength(); // Length of the content + IEI/Len
if (len < ie_len) {
Logger::nas_mm().error(
"Buffer length is less than the length of this IE (%d octet(s))",
ie_len);
return false;
}
return true;
}
/*
* 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 _STANDARD_L3_NAS_IE_H_
#define _STANDARD_L3_NAS_IE_H_
#include "NasIe.hpp"
namespace nas {
class StandardL3NasIe : public NasIe {
public:
StandardL3NasIe();
StandardL3NasIe(const uint8_t& iei);
virtual ~StandardL3NasIe();
bool Validate(const int& len) const override;
void SetIei(const uint8_t& iei);
virtual uint8_t GetIeLength() const = 0;
protected:
std::optional<uint8_t> iei_; // IEI (Optional)
};
} // namespace nas
#endif
......@@ -97,7 +97,7 @@ void Type1NasIe::SetValue(const uint8_t& value) {
//------------------------------------------------------------------------------
int Type1NasIe::Encode(uint8_t* buf, const int& len) {
Logger::nas_mm().debug("Encoding %s", GetIeName().c_str());
// Logger::nas_mm().debug("Encoding %s", GetIeName().c_str());
if (!Validate(len)) return KEncodeDecodeError;
int encoded_size = 0;
......@@ -120,8 +120,8 @@ int Type1NasIe::Encode(uint8_t* buf, const int& len) {
ENCODE_U8(buf + encoded_size, octet, encoded_size);
Logger::nas_mm().debug(
"Encoded %s (len %d)", GetIeName().c_str(), encoded_size);
// Logger::nas_mm().debug(
// "Encoded %s (len %d)", GetIeName().c_str(), encoded_size);
if (iei_.has_value()) {
return encoded_size; // 1 octet
} else {
......@@ -138,7 +138,7 @@ int Type1NasIe::Decode(const uint8_t* const buf, const int& len, bool is_iei) {
int Type1NasIe::Decode(
const uint8_t* const buf, const int& len, const bool& high_pos,
bool is_iei) {
Logger::nas_mm().debug("Decoding %s", GetIeName().c_str());
// Logger::nas_mm().debug("Decoding %s", GetIeName().c_str());
if (!Validate(len)) return KEncodeDecodeError;
......@@ -158,8 +158,8 @@ int Type1NasIe::Decode(
}
}
Logger::nas_mm().debug(
"Decoded %s (len %d)", GetIeName().c_str(), decoded_size);
// Logger::nas_mm().debug(
// "Decoded %s (len %d)", GetIeName().c_str(), decoded_size);
if (is_iei) {
return decoded_size; // 1 octet
} else {
......
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.
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