Added some logging functionality.

master
Pedro Alvarez 7 years ago
parent f93335fa50
commit 0a670d526a

@ -34,13 +34,24 @@
#define MME_H
#include <cstddef>
#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;
};

@ -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;
};

@ -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}

@ -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;

@ -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);
}

@ -32,6 +32,7 @@
#include <sys/socket.h>
#include <netinet/sctp.h>
#include <unistd.h>
#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" <<std::endl; //TODO fix logging

Loading…
Cancel
Save