[dns-operations] [PATCH] dnscap on OS X

Paul Vixie paul at vix.com
Thu May 24 00:17:04 UTC 2007


i'd missed this patch the first time around.  a version has just been
committed, and the version stamp is now V1.0-RC2.

since this change invokes the use of FD_COPY on all systems, it's worth
a round of "will it still compile" even if you last cvsup'd this morning.

re:

> Date: Fri, 18 May 2007 12:56:33 +0200
> From: Mark Santcroos <mark at NLnetLabs.nl>
> User-Agent: Thunderbird 2.0.0.0 (Macintosh/20070326)
> To: Joao Damas <Joao_Damas at isc.org>
> X-Enigmail-Version: 0.95.0
> Cc: dns-operations at lists.oarci.net
> Subject: Re: [dns-operations] [PATCH] dnscap on OS X
> Sender: dns-operations-bounces at lists.oarci.net
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Joao Damas wrote:
> > Mark, have a look at
> > http://osdir.com/ml/network.tcpdump.devel/2006-06/msg00056.html
> 
> The ioctl(2) does the job, but then you loose buffering capabilities.
> 
> I don't have emperical evidence to proof, but under high network load
> that will become a problem probably. (I think my solution works in that
> case)
> 
> Anyway, at this moment I don't have strong preference for either
> solution, I just wanted the thing to compile in the first place :-)
> 
> Patch attached for the ioctl solution.
> 
> Mark
> 
> - --
> Mark Santcroos
> NLnet Labs
> http://www.nlnetlabs.nl/
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.5 (Darwin)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
> 
> iD8DBQFGTYZgvgq6Qtvn644RAlseAJ49XSqY6CwmdXLg1AgMaVO5CrptxACgmDo8
> PXZXNEFUb0K2/ofdI9R2dP4=
> =rICy
> -----END PGP SIGNATURE-----
> Index: dnscap.c
> ===================================================================
> RCS file: /proj/cvsroot/dnscap/dnscap.c,v
> retrieving revision 1.12
> diff -d -u -r1.12 dnscap.c
> --- dnscap.c	16 May 2007 23:10:18 -0000	1.12
> +++ dnscap.c	18 May 2007 10:55:34 -0000
> @@ -32,6 +32,13 @@
>  #include <sys/select.h>
>  #include <sys/socket.h>
>  
> +#ifdef __APPLE__
> +#include <sys/ioctl.h>
> +#include <net/ethernet.h>
> +#include <net/bpf.h>
> +#include <arpa/nameser_compat.h>
> +#endif
> +
>  #ifdef __linux__
>  # define __FAVOR_BSD
>  # define __USE_GNU
> @@ -743,6 +750,9 @@
>  	     mypcap = ISC_LIST_NEXT(mypcap, link))
>  	{
>  		struct bpf_program bpfp;
> +#ifdef __APPLE__
> +		unsigned int ioarg = 1;
> +#endif
>  
>  		errbuf[0] = '\0';
>  		if (pcap_offline == NULL)
> @@ -764,6 +774,9 @@
>  		else if (linktype != mypcap->dlt)
>  			linktype = DLT_LOOP;
>  		mypcap->fdes = pcap_get_selectable_fd(mypcap->pcap);
> +#ifdef __APPLE__
> +		ioctl(mypcap->fdes, BIOCIMMEDIATE, &ioarg);
> +#endif
>  		if (pcap_offline == NULL)
>  			if (pcap_setnonblock(mypcap->pcap, TRUE, errbuf) < 0) {
>  				fprintf(stderr, "%s: pcap_setnonblock: %s\n",
> @@ -792,7 +805,7 @@
>  	int n;
>  
>  	do {
> -		readfds = mypcap_fdset;
> +		FD_COPY(&mypcap_fdset, &readfds);
>  		n = select(pcap_maxfd+1, &readfds, NULL, NULL, NULL);
>  	} while (n < 0 && errno == EINTR && !main_exit);
>  	if (n < 0) {
> _______________________________________________
> dns-operations mailing list
> dns-operations at lists.oarci.net
> http://lists.oarci.net/mailman/listinfo/dns-operations



More information about the dns-operations mailing list