libpcap; it generates the string at run time on the first call, so that
it's not a constant string - in at least some UNIXes, constant data in a
shared library is kept separate from the library code, and is bound into
applications linked with that library at link time, not at run time, so
a constant string (such as "pcap_version[]") can reflect the version of
the library with which the application was built, not the version with
which it's running.
Document it, in the hopes that vendors will be less likely to omit it
from their libpcaps (unlike "pcap_version[]", which is absent from some
vendors' libpcaps).
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
-# @(#) $Header: /tcpdump/master/libpcap/Makefile.in,v 1.90 2003-02-11 01:46:05 guy Exp $ (LBL)
+# @(#) $Header: /tcpdump/master/libpcap/Makefile.in,v 1.91 2003-02-11 07:40:09 guy Exp $ (LBL)
#
# Various configurable paths (remember to edit Makefile.in, not Makefile)
#
# Various configurable paths (remember to edit Makefile.in, not Makefile)
HDR = pcap.h pcap-int.h pcap-namedb.h pcap-nit.h pcap-pf.h \
ethertype.h gencode.h gnuc.h
GENHDR = \
HDR = pcap.h pcap-int.h pcap-namedb.h pcap-nit.h pcap-pf.h \
ethertype.h gencode.h gnuc.h
GENHDR = \
@rm -f $@
sed -e 's/.*/char pcap_version[] = "&";/' $(srcdir)/VERSION > $@
@rm -f $@
sed -e 's/.*/char pcap_version[] = "&";/' $(srcdir)/VERSION > $@
+version.h: $(srcdir)/VERSION
+ @rm -f $@
+ sed -e 's/\([0-9]*\)\.[0-9]*/#define VERSION_MAJOR \1/' $(srcdir)/VERSION > $@
+ sed -e 's/[0-9]*\.\([0-9]*\)/#define VERSION_MINOR \1/' $(srcdir)/VERSION >> $@
+
bpf_filter.c: $(srcdir)/bpf/net/bpf_filter.c
rm -f bpf_filter.c
ln -s $(srcdir)/bpf/net/bpf_filter.c bpf_filter.c
bpf_filter.c: $(srcdir)/bpf/net/bpf_filter.c
rm -f bpf_filter.c
ln -s $(srcdir)/bpf/net/bpf_filter.c bpf_filter.c
-.\" @(#) $Header: /tcpdump/master/libpcap/Attic/pcap.3,v 1.45 2003-01-16 07:29:15 guy Exp $
+.\" @(#) $Header: /tcpdump/master/libpcap/Attic/pcap.3,v 1.46 2003-02-11 07:40:09 guy Exp $
.\"
.\" Copyright (c) 1994, 1996, 1997
.\" The Regents of the University of California. All rights reserved.
.\"
.\" Copyright (c) 1994, 1996, 1997
.\" The Regents of the University of California. All rights reserved.
void pcap_perror(pcap_t *p, char *prefix)
char *pcap_geterr(pcap_t *p)
char *pcap_strerror(int error)
void pcap_perror(pcap_t *p, char *prefix)
char *pcap_geterr(pcap_t *p)
char *pcap_strerror(int error)
+const char *pcap_lib_version(void)
than the current system.
.PP
.B pcap_major_version()
than the current system.
.PP
.B pcap_major_version()
-returns the major number of the version of the pcap used to write the
-savefile.
-.PP
+returns the major number of the file format of the savefile;
-returns the minor number of the version of the pcap used to write the
-savefile.
+returns the minor number of the file format of the savefile. The
+version number is stored in the header of the savefile.
.PP
.B pcap_file()
returns the standard I/O stream of the ``savefile,'' if a ``savefile''
.PP
.B pcap_file()
returns the standard I/O stream of the ``savefile,'' if a ``savefile''
.BR strerror (1)
isn't available.
.PP
.BR strerror (1)
isn't available.
.PP
+.B pcap_lib_version()
+returns a pointer to a string giving the version number of the libpcap
+library being used.
+.PP
.B pcap_close()
closes the files associated with
.I p
.B pcap_close()
closes the files associated with
.I p
#ifndef lint
static const char rcsid[] =
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/libpcap/pcap.c,v 1.45 2003-01-23 07:24:52 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/libpcap/pcap.c,v 1.46 2003-02-11 07:40:09 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#endif
#ifdef HAVE_CONFIG_H
#endif
#include "pcap-int.h"
#endif
#include "pcap-int.h"
int
pcap_dispatch(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
int
pcap_dispatch(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
pcap_freecode(&p->fcode);
free(p);
}
pcap_freecode(&p->fcode);
free(p);
}
+
+/*
+ * Generate the version string at run time, so that if libpcap is a
+ * shared library, it reflects the version of the library with
+ * which the program calling "pcap_lib_version()" is running, not
+ * the version with which it was built (on at least some UNIXes,
+ * constant data is linked in at build time).
+ */
+const char *
+pcap_lib_version(void)
+{
+ static char version_string[10+1+10+1];
+
+ if (version_string[0] == '\0') {
+ /*
+ * We haven't built the string yet.
+ */
+ snprintf(version_string, sizeof (version_string), "%u.%u",
+ VERSION_MAJOR, VERSION_MINOR);
+ }
+ return (version_string);
+}
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#) $Header: /tcpdump/master/libpcap/pcap.h,v 1.42 2003-02-11 01:46:06 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/libpcap/pcap.h,v 1.43 2003-02-11 07:40:09 guy Exp $ (LBL)
int pcap_findalldevs(pcap_if_t **, char *);
void pcap_freealldevs(pcap_if_t *);
int pcap_findalldevs(pcap_if_t **, char *);
void pcap_freealldevs(pcap_if_t *);
+const char *pcap_lib_version(void);
+
/* XXX this guy lives in the bpf tree */
u_int bpf_filter(struct bpf_insn *, u_char *, u_int, u_int);
int bpf_validate(struct bpf_insn *f, int len);
/* XXX this guy lives in the bpf tree */
u_int bpf_filter(struct bpf_insn *, u_char *, u_int, u_int);
int bpf_validate(struct bpf_insn *f, int len);