Added config option to enable pcap.

master
Pedro Alvarez 6 years ago
parent ba5708dc60
commit b89ad628e2

@ -45,8 +45,21 @@ db_file = user_db.csv
##################################################################### #####################################################################
[spgw] [spgw]
gtpu_bind_addr=127.0.1.100 gtpu_bind_addr = 127.0.1.100
sgi_if_addr=172.16.0.1 sgi_if_addr = 172.16.0.1
####################################################################
# PCAP configuration
#
# Enable PCAP tracing of S1AP packets
#
# enable: Enable or disable the PCAP.
# filename: File name where to save the PCAP.
#
####################################################################
[pcap]
enable = false
filename = /tmp/epc.pcap
#################################################################### ####################################################################
# Log configuration # Log configuration

@ -128,6 +128,7 @@ private:
mme_gtpc *m_mme_gtpc; mme_gtpc *m_mme_gtpc;
//PCAP //PCAP
bool m_pcap_enable;
srslte::s1ap_pcap m_pcap; srslte::s1ap_pcap m_pcap;
}; };

@ -93,6 +93,8 @@ typedef struct{
std::string mme_name; std::string mme_name;
std::string dns_addr; std::string dns_addr;
std::string mme_apn; std::string mme_apn;
bool pcap_enable;
std::string pcap_filename;
} s1ap_args_t; } s1ap_args_t;
typedef struct{ typedef struct{

@ -100,35 +100,38 @@ parse_args(all_args_t *args, int argc, char* argv[]) {
bpo::options_description common("Configuration options"); bpo::options_description common("Configuration options");
common.add_options() common.add_options()
("mme.mme_code", bpo::value<string>(&mme_code)->default_value("0x01"), "MME Code") ("mme.mme_code", bpo::value<string>(&mme_code)->default_value("0x01"), "MME Code")
("mme.name", bpo::value<string>(&mme_name)->default_value("srsmme01"), "MME Name") ("mme.name", bpo::value<string>(&mme_name)->default_value("srsmme01"), "MME Name")
("mme.mme_group", bpo::value<string>(&mme_group)->default_value("0x01"), "Cell ID") ("mme.mme_group", bpo::value<string>(&mme_group)->default_value("0x01"), "Cell ID")
("mme.tac", bpo::value<string>(&tac)->default_value("0x0"), "Tracking Area Code") ("mme.tac", bpo::value<string>(&tac)->default_value("0x0"), "Tracking Area Code")
("mme.mcc", bpo::value<string>(&mcc)->default_value("001"), "Mobile Country Code") ("mme.mcc", bpo::value<string>(&mcc)->default_value("001"), "Mobile Country Code")
("mme.mnc", bpo::value<string>(&mnc)->default_value("01"), "Mobile Network Code") ("mme.mnc", bpo::value<string>(&mnc)->default_value("01"), "Mobile Network Code")
("mme.mme_bind_addr", bpo::value<string>(&mme_bind_addr)->default_value("127.0.0.1"),"IP address of MME for S1 connnection") ("mme.mme_bind_addr", bpo::value<string>(&mme_bind_addr)->default_value("127.0.0.1"), "IP address of MME for S1 connnection")
("mme.dns_addr", bpo::value<string>(&dns_addr)->default_value("8.8.8.8"),"IP address of the DNS server for the UEs") ("mme.dns_addr", bpo::value<string>(&dns_addr)->default_value("8.8.8.8"), "IP address of the DNS server for the UEs")
("mme.apn", bpo::value<string>(&mme_apn)->default_value(""), "Set Access Point Name (APN) for data services") ("mme.apn", bpo::value<string>(&mme_apn)->default_value(""), "Set Access Point Name (APN) for data services")
("hss.db_file", bpo::value<string>(&hss_db_file)->default_value("ue_db.csv"),".csv file that stores UE's keys") ("hss.db_file", bpo::value<string>(&hss_db_file)->default_value("ue_db.csv"), ".csv file that stores UE's keys")
("hss.auth_algo", bpo::value<string>(&hss_auth_algo)->default_value("milenage"),"HSS uthentication algorithm.") ("hss.auth_algo", bpo::value<string>(&hss_auth_algo)->default_value("milenage"), "HSS uthentication algorithm.")
("spgw.gtpu_bind_addr", bpo::value<string>(&spgw_bind_addr)->default_value("127.0.0.1"),"IP address of SP-GW for the S1-U connection") ("spgw.gtpu_bind_addr", bpo::value<string>(&spgw_bind_addr)->default_value("127.0.0.1"), "IP address of SP-GW for the S1-U connection")
("spgw.sgi_if_addr", bpo::value<string>(&sgi_if_addr)->default_value("176.16.0.1"),"IP address of TUN interface for the SGi connection") ("spgw.sgi_if_addr", bpo::value<string>(&sgi_if_addr)->default_value("176.16.0.1"), "IP address of TUN interface for the SGi connection")
("log.s1ap_level", bpo::value<string>(&args->log_args.s1ap_level), "MME S1AP log level") ("pcap.enable", bpo::value<bool>(&args->mme_args.s1ap_args.pcap_enable)->default_value(false), "Enable S1AP PCAP")
("log.s1ap_hex_limit", bpo::value<int>(&args->log_args.s1ap_hex_limit), "MME S1AP log hex dump limit") ("pcap.filename", bpo::value<string>(&args->mme_args.s1ap_args.pcap_filename)->default_value("/tmp/epc.pcap"), "PCAP filename")
("log.gtpc_level", bpo::value<string>(&args->log_args.gtpc_level), "MME GTPC log level")
("log.gtpc_hex_limit", bpo::value<int>(&args->log_args.gtpc_hex_limit), "MME GTPC log hex dump limit") ("log.s1ap_level", bpo::value<string>(&args->log_args.s1ap_level), "MME S1AP log level")
("log.spgw_level", bpo::value<string>(&args->log_args.spgw_level), "SPGW log level") ("log.s1ap_hex_limit", bpo::value<int>(&args->log_args.s1ap_hex_limit), "MME S1AP log hex dump limit")
("log.spgw_hex_limit", bpo::value<int>(&args->log_args.spgw_hex_limit), "SPGW log hex dump limit") ("log.gtpc_level", bpo::value<string>(&args->log_args.gtpc_level), "MME GTPC log level")
("log.gtpc_hex_limit", bpo::value<int>(&args->log_args.gtpc_hex_limit), "MME GTPC log hex dump limit")
("log.spgw_level", bpo::value<string>(&args->log_args.spgw_level), "SPGW log level")
("log.spgw_hex_limit", bpo::value<int>(&args->log_args.spgw_hex_limit), "SPGW log hex dump limit")
//("log.gtpu_level", bpo::value<string>(&args->log.gtpu_level), "GTPU log level") //("log.gtpu_level", bpo::value<string>(&args->log.gtpu_level), "GTPU log level")
("log.hss_level", bpo::value<string>(&args->log_args.hss_level), "HSS log level") ("log.hss_level", bpo::value<string>(&args->log_args.hss_level), "HSS log level")
("log.hss_hex_limit", bpo::value<int>(&args->log_args.hss_hex_limit), "HSS log hex dump limit") ("log.hss_hex_limit", bpo::value<int>(&args->log_args.hss_hex_limit), "HSS log hex dump limit")
//("log.gtpu_hex_limit",bpo::value<int>(&args->log.gtpu_hex_limit), "GTPU log hex dump limit") //("log.gtpu_hex_limit",bpo::value<int>(&args->log.gtpu_hex_limit), "GTPU log hex dump limit")
("log.all_level", bpo::value<string>(&args->log_args.all_level)->default_value("info"), "ALL log level") ("log.all_level", bpo::value<string>(&args->log_args.all_level)->default_value("info"), "ALL log level")
("log.all_hex_limit", bpo::value<int>(&args->log_args.all_hex_limit)->default_value(32), "ALL log hex dump limit") ("log.all_hex_limit", bpo::value<int>(&args->log_args.all_hex_limit)->default_value(32), "ALL log hex dump limit")
("log.filename", bpo::value<string>(&args->log_args.filename)->default_value("/tmp/epc.log"),"Log filename") ("log.filename", bpo::value<string>(&args->log_args.filename)->default_value("/tmp/epc.log"),"Log filename")
; ;
// Positional options - config file location // Positional options - config file location

@ -100,8 +100,12 @@ s1ap::init(s1ap_args_t s1ap_args, srslte::log_filter *s1ap_log, hss_interface_s1
m_s1mme = enb_listen(); m_s1mme = enb_listen();
//Init PCAP //Init PCAP
m_pcap.open("/tmp/epc.pcap"); m_pcap_enable = s1ap_args.pcap_enable;
m_s1ap_log->info("S1AP Initialized\n"); if(m_pcap_enable)
{
m_pcap.open(s1ap_args.pcap_filename.c_str());
m_s1ap_log->info("S1AP Initialized\n");
}
return 0; return 0;
} }
@ -134,7 +138,10 @@ s1ap::stop()
s1ap_ctx_mngmt_proc::cleanup(); s1ap_ctx_mngmt_proc::cleanup();
//PCAP //PCAP
m_pcap.close(); if(m_pcap_enable)
{
m_pcap.close();
}
return; return;
} }
@ -213,7 +220,9 @@ s1ap::handle_s1ap_rx_pdu(srslte::byte_buffer_t *pdu, struct sctp_sndrcvinfo *enb
return false; return false;
} }
m_pcap.write_s1ap(pdu->msg,pdu->N_bytes); if(m_pcap_enable){
m_pcap.write_s1ap(pdu->msg,pdu->N_bytes);
}
switch(rx_pdu.choice_type) { switch(rx_pdu.choice_type) {
case LIBLTE_S1AP_S1AP_PDU_CHOICE_INITIATINGMESSAGE: case LIBLTE_S1AP_S1AP_PDU_CHOICE_INITIATINGMESSAGE:

Loading…
Cancel
Save