Commit 54f38bb0 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Merge branch 'prepare_release_v1.0' into 'develop'

Prepare release v1.0

See merge request oai/cn5g/oai-cn5g-amf!2
parents 8341c820 838416d5
This diff is collapsed.
......@@ -30,11 +30,8 @@
#define _AMF_APP_H_
#include <map>
#include <set>
#include <shared_mutex>
#include <string>
#include <thread>
#include <sstream>
#include "amf_config.hpp"
#include "amf_module_from_config.hpp"
#include "itti_msg_amf_app.hpp"
......@@ -65,16 +62,21 @@ class amf_app {
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);
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);
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
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);
bool generate_5g_guti(uint32_t ranid, long amfid, std::string &mcc,
std::string &mnc, uint32_t &tmsi);
};
}
......
This diff is collapsed.
......@@ -35,15 +35,10 @@
#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>
#define AMF_CONFIG_STRING_AMF_CONFIG "AMF"
#define AMF_CONFIG_STRING_PID_DIRECTORY "PID_DIRECTORY"
#define AMF_CONFIG_STRING_INSTANCE_ID "INSTANCE_ID"
......@@ -164,7 +159,9 @@ class 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_thread_sched_params(
const libconfig::Setting &thread_sched_params_cfg,
util::thread_sched_params &cfg);
void display();
unsigned int instance;
std::string pid_dir;
......
......@@ -37,15 +37,18 @@ 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());
Logger::amf_app().debug("\nLoad AMF module configuration file (%s)",
config_file.c_str());
Config cfg;
try {
cfg.readFile(config_file.c_str());
} 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;
} 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;
}
const Setting &root = cfg.getRoot();
......@@ -62,9 +65,13 @@ int amf_modules::load(const std::string &config_file) {
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);
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"))) {
typeOfMsg = Ngap_NGAP_PDU_PR_initiatingMessage;
......@@ -82,7 +89,8 @@ int amf_modules::load(const std::string &config_file) {
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);
Logger::config().info("- %s(Procedure code %d, Type of Msg %d)\n",
msgName.c_str(), procedureCode, typeOfMsg);
}
}
......@@ -29,14 +29,7 @@
#ifndef _AMF_MODULE_FROM_CONFIG_H_
#define _AMF_MODULE_FROM_CONFIG_H_
#include <arpa/inet.h>
#include <libconfig.h++>
#include <netinet/in.h>
#include <sys/socket.h>
#include <mutex>
#include <vector>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -44,22 +44,30 @@ class 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);
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_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
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::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 smf_selection_from_configuration(std::string &smf_addr);
bool smf_selection_from_context(std::string &smf_addr);
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, 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 curl_http_client(std::string remoteUri, std::string jsonData,
std::string n1SmMsg, std::string n2SmMsg,
std::string supi, uint8_t pdu_session_id);
};
}
......
This diff is collapsed.
......@@ -34,9 +34,9 @@
#include "ue_ngap_context.hpp"
#include "amf.hpp"
namespace amf_application{
namespace amf_application {
class amf_n2 : public ngap::ngap_app{
class amf_n2 : public ngap::ngap_app {
public:
amf_n2(const std::string &address, const uint16_t port_num);
~amf_n2();
......@@ -50,15 +50,18 @@ class amf_n2 : public ngap::ngap_app{
void handle_itti_message(itti_ue_context_release_request &itti_msg);
void handle_itti_message(itti_ue_radio_capability_indication &itti_msg);
bool verifyPlmn(std::vector<SupportedItem_t> list);
std::vector<SupportedItem_t> get_common_plmn(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
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);
};
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);
};
}
......
......@@ -28,8 +28,6 @@
#include "amf_statistics.hpp"
#include <iostream>
#include "logger.hpp"
//------------------------------------------------------------------------------
......@@ -40,30 +38,46 @@ void statistics::display() {
//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(
"|----------------------------------------------------gNBs' information-------------------------------------------|");
Logger::amf_app().info(
"| Index | Status | Global ID | gNB Name | Tracking Area (PLMN, TAC) |");
if (gnbs.size() == 0) {
Logger::amf_app().info(
"| - | - | - | - | - |");
}
//TODO: Show the list of common PLMNs
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(
"| %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("| Index | Connection state | Registration state | IMSI | GUTI | RAN UE NGAP ID | AMF UE ID |");
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(
"| %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("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("");
}
......
......@@ -29,9 +29,6 @@
#ifndef _STATISTICS_H_
#define _STATISTICS_H_
#include <stdlib.h>
#include <unistd.h>
#include <stdint.h>
#include <vector>
#include <string>
......
......@@ -45,11 +45,13 @@ bool amf_n1::get_mysql_auth_info(std::string imsi, mysql_auth_info_t &resp) { /
Logger::amf_n1().error("Cannot connect to MySQL DB");
return false;
}
query = "SELECT `key`,`sqn`,`rand`,`OPc` FROM `users` WHERE `users`.`imsi`='" + imsi + "' ";
query = "SELECT `key`,`sqn`,`rand`,`OPc` FROM `users` WHERE `users`.`imsi`='"
+ imsi + "' ";
pthread_mutex_lock(&db_desc->db_cs_mutex);
if (mysql_query(db_desc->db_conn, query.c_str())) {
pthread_mutex_unlock(&db_desc->db_cs_mutex);
Logger::amf_n1().error("Query execution failed: %s\n", mysql_error(db_desc->db_conn));
Logger::amf_n1().error("Query execution failed: %s\n",
mysql_error(db_desc->db_conn));
return false;
}
res = mysql_store_result(db_desc->db_conn);
......@@ -84,7 +86,8 @@ bool amf_n1::connect_to_mysql() {
const int mysql_reconnect_val = 1;
db_desc = (database_t*) calloc(1, sizeof(database_t));
if (!db_desc) {
Logger::amf_n1().error("An error occurs when allocating memory for DB_DESC");
Logger::amf_n1().error(
"An error occurs when allocating memory for DB_DESC");
return false;
}
pthread_mutex_init(&db_desc->db_cs_mutex, NULL);
......@@ -94,8 +97,11 @@ bool amf_n1::connect_to_mysql() {
db_desc->database = amf_cfg.auth_para.mysql_db;
db_desc->db_conn = mysql_init(NULL);
mysql_options(db_desc->db_conn, MYSQL_OPT_RECONNECT, &mysql_reconnect_val);
if (!mysql_real_connect(db_desc->db_conn, db_desc->server.c_str(), db_desc->user.c_str(), db_desc->password.c_str(), db_desc->database.c_str(), 0, NULL, 0)) {
Logger::amf_n1().error("An error occurred while connecting to db: %s", mysql_error(db_desc->db_conn));
if (!mysql_real_connect(db_desc->db_conn, db_desc->server.c_str(),
db_desc->user.c_str(), db_desc->password.c_str(),
db_desc->database.c_str(), 0, NULL, 0)) {
Logger::amf_n1().error("An error occurred while connecting to db: %s",
mysql_error(db_desc->db_conn));
mysql_thread_end();
return false;
}
......@@ -104,7 +110,8 @@ bool amf_n1::connect_to_mysql() {
}
//------------------------------------------------------------------------------
void amf_n1::mysql_push_rand_sqn(std::string imsi, uint8_t *rand_p, uint8_t *sqn) {
void amf_n1::mysql_push_rand_sqn(std::string imsi, uint8_t *rand_p,
uint8_t *sqn) {
int status = 0;
MYSQL_RES *res;
char query[1000];
......@@ -118,18 +125,21 @@ void amf_n1::mysql_push_rand_sqn(std::string imsi, uint8_t *rand_p, uint8_t *sqn
Logger::amf_n1().error("Need sqn and rand");
return;
}
sqn_decimal = ((uint64_t) sqn[0] << 40) | ((uint64_t) sqn[1] << 32) | ((uint64_t) sqn[2] << 24) | (sqn[3] << 16) | (sqn[4] << 8) | sqn[5];
sqn_decimal = ((uint64_t) sqn[0] << 40) | ((uint64_t) sqn[1] << 32)
| ((uint64_t) sqn[2] << 24) | (sqn[3] << 16) | (sqn[4] << 8) | sqn[5];
query_length = sprintf(query, "UPDATE `users` SET `rand`=UNHEX('");
for (int i = 0; i < RAND_LENGTH; i++) {
query_length += sprintf(&query[query_length], "%02x", rand_p[i]);
}
query_length += sprintf (&query[query_length], "'),`sqn`=%" PRIu64, sqn_decimal);
query_length += sprintf(&query[query_length], " WHERE `users`.`imsi`='%s'", imsi.c_str());
query_length += sprintf(&query[query_length], " WHERE `users`.`imsi`='%s'",
imsi.c_str());
pthread_mutex_lock(&db_desc->db_cs_mutex);
if (mysql_query(db_desc->db_conn, query)) {
pthread_mutex_unlock(&db_desc->db_cs_mutex);
Logger::amf_n1().error("Query execution failed: %s", mysql_error(db_desc->db_conn));
Logger::amf_n1().error("Query execution failed: %s",
mysql_error(db_desc->db_conn));
return;
}
do {
......@@ -138,7 +148,8 @@ void amf_n1::mysql_push_rand_sqn(std::string imsi, uint8_t *rand_p, uint8_t *sqn
mysql_free_result(res);
} else {
if (mysql_field_count(db_desc->db_conn) == 0) {
Logger::amf_n1().error("[MySQL] %lld rows affected", mysql_affected_rows(db_desc->db_conn));
Logger::amf_n1().error("[MySQL] %lld rows affected",
mysql_affected_rows(db_desc->db_conn));
} else { /* some error occurred */
Logger::amf_n1().error("Could not retrieve result set");
break;
......@@ -160,13 +171,16 @@ void amf_n1::mysql_increment_sqn(std::string imsi) {
Logger::amf_n1().error("Cannot connect to MySQL DB");
return;
}
sprintf(query, "UPDATE `users` SET `sqn` = `sqn` + 32 WHERE `users`.`imsi`='%s'", imsi.c_str());
sprintf(query,
"UPDATE `users` SET `sqn` = `sqn` + 32 WHERE `users`.`imsi`='%s'",
imsi.c_str());
pthread_mutex_lock(&db_desc->db_cs_mutex);
if (mysql_query(db_desc->db_conn, query)) {
pthread_mutex_unlock(&db_desc->db_cs_mutex);
Logger::amf_n1().error("Query execution failed: %s", mysql_error(db_desc->db_conn));
Logger::amf_n1().error("Query execution failed: %s",
mysql_error(db_desc->db_conn));
return;
}
do {
......@@ -175,7 +189,8 @@ void amf_n1::mysql_increment_sqn(std::string imsi) {
mysql_free_result(res);
} else {
if (mysql_field_count(db_desc->db_conn) == 0) {
Logger::amf_n1().error("[MySQL] %lld rows affected", mysql_affected_rows(db_desc->db_conn));
Logger::amf_n1().error("[MySQL] %lld rows affected",
mysql_affected_rows(db_desc->db_conn));
} else {
Logger::amf_n1().error("Could not retrieve result set");
break;
......
......@@ -29,10 +29,8 @@
#ifndef _MYSQL_DB_HANDLERS_H_
#define _MYSQL_DB_HANDLERS_H_
#include <stdint.h>
#include <pthread.h>
#include <mysql/mysql.h>
#include <netinet/in.h>
#include <string>
#define KEY_LENGTH (16)
......
......@@ -34,7 +34,6 @@ typedef struct {
uint32_t tac;
} plmn_t;
typedef struct s_nssai // section 28.4, TS23.003
{
uint8_t sST;
......@@ -65,7 +64,6 @@ typedef struct s_nssai // section 28.4, TS23.003
} snssai_t;
//SMF + AMF + 3GPP TS 29.571 (Common data)
enum class http_response_codes_e {
HTTP_RESPONSE_CODE_200_OK = 200,
......@@ -94,13 +92,10 @@ enum class http_response_codes_e {
};
//for CURL
#define SMF_CURL_TIMEOUT_MS 100L
#define SMF_NUMBER_RETRIES 3
constexpr auto CURL_MIME_BOUNDARY = "----Boundary";
#endif
......@@ -33,7 +33,8 @@
#include <string>
//------------------------------------------------------------------------------
void print_buffer(const std::string app, const std::string commit, uint8_t *buf, int len) {
void print_buffer(const std::string app, const std::string commit, uint8_t *buf,
int len) {
if (!app.compare("amf_app"))
Logger::amf_app().debug(commit.c_str());
if (!app.compare("amf_n1"))
......
......@@ -33,12 +33,24 @@
#include <inttypes.h>
#include <arpa/inet.h>
static const char hex_to_ascii_table[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', };
static const signed char ascii_to_hex_table[0x100] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
-1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
static const char hex_to_ascii_table[16] = { '0', '1', '2', '3', '4', '5', '6',
'7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', };
static const signed char ascii_to_hex_table[0x100] = { -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, -1,
10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1 };
//------------------------------------------------------------------------------
void conv::hexa_to_ascii(uint8_t *from, char *to, size_t length) {
......@@ -88,7 +100,8 @@ int conv::ascii_to_hex(uint8_t *dst, const char *h) {
}
//------------------------------------------------------------------------------
std::string conv::mccToString(const uint8_t digit1, const uint8_t digit2, const uint8_t digit3) {
std::string conv::mccToString(const uint8_t digit1, const uint8_t digit2,
const uint8_t digit3) {
std::string s = { };
uint16_t mcc16 = digit1 * 100 + digit2 * 10 + digit3;
//s.append(std::to_string(digit1)).append(std::to_string(digit2)).append(std::to_string(digit3));
......@@ -97,7 +110,8 @@ std::string conv::mccToString(const uint8_t digit1, const uint8_t digit2, const
}
//------------------------------------------------------------------------------
std::string conv::mncToString(const uint8_t digit1, const uint8_t digit2, const uint8_t digit3) {
std::string conv::mncToString(const uint8_t digit1, const uint8_t digit2,
const uint8_t digit3) {
std::string s = { };
uint16_t mcc16 = 0;
......@@ -122,7 +136,8 @@ struct in_addr conv::fromString(const std::string addr4) {
std::string conv::toString(const struct in_addr &inaddr) {
std::string s = { };
char str[INET6_ADDRSTRLEN] = { };
if (inet_ntop(AF_INET, (const void*) &inaddr, str, INET6_ADDRSTRLEN) == NULL) {
if (inet_ntop(AF_INET, (const void*) &inaddr, str, INET6_ADDRSTRLEN)
== NULL) {
s.append("Error in_addr");
} else {
s.append(str);
......@@ -134,7 +149,8 @@ std::string conv::toString(const struct in_addr &inaddr) {
std::string conv::toString(const struct in6_addr &in6addr) {
std::string s = { };
char str[INET6_ADDRSTRLEN] = { };
if (inet_ntop(AF_INET6, (const void*) &in6addr, str, INET6_ADDRSTRLEN) == nullptr) {
if (inet_ntop(AF_INET6, (const void*) &in6addr, str, INET6_ADDRSTRLEN)
== nullptr) {
s.append("Error in6_addr");
} else {
s.append(str);
......
......@@ -50,7 +50,9 @@ class conv {
static struct in_addr fromString(const std::string addr4);
static std::string toString(const struct in_addr &inaddr);
static std::string toString(const struct in6_addr &in6addr);
static std::string mccToString(const uint8_t digit1, const uint8_t digit2, const uint8_t digit3);
static std::string mncToString(const uint8_t digit1, const uint8_t digit2, const uint8_t digit3);
static std::string mccToString(const uint8_t digit1, const uint8_t digit2,
const uint8_t digit3);
static std::string mncToString(const uint8_t digit1, const uint8_t digit2,
const uint8_t digit3);
};
#endif /* FILE_CONVERSIONS_HPP_SEEN */
......@@ -36,7 +36,8 @@
Logger *Logger::m_singleton = NULL;
//------------------------------------------------------------------------------
void Logger::_init(const char *app, const bool log_stdout, const bool log_rot_file) {
void Logger::_init(const char *app, const bool log_stdout,
const bool log_rot_file) {
int num_sinks = 0;
spdlog::set_async_mode(2048);
#if TRACE_IS_ON
......@@ -51,12 +52,15 @@ void Logger::_init(const char *app, const bool log_stdout, const bool log_rot_fi
if (log_stdout) {
std::string filename = fmt::format("./{}.log", app);
m_sinks.push_back(std::make_shared<spdlog::sinks::ansicolor_stdout_sink_mt>());
m_sinks.push_back(
std::make_shared<spdlog::sinks::ansicolor_stdout_sink_mt>());
m_sinks[num_sinks++].get()->set_level(llevel);
}
if (log_rot_file) {
std::string filename = fmt::format("./{}.log", app);
m_sinks.push_back(std::make_shared < spdlog::sinks::rotating_file_sink_mt > (filename, 5 * 1024 * 1024, 3));
m_sinks.push_back(
std::make_shared < spdlog::sinks::rotating_file_sink_mt
> (filename, 5 * 1024 * 1024, 3));
}
std::stringstream ss;
......@@ -78,7 +82,8 @@ void Logger::_init(const char *app, const bool log_stdout, const bool log_rot_fi
}
//------------------------------------------------------------------------------
_Logger::_Logger(const char *category, std::vector<spdlog::sink_ptr> &sinks, const char *pattern)
_Logger::_Logger(const char *category, std::vector<spdlog::sink_ptr> &sinks,
const char *pattern)
:
m_log(category, sinks.begin(), sinks.end()) {
m_log.set_pattern(pattern);
......
......@@ -51,7 +51,8 @@ class LoggerException : public std::runtime_error {
class _Logger {
public:
_Logger(const char *category, std::vector<spdlog::sink_ptr> &sinks, const char *pattern);
_Logger(const char *category, std::vector<spdlog::sink_ptr> &sinks,
const char *pattern);
void trace(const char *format, ...);
void trace(const std::string &format, ...);
......@@ -84,10 +85,12 @@ class _Logger {
class Logger {
public:
static void init(const char *app, const bool log_stdout, const bool log_rot_file) {
static void init(const char *app, const bool log_stdout,
const bool log_rot_file) {
singleton()._init(app, log_stdout, log_rot_file);
}
static void init(const std::string &app, const bool log_stdout, const bool log_rot_file) {
static void init(const std::string &app, const bool log_stdout,
const bool log_rot_file) {
init(app.c_str(), log_stdout, log_rot_file);
}
......
......@@ -30,8 +30,6 @@
#define _UE_CONTEXT_H_
#include <stdint.h>
#include <map>
#include <shared_mutex>
#include "NgapIEsStruct.hpp"
......
......@@ -31,7 +31,6 @@
#include <stdint.h>
#include <map>
#include <shared_mutex>
#include "gNB_context.hpp"
......
......@@ -36,10 +36,12 @@
extern itti_mw *itti_inst;
static itti_timer null_timer(ITTI_INVALID_TIMER_ID, TASK_NONE, 0xFFFFFFFF, 0xFFFFFFFF, 0, 0);
static itti_timer null_timer(ITTI_INVALID_TIMER_ID, TASK_NONE, 0xFFFFFFFF,
0xFFFFFFFF, 0, 0);
//------------------------------------------------------------------------------
void itti_mw::timer_manager_task(const util::thread_sched_params &sched_params) {
void itti_mw::timer_manager_task(
const util::thread_sched_params &sched_params) {
Logger::itti().info("Starting timer_manager_task");
sched_params.apply(TASK_ITTI_TIMER, Logger::itti());
while (true) {
......@@ -56,15 +58,22 @@ void itti_mw::timer_manager_task(const util::thread_sched_params &sched_params)
lx.unlock();
// check time-out
if (itti_inst->current_timer.time_out > std::chrono::system_clock::now()) {
if (itti_inst->current_timer.time_out
> std::chrono::system_clock::now()) {
std::unique_lock < std::mutex > lto(itti_inst->m_timeout);
auto diff = itti_inst->current_timer.time_out - std::chrono::system_clock::now();
auto diff = itti_inst->current_timer.time_out
- std::chrono::system_clock::now();
auto rc = itti_inst->c_timeout.wait_for(lto, diff);
lto.unlock();
if (std::cv_status::timeout == rc) {
// signal time-out
itti_msg_timeout mto(TASK_ITTI_TIMER, itti_inst->current_timer.task_id, itti_inst->current_timer.id, itti_inst->current_timer.arg1_user, itti_inst->current_timer.arg2_user);
std::shared_ptr<itti_msg_timeout> msgsh = std::make_shared < itti_msg_timeout > (mto);
itti_msg_timeout mto(TASK_ITTI_TIMER,
itti_inst->current_timer.task_id,
itti_inst->current_timer.id,
itti_inst->current_timer.arg1_user,
itti_inst->current_timer.arg2_user);
std::shared_ptr<itti_msg_timeout> msgsh = std::make_shared
< itti_msg_timeout > (mto);
int ret = itti_inst->send_msg(msgsh);
} else {
// other timer required ?
......@@ -78,8 +87,12 @@ void itti_mw::timer_manager_task(const util::thread_sched_params &sched_params)
}
} else {
// signal time-out
itti_msg_timeout mto(TASK_ITTI_TIMER, itti_inst->current_timer.task_id, itti_inst->current_timer.id, itti_inst->current_timer.arg1_user, itti_inst->current_timer.arg2_user);
std::shared_ptr<itti_msg_timeout> msgsh = std::make_shared < itti_msg_timeout > (mto);
itti_msg_timeout mto(TASK_ITTI_TIMER, itti_inst->current_timer.task_id,
itti_inst->current_timer.id,
itti_inst->current_timer.arg1_user,
itti_inst->current_timer.arg2_user);
std::shared_ptr<itti_msg_timeout> msgsh = std::make_shared
< itti_msg_timeout > (mto);
itti_inst->send_msg(msgsh);
}
}
......@@ -133,7 +146,8 @@ unsigned int itti_mw::increment_message_number() {
}
//------------------------------------------------------------------------------
int itti_mw::create_task(const task_id_t task_id, void (*start_routine)(void*), void *args_p) {
int itti_mw::create_task(const task_id_t task_id, void (*start_routine)(void*),
void *args_p) {
if (nullptr == start_routine) {
Logger::itti().error("Null start routine for task %d", task_id);
return RETURNerror ;
......@@ -150,7 +164,8 @@ int itti_mw::create_task(const task_id_t task_id, void (*start_routine)(void*),
lk.unlock();
}
itti_task_ctxts[task_id]->thread = std::thread(start_routine, args_p);
while ((itti_task_ctxts[task_id]->task_state != TASK_STATE_READY) && (itti_task_ctxts[task_id]->task_state != TASK_STATE_ENDED))
while ((itti_task_ctxts[task_id]->task_state != TASK_STATE_READY)
&& (itti_task_ctxts[task_id]->task_state != TASK_STATE_ENDED))
usleep(1000);
return 0;
} else {
......@@ -172,7 +187,8 @@ int itti_mw::notify_task_ready(const task_id_t task_id) {
return RETURNok ;
}
itti_task_ctxts[task_id]->m_state.unlock();
Logger::itti().error("Notify task ready, bad state %d", itti_task_ctxts[task_id]->task_state);
Logger::itti().error("Notify task ready, bad state %d",
itti_task_ctxts[task_id]->task_state);
} else {
Logger::itti().error("Notify task ready, task not starting %d", task_id);
}
......@@ -182,21 +198,29 @@ int itti_mw::notify_task_ready(const task_id_t task_id) {
//------------------------------------------------------------------------------
int itti_mw::send_msg(std::shared_ptr<itti_msg> message) {
if ((TASK_FIRST <= message->destination) && (TASK_MAX > message->destination)) {
if ((TASK_FIRST <= message->destination)
&& (TASK_MAX > message->destination)) {
if (itti_task_ctxts[message->destination]) {
if (itti_task_ctxts[message->destination]->task_state == TASK_STATE_READY) {
std::unique_lock < std::mutex > l(itti_task_ctxts[message->destination]->m_queue);
if (itti_task_ctxts[message->destination]->task_state
== TASK_STATE_READY) {
std::unique_lock < std::mutex
> l(itti_task_ctxts[message->destination]->m_queue);
//res =
itti_task_ctxts[message->destination]->msg_queue.push(message);
itti_task_ctxts[message->destination]->c_queue.notify_one();
return RETURNok ;
} else if (itti_task_ctxts[message->destination]->task_state == TASK_STATE_ENDED) {
Logger::itti().warn("Unicast message number %lu can not be sent from %d to %d, ended destination task!", message->msg_num, message->origin, message->destination);
} else if (itti_task_ctxts[message->destination]->task_state
== TASK_STATE_ENDED) {
Logger::itti().warn(
"Unicast message number %lu can not be sent from %d to %d, ended destination task!",
message->msg_num, message->origin, message->destination);
return RETURNerror ;
}
} else {
Logger::itti().warn("Unicast message number %lu can not be sent from %d to %d, not started destination task!", message->msg_num, message->origin, message->destination);
Logger::itti().warn(
"Unicast message number %lu can not be sent from %d to %d, not started destination task!",
message->msg_num, message->origin, message->destination);
}
} else if (message->destination == TASK_ALL) {
return send_broadcast_msg(message);
......@@ -215,9 +239,14 @@ int itti_mw::send_broadcast_msg(std::shared_ptr<itti_msg> message) {
itti_task_ctxts[t]->msg_queue.push(message);
itti_task_ctxts[t]->c_queue.notify_one();
} else if (itti_task_ctxts[t]->task_state == TASK_STATE_ENDED) {
Logger::itti().warn("Broadcast message number %lu can not be sent from %d to %d, ended destination task!", message->msg_num, message->origin, t);
Logger::itti().warn(
"Broadcast message number %lu can not be sent from %d to %d, ended destination task!",
message->msg_num, message->origin, t);
} else {
Logger::itti().warn("Broadcast message number %lu can not be sent from %d to %d, unknown state %d !", message->msg_num, message->origin, t, itti_task_ctxts[t]->task_state);
Logger::itti().warn(
"Broadcast message number %lu can not be sent from %d to %d, unknown state %d !",
message->msg_num, message->origin, t,
itti_task_ctxts[t]->task_state);
}
}
}
......@@ -231,7 +260,8 @@ int itti_mw::send_terminate_msg(task_id_t src_task_id) {
itti_msg_terminate msg(src_task_id, TASK_ALL);
terminate = true;
std::shared_ptr<itti_msg_terminate> smsg = std::make_shared < itti_msg_terminate > (msg);
std::shared_ptr<itti_msg_terminate> smsg = std::make_shared
< itti_msg_terminate > (msg);
int ret = itti_inst->send_broadcast_msg(smsg);
return ret;
......@@ -244,7 +274,8 @@ std::shared_ptr<itti_msg> itti_mw::receive_msg(task_id_t task_id) {
while (itti_task_ctxts[task_id]->msg_queue.empty()) {
itti_task_ctxts[task_id]->c_queue.wait(lk);
}
std::shared_ptr<itti_msg> msg = itti_task_ctxts[task_id]->msg_queue.front();
std::shared_ptr<itti_msg> msg =
itti_task_ctxts[task_id]->msg_queue.front();
itti_task_ctxts[task_id]->msg_queue.pop();
return msg;
}
......@@ -259,7 +290,8 @@ std::shared_ptr<itti_msg> itti_mw::poll_msg(task_id_t task_id) {
if (itti_task_ctxts[task_id]) {
std::lock_guard < std::mutex > lk(itti_task_ctxts[task_id]->m_queue);
if (!itti_task_ctxts[task_id]->msg_queue.empty()) {
std::shared_ptr<itti_msg> msg = itti_task_ctxts[task_id]->msg_queue.front();
std::shared_ptr<itti_msg> msg = itti_task_ctxts[task_id]->msg_queue
.front();
itti_task_ctxts[task_id]->msg_queue.pop();
return msg;
}
......@@ -286,10 +318,13 @@ void itti_mw::wait_tasks_end(void) {
}
//------------------------------------------------------------------------------
timer_id_t itti_mw::timer_setup(uint32_t interval_sec, uint32_t interval_us, task_id_t task_id, uint64_t arg1_user, uint64_t arg2_user) {
timer_id_t itti_mw::timer_setup(uint32_t interval_sec, uint32_t interval_us,
task_id_t task_id, uint64_t arg1_user,
uint64_t arg2_user) {
// Not sending to task timer
if ((TASK_FIRST < task_id) && (TASK_MAX > task_id)) {
itti_timer t(increment_timer_id(), task_id, interval_sec, interval_us, arg1_user, arg2_user);
itti_timer t(increment_timer_id(), task_id, interval_sec, interval_us,
arg1_user, arg2_user);
timer_id_t id = t.id;
std::unique_lock < std::mutex > l(m_timers);
timers.insert(t);
......
......@@ -19,15 +19,14 @@
* contact@openairinterface.org
*/
/*! \file itti.hpp
\brief
\author Lionel GAUTHIER
\date 2018
\email: lionel.gauthier@eurecom.fr
*/
\brief
\author Lionel GAUTHIER
\date 2018
\email: lionel.gauthier@eurecom.fr
*/
#ifndef SRC_OAI_ITTI_ITTI_HPP_INCLUDED_
#define SRC_OAI_ITTI_ITTI_HPP_INCLUDED_
#include <chrono>
#include <condition_variable>
//#include <iomanip>
......@@ -42,104 +41,137 @@
#include "thread_sched.hpp"
typedef volatile enum task_state_s {
TASK_STATE_NOT_CONFIGURED, TASK_STATE_STARTING, TASK_STATE_READY, TASK_STATE_ENDED, TASK_STATE_MAX,
TASK_STATE_NOT_CONFIGURED,
TASK_STATE_STARTING,
TASK_STATE_READY,
TASK_STATE_ENDED,
TASK_STATE_MAX,
} task_state_t;
typedef uint32_t timer_id_t;
#define ITTI_INVALID_TIMER_ID (timer_id_t)0
class itti_timer {
public:
itti_timer(const timer_id_t id, const task_id_t task_id, const uint32_t interval_sec, const uint32_t interval_us, uint64_t arg1_user, uint64_t arg2_user) :
id(id), task_id(task_id), arg1_user(arg1_user), arg2_user(arg2_user) {
time_out = std::chrono::system_clock::now() + std::chrono::seconds(interval_sec) + std::chrono::microseconds(interval_us);
public:
itti_timer(const timer_id_t id, const task_id_t task_id,
const uint32_t interval_sec, const uint32_t interval_us,
uint64_t arg1_user, uint64_t arg2_user)
:
id(id),
task_id(task_id),
arg1_user(arg1_user),
arg2_user(arg2_user) {
time_out = std::chrono::system_clock::now()
+ std::chrono::seconds(interval_sec)
+ std::chrono::microseconds(interval_us);
}
itti_timer(const timer_id_t id, const task_id_t task_id, const std::chrono::system_clock::time_point time_out, uint64_t arg1_user, uint64_t arg2_user) :
id(id), task_id(task_id), time_out(time_out), arg1_user(arg1_user), arg2_user(arg2_user) {
itti_timer(const timer_id_t id, const task_id_t task_id,
const std::chrono::system_clock::time_point time_out,
uint64_t arg1_user, uint64_t arg2_user)
:
id(id),
task_id(task_id),
time_out(time_out),
arg1_user(arg1_user),
arg2_user(arg2_user) {
}
itti_timer(const itti_timer &t)
:
id(t.id),
task_id(t.task_id),
time_out(t.time_out),
arg1_user(t.arg1_user),
arg2_user(t.arg2_user) {
}
itti_timer(const itti_timer &t) : id(t.id), task_id(t.task_id) , time_out(t.time_out), arg1_user(t.arg1_user), arg2_user(t.arg2_user) {}
//itti_timer(itti_timer&& t) noexcept : id(std::move(t.id)), task_id(std::move(t.task_id)) , time_out(std::move(t.time_out)) {}
bool operator<(const itti_timer& t) const { return time_out < t.time_out; }
~itti_timer() {}
timer_id_t id;
task_id_t task_id;
bool operator<(const itti_timer &t) const {
return time_out < t.time_out;
}
~itti_timer() {
}
timer_id_t id;
task_id_t task_id;
std::chrono::system_clock::time_point time_out;
uint64_t arg1_user;
uint64_t arg2_user;
uint64_t arg1_user;
uint64_t arg2_user;
};
//------------------------------------------------------------------------------
struct timer_comparator {
bool operator()(const itti_timer &left, const itti_timer &right) const
{
return (left.time_out < right.time_out);
}
bool operator()(const itti_timer &left, const itti_timer &right) const {
return (left.time_out < right.time_out);
}
};
class itti_task_ctxt {
public:
explicit itti_task_ctxt(const task_id_t task_id) :
task_id(task_id), m_state(), task_state(TASK_STATE_STARTING), msg_queue() , m_queue(), c_queue() {}
~itti_task_ctxt() {}
public:
explicit itti_task_ctxt(const task_id_t task_id)
:
task_id(task_id),
m_state(),
task_state(TASK_STATE_STARTING),
msg_queue(),
m_queue(),
c_queue() {
}
~itti_task_ctxt() {
}
const task_id_t task_id;
const task_id_t task_id;
/*
* pthread associated with the thread
*/
//std::thread::id thread_id;
std::thread thread;
std::thread thread;
/*
* State of the thread
*/
std::mutex m_state;
volatile task_state_t task_state;
std::mutex m_state;
volatile task_state_t task_state;
std::queue<std::shared_ptr<itti_msg>> msg_queue;
std::mutex m_queue;
std::condition_variable c_queue;
std::queue<std::shared_ptr<itti_msg>> msg_queue;
std::mutex m_queue;
std::condition_variable c_queue;
};
class itti_mw {
private:
itti_task_ctxt *itti_task_ctxts[TASK_MAX];
private:
itti_task_ctxt *itti_task_ctxts[TASK_MAX];
/*
* Current message number. Incremented every call to send_msg_to_task
*/
unsigned long msg_number;
timer_id_t timer_id;
std::mutex m_timer_id;
std::thread timer_thread;
unsigned long msg_number;
timer_id_t timer_id;
std::mutex m_timer_id;
std::thread timer_thread;
std::atomic<int> created_tasks;
std::atomic<int> ready_tasks;
std::atomic<int> created_tasks;
std::atomic<int> ready_tasks;
std::set<itti_timer, timer_comparator> timers;
itti_timer current_timer;
std::mutex m_timers;
std::condition_variable c_timers;
std::set<itti_timer, timer_comparator> timers;
itti_timer current_timer;
std::mutex m_timers;
std::condition_variable c_timers;
std::mutex m_timeout;
std::condition_variable c_timeout;
std::mutex m_timeout;
std::condition_variable c_timeout;
bool terminate;
bool terminate;
static void timer_manager_task(const util::thread_sched_params& sched_params);
static void timer_manager_task(const util::thread_sched_params &sched_params);
public:
public:
itti_mw();
itti_mw(itti_mw const&) = delete;
void operator=(itti_mw const&) = delete;
itti_mw(itti_mw const&) = delete;
void operator=(itti_mw const&) = delete;
~itti_mw();
void start(const util::thread_sched_params& sched_params);
void start(const util::thread_sched_params &sched_params);
timer_id_t increment_timer_id ();
unsigned int increment_message_number ();
timer_id_t increment_timer_id();
unsigned int increment_message_number();
/** \brief Send a broadcast message to every task
\param message_p Pointer to the message to send
......@@ -158,13 +190,13 @@ public:
\param task_id Task ID of the receiving task
\param received_msg Pointer to the allocated message
**/
std::shared_ptr<itti_msg> receive_msg (task_id_t task_id);
std::shared_ptr<itti_msg> receive_msg(task_id_t task_id);
/** \brief Try to retrieves a message in the queue associated to task_id.
\param task_id Task ID of the receiving task
\param received_msg Pointer to the allocated message
**/
std::shared_ptr<itti_msg> poll_msg(task_id_t task_id);
std::shared_ptr<itti_msg> poll_msg(task_id_t task_id);
/** \brief Start thread associated to the task
* \param task_id task to start
......@@ -172,9 +204,8 @@ public:
* \param args_p Optional argument to pass to the start routine
* @returns -1 on failure, 0 otherwise
**/
int create_task (const task_id_t task_id,
void (*start_routine) (void *),
void *args_p);
int create_task(const task_id_t task_id, void (*start_routine)(void*),
void *args_p);
/** \brief Notify ITTI of a started thread
* \param task_id of started task
......@@ -188,12 +219,10 @@ public:
* \param wait_tasks non 0 to make new created tasks to wait, 0 to let created tasks to run
**/
//void wait_ready(int wait_tasks);
/** \brief Mark the task as in ready state
* \param task_id task to mark as ready
**/
//void mark_task_ready(task_id_t task_id);
/** \brief handle signals and wait for all threads to join when the process complete.
* This function should be called from the main thread after having created all ITTI tasks.
**/
......@@ -210,21 +239,18 @@ public:
* \param task_id task id of the task requesting the timer
* @returns 0 on failure, timer id otherwise
**/
timer_id_t timer_setup(
uint32_t interval_sec,
uint32_t interval_us,
task_id_t task_id,
uint64_t arg1_user = 0,
uint64_t arg2_user = 0);
timer_id_t timer_setup(uint32_t interval_sec, uint32_t interval_us,
task_id_t task_id, uint64_t arg1_user = 0,
uint64_t arg2_user = 0);
/** \brief Remove the timer from list
* \param timer_id unique timer id
* \param task_id task id of the task that requested the timer
* @returns -1 on failure, 0 otherwise
**/
int timer_remove (timer_id_t timer_id);
int timer_remove(timer_id_t timer_id);
static void signal_handler( int signum );
static void signal_handler(int signum);
};
......
......@@ -20,32 +20,45 @@
*/
/*! \file itti_msg.cpp
\brief
\author Lionel GAUTHIER
\date 2018
\email: lionel.gauthier@eurecom.fr
*/
\brief
\author Lionel GAUTHIER
\date 2018
\email: lionel.gauthier@eurecom.fr
*/
#include "itti_msg.hpp"
#include "itti.hpp"
extern itti_mw *itti_inst;
itti_msg::itti_msg() :
msg_type(ITTI_MSG_TYPE_NONE), origin(TASK_NONE), destination(TASK_NONE) {
itti_msg::itti_msg()
:
msg_type(ITTI_MSG_TYPE_NONE),
origin(TASK_NONE),
destination(TASK_NONE) {
msg_num = itti_inst->increment_message_number();
};
}
;
itti_msg::itti_msg(const itti_msg_type_t msg_type, task_id_t origin, task_id_t destination) :
msg_type(msg_type), origin(origin), destination(destination) {
itti_msg::itti_msg(const itti_msg_type_t msg_type, task_id_t origin,
task_id_t destination)
:
msg_type(msg_type),
origin(origin),
destination(destination) {
msg_num = itti_inst->increment_message_number();
};
}
;
itti_msg::itti_msg(const itti_msg& i) :
msg_type(i.msg_type),msg_num(i.msg_num), origin(i.origin), destination(i.destination) {
};
itti_msg::itti_msg(const itti_msg &i)
:
msg_type(i.msg_type),
msg_num(i.msg_num),
origin(i.origin),
destination(i.destination) {
}
;
const char* itti_msg::get_msg_name()
{
const char* itti_msg::get_msg_name() {
return "UNINITIALIZED";
}
......@@ -19,11 +19,11 @@
* contact@openairinterface.org
*/
/*! \file itti_msg.hpp
\brief
\author Lionel GAUTHIER
\date 2018
\email: lionel.gauthier@eurecom.fr
*/
\brief
\author Lionel GAUTHIER
\date 2018
\email: lionel.gauthier@eurecom.fr
*/
#ifndef SRC_ITTI_ITTI_MSG_HPP_INCLUDED_
#define SRC_ITTI_ITTI_MSG_HPP_INCLUDED_
......@@ -46,13 +46,13 @@ typedef enum {
} task_id_t;
typedef enum message_priorities_e {
MESSAGE_PRIORITY_MAX = 100,
MESSAGE_PRIORITY_MAX = 100,
MESSAGE_PRIORITY_MAX_LEAST = 85,
MESSAGE_PRIORITY_MED_PLUS = 70,
MESSAGE_PRIORITY_MED = 55,
MESSAGE_PRIORITY_MED_PLUS = 70,
MESSAGE_PRIORITY_MED = 55,
MESSAGE_PRIORITY_MED_LEAST = 40,
MESSAGE_PRIORITY_MIN_PLUS = 25,
MESSAGE_PRIORITY_MIN = 10,
MESSAGE_PRIORITY_MIN_PLUS = 25,
MESSAGE_PRIORITY_MIN = 10,
} message_priorities_t;
typedef enum {
......@@ -68,15 +68,15 @@ typedef enum {
PDU_SESSION_RESOURCE_SETUP_REQUEST,
UE_CONTEXT_RELEASE_REQUEST,
UE_RADIO_CAP_IND,
UL_NAS_DATA_IND,//task amf_n1 message id
UL_NAS_DATA_IND, //task amf_n1 message id
DOWNLINK_NAS_TRANSFER,
NAS_SIG_ESTAB_REQ,//task amf_app
NAS_SIG_ESTAB_REQ, //task amf_app
N1N2_MESSAGE_TRANSFER_REQ,
SMF_SERVICES_CONSUMER,
NSMF_PDU_SESSION_UPDATE_SM_CTX,
PDU_SESS_RES_SET_RESP,
TIME_OUT,
HEALTH_PING,
HEALTH_PING,
TERMINATE,
ITTI_MSG_TYPE_MAX
} itti_msg_type_t;
......@@ -84,13 +84,13 @@ typedef enum {
typedef unsigned long message_number_t;
class itti_msg {
public:
public:
itti_msg();
itti_msg(const itti_msg_type_t msg_type, const task_id_t origin, const task_id_t destination);
itti_msg(const itti_msg& i);
itti_msg(const itti_msg_type_t msg_type, const task_id_t origin,
const task_id_t destination);
itti_msg(const itti_msg &i);
itti_msg& operator=(itti_msg other)
{
itti_msg& operator=(itti_msg other) {
std::swap(msg_num, other.msg_num);
std::swap(origin, other.origin);
std::swap(destination, other.destination);
......@@ -102,36 +102,71 @@ public:
static const char* get_msg_name();
message_number_t msg_num;
task_id_t origin;
task_id_t destination;
itti_msg_type_t msg_type;
task_id_t origin;
task_id_t destination;
itti_msg_type_t msg_type;
};
class itti_msg_timeout : public itti_msg {
public:
itti_msg_timeout(const task_id_t origin, const task_id_t destination, uint32_t timer_id, uint64_t arg1_user, uint64_t arg2_user):
itti_msg(TIME_OUT, origin, destination), timer_id(timer_id), arg1_user(arg1_user), arg2_user(arg2_user) {}
itti_msg_timeout(const itti_msg_timeout& i) : itti_msg(i), timer_id(i.timer_id), arg1_user(i.arg1_user), arg2_user(i.arg2_user) {}
static const char* get_msg_name() {return "TIME_OUT";};
public:
itti_msg_timeout(const task_id_t origin, const task_id_t destination,
uint32_t timer_id, uint64_t arg1_user, uint64_t arg2_user)
:
itti_msg(TIME_OUT, origin, destination),
timer_id(timer_id),
arg1_user(arg1_user),
arg2_user(arg2_user) {
}
itti_msg_timeout(const itti_msg_timeout &i)
:
itti_msg(i),
timer_id(i.timer_id),
arg1_user(i.arg1_user),
arg2_user(i.arg2_user) {
}
static const char* get_msg_name() {
return "TIME_OUT";
}
;
uint32_t timer_id;
uint64_t arg1_user;
uint64_t arg2_user;
};
class itti_msg_ping : public itti_msg {
public:
itti_msg_ping(const task_id_t origin, const task_id_t destination, uint32_t seq): itti_msg(HEALTH_PING, origin, destination), seq(seq) {}
itti_msg_ping(const itti_msg_ping& i) : itti_msg(i), seq(i.seq) {}
static const char* get_msg_name() {return "HEALTH_PING";};
public:
itti_msg_ping(const task_id_t origin, const task_id_t destination,
uint32_t seq)
:
itti_msg(HEALTH_PING, origin, destination),
seq(seq) {
}
itti_msg_ping(const itti_msg_ping &i)
:
itti_msg(i),
seq(i.seq) {
}
static const char* get_msg_name() {
return "HEALTH_PING";
}
;
uint32_t seq;
};
class itti_msg_terminate : public itti_msg {
public:
itti_msg_terminate(const task_id_t origin, const task_id_t destination):
itti_msg(TERMINATE, origin, destination) {}
itti_msg_terminate(const itti_msg_terminate& i) : itti_msg(i) {}
static const char* get_msg_name() {return "TERMINATE";};
public:
itti_msg_terminate(const task_id_t origin, const task_id_t destination)
:
itti_msg(TERMINATE, origin, destination) {
}
itti_msg_terminate(const itti_msg_terminate &i)
:
itti_msg(i) {
}
static const char* get_msg_name() {
return "TERMINATE";
}
;
};
#endif /* SRC_ITTI_ITTI_MSG_HPP_INCLUDED_ */
......@@ -7,37 +7,59 @@
using namespace ngap;
#include "bstrlib.h"
class itti_msg_amf_app : public itti_msg{
public:
itti_msg_amf_app(const itti_msg_type_t msg_type, const task_id_t origin, const task_id_t destination):itti_msg(msg_type,origin,destination){}
itti_msg_amf_app(const itti_msg_amf_app& i) : itti_msg(i){
class itti_msg_amf_app : public itti_msg {
public:
itti_msg_amf_app(const itti_msg_type_t msg_type, const task_id_t origin,
const task_id_t destination)
:
itti_msg(msg_type, origin, destination) {
}
itti_msg_amf_app(const itti_msg_amf_app &i)
:
itti_msg(i) {
ran_ue_ngap_id = i.ran_ue_ngap_id;
amf_ue_ngap_id = i.amf_ue_ngap_id;
}
uint32_t ran_ue_ngap_id;
long amf_ue_ngap_id;
long amf_ue_ngap_id;
};
class itti_nas_signalling_establishment_request : public itti_msg_amf_app{
public:
itti_nas_signalling_establishment_request(const task_id_t origin, const task_id_t destination):itti_msg_amf_app(NAS_SIG_ESTAB_REQ, origin, destination){}
itti_nas_signalling_establishment_request(const itti_nas_signalling_establishment_request & i) : itti_msg_amf_app(i){}
class itti_nas_signalling_establishment_request : public itti_msg_amf_app {
public:
itti_nas_signalling_establishment_request(const task_id_t origin,
const task_id_t destination)
:
itti_msg_amf_app(NAS_SIG_ESTAB_REQ, origin, destination) {
}
itti_nas_signalling_establishment_request(
const itti_nas_signalling_establishment_request &i)
:
itti_msg_amf_app(i) {
}
int rrc_cause;
int ueCtxReq;
NrCgi_t cgi;
Tai_t tai;
Tai_t tai;
bstring nas_buf;
bool is_5g_s_tmsi_present;
std::string _5g_s_tmsi;
};
class itti_n1n2_message_transfer_request : public itti_msg_amf_app{
public:
itti_n1n2_message_transfer_request(const task_id_t origin, const task_id_t destination) : itti_msg_amf_app(N1N2_MESSAGE_TRANSFER_REQ, origin, destination){}
itti_n1n2_message_transfer_request(const itti_n1n2_message_transfer_request & i) : itti_msg_amf_app(i){}
class itti_n1n2_message_transfer_request : public itti_msg_amf_app {
public:
itti_n1n2_message_transfer_request(const task_id_t origin,
const task_id_t destination)
:
itti_msg_amf_app(N1N2_MESSAGE_TRANSFER_REQ, origin, destination) {
}
itti_n1n2_message_transfer_request(
const itti_n1n2_message_transfer_request &i)
:
itti_msg_amf_app(i) {
}
std::string supi;
bstring n1sm;
bstring n2sm;
......@@ -48,9 +70,4 @@ public:
};
#endif
......@@ -4,27 +4,38 @@
#include "bstrlib.h"
#include "itti_msg.hpp"
class itti_msg_n1 : public itti_msg{
public:
itti_msg_n1(const itti_msg_type_t msg_type, const task_id_t origin, const task_id_t destination):itti_msg(msg_type,origin,destination){
class itti_msg_n1 : public itti_msg {
public:
itti_msg_n1(const itti_msg_type_t msg_type, const task_id_t origin,
const task_id_t destination)
:
itti_msg(msg_type, origin, destination) {
}
itti_msg_n1(const itti_msg_n1& i) : itti_msg(i){
is_nas_signalling_estab_req =i.is_nas_signalling_estab_req;
itti_msg_n1(const itti_msg_n1 &i)
:
itti_msg(i) {
is_nas_signalling_estab_req = i.is_nas_signalling_estab_req;
ran_ue_ngap_id = i.ran_ue_ngap_id;
}
public:
public:
bool is_nas_signalling_estab_req;
long amf_ue_ngap_id;
uint32_t ran_ue_ngap_id;
};
class itti_uplink_nas_data_ind : public itti_msg_n1{
public:
itti_uplink_nas_data_ind(const task_id_t origin, const task_id_t destination):itti_msg_n1(UL_NAS_DATA_IND,origin,destination){}
itti_uplink_nas_data_ind(const itti_uplink_nas_data_ind &i) : itti_msg_n1(i){}
class itti_uplink_nas_data_ind : public itti_msg_n1 {
public:
itti_uplink_nas_data_ind(const task_id_t origin, const task_id_t destination)
:
itti_msg_n1(UL_NAS_DATA_IND, origin, destination) {
}
itti_uplink_nas_data_ind(const itti_uplink_nas_data_ind &i)
:
itti_msg_n1(i) {
}
public:
public:
bstring nas_msg;
std::string mcc;
std::string mnc;
......@@ -32,27 +43,22 @@ public:
std::string guti;
};
class itti_downlink_nas_transfer : public itti_msg_n1{
public:
itti_downlink_nas_transfer(const task_id_t origin, const task_id_t destination) : itti_msg_n1(DOWNLINK_NAS_TRANSFER, origin,destination){}
itti_downlink_nas_transfer(const itti_downlink_nas_transfer &i) : itti_msg_n1(i){}
public:
class itti_downlink_nas_transfer : public itti_msg_n1 {
public:
itti_downlink_nas_transfer(const task_id_t origin,
const task_id_t destination)
:
itti_msg_n1(DOWNLINK_NAS_TRANSFER, origin, destination) {
}
itti_downlink_nas_transfer(const itti_downlink_nas_transfer &i)
:
itti_msg_n1(i) {
}
public:
bstring dl_nas;
bstring n2sm;
bool is_n2sm_set;
bool is_n2sm_set;
uint8_t pdu_session_id;
};
#endif
......@@ -6,49 +6,76 @@
#include <string>
#include "amf.hpp"
class itti_msg_n11 : public itti_msg{
public:
itti_msg_n11(const itti_msg_type_t msg_type, const task_id_t origin, const task_id_t destination):itti_msg(msg_type,origin,destination){}
itti_msg_n11(const itti_msg_n11& i) : itti_msg(i){
class itti_msg_n11 : public itti_msg {
public:
itti_msg_n11(const itti_msg_type_t msg_type, const task_id_t origin,
const task_id_t destination)
:
itti_msg(msg_type, origin, destination) {
}
itti_msg_n11(const itti_msg_n11 &i)
:
itti_msg(i) {
ran_ue_ngap_id = i.ran_ue_ngap_id;
amf_ue_ngap_id = i.amf_ue_ngap_id;
}
public:
public:
long amf_ue_ngap_id;
uint32_t ran_ue_ngap_id;
};
class itti_smf_services_consumer : public itti_msg_n11{
public:
itti_smf_services_consumer(const task_id_t origin, const task_id_t destination):itti_msg_n11(SMF_SERVICES_CONSUMER, origin, destination){
class itti_smf_services_consumer : public itti_msg_n11 {
public:
itti_smf_services_consumer(const task_id_t origin,
const task_id_t destination)
:
itti_msg_n11(SMF_SERVICES_CONSUMER, origin, destination) {
}
itti_smf_services_consumer(const itti_smf_services_consumer& i) : itti_msg_n11(i){
itti_smf_services_consumer(const itti_smf_services_consumer &i)
:
itti_msg_n11(i) {
}
public:
public:
uint8_t req_type;
uint8_t pdu_sess_id;
uint8_t pdu_sess_id;
bstring dnn;
bstring sm_msg;
snssai_t snssai;
plmn_t plmn;
};
class itti_pdu_session_resource_setup_response : public itti_msg_n11{
public:
itti_pdu_session_resource_setup_response(const task_id_t origin, const task_id_t destination) : itti_msg_n11(PDU_SESS_RES_SET_RESP, origin, destination){}
itti_pdu_session_resource_setup_response(const itti_pdu_session_resource_setup_response &i) : itti_msg_n11(i){}
public:
class itti_pdu_session_resource_setup_response : public itti_msg_n11 {
public:
itti_pdu_session_resource_setup_response(const task_id_t origin,
const task_id_t destination)
:
itti_msg_n11(PDU_SESS_RES_SET_RESP, origin, destination) {
}
itti_pdu_session_resource_setup_response(
const itti_pdu_session_resource_setup_response &i)
:
itti_msg_n11(i) {
}
public:
uint8_t pdu_session_id;
bstring n2sm;
};
class itti_nsmf_pdusession_update_sm_context : public itti_msg_n11{
public:
itti_nsmf_pdusession_update_sm_context(const task_id_t origin, const task_id_t destination) : itti_msg_n11(NSMF_PDU_SESSION_UPDATE_SM_CTX, origin, destination){}
itti_nsmf_pdusession_update_sm_context(const itti_nsmf_pdusession_update_sm_context &i) : itti_msg_n11(i){}
public:
class itti_nsmf_pdusession_update_sm_context : public itti_msg_n11 {
public:
itti_nsmf_pdusession_update_sm_context(const task_id_t origin,
const task_id_t destination)
:
itti_msg_n11(NSMF_PDU_SESSION_UPDATE_SM_CTX, origin, destination) {
}
itti_nsmf_pdusession_update_sm_context(
const itti_nsmf_pdusession_update_sm_context &i)
:
itti_msg_n11(i) {
}
public:
uint8_t pdu_session_id;
bstring n2sm;
};
......
#ifndef _ITTI_MSG_N2_H_
#define _ITTI_MSG_N2_H_
#include "itti_msg.hpp"
#include "NGSetupRequest.hpp"
#include "InitialUEMessage.hpp"
......@@ -13,11 +12,16 @@
using namespace ngap;
using namespace sctp;
class itti_msg_n2 : public itti_msg{
public:
itti_msg_n2(const itti_msg_type_t msg_type, const task_id_t origin, const task_id_t destination):itti_msg(msg_type,origin,destination){
class itti_msg_n2 : public itti_msg {
public:
itti_msg_n2(const itti_msg_type_t msg_type, const task_id_t origin,
const task_id_t destination)
:
itti_msg(msg_type, origin, destination) {
}
itti_msg_n2(const itti_msg_n2& i) : itti_msg(i){
itti_msg_n2(const itti_msg_n2 &i)
:
itti_msg(i) {
assoc_id = i.assoc_id;
stream = i.stream;
}
......@@ -25,84 +29,139 @@ public:
sctp_stream_id_t stream;
};
class itti_new_sctp_association : public itti_msg_n2{
public:
itti_new_sctp_association(const task_id_t origin, const task_id_t destination) : itti_msg_n2(NEW_SCTP_ASSOCIATION, origin, destination){}
class itti_new_sctp_association : public itti_msg_n2 {
public:
itti_new_sctp_association(const task_id_t origin, const task_id_t destination)
:
itti_msg_n2(NEW_SCTP_ASSOCIATION, origin, destination) {
}
};
class itti_ng_setup_request : public itti_msg_n2{
public:
itti_ng_setup_request(const task_id_t origin, const task_id_t destination):itti_msg_n2(NG_SETUP_REQ,origin,destination){}
itti_ng_setup_request(const itti_ng_setup_request &i) : itti_msg_n2(i){
class itti_ng_setup_request : public itti_msg_n2 {
public:
itti_ng_setup_request(const task_id_t origin, const task_id_t destination)
:
itti_msg_n2(NG_SETUP_REQ, origin, destination) {
}
itti_ng_setup_request(const itti_ng_setup_request &i)
:
itti_msg_n2(i) {
}
public:
NGSetupRequestMsg * ngSetupReq;
public:
NGSetupRequestMsg *ngSetupReq;
};
class itti_initial_ue_message : public itti_msg_n2{
public:
itti_initial_ue_message(const task_id_t origin, const task_id_t destination):itti_msg_n2(INITIAL_UE_MSG,origin,destination){}
itti_initial_ue_message(const itti_initial_ue_message &i) : itti_msg_n2(i){}
class itti_initial_ue_message : public itti_msg_n2 {
public:
itti_initial_ue_message(const task_id_t origin, const task_id_t destination)
:
itti_msg_n2(INITIAL_UE_MSG, origin, destination) {
}
itti_initial_ue_message(const itti_initial_ue_message &i)
:
itti_msg_n2(i) {
}
InitialUEMessageMsg * initUeMsg;
InitialUEMessageMsg *initUeMsg;
};
class itti_ul_nas_transport : public itti_msg_n2{
public:
itti_ul_nas_transport(const task_id_t origin, const task_id_t destination):itti_msg_n2(ITTI_UL_NAS_TRANSPORT,origin,destination){}
itti_ul_nas_transport(const itti_ul_nas_transport &i) : itti_msg_n2(i){}
class itti_ul_nas_transport : public itti_msg_n2 {
public:
itti_ul_nas_transport(const task_id_t origin, const task_id_t destination)
:
itti_msg_n2(ITTI_UL_NAS_TRANSPORT, origin, destination) {
}
itti_ul_nas_transport(const itti_ul_nas_transport &i)
:
itti_msg_n2(i) {
}
UplinkNASTransportMsg *ulNas;
};
class itti_dl_nas_transport : public itti_msg_n2{
public:
itti_dl_nas_transport(const task_id_t origin, const task_id_t destination):itti_msg_n2(ITTI_DL_NAS_TRANSPORT,origin,destination){}
itti_dl_nas_transport(const itti_dl_nas_transport &i) : itti_msg_n2(i){}
public:
class itti_dl_nas_transport : public itti_msg_n2 {
public:
itti_dl_nas_transport(const task_id_t origin, const task_id_t destination)
:
itti_msg_n2(ITTI_DL_NAS_TRANSPORT, origin, destination) {
}
itti_dl_nas_transport(const itti_dl_nas_transport &i)
:
itti_msg_n2(i) {
}
public:
uint32_t ran_ue_ngap_id;
long amf_ue_ngap_id;
bstring nas;
long amf_ue_ngap_id;
bstring nas;
};
class itti_initial_context_setup_request : public itti_msg_n2{
public:
itti_initial_context_setup_request(const task_id_t origin, const task_id_t destination):itti_msg_n2(INITIAL_CONTEXT_SETUP_REQUEST,origin,destination){}
itti_initial_context_setup_request(const itti_initial_context_setup_request &i):itti_msg_n2(i){}
class itti_initial_context_setup_request : public itti_msg_n2 {
public:
itti_initial_context_setup_request(const task_id_t origin,
const task_id_t destination)
:
itti_msg_n2(INITIAL_CONTEXT_SETUP_REQUEST, origin, destination) {
}
itti_initial_context_setup_request(
const itti_initial_context_setup_request &i)
:
itti_msg_n2(i) {
}
uint32_t ran_ue_ngap_id;
long amf_ue_ngap_id;
bstring kgnb;
bstring nas;
bool is_sr;
bstring n2sm;
long amf_ue_ngap_id;
bstring kgnb;
bstring nas;
bool is_sr;
bstring n2sm;
uint8_t pdu_session_id;
};
class itti_pdu_session_resource_setup_request : public itti_msg_n2{
public:
itti_pdu_session_resource_setup_request(const task_id_t origin, const task_id_t destination) : itti_msg_n2(PDU_SESSION_RESOURCE_SETUP_REQUEST,origin,destination){}
itti_pdu_session_resource_setup_request(const itti_pdu_session_resource_setup_request &i) : itti_msg_n2(i){}
class itti_pdu_session_resource_setup_request : public itti_msg_n2 {
public:
itti_pdu_session_resource_setup_request(const task_id_t origin,
const task_id_t destination)
:
itti_msg_n2(PDU_SESSION_RESOURCE_SETUP_REQUEST, origin, destination) {
}
itti_pdu_session_resource_setup_request(
const itti_pdu_session_resource_setup_request &i)
:
itti_msg_n2(i) {
}
bstring nas;
bstring n2sm;
uint32_t ran_ue_ngap_id;
long amf_ue_ngap_id;
long amf_ue_ngap_id;
uint8_t pdu_session_id;
};
class itti_ue_context_release_request : public itti_msg_n2{
public:
itti_ue_context_release_request(const task_id_t origin, const task_id_t destination) : itti_msg_n2(UE_CONTEXT_RELEASE_REQUEST, origin,destination){}
itti_ue_context_release_request(const itti_ue_context_release_request &i) : itti_msg_n2(i){}
UEContextReleaseRequestMsg * ueCtxRel;
class itti_ue_context_release_request : public itti_msg_n2 {
public:
itti_ue_context_release_request(const task_id_t origin,
const task_id_t destination)
:
itti_msg_n2(UE_CONTEXT_RELEASE_REQUEST, origin, destination) {
}
itti_ue_context_release_request(const itti_ue_context_release_request &i)
:
itti_msg_n2(i) {
}
UEContextReleaseRequestMsg *ueCtxRel;
};
class itti_ue_radio_capability_indication : public itti_msg_n2{
public:
itti_ue_radio_capability_indication(const task_id_t origin, const task_id_t destination) : itti_msg_n2(UE_RADIO_CAP_IND, origin, destination){}
itti_ue_radio_capability_indication(const itti_ue_radio_capability_indication &i) : itti_msg_n2(i){}
UeRadioCapabilityInfoIndicationMsg * ueRadioCap;
class itti_ue_radio_capability_indication : public itti_msg_n2 {
public:
itti_ue_radio_capability_indication(const task_id_t origin,
const task_id_t destination)
:
itti_msg_n2(UE_RADIO_CAP_IND, origin, destination) {
}
itti_ue_radio_capability_indication(
const itti_ue_radio_capability_indication &i)
:
itti_msg_n2(i) {
}
UeRadioCapabilityInfoIndicationMsg *ueRadioCap;
};
#endif
......@@ -46,7 +46,8 @@ AuthenticationFailure::~AuthenticationFailure() {
//------------------------------------------------------------------------------
void AuthenticationFailure::setHeader(uint8_t security_header_type) {
plain_header = new NasMmPlainHeader();
plain_header->setHeader(EPD_5GS_MM_MSG, security_header_type, AUTHENTICATION_FAILURE);
plain_header->setHeader(EPD_5GS_MM_MSG, security_header_type,
AUTHENTICATION_FAILURE);
}
//------------------------------------------------------------------------------
......@@ -65,7 +66,8 @@ uint8_t AuthenticationFailure::get5GMmCause() {
//------------------------------------------------------------------------------
void AuthenticationFailure::setAuthentication_Failure_Parameter(bstring auts) {
ie_authentication_failure_parameter = new Authentication_Failure_Parameter(0x30, auts);
ie_authentication_failure_parameter = new Authentication_Failure_Parameter(
0x30, auts);
}
bool AuthenticationFailure::getAutsInAuthFailPara(bstring &auts) {
if (ie_authentication_failure_parameter) {
......@@ -90,34 +92,41 @@ int AuthenticationFailure::encode2buffer(uint8_t *buf, int len) {
if (!ie_5gmm_cause) {
Logger::nas_mm().warn("IE ie_5gmm_cause is not available");
} else {
if (int size = ie_5gmm_cause->encode2buffer(buf + encoded_size, len - encoded_size)) {
if (int size = ie_5gmm_cause->encode2buffer(buf + encoded_size,
len - encoded_size)) {
encoded_size += size;
} else {
Logger::nas_mm().error("Encoding ie_5gmm_cause error");
}
}
if (!ie_authentication_failure_parameter) {
Logger::nas_mm().warn("IE ie_authentication_failure_parameter is not available");
Logger::nas_mm().warn(
"IE ie_authentication_failure_parameter is not available");
} else {
if (int size = ie_authentication_failure_parameter->encode2buffer(buf + encoded_size, len - encoded_size)) {
if (int size = ie_authentication_failure_parameter->encode2buffer(
buf + encoded_size, len - encoded_size)) {
encoded_size += size;
} else {
Logger::nas_mm().error("Encoding ie_authentication_failure_parameter error");
Logger::nas_mm().error(
"Encoding ie_authentication_failure_parameter error");
return 0;
}
}
Logger::nas_mm().debug("Encoded AuthenticationFailure message len (%d)", encoded_size);
Logger::nas_mm().debug("Encoded AuthenticationFailure message len (%d)",
encoded_size);
return 1;
}
//------------------------------------------------------------------------------
int AuthenticationFailure::decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf, int len) {
int AuthenticationFailure::decodefrombuffer(NasMmPlainHeader *header,
uint8_t *buf, int len) {
Logger::nas_mm().debug("Decoding AuthenticationFailure message");
int decoded_size = 3;
plain_header = header;
ie_5gmm_cause = new _5GMM_Cause();
decoded_size += ie_5gmm_cause->decodefrombuffer(buf + decoded_size, len - decoded_size, false);
decoded_size += ie_5gmm_cause->decodefrombuffer(buf + decoded_size,
len - decoded_size, false);
Logger::nas_mm().debug("Decoded_size (%d)", decoded_size);
uint8_t octet = *(buf + decoded_size);
Logger::nas_mm().debug("First option IEI (0x%x)", octet);
......@@ -125,15 +134,18 @@ int AuthenticationFailure::decodefrombuffer(NasMmPlainHeader *header, uint8_t *b
switch (octet) {
case 0x30: {
Logger::nas_mm().debug("Decoding IEI (0x30)");
ie_authentication_failure_parameter = new Authentication_Failure_Parameter();
decoded_size += ie_authentication_failure_parameter->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
ie_authentication_failure_parameter =
new Authentication_Failure_Parameter();
decoded_size += ie_authentication_failure_parameter->decodefrombuffer(
buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("Next IEI (0x%x)", octet);
}
break;
}
}
Logger::nas_mm().debug("Decoded AuthenticationFailure message len (%d)", decoded_size);
Logger::nas_mm().debug("Decoded AuthenticationFailure message len (%d)",
decoded_size);
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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