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

First version for UE Context Release procedure

parent 765c0f42
......@@ -152,6 +152,13 @@ void amf_n2_task(void* args_p) {
dynamic_cast<itti_ue_context_release_command*>(msg);
amf_n2_inst->handle_itti_message(ref(*m));
} break;
case UE_CONTEXT_RELEASE_COMPLETE: {
Logger::task_amf_n2().info(
"Received UE_CONTEXT_RELEASE_COMPLETE message, handling");
itti_ue_context_release_complete* m =
dynamic_cast<itti_ue_context_release_complete*>(msg);
amf_n2_inst->handle_itti_message(ref(*m));
} break;
case PDU_SESSION_RESOURCE_RELEASE_COMMAND: {
Logger::task_amf_n2().info(
"Received PDU_SESSION_RESOURCE_RELEASE_COMMAND message, handling");
......@@ -998,6 +1005,18 @@ void amf_n2::handle_itti_message(itti_ue_context_release_command& itti_msg) {
return;
}
//------------------------------------------------------------------------------
void amf_n2::handle_itti_message(itti_ue_context_release_complete& itti_msg) {
Logger::amf_n2().debug("Handling UE Context Release Complete ...");
unsigned long amf_ue_ngap_id = itti_msg.ueCtxRelCmpl->getAmfUeNgapId();
uint32_t ran_ue_ngap_id = itti_msg.ueCtxRelCmpl->getRanUeNgapId();
// TODO: User Location Information IE
// TODO: Information on Recommended Cells & RAN Nodes for Paging IE
// TODO: Process Secondary RAT Usage Information IE if available
// send Nsmf_PDUSession_UpdateSMContext to SMF
}
//------------------------------------------------------------------------------
void amf_n2::handle_itti_message(
itti_ue_radio_capability_indication& itti_msg) {
......
......@@ -54,6 +54,7 @@ class amf_n2 : public ngap::ngap_app {
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_ue_context_release_request& itti_msg);
void handle_itti_message(itti_ue_context_release_complete& itti_msg);
void handle_itti_message(itti_ue_radio_capability_indication& itti_msg);
void handle_itti_message(itti_ue_context_release_command& itti_msg);
void handle_itti_message(itti_pdu_session_resource_release_command& itti_msg);
......
......@@ -71,6 +71,7 @@ typedef enum {
PDU_SESSION_RESOURCE_SETUP_REQUEST,
PDU_SESSION_RESOURCE_RELEASE_COMMAND,
UE_CONTEXT_RELEASE_REQUEST,
UE_CONTEXT_RELEASE_COMPLETE,
UE_RADIO_CAP_IND,
UL_NAS_DATA_IND, // task amf_n1 message id
DOWNLINK_NAS_TRANSFER,
......
......@@ -29,6 +29,7 @@
#include "NGReset.hpp"
#include "NGSetupRequest.hpp"
#include "UEContextReleaseRequest.hpp"
#include "UEContextReleaseComplete.hpp"
#include "UERadioCapabilityInfoIndication.hpp"
#include "UplinkNASTransport.hpp"
#include "UplinkRANStatusTransfer.hpp"
......@@ -191,6 +192,16 @@ class itti_ue_context_release_command : public itti_msg_n2 {
Cause cause;
};
class itti_ue_context_release_complete : public itti_msg_n2 {
public:
itti_ue_context_release_complete(
const task_id_t origin, const task_id_t destination)
: itti_msg_n2(UE_CONTEXT_RELEASE_COMPLETE, origin, destination) {}
itti_ue_context_release_complete(const itti_ue_context_release_complete& i)
: itti_msg_n2(i) {}
UEContextReleaseCompleteMsg* ueCtxRelCmpl;
};
class itti_ue_radio_capability_indication : public itti_msg_n2 {
public:
itti_ue_radio_capability_indication(
......
......@@ -29,6 +29,8 @@
#include "UEContextReleaseComplete.hpp"
#include <iostream>
#include <memory>
extern "C" {
#include "asn_codecs.h"
#include "constr_TYPE.h"
......@@ -89,6 +91,11 @@ void UEContextReleaseCompleteMsg::setAmfUeNgapId(unsigned long id) {
// free_wrapper((void**) &ie);
}
//------------------------------------------------------------------------------
unsigned long UEContextReleaseCompleteMsg::getAmfUeNgapId() const {
if (amfUeNgapId) return amfUeNgapId->getAMF_UE_NGAP_ID();
}
//------------------------------------------------------------------------------
void UEContextReleaseCompleteMsg::setRanUeNgapId(uint32_t ran_ue_ngap_id) {
if (!ranUeNgapId) ranUeNgapId = new RAN_UE_NGAP_ID();
......@@ -111,6 +118,11 @@ void UEContextReleaseCompleteMsg::setRanUeNgapId(uint32_t ran_ue_ngap_id) {
// free_wrapper((void**) &ie);
}
//------------------------------------------------------------------------------
uint32_t UEContextReleaseCompleteMsg::getRanUeNgapId() const {
if (ranUeNgapId) return ranUeNgapId->getRanUeNgapId();
}
//------------------------------------------------------------------------------
void UEContextReleaseCompleteMsg::setUserLocationInfoNR(
struct NrCgi_s cig, struct Tai_s tai) {
......@@ -156,6 +168,40 @@ void UEContextReleaseCompleteMsg::setUserLocationInfoNR(
// free_wrapper((void**) &ie);
}
//------------------------------------------------------------------------------
void UEContextReleaseCompleteMsg::getUserLocationInfoNR(
struct NrCgi_s& cig, struct Tai_s& tai) {
// TODO:
/*
if (userLocationInformation) {
UserLocationInformationNR* informationNR = new
UserLocationInformationNR();
userLocationInformation->getInformation(informationNR);
//std::unique_ptr<NR_CGI> nR_CGI = std::make_unique<NR_CGI>();
NR_CGI* nR_CGI = new NR_CGI();
TAI* tai_nr = new TAI();
informationNR->getInformationNR(nR_CGI, tai_nr);
PlmnId* plmnId_cgi = new PlmnId();
NRCellIdentity* nRCellIdentity = new NRCellIdentity();
nR_CGI->getNR_CGI(plmnId_cgi, nRCellIdentity);
cig.nrCellID = nRCellIdentity->getNRCellIdentity();
plmnId_cgi->getMcc(cig.mcc);
plmnId_cgi->getMnc(cig.mnc);
PlmnId* plmnId = new PlmnId();
TAC* tac = new TAC();
tai_nr->getTAI(plmnId, tac);
plmnId->getMcc(tai.mcc);
plmnId->getMnc(tai.mnc);
tai.tac = tac->getTac() & 0x00ffffff;
}
*/
}
//------------------------------------------------------------------------------
int UEContextReleaseCompleteMsg::encode2buffer(uint8_t* buf, int buf_size) {
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, pdu);
......@@ -164,3 +210,72 @@ int UEContextReleaseCompleteMsg::encode2buffer(uint8_t* buf, int buf_size) {
cout << "er.encoded(" << er.encoded << ")" << endl;
return er.encoded;
}
//------------------------------------------------------------------------------
bool UEContextReleaseCompleteMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
pdu = ngap_msg_pdu;
if (pdu->present == Ngap_NGAP_PDU_PR_successfulOutcome) {
if (pdu->choice.successfulOutcome &&
pdu->choice.successfulOutcome->procedureCode ==
Ngap_ProcedureCode_id_UEContextRelease &&
pdu->choice.successfulOutcome->criticality == Ngap_Criticality_reject &&
pdu->choice.successfulOutcome->value.present ==
Ngap_SuccessfulOutcome__value_PR_UEContextReleaseComplete) {
ies =
&pdu->choice.successfulOutcome->value.choice.UEContextReleaseComplete;
} else {
cout << "Check UEContextReleaseComplete message error" << endl;
return false;
}
} else {
cout << "typeOfMessage of UEContextReleaseComplete is not SuccessfulOutcome"
<< endl;
return false;
}
// TODO
for (int i = 0; i < ies->protocolIEs.list.count; i++) {
switch (ies->protocolIEs.list.array[i]->id) {
case Ngap_ProtocolIE_ID_id_AMF_UE_NGAP_ID: {
if (ies->protocolIEs.list.array[i]->criticality ==
Ngap_Criticality_ignore &&
ies->protocolIEs.list.array[i]->value.present ==
Ngap_UEContextReleaseComplete_IEs__value_PR_AMF_UE_NGAP_ID) {
amfUeNgapId = new AMF_UE_NGAP_ID();
if (!amfUeNgapId->decodefromAMF_UE_NGAP_ID(
ies->protocolIEs.list.array[i]
->value.choice.AMF_UE_NGAP_ID)) {
cout << "decode AMF_UE_NGAP_ID error" << endl;
return false;
}
} else {
cout << "IE AMF_UE_NGAP_ID is not correct" << endl;
return false;
}
} break;
case Ngap_ProtocolIE_ID_id_RAN_UE_NGAP_ID: {
if (ies->protocolIEs.list.array[i]->criticality ==
Ngap_Criticality_ignore &&
ies->protocolIEs.list.array[i]->value.present ==
Ngap_UEContextReleaseComplete_IEs__value_PR_RAN_UE_NGAP_ID) {
ranUeNgapId = new RAN_UE_NGAP_ID();
if (!ranUeNgapId->decodefromRAN_UE_NGAP_ID(
ies->protocolIEs.list.array[i]
->value.choice.RAN_UE_NGAP_ID)) {
cout << "decode RAN_UE_NGAP_ID error" << endl;
return false;
}
} else {
cout << "IE RAN_UE_NGAP_ID is not correct" << endl;
return false;
}
} break;
// TODO: User Location Information
// TODO: Information on Recommended Cells and RAN Nodes for Paging
// TODO: PDU Session Resource List
// TODO: Criticality Diagnostics
}
}
return true;
}
......@@ -50,9 +50,13 @@ class UEContextReleaseCompleteMsg {
public:
void setMessageType();
void setAmfUeNgapId(unsigned long id);
unsigned long getAmfUeNgapId() const;
void setRanUeNgapId(uint32_t ran_ue_ngap_id);
uint32_t getRanUeNgapId() const;
void setUserLocationInfoNR(struct NrCgi_s cig, struct Tai_s tai);
void getUserLocationInfoNR(struct NrCgi_s& cig, struct Tai_s& tai);
int encode2buffer(uint8_t* buf, int buf_size);
bool decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu);
private:
Ngap_NGAP_PDU_t* pdu;
......
......@@ -263,6 +263,27 @@ int ngap_amf_handle_ue_context_release_complete(
struct Ngap_NGAP_PDU* message_p) {
Logger::ngap().debug(
"Sending itti ue context release complete to TASK_AMF_N2");
UEContextReleaseCompleteMsg* ueCtxRelCmpl = new UEContextReleaseCompleteMsg();
if (!ueCtxRelCmpl->decodefrompdu(message_p)) {
Logger::ngap().error("Decoding UEContextReleaseComplete message error");
return -1;
}
itti_ue_context_release_complete* itti_msg =
new itti_ue_context_release_complete(TASK_NGAP, TASK_AMF_N2);
itti_msg->assoc_id = assoc_id;
itti_msg->stream = stream;
itti_msg->ueCtxRelCmpl = ueCtxRelCmpl;
std::shared_ptr<itti_ue_context_release_complete> i =
std::shared_ptr<itti_ue_context_release_complete>(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_N2",
i->get_msg_name());
}
return 0;
return 0;
}
......
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