Lines Matching full:pcap

33 /* Prevent pcap.h from including pcap/bpf.h and causing conflicts */
35 #include <pcap/pcap.h>
36 #include <pcap/dlt.h>
726 pcap_t *pcap; member
892 pcap_t *pcap = ctx->pcap; in traffic_monitor_thread() local
910 log_err("Fail to select on pcap fd and wake fd"); in traffic_monitor_thread()
914 /* This instance of pcap is non-blocking */ in traffic_monitor_thread()
915 packet = pcap_next(pcap, &header); in traffic_monitor_thread()
965 /* Prepare the pcap handle to capture packets.
967 * This pcap is non-blocking and immediate mode is enabled to receive
976 pcap_t *pcap; in traffic_monitor_prepare_pcap() local
980 pcap = pcap_create("any", errbuf); in traffic_monitor_prepare_pcap()
981 if (!pcap) { in traffic_monitor_prepare_pcap()
982 log_err("Failed to open pcap: %s", errbuf); in traffic_monitor_prepare_pcap()
986 r = pcap_set_snaplen(pcap, 1024); in traffic_monitor_prepare_pcap()
988 log_err("Failed to set snaplen: %s", pcap_geterr(pcap)); in traffic_monitor_prepare_pcap()
992 r = pcap_set_immediate_mode(pcap, 1); in traffic_monitor_prepare_pcap()
994 log_err("Failed to set immediate mode: %s", pcap_geterr(pcap)); in traffic_monitor_prepare_pcap()
997 r = pcap_setnonblock(pcap, 1, errbuf); in traffic_monitor_prepare_pcap()
1002 r = pcap_activate(pcap); in traffic_monitor_prepare_pcap()
1004 log_err("Failed to activate pcap: %s", pcap_geterr(pcap)); in traffic_monitor_prepare_pcap()
1008 r = pcap_set_datalink(pcap, DLT_LINUX_SLL2); in traffic_monitor_prepare_pcap()
1010 log_err("Failed to set datalink: %s", pcap_geterr(pcap)); in traffic_monitor_prepare_pcap()
1014 return pcap; in traffic_monitor_prepare_pcap()
1016 pcap_close(pcap); in traffic_monitor_prepare_pcap()
1079 ctx->pcap = traffic_monitor_prepare_pcap(); in traffic_monitor_start()
1080 if (!ctx->pcap) in traffic_monitor_start()
1082 ctx->pcap_fd = pcap_get_selectable_fd(ctx->pcap); in traffic_monitor_start()
1084 log_err("Failed to get pcap fd"); in traffic_monitor_start()
1089 ctx->dumper = pcap_dump_open(ctx->pcap, ctx->pkt_fname); in traffic_monitor_start()
1091 log_err("Failed to open pcap dump: %s", ctx->pkt_fname); in traffic_monitor_start()
1120 pcap_close(ctx->pcap); in traffic_monitor_start()
1133 pcap_close(ctx->pcap); in traffic_monitor_release()