Commit 98461495 authored by Niuhaiwen's avatar Niuhaiwen

add handover and motify configuration file

parent d64549c3
......@@ -37,19 +37,19 @@ AMF =
GUAMI:
{
MCC = "208"; MNC = "95"; RegionID = "128"; AMFSetID = "1"; AMFPointer = "1" # YOUR GUAMI CONFIG HERE
MCC = "110"; MNC = "11"; RegionID = "128"; AMFSetID = "1"; AMFPointer = "1" # YOUR GUAMI CONFIG HERE
}
SERVED_GUAMI_LIST = (
{MCC = "208"; MNC = "95"; RegionID = "128"; AMFSetID = "1"; AMFPointer = "0"}, #48bits <MCC><MNC><RegionID><AMFSetID><AMFPointer>
{MCC = "460"; MNC = "11"; RegionID = "10"; AMFSetID = "1"; AMFPointer = "1"} #48bits <MCC><MNC><RegionID><AMFSetID><AMFPointer>
{MCC = "110"; MNC = "11"; RegionID = "128"; AMFSetID = "1"; AMFPointer = "0"}, #48bits <MCC><MNC><RegionID><AMFSetID><AMFPointer>
{MCC = "110"; MNC = "11"; RegionID = "10"; AMFSetID = "1"; AMFPointer = "1"} #48bits <MCC><MNC><RegionID><AMFSetID><AMFPointer>
);
PLMN_SUPPORT_LIST = (
{
MCC = "208"; MNC = "95"; TAC = 0xa000; # YOUR PLMN CONFIG HERE
MCC = "110"; MNC = "11"; TAC = 100; # YOUR PLMN CONFIG HERE
SLICE_SUPPORT_LIST = (
{SST = "222"; SD = "123"}, # YOUR NSSAI CONFIG HERE
{SST = "1"; SD = "none"}, # YOUR NSSAI CONFIG HERE
{SST = "1"; SD = "12"} # YOUR NSSAI CONFIG HERE
)
}
......@@ -60,7 +60,7 @@ AMF =
# AMF binded interface for N1/N2 interface (NGAP)
NGAP_AMF:
{
INTERFACE_NAME = "ens3"; # YOUR NETWORK CONFIG HERE
INTERFACE_NAME = "ens32"; # YOUR NETWORK CONFIG HERE
IPV4_ADDRESS = "read";
PORT = 38412; # YOUR NETWORK CONFIG HERE
PPID = 60; # YOUR NETWORK CONFIG HERE
......@@ -69,12 +69,12 @@ AMF =
# AMF binded interface for N11
N11:
{
INTERFACE_NAME = "ens3"; # YOUR NETWORK CONFIG HERE
INTERFACE_NAME = "ens32"; # YOUR NETWORK CONFIG HERE
IPV4_ADDRESS = "read";
PORT = 80; # YOUR NETWORK CONFIG HERE
PORT = 8282; # YOUR NETWORK CONFIG HERE
SMF_INSTANCES_POOL = (
{SMF_INSTANCE_ID = 1; IPV4_ADDRESS = "192.168.122.1"; PORT = "80"; VERSION = "v1"; SELECTED = "true"}, # YOUR SMF CONFIG HERE
{SMF_INSTANCE_ID = 1; IPV4_ADDRESS = "192.168.199.203"; PORT = "8889"; VERSION = "v1"; SELECTED = "true"}, # YOUR SMF CONFIG HERE
{SMF_INSTANCE_ID = 2; IPV4_ADDRESS = "192.168.122.2"; PORT = "80"; VERSION = "v1"; SELECTED = "false"} # YOUR SMF CONFIG HERE
);
};
......@@ -85,9 +85,9 @@ AMF =
{
## MySQL mandatory options
MYSQL_server = "127.0.0.1"; # MySQL Server address
MYSQL_user = "root"; # Database server login
MYSQL_user = "bupt"; # Database server login
MYSQL_pass = "linux"; # Database server password
MYSQL_db = "oai_db"; # Your database name
MYSQL_db = "OAI_DB"; # Your database name
## OP
OPERATOR_key = "63bfa50ee6523365ff14c1f45f88737d"; # OP key matching your database
......@@ -96,7 +96,7 @@ AMF =
NAS:
{
ORDERED_SUPPORTED_INTEGRITY_ALGORITHM_LIST = [ "NIA0" , "NIA1" , "NIA2" ];
ORDERED_SUPPORTED_INTEGRITY_ALGORITHM_LIST = [ "NIA2" , "NIA1" , "NIA0" ];
ORDERED_SUPPORTED_CIPHERING_ALGORITHM_LIST = [ "NEA0" , "NEA1" , "NEA2" ];
};
......
......@@ -352,7 +352,7 @@ void amf_n11::handle_pdu_session_initial_request(
supi.c_str(), psc.get()->pdu_session_id);
//TODO: Remove hardcoded values
std::string remote_uri = smf_addr + "/nsmf-pdusession/v1/sm-contexts"; //TODO
std::string remote_uri = smf_addr + "/nsmf-pdusession/v2/sm-contexts"; //TODO
nlohmann::json pdu_session_establishment_request;
pdu_session_establishment_request["supi"] = supi.c_str();
pdu_session_establishment_request["pei"] = "imei-200000000000001";
......
......@@ -66,9 +66,12 @@ extern amf_n11 *amf_n11_inst;
extern amf_config amf_cfg;
extern amf_app *amf_app_inst;
extern statistics stacs;
extern void print_buffer(const std::string app, const std::string commit, uint8_t *buf, int len);
uint32_t ran_id_Global = 0;
uint32_t AMF_TARGET_ran_id_global = 0;
sctp_assoc_id_t downlink_sctp_assoc_id = 0;
sctp_assoc_id_t source_assoc_id = 0;
void amf_n2_task(void*);
......@@ -858,55 +861,53 @@ void amf_n2::handle_itti_message(
}
//------------------------------------------------------------------------------
void amf_n2::handle_itti_message(itti_handover_required &itti_msg) {
void amf_n2::handle_itti_message(itti_handover_required &itti_msg)
{
unsigned long amf_ue_ngap_id = itti_msg.handvoerRequ->getAmfUeNgapId();
uint32_t ran_ue_ngap_id = itti_msg.handvoerRequ->getRanUeNgapId();
ran_id_Global = ran_ue_ngap_id;
std::shared_ptr < gnb_context > gc;
if (!is_assoc_id_2_gnb_context(itti_msg.assoc_id)) {
Logger::amf_n2().error("gnb with assoc_id(%d) is illegal",
itti_msg.assoc_id);
source_assoc_id = itti_msg.assoc_id;
std::shared_ptr<gnb_context> gc;
if (!is_assoc_id_2_gnb_context(itti_msg.assoc_id))
{
Logger::amf_n2().error("gnb with assoc_id(%d) is illegal", itti_msg.assoc_id);
return;
}
gc = assoc_id_2_gnb_context(itti_msg.assoc_id);
std::shared_ptr < ue_ngap_context > unc;
if (!is_ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id)) {
Logger::amf_n2().error(
"UE with ran_ue_ngap_id(0x%x) is not attached to gnb with assoc_id(%d)",
ran_ue_ngap_id, itti_msg.assoc_id);
std::shared_ptr<ue_ngap_context> unc;
if (!is_ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id))
{
Logger::amf_n2().error("UE with ran_ue_ngap_id(0x%x) is not attached to gnb with assoc_id(%d)", ran_ue_ngap_id, itti_msg.assoc_id);
return;
}
if (!is_ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id)) {
Logger::amf_n2().error("no ue ngap context with ran_ue_ngap_id(%d)",
ran_ue_ngap_id);
if (!is_ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id))
{
Logger::amf_n2().error("no ue ngap context with ran_ue_ngap_id(%d)", ran_ue_ngap_id);
return;
}
unc = ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id);
if (unc.get()->amf_ue_ngap_id != amf_ue_ngap_id) {
Logger::amf_n2().error(
"The requested UE(amf_ue_ngap_id:0x%x) is not valid, existed UE which's amf_ue_ngap_id(0x%x)",
amf_ue_ngap_id, unc.get()->amf_ue_ngap_id);
if (unc.get()->amf_ue_ngap_id != amf_ue_ngap_id)
{
Logger::amf_n2().error("The requested UE(amf_ue_ngap_id:0x%x) is not valid, existed UE which's amf_ue_ngap_id(0x%x)", amf_ue_ngap_id, unc.get()->amf_ue_ngap_id);
}
if (itti_msg.handvoerRequ->getHandoverType() != Ngap_HandoverType_intra5gs) {
Logger::amf_n2().error(
"Received Handover Required message,but handover type is not Ngap_HandoverType_intra5gs");
if (itti_msg.handvoerRequ->getHandoverType() != Ngap_HandoverType_intra5gs)
{
Logger::amf_n2().error("Received Handover Required message,but handover type is not Ngap_HandoverType_intra5gs");
return;
}
if (itti_msg.handvoerRequ->getChoiceOfCause() != Ngap_Cause_PR_radioNetwork) {
Logger::amf_n2().error(
"Received Handover Required message,but Cause Of Choice is wrong");
if (itti_msg.handvoerRequ->getChoiceOfCause() != Ngap_Cause_PR_radioNetwork)
{
Logger::amf_n2().error("Received Handover Required message,but Cause Of Choice is wrong");
return;
}
if (itti_msg.handvoerRequ->getCauseValue()
!= Ngap_CauseRadioNetwork_handover_desirable_for_radio_reason) {
Logger::amf_n2().error(
"Received Handover Required message,but Value of Cause is wrong");
if (itti_msg.handvoerRequ->getCauseValue() != Ngap_CauseRadioNetwork_handover_desirable_for_radio_reason)
{
Logger::amf_n2().error("Received Handover Required message,but Value of Cause is wrong");
return;
}
if (itti_msg.handvoerRequ->getDirectForwardingPathAvailability()
!= Ngap_DirectForwardingPathAvailability_direct_path_available) {
Logger::amf_n2().error(
"Received Handover Required message,but DirectForwardingPathAvailability is wrong");
if (itti_msg.handvoerRequ->getDirectForwardingPathAvailability() != Ngap_DirectForwardingPathAvailability_direct_path_available)
{
Logger::amf_n2().error("Received Handover Required message,but DirectForwardingPathAvailability is wrong");
return;
}
GlobalgNBId *TargetGlobalgNBId = new GlobalgNBId();
......@@ -917,9 +918,7 @@ void amf_n2::handle_itti_message(itti_handover_required &itti_msg) {
string mcc, mnc;
plmn->getMcc(mcc);
plmn->getMnc(mnc);
printf(
"handover required:Target ID GlobalRanNodeID PLmn=mcc%s mnc%s gnbid=%x\n",
mcc.c_str(), mnc.c_str(), gnbid->getValue());
printf("handover required:Target ID GlobalRanNodeID PLmn=mcc%s mnc%s gnbid=%x\n", mcc.c_str(), mnc.c_str(), gnbid->getValue());
TAI *tai = new TAI();
itti_msg.handvoerRequ->getTAI(tai);
PlmnId *plmnOfTAI = new PlmnId();
......@@ -928,34 +927,30 @@ void amf_n2::handle_itti_message(itti_handover_required &itti_msg) {
string mccOfselectTAI, mncOfselectTAI;
plmn->getMcc(mccOfselectTAI);
plmn->getMnc(mncOfselectTAI);
printf("handover required:Target ID selectedTAI PLmn=mcc%s mnc%s tac=%x\n",
mccOfselectTAI.c_str(), mncOfselectTAI.c_str(), tac->getTac());
printf("handover required:Target ID selectedTAI PLmn=mcc%s mnc%s tac=%x\n", mccOfselectTAI.c_str(), mncOfselectTAI.c_str(), tac->getTac());
std::vector<PDUSessionResourceItem_t> List_HORqd;
if (!itti_msg.handvoerRequ->getPDUSessionResourceList(List_HORqd)) {
Logger::ngap().error(
"decoding HandoverRequiredMsg getPDUSessionResourceList IE error");
if (!itti_msg.handvoerRequ->getPDUSessionResourceList(List_HORqd))
{
Logger::ngap().error("decoding HandoverRequiredMsg getPDUSessionResourceList IE error");
return;
}
OCTET_STRING_t sourceTotarget;
sourceTotarget =
itti_msg.handvoerRequ->getSourceToTarget_TransparentContainer();
sourceTotarget = itti_msg.handvoerRequ->getSourceToTarget_TransparentContainer();
//send handover request to target gnb
/**********************send handover request to target gnb*******************************/
HandoverRequest *handoverrequest = new HandoverRequest();
handoverrequest->setMessageType();
handoverrequest->setAmfUeNgapId(amf_ue_ngap_id);
handoverrequest->setHandoverType(0);
handoverrequest->setCause(
Ngap_Cause_PR_radioNetwork,
Ngap_CauseRadioNetwork_handover_desirable_for_radio_reason);
handoverrequest->setCause(Ngap_Cause_PR_radioNetwork, Ngap_CauseRadioNetwork_handover_desirable_for_radio_reason);
handoverrequest->setUEAggregateMaximumBitRate(300000000, 100000000);
handoverrequest->setUESecurityCapabilities(0, 1, 2, 3);
handoverrequest->setUESecurityCapabilities(0xe000, 0xe000, 0xe000, 0xe000);
S_NSSAI s_nssai;
s_nssai.setSst("01");
std::vector < S_NSSAI > Allowed_Nssai;
std::vector<S_NSSAI> Allowed_Nssai;
Allowed_Nssai.push_back(s_nssai);
handoverrequest->setAllowedNSSAI(Allowed_Nssai);
//handoverrequest->setAllowedNSSAI(Allowed_Nssai);
Guami_t guami;
guami.mcc = amf_cfg.guami.mcc;
guami.mnc = amf_cfg.guami.mnc;
......@@ -970,22 +965,43 @@ void amf_n2::handle_itti_message(itti_handover_required &itti_msg) {
m_aMFRegionID->setAMFRegionID(guami.regionID);
m_aMFSetID->setAMFSetID(guami.AmfSetID);
m_aMFPointer->setAMFPointer(guami.AmfPointer);
handoverrequest->setGUAMI(m_plmnId, m_aMFRegionID, m_aMFSetID, m_aMFPointer);
//handoverrequest->setMobilityRestrictionList(m_plmnId);
//handoverrequest->setGUAMI(m_plmnId, m_aMFRegionID, m_aMFSetID, m_aMFPointer);
std::shared_ptr < nas_context > nc = amf_n1_inst->amf_ue_id_2_nas_context(
amf_ue_ngap_id);
std::shared_ptr<nas_context> nc = amf_n1_inst->amf_ue_id_2_nas_context(amf_ue_ngap_id);
nas_secu_ctx *secu = nc.get()->security_ctx;
uint8_t *kamf = nc.get()->kamf[secu->vector_pointer];
uint8_t kgnb[32];
uint32_t ulcount = secu->ul_count.seq_num | (secu->ul_count.overflow << 8);
Logger::amf_n1().debug("uplink count(%d)", secu->ul_count.seq_num);
Authentication_5gaka::derive_kgnb(ulcount, 0x01, kamf, kgnb);
bstring kgnb_bs = blk2bstr(kgnb, 32);
handoverrequest->setSecurityContext(2, (uint8_t*) bdata(kgnb_bs));
handoverrequest->setSourceToTarget_TransparentContainer(sourceTotarget);
uint8_t knh[32];
Authentication_5gaka::handover_ncc_derive_knh(ulcount, 0x01, kamf, kgnb, knh, 2);
/*Authentication_5gaka::derive_kgnb(ulcount, 0x01, kamf, kgnb);
print_buffer("amf_n1", "HO:kgnb", kgnb, 32);
//NCC = 1
uint8_t S[35], knh[32];
S[0] = 0x6f;
memcpy(S + 1, kgnb, 32);
S[33] = 0x00;
S[34] = 0x20;
print_buffer("amf_n1", "NCC=1: S", S, 35);
Authentication_5gaka::kdf(kamf, 32, S, 35, knh, 32);
//NCC = 2
uint8_t S2[35], knh2[32];
S2[0] = 0x6f;
memcpy(S2 + 1, knh, 32);
S2[33] = 0x00;
S2[34] = 0x20;
print_buffer("amf_n1", "NCC=2: S2", S2, 35);
Authentication_5gaka::kdf(kamf, 32, S2, 35, knh2, 32);
print_buffer("amf_n1", "Knh2", knh2, 32);
bstring knh_bs = blk2bstr(knh2, 32);*/
bstring knh_bs = blk2bstr(knh, 32);
handoverrequest->setSecurityContext(2 /*NCC count*/, (uint8_t *)bdata(knh_bs));
//handoverrequest->setSourceToTarget_TransparentContainer(sourceTotarget);
string supi = "imsi-" + nc.get()->imsi;
std::shared_ptr<pdu_session_context> psc = amf_n11_inst->supi_to_pdu_ctx(
supi);
std::shared_ptr<pdu_session_context> psc = amf_n11_inst->supi_to_pdu_ctx(supi);
std::vector<PDUSessionResourceSetupRequestItem_t> list;
PDUSessionResourceSetupRequestItem_t item;
item.pduSessionId = psc.get()->pdu_session_id;
......@@ -993,64 +1009,69 @@ void amf_n2::handle_itti_message(itti_handover_required &itti_msg) {
item.s_nssai.sd = "";
item.pduSessionNAS_PDU = NULL;
bstring n2sm = psc.get()->n2sm;
if (blength(psc.get()->n2sm) != 0) {
item.pduSessionResourceSetupRequestTransfer.buf = (uint8_t*) bdata(
psc.get()->n2sm);
if (blength(psc.get()->n2sm) != 0)
{
item.pduSessionResourceSetupRequestTransfer.buf = (uint8_t *)bdata(psc.get()->n2sm);
item.pduSessionResourceSetupRequestTransfer.size = blength(psc.get()->n2sm);
} else {
}
else
{
Logger::amf_n2().error("n2sm empty!");
}
list.push_back(item);
handoverrequest->setPduSessionResourceSetupList(list);
handoverrequest->setAllowedNSSAI(Allowed_Nssai);
handoverrequest->setSourceToTarget_TransparentContainer(sourceTotarget);
handoverrequest->setMobilityRestrictionList(m_plmnId);
handoverrequest->setGUAMI(m_plmnId, m_aMFRegionID, m_aMFSetID, m_aMFPointer);
uint8_t buffer[20240];
int encoded_size = handoverrequest->encode2buffer(buffer, 20240);
bstring b = blk2bstr(buffer, encoded_size);
std::shared_ptr < gnb_context > gc_target;
std::shared_ptr<gnb_context> gc_target;
gc_target = gnb_id_2_gnb_context(gnbid->getValue());
downlink_sctp_assoc_id = gc_target.get()->sctp_assoc_id;
sctp_s_38412.sctp_send_msg(gc_target.get()->sctp_assoc_id, 0, &b);
}
//------------------------------------------------------------------------------
void amf_n2::handle_itti_message(itti_handover_request_Ack &itti_msg) {
void amf_n2::handle_itti_message(itti_handover_request_Ack &itti_msg)
{
unsigned long amf_ue_ngap_id = itti_msg.handoverrequestAck->getAmfUeNgapId();
uint32_t ran_ue_ngap_id = itti_msg.handoverrequestAck->getRanUeNgapId();
AMF_TARGET_ran_id_global = ran_ue_ngap_id;
Logger::amf_n2().error(
"handover request Ack ran_ue_ngap_id(0x%d) amf_ue_ngap_id(%d)",
ran_ue_ngap_id, amf_ue_ngap_id);
std::shared_ptr < gnb_context > gc;
if (!is_assoc_id_2_gnb_context(itti_msg.assoc_id)) {
Logger::amf_n2().error("gnb with assoc_id(%d) is illegal",
itti_msg.assoc_id);
Logger::amf_n2().error("handover request Ack ran_ue_ngap_id(0x%d) amf_ue_ngap_id(%d)", ran_ue_ngap_id, amf_ue_ngap_id);
std::shared_ptr<gnb_context> gc;
if (!is_assoc_id_2_gnb_context(itti_msg.assoc_id))
{
Logger::amf_n2().error("gnb with assoc_id(%d) is illegal", itti_msg.assoc_id);
return;
}
gc = assoc_id_2_gnb_context(itti_msg.assoc_id);
std::vector<PDUSessionResourceAdmittedItem_t> list;
if (!itti_msg.handoverrequestAck->getPDUSessionResourceAdmittedList(list)) {
Logger::ngap().error(
"decoding HandoverRequestACK getPDUSessionResourceList IE error");
if (!itti_msg.handoverrequestAck->getPDUSessionResourceAdmittedList(list))
{
Logger::ngap().error("decoding HandoverRequestACK getPDUSessionResourceList IE error");
return;
}
OCTET_STRING_t targetTosource;
targetTosource = itti_msg.handoverrequestAck
->getTargetToSource_TransparentContainer();
targetTosource = itti_msg.handoverrequestAck->getTargetToSource_TransparentContainer();
PDUSessionResourceHandoverRequestAckTransfer *PDUHandoverRequestAckTransfer =
new PDUSessionResourceHandoverRequestAckTransfer();
/**************************add-start**************************/
PDUSessionResourceHandoverRequestAckTransfer *PDUHandoverRequestAckTransfer = new PDUSessionResourceHandoverRequestAckTransfer();
uint8_t buf[1024];
cout << list[0].handoverRequestAcknowledgeTransfer.buf << endl;
cout << list[0].handoverRequestAcknowledgeTransfer.size << endl;
memcpy(buf, list[0].handoverRequestAcknowledgeTransfer.buf,
list[0].handoverRequestAcknowledgeTransfer.size);
if (!PDUHandoverRequestAckTransfer->decodefromHandoverRequestAckTransfer(
buf, list[0].handoverRequestAcknowledgeTransfer.size)) {
memcpy(buf, list[0].handoverRequestAcknowledgeTransfer.buf, list[0].handoverRequestAcknowledgeTransfer.size);
if (!PDUHandoverRequestAckTransfer->decodefromHandoverRequestAckTransfer(buf, list[0].handoverRequestAcknowledgeTransfer.size))
{
cout << "decode handoverrequestacktransfer error" << endl;
return;
}
GtpTunnel_t *gtptunnel = new GtpTunnel_t();
if (!PDUHandoverRequestAckTransfer->getUpTransportLayerInformation2(
gtptunnel)) {
if (!PDUHandoverRequestAckTransfer->getUpTransportLayerInformation2(gtptunnel))
{
cout << "decode GtpTunnel error" << endl;
return;
}
......@@ -1059,25 +1080,22 @@ void amf_n2::handle_itti_message(itti_handover_request_Ack &itti_msg) {
n3_ip_address = gtptunnel->ip_address;
teid = gtptunnel->gtp_teid;
std::vector<QosFlowLItemWithDataForwarding_t> QosFlowWithDataForwardinglist;
PDUHandoverRequestAckTransfer->getqosFlowSetupResponseList(
QosFlowWithDataForwardinglist);
PDUHandoverRequestAckTransfer->getqosFlowSetupResponseList(QosFlowWithDataForwardinglist);
long qosflowidentifiervalue;
qosflowidentifiervalue = (long) QosFlowWithDataForwardinglist[0]
.qosFlowIdentifier;
qosflowidentifiervalue = (long)QosFlowWithDataForwardinglist[0].qosFlowIdentifier;
cout << "QFI get is " << qosflowidentifiervalue << endl;
/**************************add-end**************************/
//send HandoverCommandMsg to Source gnb
/**************************send HandoverCommandMsg to Source gnb**************************/
HandoverCommandMsg *handovercommand = new HandoverCommandMsg();
handovercommand->setMessageType();
handovercommand->setAmfUeNgapId(amf_ue_ngap_id);
handovercommand->setRanUeNgapId(ran_id_Global);
handovercommand->setHandoverType(Ngap_HandoverType_intra5gs);
handovercommand->setTargetToSource_TransparentContainer(targetTosource);
std::shared_ptr < nas_context > nc = amf_n1_inst->amf_ue_id_2_nas_context(
amf_ue_ngap_id);
std::shared_ptr<nas_context> nc = amf_n1_inst->amf_ue_id_2_nas_context(amf_ue_ngap_id);
//setPduSessionResourceHandoverList_PDYSessionID_handovercommandtransfer
std::vector < PDUSessionResourceHandoverItem_t > handover_list;
/**************************setPduSessionResourceHandoverList_PDYSessionID_handovercommandtransfer**************************/
std::vector<PDUSessionResourceHandoverItem_t> handover_list;
PDUSessionResourceHandoverItem_t item;
//set pdu id
item.pduSessionId = list[0].pduSessionId;
......@@ -1091,99 +1109,118 @@ void amf_n2::handle_itti_message(itti_handover_request_Ack &itti_msg) {
//transportlayeraddress->setTransportLayerAddress(n3_ip_address);
//GtpTeid *gtpTeid = new GtpTeid();
//gtpTeid->setGtpTeid(teid);
PDUSessionResourceHandoverCommandTransfer *handovercommandtransfer =
new PDUSessionResourceHandoverCommandTransfer();
PDUSessionResourceHandoverCommandTransfer *handovercommandtransfer = new PDUSessionResourceHandoverCommandTransfer();
handovercommandtransfer->setQosFlowToBeForwardedList(forward_list);
GtpTunnel_t uptlinfo;
uptlinfo.gtp_teid = teid;
uptlinfo.ip_address = n3_ip_address;
handovercommandtransfer->setUPTransportLayerInformation(uptlinfo);
//handovercommand->setTargetToSource_TransparentContainer(targetTosource);
uint8_t buffer2[500];
int encoded_size2 = handovercommandtransfer
->encodePDUSessionResourceHandoverCommandTransfer(buffer2, 500);
int encoded_size2 = handovercommandtransfer->encodePDUSessionResourceHandoverCommandTransfer(buffer2, 500);
OCTET_STRING_t OCT_handovercommandtransfer;
OCT_handovercommandtransfer.buf = buffer2;
OCT_handovercommandtransfer.size = encoded_size2;
item.HandoverCommandTransfer = OCT_handovercommandtransfer;
handover_list.push_back(item);
handovercommand->setPduSessionResourceHandoverList(handover_list);
//setPduSessionResourceHandoverList_PDYSessionID_handovercommandtransfer-end
handovercommand->setTargetToSource_TransparentContainer(targetTosource);
/**************************setPduSessionResourceHandoverList_PDYSessionID_handovercommandtransfer-end**************************/
uint8_t buffer[10240];
int encoded_size = handovercommand->encode2buffer(buffer, 10240);
bstring b = blk2bstr(buffer, encoded_size);
std::shared_ptr < ue_ngap_context > ngc = ran_ue_id_2_ue_ngap_context(
nc.get()->ran_ue_ngap_id);
sctp_s_38412.sctp_send_msg(ngc.get()->gnb_assoc_id, 0, &b);
std::shared_ptr<ue_ngap_context> unc;
if (!is_ran_ue_id_2_ue_ngap_context(ran_id_Global))
{
Logger::amf_n2().debug("Create a new ue ngap context with ran_ue_ngap_id(0x%x)", ran_id_Global);
unc = std::shared_ptr<ue_ngap_context>(new ue_ngap_context());
set_ran_ue_ngap_id_2_ue_ngap_context(ran_id_Global, unc);
unc.get()->gnb_assoc_id = source_assoc_id;
}
//std::shared_ptr<ue_ngap_context> ngc = ran_ue_id_2_ue_ngap_context(nc.get()->ran_ue_ngap_id);
//std::shared_ptr<ue_ngap_context> ngc = ran_ue_id_2_ue_ngap_context(ran_id_Global);
//sctp_s_38412.sctp_send_msg(ngc.get()->gnb_assoc_id, 0, &b);
sctp_s_38412.sctp_send_msg(unc.get()->gnb_assoc_id, 0, &b);
}
//------------------------------------------------------------------------------
void amf_n2::handle_itti_message(itti_handover_notify &itti_msg) {
void amf_n2::handle_itti_message(itti_handover_notify &itti_msg)
{
unsigned long amf_ue_ngap_id = itti_msg.handovernotify->getAmfUeNgapId();
uint32_t ran_ue_ngap_id = itti_msg.handovernotify->getRanUeNgapId();
Logger::amf_n2().error(
"handover notify ran_ue_ngap_id(0x%d) amf_ue_ngap_id(%d)", ran_ue_ngap_id,
amf_ue_ngap_id);
if (!is_assoc_id_2_gnb_context(itti_msg.assoc_id)) {
Logger::amf_n2().error("gnb with assoc_id(%d) is illegal",
itti_msg.assoc_id);
Logger::amf_n2().error("handover notify ran_ue_ngap_id(0x%d) amf_ue_ngap_id(%d)", ran_ue_ngap_id, amf_ue_ngap_id);
if (!is_assoc_id_2_gnb_context(itti_msg.assoc_id))
{
Logger::amf_n2().error("gnb with assoc_id(%d) is illegal", itti_msg.assoc_id);
return;
}
NrCgi_t NR_CGI = { };
Tai_t TAI = { };
if (!itti_msg.handovernotify->getUserLocationInfoNR(NR_CGI, TAI)) {
NrCgi_t NR_CGI = {};
Tai_t TAI = {};
if (!itti_msg.handovernotify->getUserLocationInfoNR(NR_CGI, TAI))
{
Logger::amf_n2().debug("Missing IE UserLocationInformationNR");
return;
}
std::shared_ptr < nas_context > nc = amf_n1_inst->amf_ue_id_2_nas_context(
amf_ue_ngap_id);
UEContextReleaseCommandMsg *ueContextReleaseCommand = new UEContextReleaseCommandMsg();
ueContextReleaseCommand->setMessageType();
ueContextReleaseCommand->setUeNgapIdPair(amf_ue_ngap_id, ran_id_Global);
ueContextReleaseCommand->setCauseRadioNetwork(Ngap_CauseRadioNetwork_successful_handover);
uint8_t buffer[10240];
int encoded_size = ueContextReleaseCommand->encode2buffer(buffer, 10240);
bstring b = blk2bstr(buffer, encoded_size);
std::shared_ptr<nas_context> nc = amf_n1_inst->amf_ue_id_2_nas_context(amf_ue_ngap_id);
std::shared_ptr<ue_ngap_context> ngc = ran_ue_id_2_ue_ngap_context(nc.get()->ran_ue_ngap_id);
sctp_s_38412.sctp_send_msg(ngc.get()->gnb_assoc_id, 0, &b);
/*std::shared_ptr<nas_context> nc = amf_n1_inst->amf_ue_id_2_nas_context(amf_ue_ngap_id);
string supi = "imsi-" + nc.get()->imsi;
std::shared_ptr<pdu_session_context> psc = amf_n11_inst->supi_to_pdu_ctx(
supi);
itti_nsmf_pdusession_update_sm_context *itti_nsmf_msg =
new itti_nsmf_pdusession_update_sm_context(TASK_AMF_N2, TASK_AMF_N11);
std::shared_ptr<pdu_session_context> psc = amf_n11_inst->supi_to_pdu_ctx(supi);
itti_nsmf_pdusession_update_sm_context *itti_nsmf_msg = new itti_nsmf_pdusession_update_sm_context(TASK_AMF_N2, TASK_AMF_N11);
itti_nsmf_msg->supi = supi;
itti_nsmf_msg->pdu_session_id = psc.get()->pdu_session_id;
itti_nsmf_msg->n2sm = psc.get()->n2sm;
std::shared_ptr<itti_nsmf_pdusession_update_sm_context> i = std::shared_ptr
< itti_nsmf_pdusession_update_sm_context > (itti_nsmf_msg);
int ret = itti_inst->send_msg(i);
if (0 != ret) {
Logger::ngap().error("Could not send ITTI message %s to task TASK_AMF_N11",
i->get_msg_name());
std::shared_ptr<itti_nsmf_pdusession_update_sm_context> i = std::shared_ptr<itti_nsmf_pdusession_update_sm_context>(itti_nsmf_msg);
//int ret = itti_inst->send_msg(i);*/
std::shared_ptr<ue_ngap_context> unc;
if (!is_ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id))
{
Logger::amf_n2().debug("Create a new ue ngap context with ran_ue_ngap_id(0x%x)", ran_ue_ngap_id);
unc = std::shared_ptr<ue_ngap_context>(new ue_ngap_context());
set_ran_ue_ngap_id_2_ue_ngap_context(ran_ue_ngap_id, unc);
unc.get()->gnb_assoc_id = ngc.get()->gnb_assoc_id;
}
/*if (0 != ret)
{
Logger::ngap().error("Could not send ITTI message %s to task TASK_AMF_N11", i->get_msg_name());
}*/
}
void amf_n2::handle_itti_message(itti_uplinkranstatsutransfer &itti_msg) {
//------------------------------------------------------------------------------
void amf_n2::handle_itti_message(itti_uplinkranstatsutransfer &itti_msg)
{
unsigned long amf_ue_ngap_id = itti_msg.uplinkrantransfer->getAmfUeNgapId();
Logger::amf_n2().error("uplinkranstatustransfer amf_ue_ngap_id(%d)",
amf_ue_ngap_id);
if (!is_assoc_id_2_gnb_context(itti_msg.assoc_id)) {
Logger::amf_n2().error("gnb with assoc_id(%d) is illegal",
itti_msg.assoc_id);
Logger::amf_n2().error("uplinkranstatustransfer amf_ue_ngap_id(%d)", amf_ue_ngap_id);
if (!is_assoc_id_2_gnb_context(itti_msg.assoc_id))
{
Logger::amf_n2().error("gnb with assoc_id(%d) is illegal", itti_msg.assoc_id);
return;
}
RANStatusTransferTransparentContainer *ran_status_transfer =
(RANStatusTransferTransparentContainer*) calloc(
1, sizeof(RANStatusTransferTransparentContainer));
itti_msg.uplinkrantransfer->getRANStatusTransfer_TransparentContainer(
ran_status_transfer);
dRBSubjectList *amf_m_list = (dRBSubjectList*) calloc(1,
sizeof(dRBSubjectList));
RANStatusTransferTransparentContainer *ran_status_transfer = (RANStatusTransferTransparentContainer *)calloc(1, sizeof(RANStatusTransferTransparentContainer));
itti_msg.uplinkrantransfer->getRANStatusTransfer_TransparentContainer(ran_status_transfer);
dRBSubjectList *amf_m_list = (dRBSubjectList *)calloc(1, sizeof(dRBSubjectList));
ran_status_transfer->getdRBSubject_list(amf_m_list);
dRBSubjectItem *amf_m_item = (dRBSubjectItem*) calloc(1,
sizeof(dRBSubjectItem));
dRBSubjectItem *amf_m_item = (dRBSubjectItem *)calloc(1, sizeof(dRBSubjectItem));
int numofitem = 0;
amf_m_list->getdRBSubjectItem(amf_m_item, numofitem);
dRBStatusDL *amf_DL = (dRBStatusDL*) calloc(1, sizeof(dRBStatusDL));
dRBStatusUL *amf_UL = (dRBStatusUL*) calloc(1, sizeof(dRBStatusUL));
Ngap_DRB_ID_t *amf_dRB_id = (Ngap_DRB_ID_t*) calloc(1, sizeof(Ngap_DRB_ID_t));
dRBStatusDL *amf_DL = (dRBStatusDL *)calloc(1, sizeof(dRBStatusDL));
dRBStatusUL *amf_UL = (dRBStatusUL *)calloc(1, sizeof(dRBStatusUL));
Ngap_DRB_ID_t *amf_dRB_id = (Ngap_DRB_ID_t *)calloc(1, sizeof(Ngap_DRB_ID_t));
amf_m_item->getdRBSubjectItem(amf_dRB_id, amf_UL, amf_DL);
dRBStatusUL18 *UL18 = (dRBStatusUL18*) calloc(1, sizeof(dRBStatusUL18));
DRBStatusDL18 *DL18 = (DRBStatusDL18*) calloc(1, sizeof(DRBStatusDL18));
dRBStatusUL18 *UL18 = (dRBStatusUL18 *)calloc(1, sizeof(dRBStatusUL18));
DRBStatusDL18 *DL18 = (DRBStatusDL18 *)calloc(1, sizeof(DRBStatusDL18));
amf_DL->getDRBStatusDL18(DL18);
amf_UL->getdRBStatusUL(UL18);
COUNTValueForPDCP_SN18 *amf_UL_value = (COUNTValueForPDCP_SN18*) calloc(
1, sizeof(COUNTValueForPDCP_SN18));
COUNTValueForPDCP_SN18 *amf_DL_value = (COUNTValueForPDCP_SN18*) calloc(
1, sizeof(COUNTValueForPDCP_SN18));
COUNTValueForPDCP_SN18 *amf_UL_value = (COUNTValueForPDCP_SN18 *)calloc(1, sizeof(COUNTValueForPDCP_SN18));
COUNTValueForPDCP_SN18 *amf_DL_value = (COUNTValueForPDCP_SN18 *)calloc(1, sizeof(COUNTValueForPDCP_SN18));
UL18->getcountvalue(amf_UL_value);
DL18->getcountvalue(amf_DL_value);
long amf_ul_pdcp;
......@@ -1194,21 +1231,17 @@ void amf_n2::handle_itti_message(itti_uplinkranstatsutransfer &itti_msg) {
amf_DL_value->getvalue(amf_dl_pdcp, amf_hfn_dl_pdcp);
long amf_drb_id;
amf_drb_id = *amf_dRB_id;
DownlinkRANStatusTransfer *downLinkranstatustransfer =
new DownlinkRANStatusTransfer();
DownlinkRANStatusTransfer *downLinkranstatustransfer = new DownlinkRANStatusTransfer();
downLinkranstatustransfer->setmessagetype();
downLinkranstatustransfer->setAmfUeNgapId(amf_ue_ngap_id);
downLinkranstatustransfer->setRanUeNgapId(AMF_TARGET_ran_id_global);
downLinkranstatustransfer->setRANStatusTransfer_TransparentContainer(
amf_drb_id, amf_ul_pdcp, amf_hfn_ul_pdcp, amf_dl_pdcp, amf_hfn_dl_pdcp);
downLinkranstatustransfer->setRANStatusTransfer_TransparentContainer(amf_drb_id, amf_ul_pdcp, amf_hfn_ul_pdcp, amf_dl_pdcp, amf_hfn_dl_pdcp);
uint8_t buffer[1024];
int encode_size = downLinkranstatustransfer->encodetobuffer(buffer, 1024);
bstring b = blk2bstr(buffer, encode_size);
std::shared_ptr < ue_ngap_context > ngc = ran_ue_id_2_ue_ngap_context(
AMF_TARGET_ran_id_global);
sctp_s_38412.sctp_send_msg(ngc.get()->gnb_assoc_id, 0, &b);
//std::shared_ptr<ue_ngap_context> ngc = ran_ue_id_2_ue_ngap_context(AMF_TARGET_ran_id_global);
sctp_s_38412.sctp_send_msg(downlink_sctp_assoc_id, 0, &b);
}
//Context management functions
//------------------------------------------------------------------------------
......
......@@ -79,7 +79,7 @@ int IdentityRequest::encode2buffer(uint8_t *buf, int len) {
}
Logger::nas_mm().debug("encoded IdentityRequest message len(%d)",
encoded_size);
return 1;
return encoded_size;
}
//------------------------------------------------------------------------------
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "COUNTValueForPDCP_SN18.hpp"
#include <iostream>
#include <vector>
using namespace std;
namespace ngap {
COUNTValueForPDCP_SN18::COUNTValueForPDCP_SN18() {
pdcp = 0;
hfn_pdcp = 0;
}
COUNTValueForPDCP_SN18::~COUNTValueForPDCP_SN18() {
}
void COUNTValueForPDCP_SN18::setvalue(long pDCP, long hfn_PDCP) {
pdcp = pDCP;
hfn_pdcp = hfn_PDCP;
}
void COUNTValueForPDCP_SN18::getvalue(long &pDCP, long &hFN_PDCP) {
pDCP = pdcp;
hFN_PDCP = hfn_pdcp;
}
bool COUNTValueForPDCP_SN18::encodedCOUNTValueForPDCP_SN18(
Ngap_COUNTValueForPDCP_SN18_t &countvalue) {
countvalue.pDCP_SN18 = pdcp;
countvalue.hFN_PDCP_SN18 = hfn_pdcp;
cout << "the encode pdcp_sn18 is" << countvalue.pDCP_SN18 << endl;
cout << "the encode hfn_pdcp_sn18 is" << countvalue.hFN_PDCP_SN18 << endl;
return true;
}
bool COUNTValueForPDCP_SN18::decodedCOUNTValueForPDCP_SN18(
Ngap_COUNTValueForPDCP_SN18_t &countValue) {
pdcp = countValue.pDCP_SN18;
hfn_pdcp = countValue.hFN_PDCP_SN18;
cout << "the decode pdcp_sn18 is" << countValue.pDCP_SN18 << endl;
cout << "the decode hfn_pdcp_sn18 is" << countValue.hFN_PDCP_SN18 << endl;
return true;
}
} // namespace ngap
namespace ngap
{
COUNTValueForPDCP_SN18::COUNTValueForPDCP_SN18()
{
pdcp = 0;
hfn_pdcp = 0;
}
COUNTValueForPDCP_SN18::~COUNTValueForPDCP_SN18() {}
void COUNTValueForPDCP_SN18::setvalue(long pDCP, long hfn_PDCP)
{
pdcp = pDCP;
hfn_pdcp = hfn_PDCP;
}
void COUNTValueForPDCP_SN18::getvalue(long &pDCP, long &hFN_PDCP)
{
pDCP = pdcp;
hFN_PDCP = hfn_pdcp;
}
bool COUNTValueForPDCP_SN18::encodedCOUNTValueForPDCP_SN18(Ngap_COUNTValueForPDCP_SN18_t *countvalue)
{
countvalue->pDCP_SN18 = pdcp;
countvalue->hFN_PDCP_SN18 = hfn_pdcp;
cout << "the encode pdcp_sn18 is" << countvalue->pDCP_SN18 << endl;
cout << "the encode hfn_pdcp_sn18 is" << countvalue->hFN_PDCP_SN18 << endl;
return true;
}
bool COUNTValueForPDCP_SN18::decodedCOUNTValueForPDCP_SN18(Ngap_COUNTValueForPDCP_SN18_t &countValue)
{
pdcp = countValue.pDCP_SN18;
hfn_pdcp = countValue.hFN_PDCP_SN18;
cout << "the decode pdcp_sn18 is" << countValue.pDCP_SN18 << endl;
cout << "the decode hfn_pdcp_sn18 is" << countValue.hFN_PDCP_SN18 << endl;
return true;
}
} // namespace ngap
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _COUNTVALUEFORPDCP_SN18_H_
#define _COUNTVALUEFORPDCP_SN18_H_
extern "C" {
extern "C"
{
#include "Ngap_COUNTValueForPDCP-SN18.h"
}
namespace ngap {
class COUNTValueForPDCP_SN18 {
private:
/* data */
long pdcp;
long hfn_pdcp;
namespace ngap
{
class COUNTValueForPDCP_SN18
{
private:
/* data */
long pdcp;
long hfn_pdcp;
public:
COUNTValueForPDCP_SN18(/* args */);
virtual ~COUNTValueForPDCP_SN18();
void getvalue(long &pDCP, long &hFN_PDCP);
void setvalue(long pDCP, long hfn_PDCP);
bool encodedCOUNTValueForPDCP_SN18(Ngap_COUNTValueForPDCP_SN18_t &countvalue);
bool decodedCOUNTValueForPDCP_SN18(Ngap_COUNTValueForPDCP_SN18_t &countValue);
};
public:
COUNTValueForPDCP_SN18(/* args */);
virtual ~COUNTValueForPDCP_SN18();
void getvalue(long &pDCP, long &hFN_PDCP);
void setvalue(long pDCP, long hfn_PDCP);
bool encodedCOUNTValueForPDCP_SN18(Ngap_COUNTValueForPDCP_SN18_t *countvalue);
bool decodedCOUNTValueForPDCP_SN18(Ngap_COUNTValueForPDCP_SN18_t &countValue);
};
} // namespace ngap
} // namespace ngap
#endif
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "MobilityRestrictionList.hpp"
#include <iostream>
using namespace std;
namespace ngap
{
//------------------------------------------------------------------------------
MobilityRestrictionList::MobilityRestrictionList()
{
Servingplmn = NULL;
}
//------------------------------------------------------------------------------
MobilityRestrictionList::~MobilityRestrictionList() {}
//------------------------------------------------------------------------------
void MobilityRestrictionList::setMobilityRestrictionList(PlmnId *servingplmn)
{
Servingplmn = servingplmn;
}
//------------------------------------------------------------------------------
bool MobilityRestrictionList::encodeMobilityRestrictionList(Ngap_MobilityRestrictionList_t *mobilityrestrictionlist)
{
if (!Servingplmn->encode2octetstring(mobilityrestrictionlist->servingPLMN))
{
return false;
}
return true;
}
} // namespace ngap
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _MOBILITYRESTRICETIONLIST_H_
#define _MOBILITYRESTRICETIONLIST_H_
#include "PlmnId.hpp"
extern "C"
{
#include "Ngap_MobilityRestrictionList.h"
}
namespace ngap
{
class MobilityRestrictionList
{
public:
MobilityRestrictionList();
virtual ~MobilityRestrictionList();
void setMobilityRestrictionList(PlmnId *servingplmn);
bool encodeMobilityRestrictionList(Ngap_MobilityRestrictionList_t *mobilityrestrictionlist);
private:
PlmnId *Servingplmn;
};
} // namespace ngap
#endif
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "PDUSessionResourceAdmittedItem.hpp"
#include "PDUSessionResourceAdmittedItem.hpp"
#include <iostream>
using namespace std;
namespace ngap {
PDUSessionResourceAdmittedItem::PDUSessionResourceAdmittedItem() {
pDUSessionID = NULL;
}
PDUSessionResourceAdmittedItem::~PDUSessionResourceAdmittedItem() {
}
void PDUSessionResourceAdmittedItem::setPDUSessionResourceAdmittedItem(
PDUSessionID *m_pDUSessionID, OCTET_STRING_t m_handoverrequestAcktransfer) {
pDUSessionID = m_pDUSessionID;
handoverrequestAcktransfer = m_handoverrequestAcktransfer;
}
bool PDUSessionResourceAdmittedItem::encode2PDUSessionResourceAdmittedItem(
Ngap_PDUSessionResourceAdmittedItem_t *pdUSessionResourceAdmittedItem) {
if (!pDUSessionID)
return false;
if (!pDUSessionID->encode2PDUSessionID(
pdUSessionResourceAdmittedItem->pDUSessionID))
return false;
pdUSessionResourceAdmittedItem->handoverRequestAcknowledgeTransfer =
handoverrequestAcktransfer;
namespace ngap{
PDUSessionResourceAdmittedItem::PDUSessionResourceAdmittedItem()
{
pDUSessionID = NULL;
}
PDUSessionResourceAdmittedItem::~PDUSessionResourceAdmittedItem(){}
void PDUSessionResourceAdmittedItem::setPDUSessionResourceAdmittedItem(PDUSessionID *m_pDUSessionID, OCTET_STRING_t m_handoverrequestAcktransfer)
{
pDUSessionID = m_pDUSessionID;
handoverrequestAcktransfer = m_handoverrequestAcktransfer;
}
bool PDUSessionResourceAdmittedItem::encode2PDUSessionResourceAdmittedItem(Ngap_PDUSessionResourceAdmittedItem_t *pdUSessionResourceAdmittedItem)
{
if(!pDUSessionID) return false;
if(!pDUSessionID->encode2PDUSessionID(pdUSessionResourceAdmittedItem->pDUSessionID)) return false;
pdUSessionResourceAdmittedItem->handoverRequestAcknowledgeTransfer = handoverrequestAcktransfer;
return true;
}
//......
bool PDUSessionResourceAdmittedItem::decodefromPDUSessionResourceAdmittedItem(Ngap_PDUSessionResourceAdmittedItem_t *pdUSessionResourceAdmittedItem)
{
pDUSessionID = new PDUSessionID();
if(!pDUSessionID->decodefromPDUSessionID(pdUSessionResourceAdmittedItem->pDUSessionID)) return false;
handoverrequestAcktransfer = pdUSessionResourceAdmittedItem->handoverRequestAcknowledgeTransfer;
return true;
}
void PDUSessionResourceAdmittedItem::getPDUSessionResourceAdmittedItem(PDUSessionID *&m_pDUSessionID, OCTET_STRING_t&m_handoverrequestAcktransfer)
{
m_pDUSessionID = pDUSessionID;
m_handoverrequestAcktransfer = handoverrequestAcktransfer;
}
return true;
}
//�����......
bool PDUSessionResourceAdmittedItem::decodefromPDUSessionResourceAdmittedItem(
Ngap_PDUSessionResourceAdmittedItem_t *pdUSessionResourceAdmittedItem) {
pDUSessionID = new PDUSessionID();
if (!pDUSessionID->decodefromPDUSessionID(
pdUSessionResourceAdmittedItem->pDUSessionID))
return false;
handoverrequestAcktransfer = pdUSessionResourceAdmittedItem
->handoverRequestAcknowledgeTransfer;
return true;
}
void PDUSessionResourceAdmittedItem::getPDUSessionResourceAdmittedItem(
PDUSessionID *&m_pDUSessionID,
OCTET_STRING_t &m_handoverrequestAcktransfer) {
m_pDUSessionID = pDUSessionID;
m_handoverrequestAcktransfer = handoverrequestAcktransfer;
}
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _PDUSESSIONRESOURCEADMITTEDITEM_H_
#define _PDUSESSIONRESOURCEADMITTEDITEM_H_
#include "PDUSessionID.hpp"
#include "PDUSessionResourceHandoverRequestAckTransfer.hpp"
extern "C" {
#include "Ngap_PDUSessionResourceAdmittedItem.h"
extern "C"{
#include "Ngap_PDUSessionResourceAdmittedItem.h"
}
namespace ngap {
class PDUSessionResourceAdmittedItem {
public:
PDUSessionResourceAdmittedItem();
virtual ~PDUSessionResourceAdmittedItem();
void setPDUSessionResourceAdmittedItem(
PDUSessionID *m_pDUSessionID,
OCTET_STRING_t m_handoverrequestAcktransfer);
void getPDUSessionResourceAdmittedItem(
PDUSessionID *&m_pDUSessionID,
OCTET_STRING_t &m_handoverrequestAcktransfer);
bool encode2PDUSessionResourceAdmittedItem(
Ngap_PDUSessionResourceAdmittedItem_t *pdUSessionResourceAdmittedItem);
bool decodefromPDUSessionResourceAdmittedItem(
Ngap_PDUSessionResourceAdmittedItem_t *pdUSessionResourceAdmittedItem);
private:
PDUSessionID *pDUSessionID;
OCTET_STRING_t handoverrequestAcktransfer;
};
namespace ngap{
class PDUSessionResourceAdmittedItem {
public:
PDUSessionResourceAdmittedItem();
virtual ~PDUSessionResourceAdmittedItem();
void setPDUSessionResourceAdmittedItem(PDUSessionID *m_pDUSessionID, OCTET_STRING_t m_handoverrequestAcktransfer);
void getPDUSessionResourceAdmittedItem(PDUSessionID *&m_pDUSessionID, OCTET_STRING_t&m_handoverrequestAcktransfer);
bool encode2PDUSessionResourceAdmittedItem(Ngap_PDUSessionResourceAdmittedItem_t *pdUSessionResourceAdmittedItem);
bool decodefromPDUSessionResourceAdmittedItem(Ngap_PDUSessionResourceAdmittedItem_t *pdUSessionResourceAdmittedItem);
private:
PDUSessionID *pDUSessionID;
OCTET_STRING_t handoverrequestAcktransfer;
};
}
#endif
#include "PDUSessionResourceAdmittedList.hpp"
#include <iostream>
using namespace std;
namespace ngap{
PDUSessionResourceAdmittedList::PDUSessionResourceAdmittedList()
{
pduSessionResourceAdmittedItem = NULL;
numofSessionResourceAdmittedItem = 0;
}
PDUSessionResourceAdmittedList::~PDUSessionResourceAdmittedList(){}
void PDUSessionResourceAdmittedList::setPDUSessionResourceAdmittedList(PDUSessionResourceAdmittedItem *m_pduSessionResourceAdmittedItem,int num)
{
pduSessionResourceAdmittedItem = m_pduSessionResourceAdmittedItem;
numofSessionResourceAdmittedItem = num;
}
bool PDUSessionResourceAdmittedList::encode2PDUSessionResourceAdmittedList(Ngap_PDUSessionResourceAdmittedList_t *pduSessionResourceAdmittedList)
{
for(int i=0;i< numofSessionResourceAdmittedItem;i++)
{
Ngap_PDUSessionResourceAdmittedItem_t *response = (Ngap_PDUSessionResourceAdmittedItem_t *)calloc(1,sizeof(Ngap_PDUSessionResourceAdmittedItem_t));
if(!response) return false;
if(!pduSessionResourceAdmittedItem[i].encode2PDUSessionResourceAdmittedItem(response)) return false;
if(ASN_SEQUENCE_ADD(&pduSessionResourceAdmittedList->list, response) != 0) return false;
}
return true;
}
bool PDUSessionResourceAdmittedList::decodefromPDUSessionResourceAdmittedList(Ngap_PDUSessionResourceAdmittedList_t *pduSessionResourceAdmittedList)
{
numofSessionResourceAdmittedItem = pduSessionResourceAdmittedList->list.count;
pduSessionResourceAdmittedItem = new PDUSessionResourceAdmittedItem[numofSessionResourceAdmittedItem]();
for(int i=0;i< numofSessionResourceAdmittedItem;i++)
{
if(!pduSessionResourceAdmittedItem[i].decodefromPDUSessionResourceAdmittedItem(pduSessionResourceAdmittedList->list.array[i])) return false;
}
return true;
}
void PDUSessionResourceAdmittedList::getPDUSessionResourceAdmittedList(PDUSessionResourceAdmittedItem *&m_pduSessionResourceAdmittedItem,int &num)
{
m_pduSessionResourceAdmittedItem = pduSessionResourceAdmittedItem;
num = numofSessionResourceAdmittedItem;
}
}
#include <iostream>
using namespace std;
namespace ngap {
PDUSessionResourceAdmittedList::PDUSessionResourceAdmittedList() {
pduSessionResourceAdmittedItem = NULL;
numofSessionResourceAdmittedItem = 0;
}
PDUSessionResourceAdmittedList::~PDUSessionResourceAdmittedList() {
}
void PDUSessionResourceAdmittedList::setPDUSessionResourceAdmittedList(
PDUSessionResourceAdmittedItem *m_pduSessionResourceAdmittedItem, int num) {
pduSessionResourceAdmittedItem = m_pduSessionResourceAdmittedItem;
numofSessionResourceAdmittedItem = num;
}
bool PDUSessionResourceAdmittedList::encode2PDUSessionResourceAdmittedList(
Ngap_PDUSessionResourceAdmittedList_t *pduSessionResourceAdmittedList) {
for (int i = 0; i < numofSessionResourceAdmittedItem; i++) {
Ngap_PDUSessionResourceAdmittedItem_t *response =
(Ngap_PDUSessionResourceAdmittedItem_t*) calloc(
1, sizeof(Ngap_PDUSessionResourceAdmittedItem_t));
if (!response)
return false;
if (!pduSessionResourceAdmittedItem[i].encode2PDUSessionResourceAdmittedItem(
response))
return false;
if (ASN_SEQUENCE_ADD(&pduSessionResourceAdmittedList->list, response) != 0)
return false;
}
return true;
}
bool PDUSessionResourceAdmittedList::decodefromPDUSessionResourceAdmittedList(
Ngap_PDUSessionResourceAdmittedList_t *pduSessionResourceAdmittedList) {
numofSessionResourceAdmittedItem = pduSessionResourceAdmittedList->list.count;
pduSessionResourceAdmittedItem =
new PDUSessionResourceAdmittedItem[numofSessionResourceAdmittedItem]();
for (int i = 0; i < numofSessionResourceAdmittedItem; i++) {
if (!pduSessionResourceAdmittedItem[i]
.decodefromPDUSessionResourceAdmittedItem(
pduSessionResourceAdmittedList->list.array[i]))
return false;
}
return true;
}
void PDUSessionResourceAdmittedList::getPDUSessionResourceAdmittedList(
PDUSessionResourceAdmittedItem *&m_pduSessionResourceAdmittedItem,
int &num) {
m_pduSessionResourceAdmittedItem = pduSessionResourceAdmittedItem;
num = numofSessionResourceAdmittedItem;
}
}
......@@ -3,32 +3,26 @@
#include "PDUSessionResourceAdmittedItem.hpp"
extern "C" {
#include "Ngap_PDUSessionResourceAdmittedList.h"
extern "C"{
#include "Ngap_PDUSessionResourceAdmittedList.h"
}
namespace ngap {
class PDUSessionResourceAdmittedList {
public:
PDUSessionResourceAdmittedList();
virtual ~PDUSessionResourceAdmittedList();
void setPDUSessionResourceAdmittedList(
PDUSessionResourceAdmittedItem *m_pduSessionResourceAdmittedItem,
int num);
void getPDUSessionResourceAdmittedList(
PDUSessionResourceAdmittedItem *&m_pduSessionResourceAdmittedItem,
int &num);
bool encode2PDUSessionResourceAdmittedList(
Ngap_PDUSessionResourceAdmittedList_t *pduSessionResourceAdmittedList);
bool decodefromPDUSessionResourceAdmittedList(
Ngap_PDUSessionResourceAdmittedList_t *pduSessionResourceAdmittedList);
private:
PDUSessionResourceAdmittedItem *pduSessionResourceAdmittedItem;
int numofSessionResourceAdmittedItem;
};
namespace ngap{
class PDUSessionResourceAdmittedList {
public:
PDUSessionResourceAdmittedList();
virtual ~PDUSessionResourceAdmittedList();
void setPDUSessionResourceAdmittedList(PDUSessionResourceAdmittedItem *m_pduSessionResourceAdmittedItem,int num);
void getPDUSessionResourceAdmittedList(PDUSessionResourceAdmittedItem *&m_pduSessionResourceAdmittedItem,int &num);
bool encode2PDUSessionResourceAdmittedList(Ngap_PDUSessionResourceAdmittedList_t *pduSessionResourceAdmittedList);
bool decodefromPDUSessionResourceAdmittedList(Ngap_PDUSessionResourceAdmittedList_t *pduSessionResourceAdmittedList);
private:
PDUSessionResourceAdmittedItem *pduSessionResourceAdmittedItem;
int numofSessionResourceAdmittedItem;
};
}
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "PDUSessionResourceHandoverCommandTransfer.hpp"
extern "C" {
extern "C"
{
#include "constr_TYPE.h"
#include "asn_codecs.h"
#include "per_encoder.h"
......@@ -35,81 +9,78 @@ extern "C" {
}
#include <iostream>
using namespace std;
namespace ngap {
PDUSessionResourceHandoverCommandTransfer::PDUSessionResourceHandoverCommandTransfer() {
handovercommandtransferIE = (Ngap_HandoverCommandTransfer_t*) calloc(
1, sizeof(Ngap_HandoverCommandTransfer_t));
dLForwardingUP_TNLInformation = NULL;
qosFlowToBeForwardedList = NULL;
}
PDUSessionResourceHandoverCommandTransfer::~PDUSessionResourceHandoverCommandTransfer() {
}
void PDUSessionResourceHandoverCommandTransfer::setQosFlowToBeForwardedList(
std::vector<QosFlowToBeForwardedItem_t> list) {
if (!qosFlowToBeForwardedList)
qosFlowToBeForwardedList = new QosFlowToBeForwardedList();
QosFlowToBeForwardedItem *m_item =
new QosFlowToBeForwardedItem[list.size()]();
for (int i = 0; i < list.size(); i++) {
QosFlowIdentifier *m_qosFlowIdentifier = new QosFlowIdentifier();
m_qosFlowIdentifier->setQosFlowIdentifier(list[i].QFI);
m_item[i].setQosFlowIdentifier(m_qosFlowIdentifier);
}
qosFlowToBeForwardedList->setQosFlowToBeForwardedItem(m_item, list.size());
int ret = qosFlowToBeForwardedList->encodeQosFlowToBeForwardedList(
handovercommandtransferIE->qosFlowToBeForwardedList);
cout << "QFI in list "
<< handovercommandtransferIE->qosFlowToBeForwardedList->list.count
<< endl;
if (handovercommandtransferIE->qosFlowToBeForwardedList->list.array) {
cout << "array OK" << endl;
if (handovercommandtransferIE->qosFlowToBeForwardedList->list.array[0]) {
cout << "QFI in list "
<< handovercommandtransferIE->qosFlowToBeForwardedList->list.array[0]
->qosFlowIdentifier << endl;
} else {
cout << "error1" << endl;
namespace ngap
{
PDUSessionResourceHandoverCommandTransfer::PDUSessionResourceHandoverCommandTransfer()
{
handovercommandtransferIE = (Ngap_HandoverCommandTransfer_t *)calloc(1, sizeof(Ngap_HandoverCommandTransfer_t));
dLForwardingUP_TNLInformation = NULL;
qosFlowToBeForwardedList = NULL;
}
} else {
cout << "error2" << endl;
}
PDUSessionResourceHandoverCommandTransfer::~PDUSessionResourceHandoverCommandTransfer() {}
void PDUSessionResourceHandoverCommandTransfer::setQosFlowToBeForwardedList(std::vector<QosFlowToBeForwardedItem_t> list)
{
if (!qosFlowToBeForwardedList)
qosFlowToBeForwardedList = new QosFlowToBeForwardedList();
QosFlowToBeForwardedItem *m_item = new QosFlowToBeForwardedItem[list.size()]();
for (int i = 0; i < list.size(); i++)
{
QosFlowIdentifier *m_qosFlowIdentifier = new QosFlowIdentifier();
m_qosFlowIdentifier->setQosFlowIdentifier(list[i].QFI);
m_item[i].setQosFlowIdentifier(m_qosFlowIdentifier);
}
qosFlowToBeForwardedList->setQosFlowToBeForwardedItem(m_item, list.size());
int ret = qosFlowToBeForwardedList->encodeQosFlowToBeForwardedList(handovercommandtransferIE->qosFlowToBeForwardedList);
cout << "QFI in list " << handovercommandtransferIE->qosFlowToBeForwardedList->list.count << endl;
if (handovercommandtransferIE->qosFlowToBeForwardedList->list.array)
{
cout << "array OK" << endl;
if (handovercommandtransferIE->qosFlowToBeForwardedList->list.array[0])
{
cout << "QFI in list " << handovercommandtransferIE->qosFlowToBeForwardedList->list.array[0]->qosFlowIdentifier << endl;
}
else
{
cout << "error1" << endl;
}
}
else
{
cout << "error2" << endl;
}
if (!ret) {
cout << "encode QosFlowToBeForwardedList IE error" << endl;
return;
}
}
void PDUSessionResourceHandoverCommandTransfer::setUPTransportLayerInformation(
GtpTunnel_t uptlinfo) {
if (!dLForwardingUP_TNLInformation) {
dLForwardingUP_TNLInformation = new UpTransportLayerInformation();
}
TransportLayerAddress *m_transportLayerAddress = new TransportLayerAddress();
GtpTeid *m_gtpTeid = new GtpTeid();
m_transportLayerAddress->setTransportLayerAddress(uptlinfo.ip_address);
m_gtpTeid->setGtpTeid(uptlinfo.gtp_teid);
dLForwardingUP_TNLInformation->setUpTransportLayerInformation(
m_transportLayerAddress, m_gtpTeid);
Ngap_UPTransportLayerInformation *test =
(Ngap_UPTransportLayerInformation*) calloc(
1, sizeof(Ngap_UPTransportLayerInformation));
handovercommandtransferIE->dLForwardingUP_TNLInformation = test;
int ret = dLForwardingUP_TNLInformation->encode2UpTransportLayerInformation(
*test);
if (!ret) {
cout << "encode dLForwardingUP_TNLInformation IE error";
return;
}
}
int PDUSessionResourceHandoverCommandTransfer::encodePDUSessionResourceHandoverCommandTransfer(
uint8_t *buf, int buf_size) {
asn_fprint(stderr, &asn_DEF_Ngap_HandoverCommandTransfer,
handovercommandtransferIE);
asn_enc_rval_t er = aper_encode_to_buffer(
&asn_DEF_Ngap_HandoverCommandTransfer, NULL, handovercommandtransferIE,
buf, buf_size);
cout << "er.encoded(" << er.encoded << ")" << endl;
return er.encoded;
}
if (!ret)
{
cout << "encode QosFlowToBeForwardedList IE error" << endl;
return;
}
}
void PDUSessionResourceHandoverCommandTransfer::setUPTransportLayerInformation(GtpTunnel_t uptlinfo)
{
if (!dLForwardingUP_TNLInformation)
{
dLForwardingUP_TNLInformation = new UpTransportLayerInformation();
}
TransportLayerAddress *m_transportLayerAddress = new TransportLayerAddress();
GtpTeid *m_gtpTeid = new GtpTeid();
m_transportLayerAddress->setTransportLayerAddress(uptlinfo.ip_address);
m_gtpTeid->setGtpTeid(uptlinfo.gtp_teid);
dLForwardingUP_TNLInformation->setUpTransportLayerInformation(m_transportLayerAddress, m_gtpTeid);
Ngap_UPTransportLayerInformation *test = (Ngap_UPTransportLayerInformation *)calloc(1, sizeof(Ngap_UPTransportLayerInformation));
handovercommandtransferIE->dLForwardingUP_TNLInformation = test;
int ret = dLForwardingUP_TNLInformation->encode2UpTransportLayerInformation(*test);
if (!ret)
{
cout << "encode dLForwardingUP_TNLInformation IE error";
return;
}
}
int PDUSessionResourceHandoverCommandTransfer::encodePDUSessionResourceHandoverCommandTransfer(uint8_t *buf, int buf_size)
{
asn_fprint(stderr, &asn_DEF_Ngap_HandoverCommandTransfer, handovercommandtransferIE);
asn_enc_rval_t er = aper_encode_to_buffer(&asn_DEF_Ngap_HandoverCommandTransfer, NULL, handovercommandtransferIE, buf, buf_size);
cout << "er.encoded(" << er.encoded << ")" << endl;
return er.encoded;
}
} // namespace ngap
} // namespace ngap
\ No newline at end of file
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _PDUSessionResourceHandoverCommandTransfer_H_
#define _PDUSessionResourceHandoverCommandTransfer_H_
#include "UPTransportLayerInformation.hpp"
#include "QosFlowToBeForwardedList.hpp"
#include "NgapIEsStruct.hpp"
extern "C" {
extern "C"
{
#include "Ngap_ProtocolIE-Field.h"
#include "Ngap_HandoverCommandTransfer.h"
}
namespace ngap {
class PDUSessionResourceHandoverCommandTransfer {
private:
/* data */
Ngap_HandoverCommandTransfer_t *handovercommandtransferIE;
UpTransportLayerInformation *dLForwardingUP_TNLInformation;
QosFlowToBeForwardedList *qosFlowToBeForwardedList;
namespace ngap
{
class PDUSessionResourceHandoverCommandTransfer
{
private:
/* data */
Ngap_HandoverCommandTransfer_t *handovercommandtransferIE;
UpTransportLayerInformation *dLForwardingUP_TNLInformation;
QosFlowToBeForwardedList *qosFlowToBeForwardedList;
public:
PDUSessionResourceHandoverCommandTransfer(/* args */);
virtual ~PDUSessionResourceHandoverCommandTransfer();
void setUPTransportLayerInformation(GtpTunnel_t uptlinfo);
void setQosFlowToBeForwardedList(
std::vector<QosFlowToBeForwardedItem_t> list);
int encodePDUSessionResourceHandoverCommandTransfer(uint8_t *buf,
int buf_size);
};
public:
PDUSessionResourceHandoverCommandTransfer(/* args */);
virtual ~PDUSessionResourceHandoverCommandTransfer();
void setUPTransportLayerInformation(GtpTunnel_t uptlinfo);
void setQosFlowToBeForwardedList(std::vector<QosFlowToBeForwardedItem_t> list);
int encodePDUSessionResourceHandoverCommandTransfer(uint8_t *buf, int buf_size);
};
} // namespace ngap
#endif
} // namespace ngap
#endif
\ No newline at end of file
......@@ -20,14 +20,15 @@
*/
/*! \file
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "PDUSessionResourceHandoverRequestAckTransfer.hpp"
extern "C" {
extern "C"
{
#include "constr_TYPE.h"
#include "asn_codecs.h"
#include "per_encoder.h"
......@@ -38,79 +39,78 @@ extern "C" {
#include <iostream>
using namespace std;
namespace ngap {
PDUSessionResourceHandoverRequestAckTransfer::PDUSessionResourceHandoverRequestAckTransfer() {
handoverRequestAcknowledegTransferIEs =
(Ngap_HandoverRequestAcknowledgeTransfer_t*) calloc(
1, sizeof(Ngap_HandoverRequestAcknowledgeTransfer_t));
dLForwardingUP_TNLInformation = NULL;
QosFlowSetupResponseList = NULL;
}
PDUSessionResourceHandoverRequestAckTransfer::~PDUSessionResourceHandoverRequestAckTransfer() {
}
bool PDUSessionResourceHandoverRequestAckTransfer::decodefromHandoverRequestAckTransfer(
uint8_t *buf, int buf_size) {
asn_dec_rval_t rc = asn_decode(
NULL, ATS_ALIGNED_CANONICAL_PER,
&asn_DEF_Ngap_HandoverRequestAcknowledgeTransfer,
(void**) &handoverRequestAcknowledegTransferIEs, buf, buf_size);
if (rc.code == RC_OK) {
cout << "Decoded handoverRequestAcknowledegTransfer successfully" << endl;
} else if (rc.code == RC_WMORE) {
cout << "More data expected, call again" << endl;
return false;
} else {
cout << "Failure to decode handoverRequestAcknowledegTransfer data" << endl;
//return false;
}
cout << "rc.consumed to decode = " << rc.consumed << endl;
cout << endl;
dLForwardingUP_TNLInformation = new UpTransportLayerInformation();
if (!dLForwardingUP_TNLInformation->decodefromUpTransportLayerInformation(
*handoverRequestAcknowledegTransferIEs->dLForwardingUP_TNLInformation)) {
cout << "decoded ngap DL_NGU_UP_TNLInformation IE error" << endl;
return false;
}
QosFlowSetupResponseList = new QosFlowListWithDataForwarding();
if (!QosFlowSetupResponseList->decodeFormQosFlowListWithDataForwarding(
handoverRequestAcknowledegTransferIEs->qosFlowSetupResponseList)) {
cout << "decoded ngap QosFlowSetupResponseList IE error" << endl;
return false;
}
return true;
}
bool PDUSessionResourceHandoverRequestAckTransfer::getUpTransportLayerInformation2(
GtpTunnel_t *&upTnlInfo) {
if (!dLForwardingUP_TNLInformation->decodefromUpTransportLayerInformation(
*handoverRequestAcknowledegTransferIEs->dLForwardingUP_TNLInformation))
return false;
TransportLayerAddress *m_transportLayerAddress;
GtpTeid *m_gtpTeid;
if (!dLForwardingUP_TNLInformation->getUpTransportLayerInformation(
m_transportLayerAddress, m_gtpTeid))
return false;
if (!m_transportLayerAddress->getTransportLayerAddress(upTnlInfo->ip_address))
return false;
if (!m_gtpTeid->getGtpTeid(upTnlInfo->gtp_teid))
return false;
return true;
}
bool PDUSessionResourceHandoverRequestAckTransfer::getqosFlowSetupResponseList(
std::vector<QosFlowLItemWithDataForwarding_t> &list) {
if (!QosFlowSetupResponseList)
return false;
QosFlowItemWithDataForWarding *m_qosflowitemwithdataforwarding;
int num = 0;
if (QosFlowSetupResponseList->getQosFlowListWithDataForwarding(
m_qosflowitemwithdataforwarding, num)) {
cout << "successful decode QosFlowList" << endl;
}
for (int i = 0; i < num; i++) {
QosFlowLItemWithDataForwarding_t response;
m_qosflowitemwithdataforwarding[i].getQosFlowItemWithDataForWarding(
response.qosFlowIdentifier);
list.push_back(response);
}
return true;
}
} // namespace ngap
namespace ngap
{
PDUSessionResourceHandoverRequestAckTransfer::PDUSessionResourceHandoverRequestAckTransfer()
{
handoverRequestAcknowledegTransferIEs = (Ngap_HandoverRequestAcknowledgeTransfer_t *)calloc(1, sizeof(Ngap_HandoverRequestAcknowledgeTransfer_t));
dLForwardingUP_TNLInformation = NULL;
QosFlowSetupResponseList = NULL;
}
PDUSessionResourceHandoverRequestAckTransfer::~PDUSessionResourceHandoverRequestAckTransfer() {}
bool PDUSessionResourceHandoverRequestAckTransfer::decodefromHandoverRequestAckTransfer(uint8_t *buf, int buf_size)
{
asn_dec_rval_t rc = asn_decode(NULL, ATS_ALIGNED_CANONICAL_PER, &asn_DEF_Ngap_HandoverRequestAcknowledgeTransfer, (void **)&handoverRequestAcknowledegTransferIEs, buf, buf_size);
if (rc.code == RC_OK)
{
cout << "Decoded handoverRequestAcknowledegTransfer successfully" << endl;
}
else if (rc.code == RC_WMORE)
{
cout << "More data expected, call again" << endl;
return false;
}
else
{
cout << "Failure to decode handoverRequestAcknowledegTransfer data" << endl;
//return false;
}
cout << "rc.consumed to decode = " << rc.consumed << endl;
cout << endl;
dLForwardingUP_TNLInformation = new UpTransportLayerInformation();
if (!dLForwardingUP_TNLInformation->decodefromUpTransportLayerInformation(*handoverRequestAcknowledegTransferIEs->dLForwardingUP_TNLInformation))
{
cout << "decoded ngap DL_NGU_UP_TNLInformation IE error" << endl;
return false;
}
QosFlowSetupResponseList = new QosFlowListWithDataForwarding();
if (!QosFlowSetupResponseList->decodeFormQosFlowListWithDataForwarding(handoverRequestAcknowledegTransferIEs->qosFlowSetupResponseList))
{
cout << "decoded ngap QosFlowSetupResponseList IE error" << endl;
return false;
}
return true;
}
bool PDUSessionResourceHandoverRequestAckTransfer::getUpTransportLayerInformation2(GtpTunnel_t *&upTnlInfo)
{
if (!dLForwardingUP_TNLInformation->decodefromUpTransportLayerInformation(*handoverRequestAcknowledegTransferIEs->dLForwardingUP_TNLInformation))
return false;
TransportLayerAddress *m_transportLayerAddress;
GtpTeid *m_gtpTeid;
if (!dLForwardingUP_TNLInformation->getUpTransportLayerInformation(m_transportLayerAddress, m_gtpTeid))
return false;
if (!m_transportLayerAddress->getTransportLayerAddress(upTnlInfo->ip_address))
return false;
if (!m_gtpTeid->getGtpTeid(upTnlInfo->gtp_teid))
return false;
return true;
}
bool PDUSessionResourceHandoverRequestAckTransfer::getqosFlowSetupResponseList(std::vector<QosFlowLItemWithDataForwarding_t> &list)
{
if (!QosFlowSetupResponseList)
return false;
QosFlowItemWithDataForWarding *m_qosflowitemwithdataforwarding;
int num = 0;
if (QosFlowSetupResponseList->getQosFlowListWithDataForwarding(m_qosflowitemwithdataforwarding, num))
{
cout << "successful decode QosFlowList" << endl;
}
for (int i = 0; i < num; i++)
{
QosFlowLItemWithDataForwarding_t response;
m_qosflowitemwithdataforwarding[i].getQosFlowItemWithDataForWarding(response.qosFlowIdentifier);
list.push_back(response);
}
return true;
}
} // namespace ngap
......@@ -20,11 +20,11 @@
*/
/*! \file
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _PDUSESSIONRESOURCEHANDOVERREQUESTACKTRANSFER_H_
#define _PDUSESSIONRESOURCEHANDOVERREQUESTACKTRANSFER_H_
......@@ -33,25 +33,27 @@
#include "DLQoSFlowPerTNLInformation.hpp"
#include "SecurityResult.hpp"
#include "QosFlowListWithDataForwarding.hpp"
extern "C" {
extern "C"
{
#include "Ngap_ProtocolIE-Field.h"
#include "Ngap_HandoverRequestAcknowledgeTransfer.h"
}
namespace ngap {
class PDUSessionResourceHandoverRequestAckTransfer {
public:
PDUSessionResourceHandoverRequestAckTransfer();
virtual ~PDUSessionResourceHandoverRequestAckTransfer();
bool decodefromHandoverRequestAckTransfer(uint8_t *buf, int buf_size);
bool getUpTransportLayerInformation2(GtpTunnel_t *&upTnlInfo);
bool getqosFlowSetupResponseList(
std::vector<QosFlowLItemWithDataForwarding_t> &list);
namespace ngap
{
class PDUSessionResourceHandoverRequestAckTransfer
{
public:
PDUSessionResourceHandoverRequestAckTransfer();
virtual ~PDUSessionResourceHandoverRequestAckTransfer();
bool decodefromHandoverRequestAckTransfer(uint8_t *buf, int buf_size);
bool getUpTransportLayerInformation2(GtpTunnel_t *&upTnlInfo);
bool getqosFlowSetupResponseList(std::vector<QosFlowLItemWithDataForwarding_t> &list);
private:
Ngap_HandoverRequestAcknowledgeTransfer_t *handoverRequestAcknowledegTransferIEs;
UpTransportLayerInformation *dLForwardingUP_TNLInformation;
QosFlowListWithDataForwarding *QosFlowSetupResponseList;
};
} // namespace ngap
private:
Ngap_HandoverRequestAcknowledgeTransfer_t *handoverRequestAcknowledegTransferIEs;
UpTransportLayerInformation *dLForwardingUP_TNLInformation;
QosFlowListWithDataForwarding *QosFlowSetupResponseList;
};
} // namespace ngap
#endif
#endif
\ No newline at end of file
#include "PDUSessionResourceHandoverRequiredTransfer.hpp"
extern "C" {
#include "constr_TYPE.h"
#include "asn_codecs.h"
#include "per_encoder.h"
#include "per_decoder.h"
#include "constraints.h"
extern "C"{
#include "constr_TYPE.h"
#include "asn_codecs.h"
#include "per_encoder.h"
#include "per_decoder.h"
#include "constraints.h"
}
#include <iostream>
using namespace std;
namespace ngap {
PDUSessionResourceHandoverRequiredTransfer::PDUSessionResourceHandoverRequiredTransfer() {
handoverrquiredTransferIEs = (Ngap_HandoverRequiredTransfer_t*) calloc(
1, sizeof(Ngap_HandoverRequiredTransfer_t));
DirectForwardingPathAvailability = NULL;
}
PDUSessionResourceHandoverRequiredTransfer::~PDUSessionResourceHandoverRequiredTransfer() {
}
void PDUSessionResourceHandoverRequiredTransfer::setDirectForwardingPathAvailability(
Ngap_DirectForwardingPathAvailability_t directForwardingPathAvailability) {
if (!DirectForwardingPathAvailability)
DirectForwardingPathAvailability =
new Ngap_DirectForwardingPathAvailability_t();
*DirectForwardingPathAvailability = directForwardingPathAvailability;
}
namespace ngap{
PDUSessionResourceHandoverRequiredTransfer::PDUSessionResourceHandoverRequiredTransfer()
{
handoverrquiredTransferIEs = (Ngap_HandoverRequiredTransfer_t *)calloc(1,sizeof(Ngap_HandoverRequiredTransfer_t));
DirectForwardingPathAvailability = NULL;
}
PDUSessionResourceHandoverRequiredTransfer::~PDUSessionResourceHandoverRequiredTransfer(){}
int PDUSessionResourceHandoverRequiredTransfer::encode2buffer(uint8_t *buf,
int buf_size) {
asn_fprint(stderr, &asn_DEF_Ngap_HandoverRequiredTransfer,
handoverrquiredTransferIEs);
asn_enc_rval_t er = aper_encode_to_buffer(
&asn_DEF_Ngap_HandoverRequiredTransfer, NULL, handoverrquiredTransferIEs,
buf, buf_size);
cout << "er.encoded(" << er.encoded << ")" << endl;
return er.encoded;
}
//Decapsulation
bool PDUSessionResourceHandoverRequiredTransfer::decodefromIE(uint8_t *buf,
int buf_size) {
asn_dec_rval_t rc = asn_decode(NULL, ATS_ALIGNED_CANONICAL_PER,
&asn_DEF_Ngap_HandoverRequiredTransfer,
(void**) &handoverrquiredTransferIEs, buf,
buf_size);
if (rc.code == RC_OK) {
cout << "Decoded successfully" << endl;
} else if (rc.code == RC_WMORE) {
cout << "More data expected, call again" << endl;
return false;
} else {
cout << "Failure to decode data" << endl;
return false;
}
cout << "rc.consumed to decode = " << rc.consumed << endl;
cout << endl;
//asn_fprint(stderr, &asn_DEF_Ngap_PDUSessionResourceSetupResponseTransfer, pduSessionResourceSetupResponseTransferIEs);
if (handoverrquiredTransferIEs->directForwardingPathAvailability) {
Ngap_DirectForwardingPathAvailability_t *directForwardingPathAvailability =
new Ngap_DirectForwardingPathAvailability_t;
directForwardingPathAvailability = handoverrquiredTransferIEs
->directForwardingPathAvailability;
}
return true;
}
void PDUSessionResourceHandoverRequiredTransfer::setDirectForwardingPathAvailability(Ngap_DirectForwardingPathAvailability_t directForwardingPathAvailability)
{
if(!DirectForwardingPathAvailability)
DirectForwardingPathAvailability = new Ngap_DirectForwardingPathAvailability_t();
*DirectForwardingPathAvailability = directForwardingPathAvailability;
}
bool PDUSessionResourceHandoverRequiredTransfer::getDirectForwardingPathAvailability(
long *directForwardingPathAvailability) {
directForwardingPathAvailability = DirectForwardingPathAvailability;
return true;
}
int PDUSessionResourceHandoverRequiredTransfer::encode2buffer(uint8_t *buf, int buf_size)
{
asn_fprint(stderr, &asn_DEF_Ngap_HandoverRequiredTransfer, handoverrquiredTransferIEs);
asn_enc_rval_t er = aper_encode_to_buffer(&asn_DEF_Ngap_HandoverRequiredTransfer, NULL, handoverrquiredTransferIEs, buf, buf_size);
cout<<"er.encoded("<<er.encoded<<")"<<endl;
return er.encoded;
}
//Decapsulation
bool PDUSessionResourceHandoverRequiredTransfer::decodefromIE(uint8_t *buf, int buf_size)
{
asn_dec_rval_t rc = asn_decode(NULL,ATS_ALIGNED_CANONICAL_PER,&asn_DEF_Ngap_HandoverRequiredTransfer,(void**)&handoverrquiredTransferIEs,buf,buf_size);
if(rc.code == RC_OK)
{
cout<<"Decoded successfully"<<endl;
}
else if(rc.code == RC_WMORE)
{
cout<<"More data expected, call again"<<endl;
return false;
}
else
{
cout<<"Failure to decode data"<<endl;
return false;
}
cout<<"rc.consumed to decode = "<<rc.consumed<<endl;
cout<<endl;
//asn_fprint(stderr, &asn_DEF_Ngap_PDUSessionResourceSetupResponseTransfer, pduSessionResourceSetupResponseTransferIEs);
if(handoverrquiredTransferIEs->directForwardingPathAvailability)
{
Ngap_DirectForwardingPathAvailability_t *directForwardingPathAvailability=new Ngap_DirectForwardingPathAvailability_t;
directForwardingPathAvailability = handoverrquiredTransferIEs->directForwardingPathAvailability;
}
return true;
}
bool PDUSessionResourceHandoverRequiredTransfer::getDirectForwardingPathAvailability(long *directForwardingPathAvailability)
{
directForwardingPathAvailability = DirectForwardingPathAvailability;
return true;
}
}
......@@ -6,30 +6,30 @@
#include "DLQoSFlowPerTNLInformation.hpp"
#include "SecurityResult.hpp"
extern "C" {
#include "Ngap_ProtocolIE-Field.h"
#include "Ngap_HandoverRequiredTransfer.h"
extern "C"{
#include "Ngap_ProtocolIE-Field.h"
#include "Ngap_HandoverRequiredTransfer.h"
}
namespace ngap {
class PDUSessionResourceHandoverRequiredTransfer {
public:
PDUSessionResourceHandoverRequiredTransfer();
virtual ~PDUSessionResourceHandoverRequiredTransfer();
void setDirectForwardingPathAvailability(
Ngap_DirectForwardingPathAvailability_t directForwardingPathAvailability);
int encode2buffer(uint8_t *buf, int buf_size);
//Decapsulation
bool decodefromIE(uint8_t *buf, int buf_size);
bool getDirectForwardingPathAvailability(
long *directForwardingPathAvailability);
private:
Ngap_HandoverRequiredTransfer_t *handoverrquiredTransferIEs;
Ngap_DirectForwardingPathAvailability_t *DirectForwardingPathAvailability;
};
namespace ngap{
class PDUSessionResourceHandoverRequiredTransfer {
public:
PDUSessionResourceHandoverRequiredTransfer();
virtual ~PDUSessionResourceHandoverRequiredTransfer();
void setDirectForwardingPathAvailability(Ngap_DirectForwardingPathAvailability_t directForwardingPathAvailability);
int encode2buffer(uint8_t *buf, int buf_size);
//Decapsulation
bool decodefromIE(uint8_t *buf, int buf_size);
bool getDirectForwardingPathAvailability(long *directForwardingPathAvailability);
private:
Ngap_HandoverRequiredTransfer_t *handoverrquiredTransferIEs;
Ngap_DirectForwardingPathAvailability_t *DirectForwardingPathAvailability;
};
}
#endif
......@@ -20,40 +20,42 @@
*/
/*! \file
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "QosFlowItemWithDataForwarding.hpp"
#include <iostream>
using namespace std;
namespace ngap {
QosFlowItemWithDataForWarding::QosFlowItemWithDataForWarding() {
qosFlowIdentifier = NULL;
}
QosFlowItemWithDataForWarding::~QosFlowItemWithDataForWarding() {
}
void QosFlowItemWithDataForWarding::getQosFlowItemWithDataForWarding(
Ngap_QosFlowIdentifier_t &m_QosFlowIdentifier) {
if (!qosFlowIdentifier)
printf("qosFlowIdentifier null\n");
else
printf("qosFlowIdentifier \n");
if (qosFlowIdentifier->getQosFlowIdentifier(value)) {
m_QosFlowIdentifier = (Ngap_QosFlowIdentifier_t) value;
}
}
bool QosFlowItemWithDataForWarding::decodeformQosFlowItemWithDataForWarding(
Ngap_QosFlowSetupResponseItemHOReqAck_t *qosFlowItemWithDataForWarding) {
qosFlowIdentifier = new QosFlowIdentifier();
if (!qosFlowIdentifier->decodefromQosFlowIdentifier(
&(qosFlowItemWithDataForWarding->qosFlowIdentifier))) {
printf("false\n");
return false;
}
printf("true\n");
return true;
}
} // namespace ngap
namespace ngap
{
QosFlowItemWithDataForWarding::QosFlowItemWithDataForWarding()
{
qosFlowIdentifier = NULL;
}
QosFlowItemWithDataForWarding::~QosFlowItemWithDataForWarding() {}
void QosFlowItemWithDataForWarding::getQosFlowItemWithDataForWarding(Ngap_QosFlowIdentifier_t &m_QosFlowIdentifier)
{
if (!qosFlowIdentifier)
printf("qosFlowIdentifier null\n");
else
printf("qosFlowIdentifier \n");
if (qosFlowIdentifier->getQosFlowIdentifier(value))
{
m_QosFlowIdentifier = (Ngap_QosFlowIdentifier_t)value;
}
}
bool QosFlowItemWithDataForWarding::decodeformQosFlowItemWithDataForWarding(Ngap_QosFlowSetupResponseItemHOReqAck_t *qosFlowItemWithDataForWarding)
{
qosFlowIdentifier = new QosFlowIdentifier();
if (!qosFlowIdentifier->decodefromQosFlowIdentifier(&(qosFlowItemWithDataForWarding->qosFlowIdentifier)))
{
printf("false\n");
return false;
}
printf("true\n");
return true;
}
} // namespace ngap
......@@ -20,34 +20,35 @@
*/
/*! \file
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _QOSFLOWITEMWITHDATAFORWARDING_H_
#define _QOSFLOWITEMWITHDATAFORWARDING_H_
#include "QosFlowLevelQosParameters.hpp"
#include "QosFlowIdentifier.hpp"
extern "C" {
extern "C"
{
#include "Ngap_QosFlowSetupResponseItemHOReqAck.h"
}
namespace ngap {
class QosFlowItemWithDataForWarding {
public:
QosFlowItemWithDataForWarding();
virtual ~QosFlowItemWithDataForWarding();
namespace ngap
{
class QosFlowItemWithDataForWarding
{
public:
QosFlowItemWithDataForWarding();
virtual ~QosFlowItemWithDataForWarding();
void getQosFlowItemWithDataForWarding(
Ngap_QosFlowIdentifier_t &m_QosFlowIdentifier);
bool decodeformQosFlowItemWithDataForWarding(
Ngap_QosFlowSetupResponseItemHOReqAck_t *qosFlowItemWithDataForWarding);
void getQosFlowItemWithDataForWarding(Ngap_QosFlowIdentifier_t &m_QosFlowIdentifier);
bool decodeformQosFlowItemWithDataForWarding(Ngap_QosFlowSetupResponseItemHOReqAck_t *qosFlowItemWithDataForWarding);
private:
long value;
QosFlowIdentifier *qosFlowIdentifier;
};
} // namespace ngap
private:
long value;
QosFlowIdentifier *qosFlowIdentifier;
};
} // namespace ngap
#endif // !_QOSFLOWITEMWITHDATAFORWARDING_H_
......@@ -19,41 +19,36 @@
* contact@openairinterface.org
*/
/*! \file
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
/*! \file
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "QosFlowListWithDataForwarding.hpp"
#include <iostream>
using namespace std;
namespace ngap {
QosFlowListWithDataForwarding::QosFlowListWithDataForwarding() {
qosFlowItemWithDataForwarding = NULL;
numofQosFlowItemWithDataForwarding = 0;
}
QosFlowListWithDataForwarding::~QosFlowListWithDataForwarding() {
}
QosFlowListWithDataForwarding::QosFlowListWithDataForwarding()
{
qosFlowItemWithDataForwarding = NULL;
numofQosFlowItemWithDataForwarding = 0;
}
QosFlowListWithDataForwarding::~QosFlowListWithDataForwarding(){}
bool QosFlowListWithDataForwarding::decodeFormQosFlowListWithDataForwarding(
Ngap_QosFlowSetupResponseListHOReqAck_t qosFlowSetupResponseList) {
numofQosFlowItemWithDataForwarding = qosFlowSetupResponseList.list.count;
qosFlowItemWithDataForwarding =
new QosFlowItemWithDataForWarding[numofQosFlowItemWithDataForwarding]();
for (int i = 0; i < numofQosFlowItemWithDataForwarding; i++) {
if (!qosFlowItemWithDataForwarding[i]
.decodeformQosFlowItemWithDataForWarding(
qosFlowSetupResponseList.list.array[i]))
return false;
}
return true;
}
bool QosFlowListWithDataForwarding::getQosFlowListWithDataForwarding(
QosFlowItemWithDataForWarding *&m_QosFlowItemWithDataForwarding, int &num) {
m_QosFlowItemWithDataForwarding = qosFlowItemWithDataForwarding;
num = numofQosFlowItemWithDataForwarding;
return true;
}
bool QosFlowListWithDataForwarding::decodeFormQosFlowListWithDataForwarding(Ngap_QosFlowSetupResponseListHOReqAck_t qosFlowSetupResponseList) {
numofQosFlowItemWithDataForwarding = qosFlowSetupResponseList.list.count;
qosFlowItemWithDataForwarding = new QosFlowItemWithDataForWarding[numofQosFlowItemWithDataForwarding]();
for (int i = 0; i < numofQosFlowItemWithDataForwarding; i++) {
if (!qosFlowItemWithDataForwarding[i].decodeformQosFlowItemWithDataForWarding(qosFlowSetupResponseList.list.array[i]))
return false;
}
return true;
}
bool QosFlowListWithDataForwarding::getQosFlowListWithDataForwarding(QosFlowItemWithDataForWarding *&m_QosFlowItemWithDataForwarding, int &num){
m_QosFlowItemWithDataForwarding = qosFlowItemWithDataForwarding;
num = numofQosFlowItemWithDataForwarding;
return true;
}
}
......@@ -19,35 +19,33 @@
* contact@openairinterface.org
*/
/*! \file
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
/*! \file
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _QOSFLOWLISTWITHDATAFORWRADING_H_
#define _QOSFLOWLISTWITHDATAFORWRADING_H_
#include "QosFlowLevelQosParameters.hpp"
#include "QosFlowItemWithDataForwarding.hpp"
extern "C" {
#include "Ngap_QosFlowSetupResponseListHOReqAck.h"
extern "C"
{
#include "Ngap_QosFlowSetupResponseListHOReqAck.h"
}
namespace ngap {
class QosFlowListWithDataForwarding {
public:
QosFlowListWithDataForwarding();
virtual ~QosFlowListWithDataForwarding();
bool getQosFlowListWithDataForwarding(
QosFlowItemWithDataForWarding *&m_QosFlowItemWithDataForwarding,
int &num);
bool decodeFormQosFlowListWithDataForwarding(
Ngap_QosFlowSetupResponseListHOReqAck_t qosFlowSetupResponseList);
private:
//QosFlowIdentifier *qosFlowIdentifier;
QosFlowItemWithDataForWarding *qosFlowItemWithDataForwarding;
int numofQosFlowItemWithDataForwarding;
};
class QosFlowListWithDataForwarding {
public:
QosFlowListWithDataForwarding();
virtual ~QosFlowListWithDataForwarding();
bool getQosFlowListWithDataForwarding(QosFlowItemWithDataForWarding *&m_QosFlowItemWithDataForwarding, int &num);
bool decodeFormQosFlowListWithDataForwarding(Ngap_QosFlowSetupResponseListHOReqAck_t qosFlowSetupResponseList);
private:
//QosFlowIdentifier *qosFlowIdentifier;
QosFlowItemWithDataForWarding* qosFlowItemWithDataForwarding;
int numofQosFlowItemWithDataForwarding;
};
}
#endif
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "QosFlowToBeForwardedItem.hpp"
extern "C" {
extern "C"
{
}
#include <iostream>
using namespace std;
namespace ngap {
QosFlowToBeForwardedItem::QosFlowToBeForwardedItem() {
qosflowidentifier = NULL;
}
QosFlowToBeForwardedItem::~QosFlowToBeForwardedItem() {
}
void QosFlowToBeForwardedItem::setQosFlowIdentifier(
QosFlowIdentifier *m_qosflowidentifier) {
qosflowidentifier = m_qosflowidentifier;
}
bool QosFlowToBeForwardedItem::encodeQosFlowToBeForwardedItem(
Ngap_QosFlowToBeForwardedItem_t *qosflowtobeforwardeditem) {
if (!qosflowidentifier)
return false;
if (!qosflowidentifier->encode2QosFlowIdentifier(
&qosflowtobeforwardeditem->qosFlowIdentifier)) {
cout << "encode QFI error" << endl;
return false;
}
return true;
}
} // namespace ngap
namespace ngap
{
QosFlowToBeForwardedItem::QosFlowToBeForwardedItem()
{
qosflowidentifier = NULL;
}
QosFlowToBeForwardedItem::~QosFlowToBeForwardedItem() {}
void QosFlowToBeForwardedItem::setQosFlowIdentifier(QosFlowIdentifier *m_qosflowidentifier)
{
qosflowidentifier = m_qosflowidentifier;
}
bool QosFlowToBeForwardedItem::encodeQosFlowToBeForwardedItem(Ngap_QosFlowToBeForwardedItem_t *qosflowtobeforwardeditem)
{
if (!qosflowidentifier)
return false;
if (!qosflowidentifier->encode2QosFlowIdentifier(&qosflowtobeforwardeditem->qosFlowIdentifier))
{
cout << "encode QFI error" << endl;
return false;
}
return true;
}
} // namespace ngap
\ No newline at end of file
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _QOSFLOWTOBEFORWARDEDITEM_H_
#define _QOSFLOWTOBEFORWARDEDITEM_H_
#include "QosFlowIdentifier.hpp"
extern "C" {
extern "C"
{
#include "Ngap_QosFlowToBeForwardedItem.h"
}
namespace ngap {
class QosFlowToBeForwardedItem {
public:
QosFlowToBeForwardedItem();
virtual ~QosFlowToBeForwardedItem();
void setQosFlowIdentifier(QosFlowIdentifier *m_qosflowidentifier);
bool encodeQosFlowToBeForwardedItem(
Ngap_QosFlowToBeForwardedItem_t *qosflowtobeforwardeditem);
namespace ngap
{
class QosFlowToBeForwardedItem
{
public:
QosFlowToBeForwardedItem();
virtual ~QosFlowToBeForwardedItem();
void setQosFlowIdentifier(QosFlowIdentifier *m_qosflowidentifier);
bool encodeQosFlowToBeForwardedItem(Ngap_QosFlowToBeForwardedItem_t *qosflowtobeforwardeditem);
private:
QosFlowIdentifier *qosflowidentifier;
};
} // namespace ngap
#endif
private:
QosFlowIdentifier *qosflowidentifier;
};
} // namespace ngap
#endif
\ No newline at end of file
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "QosFlowToBeForwardedList.hpp"
#include <iostream>
using namespace std;
namespace ngap {
QosFlowToBeForwardedList::QosFlowToBeForwardedList() {
Qosflowtobeforwardeditem = NULL;
numofqosflowtobeforwardeditem = 0;
}
QosFlowToBeForwardedList::~QosFlowToBeForwardedList() {
}
void QosFlowToBeForwardedList::setQosFlowToBeForwardedItem(
QosFlowToBeForwardedItem *m_qosflowtobeforwardeditem, int num) {
Qosflowtobeforwardeditem = m_qosflowtobeforwardeditem;
numofqosflowtobeforwardeditem = num;
}
bool QosFlowToBeForwardedList::encodeQosFlowToBeForwardedList(
Ngap_QosFlowToBeForwardedList *&m_ngap_qosflowtobeforwardedlist) {
m_ngap_qosflowtobeforwardedlist = (Ngap_QosFlowToBeForwardedList_t*) calloc(
1, sizeof(Ngap_QosFlowToBeForwardedList_t));
for (int i = 0; i < numofqosflowtobeforwardeditem; i++) {
cout << "encoding list..." << endl;
Ngap_QosFlowToBeForwardedItem_t *response =
(Ngap_QosFlowToBeForwardedItem_t*) calloc(
1, sizeof(Ngap_QosFlowToBeForwardedItem_t));
if (!response)
return false;
if (!Qosflowtobeforwardeditem[i].encodeQosFlowToBeForwardedItem(response)) {
cout << "encode QosFlowTowardedItem error" << endl;
return false;
namespace ngap
{
QosFlowToBeForwardedList::QosFlowToBeForwardedList()
{
Qosflowtobeforwardeditem = NULL;
numofqosflowtobeforwardeditem = 0;
}
cout << "QFI is " << response->qosFlowIdentifier << endl;
if (ASN_SEQUENCE_ADD(&m_ngap_qosflowtobeforwardedlist->list, response)
!= 0) {
cout << "encode QosFlowTowardedList error" << endl;
return false;
QosFlowToBeForwardedList::~QosFlowToBeForwardedList() {}
void QosFlowToBeForwardedList::setQosFlowToBeForwardedItem(QosFlowToBeForwardedItem *m_qosflowtobeforwardeditem, int num)
{
Qosflowtobeforwardeditem = m_qosflowtobeforwardeditem;
numofqosflowtobeforwardeditem = num;
}
}
return true;
}
} // namespace ngap
bool QosFlowToBeForwardedList::encodeQosFlowToBeForwardedList(Ngap_QosFlowToBeForwardedList *&m_ngap_qosflowtobeforwardedlist)
{
m_ngap_qosflowtobeforwardedlist = (Ngap_QosFlowToBeForwardedList_t *)calloc(1, sizeof(Ngap_QosFlowToBeForwardedList_t));
for (int i = 0; i < numofqosflowtobeforwardeditem; i++)
{
cout << "encoding list..." << endl;
Ngap_QosFlowToBeForwardedItem_t *response = (Ngap_QosFlowToBeForwardedItem_t *)calloc(1, sizeof(Ngap_QosFlowToBeForwardedItem_t));
if (!response)
return false;
if (!Qosflowtobeforwardeditem[i].encodeQosFlowToBeForwardedItem(response))
{
cout << "encode QosFlowTowardedItem error" << endl;
return false;
}
cout << "QFI is " << response->qosFlowIdentifier << endl;
if (ASN_SEQUENCE_ADD(&m_ngap_qosflowtobeforwardedlist->list, response) != 0)
{
cout << "encode QosFlowTowardedList error" << endl;
return false;
}
}
return true;
}
} // namespace ngap
\ No newline at end of file
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _QOSFLOWTOBEFORWARDEDLIST_H_
#define _QOSFLOWTOBEFORWARDEDLIST_H_
#include "QosFlowToBeForwardedItem.hpp"
extern "C" {
extern "C"
{
#include "Ngap_QosFlowToBeForwardedList.h"
}
namespace ngap {
class QosFlowToBeForwardedList {
public:
QosFlowToBeForwardedList();
virtual ~QosFlowToBeForwardedList();
void setQosFlowToBeForwardedItem(
QosFlowToBeForwardedItem *m_qosflowtobeforwardeditem, int num);
bool encodeQosFlowToBeForwardedList(
Ngap_QosFlowToBeForwardedList *&m_ngap_qosflowtobeforwardedlist);
namespace ngap
{
class QosFlowToBeForwardedList
{
public:
QosFlowToBeForwardedList();
virtual ~QosFlowToBeForwardedList();
void setQosFlowToBeForwardedItem(QosFlowToBeForwardedItem *m_qosflowtobeforwardeditem, int num);
bool encodeQosFlowToBeForwardedList(Ngap_QosFlowToBeForwardedList *&m_ngap_qosflowtobeforwardedlist);
private:
QosFlowToBeForwardedItem *Qosflowtobeforwardeditem;
int numofqosflowtobeforwardeditem;
};
} // namespace ngap
#endif
private:
QosFlowToBeForwardedItem *Qosflowtobeforwardeditem;
int numofqosflowtobeforwardeditem;
};
} // namespace ngap
#endif
\ No newline at end of file
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "RANStatusTransferTransparentContainer.hpp"
#include <iostream>
#include <vector>
using namespace std;
namespace ngap {
RANStatusTransferTransparentContainer::RANStatusTransferTransparentContainer() {
drb_sub_list = NULL;
}
RANStatusTransferTransparentContainer::~RANStatusTransferTransparentContainer() {
}
void RANStatusTransferTransparentContainer::getdRBSubject_list(
dRBSubjectList *&drblist) {
drblist = drb_sub_list;
}
void RANStatusTransferTransparentContainer::setdRBSubject_list(
dRBSubjectList *drblist) {
drb_sub_list = drblist;
}
bool RANStatusTransferTransparentContainer::encoderanstatustransfer_transparentcontainer(
Ngap_RANStatusTransfer_TransparentContainer_t *ranstatustransfer_transparentcontainer) {
if (!drb_sub_list->encodefromdRBSubjectlist(
ranstatustransfer_transparentcontainer->dRBsSubjectToStatusTransferList)) {
cout << "encoderanstatustransfer_transparentcontainer error" << endl;
return false;
}
return true;
}
bool RANStatusTransferTransparentContainer::decoderanstatustransfer_transparentcontainer(
Ngap_RANStatusTransfer_TransparentContainer_t *ranstatustransfer_transparentcontainer) {
drb_sub_list = new dRBSubjectList();
if (!drb_sub_list->decodefromdRBSubjectlist(
ranstatustransfer_transparentcontainer->dRBsSubjectToStatusTransferList)) {
cout << "decoderanstatustransfer_transparentcontainer error" << endl;
return false;
}
return true;
}
} // namespace ngap
namespace ngap
{
RANStatusTransferTransparentContainer::RANStatusTransferTransparentContainer()
{
drb_sub_list = NULL;
}
RANStatusTransferTransparentContainer::~RANStatusTransferTransparentContainer() {}
void RANStatusTransferTransparentContainer::getdRBSubject_list(dRBSubjectList *&drblist)
{
drblist = drb_sub_list;
}
void RANStatusTransferTransparentContainer::setdRBSubject_list(dRBSubjectList *drblist)
{
drb_sub_list = drblist;
}
bool RANStatusTransferTransparentContainer::encoderanstatustransfer_transparentcontainer(Ngap_RANStatusTransfer_TransparentContainer_t *ranstatustransfer_transparentcontainer)
{
if (!drb_sub_list->encodefromdRBSubjectlist(ranstatustransfer_transparentcontainer->dRBsSubjectToStatusTransferList))
{
cout << "encoderanstatustransfer_transparentcontainer error" << endl;
return false;
}
return true;
}
bool RANStatusTransferTransparentContainer::decoderanstatustransfer_transparentcontainer(Ngap_RANStatusTransfer_TransparentContainer_t *ranstatustransfer_transparentcontainer)
{
drb_sub_list = new dRBSubjectList();
if (!drb_sub_list->decodefromdRBSubjectlist(ranstatustransfer_transparentcontainer->dRBsSubjectToStatusTransferList))
{
cout << "decoderanstatustransfer_transparentcontainer error" << endl;
return false;
}
return true;
}
} // namespace ngap
\ No newline at end of file
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _RANSTATUSTRANSFERTRANSPATENTCONTAINER_H_
#define _RANSTATUSTRANSFERTRANSPATENTCONTAINER_H_
#include "dRBsSubjectToStatusTransferList.hpp"
#include "dRBsSubjectToStatusTransferItem.hpp"
extern "C" {
extern "C"
{
#include "Ngap_RANStatusTransfer-TransparentContainer.h"
}
namespace ngap {
class RANStatusTransferTransparentContainer {
private:
/* data */
dRBSubjectList *drb_sub_list;
namespace ngap
{
class RANStatusTransferTransparentContainer
{
private:
/* data */
dRBSubjectList *drb_sub_list;
public:
RANStatusTransferTransparentContainer(/* args */);
virtual ~RANStatusTransferTransparentContainer();
void getdRBSubject_list(dRBSubjectList *&drblist);
void setdRBSubject_list(dRBSubjectList *drblist);
bool encoderanstatustransfer_transparentcontainer(
Ngap_RANStatusTransfer_TransparentContainer_t *ranstatustransfer_transparentcontainer);
bool decoderanstatustransfer_transparentcontainer(
Ngap_RANStatusTransfer_TransparentContainer_t *ranstatustransfer_transparentcontainer);
};
public:
RANStatusTransferTransparentContainer(/* args */);
virtual ~RANStatusTransferTransparentContainer();
void getdRBSubject_list(dRBSubjectList *&drblist);
void setdRBSubject_list(dRBSubjectList *drblist);
bool encoderanstatustransfer_transparentcontainer(Ngap_RANStatusTransfer_TransparentContainer_t *ranstatustransfer_transparentcontainer);
bool decoderanstatustransfer_transparentcontainer(Ngap_RANStatusTransfer_TransparentContainer_t *ranstatustransfer_transparentcontainer);
};
} // namespace ngap
#endif
} // namespace ngap
#endif
\ No newline at end of file
......@@ -29,33 +29,42 @@
#include <iostream>
#include <vector>
using namespace std;
namespace ngap {
dRBStatusDL::dRBStatusDL() {
dl18 = (DRBStatusDL18*) calloc(1, sizeof(DRBStatusDL18));
}
dRBStatusDL::~dRBStatusDL() {
}
void dRBStatusDL::setDRBStatusDL18(DRBStatusDL18 *dL18) {
dl18 = dL18;
}
void dRBStatusDL::getDRBStatusDL18(DRBStatusDL18 *&dL18) {
dL18 = dl18;
}
bool dRBStatusDL::encodedRBStatusDL(Ngap_DRBStatusDL_t *dL) {
if (!dl18->encodeddRBStatusDL18(dL->choice.dRBStatusDL18)) {
cout << "encodedRBStatusDL error" << endl;
return false;
}
cout << "encodedRBStatusDL successfully" << endl;
return true;
}
bool dRBStatusDL::decodedRBStatusDL(Ngap_DRBStatusDL_t *dL) {
dl18 = new DRBStatusDL18();
if (!dl18->decodeddRBStatusDL18(dL->choice.dRBStatusDL18)) {
cout << "decodedRBStatusDL error" << endl;
return false;
}
cout << "decodedRBStatusDL successfully" << endl;
return true;
}
} // namespace ngap
namespace ngap
{
dRBStatusDL::dRBStatusDL()
{
dl18 = (DRBStatusDL18 *)calloc(1, sizeof(DRBStatusDL18));
}
dRBStatusDL::~dRBStatusDL() {}
void dRBStatusDL::setDRBStatusDL18(DRBStatusDL18 *dL18)
{
dl18 = dL18;
}
void dRBStatusDL::getDRBStatusDL18(DRBStatusDL18 *&dL18)
{
dL18 = dl18;
}
bool dRBStatusDL::encodedRBStatusDL(Ngap_DRBStatusDL_t *dL)
{
dL->present = Ngap_DRBStatusDL_PR_dRBStatusDL18;
dL->choice.dRBStatusDL18 = (Ngap_DRBStatusDL18_t *)calloc(1, sizeof(Ngap_DRBStatusDL18_t));
if (!dl18->encodeddRBStatusDL18(dL->choice.dRBStatusDL18))
{
cout << "encodedRBStatusDL error" << endl;
return false;
}
cout << "encodedRBStatusDL successfully" << endl;
return true;
}
bool dRBStatusDL::decodedRBStatusDL(Ngap_DRBStatusDL_t *dL)
{
dl18 = new DRBStatusDL18();
if (!dl18->decodeddRBStatusDL18(dL->choice.dRBStatusDL18))
{
cout << "decodedRBStatusDL error" << endl;
return false;
}
cout << "decodedRBStatusDL successfully" << endl;
return true;
}
} // namespace ngap
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _DRBSTATUSDL_H_
#define _DRBSTATUSDL_H_
#include "dRBStatusDL18.hpp"
extern "C" {
extern "C"
{
#include "Ngap_DRBStatusDL.h"
#include "Ngap_DRBStatusDL18.h"
}
namespace ngap {
class dRBStatusDL {
private:
/* data */
DRBStatusDL18 *dl18;
namespace ngap
{
class dRBStatusDL
{
private:
/* data */
DRBStatusDL18 *dl18;
public:
dRBStatusDL();
virtual ~dRBStatusDL();
void getDRBStatusDL18(DRBStatusDL18 *&dL18);
void setDRBStatusDL18(DRBStatusDL18 *dL18);
bool encodedRBStatusDL(Ngap_DRBStatusDL_t *dL);
bool decodedRBStatusDL(Ngap_DRBStatusDL_t *dL);
};
public:
dRBStatusDL();
virtual ~dRBStatusDL();
void getDRBStatusDL18(DRBStatusDL18 *&dL18);
void setDRBStatusDL18(DRBStatusDL18 *dL18);
bool encodedRBStatusDL(Ngap_DRBStatusDL_t *dL);
bool decodedRBStatusDL(Ngap_DRBStatusDL_t *dL);
};
} // namespace ngap
} // namespace ngap
#endif
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "dRBStatusDL18.hpp"
#include <iostream>
using namespace std;
namespace ngap {
DRBStatusDL18::DRBStatusDL18() {
pdcp_value = NULL;
}
DRBStatusDL18::~DRBStatusDL18() {
}
void DRBStatusDL18::getcountvalue(COUNTValueForPDCP_SN18 *&count_value) {
count_value = pdcp_value;
}
void DRBStatusDL18::setcountvalue(COUNTValueForPDCP_SN18 *count_value) {
pdcp_value = count_value;
}
bool DRBStatusDL18::encodeddRBStatusDL18(Ngap_DRBStatusDL18_t *DL18) {
if (!pdcp_value->encodedCOUNTValueForPDCP_SN18(DL18->dL_COUNTValue)) {
cout << "encodeddRBStatusDL18 error" << endl;
return false;
}
return true;
}
bool DRBStatusDL18::decodeddRBStatusDL18(Ngap_DRBStatusDL18_t *DL18) {
pdcp_value = new COUNTValueForPDCP_SN18();
if (!pdcp_value->decodedCOUNTValueForPDCP_SN18(DL18->dL_COUNTValue)) {
cout << "decodeddRBStatusDL18 error" << endl;
return false;
}
return true;
}
} // namespace ngap
namespace ngap
{
DRBStatusDL18::DRBStatusDL18()
{
pdcp_value = NULL;
}
DRBStatusDL18::~DRBStatusDL18() {}
void DRBStatusDL18::getcountvalue(COUNTValueForPDCP_SN18 *&count_value)
{
count_value = pdcp_value;
}
void DRBStatusDL18::setcountvalue(COUNTValueForPDCP_SN18 *count_value)
{
pdcp_value = count_value;
}
bool DRBStatusDL18::encodeddRBStatusDL18(Ngap_DRBStatusDL18_t *DL18)
{
if (!pdcp_value->encodedCOUNTValueForPDCP_SN18(&DL18->dL_COUNTValue))
{
cout << "encodeddRBStatusDL18 error" << endl;
return false;
}
return true;
}
bool DRBStatusDL18::decodeddRBStatusDL18(Ngap_DRBStatusDL18_t *DL18)
{
pdcp_value = new COUNTValueForPDCP_SN18();
if (!pdcp_value->decodedCOUNTValueForPDCP_SN18(DL18->dL_COUNTValue))
{
cout << "decodeddRBStatusDL18 error" << endl;
return false;
}
return true;
}
} // namespace ngap
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _DRBSTATUSDL18_H_
#define _DRBSTATUSDL18_H_
#include "COUNTValueForPDCP_SN18.hpp"
extern "C" {
extern "C"
{
#include "Ngap_DRBStatusDL18.h"
}
namespace ngap {
class DRBStatusDL18 {
private:
/* data */
COUNTValueForPDCP_SN18 *pdcp_value;
namespace ngap
{
class DRBStatusDL18
{
private:
/* data */
COUNTValueForPDCP_SN18 *pdcp_value;
public:
DRBStatusDL18(/* args */);
virtual ~DRBStatusDL18();
void getcountvalue(COUNTValueForPDCP_SN18 *&count_value);
void setcountvalue(COUNTValueForPDCP_SN18 *count_value);
bool encodeddRBStatusDL18(Ngap_DRBStatusDL18_t *DL18);
bool decodeddRBStatusDL18(Ngap_DRBStatusDL18_t *DL18);
};
} // namespace ngap
#endif
public:
DRBStatusDL18(/* args */);
virtual ~DRBStatusDL18();
void getcountvalue(COUNTValueForPDCP_SN18 *&count_value);
void setcountvalue(COUNTValueForPDCP_SN18 *count_value);
bool encodeddRBStatusDL18(Ngap_DRBStatusDL18_t *DL18);
bool decodeddRBStatusDL18(Ngap_DRBStatusDL18_t *DL18);
};
} // namespace ngap
#endif
\ No newline at end of file
......@@ -30,33 +30,42 @@
#include <vector>
using namespace std;
namespace ngap {
dRBStatusUL::dRBStatusUL() {
ul18 = (dRBStatusUL18*) calloc(1, sizeof(dRBStatusUL18));
}
dRBStatusUL::~dRBStatusUL() {
}
void dRBStatusUL::setdRBStatusUL(dRBStatusUL18 *uL18) {
ul18 = uL18;
}
void dRBStatusUL::getdRBStatusUL(dRBStatusUL18 *&uL18) {
uL18 = ul18;
}
bool dRBStatusUL::encodedRBStatusUL(Ngap_DRBStatusUL_t *uL) {
if (ul18->encodeddRBStatusUL18(uL->choice.dRBStatusUL18)) {
cout << "encodeddRBStatusUL18 error" << endl;
return false;
}
cout << "encodedRBStatusUL successfully" << endl;
return true;
}
bool dRBStatusUL::decodedRBStatusUL(Ngap_DRBStatusUL_t *uL) {
ul18 = new dRBStatusUL18();
if (!ul18->decodeddRBStatusUL18(uL->choice.dRBStatusUL18)) {
cout << "decodeddRBStatusUL18 error" << endl;
return false;
}
cout << "decodedRBStatusUL successfully" << endl;
return true;
}
} // namespace ngap
namespace ngap
{
dRBStatusUL::dRBStatusUL()
{
ul18 = (dRBStatusUL18 *)calloc(1, sizeof(dRBStatusUL18));
}
dRBStatusUL::~dRBStatusUL() {}
void dRBStatusUL::setdRBStatusUL(dRBStatusUL18 *uL18)
{
ul18 = uL18;
}
void dRBStatusUL::getdRBStatusUL(dRBStatusUL18 *&uL18)
{
uL18 = ul18;
}
bool dRBStatusUL::encodedRBStatusUL(Ngap_DRBStatusUL_t *uL)
{
uL->present = Ngap_DRBStatusUL_PR_dRBStatusUL18;
uL->choice.dRBStatusUL18 = (Ngap_DRBStatusUL18_t *)calloc(1, sizeof(Ngap_DRBStatusUL18_t));
if (!ul18->encodeddRBStatusUL18(uL->choice.dRBStatusUL18))
{
cout << "encodeddRBStatusUL18 error" << endl;
return false;
}
cout << "encodedRBStatusUL successfully" << endl;
return true;
}
bool dRBStatusUL::decodedRBStatusUL(Ngap_DRBStatusUL_t *uL)
{
ul18 = new dRBStatusUL18();
if (!ul18->decodeddRBStatusUL18(uL->choice.dRBStatusUL18))
{
cout << "decodeddRBStatusUL18 error" << endl;
return false;
}
cout << "decodedRBStatusUL successfully" << endl;
return true;
}
} // namespace ngap
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _DRBSTATUSUL_H_
#define _DRBSTATUSUL_H_
#include "dRBStatusUL18.hpp"
extern "C" {
extern "C"
{
#include "Ngap_DRBStatusUL.h"
}
namespace ngap {
class dRBStatusUL {
private:
/* data */
dRBStatusUL18 *ul18;
namespace ngap
{
class dRBStatusUL
{
private:
/* data */
dRBStatusUL18 *ul18;
public:
dRBStatusUL(/* args */);
virtual ~dRBStatusUL();
void setdRBStatusUL(dRBStatusUL18 *uL18);
void getdRBStatusUL(dRBStatusUL18 *&uL18);
bool encodedRBStatusUL(Ngap_DRBStatusUL_t *uL);
bool decodedRBStatusUL(Ngap_DRBStatusUL_t *uL);
};
} // namespace ngap
#endif
public:
dRBStatusUL(/* args */);
virtual ~dRBStatusUL();
void setdRBStatusUL(dRBStatusUL18 *uL18);
void getdRBStatusUL(dRBStatusUL18 *&uL18);
bool encodedRBStatusUL(Ngap_DRBStatusUL_t *uL);
bool decodedRBStatusUL(Ngap_DRBStatusUL_t *uL);
};
} // namespace ngap
#endif
\ No newline at end of file
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "dRBStatusUL18.hpp"
#include <iostream>
using namespace std;
namespace ngap {
dRBStatusUL18::dRBStatusUL18() {
pdcp_value = NULL;
}
dRBStatusUL18::~dRBStatusUL18() {
}
void dRBStatusUL18::getcountvalue(COUNTValueForPDCP_SN18 *&count_value) {
count_value = pdcp_value;
}
void dRBStatusUL18::setcountvalue(COUNTValueForPDCP_SN18 *count_value) {
pdcp_value = count_value;
}
bool dRBStatusUL18::encodeddRBStatusUL18(Ngap_DRBStatusUL18_t *UL18) {
if (!pdcp_value->encodedCOUNTValueForPDCP_SN18(UL18->uL_COUNTValue)) {
cout << "encodeddRBStatusUL18 error" << endl;
return false;
}
return true;
}
bool dRBStatusUL18::decodeddRBStatusUL18(Ngap_DRBStatusUL18_t *UL18) {
pdcp_value = new COUNTValueForPDCP_SN18();
if (!pdcp_value->decodedCOUNTValueForPDCP_SN18(UL18->uL_COUNTValue)) {
cout << "decodeddRBStatusUL18 error" << endl;
return false;
}
return true;
}
} // namespace ngap
namespace ngap
{
dRBStatusUL18::dRBStatusUL18()
{
pdcp_value = NULL;
}
dRBStatusUL18::~dRBStatusUL18() {}
void dRBStatusUL18::getcountvalue(COUNTValueForPDCP_SN18 *&count_value)
{
count_value = pdcp_value;
}
void dRBStatusUL18::setcountvalue(COUNTValueForPDCP_SN18 *count_value)
{
pdcp_value = count_value;
}
bool dRBStatusUL18::encodeddRBStatusUL18(Ngap_DRBStatusUL18_t *UL18)
{
if (!pdcp_value->encodedCOUNTValueForPDCP_SN18(&UL18->uL_COUNTValue))
{
cout << "encodeddRBStatusUL18 error" << endl;
return false;
}
return true;
}
bool dRBStatusUL18::decodeddRBStatusUL18(Ngap_DRBStatusUL18_t *UL18)
{
pdcp_value = new COUNTValueForPDCP_SN18();
if (!pdcp_value->decodedCOUNTValueForPDCP_SN18(UL18->uL_COUNTValue))
{
cout << "decodeddRBStatusUL18 error" << endl;
return false;
}
return true;
}
} // namespace ngap
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _DRBSTATUSUL18_H_
#define _DRBSTATUSUL18_H_
#include "COUNTValueForPDCP_SN18.hpp"
extern "C" {
extern "C"
{
#include "Ngap_DRBStatusUL18.h"
}
namespace ngap {
class dRBStatusUL18 {
private:
/* data */
COUNTValueForPDCP_SN18 *pdcp_value;
namespace ngap
{
class dRBStatusUL18
{
private:
/* data */
COUNTValueForPDCP_SN18 *pdcp_value;
public:
dRBStatusUL18(/* args */);
virtual ~dRBStatusUL18();
void getcountvalue(COUNTValueForPDCP_SN18 *&count_value);
void setcountvalue(COUNTValueForPDCP_SN18 *count_value);
bool encodeddRBStatusUL18(Ngap_DRBStatusUL18_t *UL18);
bool decodeddRBStatusUL18(Ngap_DRBStatusUL18_t *UL18);
};
public:
dRBStatusUL18(/* args */);
virtual ~dRBStatusUL18();
void getcountvalue(COUNTValueForPDCP_SN18 *&count_value);
void setcountvalue(COUNTValueForPDCP_SN18 *count_value);
bool encodeddRBStatusUL18(Ngap_DRBStatusUL18_t *UL18);
bool decodeddRBStatusUL18(Ngap_DRBStatusUL18_t *UL18);
};
} // namespace ngap
#endif
} // namespace ngap
#endif
\ No newline at end of file
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "dRBsSubjectToStatusTransferItem.hpp"
#include <iostream>
#include <vector>
using namespace std;
namespace ngap {
dRBSubjectItem::dRBSubjectItem() {
drb_id = NULL;
drb_ul = NULL;
drb_dl = NULL;
}
dRBSubjectItem::~dRBSubjectItem() {
}
void dRBSubjectItem::setdRBSubjectItem(Ngap_DRB_ID_t *dRB_ID,
dRBStatusUL *dRB_UL,
dRBStatusDL *dRB_DL) {
drb_id = dRB_ID;
drb_ul = dRB_UL;
drb_dl = dRB_DL;
}
void dRBSubjectItem::getdRBSubjectItem(Ngap_DRB_ID_t *&dRB_ID,
dRBStatusUL *&dRB_UL,
dRBStatusDL *&dRB_DL) {
dRB_ID = drb_id;
dRB_UL = drb_ul;
dRB_DL = drb_dl;
}
bool dRBSubjectItem::decodefromdRBSubjectItem(
Ngap_DRBsSubjectToStatusTransferItem_t *dRB_item) {
if (dRB_item->dRB_ID) {
drb_id = &dRB_item->dRB_ID;
cout << "the decode drb_id is" << *drb_id << endl;
}
drb_ul = new dRBStatusUL();
if (!drb_ul->decodedRBStatusUL(&dRB_item->dRBStatusUL)) {
cout << "decode from dRBSubjectItem dRBStatusUL error" << endl;
return false;
}
drb_dl = new dRBStatusDL();
if (!drb_dl->decodedRBStatusDL(&dRB_item->dRBStatusDL)) {
cout << "decode from dRBSubjectItem dRBStatusDL error" << endl;
return false;
}
cout << "decode from dRBSubjectItem successfully" << endl;
return true;
}
bool dRBSubjectItem::encodedRBSubjectItem(
Ngap_DRBsSubjectToStatusTransferItem_t *dRB_item) {
if (drb_id) {
dRB_item->dRB_ID = *drb_id;
cout << "the encode drb_id is" << *drb_id << endl;
}
if (!drb_ul->encodedRBStatusUL(&dRB_item->dRBStatusUL)) {
cout << "encode from dRBSubjectItem dRBStatusUL error" << endl;
return false;
}
if (!drb_dl->encodedRBStatusDL(&dRB_item->dRBStatusDL)) {
cout << "encode from dRBSubjectItem dRBStatusDL error" << endl;
return false;
}
cout << "encode from dRBSubjectItem successfully" << endl;
return true;
}
} // namespace ngap
namespace ngap
{
dRBSubjectItem::dRBSubjectItem()
{
drb_id = NULL;
drb_ul = NULL;
drb_dl = NULL;
}
dRBSubjectItem::~dRBSubjectItem() {}
void dRBSubjectItem::setdRBSubjectItem(Ngap_DRB_ID_t *dRB_ID, dRBStatusUL *dRB_UL, dRBStatusDL *dRB_DL)
{
drb_id = dRB_ID;
drb_ul = dRB_UL;
drb_dl = dRB_DL;
}
void dRBSubjectItem::getdRBSubjectItem(Ngap_DRB_ID_t *&dRB_ID, dRBStatusUL *&dRB_UL, dRBStatusDL *&dRB_DL)
{
dRB_ID = drb_id;
dRB_UL = drb_ul;
dRB_DL = drb_dl;
}
bool dRBSubjectItem::decodefromdRBSubjectItem(Ngap_DRBsSubjectToStatusTransferItem_t *dRB_item)
{
if (dRB_item->dRB_ID)
{
drb_id = &dRB_item->dRB_ID;
cout << "the decode drb_id is" << *drb_id << endl;
}
drb_ul = new dRBStatusUL();
if (!drb_ul->decodedRBStatusUL(&dRB_item->dRBStatusUL))
{
cout << "decode from dRBSubjectItem dRBStatusUL error" << endl;
return false;
}
drb_dl = new dRBStatusDL();
if (!drb_dl->decodedRBStatusDL(&dRB_item->dRBStatusDL))
{
cout << "decode from dRBSubjectItem dRBStatusDL error" << endl;
return false;
}
cout << "decode from dRBSubjectItem successfully" << endl;
return true;
}
bool dRBSubjectItem::encodedRBSubjectItem(Ngap_DRBsSubjectToStatusTransferItem_t *dRB_item)
{
if (drb_id)
{
dRB_item->dRB_ID = *drb_id;
cout << "the encode drb_id is" << *drb_id << endl;
}
if (!drb_ul->encodedRBStatusUL(&dRB_item->dRBStatusUL))
{
cout << "encode from dRBSubjectItem dRBStatusUL error" << endl;
return false;
}
if (!drb_dl->encodedRBStatusDL(&dRB_item->dRBStatusDL))
{
cout << "encode from dRBSubjectItem dRBStatusDL error" << endl;
return false;
}
cout << "encode from dRBSubjectItem successfully" << endl;
return true;
}
} // namespace ngap
\ No newline at end of file
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _DRBSSUBJECTTOSTATUSTRANSFERITEM_H_
#define _DRBSSUBJECTTOSTATUSTRANSFERITEM_H_
#include "dRBStatusUL.hpp"
#include "dRBStatusDL.hpp"
extern "C" {
extern "C"
{
#include "Ngap_DRBsSubjectToStatusTransferItem.h"
}
namespace ngap {
class dRBSubjectItem {
public:
dRBSubjectItem();
virtual ~dRBSubjectItem();
void getdRBSubjectItem(Ngap_DRB_ID_t *&dRB_ID, dRBStatusUL *&dRB_UL,
dRBStatusDL *&dRB_DL);
void setdRBSubjectItem(Ngap_DRB_ID_t *dRB_ID, dRBStatusUL *dRB_UL,
dRBStatusDL *dRB_DL);
bool decodefromdRBSubjectItem(
Ngap_DRBsSubjectToStatusTransferItem_t *dRB_item);
bool encodedRBSubjectItem(Ngap_DRBsSubjectToStatusTransferItem_t *dRB_item);
namespace ngap
{
class dRBSubjectItem
{
public:
dRBSubjectItem();
virtual ~dRBSubjectItem();
void getdRBSubjectItem(Ngap_DRB_ID_t *&dRB_ID, dRBStatusUL *&dRB_UL, dRBStatusDL *&dRB_DL);
void setdRBSubjectItem(Ngap_DRB_ID_t *dRB_ID, dRBStatusUL *dRB_UL, dRBStatusDL *dRB_DL);
bool decodefromdRBSubjectItem(Ngap_DRBsSubjectToStatusTransferItem_t *dRB_item);
bool encodedRBSubjectItem(Ngap_DRBsSubjectToStatusTransferItem_t *dRB_item);
private:
Ngap_DRB_ID_t *drb_id;
dRBStatusUL *drb_ul;
dRBStatusDL *drb_dl;
};
} // namespace ngap
#endif
private:
Ngap_DRB_ID_t *drb_id;
dRBStatusUL *drb_ul;
dRBStatusDL *drb_dl;
};
} // namespace ngap
#endif
\ No newline at end of file
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "dRBsSubjectToStatusTransferList.hpp"
#include <iostream>
#include <vector>
using namespace std;
namespace ngap {
dRBSubjectList::dRBSubjectList() {
drbsubjectitem = NULL;
numofitem = 0;
}
dRBSubjectList::~dRBSubjectList() {
}
void dRBSubjectList::setdRBSubjectItem(dRBSubjectItem *m_item, int num) {
drbsubjectitem = m_item;
numofitem = num;
}
void dRBSubjectList::getdRBSubjectItem(dRBSubjectItem *&m_item, int &num) {
m_item = drbsubjectitem;
num = numofitem;
}
bool dRBSubjectList::encodefromdRBSubjectlist(
Ngap_DRBsSubjectToStatusTransferList_t &DRBsSubjectToStatusTransferList) {
for (int i = 0; i < numofitem; i++) {
Ngap_DRBsSubjectToStatusTransferItem_t *ie =
(Ngap_DRBsSubjectToStatusTransferItem_t*) calloc(
1, sizeof(Ngap_DRBsSubjectToStatusTransferItem_t));
if (!ie)
return false;
if (!drbsubjectitem[i].encodedRBSubjectItem(ie)) {
cout << "encodefromdRBSubjectlist error" << endl;
return false;
namespace ngap
{
dRBSubjectList::dRBSubjectList()
{
drbsubjectitem = NULL;
numofitem = 0;
}
if (ASN_SEQUENCE_ADD(&DRBsSubjectToStatusTransferList.list, ie) != 0) {
cout
<< "ASN_SEQUENCE_ADD(&DRBsSubjectToStatusTransferList.list, ie) error"
<< endl;
return false;
dRBSubjectList::~dRBSubjectList() {}
void dRBSubjectList::setdRBSubjectItem(dRBSubjectItem *m_item, int num)
{
drbsubjectitem = m_item;
numofitem = num;
}
}
cout << "encodefromdRBSubjectlist successfully" << endl;
return true;
}
bool dRBSubjectList::decodefromdRBSubjectlist(
Ngap_DRBsSubjectToStatusTransferList_t &DRBsSubjectToStatusTransferList) {
numofitem = DRBsSubjectToStatusTransferList.list.count;
drbsubjectitem = new dRBSubjectItem[numofitem]();
for (int i = 0; i < numofitem; i++) {
if (!drbsubjectitem[i].decodefromdRBSubjectItem(
DRBsSubjectToStatusTransferList.list.array[i])) {
cout << "decodefromdRBSubjectlist error" << endl;
return false;
void dRBSubjectList::getdRBSubjectItem(dRBSubjectItem *&m_item, int &num)
{
m_item = drbsubjectitem;
num = numofitem;
}
}
cout << "decodefromdRBSubjectlist successfully" << endl;
return true;
}
} // namespace ngap
bool dRBSubjectList::encodefromdRBSubjectlist(Ngap_DRBsSubjectToStatusTransferList_t &DRBsSubjectToStatusTransferList)
{
for (int i = 0; i < numofitem; i++)
{
Ngap_DRBsSubjectToStatusTransferItem_t *ie = (Ngap_DRBsSubjectToStatusTransferItem_t *)calloc(1, sizeof(Ngap_DRBsSubjectToStatusTransferItem_t));
if (!ie)
return false;
if (!drbsubjectitem[i].encodedRBSubjectItem(ie))
{
cout << "encodefromdRBSubjectlist error" << endl;
return false;
}
if (ASN_SEQUENCE_ADD(&DRBsSubjectToStatusTransferList.list, ie) != 0)
{
cout << "ASN_SEQUENCE_ADD(&DRBsSubjectToStatusTransferList.list, ie) error" << endl;
return false;
}
}
cout << "encodefromdRBSubjectlist successfully" << endl;
return true;
}
bool dRBSubjectList::decodefromdRBSubjectlist(Ngap_DRBsSubjectToStatusTransferList_t &DRBsSubjectToStatusTransferList)
{
numofitem = DRBsSubjectToStatusTransferList.list.count;
drbsubjectitem = new dRBSubjectItem[numofitem]();
for (int i = 0; i < numofitem; i++)
{
if (!drbsubjectitem[i].decodefromdRBSubjectItem(DRBsSubjectToStatusTransferList.list.array[i]))
{
cout << "decodefromdRBSubjectlist error" << endl;
return false;
}
}
cout << "decodefromdRBSubjectlist successfully" << endl;
return true;
}
} // namespace ngap
\ No newline at end of file
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _DRBSSUBJECTTOSTATUSTRANSFERLIST_H_
#define _DRBSSUBJECTTOSTATUSTRANSFERLIST_H_
#include "dRBsSubjectToStatusTransferItem.hpp"
extern "C" {
extern "C"
{
#include "Ngap_DRBsSubjectToStatusTransferList.h"
#include "asn_SEQUENCE_OF.h"
}
namespace ngap {
class dRBSubjectList {
public:
dRBSubjectList();
virtual ~dRBSubjectList();
void setdRBSubjectItem(dRBSubjectItem *m_item, int num);
void getdRBSubjectItem(dRBSubjectItem *&m_item, int &num);
bool decodefromdRBSubjectlist(
Ngap_DRBsSubjectToStatusTransferList_t &DRBsSubjectToStatusTransferList);
bool encodefromdRBSubjectlist(
Ngap_DRBsSubjectToStatusTransferList_t &DRBsSubjectToStatusTransferList);
namespace ngap
{
class dRBSubjectList
{
public:
dRBSubjectList();
virtual ~dRBSubjectList();
void setdRBSubjectItem(dRBSubjectItem *m_item, int num);
void getdRBSubjectItem(dRBSubjectItem *&m_item, int &num);
bool decodefromdRBSubjectlist(Ngap_DRBsSubjectToStatusTransferList_t &DRBsSubjectToStatusTransferList);
bool encodefromdRBSubjectlist(Ngap_DRBsSubjectToStatusTransferList_t &DRBsSubjectToStatusTransferList);
private:
dRBSubjectItem *drbsubjectitem;
int numofitem;
};
} // namespace ngap
#endif
private:
dRBSubjectItem *drbsubjectitem;
int numofitem;
};
} // namespace ngap
#endif
\ No newline at end of file
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "DownlinkRANStatusTransfer.hpp"
#include <iostream>
#include <vector>
using namespace std;
namespace ngap {
DownlinkRANStatusTransfer::DownlinkRANStatusTransfer() {
amfUeNgapId = NULL;
ranUeNgapId = NULL;
ranStatusTransfer_TransparentContainer = NULL;
DownlinkranstatustransferIEs = NULL;
DownlinkranstatustransferPDU = NULL;
}
DownlinkRANStatusTransfer::~DownlinkRANStatusTransfer() {
}
void DownlinkRANStatusTransfer::setAmfUeNgapId(unsigned long id) {
if (!amfUeNgapId)
amfUeNgapId = new AMF_UE_NGAP_ID();
amfUeNgapId->setAMF_UE_NGAP_ID(id);
namespace ngap
{
DownlinkRANStatusTransfer::DownlinkRANStatusTransfer()
{
amfUeNgapId = NULL;
ranUeNgapId = NULL;
ranStatusTransfer_TransparentContainer = NULL;
DownlinkranstatustransferIEs = NULL;
DownlinkranstatustransferPDU = NULL;
}
DownlinkRANStatusTransfer::~DownlinkRANStatusTransfer()
{
}
void DownlinkRANStatusTransfer::setAmfUeNgapId(unsigned long id)
{
if (!amfUeNgapId)
amfUeNgapId = new AMF_UE_NGAP_ID();
amfUeNgapId->setAMF_UE_NGAP_ID(id);
Ngap_DownlinkRANStatusTransferIEs_t *ie =
(Ngap_DownlinkRANStatusTransferIEs_t*) calloc(
1, sizeof(Ngap_DownlinkRANStatusTransferIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_AMF_UE_NGAP_ID;
ie->criticality = Ngap_Criticality_reject;
ie->value.present =
Ngap_DownlinkRANStatusTransferIEs__value_PR_AMF_UE_NGAP_ID;
Ngap_DownlinkRANStatusTransferIEs_t *ie = (Ngap_DownlinkRANStatusTransferIEs_t *)calloc(1, sizeof(Ngap_DownlinkRANStatusTransferIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_AMF_UE_NGAP_ID;
ie->criticality = Ngap_Criticality_reject;
ie->value.present = Ngap_DownlinkRANStatusTransferIEs__value_PR_AMF_UE_NGAP_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;
return;
}
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;
return;
}
ret = ASN_SEQUENCE_ADD(&DownlinkranstatustransferIEs->protocolIEs.list, ie);
if (ret != 0)
cout << "encode AMF_UE_NGAP_ID IE error" << endl;
}
void DownlinkRANStatusTransfer::setRanUeNgapId(uint32_t id) {
if (!ranUeNgapId)
ranUeNgapId = new RAN_UE_NGAP_ID();
ranUeNgapId->setRanUeNgapId(id);
ret = ASN_SEQUENCE_ADD(&DownlinkranstatustransferIEs->protocolIEs.list, ie);
if (ret != 0)
cout << "encode AMF_UE_NGAP_ID IE error" << endl;
}
void DownlinkRANStatusTransfer::setRanUeNgapId(uint32_t id)
{
if (!ranUeNgapId)
ranUeNgapId = new RAN_UE_NGAP_ID();
ranUeNgapId->setRanUeNgapId(id);
Ngap_DownlinkRANStatusTransferIEs_t *ie =
(Ngap_DownlinkRANStatusTransferIEs_t*) calloc(
1, sizeof(Ngap_DownlinkRANStatusTransferIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_RAN_UE_NGAP_ID;
ie->criticality = Ngap_Criticality_reject;
ie->value.present =
Ngap_DownlinkRANStatusTransferIEs__value_PR_RAN_UE_NGAP_ID;
Ngap_DownlinkRANStatusTransferIEs_t *ie = (Ngap_DownlinkRANStatusTransferIEs_t *)calloc(1, sizeof(Ngap_DownlinkRANStatusTransferIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_RAN_UE_NGAP_ID;
ie->criticality = Ngap_Criticality_reject;
ie->value.present = Ngap_DownlinkRANStatusTransferIEs__value_PR_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;
return;
}
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;
return;
}
ret = ASN_SEQUENCE_ADD(&DownlinkranstatustransferIEs->protocolIEs.list, ie);
if (ret != 0)
cout << "encode RAN_UE_NGAP_ID IE error" << endl;
}
void DownlinkRANStatusTransfer::setRANStatusTransfer_TransparentContainer(
long drb_id, long ul_pcdp, long ul_hfn_pdcp, long dl_pcdp,
long dl_hfn_pdcp) {
if (!ranStatusTransfer_TransparentContainer) {
ranStatusTransfer_TransparentContainer =
new RANStatusTransferTransparentContainer();
}
Ngap_DRB_ID_t *dRB_id = (Ngap_DRB_ID_t*) calloc(1, sizeof(Ngap_DRB_ID_t));
dRB_id = &drb_id;
COUNTValueForPDCP_SN18 *UL_value = (COUNTValueForPDCP_SN18*) calloc(
1, sizeof(COUNTValueForPDCP_SN18));
UL_value->setvalue(ul_pcdp, ul_hfn_pdcp);
COUNTValueForPDCP_SN18 *DL_value = (COUNTValueForPDCP_SN18*) calloc(
1, sizeof(COUNTValueForPDCP_SN18));
DL_value->setvalue(dl_pcdp, dl_hfn_pdcp);
dRBStatusUL18 *UL18 = (dRBStatusUL18*) calloc(1, sizeof(dRBStatusUL18));
UL18->setcountvalue(UL_value);
DRBStatusDL18 *DL18 = (DRBStatusDL18*) calloc(1, sizeof(DRBStatusDL18));
DL18->setcountvalue(DL_value);
dRBStatusDL *DL = (dRBStatusDL*) calloc(1, sizeof(dRBStatusDL));
DL->setDRBStatusDL18(DL18);
dRBStatusUL *UL = (dRBStatusUL*) calloc(1, sizeof(dRBStatusUL));
UL->setdRBStatusUL(UL18);
dRBSubjectItem *m_item = (dRBSubjectItem*) calloc(1, sizeof(dRBSubjectItem));
m_item->setdRBSubjectItem(dRB_id, UL, DL);
dRBSubjectList *m_list = (dRBSubjectList*) calloc(1, sizeof(dRBSubjectList));
m_list->setdRBSubjectItem(m_item, 1);
ranStatusTransfer_TransparentContainer->setdRBSubject_list(m_list);
Ngap_DownlinkRANStatusTransferIEs_t *ie =
(Ngap_DownlinkRANStatusTransferIEs_t*) calloc(
1, sizeof(Ngap_DownlinkRANStatusTransferIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_RANStatusTransfer_TransparentContainer;
ie->criticality = Ngap_Criticality_reject;
ie->value.present =
Ngap_DownlinkRANStatusTransferIEs__value_PR_RANStatusTransfer_TransparentContainer;
bool ret = ranStatusTransfer_TransparentContainer
->encoderanstatustransfer_transparentcontainer(
&ie->value.choice.RANStatusTransfer_TransparentContainer);
if (!ret) {
cout << "encode ranstatustransfer_transparentcontainer error" << endl;
}
if (ASN_SEQUENCE_ADD(&DownlinkranstatustransferIEs->protocolIEs.list, ie)
!= 0) {
cout << "encode ranstatustransfer_transparentcontainer error 2" << endl;
}
}
void DownlinkRANStatusTransfer::setmessagetype() {
if (!DownlinkranstatustransferPDU) {
DownlinkranstatustransferPDU = (Ngap_NGAP_PDU_t*) calloc(
1, sizeof(Ngap_NGAP_PDU_t));
}
MessageType downlinkranstatustransfermessageIEs;
downlinkranstatustransfermessageIEs.setProcedureCode(
Ngap_ProcedureCode_id_DownlinkRANStatusTransfer);
downlinkranstatustransfermessageIEs.setTypeOfMessage(
Ngap_NGAP_PDU_PR_initiatingMessage);
downlinkranstatustransfermessageIEs.setCriticality(Ngap_Criticality_ignore);
downlinkranstatustransfermessageIEs.setValuePresent(
Ngap_InitiatingMessage__value_PR_DownlinkRANStatusTransfer);
if (downlinkranstatustransfermessageIEs.getProcedureCode()
== Ngap_ProcedureCode_id_DownlinkRANStatusTransfer
&& downlinkranstatustransfermessageIEs.getTypeOfMessage()
== Ngap_NGAP_PDU_PR_initiatingMessage) {
downlinkranstatustransfermessageIEs.encode2pdu(
DownlinkranstatustransferPDU);
DownlinkranstatustransferIEs = &(DownlinkranstatustransferPDU->choice
.initiatingMessage->value.choice.DownlinkRANStatusTransfer);
} else {
cout
<< "[warning] This information doesn't refer to downlinkranstatustransfer Message!!!"
<< endl;
}
}
int DownlinkRANStatusTransfer::encodetobuffer(uint8_t *buf, int buf_size) {
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, DownlinkranstatustransferPDU);
asn_enc_rval_t er = aper_encode_to_buffer(&asn_DEF_Ngap_NGAP_PDU, NULL,
DownlinkranstatustransferPDU, buf,
buf_size);
cout << "er.encoded(" << er.encoded << ")" << endl;
return er.encoded;
}
} // namespace ngap
ret = ASN_SEQUENCE_ADD(&DownlinkranstatustransferIEs->protocolIEs.list, ie);
if (ret != 0)
cout << "encode RAN_UE_NGAP_ID IE error" << endl;
}
void DownlinkRANStatusTransfer::setRANStatusTransfer_TransparentContainer(long drb_id, long ul_pcdp, long ul_hfn_pdcp, long dl_pcdp, long dl_hfn_pdcp)
{
if (!ranStatusTransfer_TransparentContainer)
{
ranStatusTransfer_TransparentContainer = new RANStatusTransferTransparentContainer();
}
Ngap_DRB_ID_t *dRB_id = (Ngap_DRB_ID_t *)calloc(1, sizeof(Ngap_DRB_ID_t));
dRB_id = &drb_id;
COUNTValueForPDCP_SN18 *UL_value = (COUNTValueForPDCP_SN18 *)calloc(1, sizeof(COUNTValueForPDCP_SN18));
UL_value->setvalue(ul_pcdp, ul_hfn_pdcp);
COUNTValueForPDCP_SN18 *DL_value = (COUNTValueForPDCP_SN18 *)calloc(1, sizeof(COUNTValueForPDCP_SN18));
DL_value->setvalue(dl_pcdp, dl_hfn_pdcp);
dRBStatusUL18 *UL18 = (dRBStatusUL18 *)calloc(1, sizeof(dRBStatusUL18));
UL18->setcountvalue(UL_value);
DRBStatusDL18 *DL18 = (DRBStatusDL18 *)calloc(1, sizeof(DRBStatusDL18));
DL18->setcountvalue(DL_value);
dRBStatusDL *DL = (dRBStatusDL *)calloc(1, sizeof(dRBStatusDL));
DL->setDRBStatusDL18(DL18);
dRBStatusUL *UL = (dRBStatusUL *)calloc(1, sizeof(dRBStatusUL));
UL->setdRBStatusUL(UL18);
dRBSubjectItem *m_item = (dRBSubjectItem *)calloc(1, sizeof(dRBSubjectItem));
m_item->setdRBSubjectItem(dRB_id, UL, DL);
dRBSubjectList *m_list = (dRBSubjectList *)calloc(1, sizeof(dRBSubjectList));
m_list->setdRBSubjectItem(m_item, 1);
ranStatusTransfer_TransparentContainer->setdRBSubject_list(m_list);
Ngap_DownlinkRANStatusTransferIEs_t *ie = (Ngap_DownlinkRANStatusTransferIEs_t *)calloc(1, sizeof(Ngap_DownlinkRANStatusTransferIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_RANStatusTransfer_TransparentContainer;
ie->criticality = Ngap_Criticality_reject;
ie->value.present = Ngap_DownlinkRANStatusTransferIEs__value_PR_RANStatusTransfer_TransparentContainer;
bool ret = ranStatusTransfer_TransparentContainer->encoderanstatustransfer_transparentcontainer(&ie->value.choice.RANStatusTransfer_TransparentContainer);
if (!ret)
{
cout << "encode ranstatustransfer_transparentcontainer error" << endl;
}
if (ASN_SEQUENCE_ADD(&DownlinkranstatustransferIEs->protocolIEs.list, ie) != 0)
{
cout << "encode ranstatustransfer_transparentcontainer error 2" << endl;
}
}
void DownlinkRANStatusTransfer::setmessagetype()
{
if (!DownlinkranstatustransferPDU)
{
DownlinkranstatustransferPDU = (Ngap_NGAP_PDU_t *)calloc(1, sizeof(Ngap_NGAP_PDU_t));
}
MessageType downlinkranstatustransfermessageIEs;
downlinkranstatustransfermessageIEs.setProcedureCode(Ngap_ProcedureCode_id_DownlinkRANStatusTransfer);
downlinkranstatustransfermessageIEs.setTypeOfMessage(Ngap_NGAP_PDU_PR_initiatingMessage);
downlinkranstatustransfermessageIEs.setCriticality(Ngap_Criticality_ignore);
downlinkranstatustransfermessageIEs.setValuePresent(Ngap_InitiatingMessage__value_PR_DownlinkRANStatusTransfer);
if (downlinkranstatustransfermessageIEs.getProcedureCode() == Ngap_ProcedureCode_id_DownlinkRANStatusTransfer && downlinkranstatustransfermessageIEs.getTypeOfMessage() == Ngap_NGAP_PDU_PR_initiatingMessage)
{
downlinkranstatustransfermessageIEs.encode2pdu(DownlinkranstatustransferPDU);
DownlinkranstatustransferIEs = &(DownlinkranstatustransferPDU->choice.initiatingMessage->value.choice.DownlinkRANStatusTransfer);
}
else
{
cout << "[warning] This information doesn't refer to downlinkranstatustransfer Message!!!" << endl;
}
}
int DownlinkRANStatusTransfer::encodetobuffer(uint8_t *buf, int buf_size)
{
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, DownlinkranstatustransferPDU);
asn_enc_rval_t er = aper_encode_to_buffer(&asn_DEF_Ngap_NGAP_PDU, NULL, DownlinkranstatustransferPDU, buf, buf_size);
cout << "er.encoded(" << er.encoded << ")" << endl;
return er.encoded;
}
} // namespace ngap
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _DOWNLINKRANSTATUSTRANSFER_H_
#define _DOWNLINKRANSTATUSTRANSFER_H_
#include "AMF-UE-NGAP-ID.hpp"
......@@ -32,7 +5,8 @@
#include "MessageType.hpp"
#include "RANStatusTransferTransparentContainer.hpp"
#include "dRBStatusDL18.hpp"
extern "C" {
extern "C"
{
#include "Ngap_UplinkRANStatusTransfer.h"
#include "Ngap_RANStatusTransfer-TransparentContainer.h"
#include "Ngap_NGAP-PDU.h"
......@@ -42,23 +16,23 @@ extern "C" {
}
namespace ngap
{
class DownlinkRANStatusTransfer
{
public:
DownlinkRANStatusTransfer();
virtual ~DownlinkRANStatusTransfer();
void setmessagetype();
void setAmfUeNgapId(unsigned long id); //40 bits
void setRanUeNgapId(uint32_t id);// 32 bits
void setRANStatusTransfer_TransparentContainer(long drb_id, long ul_pcdp, long ul_hfn_pdcp, long dl_pcdp, long dl_hfn_pdcp);
int encodetobuffer(uint8_t *buf, int buf_size);
class DownlinkRANStatusTransfer
{
public:
DownlinkRANStatusTransfer();
virtual ~DownlinkRANStatusTransfer();
void setmessagetype();
void setAmfUeNgapId(unsigned long id); //40 bits
void setRanUeNgapId(uint32_t id); // 32 bits
void setRANStatusTransfer_TransparentContainer(long drb_id, long ul_pcdp, long ul_hfn_pdcp, long dl_pcdp, long dl_hfn_pdcp);
int encodetobuffer(uint8_t *buf, int buf_size);
private:
Ngap_NGAP_PDU_t *DownlinkranstatustransferPDU;
Ngap_DownlinkRANStatusTransfer_t *DownlinkranstatustransferIEs;
AMF_UE_NGAP_ID *amfUeNgapId;
RAN_UE_NGAP_ID *ranUeNgapId;
RANStatusTransferTransparentContainer *ranStatusTransfer_TransparentContainer;
};
} // namespace ngap
#endif
private:
Ngap_NGAP_PDU_t *DownlinkranstatustransferPDU;
Ngap_DownlinkRANStatusTransfer_t *DownlinkranstatustransferIEs;
AMF_UE_NGAP_ID *amfUeNgapId;
RAN_UE_NGAP_ID *ranUeNgapId;
RANStatusTransferTransparentContainer *ranStatusTransfer_TransparentContainer;
};
} // namespace ngap
#endif
\ No newline at end of file
#include "HandoverCommandMsg.hpp"
extern "C" {
#include "constr_TYPE.h"
#include "Ngap_NGAP-PDU.h"
#include "asn_codecs.h"
#include "per_encoder.h"
#include "per_decoder.h"
#include "constraints.h"
#include "Ngap_PDUSessionResourceHandoverItem.h"
extern "C"{
#include "constr_TYPE.h"
#include "Ngap_NGAP-PDU.h"
#include "asn_codecs.h"
#include "per_encoder.h"
#include "per_decoder.h"
#include "constraints.h"
#include "Ngap_PDUSessionResourceHandoverItem.h"
}
#include <iostream>
......@@ -14,303 +14,296 @@ extern "C" {
using namespace std;
namespace ngap {
HandoverCommandMsg::HandoverCommandMsg() {
amfUeNgapId = NULL;
ranUeNgapId = NULL;
ngap_handovertype = NULL;
NASSecurityParametersFromNGRAN = NULL;
PDUSessionResourceHandoverList = NULL;
PDUSessionResourceToReleaseListHOCmd = NULL;
TargetToSource_TransparentContainer = NULL;
CriticalityDiagnostics = NULL;
handoverCommandPdu = NULL;
handoverCommandIEs = NULL;
}
HandoverCommandMsg::~HandoverCommandMsg() {
}
namespace ngap{
HandoverCommandMsg::HandoverCommandMsg()
{
amfUeNgapId = NULL;
ranUeNgapId = NULL;
ngap_handovertype = NULL;
NASSecurityParametersFromNGRAN = NULL;
PDUSessionResourceHandoverList = NULL;
PDUSessionResourceToReleaseListHOCmd = NULL;
TargetToSource_TransparentContainer = NULL;
CriticalityDiagnostics = NULL;
handoverCommandPdu = NULL;
handoverCommandIEs = NULL;
}
HandoverCommandMsg::~HandoverCommandMsg() {}
unsigned long HandoverCommandMsg::getAmfUeNgapId()
{
return amfUeNgapId->getAMF_UE_NGAP_ID();
}
uint32_t HandoverCommandMsg::getRanUeNgapId()
{
return ranUeNgapId->getRanUeNgapId();
}
bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu)
{
handoverCommandPdu = ngap_msg_pdu;
if (handoverCommandPdu->present == Ngap_NGAP_PDU_PR_successfulOutcome)
{
if (handoverCommandPdu->choice.successfulOutcome && handoverCommandPdu->choice.successfulOutcome->procedureCode == Ngap_ProcedureCode_id_HandoverPreparation && handoverCommandPdu->choice.successfulOutcome->criticality == Ngap_Criticality_reject && handoverCommandPdu->choice.successfulOutcome->value.present == Ngap_SuccessfulOutcome__value_PR_HandoverCommand)
{
handoverCommandIEs = &handoverCommandPdu->choice.successfulOutcome->value.choice.HandoverCommand;
}
else
{
cout << "Check HandoverCommand message error!!!" << endl;
return false;
}
}
else
{
cout << "HandoverRequired MessageType error!!!" << endl;
return false;
}
for (int i = 0; i < handoverCommandIEs->protocolIEs.list.count; i++)
{
switch (handoverCommandIEs->protocolIEs.list.array[i]->id)
{
case Ngap_ProtocolIE_ID_id_AMF_UE_NGAP_ID: {
if (handoverCommandIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_reject && handoverCommandIEs->protocolIEs.list.array[i]->value.present == Ngap_HandoverCommandIEs__value_PR_AMF_UE_NGAP_ID)
{
amfUeNgapId = new AMF_UE_NGAP_ID();
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;
return false;
}
}
else
{
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl;
return false;
}
}break;
case Ngap_ProtocolIE_ID_id_RAN_UE_NGAP_ID: {
if (handoverCommandIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_reject && handoverCommandIEs->protocolIEs.list.array[i]->value.present == Ngap_HandoverCommandIEs__value_PR_RAN_UE_NGAP_ID)
{
ranUeNgapId = new RAN_UE_NGAP_ID();
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;
return false;
}
}
else
{
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl;
return false;
}
}break;
case Ngap_ProtocolIE_ID_id_HandoverType: {
if (handoverCommandIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_reject && handoverCommandIEs->protocolIEs.list.array[i]->value.present == Ngap_HandoverCommandIEs__value_PR_HandoverType)
{
ngap_handovertype = new Ngap_HandoverType_t();
*ngap_handovertype = handoverCommandIEs->protocolIEs.list.array[i]->value.choice.HandoverType;
}
else
{
cout << "decoded ngap Handover Type IE error" << endl;
return false;
}
}break;
case Ngap_ProtocolIE_ID_id_PDUSessionResourceHandoverList: {
if (handoverCommandIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_ignore && handoverCommandIEs->protocolIEs.list.array[i]->value.present == Ngap_HandoverCommandIEs__value_PR_PDUSessionResourceHandoverList)
{
}
else
{
cout << "decoded ngap PDUSessionResourceHandoverList IE error" << endl;
return false;
}
}break;
case Ngap_ProtocolIE_ID_id_PDUSessionResourceToReleaseListHOCmd: {
if (handoverCommandIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_ignore && handoverCommandIEs->protocolIEs.list.array[i]->value.present == Ngap_HandoverCommandIEs__value_PR_PDUSessionResourceToReleaseListHOCmd)
{
}
else
{
cout << "decoded ngap PDUSessionResourceToReleaseListHOCmd IE error" << endl;
return false;
}
}break;
case Ngap_ProtocolIE_ID_id_TargetToSource_TransparentContainer: {
if (handoverCommandIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_reject && handoverCommandIEs->protocolIEs.list.array[i]->value.present == Ngap_HandoverCommandIEs__value_PR_TargetToSource_TransparentContainer)
{
}
else
{
cout << "decoded ngap TargetToSource_TransparentContainer IE error" << endl;
return false;
}
}break;
case Ngap_ProtocolIE_ID_id_CriticalityDiagnostics: {
if (handoverCommandIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_ignore && handoverCommandIEs->protocolIEs.list.array[i]->value.present == Ngap_HandoverCommandIEs__value_PR_CriticalityDiagnostics)
{
}
else
{
cout << "decoded ngap CriticalityDiagnostics IE error" << endl;
return false;
}
}break;
default: {
cout << "decoded ngap message pdu error" << endl;
return false;
}
}
}
return true;
}
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);
cout << "er.encoded(" << er.encoded << ")" << endl;
return er.encoded;
}
void HandoverCommandMsg::setMessageType()
{
if (!handoverCommandPdu) handoverCommandPdu = (Ngap_NGAP_PDU_t*)calloc(1, sizeof(Ngap_NGAP_PDU_t));
MessageType HandoverCommandMessageTypeIE;
HandoverCommandMessageTypeIE.setProcedureCode(Ngap_ProcedureCode_id_HandoverPreparation);
HandoverCommandMessageTypeIE.setTypeOfMessage(Ngap_NGAP_PDU_PR_successfulOutcome);
HandoverCommandMessageTypeIE.setCriticality(Ngap_Criticality_reject);
HandoverCommandMessageTypeIE.setValuePresent(Ngap_SuccessfulOutcome__value_PR_HandoverCommand);
if (HandoverCommandMessageTypeIE.getProcedureCode() == Ngap_ProcedureCode_id_HandoverPreparation && HandoverCommandMessageTypeIE.getTypeOfMessage() == Ngap_NGAP_PDU_PR_successfulOutcome)
{
HandoverCommandMessageTypeIE.encode2pdu(handoverCommandPdu);
handoverCommandIEs = &(handoverCommandPdu->choice.successfulOutcome->value.choice.HandoverCommand);
}
else
{
cout << "[warning] This information doesn't refer to HandoverCommand Message!!!" << endl;
}
}
void HandoverCommandMsg::setAmfUeNgapId(unsigned long id)
{
if (!amfUeNgapId)
amfUeNgapId = new AMF_UE_NGAP_ID();
amfUeNgapId->setAMF_UE_NGAP_ID(id);
Ngap_HandoverCommandIEs_t *ie = (Ngap_HandoverCommandIEs_t *)calloc(1, sizeof(Ngap_HandoverCommandIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_AMF_UE_NGAP_ID;
ie->criticality = Ngap_Criticality_reject;
ie->value.present = Ngap_HandoverCommandIEs__value_PR_AMF_UE_NGAP_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;
return;
}
ret = ASN_SEQUENCE_ADD(&handoverCommandIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode AMF_UE_NGAP_ID IE error" << endl;
}
void HandoverCommandMsg::setRanUeNgapId(uint32_t ran_ue_ngap_id)
{
if (!ranUeNgapId)
ranUeNgapId = new RAN_UE_NGAP_ID();
ranUeNgapId->setRanUeNgapId(ran_ue_ngap_id);
Ngap_HandoverCommandIEs_t *ie = (Ngap_HandoverCommandIEs_t *)calloc(1, sizeof(Ngap_HandoverCommandIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_RAN_UE_NGAP_ID;
ie->criticality = Ngap_Criticality_reject;
ie->value.present = Ngap_HandoverCommandIEs__value_PR_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;
return;
}
ret = ASN_SEQUENCE_ADD(&handoverCommandIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode RAN_UE_NGAP_ID IE error" << endl;
}
void HandoverCommandMsg::setHandoverType(long type)
{
if (!ngap_handovertype)
ngap_handovertype = new Ngap_HandoverType_t();
Ngap_HandoverCommandIEs_t *ie = (Ngap_HandoverCommandIEs_t *)calloc(1, sizeof(Ngap_HandoverCommandIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_HandoverType;
ie->criticality = Ngap_Criticality_reject;
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;
}
void HandoverCommandMsg::setPduSessionResourceHandoverList(std::vector<PDUSessionResourceHandoverItem_t> list)
{
if (!PDUSessionResourceHandoverList)
PDUSessionResourceHandoverList = new Ngap_PDUSessionResourceHandoverList_t();
Ngap_HandoverCommandIEs_t *ie = (Ngap_HandoverCommandIEs_t *)calloc(1, sizeof(Ngap_HandoverCommandIEs_t));
for (int i = 0; i < list.size(); i++)
{
Ngap_PDUSessionResourceHandoverItem_t *item = (Ngap_PDUSessionResourceHandoverItem_t *)calloc(1, sizeof(Ngap_PDUSessionResourceHandoverItem_t));
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;
}
ie->id = Ngap_ProtocolIE_ID_id_PDUSessionResourceHandoverList;
ie->criticality = Ngap_Criticality_ignore;
ie->value.present = Ngap_HandoverCommandIEs__value_PR_PDUSessionResourceHandoverList;
ie->value.choice.PDUSessionResourceHandoverList = *PDUSessionResourceHandoverList;
int ret = ASN_SEQUENCE_ADD(&handoverCommandIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode PDUSessionResourceHandoverList IE error" << endl;
}
void HandoverCommandMsg::setTargetToSource_TransparentContainer(OCTET_STRING_t targetTosource)
{
if (!TargetToSource_TransparentContainer)
TargetToSource_TransparentContainer = new Ngap_TargetToSource_TransparentContainer_t();
Ngap_HandoverCommandIEs_t *ie = (Ngap_HandoverCommandIEs_t *)calloc(1, sizeof(Ngap_HandoverCommandIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_TargetToSource_TransparentContainer;
ie->criticality = Ngap_Criticality_reject;
ie->value.present = 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;
}
unsigned long HandoverCommandMsg::getAmfUeNgapId() {
return amfUeNgapId->getAMF_UE_NGAP_ID();
}
uint32_t HandoverCommandMsg::getRanUeNgapId() {
return ranUeNgapId->getRanUeNgapId();
}
bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu) {
handoverCommandPdu = ngap_msg_pdu;
if (handoverCommandPdu->present == Ngap_NGAP_PDU_PR_successfulOutcome) {
if (handoverCommandPdu->choice.successfulOutcome
&& handoverCommandPdu->choice.successfulOutcome->procedureCode
== Ngap_ProcedureCode_id_HandoverPreparation
&& handoverCommandPdu->choice.successfulOutcome->criticality
== Ngap_Criticality_reject
&& handoverCommandPdu->choice.successfulOutcome->value.present
== Ngap_SuccessfulOutcome__value_PR_HandoverCommand) {
handoverCommandIEs = &handoverCommandPdu->choice.successfulOutcome->value
.choice.HandoverCommand;
} else {
cout << "Check HandoverCommand message error!!!" << endl;
return false;
}
} else {
cout << "HandoverRequired MessageType error!!!" << endl;
return false;
}
for (int i = 0; i < handoverCommandIEs->protocolIEs.list.count; i++) {
switch (handoverCommandIEs->protocolIEs.list.array[i]->id) {
case Ngap_ProtocolIE_ID_id_AMF_UE_NGAP_ID: {
if (handoverCommandIEs->protocolIEs.list.array[i]->criticality
== Ngap_Criticality_reject
&& handoverCommandIEs->protocolIEs.list.array[i]->value.present
== Ngap_HandoverCommandIEs__value_PR_AMF_UE_NGAP_ID) {
amfUeNgapId = new AMF_UE_NGAP_ID();
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;
return false;
}
} else {
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl;
return false;
}
}
break;
case Ngap_ProtocolIE_ID_id_RAN_UE_NGAP_ID: {
if (handoverCommandIEs->protocolIEs.list.array[i]->criticality
== Ngap_Criticality_reject
&& handoverCommandIEs->protocolIEs.list.array[i]->value.present
== Ngap_HandoverCommandIEs__value_PR_RAN_UE_NGAP_ID) {
ranUeNgapId = new RAN_UE_NGAP_ID();
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;
return false;
}
} else {
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl;
return false;
}
}
break;
case Ngap_ProtocolIE_ID_id_HandoverType: {
if (handoverCommandIEs->protocolIEs.list.array[i]->criticality
== Ngap_Criticality_reject
&& handoverCommandIEs->protocolIEs.list.array[i]->value.present
== Ngap_HandoverCommandIEs__value_PR_HandoverType) {
ngap_handovertype = new Ngap_HandoverType_t();
*ngap_handovertype = handoverCommandIEs->protocolIEs.list.array[i]
->value.choice.HandoverType;
} else {
cout << "decoded ngap Handover Type IE error" << endl;
return false;
}
}
break;
case Ngap_ProtocolIE_ID_id_PDUSessionResourceHandoverList: {
if (handoverCommandIEs->protocolIEs.list.array[i]->criticality
== Ngap_Criticality_ignore
&& handoverCommandIEs->protocolIEs.list.array[i]->value.present
== Ngap_HandoverCommandIEs__value_PR_PDUSessionResourceHandoverList) {
} else {
cout << "decoded ngap PDUSessionResourceHandoverList IE error"
<< endl;
return false;
}
}
break;
case Ngap_ProtocolIE_ID_id_PDUSessionResourceToReleaseListHOCmd: {
if (handoverCommandIEs->protocolIEs.list.array[i]->criticality
== Ngap_Criticality_ignore
&& handoverCommandIEs->protocolIEs.list.array[i]->value.present
== Ngap_HandoverCommandIEs__value_PR_PDUSessionResourceToReleaseListHOCmd) {
} else {
cout << "decoded ngap PDUSessionResourceToReleaseListHOCmd IE error"
<< endl;
return false;
}
}
break;
case Ngap_ProtocolIE_ID_id_TargetToSource_TransparentContainer: {
if (handoverCommandIEs->protocolIEs.list.array[i]->criticality
== Ngap_Criticality_reject
&& handoverCommandIEs->protocolIEs.list.array[i]->value.present
== Ngap_HandoverCommandIEs__value_PR_TargetToSource_TransparentContainer) {
} else {
cout << "decoded ngap TargetToSource_TransparentContainer IE error"
<< endl;
return false;
}
}
break;
case Ngap_ProtocolIE_ID_id_CriticalityDiagnostics: {
if (handoverCommandIEs->protocolIEs.list.array[i]->criticality
== Ngap_Criticality_ignore
&& handoverCommandIEs->protocolIEs.list.array[i]->value.present
== Ngap_HandoverCommandIEs__value_PR_CriticalityDiagnostics) {
} else {
cout << "decoded ngap CriticalityDiagnostics IE error" << endl;
return false;
}
}
break;
default: {
cout << "decoded ngap message pdu error" << endl;
return false;
}
}
}
return true;
}
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);
cout << "er.encoded(" << er.encoded << ")" << endl;
return er.encoded;
}
void HandoverCommandMsg::setMessageType() {
if (!handoverCommandPdu)
handoverCommandPdu = (Ngap_NGAP_PDU_t*) calloc(1, sizeof(Ngap_NGAP_PDU_t));
MessageType HandoverCommandMessageTypeIE;
HandoverCommandMessageTypeIE.setProcedureCode(
Ngap_ProcedureCode_id_HandoverPreparation);
HandoverCommandMessageTypeIE.setTypeOfMessage(
Ngap_NGAP_PDU_PR_successfulOutcome);
HandoverCommandMessageTypeIE.setCriticality(Ngap_Criticality_reject);
HandoverCommandMessageTypeIE.setValuePresent(
Ngap_SuccessfulOutcome__value_PR_HandoverCommand);
if (HandoverCommandMessageTypeIE.getProcedureCode()
== Ngap_ProcedureCode_id_HandoverPreparation
&& HandoverCommandMessageTypeIE.getTypeOfMessage()
== Ngap_NGAP_PDU_PR_successfulOutcome) {
HandoverCommandMessageTypeIE.encode2pdu(handoverCommandPdu);
handoverCommandIEs = &(handoverCommandPdu->choice.successfulOutcome->value
.choice.HandoverCommand);
} else {
cout
<< "[warning] This information doesn't refer to HandoverCommand Message!!!"
<< endl;
}
}
void HandoverCommandMsg::setAmfUeNgapId(unsigned long id) {
if (!amfUeNgapId)
amfUeNgapId = new AMF_UE_NGAP_ID();
amfUeNgapId->setAMF_UE_NGAP_ID(id);
Ngap_HandoverCommandIEs_t *ie = (Ngap_HandoverCommandIEs_t*) calloc(
1, sizeof(Ngap_HandoverCommandIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_AMF_UE_NGAP_ID;
ie->criticality = Ngap_Criticality_reject;
ie->value.present = Ngap_HandoverCommandIEs__value_PR_AMF_UE_NGAP_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;
return;
}
ret = ASN_SEQUENCE_ADD(&handoverCommandIEs->protocolIEs.list, ie);
if (ret != 0)
cout << "encode AMF_UE_NGAP_ID IE error" << endl;
}
void HandoverCommandMsg::setRanUeNgapId(uint32_t ran_ue_ngap_id) {
if (!ranUeNgapId)
ranUeNgapId = new RAN_UE_NGAP_ID();
ranUeNgapId->setRanUeNgapId(ran_ue_ngap_id);
Ngap_HandoverCommandIEs_t *ie = (Ngap_HandoverCommandIEs_t*) calloc(
1, sizeof(Ngap_HandoverCommandIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_RAN_UE_NGAP_ID;
ie->criticality = Ngap_Criticality_reject;
ie->value.present = Ngap_HandoverCommandIEs__value_PR_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;
return;
}
ret = ASN_SEQUENCE_ADD(&handoverCommandIEs->protocolIEs.list, ie);
if (ret != 0)
cout << "encode RAN_UE_NGAP_ID IE error" << endl;
}
void HandoverCommandMsg::setHandoverType(long type) {
if (!ngap_handovertype)
ngap_handovertype = new Ngap_HandoverType_t();
Ngap_HandoverCommandIEs_t *ie = (Ngap_HandoverCommandIEs_t*) calloc(
1, sizeof(Ngap_HandoverCommandIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_HandoverType;
ie->criticality = Ngap_Criticality_reject;
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;
}
void HandoverCommandMsg::setPduSessionResourceHandoverList(
std::vector<PDUSessionResourceHandoverItem_t> list) {
if (!PDUSessionResourceHandoverList)
PDUSessionResourceHandoverList =
new Ngap_PDUSessionResourceHandoverList_t();
Ngap_HandoverCommandIEs_t *ie = (Ngap_HandoverCommandIEs_t*) calloc(
1, sizeof(Ngap_HandoverCommandIEs_t));
for (int i = 0; i < list.size(); i++) {
Ngap_PDUSessionResourceHandoverItem_t *item =
(Ngap_PDUSessionResourceHandoverItem_t*) calloc(
1, sizeof(Ngap_PDUSessionResourceHandoverItem_t));
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;
}
ie->id = Ngap_ProtocolIE_ID_id_PDUSessionResourceHandoverList;
ie->criticality = Ngap_Criticality_ignore;
ie->value.present =
Ngap_HandoverCommandIEs__value_PR_PDUSessionResourceHandoverList;
ie->value.choice.PDUSessionResourceHandoverList =
*PDUSessionResourceHandoverList;
int ret = ASN_SEQUENCE_ADD(&handoverCommandIEs->protocolIEs.list, ie);
if (ret != 0)
cout << "encode PDUSessionResourceHandoverList IE error" << endl;
}
void HandoverCommandMsg::setTargetToSource_TransparentContainer(
OCTET_STRING_t targetTosource) {
if (!TargetToSource_TransparentContainer)
TargetToSource_TransparentContainer =
new Ngap_TargetToSource_TransparentContainer_t();
Ngap_HandoverCommandIEs_t *ie = (Ngap_HandoverCommandIEs_t*) calloc(
1, sizeof(Ngap_HandoverCommandIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_TargetToSource_TransparentContainer;
ie->criticality = Ngap_Criticality_reject;
ie->value.present =
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;
}
}
......@@ -11,56 +11,60 @@
#include "AMF-UE-NGAP-ID.hpp"
#include "RAN-UE-NGAP-ID.hpp"
#include "Cause.hpp"
extern "C" {
#include "Ngap_NGAP-PDU.h"
#include "Ngap_ProtocolIE-Field.h"
#include "Ngap_NGSetupRequest.h"
extern "C"{
#include "Ngap_NGAP-PDU.h"
#include "Ngap_ProtocolIE-Field.h"
#include "Ngap_NGSetupRequest.h"
}
namespace ngap {
typedef struct {
uint8_t pduSessionId;
OCTET_STRING_t HandoverCommandTransfer;
}PDUSessionResourceHandoverItem_t;
class HandoverCommandMsg {
public:
HandoverCommandMsg();
virtual ~HandoverCommandMsg();
void setMessageType(); //Initialize the PDU and populate the MessageType;
void setAmfUeNgapId(unsigned long id);//40 bits
void setRanUeNgapId(uint32_t id);// 32 bits
void setHandoverType(long type);
void setPduSessionResourceHandoverList(std::vector<PDUSessionResourceHandoverItem_t> list);
void setTargetToSource_TransparentContainer(OCTET_STRING_t targetTosource);
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;(不存在)
/*void getHandoverType(Ngap_HandoverType_t &handovertype);
void getCause(Cause cause);
void getTargetID(Ngap_TargetID_t targetID);
void getDirectForwardingPathAvailability(Ngap_DirectForwardingPathAvailability_t directpathavailable);
void getPDUSessionResourceList(Ngap_PDUSessionResourceHandoverList_t pdusessionresourcelist);
void getSourceToTargetTransparentContainer();*/
private:
Ngap_NGAP_PDU_t *handoverCommandPdu;
Ngap_HandoverCommand_t *handoverCommandIEs;
/***************** for decoding ****************/
AMF_UE_NGAP_ID *amfUeNgapId;
RAN_UE_NGAP_ID *ranUeNgapId;
Ngap_HandoverType_t *ngap_handovertype;
Ngap_NASSecurityParametersFromNGRAN_t *NASSecurityParametersFromNGRAN;
Ngap_PDUSessionResourceHandoverList_t *PDUSessionResourceHandoverList;
Ngap_PDUSessionResourceToReleaseListHOCmd_t *PDUSessionResourceToReleaseListHOCmd;
Ngap_TargetToSource_TransparentContainer_t *TargetToSource_TransparentContainer;
Ngap_CriticalityDiagnostics_t *CriticalityDiagnostics;
};
namespace ngap{
typedef struct {
uint8_t pduSessionId;
OCTET_STRING_t HandoverCommandTransfer;
}PDUSessionResourceHandoverItem_t;
class HandoverCommandMsg{
public:
HandoverCommandMsg();
virtual ~HandoverCommandMsg();
void setMessageType(); //Initialize the PDU and populate the MessageType;
void setAmfUeNgapId(unsigned long id);//40 bits
void setRanUeNgapId(uint32_t id);// 32 bits
void setHandoverType(long type);
void setPduSessionResourceHandoverList(std::vector<PDUSessionResourceHandoverItem_t> list);
void setTargetToSource_TransparentContainer(OCTET_STRING_t targetTosource);
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;(不存在)
/*void getHandoverType(Ngap_HandoverType_t &handovertype);
void getCause(Cause cause);
void getTargetID(Ngap_TargetID_t targetID);
void getDirectForwardingPathAvailability(Ngap_DirectForwardingPathAvailability_t directpathavailable);
void getPDUSessionResourceList(Ngap_PDUSessionResourceHandoverList_t pdusessionresourcelist);
void getSourceToTargetTransparentContainer();*/
private:
Ngap_NGAP_PDU_t *handoverCommandPdu;
Ngap_HandoverCommand_t *handoverCommandIEs;
/***************** for decoding ****************/
AMF_UE_NGAP_ID *amfUeNgapId;
RAN_UE_NGAP_ID *ranUeNgapId;
Ngap_HandoverType_t *ngap_handovertype;
Ngap_NASSecurityParametersFromNGRAN_t *NASSecurityParametersFromNGRAN;
Ngap_PDUSessionResourceHandoverList_t *PDUSessionResourceHandoverList;
Ngap_PDUSessionResourceToReleaseListHOCmd_t *PDUSessionResourceToReleaseListHOCmd;
Ngap_TargetToSource_TransparentContainer_t *TargetToSource_TransparentContainer;
Ngap_CriticalityDiagnostics_t *CriticalityDiagnostics;
};
}
......
......@@ -19,12 +19,12 @@
* contact@openairinterface.org
*/
/*! \file HandoverNotifyMsg.cpp
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
/*! \file HandoverNotifyMsg.cpp
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "HandoverNotifyMsg.hpp"
extern "C" {
......@@ -40,171 +40,169 @@ extern "C" {
using namespace std;
namespace ngap {
HandoverNotifyMsg::HandoverNotifyMsg() {
amfUeNgapId = NULL;
ranUeNgapId = NULL;
userLocationInformation = NULL;
}
HandoverNotifyMsg::~HandoverNotifyMsg() {
}
;
unsigned long HandoverNotifyMsg::getAmfUeNgapId() {
return amfUeNgapId->getAMF_UE_NGAP_ID();
}
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);
cout << "er.encoded(" << er.encoded << ")" << endl;
return er.encoded;
}
bool HandoverNotifyMsg::decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu) {
handoverNotifyPdu = ngap_msg_pdu;
HandoverNotifyMsg::HandoverNotifyMsg()
{
amfUeNgapId = NULL;
ranUeNgapId = NULL;
userLocationInformation = NULL;
}
HandoverNotifyMsg::~HandoverNotifyMsg() {};
unsigned long HandoverNotifyMsg::getAmfUeNgapId()
{
return amfUeNgapId->getAMF_UE_NGAP_ID();
}
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);
cout << "er.encoded(" << er.encoded << ")" << endl;
return er.encoded;
}
bool HandoverNotifyMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu)
{
handoverNotifyPdu = ngap_msg_pdu;
if (handoverNotifyPdu->present == Ngap_NGAP_PDU_PR_initiatingMessage) {
if (handoverNotifyPdu->choice.initiatingMessage
&& handoverNotifyPdu->choice.initiatingMessage->procedureCode
== Ngap_ProcedureCode_id_HandoverPreparation
&& handoverNotifyPdu->choice.initiatingMessage->criticality
== Ngap_Criticality_reject
&& handoverNotifyPdu->choice.initiatingMessage->value.present
== Ngap_InitiatingMessage__value_PR_HandoverNotify) {
handoverNotifyIEs = &handoverNotifyPdu->choice.initiatingMessage->value
.choice.HandoverNotify;
} else {
cout << "Check HandoverNotify message error!!!" << endl;
return false;
}
} else {
cout << "HandoverNotify MessageType error!!!" << endl;
return false;
}
for (int i = 0; i < handoverNotifyIEs->protocolIEs.list.count; i++) {
switch (handoverNotifyIEs->protocolIEs.list.array[i]->id) {
case Ngap_ProtocolIE_ID_id_AMF_UE_NGAP_ID: {
if (handoverNotifyIEs->protocolIEs.list.array[i]->criticality
== Ngap_Criticality_reject
&& handoverNotifyIEs->protocolIEs.list.array[i]->value.present
== Ngap_HandoverNotifyIEs__value_PR_AMF_UE_NGAP_ID) {
amfUeNgapId = new AMF_UE_NGAP_ID();
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;
return false;
}
} else {
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl;
return false;
}
}
break;
case Ngap_ProtocolIE_ID_id_RAN_UE_NGAP_ID: {
if (handoverNotifyIEs->protocolIEs.list.array[i]->criticality
== Ngap_Criticality_reject
&& handoverNotifyIEs->protocolIEs.list.array[i]->value.present
== Ngap_HandoverNotifyIEs__value_PR_RAN_UE_NGAP_ID) {
ranUeNgapId = new RAN_UE_NGAP_ID();
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;
return false;
}
} else {
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl;
return false;
}
}
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) {
userLocationInformation = new UserLocationInformation();
if (!userLocationInformation->decodefromUserLocationInformation(
&handoverNotifyIEs->protocolIEs.list.array[i]->value.choice
.UserLocationInformation)) {
cout << "decoded ngap UserLocationInformation IE error" << endl;
return false;
}
} else {
cout << "decoded ngap UserLocationInformation IE error" << endl;
return false;
}
}
break;
}
}
return true;
}
void HandoverNotifyMsg::setUserLocationInfoNR(struct NrCgi_s cig,
struct Tai_s tai) {
if (!userLocationInformation)
userLocationInformation = new UserLocationInformation();
if (handoverNotifyPdu->present == Ngap_NGAP_PDU_PR_initiatingMessage)
{
if (handoverNotifyPdu->choice.initiatingMessage && handoverNotifyPdu->choice.initiatingMessage->procedureCode == Ngap_ProcedureCode_id_HandoverNotification && handoverNotifyPdu->choice.initiatingMessage->criticality == Ngap_Criticality_ignore && handoverNotifyPdu->choice.initiatingMessage->value.present == Ngap_InitiatingMessage__value_PR_HandoverNotify)
{
handoverNotifyIEs = &handoverNotifyPdu->choice.initiatingMessage->value.choice.HandoverNotify;
}
else
{
cout << "Check HandoverNotify message error!!!" << endl;
return false;
}
}
else
{
cout << "HandoverNotify MessageType error!!!" << endl;
return false;
}
for (int i = 0; i < handoverNotifyIEs->protocolIEs.list.count; i++)
{
switch (handoverNotifyIEs->protocolIEs.list.array[i]->id)
{
case Ngap_ProtocolIE_ID_id_AMF_UE_NGAP_ID: {
if (handoverNotifyIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_reject && handoverNotifyIEs->protocolIEs.list.array[i]->value.present == Ngap_HandoverNotifyIEs__value_PR_AMF_UE_NGAP_ID)
{
amfUeNgapId = new AMF_UE_NGAP_ID();
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;
return false;
}
}
else
{
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl;
return false;
}
}break;
case Ngap_ProtocolIE_ID_id_RAN_UE_NGAP_ID:{
if (handoverNotifyIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_reject && handoverNotifyIEs->protocolIEs.list.array[i]->value.present == Ngap_HandoverNotifyIEs__value_PR_RAN_UE_NGAP_ID)
{
ranUeNgapId = new RAN_UE_NGAP_ID();
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;
return false;
}
}
else
{
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl;
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)
{
userLocationInformation = new UserLocationInformation();
if (!userLocationInformation->decodefromUserLocationInformation(&handoverNotifyIEs->protocolIEs.list.array[i]->value.choice.UserLocationInformation))
{
cout << "decoded ngap UserLocationInformation IE error" << endl;
return false;
}
}
else
{
cout << "decoded ngap UserLocationInformation IE error" << endl;
return false;
}
}break;
default: {
cout << "decoded ngap message pdu error" << endl;
return false;
}
}
}
return true;
}
void HandoverNotifyMsg::setUserLocationInfoNR(struct NrCgi_s cig, struct Tai_s tai)
{
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();
NRCellIdentity *nRCellIdentity = new NRCellIdentity();
plmnId_cgi->setMccMnc(cig.mcc, cig.mnc);
nRCellIdentity->setNRCellIdentity(cig.nrCellID);
nR_CGI->setNR_CGI(plmnId_cgi, nRCellIdentity);
//userLocationInformation->setInformation(UserLocationInformationEUTRA * informationEUTRA);
UserLocationInformationNR* informationNR = new UserLocationInformationNR();
NR_CGI* nR_CGI = new NR_CGI();
PlmnId* plmnId_cgi = new PlmnId();
NRCellIdentity* nRCellIdentity = new NRCellIdentity();
plmnId_cgi->setMccMnc(cig.mcc, cig.mnc);
nRCellIdentity->setNRCellIdentity(cig.nrCellID);
nR_CGI->setNR_CGI(plmnId_cgi, nRCellIdentity);
TAI *tai_nr = new TAI();
PlmnId *plmnId_tai = new PlmnId();
plmnId_tai->setMccMnc(tai.mcc, tai.mnc);
TAC *tac = new TAC();
tac->setTac(tai.tac);
tai_nr->setTAI(plmnId_tai, tac);
informationNR->setInformationNR(nR_CGI, tai_nr);
userLocationInformation->setInformation(informationNR);
TAI* tai_nr = new TAI();
PlmnId* plmnId_tai = new PlmnId();
plmnId_tai->setMccMnc(tai.mcc, tai.mnc);
TAC* tac = new TAC();
tac->setTac(tai.tac);
tai_nr->setTAI(plmnId_tai, tac);
informationNR->setInformationNR(nR_CGI, tai_nr);
userLocationInformation->setInformation(informationNR);
Ngap_HandoverNotifyIEs_t *ie = (Ngap_HandoverNotifyIEs_t*) calloc(
1, sizeof(Ngap_HandoverNotifyIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_UserLocationInformation;
ie->criticality = Ngap_Criticality_ignore;
ie->value.present = Ngap_HandoverNotifyIEs__value_PR_UserLocationInformation;
Ngap_HandoverNotifyIEs_t* ie = (Ngap_HandoverNotifyIEs_t*)calloc(1, sizeof(Ngap_HandoverNotifyIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_UserLocationInformation;
ie->criticality = Ngap_Criticality_ignore;
ie->value.present = Ngap_HandoverNotifyIEs__value_PR_UserLocationInformation;
int ret = userLocationInformation->encodefromUserLocationInformation(
&ie->value.choice.UserLocationInformation);
if (!ret) {
cout << "encode UserLocationInformation IE error" << endl;
return;
}
int ret = userLocationInformation->encodefromUserLocationInformation(&ie->value.choice.UserLocationInformation);
if (!ret)
{
cout << "encode UserLocationInformation IE error" << endl;
return;
}
ret = ASN_SEQUENCE_ADD(&handoverNotifyIEs->protocolIEs.list, ie);
if (ret != 0)
cout << "encode UserLocationInformation IE error" << endl;
}
uint32_t HandoverNotifyMsg::getRanUeNgapId() {
return ranUeNgapId->getRanUeNgapId();
}
bool HandoverNotifyMsg::getUserLocationInfoNR(struct NrCgi_s &cig,
struct Tai_s &tai) {
UserLocationInformationNR *informationNR;
userLocationInformation->getInformation(informationNR);
if (userLocationInformation->getChoiceOfUserLocationInformation()
!= Ngap_UserLocationInformation_PR_userLocationInformationNR)
return false;
NR_CGI *nR_CGI;
TAI *nR_TAI;
informationNR->getInformationNR(nR_CGI, nR_TAI);
PlmnId *cgi_plmnId;
NRCellIdentity *nRCellIdentity;
nR_CGI->getNR_CGI(cgi_plmnId, nRCellIdentity);
cgi_plmnId->getMcc(cig.mcc);
cgi_plmnId->getMnc(cig.mnc);
cig.nrCellID = nRCellIdentity->getNRCellIdentity();
ret = ASN_SEQUENCE_ADD(&handoverNotifyIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode UserLocationInformation IE error" << endl;
}
uint32_t HandoverNotifyMsg::getRanUeNgapId()
{
return ranUeNgapId->getRanUeNgapId();
}
bool HandoverNotifyMsg::getUserLocationInfoNR(struct NrCgi_s& cig, struct Tai_s& tai)
{
UserLocationInformationNR* informationNR;
userLocationInformation->getInformation(informationNR);
if (userLocationInformation->getChoiceOfUserLocationInformation() != Ngap_UserLocationInformation_PR_userLocationInformationNR) return false;
NR_CGI* nR_CGI;
TAI* nR_TAI;
informationNR->getInformationNR(nR_CGI, nR_TAI);
PlmnId* cgi_plmnId;
NRCellIdentity* nRCellIdentity;
nR_CGI->getNR_CGI(cgi_plmnId, nRCellIdentity);
cgi_plmnId->getMcc(cig.mcc);
cgi_plmnId->getMnc(cig.mnc);
cig.nrCellID = nRCellIdentity->getNRCellIdentity();
PlmnId *tai_plmnId;
TAC *tac;
nR_TAI->getTAI(tai_plmnId, tac);
tai_plmnId->getMcc(tai.mcc);
tai_plmnId->getMnc(tai.mnc);
tai.tac = tac->getTac();
PlmnId* tai_plmnId;
TAC* tac;
nR_TAI->getTAI(tai_plmnId, tac);
tai_plmnId->getMcc(tai.mcc);
tai_plmnId->getMnc(tai.mnc);
tai.tac = tac->getTac();
return true;
}
return true;
}
}
......@@ -19,12 +19,12 @@
* contact@openairinterface.org
*/
/*! \file HandoverNotifyMsg.hpp
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
/*! \file HandoverNotifyMsg.hpp
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _HANDOVERNOTIFYMSG_H_
#define _HANDOVERNOTIFYMSG_H_
......@@ -42,24 +42,24 @@ extern "C" {
}
namespace ngap {
class HandoverNotifyMsg {
public:
HandoverNotifyMsg();
virtual ~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;(������)
bool getUserLocationInfoNR(struct NrCgi_s &cig, struct Tai_s &tai);
class HandoverNotifyMsg{
public:
HandoverNotifyMsg();
virtual ~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;()
bool getUserLocationInfoNR(struct NrCgi_s& cig, struct Tai_s& tai);
private:
Ngap_NGAP_PDU_t *handoverNotifyPdu;
Ngap_HandoverNotify_t *handoverNotifyIEs;
AMF_UE_NGAP_ID *amfUeNgapId;
RAN_UE_NGAP_ID *ranUeNgapId;
UserLocationInformation *userLocationInformation;
};
private:
Ngap_NGAP_PDU_t* handoverNotifyPdu;
Ngap_HandoverNotify_t* handoverNotifyIEs;
AMF_UE_NGAP_ID* amfUeNgapId;
RAN_UE_NGAP_ID* ranUeNgapId;
UserLocationInformation* userLocationInformation;
};
}
#endif
#include "HandoverRequest.hpp"
extern "C" {
#include "constr_TYPE.h"
#include "Ngap_NGAP-PDU.h"
#include "asn_codecs.h"
#include "per_encoder.h"
#include "per_decoder.h"
#include "constraints.h"
extern "C"{
#include "constr_TYPE.h"
#include "Ngap_NGAP-PDU.h"
#include "asn_codecs.h"
#include "per_encoder.h"
#include "per_decoder.h"
#include "constraints.h"
}
#include <iostream>
......@@ -14,405 +14,390 @@ extern "C" {
using namespace std;
namespace ngap {
HandoverRequest::HandoverRequest() {
amfUeNgapId = NULL;
handovertype = NULL;
cause = NULL;
ueAggregateMaximumBitRate = NULL;
ueSecurityCapabilities = NULL;
SecurityContext = NULL;
PDUSessionResourceSetupList = NULL;
allowedNSSAI = NULL;
SourceToTarget_TransparentContainer = NULL;
guami = NULL;
handoverRequestPdu = NULL;
handoverRequestIEs = NULL;
}
HandoverRequest::~HandoverRequest() {
}
unsigned long HandoverRequest::getAmfUeNgapId() {
return amfUeNgapId->getAMF_UE_NGAP_ID();
}
/*bool HandoverRequest::decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu)
{
handoverCommandPdu = ngap_msg_pdu;
if (handoverCommandPdu->present == Ngap_NGAP_PDU_PR_successfulOutcome)
{
if (handoverCommandPdu->choice.successfulOutcome && handoverCommandPdu->choice.successfulOutcome->procedureCode == Ngap_ProcedureCode_id_HandoverPreparation && handoverCommandPdu->choice.successfulOutcome->criticality == Ngap_Criticality_reject && handoverRequiredPdu->choice.successfulOutcome->value.present == Ngap_SuccessfulOutcome__value_PR_HandoverCommand)
{
handoverCommandIEs = &handoverCommandIEs->choice.successfulOutcome->value.choice.HandoverCommand;
}
else
{
cout << "Check HandoverCommand message error!!!" << endl;
return false;
}
}
else
{
cout << "HandoverRequired MessageType error!!!" << endl;
return false;
}
for (int i = 0; i < handoverCommandIEs->protocolIEs.list.count; i++)
{
switch (handoverCommandIEs->protocolIEs.list.array[i]->id)
{
case Ngap_ProtocolIE_ID_id_AMF_UE_NGAP_ID: {
if (handoverCommandIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_reject && handoverCommandIEs->protocolIEs.list.array[i]->value.present == Ngap_HandoverCommandIEs__value_PR_AMF_UE_NGAP_ID)
{
amfUeNgapId = new AMF_UE_NGAP_ID();
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;
return false;
}
}
else
{
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl;
return false;
}
}break;
case Ngap_ProtocolIE_ID_id_RAN_UE_NGAP_ID: {
if (handoverCommandIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_reject && handoverCommandIEs->protocolIEs.list.array[i]->value.present == Ngap_HandoverCommandIEs__value_PR_RAN_UE_NGAP_ID)
{
ranUeNgapId = new RAN_UE_NGAP_ID();
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;
return false;
}
}
else
{
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl;
return false;
}
}break;
case Ngap_ProtocolIE_ID_id_HandoverType: {
if (handoverCommandIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_reject && handoverCommandIEs->protocolIEs.list.array[i]->value.present == Ngap_HandoverCommandIEs__value_PR_HandoverType)
{
ngap_handovertype = new Ngap_HandoverType_t();
ngap_handovertype = handoverCommandIEs->protocolIEs.list.array[i]->value.choice.HandoverType;
}
else
{
cout << "decoded ngap Handover Type IE error" << endl;
return false;
}
}break;
case Ngap_ProtocolIE_ID_id_PDUSessionResourceHandoverList: {
if (handoverCommandIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_ignore && handoverCommandIEs->protocolIEs.list.array[i]->value.present == Ngap_HandoverCommandIEs__value_PR_PDUSessionResourceHandoverList)
{
}
else
{
cout << "decoded ngap PDUSessionResourceHandoverList IE error" << endl;
return false;
}
}break;
case Ngap_ProtocolIE_ID_id_PDUSessionResourceToReleaseListHOCmd: {
if (handoverCommandIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_ignore && handoverCommandIEs->protocolIEs.list.array[i]->value.present == Ngap_HandoverCommandIEs__value_PR_PDUSessionResourceToReleaseListHOCmd)
{
}
else
{
cout << "decoded ngap PDUSessionResourceToReleaseListHOCmd IE error" << endl;
return false;
}
}break;
case Ngap_ProtocolIE_ID_id_TargetToSource_TransparentContainer: {
if (handoverCommandIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_reject && handoverCommandIEs->protocolIEs.list.array[i]->value.present == Ngap_HandoverCommandIEs__value_PR_TargetToSource_TransparentContainer)
{
}
else
{
cout << "decoded ngap TargetToSource_TransparentContainer IE error" << endl;
return false;
}
}break;
case Ngap_ProtocolIE_ID_id_CriticalityDiagnostics: {
if (handoverCommandIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_ignore && handoverCommandIEs->protocolIEs.list.array[i]->value.present == Ngap_HandoverCommandIEs__value_PR_CriticalityDiagnostics)
{
}
else
{
cout << "decoded ngap CriticalityDiagnostics IE error" << endl;
return false;
}
}break;
default: {
cout << "decoded ngap message pdu error" << endl;
return false;
}
}
}
return true;
}*/
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);
cout << "er.encoded(" << er.encoded << ")" << endl;
return er.encoded;
}
void HandoverRequest::setMessageType() {
if (!handoverRequestPdu)
handoverRequestPdu = (Ngap_NGAP_PDU_t*) calloc(1, sizeof(Ngap_NGAP_PDU_t));
MessageType handoverRequestMessageTypeIE;
handoverRequestMessageTypeIE.setProcedureCode(
Ngap_ProcedureCode_id_HandoverResourceAllocation);
handoverRequestMessageTypeIE.setTypeOfMessage(
Ngap_NGAP_PDU_PR_initiatingMessage);
handoverRequestMessageTypeIE.setCriticality(Ngap_Criticality_reject);
handoverRequestMessageTypeIE.setValuePresent(
Ngap_InitiatingMessage__value_PR_HandoverRequest);
if (handoverRequestMessageTypeIE.getProcedureCode()
== Ngap_ProcedureCode_id_HandoverResourceAllocation
&& handoverRequestMessageTypeIE.getTypeOfMessage()
== Ngap_NGAP_PDU_PR_initiatingMessage) {
handoverRequestMessageTypeIE.encode2pdu(handoverRequestPdu);
handoverRequestIEs = &(handoverRequestPdu->choice.initiatingMessage->value
.choice.HandoverRequest);
} else {
cout
<< "[warning] This information doesn't refer to HandoverRequest Message!!!"
<< endl;
}
}
void HandoverRequest::setAmfUeNgapId(unsigned long id) {
if (!amfUeNgapId)
amfUeNgapId = new AMF_UE_NGAP_ID();
amfUeNgapId->setAMF_UE_NGAP_ID(id);
Ngap_HandoverRequestIEs_t *ie = (Ngap_HandoverRequestIEs_t*) calloc(
1, sizeof(Ngap_HandoverRequestIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_AMF_UE_NGAP_ID;
ie->criticality = Ngap_Criticality_reject;
ie->value.present = Ngap_HandoverRequestIEs__value_PR_AMF_UE_NGAP_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;
return;
}
ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0)
cout << "encode AMF_UE_NGAP_ID IE error" << endl;
}
void HandoverRequest::setHandoverType(long type) //0--intra5gs
{
if (!handovertype)
handovertype = new Ngap_HandoverType_t();
Ngap_HandoverRequestIEs_t *ie = (Ngap_HandoverRequestIEs_t*) calloc(
1, sizeof(Ngap_HandoverRequestIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_HandoverType;
ie->criticality = Ngap_Criticality_reject;
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;
}
void HandoverRequest::setCause(Ngap_Cause_PR m_causePresent, long value) //
{
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;
ie->criticality = Ngap_Criticality_ignore;
ie->value.present = Ngap_HandoverRequestIEs__value_PR_Cause;
cause->setChoiceOfCause(m_causePresent);
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;
}
void HandoverRequest::setUEAggregateMaximumBitRate(long bit_rate_downlink,
long bit_rate_uplink) {
if (!ueAggregateMaximumBitRate)
ueAggregateMaximumBitRate = new UEAggregateMaxBitRate;
ueAggregateMaximumBitRate->setUEAggregateMaxBitRate(bit_rate_downlink,
bit_rate_uplink);
Ngap_HandoverRequestIEs_t *ie = (Ngap_HandoverRequestIEs_t*) calloc(
1, sizeof(Ngap_HandoverRequestIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_UEAggregateMaximumBitRate;
ie->criticality = Ngap_Criticality_reject;
ie->value.present =
Ngap_HandoverRequestIEs__value_PR_UEAggregateMaximumBitRate;
ueAggregateMaximumBitRate->encode2UEAggregateMaxBitRate(
ie->value.choice.UEAggregateMaximumBitRate);
int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0)
cout << "encode UEAggregateMaximumBitRate IE error" << endl;
}
void HandoverRequest::setUESecurityCapabilities(
uint16_t m_NR_EncryptionAlgs, uint16_t m_NR_IntegrityProtectionAlgs,
uint16_t m_E_UTRA_EncryptionAlgs,
uint16_t m_E_UTRA_IntegrityProtectionAlgs) {
if (!ueSecurityCapabilities)
ueSecurityCapabilities = new UESecurityCapabilities;
Ngap_HandoverRequestIEs_t *ie = (Ngap_HandoverRequestIEs_t*) calloc(
1, sizeof(Ngap_HandoverRequestIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_UESecurityCapabilities;
ie->criticality = Ngap_Criticality_reject;
ie->value.present = Ngap_HandoverRequestIEs__value_PR_UESecurityCapabilities;
ueSecurityCapabilities->setUESecurityCapabilities(
m_NR_EncryptionAlgs, m_NR_IntegrityProtectionAlgs,
m_E_UTRA_EncryptionAlgs, m_E_UTRA_IntegrityProtectionAlgs);
ueSecurityCapabilities->encode2UESecurityCapabilities(
(ie->value.choice.UESecurityCapabilities));
int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0)
cout << "encode UESecurityCapabilities IE error" << endl;
}
void HandoverRequest::setGUAMI(PlmnId *m_plmnId, AMFRegionID *m_aMFRegionID,
AMFSetID *m_aMFSetID, AMFPointer *m_aMFPointer) {
if (!guami)
guami = new GUAMI;
Ngap_HandoverRequestIEs_t *ie = (Ngap_HandoverRequestIEs_t*) calloc(
1, sizeof(Ngap_HandoverRequestIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_GUAMI;
ie->criticality = Ngap_Criticality_reject;
ie->value.present = Ngap_HandoverRequestIEs__value_PR_GUAMI;
guami->setGUAMI(m_plmnId, m_aMFRegionID, m_aMFSetID, m_aMFPointer);
guami->encode2GUAMI(&(ie->value.choice.GUAMI));
int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0)
cout << "encode GUAMI IE error" << endl;
}
void HandoverRequest::setAllowedNSSAI(std::vector<S_NSSAI> list) {
if (!allowedNSSAI)
allowedNSSAI = new Ngap_AllowedNSSAI_t();
for (int i = 0; i < list.size(); i++) {
Ngap_AllowedNSSAI_Item_t *item = (Ngap_AllowedNSSAI_Item_t*) calloc(
1, sizeof(Ngap_AllowedNSSAI_Item_t));
//item->s_NSSAI = list[i].s_NSSAI;
//S_NSSAI *s_NSSAI = new S_NSSAI();
list[i].encode2S_NSSAI(&item->s_NSSAI);
int ret = ASN_SEQUENCE_ADD(&allowedNSSAI->list, item);
if (ret != 0)
cout << "encode PDUSessionResourceHandoverListItem IE error" << endl;
}
asn_fprint(stderr, &asn_DEF_Ngap_AllowedNSSAI, allowedNSSAI);
Ngap_HandoverRequestIEs_t *ie = (Ngap_HandoverRequestIEs_t*) calloc(
1, sizeof(Ngap_HandoverRequestIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_AllowedNSSAI;
ie->criticality = Ngap_Criticality_reject;
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;
}
void HandoverRequest::setSecurityContext(long count, uint8_t *buffer) {
if (!SecurityContext)
SecurityContext = new Ngap_SecurityContext_t();
SecurityKey securitykey;
securitykey.setSecurityKey(buffer);
securitykey.encode2bitstring(SecurityContext->nextHopNH);
SecurityContext->nextHopChainingCount = count;
Ngap_HandoverRequestIEs_t *ie = (Ngap_HandoverRequestIEs_t*) calloc(
1, sizeof(Ngap_HandoverRequestIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_SecurityContext;
ie->criticality = Ngap_Criticality_reject;
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;
}
void HandoverRequest::setPduSessionResourceSetupList(
std::vector<PDUSessionResourceSetupRequestItem_t> list) {
if (!PDUSessionResourceSetupList)
PDUSessionResourceSetupList = new PDUSessionResourceSetupListHOReq();
PDUSessionResourceSetupItemHOReq *m_pduSessionResourceSetupItemHOReq =
new PDUSessionResourceSetupItemHOReq[list.size()]();
for (int i = 0; i < list.size(); i++) {
PDUSessionID *m_pDUSessionID = new PDUSessionID();
m_pDUSessionID->setPDUSessionID(list[i].pduSessionId);
S_NSSAI *m_s_NSSAI = new S_NSSAI();
m_s_NSSAI->setSst(list[i].s_nssai.sst);
if (list[i].s_nssai.sd.size())
m_s_NSSAI->setSd(list[i].s_nssai.sd);
m_pduSessionResourceSetupItemHOReq[i].setPDUSessionResourceSetupItemHOReq(
m_pDUSessionID, m_s_NSSAI,
list[i].pduSessionResourceSetupRequestTransfer);
}
PDUSessionResourceSetupList->setPDUSessionResourceSetupListHOReq(
m_pduSessionResourceSetupItemHOReq, list.size());
Ngap_HandoverRequestIEs_t *ie = (Ngap_HandoverRequestIEs_t*) calloc(
1, sizeof(Ngap_HandoverRequestIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_PDUSessionResourceSetupListHOReq;
ie->criticality = Ngap_Criticality_reject;
ie->value.present =
Ngap_HandoverRequestIEs__value_PR_PDUSessionResourceSetupListHOReq;
int ret =
PDUSessionResourceSetupList->encode2PDUSessionResourceSetupListHOReq(
&ie->value.choice.PDUSessionResourceSetupListHOReq);
if (!ret) {
cout << "encode PDUSessionResourceSetupListSUReq IE error" << endl;
return;
}
ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0)
cout << "encode PDUSessionResourceSetupListSUReq IE error" << endl;
}
void HandoverRequest::setSourceToTarget_TransparentContainer(
OCTET_STRING_t sourceTotarget) {
if (!SourceToTarget_TransparentContainer)
SourceToTarget_TransparentContainer =
new Ngap_SourceToTarget_TransparentContainer_t();
Ngap_HandoverRequestIEs_t *ie = (Ngap_HandoverRequestIEs_t*) calloc(
1, sizeof(Ngap_HandoverRequestIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_SourceToTarget_TransparentContainer;
ie->criticality = Ngap_Criticality_reject;
ie->value.present =
Ngap_HandoverRequestIEs__value_PR_SourceToTarget_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;
}
namespace ngap{
HandoverRequest::HandoverRequest()
{
amfUeNgapId=NULL;
handovertype = NULL;
cause = NULL;
ueAggregateMaximumBitRate = NULL;
ueSecurityCapabilities = NULL;
SecurityContext = NULL;
PDUSessionResourceSetupList = NULL;
allowedNSSAI = NULL;
SourceToTarget_TransparentContainer = NULL;
mobilityrestrictionlist = NULL;
guami = NULL;
handoverRequestPdu = NULL;
handoverRequestIEs = NULL;
}
HandoverRequest::~HandoverRequest() {}
unsigned long HandoverRequest::getAmfUeNgapId()
{
return amfUeNgapId->getAMF_UE_NGAP_ID();
}
/*bool HandoverRequest::decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu)
{
handoverCommandPdu = ngap_msg_pdu;
if (handoverCommandPdu->present == Ngap_NGAP_PDU_PR_successfulOutcome)
{
if (handoverCommandPdu->choice.successfulOutcome && handoverCommandPdu->choice.successfulOutcome->procedureCode == Ngap_ProcedureCode_id_HandoverPreparation && handoverCommandPdu->choice.successfulOutcome->criticality == Ngap_Criticality_reject && handoverRequiredPdu->choice.successfulOutcome->value.present == Ngap_SuccessfulOutcome__value_PR_HandoverCommand)
{
handoverCommandIEs = &handoverCommandIEs->choice.successfulOutcome->value.choice.HandoverCommand;
}
else
{
cout << "Check HandoverCommand message error!!!" << endl;
return false;
}
}
else
{
cout << "HandoverRequired MessageType error!!!" << endl;
return false;
}
for (int i = 0; i < handoverCommandIEs->protocolIEs.list.count; i++)
{
switch (handoverCommandIEs->protocolIEs.list.array[i]->id)
{
case Ngap_ProtocolIE_ID_id_AMF_UE_NGAP_ID: {
if (handoverCommandIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_reject && handoverCommandIEs->protocolIEs.list.array[i]->value.present == Ngap_HandoverCommandIEs__value_PR_AMF_UE_NGAP_ID)
{
amfUeNgapId = new AMF_UE_NGAP_ID();
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;
return false;
}
}
else
{
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl;
return false;
}
}break;
case Ngap_ProtocolIE_ID_id_RAN_UE_NGAP_ID: {
if (handoverCommandIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_reject && handoverCommandIEs->protocolIEs.list.array[i]->value.present == Ngap_HandoverCommandIEs__value_PR_RAN_UE_NGAP_ID)
{
ranUeNgapId = new RAN_UE_NGAP_ID();
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;
return false;
}
}
else
{
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl;
return false;
}
}break;
case Ngap_ProtocolIE_ID_id_HandoverType: {
if (handoverCommandIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_reject && handoverCommandIEs->protocolIEs.list.array[i]->value.present == Ngap_HandoverCommandIEs__value_PR_HandoverType)
{
ngap_handovertype = new Ngap_HandoverType_t();
ngap_handovertype = handoverCommandIEs->protocolIEs.list.array[i]->value.choice.HandoverType;
}
else
{
cout << "decoded ngap Handover Type IE error" << endl;
return false;
}
}break;
case Ngap_ProtocolIE_ID_id_PDUSessionResourceHandoverList: {
if (handoverCommandIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_ignore && handoverCommandIEs->protocolIEs.list.array[i]->value.present == Ngap_HandoverCommandIEs__value_PR_PDUSessionResourceHandoverList)
{
}
else
{
cout << "decoded ngap PDUSessionResourceHandoverList IE error" << endl;
return false;
}
}break;
case Ngap_ProtocolIE_ID_id_PDUSessionResourceToReleaseListHOCmd: {
if (handoverCommandIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_ignore && handoverCommandIEs->protocolIEs.list.array[i]->value.present == Ngap_HandoverCommandIEs__value_PR_PDUSessionResourceToReleaseListHOCmd)
{
}
else
{
cout << "decoded ngap PDUSessionResourceToReleaseListHOCmd IE error" << endl;
return false;
}
}break;
case Ngap_ProtocolIE_ID_id_TargetToSource_TransparentContainer: {
if (handoverCommandIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_reject && handoverCommandIEs->protocolIEs.list.array[i]->value.present == Ngap_HandoverCommandIEs__value_PR_TargetToSource_TransparentContainer)
{
}
else
{
cout << "decoded ngap TargetToSource_TransparentContainer IE error" << endl;
return false;
}
}break;
case Ngap_ProtocolIE_ID_id_CriticalityDiagnostics: {
if (handoverCommandIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_ignore && handoverCommandIEs->protocolIEs.list.array[i]->value.present == Ngap_HandoverCommandIEs__value_PR_CriticalityDiagnostics)
{
}
else
{
cout << "decoded ngap CriticalityDiagnostics IE error" << endl;
return false;
}
}break;
default: {
cout << "decoded ngap message pdu error" << endl;
return false;
}
}
}
return true;
}*/
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);
cout << "er.encoded(" << er.encoded << ")" << endl;
return er.encoded;
}
void HandoverRequest::setMessageType()
{
if (!handoverRequestPdu) handoverRequestPdu = (Ngap_NGAP_PDU_t*)calloc(1, sizeof(Ngap_NGAP_PDU_t));
MessageType handoverRequestMessageTypeIE;
handoverRequestMessageTypeIE.setProcedureCode(Ngap_ProcedureCode_id_HandoverResourceAllocation);
handoverRequestMessageTypeIE.setTypeOfMessage(Ngap_NGAP_PDU_PR_initiatingMessage);
handoverRequestMessageTypeIE.setCriticality(Ngap_Criticality_reject);
handoverRequestMessageTypeIE.setValuePresent(Ngap_InitiatingMessage__value_PR_HandoverRequest);
if (handoverRequestMessageTypeIE.getProcedureCode() == Ngap_ProcedureCode_id_HandoverResourceAllocation && handoverRequestMessageTypeIE.getTypeOfMessage() ==Ngap_NGAP_PDU_PR_initiatingMessage)
{
handoverRequestMessageTypeIE.encode2pdu(handoverRequestPdu);
handoverRequestIEs = &(handoverRequestPdu->choice.initiatingMessage->value.choice.HandoverRequest);
}
else
{
cout << "[warning] This information doesn't refer to HandoverRequest Message!!!" << endl;
}
}
void HandoverRequest::setAmfUeNgapId(unsigned long id)
{
if (!amfUeNgapId)
amfUeNgapId = new AMF_UE_NGAP_ID();
amfUeNgapId->setAMF_UE_NGAP_ID(id);
Ngap_HandoverRequestIEs_t *ie = (Ngap_HandoverRequestIEs_t *)calloc(1, sizeof(Ngap_HandoverRequestIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_AMF_UE_NGAP_ID;
ie->criticality = Ngap_Criticality_reject;
ie->value.present = Ngap_HandoverRequestIEs__value_PR_AMF_UE_NGAP_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;
return;
}
ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode AMF_UE_NGAP_ID IE error" << endl;
}
void HandoverRequest::setHandoverType(long type)//0--intra5gs
{
if (!handovertype)
handovertype = new Ngap_HandoverType_t();
Ngap_HandoverRequestIEs_t *ie = (Ngap_HandoverRequestIEs_t *)calloc(1, sizeof(Ngap_HandoverRequestIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_HandoverType;
ie->criticality = Ngap_Criticality_reject;
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;
}
void HandoverRequest::setCause(Ngap_Cause_PR m_causePresent,long value)//
{
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;
ie->criticality = Ngap_Criticality_ignore;
ie->value.present = Ngap_HandoverRequestIEs__value_PR_Cause;
cause->setChoiceOfCause(m_causePresent);
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;
}
void HandoverRequest::setUEAggregateMaximumBitRate(long bit_rate_downlink,long bit_rate_uplink)
{
if (!ueAggregateMaximumBitRate)
ueAggregateMaximumBitRate = new UEAggregateMaxBitRate;
ueAggregateMaximumBitRate->setUEAggregateMaxBitRate(bit_rate_downlink,bit_rate_uplink);
Ngap_HandoverRequestIEs_t *ie = (Ngap_HandoverRequestIEs_t *)calloc(1, sizeof(Ngap_HandoverRequestIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_UEAggregateMaximumBitRate;
ie->criticality = Ngap_Criticality_reject;
ie->value.present = Ngap_HandoverRequestIEs__value_PR_UEAggregateMaximumBitRate;
ueAggregateMaximumBitRate->encode2UEAggregateMaxBitRate(ie->value.choice.UEAggregateMaximumBitRate);
int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode UEAggregateMaximumBitRate IE error" << endl;
}
void HandoverRequest::setUESecurityCapabilities(uint16_t m_NR_EncryptionAlgs, uint16_t m_NR_IntegrityProtectionAlgs, uint16_t m_E_UTRA_EncryptionAlgs, uint16_t m_E_UTRA_IntegrityProtectionAlgs)
{
if (!ueSecurityCapabilities)
ueSecurityCapabilities = new UESecurityCapabilities;
Ngap_HandoverRequestIEs_t *ie = (Ngap_HandoverRequestIEs_t *)calloc(1, sizeof(Ngap_HandoverRequestIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_UESecurityCapabilities;
ie->criticality = Ngap_Criticality_reject;
ie->value.present = Ngap_HandoverRequestIEs__value_PR_UESecurityCapabilities;
ueSecurityCapabilities->setUESecurityCapabilities( m_NR_EncryptionAlgs, m_NR_IntegrityProtectionAlgs, m_E_UTRA_EncryptionAlgs, m_E_UTRA_IntegrityProtectionAlgs);
ueSecurityCapabilities->encode2UESecurityCapabilities((ie->value.choice.UESecurityCapabilities));
int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode UESecurityCapabilities IE error" << endl;
}
void HandoverRequest::setGUAMI(PlmnId* m_plmnId, AMFRegionID* m_aMFRegionID, AMFSetID* m_aMFSetID, AMFPointer* m_aMFPointer)
{
if (!guami)
guami = new GUAMI;
Ngap_HandoverRequestIEs_t *ie = (Ngap_HandoverRequestIEs_t *)calloc(1, sizeof(Ngap_HandoverRequestIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_GUAMI;
ie->criticality = Ngap_Criticality_reject;
ie->value.present = Ngap_HandoverRequestIEs__value_PR_GUAMI;
guami->setGUAMI( m_plmnId, m_aMFRegionID, m_aMFSetID, m_aMFPointer);
guami->encode2GUAMI(&(ie->value.choice.GUAMI));
int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode GUAMI IE error" << endl;
}
void HandoverRequest::setAllowedNSSAI(std::vector<S_NSSAI> list)
{
if (!allowedNSSAI)
allowedNSSAI = new Ngap_AllowedNSSAI_t();
for (int i = 0; i < list.size(); i++)
{
Ngap_AllowedNSSAI_Item_t *item = (Ngap_AllowedNSSAI_Item_t *)calloc(1, sizeof(Ngap_AllowedNSSAI_Item_t));
//item->s_NSSAI = list[i].s_NSSAI;
//S_NSSAI *s_NSSAI = new S_NSSAI();
list[i].encode2S_NSSAI(&item->s_NSSAI);
int ret = ASN_SEQUENCE_ADD(&allowedNSSAI->list, item);
if (ret != 0) cout << "encode PDUSessionResourceHandoverListItem IE error" << endl;
}
asn_fprint(stderr, &asn_DEF_Ngap_AllowedNSSAI, allowedNSSAI);
Ngap_HandoverRequestIEs_t *ie = (Ngap_HandoverRequestIEs_t *)calloc(1, sizeof(Ngap_HandoverRequestIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_AllowedNSSAI;
ie->criticality = Ngap_Criticality_reject;
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;
}
void HandoverRequest::setSecurityContext(long count, uint8_t* buffer)
{
if (!SecurityContext)
SecurityContext = new Ngap_SecurityContext_t();
SecurityKey securitykey;
securitykey.setSecurityKey(buffer);
securitykey.encode2bitstring(SecurityContext->nextHopNH);
SecurityContext->nextHopChainingCount = count;
Ngap_HandoverRequestIEs_t *ie = (Ngap_HandoverRequestIEs_t *)calloc(1, sizeof(Ngap_HandoverRequestIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_SecurityContext;
ie->criticality = Ngap_Criticality_reject;
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;
}
void HandoverRequest::setPduSessionResourceSetupList(std::vector<PDUSessionResourceSetupRequestItem_t>list)
{
if (!PDUSessionResourceSetupList)
PDUSessionResourceSetupList = new PDUSessionResourceSetupListHOReq();
PDUSessionResourceSetupItemHOReq * m_pduSessionResourceSetupItemHOReq = new PDUSessionResourceSetupItemHOReq[list.size()]();
for (int i = 0; i < list.size(); i++)
{
PDUSessionID * m_pDUSessionID = new PDUSessionID();
m_pDUSessionID->setPDUSessionID(list[i].pduSessionId);
S_NSSAI * m_s_NSSAI = new S_NSSAI();
m_s_NSSAI->setSst(list[i].s_nssai.sst);
if (list[i].s_nssai.sd.size())
m_s_NSSAI->setSd(list[i].s_nssai.sd);
m_pduSessionResourceSetupItemHOReq[i].setPDUSessionResourceSetupItemHOReq(m_pDUSessionID, m_s_NSSAI, list[i].pduSessionResourceSetupRequestTransfer);
}
PDUSessionResourceSetupList->setPDUSessionResourceSetupListHOReq(m_pduSessionResourceSetupItemHOReq, list.size());
Ngap_HandoverRequestIEs_t *ie = (Ngap_HandoverRequestIEs_t *)calloc(1, sizeof(Ngap_HandoverRequestIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_PDUSessionResourceSetupListHOReq;
ie->criticality = Ngap_Criticality_reject;
ie->value.present = Ngap_HandoverRequestIEs__value_PR_PDUSessionResourceSetupListHOReq;
int ret = PDUSessionResourceSetupList->encode2PDUSessionResourceSetupListHOReq(&ie->value.choice.PDUSessionResourceSetupListHOReq);
if (!ret)
{
cout << "encode PDUSessionResourceSetupListSUReq IE error" << endl;
return;
}
ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode PDUSessionResourceSetupListSUReq IE error" << endl;
}
void HandoverRequest::setSourceToTarget_TransparentContainer(OCTET_STRING_t sourceTotarget)
{
if (!SourceToTarget_TransparentContainer)
SourceToTarget_TransparentContainer = new Ngap_SourceToTarget_TransparentContainer_t();
Ngap_HandoverRequestIEs_t *ie = (Ngap_HandoverRequestIEs_t *)calloc(1, sizeof(Ngap_HandoverRequestIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_SourceToTarget_TransparentContainer;
ie->criticality = Ngap_Criticality_reject;
ie->value.present = Ngap_HandoverRequestIEs__value_PR_SourceToTarget_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;
}
void HandoverRequest::setMobilityRestrictionList(PlmnId *m_plmnId)
{
if (!mobilityrestrictionlist)
{
mobilityrestrictionlist = new MobilityRestrictionList();
}
Ngap_HandoverRequestIEs_t *ie = (Ngap_HandoverRequestIEs_t *)calloc(1, sizeof(Ngap_HandoverRequestIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_MobilityRestrictionList;
ie->criticality = Ngap_Criticality_ignore;
ie->value.present = Ngap_HandoverRequestIEs__value_PR_MobilityRestrictionList;
mobilityrestrictionlist->setMobilityRestrictionList(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;
}
}
......@@ -12,11 +12,11 @@
#include "RAN-UE-NGAP-ID.hpp"
#include "Cause.hpp"
#include "UEAggregateMaxBitRate.hpp"
extern "C" {
#include "Ngap_NGAP-PDU.h"
#include "Ngap_ProtocolIE-Field.h"
#include "Ngap_NGSetupRequest.h"
#include "Ngap_AllowedNSSAI-Item.h"
extern "C"{
#include "Ngap_NGAP-PDU.h"
#include "Ngap_ProtocolIE-Field.h"
#include "Ngap_NGSetupRequest.h"
#include "Ngap_AllowedNSSAI-Item.h"
}
#include "UESecurityCapabilities.hpp"
......@@ -24,56 +24,61 @@ extern "C" {
#include "GUAMI.hpp"
#include "S-NSSAI.hpp"
#include "SecurityKey.hpp"
namespace ngap {
#include "MobilityRestrictionList.hpp"
namespace ngap{
class HandoverRequest {
public:
HandoverRequest();
virtual ~HandoverRequest();
void setMessageType(); //Initialize the PDU and populate the MessageType;
void setAmfUeNgapId(unsigned long id);//40 bits
void setHandoverType(long type);
void setCause(Ngap_Cause_PR m_causePresent,long value);
void setUEAggregateMaximumBitRate(long bit_rate_downlink,long bit_rate_uplink);
void setUESecurityCapabilities(uint16_t m_NR_EncryptionAlgs, uint16_t m_NR_IntegrityProtectionAlgs, uint16_t m_E_UTRA_EncryptionAlgs, uint16_t m_E_UTRA_IntegrityProtectionAlgs);
void setSecurityContext(long count, uint8_t* buffer);
void setPduSessionResourceSetupList(std::vector<PDUSessionResourceSetupRequestItem_t>list);
class HandoverRequest{
public:
HandoverRequest();
virtual ~HandoverRequest();
void setSourceToTarget_TransparentContainer(OCTET_STRING_t sourceTotarget);
void setMessageType(); //Initialize the PDU and populate the MessageType;
void setAmfUeNgapId(unsigned long id);//40 bits
void setHandoverType(long type);
void setCause(Ngap_Cause_PR m_causePresent,long value);
void setUEAggregateMaximumBitRate(long bit_rate_downlink,long bit_rate_uplink);
void setUESecurityCapabilities(uint16_t m_NR_EncryptionAlgs, uint16_t m_NR_IntegrityProtectionAlgs, uint16_t m_E_UTRA_EncryptionAlgs, uint16_t m_E_UTRA_IntegrityProtectionAlgs);
void setSecurityContext(long count, uint8_t* buffer);
void setPduSessionResourceSetupList(std::vector<PDUSessionResourceSetupRequestItem_t>list);
void setAllowedNSSAI(std::vector<S_NSSAI> list);
void setGUAMI(PlmnId* m_plmnId, AMFRegionID* m_aMFRegionID, AMFSetID* m_aMFSetID, AMFPointer* m_aMFPointer);
int encode2buffer(uint8_t *buf, int buf_size);
//bool decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu);
unsigned long getAmfUeNgapId();//return -1;(不存在)
void setSourceToTarget_TransparentContainer(OCTET_STRING_t sourceTotarget);
private:
Ngap_NGAP_PDU_t *handoverRequestPdu;
Ngap_HandoverRequest_t *handoverRequestIEs;
/***************** for decoding ****************/
AMF_UE_NGAP_ID *amfUeNgapId;
Ngap_HandoverType_t *handovertype;
Cause *cause;
UEAggregateMaxBitRate *ueAggregateMaximumBitRate;
//Core Network Assistance Information for RRC INACTIVE
UESecurityCapabilities *ueSecurityCapabilities;
Ngap_SecurityContext_t *SecurityContext;
//New Security Context Indicator
//NASC
PDUSessionResourceSetupListHOReq *PDUSessionResourceSetupList;
Ngap_AllowedNSSAI_t *allowedNSSAI;
//Trace Activation
//Masked IMEISV
Ngap_SourceToTarget_TransparentContainer_t *SourceToTarget_TransparentContainer;
//Mobility Restriction List
//Location Reporting Request Type
//RRC Inactive Transition Report Request
GUAMI *guami;
//Redirection for Voice EPS Fallback
//CN Assisted RAN Parameters Tuning
};
void setAllowedNSSAI(std::vector<S_NSSAI> list);
void setGUAMI(PlmnId* m_plmnId, AMFRegionID* m_aMFRegionID, AMFSetID* m_aMFSetID, AMFPointer* m_aMFPointer);
void setMobilityRestrictionList(PlmnId *m_plmnId);
int encode2buffer(uint8_t *buf, int buf_size);
//bool decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu);
unsigned long getAmfUeNgapId();//return -1;(不存在)
private:
Ngap_NGAP_PDU_t *handoverRequestPdu;
Ngap_HandoverRequest_t *handoverRequestIEs;
/***************** for decoding ****************/
AMF_UE_NGAP_ID *amfUeNgapId;
Ngap_HandoverType_t *handovertype;
Cause *cause;
UEAggregateMaxBitRate *ueAggregateMaximumBitRate;
//Core Network Assistance Information for RRC INACTIVE
UESecurityCapabilities *ueSecurityCapabilities;
Ngap_SecurityContext_t *SecurityContext;
//New Security Context Indicator
//NASC
PDUSessionResourceSetupListHOReq *PDUSessionResourceSetupList;
Ngap_AllowedNSSAI_t *allowedNSSAI;
//Trace Activation
//Masked IMEISV
Ngap_SourceToTarget_TransparentContainer_t *SourceToTarget_TransparentContainer;
//Mobility Restriction List
//Location Reporting Request Type
//RRC Inactive Transition Report Request
GUAMI *guami;
MobilityRestrictionList *mobilityrestrictionlist;
//Redirection for Voice EPS Fallback
//CN Assisted RAN Parameters Tuning
};
}
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "HandoverRequestAck.hpp"
#include "TransportLayerAddress.hpp"
#include "String2Value.hpp"
#include "GTP-TEID.hpp"
extern "C" {
extern "C"
{
#include "constr_TYPE.h"
#include "Ngap_NGAP-PDU.h"
#include "asn_codecs.h"
......@@ -45,313 +19,306 @@ extern "C" {
using namespace std;
namespace ngap {
HandoverRequestAck::HandoverRequestAck() {
amfUeNgapId = NULL;
ranUeNgapId = NULL;
pduSessionResourceAdmittedList = NULL;
PDUSessionResourceFailedToSetupList = NULL;
TargetToSource_TransparentContainer = NULL;
CriticalityDiagnostics = NULL;
}
HandoverRequestAck::~HandoverRequestAck() {
}
unsigned long HandoverRequestAck::getAmfUeNgapId() {
return amfUeNgapId->getAMF_UE_NGAP_ID();
}
void HandoverRequestAck::setMessageType() {
if (!handoverRequestAckPdu)
handoverRequestAckPdu = (Ngap_NGAP_PDU_t*) calloc(1,
sizeof(Ngap_NGAP_PDU_t));
MessageType handoverRequestMessageTypeIE;
handoverRequestMessageTypeIE.setProcedureCode(
Ngap_ProcedureCode_id_HandoverResourceAllocation);
handoverRequestMessageTypeIE.setTypeOfMessage(
Ngap_NGAP_PDU_PR_initiatingMessage);
handoverRequestMessageTypeIE.setCriticality(Ngap_Criticality_reject);
handoverRequestMessageTypeIE.setValuePresent(
Ngap_InitiatingMessage__value_PR_HandoverRequest);
if (handoverRequestMessageTypeIE.getProcedureCode()
== Ngap_ProcedureCode_id_HandoverResourceAllocation
&& handoverRequestMessageTypeIE.getTypeOfMessage()
== Ngap_NGAP_PDU_PR_initiatingMessage) {
handoverRequestMessageTypeIE.encode2pdu(handoverRequestAckPdu);
handoverRequestAckIEs = &(handoverRequestAckPdu->choice.successfulOutcome
->value.choice.HandoverRequestAcknowledge);
} else {
cout
<< "[warning] This information doesn't refer to HandoverRequest Message!!!"
<< endl;
}
}
uint32_t HandoverRequestAck::getRanUeNgapId() {
return ranUeNgapId->getRanUeNgapId();
}
OCTET_STRING_t HandoverRequestAck::getTargetToSource_TransparentContainer() {
return *TargetToSource_TransparentContainer;
}
bool HandoverRequestAck::getPDUSessionResourceAdmittedList(
std::vector<PDUSessionResourceAdmittedItem_t> &list) {
if (!pduSessionResourceAdmittedList)
return false;
PDUSessionResourceAdmittedItem *m_pduSessionResourceAdmittedItem;
int num = 0;
pduSessionResourceAdmittedList->getPDUSessionResourceAdmittedList(
m_pduSessionResourceAdmittedItem, num);
for (int i = 0; i < num; i++) {
PDUSessionResourceAdmittedItem_t response;
PDUSessionID *m_pDUSessionID;
m_pduSessionResourceAdmittedItem[i].getPDUSessionResourceAdmittedItem(
m_pDUSessionID, response.handoverRequestAcknowledgeTransfer);
m_pDUSessionID->getPDUSessionID(response.pduSessionId);
list.push_back(response);
}
return true;
}
bool HandoverRequestAck::decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu) {
handoverRequestAckPdu = ngap_msg_pdu;
if (handoverRequestAckPdu->present == Ngap_NGAP_PDU_PR_successfulOutcome) {
if (handoverRequestAckPdu->choice.successfulOutcome
&& handoverRequestAckPdu->choice.successfulOutcome->procedureCode
== Ngap_ProcedureCode_id_HandoverResourceAllocation
&& handoverRequestAckPdu->choice.successfulOutcome->criticality
== Ngap_Criticality_reject
&& handoverRequestAckPdu->choice.successfulOutcome->value.present
== Ngap_SuccessfulOutcome__value_PR_HandoverRequestAcknowledge) {
handoverRequestAckIEs = &handoverRequestAckPdu->choice.successfulOutcome
->value.choice.HandoverRequestAcknowledge;
} else {
cout << "Check handoverRequestAck message error!!!" << endl;
return false;
}
} else {
cout << "handoverRequestAck MessageType error!!!" << endl;
return false;
}
for (int i = 0; i < handoverRequestAckIEs->protocolIEs.list.count; i++) {
switch (handoverRequestAckIEs->protocolIEs.list.array[i]->id) {
case Ngap_ProtocolIE_ID_id_AMF_UE_NGAP_ID: {
if (handoverRequestAckIEs->protocolIEs.list.array[i]->criticality
== Ngap_Criticality_ignore
&& handoverRequestAckIEs->protocolIEs.list.array[i]->value.present
== Ngap_HandoverRequestAcknowledgeIEs__value_PR_AMF_UE_NGAP_ID) {
amfUeNgapId = new AMF_UE_NGAP_ID();
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;
return false;
}
} else {
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl;
return false;
}
}
break;
case Ngap_ProtocolIE_ID_id_RAN_UE_NGAP_ID: {
if (handoverRequestAckIEs->protocolIEs.list.array[i]->criticality
== Ngap_Criticality_ignore
&& handoverRequestAckIEs->protocolIEs.list.array[i]->value.present
== Ngap_HandoverRequestAcknowledgeIEs__value_PR_RAN_UE_NGAP_ID) {
ranUeNgapId = new RAN_UE_NGAP_ID();
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;
return false;
}
} else {
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl;
return false;
}
}
break;
case Ngap_ProtocolIE_ID_id_PDUSessionResourceAdmittedList: {
if (handoverRequestAckIEs->protocolIEs.list.array[i]->criticality
== Ngap_Criticality_ignore
&& handoverRequestAckIEs->protocolIEs.list.array[i]->value.present
== Ngap_HandoverRequestAcknowledgeIEs__value_PR_PDUSessionResourceAdmittedList) {
pduSessionResourceAdmittedList = new PDUSessionResourceAdmittedList();
if (!pduSessionResourceAdmittedList
->decodefromPDUSessionResourceAdmittedList(
&handoverRequestAckIEs->protocolIEs.list.array[i]->value.choice
.PDUSessionResourceAdmittedList)) {
cout << "decoded ngap PDUSessionResourceAdmittedList IE error"
<< endl;
return false;
}
} else {
cout << "decoded ngap PDUSessionResourceAdmittedList Type IE error"
<< endl;
return false;
}
}
break;
case Ngap_ProtocolIE_ID_id_TargetToSource_TransparentContainer: {
if (handoverRequestAckIEs->protocolIEs.list.array[i]->criticality
== Ngap_Criticality_reject
&& handoverRequestAckIEs->protocolIEs.list.array[i]->value.present
== Ngap_HandoverRequestAcknowledgeIEs__value_PR_TargetToSource_TransparentContainer) {
TargetToSource_TransparentContainer =
new Ngap_TargetToSource_TransparentContainer_t();
*TargetToSource_TransparentContainer = handoverRequestAckIEs
->protocolIEs.list.array[i]->value.choice
.TargetToSource_TransparentContainer;
} else {
cout << "decoded ngap TargetToSource_TransparentContainer IE error"
<< endl;
return false;
}
}
break;
default: {
cout << "decoded ngap message pdu error" << endl;
return false;
}
}
}
return true;
}
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);
cout << "er.encoded(" << er.encoded << ")" << endl;
return er.encoded;
}
/* void HandoverRequestAck::setMessageType()
{
if (!handoverRequestAckPdu) handoverRequestAckPdu = (Ngap_NGAP_PDU_t*)calloc(1, sizeof(Ngap_NGAP_PDU_t));
MessageType HandoverRequestAckMessageTypeIE;
HandoverRequestAckMessageTypeIE.setProcedureCode(Ngap_ProcedureCode_id_HandoverResourceAllocation);
HandoverRequestAckMessageTypeIE.setTypeOfMessage(Ngap_NGAP_PDU_PR_successfulOutcome);
HandoverRequestAckMessageTypeIE.setCriticality(Ngap_Criticality_reject);
HandoverRequestAckMessageTypeIE.setValuePresent(Ngap_SuccessfulOutcome__value_PR_HandoverRequestAcknowledge);
if (HandoverRequestAckMessageTypeIE.getProcedureCode() == Ngap_ProcedureCode_id_HandoverResourceAllocation && HandoverRequestAckMessageTypeIE.getTypeOfMessage() == Ngap_NGAP_PDU_PR_successfulOutcome)
{
HandoverRequestAckMessageTypeIE.encode2pdu(handoverRequestAckPdu);
handoverRequestAckIEs = &(handoverRequestAckPdu->choice.successfulOutcome->value.choice.HandoverRequestAcknowledge);
}
else
{
cout << "[warning] This information doesn't refer to HandoverRequestAcknowledge Message!!!" << endl;
}
}
*/
/* void HandoverRequestAck::setAmfUeNgapId(unsigned long id)
{
if (!amfUeNgapId)
amfUeNgapId = new AMF_UE_NGAP_ID();
amfUeNgapId->setAMF_UE_NGAP_ID(id);
Ngap_HandoverRequestAcknowledgeIEs_t *ie = (Ngap_HandoverRequestAcknowledgeIEs_t *)calloc(1, sizeof(Ngap_HandoverRequestAcknowledgeIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_AMF_UE_NGAP_ID;
ie->criticality = Ngap_Criticality_reject;
ie->value.present = Ngap_HandoverRequestAcknowledgeIEs__value_PR_AMF_UE_NGAP_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;
return;
}
ret = ASN_SEQUENCE_ADD(&handoverRequestAckIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode AMF_UE_NGAP_ID IE error" << endl;
}
*/
/* void HandoverRequestAck::setRanUeNgapId(uint32_t ran_ue_ngap_id)
{
if (!ranUeNgapId)
ranUeNgapId = new RAN_UE_NGAP_ID();
ranUeNgapId->setRanUeNgapId(ran_ue_ngap_id);
Ngap_HandoverRequestAcknowledgeIEs_t *ie = (Ngap_HandoverRequestAcknowledgeIEs_t *)calloc(1, sizeof(Ngap_HandoverRequestAcknowledgeIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_RAN_UE_NGAP_ID;
ie->criticality = Ngap_Criticality_reject;
ie->value.present = Ngap_HandoverRequestAcknowledgeIEs__value_PR_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;
return;
}
ret = ASN_SEQUENCE_ADD(&handoverRequestAckIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode RAN_UE_NGAP_ID IE error" << endl;
}
*/
/* void HandoverRequestAck::setPDUSessionResourceAdmittedList(std::vector<Ngap_PDUSessionResourceAdmittedItem_t> list)
{
if (!PDUSessionResourceAdmittedList)
PDUSessionResourceAdmittedList = new Ngap_PDUSessionResourceAdmittedList_t();
Ngap_HandoverRequestAcknowledgeIEs_t *ie = (Ngap_HandoverRequestAcknowledgeIEs_t *)calloc(1, sizeof(Ngap_HandoverRequestAcknowledgeIEs_t));
for (int i = 0; i < list.size(); i++)
{
Ngap_PDUSessionResourceAdmittedItem_t *item = (Ngap_PDUSessionResourceAdmittedItem_t *)calloc(1, sizeof(Ngap_PDUSessionResourceAdmittedItem_t));
item->pDUSessionID = list[i].pDUSessionID;
Ngap_HandoverRequestAcknowledgeTransfer_t *handoverrequestacknowledgetransfer;
handoverrequestacknowledgetransfer->dL_NGU_UP_TNLInformation.present = Ngap_UPTransportLayerInformation_PR_gTPTunnel;
TransportLayerAddress transportlayeraddress;
transportlayeraddress.setTransportLayerAddress("127.0.1.1");
transportlayeraddress.encode2TransportLayerAddress((handoverrequestacknowledgetransfer->dL_NGU_UP_TNLInformation).choice.gTPTunnel->transportLayerAddress);
GtpTeid gtpteid;
gtpteid.setGtpTeid(159);
gtpteid.encode2GtpTeid((handoverrequestacknowledgetransfer->dL_NGU_UP_TNLInformation.choice.gTPTunnel->gTP_TEID));
item->handoverRequestAcknowledgeTransfer = list[i].handoverRequestAcknowledgeTransfer;
int ret = ASN_SEQUENCE_ADD(&PDUSessionResourceAdmittedList->list, item);
if (ret != 0) cout << "encode PDUSessionResourceAdmittedList IE error" << endl;
}
ie->id = Ngap_ProtocolIE_ID_id_PDUSessionResourceAdmittedList;
ie->criticality = Ngap_Criticality_ignore;
ie->value.present = Ngap_HandoverRequestAcknowledgeIEs__value_PR_PDUSessionResourceAdmittedList;
ie->value.choice.PDUSessionResourceAdmittedList = *PDUSessionResourceAdmittedList;
int ret = ASN_SEQUENCE_ADD(&handoverRequestAckIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode PDUSessionResourceAdmittedList IE error" << endl;
}
*/
/* void HandoverRequestAck::setTargetToSource_TransparentContainer(OCTET_STRING_t targetTosource)
{
if (!TargetToSource_TransparentContainer)
TargetToSource_TransparentContainer = new Ngap_TargetToSource_TransparentContainer_t();
Ngap_HandoverRequestAcknowledgeIEs_t *ie = (Ngap_HandoverRequestAcknowledgeIEs_t *)calloc(1, sizeof(Ngap_HandoverRequestAcknowledgeIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_TargetToSource_TransparentContainer;
ie->criticality = Ngap_Criticality_reject;
ie->value.present = Ngap_HandoverRequestAcknowledgeIEs__value_PR_TargetToSource_TransparentContainer;
ie->value.choice.TargetToSource_TransparentContainer = targetTosource;
int ret = ASN_SEQUENCE_ADD(&handoverRequestAckIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode TargetToSource_TransparentContainer IE error" << endl;
}
*/
} // namespace ngap
namespace ngap
{
HandoverRequestAck::HandoverRequestAck()
{
amfUeNgapId = NULL;
ranUeNgapId = NULL;
pduSessionResourceAdmittedList = NULL;
PDUSessionResourceFailedToSetupList = NULL;
TargetToSource_TransparentContainer = NULL;
CriticalityDiagnostics = NULL;
}
HandoverRequestAck::~HandoverRequestAck() {}
unsigned long HandoverRequestAck::getAmfUeNgapId()
{
return amfUeNgapId->getAMF_UE_NGAP_ID();
}
void HandoverRequestAck::setMessageType()
{
if (!handoverRequestAckPdu)
handoverRequestAckPdu = (Ngap_NGAP_PDU_t *)calloc(1, sizeof(Ngap_NGAP_PDU_t));
MessageType handoverRequestMessageTypeIE;
handoverRequestMessageTypeIE.setProcedureCode(Ngap_ProcedureCode_id_HandoverResourceAllocation);
handoverRequestMessageTypeIE.setTypeOfMessage(Ngap_NGAP_PDU_PR_initiatingMessage);
handoverRequestMessageTypeIE.setCriticality(Ngap_Criticality_reject);
handoverRequestMessageTypeIE.setValuePresent(Ngap_InitiatingMessage__value_PR_HandoverRequest);
if (handoverRequestMessageTypeIE.getProcedureCode() == Ngap_ProcedureCode_id_HandoverResourceAllocation && handoverRequestMessageTypeIE.getTypeOfMessage() == Ngap_NGAP_PDU_PR_initiatingMessage)
{
handoverRequestMessageTypeIE.encode2pdu(handoverRequestAckPdu);
handoverRequestAckIEs = &(handoverRequestAckPdu->choice.successfulOutcome->value.choice.HandoverRequestAcknowledge);
}
else
{
cout << "[warning] This information doesn't refer to HandoverRequest Message!!!" << endl;
}
}
uint32_t HandoverRequestAck::getRanUeNgapId()
{
return ranUeNgapId->getRanUeNgapId();
}
OCTET_STRING_t HandoverRequestAck::getTargetToSource_TransparentContainer()
{
return *TargetToSource_TransparentContainer;
}
bool HandoverRequestAck::getPDUSessionResourceAdmittedList(std::vector<PDUSessionResourceAdmittedItem_t> &list)
{
if (!pduSessionResourceAdmittedList)
return false;
PDUSessionResourceAdmittedItem *m_pduSessionResourceAdmittedItem;
int num = 0;
pduSessionResourceAdmittedList->getPDUSessionResourceAdmittedList(m_pduSessionResourceAdmittedItem, num);
for (int i = 0; i < num; i++)
{
PDUSessionResourceAdmittedItem_t response;
PDUSessionID *m_pDUSessionID;
m_pduSessionResourceAdmittedItem[i].getPDUSessionResourceAdmittedItem(m_pDUSessionID, response.handoverRequestAcknowledgeTransfer);
m_pDUSessionID->getPDUSessionID(response.pduSessionId);
list.push_back(response);
}
return true;
}
bool HandoverRequestAck::decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu)
{
handoverRequestAckPdu = ngap_msg_pdu;
if (handoverRequestAckPdu->present == Ngap_NGAP_PDU_PR_successfulOutcome)
{
if (handoverRequestAckPdu->choice.successfulOutcome && handoverRequestAckPdu->choice.successfulOutcome->procedureCode == Ngap_ProcedureCode_id_HandoverResourceAllocation && handoverRequestAckPdu->choice.successfulOutcome->criticality == Ngap_Criticality_reject && handoverRequestAckPdu->choice.successfulOutcome->value.present == Ngap_SuccessfulOutcome__value_PR_HandoverRequestAcknowledge)
{
handoverRequestAckIEs = &handoverRequestAckPdu->choice.successfulOutcome->value.choice.HandoverRequestAcknowledge;
}
else
{
cout << "Check handoverRequestAck message error!!!" << endl;
return false;
}
}
else
{
cout << "handoverRequestAck MessageType error!!!" << endl;
return false;
}
for (int i = 0; i < handoverRequestAckIEs->protocolIEs.list.count; i++)
{
switch (handoverRequestAckIEs->protocolIEs.list.array[i]->id)
{
case Ngap_ProtocolIE_ID_id_AMF_UE_NGAP_ID:
{
if (handoverRequestAckIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_ignore && handoverRequestAckIEs->protocolIEs.list.array[i]->value.present == Ngap_HandoverRequestAcknowledgeIEs__value_PR_AMF_UE_NGAP_ID)
{
amfUeNgapId = new AMF_UE_NGAP_ID();
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;
return false;
}
}
else
{
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl;
return false;
}
}
break;
case Ngap_ProtocolIE_ID_id_RAN_UE_NGAP_ID:
{
if (handoverRequestAckIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_ignore && handoverRequestAckIEs->protocolIEs.list.array[i]->value.present == Ngap_HandoverRequestAcknowledgeIEs__value_PR_RAN_UE_NGAP_ID)
{
ranUeNgapId = new RAN_UE_NGAP_ID();
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;
return false;
}
}
else
{
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl;
return false;
}
}
break;
case Ngap_ProtocolIE_ID_id_PDUSessionResourceAdmittedList:
{
if (handoverRequestAckIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_ignore && handoverRequestAckIEs->protocolIEs.list.array[i]->value.present == Ngap_HandoverRequestAcknowledgeIEs__value_PR_PDUSessionResourceAdmittedList)
{
pduSessionResourceAdmittedList = new PDUSessionResourceAdmittedList();
if (!pduSessionResourceAdmittedList->decodefromPDUSessionResourceAdmittedList(&handoverRequestAckIEs->protocolIEs.list.array[i]->value.choice.PDUSessionResourceAdmittedList))
{
cout << "decoded ngap PDUSessionResourceAdmittedList IE error" << endl;
return false;
}
}
else
{
cout << "decoded ngap PDUSessionResourceAdmittedList Type IE error" << endl;
return false;
}
}
break;
case Ngap_ProtocolIE_ID_id_TargetToSource_TransparentContainer:
{
if (handoverRequestAckIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_reject && handoverRequestAckIEs->protocolIEs.list.array[i]->value.present == Ngap_HandoverRequestAcknowledgeIEs__value_PR_TargetToSource_TransparentContainer)
{
TargetToSource_TransparentContainer = new Ngap_TargetToSource_TransparentContainer_t();
*TargetToSource_TransparentContainer = handoverRequestAckIEs->protocolIEs.list.array[i]->value.choice.TargetToSource_TransparentContainer;
}
else
{
cout << "decoded ngap TargetToSource_TransparentContainer IE error" << endl;
return false;
}
}
break;
default:
{
cout << "decoded ngap message pdu error" << endl;
return false;
}
}
}
return true;
}
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);
cout << "er.encoded(" << er.encoded << ")" << endl;
return er.encoded;
}
/* void HandoverRequestAck::setMessageType()
{
if (!handoverRequestAckPdu) handoverRequestAckPdu = (Ngap_NGAP_PDU_t*)calloc(1, sizeof(Ngap_NGAP_PDU_t));
MessageType HandoverRequestAckMessageTypeIE;
HandoverRequestAckMessageTypeIE.setProcedureCode(Ngap_ProcedureCode_id_HandoverResourceAllocation);
HandoverRequestAckMessageTypeIE.setTypeOfMessage(Ngap_NGAP_PDU_PR_successfulOutcome);
HandoverRequestAckMessageTypeIE.setCriticality(Ngap_Criticality_reject);
HandoverRequestAckMessageTypeIE.setValuePresent(Ngap_SuccessfulOutcome__value_PR_HandoverRequestAcknowledge);
if (HandoverRequestAckMessageTypeIE.getProcedureCode() == Ngap_ProcedureCode_id_HandoverResourceAllocation && HandoverRequestAckMessageTypeIE.getTypeOfMessage() == Ngap_NGAP_PDU_PR_successfulOutcome)
{
HandoverRequestAckMessageTypeIE.encode2pdu(handoverRequestAckPdu);
handoverRequestAckIEs = &(handoverRequestAckPdu->choice.successfulOutcome->value.choice.HandoverRequestAcknowledge);
}
else
{
cout << "[warning] This information doesn't refer to HandoverRequestAcknowledge Message!!!" << endl;
}
}
*/
/* void HandoverRequestAck::setAmfUeNgapId(unsigned long id)
{
if (!amfUeNgapId)
amfUeNgapId = new AMF_UE_NGAP_ID();
amfUeNgapId->setAMF_UE_NGAP_ID(id);
Ngap_HandoverRequestAcknowledgeIEs_t *ie = (Ngap_HandoverRequestAcknowledgeIEs_t *)calloc(1, sizeof(Ngap_HandoverRequestAcknowledgeIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_AMF_UE_NGAP_ID;
ie->criticality = Ngap_Criticality_reject;
ie->value.present = Ngap_HandoverRequestAcknowledgeIEs__value_PR_AMF_UE_NGAP_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;
return;
}
ret = ASN_SEQUENCE_ADD(&handoverRequestAckIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode AMF_UE_NGAP_ID IE error" << endl;
}
*/
/* void HandoverRequestAck::setRanUeNgapId(uint32_t ran_ue_ngap_id)
{
if (!ranUeNgapId)
ranUeNgapId = new RAN_UE_NGAP_ID();
ranUeNgapId->setRanUeNgapId(ran_ue_ngap_id);
Ngap_HandoverRequestAcknowledgeIEs_t *ie = (Ngap_HandoverRequestAcknowledgeIEs_t *)calloc(1, sizeof(Ngap_HandoverRequestAcknowledgeIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_RAN_UE_NGAP_ID;
ie->criticality = Ngap_Criticality_reject;
ie->value.present = Ngap_HandoverRequestAcknowledgeIEs__value_PR_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;
return;
}
ret = ASN_SEQUENCE_ADD(&handoverRequestAckIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode RAN_UE_NGAP_ID IE error" << endl;
}
*/
/* void HandoverRequestAck::setPDUSessionResourceAdmittedList(std::vector<Ngap_PDUSessionResourceAdmittedItem_t> list)
{
if (!PDUSessionResourceAdmittedList)
PDUSessionResourceAdmittedList = new Ngap_PDUSessionResourceAdmittedList_t();
Ngap_HandoverRequestAcknowledgeIEs_t *ie = (Ngap_HandoverRequestAcknowledgeIEs_t *)calloc(1, sizeof(Ngap_HandoverRequestAcknowledgeIEs_t));
for (int i = 0; i < list.size(); i++)
{
Ngap_PDUSessionResourceAdmittedItem_t *item = (Ngap_PDUSessionResourceAdmittedItem_t *)calloc(1, sizeof(Ngap_PDUSessionResourceAdmittedItem_t));
item->pDUSessionID = list[i].pDUSessionID;
Ngap_HandoverRequestAcknowledgeTransfer_t *handoverrequestacknowledgetransfer;
handoverrequestacknowledgetransfer->dL_NGU_UP_TNLInformation.present = Ngap_UPTransportLayerInformation_PR_gTPTunnel;
TransportLayerAddress transportlayeraddress;
transportlayeraddress.setTransportLayerAddress("127.0.1.1");
transportlayeraddress.encode2TransportLayerAddress((handoverrequestacknowledgetransfer->dL_NGU_UP_TNLInformation).choice.gTPTunnel->transportLayerAddress);
GtpTeid gtpteid;
gtpteid.setGtpTeid(159);
gtpteid.encode2GtpTeid((handoverrequestacknowledgetransfer->dL_NGU_UP_TNLInformation.choice.gTPTunnel->gTP_TEID));
item->handoverRequestAcknowledgeTransfer = list[i].handoverRequestAcknowledgeTransfer;
int ret = ASN_SEQUENCE_ADD(&PDUSessionResourceAdmittedList->list, item);
if (ret != 0) cout << "encode PDUSessionResourceAdmittedList IE error" << endl;
}
ie->id = Ngap_ProtocolIE_ID_id_PDUSessionResourceAdmittedList;
ie->criticality = Ngap_Criticality_ignore;
ie->value.present = Ngap_HandoverRequestAcknowledgeIEs__value_PR_PDUSessionResourceAdmittedList;
ie->value.choice.PDUSessionResourceAdmittedList = *PDUSessionResourceAdmittedList;
int ret = ASN_SEQUENCE_ADD(&handoverRequestAckIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode PDUSessionResourceAdmittedList IE error" << endl;
}
*/
/* void HandoverRequestAck::setTargetToSource_TransparentContainer(OCTET_STRING_t targetTosource)
{
if (!TargetToSource_TransparentContainer)
TargetToSource_TransparentContainer = new Ngap_TargetToSource_TransparentContainer_t();
Ngap_HandoverRequestAcknowledgeIEs_t *ie = (Ngap_HandoverRequestAcknowledgeIEs_t *)calloc(1, sizeof(Ngap_HandoverRequestAcknowledgeIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_TargetToSource_TransparentContainer;
ie->criticality = Ngap_Criticality_reject;
ie->value.present = Ngap_HandoverRequestAcknowledgeIEs__value_PR_TargetToSource_TransparentContainer;
ie->value.choice.TargetToSource_TransparentContainer = targetTosource;
int ret = ASN_SEQUENCE_ADD(&handoverRequestAckIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode TargetToSource_TransparentContainer IE error" << endl;
}
*/
} // namespace ngap
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file
\brief
\author niuxiansheng-niu, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _HANDOVERREQUESTACK_H_
#define _HANDOVERREQUESTACK_H_
......@@ -50,36 +23,35 @@ extern "C" {
}
namespace ngap {
class HandoverRequestAck {
public:
HandoverRequestAck();
virtual ~HandoverRequestAck();
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;(不存在)
void setMessageType(); //Initialize the PDU and populate the MessageType;
OCTET_STRING_t getTargetToSource_TransparentContainer();
bool getPDUSessionResourceAdmittedList(
std::vector<PDUSessionResourceAdmittedItem_t> &list);
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;
PDUSessionResourceAdmittedList *pduSessionResourceAdmittedList;
Ngap_PDUSessionResourceFailedToSetupListHOAck_t *PDUSessionResourceFailedToSetupList;
Ngap_TargetToSource_TransparentContainer_t *TargetToSource_TransparentContainer;
Ngap_CriticalityDiagnostics_t *CriticalityDiagnostics;
};
class HandoverRequestAck {
public:
HandoverRequestAck();
virtual ~HandoverRequestAck();
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;(不存在)
void setMessageType(); //Initialize the PDU and populate the MessageType;
OCTET_STRING_t getTargetToSource_TransparentContainer();
bool getPDUSessionResourceAdmittedList(std::vector<PDUSessionResourceAdmittedItem_t>& list);
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;
PDUSessionResourceAdmittedList *pduSessionResourceAdmittedList;
Ngap_PDUSessionResourceFailedToSetupListHOAck_t *PDUSessionResourceFailedToSetupList;
Ngap_TargetToSource_TransparentContainer_t *TargetToSource_TransparentContainer;
Ngap_CriticalityDiagnostics_t *CriticalityDiagnostics;
};
}
......
#include "HandoverRequiredMsg.hpp"
extern "C" {
#include "constr_TYPE.h"
#include "Ngap_NGAP-PDU.h"
#include "asn_codecs.h"
#include "per_encoder.h"
#include "per_decoder.h"
#include "constraints.h"
extern "C"{
#include "constr_TYPE.h"
#include "Ngap_NGAP-PDU.h"
#include "asn_codecs.h"
#include "per_encoder.h"
#include "per_decoder.h"
#include "constraints.h"
}
#include "TAI.hpp"
#include <iostream>
......@@ -13,252 +13,258 @@ extern "C" {
using namespace std;
namespace ngap {
HandoverRequiredMsg::HandoverRequiredMsg() {
amfUeNgapId = NULL;
ranUeNgapId = NULL;
handovertype = NULL;
cause = NULL;
targetid = NULL;
directforwardingPathAvailability = NULL;
PDUSessionResourceList = NULL;
SourceToTarget_TransparentContainer = NULL;
}
HandoverRequiredMsg::~HandoverRequiredMsg() {
}
namespace ngap{
HandoverRequiredMsg::HandoverRequiredMsg()
{
amfUeNgapId = NULL;
ranUeNgapId = NULL;
handovertype = NULL;
cause = NULL;
targetid = NULL;
directforwardingPathAvailability = NULL;
PDUSessionResourceList = NULL;
SourceToTarget_TransparentContainer = NULL;
}
HandoverRequiredMsg::~HandoverRequiredMsg() {}
unsigned long HandoverRequiredMsg::getAmfUeNgapId()
{
return amfUeNgapId->getAMF_UE_NGAP_ID();
}
uint32_t HandoverRequiredMsg::getRanUeNgapId()
{
return ranUeNgapId->getRanUeNgapId();
}
Ngap_HandoverType_t HandoverRequiredMsg::getHandoverType()
{
return *handovertype;
}
Ngap_Cause_PR HandoverRequiredMsg::getChoiceOfCause()
{
return cause->getChoiceOfCause();
}
long HandoverRequiredMsg::getCauseValue()
{
return cause->getValue();
}
void HandoverRequiredMsg::getGlobalRanNodeId(GlobalgNBId *&ptr)
{
ptr->decodefromGlobalgNBId(targetid->choice.targetRANNodeID->globalRANNodeID.choice.globalGNB_ID);
}
void HandoverRequiredMsg::getTAI(TAI *&ptr)
{
ptr->decodefromTAI(&(targetid->choice.targetRANNodeID->selectedTAI));
}
OCTET_STRING_t HandoverRequiredMsg::getSourceToTarget_TransparentContainer()
{
return *SourceToTarget_TransparentContainer;
}
bool HandoverRequiredMsg::getPDUSessionResourceList(std::vector<PDUSessionResourceItem_t> &list)
{
if (!PDUSessionResourceList) return false;
PDUSessionResourceItemHORqd *m_pduSessionResourceItemHORqd;
int num = 0;
PDUSessionResourceList->getPDUSessionResourceListHORqd(m_pduSessionResourceItemHORqd, num);
for (int i = 0; i < num; i++)
{
PDUSessionResourceItem_t response;
PDUSessionID *m_pDUSessionID;
m_pduSessionResourceItemHORqd[i].getPDUSessionResourceItemHORqd(m_pDUSessionID, response.HandoverRequiredTransfer);
m_pDUSessionID->getPDUSessionID(response.pduSessionId);
list.push_back(response);
}
return true;
}
long HandoverRequiredMsg::getDirectForwardingPathAvailability()
{
return *directforwardingPathAvailability;
}
bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu)
{
handoverRequiredPdu = ngap_msg_pdu;
if (handoverRequiredPdu->present == Ngap_NGAP_PDU_PR_initiatingMessage)
{
if (handoverRequiredPdu->choice.initiatingMessage && handoverRequiredPdu->choice.initiatingMessage->procedureCode == Ngap_ProcedureCode_id_HandoverPreparation && handoverRequiredPdu->choice.initiatingMessage->criticality == Ngap_Criticality_reject && handoverRequiredPdu->choice.initiatingMessage->value.present == Ngap_InitiatingMessage__value_PR_HandoverRequired)
{
handoverRequiredIEs = &handoverRequiredPdu->choice.initiatingMessage->value.choice.HandoverRequired;
}
else
{
cout << "Check HandoverRequired message error!!!" << endl;
return false;
}
}
else
{
cout << "HandoverRequired MessageType error!!!" << endl;
return false;
}
for (int i = 0; i < handoverRequiredIEs->protocolIEs.list.count; i++)
{
switch (handoverRequiredIEs->protocolIEs.list.array[i]->id)
{
case Ngap_ProtocolIE_ID_id_AMF_UE_NGAP_ID: {
if (handoverRequiredIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_reject && handoverRequiredIEs->protocolIEs.list.array[i]->value.present == Ngap_HandoverRequiredIEs__value_PR_AMF_UE_NGAP_ID)
{
amfUeNgapId = new AMF_UE_NGAP_ID();
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;
return false;
}
}
else
{
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl;
return false;
}
}break;
case Ngap_ProtocolIE_ID_id_RAN_UE_NGAP_ID: {
if (handoverRequiredIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_reject && handoverRequiredIEs->protocolIEs.list.array[i]->value.present == Ngap_HandoverRequiredIEs__value_PR_RAN_UE_NGAP_ID)
{
ranUeNgapId = new RAN_UE_NGAP_ID();
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;
return false;
}
}
else
{
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl;
return false;
}
}break;
case Ngap_ProtocolIE_ID_id_HandoverType: {
if (handoverRequiredIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_reject && handoverRequiredIEs->protocolIEs.list.array[i]->value.present == Ngap_HandoverRequiredIEs__value_PR_HandoverType)
{
handovertype = new Ngap_HandoverType_t();
*handovertype = handoverRequiredIEs->protocolIEs.list.array[i]->value.choice.HandoverType;
}
else
{
cout << "decoded ngap Handover Type IE error" << endl;
return false;
}
}break;
case Ngap_ProtocolIE_ID_id_Cause: {
if (handoverRequiredIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_ignore && handoverRequiredIEs->protocolIEs.list.array[i]->value.present == Ngap_HandoverRequiredIEs__value_PR_Cause)
{
cause = new Cause();
if(!cause->decodefromCause(&handoverRequiredIEs->protocolIEs.list.array[i]->value.choice.Cause))
{
cout << "decoded ngap Cause IE error" << endl;
return false;
}
}
else
{
cout << "decoded ngap Cause IE error" << endl;
return false;
}
}break;
case Ngap_ProtocolIE_ID_id_TargetID: {
if (handoverRequiredIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_reject && handoverRequiredIEs->protocolIEs.list.array[i]->value.present == Ngap_HandoverRequiredIEs__value_PR_TargetID)
{
targetid = new Ngap_TargetID_t();
*targetid = handoverRequiredIEs->protocolIEs.list.array[i]->value.choice.TargetID;
}
else
{
cout << "decoded ngap TargetID IE error" << endl;
return false;
}
}break;
case Ngap_ProtocolIE_ID_id_DirectForwardingPathAvailability: {
if (handoverRequiredIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_ignore && handoverRequiredIEs->protocolIEs.list.array[i]->value.present == Ngap_HandoverRequiredIEs__value_PR_DirectForwardingPathAvailability)
{
directforwardingPathAvailability = new Ngap_DirectForwardingPathAvailability_t();
*directforwardingPathAvailability = handoverRequiredIEs->protocolIEs.list.array[i]->value.choice.DirectForwardingPathAvailability;
}
else
{
cout << "decoded ngap DirectForwardingPathAvailability IE error" << endl;
return false;
}
}break;
case Ngap_ProtocolIE_ID_id_PDUSessionResourceListHORqd: {
if (handoverRequiredIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_reject && handoverRequiredIEs->protocolIEs.list.array[i]->value.present == Ngap_HandoverRequiredIEs__value_PR_PDUSessionResourceListHORqd)
{
PDUSessionResourceList = new PDUSessionResourceListHORqd();
if (!PDUSessionResourceList->decodefromPDUSessionResourceListHORqd(&handoverRequiredIEs->protocolIEs.list.array[i]->value.choice.PDUSessionResourceListHORqd))
{
cout << "decoded ngap PDUSessionResourceSetupListCxtRes IE error" << endl;
return false;
}
}
else
{
cout << "decoded ngap PDUSessionResourceListHORqd IE error" << endl;
return false;
}
}break;
case Ngap_ProtocolIE_ID_id_SourceToTarget_TransparentContainer: {
if (handoverRequiredIEs->protocolIEs.list.array[i]->criticality == Ngap_Criticality_reject && handoverRequiredIEs->protocolIEs.list.array[i]->value.present == Ngap_HandoverRequiredIEs__value_PR_SourceToTarget_TransparentContainer)
{
SourceToTarget_TransparentContainer = new Ngap_SourceToTarget_TransparentContainer_t();
*SourceToTarget_TransparentContainer = handoverRequiredIEs->protocolIEs.list.array[i]->value.choice.SourceToTarget_TransparentContainer;
}
else
{
cout << "decoded ngap SourceToTarget_TransparentContainer IE error" << endl;
return false;
}
}break;
default: {
cout << "decoded ngap message pdu error" << endl;
return false;
}
}
}
return true;
}
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;
return er.encoded;
}
unsigned long HandoverRequiredMsg::getAmfUeNgapId() {
return amfUeNgapId->getAMF_UE_NGAP_ID();
}
uint32_t HandoverRequiredMsg::getRanUeNgapId() {
return ranUeNgapId->getRanUeNgapId();
}
Ngap_HandoverType_t HandoverRequiredMsg::getHandoverType() {
return *handovertype;
}
Ngap_Cause_PR HandoverRequiredMsg::getChoiceOfCause() {
return cause->getChoiceOfCause();
}
long HandoverRequiredMsg::getCauseValue() {
return cause->getValue();
}
void HandoverRequiredMsg::getGlobalRanNodeId(GlobalgNBId *&ptr) {
ptr->decodefromGlobalgNBId(
targetid->choice.targetRANNodeID->globalRANNodeID.choice.globalGNB_ID);
}
void HandoverRequiredMsg::getTAI(TAI *&ptr) {
ptr->decodefromTAI(&(targetid->choice.targetRANNodeID->selectedTAI));
}
OCTET_STRING_t HandoverRequiredMsg::getSourceToTarget_TransparentContainer() {
return *SourceToTarget_TransparentContainer;
}
bool HandoverRequiredMsg::getPDUSessionResourceList(
std::vector<PDUSessionResourceItem_t> &list) {
if (!PDUSessionResourceList)
return false;
PDUSessionResourceItemHORqd *m_pduSessionResourceItemHORqd;
int num = 0;
PDUSessionResourceList->getPDUSessionResourceListHORqd(
m_pduSessionResourceItemHORqd, num);
for (int i = 0; i < num; i++) {
PDUSessionResourceItem_t response;
PDUSessionID *m_pDUSessionID;
m_pduSessionResourceItemHORqd[i].getPDUSessionResourceItemHORqd(
m_pDUSessionID, response.HandoverRequiredTransfer);
m_pDUSessionID->getPDUSessionID(response.pduSessionId);
list.push_back(response);
}
return true;
}
long HandoverRequiredMsg::getDirectForwardingPathAvailability() {
return *directforwardingPathAvailability;
}
bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu) {
handoverRequiredPdu = ngap_msg_pdu;
if (handoverRequiredPdu->present == Ngap_NGAP_PDU_PR_initiatingMessage) {
if (handoverRequiredPdu->choice.initiatingMessage
&& handoverRequiredPdu->choice.initiatingMessage->procedureCode
== Ngap_ProcedureCode_id_HandoverPreparation
&& handoverRequiredPdu->choice.initiatingMessage->criticality
== Ngap_Criticality_reject
&& handoverRequiredPdu->choice.initiatingMessage->value.present
== Ngap_InitiatingMessage__value_PR_HandoverRequired) {
handoverRequiredIEs = &handoverRequiredPdu->choice.initiatingMessage
->value.choice.HandoverRequired;
} else {
cout << "Check HandoverRequired message error!!!" << endl;
return false;
}
} else {
cout << "HandoverRequired MessageType error!!!" << endl;
return false;
}
for (int i = 0; i < handoverRequiredIEs->protocolIEs.list.count; i++) {
switch (handoverRequiredIEs->protocolIEs.list.array[i]->id) {
case Ngap_ProtocolIE_ID_id_AMF_UE_NGAP_ID: {
if (handoverRequiredIEs->protocolIEs.list.array[i]->criticality
== Ngap_Criticality_reject
&& handoverRequiredIEs->protocolIEs.list.array[i]->value.present
== Ngap_HandoverRequiredIEs__value_PR_AMF_UE_NGAP_ID) {
amfUeNgapId = new AMF_UE_NGAP_ID();
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;
return false;
}
} else {
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl;
return false;
}
}
break;
case Ngap_ProtocolIE_ID_id_RAN_UE_NGAP_ID: {
if (handoverRequiredIEs->protocolIEs.list.array[i]->criticality
== Ngap_Criticality_reject
&& handoverRequiredIEs->protocolIEs.list.array[i]->value.present
== Ngap_HandoverRequiredIEs__value_PR_RAN_UE_NGAP_ID) {
ranUeNgapId = new RAN_UE_NGAP_ID();
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;
return false;
}
} else {
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl;
return false;
}
}
break;
case Ngap_ProtocolIE_ID_id_HandoverType: {
if (handoverRequiredIEs->protocolIEs.list.array[i]->criticality
== Ngap_Criticality_reject
&& handoverRequiredIEs->protocolIEs.list.array[i]->value.present
== Ngap_HandoverRequiredIEs__value_PR_HandoverType) {
handovertype = new Ngap_HandoverType_t();
*handovertype = handoverRequiredIEs->protocolIEs.list.array[i]->value
.choice.HandoverType;
} else {
cout << "decoded ngap Handover Type IE error" << endl;
return false;
}
}
break;
case Ngap_ProtocolIE_ID_id_Cause: {
if (handoverRequiredIEs->protocolIEs.list.array[i]->criticality
== Ngap_Criticality_ignore
&& handoverRequiredIEs->protocolIEs.list.array[i]->value.present
== Ngap_HandoverRequiredIEs__value_PR_Cause) {
cause = new Cause();
if (!cause->decodefromCause(
&handoverRequiredIEs->protocolIEs.list.array[i]->value.choice
.Cause)) {
cout << "decoded ngap Cause IE error" << endl;
return false;
}
} else {
cout << "decoded ngap Cause IE error" << endl;
return false;
}
}
break;
case Ngap_ProtocolIE_ID_id_TargetID: {
if (handoverRequiredIEs->protocolIEs.list.array[i]->criticality
== Ngap_Criticality_reject
&& handoverRequiredIEs->protocolIEs.list.array[i]->value.present
== Ngap_HandoverRequiredIEs__value_PR_TargetID) {
targetid = new Ngap_TargetID_t();
*targetid = handoverRequiredIEs->protocolIEs.list.array[i]->value
.choice.TargetID;
} else {
cout << "decoded ngap TargetID IE error" << endl;
return false;
}
}
break;
case Ngap_ProtocolIE_ID_id_DirectForwardingPathAvailability: {
if (handoverRequiredIEs->protocolIEs.list.array[i]->criticality
== Ngap_Criticality_ignore
&& handoverRequiredIEs->protocolIEs.list.array[i]->value.present
== Ngap_HandoverRequiredIEs__value_PR_DirectForwardingPathAvailability) {
directforwardingPathAvailability =
new Ngap_DirectForwardingPathAvailability_t();
*directforwardingPathAvailability = handoverRequiredIEs->protocolIEs
.list.array[i]->value.choice.DirectForwardingPathAvailability;
} else {
cout << "decoded ngap DirectForwardingPathAvailability IE error"
<< endl;
return false;
}
}
break;
case Ngap_ProtocolIE_ID_id_PDUSessionResourceListHORqd: {
if (handoverRequiredIEs->protocolIEs.list.array[i]->criticality
== Ngap_Criticality_reject
&& handoverRequiredIEs->protocolIEs.list.array[i]->value.present
== Ngap_HandoverRequiredIEs__value_PR_PDUSessionResourceListHORqd) {
PDUSessionResourceList = new PDUSessionResourceListHORqd();
if (!PDUSessionResourceList->decodefromPDUSessionResourceListHORqd(
&handoverRequiredIEs->protocolIEs.list.array[i]->value.choice
.PDUSessionResourceListHORqd)) {
cout << "decoded ngap PDUSessionResourceSetupListCxtRes IE error"
<< endl;
return false;
}
} else {
cout << "decoded ngap PDUSessionResourceListHORqd IE error" << endl;
return false;
}
}
break;
case Ngap_ProtocolIE_ID_id_SourceToTarget_TransparentContainer: {
if (handoverRequiredIEs->protocolIEs.list.array[i]->criticality
== Ngap_Criticality_reject
&& handoverRequiredIEs->protocolIEs.list.array[i]->value.present
== Ngap_HandoverRequiredIEs__value_PR_SourceToTarget_TransparentContainer) {
SourceToTarget_TransparentContainer =
new Ngap_SourceToTarget_TransparentContainer_t();
*SourceToTarget_TransparentContainer = handoverRequiredIEs
->protocolIEs.list.array[i]->value.choice
.SourceToTarget_TransparentContainer;
} else {
cout << "decoded ngap SourceToTarget_TransparentContainer IE error"
<< endl;
return false;
}
}
break;
default: {
cout << "decoded ngap message pdu error" << endl;
return false;
}
}
}
return true;
}
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;
return er.encoded;
}
}
......@@ -11,49 +11,51 @@
#include "AMF-UE-NGAP-ID.hpp"
#include "RAN-UE-NGAP-ID.hpp"
#include "Cause.hpp"
extern "C" {
#include "Ngap_NGAP-PDU.h"
#include "Ngap_ProtocolIE-Field.h"
#include "Ngap_NGSetupRequest.h"
extern "C"{
#include "Ngap_NGAP-PDU.h"
#include "Ngap_ProtocolIE-Field.h"
#include "Ngap_NGSetupRequest.h"
}
#include "TAI.hpp"
#include "NgapIEsStruct.hpp"
#include "PDUSessionResourceListHORqd.hpp"
namespace ngap {
class HandoverRequiredMsg {
public:
HandoverRequiredMsg();
virtual ~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;(不存在)
Ngap_HandoverType_t getHandoverType();
Ngap_Cause_PR getChoiceOfCause();
long getCauseValue();
OCTET_STRING_t getSourceToTarget_TransparentContainer();
void getGlobalRanNodeId(GlobalgNBId *&ptr);
void getTAI(TAI *&ptr);
bool getPDUSessionResourceList(std::vector<PDUSessionResourceItem_t> &list);
long getDirectForwardingPathAvailability();
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;
Cause *cause;
Ngap_TargetID_t *targetid;
Ngap_DirectForwardingPathAvailability_t *directforwardingPathAvailability;
PDUSessionResourceListHORqd *PDUSessionResourceList;
Ngap_SourceToTarget_TransparentContainer_t *SourceToTarget_TransparentContainer;
};
namespace ngap{
class HandoverRequiredMsg{
public:
HandoverRequiredMsg();
virtual ~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;(不存在)
Ngap_HandoverType_t getHandoverType();
Ngap_Cause_PR getChoiceOfCause();
long getCauseValue();
OCTET_STRING_t getSourceToTarget_TransparentContainer();
void getGlobalRanNodeId(GlobalgNBId *&ptr);
void getTAI(TAI *&ptr);
bool getPDUSessionResourceList(std::vector<PDUSessionResourceItem_t> &list);
long getDirectForwardingPathAvailability();
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;
Cause *cause;
Ngap_TargetID_t *targetid;
Ngap_DirectForwardingPathAvailability_t *directforwardingPathAvailability;
PDUSessionResourceListHORqd *PDUSessionResourceList;
Ngap_SourceToTarget_TransparentContainer_t *SourceToTarget_TransparentContainer;
};
}
......
......@@ -144,7 +144,7 @@ bool UEContextReleaseRequestMsg::decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu) {
if (pdu->choice.initiatingMessage
&& pdu->choice.initiatingMessage->procedureCode
== Ngap_ProcedureCode_id_UEContextReleaseRequest
&& pdu->choice.initiatingMessage->criticality == Ngap_Criticality_reject
&& pdu->choice.initiatingMessage->criticality == Ngap_Criticality_ignore
&& pdu->choice.initiatingMessage->value.present
== Ngap_InitiatingMessage__value_PR_UEContextReleaseRequest) {
ies =
......
......@@ -44,7 +44,7 @@ public:
virtual ~N1N2MessageCollectionDocumentApi() {}
void init();
const std::string base = "/namf-comm/v1";
const std::string base = "/namf-comm/v2";
private:
void setupRoutes();
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file authentication_algorithms_with_5gaka.cpp
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "authentication_algorithms_with_5gaka.hpp"
#include <pthread.h>
#include <stdio.h>
......@@ -37,30 +9,26 @@
#include "logger.hpp"
#include "OCTET_STRING.h"
extern void print_buffer(const std::string app, const std::string commit,
uint8_t *buf, int len);
extern void hexStr2Byte(const char *src, unsigned char *dest, int len);
//------------------------------------------------------------------------------
extern void print_buffer(const std::string app, const std::string commit, uint8_t *buf, int len);
extern void hexStr2Byte(const char* src, unsigned char *dest, int len);
/************ algorithm f1 **************/
/*
Computes network authentication code MAC-A from key K, random, challenge RAND, sequence number SQN and authentication management field AMF.
*/
void Authentication_5gaka::f1(const uint8_t opc[16], const uint8_t k[16],
const uint8_t _rand[16], const uint8_t sqn[6],
const uint8_t amf[2], uint8_t mac_a[8]) {
uint8_t temp[16];
uint8_t in1[16];
uint8_t out1[16];
uint8_t rijndaelInput[16];
uint8_t i;
RijndaelKeySchedule(k);
Computes network authentication code MAC-A from key K, random, challenge RAND, sequence number SQN and authentication management field AMF.
*/
void Authentication_5gaka::f1 ( const uint8_t opc[16],const uint8_t k[16], const uint8_t _rand[16], const uint8_t sqn[6], const uint8_t amf[2], uint8_t mac_a[8] ){
uint8_t temp[16];
uint8_t in1[16];
uint8_t out1[16];
uint8_t rijndaelInput[16];
uint8_t i;
RijndaelKeySchedule (k);
for (i = 0; i < 16; i++)
rijndaelInput[i] = _rand[i] ^ opc[i];
RijndaelEncrypt(rijndaelInput, temp);
RijndaelEncrypt (rijndaelInput, temp);
for (i = 0; i < 6; i++) {
in1[i] = sqn[i];
......@@ -85,7 +53,7 @@ void Authentication_5gaka::f1(const uint8_t opc[16], const uint8_t k[16],
for (i = 0; i < 16; i++)
rijndaelInput[i] ^= temp[i];
RijndaelEncrypt(rijndaelInput, out1);
RijndaelEncrypt (rijndaelInput, out1);
for (i = 0; i < 16; i++)
out1[i] ^= opc[i];
......@@ -95,29 +63,26 @@ void Authentication_5gaka::f1(const uint8_t opc[16], const uint8_t k[16],
return;
}
//------------------------------------------------------------------------------
/*-------------------------------------------------------------------
Algorithms f2-f5
-------------------------------------------------------------------
Takes key K and random challenge RAND, and returns response RES,
confidentiality key CK, integrity key IK and anonymity key AK.
-----------------------------------------------------------------*/
void Authentication_5gaka::f2345(const uint8_t opc[16], const uint8_t k[16],
const uint8_t _rand[16], uint8_t res[8],
uint8_t ck[16], uint8_t ik[16],
uint8_t ak[6]) {
uint8_t temp[16];
uint8_t out[16];
uint8_t rijndaelInput[16];
uint8_t i;
RijndaelKeySchedule(k);
Algorithms f2-f5
-------------------------------------------------------------------
Takes key K and random challenge RAND, and returns response RES,
confidentiality key CK, integrity key IK and anonymity key AK.
-----------------------------------------------------------------*/
void Authentication_5gaka::f2345 ( const uint8_t opc[16],const uint8_t k[16], const uint8_t _rand[16], uint8_t res[8], uint8_t ck[16], uint8_t ik[16], uint8_t ak[6] ){
uint8_t temp[16];
uint8_t out[16];
uint8_t rijndaelInput[16];
uint8_t i;
RijndaelKeySchedule (k);
for (i = 0; i < 16; i++)
rijndaelInput[i] = _rand[i] ^ opc[i];
RijndaelEncrypt(rijndaelInput, temp);
RijndaelEncrypt (rijndaelInput, temp);
/*
* To obtain output block OUT2: XOR OPc and TEMP,
......@@ -128,7 +93,7 @@ void Authentication_5gaka::f2345(const uint8_t opc[16], const uint8_t k[16],
rijndaelInput[i] = temp[i] ^ opc[i];
rijndaelInput[15] ^= 1;
RijndaelEncrypt(rijndaelInput, out);
RijndaelEncrypt (rijndaelInput, out);
for (i = 0; i < 16; i++)
out[i] ^= opc[i];
......@@ -148,7 +113,7 @@ void Authentication_5gaka::f2345(const uint8_t opc[16], const uint8_t k[16],
rijndaelInput[(i + 12) % 16] = temp[i] ^ opc[i];
rijndaelInput[15] ^= 2;
RijndaelEncrypt(rijndaelInput, out);
RijndaelEncrypt (rijndaelInput, out);
for (i = 0; i < 16; i++)
out[i] ^= opc[i];
......@@ -165,7 +130,7 @@ void Authentication_5gaka::f2345(const uint8_t opc[16], const uint8_t k[16],
rijndaelInput[(i + 8) % 16] = temp[i] ^ opc[i];
rijndaelInput[15] ^= 4;
RijndaelEncrypt(rijndaelInput, out);
RijndaelEncrypt (rijndaelInput, out);
for (i = 0; i < 16; i++)
out[i] ^= opc[i];
......@@ -174,31 +139,31 @@ void Authentication_5gaka::f2345(const uint8_t opc[16], const uint8_t k[16],
ik[i] = out[i];
return;
} /* end of function f2345 */
} /* end of function f2345 */
/*-------------------------------------------------------------------
Algorithm f1
-------------------------------------------------------------------
Computes resynch authentication code MAC-S from key K, random
challenge RAND, sequence number SQN and authentication management
field AMF.
-----------------------------------------------------------------*/
void Authentication_5gaka::f1star(const uint8_t opc[16], const uint8_t k[16],
const uint8_t _rand[16], const uint8_t sqn[6],
const uint8_t amf[2], uint8_t mac_s[8]) {
uint8_t temp[16];
uint8_t in1[16];
uint8_t out1[16];
uint8_t rijndaelInput[16];
uint8_t i;
RijndaelKeySchedule(k);
Algorithm f1
-------------------------------------------------------------------
Computes resynch authentication code MAC-S from key K, random
challenge RAND, sequence number SQN and authentication management
field AMF.
-----------------------------------------------------------------*/
void Authentication_5gaka::f1star(const uint8_t opc[16], const uint8_t k[16], const uint8_t _rand[16], const uint8_t sqn[6], const uint8_t amf[2], uint8_t mac_s[8]){
uint8_t temp[16];
uint8_t in1[16];
uint8_t out1[16];
uint8_t rijndaelInput[16];
uint8_t i;
RijndaelKeySchedule (k);
for (i = 0; i < 16; i++)
rijndaelInput[i] = _rand[i] ^ opc[i];
RijndaelEncrypt(rijndaelInput, temp);
RijndaelEncrypt (rijndaelInput, temp);
for (i = 0; i < 6; i++) {
in1[i] = sqn[i];
......@@ -223,7 +188,7 @@ void Authentication_5gaka::f1star(const uint8_t opc[16], const uint8_t k[16],
for (i = 0; i < 16; i++)
rijndaelInput[i] ^= temp[i];
RijndaelEncrypt(rijndaelInput, out1);
RijndaelEncrypt (rijndaelInput, out1);
for (i = 0; i < 16; i++)
out1[i] ^= opc[i];
......@@ -235,56 +200,55 @@ void Authentication_5gaka::f1star(const uint8_t opc[16], const uint8_t k[16],
}
/*-------------------------------------------------------------------
Algorithm f5
-------------------------------------------------------------------
Takes key K and random challenge RAND, and returns resynch
anonymity key AK.
-----------------------------------------------------------------*/
Algorithm f5
-------------------------------------------------------------------
void Authentication_5gaka::f5star(const uint8_t opc[16], const uint8_t k[16],
const uint8_t _rand[16], uint8_t ak[6]) {
uint8_t temp[16];
uint8_t out[16];
uint8_t rijndaelInput[16];
uint8_t i;
Takes key K and random challenge RAND, and returns resynch
anonymity key AK.
RijndaelKeySchedule(k);
-----------------------------------------------------------------*/
void Authentication_5gaka::f5star(const uint8_t opc[16], const uint8_t k[16], const uint8_t _rand[16], uint8_t ak[6]){
uint8_t temp[16];
uint8_t out[16];
uint8_t rijndaelInput[16];
uint8_t i;
RijndaelKeySchedule (k);
for (i = 0; i < 16; i++)
rijndaelInput[i] = _rand[i] ^ opc[i];
RijndaelEncrypt(rijndaelInput, temp);
RijndaelEncrypt (rijndaelInput, temp);
/*
* To obtain output block OUT5: XOR OPc and TEMP,
* * * * rotate by r5=96, and XOR on the constant c5 (which *
* * * * is all zeroes except that the 3rd from last bit is 1).
*/
*/
for (i = 0; i < 16; i++)
rijndaelInput[(i + 4) % 16] = temp[i] ^ opc[i];
rijndaelInput[15] ^= 8;
RijndaelEncrypt(rijndaelInput, out);
RijndaelEncrypt (rijndaelInput, out);
for (i = 0; i < 16; i++)
out[i] ^= opc[i];
for (i = 0; i < 6; i++)
ak[i] = out[i];
return;
}
/*-------------------------------------------------------------------
Function to compute OPc from OP and K.
-----------------------------------------------------------------*/
void Authentication_5gaka::ComputeOPc(const uint8_t kP[16],
const uint8_t opP[16], uint8_t opcP[16]) {
uint8_t i;
Function to compute OPc from OP and K.
-----------------------------------------------------------------*/
void Authentication_5gaka::ComputeOPc(const uint8_t kP[16], const uint8_t opP[16], uint8_t opcP[16]){
uint8_t i;
RijndaelKeySchedule(kP);
RijndaelKeySchedule (kP);
//FPRINTF_DEBUG ("Compute opc:\n\tK:\t%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X\n", kP[0], kP[1], kP[2], kP[3], kP[4], kP[5], kP[6], kP[7], kP[8], kP[9], kP[10], kP[11], kP[12], kP[13], kP[14], kP[15]);
RijndaelEncrypt(opP, opcP);
RijndaelEncrypt (opP, opcP);
//FPRINTF_DEBUG ("\tIn:\t%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X\n\tRinj:\t%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X\n",
// opP[0], opP[1], opP[2], opP[3], opP[4], opP[5], opP[6], opP[7],
// opP[8], opP[9], opP[10], opP[11], opP[12], opP[13], opP[14], opP[15], opcP[0], opcP[1], opcP[2], opcP[3], opcP[4], opcP[5], opcP[6], opcP[7], opcP[8], opcP[9], opcP[10], opcP[11], opcP[12], opcP[13], opcP[14], opcP[15]);
......@@ -296,119 +260,139 @@ void Authentication_5gaka::ComputeOPc(const uint8_t kP[16],
return;
}
//------------------------------------------------------------------------------
void Authentication_5gaka::generate_autn(const uint8_t sqn[6],
const uint8_t ak[6],
const uint8_t amf[2],
const uint8_t mac_a[8],
uint8_t autn[16]) {
for (int i = 0; i < 6; i++) {
void Authentication_5gaka::generate_autn(const uint8_t sqn[6], const uint8_t ak[6], const uint8_t amf[2], const uint8_t mac_a[8], uint8_t autn[16]){
for(int i=0; i<6; i++){
autn[i] = sqn[i] ^ ak[i];
}
memcpy(&autn[6], amf, 2);
memcpy(&autn[8], mac_a, 8);
memcpy (&autn[6], amf, 2);
memcpy (&autn[8], mac_a, 8);
}
//------------------------------------------------------------------------------
void Authentication_5gaka::kdf(uint8_t *key, uint16_t key_len, uint8_t *s,
uint16_t s_len, uint8_t *out, uint16_t out_len) {
struct hmac_sha256_ctx ctx;
memset(&ctx, 0, sizeof(ctx));
hmac_sha256_set_key(&ctx, key_len, key);
hmac_sha256_update(&ctx, s_len, s);
hmac_sha256_digest(&ctx, out_len, out);
void Authentication_5gaka::kdf(uint8_t * key, uint16_t key_len, uint8_t * s, uint16_t s_len, uint8_t * out, uint16_t out_len){
struct hmac_sha256_ctx ctx;
memset (&ctx, 0, sizeof (ctx));
hmac_sha256_set_key (&ctx, key_len, key);
hmac_sha256_update (&ctx, s_len, s);
hmac_sha256_digest (&ctx, out_len, out);
}
//------------------------------------------------------------------------------
void Authentication_5gaka::derive_kseaf(std::string serving_network,
uint8_t kausf[32], uint8_t kseaf[32]) {
void Authentication_5gaka::derive_kseaf(std::string serving_network, uint8_t kausf[32], uint8_t kseaf[32]){
Logger::amf_n1().debug("derive_kseaf ...");
//Logger::amf_n1().debug("inputstring: snn(%s)", serving_network.c_str());
OCTET_STRING_t netName;
OCTET_STRING_fromBuf(&netName, serving_network.c_str(),
serving_network.length());
OCTET_STRING_fromBuf(&netName, serving_network.c_str(), serving_network.length());
//print_buffer("amf_n1", "inputstring: snn(hex)", netName.buf, netName.size);
uint8_t S[100];
S[0] = 0x6C; //FC
S[0] = 0x6C;//FC
memcpy(&S[1], netName.buf, netName.size);
//memcpy (&S[1+netName.size], &netName.size, 2);
S[1 + netName.size] = (uint8_t)((netName.size & 0xff00) >> 8);
S[2 + netName.size] = (uint8_t)(netName.size & 0x00ff);
kdf(kausf, 32, S, 3 + netName.size, kseaf, 32);
Logger::amf_n1().debug("derive kseaf finished!");
S[1+netName.size] = (uint8_t)((netName.size & 0xff00) >> 8);
S[2+netName.size] = (uint8_t)(netName.size & 0x00ff);
//print_buffer("amf_n1", "inputstring S", S, 3+netName.size);
//print_buffer("amf_n1", "key KEY", kausf, 32);
kdf(kausf, 32, S, 3+netName.size, kseaf, 32);
//print_buffer("amf_n1", "KDF out: Kseaf", kseaf, 32);
//Logger::amf_n1().debug("derive kseaf finished!");
}
//------------------------------------------------------------------------------
void Authentication_5gaka::derive_kausf(uint8_t ck[16], uint8_t ik[16],
std::string serving_network,
uint8_t sqn[6], uint8_t ak[6],
uint8_t kausf[32]) {
void Authentication_5gaka::derive_kausf(uint8_t ck[16], uint8_t ik[16], std::string serving_network, uint8_t sqn[6], uint8_t ak[6], uint8_t kausf[32]){
Logger::amf_n1().debug("derive_kausf ...");
//Logger::amf_n1().debug("inputstring: snn(%s)", serving_network.c_str());
OCTET_STRING_t netName;
OCTET_STRING_fromBuf(&netName, serving_network.c_str(),
serving_network.length());
OCTET_STRING_fromBuf(&netName, serving_network.c_str(), serving_network.length());
//print_buffer("amf_n1", "inputstring: snn(hex)", netName.buf, netName.size);
uint8_t S[100];
uint8_t key[32];
memcpy(&key[0], ck, 16);
memcpy(&key[16], ik, 16); //KEY
memcpy (&key[0], ck, 16);
memcpy (&key[16], ik, 16);//KEY
S[0] = 0x6A;
memcpy(&S[1], netName.buf, netName.size);
memcpy (&S[1], netName.buf, netName.size);
//memcpy (&S[1+netName.size], &netName.size, 2);
S[1 + netName.size] = (uint8_t)((netName.size & 0xff00) >> 8);
S[2 + netName.size] = (uint8_t)(netName.size & 0x00ff);
for (int i = 0; i < 6; i++) {
S[3 + netName.size + i] = sqn[i] ^ ak[i];
S[1+netName.size] = (uint8_t)((netName.size & 0xff00) >> 8);
S[2+netName.size] = (uint8_t)(netName.size & 0x00ff);
for(int i=0; i<6; i++){
S[3+netName.size+i] = sqn[i] ^ ak[i];
}
S[9 + netName.size] = 0x00;
S[10 + netName.size] = 0x06;
kdf(key, 32, S, 11 + netName.size, kausf, 32);
S[9+netName.size] = 0x00;
S[10+netName.size] = 0x06;
//print_buffer("amf_n1", "inputstring S", S, 11+netName.size);
//print_buffer("amf_n1", "key KEY", key, 32);
kdf(key, 32, S, 11+netName.size, kausf, 32);
//print_buffer("amf_n1", "KDF out: Kausf", kausf, 32);
//Logger::amf_n1().debug("derive kausf finished!");
}
//------------------------------------------------------------------------------
void Authentication_5gaka::derive_kamf(std::string imsi, uint8_t *kseaf,
uint8_t *kamf, uint16_t abba) {
void Authentication_5gaka::derive_kamf(std::string imsi, uint8_t *kseaf, uint8_t *kamf, uint16_t abba){
Logger::amf_n1().debug("derive_kamf ...");
std::string ueSupi = imsi; //OK
std::string ueSupi = imsi;//OK
//Logger::amf_n1().debug("inputstring: supi(%s)", ueSupi.c_str());
//int supiLen = (imsi.length()*sizeof(unsigned char))/2;
//unsigned char * supi = (unsigned char*)calloc(1, supiLen);
//hexStr2Byte(imsi.c_str(), supi, imsi.length());
OCTET_STRING_t supi;
OCTET_STRING_fromBuf(&supi, ueSupi.c_str(), ueSupi.length());
//uint8_t supi[8] = {0x64, 0xf0, 0x11, 0x10, 0x32, 0x54, 0x76, 0x98};
int supiLen = supi.size;
//print_buffer("amf_n1", "inputstring: supi(hex)", supi.buf, supiLen);
uint8_t S[100];
S[0] = 0x6D; //FC = 0x6D
memcpy(&S[1], supi.buf, supiLen);
S[0] = 0x6D;//FC = 0x6D
memcpy (&S[1], supi.buf, supiLen);
//memcpy (&S[1+supiLen], &supiLen, 2);
S[1 + supiLen] = (uint8_t)((supiLen & 0xff00) >> 8);
S[2 + supiLen] = (uint8_t)(supiLen & 0x00ff);
S[3 + supiLen] = abba & 0x00ff;
S[4 + supiLen] = (abba & 0xff00) >> 8;
S[5 + supiLen] = 0x00;
S[6 + supiLen] = 0x02;
kdf(kseaf, 32, S, 7 + supiLen, kamf, 32);
S[1+supiLen] = (uint8_t)((supiLen & 0xff00) >> 8);
S[2+supiLen] = (uint8_t)(supiLen & 0x00ff);
S[3+supiLen] = abba & 0x00ff;
S[4+supiLen] = (abba & 0xff00)>>8;
S[5+supiLen] = 0x00;
S[6+supiLen] = 0x02;
//print_buffer("amf_n1", "inputstring S", S, 7+supiLen);
//print_buffer("amf_n1", "key KEY", kseaf, 32);
kdf(kseaf, 32, S, 7+supiLen, kamf, 32);
//print_buffer("amf_n1", "KDF out: Kamf", kamf, 32);
//Logger::amf_n1().debug("derive kamf finished!");
}
//------------------------------------------------------------------------------
void Authentication_5gaka::derive_knas(algorithm_type_dist_t nas_alg_type,
uint8_t nas_alg_id, uint8_t kamf[32],
uint8_t *knas) {
void Authentication_5gaka::derive_knas(algorithm_type_dist_t nas_alg_type, uint8_t nas_alg_id, uint8_t kamf[32], uint8_t * knas){
Logger::amf_n1().debug("derive_knas ...");
uint8_t S[20];
uint8_t out[32] = { 0 };
S[0] = 0x69; //FC
S[1] = (uint8_t)(nas_alg_type & 0xFF);
uint8_t out[32] = {0};
S[0] = 0x69;//FC
S[1] = (uint8_t) (nas_alg_type & 0xFF);
S[2] = 0x00;
S[3] = 0x01;
S[4] = nas_alg_id;
S[5] = 0x00;
S[6] = 0x01;
kdf(kamf, 32, S, 7, out, 32);
//print_buffer("amf_n1", "inputstring S", S, 7);
//print_buffer("amf_n1", "key KEY", kamf, 32);
kdf (kamf, 32, S, 7, out, 32);
//memcpy (knas, &out[31 - 16 + 1], 16);
for (int i = 0; i < 16; i++)
knas[i] = out[16 + i];
for(int i=0; i<16; i++)
knas[i] = out[16+i];
//print_buffer("amf_n1", "knas", knas, 16);
//Logger::amf_n1().debug("derive knas finished!");
}
//------------------------------------------------------------------------------
void Authentication_5gaka::derive_kgnb(uint32_t uplinkCount, uint8_t accessType,
uint8_t kamf[32], uint8_t *kgnb) {
void Authentication_5gaka::derive_kgnb(uint32_t uplinkCount, uint8_t accessType, uint8_t kamf[32], uint8_t * kgnb){
Logger::amf_n1().debug("derive_kgnb ...");
uint8_t S[20];
S[0] = 0x6E;
*(uint32_t*)(S+1) = htonl(uplinkCount);
S[5] = 0x00;
S[6] = 0x04;
S[7] = accessType;
S[8] = 0x00;
S[9] = 0x01;
//print_buffer("amf_n1", "inputstring S", S, 10);
//print_buffer("amf_n1", "key KEY", kamf, 32);
kdf(kamf, 32, S, 10, kgnb, 32);
//print_buffer("amf_n1", "kgnb", kgnb, 32);
//Logger::amf_n1().debug("derive kgnb finished!");
}
void Authentication_5gaka::handover_ncc_derive_knh(uint32_t uplinkCount, uint8_t accessType, uint8_t kamf[32], uint8_t *kgnb, uint8_t *knh, int ncc)
{
Logger::amf_n1().debug("derive_handover_ncc_knh ...");
uint8_t S[20],SS[ncc][35];
S[0] = 0x6E;
*(uint32_t*) (S + 1) = htonl(uplinkCount);
S[5] = 0x00;
S[6] = 0x04;
......@@ -416,17 +400,34 @@ void Authentication_5gaka::derive_kgnb(uint32_t uplinkCount, uint8_t accessType,
S[8] = 0x00;
S[9] = 0x01;
kdf(kamf, 32, S, 10, kgnb, 32);
for(int i = 0; i<ncc; i++)
{
if(i == 0)
{
SS[0][0] = 0x6f;
memcpy(SS[0] + 1, kgnb, 32);
SS[0][33] = 0x00;
SS[0][34] = 0x20;
kdf(kamf, 32, SS[0], 35, knh, 32);
}
else
{
SS[i][0] = 0x6f;
memcpy(SS[i] + 1, knh, 32);
SS[i][33] = 0x00;
SS[i][34] = 0x20;
kdf(kamf, 32, SS[i], 35, knh, 32);
}
print_buffer("amf_n1", "SS", SS[i], 35);
print_buffer("amf_n1", "Knh", knh, 32);
}
}
//------------------------------------------------------------------------------
void Authentication_5gaka::derive_kasme(uint8_t ck[16], uint8_t ik[16],
uint8_t plmn[3], uint8_t sqn[6],
uint8_t ak[6], uint8_t *kasme) {
uint8_t s[14];
int i;
uint8_t key[32];
memcpy(&key[0], ck, 16);
memcpy(&key[16], ik, 16);
void Authentication_5gaka::derive_kasme(uint8_t ck[16], uint8_t ik[16], uint8_t plmn[3], uint8_t sqn[6], uint8_t ak[6], uint8_t * kasme){
uint8_t s[14];
int i;
uint8_t key[32];
memcpy (&key[0], ck, 16);
memcpy (&key[16], ik, 16);
/*
* FC
*/
......@@ -438,7 +439,7 @@ void Authentication_5gaka::derive_kasme(uint8_t ck[16], uint8_t ik[16],
* * * * 2 MNC digit 3 | MCC digit 3
* * * * 3 MNC digit 2 | MNC digit 1
*/
memcpy(&s[1], plmn, 3);
memcpy (&s[1], plmn, 3);
/*
* L0
*/
......@@ -456,19 +457,15 @@ void Authentication_5gaka::derive_kasme(uint8_t ck[16], uint8_t ik[16],
*/
s[12] = 0x00;
s[13] = 0x06;
kdf(key, 32, s, 14, kasme, 32);
kdf (key, 32, s, 14, kasme, 32);
}
//------------------------------------------------------------------------------
int Authentication_5gaka::generate_vector(const uint8_t opc[16], uint64_t imsi,
uint8_t key[16], uint8_t plmn[3],
uint8_t sqn[6],
auc_vector_t *vector) {
uint8_t amf[] = { 0x80, 0x00 };
uint8_t mac_a[8];
uint8_t ck[16];
uint8_t ik[16];
uint8_t ak[6];
int Authentication_5gaka::generate_vector(const uint8_t opc[16], uint64_t imsi, uint8_t key[16], uint8_t plmn[3], uint8_t sqn[6], auc_vector_t * vector){
uint8_t amf[] = { 0x80, 0x00 };
uint8_t mac_a[8];
uint8_t ck[16];
uint8_t ik[16];
uint8_t ak[6];
if (vector == NULL) {
return EINVAL;
......@@ -477,41 +474,45 @@ int Authentication_5gaka::generate_vector(const uint8_t opc[16], uint64_t imsi,
/*
* Compute MAC
*/
f1(opc, key, vector->rand, sqn, amf, mac_a);
f1 (opc, key, vector->rand, sqn, amf, mac_a);
//print_buffer ("MAC_A : ", mac_a, 8);
//print_buffer ("SQN : ", sqn, 6);
//print_buffer ("RAND : ", vector->rand, 16);
/*
* Compute XRES, CK, IK, AK
*/
f2345(opc, key, vector->rand, vector->xres, ck, ik, ak);
f2345 (opc, key, vector->rand, vector->xres, ck, ik, ak);
//print_buffer ("AK : ", ak, 6);
//print_buffer ("CK : ", ck, 16);
//print_buffer ("IK : ", ik, 16);
//print_buffer ("XRES : ", vector->xres, 8);
/*
* AUTN = SQN ^ AK || AMF || MAC
*/
generate_autn(sqn, ak, amf, mac_a, vector->autn);
generate_autn (sqn, ak, amf, mac_a, vector->autn);
//print_buffer ("AUTN : ", vector->autn, 16);
derive_kasme(ck, ik, plmn, sqn, ak, vector->kasme);
derive_kasme (ck, ik, plmn, sqn, ak, vector->kasme);
//print_buffer ("KASME : ", vector->kasme, 32);
return 0;
}
//------------------------------------------------------------------------------
uint8_t* Authentication_5gaka::sqn_ms_derive(const uint8_t opc[16],
uint8_t *key, uint8_t *auts,
uint8_t *rand_p) {
uint8_t* Authentication_5gaka::sqn_ms_derive (const uint8_t opc[16], uint8_t * key, uint8_t * auts, uint8_t * rand_p){
/*
* AUTS = Conc(SQN MS ) || MAC-S
* * * * Conc(SQN MS ) = SQN MS ^ f5* (RAND)
* * * * MAC-S = f1* (SQN MS || RAND || AMF)
*/
uint8_t ak[6] = { 0 };
uint8_t *conc_sqn_ms = NULL;
uint8_t *mac_s = NULL;
uint8_t mac_s_computed[MAC_S_LENGTH] = { 0 };
uint8_t *sqn_ms = NULL;
uint8_t amf[2] = { 0, 0 };
int i = 0;
uint8_t ak[6] = {0};
uint8_t *conc_sqn_ms = NULL;
uint8_t *mac_s = NULL;
uint8_t mac_s_computed[MAC_S_LENGTH] = {0};
uint8_t *sqn_ms = NULL;
uint8_t amf[2] = { 0, 0 };
int i = 0;
conc_sqn_ms = auts;
mac_s = &auts[6];
sqn_ms = (uint8_t*) malloc(SQN_LENGTH_OCTEST);
sqn_ms = (uint8_t*)malloc (SQN_LENGTH_OCTEST);
/*
* if (hss_config.valid_opc == 0) {
* SetOP(hss_config.operator_key);
......@@ -520,17 +521,24 @@ uint8_t* Authentication_5gaka::sqn_ms_derive(const uint8_t opc[16],
/*
* Derive AK from key and rand
*/
f5star(opc, key, rand_p, ak);
f5star (opc, key, rand_p, ak);
for (i = 0; i < 6; i++) {
sqn_ms[i] = ak[i] ^ conc_sqn_ms[i];
}
f1star(opc, key, rand_p, sqn_ms, amf, mac_s_computed);
//print_buffer ("sqn_ms_derive() KEY : ", key, 16);
//print_buffer ("sqn_ms_derive() RAND : ", rand_p, 16);
//print_buffer ("sqn_ms_derive() AUTS : ", auts, 14);
//print_buffer ("sqn_ms_derive() AK : ", ak, 6);
//print_buffer ("sqn_ms_derive() SQN_MS : ", sqn_ms, 6);
//print_buffer ("sqn_ms_derive() MAC_S : ", mac_s, 8);
f1star (opc, key, rand_p, sqn_ms, amf, mac_s_computed);
//print_buffer ("MAC_S +: ", mac_s_computed, 8);
if (memcmp(mac_s_computed, mac_s, 8) != 0) {
if (memcmp (mac_s_computed, mac_s, 8) != 0) {
//FPRINTF_ERROR ( "Failed to verify computed SQN_MS\n");
free(sqn_ms);
free (sqn_ms);
return NULL;
}
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file authentication_algorithms_with_5gaka.hpp
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _5GAKA_H_
#define _5GAKA_H_
//extern "C"{
#include <stdint.h>
#include <stdio.h>
#include <unistd.h>
#include <gmp.h>
#include <pthread.h>
#include <string>
#include <stdint.h>
#include <stdio.h>
#include <unistd.h>
#include <gmp.h>
#include <pthread.h>
#include <string>
//}
#define SQN_LENGTH_BITS (48)
......@@ -60,27 +32,27 @@ typedef struct {
uint8_t kasme[32];
} auc_vector_t;
typedef struct {
typedef struct{
uint8_t avType;
uint8_t rand[16];
uint8_t xres[8];
uint8_t xresStar[16];
uint8_t autn[16];
uint8_t kausf[32];
} _5G_HE_AV_t; //clause 6.3.6.2.5, ts33.501
}_5G_HE_AV_t;//clause 6.3.6.2.5, ts33.501
typedef struct {
typedef struct{
uint8_t avType;
uint8_t rand[16];
uint8_t hxres[16];
uint8_t hxresStar[16];
uint8_t autn[16];
uint8_t kseaf[32];
} _5G_AV_t;
}_5G_AV_t;
typedef struct random_state_s {
pthread_mutex_t lock;
gmp_randstate_t state;
pthread_mutex_t lock;
gmp_randstate_t state;
} random_state_t;
#define _NEA0_ 0b0000
......@@ -97,56 +69,64 @@ typedef enum {
NAS_INT_ALG = 0x02,
RRC_ENC_ALG = 0x03,
RRC_INT_ALG = 0x04,
UP_ENC_ALG = 0x05,
UP_INT_ALG = 0x06
UP_ENC_ALG = 0x05,
UP_INT_ALG = 0x06
} algorithm_type_dist_t;
class Authentication_5gaka {
public:
/****** internal algorithms f1 f2 f3 f4 f5 ********/
static void f1(const uint8_t opc[16], const uint8_t k[16],
const uint8_t _rand[16], const uint8_t sqn[6],
const uint8_t amf[2], uint8_t mac_a[8]);
static void f1star(const uint8_t kP[16], const uint8_t k[16],
const uint8_t rand[16], const uint8_t sqn[6],
const uint8_t amf[2], uint8_t mac_s[8]);
static void f2345(const uint8_t opc[16], const uint8_t k[16],
const uint8_t _rand[16], uint8_t res[8], uint8_t ck[16],
uint8_t ik[16], uint8_t ak[6]);
static void f5star(const uint8_t kP[16], const uint8_t k[16],
const uint8_t rand[16], uint8_t ak[6]);
/****** key derive ***********/
static void kdf(uint8_t *key, uint16_t key_len, uint8_t *s, uint16_t s_len,
uint8_t *out, uint16_t out_len);
static void derive_kasme(uint8_t ck[16], uint8_t ik[16], uint8_t plmn[3],
uint8_t sqn[6], uint8_t ak[6], uint8_t kasme[32]);
static void derive_kausf(uint8_t ck[16], uint8_t ik[16],
std::string serving_network, uint8_t sqn[6],
uint8_t ak[6], uint8_t kausf[32]);
static void derive_kseaf(std::string serving_network, uint8_t kausf[32],
uint8_t kseaf[32]);
static void derive_kamf(std::string imsi, uint8_t *kseaf, uint8_t *kamf,
uint16_t abba);
static void derive_knas(algorithm_type_dist_t nas_alg_type,
uint8_t nas_alg_id, uint8_t kamf[32], uint8_t *knas);
static void derive_kgnb(uint32_t uplinkCount, uint8_t accessType,
uint8_t kamf[32], uint8_t *kgnb);
static uint8_t* sqn_ms_derive(const uint8_t opc[16], uint8_t *key,
uint8_t *auts, uint8_t *rand);
/****** general functions ********/
static void ComputeOPc(const uint8_t kP[16], const uint8_t opP[16],
uint8_t opcP[16]);
static void generate_autn(const uint8_t sqn[6], const uint8_t ak[6],
const uint8_t amf[2], const uint8_t mac_a[8],
uint8_t autn[16]);
static int generate_vector(const uint8_t opc[16], uint64_t imsi,
uint8_t key[16], uint8_t plmn[3], uint8_t sqn[6],
auc_vector_t *vector);
/****** Rijndael ********/
class Authentication_5gaka{
public:
/****** sequence number functions ********/
//struct sqn_ue_s *sqn_exists(uint64_t imsi);
//void sqn_insert(struct sqn_ue_s *item);
//void sqn_init(struct sqn_ue_s *item);
//struct sqn_ue_s *sqn_new(uint64_t imsi);
//void sqn_list_init(void);
//void sqn_get(uint64_t imsi, uint8_t sqn[6]);
public:
/****** random number functions *********/
//void random_init(void);
//void generate_random(uint8_t *random, ssize_t length);
public:
/****** internal algorithms f1 f2 f3 f4 f5 ********/
static void f1 ( const uint8_t opc[16],const uint8_t k[16], const uint8_t _rand[16], const uint8_t sqn[6], const uint8_t amf[2], uint8_t mac_a[8] );
static void f1star( const uint8_t kP[16],const uint8_t k[16], const uint8_t rand[16], const uint8_t sqn[6], const uint8_t amf[2], uint8_t mac_s[8] );
static void f2345 ( const uint8_t opc[16],const uint8_t k[16], const uint8_t _rand[16], uint8_t res[8], uint8_t ck[16], uint8_t ik[16], uint8_t ak[6] );
static void f5star( const uint8_t kP[16],const uint8_t k[16], const uint8_t rand[16], uint8_t ak[6] );
public:
/****** key derive ***********/
static void kdf(uint8_t *key, uint16_t key_len, uint8_t *s, uint16_t s_len, uint8_t *out, uint16_t out_len);
static void derive_kasme(uint8_t ck[16], uint8_t ik[16], uint8_t plmn[3], uint8_t sqn[6], uint8_t ak[6], uint8_t kasme[32]);
static void derive_kausf(uint8_t ck[16], uint8_t ik[16], std::string serving_network, uint8_t sqn[6], uint8_t ak[6], uint8_t kausf[32]);
static void derive_kseaf(std::string serving_network, uint8_t kausf[32], uint8_t kseaf[32]);
static void derive_kamf(std::string imsi, uint8_t *kseaf, uint8_t *kamf, uint16_t abba);
static void derive_knas(algorithm_type_dist_t nas_alg_type, uint8_t nas_alg_id, uint8_t kamf[32], uint8_t * knas);
static void derive_kgnb(uint32_t uplinkCount, uint8_t accessType, uint8_t kamf[32], uint8_t * kgnb);
static void handover_ncc_derive_knh(uint32_t uplinkCount, uint8_t accessType, uint8_t kamf[32], uint8_t * kgnb, uint8_t * knh, int ncc);
static uint8_t *sqn_ms_derive(const uint8_t opc[16], uint8_t *key, uint8_t *auts, uint8_t *rand);
public:
/****** general functions ********/
static void ComputeOPc( const uint8_t kP[16], const uint8_t opP[16], uint8_t opcP[16] );
static void generate_autn(const uint8_t sqn[6], const uint8_t ak[6], const uint8_t amf[2], const uint8_t mac_a[8], uint8_t autn[16]);
static int generate_vector(const uint8_t opc[16], uint64_t imsi, uint8_t key[16], uint8_t plmn[3], uint8_t sqn[6], auc_vector_t *vector);
public:
/****** Rijndael ********/
static void RijndaelKeySchedule(const uint8_t key[16]);
static void RijndaelEncrypt(const uint8_t in[16], uint8_t out[16]);
private:
private:
auc_vector_t auc_vector;
};
#endif
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