|
Hi. I’m tryin to write a
simple sniffer with libpcap but I have some problems that I can’t be able
to solve and it’s starting to get frustrating. Code: #define FILTER “udp or
tcp” #define PROMISC 1 ... if(pcap_open_live(device,
BUFSIZ, PROMISC, 0, errbuf) == -1) { ��������������������� error handling } if(pcap_lookupnet(device,
&local_net, &netmask, errbuf) == -1) { ��������������������� error handling } if(pcap_compile(p,
&filter_code, TESTFILTER, 0, netmask) == -1) { ��� ����������������� error handling��� } if(pcap_setfilter(p, &filter_code) == -1) { �������������� ������ error handling } After pcap_lookupnet the
program segfaults. I have tested everything with pcap_compile and I can’t
understabd what is wrong. Program received signal
SIGSEGV, Segmentation fault. 0x88208ac in pcap_snapshot () (gdb) And it says there is an error
in pcap_snapshot. If i put a break on
pcap_compile and step through it it looks like this: Breakpoint 1, 0x8821d0c in
pcap_compile () (gdb) ni 0x8821d10 in pcap_compile () (gdb) 0x8821d14 in pcap_compile () (gdb) 0x8821b4c in bpf_filter () (gdb) 0x8821b50 in bpf_filter () (gdb) 0x8821d18 in pcap_compile () (gdb) 0x8821d1c in pcap_compile () (gdb) 0x8821d20 in pcap_compile () (gdb) 0x8821d24 in pcap_compile () (gdb) 0x8821d28 in pcap_compile () (gdb) 0x8821d2c in pcap_compile () (gdb) 0x8821d30 in pcap_compile () (gdb) 0x8821d34 in pcap_compile () (gdb) 0x8821d38 in pcap_compile () (gdb) 0x8821d3c in pcap_compile () (gdb) 0x8821d40 in pcap_compile () (gdb) 0x8821d44 in pcap_compile () (gdb) 0x8821d48 in pcap_compile () (gdb) 0x8821d4c in pcap_compile () (gdb) 0x8821d50 in pcap_compile () (gdb) 0x8821d54 in pcap_compile () (gdb) 0x8b34170 in __DTOR_LIST__ () (gdb) 0x8b34174 in __DTOR_LIST__ () (gdb) 0x8b34128 in __DTOR_LIST__ () (gdb) 0x8b3412c in __DTOR_LIST__ () (gdb) 0x8b34130 in __DTOR_LIST__ () (gdb) Program received signal
SIGBUS, Bus error. 0x82141c4 in _dl_bind () (gdb) Anybody that can see any
errors or can point me in the right direction where to find good info on how I
can write the pcap_compile because it looks like there error is made there or
maybe in the creation of p. Thanks. // Dunceor --- |
- Re: [tcpdump-workers] segfault in pcap_snapshot Karl Sj�dahl
- Re: [tcpdump-workers] segfault in pcap_snapshot Guy Harris
- SV: [tcpdump-workers] segfault in pcap_snapshot Karl Sj�dahl
