Commit 98e4efa5 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen Committed by sagar arora

Fix nake ptr

parent 67253515
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <iostream> #include <iostream>
#include <stdexcept> #include <stdexcept>
#include "3gpp_29.500.h"
#include "DLNASTransport.hpp" #include "DLNASTransport.hpp"
#include "GlobalRanNodeId.h" #include "GlobalRanNodeId.h"
#include "RegistrationContextContainer.h" #include "RegistrationContextContainer.h"
...@@ -322,7 +323,7 @@ void amf_app::handle_itti_message( ...@@ -322,7 +323,7 @@ void amf_app::handle_itti_message(
} else { } else {
Logger::amf_app().info("Handle ITTI N1N2 Message Transfer Request"); Logger::amf_app().info("Handle ITTI N1N2 Message Transfer Request");
// Encode DL NAS TRANSPORT message(NAS message) // Encode DL NAS TRANSPORT message(NAS message)
DLNASTransport* dl = new DLNASTransport(); auto dl = std::make_unique<DLNASTransport>();
dl->setHeader(PLAIN_5GS_MSG); dl->setHeader(PLAIN_5GS_MSG);
dl->setPayload_Container_Type(N1_SM_INFORMATION); dl->setPayload_Container_Type(N1_SM_INFORMATION);
dl->setPayload_Container( dl->setPayload_Container(
...@@ -334,8 +335,9 @@ void amf_app::handle_itti_message( ...@@ -334,8 +335,9 @@ void amf_app::handle_itti_message(
comUt::print_buffer("amf_app", "n1n2 transfer", nas, encoded_size); comUt::print_buffer("amf_app", "n1n2 transfer", nas, encoded_size);
bstring dl_nas = blk2bstr(nas, encoded_size); bstring dl_nas = blk2bstr(nas, encoded_size);
itti_downlink_nas_transfer* dl_msg = std::shared_ptr<itti_downlink_nas_transfer> dl_msg =
new itti_downlink_nas_transfer(TASK_AMF_APP, TASK_AMF_N1); std::make_shared<itti_downlink_nas_transfer>(TASK_AMF_APP, TASK_AMF_N1);
dl_msg->dl_nas = dl_nas; dl_msg->dl_nas = dl_nas;
if (!itti_msg.is_n2sm_set) { if (!itti_msg.is_n2sm_set) {
dl_msg->is_n2sm_set = false; dl_msg->is_n2sm_set = false;
...@@ -347,13 +349,12 @@ void amf_app::handle_itti_message( ...@@ -347,13 +349,12 @@ void amf_app::handle_itti_message(
} }
amf_n1_inst->supi_2_amf_id(itti_msg.supi, dl_msg->amf_ue_ngap_id); amf_n1_inst->supi_2_amf_id(itti_msg.supi, dl_msg->amf_ue_ngap_id);
amf_n1_inst->supi_2_ran_id(itti_msg.supi, dl_msg->ran_ue_ngap_id); amf_n1_inst->supi_2_ran_id(itti_msg.supi, dl_msg->ran_ue_ngap_id);
std::shared_ptr<itti_downlink_nas_transfer> i =
std::shared_ptr<itti_downlink_nas_transfer>(dl_msg); int ret = itti_inst->send_msg(dl_msg);
int ret = itti_inst->send_msg(i);
if (0 != ret) { if (0 != ret) {
Logger::amf_app().error( Logger::amf_app().error(
"Could not send ITTI message %s to task TASK_AMF_N1", "Could not send ITTI message %s to task TASK_AMF_N1",
i->get_msg_name()); dl_msg->get_msg_name());
} }
} }
} }
...@@ -361,15 +362,11 @@ void amf_app::handle_itti_message( ...@@ -361,15 +362,11 @@ void amf_app::handle_itti_message(
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void amf_app::handle_itti_message( void amf_app::handle_itti_message(
itti_nas_signalling_establishment_request& itti_msg) { itti_nas_signalling_establishment_request& itti_msg) {
// 1. Generate amf_ue_ngap_id long amf_ue_ngap_id = 0;
// 2. Create UE Context and store related information information std::shared_ptr<ue_context> uc = {};
// 3. Send nas-pdu to task_amf_n1
long amf_ue_ngap_id = 0;
std::shared_ptr<ue_context> uc;
// Check UE Context with 5g-s-tmsi // Generate amf_ue_ngap_id
if ((amf_ue_ngap_id = itti_msg.amf_ue_ngap_id) == -1) { if ((amf_ue_ngap_id = itti_msg.amf_ue_ngap_id) == INVALID_AMF_UE_NGAP_ID) {
amf_ue_ngap_id = generate_amf_ue_ngap_id(); amf_ue_ngap_id = generate_amf_ue_ngap_id();
} }
...@@ -396,6 +393,7 @@ void amf_app::handle_itti_message( ...@@ -396,6 +393,7 @@ void amf_app::handle_itti_message(
amf_n2_inst->set_amf_ue_ngap_id_2_ue_ngap_context(amf_ue_ngap_id, unc); amf_n2_inst->set_amf_ue_ngap_id_2_ue_ngap_context(amf_ue_ngap_id, unc);
} }
// Create UE Context and store related information information
if (uc.get() == nullptr) { if (uc.get() == nullptr) {
Logger::amf_app().error( Logger::amf_app().error(
"Failed to create ue_context with ran_amf_id %s", "Failed to create ue_context with ran_amf_id %s",
...@@ -422,8 +420,10 @@ void amf_app::handle_itti_message( ...@@ -422,8 +420,10 @@ void amf_app::handle_itti_message(
Logger::amf_app().debug("Receiving GUTI %s", guti.c_str()); Logger::amf_app().debug("Receiving GUTI %s", guti.c_str());
} }
itti_uplink_nas_data_ind* itti_n1_msg = // Send NAS PDU to task_amf_n1 for further processing
new itti_uplink_nas_data_ind(TASK_AMF_APP, TASK_AMF_N1); std::shared_ptr<itti_uplink_nas_data_ind> itti_n1_msg =
std::make_shared<itti_uplink_nas_data_ind>(TASK_AMF_APP, TASK_AMF_N1);
itti_n1_msg->amf_ue_ngap_id = amf_ue_ngap_id; itti_n1_msg->amf_ue_ngap_id = amf_ue_ngap_id;
itti_n1_msg->ran_ue_ngap_id = itti_msg.ran_ue_ngap_id; itti_n1_msg->ran_ue_ngap_id = itti_msg.ran_ue_ngap_id;
itti_n1_msg->is_nas_signalling_estab_req = true; itti_n1_msg->is_nas_signalling_estab_req = true;
...@@ -434,13 +434,12 @@ void amf_app::handle_itti_message( ...@@ -434,13 +434,12 @@ void amf_app::handle_itti_message(
if (is_guti_valid) { if (is_guti_valid) {
itti_n1_msg->guti = guti; itti_n1_msg->guti = guti;
} }
std::shared_ptr<itti_uplink_nas_data_ind> i =
std::shared_ptr<itti_uplink_nas_data_ind>(itti_n1_msg); int ret = itti_inst->send_msg(itti_n1_msg);
int ret = itti_inst->send_msg(i);
if (0 != ret) { if (0 != ret) {
Logger::amf_app().error( Logger::amf_app().error(
"Could not send ITTI message %s to task TASK_AMF_N1", "Could not send ITTI message %s to task TASK_AMF_N1",
i->get_msg_name()); itti_n1_msg->get_msg_name());
} }
} }
} }
...@@ -536,12 +535,12 @@ void amf_app::handle_itti_message(itti_sbi_n1_message_notification& itti_msg) { ...@@ -536,12 +535,12 @@ void amf_app::handle_itti_message(itti_sbi_n1_message_notification& itti_msg) {
} }
*/ */
long amf_ue_ngap_id = -1; long amf_ue_ngap_id = INVALID_AMF_UE_NGAP_ID;
// Generate AMF UE NGAP ID if necessary // Generate AMF UE NGAP ID if necessary
if (!uc.get()) { // No UE context existed if (!uc.get()) { // No UE context existed
amf_ue_ngap_id = generate_amf_ue_ngap_id(); amf_ue_ngap_id = generate_amf_ue_ngap_id();
} else { } else {
if ((amf_ue_ngap_id = uc->amf_ue_ngap_id) == -1) { if ((amf_ue_ngap_id = uc->amf_ue_ngap_id) == INVALID_AMF_UE_NGAP_ID) {
amf_ue_ngap_id = generate_amf_ue_ngap_id(); amf_ue_ngap_id = generate_amf_ue_ngap_id();
} }
} }
...@@ -620,8 +619,9 @@ void amf_app::handle_itti_message(itti_sbi_n1_message_notification& itti_msg) { ...@@ -620,8 +619,9 @@ void amf_app::handle_itti_message(itti_sbi_n1_message_notification& itti_msg) {
// Step 5. Trigger the procedure following RegistrationRequest // Step 5. Trigger the procedure following RegistrationRequest
itti_uplink_nas_data_ind* itti_n1_msg = std::shared_ptr<itti_uplink_nas_data_ind> itti_n1_msg =
new itti_uplink_nas_data_ind(TASK_AMF_APP, TASK_AMF_N1); std::make_shared<itti_uplink_nas_data_ind>(TASK_AMF_APP, TASK_AMF_N1);
itti_n1_msg->amf_ue_ngap_id = amf_ue_ngap_id; itti_n1_msg->amf_ue_ngap_id = amf_ue_ngap_id;
itti_n1_msg->ran_ue_ngap_id = ran_ue_ngap_id; itti_n1_msg->ran_ue_ngap_id = ran_ue_ngap_id;
itti_n1_msg->is_nas_signalling_estab_req = true; itti_n1_msg->is_nas_signalling_estab_req = true;
...@@ -630,13 +630,11 @@ void amf_app::handle_itti_message(itti_sbi_n1_message_notification& itti_msg) { ...@@ -630,13 +630,11 @@ void amf_app::handle_itti_message(itti_sbi_n1_message_notification& itti_msg) {
itti_n1_msg->mnc = ran_node_id.getPlmnId().getMnc(); itti_n1_msg->mnc = ran_node_id.getPlmnId().getMnc();
itti_n1_msg->is_guti_valid = false; itti_n1_msg->is_guti_valid = false;
std::shared_ptr<itti_uplink_nas_data_ind> i = int ret = itti_inst->send_msg(itti_n1_msg);
std::shared_ptr<itti_uplink_nas_data_ind>(itti_n1_msg);
int ret = itti_inst->send_msg(i);
if (0 != ret) { if (0 != ret) {
Logger::amf_app().error( Logger::amf_app().error(
"Could not send ITTI message %s to task TASK_AMF_N1", "Could not send ITTI message %s to task TASK_AMF_N1",
i->get_msg_name()); itti_n1_msg->get_msg_name());
} }
return; return;
...@@ -672,8 +670,9 @@ void amf_app::handle_itti_message(itti_sbi_n1n2_message_subscribe& itti_msg) { ...@@ -672,8 +670,9 @@ void amf_app::handle_itti_message(itti_sbi_n1n2_message_subscribe& itti_msg) {
nlohmann::json response_data = {}; nlohmann::json response_data = {};
response_data["createdData"] = created_data; response_data["createdData"] = created_data;
response_data["httpResponseCode"] = 201; // TODO: response_data["httpResponseCode"] = static_cast<uint32_t>(
response_data["location"] = location; http_response_codes_e::HTTP_RESPONSE_CODE_201_CREATED);
response_data["location"] = location;
// Notify to the result // Notify to the result
if (itti_msg.promise_id > 0) { if (itti_msg.promise_id > 0) {
...@@ -693,9 +692,11 @@ void amf_app::handle_itti_message(itti_sbi_n1n2_message_unsubscribe& itti_msg) { ...@@ -693,9 +692,11 @@ void amf_app::handle_itti_message(itti_sbi_n1n2_message_unsubscribe& itti_msg) {
nlohmann::json response_data = {}; nlohmann::json response_data = {};
if (remove_n1n2_message_subscription( if (remove_n1n2_message_subscription(
itti_msg.ue_cxt_id, itti_msg.subscription_id)) { itti_msg.ue_cxt_id, itti_msg.subscription_id)) {
response_data["httpResponseCode"] = 204; // TODO: response_data["httpResponseCode"] = static_cast<uint32_t>(
http_response_codes_e::HTTP_RESPONSE_CODE_204_NO_CONTENT);
} else { } else {
response_data["httpResponseCode"] = 400; // TODO: response_data["httpResponseCode"] = static_cast<uint32_t>(
http_response_codes_e::HTTP_RESPONSE_CODE_BAD_REQUEST);
oai::amf::model::ProblemDetails problem_details = {}; oai::amf::model::ProblemDetails problem_details = {};
// TODO set problem_details // TODO set problem_details
to_json(response_data["ProblemDetails"], problem_details); to_json(response_data["ProblemDetails"], problem_details);
...@@ -721,9 +722,11 @@ void amf_app::handle_itti_message(itti_sbi_amf_configuration& itti_msg) { ...@@ -721,9 +722,11 @@ void amf_app::handle_itti_message(itti_sbi_amf_configuration& itti_msg) {
if (read_amf_configuration(response_data["content"])) { if (read_amf_configuration(response_data["content"])) {
Logger::amf_app().debug( Logger::amf_app().debug(
"AMF configuration:\n %s", response_data["content"].dump().c_str()); "AMF configuration:\n %s", response_data["content"].dump().c_str());
response_data["httpResponseCode"] = 200; // TODO: response_data["httpResponseCode"] =
static_cast<uint32_t>(http_response_codes_e::HTTP_RESPONSE_CODE_200_OK);
} else { } else {
response_data["httpResponseCode"] = 400; // TODO: response_data["httpResponseCode"] = static_cast<uint32_t>(
http_response_codes_e::HTTP_RESPONSE_CODE_BAD_REQUEST);
oai::amf::model::ProblemDetails problem_details = {}; oai::amf::model::ProblemDetails problem_details = {};
// TODO set problem_details // TODO set problem_details
to_json(response_data["ProblemDetails"], problem_details); to_json(response_data["ProblemDetails"], problem_details);
...@@ -750,7 +753,8 @@ void amf_app::handle_itti_message(itti_sbi_update_amf_configuration& itti_msg) { ...@@ -750,7 +753,8 @@ void amf_app::handle_itti_message(itti_sbi_update_amf_configuration& itti_msg) {
if (update_amf_configuration(response_data["content"])) { if (update_amf_configuration(response_data["content"])) {
Logger::amf_app().debug( Logger::amf_app().debug(
"AMF configuration:\n %s", response_data["content"].dump().c_str()); "AMF configuration:\n %s", response_data["content"].dump().c_str());
response_data["httpResponseCode"] = 200; // TODO: response_data["httpResponseCode"] =
static_cast<uint32_t>(http_response_codes_e::HTTP_RESPONSE_CODE_200_OK);
// Update AMF profile // Update AMF profile
generate_amf_profile(); generate_amf_profile();
...@@ -762,7 +766,8 @@ void amf_app::handle_itti_message(itti_sbi_update_amf_configuration& itti_msg) { ...@@ -762,7 +766,8 @@ void amf_app::handle_itti_message(itti_sbi_update_amf_configuration& itti_msg) {
register_to_nrf(); register_to_nrf();
} else { } else {
response_data["httpResponseCode"] = 400; // TODO: response_data["httpResponseCode"] = static_cast<uint32_t>(
http_response_codes_e::HTTP_RESPONSE_CODE_BAD_REQUEST);
oai::amf::model::ProblemDetails problem_details = {}; oai::amf::model::ProblemDetails problem_details = {};
// TODO set problem_details // TODO set problem_details
to_json(response_data["ProblemDetails"], problem_details); to_json(response_data["ProblemDetails"], problem_details);
...@@ -925,8 +930,8 @@ bool amf_app::handle_nf_status_notification( ...@@ -925,8 +930,8 @@ bool amf_app::handle_nf_status_notification(
"Handle a NF status notification from NRF (HTTP version " "Handle a NF status notification from NRF (HTTP version "
"%d)", "%d)",
msg->http_version); msg->http_version);
// TODO http_code = static_cast<uint32_t>(
http_code = 204; // HTTP_STATUS_CODE_204_NO_CONTENT; http_response_codes_e::HTTP_RESPONSE_CODE_204_NO_CONTENT);
return true; return true;
} }
......
...@@ -138,12 +138,20 @@ void amf_n1_task(void*) { ...@@ -138,12 +138,20 @@ void amf_n1_task(void*) {
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
amf_n1::amf_n1() { amf_n1::amf_n1()
: m_amfueid2nas_context(), m_nas_context(), m_guti2nas_context() {
if (itti_inst->create_task(TASK_AMF_N1, amf_n1_task, nullptr)) { if (itti_inst->create_task(TASK_AMF_N1, amf_n1_task, nullptr)) {
Logger::amf_n1().error("Cannot create task TASK_AMF_N1"); Logger::amf_n1().error("Cannot create task TASK_AMF_N1");
throw std::runtime_error("Cannot create task TASK_AMF_N1"); throw std::runtime_error("Cannot create task TASK_AMF_N1");
} }
Logger::amf_n1().startup("amf_n1 started"); amfueid2nas_context = {};
imsi2nas_context = {};
supi2amfId = {};
supi2ranId = {};
guti2nas_context = {};
random_state = {};
db_desc = {};
db_desc.db_conn = nullptr;
// EventExposure: subscribe to UE Location Report // EventExposure: subscribe to UE Location Report
ee_ue_location_report_connection = event_sub.subscribe_ue_location_report( ee_ue_location_report_connection = event_sub.subscribe_ue_location_report(
...@@ -173,6 +181,8 @@ amf_n1::amf_n1() { ...@@ -173,6 +181,8 @@ amf_n1::amf_n1() {
ee_ue_communication_failure_connection = ee_ue_communication_failure_connection =
event_sub.subscribe_ue_communication_failure(boost::bind( event_sub.subscribe_ue_communication_failure(boost::bind(
&amf_n1::handle_ue_communication_failure_change, this, _1, _2, _3)); &amf_n1::handle_ue_communication_failure_change, this, _1, _2, _3));
Logger::amf_n1().startup("amf_n1 started");
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -774,9 +784,16 @@ void amf_n1::identity_response_handle( ...@@ -774,9 +784,16 @@ void amf_n1::identity_response_handle(
stacs.update_ue_info(ueItem); stacs.update_ue_info(ueItem);
set_5gmm_state(nc, _5GMM_COMMON_PROCEDURE_INITIATED); set_5gmm_state(nc, _5GMM_COMMON_PROCEDURE_INITIATED);
// stacs.display(); // stacs.display();
nc.get()->is_stacs_available = true; nc.get()->is_stacs_available = true;
} }
set_5gmm_state(nc, _5GMM_COMMON_PROCEDURE_INITIATED);
string supi = "imsi-" + nc.get()->imsi;
Logger::amf_n1().debug(
"Signal the UE Registration State Event notification for SUPI %s",
supi.c_str());
event_sub.ue_registration_state(supi, _5GMM_COMMON_PROCEDURE_INITIATED, 1);
// TODO: Trigger UE Location Report // TODO: Trigger UE Location Report
run_registration_procedure(nc); run_registration_procedure(nc);
...@@ -820,7 +837,7 @@ void amf_n1::service_request_handle( ...@@ -820,7 +837,7 @@ void amf_n1::service_request_handle(
} }
set_amf_ue_ngap_id_2_nas_context(amf_ue_ngap_id, nc); set_amf_ue_ngap_id_2_nas_context(amf_ue_ngap_id, nc);
nas_secu_ctx* secu = nc.get()->security_ctx; nas_secu_ctx* secu = nc.get()->security_ctx; // TODO: remove naked ptr
if (!secu) { if (!secu) {
Logger::amf_n1().error("No Security Context found"); Logger::amf_n1().error("No Security Context found");
return; return;
...@@ -872,7 +889,12 @@ void amf_n1::service_request_handle( ...@@ -872,7 +889,12 @@ void amf_n1::service_request_handle(
// Get PDU Session Status from NAS Message Container if available // Get PDU Session Status from NAS Message Container if available
bstring plain_msg; bstring plain_msg;
if (service_request->getNasMessageContainer(plain_msg)) { if (service_request->getNasMessageContainer(plain_msg)) {
uint8_t* buf_nas = (uint8_t*) bdata(plain_msg); if (blength(plain_msg) < NAS_MESSAGE_MIN_LENGTH) {
Logger::amf_n1().debug("NAS message too short!");
return;
}
uint8_t* buf_nas = (uint8_t*) bdata(plain_msg); // TODO
uint8_t message_type = *(buf_nas + 2); uint8_t message_type = *(buf_nas + 2);
Logger::amf_n1().debug("NAS message type 0x%x", message_type); Logger::amf_n1().debug("NAS message type 0x%x", message_type);
...@@ -1161,7 +1183,7 @@ void amf_n1::registration_request_handle( ...@@ -1161,7 +1183,7 @@ void amf_n1::registration_request_handle(
nc.get()->serving_network = snn; nc.get()->serving_network = snn;
nc.get()->is_5g_guti_present = true; nc.get()->is_5g_guti_present = true;
nc.get()->to_be_register_by_new_suci = true; nc.get()->to_be_register_by_new_suci = true;
nc.get()->ngKsi = 100 & 0xf; nc.get()->ngKsi = 100 & 0xf; // TODO: remove hardcoded value
// nc.get()->imsi = // nc.get()->imsi =
// set_supi_2_amf_id("imsi-" + nc.get()->imsi, amf_ue_ngap_id); // set_supi_2_amf_id("imsi-" + nc.get()->imsi, amf_ue_ngap_id);
// set_supi_2_ran_id("imsi-" + nc.get()->imsi, ran_ue_ngap_id); // set_supi_2_ran_id("imsi-" + nc.get()->imsi, ran_ue_ngap_id);
...@@ -1728,14 +1750,12 @@ void amf_n1::run_registration_procedure(std::shared_ptr<nas_context>& nc) { ...@@ -1728,14 +1750,12 @@ void amf_n1::run_registration_procedure(std::shared_ptr<nas_context>& nc) {
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Get authentication vectors either from AUSF(UDM) or from AMF (generate
// locally)
bool amf_n1::auth_vectors_generator(std::shared_ptr<nas_context>& nc) { bool amf_n1::auth_vectors_generator(std::shared_ptr<nas_context>& nc) {
Logger::amf_n1().debug("Start to generate Authentication Vectors"); Logger::amf_n1().debug("Start to generate Authentication Vectors");
if (amf_cfg.support_features.enable_external_ausf) { if (amf_cfg.support_features.enable_external_ausf) {
// get authentication vectors from AUSF // get authentication vectors from AUSF
if (!get_authentication_vectors_from_ausf(nc)) return false; if (!get_authentication_vectors_from_ausf(nc)) return false;
} else { } else { // Generate locally
authentication_vectors_generator_in_udm(nc); authentication_vectors_generator_in_udm(nc);
authentication_vectors_generator_in_ausf(nc); authentication_vectors_generator_in_ausf(nc);
Logger::amf_n1().debug("Deriving kamf"); Logger::amf_n1().debug("Deriving kamf");
...@@ -1752,14 +1772,15 @@ bool amf_n1::auth_vectors_generator(std::shared_ptr<nas_context>& nc) { ...@@ -1752,14 +1772,15 @@ bool amf_n1::auth_vectors_generator(std::shared_ptr<nas_context>& nc) {
bool amf_n1::get_authentication_vectors_from_ausf( bool amf_n1::get_authentication_vectors_from_ausf(
std::shared_ptr<nas_context>& nc) { std::shared_ptr<nas_context>& nc) {
Logger::amf_n1().debug("Get Authentication Vectors from AUSF"); Logger::amf_n1().debug("Get Authentication Vectors from AUSF");
// TODO: remove naked ptr
UEAuthenticationCtx ueauthenticationctx = {}; UEAuthenticationCtx ueauthenticationctx = {};
AuthenticationInfo authenticationinfo = {}; AuthenticationInfo authenticationinfo = {};
authenticationinfo.setSupiOrSuci(nc.get()->imsi); authenticationinfo.setSupiOrSuci(nc.get()->imsi);
authenticationinfo.setServingNetworkName(nc.get()->serving_network); authenticationinfo.setServingNetworkName(nc.get()->serving_network);
ResynchronizationInfo resynchronizationInfo = {}; ResynchronizationInfo resynchronizationInfo = {};
uint8_t auts_len = blength(nc.get()->auts); uint8_t auts_len = blength(nc.get()->auts); // TODO
uint8_t* auts_value = (uint8_t*) bdata(nc.get()->auts); uint8_t* auts_value = (uint8_t*) bdata(nc.get()->auts); // TODO
std::string authenticationinfo_auts = {}; std::string authenticationinfo_auts = {};
std::string authenticationinfo_rand = {}; std::string authenticationinfo_rand = {};
if (auts_value) { if (auts_value) {
...@@ -1840,6 +1861,7 @@ bool amf_n1::get_authentication_vectors_from_ausf( ...@@ -1840,6 +1861,7 @@ bool amf_n1::get_authentication_vectors_from_ausf(
bool amf_n1::_5g_aka_confirmation_from_ausf( bool amf_n1::_5g_aka_confirmation_from_ausf(
std::shared_ptr<nas_context>& nc, bstring resStar) { std::shared_ptr<nas_context>& nc, bstring resStar) {
Logger::amf_n1().debug("5G AKA Confirmation from AUSF"); Logger::amf_n1().debug("5G AKA Confirmation from AUSF");
// TODO: remove naked ptr
std::string remoteUri = nc.get()->Href; std::string remoteUri = nc.get()->Href;
std::string msgBody = {}; std::string msgBody = {};
...@@ -1905,9 +1927,9 @@ bool amf_n1::_5g_aka_confirmation_from_ausf( ...@@ -1905,9 +1927,9 @@ bool amf_n1::_5g_aka_confirmation_from_ausf(
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool amf_n1::authentication_vectors_generator_in_ausf( bool amf_n1::authentication_vectors_generator_in_ausf(
std::shared_ptr<nas_context>& nc) { // A.5, 3gpp ts33.501 std::shared_ptr<nas_context>& nc) { // A.5, 3gpp ts33.501
// TODO: remove naked ptr
Logger::amf_n1().debug( Logger::amf_n1().debug(
"Generate Authentication Vectors in AUSF"); // Actually, done locally in "Generate Authentication Vectors in AUSF (locally in AMF)");
// AMF
uint8_t inputString[MAX_5GS_AUTH_VECTORS][40]; uint8_t inputString[MAX_5GS_AUTH_VECTORS][40];
uint8_t* xresStar[MAX_5GS_AUTH_VECTORS]; uint8_t* xresStar[MAX_5GS_AUTH_VECTORS];
uint8_t* rand[MAX_5GS_AUTH_VECTORS]; uint8_t* rand[MAX_5GS_AUTH_VECTORS];
...@@ -1933,7 +1955,9 @@ bool amf_n1::authentication_vectors_generator_in_ausf( ...@@ -1933,7 +1955,9 @@ bool amf_n1::authentication_vectors_generator_in_ausf(
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool amf_n1::authentication_vectors_generator_in_udm( bool amf_n1::authentication_vectors_generator_in_udm(
std::shared_ptr<nas_context>& nc) { std::shared_ptr<nas_context>& nc) {
Logger::amf_n1().debug("Generate Authentication Vectors"); // TODO: remove naked ptr
Logger::amf_n1().debug(
"Generate Authentication Vectors in UDM (locally in AMF)");
uint8_t* sqn = nullptr; uint8_t* sqn = nullptr;
uint8_t* auts = (uint8_t*) bdata(nc.get()->auts); uint8_t* auts = (uint8_t*) bdata(nc.get()->auts);
_5G_HE_AV_t* vector = nc.get()->_5g_he_av; _5G_HE_AV_t* vector = nc.get()->_5g_he_av;
......
...@@ -277,7 +277,8 @@ class amf_n1 { ...@@ -277,7 +277,8 @@ class amf_n1 {
std::shared_ptr<nas_context>& nc, bstring& nas_msg); std::shared_ptr<nas_context>& nc, bstring& nas_msg);
/* /*
* Generate the Authentication Vectors * Generate the Authentication Vectors (either from AUSF(UDM) or generate
* locally in AMF)
* @param [std::shared_ptr<nas_context>&] nc: Pointer to the UE NAS Context * @param [std::shared_ptr<nas_context>&] nc: Pointer to the UE NAS Context
* @return true if generated successfully, otherwise return false * @return true if generated successfully, otherwise return false
*/ */
...@@ -832,16 +833,6 @@ class amf_n1 { ...@@ -832,16 +833,6 @@ class amf_n1 {
std::string supi, oai::amf::model::CommunicationFailure, std::string supi, oai::amf::model::CommunicationFailure,
uint8_t http_version); uint8_t http_version);
// for Event Handling
amf_event event_sub;
bs2::connection ee_ue_location_report_connection;
bs2::connection ee_ue_reachability_status_connection;
bs2::connection ee_ue_registration_state_connection;
bs2::connection ee_ue_connectivity_state_connection;
bs2::connection ee_ue_loss_of_connectivity_connection;
bs2::connection ee_ue_communication_failure_connection;
private:
/* /*
* Handle UE-initiated Deregistration Request message * Handle UE-initiated Deregistration Request message
* @param [const uint32_t] ran_ue_ngap_id: RAN UE NGAP ID * @param [const uint32_t] ran_ue_ngap_id: RAN UE NGAP ID
...@@ -986,6 +977,16 @@ class amf_n1 { ...@@ -986,6 +977,16 @@ class amf_n1 {
const uint8_t cause_value, const uint32_t ran_ue_ngap_id, const uint8_t cause_value, const uint32_t ran_ue_ngap_id,
const long amf_ue_ngap_id); const long amf_ue_ngap_id);
// for Event Handling
amf_event event_sub;
bs2::connection ee_ue_location_report_connection;
bs2::connection ee_ue_reachability_status_connection;
bs2::connection ee_ue_registration_state_connection;
bs2::connection ee_ue_connectivity_state_connection;
bs2::connection ee_ue_loss_of_connectivity_connection;
bs2::connection ee_ue_communication_failure_connection;
private:
std::map<long, std::shared_ptr<nas_context>> std::map<long, std::shared_ptr<nas_context>>
amfueid2nas_context; // amf ue ngap id amfueid2nas_context; // amf ue ngap id
mutable std::shared_mutex m_amfueid2nas_context; mutable std::shared_mutex m_amfueid2nas_context;
...@@ -1001,7 +1002,7 @@ class amf_n1 { ...@@ -1001,7 +1002,7 @@ class amf_n1 {
static std::map<std::string, std::string> rand_record; static std::map<std::string, std::string> rand_record;
static uint8_t no_random_delta; static uint8_t no_random_delta;
random_state_t random_state; random_state_t random_state;
database_t* db_desc; database_t db_desc;
}; };
} // namespace amf_application } // namespace amf_application
......
...@@ -227,11 +227,13 @@ void amf_n2_task(void* args_p) { ...@@ -227,11 +227,13 @@ void amf_n2_task(void* args_p) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
amf_n2::amf_n2(const std::string& address, const uint16_t port_num) amf_n2::amf_n2(const std::string& address, const uint16_t port_num)
: ngap_app(address, port_num) { : ngap_app(address, port_num), m_ranid2uecontext(), m_amfueid2uecontext() {
if (itti_inst->create_task(TASK_AMF_N2, amf_n2_task, nullptr)) { if (itti_inst->create_task(TASK_AMF_N2, amf_n2_task, nullptr)) {
Logger::amf_n2().error("Cannot create task TASK_AMF_N2"); Logger::amf_n2().error("Cannot create task TASK_AMF_N2");
throw std::runtime_error("Cannot create task TASK_AMF_N2"); throw std::runtime_error("Cannot create task TASK_AMF_N2");
} }
ranid2uecontext = {};
amfueid2uecontext = {};
Logger::amf_n2().startup("amf_n2 started"); Logger::amf_n2().startup("amf_n2 started");
} }
...@@ -411,17 +413,17 @@ void amf_n2::handle_itti_message(itti_ng_setup_request& itti_msg) { ...@@ -411,17 +413,17 @@ void amf_n2::handle_itti_message(itti_ng_setup_request& itti_msg) {
Logger::amf_n2().debug("Encoding NG_SETUP_RESPONSE ..."); Logger::amf_n2().debug("Encoding NG_SETUP_RESPONSE ...");
// encode NG SETUP RESPONSE message with information stored in configuration // encode NG SETUP RESPONSE message with information stored in configuration
// file and send_msg // file and send_msg
uint8_t* buffer = (uint8_t*) calloc(1, BUFFER_SIZE_1024); uint8_t* buffer = (uint8_t*) calloc(1, BUFFER_SIZE_1024);
NGSetupResponseMsg ngSetupResp; NGSetupResponseMsg ngSetupResp = {};
ngSetupResp.setAMFName(amf_cfg.amf_name); ngSetupResp.setAMFName(amf_cfg.amf_name);
std::vector<struct GuamiItem_s> guami_list; std::vector<GuamiItem_t> guami_list;
for (int i = 0; i < amf_cfg.guami_list.size(); i++) { for (int i = 0; i < amf_cfg.guami_list.size(); i++) {
struct GuamiItem_s tmp; GuamiItem_t tmp = {};
tmp.mcc = amf_cfg.guami_list[i].mcc; tmp.mcc = amf_cfg.guami_list[i].mcc;
tmp.mnc = amf_cfg.guami_list[i].mnc; tmp.mnc = amf_cfg.guami_list[i].mnc;
tmp.regionID = amf_cfg.guami_list[i].regionID; tmp.regionID = amf_cfg.guami_list[i].regionID;
tmp.AmfSetID = amf_cfg.guami_list[i].AmfSetID; tmp.AmfSetID = amf_cfg.guami_list[i].AmfSetID;
tmp.AmfPointer = amf_cfg.guami_list[i].AmfPointer; tmp.AmfPointer = amf_cfg.guami_list[i].AmfPointer;
guami_list.push_back(tmp); guami_list.push_back(tmp);
} }
ngSetupResp.setGUAMIList(guami_list); ngSetupResp.setGUAMIList(guami_list);
...@@ -429,13 +431,13 @@ void amf_n2::handle_itti_message(itti_ng_setup_request& itti_msg) { ...@@ -429,13 +431,13 @@ void amf_n2::handle_itti_message(itti_ng_setup_request& itti_msg) {
ngSetupResp.setRelativeAmfCapacity(amf_cfg.relative_amf_capacity); ngSetupResp.setRelativeAmfCapacity(amf_cfg.relative_amf_capacity);
std::vector<PlmnSliceSupport_t> plmn_list; std::vector<PlmnSliceSupport_t> plmn_list;
for (int i = 0; i < amf_cfg.plmn_list.size(); i++) { for (int i = 0; i < amf_cfg.plmn_list.size(); i++) {
PlmnSliceSupport_t tmp; PlmnSliceSupport_t tmp = {};
tmp.mcc = amf_cfg.plmn_list[i].mcc; tmp.mcc = amf_cfg.plmn_list[i].mcc;
tmp.mnc = amf_cfg.plmn_list[i].mnc; tmp.mnc = amf_cfg.plmn_list[i].mnc;
for (int j = 0; j < amf_cfg.plmn_list[i].slice_list.size(); j++) { for (int j = 0; j < amf_cfg.plmn_list[i].slice_list.size(); j++) {
S_Nssai s_tmp; S_Nssai s_tmp = {};
s_tmp.sst = std::to_string(amf_cfg.plmn_list[i].slice_list[j].sst); s_tmp.sst = std::to_string(amf_cfg.plmn_list[i].slice_list[j].sst);
s_tmp.sd = std::to_string(amf_cfg.plmn_list[i].slice_list[j].sd); s_tmp.sd = std::to_string(amf_cfg.plmn_list[i].slice_list[j].sd);
tmp.slice_list.push_back(s_tmp); tmp.slice_list.push_back(s_tmp);
} }
plmn_list.push_back(tmp); plmn_list.push_back(tmp);
...@@ -717,7 +719,7 @@ void amf_n2::handle_itti_message(itti_initial_ue_message& init_ue_msg) { ...@@ -717,7 +719,7 @@ void amf_n2::handle_itti_message(itti_initial_ue_message& init_ue_msg) {
} }
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 = -1; itti_msg->amf_ue_ngap_id = INVALID_AMF_UE_NGAP_ID;
int ret = itti_inst->send_msg(itti_msg); int ret = itti_inst->send_msg(itti_msg);
if (0 != ret) { if (0 != ret) {
......
...@@ -77,6 +77,7 @@ class nf_profile : public std::enable_shared_from_this<nf_profile> { ...@@ -77,6 +77,7 @@ class nf_profile : public std::enable_shared_from_this<nf_profile> {
return *this; return *this;
} }
// nf_profile(nf_profile &b) = delete; // nf_profile(nf_profile &b) = delete;
virtual ~nf_profile() {}
/* /*
* Set NF instance ID * Set NF instance ID
......
...@@ -857,7 +857,8 @@ bool amf_sbi::discover_smf( ...@@ -857,7 +857,8 @@ bool amf_sbi::discover_smf(
"NFDiscovery, response from NRF, json data: \n %s", "NFDiscovery, response from NRF, json data: \n %s",
response_data.dump().c_str()); response_data.dump().c_str());
if (response_code != 200) { if (static_cast<http_response_codes_e>(response_code) !=
http_response_codes_e::HTTP_RESPONSE_CODE_200_OK) {
Logger::amf_sbi().warn("NFDiscovery, could not get response from NRF"); Logger::amf_sbi().warn("NFDiscovery, could not get response from NRF");
result = false; result = false;
} else { } else {
...@@ -1001,8 +1002,10 @@ bool amf_sbi::send_ue_authentication_request( ...@@ -1001,8 +1002,10 @@ bool amf_sbi::send_ue_authentication_request(
Logger::amf_sbi().debug( Logger::amf_sbi().debug(
"UE Authentication, response from AUSF, HTTP Code: %d", response_code); "UE Authentication, response from AUSF, HTTP Code: %d", response_code);
if ((response_code == 200) or if ((static_cast<http_response_codes_e>(response_code) ==
(response_code == 201)) { // TODO: remove hardcoded value http_response_codes_e::HTTP_RESPONSE_CODE_200_OK) or
(static_cast<http_response_codes_e>(response_code) ==
http_response_codes_e::HTTP_RESPONSE_CODE_201_CREATED)) {
Logger::amf_sbi().debug( Logger::amf_sbi().debug(
"UE Authentication, response from AUSF\n, %s ", "UE Authentication, response from AUSF\n, %s ",
response_data.dump().c_str()); response_data.dump().c_str());
...@@ -1652,7 +1655,8 @@ bool amf_sbi::get_nrf_uri( ...@@ -1652,7 +1655,8 @@ bool amf_sbi::get_nrf_uri(
"NS Selection, response from NSSF, json data: \n %s", "NS Selection, response from NSSF, json data: \n %s",
response_data.dump().c_str()); response_data.dump().c_str());
if (response_code != 200) { if (static_cast<http_response_codes_e>(response_code) !=
http_response_codes_e::HTTP_RESPONSE_CODE_200_OK) {
Logger::amf_sbi().warn("NS Selection, could not get response from NSSF"); Logger::amf_sbi().warn("NS Selection, could not get response from NSSF");
result = false; result = false;
} else { } else {
......
...@@ -124,7 +124,7 @@ class statistics { ...@@ -124,7 +124,7 @@ class statistics {
*/ */
uint32_t get_number_connected_gnbs() const; uint32_t get_number_connected_gnbs() const;
public: private:
uint32_t gNB_connected; uint32_t gNB_connected;
uint32_t UE_connected; uint32_t UE_connected;
uint32_t UE_registred; uint32_t UE_registred;
......
...@@ -37,22 +37,22 @@ bool amf_n1::get_mysql_auth_info( ...@@ -37,22 +37,22 @@ bool amf_n1::get_mysql_auth_info(
MYSQL_ROW row; MYSQL_ROW row;
std::string query; std::string query;
if (!db_desc->db_conn) { if (!db_desc.db_conn) {
Logger::amf_n1().error("Cannot connect to MySQL DB"); Logger::amf_n1().error("Cannot connect to MySQL DB");
return false; return false;
} }
query = query =
"SELECT `key`,`sqn`,`rand`,`OPc` FROM `users` WHERE `users`.`imsi`='" + "SELECT `key`,`sqn`,`rand`,`OPc` FROM `users` WHERE `users`.`imsi`='" +
imsi + "' "; imsi + "' ";
pthread_mutex_lock(&db_desc->db_cs_mutex); pthread_mutex_lock(&db_desc.db_cs_mutex);
if (mysql_query(db_desc->db_conn, query.c_str())) { if (mysql_query(db_desc.db_conn, query.c_str())) {
pthread_mutex_unlock(&db_desc->db_cs_mutex); pthread_mutex_unlock(&db_desc.db_cs_mutex);
Logger::amf_n1().error( Logger::amf_n1().error(
"Query execution failed: %s\n", mysql_error(db_desc->db_conn)); "Query execution failed: %s\n", mysql_error(db_desc.db_conn));
return false; return false;
} }
res = mysql_store_result(db_desc->db_conn); res = mysql_store_result(db_desc.db_conn);
pthread_mutex_unlock(&db_desc->db_cs_mutex); pthread_mutex_unlock(&db_desc.db_cs_mutex);
if (!res) { if (!res) {
Logger::amf_n1().error("Data fetched from MySQL is not present"); Logger::amf_n1().error("Data fetched from MySQL is not present");
return false; return false;
...@@ -81,29 +81,24 @@ bool amf_n1::get_mysql_auth_info( ...@@ -81,29 +81,24 @@ bool amf_n1::get_mysql_auth_info(
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool amf_n1::connect_to_mysql() { bool amf_n1::connect_to_mysql() {
const int mysql_reconnect_val = 1; const int mysql_reconnect_val = 1;
db_desc = (database_t*) calloc(1, sizeof(database_t));
if (!db_desc) { pthread_mutex_init(&db_desc.db_cs_mutex, NULL);
Logger::amf_n1().error( db_desc.server = amf_cfg.auth_para.mysql_server;
"An error occurs when allocating memory for DB_DESC"); db_desc.user = amf_cfg.auth_para.mysql_user;
return false; db_desc.password = amf_cfg.auth_para.mysql_pass;
} db_desc.database = amf_cfg.auth_para.mysql_db;
pthread_mutex_init(&db_desc->db_cs_mutex, NULL); db_desc.db_conn = mysql_init(NULL);
db_desc->server = amf_cfg.auth_para.mysql_server; mysql_options(db_desc.db_conn, MYSQL_OPT_RECONNECT, &mysql_reconnect_val);
db_desc->user = amf_cfg.auth_para.mysql_user;
db_desc->password = amf_cfg.auth_para.mysql_pass;
db_desc->database = amf_cfg.auth_para.mysql_db;
db_desc->db_conn = mysql_init(NULL);
mysql_options(db_desc->db_conn, MYSQL_OPT_RECONNECT, &mysql_reconnect_val);
if (!mysql_real_connect( if (!mysql_real_connect(
db_desc->db_conn, db_desc->server.c_str(), db_desc->user.c_str(), db_desc.db_conn, db_desc.server.c_str(), db_desc.user.c_str(),
db_desc->password.c_str(), db_desc->database.c_str(), 0, NULL, 0)) { db_desc.password.c_str(), db_desc.database.c_str(), 0, NULL, 0)) {
Logger::amf_n1().error( Logger::amf_n1().error(
"An error occurred while connecting to db: %s", "An error occurred while connecting to db: %s",
mysql_error(db_desc->db_conn)); mysql_error(db_desc.db_conn));
mysql_thread_end(); mysql_thread_end();
return false; return false;
} }
mysql_set_server_option(db_desc->db_conn, MYSQL_OPTION_MULTI_STATEMENTS_ON); mysql_set_server_option(db_desc.db_conn, MYSQL_OPTION_MULTI_STATEMENTS_ON);
return true; return true;
} }
...@@ -115,7 +110,7 @@ void amf_n1::mysql_push_rand_sqn( ...@@ -115,7 +110,7 @@ void amf_n1::mysql_push_rand_sqn(
char query[1000]; char query[1000];
int query_length = 0; int query_length = 0;
uint64_t sqn_decimal = 0; uint64_t sqn_decimal = 0;
if (!db_desc->db_conn) { if (!db_desc.db_conn) {
Logger::amf_n1().error("Cannot connect to MySQL DB"); Logger::amf_n1().error("Cannot connect to MySQL DB");
return; return;
} }
...@@ -135,31 +130,30 @@ void amf_n1::mysql_push_rand_sqn( ...@@ -135,31 +130,30 @@ void amf_n1::mysql_push_rand_sqn(
sprintf(&query[query_length], "'),`sqn`=%" PRIu64, sqn_decimal); sprintf(&query[query_length], "'),`sqn`=%" PRIu64, sqn_decimal);
query_length += query_length +=
sprintf(&query[query_length], " WHERE `users`.`imsi`='%s'", imsi.c_str()); sprintf(&query[query_length], " WHERE `users`.`imsi`='%s'", imsi.c_str());
pthread_mutex_lock(&db_desc->db_cs_mutex); pthread_mutex_lock(&db_desc.db_cs_mutex);
if (mysql_query(db_desc->db_conn, query)) { if (mysql_query(db_desc.db_conn, query)) {
pthread_mutex_unlock(&db_desc->db_cs_mutex); pthread_mutex_unlock(&db_desc.db_cs_mutex);
Logger::amf_n1().error( Logger::amf_n1().error(
"Query execution failed: %s", mysql_error(db_desc->db_conn)); "Query execution failed: %s", mysql_error(db_desc.db_conn));
return; return;
} }
do { do {
res = mysql_store_result(db_desc->db_conn); res = mysql_store_result(db_desc.db_conn);
if (res) { if (res) {
mysql_free_result(res); mysql_free_result(res);
} else { } else {
if (mysql_field_count(db_desc->db_conn) == 0) { if (mysql_field_count(db_desc.db_conn) == 0) {
Logger::amf_n1().debug( Logger::amf_n1().debug(
"[MySQL] %lld rows affected", "[MySQL] %lld rows affected", mysql_affected_rows(db_desc.db_conn));
mysql_affected_rows(db_desc->db_conn));
} else { /* some error occurred */ } else { /* some error occurred */
Logger::amf_n1().error("Could not retrieve result set"); Logger::amf_n1().error("Could not retrieve result set");
break; break;
} }
} }
if ((status = mysql_next_result(db_desc->db_conn)) > 0) if ((status = mysql_next_result(db_desc.db_conn)) > 0)
Logger::amf_n1().error("Could not execute statement"); Logger::amf_n1().error("Could not execute statement");
} while (status == 0); } while (status == 0);
pthread_mutex_unlock(&db_desc->db_cs_mutex); pthread_mutex_unlock(&db_desc.db_cs_mutex);
return; return;
} }
...@@ -168,7 +162,7 @@ void amf_n1::mysql_increment_sqn(const std::string& imsi) { ...@@ -168,7 +162,7 @@ void amf_n1::mysql_increment_sqn(const std::string& imsi) {
int status; int status;
MYSQL_RES* res; MYSQL_RES* res;
char query[1000]; char query[1000];
if (db_desc->db_conn == NULL) { if (db_desc.db_conn == NULL) {
Logger::amf_n1().error("Cannot connect to MySQL DB"); Logger::amf_n1().error("Cannot connect to MySQL DB");
return; return;
} }
...@@ -176,31 +170,30 @@ void amf_n1::mysql_increment_sqn(const std::string& imsi) { ...@@ -176,31 +170,30 @@ void amf_n1::mysql_increment_sqn(const std::string& imsi) {
query, "UPDATE `users` SET `sqn` = `sqn` + 32 WHERE `users`.`imsi`='%s'", query, "UPDATE `users` SET `sqn` = `sqn` + 32 WHERE `users`.`imsi`='%s'",
imsi.c_str()); imsi.c_str());
pthread_mutex_lock(&db_desc->db_cs_mutex); pthread_mutex_lock(&db_desc.db_cs_mutex);
if (mysql_query(db_desc->db_conn, query)) { if (mysql_query(db_desc.db_conn, query)) {
pthread_mutex_unlock(&db_desc->db_cs_mutex); pthread_mutex_unlock(&db_desc.db_cs_mutex);
Logger::amf_n1().error( Logger::amf_n1().error(
"Query execution failed: %s", mysql_error(db_desc->db_conn)); "Query execution failed: %s", mysql_error(db_desc.db_conn));
return; return;
} }
do { do {
res = mysql_store_result(db_desc->db_conn); res = mysql_store_result(db_desc.db_conn);
if (res) { if (res) {
mysql_free_result(res); mysql_free_result(res);
} else { } else {
if (mysql_field_count(db_desc->db_conn) == 0) { if (mysql_field_count(db_desc.db_conn) == 0) {
Logger::amf_n1().debug( Logger::amf_n1().debug(
"[MySQL] %lld rows affected", "[MySQL] %lld rows affected", mysql_affected_rows(db_desc.db_conn));
mysql_affected_rows(db_desc->db_conn));
} else { } else {
Logger::amf_n1().error("Could not retrieve result set"); Logger::amf_n1().error("Could not retrieve result set");
break; break;
} }
} }
if ((status = mysql_next_result(db_desc->db_conn)) > 0) if ((status = mysql_next_result(db_desc.db_conn)) > 0)
Logger::amf_n1().error("Could not execute statement"); Logger::amf_n1().error("Could not execute statement");
} while (status == 0); } while (status == 0);
pthread_mutex_unlock(&db_desc->db_cs_mutex); pthread_mutex_unlock(&db_desc.db_cs_mutex);
return; return;
} }
...@@ -42,6 +42,8 @@ constexpr auto CURL_MIME_BOUNDARY = "----Boundary"; ...@@ -42,6 +42,8 @@ constexpr auto CURL_MIME_BOUNDARY = "----Boundary";
#define GNB_UE_NGAP_ID_FMT "%" PRIu32 #define GNB_UE_NGAP_ID_FMT "%" PRIu32
#define AMF_UE_NGAP_ID_FMT "%" PRIu64 #define AMF_UE_NGAP_ID_FMT "%" PRIu64
constexpr long INVALID_AMF_UE_NGAP_ID = -1;
// Event Subscription IDs) // Event Subscription IDs)
typedef uint32_t evsub_id_t; typedef uint32_t evsub_id_t;
#define EVSUB_ID_FMT "0x%" PRIx32 #define EVSUB_ID_FMT "0x%" PRIx32
......
...@@ -123,7 +123,7 @@ class nas_context { ...@@ -123,7 +123,7 @@ class nas_context {
uint8_t kamf[MAX_5GS_AUTH_VECTORS][32]; uint8_t kamf[MAX_5GS_AUTH_VECTORS][32];
security_context_t _security; security_context_t _security;
nas_secu_ctx* security_ctx; nas_secu_ctx* security_ctx; // TODO: avoid using naked ptr
bool is_current_security_available; bool is_current_security_available;
......
...@@ -183,4 +183,6 @@ static const std::vector<std::string> nas_ciphering_algorithm_list_e2str = { ...@@ -183,4 +183,6 @@ static const std::vector<std::string> nas_ciphering_algorithm_list_e2str = {
#define DEREGISTRATION_TYPE_MASK 0b00001000 #define DEREGISTRATION_TYPE_MASK 0b00001000
#define NAS_MESSAGE_MIN_LENGTH 3
#endif #endif
This diff is collapsed.
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <AMFConfigurationApiImpl.h> #include <AMFConfigurationApiImpl.h>
#include "3gpp_29.500.h"
#include "logger.hpp" #include "logger.hpp"
extern itti_mw* itti_inst; extern itti_mw* itti_inst;
...@@ -81,7 +82,8 @@ void AMFConfigurationApiImpl::read_configuration( ...@@ -81,7 +82,8 @@ void AMFConfigurationApiImpl::read_configuration(
http_response_code = result["httpResponseCode"].get<int>(); http_response_code = result["httpResponseCode"].get<int>();
} }
if (http_response_code == 200) { if (static_cast<http_response_codes_e>(http_response_code) ==
http_response_codes_e::HTTP_RESPONSE_CODE_200_OK) {
if (result.find("content") != result.end()) { if (result.find("content") != result.end()) {
json_data = result["content"]; json_data = result["content"];
} }
...@@ -152,7 +154,8 @@ void AMFConfigurationApiImpl::update_configuration( ...@@ -152,7 +154,8 @@ void AMFConfigurationApiImpl::update_configuration(
http_response_code = result["httpResponseCode"].get<int>(); http_response_code = result["httpResponseCode"].get<int>();
} }
if (http_response_code == 200) { if (static_cast<http_response_codes_e>(http_response_code) ==
http_response_codes_e::HTTP_RESPONSE_CODE_200_OK) {
if (result.find("content") != result.end()) { if (result.find("content") != result.end()) {
json_data = result["content"]; json_data = result["content"];
} }
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
#include "N1N2IndividualSubscriptionDocumentApiImpl.h" #include "N1N2IndividualSubscriptionDocumentApiImpl.h"
#include "3gpp_29.500.h"
extern itti_mw* itti_inst; extern itti_mw* itti_inst;
namespace oai { namespace oai {
namespace amf { namespace amf {
...@@ -77,7 +79,8 @@ void N1N2IndividualSubscriptionDocumentApiImpl::n1_n2_message_un_subscribe( ...@@ -77,7 +79,8 @@ void N1N2IndividualSubscriptionDocumentApiImpl::n1_n2_message_un_subscribe(
http_response_code = result["httpResponseCode"].get<int>(); http_response_code = result["httpResponseCode"].get<int>();
} }
if (http_response_code == 204) { if (static_cast<http_response_codes_e>(http_response_code) ==
http_response_codes_e::HTTP_RESPONSE_CODE_204_NO_CONTENT) {
response.send(Pistache::Http::Code::No_Content); response.send(Pistache::Http::Code::No_Content);
} else { } else {
// Problem//details // Problem//details
......
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
*/ */
#include "N1N2SubscriptionsCollectionForIndividualUEContextsDocumentApiImpl.h" #include "N1N2SubscriptionsCollectionForIndividualUEContextsDocumentApiImpl.h"
#include "3gpp_29.500.h"
#include "itti.hpp" #include "itti.hpp"
extern itti_mw* itti_inst; extern itti_mw* itti_inst;
...@@ -93,7 +95,8 @@ void N1N2SubscriptionsCollectionForIndividualUEContextsDocumentApiImpl:: ...@@ -93,7 +95,8 @@ void N1N2SubscriptionsCollectionForIndividualUEContextsDocumentApiImpl::
json_data = result["createdData"]; json_data = result["createdData"];
} }
if (http_response_code == 201) { // TODO: if (static_cast<http_response_codes_e>(http_response_code) ==
http_response_codes_e::HTTP_RESPONSE_CODE_201_CREATED) {
response.headers().add<Pistache::Http::Header::Location>( response.headers().add<Pistache::Http::Header::Location>(
location); // Location header location); // Location header
response.headers().add<Pistache::Http::Header::ContentType>( response.headers().add<Pistache::Http::Header::ContentType>(
......
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