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{

@ -106,13 +106,16 @@ parse_args(all_args_t *args, int argc, char* argv[]) {
("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")
("pcap.enable", bpo::value<bool>(&args->mme_args.s1ap_args.pcap_enable)->default_value(false), "Enable S1AP PCAP")
("pcap.filename", bpo::value<string>(&args->mme_args.s1ap_args.pcap_filename)->default_value("/tmp/epc.pcap"), "PCAP filename")
("log.s1ap_level", bpo::value<string>(&args->log_args.s1ap_level), "MME S1AP log level") ("log.s1ap_level", bpo::value<string>(&args->log_args.s1ap_level), "MME S1AP log level")
("log.s1ap_hex_limit", bpo::value<int>(&args->log_args.s1ap_hex_limit), "MME S1AP log hex dump limit") ("log.s1ap_hex_limit", bpo::value<int>(&args->log_args.s1ap_hex_limit), "MME S1AP log hex dump limit")

@ -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;
if(m_pcap_enable)
{
m_pcap.open(s1ap_args.pcap_filename.c_str());
m_s1ap_log->info("S1AP Initialized\n"); 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
if(m_pcap_enable)
{
m_pcap.close(); 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;
} }
if(m_pcap_enable){
m_pcap.write_s1ap(pdu->msg,pdu->N_bytes); 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