Chinna
Chinna

Reputation: 3992

Pcap filter for capturing only rx packets of a particular interface

Trying to capture all rx packets of particular interface(eth0). Need to compile a filter for the same. What should be the filter string?

Upvotes: 1

Views: 529

Answers (1)

pchaigno
pchaigno

Reputation: 13083

You cannot select the direction in the filter, but you can do it at the libpcap level, with the function pcap_setdirection, declared as:

int pcap_setdirection(pcap_t *p, pcap_direction_t d);

typedef enum {
   PCAP_D_INOUT = 0, # To capture both RX and TX, default.
   PCAP_D_IN,        # To capture RX only.
   PCAP_D_OUT        # To capture TX only.
} pcap_direction_t;

Upvotes: 1

Related Questions