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

Fix issue for nullptr for HO

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