Commit 18d41c6b authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Update Security Mode Reject

parent d1ff5425
...@@ -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
*/
#include "AuthenticationResult.hpp" #include "AuthenticationResult.hpp"
#include "3gpp_24.501.hpp" #include "3gpp_24.501.hpp"
...@@ -56,7 +49,7 @@ void AuthenticationResult::SetNgKsi(uint8_t tsc, uint8_t key_set_id) { ...@@ -56,7 +49,7 @@ void AuthenticationResult::SetNgKsi(uint8_t tsc, uint8_t key_set_id) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void AuthenticationResult::SetAbba(uint8_t length, uint8_t* value) { void AuthenticationResult::SetAbba(uint8_t length, uint8_t* value) {
ie_abba = std::make_optional<ABBA>(0x38, length, value); ie_abba = std::make_optional<ABBA>(kIeiAbba, length, value);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -67,7 +60,6 @@ void AuthenticationResult::SetEapMessage(bstring eap) { ...@@ -67,7 +60,6 @@ void AuthenticationResult::SetEapMessage(bstring eap) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int AuthenticationResult::Encode(uint8_t* buf, int len) { int AuthenticationResult::Encode(uint8_t* buf, int len) {
Logger::nas_mm().debug("Encoding AuthenticationResult message"); Logger::nas_mm().debug("Encoding AuthenticationResult message");
int encoded_size = 0; int encoded_size = 0;
int encoded_ie_size = 0; int encoded_ie_size = 0;
......
...@@ -34,65 +34,73 @@ ...@@ -34,65 +34,73 @@
using namespace nas; using namespace nas;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
SecurityModeReject::SecurityModeReject() { SecurityModeReject::SecurityModeReject()
Logger::nas_mm().debug("initiating class SecurityModeReject"); : NasMmPlainHeader(EPD_5GS_MM_MSG, SECURITY_MODE_REJECT) {}
plain_header = NULL;
ie_5gmm_cause = NULL;
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
SecurityModeReject::~SecurityModeReject() {} SecurityModeReject::~SecurityModeReject() {}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void SecurityModeReject::SetHeader(uint8_t security_header_type) { void SecurityModeReject::SetHeader(uint8_t security_header_type) {
plain_header = new NasMmPlainHeader(); NasMmPlainHeader::SetSecurityHeaderType(security_header_type);
plain_header->SetHeader(
EPD_5GS_MM_MSG, security_header_type, SECURITY_MODE_REJECT);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void SecurityModeReject::Set5gmmCause(uint8_t value) { void SecurityModeReject::Set5gmmCause(uint8_t value) {
ie_5gmm_cause = new _5gmmCause(0x00, value); ie_5gmm_cause.SetValue(value);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int SecurityModeReject::Encode(uint8_t* buf, int len) { int SecurityModeReject::Encode(uint8_t* buf, int len) {
Logger::nas_mm().debug("encoding SecurityModeReject message"); Logger::nas_mm().debug("encoding SecurityModeReject message");
int encoded_size = 0; int encoded_size = 0;
if (!plain_header) { int encoded_ie_size = 0;
Logger::nas_mm().error("Mandatory IE missing Header"); // Header
return 0; if ((encoded_ie_size = NasMmPlainHeader::Encode(buf, len)) ==
KEncodeDecodeError) {
Logger::nas_mm().error("Encoding NAS Header error");
return KEncodeDecodeError;
} }
if (!(plain_header->Encode(buf, len))) return 0; encoded_size += encoded_ie_size;
encoded_size += 3;
if (!ie_5gmm_cause) { // 5GMM Cause
Logger::nas_mm().warn("IE ie_5gmm_cause is not available"); if (int size = ie_5gmm_cause.Encode(buf + encoded_size, len - encoded_size)) {
} else {
if (int size =
ie_5gmm_cause->Encode(buf + encoded_size, len - encoded_size)) {
encoded_size += size; encoded_size += size;
} else { } else {
Logger::nas_mm().error("encoding ie_5gmm_cause error"); Logger::nas_mm().error("Encoding ie_5gmm_cause error");
}
} }
Logger::nas_mm().debug( Logger::nas_mm().debug(
"encoded SecurityModeReject message len(%d)", encoded_size); "encoded SecurityModeReject message len(%d)", encoded_size);
return 1; return encoded_size;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int SecurityModeReject::Decode( int SecurityModeReject::Decode(uint8_t* buf, int len) {
NasMmPlainHeader* header, uint8_t* buf, int len) {
Logger::nas_mm().debug("decoding SecurityModeReject message"); Logger::nas_mm().debug("decoding SecurityModeReject message");
int decoded_size = 3; int decoded_size = 0;
plain_header = header; int decoded_result = 0;
ie_5gmm_cause = new _5gmmCause();
decoded_size += // Header
ie_5gmm_cause->Decode(buf + decoded_size, len - decoded_size, false); decoded_result = NasMmPlainHeader::Decode(buf, len);
Logger::nas_mm().debug("decoded_size(%d)", decoded_size); if (decoded_result == KEncodeDecodeError) {
uint8_t octet = *(buf + decoded_size); Logger::nas_mm().error("Decoding NAS Header error");
Logger::nas_mm().debug("first option iei(0x%x)", octet); return KEncodeDecodeError;
}
decoded_size += decoded_result;
// 5GMM Cause
decoded_result =
ie_5gmm_cause.Decode(buf + decoded_size, len - decoded_size, false);
if (decoded_result != KEncodeDecodeError) {
decoded_size += decoded_result;
} else {
Logger::nas_mm().error("Encoding ie_payload_container error");
return KEncodeDecodeError;
}
Logger::nas_mm().debug( Logger::nas_mm().debug(
"decoded SecurityModeReject message len(%d)", decoded_size); "decoded SecurityModeReject message len(%d)", decoded_size);
return 1; return decoded_size;
} }
...@@ -19,32 +19,28 @@ ...@@ -19,32 +19,28 @@
* contact@openairinterface.org * contact@openairinterface.org
*/ */
/*! \file #ifndef _SECURITY_MODE_REJECT_H_
\brief #define _SECURITY_MODE_REJECT_H_
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _SecurityModeReject_H_
#define _SecurityModeReject_H_
#include "NasIeHeader.hpp" #include "NasIeHeader.hpp"
namespace nas { namespace nas {
class SecurityModeReject { class SecurityModeReject : public NasMmPlainHeader {
public: public:
SecurityModeReject(); SecurityModeReject();
~SecurityModeReject(); ~SecurityModeReject();
int Encode(uint8_t* buf, int len);
int Decode(NasMmPlainHeader* header, uint8_t* buf, int len);
void SetHeader(uint8_t security_header_type); void SetHeader(uint8_t security_header_type);
int Encode(uint8_t* buf, int len);
int Decode(uint8_t* buf, int len);
void Set5gmmCause(uint8_t value); void Set5gmmCause(uint8_t value);
// Get
public: public:
NasMmPlainHeader* plain_header; _5gmmCause ie_5gmm_cause; // Mandatory
_5gmmCause* ie_5gmm_cause;
}; };
} // 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