[dns-operations] Porting dnscap to NetBSD (Was: announcement of new tool -- dnscap
Mark Andrews
Mark_Andrews at isc.org
Wed May 2 23:31:02 UTC 2007
> On Wed, May 02, 2007 at 09:04:47PM +0000,
> Paul Vixie <paul at vix.com> wrote
> a message of 5 lines which said:
>
> > http://public.oarci.net/tools/dnscap
>
> Some rough parts, it seems. I suggest to adapt it to a portability
> framework like GNU autoconf because, currently, it does not compile
> out of the box on NetBSD 3.1. Here is the patch I had to do:
>
> --- dnscap.c.orig 2007-05-02 23:17:17.000000000 +0200
> +++ dnscap.c 2007-05-02 23:20:32.000000000 +0200
> @@ -38,7 +38,10 @@
> # define _GNU_SOURCE
> #endif
>
> -#include <net/ethernet.h>
> +/* #include <net/ethernet.h> */
> +#include <net/ethertypes.h>
> +#include <net/if.h>
> +#include <net/if_ether.h>
> #include <netinet/in_systm.h>
> #include <netinet/in.h>
> #include <netinet/ip.h>
>
> After that, it starts but crashes at the first DNS packet. No time to
> debug it yet:
>
> (gdb) run
> Starting program: /home/stephane/tmp/dnscap/dnscap
>
> Program received signal SIGBUS, Bus error.
> live_packet (user=0x2060c0 "", hdr=0x20e000, opkt=0xfffffffffffec364 "\b")
> at dnscap.c:935
> 935 if (dns->qr == 0 && dport == dns_port) {
> (gdb) where
> #0 live_packet (user=0x2060c0 "", hdr=0x20e000, opkt=0xfffffffffffec364 "\b"
> )
> at dnscap.c:935
> #1 0x0000000040515ca0 in install_bpf_program () from /usr/lib/libpcap.so.1
> #2 0x00000000405164fc in pcap_dispatch () from /usr/lib/libpcap.so.1
> #3 0x0000000000102bf8 in poll_pcaps () at dnscap.c:689
> #4 0x00000000001017f0 in main (argc=1, argv=0x1) at dnscap.c:226
> #5 0x00000000001014f8 in ___start ()
> (gdb) print dns
> $1 = (const HEADER *) 0xfffffffffffec38e
> (gdb) print *dns
> $2 = {id = 24530, qr = 0, opcode = 0, aa = 0, tc = 0, rd = 1, ra = 0,
> unused = 0, ad = 0, cd = 0, rcode = 0, qdcount = 1, ancount = 0,
> nscount = 0, arcount = 0}
Looks like a simple allignment bug. dns is not word (%4) alligned.
--
Mark Andrews, ISC
1 Seymour St., Dundas Valley, NSW 2117, Australia
PHONE: +61 2 9871 4742 INTERNET: Mark_Andrews at isc.org
More information about the dns-operations
mailing list