Subject: writable file descriptors in libpcap
To: None <tech-net@netbsd.org>
From: Jason R Thorpe <thorpej@wasabisystems.com>
List: tech-net
Date: 10/18/2002 19:02:35
--vTUhhhdwRI43FzeR
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

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?

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

--vTUhhhdwRI43FzeR
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=pcap-patch

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);
  
  	/*

--vTUhhhdwRI43FzeR--