Commit 247cfd26 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Merge branch 'develop' into 'session_release'

# Conflicts:
#   src/amf-app/amf_n1.cpp
#   src/amf-app/amf_n1.hpp
#   src/amf-app/amf_n11.cpp
#   src/amf-app/amf_statistics.cpp
parents 058c666e 54f38bb0
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>
......
......@@ -31,15 +31,8 @@
#include <map>
#include <shared_mutex>
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <error.h>
#include <inttypes.h>
#include <mysql/mysql.h>
#include "nas_context.hpp"
......
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"
//------------------------------------------------------------------------------
......
......@@ -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);
}
......@@ -45,7 +45,8 @@ AuthenticationReject::~AuthenticationReject() {
//------------------------------------------------------------------------------
void AuthenticationReject::setHeader(uint8_t security_header_type) {
plain_header = new NasMmPlainHeader();
plain_header->setHeader(EPD_5GS_MM_MSG, security_header_type, AUTHENTICATION_REJECT);
plain_header->setHeader(EPD_5GS_MM_MSG, security_header_type,
AUTHENTICATION_REJECT);
}
//------------------------------------------------------------------------------
......@@ -67,19 +68,22 @@ int AuthenticationReject::encode2buffer(uint8_t *buf, int len) {
if (!ie_eap_message) {
Logger::nas_mm().warn("IE ie_eap_message is not available");
} else {
if (int size = ie_eap_message->encode2buffer(buf + encoded_size, len - encoded_size)) {
if (int size = ie_eap_message->encode2buffer(buf + encoded_size,
len - encoded_size)) {
encoded_size += size;
} else {
Logger::nas_mm().error("Encoding ie_eap_message error");
return 0;
}
}
Logger::nas_mm().debug("Encoded AuthenticationReject message len (%d)", encoded_size);
Logger::nas_mm().debug("Encoded AuthenticationReject message len (%d)",
encoded_size);
return 1;
}
//------------------------------------------------------------------------------
int AuthenticationReject::decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf, int len) {
int AuthenticationReject::decodefrombuffer(NasMmPlainHeader *header,
uint8_t *buf, int len) {
Logger::nas_mm().debug("Decoding AuthenticationReject message");
int decoded_size = 3;
plain_header = header;
......@@ -91,14 +95,17 @@ int AuthenticationReject::decodefrombuffer(NasMmPlainHeader *header, uint8_t *bu
case 0x78: {
Logger::nas_mm().debug("Decoding IEI (0x78)");
ie_eap_message = new EAP_Message();
decoded_size += ie_eap_message->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
decoded_size += ie_eap_message->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 AuthenticationReject message len (%d)", decoded_size);
Logger::nas_mm().debug("Decoded AuthenticationReject message len (%d)",
decoded_size);
}
......@@ -49,7 +49,8 @@ AuthenticationRequest::~AuthenticationRequest() {
//------------------------------------------------------------------------------
void AuthenticationRequest::setHeader(uint8_t security_header_type) {
plain_header = new NasMmPlainHeader();
plain_header->setHeader(EPD_5GS_MM_MSG, security_header_type, AUTHENTICATION_REQUEST);
plain_header->setHeader(EPD_5GS_MM_MSG, security_header_type,
AUTHENTICATION_REQUEST);
}
//------------------------------------------------------------------------------
......@@ -64,12 +65,14 @@ void AuthenticationRequest::setABBA(uint8_t length, uint8_t *value) {
//------------------------------------------------------------------------------
void AuthenticationRequest::setAuthentication_Parameter_RAND(uint8_t *value) {
ie_authentication_parameter_rand = new Authentication_Parameter_RAND(0x21, value);
ie_authentication_parameter_rand = new Authentication_Parameter_RAND(0x21,
value);
}
//------------------------------------------------------------------------------
void AuthenticationRequest::setAuthentication_Parameter_AUTN(uint8_t *value) {
ie_authentication_parameter_autn = new Authentication_Parameter_AUTN(0x20, value);
ie_authentication_parameter_autn = new Authentication_Parameter_AUTN(0x20,
value);
}
//------------------------------------------------------------------------------
......@@ -104,7 +107,8 @@ int AuthenticationRequest::encode2buffer(uint8_t *buf, int len) {
} else {
int size = ie_abba->encode2buffer(buf + encoded_size, len - encoded_size);
if (size != 0) {
Logger::nas_mm().debug("0x%x, 0x%x, 0x%x", (buf + encoded_size)[0], (buf + encoded_size)[1], (buf + encoded_size)[2]);
Logger::nas_mm().debug("0x%x, 0x%x, 0x%x", (buf + encoded_size)[0],
(buf + encoded_size)[1], (buf + encoded_size)[2]);
encoded_size += size;
} else {
Logger::nas_mm().error("Encoding ie_abba error");
......@@ -112,9 +116,11 @@ int AuthenticationRequest::encode2buffer(uint8_t *buf, int len) {
}
}
if (!ie_authentication_parameter_rand) {
Logger::nas_mm().warn("IE ie_authentication_parameter_rand is not available");
Logger::nas_mm().warn(
"IE ie_authentication_parameter_rand is not available");
} else {
int size = ie_authentication_parameter_rand->encode2buffer(buf + encoded_size, len - encoded_size);
int size = ie_authentication_parameter_rand->encode2buffer(
buf + encoded_size, len - encoded_size);
if (size != 0) {
encoded_size += size;
} else {
......@@ -123,9 +129,11 @@ int AuthenticationRequest::encode2buffer(uint8_t *buf, int len) {
}
}
if (!ie_authentication_parameter_autn) {
Logger::nas_mm().warn("IE ie_authentication_parameter_autn is not available");
Logger::nas_mm().warn(
"IE ie_authentication_parameter_autn is not available");
} else {
int size = ie_authentication_parameter_autn->encode2buffer(buf + encoded_size, len - encoded_size);
int size = ie_authentication_parameter_autn->encode2buffer(
buf + encoded_size, len - encoded_size);
if (size != 0) {
encoded_size += size;
} else {
......@@ -136,7 +144,8 @@ int AuthenticationRequest::encode2buffer(uint8_t *buf, int len) {
if (!ie_eap_message) {
Logger::nas_mm().warn("IE ie_eap_message is not available");
} else {
int size = ie_eap_message->encode2buffer(buf + encoded_size, len - encoded_size);
int size = ie_eap_message->encode2buffer(buf + encoded_size,
len - encoded_size);
if (size != 0) {
encoded_size += size;
} else {
......@@ -145,20 +154,24 @@ int AuthenticationRequest::encode2buffer(uint8_t *buf, int len) {
}
}
Logger::nas_mm().debug("Encoded AuthenticationRequest message (len %d)", encoded_size);
Logger::nas_mm().debug("Encoded AuthenticationRequest message (len %d)",
encoded_size);
return encoded_size;
}
//------------------------------------------------------------------------------
int AuthenticationRequest::decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf, int len) {
int AuthenticationRequest::decodefrombuffer(NasMmPlainHeader *header,
uint8_t *buf, int len) {
Logger::nas_mm().debug("Decoding RegistrationReject message");
int decoded_size = 3;
plain_header = header;
ie_ngKSI = new NasKeySetIdentifier();
decoded_size += ie_ngKSI->decodefrombuffer(buf + decoded_size, len - decoded_size, false, false);
decoded_size += ie_ngKSI->decodefrombuffer(buf + decoded_size,
len - decoded_size, false, false);
decoded_size++;
ie_abba = new ABBA();
decoded_size += ie_abba->decodefrombuffer(buf + decoded_size, len - decoded_size, false);
decoded_size += ie_abba->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);
......@@ -167,14 +180,16 @@ int AuthenticationRequest::decodefrombuffer(NasMmPlainHeader *header, uint8_t *b
case 0x21: {
Logger::nas_mm().debug("Decoding IEI(0x21)");
ie_authentication_parameter_rand = new Authentication_Parameter_RAND();
decoded_size += ie_authentication_parameter_rand->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
decoded_size += ie_authentication_parameter_rand->decodefrombuffer(
buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("Next IEI 0x%x", octet);
}
break;
case 0x20: {
ie_authentication_parameter_autn = new Authentication_Parameter_AUTN();
decoded_size += ie_authentication_parameter_autn->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
decoded_size += ie_authentication_parameter_autn->decodefrombuffer(
buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("Next IEI 0x%x", octet);
}
......@@ -182,14 +197,17 @@ int AuthenticationRequest::decodefrombuffer(NasMmPlainHeader *header, uint8_t *b
case 0x78: {
Logger::nas_mm().debug("Decoding IEI 0x78");
ie_eap_message = new EAP_Message();
decoded_size += ie_eap_message->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
decoded_size += ie_eap_message->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 AuthenticationRequest message (len %d)", decoded_size);
Logger::nas_mm().debug("Decoded AuthenticationRequest message (len %d)",
decoded_size);
}
......@@ -46,12 +46,15 @@ AuthenticationResponse::~AuthenticationResponse() {
//------------------------------------------------------------------------------
void AuthenticationResponse::setHeader(uint8_t security_header_type) {
plain_header = new NasMmPlainHeader();
plain_header->setHeader(EPD_5GS_MM_MSG, security_header_type, AUTHENTICATION_RESPONSE);
plain_header->setHeader(EPD_5GS_MM_MSG, security_header_type,
AUTHENTICATION_RESPONSE);
}
//------------------------------------------------------------------------------
void AuthenticationResponse::setAuthentication_Response_Parameter(bstring para) {
ie_authentication_response_parameter = new Authentication_Response_Parameter(0x2D, para);
void AuthenticationResponse::setAuthentication_Response_Parameter(
bstring para) {
ie_authentication_response_parameter = new Authentication_Response_Parameter(
0x2D, para);
}
//------------------------------------------------------------------------------
......@@ -91,31 +94,37 @@ int AuthenticationResponse::encode2buffer(uint8_t *buf, int len) {
return 0;
encoded_size += 3;
if (!ie_authentication_response_parameter) {
Logger::nas_mm().warn("IE ie_authentication_response_parameter is not available");
Logger::nas_mm().warn(
"IE ie_authentication_response_parameter is not available");
} else {
if (int size = ie_authentication_response_parameter->encode2buffer(buf + encoded_size, len - encoded_size)) {
if (int size = ie_authentication_response_parameter->encode2buffer(
buf + encoded_size, len - encoded_size)) {
encoded_size += size;
} else {
Logger::nas_mm().error("Encoding ie_authentication_response_parameter error");
Logger::nas_mm().error(
"Encoding ie_authentication_response_parameter error");
return 0;
}
}
if (!ie_eap_message) {
Logger::nas_mm().warn("IE ie_eap_message is not available");
} else {
if (int size = ie_eap_message->encode2buffer(buf + encoded_size, len - encoded_size)) {
if (int size = ie_eap_message->encode2buffer(buf + encoded_size,
len - encoded_size)) {
encoded_size += size;
} else {
Logger::nas_mm().error("Encoding ie_eap_message error");
return 0;
}
}
Logger::nas_mm().debug("Encoded AuthenticationResponse message len (%d)", encoded_size);
Logger::nas_mm().debug("Encoded AuthenticationResponse message len (%d)",
encoded_size);
return 1;
}
//------------------------------------------------------------------------------
int AuthenticationResponse::decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf, int len) {
int AuthenticationResponse::decodefrombuffer(NasMmPlainHeader *header,
uint8_t *buf, int len) {
Logger::nas_mm().debug("Decoding AuthenticationResponse message");
int decoded_size = 3;
plain_header = header;
......@@ -126,8 +135,10 @@ int AuthenticationResponse::decodefrombuffer(NasMmPlainHeader *header, uint8_t *
switch (octet) {
case 0x2D: {
Logger::nas_mm().debug("Decoding IEI (0x2D)");
ie_authentication_response_parameter = new Authentication_Response_Parameter();
decoded_size += ie_authentication_response_parameter->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
ie_authentication_response_parameter =
new Authentication_Response_Parameter();
decoded_size += ie_authentication_response_parameter->decodefrombuffer(
buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("Next IEI (0x%x)", octet);
}
......@@ -135,14 +146,17 @@ int AuthenticationResponse::decodefrombuffer(NasMmPlainHeader *header, uint8_t *
case 0x78: {
Logger::nas_mm().debug("Decoding IEI (0x78)");
ie_eap_message = new EAP_Message();
decoded_size += ie_eap_message->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
decoded_size += ie_eap_message->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 AuthenticationResponse message len (%d)", decoded_size);
Logger::nas_mm().debug("Decoded AuthenticationResponse message len (%d)",
decoded_size);
}
......@@ -47,7 +47,8 @@ AuthenticationResult::~AuthenticationResult() {
//------------------------------------------------------------------------------
void AuthenticationResult::setHeader(uint8_t security_header_type) {
plain_header = new NasMmPlainHeader();
plain_header->setHeader(EPD_5GS_MM_MSG, security_header_type, AUTHENTICATION_RESULT);
plain_header->setHeader(EPD_5GS_MM_MSG, security_header_type,
AUTHENTICATION_RESULT);
}
//------------------------------------------------------------------------------
......@@ -79,7 +80,8 @@ int AuthenticationResult::encode2buffer(uint8_t *buf, int len) {
if (!ie_ngKSI) {
Logger::nas_mm().warn("IE ie_ngKSI is not available");
} else {
if (int size = ie_ngKSI->encode2buffer(buf + encoded_size, len - encoded_size)) {
if (int size = ie_ngKSI->encode2buffer(buf + encoded_size,
len - encoded_size)) {
encoded_size += size;
} else {
Logger::nas_mm().error("Encoding ie_ngKSI error");
......@@ -89,7 +91,8 @@ int AuthenticationResult::encode2buffer(uint8_t *buf, int len) {
if (!ie_eap_message) {
Logger::nas_mm().warn("IE ie_eap_message is not available");
} else {
if (int size = ie_eap_message->encode2buffer(buf + encoded_size, len - encoded_size)) {
if (int size = ie_eap_message->encode2buffer(buf + encoded_size,
len - encoded_size)) {
encoded_size += size;
} else {
Logger::nas_mm().error("Encoding ie_eap_message error");
......@@ -99,27 +102,32 @@ int AuthenticationResult::encode2buffer(uint8_t *buf, int len) {
if (!ie_abba) {
Logger::nas_mm().warn("IE ie_abba is not available");
} else {
if (int size = ie_abba->encode2buffer(buf + encoded_size, len - encoded_size)) {
if (int size = ie_abba->encode2buffer(buf + encoded_size,
len - encoded_size)) {
encoded_size += size;
} else {
Logger::nas_mm().error("encoding ie_abba error");
return 0;
}
}
Logger::nas_mm().debug("Encoded AuthenticationResult message len (%d)", encoded_size);
Logger::nas_mm().debug("Encoded AuthenticationResult message len (%d)",
encoded_size);
return 1;
}
//------------------------------------------------------------------------------
int AuthenticationResult::decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf, int len) {
int AuthenticationResult::decodefrombuffer(NasMmPlainHeader *header,
uint8_t *buf, int len) {
Logger::nas_mm().debug("Decoding AuthenticationResult message");
int decoded_size = 3;
plain_header = header;
ie_ngKSI = new NasKeySetIdentifier();
decoded_size += ie_ngKSI->decodefrombuffer(buf + decoded_size, len - decoded_size, false, false);
decoded_size += ie_ngKSI->decodefrombuffer(buf + decoded_size,
len - decoded_size, false, false);
decoded_size++;
ie_eap_message = new EAP_Message();
decoded_size += ie_eap_message->decodefrombuffer(buf + decoded_size, len - decoded_size, false);
decoded_size += ie_eap_message->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);
......@@ -128,14 +136,16 @@ int AuthenticationResult::decodefrombuffer(NasMmPlainHeader *header, uint8_t *bu
case 0x38: {
Logger::nas_mm().debug("Decoding IEI (0x38)");
ie_abba = new ABBA();
decoded_size += ie_abba->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
decoded_size += ie_abba->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 AuthenticationResult message len (%d)", decoded_size);
Logger::nas_mm().debug("Decoded AuthenticationResult message len (%d)",
decoded_size);
}
......@@ -51,7 +51,8 @@ DLNASTransport::~DLNASTransport() {
//------------------------------------------------------------------------------
void DLNASTransport::setHeader(uint8_t security_header_type) {
plain_header = new NasMmPlainHeader();
plain_header->setHeader(EPD_5GS_MM_MSG, security_header_type, DL_NAS_TRANSPORT);
plain_header->setHeader(EPD_5GS_MM_MSG, security_header_type,
DL_NAS_TRANSPORT);
}
//------------------------------------------------------------------------------
......@@ -60,7 +61,8 @@ void DLNASTransport::setPayload_Container_Type(uint8_t value) {
}
//------------------------------------------------------------------------------
void DLNASTransport::setPayload_Container(std::vector<PayloadContainerEntry> content) {
void DLNASTransport::setPayload_Container(
std::vector<PayloadContainerEntry> content) {
ie_payload_container = new Payload_Container(0x00, content);
}
......@@ -104,7 +106,8 @@ int DLNASTransport::encode2buffer(uint8_t *buf, int len) {
if (!ie_payload_container_type) {
Logger::nas_mm().warn("IE ie_payload_container_type is not available");
} else {
if (int size = ie_payload_container_type->encode2buffer(buf + encoded_size, len - encoded_size)) {
if (int size = ie_payload_container_type->encode2buffer(
buf + encoded_size, len - encoded_size)) {
encoded_size += size;
} else {
Logger::nas_mm().error("Encoding ie_payload_container_type error");
......@@ -114,7 +117,8 @@ int DLNASTransport::encode2buffer(uint8_t *buf, int len) {
if (!ie_payload_container) {
Logger::nas_mm().warn("IE ie_payload_container is not available");
} else {
if (int size = ie_payload_container->encode2buffer(buf + encoded_size, len - encoded_size)) {
if (int size = ie_payload_container->encode2buffer(buf + encoded_size,
len - encoded_size)) {
encoded_size += size;
} else {
Logger::nas_mm().error("Encoding ie_payload_container error");
......@@ -124,7 +128,8 @@ int DLNASTransport::encode2buffer(uint8_t *buf, int len) {
if (!ie_pdu_session_identity_2) {
Logger::nas_mm().warn("IE ie_pdu_session_identity_2 is not available");
} else {
if (int size = ie_pdu_session_identity_2->encode2buffer(buf + encoded_size, len - encoded_size)) {
if (int size = ie_pdu_session_identity_2->encode2buffer(
buf + encoded_size, len - encoded_size)) {
encoded_size += size;
} else {
Logger::nas_mm().error("Encoding IE ie_pdu_session_identity_2 error");
......@@ -135,7 +140,8 @@ int DLNASTransport::encode2buffer(uint8_t *buf, int len) {
if (!ie_additional_information) {
Logger::nas_mm().warn("IE ie_additional_information is not available");
} else {
if (int size = ie_additional_information->encode2buffer(buf + encoded_size, len - encoded_size)) {
if (int size = ie_additional_information->encode2buffer(
buf + encoded_size, len - encoded_size)) {
encoded_size += size;
} else {
Logger::nas_mm().error("Encoding IE ie_additional_information error");
......@@ -146,7 +152,8 @@ int DLNASTransport::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");
......@@ -155,26 +162,32 @@ int DLNASTransport::encode2buffer(uint8_t *buf, int len) {
if (!ie_back_off_timer_value) {
Logger::nas_mm().warn("IE ie_back_off_timer_value is not available");
} else {
if (int size = ie_back_off_timer_value->encode2buffer(buf + encoded_size, len - encoded_size)) {
if (int size = ie_back_off_timer_value->encode2buffer(buf + encoded_size,
len - encoded_size)) {
encoded_size += size;
} else {
Logger::nas_mm().error("Encoding ie_back_off_timer_value error");
return 0;
}
}
Logger::nas_mm().debug("Encoded DLNASTransport message len (%d)", encoded_size);
Logger::nas_mm().debug("Encoded DLNASTransport message len (%d)",
encoded_size);
return encoded_size;
}
//------------------------------------------------------------------------------
int DLNASTransport::decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf, int len) {
int DLNASTransport::decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf,
int len) {
Logger::nas_mm().debug("Decoding DLNASTransport message");
int decoded_size = 3;
plain_header = header;
ie_payload_container_type = new Payload_Container_Type();
decoded_size += ie_payload_container_type->decodefrombuffer(buf + decoded_size, len - decoded_size, false);
decoded_size += ie_payload_container_type->decodefrombuffer(
buf + decoded_size, len - decoded_size, false);
ie_payload_container = new Payload_Container();
decoded_size += ie_payload_container->decodefrombuffer(buf + decoded_size, len - decoded_size, false);
decoded_size += ie_payload_container->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);
......@@ -183,7 +196,8 @@ int DLNASTransport::decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf, int
case 0x12: {
Logger::nas_mm().debug("Decoding IEI (0x12)");
ie_pdu_session_identity_2 = new PDU_Session_Identity_2();
decoded_size += ie_pdu_session_identity_2->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
decoded_size += ie_pdu_session_identity_2->decodefrombuffer(
buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("Next IEI (0x%x)", octet);
}
......@@ -191,7 +205,8 @@ int DLNASTransport::decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf, int
case 0x24: {
Logger::nas_mm().debug("Decoding IEI (0x24)");
ie_additional_information = new Additional_Information();
decoded_size += ie_additional_information->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
decoded_size += ie_additional_information->decodefrombuffer(
buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("Next IEI (0x%x)", octet);
}
......@@ -199,7 +214,9 @@ int DLNASTransport::decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf, int
case 0x58: {
Logger::nas_mm().debug("Decoding IEI (0x58)");
ie_5gmm_cause = new _5GMM_Cause();
decoded_size += ie_5gmm_cause->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
decoded_size += ie_5gmm_cause->decodefrombuffer(buf + decoded_size,
len - decoded_size,
true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("Next IEI (0x%x)", octet);
}
......@@ -207,14 +224,16 @@ int DLNASTransport::decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf, int
case 0x37: {
Logger::nas_mm().debug("Decoding IEI (0x37)");
ie_back_off_timer_value = new GPRS_Timer_3();
decoded_size += ie_back_off_timer_value->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
decoded_size += ie_back_off_timer_value->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 DLNASTransport message len (%d)", decoded_size);
Logger::nas_mm().debug("Decoded DLNASTransport message len (%d)",
decoded_size);
}
......@@ -46,7 +46,8 @@ IdentityRequest::~IdentityRequest() {
//------------------------------------------------------------------------------
void IdentityRequest::setHeader(uint8_t security_header_type) {
plain_header = new NasMmPlainHeader();
plain_header->setHeader(EPD_5GS_MM_MSG, security_header_type, IDENTITY_REQUEST);
plain_header->setHeader(EPD_5GS_MM_MSG, security_header_type,
IDENTITY_REQUEST);
}
//------------------------------------------------------------------------------
......@@ -68,26 +69,32 @@ int IdentityRequest::encode2buffer(uint8_t *buf, int len) {
if (!_5gs_identity_type) {
Logger::nas_mm().warn("IE _5gs_identity_type is not available");
} else {
if (int size = _5gs_identity_type->encode2buffer(buf + encoded_size, len - encoded_size)) {
if (int size = _5gs_identity_type->encode2buffer(buf + encoded_size,
len - encoded_size)) {
encoded_size += size;
} else {
Logger::nas_mm().error("encoding _5gs_identity_type error");
return 0;
}
}
Logger::nas_mm().debug("encoded IdentityRequest message len(%d)", encoded_size);
Logger::nas_mm().debug("encoded IdentityRequest message len(%d)",
encoded_size);
return 1;
}
//------------------------------------------------------------------------------
int IdentityRequest::decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf, int len) {
int IdentityRequest::decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf,
int len) {
Logger::nas_mm().debug("decoding IdentityRequest message");
int decoded_size = 3;
plain_header = header;
_5gs_identity_type = new _5GS_Identity_Type();
decoded_size += _5gs_identity_type->decodefrombuffer(buf + decoded_size, len - decoded_size, false);
decoded_size += _5gs_identity_type->decodefrombuffer(buf + decoded_size,
len - decoded_size,
false);
Logger::nas_mm().debug("decoded_size(%d)", decoded_size);
Logger::nas_mm().debug("decoded IdentityRequest message len(%d)", decoded_size);
Logger::nas_mm().debug("decoded IdentityRequest message len(%d)",
decoded_size);
}
......@@ -46,21 +46,33 @@ IdentityResponse::~IdentityResponse() {
//------------------------------------------------------------------------------
void IdentityResponse::setHeader(uint8_t security_header_type) {
plain_header = new NasMmPlainHeader();
plain_header->setHeader(EPD_5GS_MM_MSG, security_header_type, IDENTITY_RESPONSE);
plain_header->setHeader(EPD_5GS_MM_MSG, security_header_type,
IDENTITY_RESPONSE);
}
//------------------------------------------------------------------------------
void IdentityResponse::setSUCI_SUPI_format_IMSI(const string mcc, const string mnc, const string routingInd, uint8_t protection_sch_id, const string msin) {
void IdentityResponse::setSUCI_SUPI_format_IMSI(const string mcc,
const string mnc,
const string routingInd,
uint8_t protection_sch_id,
const string msin) {
if (protection_sch_id != NULL_SCHEME) {
Logger::nas_mm().error("encoding suci and supi format for imsi error, please choose right interface");
Logger::nas_mm().error(
"encoding suci and supi format for imsi error, please choose right interface");
return;
} else {
ie_mobility_id = new _5GSMobilityIdentity(mcc, mnc, routingInd, protection_sch_id, msin);
ie_mobility_id = new _5GSMobilityIdentity(mcc, mnc, routingInd,
protection_sch_id, msin);
}
}
//------------------------------------------------------------------------------
void IdentityResponse::setSUCI_SUPI_format_IMSI(const string mcc, const string mnc, const string routingInd, uint8_t protection_sch_id, uint8_t hnpki, const string msin) {
void IdentityResponse::setSUCI_SUPI_format_IMSI(const string mcc,
const string mnc,
const string routingInd,
uint8_t protection_sch_id,
uint8_t hnpki,
const string msin) {
}
//------------------------------------------------------------------------------
......@@ -89,26 +101,31 @@ int IdentityResponse::encode2buffer(uint8_t *buf, int len) {
if (!ie_mobility_id) {
Logger::nas_mm().warn("IE ie_mobility_id is not available");
} else {
if (int size = ie_mobility_id->encode2buffer(buf + encoded_size, len - encoded_size)) {
if (int size = ie_mobility_id->encode2buffer(buf + encoded_size,
len - encoded_size)) {
encoded_size += size;
} else {
Logger::nas_mm().error("encoding ie_mobility_id error");
return 0;
}
}
Logger::nas_mm().debug("encoded IdentityResponse message len(%d)", encoded_size);
Logger::nas_mm().debug("encoded IdentityResponse message len(%d)",
encoded_size);
return 1;
}
//------------------------------------------------------------------------------
int IdentityResponse::decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf, int len) {
int IdentityResponse::decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf,
int len) {
Logger::nas_mm().debug("decoding IdentityResponse message");
int decoded_size = 3;
plain_header = header;
ie_mobility_id = new _5GSMobilityIdentity();
decoded_size += ie_mobility_id->decodefrombuffer(buf + decoded_size, len - decoded_size, false);
decoded_size += ie_mobility_id->decodefrombuffer(buf + decoded_size,
len - decoded_size, false);
Logger::nas_mm().debug("decoded_size(%d)", decoded_size);
Logger::nas_mm().debug("decoded IdentityResponse message len(%d)", decoded_size);
Logger::nas_mm().debug("decoded IdentityResponse message len(%d)",
decoded_size);
}
......@@ -40,8 +40,13 @@ class IdentityResponse {
int encode2buffer(uint8_t *buf, int len);
int decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf, int len);
void setHeader(uint8_t security_header_type);
void setSUCI_SUPI_format_IMSI(const string mcc, const string mnc, const string routingInd, uint8_t protection_sch_id, const string msin);
void setSUCI_SUPI_format_IMSI(const string mcc, const string mnc, const string routingInd, uint8_t protection_sch_id, uint8_t hnpki, const string msin);
void setSUCI_SUPI_format_IMSI(const string mcc, const string mnc,
const string routingInd,
uint8_t protection_sch_id, const string msin);
void setSUCI_SUPI_format_IMSI(const string mcc, const string mnc,
const string routingInd,
uint8_t protection_sch_id, uint8_t hnpki,
const string msin);
void set5G_GUTI();
void setIMEI_IMEISV();
void set5G_S_TMSI();
......
This diff is collapsed.
......@@ -41,22 +41,32 @@ class RegistrationAccept {
int decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf, int len);
void setHeader(uint8_t security_header_type);
void setSOR_Transparent_Container(uint8_t header, uint8_t *value);
void set_5GS_Registration_Result(bool emergency, bool nssaa, bool sms, uint8_t value);
void set_5GS_Registration_Result(bool emergency, bool nssaa, bool sms,
uint8_t value);
/*** belongs to _5GSMobilityIdentity**/
void setSUCI_SUPI_format_IMSI(const string mcc, const string mnc, const string routingInd, uint8_t protection_sch_id, const string msin);
void setSUCI_SUPI_format_IMSI(const string mcc, const string mnc, const string routingInd, uint8_t protection_sch_id, uint8_t hnpki, const string msin);
void set5G_GUTI(const string mcc, const string mnc, const string amfRegionId, const string amfSetId, const string amfPointer, const uint32_t tmsi);
void setSUCI_SUPI_format_IMSI(const string mcc, const string mnc,
const string routingInd,
uint8_t protection_sch_id, const string msin);
void setSUCI_SUPI_format_IMSI(const string mcc, const string mnc,
const string routingInd,
uint8_t protection_sch_id, uint8_t hnpki,
const string msin);
void set5G_GUTI(const string mcc, const string mnc, const string amfRegionId,
const string amfSetId, const string amfPointer,
const uint32_t tmsi);
void setIMEI_IMEISV();
void set5G_S_TMSI();
/*** belongs to _5GSMobilityIdentity**/
void setEquivalent_PLMNs(uint8_t MNC_MCC1, uint8_t MNC_MCC2, uint8_t MNC_MCC3);
void setEquivalent_PLMNs(uint8_t MNC_MCC1, uint8_t MNC_MCC2,
uint8_t MNC_MCC3);
void setALLOWED_NSSAI(std::vector<struct SNSSAI_s> nssai);
void setRejected_NSSAI(uint8_t cause, uint8_t value);
void setCONFIGURED_NSSAI(std::vector<struct SNSSAI_s> nssai);
void set_5GS_Network_Feature_Support(uint8_t value, uint8_t value2);
void setPDU_session_status(uint16_t value);
void setPDU_session_reactivation_result(uint16_t value);
void setPDU_session_reactivation_result_error_cause(uint8_t session_id, uint8_t value);
void setPDU_session_reactivation_result_error_cause(uint8_t session_id,
uint8_t value);
void setMICO_Indication(bool sprti, bool raai);
void setNetwork_Slicing_Indication(bool dcni, bool nssci);
void setT3512_Value(uint8_t unit, uint8_t value);
......
......@@ -46,12 +46,15 @@ RegistrationComplete::~RegistrationComplete() {
//------------------------------------------------------------------------------
void RegistrationComplete::setHeader(uint8_t security_header_type) {
plain_header = new NasMmPlainHeader();
plain_header->setHeader(EPD_5GS_MM_MSG, security_header_type, REGISTRATION_COMPLETE);
plain_header->setHeader(EPD_5GS_MM_MSG, security_header_type,
REGISTRATION_COMPLETE);
}
//------------------------------------------------------------------------------
void RegistrationComplete::setSOR_Transparent_Container(uint8_t header, uint8_t *value) {
ie_sor_transparent_container = new SOR_Transparent_Container(0x73, header, value);
void RegistrationComplete::setSOR_Transparent_Container(uint8_t header,
uint8_t *value) {
ie_sor_transparent_container = new SOR_Transparent_Container(0x73, header,
value);
}
//------------------------------------------------------------------------------
......@@ -68,19 +71,22 @@ int RegistrationComplete::encode2buffer(uint8_t *buf, int len) {
if (!ie_sor_transparent_container) {
Logger::nas_mm().warn("IE ie_sor_transparent_container is not available");
} else {
if (int size = ie_sor_transparent_container->encode2buffer(buf + encoded_size, len - encoded_size)) {
if (int size = ie_sor_transparent_container->encode2buffer(
buf + encoded_size, len - encoded_size)) {
encoded_size += size;
} else {
Logger::nas_mm().error("Encoding ie_sor_transparent_container error");
return 0;
}
}
Logger::nas_mm().debug("Encoded RegistrationComplete message len (%d)", encoded_size);
Logger::nas_mm().debug("Encoded RegistrationComplete message len (%d)",
encoded_size);
return 1;
}
//------------------------------------------------------------------------------
int RegistrationComplete::decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf, int len) {
int RegistrationComplete::decodefrombuffer(NasMmPlainHeader *header,
uint8_t *buf, int len) {
Logger::nas_mm().debug("Decoding RegistrationComplete message");
int decoded_size = 3;
plain_header = header;
......@@ -92,14 +98,16 @@ int RegistrationComplete::decodefrombuffer(NasMmPlainHeader *header, uint8_t *bu
case 0x73: {
Logger::nas_mm().debug("Decoding IEI (0x73)");
ie_sor_transparent_container = new SOR_Transparent_Container();
decoded_size += ie_sor_transparent_container->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
decoded_size += ie_sor_transparent_container->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 RegistrationComplete message len (%d)", decoded_size);
Logger::nas_mm().debug("Decoded RegistrationComplete message len (%d)",
decoded_size);
}
......@@ -50,7 +50,8 @@ RegistrationReject::~RegistrationReject() {
//------------------------------------------------------------------------------
void RegistrationReject::setHeader(uint8_t security_header_type) {
plain_header = new NasMmPlainHeader();
plain_header->setHeader(EPD_5GS_MM_MSG, security_header_type, REGISTRATION_REJECT);
plain_header->setHeader(EPD_5GS_MM_MSG, security_header_type,
REGISTRATION_REJECT);
}
//------------------------------------------------------------------------------
......@@ -92,7 +93,8 @@ int RegistrationReject::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");
......@@ -101,7 +103,8 @@ int RegistrationReject::encode2buffer(uint8_t *buf, int len) {
if (!ie_T3346_value) {
Logger::nas_mm().warn("IE ie_T3346_value is not available");
} else {
if (int size = ie_T3346_value->encode2buffer(buf + encoded_size, len - encoded_size)) {
if (int size = ie_T3346_value->encode2buffer(buf + encoded_size,
len - encoded_size)) {
encoded_size += size;
} else {
Logger::nas_mm().error("Encoding ie_T3346_value error");
......@@ -111,7 +114,8 @@ int RegistrationReject::encode2buffer(uint8_t *buf, int len) {
if (!ie_T3502_value) {
Logger::nas_mm().warn("IE ie_T3502_value is not available");
} else {
if (int size = ie_T3502_value->encode2buffer(buf + encoded_size, len - encoded_size)) {
if (int size = ie_T3502_value->encode2buffer(buf + encoded_size,
len - encoded_size)) {
encoded_size += size;
} else {
Logger::nas_mm().error("Encoding ie_T3502_value error");
......@@ -121,7 +125,8 @@ int RegistrationReject::encode2buffer(uint8_t *buf, int len) {
if (!ie_eap_message) {
Logger::nas_mm().warn("IE ie_eap_message is not available");
} else {
if (int size = ie_eap_message->encode2buffer(buf + encoded_size, len - encoded_size)) {
if (int size = ie_eap_message->encode2buffer(buf + encoded_size,
len - encoded_size)) {
encoded_size += size;
} else {
Logger::nas_mm().error("Encoding ie_eap_message error");
......@@ -131,23 +136,27 @@ int RegistrationReject::encode2buffer(uint8_t *buf, int len) {
if (!ie_rejected_nssai) {
Logger::nas_mm().warn("IE ie_rejected_nssai is not available");
} else {
if (int size = ie_rejected_nssai->encode2buffer(buf + encoded_size, len - encoded_size)) {
if (int size = ie_rejected_nssai->encode2buffer(buf + encoded_size,
len - encoded_size)) {
encoded_size += size;
} else {
Logger::nas_mm().error("Encoding ie_rejected_nssai error");
}
}
Logger::nas_mm().debug("Encoded RegistrationReject message len (%d)", encoded_size);
Logger::nas_mm().debug("Encoded RegistrationReject message len (%d)",
encoded_size);
return encoded_size;
}
//------------------------------------------------------------------------------
int RegistrationReject::decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf, int len) {
int RegistrationReject::decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf,
int len) {
Logger::nas_mm().debug("Decoding RegistrationReject 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);
......@@ -156,7 +165,9 @@ int RegistrationReject::decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf,
case 0x5F: {
Logger::nas_mm().debug("Decoding IEI (0x5F)");
ie_T3346_value = new GPRS_Timer_2();
decoded_size += ie_T3346_value->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
decoded_size += ie_T3346_value->decodefrombuffer(buf + decoded_size,
len - decoded_size,
true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("Next IEI (0x%x)", octet);
}
......@@ -164,7 +175,9 @@ int RegistrationReject::decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf,
case 0x16: {
Logger::nas_mm().debug("Decoding iei(0x16)");
ie_T3502_value = new GPRS_Timer_2();
decoded_size += ie_T3502_value->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
decoded_size += ie_T3502_value->decodefrombuffer(buf + decoded_size,
len - decoded_size,
true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("Next IEI (0x%x)", octet);
}
......@@ -172,7 +185,9 @@ int RegistrationReject::decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf,
case 0x78: {
Logger::nas_mm().debug("Decoding iei(0x78)");
ie_eap_message = new EAP_Message();
decoded_size += ie_eap_message->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
decoded_size += ie_eap_message->decodefrombuffer(buf + decoded_size,
len - decoded_size,
true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("Next IEI (0x%x)", octet);
}
......@@ -180,14 +195,17 @@ int RegistrationReject::decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf,
case 0x69: {
Logger::nas_mm().debug("Decoding IEI (0x69)");
ie_rejected_nssai = new Rejected_NSSAI();
decoded_size += ie_rejected_nssai->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
decoded_size += ie_rejected_nssai->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 RegistrationReject message len(%d)", decoded_size);
Logger::nas_mm().debug("decoded RegistrationReject message len(%d)",
decoded_size);
}
This diff is collapsed.
......@@ -48,12 +48,22 @@ class RegistrationRequest {
void set5gsRegistrationType(bool is_for, uint8_t type);
void setngKSI(uint8_t tsc, uint8_t key_set_id);
/*** belongs to _5GSMobilityIdentity**/
void setSUCI_SUPI_format_IMSI(const string mcc, const string mnc, const string routingInd, uint8_t protection_sch_id, const string msin);
void setSUCI_SUPI_format_IMSI(const string mcc, const string mnc, const string routingInd, uint8_t protection_sch_id, uint8_t hnpki, const string msin);
void setSUCI_SUPI_format_IMSI(const string mcc, const string mnc,
const string routingInd,
uint8_t protection_sch_id, const string msin);
void setSUCI_SUPI_format_IMSI(const string mcc, const string mnc,
const string routingInd,
uint8_t protection_sch_id, uint8_t hnpki,
const string msin);
void set5G_GUTI();
void setIMEI_IMEISV();
void set5G_S_TMSI();
void setAdditional_GUTI_SUCI_SUPI_format_IMSI(const string mcc, const string mnc, uint8_t amf_region_id, uint8_t amf_set_id, uint8_t amf_pointer, const string _5g_tmsi);
void setAdditional_GUTI_SUCI_SUPI_format_IMSI(const string mcc,
const string mnc,
uint8_t amf_region_id,
uint8_t amf_set_id,
uint8_t amf_pointer,
const string _5g_tmsi);
//for Additional_GUTI
/*** belongs to _5GSMobilityIdentity**/
void setNon_current_native_nas_ksi(uint8_t tsc, uint8_t key_set_id);
......@@ -63,7 +73,8 @@ class RegistrationRequest {
void setUENetworkCapability(uint8_t g_EEASel, uint8_t g_EIASel);
void setUplink_data_status(uint16_t value);
void setLast_Visited_Registered_TAI(uint8_t MNC_MCC1, uint8_t MNC_MCC2, uint8_t MNC_MCC3, uint32_t TAC);
void setLast_Visited_Registered_TAI(uint8_t MNC_MCC1, uint8_t MNC_MCC2,
uint8_t MNC_MCC3, uint32_t TAC);
void setPDU_session_status(uint16_t value);
void setMICO_Indication(bool sprti, bool raai);
void setUE_Status(bool n1, bool s1);
......@@ -76,21 +87,22 @@ class RegistrationRequest {
void setPayload_Container_Type(uint8_t value);
void setPayload_Container(std::vector<PayloadContainerEntry> content);
void setNetwork_Slicing_Indication(bool dcni, bool nssci);
void set_5GS_Update_Type(uint8_t eps_pnb_ciot, uint8_t _5gs_pnb_ciot, bool ng_ran, bool sms);
void set_5GS_Update_Type(uint8_t eps_pnb_ciot, uint8_t _5gs_pnb_ciot,
bool ng_ran, bool sms);
void setNAS_Message_Container(bstring value);
void setEPS_Bearer_Context_Status(uint16_t value);
bool get5GSRegistrationType(bool &is_for, uint8_t &reg_type/*3bits*/); //返回获取IE的状态,成功或者失败
uint8_t getngKSI(); //return -1;表示获取IE失败
uint8_t getMobilityIdentityType(); //return -1;表示获取IE失败
bool get5GSRegistrationType(bool &is_for, uint8_t &reg_type/*3bits*/);
uint8_t getngKSI();
uint8_t getMobilityIdentityType();
std::string get_5g_guti(); //"error" for missing IE GUTI
bool getSuciSupiFormatImsi(nas::SUCI_imsi_t &imsi);
uint8_t getNonCurrentNativeNasKSI(); //return -1;表示获取IE失败
uint8_t get5GMMCapability(); //return -1;表示获取IE失败; set接口可能有bug
uint8_t getNonCurrentNativeNasKSI();
uint8_t get5GMMCapability();
bool getUeSecurityCapability(uint8_t &ea, uint8_t &ia);
bool getRequestedNssai(std::vector<struct SNSSAI_s> &nssai);
bool getS1UeNetworkCapability(uint8_t &eea, uint8_t &eia);
uint16_t getUplinkDataStatus(); //return -1;表示获取IE失败;
uint16_t getUplinkDataStatus();
uint16_t getPduSessionStatus();
bool getMicoIndication(uint8_t &sprti, uint8_t &raai);
bool getUeStatus(uint8_t &n1ModeReg, uint8_t &s1ModeReg);
......@@ -101,7 +113,8 @@ class RegistrationRequest {
bool getEpsNasMessageContainer(bstring &epsNas);
uint8_t getPayloadContainerType();
bool getNetworkSlicingIndication(uint8_t &dcni, uint8_t &nssci);
bool get5GSUpdateType(uint8_t &eps_pnb_ciot, uint8_t &_5gs_pnb_ciot, bool &ng_ran_rcu, bool &sms_requested);
bool get5GSUpdateType(uint8_t &eps_pnb_ciot, uint8_t &_5gs_pnb_ciot,
bool &ng_ran_rcu, bool &sms_requested);
bool getNasMessageContainer(bstring &nas);
uint16_t getEpsBearerContextStatus();
bool getLadnIndication(std::vector<bstring> &ladnValue);
......
This diff is collapsed.
......@@ -49,7 +49,8 @@ SecurityModeComplete::~SecurityModeComplete() {
//------------------------------------------------------------------------------
void SecurityModeComplete::setHeader(uint8_t security_header_type) {
plain_header = new NasMmPlainHeader();
plain_header->setHeader(EPD_5GS_MM_MSG, security_header_type, SECURITY_MODE_COMPLETE);
plain_header->setHeader(EPD_5GS_MM_MSG, security_header_type,
SECURITY_MODE_COMPLETE);
}
//------------------------------------------------------------------------------
......@@ -115,7 +116,8 @@ int SecurityModeComplete::encode2buffer(uint8_t *buf, int len) {
if (!ie_imeisv) {
Logger::nas_mm().warn("IE ie_imeisv is not available");
} else {
if (int size = ie_imeisv->encode2buffer(buf + encoded_size, len - encoded_size)) {
if (int size = ie_imeisv->encode2buffer(buf + encoded_size,
len - encoded_size)) {
encoded_size += size;
} else {
Logger::nas_mm().error("Encoding IE ie_imeisv error");
......@@ -126,7 +128,8 @@ int SecurityModeComplete::encode2buffer(uint8_t *buf, int len) {
if (!ie_nas_message_container) {
Logger::nas_mm().warn("IE ie_nas_message_container is not available");
} else {
if (int size = ie_nas_message_container->encode2buffer(buf + encoded_size, len - encoded_size)) {
if (int size = ie_nas_message_container->encode2buffer(
buf + encoded_size, len - encoded_size)) {
encoded_size += size;
} else {
Logger::nas_mm().error("Encoding ie_nas_message_container error");
......@@ -136,7 +139,8 @@ int SecurityModeComplete::encode2buffer(uint8_t *buf, int len) {
if (!ie_non_imeisvpei) {
Logger::nas_mm().warn("IE ie_non_imeisvpei is not available");
} else {
if (int size = ie_non_imeisvpei->encode2buffer(buf + encoded_size, len - encoded_size)) {
if (int size = ie_non_imeisvpei->encode2buffer(buf + encoded_size,
len - encoded_size)) {
encoded_size += size;
} else {
Logger::nas_mm().error("Encoding IE ie_non_imeisvpei error");
......@@ -144,12 +148,14 @@ int SecurityModeComplete::encode2buffer(uint8_t *buf, int len) {
}
}
Logger::nas_mm().debug("Encoded SecurityModeComplete message len (%d)", encoded_size);
Logger::nas_mm().debug("Encoded SecurityModeComplete message len (%d)",
encoded_size);
return 1;
}
//------------------------------------------------------------------------------
int SecurityModeComplete::decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf, int len) {
int SecurityModeComplete::decodefrombuffer(NasMmPlainHeader *header,
uint8_t *buf, int len) {
Logger::nas_mm().debug("Decoding SecurityModeComplete message");
int decoded_size = 3;
plain_header = header;
......@@ -161,7 +167,8 @@ int SecurityModeComplete::decodefrombuffer(NasMmPlainHeader *header, uint8_t *bu
case 0x77: {
Logger::nas_mm().debug("Decoding IEI (0x77)");
ie_imeisv = new _5GSMobilityIdentity();
decoded_size += ie_imeisv->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
decoded_size += ie_imeisv->decodefrombuffer(buf + decoded_size,
len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("Next IEI (0x%x)", octet);
}
......@@ -169,7 +176,8 @@ int SecurityModeComplete::decodefrombuffer(NasMmPlainHeader *header, uint8_t *bu
case 0x71: {
Logger::nas_mm().debug("Decoding IEI (0x71)");
ie_nas_message_container = new NAS_Message_Container();
decoded_size += ie_nas_message_container->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
decoded_size += ie_nas_message_container->decodefrombuffer(
buf + decoded_size, len - decoded_size, true);
octet = *(buf + decoded_size);
Logger::nas_mm().debug("Next IEI (0x%x)", octet);
}
......@@ -177,14 +185,17 @@ int SecurityModeComplete::decodefrombuffer(NasMmPlainHeader *header, uint8_t *bu
case 0x78: {
Logger::nas_mm().debug("Decoding IEI (0x78)");
ie_non_imeisvpei = new _5GSMobilityIdentity();
decoded_size += ie_non_imeisvpei->decodefrombuffer(buf + decoded_size, len - decoded_size, true);
decoded_size += ie_non_imeisvpei->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 SecurityModeComplete message len (%d)", decoded_size);
Logger::nas_mm().debug("Decoded SecurityModeComplete message len (%d)",
decoded_size);
}
......@@ -46,7 +46,8 @@ SecurityModeReject::~SecurityModeReject() {
//------------------------------------------------------------------------------
void SecurityModeReject::setHeader(uint8_t security_header_type) {
plain_header = new NasMmPlainHeader();
plain_header->setHeader(EPD_5GS_MM_MSG, security_header_type, SECURITY_MODE_REJECT);
plain_header->setHeader(EPD_5GS_MM_MSG, security_header_type,
SECURITY_MODE_REJECT);
}
//------------------------------------------------------------------------------
......@@ -68,27 +69,32 @@ int SecurityModeReject::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");
}
}
Logger::nas_mm().debug("encoded SecurityModeReject message len(%d)", encoded_size);
Logger::nas_mm().debug("encoded SecurityModeReject message len(%d)",
encoded_size);
return 1;
}
//------------------------------------------------------------------------------
int SecurityModeReject::decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf, int len) {
int SecurityModeReject::decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf,
int len) {
Logger::nas_mm().debug("decoding SecurityModeReject 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);
Logger::nas_mm().debug("decoded SecurityModeReject message len(%d)", decoded_size);
Logger::nas_mm().debug("decoded SecurityModeReject message len(%d)",
decoded_size);
}
......@@ -52,7 +52,8 @@ void ServiceAccept::setPDU_session_status(uint16_t value) {
//------------------------------------------------------------------------------
void ServiceAccept::setPDU_session_reactivation_result(uint16_t value) {
ie_session_reactivation_result = new PDU_Session_Reactivation_Result(0x26, value);
ie_session_reactivation_result = new PDU_Session_Reactivation_Result(0x26,
value);
}
//------------------------------------------------------------------------------
......@@ -66,8 +67,10 @@ int ServiceAccept::encode2buffer(uint8_t *buf, int len) {
return -1;
encoded_size += 3;
if (ie_PDU_session_status)
encoded_size += ie_PDU_session_status->encode2buffer(buf + encoded_size, len - encoded_size);
encoded_size += ie_PDU_session_status->encode2buffer(buf + encoded_size,
len - encoded_size);
if (ie_session_reactivation_result)
encoded_size += ie_session_reactivation_result->encode2buffer(buf + encoded_size, len - encoded_size);
encoded_size += ie_session_reactivation_result->encode2buffer(
buf + encoded_size, len - encoded_size);
return encoded_size;
}
This diff is collapsed.
......@@ -53,10 +53,10 @@ class ServiceRequest {
int encode2buffer(uint8_t *buf, int len);
public:
int decodefrombuffer(NasMmPlainHeader *header, uint8_t *buf, int len);
uint8_t getngKSI(); //return -1;表示获取IE失败
uint8_t getngKSI();
uint8_t getServiceType();
bool get5G_S_TMSI(uint16_t &amfSetId, uint8_t &amfPointer, string &tmsi);
uint16_t getUplinkDataStatus(); //return -1;表示获取IE失败;
uint16_t getUplinkDataStatus();
uint16_t getPduSessionStatus();
uint16_t getAllowedPduSessionStatus();
bool getNasMessageContainer(bstring &nas);
......
This diff is collapsed.
......@@ -63,7 +63,8 @@ uint8_t NasMmPlainHeader::getMessageType() {
}
//------------------------------------------------------------------------------
void NasMmPlainHeader::setHeader(uint8_t epd_, uint8_t security_header_type, uint8_t msg_type_) {
void NasMmPlainHeader::setHeader(uint8_t epd_, uint8_t security_header_type,
uint8_t msg_type_) {
epd = epd_;
secu_header_type = security_header_type;
msg_type = msg_type_;
......@@ -88,7 +89,8 @@ int NasMmPlainHeader::encode2buffer(uint8_t *buf, int len) {
int NasMmPlainHeader::decodefrombuffer(uint8_t *buf, int len) {
Logger::nas_mm().debug("decoding NasMmPlainHeader");
if (len < 3) {
Logger::nas_mm().error("[decoding nas mm header error][buffer length is less than 3 octets]");
Logger::nas_mm().error(
"[decoding nas mm header error][buffer length is less than 3 octets]");
return 0;
} else {
epd = *(buf++);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -59,14 +59,16 @@ bool AMF_UE_NGAP_ID::encode2AMF_UE_NGAP_ID(Ngap_AMF_UE_NGAP_ID_t &amfuengapid) {
return false;
for (int i = 0; i < amfuengapid.size; i++) {
amfuengapid.buf[i] = (amfUeNgapId & (0xff00000000 >> i * 8)) >> ((amfuengapid.size - i - 1) * 8);
amfuengapid.buf[i] = (amfUeNgapId & (0xff00000000 >> i * 8))
>> ((amfuengapid.size - i - 1) * 8);
}
return true;
}
//------------------------------------------------------------------------------
bool AMF_UE_NGAP_ID::decodefromAMF_UE_NGAP_ID(Ngap_AMF_UE_NGAP_ID_t &amfuengapid) {
bool AMF_UE_NGAP_ID::decodefromAMF_UE_NGAP_ID(
Ngap_AMF_UE_NGAP_ID_t &amfuengapid) {
if (!amfuengapid.buf)
return false;
......
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