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

Merge branch 'n2_handover' into 'develop'

N2 handover

See merge request oai/cn5g/oai-cn5g-amf!33
parents ed629ee8 dc61ff89
...@@ -76,6 +76,7 @@ COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libpsl.so.5 . ...@@ -76,6 +76,7 @@ COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libpsl.so.5 .
WORKDIR /usr/local/lib WORKDIR /usr/local/lib
COPY --from=oai-amf-builder /usr/lib/libboost_system.so.1.67.0 . COPY --from=oai-amf-builder /usr/lib/libboost_system.so.1.67.0 .
COPY --from=oai-amf-builder /usr/lib/libboost_thread.so.1.67.0 . COPY --from=oai-amf-builder /usr/lib/libboost_thread.so.1.67.0 .
COPY --from=oai-amf-builder /usr/lib/libboost_chrono.so.1.67.0 .
COPY --from=oai-amf-builder /usr/local/lib/libpistache.so . COPY --from=oai-amf-builder /usr/local/lib/libpistache.so .
RUN ldconfig RUN ldconfig
......
...@@ -97,6 +97,7 @@ COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libpsl.so.5 . ...@@ -97,6 +97,7 @@ COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libpsl.so.5 .
WORKDIR /usr/local/lib WORKDIR /usr/local/lib
COPY --from=oai-amf-builder /usr/lib/libboost_system.so.1.67.0 . COPY --from=oai-amf-builder /usr/lib/libboost_system.so.1.67.0 .
COPY --from=oai-amf-builder /usr/lib/libboost_thread.so.1.67.0 . COPY --from=oai-amf-builder /usr/lib/libboost_thread.so.1.67.0 .
COPY --from=oai-amf-builder /usr/lib/libboost_chrono.so.1.67.0 .
COPY --from=oai-amf-builder /usr/local/lib/libpistache.so . COPY --from=oai-amf-builder /usr/local/lib/libpistache.so .
RUN ldconfig RUN ldconfig
......
...@@ -62,7 +62,15 @@ void amf_app_task(void*); ...@@ -62,7 +62,15 @@ void amf_app_task(void*);
uint32_t golbal_tmsi = 1; uint32_t golbal_tmsi = 1;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
amf_app::amf_app(const amf_config& amf_cfg) { amf_app::amf_app(const amf_config& amf_cfg)
: m_amf_ue_ngap_id2ue_ctx(),
m_ue_ctx_key(),
m_supi2ue_ctx(),
m_curl_handle_responses_n2_sm() {
amf_ue_ngap_id2ue_ctx = {};
ue_ctx_key = {};
supi2ue_ctx = {};
curl_handle_responses_n2_sm = {};
Logger::amf_app().startup("Creating AMF application functionality layer"); Logger::amf_app().startup("Creating AMF application functionality layer");
if (itti_inst->create_task(TASK_AMF_APP, amf_app_task, nullptr)) { if (itti_inst->create_task(TASK_AMF_APP, amf_app_task, nullptr)) {
Logger::amf_app().error("Cannot create task TASK_AMF_APP"); Logger::amf_app().error("Cannot create task TASK_AMF_APP");
...@@ -205,6 +213,7 @@ void amf_app::set_supi_2_ue_context( ...@@ -205,6 +213,7 @@ void amf_app::set_supi_2_ue_context(
supi2ue_ctx[supi] = uc; supi2ue_ctx[supi] = uc;
} }
//------------------------------------------------------------------------------
bool amf_app::find_pdu_session_context( bool amf_app::find_pdu_session_context(
const string& supi, const std::uint8_t pdu_session_id, const string& supi, const std::uint8_t pdu_session_id,
std::shared_ptr<pdu_session_context>& psc) { std::shared_ptr<pdu_session_context>& psc) {
...@@ -215,6 +224,7 @@ bool amf_app::find_pdu_session_context( ...@@ -215,6 +224,7 @@ bool amf_app::find_pdu_session_context(
return true; return true;
} }
//------------------------------------------------------------------------------
bool amf_app::get_pdu_sessions_context( bool amf_app::get_pdu_sessions_context(
const string& supi, const string& supi,
std::vector<std::shared_ptr<pdu_session_context>>& sessions_ctx) { std::vector<std::shared_ptr<pdu_session_context>>& sessions_ctx) {
...@@ -298,6 +308,7 @@ void amf_app::handle_itti_message( ...@@ -298,6 +308,7 @@ void amf_app::handle_itti_message(
} else { } else {
unc = amf_n2_inst->ran_ue_id_2_ue_ngap_context(itti_msg.ran_ue_ngap_id); unc = amf_n2_inst->ran_ue_id_2_ue_ngap_context(itti_msg.ran_ue_ngap_id);
unc.get()->amf_ue_ngap_id = amf_ue_ngap_id; unc.get()->amf_ue_ngap_id = amf_ue_ngap_id;
amf_n2_inst->set_amf_ue_ngap_id_2_ue_ngap_context(amf_ue_ngap_id, unc);
} }
if (uc.get() == nullptr) { if (uc.get() == nullptr) {
...@@ -477,3 +488,24 @@ void amf_app::trigger_nf_deregistration() { ...@@ -477,3 +488,24 @@ void amf_app::trigger_nf_deregistration() {
itti_msg->get_msg_name()); itti_msg->get_msg_name());
} }
} }
//---------------------------------------------------------------------------------------------
void amf_app::add_promise(
uint32_t id, boost::shared_ptr<boost::promise<std::string>>& p) {
std::unique_lock lock(m_curl_handle_responses_n2_sm);
curl_handle_responses_n2_sm.emplace(id, p);
}
//------------------------------------------------------------------------------
void amf_app::trigger_process_response(uint32_t pid, std::string n2_sm) {
Logger::amf_app().debug(
"Trigger process response: Set promise with ID %u "
"to ready",
pid);
std::unique_lock lock(m_curl_handle_responses_n2_sm);
if (curl_handle_responses_n2_sm.count(pid) > 0) {
curl_handle_responses_n2_sm[pid]->set_value(n2_sm);
// Remove this promise from list
curl_handle_responses_n2_sm.erase(pid);
}
}
...@@ -40,6 +40,10 @@ ...@@ -40,6 +40,10 @@
#include "itti_msg_amf_app.hpp" #include "itti_msg_amf_app.hpp"
#include "ue_context.hpp" #include "ue_context.hpp"
#include "uint_generator.hpp"
#include <boost/thread.hpp>
#include <boost/thread/future.hpp>
using namespace config; using namespace config;
static uint32_t amf_app_ue_ngap_id_generator = 1; static uint32_t amf_app_ue_ngap_id_generator = 1;
...@@ -63,14 +67,6 @@ class amf_app { ...@@ -63,14 +67,6 @@ class amf_app {
// itti handlers // itti handlers
void handle_itti_message(itti_nas_signalling_establishment_request& itti_msg); void handle_itti_message(itti_nas_signalling_establishment_request& itti_msg);
void handle_itti_message(itti_n1n2_message_transfer_request& itti_msg); void handle_itti_message(itti_n1n2_message_transfer_request& itti_msg);
// context management
std::map<long, std::shared_ptr<ue_context>> amf_ue_ngap_id2ue_ctx;
mutable std::shared_mutex m_amf_ue_ngap_id2ue_ctx;
std::map<std::string, std::shared_ptr<ue_context>> ue_ctx_key;
mutable std::shared_mutex m_ue_ctx_key;
std::map<std::string, std::shared_ptr<ue_context>> supi2ue_ctx;
mutable std::shared_mutex m_supi2ue_ctx;
bool is_amf_ue_id_2_ue_context(const long& amf_ue_ngap_id) const; bool is_amf_ue_id_2_ue_context(const long& amf_ue_ngap_id) const;
std::shared_ptr<ue_context> amf_ue_id_2_ue_context( std::shared_ptr<ue_context> amf_ue_id_2_ue_context(
...@@ -137,6 +133,51 @@ class amf_app { ...@@ -137,6 +133,51 @@ class amf_app {
* @return void * @return void
*/ */
void trigger_nf_deregistration(); void trigger_nf_deregistration();
/*
* Store the promise
* @param [uint32_t] pid: promise id
* @param [boost::shared_ptr<boost::promise<uint32_t>>&] p: promise
* @return void
*/
void add_promise(
uint32_t pid, boost::shared_ptr<boost::promise<uint32_t>>& p);
/*
* Remove the promise
* @param [uint32_t] pid: promise id
* @return void
*/
void remove_promise(uint32_t id);
/*
* Generate an unique value for promise id
* @param void
* @return generated promise id
*/
static uint64_t generate_promise_id() {
return util::uint_uid_generator<uint64_t>::get_instance().get_uid();
}
void trigger_process_response(uint32_t pid, uint32_t http_code);
void add_promise(
uint32_t pid, boost::shared_ptr<boost::promise<std::string>>& p);
void trigger_process_response(uint32_t pid, std::string n2_sm);
private:
// context management
std::map<long, std::shared_ptr<ue_context>> amf_ue_ngap_id2ue_ctx;
mutable std::shared_mutex m_amf_ue_ngap_id2ue_ctx;
std::map<std::string, std::shared_ptr<ue_context>> ue_ctx_key;
mutable std::shared_mutex m_ue_ctx_key;
std::map<std::string, std::shared_ptr<ue_context>> supi2ue_ctx;
mutable std::shared_mutex m_supi2ue_ctx;
mutable std::shared_mutex m_curl_handle_responses_n2_sm;
std::map<uint32_t, boost::shared_ptr<boost::promise<std::string>>>
curl_handle_responses_n2_sm;
}; };
} // namespace amf_application } // namespace amf_application
......
...@@ -84,7 +84,6 @@ extern statistics stacs; ...@@ -84,7 +84,6 @@ extern statistics stacs;
extern void convert_string_2_hex(std::string& input, std::string& output); extern void convert_string_2_hex(std::string& input, std::string& output);
extern unsigned char* format_string_as_hex(std::string str); extern unsigned char* format_string_as_hex(std::string str);
extern int ncc;
Sha256 ctx; Sha256 ctx;
random_state_t random_state; random_state_t random_state;
static uint8_t no_random_delta = 0; static uint8_t no_random_delta = 0;
...@@ -210,7 +209,6 @@ void amf_n1::handle_itti_message(itti_downlink_nas_transfer& itti_msg) { ...@@ -210,7 +209,6 @@ void amf_n1::handle_itti_message(itti_downlink_nas_transfer& itti_msg) {
uint32_t ulcount = uint32_t ulcount =
secu->ul_count.seq_num | (secu->ul_count.overflow << 8); secu->ul_count.seq_num | (secu->ul_count.overflow << 8);
Authentication_5gaka::derive_kgnb(0, 0x01, kamf, kgnb); Authentication_5gaka::derive_kgnb(0, 0x01, kamf, kgnb);
ncc = 1;
print_buffer("amf_n1", "kamf", kamf, 32); print_buffer("amf_n1", "kamf", kamf, 32);
// Authentication_5gaka::derive_kgnb(ulcount, 0x01, kamf, kgnb); // Authentication_5gaka::derive_kgnb(ulcount, 0x01, kamf, kgnb);
bstring kgnb_bs = blk2bstr(kgnb, 32); bstring kgnb_bs = blk2bstr(kgnb, 32);
...@@ -457,58 +455,6 @@ void amf_n1::nas_signalling_establishment_request_handle( ...@@ -457,58 +455,6 @@ void amf_n1::nas_signalling_establishment_request_handle(
} }
} }
//------------------------------------------------------------------------------
void amf_n1::uplink_nas_msg_handle(
uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, bstring plain_msg) {
uint8_t* buf = (uint8_t*) bdata(plain_msg);
uint8_t message_type = *(buf + 2);
switch (message_type) {
case AUTHENTICATION_RESPONSE: {
Logger::amf_n1().debug(
"Received authentication response message, handling...");
authentication_response_handle(ran_ue_ngap_id, amf_ue_ngap_id, plain_msg);
} break;
case AUTHENTICATION_FAILURE: {
Logger::amf_n1().debug(
"Received authentication failure message, handling...");
authentication_failure_handle(ran_ue_ngap_id, amf_ue_ngap_id, plain_msg);
} break;
case SECURITY_MODE_COMPLETE: {
Logger::amf_n1().debug(
"Received security mode complete message, handling...");
security_mode_complete_handle(ran_ue_ngap_id, amf_ue_ngap_id, plain_msg);
} break;
case SECURITY_MODE_REJECT: {
Logger::amf_n1().debug(
"Received security mode reject message, handling...");
security_mode_reject_handle(ran_ue_ngap_id, amf_ue_ngap_id, plain_msg);
} break;
case UL_NAS_TRANSPORT: {
Logger::amf_n1().debug("Received UL NAS transport message, handling...");
ul_nas_transport_handle(ran_ue_ngap_id, amf_ue_ngap_id, plain_msg);
} break;
case UE_INIT_DEREGISTER: {
Logger::amf_n1().debug(
"Received de-registration request message, handling...");
ue_initiate_de_registration_handle(
ran_ue_ngap_id, amf_ue_ngap_id, plain_msg);
} break;
case IDENTITY_RESPONSE: {
Logger::amf_n1().debug("received identity response message , handle ...");
identity_response_handle(ran_ue_ngap_id, amf_ue_ngap_id, plain_msg);
} break;
case REGISTRATION_COMPLETE: {
Logger::amf_n1().debug(
"Received registration complete message, handling...");
registration_complete_handle(ran_ue_ngap_id, amf_ue_ngap_id, plain_msg);
// TODO
} break;
default: {
// TODO:
}
}
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void amf_n1::uplink_nas_msg_handle( void amf_n1::uplink_nas_msg_handle(
uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, bstring plain_msg, uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, bstring plain_msg,
...@@ -1422,9 +1368,9 @@ bool amf_n1::_5g_aka_confirmation_from_ausf( ...@@ -1422,9 +1368,9 @@ bool amf_n1::_5g_aka_confirmation_from_ausf(
Logger::amf_n1().debug("_5g_aka_confirmation_from_ausf"); Logger::amf_n1().debug("_5g_aka_confirmation_from_ausf");
std::string remoteUri = nc.get()->Href; std::string remoteUri = nc.get()->Href;
std::string msgBody; std::string msgBody = {};
std::string Response; std::string response = {};
std::string resStar_string; std::string resStar_string = {};
std::map<std::string, std::string>::iterator iter; std::map<std::string, std::string>::iterator iter;
iter = rand_record.find(nc.get()->imsi); iter = rand_record.find(nc.get()->imsi);
...@@ -1450,12 +1396,12 @@ bool amf_n1::_5g_aka_confirmation_from_ausf( ...@@ -1450,12 +1396,12 @@ bool amf_n1::_5g_aka_confirmation_from_ausf(
msgBody = confirmationdata_j.dump(); msgBody = confirmationdata_j.dump();
// TODO: Should be updated // TODO: Should be updated
amf_n11_inst->curl_http_client(remoteUri, "PUT", msgBody, Response); amf_n11_inst->curl_http_client(remoteUri, "PUT", msgBody, response);
free_wrapper((void**) &resStar_s); free_wrapper((void**) &resStar_s);
try { try {
ConfirmationDataResponse confirmationdataresponse; ConfirmationDataResponse confirmationdataresponse;
nlohmann::json::parse(Response.c_str()).get_to(confirmationdataresponse); nlohmann::json::parse(response.c_str()).get_to(confirmationdataresponse);
unsigned char* kseaf_hex = unsigned char* kseaf_hex =
format_string_as_hex(confirmationdataresponse.getKseaf()); format_string_as_hex(confirmationdataresponse.getKseaf());
memcpy(nc.get()->_5g_av[0].kseaf, kseaf_hex, 32); memcpy(nc.get()->_5g_av[0].kseaf, kseaf_hex, 32);
...@@ -2004,7 +1950,6 @@ bool amf_n1::start_security_mode_control_procedure( ...@@ -2004,7 +1950,6 @@ bool amf_n1::start_security_mode_control_procedure(
nc.get()->is_current_security_available = true; nc.get()->is_current_security_available = true;
} }
// SecurityModeCommand* smc = new SecurityModeCommand();
std::unique_ptr<SecurityModeCommand> smc = std::unique_ptr<SecurityModeCommand> smc =
std::make_unique<SecurityModeCommand>(); std::make_unique<SecurityModeCommand>();
smc->setHeader(PLAIN_5GS_MSG); smc->setHeader(PLAIN_5GS_MSG);
...@@ -2201,7 +2146,6 @@ void amf_n1::security_mode_complete_handle( ...@@ -2201,7 +2146,6 @@ void amf_n1::security_mode_complete_handle(
uint8_t kgnb[32]; uint8_t kgnb[32];
uint32_t ulcount = secu->ul_count.seq_num | (secu->ul_count.overflow << 8); uint32_t ulcount = secu->ul_count.seq_num | (secu->ul_count.overflow << 8);
Authentication_5gaka::derive_kgnb(0, 0x01, kamf, kgnb); Authentication_5gaka::derive_kgnb(0, 0x01, kamf, kgnb);
ncc = 1;
print_buffer("amf_n1", "kamf", kamf, 32); print_buffer("amf_n1", "kamf", kamf, 32);
// Authentication_5gaka::derive_kgnb(ulcount, 0x01, kamf, kgnb); // Authentication_5gaka::derive_kgnb(ulcount, 0x01, kamf, kgnb);
bstring kgnb_bs = blk2bstr(kgnb, 32); bstring kgnb_bs = blk2bstr(kgnb, 32);
...@@ -2587,10 +2531,8 @@ void amf_n1::ul_nas_transport_handle( ...@@ -2587,10 +2531,8 @@ void amf_n1::ul_nas_transport_handle(
Logger::amf_n1().error("Cannot decode Payload Container"); Logger::amf_n1().error("Cannot decode Payload Container");
return; return;
} }
// send_itti_to_smf_services_consumer(ran_ue_ngap_id, amf_ue_ngap_id, itti_nsmf_pdusession_create_sm_context* itti_msg =
// request_type, pdu_session_id, dnn, sm_msg); new itti_nsmf_pdusession_create_sm_context(TASK_AMF_N1, TASK_AMF_N11);
itti_smf_services_consumer* itti_msg =
new itti_smf_services_consumer(TASK_AMF_N1, TASK_AMF_N11);
itti_msg->ran_ue_ngap_id = ran_ue_ngap_id; itti_msg->ran_ue_ngap_id = ran_ue_ngap_id;
itti_msg->amf_ue_ngap_id = amf_ue_ngap_id; itti_msg->amf_ue_ngap_id = amf_ue_ngap_id;
itti_msg->req_type = request_type; itti_msg->req_type = request_type;
...@@ -2599,8 +2541,8 @@ void amf_n1::ul_nas_transport_handle( ...@@ -2599,8 +2541,8 @@ void amf_n1::ul_nas_transport_handle(
itti_msg->sm_msg = sm_msg; itti_msg->sm_msg = sm_msg;
itti_msg->snssai.sST = snssai.sst; itti_msg->snssai.sST = snssai.sst;
itti_msg->snssai.sD = std::to_string(snssai.sd); itti_msg->snssai.sD = std::to_string(snssai.sd);
std::shared_ptr<itti_smf_services_consumer> i = std::shared_ptr<itti_nsmf_pdusession_create_sm_context> i =
std::shared_ptr<itti_smf_services_consumer>(itti_msg); std::shared_ptr<itti_nsmf_pdusession_create_sm_context>(itti_msg);
int ret = itti_inst->send_msg(i); int ret = itti_inst->send_msg(i);
if (0 != ret) { if (0 != ret) {
Logger::amf_n1().error( Logger::amf_n1().error(
...@@ -2638,10 +2580,8 @@ void amf_n1::ul_nas_transport_handle( ...@@ -2638,10 +2580,8 @@ void amf_n1::ul_nas_transport_handle(
Logger::amf_n1().error("Cannot decode Payload Container"); Logger::amf_n1().error("Cannot decode Payload Container");
return; return;
} }
// send_itti_to_smf_services_consumer(ran_ue_ngap_id, amf_ue_ngap_id, itti_nsmf_pdusession_create_sm_context* itti_msg =
// request_type, pdu_session_id, dnn, sm_msg); new itti_nsmf_pdusession_create_sm_context(TASK_AMF_N1, TASK_AMF_N11);
itti_smf_services_consumer* itti_msg =
new itti_smf_services_consumer(TASK_AMF_N1, TASK_AMF_N11);
itti_msg->ran_ue_ngap_id = ran_ue_ngap_id; itti_msg->ran_ue_ngap_id = ran_ue_ngap_id;
itti_msg->amf_ue_ngap_id = amf_ue_ngap_id; itti_msg->amf_ue_ngap_id = amf_ue_ngap_id;
itti_msg->req_type = request_type; itti_msg->req_type = request_type;
...@@ -2652,8 +2592,8 @@ void amf_n1::ul_nas_transport_handle( ...@@ -2652,8 +2592,8 @@ void amf_n1::ul_nas_transport_handle(
itti_msg->snssai.sD = std::to_string(snssai.sd); itti_msg->snssai.sD = std::to_string(snssai.sd);
itti_msg->plmn.mnc = plmn.mnc; itti_msg->plmn.mnc = plmn.mnc;
itti_msg->plmn.mcc = plmn.mcc; itti_msg->plmn.mcc = plmn.mcc;
std::shared_ptr<itti_smf_services_consumer> i = std::shared_ptr<itti_nsmf_pdusession_create_sm_context> i =
std::shared_ptr<itti_smf_services_consumer>(itti_msg); std::shared_ptr<itti_nsmf_pdusession_create_sm_context>(itti_msg);
int ret = itti_inst->send_msg(i); int ret = itti_inst->send_msg(i);
if (0 != ret) { if (0 != ret) {
Logger::amf_n1().error( Logger::amf_n1().error(
...@@ -2665,28 +2605,6 @@ void amf_n1::ul_nas_transport_handle( ...@@ -2665,28 +2605,6 @@ void amf_n1::ul_nas_transport_handle(
} }
} }
//------------------------------------------------------------------------------
void amf_n1::send_itti_to_smf_services_consumer(
uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, uint8_t request_type,
uint8_t pdu_session_id, bstring dnn, bstring sm_msg) {
itti_smf_services_consumer* itti_msg =
new itti_smf_services_consumer(TASK_AMF_N1, TASK_AMF_N11);
itti_msg->ran_ue_ngap_id = ran_ue_ngap_id;
itti_msg->amf_ue_ngap_id = amf_ue_ngap_id;
itti_msg->req_type = request_type;
itti_msg->pdu_sess_id = pdu_session_id;
itti_msg->dnn = dnn;
itti_msg->sm_msg = sm_msg;
std::shared_ptr<itti_smf_services_consumer> i =
std::shared_ptr<itti_smf_services_consumer>(itti_msg);
int ret = itti_inst->send_msg(i);
if (0 != ret) {
Logger::amf_n1().error(
"Could not send ITTI message %s to task TASK_AMF_N11",
i->get_msg_name());
}
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void amf_n1::dump_nas_message(uint8_t* buf, int len) { void amf_n1::dump_nas_message(uint8_t* buf, int len) {
for (int i = 0; i < len; i++) for (int i = 0; i < len; i++)
......
...@@ -69,8 +69,6 @@ class amf_n1 { ...@@ -69,8 +69,6 @@ class amf_n1 {
SecurityHeaderType type, std::shared_ptr<nas_context> nc, SecurityHeaderType type, std::shared_ptr<nas_context> nc,
uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, bstring plain_msg, uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, bstring plain_msg,
std::string snn, uint8_t ulCount); std::string snn, uint8_t ulCount);
void uplink_nas_msg_handle(
uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, bstring plain_msg);
void uplink_nas_msg_handle( void uplink_nas_msg_handle(
uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, bstring plain_msg, uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, bstring plain_msg,
plmn_t plmn); plmn_t plmn);
...@@ -152,9 +150,6 @@ class amf_n1 { ...@@ -152,9 +150,6 @@ class amf_n1 {
void annex_a_4_33501( void annex_a_4_33501(
uint8_t ck[16], uint8_t ik[16], uint8_t* input, uint8_t rand[16], uint8_t ck[16], uint8_t ik[16], uint8_t* input, uint8_t rand[16],
std::string serving_network, uint8_t* output); std::string serving_network, uint8_t* output);
void send_itti_to_smf_services_consumer(
uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, uint8_t request_type,
uint8_t pdu_session_id, bstring dnn, bstring sm_msg);
void set_5gmm_state(std::shared_ptr<nas_context> nc, _5gmm_state_t state); void set_5gmm_state(std::shared_ptr<nas_context> nc, _5gmm_state_t state);
void get_5gmm_state(std::shared_ptr<nas_context> nc, _5gmm_state_t& state); void get_5gmm_state(std::shared_ptr<nas_context> nc, _5gmm_state_t& state);
......
This diff is collapsed.
...@@ -45,7 +45,7 @@ class amf_n11 { ...@@ -45,7 +45,7 @@ class amf_n11 {
amf_n11(); amf_n11();
~amf_n11(); ~amf_n11();
void handle_itti_message(itti_smf_services_consumer&); void handle_itti_message(itti_nsmf_pdusession_create_sm_context&);
void handle_pdu_session_initial_request( void handle_pdu_session_initial_request(
std::string supi, std::shared_ptr<pdu_session_context> psc, std::string supi, std::shared_ptr<pdu_session_context> psc,
std::string smf_addr, std::string smf_api_version, bstring sm_msg, std::string smf_addr, std::string smf_api_version, bstring sm_msg,
...@@ -66,11 +66,12 @@ class amf_n11 { ...@@ -66,11 +66,12 @@ class amf_n11 {
void curl_http_client( void curl_http_client(
std::string remoteUri, std::string jsonData, std::string n1SmMsg, std::string remoteUri, std::string jsonData, std::string n1SmMsg,
std::string n2SmMsg, std::string supi, uint8_t pdu_session_id); std::string n2SmMsg, std::string supi, uint8_t pdu_session_id,
uint32_t promise_id = 0);
void curl_http_client( void curl_http_client(
std::string remoteUri, std::string Method, std::string msgBody, std::string remoteUri, std::string Method, std::string msgBody,
std::string& Response); std::string& response);
bool discover_smf( bool discover_smf(
std::string& smf_addr, std::string& smf_api_version, std::string& smf_addr, std::string& smf_api_version,
......
This diff is collapsed.
...@@ -58,26 +58,40 @@ class amf_n2 : public ngap::ngap_app { ...@@ -58,26 +58,40 @@ class amf_n2 : public ngap::ngap_app {
void handle_itti_message(itti_ue_radio_capability_indication& itti_msg); void handle_itti_message(itti_ue_radio_capability_indication& itti_msg);
void handle_itti_message(itti_ue_context_release_command& itti_msg); void handle_itti_message(itti_ue_context_release_command& itti_msg);
void handle_itti_message(itti_pdu_session_resource_release_command& itti_msg); void handle_itti_message(itti_pdu_session_resource_release_command& itti_msg);
void handle_itti_message(itti_handover_required& itti_msg); bool handle_itti_message(itti_handover_required& itti_msg);
void handle_itti_message(itti_handover_request_Ack& itti_msg); void handle_itti_message(itti_handover_request_Ack& itti_msg);
void handle_itti_message(itti_handover_notify& itti_msg); void handle_itti_message(itti_handover_notify& itti_msg);
void handle_itti_message(itti_uplinkranstatsutransfer& itti_msg); void handle_itti_message(itti_uplink_ran_status_transfer& itti_msg);
void send_handover_preparation_failure(
const unsigned long amf_ue_ngap_id, const uint32_t ran_ue_ngap_id,
const sctp_assoc_id_t& gnb_assoc_id);
bool verifyPlmn(std::vector<SupportedItem_t> list); bool verifyPlmn(std::vector<SupportedItem_t> list);
std::vector<SupportedItem_t> get_common_plmn( std::vector<SupportedItem_t> get_common_plmn(
std::vector<SupportedItem_t> list); std::vector<SupportedItem_t> list);
std::shared_ptr<ue_ngap_context> ran_ue_id_2_ue_ngap_context( std::shared_ptr<ue_ngap_context> ran_ue_id_2_ue_ngap_context(
const uint32_t& ran_ue_ngap_id) const; const uint32_t& ran_ue_ngap_id) const;
bool is_ran_ue_id_2_ue_ngap_context(const uint32_t& ran_ue_ngap_id) const; bool is_ran_ue_id_2_ue_ngap_context(const uint32_t& ran_ue_ngap_id) const;
void set_ran_ue_ngap_id_2_ue_ngap_context( void set_ran_ue_ngap_id_2_ue_ngap_context(
const uint32_t& ran_ue_ngap_id, std::shared_ptr<ue_ngap_context> unc); const uint32_t& ran_ue_ngap_id, std::shared_ptr<ue_ngap_context> unc);
std::shared_ptr<ue_ngap_context> amf_ue_id_2_ue_ngap_context(
const unsigned long& amf_ue_ngap_id) const;
bool is_amf_ue_id_2_ue_ngap_context(
const unsigned long& amf_ue_ngap_id) const;
void set_amf_ue_ngap_id_2_ue_ngap_context(
const unsigned long& amf_ue_ngap_id,
std::shared_ptr<ue_ngap_context> unc);
private: private:
std::map<uint32_t, std::shared_ptr<ue_ngap_context>> std::map<uint32_t, std::shared_ptr<ue_ngap_context>>
ranid2uecontext; // ran ue ngap id ranid2uecontext; // ran ue ngap id
mutable std::shared_mutex m_ranid2uecontext; mutable std::shared_mutex m_ranid2uecontext;
std::map<unsigned long, std::shared_ptr<ue_ngap_context>>
amfueid2uecontext; // amf ue id
mutable std::shared_mutex m_amfueid2uecontext;
}; };
} // namespace amf_application } // namespace amf_application
......
...@@ -103,8 +103,11 @@ constexpr auto CURL_MIME_BOUNDARY = "----Boundary"; ...@@ -103,8 +103,11 @@ constexpr auto CURL_MIME_BOUNDARY = "----Boundary";
#define AUSF_CURL_TIMEOUT_MS 100L #define AUSF_CURL_TIMEOUT_MS 100L
#define CURL_TIMEOUT_MS 100L #define CURL_TIMEOUT_MS 100L
#define BUFFER_SIZE_2048 2048
#define BUFFER_SIZE_1024 1024 #define BUFFER_SIZE_1024 1024
#define BUFFER_SIZE_512 512 #define BUFFER_SIZE_512 512
#define BUFFER_SIZE_256 256 #define BUFFER_SIZE_256 256
#define FUTURE_STATUS_TIMEOUT_MS 100
#endif #endif
...@@ -46,19 +46,22 @@ typedef enum { ...@@ -46,19 +46,22 @@ typedef enum {
class ue_ngap_context { class ue_ngap_context {
public: public:
uint32_t ran_ue_ngap_id; // 32bits uint32_t ran_ue_ngap_id; // 32bits
long amf_ue_ngap_id : 40; // 40bits long amf_ue_ngap_id : 40; // 40bits
uint32_t target_ran_ue_ngap_id; // 32bits, for HO
sctp_stream_id_t sctp_stream_recv; // used to decide which ue in gNB sctp_stream_id_t sctp_stream_recv; // used to decide which ue in gNB
sctp_stream_id_t sctp_stream_send; // used to decide which ue in gNB sctp_stream_id_t sctp_stream_send; // used to decide which ue in gNB
sctp_assoc_id_t gnb_assoc_id; // to find which gnb this UE belongs to sctp_assoc_id_t gnb_assoc_id; // to find which gnb this UE belongs to
sctp_assoc_id_t target_gnb_assoc_id;
bool ueContextRequest; bool ueContextRequest;
uint32_t s_tmsi_5g; uint32_t s_tmsi_5g;
// state management, ue status over the air // state management, ue status over the air
ng_ue_state_t ng_ue_state; ng_ue_state_t ng_ue_state;
uint8_t ncc; // Next Hop Chaining Counter
}; };
#endif #endif
...@@ -77,7 +77,7 @@ typedef enum { ...@@ -77,7 +77,7 @@ typedef enum {
DOWNLINK_NAS_TRANSFER, DOWNLINK_NAS_TRANSFER,
NAS_SIG_ESTAB_REQ, // task amf_app NAS_SIG_ESTAB_REQ, // task amf_app
N1N2_MESSAGE_TRANSFER_REQ, N1N2_MESSAGE_TRANSFER_REQ,
SMF_SERVICES_CONSUMER, NSMF_PDU_SESSION_CREATE_SM_CTX,
NSMF_PDU_SESSION_UPDATE_SM_CTX, NSMF_PDU_SESSION_UPDATE_SM_CTX,
N11_REGISTER_NF_INSTANCE_REQUEST, N11_REGISTER_NF_INSTANCE_REQUEST,
N11_REGISTER_NF_INSTANCE_RESPONSE, N11_REGISTER_NF_INSTANCE_RESPONSE,
...@@ -85,12 +85,12 @@ typedef enum { ...@@ -85,12 +85,12 @@ typedef enum {
N11_UPDATE_NF_INSTANCE_RESPONSE, N11_UPDATE_NF_INSTANCE_RESPONSE,
N11_DEREGISTER_NF_INSTANCE, N11_DEREGISTER_NF_INSTANCE,
UE_CONTEXT_RELEASE_COMMAND, UE_CONTEXT_RELEASE_COMMAND,
NSMF_PDU_SESS_RELEASE_SMCTX, NSMF_PDU_SESSION_RELEASE_SM_CTX,
HANDOVER_REQUIRED, HANDOVER_REQUIRED,
HANDOVER_REQUEST_ACK, HANDOVER_REQUEST_ACK,
HANDOVER_NOTIFY, HANDOVER_NOTIFY,
UPLINKRANSTATUSTRANSFER, UPLINK_RAN_STATUS_TRANSFER,
PDU_SESS_RES_SET_RESP, PDU_SESSION_RESOURCE_SETUP_RESPONSE,
TIME_OUT, TIME_OUT,
HEALTH_PING, HEALTH_PING,
TERMINATE, TERMINATE,
......
...@@ -45,12 +45,13 @@ class itti_msg_n11 : public itti_msg { ...@@ -45,12 +45,13 @@ class itti_msg_n11 : public itti_msg {
uint32_t ran_ue_ngap_id; uint32_t ran_ue_ngap_id;
}; };
class itti_smf_services_consumer : public itti_msg_n11 { class itti_nsmf_pdusession_create_sm_context : public itti_msg_n11 {
public: public:
itti_smf_services_consumer( itti_nsmf_pdusession_create_sm_context(
const task_id_t origin, const task_id_t destination) const task_id_t origin, const task_id_t destination)
: itti_msg_n11(SMF_SERVICES_CONSUMER, origin, destination) {} : itti_msg_n11(NSMF_PDU_SESSION_CREATE_SM_CTX, origin, destination) {}
itti_smf_services_consumer(const itti_smf_services_consumer& i) itti_nsmf_pdusession_create_sm_context(
const itti_nsmf_pdusession_create_sm_context& i)
: itti_msg_n11(i) {} : itti_msg_n11(i) {}
public: public:
...@@ -66,7 +67,8 @@ class itti_pdu_session_resource_setup_response : public itti_msg_n11 { ...@@ -66,7 +67,8 @@ class itti_pdu_session_resource_setup_response : public itti_msg_n11 {
public: public:
itti_pdu_session_resource_setup_response( itti_pdu_session_resource_setup_response(
const task_id_t origin, const task_id_t destination) const task_id_t origin, const task_id_t destination)
: itti_msg_n11(PDU_SESS_RES_SET_RESP, origin, destination) {} : itti_msg_n11(PDU_SESSION_RESOURCE_SETUP_RESPONSE, origin, destination) {
}
itti_pdu_session_resource_setup_response( itti_pdu_session_resource_setup_response(
const itti_pdu_session_resource_setup_response& i) const itti_pdu_session_resource_setup_response& i)
: itti_msg_n11(i) {} : itti_msg_n11(i) {}
...@@ -82,6 +84,7 @@ class itti_nsmf_pdusession_update_sm_context : public itti_msg_n11 { ...@@ -82,6 +84,7 @@ class itti_nsmf_pdusession_update_sm_context : public itti_msg_n11 {
const task_id_t origin, const task_id_t destination) const task_id_t origin, const task_id_t destination)
: itti_msg_n11(NSMF_PDU_SESSION_UPDATE_SM_CTX, origin, destination) { : itti_msg_n11(NSMF_PDU_SESSION_UPDATE_SM_CTX, origin, destination) {
is_n2sm_set = false; is_n2sm_set = false;
promise_id = 0;
} }
itti_nsmf_pdusession_update_sm_context( itti_nsmf_pdusession_update_sm_context(
const itti_nsmf_pdusession_update_sm_context& i) const itti_nsmf_pdusession_update_sm_context& i)
...@@ -90,6 +93,8 @@ class itti_nsmf_pdusession_update_sm_context : public itti_msg_n11 { ...@@ -90,6 +93,8 @@ class itti_nsmf_pdusession_update_sm_context : public itti_msg_n11 {
n2sm = i.n2sm; n2sm = i.n2sm;
is_n2sm_set = i.is_n2sm_set; is_n2sm_set = i.is_n2sm_set;
n2sm_info_type = i.n2sm_info_type; n2sm_info_type = i.n2sm_info_type;
promise_id = i.promise_id;
;
} }
public: public:
...@@ -100,13 +105,14 @@ class itti_nsmf_pdusession_update_sm_context : public itti_msg_n11 { ...@@ -100,13 +105,14 @@ class itti_nsmf_pdusession_update_sm_context : public itti_msg_n11 {
std::string n2sm_info_type; std::string n2sm_info_type;
uint32_t ran_ue_ngap_id; uint32_t ran_ue_ngap_id;
long amf_ue_ngap_id; long amf_ue_ngap_id;
uint32_t promise_id;
}; };
class itti_nsmf_pdusession_release_sm_context : public itti_msg_n11 { class itti_nsmf_pdusession_release_sm_context : public itti_msg_n11 {
public: public:
itti_nsmf_pdusession_release_sm_context( itti_nsmf_pdusession_release_sm_context(
const task_id_t origin, const task_id_t destination) const task_id_t origin, const task_id_t destination)
: itti_msg_n11(NSMF_PDU_SESS_RELEASE_SMCTX, origin, destination) {} : itti_msg_n11(NSMF_PDU_SESSION_RELEASE_SM_CTX, origin, destination) {}
itti_nsmf_pdusession_release_sm_context( itti_nsmf_pdusession_release_sm_context(
const itti_nsmf_pdusession_update_sm_context& i) const itti_nsmf_pdusession_update_sm_context& i)
: itti_msg_n11(i) {} : itti_msg_n11(i) {}
......
...@@ -218,7 +218,7 @@ class itti_handover_required : public itti_msg_n2 { ...@@ -218,7 +218,7 @@ class itti_handover_required : public itti_msg_n2 {
itti_handover_required(const task_id_t origin, const task_id_t destination) itti_handover_required(const task_id_t origin, const task_id_t destination)
: itti_msg_n2(HANDOVER_REQUIRED, origin, destination) {} : itti_msg_n2(HANDOVER_REQUIRED, origin, destination) {}
itti_handover_required(const itti_handover_required& i) : itti_msg_n2(i) {} itti_handover_required(const itti_handover_required& i) : itti_msg_n2(i) {}
HandoverRequiredMsg* handvoerRequ; HandoverRequiredMsg* handoverReq;
}; };
class itti_handover_request_Ack : public itti_msg_n2 { class itti_handover_request_Ack : public itti_msg_n2 {
...@@ -238,12 +238,12 @@ class itti_handover_notify : public itti_msg_n2 { ...@@ -238,12 +238,12 @@ class itti_handover_notify : public itti_msg_n2 {
HandoverNotifyMsg* handovernotify; HandoverNotifyMsg* handovernotify;
}; };
class itti_uplinkranstatsutransfer : public itti_msg_n2 { class itti_uplink_ran_status_transfer : public itti_msg_n2 {
public: public:
itti_uplinkranstatsutransfer( itti_uplink_ran_status_transfer(
const task_id_t origin, const task_id_t destination) const task_id_t origin, const task_id_t destination)
: itti_msg_n2(UPLINKRANSTATUSTRANSFER, origin, destination) {} : itti_msg_n2(UPLINK_RAN_STATUS_TRANSFER, origin, destination) {}
itti_uplinkranstatsutransfer(const itti_uplinkranstatsutransfer& i) itti_uplink_ran_status_transfer(const itti_uplink_ran_status_transfer& i)
: itti_msg_n2(i) {} : itti_msg_n2(i) {}
UplinkRANStatusTransfer* uplinkrantransfer; UplinkRANStatusTransfer* uplinkrantransfer;
}; };
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
*/ */
#include "DownLinkNasTransport.hpp" #include "DownLinkNasTransport.hpp"
#include "logger.hpp"
extern "C" { extern "C" {
#include "asn_codecs.h" #include "asn_codecs.h"
...@@ -83,9 +84,8 @@ void DownLinkNasTransportMsg::setMessageType() { ...@@ -83,9 +84,8 @@ void DownLinkNasTransportMsg::setMessageType() {
&(downLinkNasTransportPdu->choice.initiatingMessage->value.choice &(downLinkNasTransportPdu->choice.initiatingMessage->value.choice
.DownlinkNASTransport); .DownlinkNASTransport);
} else { } else {
cout << "[warning] This information doesn't refer to DownlinkNASTransport " Logger::ngap().warn(
"Message!!!" "This information doesn't refer to DownlinkNASTransport Message");
<< endl;
} }
} }
...@@ -103,13 +103,13 @@ void DownLinkNasTransportMsg::setAmfUeNgapId(unsigned long id) { ...@@ -103,13 +103,13 @@ void DownLinkNasTransportMsg::setAmfUeNgapId(unsigned long id) {
int ret = amfUeNgapId->encode2AMF_UE_NGAP_ID(ie->value.choice.AMF_UE_NGAP_ID); int ret = amfUeNgapId->encode2AMF_UE_NGAP_ID(ie->value.choice.AMF_UE_NGAP_ID);
if (!ret) { if (!ret) {
cout << "encode AMF_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Encode AMF_UE_NGAP_ID IE error");
free_wrapper((void**) &ie); free_wrapper((void**) &ie);
return; return;
} }
ret = ASN_SEQUENCE_ADD(&downLinkNasTransportIEs->protocolIEs.list, ie); ret = ASN_SEQUENCE_ADD(&downLinkNasTransportIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode AMF_UE_NGAP_ID IE error" << endl; if (ret != 0) Logger::ngap().error("Encode AMF_UE_NGAP_ID IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
...@@ -127,13 +127,13 @@ void DownLinkNasTransportMsg::setRanUeNgapId(uint32_t ran_ue_ngap_id) { ...@@ -127,13 +127,13 @@ void DownLinkNasTransportMsg::setRanUeNgapId(uint32_t ran_ue_ngap_id) {
int ret = ranUeNgapId->encode2RAN_UE_NGAP_ID(ie->value.choice.RAN_UE_NGAP_ID); int ret = ranUeNgapId->encode2RAN_UE_NGAP_ID(ie->value.choice.RAN_UE_NGAP_ID);
if (!ret) { if (!ret) {
cout << "encode RAN_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Encode RAN_UE_NGAP_ID IE error");
free_wrapper((void**) &ie); free_wrapper((void**) &ie);
return; return;
} }
ret = ASN_SEQUENCE_ADD(&downLinkNasTransportIEs->protocolIEs.list, ie); ret = ASN_SEQUENCE_ADD(&downLinkNasTransportIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode RAN_UE_NGAP_ID IE error" << endl; if (ret != 0) Logger::ngap().error("Encode RAN_UE_NGAP_ID IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
...@@ -151,13 +151,13 @@ void DownLinkNasTransportMsg::setOldAmfName(const std::string name) { ...@@ -151,13 +151,13 @@ void DownLinkNasTransportMsg::setOldAmfName(const std::string name) {
int ret = oldAmfName->encode2AmfName(&ie->value.choice.AMFName); int ret = oldAmfName->encode2AmfName(&ie->value.choice.AMFName);
if (!ret) { if (!ret) {
cout << "encode oldAmfName IE error" << endl; Logger::ngap().error("Encode oldAmfName IE error");
free_wrapper((void**) &ie); free_wrapper((void**) &ie);
return; return;
} }
ret = ASN_SEQUENCE_ADD(&downLinkNasTransportIEs->protocolIEs.list, ie); ret = ASN_SEQUENCE_ADD(&downLinkNasTransportIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode oldAmfName IE error" << endl; if (ret != 0) Logger::ngap().error("Encode oldAmfName IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
...@@ -176,7 +176,7 @@ void DownLinkNasTransportMsg::setRanPagingPriority(uint8_t pagingPriority) { ...@@ -176,7 +176,7 @@ void DownLinkNasTransportMsg::setRanPagingPriority(uint8_t pagingPriority) {
int ret = ranPagingPriority->encode2RANPagingPriority( int ret = ranPagingPriority->encode2RANPagingPriority(
ie->value.choice.RANPagingPriority); ie->value.choice.RANPagingPriority);
if (!ret) { if (!ret) {
cout << "encode RANPagingPriority IE error" << endl; Logger::ngap().error("Encode RANPagingPriority IE error");
free_wrapper((void**) &ie); free_wrapper((void**) &ie);
return; return;
} }
...@@ -201,13 +201,13 @@ void DownLinkNasTransportMsg::setNasPdu(uint8_t* nas, size_t sizeofnas) { ...@@ -201,13 +201,13 @@ void DownLinkNasTransportMsg::setNasPdu(uint8_t* nas, size_t sizeofnas) {
int ret = nasPdu->encode2octetstring(ie->value.choice.NAS_PDU); int ret = nasPdu->encode2octetstring(ie->value.choice.NAS_PDU);
if (!ret) { if (!ret) {
cout << "encode NAS_PDU IE error" << endl; Logger::ngap().error("Encode NAS_PDU IE error");
free_wrapper((void**) &ie); free_wrapper((void**) &ie);
return; return;
} }
ret = ASN_SEQUENCE_ADD(&downLinkNasTransportIEs->protocolIEs.list, ie); ret = ASN_SEQUENCE_ADD(&downLinkNasTransportIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode NAS_PDU IE error" << endl; if (ret != 0) Logger::ngap().error("Encode NAS_PDU IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
...@@ -226,13 +226,13 @@ void DownLinkNasTransportMsg::setIndex2Rat_Frequency_SelectionPriority( ...@@ -226,13 +226,13 @@ void DownLinkNasTransportMsg::setIndex2Rat_Frequency_SelectionPriority(
int ret = indexToRFSP->encode2IndexToRFSP(ie->value.choice.IndexToRFSP); int ret = indexToRFSP->encode2IndexToRFSP(ie->value.choice.IndexToRFSP);
if (!ret) { if (!ret) {
cout << "encode IndexToRFSP IE error" << endl; Logger::ngap().error("Encode IndexToRFSP IE error");
free_wrapper((void**) &ie); free_wrapper((void**) &ie);
return; return;
} }
ret = ASN_SEQUENCE_ADD(&downLinkNasTransportIEs->protocolIEs.list, ie); ret = ASN_SEQUENCE_ADD(&downLinkNasTransportIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode IndexToRFSP IE error" << endl; if (ret != 0) Logger::ngap().error("Encode IndexToRFSP IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
*/ */
#include "HandoverCommandMsg.hpp" #include "HandoverCommandMsg.hpp"
#include "logger.hpp"
extern "C" { extern "C" {
#include "Ngap_NGAP-PDU.h" #include "Ngap_NGAP-PDU.h"
#include "Ngap_PDUSessionResourceHandoverItem.h" #include "Ngap_PDUSessionResourceHandoverItem.h"
...@@ -53,14 +55,15 @@ HandoverCommandMsg::HandoverCommandMsg() { ...@@ -53,14 +55,15 @@ HandoverCommandMsg::HandoverCommandMsg() {
HandoverCommandMsg::~HandoverCommandMsg() {} HandoverCommandMsg::~HandoverCommandMsg() {}
unsigned long HandoverCommandMsg::getAmfUeNgapId() { unsigned long HandoverCommandMsg::getAmfUeNgapId() {
return amfUeNgapId->getAMF_UE_NGAP_ID(); if (amfUeNgapId) return amfUeNgapId->getAMF_UE_NGAP_ID();
} }
uint32_t HandoverCommandMsg::getRanUeNgapId() { uint32_t HandoverCommandMsg::getRanUeNgapId() {
return ranUeNgapId->getRanUeNgapId(); if (ranUeNgapId) return ranUeNgapId->getRanUeNgapId();
} }
bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!ngap_msg_pdu) return false;
handoverCommandPdu = ngap_msg_pdu; handoverCommandPdu = ngap_msg_pdu;
if (handoverCommandPdu->present == Ngap_NGAP_PDU_PR_successfulOutcome) { if (handoverCommandPdu->present == Ngap_NGAP_PDU_PR_successfulOutcome) {
...@@ -74,11 +77,11 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -74,11 +77,11 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
handoverCommandIEs = &handoverCommandPdu->choice.successfulOutcome->value handoverCommandIEs = &handoverCommandPdu->choice.successfulOutcome->value
.choice.HandoverCommand; .choice.HandoverCommand;
} else { } else {
cout << "Check HandoverCommand message error!!!" << endl; Logger::ngap().error("Check HandoverCommand message error");
return false; return false;
} }
} else { } else {
cout << "HandoverRequired MessageType error!!!" << endl; Logger::ngap().error("HandoverRequired MessageType error");
return false; return false;
} }
for (int i = 0; i < handoverCommandIEs->protocolIEs.list.count; i++) { for (int i = 0; i < handoverCommandIEs->protocolIEs.list.count; i++) {
...@@ -92,11 +95,11 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -92,11 +95,11 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!amfUeNgapId->decodefromAMF_UE_NGAP_ID( if (!amfUeNgapId->decodefromAMF_UE_NGAP_ID(
handoverCommandIEs->protocolIEs.list.array[i] handoverCommandIEs->protocolIEs.list.array[i]
->value.choice.AMF_UE_NGAP_ID)) { ->value.choice.AMF_UE_NGAP_ID)) {
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Decoded ngap AMF_UE_NGAP_ID IE error");
return false; return false;
} }
} else { } else {
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Decoded ngap AMF_UE_NGAP_ID IE error");
return false; return false;
} }
} break; } break;
...@@ -109,11 +112,11 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -109,11 +112,11 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!ranUeNgapId->decodefromRAN_UE_NGAP_ID( if (!ranUeNgapId->decodefromRAN_UE_NGAP_ID(
handoverCommandIEs->protocolIEs.list.array[i] handoverCommandIEs->protocolIEs.list.array[i]
->value.choice.RAN_UE_NGAP_ID)) { ->value.choice.RAN_UE_NGAP_ID)) {
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Decoded ngap RAN_UE_NGAP_ID IE error");
return false; return false;
} }
} else { } else {
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Decoded ngap RAN_UE_NGAP_ID IE error");
return false; return false;
} }
} break; } break;
...@@ -126,7 +129,7 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -126,7 +129,7 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
*ngap_handovertype = handoverCommandIEs->protocolIEs.list.array[i] *ngap_handovertype = handoverCommandIEs->protocolIEs.list.array[i]
->value.choice.HandoverType; ->value.choice.HandoverType;
} else { } else {
cout << "decoded ngap Handover Type IE error" << endl; Logger::ngap().error("Decoded ngap Handover Type IE error");
return false; return false;
} }
} break; } break;
...@@ -136,8 +139,8 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -136,8 +139,8 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
handoverCommandIEs->protocolIEs.list.array[i]->value.present == handoverCommandIEs->protocolIEs.list.array[i]->value.present ==
Ngap_HandoverCommandIEs__value_PR_PDUSessionResourceHandoverList) { Ngap_HandoverCommandIEs__value_PR_PDUSessionResourceHandoverList) {
} else { } else {
cout << "decoded ngap PDUSessionResourceHandoverList IE error" Logger::ngap().error(
<< endl; "Decoded ngap PDUSessionResourceHandoverList IE error");
return false; return false;
} }
} break; } break;
...@@ -147,8 +150,8 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -147,8 +150,8 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
handoverCommandIEs->protocolIEs.list.array[i]->value.present == handoverCommandIEs->protocolIEs.list.array[i]->value.present ==
Ngap_HandoverCommandIEs__value_PR_PDUSessionResourceToReleaseListHOCmd) { Ngap_HandoverCommandIEs__value_PR_PDUSessionResourceToReleaseListHOCmd) {
} else { } else {
cout << "decoded ngap PDUSessionResourceToReleaseListHOCmd IE error" Logger::ngap().error(
<< endl; "Decoded ngap PDUSessionResourceToReleaseListHOCmd IE error");
return false; return false;
} }
} break; } break;
...@@ -158,8 +161,8 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -158,8 +161,8 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
handoverCommandIEs->protocolIEs.list.array[i]->value.present == handoverCommandIEs->protocolIEs.list.array[i]->value.present ==
Ngap_HandoverCommandIEs__value_PR_TargetToSource_TransparentContainer) { Ngap_HandoverCommandIEs__value_PR_TargetToSource_TransparentContainer) {
} else { } else {
cout << "decoded ngap TargetToSource_TransparentContainer IE error" Logger::ngap().error(
<< endl; "Decoded ngap TargetToSource_TransparentContainer IE error");
return false; return false;
} }
} break; } break;
...@@ -169,12 +172,12 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -169,12 +172,12 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
handoverCommandIEs->protocolIEs.list.array[i]->value.present == handoverCommandIEs->protocolIEs.list.array[i]->value.present ==
Ngap_HandoverCommandIEs__value_PR_CriticalityDiagnostics) { Ngap_HandoverCommandIEs__value_PR_CriticalityDiagnostics) {
} else { } else {
cout << "decoded ngap CriticalityDiagnostics IE error" << endl; Logger::ngap().error("Decoded ngap CriticalityDiagnostics IE error");
return false; return false;
} }
} break; } break;
default: { default: {
cout << "decoded ngap message pdu error" << endl; Logger::ngap().error("Decoded NGAP message PDU error");
return false; return false;
} }
} }
...@@ -212,9 +215,8 @@ void HandoverCommandMsg::setMessageType() { ...@@ -212,9 +215,8 @@ void HandoverCommandMsg::setMessageType() {
handoverCommandIEs = &(handoverCommandPdu->choice.successfulOutcome->value handoverCommandIEs = &(handoverCommandPdu->choice.successfulOutcome->value
.choice.HandoverCommand); .choice.HandoverCommand);
} else { } else {
cout << "[warning] This information doesn't refer to HandoverCommand " Logger::ngap().warn(
"Message!!!" "This information doesn't refer to HandoverCommand message");
<< endl;
} }
} }
...@@ -230,13 +232,13 @@ void HandoverCommandMsg::setAmfUeNgapId(unsigned long id) { ...@@ -230,13 +232,13 @@ void HandoverCommandMsg::setAmfUeNgapId(unsigned long id) {
int ret = amfUeNgapId->encode2AMF_UE_NGAP_ID(ie->value.choice.AMF_UE_NGAP_ID); int ret = amfUeNgapId->encode2AMF_UE_NGAP_ID(ie->value.choice.AMF_UE_NGAP_ID);
if (!ret) { if (!ret) {
cout << "encode AMF_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Encode AMF_UE_NGAP_ID IE error");
free_wrapper((void**) &ie); free_wrapper((void**) &ie);
return; return;
} }
ret = ASN_SEQUENCE_ADD(&handoverCommandIEs->protocolIEs.list, ie); ret = ASN_SEQUENCE_ADD(&handoverCommandIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode AMF_UE_NGAP_ID IE error" << endl; if (ret != 0) Logger::ngap().error("Encode AMF_UE_NGAP_ID IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
...@@ -252,13 +254,14 @@ void HandoverCommandMsg::setRanUeNgapId(uint32_t ran_ue_ngap_id) { ...@@ -252,13 +254,14 @@ void HandoverCommandMsg::setRanUeNgapId(uint32_t ran_ue_ngap_id) {
int ret = ranUeNgapId->encode2RAN_UE_NGAP_ID(ie->value.choice.RAN_UE_NGAP_ID); int ret = ranUeNgapId->encode2RAN_UE_NGAP_ID(ie->value.choice.RAN_UE_NGAP_ID);
if (!ret) { if (!ret) {
cout << "encode RAN_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Encode RAN_UE_NGAP_ID IE error");
free_wrapper((void**) &ie); free_wrapper((void**) &ie);
return; return;
} }
ret = ASN_SEQUENCE_ADD(&handoverCommandIEs->protocolIEs.list, ie); ret = ASN_SEQUENCE_ADD(&handoverCommandIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode RAN_UE_NGAP_ID IE error" << endl; if (ret != 0) Logger::ngap().error("Encode RAN_UE_NGAP_ID IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
...@@ -271,7 +274,8 @@ void HandoverCommandMsg::setHandoverType(long type) { ...@@ -271,7 +274,8 @@ void HandoverCommandMsg::setHandoverType(long type) {
ie->value.present = Ngap_HandoverCommandIEs__value_PR_HandoverType; ie->value.present = Ngap_HandoverCommandIEs__value_PR_HandoverType;
ie->value.choice.HandoverType = type; ie->value.choice.HandoverType = type;
int ret = ASN_SEQUENCE_ADD(&handoverCommandIEs->protocolIEs.list, ie); int ret = ASN_SEQUENCE_ADD(&handoverCommandIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode HandoverType IE error" << endl;
if (ret != 0) Logger::ngap().error("Encode HandoverType IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
...@@ -290,8 +294,10 @@ void HandoverCommandMsg::setPduSessionResourceHandoverList( ...@@ -290,8 +294,10 @@ void HandoverCommandMsg::setPduSessionResourceHandoverList(
item->pDUSessionID = list[i].pduSessionId; item->pDUSessionID = list[i].pduSessionId;
item->handoverCommandTransfer = list[i].HandoverCommandTransfer; item->handoverCommandTransfer = list[i].HandoverCommandTransfer;
int ret = ASN_SEQUENCE_ADD(&PDUSessionResourceHandoverList->list, item); int ret = ASN_SEQUENCE_ADD(&PDUSessionResourceHandoverList->list, item);
if (ret != 0) if (ret != 0)
cout << "encode PDUSessionResourceHandoverListItem IE error" << endl; Logger::ngap().error(
"Encode PDUSessionResourceHandoverListItem IE error");
} }
ie->id = Ngap_ProtocolIE_ID_id_PDUSessionResourceHandoverList; ie->id = Ngap_ProtocolIE_ID_id_PDUSessionResourceHandoverList;
...@@ -302,7 +308,8 @@ void HandoverCommandMsg::setPduSessionResourceHandoverList( ...@@ -302,7 +308,8 @@ void HandoverCommandMsg::setPduSessionResourceHandoverList(
*PDUSessionResourceHandoverList; *PDUSessionResourceHandoverList;
int ret = ASN_SEQUENCE_ADD(&handoverCommandIEs->protocolIEs.list, ie); int ret = ASN_SEQUENCE_ADD(&handoverCommandIEs->protocolIEs.list, ie);
if (ret != 0) if (ret != 0)
cout << "encode PDUSessionResourceHandoverList IE error" << endl; Logger::ngap().error("Encode PDUSessionResourceHandoverList IE error");
// free_wrapper((void**) &item); // free_wrapper((void**) &item);
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
...@@ -321,7 +328,7 @@ void HandoverCommandMsg::setTargetToSource_TransparentContainer( ...@@ -321,7 +328,7 @@ void HandoverCommandMsg::setTargetToSource_TransparentContainer(
Ngap_HandoverCommandIEs__value_PR_TargetToSource_TransparentContainer; Ngap_HandoverCommandIEs__value_PR_TargetToSource_TransparentContainer;
ie->value.choice.TargetToSource_TransparentContainer = targetTosource; ie->value.choice.TargetToSource_TransparentContainer = targetTosource;
int ret = ASN_SEQUENCE_ADD(&handoverCommandIEs->protocolIEs.list, ie); int ret = ASN_SEQUENCE_ADD(&handoverCommandIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode HandoverType IE error" << endl; if (ret != 0) Logger::ngap().error("Encode HandoverType IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
......
...@@ -60,8 +60,8 @@ class HandoverCommandMsg { ...@@ -60,8 +60,8 @@ class HandoverCommandMsg {
int encode2buffer(uint8_t* buf, int buf_size); int encode2buffer(uint8_t* buf, int buf_size);
bool decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu); bool decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu);
unsigned long getAmfUeNgapId(); // return -1;(不存在) unsigned long getAmfUeNgapId(); // return -1;
uint32_t getRanUeNgapId(); // return -1;(不存在) uint32_t getRanUeNgapId(); // return -1;
/*void getHandoverType(Ngap_HandoverType_t &handovertype); /*void getHandoverType(Ngap_HandoverType_t &handovertype);
void getCause(Cause cause); void getCause(Cause cause);
void getTargetID(Ngap_TargetID_t targetID); void getTargetID(Ngap_TargetID_t targetID);
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
\email: contact@openairinterface.org \email: contact@openairinterface.org
*/ */
#include "HandoverNotifyMsg.hpp" #include "HandoverNotifyMsg.hpp"
#include "logger.hpp"
extern "C" { extern "C" {
#include "asn_codecs.h" #include "asn_codecs.h"
...@@ -51,8 +52,12 @@ HandoverNotifyMsg::HandoverNotifyMsg() { ...@@ -51,8 +52,12 @@ HandoverNotifyMsg::HandoverNotifyMsg() {
HandoverNotifyMsg::~HandoverNotifyMsg(){}; HandoverNotifyMsg::~HandoverNotifyMsg(){};
unsigned long HandoverNotifyMsg::getAmfUeNgapId() { unsigned long HandoverNotifyMsg::getAmfUeNgapId() {
return amfUeNgapId->getAMF_UE_NGAP_ID(); if (amfUeNgapId)
return amfUeNgapId->getAMF_UE_NGAP_ID();
else
return 0;
} }
int HandoverNotifyMsg::encode2buffer(uint8_t* buf, int buf_size) { int HandoverNotifyMsg::encode2buffer(uint8_t* buf, int buf_size) {
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, handoverNotifyPdu); asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, handoverNotifyPdu);
asn_enc_rval_t er = aper_encode_to_buffer( asn_enc_rval_t er = aper_encode_to_buffer(
...@@ -60,7 +65,9 @@ int HandoverNotifyMsg::encode2buffer(uint8_t* buf, int buf_size) { ...@@ -60,7 +65,9 @@ int HandoverNotifyMsg::encode2buffer(uint8_t* buf, int buf_size) {
cout << "er.encoded(" << er.encoded << ")" << endl; cout << "er.encoded(" << er.encoded << ")" << endl;
return er.encoded; return er.encoded;
} }
bool HandoverNotifyMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { bool HandoverNotifyMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!ngap_msg_pdu) return false;
handoverNotifyPdu = ngap_msg_pdu; handoverNotifyPdu = ngap_msg_pdu;
if (handoverNotifyPdu->present == Ngap_NGAP_PDU_PR_initiatingMessage) { if (handoverNotifyPdu->present == Ngap_NGAP_PDU_PR_initiatingMessage) {
...@@ -74,11 +81,11 @@ bool HandoverNotifyMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -74,11 +81,11 @@ bool HandoverNotifyMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
handoverNotifyIEs = &handoverNotifyPdu->choice.initiatingMessage->value handoverNotifyIEs = &handoverNotifyPdu->choice.initiatingMessage->value
.choice.HandoverNotify; .choice.HandoverNotify;
} else { } else {
cout << "Check HandoverNotify message error!!!" << endl; Logger::ngap().error("Check HandoverNotify message error!");
return false; return false;
} }
} else { } else {
cout << "HandoverNotify MessageType error!!!" << endl; Logger::ngap().error("HandoverNotify MessageType error!");
return false; return false;
} }
for (int i = 0; i < handoverNotifyIEs->protocolIEs.list.count; i++) { for (int i = 0; i < handoverNotifyIEs->protocolIEs.list.count; i++) {
...@@ -92,11 +99,11 @@ bool HandoverNotifyMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -92,11 +99,11 @@ bool HandoverNotifyMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!amfUeNgapId->decodefromAMF_UE_NGAP_ID( if (!amfUeNgapId->decodefromAMF_UE_NGAP_ID(
handoverNotifyIEs->protocolIEs.list.array[i] handoverNotifyIEs->protocolIEs.list.array[i]
->value.choice.AMF_UE_NGAP_ID)) { ->value.choice.AMF_UE_NGAP_ID)) {
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Decoded ngap AMF_UE_NGAP_ID IE error");
return false; return false;
} }
} else { } else {
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Decoded ngap AMF_UE_NGAP_ID IE error");
return false; return false;
} }
} break; } break;
...@@ -109,11 +116,11 @@ bool HandoverNotifyMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -109,11 +116,11 @@ bool HandoverNotifyMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!ranUeNgapId->decodefromRAN_UE_NGAP_ID( if (!ranUeNgapId->decodefromRAN_UE_NGAP_ID(
handoverNotifyIEs->protocolIEs.list.array[i] handoverNotifyIEs->protocolIEs.list.array[i]
->value.choice.RAN_UE_NGAP_ID)) { ->value.choice.RAN_UE_NGAP_ID)) {
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Decoded ngap RAN_UE_NGAP_ID IE error");
return false; return false;
} }
} else { } else {
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Decoded ngap RAN_UE_NGAP_ID IE error");
return false; return false;
} }
} break; } break;
...@@ -126,16 +133,17 @@ bool HandoverNotifyMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -126,16 +133,17 @@ bool HandoverNotifyMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!userLocationInformation->decodefromUserLocationInformation( if (!userLocationInformation->decodefromUserLocationInformation(
&handoverNotifyIEs->protocolIEs.list.array[i] &handoverNotifyIEs->protocolIEs.list.array[i]
->value.choice.UserLocationInformation)) { ->value.choice.UserLocationInformation)) {
cout << "decoded ngap UserLocationInformation IE error" << endl; Logger::ngap().error(
"Decoded ngap UserLocationInformation IE error");
return false; return false;
} }
} else { } else {
cout << "decoded ngap UserLocationInformation IE error" << endl; Logger::ngap().error("Decoded ngap UserLocationInformation IE error");
return false; return false;
} }
} break; } break;
default: { default: {
cout << "decoded ngap message pdu error" << endl; Logger::ngap().error("Decoded NGAP message PDU error");
return false; return false;
} }
} }
...@@ -175,20 +183,28 @@ void HandoverNotifyMsg::setUserLocationInfoNR( ...@@ -175,20 +183,28 @@ void HandoverNotifyMsg::setUserLocationInfoNR(
int ret = userLocationInformation->encodefromUserLocationInformation( int ret = userLocationInformation->encodefromUserLocationInformation(
&ie->value.choice.UserLocationInformation); &ie->value.choice.UserLocationInformation);
if (!ret) { if (!ret) {
cout << "encode UserLocationInformation IE error" << endl; Logger::ngap().error("Encode UserLocationInformation IE error");
free_wrapper((void**) &ie); free_wrapper((void**) &ie);
return; return;
} }
ret = ASN_SEQUENCE_ADD(&handoverNotifyIEs->protocolIEs.list, ie); ret = ASN_SEQUENCE_ADD(&handoverNotifyIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode UserLocationInformation IE error" << endl; if (ret != 0) Logger::ngap().error("Encode UserLocationInformation IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
uint32_t HandoverNotifyMsg::getRanUeNgapId() { uint32_t HandoverNotifyMsg::getRanUeNgapId() {
return ranUeNgapId->getRanUeNgapId(); if (ranUeNgapId)
return ranUeNgapId->getRanUeNgapId();
else
return 0;
} }
bool HandoverNotifyMsg::getUserLocationInfoNR( bool HandoverNotifyMsg::getUserLocationInfoNR(
struct NrCgi_s& cig, struct Tai_s& tai) { struct NrCgi_s& cig, struct Tai_s& tai) {
if (!userLocationInformation) return false;
UserLocationInformationNR* informationNR; UserLocationInformationNR* informationNR;
userLocationInformation->getInformation(informationNR); userLocationInformation->getInformation(informationNR);
if (userLocationInformation->getChoiceOfUserLocationInformation() != if (userLocationInformation->getChoiceOfUserLocationInformation() !=
......
...@@ -48,8 +48,8 @@ class HandoverNotifyMsg { ...@@ -48,8 +48,8 @@ class HandoverNotifyMsg {
int encode2buffer(uint8_t* buf, int buf_size); int encode2buffer(uint8_t* buf, int buf_size);
bool decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu); bool decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu);
void setUserLocationInfoNR(struct NrCgi_s cig, struct Tai_s tai); void setUserLocationInfoNR(struct NrCgi_s cig, struct Tai_s tai);
unsigned long getAmfUeNgapId(); // return -1; unsigned long getAmfUeNgapId();
uint32_t getRanUeNgapId(); // return -1; uint32_t getRanUeNgapId();
bool getUserLocationInfoNR(struct NrCgi_s& cig, struct Tai_s& tai); bool getUserLocationInfoNR(struct NrCgi_s& cig, struct Tai_s& tai);
private: private:
......
This diff is collapsed.
/*
* 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
*/
#ifndef _HANDOVER_PREPARATION_FAILURE_H_
#define _HANDOVER_PREPARATION_FAILURE_H_
#include "AMF-UE-NGAP-ID.hpp"
#include "Cause.hpp"
#include "MessageType.hpp"
#include "NgapIEsStruct.hpp"
#include "RAN-UE-NGAP-ID.hpp"
extern "C" {
#include "Ngap_NGAP-PDU.h"
#include "Ngap_ProtocolIE-Field.h"
}
namespace ngap {
class HandoverPreparationFailure {
public:
HandoverPreparationFailure();
virtual ~HandoverPreparationFailure();
void setMessageType(); // Initialize the PDU and populate the MessageType;
void setAmfUeNgapId(unsigned long id); // 40 bits
unsigned long getAmfUeNgapId() const;
void setRanUeNgapId(uint32_t id); // 32 bits
uint32_t getRanUeNgapId() const;
int encode2buffer(uint8_t* buf, int buf_size);
bool decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu);
void getCause(Cause& cause) const;
void setCause(Ngap_Cause_PR m_causePresent, long value = 0);
Ngap_Cause_PR getChoiceOfCause() const;
private:
Ngap_NGAP_PDU_t* hoPreparationFailurePdu;
Ngap_HandoverPreparationFailure_t* hoPreparationFailureIEs;
AMF_UE_NGAP_ID* amfUeNgapId;
RAN_UE_NGAP_ID* ranUeNgapId;
Cause* cause;
Ngap_CriticalityDiagnostics_t* CriticalityDiagnostics;
};
} // namespace ngap
#endif
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
*/ */
#include "HandoverRequest.hpp" #include "HandoverRequest.hpp"
#include "logger.hpp"
extern "C" { extern "C" {
#include "Ngap_NGAP-PDU.h" #include "Ngap_NGAP-PDU.h"
...@@ -56,7 +57,7 @@ HandoverRequest::HandoverRequest() { ...@@ -56,7 +57,7 @@ HandoverRequest::HandoverRequest() {
HandoverRequest::~HandoverRequest() {} HandoverRequest::~HandoverRequest() {}
unsigned long HandoverRequest::getAmfUeNgapId() { unsigned long HandoverRequest::getAmfUeNgapId() {
return amfUeNgapId->getAMF_UE_NGAP_ID(); if (amfUeNgapId) return amfUeNgapId->getAMF_UE_NGAP_ID();
} }
/*bool HandoverRequest::decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu) /*bool HandoverRequest::decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu)
...@@ -244,11 +245,11 @@ void HandoverRequest::setMessageType() { ...@@ -244,11 +245,11 @@ void HandoverRequest::setMessageType() {
handoverRequestIEs = &(handoverRequestPdu->choice.initiatingMessage->value handoverRequestIEs = &(handoverRequestPdu->choice.initiatingMessage->value
.choice.HandoverRequest); .choice.HandoverRequest);
} else { } else {
cout << "[warning] This information doesn't refer to HandoverRequest " Logger::ngap().warn(
"Message!!!" "This information doesn't refer to HandoverRequest message!");
<< endl;
} }
} }
void HandoverRequest::setAmfUeNgapId(unsigned long id) { void HandoverRequest::setAmfUeNgapId(unsigned long id) {
if (!amfUeNgapId) amfUeNgapId = new AMF_UE_NGAP_ID(); if (!amfUeNgapId) amfUeNgapId = new AMF_UE_NGAP_ID();
amfUeNgapId->setAMF_UE_NGAP_ID(id); amfUeNgapId->setAMF_UE_NGAP_ID(id);
...@@ -261,13 +262,14 @@ void HandoverRequest::setAmfUeNgapId(unsigned long id) { ...@@ -261,13 +262,14 @@ void HandoverRequest::setAmfUeNgapId(unsigned long id) {
int ret = amfUeNgapId->encode2AMF_UE_NGAP_ID(ie->value.choice.AMF_UE_NGAP_ID); int ret = amfUeNgapId->encode2AMF_UE_NGAP_ID(ie->value.choice.AMF_UE_NGAP_ID);
if (!ret) { if (!ret) {
cout << "encode AMF_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Encode AMF_UE_NGAP_ID IE error");
free_wrapper((void**) &ie); free_wrapper((void**) &ie);
return; return;
} }
ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie); ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode AMF_UE_NGAP_ID IE error" << endl; if (ret != 0) Logger::ngap().error("Encode AMF_UE_NGAP_ID IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
...@@ -281,7 +283,7 @@ void HandoverRequest::setHandoverType(long type) // 0--intra5gs ...@@ -281,7 +283,7 @@ void HandoverRequest::setHandoverType(long type) // 0--intra5gs
ie->value.present = Ngap_HandoverRequestIEs__value_PR_HandoverType; ie->value.present = Ngap_HandoverRequestIEs__value_PR_HandoverType;
ie->value.choice.HandoverType = type; ie->value.choice.HandoverType = type;
int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie); int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode HandoverType IE error" << endl; if (ret != 0) Logger::ngap().error("Encode HandoverType IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
...@@ -298,7 +300,7 @@ void HandoverRequest::setCause(Ngap_Cause_PR m_causePresent, long value) // ...@@ -298,7 +300,7 @@ void HandoverRequest::setCause(Ngap_Cause_PR m_causePresent, long value) //
cause->setValue(value); cause->setValue(value);
cause->encode2Cause(&(ie->value.choice.Cause)); cause->encode2Cause(&(ie->value.choice.Cause));
int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie); int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode Cause IE error" << endl; if (ret != 0) Logger::ngap().error("Encode Cause IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
...@@ -320,7 +322,8 @@ void HandoverRequest::setUEAggregateMaximumBitRate( ...@@ -320,7 +322,8 @@ void HandoverRequest::setUEAggregateMaximumBitRate(
ie->value.choice.UEAggregateMaximumBitRate); ie->value.choice.UEAggregateMaximumBitRate);
int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie); int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode UEAggregateMaximumBitRate IE error" << endl; if (ret != 0)
Logger::ngap().error("Encode UEAggregateMaximumBitRate IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
void HandoverRequest::setUESecurityCapabilities( void HandoverRequest::setUESecurityCapabilities(
...@@ -342,14 +345,14 @@ void HandoverRequest::setUESecurityCapabilities( ...@@ -342,14 +345,14 @@ void HandoverRequest::setUESecurityCapabilities(
(ie->value.choice.UESecurityCapabilities)); (ie->value.choice.UESecurityCapabilities));
int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie); int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode UESecurityCapabilities IE error" << endl; if (ret != 0) Logger::ngap().error("Encode UESecurityCapabilities IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
void HandoverRequest::setGUAMI( void HandoverRequest::setGUAMI(
PlmnId* m_plmnId, AMFRegionID* m_aMFRegionID, AMFSetID* m_aMFSetID, PlmnId* m_plmnId, AMFRegionID* m_aMFRegionID, AMFSetID* m_aMFSetID,
AMFPointer* m_aMFPointer) { AMFPointer* m_aMFPointer) {
if (!guami) guami = new GUAMI; if (!guami) guami = new GUAMI();
Ngap_HandoverRequestIEs_t* ie = Ngap_HandoverRequestIEs_t* ie =
(Ngap_HandoverRequestIEs_t*) calloc(1, sizeof(Ngap_HandoverRequestIEs_t)); (Ngap_HandoverRequestIEs_t*) calloc(1, sizeof(Ngap_HandoverRequestIEs_t));
...@@ -360,7 +363,8 @@ void HandoverRequest::setGUAMI( ...@@ -360,7 +363,8 @@ void HandoverRequest::setGUAMI(
guami->encode2GUAMI(&(ie->value.choice.GUAMI)); guami->encode2GUAMI(&(ie->value.choice.GUAMI));
int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie); int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode GUAMI IE error" << endl;
if (ret != 0) Logger::ngap().error("Encode GUAMI IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
void HandoverRequest::setAllowedNSSAI(std::vector<S_NSSAI> list) { void HandoverRequest::setAllowedNSSAI(std::vector<S_NSSAI> list) {
...@@ -374,7 +378,8 @@ void HandoverRequest::setAllowedNSSAI(std::vector<S_NSSAI> list) { ...@@ -374,7 +378,8 @@ void HandoverRequest::setAllowedNSSAI(std::vector<S_NSSAI> list) {
list[i].encode2S_NSSAI(&item->s_NSSAI); list[i].encode2S_NSSAI(&item->s_NSSAI);
int ret = ASN_SEQUENCE_ADD(&allowedNSSAI->list, item); int ret = ASN_SEQUENCE_ADD(&allowedNSSAI->list, item);
if (ret != 0) if (ret != 0)
cout << "encode PDUSessionResourceHandoverListItem IE error" << endl; Logger::ngap().error(
"Encode PDUSessionResourceHandoverListItem IE error");
} }
asn_fprint(stderr, &asn_DEF_Ngap_AllowedNSSAI, allowedNSSAI); asn_fprint(stderr, &asn_DEF_Ngap_AllowedNSSAI, allowedNSSAI);
Ngap_HandoverRequestIEs_t* ie = Ngap_HandoverRequestIEs_t* ie =
...@@ -384,7 +389,7 @@ void HandoverRequest::setAllowedNSSAI(std::vector<S_NSSAI> list) { ...@@ -384,7 +389,7 @@ void HandoverRequest::setAllowedNSSAI(std::vector<S_NSSAI> list) {
ie->value.present = Ngap_HandoverRequestIEs__value_PR_AllowedNSSAI; ie->value.present = Ngap_HandoverRequestIEs__value_PR_AllowedNSSAI;
ie->value.choice.AllowedNSSAI = *allowedNSSAI; ie->value.choice.AllowedNSSAI = *allowedNSSAI;
int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie); int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode AllowedNSSAI IE error" << endl; if (ret != 0) Logger::ngap().error("Encode AllowedNSSAI IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
void HandoverRequest::setSecurityContext(long count, uint8_t* buffer) { void HandoverRequest::setSecurityContext(long count, uint8_t* buffer) {
...@@ -402,7 +407,7 @@ void HandoverRequest::setSecurityContext(long count, uint8_t* buffer) { ...@@ -402,7 +407,7 @@ void HandoverRequest::setSecurityContext(long count, uint8_t* buffer) {
ie->value.present = Ngap_HandoverRequestIEs__value_PR_SecurityContext; ie->value.present = Ngap_HandoverRequestIEs__value_PR_SecurityContext;
ie->value.choice.SecurityContext = *SecurityContext; ie->value.choice.SecurityContext = *SecurityContext;
int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie); int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode SecurityContext IE error" << endl; if (ret != 0) Logger::ngap().error("Encode SecurityContext IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
...@@ -438,14 +443,14 @@ void HandoverRequest::setPduSessionResourceSetupList( ...@@ -438,14 +443,14 @@ void HandoverRequest::setPduSessionResourceSetupList(
PDUSessionResourceSetupList->encode2PDUSessionResourceSetupListHOReq( PDUSessionResourceSetupList->encode2PDUSessionResourceSetupListHOReq(
&ie->value.choice.PDUSessionResourceSetupListHOReq); &ie->value.choice.PDUSessionResourceSetupListHOReq);
if (!ret) { if (!ret) {
cout << "encode PDUSessionResourceSetupListSUReq IE error" << endl; Logger::ngap().error("Encode PDUSessionResourceSetupListSUReq IE error");
free_wrapper((void**) &ie); free_wrapper((void**) &ie);
return; return;
} }
ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie); ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0) if (ret != 0)
cout << "encode PDUSessionResourceSetupListSUReq IE error" << endl; Logger::ngap().error("Encode PDUSessionResourceSetupListSUReq IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
...@@ -464,7 +469,7 @@ void HandoverRequest::setSourceToTarget_TransparentContainer( ...@@ -464,7 +469,7 @@ void HandoverRequest::setSourceToTarget_TransparentContainer(
ie->value.choice.SourceToTarget_TransparentContainer = sourceTotarget; ie->value.choice.SourceToTarget_TransparentContainer = sourceTotarget;
int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie); int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0) if (ret != 0)
cout << "encode SourceToTarget_TransparentContainer IE error" << endl; Logger::ngap().error("Encode SourceToTarget_TransparentContainer IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
void HandoverRequest::setMobilityRestrictionList(PlmnId* m_plmnId) { void HandoverRequest::setMobilityRestrictionList(PlmnId* m_plmnId) {
...@@ -480,7 +485,7 @@ void HandoverRequest::setMobilityRestrictionList(PlmnId* m_plmnId) { ...@@ -480,7 +485,7 @@ void HandoverRequest::setMobilityRestrictionList(PlmnId* m_plmnId) {
mobilityrestrictionlist->encodeMobilityRestrictionList( mobilityrestrictionlist->encodeMobilityRestrictionList(
&(ie->value.choice.MobilityRestrictionList)); &(ie->value.choice.MobilityRestrictionList));
int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie); int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode MobilityRestrictionList IE error" << endl; if (ret != 0) Logger::ngap().error("Encode MobilityRestrictionList IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
......
...@@ -81,7 +81,7 @@ class HandoverRequest { ...@@ -81,7 +81,7 @@ class HandoverRequest {
private: private:
Ngap_NGAP_PDU_t* handoverRequestPdu; Ngap_NGAP_PDU_t* handoverRequestPdu;
Ngap_HandoverRequest_t* handoverRequestIEs; Ngap_HandoverRequest_t* handoverRequestIEs;
/***************** for decoding ****************/
AMF_UE_NGAP_ID* amfUeNgapId; AMF_UE_NGAP_ID* amfUeNgapId;
Ngap_HandoverType_t* handovertype; Ngap_HandoverType_t* handovertype;
Cause* cause; Cause* cause;
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
*/ */
#include "HandoverRequestAck.hpp" #include "HandoverRequestAck.hpp"
#include "logger.hpp"
#include "GTP-TEID.hpp" #include "GTP-TEID.hpp"
#include "String2Value.hpp" #include "String2Value.hpp"
#include "TransportLayerAddress.hpp" #include "TransportLayerAddress.hpp"
...@@ -55,7 +55,10 @@ HandoverRequestAck::HandoverRequestAck() { ...@@ -55,7 +55,10 @@ HandoverRequestAck::HandoverRequestAck() {
HandoverRequestAck::~HandoverRequestAck() {} HandoverRequestAck::~HandoverRequestAck() {}
unsigned long HandoverRequestAck::getAmfUeNgapId() { unsigned long HandoverRequestAck::getAmfUeNgapId() {
return amfUeNgapId->getAMF_UE_NGAP_ID(); if (amfUeNgapId)
return amfUeNgapId->getAMF_UE_NGAP_ID();
else
return 0;
} }
void HandoverRequestAck::setMessageType() { void HandoverRequestAck::setMessageType() {
if (!handoverRequestAckPdu) if (!handoverRequestAckPdu)
...@@ -79,16 +82,21 @@ void HandoverRequestAck::setMessageType() { ...@@ -79,16 +82,21 @@ void HandoverRequestAck::setMessageType() {
handoverRequestAckIEs = &(handoverRequestAckPdu->choice.successfulOutcome handoverRequestAckIEs = &(handoverRequestAckPdu->choice.successfulOutcome
->value.choice.HandoverRequestAcknowledge); ->value.choice.HandoverRequestAcknowledge);
} else { } else {
cout << "[warning] This information doesn't refer to HandoverRequest " Logger::ngap().warn(
"Message!!!" "This information doesn't refer to HandoverRequest message");
<< endl;
} }
} }
uint32_t HandoverRequestAck::getRanUeNgapId() { uint32_t HandoverRequestAck::getRanUeNgapId() {
return ranUeNgapId->getRanUeNgapId(); if (ranUeNgapId)
return ranUeNgapId->getRanUeNgapId();
else
return 0;
} }
OCTET_STRING_t HandoverRequestAck::getTargetToSource_TransparentContainer() { OCTET_STRING_t HandoverRequestAck::getTargetToSource_TransparentContainer() {
return *TargetToSource_TransparentContainer; if (TargetToSource_TransparentContainer)
return *TargetToSource_TransparentContainer;
return OCTET_STRING_t();
} }
bool HandoverRequestAck::getPDUSessionResourceAdmittedList( bool HandoverRequestAck::getPDUSessionResourceAdmittedList(
...@@ -114,6 +122,7 @@ bool HandoverRequestAck::getPDUSessionResourceAdmittedList( ...@@ -114,6 +122,7 @@ bool HandoverRequestAck::getPDUSessionResourceAdmittedList(
} }
bool HandoverRequestAck::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { bool HandoverRequestAck::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!ngap_msg_pdu) return false;
handoverRequestAckPdu = ngap_msg_pdu; handoverRequestAckPdu = ngap_msg_pdu;
if (handoverRequestAckPdu->present == Ngap_NGAP_PDU_PR_successfulOutcome) { if (handoverRequestAckPdu->present == Ngap_NGAP_PDU_PR_successfulOutcome) {
...@@ -127,11 +136,11 @@ bool HandoverRequestAck::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -127,11 +136,11 @@ bool HandoverRequestAck::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
handoverRequestAckIEs = &handoverRequestAckPdu->choice.successfulOutcome handoverRequestAckIEs = &handoverRequestAckPdu->choice.successfulOutcome
->value.choice.HandoverRequestAcknowledge; ->value.choice.HandoverRequestAcknowledge;
} else { } else {
cout << "Check handoverRequestAck message error!!!" << endl; Logger::ngap().error("Check handoverRequestAck message error");
return false; return false;
} }
} else { } else {
cout << "handoverRequestAck MessageType error!!!" << endl; Logger::ngap().error("handoverRequestAck MessageType error");
return false; return false;
} }
for (int i = 0; i < handoverRequestAckIEs->protocolIEs.list.count; i++) { for (int i = 0; i < handoverRequestAckIEs->protocolIEs.list.count; i++) {
...@@ -145,11 +154,11 @@ bool HandoverRequestAck::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -145,11 +154,11 @@ bool HandoverRequestAck::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!amfUeNgapId->decodefromAMF_UE_NGAP_ID( if (!amfUeNgapId->decodefromAMF_UE_NGAP_ID(
handoverRequestAckIEs->protocolIEs.list.array[i] handoverRequestAckIEs->protocolIEs.list.array[i]
->value.choice.AMF_UE_NGAP_ID)) { ->value.choice.AMF_UE_NGAP_ID)) {
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Decoded NGAP AMF_UE_NGAP_ID IE error");
return false; return false;
} }
} else { } else {
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Decoded NGAP AMF_UE_NGAP_ID IE error");
return false; return false;
} }
} break; } break;
...@@ -162,11 +171,11 @@ bool HandoverRequestAck::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -162,11 +171,11 @@ bool HandoverRequestAck::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!ranUeNgapId->decodefromRAN_UE_NGAP_ID( if (!ranUeNgapId->decodefromRAN_UE_NGAP_ID(
handoverRequestAckIEs->protocolIEs.list.array[i] handoverRequestAckIEs->protocolIEs.list.array[i]
->value.choice.RAN_UE_NGAP_ID)) { ->value.choice.RAN_UE_NGAP_ID)) {
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Decoded NGAP RAN_UE_NGAP_ID IE error");
return false; return false;
} }
} else { } else {
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Decoded NGAP RAN_UE_NGAP_ID IE error");
return false; return false;
} }
} break; } break;
...@@ -180,13 +189,13 @@ bool HandoverRequestAck::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -180,13 +189,13 @@ bool HandoverRequestAck::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
->decodefromPDUSessionResourceAdmittedList( ->decodefromPDUSessionResourceAdmittedList(
&handoverRequestAckIEs->protocolIEs.list.array[i] &handoverRequestAckIEs->protocolIEs.list.array[i]
->value.choice.PDUSessionResourceAdmittedList)) { ->value.choice.PDUSessionResourceAdmittedList)) {
cout << "decoded ngap PDUSessionResourceAdmittedList IE error" Logger::ngap().error(
<< endl; "Decoded NGAP PDUSessionResourceAdmittedList IE error");
return false; return false;
} }
} else { } else {
cout << "decoded ngap PDUSessionResourceAdmittedList Type IE error" Logger::ngap().error(
<< endl; "Decoded NGAP PDUSessionResourceAdmittedList IE error");
return false; return false;
} }
} break; } break;
...@@ -201,13 +210,14 @@ bool HandoverRequestAck::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -201,13 +210,14 @@ bool HandoverRequestAck::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
handoverRequestAckIEs->protocolIEs.list.array[i] handoverRequestAckIEs->protocolIEs.list.array[i]
->value.choice.TargetToSource_TransparentContainer; ->value.choice.TargetToSource_TransparentContainer;
} else { } else {
cout << "decoded ngap TargetToSource_TransparentContainer IE error" Logger::ngap().error(
<< endl; "Decoded NGAP TargetToSource_TransparentContainer IE error");
return false; return false;
} }
} break; } break;
default: { default: {
cout << "decoded ngap message pdu error" << endl; Logger::ngap().error("Decoded NGAP Message PDU error");
return false; return false;
} }
} }
......
...@@ -65,7 +65,6 @@ class HandoverRequestAck { ...@@ -65,7 +65,6 @@ class HandoverRequestAck {
private: private:
Ngap_NGAP_PDU_t* handoverRequestAckPdu; Ngap_NGAP_PDU_t* handoverRequestAckPdu;
Ngap_HandoverRequestAcknowledge_t* handoverRequestAckIEs; Ngap_HandoverRequestAcknowledge_t* handoverRequestAckIEs;
/***************** for decoding ****************/
AMF_UE_NGAP_ID* amfUeNgapId; AMF_UE_NGAP_ID* amfUeNgapId;
RAN_UE_NGAP_ID* ranUeNgapId; RAN_UE_NGAP_ID* ranUeNgapId;
Ngap_HandoverType_t* handovertype; Ngap_HandoverType_t* handovertype;
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
*/ */
#include "HandoverRequiredMsg.hpp" #include "HandoverRequiredMsg.hpp"
#include "logger.hpp"
extern "C" { extern "C" {
#include "Ngap_NGAP-PDU.h" #include "Ngap_NGAP-PDU.h"
#include "asn_codecs.h" #include "asn_codecs.h"
...@@ -52,31 +53,53 @@ HandoverRequiredMsg::HandoverRequiredMsg() { ...@@ -52,31 +53,53 @@ HandoverRequiredMsg::HandoverRequiredMsg() {
HandoverRequiredMsg::~HandoverRequiredMsg() {} HandoverRequiredMsg::~HandoverRequiredMsg() {}
unsigned long HandoverRequiredMsg::getAmfUeNgapId() { unsigned long HandoverRequiredMsg::getAmfUeNgapId() {
return amfUeNgapId->getAMF_UE_NGAP_ID(); if (amfUeNgapId)
return amfUeNgapId->getAMF_UE_NGAP_ID();
else
return 0;
} }
uint32_t HandoverRequiredMsg::getRanUeNgapId() { uint32_t HandoverRequiredMsg::getRanUeNgapId() {
return ranUeNgapId->getRanUeNgapId(); if (ranUeNgapId)
return ranUeNgapId->getRanUeNgapId();
else
return 0;
} }
Ngap_HandoverType_t HandoverRequiredMsg::getHandoverType() { Ngap_HandoverType_t HandoverRequiredMsg::getHandoverType() {
return *handovertype; if (handovertype)
return *handovertype;
else
return Ngap_HandoverType_t();
} }
Ngap_Cause_PR HandoverRequiredMsg::getChoiceOfCause() { Ngap_Cause_PR HandoverRequiredMsg::getChoiceOfCause() {
return cause->getChoiceOfCause(); if (cause)
return cause->getChoiceOfCause();
else
return Ngap_Cause_PR();
} }
long HandoverRequiredMsg::getCauseValue() { long HandoverRequiredMsg::getCauseValue() {
return cause->getValue(); if (cause)
return cause->getValue();
else
return 0;
} }
void HandoverRequiredMsg::getGlobalRanNodeId(GlobalgNBId*& ptr) { void HandoverRequiredMsg::getGlobalRanNodeId(GlobalgNBId*& ptr) {
ptr->decodefromGlobalgNBId( if (ptr)
targetid->choice.targetRANNodeID->globalRANNodeID.choice.globalGNB_ID); ptr->decodefromGlobalgNBId(
targetid->choice.targetRANNodeID->globalRANNodeID.choice.globalGNB_ID);
} }
void HandoverRequiredMsg::getTAI(TAI*& ptr) { void HandoverRequiredMsg::getTAI(TAI*& ptr) {
ptr->decodefromTAI(&(targetid->choice.targetRANNodeID->selectedTAI)); if (ptr) ptr->decodefromTAI(&(targetid->choice.targetRANNodeID->selectedTAI));
} }
OCTET_STRING_t HandoverRequiredMsg::getSourceToTarget_TransparentContainer() { OCTET_STRING_t HandoverRequiredMsg::getSourceToTarget_TransparentContainer() {
return *SourceToTarget_TransparentContainer; if (SourceToTarget_TransparentContainer)
return *SourceToTarget_TransparentContainer;
} }
bool HandoverRequiredMsg::getPDUSessionResourceList( bool HandoverRequiredMsg::getPDUSessionResourceList(
...@@ -103,7 +126,8 @@ bool HandoverRequiredMsg::getPDUSessionResourceList( ...@@ -103,7 +126,8 @@ bool HandoverRequiredMsg::getPDUSessionResourceList(
} }
long HandoverRequiredMsg::getDirectForwardingPathAvailability() { long HandoverRequiredMsg::getDirectForwardingPathAvailability() {
return *directforwardingPathAvailability; if (directforwardingPathAvailability)
return *directforwardingPathAvailability;
} }
bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
...@@ -120,11 +144,11 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -120,11 +144,11 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
handoverRequiredIEs = &handoverRequiredPdu->choice.initiatingMessage handoverRequiredIEs = &handoverRequiredPdu->choice.initiatingMessage
->value.choice.HandoverRequired; ->value.choice.HandoverRequired;
} else { } else {
cout << "Check HandoverRequired message error!!!" << endl; Logger::ngap().error("Check HandoverRequired message error!");
return false; return false;
} }
} else { } else {
cout << "HandoverRequired MessageType error!!!" << endl; Logger::ngap().error("HandoverRequired MessageType error!");
return false; return false;
} }
for (int i = 0; i < handoverRequiredIEs->protocolIEs.list.count; i++) { for (int i = 0; i < handoverRequiredIEs->protocolIEs.list.count; i++) {
...@@ -138,11 +162,11 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -138,11 +162,11 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!amfUeNgapId->decodefromAMF_UE_NGAP_ID( if (!amfUeNgapId->decodefromAMF_UE_NGAP_ID(
handoverRequiredIEs->protocolIEs.list.array[i] handoverRequiredIEs->protocolIEs.list.array[i]
->value.choice.AMF_UE_NGAP_ID)) { ->value.choice.AMF_UE_NGAP_ID)) {
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Decoded ngap AMF_UE_NGAP_ID IE error");
return false; return false;
} }
} else { } else {
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Decoded ngap AMF_UE_NGAP_ID IE error");
return false; return false;
} }
} break; } break;
...@@ -155,11 +179,11 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -155,11 +179,11 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!ranUeNgapId->decodefromRAN_UE_NGAP_ID( if (!ranUeNgapId->decodefromRAN_UE_NGAP_ID(
handoverRequiredIEs->protocolIEs.list.array[i] handoverRequiredIEs->protocolIEs.list.array[i]
->value.choice.RAN_UE_NGAP_ID)) { ->value.choice.RAN_UE_NGAP_ID)) {
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Decoded ngap RAN_UE_NGAP_ID IE error");
return false; return false;
} }
} else { } else {
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Decoded ngap RAN_UE_NGAP_ID IE error");
return false; return false;
} }
} break; } break;
...@@ -172,7 +196,7 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -172,7 +196,7 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
*handovertype = handoverRequiredIEs->protocolIEs.list.array[i] *handovertype = handoverRequiredIEs->protocolIEs.list.array[i]
->value.choice.HandoverType; ->value.choice.HandoverType;
} else { } else {
cout << "decoded ngap Handover Type IE error" << endl; Logger::ngap().error("Decoded ngap Handover Type error");
return false; return false;
} }
} break; } break;
...@@ -185,11 +209,11 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -185,11 +209,11 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!cause->decodefromCause( if (!cause->decodefromCause(
&handoverRequiredIEs->protocolIEs.list.array[i] &handoverRequiredIEs->protocolIEs.list.array[i]
->value.choice.Cause)) { ->value.choice.Cause)) {
cout << "decoded ngap Cause IE error" << endl; Logger::ngap().error("Decoded ngap Cause IE error");
return false; return false;
} }
} else { } else {
cout << "decoded ngap Cause IE error" << endl; Logger::ngap().error("Decoded ngap Cause IE error");
return false; return false;
} }
} break; } break;
...@@ -202,7 +226,7 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -202,7 +226,7 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
*targetid = handoverRequiredIEs->protocolIEs.list.array[i] *targetid = handoverRequiredIEs->protocolIEs.list.array[i]
->value.choice.TargetID; ->value.choice.TargetID;
} else { } else {
cout << "decoded ngap TargetID IE error" << endl; Logger::ngap().error("Decoded ngap TargetID IE error");
return false; return false;
} }
} break; } break;
...@@ -217,8 +241,8 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -217,8 +241,8 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
handoverRequiredIEs->protocolIEs.list.array[i] handoverRequiredIEs->protocolIEs.list.array[i]
->value.choice.DirectForwardingPathAvailability; ->value.choice.DirectForwardingPathAvailability;
} else { } else {
cout << "decoded ngap DirectForwardingPathAvailability IE error" Logger::ngap().error(
<< endl; "Decoded ngap DirectForwardingPathAvailability IE error");
return false; return false;
} }
} break; } break;
...@@ -231,12 +255,13 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -231,12 +255,13 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!PDUSessionResourceList->decodefromPDUSessionResourceListHORqd( if (!PDUSessionResourceList->decodefromPDUSessionResourceListHORqd(
&handoverRequiredIEs->protocolIEs.list.array[i] &handoverRequiredIEs->protocolIEs.list.array[i]
->value.choice.PDUSessionResourceListHORqd)) { ->value.choice.PDUSessionResourceListHORqd)) {
cout << "decoded ngap PDUSessionResourceSetupListCxtRes IE error" Logger::ngap().error(
<< endl; "Decoded ngap PDUSessionResourceSetupListCxtRes IE error");
return false; return false;
} }
} else { } else {
cout << "decoded ngap PDUSessionResourceListHORqd IE error" << endl; Logger::ngap().error(
"Decoded ngap PDUSessionResourceSetupListCxtRes IE error");
return false; return false;
} }
} break; } break;
...@@ -251,13 +276,13 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -251,13 +276,13 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
handoverRequiredIEs->protocolIEs.list.array[i] handoverRequiredIEs->protocolIEs.list.array[i]
->value.choice.SourceToTarget_TransparentContainer; ->value.choice.SourceToTarget_TransparentContainer;
} else { } else {
cout << "decoded ngap SourceToTarget_TransparentContainer IE error" Logger::ngap().error(
<< endl; "Decoded ngap SourceToTarget_TransparentContainer IE error");
return false; return false;
} }
} break; } break;
default: { default: {
cout << "decoded ngap message pdu error" << endl; Logger::ngap().error("Decoded ngap message PDU error");
return false; return false;
} }
} }
...@@ -270,7 +295,8 @@ int HandoverRequiredMsg::encode2buffer(uint8_t* buf, int buf_size) { ...@@ -270,7 +295,8 @@ int HandoverRequiredMsg::encode2buffer(uint8_t* buf, int buf_size) {
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, handoverRequiredPdu); asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, handoverRequiredPdu);
asn_enc_rval_t er = aper_encode_to_buffer( asn_enc_rval_t er = aper_encode_to_buffer(
&asn_DEF_Ngap_NGAP_PDU, NULL, handoverRequiredPdu, buf, buf_size); &asn_DEF_Ngap_NGAP_PDU, NULL, handoverRequiredPdu, buf, buf_size);
cout << "er.encoded(" << er.encoded << ")" << endl; // cout << "er.encoded(" << er.encoded << ")" << endl;
Logger::ngap().error("er.encoded( %d )", er.encoded);
return er.encoded; return er.encoded;
} }
......
...@@ -48,9 +48,8 @@ class HandoverRequiredMsg { ...@@ -48,9 +48,8 @@ class HandoverRequiredMsg {
int encode2buffer(uint8_t* buf, int buf_size); int encode2buffer(uint8_t* buf, int buf_size);
bool decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu); bool decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu);
unsigned long getAmfUeNgapId(); // return -1;(不存在) unsigned long getAmfUeNgapId();
uint32_t getRanUeNgapId(); // return -1;(不存在) uint32_t getRanUeNgapId();
Ngap_HandoverType_t getHandoverType(); Ngap_HandoverType_t getHandoverType();
Ngap_Cause_PR getChoiceOfCause(); Ngap_Cause_PR getChoiceOfCause();
long getCauseValue(); long getCauseValue();
...@@ -63,7 +62,6 @@ class HandoverRequiredMsg { ...@@ -63,7 +62,6 @@ class HandoverRequiredMsg {
private: private:
Ngap_NGAP_PDU_t* handoverRequiredPdu; Ngap_NGAP_PDU_t* handoverRequiredPdu;
Ngap_HandoverRequired_t* handoverRequiredIEs; Ngap_HandoverRequired_t* handoverRequiredIEs;
/***************** for decoding ****************/
AMF_UE_NGAP_ID* amfUeNgapId; AMF_UE_NGAP_ID* amfUeNgapId;
RAN_UE_NGAP_ID* ranUeNgapId; RAN_UE_NGAP_ID* ranUeNgapId;
Ngap_HandoverType_t* handovertype; Ngap_HandoverType_t* handovertype;
......
...@@ -52,7 +52,6 @@ using namespace amf_application; ...@@ -52,7 +52,6 @@ using namespace amf_application;
extern itti_mw* itti_inst; extern itti_mw* itti_inst;
extern amf_n1* amf_n1_inst; extern amf_n1* amf_n1_inst;
extern amf_n11* amf_n11_inst;
extern amf_app* amf_app_inst; extern amf_app* amf_app_inst;
typedef int (*ngap_message_decoded_callback)( typedef int (*ngap_message_decoded_callback)(
...@@ -158,7 +157,7 @@ int ngap_amf_handle_initial_context_setup_response( ...@@ -158,7 +157,7 @@ int ngap_amf_handle_initial_context_setup_response(
} }
std::vector<PDUSessionResourceSetupResponseItem_t> list; std::vector<PDUSessionResourceSetupResponseItem_t> list;
if (!initCtxResp->getPduSessionResourceSetupResponseList(list)) { if (!initCtxResp->getPduSessionResourceSetupResponseList(list)) {
Logger::ngap().error( Logger::ngap().debug(
"Decode PduSessionResourceSetupResponseList IE error or this IE is not " "Decode PduSessionResourceSetupResponseList IE error or this IE is not "
"available"); "available");
return 0; return 0;
...@@ -543,7 +542,7 @@ int downlink_ue_associated_nappa_transport( ...@@ -543,7 +542,7 @@ int downlink_ue_associated_nappa_transport(
int handover_cancel( int handover_cancel(
const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream, const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream,
struct Ngap_NGAP_PDU* message_p) { struct Ngap_NGAP_PDU* message_p) {
Logger::ngap().debug("Sending itti handover cancel to TASK_AMF_N2"); Logger::ngap().debug("Sending ITTI Handover Cancel to TASK_AMF_N2");
return 0; return 0;
} }
...@@ -551,18 +550,18 @@ int handover_cancel( ...@@ -551,18 +550,18 @@ int handover_cancel(
int handover_preparation( int handover_preparation(
const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream, const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream,
struct Ngap_NGAP_PDU* message_p) { struct Ngap_NGAP_PDU* message_p) {
Logger::ngap().debug("Sending itti handover preparation to TASK_AMF_N2"); Logger::ngap().debug("Sending ITTI Handover Preparation to TASK_AMF_N2");
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, message_p); asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, message_p);
HandoverRequiredMsg* handoverrequired = new HandoverRequiredMsg(); HandoverRequiredMsg* handover_required = new HandoverRequiredMsg();
if (!handoverrequired->decodefrompdu(message_p)) { if (!handover_required->decodefrompdu(message_p)) {
Logger::ngap().error("decoding HandoverRequired message error"); Logger::ngap().error("Decoding HandoverRequired message error");
return -1; return -1;
} }
itti_handover_required* itti_handover_requ = itti_handover_required* itti_handover_requ =
new itti_handover_required(TASK_NGAP, TASK_AMF_N2); new itti_handover_required(TASK_NGAP, TASK_AMF_N2);
itti_handover_requ->assoc_id = assoc_id; itti_handover_requ->assoc_id = assoc_id;
itti_handover_requ->stream = stream; itti_handover_requ->stream = stream;
itti_handover_requ->handvoerRequ = handoverrequired; itti_handover_requ->handoverReq = handover_required;
std::shared_ptr<itti_handover_required> i = std::shared_ptr<itti_handover_required> i =
std::shared_ptr<itti_handover_required>(itti_handover_requ); std::shared_ptr<itti_handover_required>(itti_handover_requ);
int ret = itti_inst->send_msg(i); int ret = itti_inst->send_msg(i);
...@@ -578,11 +577,11 @@ int handover_preparation( ...@@ -578,11 +577,11 @@ int handover_preparation(
int handover_notification( int handover_notification(
const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream, const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream,
struct Ngap_NGAP_PDU* message_p) { struct Ngap_NGAP_PDU* message_p) {
Logger::ngap().debug("Sending itti handover Notification to TASK_AMF_N2"); Logger::ngap().debug("Sending ITTI Handover Notification to TASK_AMF_N2");
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, message_p); asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, message_p);
HandoverNotifyMsg* handoverNotify = new HandoverNotifyMsg(); HandoverNotifyMsg* handoverNotify = new HandoverNotifyMsg();
if (!handoverNotify->decodefrompdu(message_p)) { if (!handoverNotify->decodefrompdu(message_p)) {
Logger::ngap().error("decoding handoverNotify message error"); Logger::ngap().error("Decoding HandoverNotify message error");
return -1; return -1;
} }
itti_handover_notify* itti_handover_NOTIFY = itti_handover_notify* itti_handover_NOTIFY =
...@@ -606,12 +605,11 @@ int handover_resource_allocation( ...@@ -606,12 +605,11 @@ int handover_resource_allocation(
const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream, const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream,
struct Ngap_NGAP_PDU* message_p) { struct Ngap_NGAP_PDU* message_p) {
Logger::ngap().debug( Logger::ngap().debug(
"Sending itti handover resource allocation to TASK_AMF_N2"); "Sending ITTI Handover Resource Allocation to TASK_AMF_N2");
/*receive handover request acknowedge*/
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, message_p); asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, message_p);
HandoverRequestAck* handoverRequestAck = new HandoverRequestAck(); HandoverRequestAck* handoverRequestAck = new HandoverRequestAck();
if (!handoverRequestAck->decodefrompdu(message_p)) { if (!handoverRequestAck->decodefrompdu(message_p)) {
Logger::ngap().error("decoding handoverRequestAck message error"); Logger::ngap().error("Decoding Handover Request Acknowledge message error");
return -1; return -1;
} }
itti_handover_request_Ack* itti_handover_requ_Ack = itti_handover_request_Ack* itti_handover_requ_Ack =
...@@ -873,22 +871,22 @@ int uplink_ran_status_transfer( ...@@ -873,22 +871,22 @@ int uplink_ran_status_transfer(
const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream, const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream,
struct Ngap_NGAP_PDU* message_p) { struct Ngap_NGAP_PDU* message_p) {
Logger::ngap().debug( Logger::ngap().debug(
"Sending itti uplink ran status transfer to TASK_AMF_N2"); "Sending ITTI Uplink RAN Status Transfer to TASK_AMF_N2");
/*receive uplinkranstatustransfer*/
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, message_p); asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, message_p);
UplinkRANStatusTransfer* Uplinkranstatustransfer = UplinkRANStatusTransfer* Uplinkranstatustransfer =
new UplinkRANStatusTransfer(); new UplinkRANStatusTransfer();
if (!Uplinkranstatustransfer->defromPDU(message_p)) { if (!Uplinkranstatustransfer->defromPDU(message_p)) {
Logger::ngap().error("Decoding Uplinkranstatustransfer message error"); Logger::ngap().error("Decoding Uplink RAN Status Transfer message error");
return -1; return -1;
} }
itti_uplinkranstatsutransfer* itti_uplinkran_sta_tran = itti_uplink_ran_status_transfer* itti_uplinkran_sta_tran =
new itti_uplinkranstatsutransfer(TASK_NGAP, TASK_AMF_N2); new itti_uplink_ran_status_transfer(TASK_NGAP, TASK_AMF_N2);
itti_uplinkran_sta_tran->assoc_id = assoc_id; itti_uplinkran_sta_tran->assoc_id = assoc_id;
itti_uplinkran_sta_tran->stream = stream; itti_uplinkran_sta_tran->stream = stream;
itti_uplinkran_sta_tran->uplinkrantransfer = Uplinkranstatustransfer; itti_uplinkran_sta_tran->uplinkrantransfer = Uplinkranstatustransfer;
std::shared_ptr<itti_uplinkranstatsutransfer> i = std::shared_ptr<itti_uplink_ran_status_transfer> i =
std::shared_ptr<itti_uplinkranstatsutransfer>(itti_uplinkran_sta_tran); std::shared_ptr<itti_uplink_ran_status_transfer>(itti_uplinkran_sta_tran);
int ret = itti_inst->send_msg(i); int ret = itti_inst->send_msg(i);
if (0 != ret) { if (0 != ret) {
Logger::ngap().error( Logger::ngap().error(
...@@ -960,8 +958,7 @@ ngap_message_decoded_callback messages_callback[][3] = { ...@@ -960,8 +958,7 @@ ngap_message_decoded_callback messages_callback[][3] = {
{overload_stop, overload_stop, overload_stop}, /*OverloadStop*/ {overload_stop, overload_stop, overload_stop}, /*OverloadStop*/
{paging, paging, paging}, /*Paging*/ {paging, paging, paging}, /*Paging*/
{ngap_amf_handle_path_switch_request, ngap_amf_handle_path_switch_request, {ngap_amf_handle_path_switch_request, ngap_amf_handle_path_switch_request,
ngap_amf_handle_path_switch_request}, //{ngap_amf_handle_path_switch_request,0,0}, ngap_amf_handle_path_switch_request}, /*PathSwitchRequest*/
///*PathSwitchRequest*
{pdu_session_resource_modify, pdu_session_resource_modify, {pdu_session_resource_modify, pdu_session_resource_modify,
pdu_session_resource_modify}, /*PDUSessionResourceModify*/ pdu_session_resource_modify}, /*PDUSessionResourceModify*/
{pdu_session_resource_modify_indication, {pdu_session_resource_modify_indication,
......
...@@ -354,4 +354,4 @@ IF(STATIC_LINKING) ...@@ -354,4 +354,4 @@ IF(STATIC_LINKING)
ENDIF(STATIC_LINKING) ENDIF(STATIC_LINKING)
target_link_libraries(amf ${ASAN} target_link_libraries(amf ${ASAN}
-Wl,--start-group 3GPP_COMMON_TYPES AMF CONTEXTS AMF_SCTP AMF_SECU_5GAKA AMF_SECU_NAS AMF_UTILS AMF_SBI_CLIENT AMF_SBI_SERVER config++ sctp pthread ${NETTLE_LIBRARIES} ${MySQL_LIBRARY} ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} boost_system ssl crypt cpprest gmp pistache curl) -Wl,--start-group 3GPP_COMMON_TYPES AMF CONTEXTS AMF_SCTP AMF_SECU_5GAKA AMF_SECU_NAS AMF_UTILS AMF_SBI_CLIENT AMF_SBI_SERVER config++ sctp pthread ${NETTLE_LIBRARIES} ${MySQL_LIBRARY} ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} boost_system boost_thread boost_chrono ssl crypt cpprest gmp pistache curl)
...@@ -22,7 +22,6 @@ using namespace amf_application; ...@@ -22,7 +22,6 @@ using namespace amf_application;
extern void msg_str_2_msg_hex(std::string msg, bstring& b); extern void msg_str_2_msg_hex(std::string msg, bstring& b);
extern void convert_string_2_hex(std::string& input, std::string& output); extern void convert_string_2_hex(std::string& input, std::string& output);
extern itti_mw* itti_inst; extern itti_mw* itti_inst;
extern amf_n11* amf_n11_inst;
extern amf_app* amf_app_inst; extern amf_app* amf_app_inst;
extern void print_buffer( extern void print_buffer(
const std::string app, const std::string commit, uint8_t* buf, int len); const std::string app, const std::string commit, uint8_t* buf, int len);
......
/*
* 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 uint_uid_generator.hpp
\author Lionel GAUTHIER
\date 2019
\email: lionel.gauthier@eurecom.fr
*/
#ifndef FILE_UINT_GENERATOR_HPP_SEEN
#define FILE_UINT_GENERATOR_HPP_SEEN
#include <mutex>
#include <set>
namespace util {
template<class UINT>
class uint_generator {
private:
UINT uid_generator;
std::mutex m_uid_generator;
std::set<UINT> uid_generated;
std::mutex m_uid_generated;
public:
uint_generator() : m_uid_generator(), m_uid_generated() {
uid_generator = 0;
uid_generated = {};
};
uint_generator(uint_generator const&) = delete;
void operator=(uint_generator const&) = delete;
UINT get_uid() {
std::unique_lock<std::mutex> lr(m_uid_generator);
UINT uid = ++uid_generator;
while (true) {
// may happen race conditions here
std::unique_lock<std::mutex> ld(m_uid_generated);
if (uid_generated.count(uid) == 0) {
uid_generated.insert(uid);
ld.unlock();
lr.unlock();
return uid;
}
uid = ++uid_generator;
}
}
void free_uid(UINT uid) {
std::unique_lock<std::mutex> l(m_uid_generated);
uid_generated.erase(uid);
l.unlock();
}
};
template<class UINT>
class uint_uid_generator {
private:
UINT uid_generator;
std::mutex m_uid_generator;
std::set<UINT> uid_generated;
std::mutex m_uid_generated;
uint_uid_generator() : m_uid_generator(), m_uid_generated() {
uid_generator = 0;
uid_generated = {};
};
public:
static uint_uid_generator& get_instance() {
static uint_uid_generator instance;
return instance;
}
uint_uid_generator(uint_uid_generator const&) = delete;
void operator=(uint_uid_generator const&) = delete;
UINT get_uid() {
std::unique_lock<std::mutex> lr(m_uid_generator);
UINT uid = ++uid_generator;
while (true) {
// may happen race conditions here
std::unique_lock<std::mutex> ld(m_uid_generated);
if (uid_generated.count(uid) == 0) {
uid_generated.insert(uid);
lr.unlock();
ld.unlock();
return uid;
}
uid = ++uid_generator;
}
}
void free_uid(UINT uid) {
std::unique_lock<std::mutex> l(m_uid_generated);
uid_generated.erase(uid);
l.unlock();
}
};
} // namespace util
#endif // FILE_UINT_GENERATOR_HPP_SEEN
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