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

Fix issue for nullptr for HO

parent d524d28d
......@@ -27,6 +27,7 @@
*/
#include "DownLinkNasTransport.hpp"
#include "logger.hpp"
extern "C" {
#include "asn_codecs.h"
......@@ -83,9 +84,8 @@ void DownLinkNasTransportMsg::setMessageType() {
&(downLinkNasTransportPdu->choice.initiatingMessage->value.choice
.DownlinkNASTransport);
} else {
cout << "[warning] This information doesn't refer to DownlinkNASTransport "
"Message!!!"
<< endl;
Logger::ngap().warn(
"This information doesn't refer to DownlinkNASTransport Message");
}
}
......@@ -103,13 +103,13 @@ void DownLinkNasTransportMsg::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(&downLinkNasTransportIEs->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);
}
......@@ -127,13 +127,13 @@ void DownLinkNasTransportMsg::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(&downLinkNasTransportIEs->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);
}
......@@ -151,13 +151,13 @@ void DownLinkNasTransportMsg::setOldAmfName(const std::string name) {
int ret = oldAmfName->encode2AmfName(&ie->value.choice.AMFName);
if (!ret) {
cout << "encode oldAmfName IE error" << endl;
Logger::ngap().error("Encode oldAmfName IE error");
free_wrapper((void**) &ie);
return;
}
ret = ASN_SEQUENCE_ADD(&downLinkNasTransportIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode oldAmfName IE error" << endl;
if (ret != 0) Logger::ngap().error("Encode oldAmfName IE error");
// free_wrapper((void**) &ie);
}
......@@ -176,7 +176,7 @@ void DownLinkNasTransportMsg::setRanPagingPriority(uint8_t pagingPriority) {
int ret = ranPagingPriority->encode2RANPagingPriority(
ie->value.choice.RANPagingPriority);
if (!ret) {
cout << "encode RANPagingPriority IE error" << endl;
Logger::ngap().error("Encode RANPagingPriority IE error");
free_wrapper((void**) &ie);
return;
}
......@@ -201,13 +201,13 @@ void DownLinkNasTransportMsg::setNasPdu(uint8_t* nas, size_t sizeofnas) {
int ret = nasPdu->encode2octetstring(ie->value.choice.NAS_PDU);
if (!ret) {
cout << "encode NAS_PDU IE error" << endl;
Logger::ngap().error("Encode NAS_PDU IE error");
free_wrapper((void**) &ie);
return;
}
ret = ASN_SEQUENCE_ADD(&downLinkNasTransportIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode NAS_PDU IE error" << endl;
if (ret != 0) Logger::ngap().error("Encode NAS_PDU IE error");
// free_wrapper((void**) &ie);
}
......@@ -226,13 +226,13 @@ void DownLinkNasTransportMsg::setIndex2Rat_Frequency_SelectionPriority(
int ret = indexToRFSP->encode2IndexToRFSP(ie->value.choice.IndexToRFSP);
if (!ret) {
cout << "encode IndexToRFSP IE error" << endl;
Logger::ngap().error("Encode IndexToRFSP IE error");
free_wrapper((void**) &ie);
return;
}
ret = ASN_SEQUENCE_ADD(&downLinkNasTransportIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode IndexToRFSP IE error" << endl;
if (ret != 0) Logger::ngap().error("Encode IndexToRFSP IE error");
// free_wrapper((void**) &ie);
}
......
......@@ -51,7 +51,10 @@ HandoverNotifyMsg::HandoverNotifyMsg() {
HandoverNotifyMsg::~HandoverNotifyMsg(){};
unsigned long HandoverNotifyMsg::getAmfUeNgapId() {
return amfUeNgapId->getAMF_UE_NGAP_ID();
if (amfUeNgapId)
return amfUeNgapId->getAMF_UE_NGAP_ID();
else
return 0;
}
int HandoverNotifyMsg::encode2buffer(uint8_t* buf, int buf_size) {
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, handoverNotifyPdu);
......@@ -185,10 +188,15 @@ void HandoverNotifyMsg::setUserLocationInfoNR(
// free_wrapper((void**) &ie);
}
uint32_t HandoverNotifyMsg::getRanUeNgapId() {
return ranUeNgapId->getRanUeNgapId();
if (ranUeNgapId)
return ranUeNgapId->getRanUeNgapId();
else
return 0;
}
bool HandoverNotifyMsg::getUserLocationInfoNR(
struct NrCgi_s& cig, struct Tai_s& tai) {
if (!userLocationInformation) return false;
UserLocationInformationNR* informationNR;
userLocationInformation->getInformation(informationNR);
if (userLocationInformation->getChoiceOfUserLocationInformation() !=
......
......@@ -48,8 +48,8 @@ class HandoverNotifyMsg {
int encode2buffer(uint8_t* buf, int buf_size);
bool decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu);
void setUserLocationInfoNR(struct NrCgi_s cig, struct Tai_s tai);
unsigned long getAmfUeNgapId(); // return -1;
uint32_t getRanUeNgapId(); // return -1;
unsigned long getAmfUeNgapId();
uint32_t getRanUeNgapId();
bool getUserLocationInfoNR(struct NrCgi_s& cig, struct Tai_s& tai);
private:
......
......@@ -55,7 +55,10 @@ HandoverRequestAck::HandoverRequestAck() {
HandoverRequestAck::~HandoverRequestAck() {}
unsigned long HandoverRequestAck::getAmfUeNgapId() {
return amfUeNgapId->getAMF_UE_NGAP_ID();
if (amfUeNgapId)
return amfUeNgapId->getAMF_UE_NGAP_ID();
else
return 0;
}
void HandoverRequestAck::setMessageType() {
if (!handoverRequestAckPdu)
......@@ -85,10 +88,15 @@ void HandoverRequestAck::setMessageType() {
}
}
uint32_t HandoverRequestAck::getRanUeNgapId() {
return ranUeNgapId->getRanUeNgapId();
if (ranUeNgapId)
return ranUeNgapId->getRanUeNgapId();
else
return 0;
}
OCTET_STRING_t HandoverRequestAck::getTargetToSource_TransparentContainer() {
return *TargetToSource_TransparentContainer;
if (TargetToSource_TransparentContainer)
return *TargetToSource_TransparentContainer;
return OCTET_STRING_t();
}
bool HandoverRequestAck::getPDUSessionResourceAdmittedList(
......
......@@ -65,7 +65,6 @@ class HandoverRequestAck {
private:
Ngap_NGAP_PDU_t* handoverRequestAckPdu;
Ngap_HandoverRequestAcknowledge_t* handoverRequestAckIEs;
/***************** for decoding ****************/
AMF_UE_NGAP_ID* amfUeNgapId;
RAN_UE_NGAP_ID* ranUeNgapId;
Ngap_HandoverType_t* handovertype;
......
......@@ -52,31 +52,48 @@ HandoverRequiredMsg::HandoverRequiredMsg() {
HandoverRequiredMsg::~HandoverRequiredMsg() {}
unsigned long HandoverRequiredMsg::getAmfUeNgapId() {
return amfUeNgapId->getAMF_UE_NGAP_ID();
if (amfUeNgapId)
return amfUeNgapId->getAMF_UE_NGAP_ID();
else
return 0;
}
uint32_t HandoverRequiredMsg::getRanUeNgapId() {
return ranUeNgapId->getRanUeNgapId();
if (ranUeNgapId)
return ranUeNgapId->getRanUeNgapId();
else
return 0;
}
Ngap_HandoverType_t HandoverRequiredMsg::getHandoverType() {
return *handovertype;
if (handovertype)
return *handovertype;
else
Ngap_HandoverType_t();
}
Ngap_Cause_PR HandoverRequiredMsg::getChoiceOfCause() {
return cause->getChoiceOfCause();
if (cause)
return cause->getChoiceOfCause();
else
return Ngap_Cause_PR();
}
long HandoverRequiredMsg::getCauseValue() {
return cause->getValue();
if (cause)
return cause->getValue();
else
return 0;
}
void HandoverRequiredMsg::getGlobalRanNodeId(GlobalgNBId*& ptr) {
ptr->decodefromGlobalgNBId(
targetid->choice.targetRANNodeID->globalRANNodeID.choice.globalGNB_ID);
if (ptr)
ptr->decodefromGlobalgNBId(
targetid->choice.targetRANNodeID->globalRANNodeID.choice.globalGNB_ID);
}
void HandoverRequiredMsg::getTAI(TAI*& ptr) {
ptr->decodefromTAI(&(targetid->choice.targetRANNodeID->selectedTAI));
if (ptr) ptr->decodefromTAI(&(targetid->choice.targetRANNodeID->selectedTAI));
}
OCTET_STRING_t HandoverRequiredMsg::getSourceToTarget_TransparentContainer() {
return *SourceToTarget_TransparentContainer;
if (SourceToTarget_TransparentContainer)
return *SourceToTarget_TransparentContainer;
}
bool HandoverRequiredMsg::getPDUSessionResourceList(
......@@ -103,7 +120,8 @@ bool HandoverRequiredMsg::getPDUSessionResourceList(
}
long HandoverRequiredMsg::getDirectForwardingPathAvailability() {
return *directforwardingPathAvailability;
if (directforwardingPathAvailability)
return *directforwardingPathAvailability;
}
bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
......
......@@ -48,9 +48,8 @@ class HandoverRequiredMsg {
int encode2buffer(uint8_t* buf, int buf_size);
bool decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu);
unsigned long getAmfUeNgapId(); // return -1;(不存在)
uint32_t getRanUeNgapId(); // return -1;(不存在)
unsigned long getAmfUeNgapId();
uint32_t getRanUeNgapId();
Ngap_HandoverType_t getHandoverType();
Ngap_Cause_PR getChoiceOfCause();
long getCauseValue();
......@@ -63,7 +62,6 @@ class HandoverRequiredMsg {
private:
Ngap_NGAP_PDU_t* handoverRequiredPdu;
Ngap_HandoverRequired_t* handoverRequiredIEs;
/***************** for decoding ****************/
AMF_UE_NGAP_ID* amfUeNgapId;
RAN_UE_NGAP_ID* ranUeNgapId;
Ngap_HandoverType_t* handovertype;
......
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