Commit 2e6fbced authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Polish the code

parent 3aa1f3c6
...@@ -234,7 +234,7 @@ void amf_n11::handle_itti_message( ...@@ -234,7 +234,7 @@ void amf_n11::handle_itti_message(
remote_uri, json_part, "", n2SmMsg, supi, itti_msg.pdu_session_id, remote_uri, json_part, "", n2SmMsg, supi, itti_msg.pdu_session_id,
itti_msg.promise_id); itti_msg.promise_id);
stacs.display(); // stacs.display();
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
......
...@@ -1131,7 +1131,7 @@ bool amf_n2::handle_itti_message(itti_handover_required& itti_msg) { ...@@ -1131,7 +1131,7 @@ bool amf_n2::handle_itti_message(itti_handover_required& itti_msg) {
gc = assoc_id_2_gnb_context(itti_msg.assoc_id); gc = assoc_id_2_gnb_context(itti_msg.assoc_id);
Logger::amf_n2().debug( Logger::amf_n2().debug(
"Handover Required, gNB info (gNB Name: %s, globalRanNodeId %ld)", "Handover Required, gNB info (gNB Name %s, globalRanNodeId 0x%x)",
gc.get()->gnb_name.c_str(), gc.get()->globalRanNodeId); gc.get()->gnb_name.c_str(), gc.get()->globalRanNodeId);
std::shared_ptr<ue_ngap_context> unc = {}; std::shared_ptr<ue_ngap_context> unc = {};
...@@ -1144,7 +1144,7 @@ bool amf_n2::handle_itti_message(itti_handover_required& itti_msg) { ...@@ -1144,7 +1144,7 @@ bool amf_n2::handle_itti_message(itti_handover_required& itti_msg) {
if (unc.get()->amf_ue_ngap_id != amf_ue_ngap_id) { if (unc.get()->amf_ue_ngap_id != amf_ue_ngap_id) {
Logger::amf_n2().error( Logger::amf_n2().error(
"The requested UE (amf_ue_ngap_id:0x%x) is not valid, existed UE " "The requested UE (amf_ue_ngap_id 0x%x) is not valid, existed UE "
"with amf_ue_ngap_id (0x%x)", "with amf_ue_ngap_id (0x%x)",
amf_ue_ngap_id, unc.get()->amf_ue_ngap_id); amf_ue_ngap_id, unc.get()->amf_ue_ngap_id);
return false; return false;
...@@ -1156,7 +1156,7 @@ bool amf_n2::handle_itti_message(itti_handover_required& itti_msg) { ...@@ -1156,7 +1156,7 @@ bool amf_n2::handle_itti_message(itti_handover_required& itti_msg) {
} }
Logger::amf_n2().debug( Logger::amf_n2().debug(
"Cause, Choice of Cause %d, Cause %ld", "Handover Required, Choice of Cause %d, Cause %ld",
(int) itti_msg.handoverReq->getChoiceOfCause(), (int) itti_msg.handoverReq->getChoiceOfCause(),
itti_msg.handoverReq->getCauseValue()); itti_msg.handoverReq->getCauseValue());
...@@ -1182,7 +1182,7 @@ bool amf_n2::handle_itti_message(itti_handover_required& itti_msg) { ...@@ -1182,7 +1182,7 @@ bool amf_n2::handle_itti_message(itti_handover_required& itti_msg) {
*/ */
Logger::amf_n2().debug( Logger::amf_n2().debug(
"DirectForwardingPathAvailability %d", "Handover Required, DirectForwardingPathAvailability %d",
itti_msg.handoverReq->getDirectForwardingPathAvailability()); itti_msg.handoverReq->getDirectForwardingPathAvailability());
unc.get()->gnb_assoc_id = itti_msg.assoc_id; unc.get()->gnb_assoc_id = itti_msg.assoc_id;
...@@ -1200,8 +1200,8 @@ bool amf_n2::handle_itti_message(itti_handover_required& itti_msg) { ...@@ -1200,8 +1200,8 @@ bool amf_n2::handle_itti_message(itti_handover_required& itti_msg) {
plmn->getMnc(mnc); plmn->getMnc(mnc);
Logger::amf_n2().debug( Logger::amf_n2().debug(
"Handover Required: Target ID GlobalRanNodeID PLmn (mcc: %s, mnc: %s, " "Handover Required, Target ID GlobalRanNodeID PLmn (MCC %s, MNC %s, "
"gnbid: %ld)", "gNBId 0x%x)",
mcc.c_str(), mnc.c_str(), gnbid->getValue()); mcc.c_str(), mnc.c_str(), gnbid->getValue());
TAI* tai = new TAI(); TAI* tai = new TAI();
...@@ -1214,7 +1214,7 @@ bool amf_n2::handle_itti_message(itti_handover_required& itti_msg) { ...@@ -1214,7 +1214,7 @@ bool amf_n2::handle_itti_message(itti_handover_required& itti_msg) {
plmn->getMcc(mccOfselectTAI); plmn->getMcc(mccOfselectTAI);
plmn->getMnc(mncOfselectTAI); plmn->getMnc(mncOfselectTAI);
Logger::amf_n2().debug( Logger::amf_n2().debug(
"Handover Required: Target ID selected TAI PLMN (mcc %s, mnc %s, tac %x)", "Handover Required: Target ID selected TAI PLMN (MCC %s, MNC %s, TAC %x)",
mccOfselectTAI.c_str(), mncOfselectTAI.c_str(), tac->getTac()); mccOfselectTAI.c_str(), mncOfselectTAI.c_str(), tac->getTac());
OCTET_STRING_t sourceTotarget; OCTET_STRING_t sourceTotarget;
...@@ -1282,7 +1282,8 @@ bool amf_n2::handle_itti_message(itti_handover_required& itti_msg) { ...@@ -1282,7 +1282,8 @@ bool amf_n2::handle_itti_message(itti_handover_required& itti_msg) {
uint8_t* kamf = nc.get()->kamf[secu->vector_pointer]; uint8_t* kamf = nc.get()->kamf[secu->vector_pointer];
uint8_t kgnb[32]; uint8_t kgnb[32];
uint32_t ulcount = secu->ul_count.seq_num | (secu->ul_count.overflow << 8); uint32_t ulcount = secu->ul_count.seq_num | (secu->ul_count.overflow << 8);
Logger::amf_n2().debug("Uplink count (%d)", secu->ul_count.seq_num); Logger::amf_n2().debug(
"Handover Required, Uplink count (%d)", secu->ul_count.seq_num);
uint8_t knh[32]; uint8_t knh[32];
Authentication_5gaka::handover_ncc_derive_knh( Authentication_5gaka::handover_ncc_derive_knh(
ulcount, 0x01, kamf, kgnb, knh, unc.get()->ncc); ulcount, 0x01, kamf, kgnb, knh, unc.get()->ncc);
...@@ -1414,7 +1415,6 @@ bool amf_n2::handle_itti_message(itti_handover_required& itti_msg) { ...@@ -1414,7 +1415,6 @@ bool amf_n2::handle_itti_message(itti_handover_required& itti_msg) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void amf_n2::handle_itti_message(itti_handover_request_Ack& itti_msg) { void amf_n2::handle_itti_message(itti_handover_request_Ack& itti_msg) {
// TODO: Experimental procedure, to be tested
Logger::amf_n2().debug("Handling Handover Request Ack ..."); Logger::amf_n2().debug("Handling Handover Request Ack ...");
unsigned long amf_ue_ngap_id = itti_msg.handoverrequestAck->getAmfUeNgapId(); unsigned long amf_ue_ngap_id = itti_msg.handoverrequestAck->getAmfUeNgapId();
uint32_t ran_ue_ngap_id = itti_msg.handoverrequestAck->getRanUeNgapId(); uint32_t ran_ue_ngap_id = itti_msg.handoverrequestAck->getRanUeNgapId();
...@@ -1429,6 +1429,9 @@ void amf_n2::handle_itti_message(itti_handover_request_Ack& itti_msg) { ...@@ -1429,6 +1429,9 @@ void amf_n2::handle_itti_message(itti_handover_request_Ack& itti_msg) {
return; return;
} }
gc = assoc_id_2_gnb_context(itti_msg.assoc_id); gc = assoc_id_2_gnb_context(itti_msg.assoc_id);
Logger::amf_n2().debug(
"Handover Request Ack, gNB info (gNB Name %s, globalRanNodeId 0x%x)",
gc.get()->gnb_name.c_str(), gc.get()->globalRanNodeId);
std::shared_ptr<ue_ngap_context> unc = {}; std::shared_ptr<ue_ngap_context> unc = {};
if (!is_amf_ue_id_2_ue_ngap_context(amf_ue_ngap_id)) { if (!is_amf_ue_id_2_ue_ngap_context(amf_ue_ngap_id)) {
...@@ -1446,41 +1449,43 @@ void amf_n2::handle_itti_message(itti_handover_request_Ack& itti_msg) { ...@@ -1446,41 +1449,43 @@ void amf_n2::handle_itti_message(itti_handover_request_Ack& itti_msg) {
return; return;
} }
OCTET_STRING_t targetTosource; OCTET_STRING_t targetTosource =
targetTosource =
itti_msg.handoverrequestAck->getTargetToSource_TransparentContainer(); itti_msg.handoverrequestAck->getTargetToSource_TransparentContainer();
/*
PDUSessionResourceHandoverRequestAckTransfer* PDUHandoverRequestAckTransfer
= new PDUSessionResourceHandoverRequestAckTransfer(); uint8_t
buf[BUFFER_SIZE_1024];
memcpy(
buf, list[0].handoverRequestAcknowledgeTransfer.buf,
list[0].handoverRequestAcknowledgeTransfer.size);
if (!PDUHandoverRequestAckTransfer->decodefromHandoverRequestAckTransfer(
buf, list[0].handoverRequestAcknowledgeTransfer.size)) {
Logger::ngap().error("Decode Handover Request Acknowledge Transfer
error"); return;
}
PDUSessionResourceHandoverRequestAckTransfer* PDUHandoverRequestAckTransfer = GtpTunnel_t* gtpTunnel = new GtpTunnel_t();
new PDUSessionResourceHandoverRequestAckTransfer(); if (!PDUHandoverRequestAckTransfer->getUpTransportLayerInformation2(
uint8_t buf[BUFFER_SIZE_1024]; gtpTunnel)) {
Logger::ngap().error("Decode GTPTunnel error");
memcpy( return;
buf, list[0].handoverRequestAcknowledgeTransfer.buf, }
list[0].handoverRequestAcknowledgeTransfer.size);
if (!PDUHandoverRequestAckTransfer->decodefromHandoverRequestAckTransfer(
buf, list[0].handoverRequestAcknowledgeTransfer.size)) {
Logger::ngap().error("Decode Handover Request Acknowledge Transfer error");
return;
}
GtpTunnel_t* gtptunnel = new GtpTunnel_t();
if (!PDUHandoverRequestAckTransfer->getUpTransportLayerInformation2(
gtptunnel)) {
Logger::ngap().error("Decode GTPTunnel error");
return;
}
string n3_ip_address = {}; string n3_ip_address = {};
uint32_t teid = 0; uint32_t teid = 0;
n3_ip_address = gtptunnel->ip_address; n3_ip_address = gtpTunnel->ip_address;
teid = gtptunnel->gtp_teid; teid = gtpTunnel->gtp_teid;
std::vector<QosFlowLItemWithDataForwarding_t> QosFlowWithDataForwardinglist; std::vector<QosFlowLItemWithDataForwarding_t> QosFlowWithDataForwardinglist;
PDUHandoverRequestAckTransfer->getqosFlowSetupResponseList( PDUHandoverRequestAckTransfer->getqosFlowSetupResponseList(
QosFlowWithDataForwardinglist); QosFlowWithDataForwardinglist);
long qosflowidentifiervalue = 0; long qosflowidentifiervalue = 0;
qosflowidentifiervalue = //TODO: process QosFlowWithDataForwardinglist
(long) QosFlowWithDataForwardinglist[0].qosFlowIdentifier; qosflowidentifiervalue =
Logger::ngap().debug("QFI %lu", qosflowidentifiervalue); (long) QosFlowWithDataForwardinglist[0].qosFlowIdentifier;
Logger::ngap().debug("Handover Req Ack, QoS Flow Setup Response List, QFI
%lu", qosflowidentifiervalue);
*/
std::shared_ptr<nas_context> nc = std::shared_ptr<nas_context> nc =
amf_n1_inst->amf_ue_id_2_nas_context(amf_ue_ngap_id); amf_n1_inst->amf_ue_id_2_nas_context(amf_ue_ngap_id);
...@@ -1528,7 +1533,7 @@ void amf_n2::handle_itti_message(itti_handover_request_Ack& itti_msg) { ...@@ -1528,7 +1533,7 @@ void amf_n2::handle_itti_message(itti_handover_request_Ack& itti_msg) {
} }
} }
// send HandoverCommandMsg to Source gnb // send HandoverCommandMsg to Source gNB
std::unique_ptr<HandoverCommandMsg> handovercommand = std::unique_ptr<HandoverCommandMsg> handovercommand =
std::make_unique<HandoverCommandMsg>(); std::make_unique<HandoverCommandMsg>();
handovercommand->setMessageType(); handovercommand->setMessageType();
...@@ -1580,35 +1585,6 @@ void amf_n2::handle_itti_message(itti_handover_request_Ack& itti_msg) { ...@@ -1580,35 +1585,6 @@ void amf_n2::handle_itti_message(itti_handover_request_Ack& itti_msg) {
} }
curl_responses.erase(curl_responses.begin()); curl_responses.erase(curl_responses.begin());
} }
/*
item.pduSessionId = list[0].pduSessionId;
// qosFLowtobeforwardedlist
std::vector<QosFlowToBeForwardedItem_t> forward_list;
QosFlowToBeForwardedItem_t forward_item;
forward_item.QFI = qosflowidentifiervalue;
forward_list.push_back(forward_item);
// set dlforwardingup_tnlinformation
// TransportLayerAddress *transportlayeraddress = new
TransportLayerAddress();
// transportlayeraddress->setTransportLayerAddress(n3_ip_address);
// GtpTeid *gtpTeid = new GtpTeid();
// gtpTeid->setGtpTeid(teid);
PDUSessionResourceHandoverCommandTransfer* handovercommandtransfer =
new PDUSessionResourceHandoverCommandTransfer();
handovercommandtransfer->setQosFlowToBeForwardedList(forward_list);
GtpTunnel_t uptlinfo = {};
uptlinfo.gtp_teid = teid;
uptlinfo.ip_address = n3_ip_address;
handovercommandtransfer->setUPTransportLayerInformation(uptlinfo);
uint8_t buffer_ho_cmd_transfer[BUFFER_SIZE_512];
int encoded_size =
handovercommandtransfer->encodePDUSessionResourceHandoverCommandTransfer(
buffer_ho_cmd_transfer, BUFFER_SIZE_512);
item.HandoverCommandTransfer.buf = buffer_ho_cmd_transfer;
item.HandoverCommandTransfer.size = encoded_size;
handover_list.push_back(item);
*/
handovercommand->setPduSessionResourceHandoverList(handover_list); handovercommand->setPduSessionResourceHandoverList(handover_list);
handovercommand->setTargetToSource_TransparentContainer(targetTosource); handovercommand->setTargetToSource_TransparentContainer(targetTosource);
...@@ -1622,7 +1598,6 @@ void amf_n2::handle_itti_message(itti_handover_request_Ack& itti_msg) { ...@@ -1622,7 +1598,6 @@ void amf_n2::handle_itti_message(itti_handover_request_Ack& itti_msg) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void amf_n2::handle_itti_message(itti_handover_notify& itti_msg) { void amf_n2::handle_itti_message(itti_handover_notify& itti_msg) {
// TODO: Experimental procedure, to be tested
Logger::amf_n2().info("Handle Handover Notify ..."); Logger::amf_n2().info("Handle Handover Notify ...");
unsigned long amf_ue_ngap_id = itti_msg.handovernotify->getAmfUeNgapId(); unsigned long amf_ue_ngap_id = itti_msg.handovernotify->getAmfUeNgapId();
uint32_t ran_ue_ngap_id = itti_msg.handovernotify->getRanUeNgapId(); uint32_t ran_ue_ngap_id = itti_msg.handovernotify->getRanUeNgapId();
...@@ -1638,7 +1613,7 @@ void amf_n2::handle_itti_message(itti_handover_notify& itti_msg) { ...@@ -1638,7 +1613,7 @@ void amf_n2::handle_itti_message(itti_handover_notify& itti_msg) {
} }
gc = assoc_id_2_gnb_context(itti_msg.assoc_id); gc = assoc_id_2_gnb_context(itti_msg.assoc_id);
Logger::amf_n2().debug( Logger::amf_n2().debug(
"Handover Notify, gNB info (gNB Name: %s, globalRanNodeId %ld)", "Handover Notify, gNB info (gNB Name: %s, globalRanNodeId 0x%x)",
gc.get()->gnb_name.c_str(), gc.get()->globalRanNodeId); gc.get()->gnb_name.c_str(), gc.get()->globalRanNodeId);
std::shared_ptr<ue_ngap_context> unc = {}; std::shared_ptr<ue_ngap_context> unc = {};
......
...@@ -53,8 +53,8 @@ class ue_ngap_context { ...@@ -53,8 +53,8 @@ class ue_ngap_context {
sctp_stream_id_t sctp_stream_recv; // used to decide which ue in gNB sctp_stream_id_t sctp_stream_recv; // used to decide which ue in gNB
sctp_stream_id_t sctp_stream_send; // used to decide which ue in gNB sctp_stream_id_t sctp_stream_send; // used to decide which ue in gNB
sctp_assoc_id_t gnb_assoc_id; // to find which gnb this UE belongs to sctp_assoc_id_t gnb_assoc_id; // to find which gnb this UE belongs to
sctp_assoc_id_t target_gnb_assoc_id; sctp_assoc_id_t target_gnb_assoc_id; // for HO
bool ueContextRequest; bool ueContextRequest;
uint32_t s_tmsi_5g; uint32_t s_tmsi_5g;
......
...@@ -89,11 +89,11 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -89,11 +89,11 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
handoverCommandIEs = &handoverCommandPdu->choice.successfulOutcome->value handoverCommandIEs = &handoverCommandPdu->choice.successfulOutcome->value
.choice.HandoverCommand; .choice.HandoverCommand;
} else { } else {
Logger::ngap().error("Check HandoverCommand message error"); Logger::ngap().error("Check Handover Command message error");
return false; return false;
} }
} else { } else {
Logger::ngap().error("HandoverRequired MessageType error"); Logger::ngap().error("Handover Command MessageType error");
return false; return false;
} }
for (int i = 0; i < handoverCommandIEs->protocolIEs.list.count; i++) { for (int i = 0; i < handoverCommandIEs->protocolIEs.list.count; i++) {
...@@ -107,11 +107,11 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -107,11 +107,11 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!amfUeNgapId->decodefromAMF_UE_NGAP_ID( if (!amfUeNgapId->decodefromAMF_UE_NGAP_ID(
handoverCommandIEs->protocolIEs.list.array[i] handoverCommandIEs->protocolIEs.list.array[i]
->value.choice.AMF_UE_NGAP_ID)) { ->value.choice.AMF_UE_NGAP_ID)) {
Logger::ngap().error("Decoded ngap AMF_UE_NGAP_ID IE error"); Logger::ngap().error("Decoded NGAP AMF_UE_NGAP_ID IE error");
return false; return false;
} }
} else { } else {
Logger::ngap().error("Decoded ngap AMF_UE_NGAP_ID IE error"); Logger::ngap().error("Decoded NGAP AMF_UE_NGAP_ID IE error");
return false; return false;
} }
} break; } break;
...@@ -124,11 +124,11 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -124,11 +124,11 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!ranUeNgapId->decodefromRAN_UE_NGAP_ID( if (!ranUeNgapId->decodefromRAN_UE_NGAP_ID(
handoverCommandIEs->protocolIEs.list.array[i] handoverCommandIEs->protocolIEs.list.array[i]
->value.choice.RAN_UE_NGAP_ID)) { ->value.choice.RAN_UE_NGAP_ID)) {
Logger::ngap().error("Decoded ngap RAN_UE_NGAP_ID IE error"); Logger::ngap().error("Decoded NGAP RAN_UE_NGAP_ID IE error");
return false; return false;
} }
} else { } else {
Logger::ngap().error("Decoded ngap RAN_UE_NGAP_ID IE error"); Logger::ngap().error("Decoded NGAP RAN_UE_NGAP_ID IE error");
return false; return false;
} }
} break; } break;
...@@ -141,7 +141,7 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -141,7 +141,7 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
*ngap_handovertype = handoverCommandIEs->protocolIEs.list.array[i] *ngap_handovertype = handoverCommandIEs->protocolIEs.list.array[i]
->value.choice.HandoverType; ->value.choice.HandoverType;
} else { } else {
Logger::ngap().error("Decoded ngap Handover Type IE error"); Logger::ngap().error("Decoded NGAP Handover Type IE error");
return false; return false;
} }
} break; } break;
...@@ -152,7 +152,7 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -152,7 +152,7 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
Ngap_HandoverCommandIEs__value_PR_PDUSessionResourceHandoverList) { Ngap_HandoverCommandIEs__value_PR_PDUSessionResourceHandoverList) {
} else { } else {
Logger::ngap().error( Logger::ngap().error(
"Decoded ngap PDUSessionResourceHandoverList IE error"); "Decoded NGAP PDUSessionResourceHandoverList IE error");
return false; return false;
} }
} break; } break;
...@@ -163,7 +163,7 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -163,7 +163,7 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
Ngap_HandoverCommandIEs__value_PR_PDUSessionResourceToReleaseListHOCmd) { Ngap_HandoverCommandIEs__value_PR_PDUSessionResourceToReleaseListHOCmd) {
} else { } else {
Logger::ngap().error( Logger::ngap().error(
"Decoded ngap PDUSessionResourceToReleaseListHOCmd IE error"); "Decoded NGAP PDUSessionResourceToReleaseListHOCmd IE error");
return false; return false;
} }
} break; } break;
...@@ -174,7 +174,7 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -174,7 +174,7 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
Ngap_HandoverCommandIEs__value_PR_TargetToSource_TransparentContainer) { Ngap_HandoverCommandIEs__value_PR_TargetToSource_TransparentContainer) {
} else { } else {
Logger::ngap().error( Logger::ngap().error(
"Decoded ngap TargetToSource_TransparentContainer IE error"); "Decoded NGAP TargetToSource_TransparentContainer IE error");
return false; return false;
} }
} break; } break;
...@@ -184,7 +184,7 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -184,7 +184,7 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
handoverCommandIEs->protocolIEs.list.array[i]->value.present == handoverCommandIEs->protocolIEs.list.array[i]->value.present ==
Ngap_HandoverCommandIEs__value_PR_CriticalityDiagnostics) { Ngap_HandoverCommandIEs__value_PR_CriticalityDiagnostics) {
} else { } else {
Logger::ngap().error("Decoded ngap CriticalityDiagnostics IE error"); Logger::ngap().error("Decoded NGAP CriticalityDiagnostics IE error");
return false; return false;
} }
} break; } break;
...@@ -203,7 +203,8 @@ int HandoverCommandMsg::encode2buffer(uint8_t* buf, int buf_size) { ...@@ -203,7 +203,8 @@ int HandoverCommandMsg::encode2buffer(uint8_t* buf, int buf_size) {
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, handoverCommandPdu); asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, handoverCommandPdu);
asn_enc_rval_t er = aper_encode_to_buffer( asn_enc_rval_t er = aper_encode_to_buffer(
&asn_DEF_Ngap_NGAP_PDU, NULL, handoverCommandPdu, buf, buf_size); &asn_DEF_Ngap_NGAP_PDU, NULL, handoverCommandPdu, buf, buf_size);
Logger::ngap().debug("er.encoded( %d )", er.encoded); Logger::ngap().debug(
"Encode Handover Command to buffer, er.encoded( %d )", er.encoded);
return er.encoded; return er.encoded;
} }
...@@ -230,7 +231,7 @@ void HandoverCommandMsg::setMessageType() { ...@@ -230,7 +231,7 @@ void HandoverCommandMsg::setMessageType() {
.choice.HandoverCommand); .choice.HandoverCommand);
} else { } else {
Logger::ngap().warn( Logger::ngap().warn(
"This information doesn't refer to HandoverCommand message"); "This information doesn't refer to Handover Command message");
} }
} }
......
...@@ -74,7 +74,8 @@ int HandoverNotifyMsg::encode2buffer(uint8_t* buf, int buf_size) { ...@@ -74,7 +74,8 @@ int HandoverNotifyMsg::encode2buffer(uint8_t* buf, int buf_size) {
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, handoverNotifyPdu); asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, handoverNotifyPdu);
asn_enc_rval_t er = aper_encode_to_buffer( asn_enc_rval_t er = aper_encode_to_buffer(
&asn_DEF_Ngap_NGAP_PDU, NULL, handoverNotifyPdu, buf, buf_size); &asn_DEF_Ngap_NGAP_PDU, NULL, handoverNotifyPdu, buf, buf_size);
Logger::ngap().debug("er.encoded( %d )", er.encoded); Logger::ngap().debug(
"Encode Handover Notify to buffer, er.encoded( %d )", er.encoded);
return er.encoded; return er.encoded;
} }
......
...@@ -172,7 +172,9 @@ int HandoverPreparationFailure::encode2buffer(uint8_t* buf, int buf_size) { ...@@ -172,7 +172,9 @@ int HandoverPreparationFailure::encode2buffer(uint8_t* buf, int buf_size) {
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, hoPreparationFailurePdu); asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, hoPreparationFailurePdu);
asn_enc_rval_t er = aper_encode_to_buffer( asn_enc_rval_t er = aper_encode_to_buffer(
&asn_DEF_Ngap_NGAP_PDU, NULL, hoPreparationFailurePdu, buf, buf_size); &asn_DEF_Ngap_NGAP_PDU, NULL, hoPreparationFailurePdu, buf, buf_size);
Logger::ngap().debug("er.encoded( %d )", er.encoded); Logger::ngap().debug(
"Encode Handover Preparation Failure to buffer, er.encoded( %d )",
er.encoded);
return er.encoded; return er.encoded;
} }
...@@ -260,7 +262,7 @@ void HandoverPreparationFailure::setRanUeNgapId(uint32_t ran_ue_ngap_id) { ...@@ -260,7 +262,7 @@ void HandoverPreparationFailure::setRanUeNgapId(uint32_t ran_ue_ngap_id) {
void HandoverPreparationFailure::setCause( void HandoverPreparationFailure::setCause(
Ngap_Cause_PR m_causePresent, long value) // Ngap_Cause_PR m_causePresent, long value) //
{ {
if (!cause) cause = new Cause; if (!cause) cause = new Cause();
Ngap_HandoverPreparationFailureIEs_t* ie = Ngap_HandoverPreparationFailureIEs_t* ie =
(Ngap_HandoverPreparationFailureIEs_t*) calloc( (Ngap_HandoverPreparationFailureIEs_t*) calloc(
1, sizeof(Ngap_HandoverPreparationFailureIEs_t)); 1, sizeof(Ngap_HandoverPreparationFailureIEs_t));
......
...@@ -229,7 +229,8 @@ int HandoverRequest::encode2buffer(uint8_t* buf, int buf_size) { ...@@ -229,7 +229,8 @@ int HandoverRequest::encode2buffer(uint8_t* buf, int buf_size) {
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, handoverRequestPdu); asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, handoverRequestPdu);
asn_enc_rval_t er = aper_encode_to_buffer( asn_enc_rval_t er = aper_encode_to_buffer(
&asn_DEF_Ngap_NGAP_PDU, NULL, handoverRequestPdu, buf, buf_size); &asn_DEF_Ngap_NGAP_PDU, NULL, handoverRequestPdu, buf, buf_size);
Logger::ngap().debug("er.encoded( %d )", er.encoded); Logger::ngap().debug(
"Encode Handover Request to buffer, er.encoded( %d)", er.encoded);
return er.encoded; return er.encoded;
} }
...@@ -302,7 +303,7 @@ void HandoverRequest::setHandoverType(long type) // 0--intra5gs ...@@ -302,7 +303,7 @@ void HandoverRequest::setHandoverType(long type) // 0--intra5gs
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void HandoverRequest::setCause(Ngap_Cause_PR m_causePresent, long value) // void HandoverRequest::setCause(Ngap_Cause_PR m_causePresent, long value) //
{ {
if (!cause) cause = new Cause; if (!cause) cause = new Cause();
Ngap_HandoverRequestIEs_t* ie = Ngap_HandoverRequestIEs_t* ie =
(Ngap_HandoverRequestIEs_t*) calloc(1, sizeof(Ngap_HandoverRequestIEs_t)); (Ngap_HandoverRequestIEs_t*) calloc(1, sizeof(Ngap_HandoverRequestIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_Cause; ie->id = Ngap_ProtocolIE_ID_id_Cause;
......
...@@ -242,7 +242,8 @@ int HandoverRequestAck::encode2buffer(uint8_t* buf, int buf_size) { ...@@ -242,7 +242,8 @@ int HandoverRequestAck::encode2buffer(uint8_t* buf, int buf_size) {
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, handoverRequestAckPdu); asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, handoverRequestAckPdu);
asn_enc_rval_t er = aper_encode_to_buffer( asn_enc_rval_t er = aper_encode_to_buffer(
&asn_DEF_Ngap_NGAP_PDU, NULL, handoverRequestAckPdu, buf, buf_size); &asn_DEF_Ngap_NGAP_PDU, NULL, handoverRequestAckPdu, buf, buf_size);
Logger::ngap().debug("er.encoded( %d )", er.encoded); Logger::ngap().debug(
"Encode Handover Request Ack to buffer, er.encoded( %d )", er.encoded);
return er.encoded; return er.encoded;
} }
......
...@@ -326,7 +326,8 @@ int HandoverRequiredMsg::encode2buffer(uint8_t* buf, int buf_size) { ...@@ -326,7 +326,8 @@ int HandoverRequiredMsg::encode2buffer(uint8_t* buf, int buf_size) {
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, handoverRequiredPdu); asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, handoverRequiredPdu);
asn_enc_rval_t er = aper_encode_to_buffer( asn_enc_rval_t er = aper_encode_to_buffer(
&asn_DEF_Ngap_NGAP_PDU, NULL, handoverRequiredPdu, buf, buf_size); &asn_DEF_Ngap_NGAP_PDU, NULL, handoverRequiredPdu, buf, buf_size);
Logger::ngap().debug("er.encoded( %d )", er.encoded); Logger::ngap().debug(
"Encode Handover Required to buffer, er.encoded( %d)", er.encoded);
return er.encoded; return er.encoded;
} }
......
...@@ -30,30 +30,37 @@ ...@@ -30,30 +30,37 @@
#include "logger.hpp" #include "logger.hpp"
extern "C" { extern "C" {
#include "asn_codecs.h" //#include "asn_codecs.h"
#include "constr_TYPE.h" //#include "constr_TYPE.h"
#include "constraints.h" //#include "constraints.h"
#include "dynamic_memory_check.h" #include "dynamic_memory_check.h"
#include "per_decoder.h" #include "per_decoder.h"
#include "per_encoder.h" #include "per_encoder.h"
} }
#include <iostream> #include <iostream>
using namespace std; // using namespace std;
namespace ngap { namespace ngap {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
InitialContextSetupFailureMsg::InitialContextSetupFailureMsg() { InitialContextSetupFailureMsg::InitialContextSetupFailureMsg() {
initialContextSetupFailurePdu = NULL; initialContextSetupFailurePdu = nullptr;
initialContextSetupFailureIEs = NULL; initialContextSetupFailureIEs = nullptr;
amfUeNgapId = NULL; amfUeNgapId = nullptr;
ranUeNgapId = NULL; ranUeNgapId = nullptr;
pduSessionResourceFailedToSetupFailureList = NULL; pduSessionResourceFailedToSetupFailureList = nullptr;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
InitialContextSetupFailureMsg::~InitialContextSetupFailureMsg() {} InitialContextSetupFailureMsg::~InitialContextSetupFailureMsg() {
if (initialContextSetupFailurePdu) free(initialContextSetupFailurePdu);
if (initialContextSetupFailureIEs) free(initialContextSetupFailureIEs);
if (amfUeNgapId) free(amfUeNgapId);
if (ranUeNgapId) free(ranUeNgapId);
if (pduSessionResourceFailedToSetupFailureList)
free(pduSessionResourceFailedToSetupFailureList);
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void InitialContextSetupFailureMsg::setMessageType() { void InitialContextSetupFailureMsg::setMessageType() {
...@@ -199,7 +206,6 @@ int InitialContextSetupFailureMsg::encode2buffer(uint8_t* buf, int buf_size) { ...@@ -199,7 +206,6 @@ int InitialContextSetupFailureMsg::encode2buffer(uint8_t* buf, int buf_size) {
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Decapsulation
bool InitialContextSetupFailureMsg::decodefrompdu( bool InitialContextSetupFailureMsg::decodefrompdu(
Ngap_NGAP_PDU_t* ngap_msg_pdu) { Ngap_NGAP_PDU_t* ngap_msg_pdu) {
initialContextSetupFailurePdu = ngap_msg_pdu; initialContextSetupFailurePdu = ngap_msg_pdu;
......
...@@ -55,7 +55,6 @@ class InitialContextSetupFailureMsg { ...@@ -55,7 +55,6 @@ class InitialContextSetupFailureMsg {
std::vector<PDUSessionResourceFailedToSetupItem_t> list); std::vector<PDUSessionResourceFailedToSetupItem_t> list);
int encode2buffer(uint8_t* buf, int buf_size); int encode2buffer(uint8_t* buf, int buf_size);
// Decapsulation
bool decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu); bool decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu);
unsigned long getAmfUeNgapId(); unsigned long getAmfUeNgapId();
uint32_t getRanUeNgapId(); uint32_t getRanUeNgapId();
......
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