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