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_
#define _AMF_APP_H_
......@@ -41,42 +13,57 @@
#include "ue_context.hpp"
using namespace config;
using namespace std;
static uint32_t amf_app_ue_ngap_id_generator = 1;
namespace amf_application {
namespace amf_application{
#define TASK_AMF_APP_PERIODIC_STATISTICS (0)
class amf_app {
public:
class amf_app{
public:
explicit amf_app(const amf_config &amf_cfg);
amf_app(amf_app const&) = delete;
void operator=(amf_app const&) = delete;
void allRegistredModulesInit(const amf_modules &modules);
void operator=(amf_app const&) = delete;
void allRegistredModulesInit(const amf_modules & modules);
long generate_amf_ue_ngap_id();
//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
public://itti handlers
void handle_itti_message(itti_nas_signalling_establishment_request & itti_msg);
void handle_itti_message(itti_n1n2_message_transfer_request & itti_msg);
public://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;
mutable std::shared_mutex m_ue_ctx_key;
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;
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;
std::shared_ptr<ue_context> ran_amf_id_2_ue_context(const std::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);
// SMF Client response handlers
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;
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 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 string & ue_context_key, std::shared_ptr<ue_context> uc);
public:/*** SMF Client response handlers ****/
void handle_post_sm_context_response_error_400();
//others
bool generate_5g_guti(uint32_t ranid, long amfid, std::string &mcc, std::string &mnc, uint32_t &tmsi);
public:
bool generate_5g_guti(uint32_t ranid, long amfid, string &mcc, string &mnc, uint32_t& tmsi);
};
}
#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_
#define _AMF_CONFIG_H_
#include "amf_config.hpp"
#include <arpa/inet.h>
#include <libconfig.h++>
#include <netinet/in.h>
#include <sys/socket.h>
#include <mutex>
#include <vector>
#include <string>
#include "thread_sched.hpp"
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/classification.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_PID_DIRECTORY "PID_DIRECTORY"
#define AMF_CONFIG_STRING_INSTANCE_ID "INSTANCE_ID"
......@@ -52,7 +25,7 @@
#define AMF_CONFIG_STRING_INTERFACE_NGAP_AMF "NGAP_AMF"
#define AMF_CONFIG_STRING_INTERFACE_NAME "INTERFACE_NAME"
#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_INTERFACE_N11 "N11"
......@@ -69,16 +42,16 @@
#define AMF_CONFIG_STRING_AMF_NAME "AMF_NAME"
#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_MCC "MCC"
#define AMF_CONFIG_STRING_MNC "MNC"
#define AMF_CONFIG_STRING_RegionID "RegionID"
#define AMF_CONFIG_STRING_AMFSetID "AMFSetID"
#define AMF_CONFIG_STRING_AMFPointer "AMFPointer"
#define AMF_CONFIG_STRING_RELATIVE_AMF_CAPACITY "RELATIVE_CAPACITY"
#define AMF_CONFIG_STRING_PLMN_SUPPORT_LIST "PLMN_SUPPORT_LIST"
#define AMF_CONFIG_STRING_SLICE_SUPPORT_LIST "SLICE_SUPPORT_LIST"
#define AMF_CONFIG_STRING_RelativeAMFCapacity "RelativeAMFCapacity"
#define AMF_CONFIG_STRING_PLMNSupportList "PLMNSupportList"
#define AMF_CONFIG_STRING_SliceSupportList "SliceSupportList"
#define AMF_CONFIG_STRING_SST "SST"
#define AMF_CONFIG_STRING_SD "SD"
#define AMF_CONFIG_STRING_CORE_CONFIGURATION "CORE_CONFIGURATION"
......@@ -94,26 +67,28 @@
#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"
using namespace libconfig;
using namespace std;
namespace config {
namespace config{
typedef struct {
std::string mysql_server;
std::string mysql_user;
std::string mysql_pass;
std::string mysql_db;
std::string operator_key;
std::string random;
} auth_conf;
typedef struct{
string mysql_server;
string mysql_user;
string mysql_pass;
string mysql_db;
string operator_key;
string random;
}auth_conf;
typedef struct interface_cfg_s {
std::string if_name;
struct in_addr addr4;
struct in_addr network4;
std::string if_name;
struct in_addr addr4;
struct in_addr network4;
struct in6_addr addr6;
unsigned int mtu;
unsigned int port;
unsigned int mtu;
unsigned int port;
util::thread_sched_params thread_rd_sched_params;
} interface_cfg_t;
......@@ -125,64 +100,75 @@ typedef struct itti_cfg_s {
util::thread_sched_params async_cmd_sched_params;
} itti_cfg_t;
typedef struct guami_s {
std::string mcc;
std::string mnc;
std::string regionID;
std::string AmfSetID;
std::string AmfPointer;
} guami_t;
typedef struct slice_s {
std::string sST;
std::string sD;
} slice_t;
typedef struct plmn_support_item_s {
std::string mcc;
std::string mnc;
typedef struct guami_s{
string mcc;
string mnc;
string regionID;
string AmfSetID;
string AmfPointer;
}guami_t;
typedef struct slice_s{
string sST;
string sD;
}slice_t;
typedef struct plmn_support_item_s{
string mcc;
string mnc;
uint32_t tac;
std::vector<slice_t> slice_list;
} plmn_item_t;
vector<slice_t> slice_list;
}plmn_item_t;
typedef struct {
uint8_t prefered_integrity_algorithm[8];
uint8_t prefered_ciphering_algorithm[8];
} nas_conf_t;
typedef struct{
uint8_t prefered_integrity_algorithm[8];
uint8_t prefered_ciphering_algorithm[8];
}nas_conf_t;
typedef struct {
typedef struct{
int id;
std::string ipv4;
std::string port;
std::string version;
string ipv4;
string port;
string version;
bool selected;
} smf_inst_t;
}smf_inst_t;
class amf_config {
public:
class amf_config{
public:
amf_config();
~amf_config();
int load(const std::string &config_file);
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_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);
void display();
unsigned int instance;
std::string pid_dir;
interface_cfg_t n2;
interface_cfg_t n11;
itti_cfg_t itti;
unsigned int statistics_interval;
std::string AMF_Name;
guami_t guami;
std::vector<guami_t> guami_list;
unsigned int relativeAMFCapacity;
std::vector<plmn_item_t> plmn_list;
std::string is_emergency_support;
auth_conf auth_para;
nas_conf_t nas_cfg;
std::vector<smf_inst_t> smf_pool;
public:
unsigned int instance;
string pid_dir;
interface_cfg_t n2;
itti_cfg_t itti;
unsigned int statistics_interval;
string AMF_Name;
guami_t guami;
vector<guami_t> guami_list;
unsigned int relativeAMFCapacity;
vector<plmn_item_t> plmn_list;
string is_emergency_support;
auth_conf auth_para;
nas_conf_t nas_cfg;
vector<smf_inst_t> smf_pool;
};
}
#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 "logger.hpp"
#include <iostream>
#include <string>
using namespace std;
#include "logger.hpp"
namespace config {
namespace config{
//------------------------------------------------------------------------------
int amf_modules::load(const std::string &config_file) {
Logger::amf_app().debug("\nLoad AMF module configuration file (%s)", config_file.c_str());
Config cfg;
try {
int amf_modules::load(const std::string &config_file){
cout<<endl;
Logger::amf_app().debug("Load amf module configuration file(%s)",config_file.c_str());
Config cfg;
try{
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());
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());
throw;
}
const Setting &root = cfg.getRoot();
try {
const Setting &modules = root[MODULES_CONFIG_STRING_AMF_MODULES];
} catch (const SettingNotFoundException &nfex) {
try{
const Setting& modules = root[MODULES_CONFIG_STRING_AMF_MODULES];
}catch(const SettingNotFoundException &nfex){
Logger::amf_app().error("%s : %s", nfex.what(), nfex.getPath());
return -1;
}
const Setting &modules = root[MODULES_CONFIG_STRING_AMF_MODULES];
const Setting &msg = modules[MODULES_CONFIG_STRING_AMF_MODULES_NGAP_MESSAGE];
int count = msg.getLength();
for (int i = 0; i < count; i++) {
const Setting &item = msg[i];
for(int i=0; i< count; i++){
const Setting & item = msg[i];
std::string typeOfMessage;
int procedure_code;
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_TYPEOFMSG, typeOfMessage);
procedureCode = (Ngap_ProcedureCode_t) procedure_code;
if (!(typeOfMessage.compare("initialMessage"))) {
procedureCode = (Ngap_ProcedureCode_t)procedure_code;
if(!(typeOfMessage.compare("initialMessage"))){
typeOfMsg = Ngap_NGAP_PDU_PR_initiatingMessage;
} else if (!(typeOfMessage.compare("successfuloutcome"))) {
}else if(!(typeOfMessage.compare("successfuloutcome"))){
typeOfMsg = Ngap_NGAP_PDU_PR_successfulOutcome;
} else if (!(typeOfMessage.compare("unsuccessfuloutcome"))) {
}else if(!(typeOfMessage.compare("unsuccessfuloutcome"))){
typeOfMsg = Ngap_NGAP_PDU_PR_unsuccessfulOutcome;
} else {
}else{
Logger::config().error("wrong NGAP message configuration");
}
}
}
//------------------------------------------------------------------------------
void amf_modules::display() {
Logger::config().info("======= AMF Registered Modules =======");
Logger::config().info("NGAP Message Modules:");
Logger::config().info("- %s(Procedure code %d, Type of Msg %d)\n", msgName.c_str(), procedureCode, typeOfMsg);
void amf_modules::display(){
Logger::config().info( "======= AMF Registred 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( "- %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_
#define _AMF_MODULE_FROM_CONFIG_H_
......@@ -44,28 +16,38 @@
#include "Ngap_ProcedureCode.h"
#include "Ngap_NGAP-PDU.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"
using namespace libconfig;
namespace config {
namespace config{
class amf_modules {
public:
class amf_modules{
public:
int load(const std::string &config_file);
void display();
void makeModulesAlive();
private:
std::string msgName; //vector to store more msgs
Ngap_NGAP_PDU_PR typeOfMsg;
void makeModulesAlive();
private:
std::string msgName;//vector to store more msgs
Ngap_NGAP_PDU_PR typeOfMsg;
Ngap_ProcedureCode_t procedureCode;
// NGSetupRequestMsg *ngSetupRequest;
};
}
#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_
#define _AMF_N11_H_
#include "itti_msg_n11.hpp"
#include <map>
#include <shared_mutex>
#include <string>
#include "itti_msg_n11.hpp"
#include "pdu_session_context.hpp"
#include <string>
using namespace std;
namespace amf_application {
namespace amf_application{
class amf_n11 {
public:
class amf_n11{
public:
amf_n11();
~amf_n11();
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);
public:
void handle_itti_message(itti_smf_services_consumer &);
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_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;
bool is_supi_to_pdu_ctx(const std::string &supi) const;
std::shared_ptr<pdu_session_context> supi_to_pdu_ctx(const std::string &supi) const;
void set_supi_to_pdu_ctx(const std::string &supi, std::shared_ptr<pdu_session_context> psc);
std::map<uint8_t, std::string> pduid2supi;
bool is_supi_to_pdu_ctx(const string &supi) const;
std::shared_ptr<pdu_session_context> supi_to_pdu_ctx(const string & supi) const;
void set_supi_to_pdu_ctx(const string &supi, std::shared_ptr<pdu_session_context> psc);
public:
std::map<uint8_t, string> pduid2supi;
bool smf_selection_from_configuration(std::string &smf_addr);
bool smf_selection_from_context(std::string &smf_addr);
public:
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(long code, std::string cause, bstring n1sm, std::string supi, uint8_t pdu_session_id);
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 handle_post_sm_context_response_error(long code, string cause, bstring n1sm, string supi, uint8_t pdu_session_id);
public:
void curl_http_client(string remoteUri, string jsonData, string n1SmMsg, string n2SmMsg, string supi, uint8_t pdu_session_id);
};
}
#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_
#define _AMF_N2_H_
#include "HandoverCommandMsg.hpp"
#include "HandoverRequest.hpp"
#include "amf.hpp"
#include "itti_msg_n2.hpp"
#include "ngap_app.hpp"
#include "itti_msg_n2.hpp"
#include "ue_ngap_context.hpp"
namespace amf_application {
class amf_n2 : public ngap::ngap_app {
public:
amf_n2(const std::string &address, const uint16_t port_num);
~amf_n2();
void handle_itti_message(itti_new_sctp_association &new_assoc);
void handle_itti_message(itti_ng_setup_request &ngsetupreq);
void handle_itti_message(itti_initial_ue_message &init_ue_msg);
void handle_itti_message(itti_ul_nas_transport &ul_nas_transport);
void handle_itti_message(itti_dl_nas_transport &dl_nas_transport);
void handle_itti_message(itti_initial_context_setup_request &itti_msg);
void handle_itti_message(itti_pdu_session_resource_setup_request &itti_msg);
void handle_itti_message(itti_ue_context_release_request &itti_msg);
void handle_itti_message(itti_ue_radio_capability_indication &itti_msg);
void handle_itti_message(itti_handover_required &itti_msg);
void handle_itti_message(itti_handover_request_Ack &itti_msg);
void handle_itti_message(itti_handover_notify &itti_msg);
bool verifyPlmn(std::vector<SupportedItem_t> list);
std::vector<SupportedItem_t>
get_common_plmn(std::vector<SupportedItem_t> list);
private:
std::map<uint32_t, std::shared_ptr<ue_ngap_context>>
ranid2uecontext; // ran ue ngap id
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);
};
#include "PduSessionResourceReleaseCommand.hpp"
#include "HandoverRequest.hpp"
#include "HandoverCommandMsg.hpp"
#include "DownlinkRANStatusTransfer.hpp"
namespace amf_application
{
class amf_n2 : public ngap::ngap_app
{
public:
amf_n2(const string &address, const uint16_t port_num);
~amf_n2();
//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_new_sctp_association &new_assoc);
void handle_itti_message(itti_ng_setup_request &ngsetupreq);
void handle_itti_message(itti_initial_ue_message &init_ue_msg);
void handle_itti_message(itti_ul_nas_transport &ul_nas_transport);
void handle_itti_message(itti_dl_nas_transport &dl_nas_transport);
void handle_itti_message(itti_initial_context_setup_request &itti_msg);
void handle_itti_message(itti_pdu_session_resource_setup_request &itti_msg);
void handle_itti_message(itti_ue_context_release_request &itti_msg);
void handle_itti_message(itti_ue_radio_capability_indication &itti_msg);
void handle_itti_message(itti_ue_context_release_command &itti_msg);
void handle_itti_message(itti_pdu_session_resource_release_command &itti_msg);
void handle_itti_message(itti_handover_required &itti_msg);
void handle_itti_message(itti_handover_request_Ack &itti_msg);
void handle_itti_message(itti_handover_notify &itti_msg);
void handle_itti_message(itti_uplinkranstatsutransfer &itti_msg);
bool verifyPlmn(vector<SupportedItem_t> list);
public:
std::map<uint32_t, std::shared_ptr<ue_ngap_context>> ranid2uecontext; // ran ue ngap id
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
......
/*
* 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 "logger.hpp"
#include <iostream>
using namespace std;
#include "logger.hpp"
//------------------------------------------------------------------------------
void statistics::display() {
Logger::amf_app().info("");
void statistics::display(){
cout<<endl;
//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("| %d | %d | %d |",gNB_connected,UE_connected,UE_registred);
//Logger::amf_app().info("--------------------------------------------------");
Logger::amf_app().info("|----------------------------------------------------------------------------------------------------------------|");
Logger::amf_app().info("|----------------------------------------------------gNBs' information-------------------------------------------|");
Logger::amf_app().info("| Index | Status | Global ID | gNB Name | Tracking Area (PLMN, TAC) |");
if (gnbs.size() ==0 ) {
Logger::amf_app().info("| - | - | - | - | - |");
Logger::amf_app().info("|--------------------------------------------------------------------------------------------------------------------|");
Logger::amf_app().info("-----------------------------------------------------------------------------------------------------------------");
Logger::amf_app().info("|----------------------------------------------------gNBs' information--------------------------------------------|");
for(int i=0; i<gnbs.size(); i++){
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);
}
//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 | ", 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("-----------------------------------------------------------------------------------------------------------------"); cout<<endl;
Logger::amf_app().info("-----------------------------------------------------------------------------------------------------------------");
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++) {
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("Location [NrCgi][PLMN(%s), cellID(%d)]", (ues[i].mcc + ues[i].mnc).c_str(), ues[i].cellId);
Logger::amf_app().info("");
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("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("|----------------------------------------------------------------------------------------------------------------|");
Logger::amf_app().info("");
Logger::amf_app().info("-----------------------------------------------------------------------------------------------------------------");
Logger::amf_app().info("|--------------------------------------------------------------------------------------------------------------------|"); cout<<endl;
}
//------------------------------------------------------------------------------
statistics::statistics() {
statistics::statistics(){
gNB_connected = 0;
UE_connected = 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_
#define _STATISTICS_H_
......@@ -35,45 +7,49 @@
#include <vector>
#include <string>
#include "amf.hpp"
#include "ngap_app.hpp"
using namespace std;
typedef struct {
typedef struct{
uint32_t gnb_id;
//TODO: list of PLMNs
std::vector<SupportedItem_t> plmn_list;
std::string mcc;
std::string mnc;
std::string gnb_name;
string mcc;
string mnc;
string gnb_name;
uint32_t tac;
//long nrCellId;
} gnb_infos;
}gnb_infos;
typedef struct {
std::string connStatus;
std::string registerStatus;
typedef struct{
string connStatus;
string registerStatus;
uint32_t ranid;
long amfid;
std::string imsi;
std::string guti;
std::string mcc;
std::string mnc;
long amfid;
string imsi;
string guti;
string mcc;
string mnc;
uint32_t cellId;
} ue_infos;
}ue_infos;
class statistics {
public:
class statistics{
public:
void display();
statistics();
~statistics();
public:
uint32_t gNB_connected;
uint32_t UE_connected;
uint32_t UE_registred;
public:
uint32_t gNB_connected;
uint32_t UE_connected;
uint32_t UE_registred;
//uint32_t system_pdu_sessions;
std::vector<gnb_infos> gnbs;
std::vector<ue_infos> ues;
vector<gnb_infos> gnbs;
vector<ue_infos> ues;
};
#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_
#define _MYSQL_DB_HANDLERS_H_
......@@ -38,15 +10,15 @@
#define KEY_LENGTH (16)
#define SQN_LENGTH (6)
#define RAND_LENGTH (16)
typedef struct {
typedef struct{
uint8_t key[KEY_LENGTH];
uint8_t sqn[SQN_LENGTH];
uint8_t opc[KEY_LENGTH];
uint8_t rand[RAND_LENGTH];
} mysql_auth_info_t;
}mysql_auth_info_t;
typedef struct {
//mysql reference connector object
/* The 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