Commit 6a3fef00 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Code cleanup for N2 handover

parent e324c6f5
......@@ -20,6 +20,8 @@
*/
#include "HandoverCommandMsg.hpp"
#include "logger.hpp"
extern "C" {
#include "Ngap_NGAP-PDU.h"
#include "Ngap_PDUSessionResourceHandoverItem.h"
......@@ -53,14 +55,15 @@ HandoverCommandMsg::HandoverCommandMsg() {
HandoverCommandMsg::~HandoverCommandMsg() {}
unsigned long HandoverCommandMsg::getAmfUeNgapId() {
return amfUeNgapId->getAMF_UE_NGAP_ID();
if (amfUeNgapId) return amfUeNgapId->getAMF_UE_NGAP_ID();
}
uint32_t HandoverCommandMsg::getRanUeNgapId() {
return ranUeNgapId->getRanUeNgapId();
if (ranUeNgapId) return ranUeNgapId->getRanUeNgapId();
}
bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!ngap_msg_pdu) return false;
handoverCommandPdu = ngap_msg_pdu;
if (handoverCommandPdu->present == Ngap_NGAP_PDU_PR_successfulOutcome) {
......@@ -74,11 +77,11 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
handoverCommandIEs = &handoverCommandPdu->choice.successfulOutcome->value
.choice.HandoverCommand;
} else {
cout << "Check HandoverCommand message error!!!" << endl;
Logger::ngap().error("Check HandoverCommand message error");
return false;
}
} else {
cout << "HandoverRequired MessageType error!!!" << endl;
Logger::ngap().error("HandoverRequired MessageType error");
return false;
}
for (int i = 0; i < handoverCommandIEs->protocolIEs.list.count; i++) {
......@@ -92,11 +95,11 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!amfUeNgapId->decodefromAMF_UE_NGAP_ID(
handoverCommandIEs->protocolIEs.list.array[i]
->value.choice.AMF_UE_NGAP_ID)) {
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl;
Logger::ngap().error("Decoded ngap AMF_UE_NGAP_ID IE error");
return false;
}
} else {
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl;
Logger::ngap().error("Decoded ngap AMF_UE_NGAP_ID IE error");
return false;
}
} break;
......@@ -109,11 +112,11 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!ranUeNgapId->decodefromRAN_UE_NGAP_ID(
handoverCommandIEs->protocolIEs.list.array[i]
->value.choice.RAN_UE_NGAP_ID)) {
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl;
Logger::ngap().error("Decoded ngap RAN_UE_NGAP_ID IE error");
return false;
}
} else {
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl;
Logger::ngap().error("Decoded ngap RAN_UE_NGAP_ID IE error");
return false;
}
} break;
......@@ -126,7 +129,7 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
*ngap_handovertype = handoverCommandIEs->protocolIEs.list.array[i]
->value.choice.HandoverType;
} else {
cout << "decoded ngap Handover Type IE error" << endl;
Logger::ngap().error("Decoded ngap Handover Type IE error");
return false;
}
} break;
......@@ -136,8 +139,8 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
handoverCommandIEs->protocolIEs.list.array[i]->value.present ==
Ngap_HandoverCommandIEs__value_PR_PDUSessionResourceHandoverList) {
} else {
cout << "decoded ngap PDUSessionResourceHandoverList IE error"
<< endl;
Logger::ngap().error(
"Decoded ngap PDUSessionResourceHandoverList IE error");
return false;
}
} break;
......@@ -147,8 +150,8 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
handoverCommandIEs->protocolIEs.list.array[i]->value.present ==
Ngap_HandoverCommandIEs__value_PR_PDUSessionResourceToReleaseListHOCmd) {
} else {
cout << "decoded ngap PDUSessionResourceToReleaseListHOCmd IE error"
<< endl;
Logger::ngap().error(
"Decoded ngap PDUSessionResourceToReleaseListHOCmd IE error");
return false;
}
} break;
......@@ -158,8 +161,8 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
handoverCommandIEs->protocolIEs.list.array[i]->value.present ==
Ngap_HandoverCommandIEs__value_PR_TargetToSource_TransparentContainer) {
} else {
cout << "decoded ngap TargetToSource_TransparentContainer IE error"
<< endl;
Logger::ngap().error(
"Decoded ngap TargetToSource_TransparentContainer IE error");
return false;
}
} break;
......@@ -169,12 +172,12 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
handoverCommandIEs->protocolIEs.list.array[i]->value.present ==
Ngap_HandoverCommandIEs__value_PR_CriticalityDiagnostics) {
} else {
cout << "decoded ngap CriticalityDiagnostics IE error" << endl;
Logger::ngap().error("Decoded ngap CriticalityDiagnostics IE error");
return false;
}
} break;
default: {
cout << "decoded ngap message pdu error" << endl;
Logger::ngap().error("Decoded NGAP message PDU error");
return false;
}
}
......@@ -212,9 +215,8 @@ void HandoverCommandMsg::setMessageType() {
handoverCommandIEs = &(handoverCommandPdu->choice.successfulOutcome->value
.choice.HandoverCommand);
} else {
cout << "[warning] This information doesn't refer to HandoverCommand "
"Message!!!"
<< endl;
Logger::ngap().warn(
"This information doesn't refer to HandoverCommand message");
}
}
......@@ -230,13 +232,13 @@ void HandoverCommandMsg::setAmfUeNgapId(unsigned long id) {
int ret = amfUeNgapId->encode2AMF_UE_NGAP_ID(ie->value.choice.AMF_UE_NGAP_ID);
if (!ret) {
cout << "encode AMF_UE_NGAP_ID IE error" << endl;
Logger::ngap().error("Encode AMF_UE_NGAP_ID IE error");
free_wrapper((void**) &ie);
return;
}
ret = ASN_SEQUENCE_ADD(&handoverCommandIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode AMF_UE_NGAP_ID IE error" << endl;
if (ret != 0) Logger::ngap().error("Encode AMF_UE_NGAP_ID IE error");
// free_wrapper((void**) &ie);
}
......@@ -252,13 +254,14 @@ void HandoverCommandMsg::setRanUeNgapId(uint32_t ran_ue_ngap_id) {
int ret = ranUeNgapId->encode2RAN_UE_NGAP_ID(ie->value.choice.RAN_UE_NGAP_ID);
if (!ret) {
cout << "encode RAN_UE_NGAP_ID IE error" << endl;
Logger::ngap().error("Encode RAN_UE_NGAP_ID IE error");
free_wrapper((void**) &ie);
return;
}
ret = ASN_SEQUENCE_ADD(&handoverCommandIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode RAN_UE_NGAP_ID IE error" << endl;
if (ret != 0) Logger::ngap().error("Encode RAN_UE_NGAP_ID IE error");
// free_wrapper((void**) &ie);
}
......@@ -271,7 +274,8 @@ void HandoverCommandMsg::setHandoverType(long type) {
ie->value.present = Ngap_HandoverCommandIEs__value_PR_HandoverType;
ie->value.choice.HandoverType = type;
int ret = ASN_SEQUENCE_ADD(&handoverCommandIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode HandoverType IE error" << endl;
if (ret != 0) Logger::ngap().error("Encode HandoverType IE error");
// free_wrapper((void**) &ie);
}
......@@ -290,8 +294,10 @@ void HandoverCommandMsg::setPduSessionResourceHandoverList(
item->pDUSessionID = list[i].pduSessionId;
item->handoverCommandTransfer = list[i].HandoverCommandTransfer;
int ret = ASN_SEQUENCE_ADD(&PDUSessionResourceHandoverList->list, item);
if (ret != 0)
cout << "encode PDUSessionResourceHandoverListItem IE error" << endl;
Logger::ngap().error(
"Encode PDUSessionResourceHandoverListItem IE error");
}
ie->id = Ngap_ProtocolIE_ID_id_PDUSessionResourceHandoverList;
......@@ -302,7 +308,8 @@ void HandoverCommandMsg::setPduSessionResourceHandoverList(
*PDUSessionResourceHandoverList;
int ret = ASN_SEQUENCE_ADD(&handoverCommandIEs->protocolIEs.list, ie);
if (ret != 0)
cout << "encode PDUSessionResourceHandoverList IE error" << endl;
Logger::ngap().error("Encode PDUSessionResourceHandoverList IE error");
// free_wrapper((void**) &item);
// free_wrapper((void**) &ie);
}
......@@ -321,7 +328,7 @@ void HandoverCommandMsg::setTargetToSource_TransparentContainer(
Ngap_HandoverCommandIEs__value_PR_TargetToSource_TransparentContainer;
ie->value.choice.TargetToSource_TransparentContainer = targetTosource;
int ret = ASN_SEQUENCE_ADD(&handoverCommandIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode HandoverType IE error" << endl;
if (ret != 0) Logger::ngap().error("Encode HandoverType IE error");
// free_wrapper((void**) &ie);
}
......
......@@ -26,6 +26,7 @@
\email: contact@openairinterface.org
*/
#include "HandoverNotifyMsg.hpp"
#include "logger.hpp"
extern "C" {
#include "asn_codecs.h"
......@@ -56,6 +57,7 @@ unsigned long HandoverNotifyMsg::getAmfUeNgapId() {
else
return 0;
}
int HandoverNotifyMsg::encode2buffer(uint8_t* buf, int buf_size) {
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, handoverNotifyPdu);
asn_enc_rval_t er = aper_encode_to_buffer(
......@@ -63,7 +65,9 @@ int HandoverNotifyMsg::encode2buffer(uint8_t* buf, int buf_size) {
cout << "er.encoded(" << er.encoded << ")" << endl;
return er.encoded;
}
bool HandoverNotifyMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!ngap_msg_pdu) return false;
handoverNotifyPdu = ngap_msg_pdu;
if (handoverNotifyPdu->present == Ngap_NGAP_PDU_PR_initiatingMessage) {
......@@ -77,11 +81,11 @@ bool HandoverNotifyMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
handoverNotifyIEs = &handoverNotifyPdu->choice.initiatingMessage->value
.choice.HandoverNotify;
} else {
cout << "Check HandoverNotify message error!!!" << endl;
Logger::ngap().error("Check HandoverNotify message error!");
return false;
}
} else {
cout << "HandoverNotify MessageType error!!!" << endl;
Logger::ngap().error("HandoverNotify MessageType error!");
return false;
}
for (int i = 0; i < handoverNotifyIEs->protocolIEs.list.count; i++) {
......@@ -95,11 +99,11 @@ bool HandoverNotifyMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!amfUeNgapId->decodefromAMF_UE_NGAP_ID(
handoverNotifyIEs->protocolIEs.list.array[i]
->value.choice.AMF_UE_NGAP_ID)) {
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl;
Logger::ngap().error("Decoded ngap AMF_UE_NGAP_ID IE error");
return false;
}
} else {
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl;
Logger::ngap().error("Decoded ngap AMF_UE_NGAP_ID IE error");
return false;
}
} break;
......@@ -112,11 +116,11 @@ bool HandoverNotifyMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!ranUeNgapId->decodefromRAN_UE_NGAP_ID(
handoverNotifyIEs->protocolIEs.list.array[i]
->value.choice.RAN_UE_NGAP_ID)) {
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl;
Logger::ngap().error("Decoded ngap RAN_UE_NGAP_ID IE error");
return false;
}
} else {
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl;
Logger::ngap().error("Decoded ngap RAN_UE_NGAP_ID IE error");
return false;
}
} break;
......@@ -129,16 +133,17 @@ bool HandoverNotifyMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!userLocationInformation->decodefromUserLocationInformation(
&handoverNotifyIEs->protocolIEs.list.array[i]
->value.choice.UserLocationInformation)) {
cout << "decoded ngap UserLocationInformation IE error" << endl;
Logger::ngap().error(
"Decoded ngap UserLocationInformation IE error");
return false;
}
} else {
cout << "decoded ngap UserLocationInformation IE error" << endl;
Logger::ngap().error("Decoded ngap UserLocationInformation IE error");
return false;
}
} break;
default: {
cout << "decoded ngap message pdu error" << endl;
Logger::ngap().error("Decoded NGAP message PDU error");
return false;
}
}
......@@ -178,13 +183,14 @@ void HandoverNotifyMsg::setUserLocationInfoNR(
int ret = userLocationInformation->encodefromUserLocationInformation(
&ie->value.choice.UserLocationInformation);
if (!ret) {
cout << "encode UserLocationInformation IE error" << endl;
Logger::ngap().error("Encode UserLocationInformation IE error");
free_wrapper((void**) &ie);
return;
}
ret = ASN_SEQUENCE_ADD(&handoverNotifyIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode UserLocationInformation IE error" << endl;
if (ret != 0) Logger::ngap().error("Encode UserLocationInformation IE error");
// free_wrapper((void**) &ie);
}
uint32_t HandoverNotifyMsg::getRanUeNgapId() {
......
......@@ -20,6 +20,7 @@
*/
#include "HandoverRequest.hpp"
#include "logger.hpp"
extern "C" {
#include "Ngap_NGAP-PDU.h"
......@@ -56,7 +57,7 @@ HandoverRequest::HandoverRequest() {
HandoverRequest::~HandoverRequest() {}
unsigned long HandoverRequest::getAmfUeNgapId() {
return amfUeNgapId->getAMF_UE_NGAP_ID();
if (amfUeNgapId) return amfUeNgapId->getAMF_UE_NGAP_ID();
}
/*bool HandoverRequest::decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu)
......@@ -244,11 +245,11 @@ void HandoverRequest::setMessageType() {
handoverRequestIEs = &(handoverRequestPdu->choice.initiatingMessage->value
.choice.HandoverRequest);
} else {
cout << "[warning] This information doesn't refer to HandoverRequest "
"Message!!!"
<< endl;
Logger::ngap().warn(
"This information doesn't refer to HandoverRequest message!");
}
}
void HandoverRequest::setAmfUeNgapId(unsigned long id) {
if (!amfUeNgapId) amfUeNgapId = new AMF_UE_NGAP_ID();
amfUeNgapId->setAMF_UE_NGAP_ID(id);
......@@ -261,13 +262,14 @@ void HandoverRequest::setAmfUeNgapId(unsigned long id) {
int ret = amfUeNgapId->encode2AMF_UE_NGAP_ID(ie->value.choice.AMF_UE_NGAP_ID);
if (!ret) {
cout << "encode AMF_UE_NGAP_ID IE error" << endl;
Logger::ngap().error("Encode AMF_UE_NGAP_ID IE error");
free_wrapper((void**) &ie);
return;
}
ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode AMF_UE_NGAP_ID IE error" << endl;
if (ret != 0) Logger::ngap().error("Encode AMF_UE_NGAP_ID IE error");
// free_wrapper((void**) &ie);
}
......@@ -281,7 +283,7 @@ void HandoverRequest::setHandoverType(long type) // 0--intra5gs
ie->value.present = Ngap_HandoverRequestIEs__value_PR_HandoverType;
ie->value.choice.HandoverType = type;
int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode HandoverType IE error" << endl;
if (ret != 0) Logger::ngap().error("Encode HandoverType IE error");
// free_wrapper((void**) &ie);
}
......@@ -298,7 +300,7 @@ void HandoverRequest::setCause(Ngap_Cause_PR m_causePresent, long value) //
cause->setValue(value);
cause->encode2Cause(&(ie->value.choice.Cause));
int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode Cause IE error" << endl;
if (ret != 0) Logger::ngap().error("Encode Cause IE error");
// free_wrapper((void**) &ie);
}
......@@ -320,7 +322,8 @@ void HandoverRequest::setUEAggregateMaximumBitRate(
ie->value.choice.UEAggregateMaximumBitRate);
int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode UEAggregateMaximumBitRate IE error" << endl;
if (ret != 0)
Logger::ngap().error("Encode UEAggregateMaximumBitRate IE error");
// free_wrapper((void**) &ie);
}
void HandoverRequest::setUESecurityCapabilities(
......@@ -342,14 +345,14 @@ void HandoverRequest::setUESecurityCapabilities(
(ie->value.choice.UESecurityCapabilities));
int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode UESecurityCapabilities IE error" << endl;
if (ret != 0) Logger::ngap().error("Encode UESecurityCapabilities IE error");
// free_wrapper((void**) &ie);
}
void HandoverRequest::setGUAMI(
PlmnId* m_plmnId, AMFRegionID* m_aMFRegionID, AMFSetID* m_aMFSetID,
AMFPointer* m_aMFPointer) {
if (!guami) guami = new GUAMI;
if (!guami) guami = new GUAMI();
Ngap_HandoverRequestIEs_t* ie =
(Ngap_HandoverRequestIEs_t*) calloc(1, sizeof(Ngap_HandoverRequestIEs_t));
......@@ -360,7 +363,8 @@ void HandoverRequest::setGUAMI(
guami->encode2GUAMI(&(ie->value.choice.GUAMI));
int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode GUAMI IE error" << endl;
if (ret != 0) Logger::ngap().error("Encode GUAMI IE error");
// free_wrapper((void**) &ie);
}
void HandoverRequest::setAllowedNSSAI(std::vector<S_NSSAI> list) {
......@@ -374,7 +378,8 @@ void HandoverRequest::setAllowedNSSAI(std::vector<S_NSSAI> list) {
list[i].encode2S_NSSAI(&item->s_NSSAI);
int ret = ASN_SEQUENCE_ADD(&allowedNSSAI->list, item);
if (ret != 0)
cout << "encode PDUSessionResourceHandoverListItem IE error" << endl;
Logger::ngap().error(
"Encode PDUSessionResourceHandoverListItem IE error");
}
asn_fprint(stderr, &asn_DEF_Ngap_AllowedNSSAI, allowedNSSAI);
Ngap_HandoverRequestIEs_t* ie =
......@@ -384,7 +389,7 @@ void HandoverRequest::setAllowedNSSAI(std::vector<S_NSSAI> list) {
ie->value.present = Ngap_HandoverRequestIEs__value_PR_AllowedNSSAI;
ie->value.choice.AllowedNSSAI = *allowedNSSAI;
int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode AllowedNSSAI IE error" << endl;
if (ret != 0) Logger::ngap().error("Encode AllowedNSSAI IE error");
// free_wrapper((void**) &ie);
}
void HandoverRequest::setSecurityContext(long count, uint8_t* buffer) {
......@@ -402,7 +407,7 @@ void HandoverRequest::setSecurityContext(long count, uint8_t* buffer) {
ie->value.present = Ngap_HandoverRequestIEs__value_PR_SecurityContext;
ie->value.choice.SecurityContext = *SecurityContext;
int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode SecurityContext IE error" << endl;
if (ret != 0) Logger::ngap().error("Encode SecurityContext IE error");
// free_wrapper((void**) &ie);
}
......@@ -438,14 +443,14 @@ void HandoverRequest::setPduSessionResourceSetupList(
PDUSessionResourceSetupList->encode2PDUSessionResourceSetupListHOReq(
&ie->value.choice.PDUSessionResourceSetupListHOReq);
if (!ret) {
cout << "encode PDUSessionResourceSetupListSUReq IE error" << endl;
Logger::ngap().error("Encode PDUSessionResourceSetupListSUReq IE error");
free_wrapper((void**) &ie);
return;
}
ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0)
cout << "encode PDUSessionResourceSetupListSUReq IE error" << endl;
Logger::ngap().error("Encode PDUSessionResourceSetupListSUReq IE error");
// free_wrapper((void**) &ie);
}
......@@ -464,7 +469,7 @@ void HandoverRequest::setSourceToTarget_TransparentContainer(
ie->value.choice.SourceToTarget_TransparentContainer = sourceTotarget;
int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0)
cout << "encode SourceToTarget_TransparentContainer IE error" << endl;
Logger::ngap().error("Encode SourceToTarget_TransparentContainer IE error");
// free_wrapper((void**) &ie);
}
void HandoverRequest::setMobilityRestrictionList(PlmnId* m_plmnId) {
......@@ -480,7 +485,7 @@ void HandoverRequest::setMobilityRestrictionList(PlmnId* m_plmnId) {
mobilityrestrictionlist->encodeMobilityRestrictionList(
&(ie->value.choice.MobilityRestrictionList));
int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode MobilityRestrictionList IE error" << endl;
if (ret != 0) Logger::ngap().error("Encode MobilityRestrictionList IE error");
// free_wrapper((void**) &ie);
}
......
......@@ -81,7 +81,7 @@ class HandoverRequest {
private:
Ngap_NGAP_PDU_t* handoverRequestPdu;
Ngap_HandoverRequest_t* handoverRequestIEs;
/***************** for decoding ****************/
AMF_UE_NGAP_ID* amfUeNgapId;
Ngap_HandoverType_t* handovertype;
Cause* cause;
......
......@@ -20,7 +20,7 @@
*/
#include "HandoverRequestAck.hpp"
#include "logger.hpp"
#include "GTP-TEID.hpp"
#include "String2Value.hpp"
#include "TransportLayerAddress.hpp"
......@@ -82,11 +82,11 @@ void HandoverRequestAck::setMessageType() {
handoverRequestAckIEs = &(handoverRequestAckPdu->choice.successfulOutcome
->value.choice.HandoverRequestAcknowledge);
} else {
cout << "[warning] This information doesn't refer to HandoverRequest "
"Message!!!"
<< endl;
Logger::ngap().warn(
"This information doesn't refer to HandoverRequest message");
}
}
uint32_t HandoverRequestAck::getRanUeNgapId() {
if (ranUeNgapId)
return ranUeNgapId->getRanUeNgapId();
......@@ -122,6 +122,7 @@ bool HandoverRequestAck::getPDUSessionResourceAdmittedList(
}
bool HandoverRequestAck::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!ngap_msg_pdu) return false;
handoverRequestAckPdu = ngap_msg_pdu;
if (handoverRequestAckPdu->present == Ngap_NGAP_PDU_PR_successfulOutcome) {
......@@ -135,11 +136,11 @@ bool HandoverRequestAck::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
handoverRequestAckIEs = &handoverRequestAckPdu->choice.successfulOutcome
->value.choice.HandoverRequestAcknowledge;
} else {
cout << "Check handoverRequestAck message error!!!" << endl;
Logger::ngap().error("Check handoverRequestAck message error");
return false;
}
} else {
cout << "handoverRequestAck MessageType error!!!" << endl;
Logger::ngap().error("handoverRequestAck MessageType error");
return false;
}
for (int i = 0; i < handoverRequestAckIEs->protocolIEs.list.count; i++) {
......@@ -153,11 +154,11 @@ bool HandoverRequestAck::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!amfUeNgapId->decodefromAMF_UE_NGAP_ID(
handoverRequestAckIEs->protocolIEs.list.array[i]
->value.choice.AMF_UE_NGAP_ID)) {
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl;
Logger::ngap().error("Decoded NGAP AMF_UE_NGAP_ID IE error");
return false;
}
} else {
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl;
Logger::ngap().error("Decoded NGAP AMF_UE_NGAP_ID IE error");
return false;
}
} break;
......@@ -170,11 +171,11 @@ bool HandoverRequestAck::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!ranUeNgapId->decodefromRAN_UE_NGAP_ID(
handoverRequestAckIEs->protocolIEs.list.array[i]
->value.choice.RAN_UE_NGAP_ID)) {
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl;
Logger::ngap().error("Decoded NGAP RAN_UE_NGAP_ID IE error");
return false;
}
} else {
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl;
Logger::ngap().error("Decoded NGAP RAN_UE_NGAP_ID IE error");
return false;
}
} break;
......@@ -188,13 +189,13 @@ bool HandoverRequestAck::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
->decodefromPDUSessionResourceAdmittedList(
&handoverRequestAckIEs->protocolIEs.list.array[i]
->value.choice.PDUSessionResourceAdmittedList)) {
cout << "decoded ngap PDUSessionResourceAdmittedList IE error"
<< endl;
Logger::ngap().error(
"Decoded NGAP PDUSessionResourceAdmittedList IE error");
return false;
}
} else {
cout << "decoded ngap PDUSessionResourceAdmittedList Type IE error"
<< endl;
Logger::ngap().error(
"Decoded NGAP PDUSessionResourceAdmittedList IE error");
return false;
}
} break;
......@@ -209,13 +210,14 @@ bool HandoverRequestAck::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
handoverRequestAckIEs->protocolIEs.list.array[i]
->value.choice.TargetToSource_TransparentContainer;
} else {
cout << "decoded ngap TargetToSource_TransparentContainer IE error"
<< endl;
Logger::ngap().error(
"Decoded NGAP TargetToSource_TransparentContainer IE error");
return false;
}
} break;
default: {
cout << "decoded ngap message pdu error" << endl;
Logger::ngap().error("Decoded NGAP Message PDU error");
return false;
}
}
......
......@@ -20,6 +20,7 @@
*/
#include "HandoverRequiredMsg.hpp"
#include "logger.hpp"
extern "C" {
#include "Ngap_NGAP-PDU.h"
#include "asn_codecs.h"
......@@ -69,28 +70,33 @@ Ngap_HandoverType_t HandoverRequiredMsg::getHandoverType() {
if (handovertype)
return *handovertype;
else
Ngap_HandoverType_t();
return Ngap_HandoverType_t();
}
Ngap_Cause_PR HandoverRequiredMsg::getChoiceOfCause() {
if (cause)
return cause->getChoiceOfCause();
else
return Ngap_Cause_PR();
}
long HandoverRequiredMsg::getCauseValue() {
if (cause)
return cause->getValue();
else
return 0;
}
void HandoverRequiredMsg::getGlobalRanNodeId(GlobalgNBId*& ptr) {
if (ptr)
ptr->decodefromGlobalgNBId(
targetid->choice.targetRANNodeID->globalRANNodeID.choice.globalGNB_ID);
}
void HandoverRequiredMsg::getTAI(TAI*& ptr) {
if (ptr) ptr->decodefromTAI(&(targetid->choice.targetRANNodeID->selectedTAI));
}
OCTET_STRING_t HandoverRequiredMsg::getSourceToTarget_TransparentContainer() {
if (SourceToTarget_TransparentContainer)
return *SourceToTarget_TransparentContainer;
......@@ -138,11 +144,11 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
handoverRequiredIEs = &handoverRequiredPdu->choice.initiatingMessage
->value.choice.HandoverRequired;
} else {
cout << "Check HandoverRequired message error!!!" << endl;
Logger::ngap().error("Check HandoverRequired message error!");
return false;
}
} else {
cout << "HandoverRequired MessageType error!!!" << endl;
Logger::ngap().error("HandoverRequired MessageType error!");
return false;
}
for (int i = 0; i < handoverRequiredIEs->protocolIEs.list.count; i++) {
......@@ -156,11 +162,11 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!amfUeNgapId->decodefromAMF_UE_NGAP_ID(
handoverRequiredIEs->protocolIEs.list.array[i]
->value.choice.AMF_UE_NGAP_ID)) {
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl;
Logger::ngap().error("Decoded ngap AMF_UE_NGAP_ID IE error");
return false;
}
} else {
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl;
Logger::ngap().error("Decoded ngap AMF_UE_NGAP_ID IE error");
return false;
}
} break;
......@@ -173,11 +179,11 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!ranUeNgapId->decodefromRAN_UE_NGAP_ID(
handoverRequiredIEs->protocolIEs.list.array[i]
->value.choice.RAN_UE_NGAP_ID)) {
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl;
Logger::ngap().error("Decoded ngap RAN_UE_NGAP_ID IE error");
return false;
}
} else {
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl;
Logger::ngap().error("Decoded ngap RAN_UE_NGAP_ID IE error");
return false;
}
} break;
......@@ -190,7 +196,7 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
*handovertype = handoverRequiredIEs->protocolIEs.list.array[i]
->value.choice.HandoverType;
} else {
cout << "decoded ngap Handover Type IE error" << endl;
Logger::ngap().error("Decoded ngap Handover Type error");
return false;
}
} break;
......@@ -203,11 +209,11 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!cause->decodefromCause(
&handoverRequiredIEs->protocolIEs.list.array[i]
->value.choice.Cause)) {
cout << "decoded ngap Cause IE error" << endl;
Logger::ngap().error("Decoded ngap Cause IE error");
return false;
}
} else {
cout << "decoded ngap Cause IE error" << endl;
Logger::ngap().error("Decoded ngap Cause IE error");
return false;
}
} break;
......@@ -220,7 +226,7 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
*targetid = handoverRequiredIEs->protocolIEs.list.array[i]
->value.choice.TargetID;
} else {
cout << "decoded ngap TargetID IE error" << endl;
Logger::ngap().error("Decoded ngap TargetID IE error");
return false;
}
} break;
......@@ -235,8 +241,8 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
handoverRequiredIEs->protocolIEs.list.array[i]
->value.choice.DirectForwardingPathAvailability;
} else {
cout << "decoded ngap DirectForwardingPathAvailability IE error"
<< endl;
Logger::ngap().error(
"Decoded ngap DirectForwardingPathAvailability IE error");
return false;
}
} break;
......@@ -249,12 +255,13 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!PDUSessionResourceList->decodefromPDUSessionResourceListHORqd(
&handoverRequiredIEs->protocolIEs.list.array[i]
->value.choice.PDUSessionResourceListHORqd)) {
cout << "decoded ngap PDUSessionResourceSetupListCxtRes IE error"
<< endl;
Logger::ngap().error(
"Decoded ngap PDUSessionResourceSetupListCxtRes IE error");
return false;
}
} else {
cout << "decoded ngap PDUSessionResourceListHORqd IE error" << endl;
Logger::ngap().error(
"Decoded ngap PDUSessionResourceSetupListCxtRes IE error");
return false;
}
} break;
......@@ -269,13 +276,13 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
handoverRequiredIEs->protocolIEs.list.array[i]
->value.choice.SourceToTarget_TransparentContainer;
} else {
cout << "decoded ngap SourceToTarget_TransparentContainer IE error"
<< endl;
Logger::ngap().error(
"Decoded ngap SourceToTarget_TransparentContainer IE error");
return false;
}
} break;
default: {
cout << "decoded ngap message pdu error" << endl;
Logger::ngap().error("Decoded ngap message PDU error");
return false;
}
}
......@@ -288,7 +295,8 @@ int HandoverRequiredMsg::encode2buffer(uint8_t* buf, int buf_size) {
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, handoverRequiredPdu);
asn_enc_rval_t er = aper_encode_to_buffer(
&asn_DEF_Ngap_NGAP_PDU, NULL, handoverRequiredPdu, buf, buf_size);
cout << "er.encoded(" << er.encoded << ")" << endl;
// cout << "er.encoded(" << er.encoded << ")" << endl;
Logger::ngap().error("er.encoded( %d )", er.encoded);
return er.encoded;
}
......
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