Commit d22b51bf authored by Raphael Defosseux's avatar Raphael Defosseux

Merge branch 'flexible-logging-level' into 'develop'

feat(smf): adding a flexible log-level

See merge request oai/cn5g/oai-cn5g-smf!188
parents 5b33bae9 6ab4daf2
...@@ -24,6 +24,7 @@ SMF = ...@@ -24,6 +24,7 @@ SMF =
FQDN = "oai-smf-svc"; FQDN = "oai-smf-svc";
INSTANCE = {{ env["INSTANCE"] if "INSTANCE" in env.keys() else 0 }}; # 0 is the default INSTANCE = {{ env["INSTANCE"] if "INSTANCE" in env.keys() else 0 }}; # 0 is the default
PID_DIRECTORY = "{{ env["PID_DIRECTORY"] if "PID_DIRECTORY" in env.keys() else '/var/run' }}"; # /var/run is the default PID_DIRECTORY = "{{ env["PID_DIRECTORY"] if "PID_DIRECTORY" in env.keys() else '/var/run' }}"; # /var/run is the default
LOG_LEVEL = "{{ env["LOG_LEVEL"] if "LOG_LEVEL" in env.keys() else 'debug' }}";
INTERFACES : INTERFACES :
{ {
......
...@@ -73,6 +73,12 @@ class Logger { ...@@ -73,6 +73,12 @@ class Logger {
oai::logger::logger_registry::register_logger( oai::logger::logger_registry::register_logger(
name, ASYNC, log_stdout, log_rot_file); name, ASYNC, log_stdout, log_rot_file);
} }
static void set_level(spdlog::level::level_enum level) {
oai::logger::logger_registry::set_level(level);
}
static bool should_log(spdlog::level::level_enum level) {
return oai::logger::logger_registry::should_log(level);
}
static const oai::logger::printf_logger& smf_app() { static const oai::logger::printf_logger& smf_app() {
return oai::logger::logger_registry::get_logger(SMF_APP); return oai::logger::logger_registry::get_logger(SMF_APP);
...@@ -120,5 +126,4 @@ class Logger { ...@@ -120,5 +126,4 @@ class Logger {
static const oai::logger::printf_logger& async_cmd() { static const oai::logger::printf_logger& async_cmd() {
return oai::logger::logger_registry::get_logger(ASYNC); return oai::logger::logger_registry::get_logger(ASYNC);
} }
}; };
...@@ -63,11 +63,7 @@ ...@@ -63,11 +63,7 @@
} \ } \
} while (0) } while (0)
#if DEBUG_IS_ON
#define _ASSERT_FINAL_ _Assert_SegFault_ #define _ASSERT_FINAL_ _Assert_SegFault_
#else
#define _ASSERT_FINAL_ _Assert_Exit_
#endif
#define AssertFatal(cOND, ...) _Assert_(cOND, _ASSERT_FINAL_, ##__VA_ARGS__) #define AssertFatal(cOND, ...) _Assert_(cOND, _ASSERT_FINAL_, ##__VA_ARGS__)
#define DevCheck(cOND, vALUE1, vALUE2, vALUE3) \ #define DevCheck(cOND, vALUE1, vALUE2, vALUE3) \
......
...@@ -236,13 +236,14 @@ void conv::convert_string_2_hex( ...@@ -236,13 +236,14 @@ void conv::convert_string_2_hex(
memset(data, 0, input_str.length() + 1); memset(data, 0, input_str.length() + 1);
memcpy((void*) data, (void*) input_str.c_str(), input_str.length()); memcpy((void*) data, (void*) input_str.c_str(), input_str.length());
#if DEBUG_IS_ON
Logger::smf_app().debug("Input: "); Logger::smf_app().debug("Input: ");
if (Logger::should_log(spdlog::level::debug)) {
for (int i = 0; i < input_str.length(); i++) { for (int i = 0; i < input_str.length(); i++) {
printf("%02x ", data[i]); printf("%02x ", data[i]);
} }
printf("\n"); printf("\n");
#endif }
char* datahex = (char*) malloc(input_str.length() * 2 + 1); char* datahex = (char*) malloc(input_str.length() * 2 + 1);
memset(datahex, 0, input_str.length() * 2 + 1); memset(datahex, 0, input_str.length() * 2 + 1);
......
...@@ -91,10 +91,10 @@ unsigned char* mime_parser::format_string_as_hex(const std::string& str) { ...@@ -91,10 +91,10 @@ unsigned char* mime_parser::format_string_as_hex(const std::string& str) {
Logger::smf_app().debug("Input string (%d bytes): %s ", str_len, str.c_str()); Logger::smf_app().debug("Input string (%d bytes): %s ", str_len, str.c_str());
Logger::smf_app().debug("Data (formatted):"); Logger::smf_app().debug("Data (formatted):");
#if DEBUG_IS_ON if (Logger::should_log(spdlog::level::debug)) {
for (int i = 0; i < str_len / 2; i++) printf(" %02x ", data_hex[i]); for (int i = 0; i < str_len / 2; i++) printf(" %02x ", data_hex[i]);
printf("\n"); printf("\n");
#endif }
// free memory // free memory
// free_wrapper((void**) &data); // free_wrapper((void**) &data);
free(data); free(data);
......
...@@ -336,7 +336,6 @@ static int _nas_message_header_encode( ...@@ -336,7 +336,6 @@ static int _nas_message_header_encode(
unsigned char* buffer, const nas_message_security_header_t* header, unsigned char* buffer, const nas_message_security_header_t* header,
size_t length) { size_t length) {
int size = 0; int size = 0;
/* /*
* Encode the first octet of the header (security header type or EPS bearer * Encode the first octet of the header (security header type or EPS bearer
* identity, and protocol discriminator) * identity, and protocol discriminator)
...@@ -346,17 +345,10 @@ static int _nas_message_header_encode( ...@@ -346,17 +345,10 @@ static int _nas_message_header_encode(
// Security header type associated with a spare half octet; // Security header type associated with a spare half octet;
ENCODE_U8(buffer + size, *((uint8_t*) (header) + 1), size); ENCODE_U8(buffer + size, *((uint8_t*) (header) + 1), size);
// ENCODE_U8 (buffer+size,header->security_header_type,size); // ENCODE_U8 (buffer+size,header->security_header_type,size);
#if DEBUG_IS_ON
printf(
"extended_protocol_discriminator %d, security_header_type %d \n",
header->extended_protocol_discriminator, header->security_header_type);
#endif
if (header->extended_protocol_discriminator == if (header->extended_protocol_discriminator ==
EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES) { EPD_5GS_MOBILITY_MANAGEMENT_MESSAGES) {
if (header->security_header_type != SECURITY_HEADER_TYPE_NOT_PROTECTED) { if (header->security_header_type != SECURITY_HEADER_TYPE_NOT_PROTECTED) {
#if DEBUG_IS_ON
printf("security_header_type != SECURITY_HEADER_TYPE_NOT_PROTECTED\n");
#endif
if (length < NAS_MESSAGE_SECURITY_HEADER_SIZE) { if (length < NAS_MESSAGE_SECURITY_HEADER_SIZE) {
/* /*
* The buffer is not big enough to contain security header * The buffer is not big enough to contain security header
...@@ -373,11 +365,7 @@ static int _nas_message_header_encode( ...@@ -373,11 +365,7 @@ static int _nas_message_header_encode(
*/ */
ENCODE_U8(buffer + size, header->sequence_number, size); ENCODE_U8(buffer + size, header->sequence_number, size);
} }
#if DEBUG_IS_ON
printf("security_header_type: SECURITY_HEADER_TYPE_NOT_PROTECTED\n");
#endif
} }
return size;
} }
static int _nas_message_protected_encode( static int _nas_message_protected_encode(
......
...@@ -207,9 +207,7 @@ int encode_pdu_session_establishment_accept( ...@@ -207,9 +207,7 @@ int encode_pdu_session_establishment_accept(
uint8_t* buffer, uint32_t len) { uint8_t* buffer, uint32_t len) {
uint32_t encoded = 0; uint32_t encoded = 0;
int encoded_result = 0; int encoded_result = 0;
#if DEBUG_IS_ON
printf("\nEncode PDU Session Establishment Accept\n");
#endif
// Check if we got a NULL pointer and if buffer length is >= minimum length // Check if we got a NULL pointer and if buffer length is >= minimum length
// expected for the message. // expected for the message.
CHECK_PDU_POINTER_AND_LENGTH_ENCODER( CHECK_PDU_POINTER_AND_LENGTH_ENCODER(
......
...@@ -159,9 +159,7 @@ int fivegsm_msg_encode(SM_msg* msg, uint8_t* buffer, uint32_t len) { ...@@ -159,9 +159,7 @@ int fivegsm_msg_encode(SM_msg* msg, uint8_t* buffer, uint32_t len) {
buffer += header_result; buffer += header_result;
len -= header_result; len -= header_result;
#if DEBUG_IS_ON
printf("message type %d", msg->header.message_type);
#endif
switch (msg->header.message_type) { switch (msg->header.message_type) {
case PDU_SESSION_ESTABLISHMENT_REQUEST: case PDU_SESSION_ESTABLISHMENT_REQUEST:
encode_result = encode_pdu_session_establishment_request( encode_result = encode_pdu_session_establishment_request(
......
oai-cn5g-common-src @ db83907f
Subproject commit 12e0a3977f4ae1672543075e523f0ec9b0a75bf4 Subproject commit db83907f0edcfcb4a9b189decedfd00fa01f98aa
...@@ -159,21 +159,21 @@ add_definitions(-DBSTRLIB_CAN_USE_STL=1 -DBSTRLIB_CAN_USE_IOSTREAM=1 -DBSTRLIB_T ...@@ -159,21 +159,21 @@ add_definitions(-DBSTRLIB_CAN_USE_STL=1 -DBSTRLIB_CAN_USE_IOSTREAM=1 -DBSTRLIB_T
if(STATIC_LINKING) if(STATIC_LINKING)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g -fstack-protector-all -DMALLOC_CHECK_=3 -DINFO_IS_ON=1 -DDEBUG_IS_ON=1 -DTRACE_IS_ON=1 -O0 -fno-omit-frame-pointer") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g -fstack-protector-all -DMALLOC_CHECK_=3 -O0 -fno-omit-frame-pointer")
else (STATIC_LINKING) else (STATIC_LINKING)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g -fstack-protector-all -DMALLOC_CHECK_=3 -DINFO_IS_ON=1 -DDEBUG_IS_ON=1 -DTRACE_IS_ON=1 -O0 -fsanitize=address -fno-omit-frame-pointer") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g -fstack-protector-all -DMALLOC_CHECK_=3 -O0 -fsanitize=address -fno-omit-frame-pointer")
endif(STATIC_LINKING) endif(STATIC_LINKING)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -O2 -fno-omit-frame-pointer -s -DINFO_IS_ON=1 -DDEBUG_IS_ON=1 ") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -O2 -fno-omit-frame-pointer -s ")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS} -g -O2 -DINFO_IS_ON=1 ") set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS} -g -O2 ")
set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS} -Os -s") set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS} -Os -s")
if(STATIC_LINKING) if(STATIC_LINKING)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -std=c++17 -g -fstack-protector-all -DMALLOC_CHECK_=3 -DINFO_IS_ON=1 -DDEBUG_IS_ON=1 -DTRACE_IS_ON=1 -O0 -fno-omit-frame-pointer") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -std=c++17 -g -fstack-protector-all -DMALLOC_CHECK_=3 -O0 -fno-omit-frame-pointer")
else(STATIC_LINKING) else(STATIC_LINKING)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -std=c++17 -g -fstack-protector-all -DMALLOC_CHECK_=3 -DINFO_IS_ON=1 -DDEBUG_IS_ON=1 -DTRACE_IS_ON=1 -O0 -fsanitize=address -fno-omit-frame-pointer") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -std=c++17 -g -fstack-protector-all -DMALLOC_CHECK_=3 -O0 -fsanitize=address -fno-omit-frame-pointer")
endif(STATIC_LINKING) endif(STATIC_LINKING)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -std=c++17 -O2 -fno-omit-frame-pointer -s -DINFO_IS_ON=1 -DDEBUG_IS_ON=1") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -std=c++17 -O2 -fno-omit-frame-pointer -s ")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} -std=c++17 -g -O2 -DINFO_IS_ON=1") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} -std=c++17 -g -O2 ")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS} -std=c++17 -Os -s") set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS} -std=c++17 -Os -s")
......
...@@ -110,6 +110,7 @@ int main(int argc, char** argv) { ...@@ -110,6 +110,7 @@ int main(int argc, char** argv) {
// Config // Config
smf_cfg.load(Options::getlibconfigConfig()); smf_cfg.load(Options::getlibconfigConfig());
smf_cfg.display(); smf_cfg.display();
Logger::set_level(smf_cfg.log_level);
// Inter-task Interface // Inter-task Interface
itti_inst = new itti_mw(); itti_inst = new itti_mw();
......
...@@ -254,6 +254,16 @@ int smf_config::load(const string& config_file) { ...@@ -254,6 +254,16 @@ int smf_config::load(const string& config_file) {
"%s : %s, using defaults", nfex.what(), nfex.getPath()); "%s : %s, using defaults", nfex.what(), nfex.getPath());
} }
// Log Level
try {
std::string string_level;
smf_cfg.lookupValue(SMF_CONFIG_STRING_LOG_LEVEL, string_level);
log_level = spdlog::level::from_str(string_level);
} catch (const SettingNotFoundException& nfex) {
Logger::smf_app().error(
"%s : %s, using defaults", nfex.what(), nfex.getPath());
}
// FQDN // FQDN
try { try {
smf_cfg.lookupValue(SMF_CONFIG_STRING_FQDN_DNS, fqdn); smf_cfg.lookupValue(SMF_CONFIG_STRING_FQDN_DNS, fqdn);
...@@ -1176,6 +1186,9 @@ void smf_config::display() { ...@@ -1176,6 +1186,9 @@ void smf_config::display() {
index++; index++;
} }
} }
Logger::smf_app().info(
"- Log Level will be .......: %s",
spdlog::level::to_string_view(log_level));
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
......
...@@ -166,6 +166,8 @@ ...@@ -166,6 +166,8 @@
#define SMF_MAX_ALLOCATED_PDN_ADDRESSES 1024 #define SMF_MAX_ALLOCATED_PDN_ADDRESSES 1024
#define SMF_CONFIG_STRING_LOG_LEVEL "LOG_LEVEL"
namespace smf { namespace smf {
typedef struct interface_cfg_s { typedef struct interface_cfg_s {
...@@ -220,6 +222,7 @@ class smf_config { ...@@ -220,6 +222,7 @@ class smf_config {
/* Reader/writer lock for this configuration */ /* Reader/writer lock for this configuration */
std::mutex m_rw_lock; std::mutex m_rw_lock;
std::string pid_dir; std::string pid_dir;
spdlog::level::level_enum log_level;
unsigned int instance = 0; unsigned int instance = 0;
std::string fqdn = {}; std::string fqdn = {};
......
...@@ -268,11 +268,11 @@ bool smf_n1::create_n1_pdu_session_establishment_accept( ...@@ -268,11 +268,11 @@ bool smf_n1::create_n1_pdu_session_establishment_accept(
bytes = nas_message_encode( bytes = nas_message_encode(
data, &nas_msg, sizeof(data) /*don't know the size*/, nullptr); data, &nas_msg, sizeof(data) /*don't know the size*/, nullptr);
#if DEBUG_IS_ON
Logger::smf_n1().debug("Buffer Data: "); Logger::smf_n1().debug("Buffer Data: ");
if (Logger::should_log(spdlog::level::debug)) {
for (int i = 0; i < bytes; i++) printf("%02x ", data[i]); for (int i = 0; i < bytes; i++) printf("%02x ", data[i]);
printf(" (bytes %d)\n", bytes); printf(" (bytes %d)\n", bytes);
#endif }
if (bytes > 0) { if (bytes > 0) {
std::string n1Message((char*) data, bytes); std::string n1Message((char*) data, bytes);
...@@ -367,11 +367,11 @@ bool smf_n1::create_n1_pdu_session_establishment_reject( ...@@ -367,11 +367,11 @@ bool smf_n1::create_n1_pdu_session_establishment_reject(
bytes = nas_message_encode( bytes = nas_message_encode(
data, &nas_msg, sizeof(data) /*don't know the size*/, nullptr); data, &nas_msg, sizeof(data) /*don't know the size*/, nullptr);
#if DEBUG_IS_ON
Logger::smf_n1().debug("Buffer Data: "); Logger::smf_n1().debug("Buffer Data: ");
if (Logger::should_log(spdlog::level::debug)) {
for (int i = 0; i < bytes; i++) printf("%02x ", data[i]); for (int i = 0; i < bytes; i++) printf("%02x ", data[i]);
printf(" (bytes %d)\n", bytes); printf(" (bytes %d)\n", bytes);
#endif }
if (bytes > 0) { if (bytes > 0) {
std::string n1Message((char*) data, bytes); std::string n1Message((char*) data, bytes);
...@@ -503,11 +503,11 @@ bool smf_n1::create_n1_pdu_session_modification_command( ...@@ -503,11 +503,11 @@ bool smf_n1::create_n1_pdu_session_modification_command(
bytes = nas_message_encode( bytes = nas_message_encode(
data, &nas_msg, sizeof(data) /*don't know the size*/, nullptr); data, &nas_msg, sizeof(data) /*don't know the size*/, nullptr);
#if DEBUG_IS_ON
Logger::smf_n1().debug("Buffer Data: "); Logger::smf_n1().debug("Buffer Data: ");
if (Logger::should_log(spdlog::level::debug)) {
for (int i = 0; i < bytes; i++) printf("%02x ", data[i]); for (int i = 0; i < bytes; i++) printf("%02x ", data[i]);
printf(" (bytes %d)\n", bytes); printf(" (bytes %d)\n", bytes);
#endif }
if (bytes > 0) { if (bytes > 0) {
std::string n1Message((char*) data, bytes); std::string n1Message((char*) data, bytes);
...@@ -645,11 +645,11 @@ bool smf_n1::create_n1_pdu_session_modification_command( ...@@ -645,11 +645,11 @@ bool smf_n1::create_n1_pdu_session_modification_command(
bytes = nas_message_encode( bytes = nas_message_encode(
data, &nas_msg, sizeof(data) /*don't know the size*/, nullptr); data, &nas_msg, sizeof(data) /*don't know the size*/, nullptr);
#if DEBUG_IS_ON
Logger::smf_n1().debug("Buffer Data: "); Logger::smf_n1().debug("Buffer Data: ");
if (Logger::should_log(spdlog::level::debug)) {
for (int i = 0; i < bytes; i++) printf("%02x ", data[i]); for (int i = 0; i < bytes; i++) printf("%02x ", data[i]);
printf(" (bytes %d)\n", bytes); printf(" (bytes %d)\n", bytes);
#endif }
if (bytes > 0) { if (bytes > 0) {
std::string n1Message((char*) data, bytes); std::string n1Message((char*) data, bytes);
...@@ -702,11 +702,11 @@ bool smf_n1::create_n1_pdu_session_release_reject( ...@@ -702,11 +702,11 @@ bool smf_n1::create_n1_pdu_session_release_reject(
bytes = nas_message_encode( bytes = nas_message_encode(
data, &nas_msg, sizeof(data) /*don't know the size*/, nullptr); data, &nas_msg, sizeof(data) /*don't know the size*/, nullptr);
#if DEBUG_IS_ON
Logger::smf_n1().debug("Buffer Data: "); Logger::smf_n1().debug("Buffer Data: ");
if (Logger::should_log(spdlog::level::debug)) {
for (int i = 0; i < bytes; i++) printf("%02x ", data[i]); for (int i = 0; i < bytes; i++) printf("%02x ", data[i]);
printf(" (bytes %d)\n", bytes); printf(" (bytes %d)\n", bytes);
#endif }
if (bytes > 0) { if (bytes > 0) {
std::string n1Message((char*) data, bytes); std::string n1Message((char*) data, bytes);
...@@ -771,11 +771,11 @@ bool smf_n1::create_n1_pdu_session_release_command( ...@@ -771,11 +771,11 @@ bool smf_n1::create_n1_pdu_session_release_command(
bytes = nas_message_encode( bytes = nas_message_encode(
data, &nas_msg, sizeof(data) /*don't know the size*/, nullptr); data, &nas_msg, sizeof(data) /*don't know the size*/, nullptr);
#if DEBUG_IS_ON
Logger::smf_n1().debug("Buffer Data: "); Logger::smf_n1().debug("Buffer Data: ");
if (Logger::should_log(spdlog::level::debug)) {
for (int i = 0; i < bytes; i++) printf("%02x ", data[i]); for (int i = 0; i < bytes; i++) printf("%02x ", data[i]);
printf(" (bytes %d)\n", bytes); printf(" (bytes %d)\n", bytes);
#endif }
if (bytes > 0) { if (bytes > 0) {
std::string n1Message((char*) data, bytes); std::string n1Message((char*) data, bytes);
...@@ -838,11 +838,11 @@ bool smf_n1::create_n1_pdu_session_release_command( ...@@ -838,11 +838,11 @@ bool smf_n1::create_n1_pdu_session_release_command(
bytes = nas_message_encode( bytes = nas_message_encode(
data, &nas_msg, sizeof(data) /*don't know the size*/, nullptr); data, &nas_msg, sizeof(data) /*don't know the size*/, nullptr);
#if DEBUG_IS_ON
Logger::smf_n1().debug("Buffer Data: "); Logger::smf_n1().debug("Buffer Data: ");
if (Logger::should_log(spdlog::level::debug)) {
for (int i = 0; i < bytes; i++) printf("%02x ", data[i]); for (int i = 0; i < bytes; i++) printf("%02x ", data[i]);
printf(" (bytes %d)\n", bytes); printf(" (bytes %d)\n", bytes);
#endif }
if (bytes > 0) { if (bytes > 0) {
std::string n1Message((char*) data, bytes); std::string n1Message((char*) data, bytes);
...@@ -878,11 +878,11 @@ int smf_n1::decode_n1_sm_container( ...@@ -878,11 +878,11 @@ int smf_n1::decode_n1_sm_container(
memset(data, 0, data_len + 1); memset(data, 0, data_len + 1);
memcpy((void*) data, (void*) n1_sm_msg.c_str(), data_len); memcpy((void*) data, (void*) n1_sm_msg.c_str(), data_len);
#if DEBUG_IS_ON if (Logger::should_log(spdlog::level::debug)) {
printf("Content: "); printf("Content: ");
for (int i = 0; i < data_len; i++) printf(" %02x ", data[i]); for (int i = 0; i < data_len; i++) printf(" %02x ", data[i]);
printf("\n"); printf("\n");
#endif }
// decode the NAS message // decode the NAS message
decoder_rc = decoder_rc =
......
...@@ -283,11 +283,11 @@ bool smf_n2::create_n2_pdu_session_resource_setup_request_transfer( ...@@ -283,11 +283,11 @@ bool smf_n2::create_n2_pdu_session_resource_setup_request_transfer(
encoded_size); encoded_size);
result = false; result = false;
} else { } else {
#if DEBUG_IS_ON
Logger::smf_n2().debug("N2 SM buffer data: "); Logger::smf_n2().debug("N2 SM buffer data: ");
if (Logger::should_log(spdlog::level::debug)) {
for (int i = 0; i < encoded_size; i++) printf("%02x ", (char) buffer[i]); for (int i = 0; i < encoded_size; i++) printf("%02x ", (char) buffer[i]);
printf(" (%d bytes)\n", (int) encoded_size); printf(" (%d bytes)\n", (int) encoded_size);
#endif }
std::string ngap_message((char*) buffer, encoded_size); std::string ngap_message((char*) buffer, encoded_size);
ngap_msg_str = ngap_message; ngap_msg_str = ngap_message;
...@@ -546,11 +546,11 @@ bool smf_n2::create_n2_pdu_session_resource_setup_request_transfer( ...@@ -546,11 +546,11 @@ bool smf_n2::create_n2_pdu_session_resource_setup_request_transfer(
encoded_size); encoded_size);
result = false; result = false;
} else { } else {
#if DEBUG_IS_ON
Logger::smf_n2().debug("N2 SM buffer data: "); Logger::smf_n2().debug("N2 SM buffer data: ");
if (Logger::should_log(spdlog::level::debug)) {
for (int i = 0; i < encoded_size; i++) printf("%02x ", (char) buffer[i]); for (int i = 0; i < encoded_size; i++) printf("%02x ", (char) buffer[i]);
printf(" (%d bytes)\n", (int) encoded_size); printf(" (%d bytes)\n", (int) encoded_size);
#endif }
std::string ngap_message((char*) buffer, encoded_size); std::string ngap_message((char*) buffer, encoded_size);
ngap_msg_str = ngap_message; ngap_msg_str = ngap_message;
...@@ -809,11 +809,11 @@ bool smf_n2::create_n2_pdu_session_resource_modify_request_transfer( ...@@ -809,11 +809,11 @@ bool smf_n2::create_n2_pdu_session_resource_modify_request_transfer(
encoded_size); encoded_size);
result = false; result = false;
} else { } else {
#if DEBUG_IS_ON
Logger::smf_n2().debug("N2 SM buffer data: "); Logger::smf_n2().debug("N2 SM buffer data: ");
if (Logger::should_log(spdlog::level::debug)) {
for (int i = 0; i < encoded_size; i++) printf("%02x ", (char) buffer[i]); for (int i = 0; i < encoded_size; i++) printf("%02x ", (char) buffer[i]);
printf(" (%d bytes)\n", (int) encoded_size); printf(" (%d bytes)\n", (int) encoded_size);
#endif }
std::string ngap_message((char*) buffer, encoded_size); std::string ngap_message((char*) buffer, encoded_size);
ngap_msg_str = ngap_message; ngap_msg_str = ngap_message;
...@@ -877,11 +877,11 @@ bool smf_n2::create_n2_pdu_session_resource_release_command_transfer( ...@@ -877,11 +877,11 @@ bool smf_n2::create_n2_pdu_session_resource_release_command_transfer(
encoded_size); encoded_size);
result = false; result = false;
} else { } else {
#if DEBUG_IS_ON
Logger::smf_n2().debug("N2 SM buffer data: "); Logger::smf_n2().debug("N2 SM buffer data: ");
if (Logger::should_log(spdlog::level::debug)) {
for (int i = 0; i < encoded_size; i++) printf("%02x ", (char) buffer[i]); for (int i = 0; i < encoded_size; i++) printf("%02x ", (char) buffer[i]);
Logger::smf_n2().debug(" (%d bytes) \n", encoded_size); Logger::smf_n2().debug(" (%d bytes) \n", encoded_size);
#endif }
std::string ngap_message((char*) buffer, encoded_size); std::string ngap_message((char*) buffer, encoded_size);
ngap_msg_str = ngap_message; ngap_msg_str = ngap_message;
...@@ -926,11 +926,11 @@ bool smf_n2::create_n2_pdu_session_resource_release_command_transfer( ...@@ -926,11 +926,11 @@ bool smf_n2::create_n2_pdu_session_resource_release_command_transfer(
encoded_size); encoded_size);
result = false; result = false;
} else { } else {
#if DEBUG_IS_ON
Logger::smf_n2().debug("N2 SM buffer data: "); Logger::smf_n2().debug("N2 SM buffer data: ");
if (Logger::should_log(spdlog::level::debug)) {
for (int i = 0; i < encoded_size; i++) printf("%02x ", (char) buffer[i]); for (int i = 0; i < encoded_size; i++) printf("%02x ", (char) buffer[i]);
Logger::smf_n2().debug(" (%d bytes) \n", encoded_size); Logger::smf_n2().debug(" (%d bytes) \n", encoded_size);
#endif }
std::string ngap_message((char*) buffer, encoded_size); std::string ngap_message((char*) buffer, encoded_size);
ngap_msg_str = ngap_message; ngap_msg_str = ngap_message;
...@@ -1045,11 +1045,11 @@ bool smf_n2::create_n2_pdu_session_resource_modify_response_transfer( ...@@ -1045,11 +1045,11 @@ bool smf_n2::create_n2_pdu_session_resource_modify_response_transfer(
encoded_size); encoded_size);
result = false; result = false;
} else { } else {
#if DEBUG_IS_ON
Logger::smf_n2().debug("N2 SM buffer data: "); Logger::smf_n2().debug("N2 SM buffer data: ");
if (Logger::should_log(spdlog::level::debug)) {
for (int i = 0; i < encoded_size; i++) printf("%02x ", (char) buffer[i]); for (int i = 0; i < encoded_size; i++) printf("%02x ", (char) buffer[i]);
Logger::smf_n2().debug(" (%d bytes) \n", encoded_size); Logger::smf_n2().debug(" (%d bytes) \n", encoded_size);
#endif }
std::string ngap_message((char*) buffer, encoded_size); std::string ngap_message((char*) buffer, encoded_size);
ngap_msg_str = ngap_message; ngap_msg_str = ngap_message;
...@@ -1153,11 +1153,11 @@ bool smf_n2::create_n2_path_switch_request_ack( ...@@ -1153,11 +1153,11 @@ bool smf_n2::create_n2_path_switch_request_ack(
encoded_size); encoded_size);
result = false; result = false;
} else { } else {
#if DEBUG_IS_ON
Logger::smf_n2().debug("N2 SM buffer data: "); Logger::smf_n2().debug("N2 SM buffer data: ");
if (Logger::should_log(spdlog::level::debug)) {
for (int i = 0; i < encoded_size; i++) printf("%02x ", (char) buffer[i]); for (int i = 0; i < encoded_size; i++) printf("%02x ", (char) buffer[i]);
Logger::smf_n2().debug(" (%d bytes) \n", encoded_size); Logger::smf_n2().debug(" (%d bytes) \n", encoded_size);
#endif }
std::string ngap_message((char*) buffer, encoded_size); std::string ngap_message((char*) buffer, encoded_size);
ngap_msg_str = ngap_message; ngap_msg_str = ngap_message;
...@@ -1256,11 +1256,11 @@ bool smf_n2::create_n2_handover_command_transfer( ...@@ -1256,11 +1256,11 @@ bool smf_n2::create_n2_handover_command_transfer(
encoded_size); encoded_size);
result = false; result = false;
} else { } else {
#if DEBUG_IS_ON
Logger::smf_n2().debug("N2 SM buffer data: "); Logger::smf_n2().debug("N2 SM buffer data: ");
if (Logger::should_log(spdlog::level::debug)) {
for (int i = 0; i < encoded_size; i++) printf("%02x ", (char) buffer[i]); for (int i = 0; i < encoded_size; i++) printf("%02x ", (char) buffer[i]);
Logger::smf_n2().debug(" (%d bytes) \n", encoded_size); Logger::smf_n2().debug(" (%d bytes) \n", encoded_size);
#endif }
std::string ngap_message((char*) buffer, encoded_size); std::string ngap_message((char*) buffer, encoded_size);
ngap_msg_str = ngap_message; ngap_msg_str = ngap_message;
...@@ -1314,11 +1314,11 @@ bool smf_n2::create_n2_handover_preparation_unsuccessful_transfer( ...@@ -1314,11 +1314,11 @@ bool smf_n2::create_n2_handover_preparation_unsuccessful_transfer(
encoded_size); encoded_size);
result = false; result = false;
} else { } else {
#if DEBUG_IS_ON
Logger::smf_n2().debug("N2 SM buffer data: "); Logger::smf_n2().debug("N2 SM buffer data: ");
if (Logger::should_log(spdlog::level::debug)) {
for (int i = 0; i < encoded_size; i++) printf("%02x ", (char) buffer[i]); for (int i = 0; i < encoded_size; i++) printf("%02x ", (char) buffer[i]);
Logger::smf_n2().debug(" (%d bytes) \n", encoded_size); Logger::smf_n2().debug(" (%d bytes) \n", encoded_size);
#endif }
std::string ngap_message((char*) buffer, encoded_size); std::string ngap_message((char*) buffer, encoded_size);
ngap_msg_str = ngap_message; ngap_msg_str = ngap_message;
...@@ -1343,11 +1343,11 @@ int smf_n2::decode_n2_sm_information( ...@@ -1343,11 +1343,11 @@ int smf_n2::decode_n2_sm_information(
memset(data, 0, data_len + 1); memset(data, 0, data_len + 1);
memcpy((void*) data, (void*) n2_sm_info.c_str(), data_len); memcpy((void*) data, (void*) n2_sm_info.c_str(), data_len);
#if DEBUG_IS_ON if (Logger::should_log(spdlog::level::debug)) {
printf("Content: "); printf("Content: ");
for (int i = 0; i < data_len; i++) printf(" %02x ", data[i]); for (int i = 0; i < data_len; i++) printf(" %02x ", data[i]);
printf("\n"); printf("\n");
#endif }
// PDUSessionResourceSetupResponseTransfer // PDUSessionResourceSetupResponseTransfer
asn_dec_rval_t rc = asn_decode( asn_dec_rval_t rc = asn_decode(
......
...@@ -1111,7 +1111,6 @@ bool smf_sbi::curl_create_handle( ...@@ -1111,7 +1111,6 @@ bool smf_sbi::curl_create_handle(
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_URL, uri.c_str()); curl_easy_setopt(curl, CURLOPT_URL, uri.c_str());
// curl_easy_setopt(curl, CURLOPT_VERBOSE, 0L);
curl_easy_setopt(curl, CURLOPT_PRIVATE, promise_id); curl_easy_setopt(curl, CURLOPT_PRIVATE, promise_id);
if (method.compare("POST") == 0) if (method.compare("POST") == 0)
curl_easy_setopt(curl, CURLOPT_POST, 1); curl_easy_setopt(curl, CURLOPT_POST, 1);
...@@ -1126,6 +1125,7 @@ bool smf_sbi::curl_create_handle( ...@@ -1126,6 +1125,7 @@ bool smf_sbi::curl_create_handle(
curl_easy_setopt(curl, CURLOPT_INTERFACE, smf_cfg.sbi.if_name.c_str()); curl_easy_setopt(curl, CURLOPT_INTERFACE, smf_cfg.sbi.if_name.c_str());
if (http_version == 2) { if (http_version == 2) {
if (Logger::should_log(spdlog::level::debug))
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
// We use a self-signed test server, skip verification during debugging // We use a self-signed test server, skip verification during debugging
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
...@@ -1171,7 +1171,6 @@ bool smf_sbi::curl_create_handle( ...@@ -1171,7 +1171,6 @@ bool smf_sbi::curl_create_handle(
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_URL, uri.c_str()); curl_easy_setopt(curl, CURLOPT_URL, uri.c_str());
// curl_easy_setopt(curl, CURLOPT_VERBOSE, 0L);
curl_easy_setopt(curl, CURLOPT_PRIVATE, promise_id); curl_easy_setopt(curl, CURLOPT_PRIVATE, promise_id);
if (method.compare("POST") == 0) if (method.compare("POST") == 0)
...@@ -1187,6 +1186,7 @@ bool smf_sbi::curl_create_handle( ...@@ -1187,6 +1186,7 @@ bool smf_sbi::curl_create_handle(
curl_easy_setopt(curl, CURLOPT_INTERFACE, smf_cfg.sbi.if_name.c_str()); curl_easy_setopt(curl, CURLOPT_INTERFACE, smf_cfg.sbi.if_name.c_str());
if (http_version == 2) { if (http_version == 2) {
if (Logger::should_log(spdlog::level::debug))
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
// We use a self-signed test server, skip verification during debugging // We use a self-signed test server, skip verification during debugging
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
...@@ -1235,7 +1235,6 @@ bool smf_sbi::curl_create_handle( ...@@ -1235,7 +1235,6 @@ bool smf_sbi::curl_create_handle(
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_URL, uri.c_str()); curl_easy_setopt(curl, CURLOPT_URL, uri.c_str());
// curl_easy_setopt(curl, CURLOPT_VERBOSE, 0L);
curl_easy_setopt(curl, CURLOPT_PRIVATE, promise_id); curl_easy_setopt(curl, CURLOPT_PRIVATE, promise_id);
if (method.compare("POST") == 0) if (method.compare("POST") == 0)
...@@ -1251,6 +1250,7 @@ bool smf_sbi::curl_create_handle( ...@@ -1251,6 +1250,7 @@ bool smf_sbi::curl_create_handle(
curl_easy_setopt(curl, CURLOPT_INTERFACE, smf_cfg.sbi.if_name.c_str()); curl_easy_setopt(curl, CURLOPT_INTERFACE, smf_cfg.sbi.if_name.c_str());
if (http_version == 2) { if (http_version == 2) {
if (Logger::should_log(spdlog::level::debug))
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
// We use a self-signed test server, skip verification during debugging // We use a self-signed test server, skip verification during debugging
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
...@@ -1297,7 +1297,6 @@ bool smf_sbi::curl_create_handle( ...@@ -1297,7 +1297,6 @@ bool smf_sbi::curl_create_handle(
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_URL, uri.c_str()); curl_easy_setopt(curl, CURLOPT_URL, uri.c_str());
// curl_easy_setopt(curl, CURLOPT_VERBOSE, 0L);
curl_easy_setopt(curl, CURLOPT_PRIVATE, promise_id); curl_easy_setopt(curl, CURLOPT_PRIVATE, promise_id);
if (method.compare("DELETE") == 0) if (method.compare("DELETE") == 0)
...@@ -1309,6 +1308,7 @@ bool smf_sbi::curl_create_handle( ...@@ -1309,6 +1308,7 @@ bool smf_sbi::curl_create_handle(
curl_easy_setopt(curl, CURLOPT_INTERFACE, smf_cfg.sbi.if_name.c_str()); curl_easy_setopt(curl, CURLOPT_INTERFACE, smf_cfg.sbi.if_name.c_str());
if (http_version == 2) { if (http_version == 2) {
if (Logger::should_log(spdlog::level::debug))
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
// We use a self-signed test server, skip verification during debugging // We use a self-signed test server, skip verification during debugging
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
......
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