Subject: Re: writable file descriptors in libpcap
To: None <tech-net@netbsd.org>
From: Jason R Thorpe <thorpej@wasabisystems.com>
List: tech-net
Date: 10/19/2002 15:08:25
On Fri, Oct 18, 2002 at 07:02:35PM -0700, Jason R Thorpe wrote:

 > It is useful to be able to write to the pcap's file descriptor.  This
 > is used by some Ethernet simulators (like the experimenal Ethernet
 > simulator for the SIMH VAX simulator) which run on many operating systems
 > (and thus use the pcap interface to hide most of the OS-specific stuff).
 > 
 > The attached patch to libpcap causes it to open the BPF descriptors for
 > reading and writing.  Any objections?

FYI, I've checked this patch in.

 > 
 > -- 
 >         -- Jason R. Thorpe <thorpej@wasabisystems.com>

 > Index: pcap-bpf.c
 > ===================================================================
 > RCS file: /cvsroot/basesrc/lib/libpcap/pcap-bpf.c,v
 > retrieving revision 1.8
 > diff -c -r1.8 pcap-bpf.c
 > *** pcap-bpf.c	2002/09/22 16:13:01	1.8
 > --- pcap-bpf.c	2002/10/19 02:00:36
 > ***************
 > *** 152,158 ****
 >   	 */
 >   	do {
 >   		(void)snprintf(device, sizeof device, "/dev/bpf%d", n++);
 > ! 		fd = open(device, O_RDONLY);
 >   	} while (fd < 0 && errno == EBUSY);
 >   
 >   	/*
 > --- 152,158 ----
 >   	 */
 >   	do {
 >   		(void)snprintf(device, sizeof device, "/dev/bpf%d", n++);
 > ! 		fd = open(device, O_RDWR);
 >   	} while (fd < 0 && errno == EBUSY);
 >   
 >   	/*


-- 
        -- Jason R. Thorpe <thorpej@wasabisystems.com>