Subject: lib/1747: libpcap enhancement
To: None <gnats-bugs@gnats.netbsd.org>
From: Scott Reynolds <scottr@edsi.org>
List: netbsd-bugs
Date: 11/09/1995 00:14:14
>Number:         1747
>Category:       lib
>Synopsis:       Enhancement to add functionality to libpcap
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people (Library Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu Nov  9 01:35:02 1995
>Last-Modified:
>Originator:     Scott Reynolds
>Organization:
>Release:        NetBSD-current, 08-Nov-1995
>Environment:
	N/A
System: NetBSD vulcan 1.0A NetBSD 1.0A (EDSI) #7: Mon Aug 21 13:14:46 CDT 1995 scottr@vulcan:/usr/src/sys/arch/i386/compile/EDSI i386


>Description:
	The pcap code would be infinitely more flexible, at least on
	NetBSD, if it could also be used to inject raw packets onto the
	wire.  Whether such a function actually belongs in a packet
	capture library are debatable, but I believe desirable.  In
	particular it would simplify writing boot servers using odd
	protocols like HP's Remote Maintenance Protocol.  (Apollo had
	another similar protocol, but there isn't a NetBSD/Apollo...)

	Since libpcap uses BPF, security is really no more of an issue
	than it is with BPF.  This comment may not apply equally to
	other implementations of libpcap that depend on, for example,
	Sun's NIT.

>How-To-Repeat:
	N/A

>Fix:
*** pcap.h	1995/11/09 05:35:19	1.1.1.1
--- src/lib/libpcap/pcap.h	1995/11/09 05:54:47
***************
*** 110,115 ****
--- 110,116 ----
  int	pcap_dispatch(pcap_t *, int, pcap_handler, u_char *);
  const u_char*
  	pcap_next(pcap_t *, struct pcap_pkthdr *);
+ int	pcap_inject(pcap_t *, const void *, size_t);
  int	pcap_stats(pcap_t *, struct pcap_stat *);
  int	pcap_setfilter(pcap_t *, struct bpf_program *);
  void	pcap_perror(pcap_t *, char *);
*** pcap-bpf.c	1995/11/09 05:35:18	1.1.1.1
--- src/lib/libpcap/pcap-bpf.c	1995/11/09 05:55:03
***************
*** 126,131 ****
--- 126,137 ----
  	return (n);
  }
  
+ int
+ pcap_inject(pcap_t *p, const void *buf, size_t len)
+ {
+ 	return (write(p->fd, buf, len));
+ }
+ 
  static inline int
  bpf_open(pcap_t *p, char *errbuf)
  {
*** pcap.3	1995/11/09 05:35:19	1.1.1.1
--- src/lib/libpcap/pcap.3	1995/11/09 05:54:27
***************
*** 57,62 ****
--- 57,66 ----
  .ft
  .LP
  .ft B
+ int pcap_inject(pcap_t *p, void *, size_t)
+ .ft
+ .LP
+ .ft B
  int pcap_immediate(pcap_t *p)
  .ft
  .LP
***************
*** 212,217 ****
--- 216,226 ----
  .ft B
  (??? this guy is kind of weird.)
  .ft
+ .PP
+ .B pcap_inject()
+ uses
+ .B write(2)
+ to inject a raw packet through the network interface.
  .PP
  .B pcap_immediate()
  sets ``immediate'' mode.
>Audit-Trail:
>Unformatted: