Subject: Re: [tcpdump-workers] pcap_compile_nopcap() error returns
To: None <tcpdump-workers@tcpdump.org>
From: Michael Richardson <mcr@sandelman.ottawa.on.ca>
List: tech-net
Date: 12/20/2000 17:45:31
  I include all of Guy's message for tech-net readers.

  Let's not change the prototype. Add a new function with a new name.

  yes, rather MS-like... but that's what shared libraries do to you :-(

From: Guy Harris <gharris@flashcom.net>
To: tcpdump-workers@sandelman.ottawa.on.ca
Cc: tcpdump-workers@tcpdump.org
Subject: Re: [tcpdump-workers] pcap_compile_nopcap() error returns
Message-ID: <20001211193517.C349@quadrajet.flashcom.com>
Mime-Version: 1.0
Content-Disposition: inline
User-Agent: Mutt/1.2.4i
In-Reply-To: <20001028050327.41A537E56@starfruit.itojun.org>; from itojun@iijlab.net on Sat, Oct 28, 2000 at 02:03:25PM +0900

On Sat, Oct 28, 2000 at 02:03:25PM +0900, Jun-ichiro itojun Hagino wrote:
> 	with the current code, we have no way for pcap_compile_nopcap() to
> 	get error return code.  the following patch (from netbsd) should allow
> 	us to return error code.  any objections?

As per my other mail, doing so would mean we'd be synced up with NetBSD.

Unfortunately, were FreeBSD or OpenBSD to pick that up, they'd have to
change the *major* version number of libpcap.  I don't know whether
they'd be willing to do that.

(Having just checked in the change to make "pcap_compile_nopcap()" a
wrapper around "pcap_open_dead()" and "pcap_compile()", the change in
question would now just be

Index: gencode.c
===================================================================
RCS file: /tcpdump/master/libpcap/gencode.c,v
retrieving revision 1.137
diff -c -r1.137 gencode.c
*** gencode.c	2000/12/12 03:26:16	1.137
--- gencode.c	2000/12/12 03:34:29
***************
*** 339,345 ****
  int
  pcap_compile_nopcap(int snaplen_arg, int linktype_arg,
  		    struct bpf_program *program,
! 	     char *buf, int optimize, bpf_u_int32 mask)
  {
  	pcap_t *p;
  	int ret;
--- 339,345 ----
  int
  pcap_compile_nopcap(int snaplen_arg, int linktype_arg,
  		    struct bpf_program *program,
! 	     char *buf, int optimize, bpf_u_int32 mask, char *errbuf)
  {
  	pcap_t *p;
  	int ret;
***************
*** 348,353 ****
--- 348,355 ----
  	if (p == NULL)
  		return (-1);
  	ret = pcap_compile(p, program, buf, optimize, mask);
+ 	if (ret < 0)
+ 		strlcpy(errbuf, pcap_geterr(p), PCAP_ERRBUF_SIZE);
  	pcap_close(p);
  	return (ret);
  }

plus the change to "pcap.h" to change the prototype.)
-
This is the TCPDUMP workers list. It is archived at
http://www.tcpdump.org/lists/workers/index.html
To unsubscribe use mailto:tcpdump-workers-request@tcpdump.org?body=unsubscribe