Commit 71b15f0f authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Merge branch 'session_release' into 'develop'

Session release

See merge request oai/cn5g/oai-cn5g-amf!3
parents 451199f5 4669d48b
......@@ -203,12 +203,11 @@ void amf_app::handle_itti_message(
itti_downlink_nas_transfer *dl_msg = new itti_downlink_nas_transfer(
TASK_AMF_APP, TASK_AMF_N1);
dl_msg->dl_nas = dl_nas;
if (!itti_msg.is_n2sm_set) {
dl_msg->is_n2sm_set = false;
} else {
if (itti_msg.is_n2sm_set) {
dl_msg->n2sm = itti_msg.n2sm;
dl_msg->pdu_session_id = itti_msg.pdu_session_id;
dl_msg->is_n2sm_set = true;
dl_msg->n2sm_info_type = itti_msg.n2sm_info_type;
}
dl_msg->amf_ue_ngap_id = amf_n1_inst->supi2amfId.at(itti_msg.supi);
dl_msg->ran_ue_ngap_id = amf_n1_inst->supi2ranId.at(itti_msg.supi);
......
......@@ -21,7 +21,7 @@
/*! \file amf_config.cpp
\brief
\author Keliang DU, BUPT
\author Keliang DU (BUPT), Tien-Thinh NGUYEN (EURECOM)
\date 2020
\email: contact@openairinterface.org
*/
......
This diff is collapsed.
......@@ -21,7 +21,7 @@
/*! \file amf_n1.hpp
\brief
\author Keliang DU, BUPT
\author Keliang DU (BUPT), Tien-Thinh NGUYEN (EURECOM)
\date 2020
\email: contact@openairinterface.org
*/
......@@ -79,6 +79,8 @@ class amf_n1 {
std::map<std::string, long> supi2amfId;
std::map<std::string, uint32_t> supi2ranId;
mutable std::shared_mutex m_nas_context;
std::map<std::string, std::shared_ptr<nas_context>> guti2nas_context;
mutable std::shared_mutex m_guti2nas_context;
bool is_guti_2_nas_context(const std::string &guti) const;
......@@ -146,13 +148,9 @@ class amf_n1 {
uint8_t request_type,
uint8_t pdu_session_id, bstring dnn,
bstring sm_msg);
void update_ue_information_statics(ue_infos &ueItem,
const std::string connStatus,
const std::string registerStatus,
uint32_t ranid, uint32_t amfid,
std::string imsi, std::string guti,
std::string mcc, std::string mnc,
uint32_t cellId);
void set_5gmm_state(std::shared_ptr<nas_context> nc, _5gmm_state_t state);
void get_5gmm_state(std::shared_ptr<nas_context> nc, _5gmm_state_t &state);
private: //nas message handlers
void ue_initiate_de_registration_handle(uint32_t ran_ue_ngap_id,
......
This diff is collapsed.
......@@ -21,7 +21,7 @@
/*! \file amf_n11.hpp
\brief
\author Keliang DU, BUPT
\author Keliang DU (BUPT), Tien-Thinh NGUYEN (EURECOM)
\date 2020
\email: contact@openairinterface.org
*/
......@@ -47,8 +47,11 @@ class amf_n11 {
void handle_pdu_session_initial_request(
std::string supi, std::shared_ptr<pdu_session_context> psc,
std::string smf_addr, bstring sm_msg, std::string dnn);
void handle_itti_message(itti_pdu_session_resource_setup_response &itti_msg);
void handle_itti_message(itti_nsmf_pdusession_update_sm_context &itti_msg);
void send_pdu_session_update_sm_context_request(
std::string supi, std::shared_ptr<pdu_session_context> psc,
std::string smf_addr, bstring sm_msg, std::string dnn);
std::map<std::string, std::shared_ptr<pdu_session_context>> supi2pdu; // amf ue ngap id
mutable std::shared_mutex m_supi2pdu;
bool is_supi_to_pdu_ctx(const std::string &supi) const;
......
......@@ -21,7 +21,7 @@
/*! \file amf_n2.cpp
\brief
\author Keliang DU, BUPT
\author Keliang DU (BUPT), Tien-Thinh NGUYEN (EURECOM)
\date 2020
\email: contact@openairinterface.org
*/
......@@ -42,6 +42,7 @@
#include "DownLinkNasTransport.hpp"
#include "InitialContextSetupRequest.hpp"
#include "PduSessionResourceSetupRequest.hpp"
#include "PduSessionResourceReleaseCommand.hpp"
#include "UEContextReleaseCommand.hpp"
#include "amf_statistics.hpp"
#include "Ngap_Cause.h"
......@@ -113,6 +114,15 @@ void amf_n2_task(void *args_p) {
amf_n2_inst->handle_itti_message(ref(*m));
}
break;
case PDU_SESSION_RESOURCE_RELEASE_COMMAND: {
Logger::amf_n2().info(
"Encoding PDU SESSION RESOURCE RELEASE COMMAND message, sending ");
itti_pdu_session_resource_release_command *m =
dynamic_cast<itti_pdu_session_resource_release_command*>(msg);
amf_n2_inst->handle_itti_message(ref(*m));
}
break;
case INITIAL_CONTEXT_SETUP_REQUEST: {
Logger::amf_n2().info(
"Encoding INITIAL CONTEXT SETUP REQUEST message, sending ");
......@@ -536,7 +546,7 @@ void amf_n2::handle_itti_message(itti_initial_context_setup_request &itti_msg) {
guami.AmfSetID = amf_cfg.guami.AmfSetID;
guami.AmfPointer = amf_cfg.guami.AmfPointer;
msg->setGuami(guami);
msg->setUESecurityCapability(0xe000, 0xe000, 0xe000, 0xe000);
msg->setUESecurityCapability(0xe000, 0xe000, 0xe000, 0xe000); //TODO: remove hardcoded value
msg->setSecurityKey((uint8_t*) bdata(itti_msg.kgnb));
msg->setNasPdu((uint8_t*) bdata(itti_msg.nas), blength(itti_msg.nas));
......@@ -550,7 +560,7 @@ void amf_n2::handle_itti_message(itti_initial_context_setup_request &itti_msg) {
std::vector<PDUSessionResourceSetupRequestItem_t> list;
PDUSessionResourceSetupRequestItem_t item;
item.pduSessionId = itti_msg.pdu_session_id;
item.s_nssai.sst = "01";
item.s_nssai.sst = "01"; //TODO: remove hardcoded value
item.s_nssai.sd = "";
item.pduSessionNAS_PDU = NULL;
bstring n2sm = itti_msg.n2sm;
......@@ -634,7 +644,7 @@ void amf_n2::handle_itti_message(
list.push_back(item);
psrsr->setPduSessionResourceSetupRequestList(list);
size_t buffer_size = 512; //TODO: remove hardcoded value
size_t buffer_size = BUFFER_SIZE_512;
char *buffer = (char*) calloc(1, buffer_size);
int encoded_size = 0;
......@@ -653,6 +663,67 @@ void amf_n2::handle_itti_message(
free_wrapper((void**) &buffer);
}
//------------------------------------------------------------------------------
void amf_n2::handle_itti_message(itti_pdu_session_resource_release_command &itti_msg) {
std::shared_ptr<ue_ngap_context> unc;
unc = ran_ue_id_2_ue_ngap_context(itti_msg.ran_ue_ngap_id);
if (unc.get() == nullptr) {
Logger::amf_n2().error("Illegal UE with ran_ue_ngap_id (0x%x)",
itti_msg.ran_ue_ngap_id);
return;
}
std::shared_ptr<gnb_context> gc;
gc = assoc_id_2_gnb_context(unc.get()->gnb_assoc_id);
if (gc.get() == nullptr) {
Logger::amf_n2().error("Illegal gNB with assoc id (0x%x)",
unc.get()->gnb_assoc_id);
return;
}
PduSessionResourceReleaseCommandMsg *release_cmd_msg =
new PduSessionResourceReleaseCommandMsg();
release_cmd_msg->setMessageType();
release_cmd_msg->setAmfUeNgapId(itti_msg.amf_ue_ngap_id);
release_cmd_msg->setRanUeNgapId(itti_msg.ran_ue_ngap_id);
uint8_t *nas_pdu = (uint8_t*) calloc(1, blength(itti_msg.nas) + 1);
memcpy(nas_pdu, (uint8_t*) bdata(itti_msg.nas), blength(itti_msg.nas));
nas_pdu[blength(itti_msg.nas)] = '\0';
release_cmd_msg->setNasPdu(nas_pdu, blength(itti_msg.nas));
std::vector<PDUSessionResourceToReleaseItem_t> list;
PDUSessionResourceToReleaseItem_t item;
item.pduSessionId = itti_msg.pdu_session_id;
item.pduSessionResourceReleaseCommandTransfer.buf = (uint8_t*) bdata(
itti_msg.n2sm);
item.pduSessionResourceReleaseCommandTransfer.size = blength(itti_msg.n2sm);
list.push_back(item);
release_cmd_msg->setPduSessionResourceToReleaseList(list);
size_t buffer_size = BUFFER_SIZE_512;
char *buffer = (char*) calloc(1, buffer_size);
int encoded_size = 0;
release_cmd_msg->encode2buffer_new(buffer, encoded_size);
#if DEBUG_IS_ON
Logger::amf_n2().debug("N2 SM buffer data: ");
for (int i = 0; i < encoded_size; i++)
printf("%02x ", (char) buffer[i]);
#endif
Logger::amf_n2().debug(" (%d bytes) \n", encoded_size);
bstring b = blk2bstr(buffer, encoded_size);
sctp_s_38412.sctp_send_msg(gc.get()->sctp_assoc_id,
unc.get()->sctp_stream_send, &b);
//free memory
free_wrapper((void**) &nas_pdu);
free_wrapper((void**) &buffer);
}
//------------------------------------------------------------------------------
void amf_n2::handle_itti_message(itti_ue_context_release_request &itti_msg) {
Logger::amf_n2().debug("Handling UE context release request ...");
......@@ -664,8 +735,8 @@ void amf_n2::handle_itti_message(itti_ue_context_release_request &itti_msg) {
ueCtxRelCmd->setMessageType();
ueCtxRelCmd->setUeNgapIdPair(amf_ue_ngap_id, ran_ue_ngap_id);
ueCtxRelCmd->setCauseRadioNetwork(cause);
uint8_t buffer[200];
int encoded_size = ueCtxRelCmd->encode2buffer(buffer, 200);
uint8_t buffer[BUFFER_SIZE_512];
int encoded_size = ueCtxRelCmd->encode2buffer(buffer, BUFFER_SIZE_512);
bstring b = blk2bstr(buffer, encoded_size);
sctp_s_38412.sctp_send_msg(itti_msg.assoc_id, itti_msg.stream, &b);
}
......
......@@ -21,7 +21,7 @@
/*! \file amf_n2.hpp
\brief
\author Keliang DU, BUPT
\author Keliang DU (BUPT), Tien-Thinh NGUYEN (EURECOM)
\date 2020
\email: contact@openairinterface.org
*/
......@@ -47,6 +47,7 @@ class amf_n2 : public ngap::ngap_app {
void handle_itti_message(itti_dl_nas_transport &dl_nas_transport);
void handle_itti_message(itti_initial_context_setup_request &itti_msg);
void handle_itti_message(itti_pdu_session_resource_setup_request &itti_msg);
void handle_itti_message(itti_pdu_session_resource_release_command &itti_msg);
void handle_itti_message(itti_ue_context_release_request &itti_msg);
void handle_itti_message(itti_ue_radio_capability_indication &itti_msg);
bool verifyPlmn(std::vector<SupportedItem_t> list);
......
......@@ -21,7 +21,7 @@
/*! \file amf_statistics.cpp
\brief
\author Keliang DU, BUPT
\author Keliang DU (BUPT), Tien-Thinh NGUYEN (EURECOM)
\date 2020
\email: contact@openairinterface.org
*/
......@@ -65,16 +65,17 @@ void statistics::display() {
Logger::amf_app().info(
"|----------------------------------------------------UEs' information--------------------------------------------|");
Logger::amf_app().info(
"| Index | Connection state | Registration state | IMSI | GUTI | RAN UE NGAP ID | AMF UE ID |");
for (int i = 0; i < ues.size(); i++) {
Logger::amf_app().info(
"| %d | %s | %s | %s | %s | %d | %d | ",
i + 1, ues[i].connStatus.c_str(), ues[i].registerStatus.c_str(),
ues[i].imsi.c_str(), ues[i].guti.c_str(), ues[i].ranid, ues[i].amfid);
//Logger::amf_app().info("Current ran_ue_ngap_id[%d]; Current amf_ue_ngap_id[%d]", ues[i].ranid, ues[i].amfid);
Logger::amf_app().info("Location [NrCgi][PLMN(%s), cellID(%d)]",
(ues[i].mcc + ues[i].mnc).c_str(), ues[i].cellId);
Logger::amf_app().info("");
"| Index | 5GMM state | IMSI | GUTI | RAN UE NGAP ID | AMF UE ID | PLMN |Cell ID|");
int i = 0;
for (auto const &ue : ue_infos) {
Logger::amf_app().info("|%7d|%22s|%18s|%15s|%16d|%11d|%9s|%7d|", i + 1,
ue.second.registerStatus.c_str(),
ue.second.imsi.c_str(), ue.second.guti.c_str(),
ue.second.ranid, ue.second.amfid,
(ue.second.mcc + ue.second.mnc).c_str(),
ue.second.cellId);
i++;
}
Logger::amf_app().info(
"|----------------------------------------------------------------------------------------------------------------|");
......@@ -88,6 +89,40 @@ statistics::statistics() {
UE_registred = 0;
}
//------------------------------------------------------------------------------
void statistics::update_ue_info(const ue_info_t &ue_info) {
if (!(ue_info.imsi.size() > 0)) {
Logger::amf_app().warn("Update UE Info with invalid IMSI");
}
if (ue_infos.count(ue_info.imsi) > 0) {
ue_infos.erase(ue_info.imsi);
ue_infos.insert(std::pair<std::string, ue_info_t>(ue_info.imsi, ue_info));
Logger::amf_app().debug("Update UE Info (IMSI %s) success",
ue_info.imsi.c_str());
} else {
ue_infos.insert(std::pair<std::string, ue_info_t>(ue_info.imsi, ue_info));
Logger::amf_app().debug("Add UE Info (IMSI %s) success",
ue_info.imsi.c_str());
}
}
//------------------------------------------------------------------------------
void statistics::update_5gmm_state(const std::string &imsi,
const std::string &state) {
if (ue_infos.count(imsi) > 0) {
ue_info_t ue_info = ue_infos.at(imsi);
ue_info.registerStatus = state;
ue_infos.erase(ue_info.imsi);
ue_infos.insert(std::pair<std::string, ue_info_t>(imsi, ue_info));
Logger::amf_app().debug("Update UE State (IMSI %s, State %s) success",
imsi.c_str(), state.c_str());
} else {
Logger::amf_app().warn("Update UE State (IMSI %s), UE does not exist!",
imsi.c_str());
}
}
//------------------------------------------------------------------------------
statistics::~statistics() {
}
......@@ -46,7 +46,7 @@ typedef struct {
//long nrCellId;
} gnb_infos;
typedef struct {
typedef struct ue_info_s {
std::string connStatus;
std::string registerStatus;
uint32_t ranid;
......@@ -56,20 +56,22 @@ typedef struct {
std::string mcc;
std::string mnc;
uint32_t cellId;
} ue_infos;
} ue_info_t;
class statistics {
public:
void display();
statistics();
~statistics();
void update_ue_info(const ue_info_t &ue_info);
void update_5gmm_state(const std::string &imsi, const std::string &state);
public:
uint32_t gNB_connected;
uint32_t UE_connected;
uint32_t UE_registred;
//uint32_t system_pdu_sessions;
std::vector<gnb_infos> gnbs;
std::vector<ue_infos> ues;
std::map<std::string, ue_info_t> ue_infos;
};
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef FILE_3GPP_29_502_SMF_SEEN
#define FILE_3GPP_29_502_SMF_SEEN
enum pdu_session_application_error_e {
PDU_SESSION_APPLICATION_ERROR_N1_SM_ERROR = 1,
PDU_SESSION_APPLICATION_ERROR_SNSSAI_DENIED = 2,
PDU_SESSION_APPLICATION_ERROR_DNN_DENIED = 3,
PDU_SESSION_APPLICATION_ERROR_PDUTYPE_DENIED = 4,
PDU_SESSION_APPLICATION_ERROR_SSC_DENIED = 5,
PDU_SESSION_APPLICATION_ERROR_SUBSCRIPTION_DENIED = 6,
PDU_SESSION_APPLICATION_ERROR_DNN_NOT_SUPPORTED = 7,
PDU_SESSION_APPLICATION_ERROR_PDUTYPE_NOT_SUPPORTED = 8,
PDU_SESSION_APPLICATION_ERROR_SSC_NOT_SUPPORTED = 9,
PDU_SESSION_APPLICATION_ERROR_HOME_ROUTED_ROAMING_REQUIRED = 10,
PDU_SESSION_APPLICATION_ERROR_OUT_OF_LADN_SERVICE_AREA = 11,
PDU_SESSION_APPLICATION_ERROR_N2_SM_ERROR = 12,
PDU_SESSION_APPLICATION_ERROR_PRIORITIZED_SERVICES_ONLY = 13,
PDU_SESSION_APPLICATION_ERROR_PDU_SESSION_ANCHOR_CHANGE = 14,
PDU_SESSION_APPLICATION_ERROR_TARGET_MME_CAPABILITY = 15,
PDU_SESSION_APPLICATION_ERROR_NO_EPS_5GS_CONTINUITY = 16,
PDU_SESSION_APPLICATION_ERROR_UNABLE_TO_PAGE_UE = 17,
PDU_SESSION_APPLICATION_ERROR_UE_NOT_RESPONDING = 18,
PDU_SESSION_APPLICATION_ERROR_REJECTED_BY_UE = 19,
PDU_SESSION_APPLICATION_ERROR_REJECTED_DUE_VPLMN_POLICY = 20,
PDU_SESSION_APPLICATION_ERROR_HO_TAU_IN_PROGRESS = 21,
PDU_SESSION_APPLICATION_ERROR_INTEGRITY_PROTECTED_MDR_NOT_ACCEPTABLE = 22,
PDU_SESSION_APPLICATION_ERROR_EBI_EXHAUSTED = 23,
PDU_SESSION_APPLICATION_ERROR_EBI_REJECTED_LOCAL_POLICY = 24,
PDU_SESSION_APPLICATION_ERROR_EBI_REJECTED_NO_N26 = 25,
PDU_SESSION_APPLICATION_ERROR_DEFAULT_EPS_BEARER_INACTIVE = 26,
PDU_SESSION_APPLICATION_ERROR_HANDOVER_RESOURCE_ALLOCATION_FAILURE = 27,
PDU_SESSION_APPLICATION_ERROR_CONTEXT_NOT_FOUND = 28,
PDU_SESSION_APPLICATION_ERROR_INSUFFICIENT_RESOURCES_SLICE = 29,
PDU_SESSION_APPLICATION_ERROR_INSUFFICIENT_RESOURCES_SLICE_DNN = 30,
PDU_SESSION_APPLICATION_ERROR_DNN_CONGESTION = 31,
PDU_SESSION_APPLICATION_ERROR_S_NSSAI_CONGESTION = 32,
PDU_SESSION_APPLICATION_ERROR_PEER_NOT_RESPONDING = 33,
PDU_SESSION_APPLICATION_ERROR_NETWORK_FAILURE = 34
};
static const std::vector<std::string> pdu_session_application_error_e2str = {
"UNKNOWN ERROR", "N1_SM_ERROR", "SNSSAI_DENIED", "DNN_DENIED",
"PDUTYPE_DENIED", "SSC_DENIED", "SUBSCRIPTION_DENIED", "DNN_NOT_SUPPORTED",
"PDUTYPE_NOT_SUPPORTED", "SSC_NOT_SUPPORTED",
"HOME_ROUTED_ROAMING_REQUIRED", "OUT_OF_LADN_SERVICE_AREA", "N2_SM_ERROR",
"PRIORITIZED_SERVICES_ONLY", "PDU_SESSION_ANCHOR_CHANGE",
"TARGET_MME_CAPABILITY", "NO_EPS_5GS_CONTINUITY", "UNABLE_TO_PAGE_UE",
"UE_NOT_RESPONDING", "REJECTED_BY_UE", "REJECTED_DUE_VPLMN_POLICY",
"HO_TAU_IN_PROGRESS", "INTEGRITY_PROTECTED_MDR_NOT_ACCEPTABLE",
"EBI_EXHAUSTED", "EBI_REJECTED_LOCAL_POLICY", "EBI_REJECTED_NO_N26",
"DEFAULT_EPS_BEARER_INACTIVE", "HANDOVER_RESOURCE_ALLOCATION_FAILURE",
"CONTEXT_NOT_FOUND", "INSUFFICIENT_RESOURCES_SLICE",
"INSUFFICIENT_RESOURCES_SLICE_DNN", "DNN_CONGESTION", "S_NSSAI_CONGESTION",
"PEER_NOT_RESPONDING", "NETWORK_FAILURE" };
//6.1.6.3.12 Enumeration: N2SmInfoType @3GPP TS 29.502 V16.0.0
enum n2_sm_info_type_e {
PDU_RES_SETUP_REQ = 1, //PDU Session Resource Setup Request Transfer
PDU_RES_SETUP_RSP = 2, //PDU Session Resource Setup Response Transfer
PDU_RES_SETUP_FAIL = 3, //PDU Session Resource Setup Unsuccessful Transfer
PDU_RES_REL_CMD = 4, //PDU Session Resource Release Command Transfer
PDU_RES_REL_RSP = 5, //PDU Session Resource Release Response Transfer
PDU_RES_MOD_REQ = 6, //PDU Session Resource Modify Request Transfer
PDU_RES_MOD_RSP = 7, //PDU Session Resource Modify Response Transfer
PDU_RES_MOD_FAIL = 8, //PDU Session Resource Modify Unsuccessful Transfer
PDU_RES_NTY = 9, //PDU Session Resource Notify Transfer
PDU_RES_NTY_REL = 10, //PDU Session Resource Notify Released Transfer
PDU_RES_MOD_IND = 11, //PDU Session Resource Modify Indication Transfer
PDU_RES_MOD_CFM = 12, //PDU Session Resource Modify Confirm Transfer
PATH_SWITCH_REQ = 13, //Path Switch Request Transfer
PATH_SWITCH_SETUP_FAIL = 14, //Path Switch Request Setup Failed Transfer
PATH_SWITCH_REQ_ACK = 15, //Path Switch Request Acknowledge Transfer
PATH_SWITCH_REQ_FAIL = 16, //Path Switch Request Unsuccessful Transfer
HANDOVER_REQUIRED = 17, //Handover Required Transfer
HANDOVER_CMD = 18, //Handover Command Transfer
HANDOVER_PREP_FAIL = 19, //Handover Preparation Unsuccessful Transfer
HANDOVER_REQ_ACK = 20, //Handover Request Acknowledge Transfer
HANDOVER_RES_ALLOC_FAIL = 21, //Handover Resource Allocation Unsuccessful Transfer
SECONDARY_RAT_USAGE = 22 //Secondary RAT Data Usage Report Transfer
};
static const std::vector<std::string> n2_sm_info_type_e2str = { "UNKNOWN_TYPE",
"PDU_RES_SETUP_REQ", "PDU_RES_SETUP_RSP", "PDU_RES_SETUP_FAIL",
"PDU_RES_REL_CMD", "PDU_RES_REL_RSP", "PDU_RES_MOD_REQ", "PDU_RES_MOD_RSP",
"PDU_RES_MOD_FAIL", "PDU_RES_NTY", "PDU_RES_NTY_REL", "PDU_RES_MOD_IND",
"PDU_RES_MOD_CFM", "PATH_SWITCH_REQ", "PATH_SWITCH_SETUP_FAIL",
"PATH_SWITCH_REQ_ACK", "PATH_SWITCH_REQ_FAIL", "HANDOVER_REQUIRED",
"HANDOVER_CMD", "HANDOVER_PREP_FAIL", "HANDOVER_REQ_ACK",
"HANDOVER_RES_ALLOC_FAIL", "SECONDARY_RAT_USAGE" };
#endif
......@@ -66,6 +66,7 @@ typedef struct s_nssai // section 28.4, TS23.003
//SMF + AMF + 3GPP TS 29.571 (Common data)
enum class http_response_codes_e {
HTTP_RESPONSE_CODE_0 = 0,
HTTP_RESPONSE_CODE_200_OK = 200,
HTTP_RESPONSE_CODE_201_CREATED = 201,
HTTP_RESPONSE_CODE_202_ACCEPTED = 202,
......@@ -89,7 +90,6 @@ enum class http_response_codes_e {
HTTP_RESPONSE_CODE_NOT_IMPLEMENTED = 501,
HTTP_RESPONSE_CODE_SERVICE_UNAVAILABLE = 503,
HTTP_RESPONSE_CODE_GATEWAY_TIMEOUT = 504
};
//for CURL
......@@ -97,5 +97,9 @@ enum class http_response_codes_e {
#define SMF_NUMBER_RETRIES 3
constexpr auto CURL_MIME_BOUNDARY = "----Boundary";
#define BUFFER_SIZE_1024 1024
#define BUFFER_SIZE_512 512
#define BUFFER_SIZE_256 256
#endif
......@@ -37,6 +37,27 @@
#include "security_def.hpp"
#include "authentication_algorithms_with_5gaka.hpp"
typedef enum {
_5GMM_STATE_MIN = 0,
_5GMM_STATE_INVALID = _5GMM_STATE_MIN,
_5GMM_DEREGISTERED,
_5GMM_REGISTERED,
_5GMM_DEREGISTERED_INITIATED,
_5GMM_COMMON_PROCEDURE_INITIATED,
_5GMM_STATE_MAX
} _5gmm_state_t;
static const std::vector<std::string> _5gmm_state_e2str = {
"_5GMM_STATE_INVALID",
"_5GMM_DEREGISTERED",
"_5GMM_REGISTERED",
"_5GMM_DEREGISTERED_INITIATED",
"_5GMM_COMMON_PROCEDURE_INITIATED",
"_5GMM_STATE_MAX"
};
class nas_context {
public:
nas_context();
......@@ -46,6 +67,7 @@ class nas_context {
long amf_ue_ngap_id;
uint32_t ran_ue_ngap_id;
std::string nas_status;
_5gmm_state_t _5gmm_state;
/************ parameters from Registration request *************/
uint8_t registration_type :3;
......
......@@ -66,6 +66,7 @@ typedef enum {
ITTI_DL_NAS_TRANSPORT,
INITIAL_CONTEXT_SETUP_REQUEST,
PDU_SESSION_RESOURCE_SETUP_REQUEST,
PDU_SESSION_RESOURCE_RELEASE_COMMAND,
UE_CONTEXT_RELEASE_REQUEST,
UE_RADIO_CAP_IND,
UL_NAS_DATA_IND, //task amf_n1 message id
......@@ -74,7 +75,6 @@ typedef enum {
N1N2_MESSAGE_TRANSFER_REQ,
SMF_SERVICES_CONSUMER,
NSMF_PDU_SESSION_UPDATE_SM_CTX,
PDU_SESS_RES_SET_RESP,
TIME_OUT,
HEALTH_PING,
TERMINATE,
......
......@@ -66,6 +66,7 @@ class itti_n1n2_message_transfer_request : public itti_msg_amf_app {
bool is_n2sm_set;
bool is_n1sm_set;
uint8_t pdu_session_id;
std::string n2sm_info_type;
//other parameters
};
......
......@@ -59,6 +59,7 @@ class itti_downlink_nas_transfer : public itti_msg_n1 {
bstring n2sm;
bool is_n2sm_set;
uint8_t pdu_session_id;
std::string n2sm_info_type;
};
#endif
......@@ -46,38 +46,30 @@ class itti_smf_services_consumer : public itti_msg_n11 {
plmn_t plmn;
};
class itti_pdu_session_resource_setup_response : public itti_msg_n11 {
public:
itti_pdu_session_resource_setup_response(const task_id_t origin,
const task_id_t destination)
:
itti_msg_n11(PDU_SESS_RES_SET_RESP, origin, destination) {
}
itti_pdu_session_resource_setup_response(
const itti_pdu_session_resource_setup_response &i)
:
itti_msg_n11(i) {
}
public:
uint8_t pdu_session_id;
bstring n2sm;
};
class itti_nsmf_pdusession_update_sm_context : public itti_msg_n11 {
public:
itti_nsmf_pdusession_update_sm_context(const task_id_t origin,
const task_id_t destination)
:
itti_msg_n11(NSMF_PDU_SESSION_UPDATE_SM_CTX, origin, destination) {
is_n2sm_set = false;
}
itti_nsmf_pdusession_update_sm_context(
const itti_nsmf_pdusession_update_sm_context &i)
:
itti_msg_n11(i) {
pdu_session_id = i.pdu_session_id;
n2sm = i.n2sm;
is_n2sm_set = i.is_n2sm_set;
n2sm_info_type = i.n2sm_info_type;
}
public:
uint8_t pdu_session_id;
bstring n2sm;
bool is_n2sm_set;
std::string n2sm_info_type;
};
#endif
......@@ -135,6 +135,26 @@ class itti_pdu_session_resource_setup_request : public itti_msg_n2 {
uint8_t pdu_session_id;
};
class itti_pdu_session_resource_release_command : public itti_msg_n2 {
public:
itti_pdu_session_resource_release_command(const task_id_t origin,
const task_id_t destination)
:
itti_msg_n2(PDU_SESSION_RESOURCE_RELEASE_COMMAND, origin, destination) {
}
itti_pdu_session_resource_release_command(
const itti_pdu_session_resource_release_command &i)
:
itti_msg_n2(i) {
}
bstring nas;
bstring n2sm;
uint32_t ran_ue_ngap_id;
long amf_ue_ngap_id;
uint8_t pdu_session_id;
};
class itti_ue_context_release_request : public itti_msg_n2 {
public:
itti_ue_context_release_request(const task_id_t origin,
......
......@@ -45,24 +45,37 @@
/********** message type ********************/
#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_RESULT 0b01011010
#define AUTHENTICATION_FAILURE 0b01011001
#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 REGISTRATION_COMPLETE 0b01000011
#define REGISTRATION_ACCEPT 0b01000010
#define IDENTITY_REQUEST 0b01011011
#define IDENTITY_RESPONSE 0b01011100
#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 SERVICE_REQUEST 0b01001100
#define SERVICE_REJECT 0b01001101
#define SERVICE_ACCEPT 0b01001110
#define UE_INIT_DEREGISTER 0b01000101
/********* registration type ***************/
......@@ -137,11 +150,30 @@
#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 0b11000000
#define PDU_SESSION_ESTABLISHMENT_REQUEST 0b11000001
#define PDU_SESSION_ESTABLISHMENT_ACCEPT 0b11000010
#define PDU_SESSION_ESTABLISHMENT_REJECT 0b11000011
#define PDU_SESSION_AUTHENTICATION_COMMAND 0b11000101
#define PDU_SESSION_AUTHENTICATION_COMPLETE 0b11000110
#define PDU_SESSION_AUTHENTICATION_RESULT 0b11000111
#define PDU_SESSION_MODIFICATION_REQUEST 0b11001001
#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_RELEASE_REQUEST 0b11010001
#define PDU_SESSION_RELEASE_REJECT 0b11010010
#define PDU_SESSION_RELEASE_COMMAND 0b11010011
#define PDU_SESSION_RELEASE_COMPLETE 0b11010100
#endif
......@@ -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"
......
......@@ -194,7 +194,13 @@ void _5GSMobilityIdentity::getSuciWithSupiImsi(SUCI_imsi_t &ptr) {
//------------------------------------------------------------------------------
void _5GSMobilityIdentity::get5GGUTI(_5G_GUTI_t &ptr) {
ptr = *_5g_guti;
//ptr = *_5g_guti;
ptr.mcc = _5g_guti->mcc;
ptr.mnc = _5g_guti->mnc;
ptr.amf_region_id = _5g_guti->amf_region_id;
ptr.amf_set_id = _5g_guti->amf_set_id;
ptr.amf_pointer = _5g_guti->amf_pointer;
ptr._5g_tmsi = _5g_guti->_5g_tmsi;
}
//------------------------------------------------------------------------------
......
......@@ -47,6 +47,7 @@ typedef struct _5G_GUTI_s {
uint8_t amf_set_id;
uint16_t amf_pointer;
uint32_t _5g_tmsi;
} _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
......@@ -41,9 +41,9 @@ namespace nas {
typedef struct SNSSAI_s {
uint8_t sst;
int32_t sd; //若sd不存在,则sd设置为-1
int32_t mHplmnSst; //若sd不存在,则sd设置为-1
int32_t mHplmnSd; //若sd不存在,则sd设置为-1
int32_t sd;
int32_t mHplmnSst;
int32_t mHplmnSd;
} SNSSAI_t;
typedef struct {
uint8_t ie_type;
......
/*
* 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"
#include <string>
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);
}
//------------------------------------------------------------------------------
void DeregistrationRequest::getngKSI(uint8_t &ng_ksi) {
if (ie_ngKSI) {
ng_ksi = (ie_ngKSI->getTypeOfSecurityContext())
| ie_ngKSI->getasKeyIdentifier();
} else {
ng_ksi = 0;
}
}
//------------------------------------------------------------------------------
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);
}
}
//------------------------------------------------------------------------------
void DeregistrationRequest::getMobilityIdentityType(uint8_t &type) {
if (ie_5gs_mobility_id) {
type = ie_5gs_mobility_id->gettypeOfIdentity();
} else {
type = 0;
}
}
//------------------------------------------------------------------------------
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);
std::string str; //= guti.toString();
return str;
} 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);
void getngKSI(uint8_t &ng_ksi);
void getMobilityIdentityType(uint8_t &type);
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
......@@ -91,7 +91,7 @@ typedef struct Guami_s {
typedef struct {
std::string sst;
std::string sd; //可选
std::string sd;
} S_Nssai;
typedef struct {
......@@ -102,6 +102,19 @@ typedef struct {
OCTET_STRING_t pduSessionResourceSetupRequestTransfer;
} PDUSessionResourceSetupRequestItem_t;
//section 9.2.1.3 PDU Session Resource Release Command (3GPP TS 38.413 V16.0.0 (2019-12))
typedef struct {
uint8_t pduSessionId;
OCTET_STRING_t pduSessionResourceReleaseCommandTransfer;
} PDUSessionResourceToReleaseItem_t;
//PDU Session Resource Release Item (3GPP TS 38.413 V16.0.0 (2019-12))
typedef struct {
uint8_t pduSessionId;
OCTET_STRING_t pduSessionResourceReleaseResponseTransfer;
} PDUSessionResourceReleasedItem_t;
typedef struct {
std::string ip_address;
uint32_t gtp_teid;
......
/*
* 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 Keliang DU (BUPT), Tien-Thinh NGUYEN (EURECOM)
\date 2020
\email: contact@openairinterface.org
*/
#include "PDUSessionResourceReleasedItemRelRes.hpp"
namespace ngap {
//------------------------------------------------------------------------------
PDUSessionResourceReleasedItemRelRes::PDUSessionResourceReleasedItemRelRes() {
pDUSessionID = NULL;
}
//------------------------------------------------------------------------------
PDUSessionResourceReleasedItemRelRes::~PDUSessionResourceReleasedItemRelRes() {
}
//------------------------------------------------------------------------------
void PDUSessionResourceReleasedItemRelRes::setPDUSessionResourceReleasedItemRelRes(
PDUSessionID *m_pDUSessionID,
OCTET_STRING_t m_pDUSessionResourceReleaseResponseTransfer) {
pDUSessionID = m_pDUSessionID;
pDUSessionResourceReleaseResponseTransfer =
m_pDUSessionResourceReleaseResponseTransfer;
}
//------------------------------------------------------------------------------
void PDUSessionResourceReleasedItemRelRes::getPDUSessionResourceReleasedItemRelRes(
PDUSessionID *&m_pDUSessionID,
OCTET_STRING_t &m_pDUSessionResourceReleaseResponseTransfer) {
m_pDUSessionID = pDUSessionID;
m_pDUSessionResourceReleaseResponseTransfer = pDUSessionResourceReleaseResponseTransfer;
}
//------------------------------------------------------------------------------
bool PDUSessionResourceReleasedItemRelRes::encode2PDUSessionResourceReleasedItemRelRes(
Ngap_PDUSessionResourceReleasedItemRelRes_t *pduSessionResourceReleasedItemRelRes) {
if (!pDUSessionID->encode2PDUSessionID(
pduSessionResourceReleasedItemRelRes->pDUSessionID))
return false;
pduSessionResourceReleasedItemRelRes
->pDUSessionResourceReleaseResponseTransfer =
pDUSessionResourceReleaseResponseTransfer;
return true;
}
//------------------------------------------------------------------------------
bool PDUSessionResourceReleasedItemRelRes::decodefromPDUSessionResourceReleasedItemRelRes(
Ngap_PDUSessionResourceReleasedItemRelRes_t *pduSessionResourceReleasedItemRelRes) {
pDUSessionID = new PDUSessionID();
pDUSessionResourceReleaseResponseTransfer =
pduSessionResourceReleasedItemRelRes
->pDUSessionResourceReleaseResponseTransfer;
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
*/
/*! \file
\brief
\author Keliang DU (BUPT), Tien-Thinh NGUYEN (EURECOM)
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _PDU_SESSION_RESOURCE_RELEASED_ITEM_REL_RES_H_
#define _PDU_SESSION_RESOURCE_RELEASED_ITEM_REL_RES_H_
#include "PDUSessionID.hpp"
extern "C" {
#include "Ngap_PDUSessionResourceReleasedItemRelRes.h"
}
namespace ngap {
class PDUSessionResourceReleasedItemRelRes {
public:
PDUSessionResourceReleasedItemRelRes();
virtual ~PDUSessionResourceReleasedItemRelRes();
void setPDUSessionResourceReleasedItemRelRes(
PDUSessionID *m_pDUSessionID,
OCTET_STRING_t m_pDUSessionResourceReleaseResponseTransfer);
void getPDUSessionResourceReleasedItemRelRes(
PDUSessionID *&m_pDUSessionID,
OCTET_STRING_t &m_pDUSessionResourceReleaseResponseTransfer);
bool encode2PDUSessionResourceReleasedItemRelRes(
Ngap_PDUSessionResourceReleasedItemRelRes_t *pduSessionResourceReleasedItemRelRes);
bool decodefromPDUSessionResourceReleasedItemRelRes(
Ngap_PDUSessionResourceReleasedItemRelRes_t *pduSessionResourceReleasedItemRelRes);
private:
PDUSessionID *pDUSessionID;
OCTET_STRING_t pDUSessionResourceReleaseResponseTransfer;
// ProtocolExtensionContainer (OPTIONAL)
};
}
#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 Keliang DU (BUPT), Tien-Thinh NGUYEN (EURECOM)
\date 2020
\email: contact@openairinterface.org
*/
#include "PDUSessionResourceReleasedListRelRes.hpp"
namespace ngap {
//------------------------------------------------------------------------------
PDUSessionResourceReleasedListRelRes::PDUSessionResourceReleasedListRelRes() {
pduSessionResourceReleasedItemRelRes = NULL;
maxnoofPDUSessions = 0;
}
//------------------------------------------------------------------------------
PDUSessionResourceReleasedListRelRes::~PDUSessionResourceReleasedListRelRes() {
}
//------------------------------------------------------------------------------
void PDUSessionResourceReleasedListRelRes::setPDUSessionResourceReleasedListRelRes(
PDUSessionResourceReleasedItemRelRes *m_pduSessionResourceReleasedItemRelRes,
int num) {
pduSessionResourceReleasedItemRelRes =
m_pduSessionResourceReleasedItemRelRes;
maxnoofPDUSessions = num;
}
//------------------------------------------------------------------------------
void PDUSessionResourceReleasedListRelRes::getPDUSessionResourceReleasedListRelRes(
PDUSessionResourceReleasedItemRelRes *&m_pduSessionResourceReleasedItemRelRes,
int &num) {
m_pduSessionResourceReleasedItemRelRes =
pduSessionResourceReleasedItemRelRes;
num = maxnoofPDUSessions;
}
//------------------------------------------------------------------------------
bool PDUSessionResourceReleasedListRelRes::encode2PDUSessionResourceReleasedListRelRes(
Ngap_PDUSessionResourceReleasedListRelRes_t *pduSessionResourceReleasedListRelRes) {
for (int i = 0; i < maxnoofPDUSessions; i++) {
Ngap_PDUSessionResourceReleasedItemRelRes_t *rel =
(Ngap_PDUSessionResourceReleasedItemRelRes_t*) calloc(
1, sizeof(Ngap_PDUSessionResourceReleasedItemRelRes_t));
if (!rel)
return false;
if (!pduSessionResourceReleasedItemRelRes[i]
.encode2PDUSessionResourceReleasedItemRelRes(rel))
return false;
if (ASN_SEQUENCE_ADD(&pduSessionResourceReleasedListRelRes->list, rel)
!= 0)
return false;
}
return true;
}
//------------------------------------------------------------------------------
bool PDUSessionResourceReleasedListRelRes::decodefromPDUSessionResourceReleasedListRelRes(
Ngap_PDUSessionResourceReleasedListRelRes_t *pduSessionResourceReleasedListRelRes) {
maxnoofPDUSessions = pduSessionResourceReleasedListRelRes->list.count;
pduSessionResourceReleasedItemRelRes =
new PDUSessionResourceReleasedItemRelRes[maxnoofPDUSessions]();
for (int i = 0; i < maxnoofPDUSessions; i++) {
if (!pduSessionResourceReleasedItemRelRes[i]
.decodefromPDUSessionResourceReleasedItemRelRes(
pduSessionResourceReleasedListRelRes->list.array[i]))
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
*/
/*! \file
\brief
\author Keliang DU (BUPT), Tien-Thinh NGUYEN (EURECOM)
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _PDU_SESSION_RESOURCE_RELEASED_LIST_REL_RES_H_
#define _PDU_SESSION_RESOURCE_RELEASED_LIST_REL_RES_H_
#include "PDUSessionResourceReleasedItemRelRes.hpp"
extern "C" {
#include "Ngap_PDUSessionResourceReleasedItemRelRes.h"
#include "Ngap_PDUSessionResourceReleasedListRelRes.h"
}
namespace ngap {
class PDUSessionResourceReleasedListRelRes {
public:
PDUSessionResourceReleasedListRelRes();
virtual ~PDUSessionResourceReleasedListRelRes();
void setPDUSessionResourceReleasedListRelRes(
PDUSessionResourceReleasedItemRelRes *m_pduSessionResourceReleasedItemRelRes,
int num);
void getPDUSessionResourceReleasedListRelRes(
PDUSessionResourceReleasedItemRelRes *&m_pduSessionResourceReleasedItemRelRes,
int &num);
bool encode2PDUSessionResourceReleasedListRelRes(
Ngap_PDUSessionResourceReleasedListRelRes_t *pduSessionResourceReleasedListRelRes);
bool decodefromPDUSessionResourceReleasedListRelRes(
Ngap_PDUSessionResourceReleasedListRelRes_t *pduSessionResourceReleasedListRelRes);
private:
PDUSessionResourceReleasedItemRelRes *pduSessionResourceReleasedItemRelRes;
int maxnoofPDUSessions;
};
}
#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 Keliang DU (BUPT), Tien-Thinh NGUYEN (EURECOM)
\date 2020
\email: contact@openairinterface.org
*/
#include "PDUSessionResourceToReleaseItemRelCmd.hpp"
namespace ngap {
//------------------------------------------------------------------------------
PDUSessionResourceToReleaseItemRelCmd::PDUSessionResourceToReleaseItemRelCmd() {
pDUSessionID = NULL;
}
//------------------------------------------------------------------------------
PDUSessionResourceToReleaseItemRelCmd::~PDUSessionResourceToReleaseItemRelCmd() {
}
//------------------------------------------------------------------------------
void PDUSessionResourceToReleaseItemRelCmd::setPDUSessionResourceToReleaseItemRelCmd(
PDUSessionID *m_pDUSessionID,
OCTET_STRING_t m_pDUSessionResourceReleaseCommandTransfer) {
pDUSessionID = m_pDUSessionID;
pDUSessionResourceReleaseCommandTransfer =
m_pDUSessionResourceReleaseCommandTransfer;
}
//------------------------------------------------------------------------------
void PDUSessionResourceToReleaseItemRelCmd::getPDUSessionResourceToReleaseItemRelCmd(
PDUSessionID *&m_pDUSessionID,
OCTET_STRING_t &m_pDUSessionResourceReleaseCommandTransfer) {
m_pDUSessionID = pDUSessionID;
m_pDUSessionResourceReleaseCommandTransfer = pDUSessionResourceReleaseCommandTransfer;
}
//------------------------------------------------------------------------------
bool PDUSessionResourceToReleaseItemRelCmd::encode2PDUSessionResourceToReleaseItemRelCmd(
Ngap_PDUSessionResourceToReleaseItemRelCmd_t *pduSessionResourceToReleaseItemRelCmd) {
if (!pDUSessionID->encode2PDUSessionID(
pduSessionResourceToReleaseItemRelCmd->pDUSessionID))
return false;
pduSessionResourceToReleaseItemRelCmd
->pDUSessionResourceReleaseCommandTransfer =
pDUSessionResourceReleaseCommandTransfer;
return true;
}
//------------------------------------------------------------------------------
bool PDUSessionResourceToReleaseItemRelCmd::decodefromPDUSessionResourceToReleaseItemRelCmd(
Ngap_PDUSessionResourceToReleaseItemRelCmd_t *pduSessionResourceToReleaseItemRelCmd) {
pDUSessionID = new PDUSessionID();
pDUSessionResourceReleaseCommandTransfer =
pduSessionResourceToReleaseItemRelCmd
->pDUSessionResourceReleaseCommandTransfer;
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
*/
/*! \file
\brief
\author Keliang DU (BUPT), Tien-Thinh NGUYEN (EURECOM)
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _PDU_SESSION_RESOURCE_TO_RELEASE_ITEM_REL_CMD_H_
#define _PDU_SESSION_RESOURCE_TO_RELEASE_ITEM_REL_CMD_H_
#include "PDUSessionID.hpp"
extern "C" {
#include "Ngap_PDUSessionResourceToReleaseItemRelCmd.h"
}
namespace ngap {
class PDUSessionResourceToReleaseItemRelCmd {
public:
PDUSessionResourceToReleaseItemRelCmd();
virtual ~PDUSessionResourceToReleaseItemRelCmd();
void setPDUSessionResourceToReleaseItemRelCmd(
PDUSessionID *m_pDUSessionID,
OCTET_STRING_t m_pDUSessionResourceReleaseCommandTransfer);
void getPDUSessionResourceToReleaseItemRelCmd(
PDUSessionID *&m_pDUSessionID,
OCTET_STRING_t &m_pDUSessionResourceReleaseCommandTransfer);
bool encode2PDUSessionResourceToReleaseItemRelCmd(
Ngap_PDUSessionResourceToReleaseItemRelCmd_t *pduSessionResourceToReleaseItemRelCmd);
bool decodefromPDUSessionResourceToReleaseItemRelCmd(
Ngap_PDUSessionResourceToReleaseItemRelCmd_t *pduSessionResourceToReleaseItemRelCmd);
private:
PDUSessionID *pDUSessionID;
OCTET_STRING_t pDUSessionResourceReleaseCommandTransfer;
// ProtocolExtensionContainer (OPTIONAL)
};
}
#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 Keliang DU (BUPT), Tien-Thinh NGUYEN (EURECOM)
\date 2020
\email: contact@openairinterface.org
*/
#include "PDUSessionResourceToReleaseListRelCmd.hpp"
namespace ngap {
//------------------------------------------------------------------------------
PDUSessionResourceToReleaseListRelCmd::PDUSessionResourceToReleaseListRelCmd() {
pduSessionResourceToReleaseItemRelCmd = NULL;
maxnoofPDUSessions = 0;
}
//------------------------------------------------------------------------------
PDUSessionResourceToReleaseListRelCmd::~PDUSessionResourceToReleaseListRelCmd() {
}
//------------------------------------------------------------------------------
void PDUSessionResourceToReleaseListRelCmd::setPDUSessionResourceToReleaseListRelCmd(
PDUSessionResourceToReleaseItemRelCmd *m_pduSessionResourceToReleaseItemRelCmd,
int num) {
pduSessionResourceToReleaseItemRelCmd =
m_pduSessionResourceToReleaseItemRelCmd;
maxnoofPDUSessions = num;
}
//------------------------------------------------------------------------------
void PDUSessionResourceToReleaseListRelCmd::getPDUSessionResourceToReleaseListRelCmd(
PDUSessionResourceToReleaseItemRelCmd *&m_pduSessionResourceToReleaseItemRelCmd,
int &num) {
m_pduSessionResourceToReleaseItemRelCmd =
pduSessionResourceToReleaseItemRelCmd;
num = maxnoofPDUSessions;
}
//------------------------------------------------------------------------------
bool PDUSessionResourceToReleaseListRelCmd::encode2PDUSessionResourceToReleaseListRelCmd(
Ngap_PDUSessionResourceToReleaseListRelCmd_t *pduSessionResourceToReleaseListRelCmd) {
for (int i = 0; i < maxnoofPDUSessions; i++) {
Ngap_PDUSessionResourceToReleaseItemRelCmd_t *rel =
(Ngap_PDUSessionResourceToReleaseItemRelCmd_t*) calloc(
1, sizeof(Ngap_PDUSessionResourceToReleaseItemRelCmd_t));
if (!rel)
return false;
if (!pduSessionResourceToReleaseItemRelCmd[i]
.encode2PDUSessionResourceToReleaseItemRelCmd(rel))
return false;
if (ASN_SEQUENCE_ADD(&pduSessionResourceToReleaseListRelCmd->list, rel)
!= 0)
return false;
}
return true;
}
//------------------------------------------------------------------------------
bool PDUSessionResourceToReleaseListRelCmd::decodefromPDUSessionResourceToReleaseListRelCmd(
Ngap_PDUSessionResourceToReleaseListRelCmd_t *pduSessionResourceToReleaseListRelCmd) {
maxnoofPDUSessions = pduSessionResourceToReleaseListRelCmd->list.count;
pduSessionResourceToReleaseItemRelCmd =
new PDUSessionResourceToReleaseItemRelCmd[maxnoofPDUSessions]();
for (int i = 0; i < maxnoofPDUSessions; i++) {
if (!pduSessionResourceToReleaseItemRelCmd[i]
.decodefromPDUSessionResourceToReleaseItemRelCmd(
pduSessionResourceToReleaseListRelCmd->list.array[i]))
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
*/
/*! \file
\brief
\author Keliang DU (BUPT), Tien-Thinh NGUYEN (EURECOM)
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _PDU_SESSION_RESOURCE_TO_RELEASE_LIST_REL_CMD_H_
#define _PDU_SESSION_RESOURCE_TO_RELEASE_LIST_REL_CMD_H_
#include "PDUSessionResourceToReleaseItemRelCmd.hpp"
extern "C" {
#include "Ngap_PDUSessionResourceToReleaseItemRelCmd.h"
#include "Ngap_PDUSessionResourceToReleaseListRelCmd.h"
}
namespace ngap {
class PDUSessionResourceToReleaseListRelCmd {
public:
PDUSessionResourceToReleaseListRelCmd();
virtual ~PDUSessionResourceToReleaseListRelCmd();
void setPDUSessionResourceToReleaseListRelCmd(
PDUSessionResourceToReleaseItemRelCmd *m_pduSessionResourceToReleaseItemRelCmd,
int num);
void getPDUSessionResourceToReleaseListRelCmd(
PDUSessionResourceToReleaseItemRelCmd *&m_pduSessionResourceToReleaseItemRelCmd,
int &num);
bool encode2PDUSessionResourceToReleaseListRelCmd(
Ngap_PDUSessionResourceToReleaseListRelCmd_t *pduSessionResourceToReleaseListRelCmd);
bool decodefromPDUSessionResourceToReleaseListRelCmd(
Ngap_PDUSessionResourceToReleaseListRelCmd_t *pduSessionResourceToReleaseListRelCmd);
private:
PDUSessionResourceToReleaseItemRelCmd *pduSessionResourceToReleaseItemRelCmd;
int maxnoofPDUSessions;
};
}
#endif
This diff is collapsed.
/*
* 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 Keliang DU (BUPT), Tien-Thinh NGUYEN (EURECOM)
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _PDU_SESSION_RESOURCE_RELEASE_COMMAND_H_
#define _PDU_SESSION_RESOURCE_RELEASE_COMMAND_H_
#include "NgapIEsStruct.hpp"
#include "MessageType.hpp"
#include "AMF-UE-NGAP-ID.hpp"
#include "RAN-UE-NGAP-ID.hpp"
#include "RANPagingPriority.hpp"
#include "NAS-PDU.hpp"
#include "PDUSessionResourceToReleaseListRelCmd.hpp"
extern "C" {
#include "Ngap_NGAP-PDU.h"
#include "Ngap_ProtocolIE-Field.h"
}
namespace ngap {
class PduSessionResourceReleaseCommandMsg {
public:
PduSessionResourceReleaseCommandMsg();
virtual ~PduSessionResourceReleaseCommandMsg();
void setMessageType();
void setAmfUeNgapId(unsigned long id); //40 bits
void setRanUeNgapId(uint32_t id); // 32 bits
void setRanPagingPriority(uint8_t priority);
void setNasPdu(uint8_t *nas, size_t sizeofnas);
void setPduSessionResourceToReleaseList(
std::vector<PDUSessionResourceToReleaseItem_t> list);
unsigned long getAmfUeNgapId();
uint32_t getRanUeNgapId();
int getRanPagingPriority();
bool getNasPdu(uint8_t *&nas, size_t &sizeofnas);
bool getPduSessionResourceToReleaseList(
std::vector<PDUSessionResourceToReleaseItem_t> &list);
int encode2buffer(uint8_t *buf, int buf_size);
void encode2buffer_new(char *buf, int &encoded_size);
bool decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu);
private:
Ngap_NGAP_PDU_t *pduSessionResourceReleaseCommandPdu;
Ngap_PDUSessionResourceReleaseCommand_t *pduSessionResourceReleaseCommandIEs; //store list of IEs
//section 9.2.1.3 PDU Session Resource Release Command (3GPP TS 38.413 V16.0.0 (2019-12))
AMF_UE_NGAP_ID *amfUeNgapId;
RAN_UE_NGAP_ID *ranUeNgapId;
RANPagingPriority *ranPagingPriority;
NAS_PDU *nasPdu;
PDUSessionResourceToReleaseListRelCmd *pduSessionResourceToReleaseList;
};
}
#endif
This diff is collapsed.
/*
* 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 Keliang DU (BUPT), Tien-Thinh NGUYEN (EURECOM)
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _PDU_SESSION_RESOURCE_RELEASE_RESPONSE_H_
#define _PDU_SESSION_RESOURCE_RELEASE_RESPONSE_H_
#include "NgapIEsStruct.hpp"
#include "MessageType.hpp"
#include "AMF-UE-NGAP-ID.hpp"
#include "RAN-UE-NGAP-ID.hpp"
#include "UserLocationInformation.hpp"
#include "CriticalityDiagnostics.hpp"
#include "PDUSessionResourceReleasedListRelRes.hpp"
extern "C" {
#include "Ngap_NGAP-PDU.h"
#include "Ngap_ProtocolIE-Field.h"
}
namespace ngap {
class PduSessionResourceReleaseResponseMsg {
public:
PduSessionResourceReleaseResponseMsg();
virtual ~PduSessionResourceReleaseResponseMsg();
void setMessageType();
void setAmfUeNgapId(unsigned long id); //40 bits
void setRanUeNgapId(uint32_t id); // 32 bits
void setPduSessionResourceReleasedList(
std::vector<PDUSessionResourceReleasedItem_t> list);
void setUserLocationInfoNR(struct NrCgi_s cig, struct Tai_s tai);
unsigned long getAmfUeNgapId();
uint32_t getRanUeNgapId();
bool getPduSessionResourceReleasedList(
std::vector<PDUSessionResourceReleasedItem_t> &list);
bool getUserLocationInfoNR(struct NrCgi_s &cig, struct Tai_s &tai);
int encode2buffer(uint8_t *buf, int buf_size);
void encode2buffer_new(char *buf, int &encoded_size);
bool decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu);
private:
Ngap_NGAP_PDU_t *pduSessionResourceReleaseResponsePdu;
Ngap_PDUSessionResourceReleaseResponse_t *pduSessionResourceReleaseResponseIEs; //store list of IEs
//section 9.2.1.4 PDU Session Resource Release Response (3GPP TS 38.413 V16.0.0 (2019-12))
AMF_UE_NGAP_ID *amfUeNgapId;
RAN_UE_NGAP_ID *ranUeNgapId;
PDUSessionResourceReleasedListRelRes *pduSessionResourceReleasedList;
UserLocationInformation *userLocationInformation;
//CriticalityDiagnostics *criticalityDiagnostics;
};
}
#endif
......@@ -36,6 +36,7 @@
#include "itti.hpp"
#include "NGSetupRequest.hpp"
#include "PduSessionResourceSetupResponse.hpp"
#include "PduSessionResourceReleaseResponse.hpp"
#include "InitialContextSetupResponse.hpp"
using namespace sctp;
......@@ -141,6 +142,7 @@ int ngap_amf_handle_initial_context_setup_response(
"Decode PduSessionResourceSetupResponseList IE error or this IE is not available");
return 0;
}
uint8_t transferIe[500];
memcpy(transferIe, list[0].pduSessionResourceSetupResponseTransfer.buf,
list[0].pduSessionResourceSetupResponseTransfer.size);
......@@ -153,6 +155,8 @@ int ngap_amf_handle_initial_context_setup_response(
new itti_nsmf_pdusession_update_sm_context(TASK_NGAP, TASK_AMF_N11);
itti_msg->pdu_session_id = list[0].pduSessionId;
itti_msg->n2sm = n2sm;
itti_msg->is_n2sm_set = true;
itti_msg->n2sm_info_type = "PDU_RES_SETUP_RSP";
std::shared_ptr<itti_nsmf_pdusession_update_sm_context> i = std::shared_ptr
< itti_nsmf_pdusession_update_sm_context > (itti_msg);
int ret = itti_inst->send_msg(i);
......@@ -232,6 +236,54 @@ int ngap_amf_handle_ue_context_release_complete(
return 0;
}
int ngap_amf_handle_pdu_session_resource_release_response(
const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream,
struct Ngap_NGAP_PDU *message_p){
Logger::ngap().debug("Handle PDU Session Resource Setup Release Response");
PduSessionResourceReleaseResponseMsg *pduresp =
new PduSessionResourceReleaseResponseMsg();
if (!pduresp->decodefrompdu(message_p)) {
Logger::ngap().error(
"Decoding PduSessionResourceReleaseResponseMsg message error");
return -1;
}
//TODO: process User Location Information if this IE is available
//Transfer pduSessionResourceReleaseResponseTransfer to SMF
std::vector<PDUSessionResourceReleasedItem_t> list;
if (!pduresp->getPduSessionResourceReleasedList(list)) {
Logger::ngap().error(
"Decoding PduSessionResourceReleaseResponseMsg getPduSessionResourceReleasedList IE error");
return -1;
}
//TODO: add the full list
uint8_t transferIe[500];
memcpy(transferIe, list[0].pduSessionResourceReleaseResponseTransfer.buf,
list[0].pduSessionResourceReleaseResponseTransfer.size);
bstring n2sm = blk2bstr(transferIe,
list[0].pduSessionResourceReleaseResponseTransfer.size);
Logger::ngap().debug(
"Sending itti PDUSessionResourceReleaseResponse to TASK_AMF_N11");
itti_nsmf_pdusession_update_sm_context *itti_msg =
new itti_nsmf_pdusession_update_sm_context(TASK_NGAP, TASK_AMF_N11);
itti_msg->pdu_session_id = list[0].pduSessionId;
itti_msg->n2sm = n2sm;
itti_msg->is_n2sm_set = true;
itti_msg->n2sm_info_type = "PDU_RES_REL_RSP";
std::shared_ptr<itti_nsmf_pdusession_update_sm_context> i = std::shared_ptr
< itti_nsmf_pdusession_update_sm_context > (itti_msg);
int ret = itti_inst->send_msg(i);
if (0 != ret) {
Logger::ngap().error("Could not send ITTI message %s to task TASK_AMF_N11",
i->get_msg_name());
}
return 0;
}
//------------------------------------------------------------------------------
int ngap_amf_handle_pdu_session_resource_setup_response(
const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream,
......@@ -262,6 +314,9 @@ int ngap_amf_handle_pdu_session_resource_setup_response(
new itti_nsmf_pdusession_update_sm_context(TASK_NGAP, TASK_AMF_N11);
itti_msg->pdu_session_id = list[0].pduSessionId;
itti_msg->n2sm = n2sm;
itti_msg->is_n2sm_set = true;
itti_msg->n2sm_info_type = "PDU_RES_SETUP_RSP";
std::shared_ptr<itti_nsmf_pdusession_update_sm_context> i = std::shared_ptr
< itti_nsmf_pdusession_update_sm_context > (itti_msg);
int ret = itti_inst->send_msg(i);
......@@ -301,7 +356,7 @@ ngap_message_decoded_callback messages_callback[][3] = { { 0, 0, 0 }, /*0 AMFCon
{ 0, 0, 0 }, //{ngap_amf_handle_path_switch_request,0,0}, /*PathSwitchRequest*
{ 0, 0, 0 }, /*PDUSessionResourceModify*/
{ 0, 0, 0 }, /*PDUSessionResourceModifyIndication*/
{ 0, 0, 0 }, /*PDUSessionResourceRelease*/
{ 0, ngap_amf_handle_pdu_session_resource_release_response, 0 }, /*PDUSessionResourceRelease*/
{ 0, ngap_amf_handle_pdu_session_resource_setup_response, 0 }, /*PDUSessionResourceSetup*/
{ 0, 0, 0 }, /*PDUSessionResourceNotify*/
{ 0, 0, 0 }, /*PrivateMessage*/
......
......@@ -2,7 +2,7 @@
#include <string>
#include <iostream>
bool multipart_parser(std::string input, std::string &jsonData,
uint8_t multipart_parser(std::string input, std::string &jsonData,
std::string &n1sm, std::string &n2sm) {
//simple parser
......@@ -14,7 +14,7 @@ bool multipart_parser(std::string input, std::string &jsonData,
uint8_t size = parts.size();
//at least 2 parts for Json data and N1 (+ N2)
if (size < 2) {
return false;
return size;
}
jsonData = parts[0].body;
......@@ -26,6 +26,6 @@ bool multipart_parser(std::string input, std::string &jsonData,
n2sm = "null";
}
return true;
return size;
}
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