Commit a144c1de authored by dukl's avatar dukl

handle abnormal conditions

parent e4f2b911
This diff is collapsed.
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file amf_app.hpp
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _AMF_APP_H_ #ifndef _AMF_APP_H_
#define _AMF_APP_H_ #define _AMF_APP_H_
...@@ -41,42 +13,57 @@ ...@@ -41,42 +13,57 @@
#include "ue_context.hpp" #include "ue_context.hpp"
using namespace config; using namespace config;
using namespace std;
static uint32_t amf_app_ue_ngap_id_generator = 1; static uint32_t amf_app_ue_ngap_id_generator = 1;
namespace amf_application { namespace amf_application{
#define TASK_AMF_APP_PERIODIC_STATISTICS (0) #define TASK_AMF_APP_PERIODIC_STATISTICS (0)
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 public://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 public://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;
mutable std::shared_mutex m_ue_ctx_key; mutable std::shared_mutex m_ue_ctx_key;
bool is_amf_ue_id_2_ue_context(const long &amf_ue_ngap_id) const; bool is_amf_ue_id_2_ue_context(const long & amf_ue_ngap_id) const;
std::shared_ptr<ue_context> amf_ue_id_2_ue_context(const long &amf_ue_ngap_id) const; std::shared_ptr<ue_context> amf_ue_id_2_ue_context(const long & amf_ue_ngap_id) const;
void set_amf_ue_ngap_id_2_ue_context(const long &amf_ue_ngap_id, std::shared_ptr<ue_context> uc); void set_amf_ue_ngap_id_2_ue_context(const long & amf_ue_ngap_id, std::shared_ptr<ue_context> uc);
bool is_ran_amf_id_2_ue_context(const std::string &ue_context_key) const; bool is_ran_amf_id_2_ue_context(const string & ue_context_key) const;
std::shared_ptr<ue_context> ran_amf_id_2_ue_context(const std::string &ue_context_key) const; std::shared_ptr<ue_context> ran_amf_id_2_ue_context(const string & ue_context_key) const;
void set_ran_amf_id_2_ue_context(const std::string &ue_context_key, std::shared_ptr<ue_context> uc); void set_ran_amf_id_2_ue_context(const string & ue_context_key, std::shared_ptr<ue_context> uc);
// SMF Client response handlers public:/*** SMF Client response handlers ****/
void handle_post_sm_context_response_error_400(); void handle_post_sm_context_response_error_400();
//others public:
bool generate_5g_guti(uint32_t ranid, long amfid, std::string &mcc, std::string &mnc, uint32_t &tmsi); bool generate_5g_guti(uint32_t ranid, long amfid, string &mcc, string &mnc, uint32_t& tmsi);
}; };
} }
#endif #endif
This diff is collapsed.
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file amf_config.hpp
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _AMF_CONFIG_H_ #ifndef _AMF_CONFIG_H_
#define _AMF_CONFIG_H_ #define _AMF_CONFIG_H_
#include "amf_config.hpp"
#include <arpa/inet.h> #include <arpa/inet.h>
#include <libconfig.h++> #include <libconfig.h++>
#include <netinet/in.h> #include <netinet/in.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <mutex> #include <mutex>
#include <vector> #include <vector>
#include <string> #include <string>
#include "thread_sched.hpp"
#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 "amf_config.hpp"
#include "thread_sched.hpp"
#define AMF_CONFIG_STRING_AMF_CONFIG "AMF" #define AMF_CONFIG_STRING_AMF_CONFIG "AMF"
#define AMF_CONFIG_STRING_PID_DIRECTORY "PID_DIRECTORY" #define AMF_CONFIG_STRING_PID_DIRECTORY "PID_DIRECTORY"
#define AMF_CONFIG_STRING_INSTANCE_ID "INSTANCE_ID" #define AMF_CONFIG_STRING_INSTANCE_ID "INSTANCE_ID"
...@@ -52,7 +25,7 @@ ...@@ -52,7 +25,7 @@
#define AMF_CONFIG_STRING_INTERFACE_NGAP_AMF "NGAP_AMF" #define AMF_CONFIG_STRING_INTERFACE_NGAP_AMF "NGAP_AMF"
#define AMF_CONFIG_STRING_INTERFACE_NAME "INTERFACE_NAME" #define AMF_CONFIG_STRING_INTERFACE_NAME "INTERFACE_NAME"
#define AMF_CONFIG_STRING_IPV4_ADDRESS "IPV4_ADDRESS" #define AMF_CONFIG_STRING_IPV4_ADDRESS "IPV4_ADDRESS"
#define AMF_CONFIG_STRING_PORT "PORT" #define AMF_CONFIG_STRING_SCTP_PORT "SCTP_PORT"
#define AMF_CONFIG_STRING_PPID "PPID" #define AMF_CONFIG_STRING_PPID "PPID"
#define AMF_CONFIG_STRING_INTERFACE_N11 "N11" #define AMF_CONFIG_STRING_INTERFACE_N11 "N11"
...@@ -69,16 +42,16 @@ ...@@ -69,16 +42,16 @@
#define AMF_CONFIG_STRING_AMF_NAME "AMF_NAME" #define AMF_CONFIG_STRING_AMF_NAME "AMF_NAME"
#define AMF_CONFIG_STRING_GUAMI "GUAMI" #define AMF_CONFIG_STRING_GUAMI "GUAMI"
#define AMF_CONFIG_STRING_SERVED_GUAMI_LIST "SERVED_GUAMI_LIST" #define AMF_CONFIG_STRING_ServedGUAMIList "ServedGUAMIList"
#define AMF_CONFIG_STRING_TAC "TAC" #define AMF_CONFIG_STRING_TAC "TAC"
#define AMF_CONFIG_STRING_MCC "MCC" #define AMF_CONFIG_STRING_MCC "MCC"
#define AMF_CONFIG_STRING_MNC "MNC" #define AMF_CONFIG_STRING_MNC "MNC"
#define AMF_CONFIG_STRING_RegionID "RegionID" #define AMF_CONFIG_STRING_RegionID "RegionID"
#define AMF_CONFIG_STRING_AMFSetID "AMFSetID" #define AMF_CONFIG_STRING_AMFSetID "AMFSetID"
#define AMF_CONFIG_STRING_AMFPointer "AMFPointer" #define AMF_CONFIG_STRING_AMFPointer "AMFPointer"
#define AMF_CONFIG_STRING_RELATIVE_AMF_CAPACITY "RELATIVE_CAPACITY" #define AMF_CONFIG_STRING_RelativeAMFCapacity "RelativeAMFCapacity"
#define AMF_CONFIG_STRING_PLMN_SUPPORT_LIST "PLMN_SUPPORT_LIST" #define AMF_CONFIG_STRING_PLMNSupportList "PLMNSupportList"
#define AMF_CONFIG_STRING_SLICE_SUPPORT_LIST "SLICE_SUPPORT_LIST" #define AMF_CONFIG_STRING_SliceSupportList "SliceSupportList"
#define AMF_CONFIG_STRING_SST "SST" #define AMF_CONFIG_STRING_SST "SST"
#define AMF_CONFIG_STRING_SD "SD" #define AMF_CONFIG_STRING_SD "SD"
#define AMF_CONFIG_STRING_CORE_CONFIGURATION "CORE_CONFIGURATION" #define AMF_CONFIG_STRING_CORE_CONFIGURATION "CORE_CONFIGURATION"
...@@ -94,26 +67,28 @@ ...@@ -94,26 +67,28 @@
#define AMF_CONFIG_STRING_NAS_SUPPORTED_INTEGRITY_ALGORITHM_LIST "ORDERED_SUPPORTED_INTEGRITY_ALGORITHM_LIST" #define AMF_CONFIG_STRING_NAS_SUPPORTED_INTEGRITY_ALGORITHM_LIST "ORDERED_SUPPORTED_INTEGRITY_ALGORITHM_LIST"
#define AMF_CONFIG_STRING_NAS_SUPPORTED_CIPHERING_ALGORITHM_LIST "ORDERED_SUPPORTED_CIPHERING_ALGORITHM_LIST" #define AMF_CONFIG_STRING_NAS_SUPPORTED_CIPHERING_ALGORITHM_LIST "ORDERED_SUPPORTED_CIPHERING_ALGORITHM_LIST"
using namespace libconfig; using namespace libconfig;
using namespace std;
namespace config { namespace config{
typedef struct { typedef struct{
std::string mysql_server; string mysql_server;
std::string mysql_user; string mysql_user;
std::string mysql_pass; string mysql_pass;
std::string mysql_db; string mysql_db;
std::string operator_key; string operator_key;
std::string random; string random;
} auth_conf; }auth_conf;
typedef struct interface_cfg_s { typedef struct interface_cfg_s {
std::string if_name; std::string if_name;
struct in_addr addr4; struct in_addr addr4;
struct in_addr network4; struct in_addr network4;
struct in6_addr addr6; struct in6_addr addr6;
unsigned int mtu; unsigned int mtu;
unsigned int port; unsigned int port;
util::thread_sched_params thread_rd_sched_params; util::thread_sched_params thread_rd_sched_params;
} interface_cfg_t; } interface_cfg_t;
...@@ -125,64 +100,75 @@ typedef struct itti_cfg_s { ...@@ -125,64 +100,75 @@ typedef struct itti_cfg_s {
util::thread_sched_params async_cmd_sched_params; util::thread_sched_params async_cmd_sched_params;
} itti_cfg_t; } itti_cfg_t;
typedef struct guami_s { typedef struct guami_s{
std::string mcc; string mcc;
std::string mnc; string mnc;
std::string regionID; string regionID;
std::string AmfSetID; string AmfSetID;
std::string AmfPointer; string AmfPointer;
} guami_t; }guami_t;
typedef struct slice_s { typedef struct slice_s{
std::string sST; string sST;
std::string sD; string sD;
} slice_t; }slice_t;
typedef struct plmn_support_item_s { typedef struct plmn_support_item_s{
std::string mcc; string mcc;
std::string mnc; string mnc;
uint32_t tac; uint32_t tac;
std::vector<slice_t> slice_list; vector<slice_t> slice_list;
} plmn_item_t; }plmn_item_t;
typedef struct { typedef struct{
uint8_t prefered_integrity_algorithm[8]; uint8_t prefered_integrity_algorithm[8];
uint8_t prefered_ciphering_algorithm[8]; uint8_t prefered_ciphering_algorithm[8];
} nas_conf_t; }nas_conf_t;
typedef struct { typedef struct{
int id; int id;
std::string ipv4; string ipv4;
std::string port; string port;
std::string version; string version;
bool selected; bool selected;
} smf_inst_t; }smf_inst_t;
class amf_config { class amf_config{
public: public:
amf_config(); amf_config();
~amf_config(); ~amf_config();
int load(const std::string &config_file); int load(const std::string &config_file);
int load_interface(const Setting &if_cfg, interface_cfg_t &cfg); int load_interface(const Setting& if_cfg, interface_cfg_t & cfg);
int load_thread_sched_params(const libconfig::Setting &thread_sched_params_cfg, util::thread_sched_params &cfg); int load_thread_sched_params(const libconfig::Setting& thread_sched_params_cfg, util::thread_sched_params& cfg);
void display(); void display();
unsigned int instance; public:
std::string pid_dir; unsigned int instance;
interface_cfg_t n2; string pid_dir;
interface_cfg_t n11; interface_cfg_t n2;
itti_cfg_t itti; itti_cfg_t itti;
unsigned int statistics_interval; unsigned int statistics_interval;
std::string AMF_Name; string AMF_Name;
guami_t guami; guami_t guami;
std::vector<guami_t> guami_list; vector<guami_t> guami_list;
unsigned int relativeAMFCapacity; unsigned int relativeAMFCapacity;
std::vector<plmn_item_t> plmn_list; vector<plmn_item_t> plmn_list;
std::string is_emergency_support; string is_emergency_support;
auth_conf auth_para; auth_conf auth_para;
nas_conf_t nas_cfg; nas_conf_t nas_cfg;
std::vector<smf_inst_t> smf_pool; vector<smf_inst_t> smf_pool;
}; };
} }
#endif #endif
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file amf_module_from_config.cpp
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "amf_module_from_config.hpp" #include "amf_module_from_config.hpp"
#include "logger.hpp"
#include <iostream> #include <iostream>
#include <string> #include <string>
using namespace std;
#include "logger.hpp"
namespace config { namespace config{
//------------------------------------------------------------------------------ int amf_modules::load(const std::string &config_file){
int amf_modules::load(const std::string &config_file) { cout<<endl;
Logger::amf_app().debug("\nLoad AMF module configuration file (%s)", config_file.c_str()); Logger::amf_app().debug("Load amf module configuration file(%s)",config_file.c_str());
Config cfg; Config cfg;
try { try{
cfg.readFile(config_file.c_str()); cfg.readFile(config_file.c_str());
} catch (const FileIOException &fioex) { }catch(const FileIOException &fioex){
Logger::amf_app().error("I/O error while reading file %s - %s", config_file.c_str(), fioex.what()); Logger::amf_app().error("I/O error while reading file %s - %s", config_file.c_str(), fioex.what());
throw; throw;
} catch (const ParseException &pex) { }catch(const ParseException &pex){
Logger::amf_app().error("Parse error at %s:%d - %s", pex.getFile(), pex.getLine(), pex.getError()); Logger::amf_app().error("Parse error at %s:%d - %s", pex.getFile(), pex.getLine(), pex.getError());
throw; throw;
} }
const Setting &root = cfg.getRoot(); const Setting &root = cfg.getRoot();
try { try{
const Setting &modules = root[MODULES_CONFIG_STRING_AMF_MODULES]; const Setting& modules = root[MODULES_CONFIG_STRING_AMF_MODULES];
} catch (const SettingNotFoundException &nfex) { }catch(const SettingNotFoundException &nfex){
Logger::amf_app().error("%s : %s", nfex.what(), nfex.getPath()); Logger::amf_app().error("%s : %s", nfex.what(), nfex.getPath());
return -1; return -1;
} }
const Setting &modules = root[MODULES_CONFIG_STRING_AMF_MODULES]; const Setting &modules = root[MODULES_CONFIG_STRING_AMF_MODULES];
const Setting &msg = modules[MODULES_CONFIG_STRING_AMF_MODULES_NGAP_MESSAGE]; const Setting &msg = modules[MODULES_CONFIG_STRING_AMF_MODULES_NGAP_MESSAGE];
int count = msg.getLength(); int count = msg.getLength();
for (int i = 0; i < count; i++) { for(int i=0; i< count; i++){
const Setting &item = msg[i]; const Setting & item = msg[i];
std::string typeOfMessage; std::string typeOfMessage;
int procedure_code; int procedure_code;
item.lookupValue(MODULES_CONFIG_STRING_AMF_MODULES_NGAP_MESSAGE_NAME, msgName); item.lookupValue(MODULES_CONFIG_STRING_AMF_MODULES_NGAP_MESSAGE_NAME, msgName);
item.lookupValue(MODULES_CONFIG_STRING_AMF_MODULES_NGAP_MESSAGE_PROCEDURECODE, procedure_code); item.lookupValue(MODULES_CONFIG_STRING_AMF_MODULES_NGAP_MESSAGE_PROCEDURECODE, procedure_code);
item.lookupValue(MODULES_CONFIG_STRING_AMF_MODULES_NGAP_MESSAGE_TYPEOFMSG, typeOfMessage); 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"))) { 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"))){
typeOfMsg = Ngap_NGAP_PDU_PR_successfulOutcome; typeOfMsg = Ngap_NGAP_PDU_PR_successfulOutcome;
} else if (!(typeOfMessage.compare("unsuccessfuloutcome"))) { }else if(!(typeOfMessage.compare("unsuccessfuloutcome"))){
typeOfMsg = Ngap_NGAP_PDU_PR_unsuccessfulOutcome; typeOfMsg = Ngap_NGAP_PDU_PR_unsuccessfulOutcome;
} else { }else{
Logger::config().error("wrong NGAP message configuration"); Logger::config().error("wrong NGAP message configuration");
} }
} }
} }
//------------------------------------------------------------------------------ void amf_modules::display(){
void amf_modules::display() { Logger::config().info( "======= AMF Registred Modules =======");
Logger::config().info("======= AMF Registered Modules ======="); Logger::config().info( "NGAP Message Modules Repository(SourceCode) Path( ~/oai-5g-amf/src/ngap/ngapMsgs )");
Logger::config().info("NGAP Message Modules:"); Logger::config().info( "NGAP Message Modules:");
Logger::config().info("- %s(Procedure code %d, Type of Msg %d)\n", msgName.c_str(), procedureCode, typeOfMsg); Logger::config().info( "- %s([%d,%d])\n", msgName.c_str(), procedureCode, typeOfMsg);
} }
} }
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file amf_module_from_config.hpp
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _AMF_MODULE_FROM_CONFIG_H_ #ifndef _AMF_MODULE_FROM_CONFIG_H_
#define _AMF_MODULE_FROM_CONFIG_H_ #define _AMF_MODULE_FROM_CONFIG_H_
...@@ -44,28 +16,38 @@ ...@@ -44,28 +16,38 @@
#include "Ngap_ProcedureCode.h" #include "Ngap_ProcedureCode.h"
#include "Ngap_NGAP-PDU.h" #include "Ngap_NGAP-PDU.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 "ProcedureCode"
#define MODULES_CONFIG_STRING_AMF_MODULES_NGAP_MESSAGE_TYPEOFMSG "TypeOfMessage" #define MODULES_CONFIG_STRING_AMF_MODULES_NGAP_MESSAGE_TYPEOFMSG "TypeOfMessage"
using namespace libconfig; using namespace libconfig;
namespace config { namespace config{
class amf_modules { class amf_modules{
public: public:
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;
}; };
} }
#endif #endif
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file amf_n11.hpp
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _AMF_N11_H_ #ifndef _AMF_N11_H_
#define _AMF_N11_H_ #define _AMF_N11_H_
#include "itti_msg_n11.hpp"
#include <map> #include <map>
#include <shared_mutex> #include <shared_mutex>
#include <string>
#include "itti_msg_n11.hpp"
#include "pdu_session_context.hpp" #include "pdu_session_context.hpp"
#include <string>
using namespace std;
namespace amf_application { namespace amf_application{
class amf_n11 { class amf_n11{
public: public:
amf_n11(); amf_n11();
~amf_n11(); ~amf_n11();
public:
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); void handle_pdu_session_initial_request(string supi, std::shared_ptr<pdu_session_context> psc, string smf_addr, bstring sm_msg, string dnn);
void handle_itti_message(itti_pdu_session_resource_setup_response &itti_msg); void handle_itti_message(itti_pdu_session_resource_setup_response &itti_msg);
void handle_itti_message(itti_nsmf_pdusession_update_sm_context &itti_msg); void handle_itti_message(itti_nsmf_pdusession_update_sm_context &itti_msg);
std::map<std::string, std::shared_ptr<pdu_session_context>> supi2pdu; // amf ue ngap id void handle_itti_message(itti_nsmf_pdusession_release_sm_context &itti_msg);
public:
std::map<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 string &supi) const;
std::shared_ptr<pdu_session_context> supi_to_pdu_ctx(const std::string &supi) const; std::shared_ptr<pdu_session_context> supi_to_pdu_ctx(const string & supi) const;
void set_supi_to_pdu_ctx(const std::string &supi, std::shared_ptr<pdu_session_context> psc); void set_supi_to_pdu_ctx(const string &supi, std::shared_ptr<pdu_session_context> psc);
std::map<uint8_t, std::string> pduid2supi; public:
std::map<uint8_t, string> pduid2supi;
bool smf_selection_from_configuration(std::string &smf_addr); public:
bool smf_selection_from_context(std::string &smf_addr); bool smf_selection_from_configuration(string & smf_addr);
bool smf_selection_from_context(string & smf_addr);
public:
void handle_post_sm_context_response_error_400(); void handle_post_sm_context_response_error_400();
void handle_post_sm_context_response_error(long code, std::string cause, bstring n1sm, std::string supi, uint8_t pdu_session_id); void handle_post_sm_context_response_error(long code, string cause, bstring n1sm, string supi, uint8_t pdu_session_id);
public:
void curl_http_client(std::string remoteUri, std::string jsonData, std::string n1SmMsg, std::string n2SmMsg, std::string supi, uint8_t pdu_session_id); void curl_http_client(string remoteUri, string jsonData, string n1SmMsg, string n2SmMsg, string supi, uint8_t pdu_session_id);
}; };
} }
#endif #endif
This diff is collapsed.
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
*file except in compliance with the License. You may obtain a copy of the
*License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file amf_n2.hpp
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _AMF_N2_H_ #ifndef _AMF_N2_H_
#define _AMF_N2_H_ #define _AMF_N2_H_
#include "HandoverCommandMsg.hpp"
#include "HandoverRequest.hpp"
#include "amf.hpp"
#include "itti_msg_n2.hpp"
#include "ngap_app.hpp" #include "ngap_app.hpp"
#include "itti_msg_n2.hpp"
#include "ue_ngap_context.hpp" #include "ue_ngap_context.hpp"
namespace amf_application { #include "PduSessionResourceReleaseCommand.hpp"
#include "HandoverRequest.hpp"
class amf_n2 : public ngap::ngap_app { #include "HandoverCommandMsg.hpp"
public: #include "DownlinkRANStatusTransfer.hpp"
amf_n2(const std::string &address, const uint16_t port_num); namespace amf_application
~amf_n2(); {
void handle_itti_message(itti_new_sctp_association &new_assoc);
void handle_itti_message(itti_ng_setup_request &ngsetupreq); class amf_n2 : public ngap::ngap_app
void handle_itti_message(itti_initial_ue_message &init_ue_msg); {
void handle_itti_message(itti_ul_nas_transport &ul_nas_transport); public:
void handle_itti_message(itti_dl_nas_transport &dl_nas_transport); amf_n2(const string &address, const uint16_t port_num);
void handle_itti_message(itti_initial_context_setup_request &itti_msg); ~amf_n2();
void handle_itti_message(itti_pdu_session_resource_setup_request &itti_msg); //void handle_receive(bstring payload, sctp_assoc_id_t assoc_id, sctp_stream_id_t stream, sctp_stream_id_t instreams, sctp_stream_id_t outstreams);
void handle_itti_message(itti_ue_context_release_request &itti_msg); void handle_itti_message(itti_new_sctp_association &new_assoc);
void handle_itti_message(itti_ue_radio_capability_indication &itti_msg); void handle_itti_message(itti_ng_setup_request &ngsetupreq);
void handle_itti_message(itti_handover_required &itti_msg); void handle_itti_message(itti_initial_ue_message &init_ue_msg);
void handle_itti_message(itti_handover_request_Ack &itti_msg); void handle_itti_message(itti_ul_nas_transport &ul_nas_transport);
void handle_itti_message(itti_handover_notify &itti_msg); void handle_itti_message(itti_dl_nas_transport &dl_nas_transport);
bool verifyPlmn(std::vector<SupportedItem_t> list); void handle_itti_message(itti_initial_context_setup_request &itti_msg);
std::vector<SupportedItem_t> void handle_itti_message(itti_pdu_session_resource_setup_request &itti_msg);
get_common_plmn(std::vector<SupportedItem_t> list); void handle_itti_message(itti_ue_context_release_request &itti_msg);
void handle_itti_message(itti_ue_radio_capability_indication &itti_msg);
private: void handle_itti_message(itti_ue_context_release_command &itti_msg);
std::map<uint32_t, std::shared_ptr<ue_ngap_context>> void handle_itti_message(itti_pdu_session_resource_release_command &itti_msg);
ranid2uecontext; // ran ue ngap id void handle_itti_message(itti_handover_required &itti_msg);
mutable std::shared_mutex m_ranid2uecontext; void handle_itti_message(itti_handover_request_Ack &itti_msg);
void handle_itti_message(itti_handover_notify &itti_msg);
bool is_ran_ue_id_2_ue_ngap_context(const uint32_t &ran_ue_ngap_id) const; void handle_itti_message(itti_uplinkranstatsutransfer &itti_msg);
std::shared_ptr<ue_ngap_context> bool verifyPlmn(vector<SupportedItem_t> list);
ran_ue_id_2_ue_ngap_context(const uint32_t &ran_ue_ngap_id) const;
void public:
set_ran_ue_ngap_id_2_ue_ngap_context(const uint32_t &ran_ue_ngap_id, std::map<uint32_t, std::shared_ptr<ue_ngap_context>> ranid2uecontext; // ran ue ngap id
std::shared_ptr<ue_ngap_context> unc); mutable std::shared_mutex m_ranid2uecontext;
};
bool is_ran_ue_id_2_ue_ngap_context(const uint32_t &ran_ue_ngap_id) const;
std::shared_ptr<ue_ngap_context> ran_ue_id_2_ue_ngap_context(const uint32_t &ran_ue_ngap_id) const;
void set_ran_ue_ngap_id_2_ue_ngap_context(const uint32_t &ran_ue_ngap_id, std::shared_ptr<ue_ngap_context> unc);
};
} // namespace amf_application } // namespace amf_application
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file amf_statistics.cpp
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "amf_statistics.hpp" #include "amf_statistics.hpp"
#include "logger.hpp"
#include <iostream> #include <iostream>
using namespace std;
#include "logger.hpp"
//------------------------------------------------------------------------------ void statistics::display(){
void statistics::display() { cout<<endl;
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 | registred UEs |");
//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("| %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-------------------------------------------|"); Logger::amf_app().info("-----------------------------------------------------------------------------------------------------------------");
Logger::amf_app().info("| Index | Status | Global ID | gNB Name | Tracking Area (PLMN, TAC) |"); Logger::amf_app().info("|----------------------------------------------------gNBs' information--------------------------------------------|");
if (gnbs.size() ==0 ) { for(int i=0; i<gnbs.size(); i++){
Logger::amf_app().info("| - | - | - | - | - |"); Logger::amf_app().info("[index %d][connected][GlobalID: 0x%x][gnb name: %s][Tracking Area: plmn(%s), tac(%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("-----------------------------------------------------------------------------------------------------------------"); cout<<endl;
//TODO: Show the list of common PLMNs Logger::amf_app().info("-----------------------------------------------------------------------------------------------------------------");
for (int i = 0; i < gnbs.size(); i++) {
Logger::amf_app().info("| %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--------------------------------------------|"); Logger::amf_app().info("|----------------------------------------------------UEs' information--------------------------------------------|");
Logger::amf_app().info("| Index | Connection state | Registration state | IMSI | GUTI | RAN UE NGAP ID | AMF UE ID |"); for(int i=0; i<ues.size();i++){
for (int i = 0; i < ues.size(); i++) { Logger::amf_app().info("[index %d][%s][%s][imsi %s][guti %s]", i+1, ues[i].connStatus.c_str(), ues[i].registerStatus.c_str(), ues[i].imsi.c_str(), ues[i].guti.c_str());
Logger::amf_app().info("| %d | %s | %s | %s | %s | %d | %d | ", i + 1, ues[i].connStatus.c_str(), ues[i].registerStatus.c_str(), ues[i].imsi.c_str(), ues[i].guti.c_str(), ues[i].ranid, ues[i].amfid); Logger::amf_app().info("Current ran_ue_ngap_id[%d]; Current amf_ue_ngap_id[%d]", ues[i].ranid, ues[i].amfid);
//Logger::amf_app().info("Current ran_ue_ngap_id[%d]; Current amf_ue_ngap_id[%d]", ues[i].ranid, ues[i].amfid); Logger::amf_app().info("Location[NrCgi][PLMN(%s), cellID(%d)]", (ues[i].mcc+ues[i].mnc).c_str(), ues[i].cellId); cout<<endl;
Logger::amf_app().info("Location [NrCgi][PLMN(%s), cellID(%d)]", (ues[i].mcc + ues[i].mnc).c_str(), ues[i].cellId);
Logger::amf_app().info("");
} }
Logger::amf_app().info("|----------------------------------------------------------------------------------------------------------------|"); Logger::amf_app().info("-----------------------------------------------------------------------------------------------------------------");
Logger::amf_app().info(""); Logger::amf_app().info("|--------------------------------------------------------------------------------------------------------------------|"); cout<<endl;
} }
//------------------------------------------------------------------------------ statistics::statistics(){
statistics::statistics() {
gNB_connected = 0; gNB_connected = 0;
UE_connected = 0; UE_connected = 0;
UE_registred = 0; UE_registred = 0;
} }
//------------------------------------------------------------------------------ statistics::~statistics(){}
statistics::~statistics() {
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file amf_statistics.hpp
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _STATISTICS_H_ #ifndef _STATISTICS_H_
#define _STATISTICS_H_ #define _STATISTICS_H_
...@@ -35,45 +7,49 @@ ...@@ -35,45 +7,49 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include "amf.hpp" using namespace std;
#include "ngap_app.hpp"
typedef struct { typedef struct{
uint32_t gnb_id; uint32_t gnb_id;
//TODO: list of PLMNs string mcc;
std::vector<SupportedItem_t> plmn_list; string mnc;
std::string mcc; string gnb_name;
std::string mnc;
std::string gnb_name;
uint32_t tac; uint32_t tac;
//long nrCellId; //long nrCellId;
} gnb_infos; }gnb_infos;
typedef struct { typedef struct{
std::string connStatus; string connStatus;
std::string registerStatus; string registerStatus;
uint32_t ranid; uint32_t ranid;
long amfid; long amfid;
std::string imsi; string imsi;
std::string guti; string guti;
std::string mcc; string mcc;
std::string mnc; string mnc;
uint32_t cellId; uint32_t cellId;
} ue_infos; }ue_infos;
class statistics { class statistics{
public: public:
void display(); void display();
statistics(); statistics();
~statistics(); ~statistics();
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; vector<gnb_infos> gnbs;
std::vector<ue_infos> ues; vector<ue_infos> ues;
}; };
#endif #endif
This diff is collapsed.
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file mysql_db.hpp
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _MYSQL_DB_HANDLERS_H_ #ifndef _MYSQL_DB_HANDLERS_H_
#define _MYSQL_DB_HANDLERS_H_ #define _MYSQL_DB_HANDLERS_H_
...@@ -38,15 +10,15 @@ ...@@ -38,15 +10,15 @@
#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];
uint8_t sqn[SQN_LENGTH]; uint8_t sqn[SQN_LENGTH];
uint8_t opc[KEY_LENGTH]; uint8_t opc[KEY_LENGTH];
uint8_t rand[RAND_LENGTH]; uint8_t rand[RAND_LENGTH];
} mysql_auth_info_t; }mysql_auth_info_t;
typedef struct { typedef struct {
//mysql reference connector object /* The 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