From 0a670d526af81390016ea021f39611c4119b4c4a Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Wed, 11 Oct 2017 16:18:47 +0100 Subject: [PATCH] Added some logging functionality. --- srsepc/hdr/mme/mme.h | 18 ++++++++++++++++++ srsepc/hdr/mme/s1ap.h | 5 ++++- srsepc/src/CMakeLists.txt | 1 + srsepc/src/main.cc | 1 + srsepc/src/mme/mme.cc | 13 ++++++++++++- srsepc/src/mme/s1ap.cc | 6 +++++- 6 files changed, 41 insertions(+), 3 deletions(-) diff --git a/srsepc/hdr/mme/mme.h b/srsepc/hdr/mme/mme.h index 7436993da..3749eef2f 100644 --- a/srsepc/hdr/mme/mme.h +++ b/srsepc/hdr/mme/mme.h @@ -34,13 +34,24 @@ #define MME_H #include +#include "srslte/common/logger_file.h" +#include "srslte/common/log_filter.h" #include "s1ap.h" namespace srsepc{ + +typedef struct { + std::string s1ap_level; + std::string all_level; + int s1ap_hex_limit; + std::string filename; +}log_args_t; + typedef struct{ s1ap_args_t s1ap_args; + log_args_t log_args; } all_args_t; @@ -63,6 +74,13 @@ private: virtual ~mme(); static mme *m_instance; s1ap m_s1ap; + + /*Logs*/ + srslte::logger_stdout m_logger_stdout; + srslte::logger_file m_logger_file; + srslte::logger *m_logger; + + srslte::log_filter m_s1ap_log; }; diff --git a/srsepc/hdr/mme/s1ap.h b/srsepc/hdr/mme/s1ap.h index 27e275736..5a3de3ac6 100644 --- a/srsepc/hdr/mme/s1ap.h +++ b/srsepc/hdr/mme/s1ap.h @@ -23,6 +23,7 @@ * and at http://www.gnu.org/licenses/. * */ +#include "srslte/common/log.h" namespace srsepc{ @@ -44,7 +45,7 @@ public: s1ap(); virtual ~s1ap(); int enb_listen(); - int init(s1ap_args_t s1ap_args); + int init(s1ap_args_t s1ap_args, srslte::log *s1ap_log); void stop(); int get_s1_mme(); @@ -58,6 +59,8 @@ private: std::string m_mme_bindx_addr; std::string m_mme_name; + srslte::log *m_log_h; + int m_s1mme; }; diff --git a/srsepc/src/CMakeLists.txt b/srsepc/src/CMakeLists.txt index 47d125a32..11985c134 100644 --- a/srsepc/src/CMakeLists.txt +++ b/srsepc/src/CMakeLists.txt @@ -14,6 +14,7 @@ endif (RPATH) add_executable(srsepc main.cc ) target_link_libraries(srsepc srsepc_mme + srslte_common ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} ${SEC_LIBRARIES} diff --git a/srsepc/src/main.cc b/srsepc/src/main.cc index 67399f9a2..f1809af7f 100644 --- a/srsepc/src/main.cc +++ b/srsepc/src/main.cc @@ -103,6 +103,7 @@ main (int argc,char * argv[] ) args.s1ap_args.mnc = 0x01; args.s1ap_args.mme_bindx_addr="127.0.0.0/24"; + args.log_args.filename = std::string("/tmp/epc.log"); struct sockaddr_in enb_addr; char readbuf[1000]; struct sctp_sndrcvinfo sri; diff --git a/srsepc/src/mme/mme.cc b/srsepc/src/mme/mme.cc index c898d1a73..291077868 100644 --- a/srsepc/src/mme/mme.cc +++ b/srsepc/src/mme/mme.cc @@ -66,7 +66,18 @@ mme::cleanup(void) int mme::init(all_args_t* args) { - if(m_s1ap.init(args->s1ap_args)){ + + /*Init loggers*/ + if (!args->log_args.filename.compare("stdout")) { + m_logger = &m_logger_stdout; + } else { + m_logger_file.init(args->log_args.filename); + m_logger_file.log("\n\n"); + m_logger = &m_logger_file; + } + + m_s1ap_log.init("S1AP", m_logger); + if(m_s1ap.init(args->s1ap_args, &m_s1ap_log)){ std::cout << "Error initializing MME S1APP" << std::endl; exit(-1); } diff --git a/srsepc/src/mme/s1ap.cc b/srsepc/src/mme/s1ap.cc index 2e6fc0b2b..6199fd3e9 100644 --- a/srsepc/src/mme/s1ap.cc +++ b/srsepc/src/mme/s1ap.cc @@ -32,6 +32,7 @@ #include #include #include + #include "mme/s1ap.h" namespace srsepc{ @@ -46,7 +47,7 @@ s1ap::~s1ap() } int -s1ap::init(s1ap_args_t s1ap_args) +s1ap::init(s1ap_args_t s1ap_args, srslte::log *s1ap_log) { m_mme_code = s1ap_args.mme_code ; m_mme_group = s1ap_args.mme_group; @@ -56,6 +57,8 @@ s1ap::init(s1ap_args_t s1ap_args) m_mme_bindx_addr = s1ap_args.mme_bindx_addr; m_mme_name = std::string("SRS MME"); + m_log_h = s1ap_log; + m_s1mme = enb_listen(); return 0; } @@ -83,6 +86,7 @@ s1ap::enb_listen() struct sockaddr_in s1mme_addr;//TODO make this a configurable class memeber. struct sctp_event_subscribe evnts; + m_log_h->info("Initializing S1-MME ..."); sock_fd = socket (AF_INET, SOCK_SEQPACKET, IPPROTO_SCTP); if (sock_fd == -1){ std::cout << "[S1APP] Could not create SCTP socket" <