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

Apply google style format for amf-app

parent b35240b5
This diff is collapsed.
......@@ -3,9 +3,9 @@
* 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
* 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
*
......@@ -48,14 +48,14 @@ namespace amf_application {
class amf_app {
public:
explicit amf_app(const amf_config &amf_cfg);
amf_app(amf_app const&) = delete;
void operator=(amf_app const&) = delete;
amf_app(amf_app const &) = delete;
void operator=(amf_app const &) = delete;
void allRegistredModulesInit(const amf_modules &modules);
long generate_amf_ue_ngap_id();
//itti handlers
// itti handlers
void handle_itti_message(itti_nas_signalling_establishment_request &itti_msg);
void handle_itti_message(itti_n1n2_message_transfer_request &itti_msg);
//context management
// 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;
......@@ -74,11 +74,11 @@ class amf_app {
std::shared_ptr<ue_context> uc);
// SMF Client response handlers
void handle_post_sm_context_response_error_400();
//others
// others
bool generate_5g_guti(uint32_t ranid, long amfid, std::string &mcc,
std::string &mnc, uint32_t &tmsi);
};
}
} // namespace amf_application
#endif
......@@ -3,9 +3,9 @@
* 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
* 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
*
......@@ -37,10 +37,10 @@
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
#include "logger.hpp"
#include "3gpp_ts24501.hpp"
#include "amf_app.hpp"
#include "if.hpp"
#include "3gpp_ts24501.hpp"
#include "logger.hpp"
extern "C" {
#include <arpa/inet.h>
......@@ -57,12 +57,11 @@ namespace config {
//------------------------------------------------------------------------------
amf_config::amf_config() {
//TODO:
// TODO:
}
//------------------------------------------------------------------------------
amf_config::~amf_config() {
}
amf_config::~amf_config() {}
//------------------------------------------------------------------------------
int amf_config::load(const std::string &config_file) {
......@@ -126,7 +125,8 @@ int amf_config::load(const std::string &config_file) {
nfex.getPath());
}
try {
const Setting &guami_list_cfg = amf_cfg[AMF_CONFIG_STRING_SERVED_GUAMI_LIST];
const Setting &guami_list_cfg =
amf_cfg[AMF_CONFIG_STRING_SERVED_GUAMI_LIST];
int count = guami_list_cfg.getLength();
for (int i = 0; i < count; i++) {
guami_t guami;
......@@ -176,11 +176,13 @@ int amf_config::load(const std::string &config_file) {
}
try {
const Setting &new_if_cfg = amf_cfg[AMF_CONFIG_STRING_INTERFACES];
const Setting &n2_amf_cfg = new_if_cfg[AMF_CONFIG_STRING_INTERFACE_NGAP_AMF];
const Setting &n2_amf_cfg =
new_if_cfg[AMF_CONFIG_STRING_INTERFACE_NGAP_AMF];
load_interface(n2_amf_cfg, n2);
const Setting &n11_cfg = new_if_cfg[AMF_CONFIG_STRING_INTERFACE_N11];
load_interface(n11_cfg, n11);
const Setting &smf_addr_pool = n11_cfg[AMF_CONFIG_STRING_SMF_INSTANCES_POOL];
const Setting &smf_addr_pool =
n11_cfg[AMF_CONFIG_STRING_SMF_INSTANCES_POOL];
int count = smf_addr_pool.getLength();
for (int i = 0; i < count; i++) {
const Setting &smf_addr_item = smf_addr_pool[i];
......@@ -291,11 +293,10 @@ void amf_config::display() {
Logger::config().info(
"- SERVED_GUAMI_LIST...................................: ");
for (int i = 0; i < guami_list.size(); i++) {
Logger::config().info(" (%s, %s, %s , %s, %s)", guami_list[i].mcc.c_str(),
guami_list[i].mnc.c_str(),
guami_list[i].regionID.c_str(),
guami_list[i].AmfSetID.c_str(),
guami_list[i].AmfPointer.c_str());
Logger::config().info(
" (%s, %s, %s , %s, %s)", guami_list[i].mcc.c_str(),
guami_list[i].mnc.c_str(), guami_list[i].regionID.c_str(),
guami_list[i].AmfSetID.c_str(), guami_list[i].AmfPointer.c_str());
}
Logger::config().info(
"- RELATIVE_CAPACITY...................................: %d",
......@@ -345,7 +346,7 @@ void amf_config::display() {
Logger::config().info(" iface ................: %s", n11.if_name.c_str());
Logger::config().info(" ip ...................: %s", inet_ntoa(n11.addr4));
Logger::config().info(" port .................: %d", n11.port);
// Logger::config().info(" HTTP2 port ............: %d", n11_http2_port);
// Logger::config().info(" HTTP2 port ............: %d", n11_http2_port);
Logger::config().info(
"- Remote SMF Pool.....................................: ");
......@@ -368,7 +369,7 @@ int amf_config::load_interface(const libconfig::Setting &if_cfg,
if_cfg.lookupValue(AMF_CONFIG_STRING_INTERFACE_NAME, cfg.if_name);
util::trim(cfg.if_name);
if (not boost::iequals(cfg.if_name, "none")) {
std::string address = { };
std::string address = {};
if_cfg.lookupValue(AMF_CONFIG_STRING_IPV4_ADDRESS, address);
util::trim(address);
if (boost::iequals(address, "read")) {
......@@ -376,31 +377,32 @@ int amf_config::load_interface(const libconfig::Setting &if_cfg,
cfg.mtu)) {
Logger::amf_app().error(
"Could not read %s network interface configuration", cfg.if_name);
return RETURNerror ;
return RETURNerror;
}
} else {
std::vector < std::string > words;
std::vector<std::string> words;
boost::split(words, address, boost::is_any_of("/"),
boost::token_compress_on);
if (words.size() != 2) {
Logger::amf_app().error(
"Bad value " AMF_CONFIG_STRING_IPV4_ADDRESS " = %s in config file",
address.c_str());
return RETURNerror ;
Logger::amf_app().error("Bad value " AMF_CONFIG_STRING_IPV4_ADDRESS
" = %s in config file",
address.c_str());
return RETURNerror;
}
unsigned char buf_in_addr[sizeof(struct in6_addr)]; // you never know...
if (inet_pton(AF_INET, util::trim(words.at(0)).c_str(), buf_in_addr)
== 1) {
if (inet_pton(AF_INET, util::trim(words.at(0)).c_str(), buf_in_addr) ==
1) {
memcpy(&cfg.addr4, buf_in_addr, sizeof(struct in_addr));
} else {
Logger::amf_app().error(
"In conversion: Bad value " AMF_CONFIG_STRING_IPV4_ADDRESS " = %s in config file",
"In conversion: Bad value " AMF_CONFIG_STRING_IPV4_ADDRESS
" = %s in config file",
util::trim(words.at(0)).c_str());
return RETURNerror ;
return RETURNerror;
}
cfg.network4.s_addr = htons(
ntohs(cfg.addr4.s_addr)
& 0xFFFFFFFF << (32 - std::stoi(util::trim(words.at(1)))));
cfg.network4.s_addr =
htons(ntohs(cfg.addr4.s_addr) &
0xFFFFFFFF << (32 - std::stoi(util::trim(words.at(1)))));
}
if_cfg.lookupValue(AMF_CONFIG_STRING_PORT, cfg.port);
......@@ -412,13 +414,12 @@ int amf_config::load_interface(const libconfig::Setting &if_cfg,
nfex.getPath());
}
}
return RETURNok ;
return RETURNok;
}
//------------------------------------------------------------------------------
int amf_config::load_thread_sched_params(const Setting &thread_sched_params_cfg,
util::thread_sched_params &cfg) {
try {
thread_sched_params_cfg.lookupValue(AMF_CONFIG_STRING_THREAD_RD_CPU_ID,
cfg.cpu_id);
......@@ -429,8 +430,7 @@ int amf_config::load_thread_sched_params(const Setting &thread_sched_params_cfg,
try {
std::string thread_rd_sched_policy;
thread_sched_params_cfg.lookupValue(
AMF_CONFIG_STRING_THREAD_RD_SCHED_POLICY,
thread_rd_sched_policy);
AMF_CONFIG_STRING_THREAD_RD_SCHED_POLICY, thread_rd_sched_policy);
util::trim(thread_rd_sched_policy);
if (boost::iequals(thread_rd_sched_policy, "SCHED_OTHER")) {
cfg.sched_policy = SCHED_OTHER;
......@@ -446,7 +446,7 @@ int amf_config::load_thread_sched_params(const Setting &thread_sched_params_cfg,
Logger::amf_app().error(
"thread_rd_sched_policy: %s, unknown in config file",
thread_rd_sched_policy.c_str());
return RETURNerror ;
return RETURNerror;
}
} catch (const SettingNotFoundException &nfex) {
Logger::amf_app().info("%s : %s, using defaults", nfex.what(),
......@@ -455,19 +455,19 @@ int amf_config::load_thread_sched_params(const Setting &thread_sched_params_cfg,
try {
thread_sched_params_cfg.lookupValue(
AMF_CONFIG_STRING_THREAD_RD_SCHED_PRIORITY,
cfg.sched_priority);
AMF_CONFIG_STRING_THREAD_RD_SCHED_PRIORITY, cfg.sched_priority);
if ((cfg.sched_priority > 99) || (cfg.sched_priority < 1)) {
Logger::amf_app().error(
"thread_rd_sched_priority: %d, must be in interval [1..99] in config file",
"thread_rd_sched_priority: %d, must be in interval [1..99] in config "
"file",
cfg.sched_priority);
return RETURNerror ;
return RETURNerror;
}
} catch (const SettingNotFoundException &nfex) {
Logger::amf_app().info("%s : %s, using defaults", nfex.what(),
nfex.getPath());
}
return RETURNok ;
return RETURNok;
}
}
} // namespace config
......@@ -3,9 +3,9 @@
* 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
* 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
*
......@@ -180,6 +180,6 @@ class amf_config {
std::vector<smf_inst_t> smf_pool;
};
}
} // namespace config
#endif
......@@ -3,9 +3,9 @@
* 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
* 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
*
......@@ -68,11 +68,11 @@ int amf_modules::load(const std::string &config_file) {
item.lookupValue(MODULES_CONFIG_STRING_AMF_MODULES_NGAP_MESSAGE_NAME,
msgName);
item.lookupValue(
MODULES_CONFIG_STRING_AMF_MODULES_NGAP_MESSAGE_PROCEDURECODE,
procedure_code);
MODULES_CONFIG_STRING_AMF_MODULES_NGAP_MESSAGE_PROCEDURECODE,
procedure_code);
item.lookupValue(MODULES_CONFIG_STRING_AMF_MODULES_NGAP_MESSAGE_TYPEOFMSG,
typeOfMessage);
procedureCode = (Ngap_ProcedureCode_t) procedure_code;
procedureCode = (Ngap_ProcedureCode_t)procedure_code;
if (!(typeOfMessage.compare("initialMessage"))) {
typeOfMsg = Ngap_NGAP_PDU_PR_initiatingMessage;
} else if (!(typeOfMessage.compare("successfuloutcome"))) {
......@@ -93,4 +93,4 @@ void amf_modules::display() {
msgName.c_str(), procedureCode, typeOfMsg);
}
}
} // namespace config
......@@ -3,9 +3,9 @@
* 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
* 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
*
......@@ -29,19 +29,20 @@
#ifndef _AMF_MODULE_FROM_CONFIG_H_
#define _AMF_MODULE_FROM_CONFIG_H_
#include <libconfig.h++>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
#include <libconfig.h++>
#include "Ngap_ProcedureCode.h"
#include "Ngap_NGAP-PDU.h"
#include "Ngap_ProcedureCode.h"
#define MODULES_CONFIG_STRING_AMF_MODULES "MODULES"
#define MODULES_CONFIG_STRING_AMF_MODULES_NGAP_MESSAGE "NGAP_MESSAGE"
#define MODULES_CONFIG_STRING_AMF_MODULES_NGAP_MESSAGE_NAME "MSG_NAME"
#define MODULES_CONFIG_STRING_AMF_MODULES_NGAP_MESSAGE_PROCEDURECODE "ProcedureCode"
#define MODULES_CONFIG_STRING_AMF_MODULES_NGAP_MESSAGE_TYPEOFMSG "TypeOfMessage"
#define MODULES_CONFIG_STRING_AMF_MODULES "MODULES"
#define MODULES_CONFIG_STRING_AMF_MODULES_NGAP_MESSAGE "NGAP_MESSAGE"
#define MODULES_CONFIG_STRING_AMF_MODULES_NGAP_MESSAGE_NAME "MSG_NAME"
#define MODULES_CONFIG_STRING_AMF_MODULES_NGAP_MESSAGE_PROCEDURECODE \
"ProcedureCode"
#define MODULES_CONFIG_STRING_AMF_MODULES_NGAP_MESSAGE_TYPEOFMSG "TypeOfMessage"
using namespace libconfig;
......@@ -52,13 +53,13 @@ class amf_modules {
int load(const std::string &config_file);
void display();
void makeModulesAlive();
private:
std::string msgName; //vector to store more msgs
std::string msgName; // vector to store more msgs
Ngap_NGAP_PDU_PR typeOfMsg;
Ngap_ProcedureCode_t procedureCode;
// NGSetupRequestMsg *ngSetupRequest;
};
}
} // namespace config
#endif
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -3,9 +3,9 @@
* 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
* 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
*
......@@ -29,25 +29,25 @@
#ifndef _AMF_N1_H_
#define _AMF_N1_H_
#include <map>
#include <shared_mutex>
#include <mysql/mysql.h>
#include <stdlib.h>
#include <string.h>
#include <mysql/mysql.h>
#include <map>
#include <shared_mutex>
#include "nas_context.hpp"
#include "pdu_session_context.hpp"
#include "itti_msg_n1.hpp"
#include "bstrlib.h"
#include "3gpp_ts24501.hpp"
#include "amf_statistics.hpp"
#include "amf.hpp"
#include "amf_statistics.hpp"
#include "bstrlib.h"
#include "itti_msg_n1.hpp"
#include "mysql_db.hpp"
#include "nas_context.hpp"
#include "pdu_session_context.hpp"
namespace amf_application {
#define NAS_MESSAGE_DOWNLINK 1
#define NAS_MESSAGE_UPLINK 0
#define NAS_MESSAGE_UPLINK 0
typedef enum {
PlainNasMsg = 0x0,
......@@ -61,7 +61,7 @@ class amf_n1 {
public:
amf_n1();
~amf_n1();
void handle_itti_message(itti_uplink_nas_data_ind&);
void handle_itti_message(itti_uplink_nas_data_ind &);
void handle_itti_message(itti_downlink_nas_transfer &itti_msg);
// nas message decode
void nas_signalling_establishment_request_handle(
......@@ -74,7 +74,8 @@ class amf_n1 {
bstring plain_msg, plmn_t plmn);
bool check_security_header_type(SecurityHeaderType &type, uint8_t *buffer);
std::map<long, std::shared_ptr<nas_context>> amfueid2nas_context; // amf ue ngap id
std::map<long, std::shared_ptr<nas_context>>
amfueid2nas_context; // amf ue ngap id
std::map<std::string, std::shared_ptr<nas_context>> imsi2nas_context;
std::map<std::string, long> supi2amfId;
std::map<std::string, uint32_t> supi2ranId;
......@@ -97,18 +98,18 @@ class amf_n1 {
std::shared_ptr<nas_context> nc);
database_t *db_desc;
//procedures
// procedures
void run_registration_procedure(std::shared_ptr<nas_context> &nc);
void run_initial_registration_procedure();
void run_mobility_registration_update_procedure(
std::shared_ptr<nas_context> nc);
//authentication
// authentication
bool auth_vectors_generator(std::shared_ptr<nas_context> &nc);
bool authentication_vectors_generator_in_ausf(
std::shared_ptr<nas_context> &nc);
bool authentication_vectors_generator_in_udm(
std::shared_ptr<nas_context> &nc);
//mysql handlers in mysql_db.cpp
// mysql handlers in mysql_db.cpp
bool get_mysql_auth_info(std::string imsi, mysql_auth_info_t &resp);
void mysql_push_rand_sqn(std::string imsi, uint8_t *rand_p, uint8_t *sqn);
void mysql_increment_sqn(std::string imsi);
......@@ -152,7 +153,7 @@ class amf_n1 {
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);
private: //nas message handlers
private: // nas message handlers
void ue_initiate_de_registration_handle(uint32_t ran_ue_ngap_id,
long amf_ue_ngap_id, bstring nas);
void registration_request_handle(bool isNasSig,
......@@ -178,15 +179,15 @@ class amf_n1 {
void identity_response_handle(uint32_t ran_ue_ngap_id, long amf_ue_ngap_id,
bstring plain_msg);
//authentication vector
// authentication vector
bool generate_authentication_vector();
void itti_send_dl_nas_buffer_to_task_n2(bstring &b, uint32_t ran_ue_ngap_id,
long amf_ue_ngap_id);
//response message
// response message
void response_registration_reject_msg(uint8_t cause_value,
uint32_t ran_ue_ngap_id,
long amf_ue_ngap_id);
};
}
} // namespace amf_application
#endif
This diff is collapsed.
......@@ -3,9 +3,9 @@
* 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
* 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
*
......@@ -43,7 +43,7 @@ class amf_n11 {
amf_n11();
~amf_n11();
void handle_itti_message(itti_smf_services_consumer&);
void handle_itti_message(itti_smf_services_consumer &);
void handle_pdu_session_initial_request(
std::string supi, std::shared_ptr<pdu_session_context> psc,
std::string smf_addr, bstring sm_msg, std::string dnn);
......@@ -54,7 +54,8 @@ class amf_n11 {
std::string supi, std::shared_ptr<pdu_session_context> psc,
std::string smf_addr, bstring sm_msg, std::string dnn);
std::map<std::string, std::shared_ptr<pdu_session_context>> supi2pdu; // amf ue ngap id
std::map<std::string, std::shared_ptr<pdu_session_context>>
supi2pdu; // amf ue ngap id
mutable std::shared_mutex m_supi2pdu;
bool is_supi_to_pdu_ctx(const std::string &supi) const;
std::shared_ptr<pdu_session_context> supi_to_pdu_ctx(
......@@ -75,6 +76,6 @@ class amf_n11 {
std::string supi, uint8_t pdu_session_id);
};
}
} // namespace amf_application
#endif
This diff is collapsed.
......@@ -3,9 +3,9 @@
* 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
* 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
*
......@@ -29,13 +29,13 @@
#ifndef _AMF_N2_H_
#define _AMF_N2_H_
#include "ngap_app.hpp"
#include "DownlinkRANStatusTransfer.hpp"
#include "HandoverCommandMsg.hpp"
#include "HandoverRequest.hpp"
#include "PduSessionResourceReleaseCommand.hpp"
#include "itti_msg_n2.hpp"
#include "ngap_app.hpp"
#include "ue_ngap_context.hpp"
#include "PduSessionResourceReleaseCommand.hpp"
#include "HandoverRequest.hpp"
#include "HandoverCommandMsg.hpp"
#include "DownlinkRANStatusTransfer.hpp"
#include "amf.hpp"
......@@ -73,11 +73,11 @@ class amf_n2 : public ngap::ngap_app {
const uint32_t &ran_ue_ngap_id, std::shared_ptr<ue_ngap_context> unc);
private:
std::map<uint32_t, std::shared_ptr<ue_ngap_context>> ranid2uecontext; // ran ue ngap id
std::map<uint32_t, std::shared_ptr<ue_ngap_context>>
ranid2uecontext; // ran ue ngap id
mutable std::shared_mutex m_ranid2uecontext;
};
}
} // namespace amf_application
#endif
......@@ -3,9 +3,9 @@
* 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
* 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
*
......@@ -33,52 +33,63 @@
//------------------------------------------------------------------------------
void statistics::display() {
Logger::amf_app().info("");
//Logger::amf_app().info("--------------------------------------------------");
//Logger::amf_app().info("| connected gNBs | connected UEs | registered UEs |");
//Logger::amf_app().info("--------------------------------------------------");
//Logger::amf_app().info("| %d | %d | %d |",gNB_connected,UE_connected,UE_registred);
//Logger::amf_app().info("--------------------------------------------------");
// Logger::amf_app().info("--------------------------------------------------");
// Logger::amf_app().info("| connected gNBs | connected UEs | registered UEs
// |");
// Logger::amf_app().info("--------------------------------------------------");
// Logger::amf_app().info("| %d | %d | %d
// |",gNB_connected,UE_connected,UE_registred);
// Logger::amf_app().info("--------------------------------------------------");
Logger::amf_app().info(
"|----------------------------------------------------------------------------------------------------------------|");
"|-----------------------------------------------------------------------"
"-----------------------------------------|");
Logger::amf_app().info(
"|----------------------------------------------------gNBs' information-------------------------------------------|");
"|----------------------------------------------------gNBs' "
"information-------------------------------------------|");
Logger::amf_app().info(
"| Index | Status | Global ID | gNB Name | Tracking Area (PLMN, TAC) |");
"| Index | Status | Global ID | gNB "
"Name | Tracking Area (PLMN, TAC) |");
if (gnbs.size() == 0) {
Logger::amf_app().info(
"| - | - | - | - | - |");
"| - | - | - | "
"- | - |");
}
//TODO: Show the list of common PLMNs
// TODO: Show the list of common PLMNs
for (int i = 0; i < gnbs.size(); i++) {
Logger::amf_app().info(
"| %d | Connected | 0x%x | %s | %s, %d | ",
"| %d | Connected | 0x%x | %s "
" | %s, %d | ",
i + 1, gnbs[i].gnb_id, gnbs[i].gnb_name.c_str(),
(gnbs[i].mcc + gnbs[i].mnc).c_str(), gnbs[i].tac);
}
Logger::amf_app().info(
"|----------------------------------------------------------------------------------------------------------------|");
"|-----------------------------------------------------------------------"
"-----------------------------------------|");
Logger::amf_app().info("");
Logger::amf_app().info(
"|----------------------------------------------------------------------------------------------------------------|");
"|-----------------------------------------------------------------------"
"-----------------------------------------|");
Logger::amf_app().info(
"|----------------------------------------------------UEs' information--------------------------------------------|");
"|----------------------------------------------------UEs' "
"information--------------------------------------------|");
Logger::amf_app().info(
"| Index | 5GMM state | IMSI | GUTI | RAN UE NGAP ID | AMF UE ID | PLMN |Cell ID|");
"| Index | 5GMM state | IMSI | GUTI | RAN "
"UE NGAP ID | AMF UE ID | PLMN |Cell ID|");
int i = 0;
for (auto const &ue : ue_infos) {
Logger::amf_app().info("|%7d|%22s|%18s|%15s|%16d|%11d|%9s|%7d|", i + 1,
ue.second.registerStatus.c_str(),
ue.second.imsi.c_str(), ue.second.guti.c_str(),
ue.second.ranid, ue.second.amfid,
(ue.second.mcc + ue.second.mnc).c_str(),
ue.second.cellId);
Logger::amf_app().info(
"|%7d|%22s|%18s|%15s|%16d|%11d|%9s|%7d|", i + 1,
ue.second.registerStatus.c_str(), ue.second.imsi.c_str(),
ue.second.guti.c_str(), ue.second.ranid, ue.second.amfid,
(ue.second.mcc + ue.second.mnc).c_str(), ue.second.cellId);
i++;
}
Logger::amf_app().info(
"|----------------------------------------------------------------------------------------------------------------|");
"|-----------------------------------------------------------------------"
"-----------------------------------------|");
Logger::amf_app().info("");
}
......@@ -124,5 +135,4 @@ void statistics::update_5gmm_state(const std::string &imsi,
}
//------------------------------------------------------------------------------
statistics::~statistics() {
}
statistics::~statistics() {}
......@@ -3,9 +3,9 @@
* 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
* 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
*
......@@ -29,21 +29,21 @@
#ifndef _STATISTICS_H_
#define _STATISTICS_H_
#include <vector>
#include <string>
#include <vector>
#include "amf.hpp"
#include "ngap_app.hpp"
typedef struct {
uint32_t gnb_id;
//TODO: list of PLMNs
// TODO: list of PLMNs
std::vector<SupportedItem_t> plmn_list;
std::string mcc;
std::string mnc;
std::string gnb_name;
uint32_t tac;
//long nrCellId;
// long nrCellId;
} gnb_infos;
typedef struct ue_info_s {
......@@ -65,14 +65,14 @@ class statistics {
~statistics();
void update_ue_info(const ue_info_t &ue_info);
void update_5gmm_state(const std::string &imsi, const std::string &state);
public:
uint32_t gNB_connected;
uint32_t UE_connected;
uint32_t UE_registred;
//uint32_t system_pdu_sessions;
// uint32_t system_pdu_sessions;
std::vector<gnb_infos> gnbs;
std::map<std::string, ue_info_t> ue_infos;
};
#endif
......@@ -3,9 +3,9 @@
* 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
* 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
*
......@@ -26,9 +26,9 @@
\email: contact@openairinterface.org
*/
#include "amf_config.hpp"
#include "amf_n1.hpp"
#include "logger.hpp"
#include "amf_config.hpp"
using namespace amf_application;
using namespace config;
......@@ -36,7 +36,10 @@ using namespace config;
extern amf_config amf_cfg;
//------------------------------------------------------------------------------
bool amf_n1::get_mysql_auth_info(std::string imsi, mysql_auth_info_t &resp) { //openair-cn/tree/v0.5.0/src/oai_hss/db/db_connector.c
bool amf_n1::get_mysql_auth_info(
std::string imsi,
mysql_auth_info_t
&resp) { // openair-cn/tree/v0.5.0/src/oai_hss/db/db_connector.c
MYSQL_RES *res;
MYSQL_ROW row;
std::string query;
......@@ -45,8 +48,9 @@ bool amf_n1::get_mysql_auth_info(std::string imsi, mysql_auth_info_t &resp) { /
Logger::amf_n1().error("Cannot connect to MySQL DB");
return false;
}
query = "SELECT `key`,`sqn`,`rand`,`OPc` FROM `users` WHERE `users`.`imsi`='"
+ imsi + "' ";
query =
"SELECT `key`,`sqn`,`rand`,`OPc` FROM `users` WHERE `users`.`imsi`='" +
imsi + "' ";
pthread_mutex_lock(&db_desc->db_cs_mutex);
if (mysql_query(db_desc->db_conn, query.c_str())) {
pthread_mutex_unlock(&db_desc->db_cs_mutex);
......@@ -84,7 +88,7 @@ bool amf_n1::get_mysql_auth_info(std::string imsi, mysql_auth_info_t &resp) { /
//------------------------------------------------------------------------------
bool amf_n1::connect_to_mysql() {
const int mysql_reconnect_val = 1;
db_desc = (database_t*) calloc(1, sizeof(database_t));
db_desc = (database_t *)calloc(1, sizeof(database_t));
if (!db_desc) {
Logger::amf_n1().error(
"An error occurs when allocating memory for DB_DESC");
......@@ -125,16 +129,18 @@ void amf_n1::mysql_push_rand_sqn(std::string imsi, uint8_t *rand_p,
Logger::amf_n1().error("Need sqn and rand");
return;
}
sqn_decimal = ((uint64_t) sqn[0] << 40) | ((uint64_t) sqn[1] << 32)
| ((uint64_t) sqn[2] << 24) | (sqn[3] << 16) | (sqn[4] << 8) | sqn[5];
sqn_decimal = ((uint64_t)sqn[0] << 40) | ((uint64_t)sqn[1] << 32) |
((uint64_t)sqn[2] << 24) | (sqn[3] << 16) | (sqn[4] << 8) |
sqn[5];
query_length = sprintf(query, "UPDATE `users` SET `rand`=UNHEX('");
for (int i = 0; i < RAND_LENGTH; i++) {
query_length += sprintf(&query[query_length], "%02x", rand_p[i]);
}
query_length += sprintf (&query[query_length], "'),`sqn`=%" PRIu64, sqn_decimal);
query_length += sprintf(&query[query_length], " WHERE `users`.`imsi`='%s'",
imsi.c_str());
query_length +=
sprintf(&query[query_length], "'),`sqn`=%" PRIu64, sqn_decimal);
query_length +=
sprintf(&query[query_length], " WHERE `users`.`imsi`='%s'", imsi.c_str());
pthread_mutex_lock(&db_desc->db_cs_mutex);
if (mysql_query(db_desc->db_conn, query)) {
pthread_mutex_unlock(&db_desc->db_cs_mutex);
......
......@@ -3,9 +3,9 @@
* 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
* 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
*
......@@ -29,12 +29,12 @@
#ifndef _MYSQL_DB_HANDLERS_H_
#define _MYSQL_DB_HANDLERS_H_
#include <pthread.h>
#include <mysql/mysql.h>
#include <pthread.h>
#include <string>
#define KEY_LENGTH (16)
#define SQN_LENGTH (6)
#define KEY_LENGTH (16)
#define SQN_LENGTH (6)
#define RAND_LENGTH (16)
typedef struct {
uint8_t key[KEY_LENGTH];
......@@ -44,7 +44,7 @@ typedef struct {
} mysql_auth_info_t;
typedef struct {
//mysql reference connector object
// mysql reference connector object
MYSQL *db_conn;
std::string server;
std::string user;
......
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