diff --git a/libpcap-1.0.0/pcap-linux.c b/libpcap-1.0.0/pcap-linux.c index 8161af0..4cb7770 100644 --- a/libpcap-1.0.0/pcap-linux.c +++ b/libpcap-1.0.0/pcap-linux.c @@ -757,6 +757,8 @@ pcap_read_packet(pcap_t *handle, pcap_handler callback, u_char *userdata) from.sll_ifindex != handle->md.ifindex) return 0; + pcap_header.ifindex = from.sll_ifindex; + /* * Do checks based on packet direction. * We can only do this if we're using PF_PACKET; the @@ -778,6 +780,9 @@ pcap_read_packet(pcap_t *handle, pcap_handler callback, u_char *userdata) */ if (handle->direction == PCAP_D_IN) return 0; + + pcap_header.direction = PCAP_D_OUT; + } else { /* * Incoming packet. @@ -785,6 +790,9 @@ pcap_read_packet(pcap_t *handle, pcap_handler callback, u_char *userdata) */ if (handle->direction == PCAP_D_OUT) return 0; + + pcap_header.direction = PCAP_D_IN; + } } #endif @@ -2269,6 +2277,11 @@ pcap_read_linux_mmap(pcap_t *handle, int max_packets, pcap_handler callback, pcaphdr.ts.tv_usec = tp_usec; pcaphdr.caplen = tp_snaplen; pcaphdr.len = tp_len; + pcaphdr.ifindex = sll->sll_ifindex; + if(sll->sll_pkttype == PACKET_OUTGOING) + pcaphdr.direction = PCAP_D_OUT; + else + pcaphdr.direction = PCAP_D_IN; /* if required build in place the sll header*/ if (handle->md.cooked) { diff --git a/libpcap-1.0.0/pcap/pcap.h b/libpcap-1.0.0/pcap/pcap.h index ea18edc..bfc4801 100644 --- a/libpcap-1.0.0/pcap/pcap.h +++ b/libpcap-1.0.0/pcap/pcap.h @@ -155,6 +155,10 @@ struct pcap_pkthdr { struct timeval ts; /* time stamp */ bpf_u_int32 caplen; /* length of portion present */ bpf_u_int32 len; /* length this packet (off wire) */ +#ifdef PF_PACKET + int ifindex; /* interface index (Linux only) */ + pcap_direction_t direction; /* incomming or outgoing */ +#endif }; /*