Skip to content
This repository has been archived by the owner on Jan 22, 2024. It is now read-only.

Commit

Permalink
[SeeRM #6355] Fix sniffer extension on 64bits machines
Browse files Browse the repository at this point in the history
  • Loading branch information
jvazquez-r7 committed Jul 11, 2014
1 parent 2dc7f66 commit 64a0a8b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ $(build_tmp)/libpcap-1.1.1/libpcap.so.1.1.1:
echo '#undef HAVE_ETHER_HOSTTON' >> $(build_tmp)/libpcap-1.1.1/config.h
echo '#define _STDLIB_H this_works_around_malloc_definition_in_grammar_dot_c' >> $(build_tmp)/libpcap-1.1.1/config.h
(cd $(build_tmp)/libpcap-1.1.1 && patch --dry-run -p0 < ../../source/libpcap/pcap_nametoaddr_fix.diff && patch -p0 < ../../source/libpcap/pcap_nametoaddr_fix.diff)
(cd $(build_tmp)/libpcap-1.1.1 && patch --dry-run -p0 < ../../source/libpcap/pcap-linux.diff && patch -p0 < ../../source/libpcap/pcap-linux.diff)
sed -i -e s/pcap-usb-linux.c//g -e s/fad-getad.c/fad-gifc.c/g $(build_tmp)/libpcap-1.1.1/Makefile
sed -i -e s^"CC = gcc"^"CC = gcc $(PCAP_CFLAGS)"^g $(build_tmp)/libpcap-1.1.1/Makefile
$(MAKE) -C $(build_tmp)/libpcap-1.1.1
Expand Down
37 changes: 37 additions & 0 deletions source/libpcap/pcap-linux.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
--- pcap-linux.c 2010-03-11 17:56:54.000000000 -0800
+++ /opt/libpcap-1.1.1/pcap-linux.c 2014-07-11 13:18:06.133832775 -0700
@@ -3378,6 +3378,9 @@
unsigned int tp_snaplen;
unsigned int tp_sec;
unsigned int tp_usec;
+ unsigned int ulong_size = 4;
+ unsigned char *raw_data;
+ struct utsname utsbuf;

h.raw = pcap_get_ring_frame(handle, TP_STATUS_USER);
if (!h.raw)
@@ -3385,11 +3388,19 @@

switch (handle->md.tp_version) {
case TPACKET_V1:
- tp_len = h.h1->tp_len;
- tp_mac = h.h1->tp_mac;
- tp_snaplen = h.h1->tp_snaplen;
- tp_sec = h.h1->tp_sec;
- tp_usec = h.h1->tp_usec;
+ raw_data = (unsigned char *)h.raw;
+ if (uname(&utsbuf) != -1) {
+ if(strstr(utsbuf.machine, "64") == NULL) {
+ ulong_size = 4;
+ } else {
+ ulong_size = 8;
+ }
+ }
+ tp_len = (__u32)raw_data[ulong_size];
+ tp_mac = (__u16)raw_data[ulong_size + 8];
+ tp_snaplen = (__u32)raw_data[ulong_size + 4];
+ tp_sec = (__u32)raw_data[ulong_size + 12];
+ tp_usec = (__u32)raw_data[ulong_size + 16];
break;
#ifdef HAVE_TPACKET2
case TPACKET_V2:

0 comments on commit 64a0a8b

Please sign in to comment.