Commit 7d370ca2 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Merge branch 'fix_ue_context_release_complete' into 'develop'

Fix ue context release complete

See merge request oai/cn5g/oai-cn5g-amf!176
parents 034367f5 f9c4a4e5
......@@ -3132,6 +3132,9 @@ void amf_n1::ue_initiate_de_registration_handle(
}
}
// TODO: AMF-nitiated AM Policy Association Termination (if exist)
// TODO: AMF-initiated UE Policy Association Termination (if exist)
// Check Deregistration type
uint8_t deregType = 0;
dereg_request->getDeregistrationType(deregType);
......@@ -3156,7 +3159,7 @@ void amf_n1::ue_initiate_de_registration_handle(
bstring b = blk2bstr(buffer, encoded_size);
itti_send_dl_nas_buffer_to_task_n2(b, ran_ue_ngap_id, amf_ue_ngap_id);
// sleep 100ms
// sleep 200ms
usleep(200000);
}
......
......@@ -1273,6 +1273,7 @@ void amf_n2::handle_itti_message(itti_ue_context_release_complete& itti_msg) {
"No existed nas_context with amf_ue_ngap_id (" AMF_UE_NGAP_ID_FMT ")",
amf_ue_ngap_id);
}
if (nc != nullptr) {
amf_n1_inst->set_5gcm_state(nc, CM_IDLE);
......@@ -1382,6 +1383,9 @@ void amf_n2::handle_itti_message(itti_ue_context_release_complete& itti_msg) {
}
curl_responses.erase(curl_responses.begin());
}
// Remove UE NGAP context
remove_ue_context_with_ran_ue_ngap_id(ran_ue_ngap_id);
}
//------------------------------------------------------------------------------
......
......@@ -47,6 +47,7 @@ class UserLocationInformation {
// void setInformation(const UserLocationInformationN3IWF&);
// void getInformation(UserLocationInformationN3IWF&);
// TODO: use reference instead of raw pointer
bool encode(Ngap_UserLocationInformation_t* user_location_information);
bool decode(Ngap_UserLocationInformation_t* user_location_information);
Ngap_UserLocationInformation_PR getChoiceOfUserLocationInformation();
......
......@@ -31,7 +31,7 @@ using namespace ngap;
//------------------------------------------------------------------------------
UEContextReleaseCompleteMsg::UEContextReleaseCompleteMsg() : NgapUEMessage() {
ies = nullptr;
userLocationInformation = nullptr;
userLocationInformation = std::nullopt;
pduSessionResourceListCxtRelCpl = std::nullopt;
setMessageType(NgapMessageType::UE_CONTEXT_RELEASE_COMPLETE);
......@@ -91,8 +91,7 @@ void UEContextReleaseCompleteMsg::setRanUeNgapId(
//------------------------------------------------------------------------------
void UEContextReleaseCompleteMsg::setUserLocationInfoNR(
const NrCgi_t& cig, const Tai_t& tai) {
if (!userLocationInformation)
userLocationInformation = new UserLocationInformation();
UserLocationInformation m_userLocationInformation = {};
UserLocationInformationNR information_nr = {};
NR_CGI nr_cgi = {};
......@@ -101,7 +100,8 @@ void UEContextReleaseCompleteMsg::setUserLocationInfoNR(
TAI tai_nr = {};
tai_nr.setTAI(tai);
information_nr.set(nr_cgi, tai_nr);
userLocationInformation->setInformation(information_nr);
m_userLocationInformation.setInformation(information_nr);
Ngap_UEContextReleaseComplete_IEs* ie =
(Ngap_UEContextReleaseComplete_IEs*) calloc(
......@@ -111,13 +111,17 @@ void UEContextReleaseCompleteMsg::setUserLocationInfoNR(
ie->value.present =
Ngap_UEContextReleaseComplete_IEs__value_PR_UserLocationInformation;
int ret = userLocationInformation->encode(
int ret = m_userLocationInformation.encode(
&ie->value.choice.UserLocationInformation);
if (!ret) {
Logger::ngap().error("Encode NGAP UserLocationInformation IE error");
free_wrapper((void**) &ie);
return;
}
userLocationInformation =
std::optional<UserLocationInformation>{m_userLocationInformation};
ret = ASN_SEQUENCE_ADD(&ies->protocolIEs.list, ie);
if (ret != 0)
Logger::ngap().error("Encode NGAP UserLocationInformation IE error");
......@@ -126,9 +130,9 @@ void UEContextReleaseCompleteMsg::setUserLocationInfoNR(
//------------------------------------------------------------------------------
void UEContextReleaseCompleteMsg::getUserLocationInfoNR(
NrCgi_t& cig, Tai_t& tai) {
if (userLocationInformation) {
if (userLocationInformation.has_value()) {
UserLocationInformationNR information_nr = {};
if (!userLocationInformation->getInformation(information_nr)) return;
if (!userLocationInformation.value().getInformation(information_nr)) return;
NR_CGI nr_cgi = {};
TAI tai_nr = {};
......@@ -241,9 +245,9 @@ bool UEContextReleaseCompleteMsg::decodeFromPdu(Ngap_NGAP_PDU_t* ngapMsgPdu) {
} else {
Logger::ngap().error(
"TypeOfMessage of UEContextReleaseComplete is not SuccessfulOutcome");
return false;
}
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: {
......@@ -262,6 +266,7 @@ bool UEContextReleaseCompleteMsg::decodeFromPdu(Ngap_NGAP_PDU_t* ngapMsgPdu) {
return false;
}
} break;
case Ngap_ProtocolIE_ID_id_RAN_UE_NGAP_ID: {
if (ies->protocolIEs.list.array[i]->criticality ==
Ngap_Criticality_ignore &&
......@@ -277,8 +282,31 @@ bool UEContextReleaseCompleteMsg::decodeFromPdu(Ngap_NGAP_PDU_t* ngapMsgPdu) {
return false;
}
} break;
// TODO: User Location Information
case Ngap_ProtocolIE_ID_id_UserLocationInformation: {
if (ies->protocolIEs.list.array[i]->criticality ==
Ngap_Criticality_ignore &&
ies->protocolIEs.list.array[i]->value.present ==
Ngap_UEContextReleaseComplete_IEs__value_PR_UserLocationInformation) {
UserLocationInformation m_userLocationInformation = {};
if (!m_userLocationInformation.decode(
&ies->protocolIEs.list.array[i]
->value.choice.UserLocationInformation)) {
Logger::ngap().error(
"Decode NGAP UserLocationInformation IE error");
return false;
}
userLocationInformation =
std::optional<UserLocationInformation>{m_userLocationInformation};
} else {
Logger::ngap().error("Decode NGAP UserLocationInformation IE error");
return false;
}
} break;
// TODO: Information on Recommended Cells and RAN Nodes for Paging
case Ngap_ProtocolIE_ID_id_PDUSessionResourceListCxtRelCpl: {
if (ies->protocolIEs.list.array[i]->criticality ==
Ngap_Criticality_reject &&
......@@ -307,8 +335,9 @@ bool UEContextReleaseCompleteMsg::decodeFromPdu(Ngap_NGAP_PDU_t* ngapMsgPdu) {
// TODO: Criticality Diagnostics
default: {
Logger::ngap().error("Decoded NGAP message PDU error!");
return false;
Logger::ngap().error(
"Unknown IE 0x%x", ies->protocolIEs.list.array[i]->id);
return true;
}
}
}
......
......@@ -55,7 +55,7 @@ class UEContextReleaseCompleteMsg : public NgapUEMessage {
Ngap_UEContextReleaseComplete_t* ies;
// AMF_UE_NGAP_ID //Mandatory
// RAN_UE_NGAP_ID //Mandatory
UserLocationInformation* userLocationInformation; // Optional
std::optional<UserLocationInformation> userLocationInformation; // Optional
// TODO: Information on Recommended Cells and RAN Nodes for Paging (Optional)
std::optional<PDUSessionResourceListCxtRelCpl>
pduSessionResourceListCxtRelCpl; // Optional
......
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