Commit b2a7610d authored by Niuhaiwen's avatar Niuhaiwen

add amf_id_region

parent 823e1158
...@@ -173,10 +173,13 @@ void amf_app_task(void*) { ...@@ -173,10 +173,13 @@ void amf_app_task(void*) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
long amf_app::generate_amf_ue_ngap_id() { long amf_app::generate_amf_ue_ngap_id() {
long tmp = 0; //time_t now_time = time(NULL);
//tmp = __sync_fetch_and_add(&amf_app_ue_ngap_id_generator, 1); //tm* t_tm = localtime(&now_time);
//long current = t_tm->tm_mday*24*60*60 + t_tm->tm_hour*60*60 + t_tm->tm_min*60 + t_tm->tm_sec;
//long tmp = (rand()+current)%100000 + 1;
long tmp = __sync_fetch_and_add(&amf_cfg.amf_id_region, 1);
//srand(time(NULL)); //srand(time(NULL));
tmp = rand()%1000 + 1; //tmp = rand()%1000 + 1;
//return tmp & 0xffffffffff; //return tmp & 0xffffffffff;
return tmp; return tmp;
} }
...@@ -309,6 +312,7 @@ void amf_app::handle_itti_message( ...@@ -309,6 +312,7 @@ void amf_app::handle_itti_message(
long amf_ue_ngap_id = 0; long amf_ue_ngap_id = 0;
if ((amf_ue_ngap_id = itti_msg.amf_ue_ngap_id) == -1) { if ((amf_ue_ngap_id = itti_msg.amf_ue_ngap_id) == -1) {
amf_ue_ngap_id = generate_amf_ue_ngap_id(); amf_ue_ngap_id = generate_amf_ue_ngap_id();
Logger::amf_app().debug("Generated amf_ue_ngap_id(%d) for UE (ran_ue_ngap_id = %d)", amf_ue_ngap_id, itti_msg.ran_ue_ngap_id);
}else{ }else{
amf_ue_ngap_id = itti_msg.amf_ue_ngap_id; amf_ue_ngap_id = itti_msg.amf_ue_ngap_id;
} }
......
...@@ -109,6 +109,13 @@ int amf_config::load(const std::string& config_file) { ...@@ -109,6 +109,13 @@ int amf_config::load(const std::string& config_file) {
Logger::amf_app().error( Logger::amf_app().error(
"%s : %s, using defaults", nfex.what(), nfex.getPath()); "%s : %s, using defaults", nfex.what(), nfex.getPath());
} }
try {
amf_cfg.lookupValue(
"AMF_ID_REGION", amf_id_region);
} catch (const SettingNotFoundException& nfex) {
Logger::amf_app().error(
"%s : %s, using defaults", nfex.what(), nfex.getPath());
}
try { try {
amf_cfg.lookupValue(AMF_CONFIG_STRING_PID_DIRECTORY, pid_dir); amf_cfg.lookupValue(AMF_CONFIG_STRING_PID_DIRECTORY, pid_dir);
} catch (const SettingNotFoundException& nfex) { } catch (const SettingNotFoundException& nfex) {
......
...@@ -181,6 +181,7 @@ class amf_config { ...@@ -181,6 +181,7 @@ class amf_config {
util::thread_sched_params& cfg); util::thread_sched_params& cfg);
void display(); void display();
unsigned int instance; unsigned int instance;
int amf_id_region;
std::string pid_dir; std::string pid_dir;
interface_cfg_t n2; interface_cfg_t n2;
interface_cfg_t n11; interface_cfg_t n11;
......
...@@ -1241,6 +1241,7 @@ void amf_n1::registration_request_handle(bool isNasSig, ...@@ -1241,6 +1241,7 @@ void amf_n1::registration_request_handle(bool isNasSig,
} }
nc.get()->is_imsi_present = true; nc.get()->is_imsi_present = true;
nc.get()->imsi = imsi.mcc + imsi.mnc + imsi.msin; nc.get()->imsi = imsi.mcc + imsi.mnc + imsi.msin;
Logger::amf_n1().debug("Receiving Registration Request message from UE (imsi-%s)",nc.get()->imsi.c_str());
Logger::amf_n1().debug("Received IMSI %s", nc.get()->imsi.c_str()); Logger::amf_n1().debug("Received IMSI %s", nc.get()->imsi.c_str());
supi2amfId[("imsi-" + nc.get()->imsi)] = amf_ue_ngap_id; supi2amfId[("imsi-" + nc.get()->imsi)] = amf_ue_ngap_id;
supi2ranId[("imsi-" + nc.get()->imsi)] = ran_ue_ngap_id; supi2ranId[("imsi-" + nc.get()->imsi)] = ran_ue_ngap_id;
...@@ -1892,7 +1893,7 @@ void amf_n1::response_registration_reject_msg(uint8_t cause_value, ...@@ -1892,7 +1893,7 @@ void amf_n1::response_registration_reject_msg(uint8_t cause_value,
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// specific procedures running logic // specific procedures running logic
void amf_n1::run_registration_procedure(std::shared_ptr<nas_context> &nc) { void amf_n1::run_registration_procedure(std::shared_ptr<nas_context> &nc) {
Logger::amf_n1().debug("Start to run registration procedure"); Logger::amf_n1().debug("Start to run registration procedure with UE (%s)", nc.get()->imsi.c_str());
#if 0 #if 0
nlohmann::json udsf_nas_context; nlohmann::json udsf_nas_context;
nlohmann::json udsf_response; nlohmann::json udsf_response;
...@@ -2023,7 +2024,7 @@ bool amf_n1::auth_vectors_generator(std::shared_ptr<nas_context> &nc) { ...@@ -2023,7 +2024,7 @@ bool amf_n1::auth_vectors_generator(std::shared_ptr<nas_context> &nc) {
return true; return true;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#define CURL_TIMEOUT_MS 300L #define CURL_TIMEOUT_MS 3000L
std::size_t callback_ausf(const char *in, std::size_t size, std::size_t num, std::size_t callback_ausf(const char *in, std::size_t size, std::size_t num,
std::string *out) { std::string *out) {
...@@ -2767,6 +2768,7 @@ bool amf_n1::start_authentication_procedure(std::shared_ptr<nas_context> nc, ...@@ -2767,6 +2768,7 @@ bool amf_n1::start_authentication_procedure(std::shared_ptr<nas_context> nc,
is_common_procedure_for_authentication_running["content"] = to_string(nc.get()->is_common_procedure_for_authentication_running); is_common_procedure_for_authentication_running["content"] = to_string(nc.get()->is_common_procedure_for_authentication_running);
udsf_nas_context["blocks"].push_back(is_common_procedure_for_authentication_running); udsf_nas_context["blocks"].push_back(is_common_procedure_for_authentication_running);
#endif #endif
Logger::amf_n1().debug("Sending Authentication Request to UE (%s)",nc.get()->imsi.c_str());
AuthenticationRequest *authReq = new AuthenticationRequest(); AuthenticationRequest *authReq = new AuthenticationRequest();
authReq->setHeader(PLAIN_5GS_MSG); authReq->setHeader(PLAIN_5GS_MSG);
authReq->setngKSI(NAS_KEY_SET_IDENTIFIER_NATIVE, ngksi); authReq->setngKSI(NAS_KEY_SET_IDENTIFIER_NATIVE, ngksi);
......
...@@ -617,7 +617,7 @@ void amf_n2::handle_itti_message(itti_initial_ue_message& init_ue_msg) { ...@@ -617,7 +617,7 @@ void amf_n2::handle_itti_message(itti_initial_ue_message& init_ue_msg) {
} else if (gc.get()->ng_state != NGAP_READY) { } else if (gc.get()->ng_state != NGAP_READY) {
Logger::amf_n2().debug( Logger::amf_n2().debug(
"gNB with assoc_id (%d) is illegal", init_ue_msg.assoc_id); "gNB with assoc_id (%d) is illegal", init_ue_msg.assoc_id);
return; //return;
} }
......
...@@ -81,7 +81,7 @@ enum class http_response_codes_e { ...@@ -81,7 +81,7 @@ enum class http_response_codes_e {
}; };
// for CURL // for CURL
#define SMF_CURL_TIMEOUT_MS 100L #define SMF_CURL_TIMEOUT_MS 50000L
#define SMF_NUMBER_RETRIES 3 #define SMF_NUMBER_RETRIES 3
constexpr auto CURL_MIME_BOUNDARY = "----Boundary"; constexpr auto CURL_MIME_BOUNDARY = "----Boundary";
#define NRF_CURL_TIMEOUT_MS 100L #define NRF_CURL_TIMEOUT_MS 100L
......
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