Added config option to enable pcap.

master
Pedro Alvarez 6 years ago
parent ba5708dc60
commit b89ad628e2

@ -48,6 +48,19 @@ db_file = user_db.csv
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{

@ -114,6 +114,9 @@ parse_args(all_args_t *args, int argc, char* argv[]) {
("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")
("log.gtpc_level", bpo::value<string>(&args->log_args.gtpc_level), "MME GTPC log level") ("log.gtpc_level", bpo::value<string>(&args->log_args.gtpc_level), "MME GTPC log level")

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