Commit c768dba0 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Process PDUSessionResourceReleaseResponse

parent 5ec0e13d
......@@ -197,7 +197,8 @@ void amf_n11::handle_itti_message(
Logger::amf_n11().debug("SMF URI: %s", remote_uri.c_str());
nlohmann::json pdu_session_update_request = { };
pdu_session_update_request["n2SmInfoType"] = "PDU_RES_SETUP_RSP";
//if (itti_msg.is_n2sm_set){
pdu_session_update_request["n2SmInfoType"] = itti_msg.n2sm_info_type;
pdu_session_update_request["n2SmInfo"]["contentId"] = "n2msg";
std::string json_part = pdu_session_update_request.dump();
std::string n2SmMsg;
......@@ -586,7 +587,8 @@ void amf_n11::curl_http_client(std::string remoteUri, std::string jsonData,
itti_msg->n1sm = n1sm_hex;
itti_msg->is_n1sm_set = true;
} else if (n2sm.size() > 0) {
}
if (n2sm.size() > 0) {
msg_str_2_msg_hex(n2sm, n2sm_hex);
print_buffer("amf_n11", "Get response n1sm:",
(uint8_t*) bdata(n2sm_hex), blength(n2sm_hex));
......
......@@ -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
*/
......
......@@ -69,15 +69,24 @@ class itti_nsmf_pdusession_update_sm_context : public itti_msg_n11 {
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
......@@ -108,6 +108,13 @@ typedef struct {
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
......@@ -53,8 +53,7 @@ void PDUSessionResourceToReleaseItemRelCmd::getPDUSessionResourceToReleaseItemRe
PDUSessionID *&m_pDUSessionID,
OCTET_STRING_t &m_pDUSessionResourceReleaseCommandTransfer) {
m_pDUSessionID = pDUSessionID;
pDUSessionResourceReleaseCommandTransfer =
m_pDUSessionResourceReleaseCommandTransfer;
m_pDUSessionResourceReleaseCommandTransfer = pDUSessionResourceReleaseCommandTransfer;
}
//------------------------------------------------------------------------------
......
/*
* 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 "PduSessionResourceReleaseResponse.hpp"
#include "logger.hpp"
extern "C" {
#include "constr_TYPE.h"
#include "asn_codecs.h"
#include "per_encoder.h"
#include "per_decoder.h"
#include "constraints.h"
}
using namespace std;
namespace ngap {
//------------------------------------------------------------------------------
PduSessionResourceReleaseResponseMsg::PduSessionResourceReleaseResponseMsg() {
pduSessionResourceReleaseResponsePdu = NULL;
pduSessionResourceReleaseResponseIEs = NULL;
amfUeNgapId = NULL;
ranUeNgapId = NULL;
pduSessionResourceReleasedList = NULL;
userLocationInformation = NULL;
}
//------------------------------------------------------------------------------
PduSessionResourceReleaseResponseMsg::~PduSessionResourceReleaseResponseMsg() {
}
//------------------------------------------------------------------------------
void PduSessionResourceReleaseResponseMsg::setMessageType() {
if (!pduSessionResourceReleaseResponsePdu)
pduSessionResourceReleaseResponsePdu = (Ngap_NGAP_PDU_t*) calloc(
1, sizeof(Ngap_NGAP_PDU_t));
MessageType messageTypeIE;
messageTypeIE.setProcedureCode(
Ngap_ProcedureCode_id_PDUSessionResourceRelease);
messageTypeIE.setTypeOfMessage(Ngap_NGAP_PDU_PR_successfulOutcome);
messageTypeIE.setCriticality(Ngap_Criticality_reject);
messageTypeIE.setValuePresent(
Ngap_SuccessfulOutcome__value_PR_PDUSessionResourceReleaseResponse);
if (messageTypeIE.getProcedureCode()
== Ngap_ProcedureCode_id_PDUSessionResourceRelease
&& messageTypeIE.getTypeOfMessage() == Ngap_NGAP_PDU_PR_successfulOutcome
&& messageTypeIE.getCriticality() == Ngap_Criticality_reject) {
messageTypeIE.encode2pdu(pduSessionResourceReleaseResponsePdu);
pduSessionResourceReleaseResponseIEs =
&(pduSessionResourceReleaseResponsePdu->choice.successfulOutcome->value
.choice.PDUSessionResourceReleaseResponse);
} else {
Logger::nas_mm().warn(
"This information doesn't refer to PDUSessionResourceReleaseResponse Message");
}
}
//------------------------------------------------------------------------------
void PduSessionResourceReleaseResponseMsg::setAmfUeNgapId(unsigned long id) {
if (!amfUeNgapId)
amfUeNgapId = new AMF_UE_NGAP_ID();
amfUeNgapId->setAMF_UE_NGAP_ID(id);
Ngap_PDUSessionResourceReleaseResponseIEs_t *ie =
(Ngap_PDUSessionResourceReleaseResponseIEs_t*) calloc(
1, sizeof(Ngap_PDUSessionResourceReleaseResponseIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_AMF_UE_NGAP_ID;
ie->criticality = Ngap_Criticality_reject;
ie->value.present =
Ngap_PDUSessionResourceReleaseResponseIEs__value_PR_AMF_UE_NGAP_ID;
int ret = amfUeNgapId->encode2AMF_UE_NGAP_ID(ie->value.choice.AMF_UE_NGAP_ID);
if (!ret) {
Logger::nas_mm().warn("Encode AMF_UE_NGAP_ID IE error");
return;
}
ret = ASN_SEQUENCE_ADD(
&pduSessionResourceReleaseResponseIEs->protocolIEs.list, ie);
if (ret != 0)
Logger::nas_mm().warn("Encode AMF_UE_NGAP_ID IE error");
}
//------------------------------------------------------------------------------
void PduSessionResourceReleaseResponseMsg::setRanUeNgapId(
uint32_t ran_ue_ngap_id) {
if (!ranUeNgapId)
ranUeNgapId = new RAN_UE_NGAP_ID();
ranUeNgapId->setRanUeNgapId(ran_ue_ngap_id);
Ngap_PDUSessionResourceReleaseResponseIEs_t *ie =
(Ngap_PDUSessionResourceReleaseResponseIEs_t*) calloc(
1, sizeof(Ngap_PDUSessionResourceReleaseResponseIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_RAN_UE_NGAP_ID;
ie->criticality = Ngap_Criticality_reject;
ie->value.present =
Ngap_PDUSessionResourceReleaseResponseIEs__value_PR_RAN_UE_NGAP_ID;
int ret = ranUeNgapId->encode2RAN_UE_NGAP_ID(ie->value.choice.RAN_UE_NGAP_ID);
if (!ret) {
Logger::nas_mm().warn("Encode RAN_UE_NGAP_ID IE error");
return;
}
ret = ASN_SEQUENCE_ADD(
&pduSessionResourceReleaseResponseIEs->protocolIEs.list, ie);
if (ret != 0)
Logger::nas_mm().warn("Encode RAN_UE_NGAP_ID IE error");
}
//------------------------------------------------------------------------------
void PduSessionResourceReleaseResponseMsg::setPduSessionResourceReleasedList(
std::vector<PDUSessionResourceReleasedItem_t> list) {
if (!pduSessionResourceReleasedList)
pduSessionResourceReleasedList = new PDUSessionResourceReleasedListRelRes();
PDUSessionResourceReleasedItemRelRes *m_pduSessionResourceReleasedItemRelRes =
new PDUSessionResourceReleasedItemRelRes[list.size()]();
for (int i = 0; i < list.size(); i++) {
PDUSessionID *m_pDUSessionID = new PDUSessionID();
m_pDUSessionID->setPDUSessionID(list[i].pduSessionId);
m_pduSessionResourceReleasedItemRelRes[i]
.setPDUSessionResourceReleasedItemRelRes(
m_pDUSessionID, list[i].pduSessionResourceReleaseResponseTransfer);
}
pduSessionResourceReleasedList->setPDUSessionResourceReleasedListRelRes(
m_pduSessionResourceReleasedItemRelRes, list.size());
Ngap_PDUSessionResourceReleaseResponseIEs_t *ie =
(Ngap_PDUSessionResourceReleaseResponseIEs_t*) calloc(
1, sizeof(Ngap_PDUSessionResourceReleaseResponseIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_PDUSessionResourceReleasedListRelRes;
ie->criticality = Ngap_Criticality_reject;
ie->value.present =
Ngap_PDUSessionResourceReleaseResponseIEs__value_PR_PDUSessionResourceReleasedListRelRes;
int ret = pduSessionResourceReleasedList
->encode2PDUSessionResourceReleasedListRelRes(
&ie->value.choice.PDUSessionResourceReleasedListRelRes);
if (!ret) {
Logger::nas_mm().warn(
"Encode PDUSessionResourceReleasedListRelRes IE error");
return;
}
ret = ASN_SEQUENCE_ADD(
&pduSessionResourceReleaseResponseIEs->protocolIEs.list, ie);
if (ret != 0)
Logger::nas_mm().warn(
"Encode PDUSessionResourceReleasedListRelRes IE error");
}
//------------------------------------------------------------------------------
void PduSessionResourceReleaseResponseMsg::setUserLocationInfoNR(
struct NrCgi_s cig, struct Tai_s tai) {
if (!userLocationInformation)
userLocationInformation = new UserLocationInformation();
UserLocationInformationNR *informationNR = new UserLocationInformationNR();
NR_CGI *nR_CGI = new NR_CGI();
PlmnId *plmnId_cgi = new PlmnId();
NRCellIdentity *nRCellIdentity = new NRCellIdentity();
plmnId_cgi->setMccMnc(cig.mcc, cig.mnc);
nRCellIdentity->setNRCellIdentity(cig.nrCellID);
nR_CGI->setNR_CGI(plmnId_cgi, nRCellIdentity);
TAI *tai_nr = new TAI();
PlmnId *plmnId_tai = new PlmnId();
plmnId_tai->setMccMnc(tai.mcc, tai.mnc);
TAC *tac = new TAC();
tac->setTac(tai.tac);
tai_nr->setTAI(plmnId_tai, tac);
informationNR->setInformationNR(nR_CGI, tai_nr);
userLocationInformation->setInformation(informationNR);
Ngap_PDUSessionResourceReleaseResponseIEs_t *ie =
(Ngap_PDUSessionResourceReleaseResponseIEs_t*) calloc(
1, sizeof(Ngap_PDUSessionResourceReleaseResponseIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_UserLocationInformation;
ie->criticality = Ngap_Criticality_reject;
ie->value.present =
Ngap_PDUSessionResourceReleaseResponseIEs__value_PR_UserLocationInformation;
int ret = userLocationInformation->encodefromUserLocationInformation(
&ie->value.choice.UserLocationInformation);
if (!ret) {
Logger::nas_mm().warn("Encode UserLocationInformation IE error");
return;
}
ret = ASN_SEQUENCE_ADD(
&pduSessionResourceReleaseResponseIEs->protocolIEs.list, ie);
if (ret != 0)
Logger::nas_mm().warn("Encode UserLocationInformation IE error");
}
//------------------------------------------------------------------------------
int PduSessionResourceReleaseResponseMsg::encode2buffer(uint8_t *buf,
int buf_size) {
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU,
pduSessionResourceReleaseResponsePdu);
asn_enc_rval_t er = aper_encode_to_buffer(
&asn_DEF_Ngap_NGAP_PDU, NULL, pduSessionResourceReleaseResponsePdu, buf,
buf_size);
Logger::nas_mm().debug("er.encoded( %d)", er.encoded);
return er.encoded;
}
//------------------------------------------------------------------------------
void PduSessionResourceReleaseResponseMsg::encode2buffer_new(
char *buf, int &encoded_size) {
char *buffer = (char*) calloc(1, 512); //TODO: remove hardcoded value
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU,
pduSessionResourceReleaseResponsePdu);
encoded_size = aper_encode_to_new_buffer(&asn_DEF_Ngap_NGAP_PDU, NULL,
pduSessionResourceReleaseResponsePdu,
(void**) &buffer);
Logger::nas_mm().debug("er.encoded ( %d)", encoded_size);
memcpy((void*) buf, (void*) buffer, encoded_size);
free(buffer);
}
//------------------------------------------------------------------------------
//Decapsulation
bool PduSessionResourceReleaseResponseMsg::decodefrompdu(
Ngap_NGAP_PDU_t *ngap_msg_pdu) {
pduSessionResourceReleaseResponsePdu = ngap_msg_pdu;
if (pduSessionResourceReleaseResponsePdu->present
== Ngap_NGAP_PDU_PR_successfulOutcome) {
if (pduSessionResourceReleaseResponsePdu->choice.successfulOutcome
&& pduSessionResourceReleaseResponsePdu->choice.successfulOutcome
->procedureCode == Ngap_ProcedureCode_id_PDUSessionResourceRelease
&& pduSessionResourceReleaseResponsePdu->choice.successfulOutcome
->criticality == Ngap_Criticality_reject
&& pduSessionResourceReleaseResponsePdu->choice.successfulOutcome->value
.present
== Ngap_SuccessfulOutcome__value_PR_PDUSessionResourceReleaseResponse) {
pduSessionResourceReleaseResponseIEs =
&pduSessionResourceReleaseResponsePdu->choice.successfulOutcome->value
.choice.PDUSessionResourceReleaseResponse;
} else {
Logger::nas_mm().warn(
"Check PDUSessionResourceReleaseResponse message error");
return false;
}
} else {
Logger::nas_mm().warn("MessageType error");
return false;
}
for (int i = 0;
i < pduSessionResourceReleaseResponseIEs->protocolIEs.list.count; i++) {
switch (pduSessionResourceReleaseResponseIEs->protocolIEs.list.array[i]->id) {
case Ngap_ProtocolIE_ID_id_AMF_UE_NGAP_ID: {
if (pduSessionResourceReleaseResponseIEs->protocolIEs.list.array[i]
->criticality == Ngap_Criticality_reject
&& pduSessionResourceReleaseResponseIEs->protocolIEs.list.array[i]
->value.present
== Ngap_PDUSessionResourceReleaseResponseIEs__value_PR_AMF_UE_NGAP_ID) {
amfUeNgapId = new AMF_UE_NGAP_ID();
if (!amfUeNgapId->decodefromAMF_UE_NGAP_ID(
pduSessionResourceReleaseResponseIEs->protocolIEs.list.array[i]
->value.choice.AMF_UE_NGAP_ID)) {
Logger::nas_mm().warn("Decoded NGAP AMF_UE_NGAP_ID IE error");
return false;
}
} else {
Logger::nas_mm().warn("Decoded NGAP AMF_UE_NGAP_ID IE error");
return false;
}
}
break;
case Ngap_ProtocolIE_ID_id_RAN_UE_NGAP_ID: {
if (pduSessionResourceReleaseResponseIEs->protocolIEs.list.array[i]
->criticality == Ngap_Criticality_reject
&& pduSessionResourceReleaseResponseIEs->protocolIEs.list.array[i]
->value.present
== Ngap_PDUSessionResourceReleaseResponseIEs__value_PR_RAN_UE_NGAP_ID) {
ranUeNgapId = new RAN_UE_NGAP_ID();
if (!ranUeNgapId->decodefromRAN_UE_NGAP_ID(
pduSessionResourceReleaseResponseIEs->protocolIEs.list.array[i]
->value.choice.RAN_UE_NGAP_ID)) {
Logger::nas_mm().warn("Decoded NGAP RAN_UE_NGAP_ID IE error");
return false;
}
} else {
Logger::nas_mm().warn("Decoded NGAP RAN_UE_NGAP_ID IE error");
return false;
}
}
break;
case Ngap_ProtocolIE_ID_id_PDUSessionResourceReleasedListRelRes: {
if (pduSessionResourceReleaseResponseIEs->protocolIEs.list.array[i]
->criticality == Ngap_Criticality_reject
&& pduSessionResourceReleaseResponseIEs->protocolIEs.list.array[i]
->value.present
== Ngap_PDUSessionResourceReleaseResponseIEs__value_PR_PDUSessionResourceReleasedListRelRes) {
pduSessionResourceReleasedList =
new PDUSessionResourceReleasedListRelRes();
if (!pduSessionResourceReleasedList
->decodefromPDUSessionResourceReleasedListRelRes(
&pduSessionResourceReleaseResponseIEs->protocolIEs.list.array[i]
->value.choice.PDUSessionResourceReleasedListRelRes)) {
Logger::nas_mm().warn(
"Decoded NGAP PDUSessionResourceReleasedListRelRes IE error");
return false;
}
} else {
Logger::nas_mm().warn(
"Decoded NGAP PDUSessionResourceReleasedListRelRes IE error");
return false;
}
}
break;
default: {
Logger::nas_mm().warn("Decoded NGAP message PDU error");
return false;
}
}
}
return true;
}
//------------------------------------------------------------------------------
unsigned long PduSessionResourceReleaseResponseMsg::getAmfUeNgapId() {
if (!amfUeNgapId)
return -1;
return amfUeNgapId->getAMF_UE_NGAP_ID();
}
//------------------------------------------------------------------------------
uint32_t PduSessionResourceReleaseResponseMsg::getRanUeNgapId() {
if (!ranUeNgapId)
return -1;
return ranUeNgapId->getRanUeNgapId();
}
//------------------------------------------------------------------------------
bool PduSessionResourceReleaseResponseMsg::getPduSessionResourceReleasedList(
std::vector<PDUSessionResourceReleasedItem_t> &list) {
if (!pduSessionResourceReleasedList)
return false;
PDUSessionResourceReleasedItemRelRes *m_pduSessionResourceReleasedItemRelRes;
int num = 0;
pduSessionResourceReleasedList->getPDUSessionResourceReleasedListRelRes(
m_pduSessionResourceReleasedItemRelRes, num);
for (int i = 0; i < num; i++) {
PDUSessionResourceReleasedItem_t rel;
PDUSessionID *m_pDUSessionID;
m_pduSessionResourceReleasedItemRelRes[i]
.getPDUSessionResourceReleasedItemRelRes(
m_pDUSessionID, rel.pduSessionResourceReleaseResponseTransfer);
m_pDUSessionID->getPDUSessionID(rel.pduSessionId);
list.push_back(rel);
}
return true;
}
//------------------------------------------------------------------------------
bool PduSessionResourceReleaseResponseMsg::getUserLocationInfoNR(
struct NrCgi_s &cig, struct Tai_s &tai) {
UserLocationInformationNR *informationNR;
userLocationInformation->getInformation(informationNR);
if (userLocationInformation->getChoiceOfUserLocationInformation()
!= Ngap_UserLocationInformation_PR_userLocationInformationNR)
return false;
NR_CGI *nR_CGI;
TAI *nR_TAI;
informationNR->getInformationNR(nR_CGI, nR_TAI);
PlmnId *cgi_plmnId;
NRCellIdentity *nRCellIdentity;
nR_CGI->getNR_CGI(cgi_plmnId, nRCellIdentity);
cgi_plmnId->getMcc(cig.mcc);
cgi_plmnId->getMnc(cig.mnc);
cig.nrCellID = nRCellIdentity->getNRCellIdentity();
PlmnId *tai_plmnId;
TAC *tac;
nR_TAI->getTAI(tai_plmnId, tac);
tai_plmnId->getMcc(tai.mcc);
tai_plmnId->getMnc(tai.mnc);
tai.tac = tac->getTac();
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_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,55 @@ 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 +315,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 +357,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*/
......
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