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() {
not_done = false;
log(new std::string("Closing log"));
log(new std::string("Closing log\n"));
if(inited) {
wait_thread_finish();
flush();

@ -53,7 +53,7 @@ class hss
public:
static hss* get_instance(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 gen_rand(uint8_t rand_[16]);
@ -70,11 +70,7 @@ private:
srslte::byte_buffer_pool *m_pool;
/*Logs*/
srslte::logger_stdout m_logger_stdout;
srslte::logger_file m_logger_file;
srslte::logger *m_logger;
srslte::log_filter m_hss_log;
srslte::log_filter *m_hss_log;
};

@ -66,7 +66,7 @@ class mme:
public:
static mme* get_instance(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();
int get_s1_mme();
void run_thread();
@ -82,11 +82,7 @@ private:
srslte::byte_buffer_pool *m_pool;
/*Logs*/
//srslte::logger_stdout m_logger_stdout;
//srslte::logger_file m_logger_file;
srslte::logger *m_logger;
srslte::log_filter m_s1ap_log;
srslte::log_filter *m_s1ap_log;
};

@ -53,7 +53,7 @@ public:
s1ap();
virtual ~s1ap();
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();
int get_s1_mme();
@ -79,7 +79,8 @@ private:
s1ap_args_t m_s1ap_args;
uint32_t m_plmn;
srslte::byte_buffer_pool *m_pool;
srslte::log *m_s1ap_log;
srslte::logger *m_logger;
srslte::log_filter *m_s1ap_log;
hss *m_hss;
int m_s1mme;

@ -71,18 +71,14 @@ hss::cleanup(void)
}
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*/
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));
m_hss_log.info("Initialized HSS\n");
m_hss_log.console("Initialized HSS\n");
m_hss_log = hss_log;
m_hss_log->info("HSS Initialized\n");
m_hss_log->console("HSS Initialized\n");
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::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;
}
@ -183,11 +179,11 @@ hss::get_k_amf_op(uint64_t imsi, uint8_t *k, uint8_t *amf, uint8_t *op )
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;
}
m_hss_log.console("Found User %015lu\n",imsi);
m_hss_log->console("Found User %015lu\n",imsi);
memcpy(k,k_tmp,16);
memcpy(amf,amf_tmp,2);
memcpy(op,op_tmp,16);

@ -159,7 +159,7 @@ main (int argc,char * argv[] )
/*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")) {
logger = &logger_stdout;
} else {
@ -168,17 +168,29 @@ main (int argc,char * argv[] )
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();
if (mme->init(&args.mme_args, logger)) {
if (mme->init(&args.mme_args, &s1ap_log)) {
cout << "Error initializing MME" << endl;
exit(1);
}
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;
exit(1);
}
mme->start();
while(running) {
@ -188,6 +200,7 @@ main (int argc,char * argv[] )
mme->stop();
mme->cleanup();
cout << "--- exiting ---" << endl;
return 0;
}

@ -70,27 +70,19 @@ mme::cleanup(void)
}
int
mme::init(mme_args_t* args, srslte::logger *logger)
mme::init(mme_args_t* args, srslte::log_filter *s1ap_log)
{
/*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--- 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");
/*Init S1AP*/
if(m_s1ap.init(args->s1ap_args, s1ap_log)){
m_s1ap_log->error("Error initializing MME S1APP\n");
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;
}
@ -127,30 +119,30 @@ mme::run_thread()
int s1mme = m_s1ap.get_s1_mme();
while(m_running)
{
m_s1ap_log.debug("Waiting for SCTP Msg\n");
m_s1ap_log->debug("Waiting for SCTP Msg\n");
pdu->reset();
rd_sz = sctp_recvmsg(s1mme, pdu->msg, sz,(struct sockaddr*) &enb_addr, &fromlen, &sri, &msg_flags);
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){
m_s1ap_log.debug("Socket timeout reached");
m_s1ap_log->debug("Socket timeout reached");
}
else{
if(msg_flags & MSG_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)
{
m_s1ap_log.console("SCTP Association Gracefully Shutdown\n");//TODO
m_s1ap_log->console("SCTP Association Gracefully Shutdown\n");//TODO
}
}
else
{
//Received data
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);
}
}

@ -42,7 +42,7 @@ s1ap::~s1ap()
}
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;
@ -56,6 +56,7 @@ s1ap::init(s1ap_args_t s1ap_args, srslte::log *s1ap_log)
m_s1mme = enb_listen();
m_s1ap_log->info("S1AP Initialized\n");
return 0;
}
@ -89,7 +90,7 @@ s1ap::enb_listen()
struct sockaddr_in s1mme_addr;
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);
if (sock_fd == -1){
m_s1ap_log->console("Could not create SCTP socket\n");

Loading…
Cancel
Save