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

Merge branch 'fix_n2_ho' into 'develop'

Fix n2 ho

See merge request oai/cn5g/oai-cn5g-amf!48
parents e975eb79 5103c14a
......@@ -58,29 +58,32 @@ namespace config {
//------------------------------------------------------------------------------
amf_config::amf_config() {
nrf_addr.ipv4_addr.s_addr = INADDR_ANY;
nrf_addr.port = 80;
nrf_addr.api_version = "v1";
enable_nf_registration = false;
enable_smf_selection = false;
enable_external_ausf = false;
enable_external_udm = false;
instance = 0;
n2 = {};
n11 = {};
statistics_interval = 0;
guami = {};
guami_list = {};
relativeAMFCapacity = 0;
plmn_list = {};
auth_conf auth_para = {};
nas_cfg = {};
smf_pool = {};
enable_nf_registration = false;
enable_smf_selection = false;
enable_external_ausf = false;
enable_external_udm = false;
use_fqdn_dns = false;
nrf_addr.ipv4_addr.s_addr = INADDR_ANY;
nrf_addr.port = 80;
nrf_addr.api_version = "v1";
ausf_addr.ipv4_addr.s_addr = INADDR_ANY;
ausf_addr.port = 80;
ausf_addr.api_version = "v1";
enable_nf_registration = false;
enable_smf_selection = false;
enable_external_ausf = false;
enable_external_udm = false;
instance = 0;
n2 = {};
n11 = {};
statistics_interval = 0;
guami = {};
guami_list = {};
relativeAMFCapacity = 0;
plmn_list = {};
auth_conf auth_para = {};
nas_cfg = {};
smf_pool = {};
enable_nf_registration = false;
enable_smf_selection = false;
enable_external_ausf = false;
enable_external_udm = false;
use_fqdn_dns = false;
struct {
struct in_addr ipv4_addr;
......
......@@ -1291,7 +1291,7 @@ bool amf_n1::get_authentication_vectors_from_ausf(
Logger::amf_n1().debug("********* has auts *********");
char* auts_s = (char*) malloc(auts_len * 2 + 1);
// char *rand_s = (char *)malloc(RAND_LENGTH * 2 + 1);
memset(auts_s, 0, sizeof(auts_s));
memset(auts_s, 0, auts_len * 2);
// memset(rand_s, 0, sizeof(rand_s));
// uint8_t rand_value[RAND_LENGTH];
......
......@@ -210,29 +210,31 @@ void amf_n11::handle_itti_message(
Logger::amf_n11().debug("SMF URI: %s", remote_uri.c_str());
std::string n2SmMsg = {};
nlohmann::json pdu_session_update_request = {};
// if (itti_msg.is_n2sm_set){
pdu_session_update_request["n2SmInfoType"] = itti_msg.n2sm_info_type;
pdu_session_update_request["n2SmInfo"]["contentId"] = "n2msg";
std::string json_part = pdu_session_update_request.dump();
std::string n2SmMsg = {};
octet_stream_2_hex_stream(
(uint8_t*) bdata(itti_msg.n2sm), blength(itti_msg.n2sm), n2SmMsg);
if (itti_msg.is_n2sm_set) {
pdu_session_update_request["n2SmInfoType"] = itti_msg.n2sm_info_type;
pdu_session_update_request["n2SmInfo"]["contentId"] = "n2msg";
octet_stream_2_hex_stream(
(uint8_t*) bdata(itti_msg.n2sm), blength(itti_msg.n2sm), n2SmMsg);
}
// For N2 HO
if (itti_msg.n2sm_info_type.compare("HANDOVER_REQUIRED") == 0) {
if (itti_msg.ho_state.compare("PREPARING") == 0) {
pdu_session_update_request["hoState"] = "PREPARING";
} else if (itti_msg.n2sm_info_type.compare("HANDOVER_REQ_ACK") == 0) {
} else if (itti_msg.ho_state.compare("PREPARED") == 0) {
pdu_session_update_request["hoState"] = "PREPARED";
} else if (itti_msg.n2sm_info_type.compare("SECONDARY_RAT_USAGE") == 0) {
} else if (itti_msg.ho_state.compare("COMPLETED") == 0) {
pdu_session_update_request["hoState"] = "COMPLETED";
}
std::string json_part = pdu_session_update_request.dump();
curl_http_client(
remote_uri, json_part, "", n2SmMsg, supi, itti_msg.pdu_session_id,
itti_msg.promise_id);
stacs.display();
// stacs.display();
}
//------------------------------------------------------------------------------
......@@ -516,6 +518,7 @@ void amf_n11::curl_http_client(
mime_parser parser = {};
std::string body = {};
std::shared_ptr<pdu_session_context> psc = {};
bool is_multipart = true;
if (!amf_app_inst->find_pdu_session_context(supi, pdu_session_id, psc)) {
Logger::amf_n11().warn(
......@@ -537,6 +540,9 @@ void amf_n11::curl_http_client(
parser.create_multipart_related_content(
body, jsonData, CURL_MIME_BOUNDARY, n2SmMsg,
multipart_related_content_part_e::NGAP);
} else {
body = jsonData;
is_multipart = false;
}
Logger::amf_n11().debug(
......@@ -553,9 +559,13 @@ void amf_n11::curl_http_client(
if (curl) {
CURLcode res = {};
struct curl_slist* headers = nullptr;
std::string content_type = "content-type: multipart/related; boundary=" +
std::string(CURL_MIME_BOUNDARY);
std::string content_type = {};
if (is_multipart) {
content_type = "content-type: multipart/related; boundary=" +
std::string(CURL_MIME_BOUNDARY);
} else {
content_type = "content-type: application/json";
}
headers = curl_slist_append(headers, content_type.c_str());
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_URL, remoteUri.c_str());
......
This diff is collapsed.
......@@ -101,6 +101,7 @@ enum class http_response_codes_e {
constexpr auto CURL_MIME_BOUNDARY = "----Boundary";
#define CURL_TIMEOUT_MS 1000L
#define BUFFER_SIZE_4096 4096
#define BUFFER_SIZE_2048 2048
#define BUFFER_SIZE_1024 1024
#define BUFFER_SIZE_512 512
......@@ -108,4 +109,7 @@ constexpr auto CURL_MIME_BOUNDARY = "----Boundary";
#define FUTURE_STATUS_TIMEOUT_MS 100
#define UE_AGGREGATE_MAXIMUM_BIT_RATE_DL 300000000
#define UE_AGGREGATE_MAXIMUM_BIT_RATE_UL 200000000
#endif
......@@ -64,6 +64,7 @@ nas_context::nas_context() : _vector(), _5g_he_av(), _5g_av(), kamf() {
is_auth_vectors_present = false;
to_be_register_by_new_suci = false;
ueSecurityCaplen = 0;
nas_status = {};
}
//------------------------------------------------------------------------------
......
......@@ -44,6 +44,7 @@ pdu_session_context::pdu_session_context() {
smf_available = false;
snssai = {};
plmn = {};
is_ho_accepted = false;
}
//------------------------------------------------------------------------------
......
......@@ -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_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 target_gnb_assoc_id;
sctp_assoc_id_t gnb_assoc_id; // to find which gnb this UE belongs to
sctp_assoc_id_t target_gnb_assoc_id; // for HO
bool ueContextRequest;
uint32_t s_tmsi_5g;
......
......@@ -105,6 +105,7 @@ class itti_nsmf_pdusession_update_sm_context : public itti_msg_n11 {
uint32_t ran_ue_ngap_id;
long amf_ue_ngap_id;
uint32_t promise_id;
std::string ho_state;
};
class itti_nsmf_pdusession_release_sm_context : public itti_msg_n11 {
......
......@@ -133,7 +133,7 @@ int _5GSMobilityIdentity::_5g_s_tmsi_encode2buffer(uint8_t* buf, int len) {
//------------------------------------------------------------------------------
int _5GSMobilityIdentity::_5g_s_tmsi_decodefrombuffer(uint8_t* buf, int len) {
int decoded_size = 0;
_5g_s_tmsi = (_5G_S_TMSI_t*) calloc(1, sizeof(_5G_S_TMSI_t));
if (!_5g_s_tmsi) _5g_s_tmsi = (_5G_S_TMSI_t*) calloc(1, sizeof(_5G_S_TMSI_t));
decoded_size++; // type of identity
uint8_t octet = *(buf + decoded_size);
decoded_size++;
......
......@@ -36,6 +36,8 @@ UESecurityCapability::UESecurityCapability(uint8_t iei) {
_iei = iei;
_5g_EASel = 0;
_5g_IASel = 0;
EEASel = 0;
EIASel = 0;
length = 0;
}
......@@ -44,6 +46,8 @@ UESecurityCapability::UESecurityCapability() {
_iei = 0;
_5g_EASel = 0;
_5g_IASel = 0;
EEASel = 0;
EIASel = 0;
length = 0;
}
......
......@@ -68,7 +68,7 @@ bool GlobalgNBId::decodefromGlobalgNBId(Ngap_GlobalGNB_ID_t* globalgnbid) {
//------------------------------------------------------------------------------
void GlobalgNBId::getGlobalgNBId(PlmnId*& plmn, GNB_ID*& gnbid) {
plmn = plmnId;
gnbid = gNB_ID;
if (plmnId) plmn = plmnId;
if (gNB_ID) gnbid = gNB_ID;
}
} // namespace ngap
......@@ -65,7 +65,6 @@ bool PDUSessionResourceHandoverRequestAckTransfer::
// return false;
}
cout << "rc.consumed to decode = " << rc.consumed << endl;
cout << endl;
dLForwardingUP_TNLInformation = new UpTransportLayerInformation();
if (!dLForwardingUP_TNLInformation->decodefromUpTransportLayerInformation(
*handoverRequestAcknowledegTransferIEs
......
......@@ -94,7 +94,7 @@ bool PDUSessionResourceHandoverRequiredTransfer::decodefromIE(
bool PDUSessionResourceHandoverRequiredTransfer::
getDirectForwardingPathAvailability(
long* directForwardingPathAvailability) {
directForwardingPathAvailability = (long*) DirectForwardingPathAvailability;
*directForwardingPathAvailability = (long) *DirectForwardingPathAvailability;
return true;
}
......
......@@ -67,8 +67,10 @@ bool PDUSessionResourceListHORqd::decodefromPDUSessionResourceListHORqd(
}
void PDUSessionResourceListHORqd::getPDUSessionResourceListHORqd(
PDUSessionResourceItemHORqd*& m_pduSessionResourceItemHORqd, int& num) {
m_pduSessionResourceItemHORqd = pduSessionResourceItemHORqd;
num = numofpduSessionResourceItemHORqd;
if (pduSessionResourceItemHORqd) {
m_pduSessionResourceItemHORqd = pduSessionResourceItemHORqd;
num = numofpduSessionResourceItemHORqd;
}
}
} // namespace ngap
......@@ -34,7 +34,9 @@ using namespace std;
namespace ngap {
//------------------------------------------------------------------------------
PacketLossRate::PacketLossRate() {}
PacketLossRate::PacketLossRate() {
packetlossrate = 0;
}
//------------------------------------------------------------------------------
PacketLossRate::~PacketLossRate() {}
......
......@@ -38,10 +38,7 @@ QosFlowItemWithDataForWarding::QosFlowItemWithDataForWarding() {
QosFlowItemWithDataForWarding::~QosFlowItemWithDataForWarding() {}
void QosFlowItemWithDataForWarding::getQosFlowItemWithDataForWarding(
Ngap_QosFlowIdentifier_t& m_QosFlowIdentifier) {
if (!qosFlowIdentifier)
printf("qosFlowIdentifier null\n");
else
printf("qosFlowIdentifier \n");
if (!qosFlowIdentifier) return;
if (qosFlowIdentifier->getQosFlowIdentifier(value)) {
m_QosFlowIdentifier = (Ngap_QosFlowIdentifier_t) value;
}
......@@ -51,10 +48,8 @@ bool QosFlowItemWithDataForWarding::decodeformQosFlowItemWithDataForWarding(
if (qosFlowIdentifier == nullptr) qosFlowIdentifier = new QosFlowIdentifier();
if (!qosFlowIdentifier->decodefromQosFlowIdentifier(
&(qosFlowItemWithDataForWarding->qosFlowIdentifier))) {
printf("false\n");
return false;
}
printf("true\n");
return true;
}
} // namespace ngap
......@@ -89,9 +89,11 @@ bool SecurityIndication::encode2SecurityIndication(
//------------------------------------------------------------------------------
bool SecurityIndication::decodefromSecurityIndication(
Ngap_SecurityIndication_t* securityIndication) {
integrityProtectionIndication = new IntegrityProtectionIndication();
confidentialityProtectionIndication =
new ConfidentialityProtectionIndication();
if (!integrityProtectionIndication)
integrityProtectionIndication = new IntegrityProtectionIndication();
if (!confidentialityProtectionIndication)
confidentialityProtectionIndication =
new ConfidentialityProtectionIndication();
if (!integrityProtectionIndication->decodefromIntegrityProtectionIndication(
securityIndication->integrityProtectionIndication))
......
......@@ -70,7 +70,7 @@ bool ServedGUAMIItem::encode2ServedGUAMIItem(
//------------------------------------------------------------------------------
bool ServedGUAMIItem::decodefromServedGUAMIItem(Ngap_ServedGUAMIItem* pdu) {
guamiGroup = new GUAMI();
if (!guamiGroup) guamiGroup = new GUAMI();
if (!guamiGroup->decodefromGUAMI(&pdu->gUAMI)) return false;
if (pdu->backupAMFName) {
backupAMFNameIsSet = true;
......
......@@ -35,8 +35,8 @@ namespace ngap {
//------------------------------------------------------------------------------
TAI::TAI() {
plmnId = NULL;
tac = NULL;
plmnId = nullptr;
tac = nullptr;
}
//------------------------------------------------------------------------------
......@@ -68,7 +68,7 @@ bool TAI::decodefromTAI(Ngap_TAI_t* tai) {
//------------------------------------------------------------------------------
void TAI::getTAI(PlmnId*& m_plmnId, TAC*& m_tac) {
m_plmnId = plmnId;
m_tac = tac;
if (plmnId) m_plmnId = plmnId;
if (tac) m_tac = tac;
}
} // namespace ngap
......@@ -105,7 +105,7 @@ bool UEAssociationLogicalNGConnectionItem::encode(
//------------------------------------------------------------------------------
bool UEAssociationLogicalNGConnectionItem::decode(
Ngap_UE_associatedLogicalNG_connectionItem_t* item) {
amfUeNgapId = new AMF_UE_NGAP_ID();
if (!amfUeNgapId) amfUeNgapId = new AMF_UE_NGAP_ID();
if (!amfUeNgapId->decodefromAMF_UE_NGAP_ID(*item->aMF_UE_NGAP_ID)) {
cout << "Decoded NGAP AMF_UE_NGAP_ID IE error" << endl;
return false;
......
......@@ -24,6 +24,11 @@
#include <iostream>
#include <vector>
using namespace std;
extern "C" {
#include "dynamic_memory_check.h"
}
namespace ngap {
dRBSubjectList::dRBSubjectList() {
drbsubjectitem = nullptr;
......@@ -46,7 +51,10 @@ bool dRBSubjectList::encodefromdRBSubjectlist(
1, sizeof(Ngap_DRBsSubjectToStatusTransferItem_t));
if (!ie) return false;
if (!drbsubjectitem) return false;
if (!drbsubjectitem) {
free_wrapper((void**) &ie);
return false;
}
if (!drbsubjectitem[i].encodedRBSubjectItem(ie)) {
cout << "encodefromdRBSubjectlist error" << endl;
return false;
......
......@@ -104,7 +104,7 @@ void DownlinkRANStatusTransfer::setRANStatusTransfer_TransparentContainer(
new RANStatusTransferTransparentContainer();
}
Ngap_DRB_ID_t* dRB_id = (Ngap_DRB_ID_t*) calloc(1, sizeof(Ngap_DRB_ID_t));
dRB_id = &drb_id;
*dRB_id = drb_id;
COUNTValueForPDCP_SN18* UL_value =
(COUNTValueForPDCP_SN18*) calloc(1, sizeof(COUNTValueForPDCP_SN18));
UL_value->setvalue(ul_pcdp, ul_hfn_pdcp);
......
......@@ -89,11 +89,11 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
handoverCommandIEs = &handoverCommandPdu->choice.successfulOutcome->value
.choice.HandoverCommand;
} else {
Logger::ngap().error("Check HandoverCommand message error");
Logger::ngap().error("Check Handover Command message error");
return false;
}
} else {
Logger::ngap().error("HandoverRequired MessageType error");
Logger::ngap().error("Handover Command MessageType error");
return false;
}
for (int i = 0; i < handoverCommandIEs->protocolIEs.list.count; i++) {
......@@ -107,11 +107,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)) {
Logger::ngap().error("Decoded ngap AMF_UE_NGAP_ID IE error");
Logger::ngap().error("Decoded NGAP AMF_UE_NGAP_ID IE error");
return false;
}
} 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;
}
} break;
......@@ -124,11 +124,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)) {
Logger::ngap().error("Decoded ngap RAN_UE_NGAP_ID IE error");
Logger::ngap().error("Decoded NGAP RAN_UE_NGAP_ID IE error");
return false;
}
} 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;
}
} break;
......@@ -141,7 +141,7 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
*ngap_handovertype = handoverCommandIEs->protocolIEs.list.array[i]
->value.choice.HandoverType;
} else {
Logger::ngap().error("Decoded ngap Handover Type IE error");
Logger::ngap().error("Decoded NGAP Handover Type IE error");
return false;
}
} break;
......@@ -152,7 +152,7 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
Ngap_HandoverCommandIEs__value_PR_PDUSessionResourceHandoverList) {
} else {
Logger::ngap().error(
"Decoded ngap PDUSessionResourceHandoverList IE error");
"Decoded NGAP PDUSessionResourceHandoverList IE error");
return false;
}
} break;
......@@ -163,7 +163,7 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
Ngap_HandoverCommandIEs__value_PR_PDUSessionResourceToReleaseListHOCmd) {
} else {
Logger::ngap().error(
"Decoded ngap PDUSessionResourceToReleaseListHOCmd IE error");
"Decoded NGAP PDUSessionResourceToReleaseListHOCmd IE error");
return false;
}
} break;
......@@ -174,7 +174,7 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
Ngap_HandoverCommandIEs__value_PR_TargetToSource_TransparentContainer) {
} else {
Logger::ngap().error(
"Decoded ngap TargetToSource_TransparentContainer IE error");
"Decoded NGAP TargetToSource_TransparentContainer IE error");
return false;
}
} break;
......@@ -184,7 +184,7 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
handoverCommandIEs->protocolIEs.list.array[i]->value.present ==
Ngap_HandoverCommandIEs__value_PR_CriticalityDiagnostics) {
} else {
Logger::ngap().error("Decoded ngap CriticalityDiagnostics IE error");
Logger::ngap().error("Decoded NGAP CriticalityDiagnostics IE error");
return false;
}
} break;
......@@ -203,7 +203,8 @@ int HandoverCommandMsg::encode2buffer(uint8_t* buf, int buf_size) {
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, handoverCommandPdu);
asn_enc_rval_t er = aper_encode_to_buffer(
&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;
}
......@@ -230,7 +231,7 @@ void HandoverCommandMsg::setMessageType() {
.choice.HandoverCommand);
} else {
Logger::ngap().warn(
"This information doesn't refer to HandoverCommand message");
"This information doesn't refer to Handover Command message");
}
}
......
......@@ -53,7 +53,13 @@ HandoverNotifyMsg::HandoverNotifyMsg() {
}
//------------------------------------------------------------------------------
HandoverNotifyMsg::~HandoverNotifyMsg(){};
HandoverNotifyMsg::~HandoverNotifyMsg() {
if (amfUeNgapId) delete (amfUeNgapId);
if (ranUeNgapId) delete (ranUeNgapId);
if (userLocationInformation) delete (userLocationInformation);
if (handoverNotifyPdu) free(handoverNotifyPdu);
if (handoverNotifyIEs) free(handoverNotifyIEs);
};
//------------------------------------------------------------------------------
unsigned long HandoverNotifyMsg::getAmfUeNgapId() {
......@@ -68,7 +74,8 @@ 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(
&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;
}
......@@ -106,11 +113,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)) {
Logger::ngap().error("Decoded ngap AMF_UE_NGAP_ID IE error");
Logger::ngap().error("Decoded NGAP AMF_UE_NGAP_ID IE error");
return false;
}
} 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;
}
} break;
......@@ -123,29 +130,33 @@ 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)) {
Logger::ngap().error("Decoded ngap RAN_UE_NGAP_ID IE error");
Logger::ngap().error("Decoded NGAP RAN_UE_NGAP_ID IE error");
return false;
}
} 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;
}
} break;
case Ngap_ProtocolIE_ID_id_UserLocationInformation: {
if (handoverNotifyIEs->protocolIEs.list.array[i]->criticality ==
Ngap_Criticality_ignore &&
handoverNotifyIEs->protocolIEs.list.array[i]->value.present ==
Ngap_HandoverNotifyIEs__value_PR_UserLocationInformation) {
// TODO: Temporarily disable Criticality check to be tested with dsTest
/*if (handoverNotifyIEs->protocolIEs.list.array[i]->criticality ==
Ngap_Criticality_ignore &&
handoverNotifyIEs->protocolIEs.list.array[i]->value.present ==
Ngap_HandoverNotifyIEs__value_PR_UserLocationInformation) {
*/
if (handoverNotifyIEs->protocolIEs.list.array[i]->value.present ==
Ngap_HandoverNotifyIEs__value_PR_UserLocationInformation) {
userLocationInformation = new UserLocationInformation();
if (!userLocationInformation->decodefromUserLocationInformation(
&handoverNotifyIEs->protocolIEs.list.array[i]
->value.choice.UserLocationInformation)) {
Logger::ngap().error(
"Decoded ngap UserLocationInformation IE error");
"Decoded NGAP UserLocationInformation IE error");
return false;
}
} else {
Logger::ngap().error("Decoded ngap UserLocationInformation IE error");
Logger::ngap().error("Decoded NGAP UserLocationInformation IE error");
return false;
}
} break;
......@@ -164,8 +175,6 @@ void HandoverNotifyMsg::setUserLocationInfoNR(
if (!userLocationInformation)
userLocationInformation = new UserLocationInformation();
// userLocationInformation->setInformation(UserLocationInformationEUTRA *
// informationEUTRA);
UserLocationInformationNR* informationNR = new UserLocationInformationNR();
NR_CGI* nR_CGI = new NR_CGI();
PlmnId* plmnId_cgi = new PlmnId();
......@@ -216,24 +225,32 @@ bool HandoverNotifyMsg::getUserLocationInfoNR(
struct NrCgi_s& cig, struct Tai_s& tai) {
if (!userLocationInformation) return false;
UserLocationInformationNR* informationNR;
UserLocationInformationNR* informationNR = nullptr;
userLocationInformation->getInformation(informationNR);
if (!informationNR) return false;
if (userLocationInformation->getChoiceOfUserLocationInformation() !=
Ngap_UserLocationInformation_PR_userLocationInformationNR)
return false;
NR_CGI* nR_CGI;
TAI* nR_TAI;
NR_CGI* nR_CGI = nullptr;
TAI* nR_TAI = nullptr;
informationNR->getInformationNR(nR_CGI, nR_TAI);
PlmnId* cgi_plmnId;
NRCellIdentity* nRCellIdentity;
if (!nR_CGI or !nR_TAI) return false;
PlmnId* cgi_plmnId = nullptr;
NRCellIdentity* nRCellIdentity = nullptr;
nR_CGI->getNR_CGI(cgi_plmnId, nRCellIdentity);
if (!cgi_plmnId or !nRCellIdentity) return false;
cgi_plmnId->getMcc(cig.mcc);
cgi_plmnId->getMnc(cig.mnc);
cig.nrCellID = nRCellIdentity->getNRCellIdentity();
PlmnId* tai_plmnId;
TAC* tac;
PlmnId* tai_plmnId = nullptr;
TAC* tac = nullptr;
nR_TAI->getTAI(tai_plmnId, tac);
if (!tai_plmnId or !tac) return false;
tai_plmnId->getMcc(tai.mcc);
tai_plmnId->getMnc(tai.mnc);
tai.tac = tac->getTac();
......
......@@ -45,6 +45,7 @@ HandoverPreparationFailure::HandoverPreparationFailure() {
ranUeNgapId = nullptr;
cause = nullptr;
hoPreparationFailureIEs = nullptr;
hoPreparationFailurePdu = nullptr;
CriticalityDiagnostics = nullptr;
}
......@@ -172,7 +173,9 @@ int HandoverPreparationFailure::encode2buffer(uint8_t* buf, int buf_size) {
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, hoPreparationFailurePdu);
asn_enc_rval_t er = aper_encode_to_buffer(
&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;
}
......@@ -260,7 +263,7 @@ void HandoverPreparationFailure::setRanUeNgapId(uint32_t ran_ue_ngap_id) {
void HandoverPreparationFailure::setCause(
Ngap_Cause_PR m_causePresent, long value) //
{
if (!cause) cause = new Cause;
if (!cause) cause = new Cause();
Ngap_HandoverPreparationFailureIEs_t* ie =
(Ngap_HandoverPreparationFailureIEs_t*) calloc(
1, sizeof(Ngap_HandoverPreparationFailureIEs_t));
......
......@@ -229,7 +229,8 @@ int HandoverRequest::encode2buffer(uint8_t* buf, int buf_size) {
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, handoverRequestPdu);
asn_enc_rval_t er = aper_encode_to_buffer(
&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;
}
......@@ -302,7 +303,7 @@ void HandoverRequest::setHandoverType(long type) // 0--intra5gs
//------------------------------------------------------------------------------
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*) calloc(1, sizeof(Ngap_HandoverRequestIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_Cause;
......
......@@ -242,7 +242,8 @@ int HandoverRequestAck::encode2buffer(uint8_t* buf, int buf_size) {
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, handoverRequestAckPdu);
asn_enc_rval_t er = aper_encode_to_buffer(
&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;
}
......
......@@ -97,14 +97,25 @@ long HandoverRequiredMsg::getCauseValue() {
//------------------------------------------------------------------------------
void HandoverRequiredMsg::getGlobalRanNodeId(GlobalgNBId*& ptr) {
if (ptr)
ptr->decodefromGlobalgNBId(
targetid->choice.targetRANNodeID->globalRANNodeID.choice.globalGNB_ID);
if (ptr && targetid) {
if (targetid->present == Ngap_TargetID_PR_targetRANNodeID) {
if (targetid->choice.targetRANNodeID->globalRANNodeID.present ==
Ngap_GlobalRANNodeID_PR_globalGNB_ID) {
ptr->decodefromGlobalgNBId(targetid->choice.targetRANNodeID
->globalRANNodeID.choice.globalGNB_ID);
return;
}
}
}
return;
}
//------------------------------------------------------------------------------
void HandoverRequiredMsg::getTAI(TAI*& ptr) {
if (ptr) ptr->decodefromTAI(&(targetid->choice.targetRANNodeID->selectedTAI));
if (ptr) {
if (targetid->present == Ngap_TargetID_PR_targetRANNodeID)
ptr->decodefromTAI(&(targetid->choice.targetRANNodeID->selectedTAI));
}
}
//------------------------------------------------------------------------------
......@@ -120,15 +131,16 @@ bool HandoverRequiredMsg::getPDUSessionResourceList(
std::vector<PDUSessionResourceItem_t>& list) {
if (!PDUSessionResourceList) return false;
PDUSessionResourceItemHORqd* m_pduSessionResourceItemHORqd;
int num = 0;
PDUSessionResourceItemHORqd* m_pduSessionResourceItemHORqd = nullptr;
int num = 0;
PDUSessionResourceList->getPDUSessionResourceListHORqd(
m_pduSessionResourceItemHORqd, num);
if (!m_pduSessionResourceItemHORqd) return false;
for (int i = 0; i < num; i++) {
PDUSessionResourceItem_t response;
PDUSessionResourceItem_t response = {};
PDUSessionID* m_pDUSessionID;
PDUSessionID* m_pDUSessionID = nullptr;
m_pduSessionResourceItemHORqd[i].getPDUSessionResourceItemHORqd(
m_pDUSessionID, response.HandoverRequiredTransfer);
m_pDUSessionID->getPDUSessionID(response.pduSessionId);
......@@ -314,7 +326,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);
Logger::ngap().debug("er.encoded( %d )", er.encoded);
Logger::ngap().debug(
"Encode Handover Required to buffer, er.encoded( %d)", er.encoded);
return er.encoded;
}
......
......@@ -30,30 +30,37 @@
#include "logger.hpp"
extern "C" {
#include "asn_codecs.h"
#include "constr_TYPE.h"
#include "constraints.h"
//#include "asn_codecs.h"
//#include "constr_TYPE.h"
//#include "constraints.h"
#include "dynamic_memory_check.h"
#include "per_decoder.h"
#include "per_encoder.h"
}
#include <iostream>
using namespace std;
// using namespace std;
namespace ngap {
//------------------------------------------------------------------------------
InitialContextSetupFailureMsg::InitialContextSetupFailureMsg() {
initialContextSetupFailurePdu = NULL;
initialContextSetupFailureIEs = NULL;
amfUeNgapId = NULL;
ranUeNgapId = NULL;
pduSessionResourceFailedToSetupFailureList = NULL;
initialContextSetupFailurePdu = nullptr;
initialContextSetupFailureIEs = nullptr;
amfUeNgapId = nullptr;
ranUeNgapId = nullptr;
pduSessionResourceFailedToSetupFailureList = nullptr;
}
//------------------------------------------------------------------------------
InitialContextSetupFailureMsg::~InitialContextSetupFailureMsg() {}
InitialContextSetupFailureMsg::~InitialContextSetupFailureMsg() {
if (initialContextSetupFailurePdu) free(initialContextSetupFailurePdu);
if (initialContextSetupFailureIEs) free(initialContextSetupFailureIEs);
if (amfUeNgapId) delete (amfUeNgapId);
if (ranUeNgapId) delete (ranUeNgapId);
if (pduSessionResourceFailedToSetupFailureList)
delete (pduSessionResourceFailedToSetupFailureList);
}
//------------------------------------------------------------------------------
void InitialContextSetupFailureMsg::setMessageType() {
......@@ -199,7 +206,6 @@ int InitialContextSetupFailureMsg::encode2buffer(uint8_t* buf, int buf_size) {
}
//------------------------------------------------------------------------------
// Decapsulation
bool InitialContextSetupFailureMsg::decodefrompdu(
Ngap_NGAP_PDU_t* ngap_msg_pdu) {
initialContextSetupFailurePdu = ngap_msg_pdu;
......
......@@ -55,7 +55,6 @@ class InitialContextSetupFailureMsg {
std::vector<PDUSessionResourceFailedToSetupItem_t> list);
int encode2buffer(uint8_t* buf, int buf_size);
// Decapsulation
bool decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu);
unsigned long getAmfUeNgapId();
uint32_t getRanUeNgapId();
......
......@@ -53,6 +53,7 @@ PduSessionResourceSetupRequestMsg::PduSessionResourceSetupRequestMsg() {
nasPdu = nullptr;
pduSessionResourceSetupRequestList = nullptr;
uEAggregateMaxBitRate = nullptr;
pduSessionAggregateMaximumBitRate = nullptr;
}
//------------------------------------------------------------------------------
......@@ -78,6 +79,7 @@ void PduSessionResourceSetupRequestMsg::setUEAggregateMaxBitRate(
ie->value.choice.UEAggregateMaximumBitRate);
if (!ret) {
Logger::ngap().error("Encode NGAP UEAggregateMaxBitRate IE error");
free_wrapper((void**) &ie);
return;
}
......
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