Fixed some issues with the MME and HSS logging.

master
Pedro Alvarez 7 years ago
parent 1621b6e93a
commit 468b0f2581

@ -40,7 +40,7 @@ logger_file::logger_file()
logger_file::~logger_file() { logger_file::~logger_file() {
not_done = false; not_done = false;
log(new std::string("Closing log")); log(new std::string("Closing log\n"));
if(inited) { if(inited) {
wait_thread_finish(); wait_thread_finish();
flush(); flush();

@ -53,7 +53,7 @@ class hss
public: public:
static hss* get_instance(void); static hss* get_instance(void);
static void cleanup(void); static void cleanup(void);
int init(hss_args_t *hss_args, srslte::logger* logger); int init(hss_args_t *hss_args, srslte::log_filter* hss_log);
void get_sqn(uint8_t sqn[6]); void get_sqn(uint8_t sqn[6]);
void gen_rand(uint8_t rand_[16]); void gen_rand(uint8_t rand_[16]);
@ -66,15 +66,11 @@ private:
virtual ~hss(); virtual ~hss();
static hss *m_instance; static hss *m_instance;
uint64_t m_sqn; //48 bits uint64_t m_sqn; //48 bits
srslte::byte_buffer_pool *m_pool; srslte::byte_buffer_pool *m_pool;
/*Logs*/ /*Logs*/
srslte::logger_stdout m_logger_stdout; srslte::log_filter *m_hss_log;
srslte::logger_file m_logger_file;
srslte::logger *m_logger;
srslte::log_filter m_hss_log;
}; };

@ -66,7 +66,7 @@ class mme:
public: public:
static mme* get_instance(void); static mme* get_instance(void);
static void cleanup(void); static void cleanup(void);
int init(mme_args_t* args, srslte::logger *logger); int init(mme_args_t* args, srslte::log_filter *s1ap_log);
void stop(); void stop();
int get_s1_mme(); int get_s1_mme();
void run_thread(); void run_thread();
@ -82,11 +82,7 @@ private:
srslte::byte_buffer_pool *m_pool; srslte::byte_buffer_pool *m_pool;
/*Logs*/ /*Logs*/
//srslte::logger_stdout m_logger_stdout; srslte::log_filter *m_s1ap_log;
//srslte::logger_file m_logger_file;
srslte::logger *m_logger;
srslte::log_filter m_s1ap_log;
}; };

@ -53,7 +53,7 @@ public:
s1ap(); s1ap();
virtual ~s1ap(); virtual ~s1ap();
int enb_listen(); int enb_listen();
int init(s1ap_args_t s1ap_args, srslte::log *s1ap_log); int init(s1ap_args_t s1ap_args, srslte::log_filter *s1ap_log);
void stop(); void stop();
int get_s1_mme(); int get_s1_mme();
@ -79,7 +79,8 @@ private:
s1ap_args_t m_s1ap_args; s1ap_args_t m_s1ap_args;
uint32_t m_plmn; uint32_t m_plmn;
srslte::byte_buffer_pool *m_pool; srslte::byte_buffer_pool *m_pool;
srslte::log *m_s1ap_log; srslte::logger *m_logger;
srslte::log_filter *m_s1ap_log;
hss *m_hss; hss *m_hss;
int m_s1mme; int m_s1mme;

@ -71,18 +71,14 @@ hss::cleanup(void)
} }
int int
hss::init(hss_args_t *hss_args, srslte::logger *logger) hss::init(hss_args_t *hss_args, srslte::log_filter *hss_log)
{ {
/*Init loggers*/ /*Init loggers*/
m_logger=logger;
m_hss_log.init("HSS", m_logger);
m_hss_log.set_level(srslte::LOG_LEVEL_DEBUG);
m_hss_log.set_hex_limit(32);
srand(time(NULL)); srand(time(NULL));
m_hss_log.info("Initialized HSS\n"); m_hss_log = hss_log;
m_hss_log.console("Initialized HSS\n"); m_hss_log->info("HSS Initialized\n");
m_hss_log->console("HSS Initialized\n");
return 0; return 0;
} }
@ -169,7 +165,7 @@ hss::gen_auth_info_answer_milenage(uint64_t imsi, uint8_t *k_asme, uint8_t *autn
} }
std::cout<<std::endl; std::cout<<std::endl;
//std::string autn_str = ss.str(); //std::string autn_str = ss.str();
//m_hss_log.console("AUTN: %s", autn_str.c_str()); //m_hss_log->console("AUTN: %s", autn_str.c_str());
return true; return true;
} }
@ -183,11 +179,11 @@ hss::get_k_amf_op(uint64_t imsi, uint8_t *k, uint8_t *amf, uint8_t *op )
if(imsi != 1010123456789) if(imsi != 1010123456789)
{ {
m_hss_log.console("Usernot found. IMSI: %015lu\n",imsi); m_hss_log->console("User not found. IMSI: %015lu\n",imsi);
return false; return false;
} }
m_hss_log.console("Found User %015lu\n",imsi); m_hss_log->console("Found User %015lu\n",imsi);
memcpy(k,k_tmp,16); memcpy(k,k_tmp,16);
memcpy(amf,amf_tmp,2); memcpy(amf,amf_tmp,2);
memcpy(op,op_tmp,16); memcpy(op,op_tmp,16);

@ -159,7 +159,7 @@ main (int argc,char * argv[] )
/*Init logger*/ /*Init logger*/
args.log_args.filename = std::string("/tmp/epc.log"); //FIXME args.log_args.filename = std::string("/tmp/epc.log");
if (!args.log_args.filename.compare("stdout")) { if (!args.log_args.filename.compare("stdout")) {
logger = &logger_stdout; logger = &logger_stdout;
} else { } else {
@ -168,17 +168,29 @@ main (int argc,char * argv[] )
logger = &logger_file; logger = &logger_file;
} }
srslte::log_filter s1ap_log;
s1ap_log.init("S1AP",logger);
s1ap_log.set_level(srslte::LOG_LEVEL_DEBUG);
s1ap_log.set_hex_limit(32);
srslte::log_filter hss_log;
hss_log.init("HSS ",logger);
hss_log.set_level(srslte::LOG_LEVEL_DEBUG);
hss_log.set_hex_limit(32);
mme *mme = mme::get_instance(); mme *mme = mme::get_instance();
if (mme->init(&args.mme_args, logger)) { if (mme->init(&args.mme_args, &s1ap_log)) {
cout << "Error initializing MME" << endl; cout << "Error initializing MME" << endl;
exit(1); exit(1);
} }
hss *hss = hss::get_instance(); hss *hss = hss::get_instance();
if (hss->init(&args.hss_args,logger)) { if (hss->init(&args.hss_args,&hss_log)) {
cout << "Error initializing HSS" << endl; cout << "Error initializing HSS" << endl;
exit(1); exit(1);
} }
mme->start(); mme->start();
while(running) { while(running) {
@ -187,7 +199,8 @@ main (int argc,char * argv[] )
mme->stop(); mme->stop();
mme->cleanup(); mme->cleanup();
cout << "--- exiting ---" << endl; cout << "--- exiting ---" << endl;
return 0; return 0;
} }

@ -70,27 +70,19 @@ mme::cleanup(void)
} }
int int
mme::init(mme_args_t* args, srslte::logger *logger) mme::init(mme_args_t* args, srslte::log_filter *s1ap_log)
{ {
/*Init loggers*/
/* /*Init S1AP*/
if (!args->log_args.filename.compare("stdout")) { if(m_s1ap.init(args->s1ap_args, s1ap_log)){
m_logger = &m_logger_stdout; m_s1ap_log->error("Error initializing MME S1APP\n");
} else {
m_logger_file.init(args->log_args.filename);
m_logger_file.log("\n--- Software Radio Systems MME log ---\n\n");
m_logger = &m_logger_file;
}
*/
m_s1ap_log.init("S1AP", m_logger);
m_s1ap_log.set_level(srslte::LOG_LEVEL_DEBUG);
m_s1ap_log.set_hex_limit(32);
if(m_s1ap.init(args->s1ap_args, &m_s1ap_log)){
m_s1ap_log.error("Error initializing MME S1APP\n");
exit(-1); exit(-1);
} }
m_s1ap_log.info("Initialized S1-MME\n");
m_s1ap_log.console("Initialized S1-MME\n"); /*Init logger*/
m_s1ap_log = s1ap_log;
m_s1ap_log->info("MME Initialized\n");
m_s1ap_log->console("MME Initialized\n");
return 0; return 0;
} }
@ -127,30 +119,30 @@ mme::run_thread()
int s1mme = m_s1ap.get_s1_mme(); int s1mme = m_s1ap.get_s1_mme();
while(m_running) while(m_running)
{ {
m_s1ap_log.debug("Waiting for SCTP Msg\n"); m_s1ap_log->debug("Waiting for SCTP Msg\n");
pdu->reset(); pdu->reset();
rd_sz = sctp_recvmsg(s1mme, pdu->msg, sz,(struct sockaddr*) &enb_addr, &fromlen, &sri, &msg_flags); rd_sz = sctp_recvmsg(s1mme, pdu->msg, sz,(struct sockaddr*) &enb_addr, &fromlen, &sri, &msg_flags);
if (rd_sz == -1 && errno != EAGAIN){ if (rd_sz == -1 && errno != EAGAIN){
m_s1ap_log.error("Error reading from SCTP socket: %s", strerror(errno)); m_s1ap_log->error("Error reading from SCTP socket: %s", strerror(errno));
} }
else if (rd_sz == -1 && errno == EAGAIN){ else if (rd_sz == -1 && errno == EAGAIN){
m_s1ap_log.debug("Socket timeout reached"); m_s1ap_log->debug("Socket timeout reached");
} }
else{ else{
if(msg_flags & MSG_NOTIFICATION) if(msg_flags & MSG_NOTIFICATION)
{ {
//Received notification //Received notification
m_s1ap_log.console("SCTP Notification %d\n", ((union sctp_notification*)pdu->msg)->sn_header.sn_type); m_s1ap_log->console("SCTP Notification %d\n", ((union sctp_notification*)pdu->msg)->sn_header.sn_type);
if (((union sctp_notification*)pdu->msg)->sn_header.sn_type == SCTP_SHUTDOWN_EVENT) if (((union sctp_notification*)pdu->msg)->sn_header.sn_type == SCTP_SHUTDOWN_EVENT)
{ {
m_s1ap_log.console("SCTP Association Gracefully Shutdown\n");//TODO m_s1ap_log->console("SCTP Association Gracefully Shutdown\n");//TODO
} }
} }
else else
{ {
//Received data //Received data
pdu->N_bytes = rd_sz; pdu->N_bytes = rd_sz;
m_s1ap_log.info("Received S1AP msg. Size: %d\n", pdu->N_bytes); m_s1ap_log->info("Received S1AP msg. Size: %d\n", pdu->N_bytes);
m_s1ap.handle_s1ap_rx_pdu(pdu,&sri); m_s1ap.handle_s1ap_rx_pdu(pdu,&sri);
} }
} }

@ -42,9 +42,9 @@ s1ap::~s1ap()
} }
int int
s1ap::init(s1ap_args_t s1ap_args, srslte::log *s1ap_log) s1ap::init(s1ap_args_t s1ap_args, srslte::log_filter *s1ap_log)
{ {
m_s1ap_args = s1ap_args; m_s1ap_args = s1ap_args;
srslte::s1ap_mccmnc_to_plmn(s1ap_args.mcc, s1ap_args.mnc, &m_plmn); srslte::s1ap_mccmnc_to_plmn(s1ap_args.mcc, s1ap_args.mnc, &m_plmn);
@ -56,6 +56,7 @@ s1ap::init(s1ap_args_t s1ap_args, srslte::log *s1ap_log)
m_s1mme = enb_listen(); m_s1mme = enb_listen();
m_s1ap_log->info("S1AP Initialized\n");
return 0; return 0;
} }
@ -89,7 +90,7 @@ s1ap::enb_listen()
struct sockaddr_in s1mme_addr; struct sockaddr_in s1mme_addr;
struct sctp_event_subscribe evnts; struct sctp_event_subscribe evnts;
m_s1ap_log->console("Initializing S1-MME\n"); m_s1ap_log->info("S1-MME Initializing\n");
sock_fd = socket (AF_INET, SOCK_SEQPACKET, IPPROTO_SCTP); sock_fd = socket (AF_INET, SOCK_SEQPACKET, IPPROTO_SCTP);
if (sock_fd == -1){ if (sock_fd == -1){
m_s1ap_log->console("Could not create SCTP socket\n"); m_s1ap_log->console("Could not create SCTP socket\n");

Loading…
Cancel
Save