Commit 79ed2879 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Process UE-initiated Deregistration request

parent fdf5094a
......@@ -28,26 +28,28 @@
#include "amf_n1.hpp"
#include "amf_n11.hpp"
#include "amf_app.hpp"
#include "itti.hpp"
#include "logger.hpp"
#include "RegistrationRequest.hpp"
#include "RegistrationReject.hpp"
#include "amf_config.hpp"
#include "amf_n11.hpp"
#include "AuthenticationRequest.hpp"
#include "AuthenticationResponse.hpp"
#include "AuthenticationFailure.hpp"
#include "comUt.hpp"
#include "DeregistrationRequest.hpp"
#include "DeregistrationAccept.hpp"
#include "itti_msg_n2.hpp"
#include "itti_msg_n11.hpp"
#include "itti.hpp"
#include "logger.hpp"
#include "nas_algorithms.hpp"
#include "SecurityModeCommand.hpp"
#include "RegistrationRequest.hpp"
#include "RegistrationAccept.hpp"
#include "RegistrationReject.hpp"
#include "ULNASTransport.hpp"
#include "ServiceRequest.hpp"
#include "ServiceAccept.hpp"
#include "itti_msg_n2.hpp"
#include "itti_msg_n11.hpp"
#include "amf_config.hpp"
#include "String2Value.hpp"
#include "nas_algorithms.hpp"
#include "comUt.hpp"
#include "sha256.hpp"
extern "C" {
......@@ -1513,12 +1515,44 @@ void amf_n1::run_initial_registration_procedure() {
//------------------------------------------------------------------------------
void amf_n1::ue_initiate_de_registration_handle(uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, bstring nas) {
string guti = "1234567890"; //need modify
Logger::amf_n1().debug("Handling UE-initiated De-registration Request");
std::shared_ptr<nas_context> nc;
nc = guti_2_nas_context(guti);
nc.get()->is_auth_vectors_present = false;
nc.get()->is_current_security_available = false;
nc.get()->security_ctx->sc_type = SECURITY_CTX_TYPE_NOT_AVAILABLE;
if (is_amf_ue_id_2_nas_context(amf_ue_ngap_id))
nc = amf_ue_id_2_nas_context(amf_ue_ngap_id);
else {
Logger::amf_n1().warn("No existed nas_context with amf_ue_ngap_id(0x%x)", amf_ue_ngap_id);
return;
}
//decode NAS msg
DeregistrationRequest *deregReq = new DeregistrationRequest();
deregReq->decodefrombuffer(NULL, (uint8_t*) bdata(nas), blength(nas));
_5gs_deregistration_type_t type = {};
deregReq->getDeregistrationType(type);
//TODO: validate 5G Mobile Identity
//Prepare DeregistrationAccept
DeregistrationAccept *deregAccept = new DeregistrationAccept();
deregAccept->setHeader(PLAIN_5GS_MSG);
//nc.get()->is_auth_vectors_present = false;
//nc.get()->is_current_security_available = false;
//nc.get()->security_ctx->sc_type = SECURITY_CTX_TYPE_NOT_AVAILABLE;
uint8_t buffer[512] = { 0 };
int encoded_size = deregAccept->encode2buffer(buffer, 1024);
print_buffer("amf_n1", "De-registration Accept message buffer", buffer, encoded_size);
if (!encoded_size) {
Logger::nas_mm().error("Encode De-registration Accept message error");
free_wrapper((void**) &deregAccept);
return;
}
bstring b = blk2bstr(buffer, encoded_size);
itti_send_dl_nas_buffer_to_task_n2(b, ran_ue_ngap_id, amf_ue_ngap_id);
free_wrapper((void**) &deregAccept);
}
//------------------------------------------------------------------------------
......
......@@ -236,15 +236,15 @@ void amf_n11::handle_itti_message(itti_smf_services_consumer &smf) {
}
switch (smf.req_type & 0x07) {
case PDU_SESSION_INITIAL_REQUEST: {
case REQUEST_TYPE_INITIAL_REQUEST: {
handle_pdu_session_initial_request(supi, psc, smf_addr, smf.sm_msg, dnn);
}
break;
case EXISTING_PDU_SESSION: {
case REQUEST_TYPE_EXISTING_PDU_SESSION: {
//TODO:
}
break;
case PDU_SESSION_MODIFICATION_REQUEST: {
case REQUEST_TYPE_MODIFICATION_REQUEST: {
//TODO:
}
break;
......
......@@ -44,25 +44,38 @@
/********** message type ********************/
#define REGISTRATION_REQUEST 0b01000001
#define REGISTRATION_REJECT 0b01000100
#define AUTHENTICATION_REQUEST 0b01010110
#define AUTHENTICATION_RESPONSE 0b01010111
#define AUTHENTICATION_RESULT 0b01011010
#define AUTHENTICATION_FAILURE 0b01011001
#define AUTHENTICATION_REJECT 0b01011000
#define SECURITY_MODE_COMMAND 0b01011101
#define SECURITY_MODE_COMPLETE 0b01011110
#define SECURITY_MODE_REJECT 0b01011111
#define REGISTRATION_COMPLETE 0b01000011
#define REGISTRATION_ACCEPT 0b01000010
#define IDENTITY_REQUEST 0b01011011
#define IDENTITY_RESPONSE 0b01011100
#define UL_NAS_TRANSPORT 0b01100111
#define DL_NAS_TRANSPORT 0b01101000
#define SERVICE_REQUEST 0b01001100
#define SERVICE_REJECT 0b01001101
#define SERVICE_ACCEPT 0b01001110
#define REGISTRATION_REQUEST 0b01000001
#define REGISTRATION_ACCEPT 0b01000010
#define REGISTRATION_COMPLETE 0b01000011
#define REGISTRATION_REJECT 0b01000100
#define DEREGISTRATION_REQUEST_UE_ORIGINATING 0b01000101
#define DEREGISTRATION_ACCEPT_UE_ORIGINATING 0b01000110
#define DEREGISTRATION_REQUEST_UE_TERMINATED 0b01000111
#define DEREGISTRATION_ACCEPT_UE_TERMINATED 0b01001000
#define SERVICE_REQUEST 0b01001100
#define SERVICE_REJECT 0b01001101
#define SERVICE_ACCEPT 0b01001110
#define CONFIGURATION_UPDATE_COMMAND 0b01010100
#define CONFIGURATION_UPDATE_COMPLETE 0b01010101
#define AUTHENTICATION_REQUEST 0b01010110
#define AUTHENTICATION_RESPONSE 0b01010111
#define AUTHENTICATION_REJECT 0b01011000
#define AUTHENTICATION_FAILURE 0b01011001
#define AUTHENTICATION_RESULT 0b01011010
#define IDENTITY_REQUEST 0b01011011
#define IDENTITY_RESPONSE 0b01011100
#define SECURITY_MODE_COMMAND 0b01011101
#define SECURITY_MODE_COMPLETE 0b01011110
#define SECURITY_MODE_REJECT 0b01011111
#define _5GMM_STATUS 0b01100100
#define MESSAGE_TYPE_NOTIFICATION 0b01100101
#define MESSAGE_TYPE_NOTIFICATION_RESPONSE 0b01100110
#define UL_NAS_TRANSPORT 0b01100111
#define DL_NAS_TRANSPORT 0b01101000
#define UE_INIT_DEREGISTER 0b01000101
/********* registration type ***************/
......@@ -137,16 +150,16 @@
#define UE_PARAMETERS_UPDATE 0x06
#define MULTIPLE_PAYLOADS 0x0f
#define PDU_SESSION_INITIAL_REQUEST 0b001
#define EXISTING_PDU_SESSION 0b010
#define PDU_SESSION_INITIAL_EMERGENCY_REQUEST 0b011
#define EXISTING_EMERGENCY_PDU_SESSION 0b100
#define PDU_SESSION_MODIFICATION_REQUEST 0b101
#define MA_PDU_REQUEST 0b110
#define REQUEST_TYPE_INITIAL_REQUEST 0b001
#define REQUEST_TYPE_EXISTING_PDU_SESSION 0b010
#define REQUEST_TYPE_INITIAL_EMERGENCY_REQUEST 0b011
#define REQUEST_TYPE_EXISTING_EMERGENCY_PDU_SESSION 0b100
#define REQUEST_TYPE_MODIFICATION_REQUEST 0b101
#define REQUEST_TYPE_MA_PDU_REQUEST 0b110
#define PDU_SESSION_MESSAGE_TYPE_UNKNOWN 0b00000000
#define PDU_SESSION_MESSAGE_TYPE_UNKNOWN 0b11000000
#define PDU_SESSION_ESTABLISHMENT_REQUEST 0b11000001
#define PDU_SESSION_ESTABLISHMENT_ACCEPT 0b11000010
#define PDU_SESSION_ESTABLISHMENT_REJECT 0b11000011
......@@ -157,7 +170,7 @@
#define PDU_SESSION_MODIFICATION_REJECT 0b11001010
#define PDU_SESSION_MODIFICATION_COMMAND 0b11001011
#define PDU_SESSION_MODIFICATION_COMPLETE 0b11001100
#define PDU_SESSION_MODIFICATION_COMMAND_REJECT 0b11001101
#define PDU_SESSION_MODIFICATION_COMMAND_REJECT 0b11001101
#define PDU_SESSION_RELEASE_REQUEST 0b11010001
#define PDU_SESSION_RELEASE_REJECT 0b11010010
#define PDU_SESSION_RELEASE_COMMAND 0b11010011
......
......@@ -28,6 +28,7 @@
#include "nas_mm_plain_header.hpp"
#include "5GSRegistrationType.hpp"
#include "_5GSDeregistrationType.hpp"
#include "NasKeySetIdentifier.hpp"
#include "5GSMobilityIdentity.hpp"
#include "5GMMCapability.hpp"
......
......@@ -47,6 +47,12 @@ typedef struct _5G_GUTI_s {
uint8_t amf_set_id;
uint16_t amf_pointer;
uint32_t _5g_tmsi;
const std::string& toString() const {
std::string str;
str = mcc + mnc + std::to_string(amf_region_id) + std::to_string(amf_set_id) + std::to_string(amf_pointer) + std::to_string(_5g_tmsi);
return str;
}
} _5G_GUTI_t;
typedef struct IMEI_or_IMEISV_s {
......
/*
* 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
*/
/*! \file
\brief
\author
\date 2020
\email: contact@openairinterface.org
*/
#include "_5GSDeregistrationType.hpp"
#include "3gpp_ts24501.hpp"
#include "logger.hpp"
using namespace nas;
//------------------------------------------------------------------------------
_5GSDeregistrationType::_5GSDeregistrationType() {
u1.b = 0;
}
//------------------------------------------------------------------------------
_5GSDeregistrationType::_5GSDeregistrationType(uint8_t type) {
u1.b = type;
}
//------------------------------------------------------------------------------
_5GSDeregistrationType::_5GSDeregistrationType(_5gs_deregistration_type_t type) {
u1.b = 0;
u1.bf.switch_off = type.switch_off;
u1.bf.dereg_required = type.dereg_required;
u1.bf.access_type = type.access_type;
u1.bf.iei = type.iei;
}
//------------------------------------------------------------------------------
_5GSDeregistrationType::~_5GSDeregistrationType() {
}
//------------------------------------------------------------------------------
void _5GSDeregistrationType::set(_5gs_deregistration_type_t type) {
u1.b = 0;
u1.bf.switch_off = type.switch_off;
u1.bf.dereg_required = type.dereg_required;
u1.bf.access_type = type.access_type;
u1.bf.iei = type.iei;
}
//------------------------------------------------------------------------------
void _5GSDeregistrationType::get(_5gs_deregistration_type_t& type) {
type.switch_off = u1.bf.switch_off;
type.dereg_required = u1.bf.dereg_required;
type.access_type = u1.bf.access_type;
type.iei = u1.bf.iei;
}
//------------------------------------------------------------------------------
void _5GSDeregistrationType::set(uint8_t type) {
u1.b = type;
}
//------------------------------------------------------------------------------
void _5GSDeregistrationType::get(uint8_t& type) {
type = u1.b;
}
//------------------------------------------------------------------------------
int _5GSDeregistrationType::encode2buffer(uint8_t *buf, int len) {
Logger::nas_mm().error("Encoding 5GSDeregistrationType IE");
if (len < 1) {
Logger::nas_mm().error("encoding 5GSDeregistrationType error(len is less than one)");
return -1;
}
*buf = u1.b;
}
//------------------------------------------------------------------------------
int _5GSDeregistrationType::decodefrombuffer(uint8_t *buf, int len) {
Logger::nas_mm().debug("Decoding 5GSDeregistrationType");
u1.b = *buf;
Logger::nas_mm().debug("Decoded 5GSDeRegistrationType");
return 0;
}
/*
* 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
*/
/*! \file
\brief
\author
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _5GS_DEREGISTRATION_TYPE_H_
#define _5GS_DEREGISTRATION_TYPE_H_
#include <stdint.h>
namespace nas {
typedef struct _5gs_deregistration_type_s {
uint8_t iei :4;
uint8_t switch_off:1;
uint8_t dereg_required :1;
uint8_t access_type :2;
} _5gs_deregistration_type_t;
class _5GSDeregistrationType {
public:
_5GSDeregistrationType();
_5GSDeregistrationType(uint8_t type);
_5GSDeregistrationType(_5gs_deregistration_type_t type);
~_5GSDeregistrationType();
int decodefrombuffer(uint8_t *buf, int len);
int encode2buffer(uint8_t *buf, int len);
void set(_5gs_deregistration_type_t type);
void get(_5gs_deregistration_type_t& type);
void set(uint8_t type);
void get(uint8_t& type);
public:
union {
struct {
uint8_t iei :4;
uint8_t switch_off:1;
uint8_t dereg_required :1;
uint8_t access_type :2;
} bf;
uint8_t b;
} u1;
};
}
#endif
/*
* 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
*/
/*! \file
\brief
\author
\date 2020
\email: contact@openairinterface.org
*/
#include "DeregistrationAccept.hpp"
#include "3gpp_ts24501.hpp"
#include "logger.hpp"
#include "String2Value.hpp"
using namespace nas;
//------------------------------------------------------------------------------
DeregistrationAccept::DeregistrationAccept() {
plain_header = NULL;
}
//------------------------------------------------------------------------------
DeregistrationAccept::~DeregistrationAccept() {
}
//------------------------------------------------------------------------------
void DeregistrationAccept::setHeader(uint8_t security_header_type) {
plain_header = new NasMmPlainHeader();
plain_header->setHeader(EPD_5GS_MM_MSG, security_header_type, DEREGISTRATION_ACCEPT_UE_ORIGINATING);
}
//------------------------------------------------------------------------------
int DeregistrationAccept::encode2buffer(uint8_t *buf, int len) {
Logger::nas_mm().debug("Encoding De-registration Accept message");
int encoded_size = 0;
if (!plain_header) {
Logger::nas_mm().error("Mandatory IE missing Header");
return 0;
}
encoded_size = plain_header->encode2buffer(buf, len);
Logger::nas_mm().debug("Encoded De-registration Accept message len (%d)", encoded_size);
return encoded_size;
}
//------------------------------------------------------------------------------
int DeregistrationAccept::decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf, int len) {
Logger::nas_mm().debug("Decoding De-registrationReject message");
int decoded_size = 3;
plain_header = header;
Logger::nas_mm().debug("decoded De-registrationReject message len (%d)", decoded_size);
}
/*
* 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
*/
/*! \file
\brief
\author
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _DEREGISTRATION_ACCEPT_H_
#define _DEREGISTRATION_ACCEPT_H_
#include "nas_ie_header.hpp"
namespace nas {
class DeregistrationAccept {
public:
DeregistrationAccept();
~DeregistrationAccept();
int encode2buffer(uint8_t *buf, int len);
int decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf, int len);
void setHeader(uint8_t security_header_type);
public:
NasMmPlainHeader *plain_header;
};
}
#endif
/*
* 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
*/
/*! \file
\brief
\author
\date 2020
\email: contact@openairinterface.org
*/
#include "DeregistrationRequest.hpp"
#include "3gpp_ts24501.hpp"
#include "logger.hpp"
#include "String2Value.hpp"
using namespace nas;
//------------------------------------------------------------------------------
DeregistrationRequest::DeregistrationRequest() {
plain_header = NULL;
ie_deregistrationtype = NULL;
ie_ngKSI = NULL;
ie_5gs_mobility_id = NULL;
}
//------------------------------------------------------------------------------
DeregistrationRequest::~DeregistrationRequest() {
}
//------------------------------------------------------------------------------
void DeregistrationRequest::setHeader(uint8_t security_header_type) {
plain_header = new NasMmPlainHeader();
plain_header->setHeader(EPD_5GS_MM_MSG, security_header_type, DEREGISTRATION_REQUEST_UE_ORIGINATING);
}
//------------------------------------------------------------------------------
void DeregistrationRequest::setDeregistrationType(uint8_t dereg_type) {
ie_deregistrationtype = new _5GSDeregistrationType(dereg_type);
}
//------------------------------------------------------------------------------
void DeregistrationRequest::setDeregistrationType(_5gs_deregistration_type_t type) {
ie_deregistrationtype = new _5GSDeregistrationType(type);
}
//------------------------------------------------------------------------------
void DeregistrationRequest::setngKSI(uint8_t tsc, uint8_t key_set_id) {
ie_ngKSI = new NasKeySetIdentifier(tsc, key_set_id);
}
//------------------------------------------------------------------------------
void DeregistrationRequest::getDeregistrationType(uint8_t &dereg_type) {
ie_deregistrationtype->get(dereg_type );
}
//------------------------------------------------------------------------------
void DeregistrationRequest::getDeregistrationType(_5gs_deregistration_type_t& type) {
ie_deregistrationtype->get(type);
}
//------------------------------------------------------------------------------
uint8_t DeregistrationRequest::getngKSI() {
if (ie_ngKSI) {
uint8_t a = 0;
a = (ie_ngKSI->getTypeOfSecurityContext()) | ie_ngKSI->getasKeyIdentifier();
return a;
} else {
return -1;
}
}
//------------------------------------------------------------------------------
void DeregistrationRequest::setSUCI_SUPI_format_IMSI(const string mcc, const string mnc, const string routingInd, uint8_t protection_sch_id, const string msin) {
if (protection_sch_id != NULL_SCHEME) {
Logger::nas_mm().error("encoding suci and supi format for imsi error, please choose right interface");
return;
} else {
ie_5gs_mobility_id = new _5GSMobilityIdentity(mcc, mnc, routingInd, protection_sch_id, msin);
}
}
//------------------------------------------------------------------------------
uint8_t DeregistrationRequest::getMobilityIdentityType() {
if (ie_5gs_mobility_id) {
return ie_5gs_mobility_id->gettypeOfIdentity();
} else {
return -1;
}
}
//------------------------------------------------------------------------------
bool DeregistrationRequest::getSuciSupiFormatImsi(nas::SUCI_imsi_t &imsi) {
if (ie_5gs_mobility_id) {
ie_5gs_mobility_id->getSuciWithSupiImsi(imsi);
return true;
} else {
return false;
}
}
//------------------------------------------------------------------------------
std::string DeregistrationRequest::get_5g_guti() {
if (ie_5gs_mobility_id) {
nas::_5G_GUTI_t guti;
ie_5gs_mobility_id->get5GGUTI(guti);
return guti.toString();
} else {
return "error";
}
}
//------------------------------------------------------------------------------
void DeregistrationRequest::setSUCI_SUPI_format_IMSI(const string mcc, const string mnc, const string routingInd, uint8_t protection_sch_id, uint8_t hnpki, const string msin) {
}
//------------------------------------------------------------------------------
void DeregistrationRequest::set5G_GUTI() {
}
//------------------------------------------------------------------------------
void DeregistrationRequest::setIMEI_IMEISV() {
}
//------------------------------------------------------------------------------
void DeregistrationRequest::set5G_S_TMSI() {
}
//------------------------------------------------------------------------------
int DeregistrationRequest::encode2buffer(uint8_t *buf, int len) {
Logger::nas_mm().debug("Encoding DeregistrationRequest message");
int encoded_size = 0;
if (!plain_header) {
Logger::nas_mm().error("Mandatory IE missing Header");
return 0;
}
if (!ie_deregistrationtype) {
Logger::nas_mm().error("Mandatory IE missing Deregistration Type");
return 0;
}
if (!ie_ngKSI) {
Logger::nas_mm().error("Mandatory IE missing ie_ngKSI");
return 0;
}
if (!ie_5gs_mobility_id) {
Logger::nas_mm().error("Mandatory IE missing ie_5gs_mobility_id");
return 0;
}
if (!(plain_header->encode2buffer(buf, len)))
return 0;
encoded_size += 3;
if (!(ie_deregistrationtype->encode2buffer(buf + encoded_size, len - encoded_size))) {
if (!(ie_ngKSI->encode2buffer(buf + encoded_size, len - encoded_size))) {
encoded_size += 1;
} else {
Logger::nas_mm().error("Encoding IE ie_ngKSI error");
return 0;
}
} else {
Logger::nas_mm().error("Encoding IE Deregistrationt Type error");
return 0;
}
if (int size = ie_5gs_mobility_id->encode2buffer(buf + encoded_size, len - encoded_size)) {
encoded_size += size;
} else {
Logger::nas_mm().error("Encoding IE ie_5gs_mobility_id error");
return 0;
}
Logger::nas_mm().debug("Encoded DeregistrationRequest message len (%d)", encoded_size);
return 1;
}
//------------------------------------------------------------------------------
int DeregistrationRequest::decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf, int len) {
Logger::nas_mm().debug("****Decoding DeregistrationRequest message****");
int decoded_size = 3;
plain_header = header;
ie_deregistrationtype = new _5GSDeregistrationType();
decoded_size += ie_deregistrationtype->decodefrombuffer(buf + decoded_size, len - decoded_size);
ie_ngKSI = new NasKeySetIdentifier();
decoded_size += ie_ngKSI->decodefrombuffer(buf + decoded_size, len - decoded_size, false, true);
decoded_size++;
ie_5gs_mobility_id = new _5GSMobilityIdentity();
decoded_size += ie_5gs_mobility_id->decodefrombuffer(buf + decoded_size, len - decoded_size, false);
Logger::nas_mm().debug("****Decoded DeregistrationRequest message (len %d)****", decoded_size);
}
/*
* 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
*/
/*! \file
\brief
\author
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _DEREGISTRATION_REQUEST_H_
#define _DEREGISTRATION_REQUEST_H_
#include "nas_ie_header.hpp"
using namespace std;
namespace nas {
class DeregistrationRequest {
public:
DeregistrationRequest();
~DeregistrationRequest();
int encode2buffer(uint8_t *buf, int len);
int decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf, int len);
void setHeader(uint8_t security_header_type);
void setDeregistrationType(uint8_t dereg_type);
void setDeregistrationType(_5gs_deregistration_type_t type);
void setngKSI(uint8_t tsc, uint8_t key_set_id);
void setMobilityIdentityType(uint8_t type);
void setSUCI_SUPI_format_IMSI(const string mcc, const string mnc, const string routingInd, uint8_t protection_sch_id, const string msin);
void setSUCI_SUPI_format_IMSI(const string mcc, const string mnc, const string routingInd, uint8_t protection_sch_id, uint8_t hnpki, const string msin);
void set5G_GUTI();
void setIMEI_IMEISV();
void set5G_S_TMSI();
void getDeregistrationType(uint8_t &dereg_type);
void getDeregistrationType(_5gs_deregistration_type_t& type);
uint8_t getngKSI();
uint8_t getMobilityIdentityType();
std::string get_5g_guti();
bool getSuciSupiFormatImsi(nas::SUCI_imsi_t &imsi);
public:
NasMmPlainHeader *plain_header;
_5GSDeregistrationType *ie_deregistrationtype;
NasKeySetIdentifier *ie_ngKSI;
_5GSMobilityIdentity *ie_5gs_mobility_id;
};
}
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment