diff --git a/tcpdump-4.0.0/interface.h b/tcpdump-4.0.0/interface.h index 1f03123..79ed0c2 100644 --- a/tcpdump-4.0.0/interface.h +++ b/tcpdump-4.0.0/interface.h @@ -370,6 +370,7 @@ extern netdissect_options *gndo; #define Nflag gndo->ndo_Nflag #define Oflag gndo->ndo_Oflag #define pflag gndo->ndo_pflag +#define Pflag gndo->ndo_Pflag #define qflag gndo->ndo_qflag #define Rflag gndo->ndo_Rflag #define sflag gndo->ndo_sflag diff --git a/tcpdump-4.0.0/netdissect.h b/tcpdump-4.0.0/netdissect.h index cd6f2f1..432d455 100644 --- a/tcpdump-4.0.0/netdissect.h +++ b/tcpdump-4.0.0/netdissect.h @@ -107,6 +107,7 @@ struct netdissect_options { int ndo_Oflag; /* run filter code optimizer */ int ndo_dlt; /* if != -1, ask libpcap for the DLT it names*/ int ndo_pflag; /* don't go promiscuous */ + int ndo_Pflag; /* show pcap collected information */ int ndo_Cflag; /* rotate dump files after this many bytes */ int ndo_Cflag_count; /* Keep track of which file number we're writing */ diff --git a/tcpdump-4.0.0/tcpdump.1 b/tcpdump-4.0.0/tcpdump.1 index 50efc31..dd2660f 100644 --- a/tcpdump-4.0.0/tcpdump.1 +++ b/tcpdump-4.0.0/tcpdump.1 @@ -29,7 +29,7 @@ tcpdump \- dump traffic on a network .na .B tcpdump [ -.B \-AdDefIKlLnNOpqRStuUvxX +.B \-AdDefIKlLnNOpPqRStuUvxX ] [ .B \-B .I buffer_size @@ -392,6 +392,9 @@ Note that the interface might be in promiscuous mode for some other reason; hence, `-p' cannot be used as an abbreviation for `ether host {local-hw-addr} or ether broadcast'. .TP +.B \-P +Show pcap collected information (interface where the packet was captured, direction, etc). Linux only. +.TP .B \-q Quick (quiet?) output. Print less protocol information so output diff --git a/tcpdump-4.0.0/tcpdump.c b/tcpdump-4.0.0/tcpdump.c index 4328b30..8dea4b1 100644 --- a/tcpdump-4.0.0/tcpdump.c +++ b/tcpdump-4.0.0/tcpdump.c @@ -66,6 +66,7 @@ extern int SIZE_BUF; #include #include #include +#include #ifndef WIN32 #include #include @@ -535,7 +536,7 @@ main(int argc, char **argv) opterr = 0; while ( - (op = getopt(argc, argv, "aA" B_FLAG "c:C:d" D_FLAG "eE:fF:G:i:" I_FLAG "KlLm:M:nNOpqr:Rs:StT:u" U_FLAG "vw:W:xXy:Yz:Z:")) != -1) + (op = getopt(argc, argv, "aA" B_FLAG "c:C:d" D_FLAG "eE:fF:G:i:" I_FLAG "KlLm:M:nNOpPqr:Rs:StT:u" U_FLAG "vw:W:xXy:Yz:Z:")) != -1) switch (op) { case 'a': @@ -727,6 +728,10 @@ main(int argc, char **argv) ++pflag; break; + case 'P': + ++Pflag; + break; + case 'q': ++qflag; ++suppress_default_print; @@ -1493,6 +1498,20 @@ print_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp) ++infodelay; ts_print(&h->ts); +#ifdef PF_PACKET + if(Pflag){ + char ifname[IFNAMSIZ]; + if(if_indextoname(h->ifindex, ifname) != NULL){ + if(h->direction == PCAP_D_OUT) + (void)printf("device %s, direction OUT: ", + ifname); + else + (void)printf("device %s, direction IN: ", + ifname); + } + } +#endif + print_info = (struct print_info *)user; /* @@ -1672,7 +1691,7 @@ usage(void) #endif /* WIN32 */ #endif /* HAVE_PCAP_LIB_VERSION */ (void)fprintf(stderr, -"Usage: %s [-aAd" D_FLAG "ef" I_FLAG "KlLnNOpqRStu" U_FLAG "vxX]" B_FLAG_USAGE " [ -c count ]\n", program_name); +"Usage: %s [-aAd" D_FLAG "ef" I_FLAG "KlLnNOpPqRStu" U_FLAG "vxX]" B_FLAG_USAGE " [ -c count ]\n", program_name); (void)fprintf(stderr, "\t\t[ -C file_size ] [ -E algo:secret ] [ -F file ] [ -G seconds ]\n"); (void)fprintf(stderr,