mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
Update libpcap to 1.2.1.
This commit is contained in:
@@ -1,3 +1,77 @@
|
||||
Friday December 9, 2011. guy@alum.mit.edu.
|
||||
Summary for 1.2.1 libpcap release
|
||||
Update README file.
|
||||
Fix typoes in README.linux file.
|
||||
Clean up some compiler warnings.
|
||||
Fix Linux compile problems and tests for ethtool.h.
|
||||
Treat Debian/kFreeBSD and GNU/Hurd as systems with GNU
|
||||
toolchains.
|
||||
Support 802.1 QinQ as a form of VLAN in filters.
|
||||
Treat "carp" as equivalent to "vrrp" in filters.
|
||||
Fix code generated for "ip6 protochain".
|
||||
Add some new link-layer header types.
|
||||
Support capturing NetFilter log messages on Linux.
|
||||
Clean up some error messages.
|
||||
Turn off monitor mode on exit for mac80211 interfaces on Linux.
|
||||
Fix problems turning monitor mode on for non-mac80211 interfaces
|
||||
on Linux.
|
||||
Properly fail if /sys/class/net or /proc/net/dev exist but can't
|
||||
be opened.
|
||||
Fail if pcap_activate() is called on an already-activated
|
||||
pcap_t, and add a test program for that.
|
||||
Fix filtering in pcap-ng files.
|
||||
Don't build for PowerPC on Mac OS X Lion.
|
||||
Simplify handling of new DLT_/LINKTYPE_ values.
|
||||
Expand pcap(3PCAP) man page.
|
||||
|
||||
Sunday July 24, 2011. mcr@sandelman.ca.
|
||||
Summary for 1.2 libpcap release
|
||||
All of the changes listed below for 1.1.1 and 1.1.2.
|
||||
Changes to error handling for pcap_findalldevs().
|
||||
Fix the calculation of the frame size in memory-mapped captures.
|
||||
Add a link-layer header type for STANAG 5066 D_PDUs.
|
||||
Add a link-layer type for a variant of 3GPP TS 27.010.
|
||||
Noted real nature of LINKTYPE_ARCNET.
|
||||
Add a link-layer type for DVB-CI.
|
||||
Fix configure-script discovery of VLAN acceleration support.
|
||||
see http://netoptimizer.blogspot.com/2010/09/tcpdump-vs-vlan-tags.html
|
||||
Linux, HP-UX, AIX, NetBSD and OpenBSD compilation/conflict fixes.
|
||||
Protect against including AIX 5.x's <net/bpf.h> having been included.
|
||||
Add DLT_DBUS, for raw D-Bus messages.
|
||||
Treat either EPERM or EACCES as "no soup for you".
|
||||
Changes to permissions on DLPI systems.
|
||||
Add DLT_IEEE802_15_4_NOFCS for 802.15.4 interfaces.
|
||||
|
||||
Fri. August 6, 2010. guy@alum.mit.edu.
|
||||
Summary for 1.1.2 libpcap release
|
||||
Return DLT_ values, not raw LINKTYPE_ values from
|
||||
pcap_datalink() when reading pcap-ng files
|
||||
Add support for "wlan ra" and "wlan ta", to check the RA and TA
|
||||
of WLAN frames that have them
|
||||
Don't crash if "wlan addr{1,2,3,4}" are used without 802.11
|
||||
headers
|
||||
Do filtering on USB and Bluetooth capturing
|
||||
On FreeBSD/SPARC64, use -fPIC - it's apparently necessary
|
||||
Check for valid port numbers (fit in a 16-bit unsigned field) in
|
||||
"port" filters
|
||||
Reject attempts to put savefiles into non-blocking mode
|
||||
Check for "no such device" for the "get the media types" ioctl
|
||||
in *BSD
|
||||
Improve error messages from bpf_open(), and let it do the error
|
||||
handling
|
||||
Return more specific errors from pcap_can_set_rfmon(); fix
|
||||
documentation
|
||||
Update description fetching code for FreeBSD, fix code for
|
||||
OpenBSD
|
||||
Ignore /sys/net/dev files if we get ENODEV for them, not just
|
||||
ENXIO; fixes handling of bonding devices on Linux
|
||||
Fix check for a constant 0 argument to BPF_DIV
|
||||
Use the right version of ar when cross-building
|
||||
Free any filter set on a savefile when the savefile is closed
|
||||
Include the CFLAGS setting when configure was run in the
|
||||
compiler flags
|
||||
Add support for 802.15.4 interfaces on Linux
|
||||
|
||||
Thu. April 1, 2010. guy@alum.mit.edu.
|
||||
Summary for 1.1.1 libpcap release
|
||||
Update CHANGES to reflect more of the changes in 1.1.0.
|
||||
|
||||
279
libpcap/CREDITS
279
libpcap/CREDITS
@@ -1,145 +1,154 @@
|
||||
This file lists people who have contributed to libpcap:
|
||||
|
||||
The current maintainers:
|
||||
Bill Fenner <fenner at research dot att dot com>
|
||||
Fulvio Risso <risso at polito dot it>
|
||||
Guy Harris <guy at alum dot mit dot edu>
|
||||
Hannes Gredler <hannes at juniper dot net>
|
||||
Michael Richardson <mcr at sandelman dot ottawa dot on dot ca>
|
||||
Bill Fenner <fenner at research dot att dot com>
|
||||
Fulvio Risso <risso at polito dot it>
|
||||
Guy Harris <guy at alum dot mit dot edu>
|
||||
Hannes Gredler <hannes at juniper dot net>
|
||||
Michael Richardson <mcr at sandelman dot ottawa dot on dot ca>
|
||||
|
||||
Additional people who have contributed patches:
|
||||
|
||||
Alan Bawden <Alan at LCS dot MIT dot EDU>
|
||||
Albert Chin <china at thewrittenword dot com>
|
||||
Alexander 'Leo' Bergolth <Leo dot Bergolth at wu-wien dot ac dot at>
|
||||
Alexey Kuznetsov <kuznet at ms2 dot inr dot ac dot ru>
|
||||
Alon Bar-Lev <alonbl at sourceforge dot net>
|
||||
Andrew Brown <atatat at atatdot dot net>
|
||||
Antti Kantee <pooka at netbsd dot org>
|
||||
Arien Vijn <arienvijn at sourceforge dot net>
|
||||
Arkadiusz Miskiewicz <misiek at pld dot org dot pl>
|
||||
Armando L. Caro Jr. <acaro at mail dot eecis dot udel dot edu>
|
||||
Assar Westerlund <assar at sics dot se>
|
||||
Brian Ginsbach <ginsbach at cray dot com>
|
||||
Charles M. Hannum <mycroft at netbsd dot org>
|
||||
Chris G. Demetriou <cgd at netbsd dot org>
|
||||
Chris Lightfoot <cwrl at users dot sourceforge dot net>
|
||||
Chris Maynard <Chris dot Maynard at gtech dot com>
|
||||
Chris Pepper <pepper at mail dot reppep dot com>
|
||||
Christian Bell <csbell at myri dot com>
|
||||
Christian Peron <csjp at freebsd dot org>
|
||||
Daniele Orlandi <daniele at orlandi dot com>
|
||||
Darren Reed <darrenr at sun dot com>
|
||||
David Kaelbling <drk at sgi dot com>
|
||||
David Young <dyoung at ojctech dot com>
|
||||
Dean Gaudet <dean at arctic dot org>
|
||||
Don Ebright <Don dot Ebright at compuware dot com>
|
||||
Dug Song <dugsong at monkey dot org>
|
||||
Dustin Spicuzza <dustin at virtualroadside dot com>
|
||||
Eric Anderson <anderse at hpl dot hp dot com>
|
||||
Erik de Castro Lopo <erik dot de dot castro dot lopo at sensorynetworks dot com>
|
||||
Felix Obenhuber <felix at obenhuber dot de>
|
||||
Florent Drouin <Florent dot Drouin at alcatel-lucent dot fr>
|
||||
Franz Schaefer <schaefer at mond dot at>
|
||||
Fulko Hew <fulko dot hew at gmail dot com>
|
||||
Fumiyuki Shimizu <fumifumi at abacustech dot jp>
|
||||
Gianluca Varenni <varenni at netgroup-serv dot polito dot it>
|
||||
Gilbert Hoyek <gil_hoyek at hotmail dot com>
|
||||
Gisle Vanem <gvanem at broadpark dot no>
|
||||
Graeme Hewson <ghewson at cix dot compulink dot co dot uk>
|
||||
Greg Stark <gsstark at mit dot edu>
|
||||
Greg Troxel <gdt at ir dot bbn dot com>
|
||||
Gregor Maier <gregor at net dot in dot tum dot de>
|
||||
Guillaume Pelat <endymion_ at users dot sourceforge dot net>
|
||||
Hagen Paul Pfeifer <hagen at jauu dot net>
|
||||
Hyung Sik Yoon <hsyn at kr dot ibm dot com>
|
||||
Igor Khristophorov <igor at atdot dot org>
|
||||
Jan-Philip Velders <jpv at veldersjes dot net>
|
||||
Jason R. Thorpe <thorpej at netbsd dot org>
|
||||
Javier Achirica <achirica at ttd dot net>
|
||||
Jean Tourrilhes <jt at hpl dot hp dot com>
|
||||
Jean-Louis Charton <Jean-Louis.CHARTON at oikialog dot com>
|
||||
Jefferson Ogata <jogata at nodc dot noaa dot gov>
|
||||
Jesper Peterson <jesper at endace dot com>
|
||||
Joerg Mayer <jmayer at loplof dot de>
|
||||
John Bankier <jbankier at rainfinity dot com>
|
||||
Jon Lindgren <jonl at yubyub dot net>
|
||||
Jon Smirl <jonsmirl at gmail dot com>
|
||||
Juergen Schoenwaelder <schoenw at ibr dot cs dot tu-bs dot de>
|
||||
Jung-uk Kim <jkim at FreeBSD dot org>
|
||||
Kazushi Sugyo <sugyo at pb dot jp dot nec dot com>
|
||||
Klaus Klein <kleink at netbsd dot org>
|
||||
Koryn Grant <koryn at endace dot com>
|
||||
Kris Katterjohn <katterjohn at gmail dot com>
|
||||
Krzysztof Halasa <khc at pm dot waw dot pl>
|
||||
Lorenzo Cavallaro <sullivan at sikurezza dot org>
|
||||
Loris Degioanni <loris at netgroup-serv dot polito dot it>
|
||||
Love Hörnquist-Åstrand <lha at stacken dot kth dot se>
|
||||
Luis Martin Garcia <luis dot mgarc at gmail dot com>
|
||||
Maciej W. Rozycki <macro at ds2 dot pg dot gda dot pl>
|
||||
Marcus Felipe Pereira <marcus at task dot com dot br>
|
||||
Mark C. Brown <mbrown at hp dot com>
|
||||
Mark Pizzolato <List-tcpdump-workers at subscriptions dot pizzolato dot net>
|
||||
Markus Mayer <markus_mayer at sourceforge dot net>
|
||||
Martin Husemann <martin at netbsd dot org>
|
||||
Márton Németh <nm127 at freemail dot hu>
|
||||
Matthew Luckie <mjl at luckie dot org dot nz>
|
||||
Max Laier <max at love2party dot net>
|
||||
Mike Frysinger <vapier at gmail dot com>
|
||||
Mike Kershaw <dragorn at kismetwireless dot net>
|
||||
Mike Wiacek <mike at iroot dot net>
|
||||
Monroe Williams <monroe at pobox dot com>
|
||||
N. Leiten <nleiten at sourceforge dot net>
|
||||
Nicolas Dade <ndade at nsd dot dyndns dot org>
|
||||
Octavian Cerna <tavy at ylabs dot com>
|
||||
Olaf Kirch <okir at caldera dot de>
|
||||
Ollie Wild <aaw at users dot sourceforge dot net>
|
||||
Onno van der Linden <onno at simplex dot nl>
|
||||
Paolo Abeni <paolo dot abeni at email dot it>
|
||||
Patrick Marie <mycroft at virgaria dot org>
|
||||
Patrick McHardy <kaber at trash not net>
|
||||
Paul Mundt <lethal at linux-sh dot org>
|
||||
Pavel Kankovsky <kan at dcit dot cz>
|
||||
Pawel Pokrywka <publicpp at gmail dot com>
|
||||
Peter Fales <peter at fales-lorenz dot net>
|
||||
Peter Jeremy <peter dot jeremy at alcatel dot com dot au>
|
||||
Peter Volkov <pva at gentoo dot org>
|
||||
Phil Wood <cpw at lanl dot gov>
|
||||
Rafal Maszkowski <rzm at icm dot edu dot pl>
|
||||
<rcb-isis at users dot sourceforge dot net>
|
||||
Richard Stearn <richard at rns-stearn dot demon dot co dot uk>
|
||||
Rick Jones <raj at cup dot hp dot com>
|
||||
Robert Edmonds <stu-42 at sourceforge dot net>
|
||||
Roberto Mariani <jelot-tcpdump at jelot dot it>
|
||||
Romain Francoise <rfrancoise at debian dot org>
|
||||
Sagun Shakya <sagun dot shakya at sun dot com>
|
||||
Scott Barron <sb125499 at ohiou dot edu>
|
||||
Scott Gifford <sgifford at tir dot com>
|
||||
Sebastian Krahmer <krahmer at cs dot uni-potsdam dot de>
|
||||
Sebastien Roy <Sebastien dot Roy at Sun dot COM>
|
||||
Sepherosa Ziehau <sepherosa at gmail dot com>
|
||||
Shaun Clowes <delius at progsoc dot uts dot edu dot au>
|
||||
Solomon Peachy <pizza at shaftnet dot org>
|
||||
Stefan Hudson <hudson at mbay dot net>
|
||||
Stephen Donnelly <stephen at endace dot com>
|
||||
Takashi Yamamoto <yamt at mwd dot biglobe dot ne dot jp>
|
||||
Tanaka Shin-ya <zstanaka at archer dot livedoor dot com>
|
||||
Tobias Poschwatta <posch at sourceforge dot net>
|
||||
Tony Li <tli at procket dot com>
|
||||
Torsten Landschoff <torsten at debian dot org>
|
||||
Uns Lider <unslider at miranda dot org>
|
||||
Uwe Girlich <Uwe dot Girlich at philosys dot de>
|
||||
Wesley Shields <wxs at FreeBSD dot org>
|
||||
Xianjie Zhang <xzhang at cup dot hp dot com>
|
||||
Xin Li <delphij at FreeBSD dot org>
|
||||
Yen Yen Lim
|
||||
Yvan Vanhullebus <vanhu at sourceforge dot net>
|
||||
Yoann Vandoorselaere <yoann at prelude-ids dot org>
|
||||
Alan Bawden <Alan at LCS dot MIT dot EDU>
|
||||
Albert Chin <china at thewrittenword dot com>
|
||||
Alexander 'Leo' Bergolth <Leo dot Bergolth at wu-wien dot ac dot at>
|
||||
Alexey Kuznetsov <kuznet at ms2 dot inr dot ac dot ru>
|
||||
Alon Bar-Lev <alonbl at sourceforge dot net>
|
||||
Andrew Brown <atatat at atatdot dot net>
|
||||
<andy-1 at sourceforge dot net>
|
||||
Antti Kantee <pooka at netbsd dot org>
|
||||
Arien Vijn <arienvijn at sourceforge dot net>
|
||||
Arkadiusz Miskiewicz <misiek at pld dot org dot pl>
|
||||
Armando L. Caro Jr. <acaro at mail dot eecis dot udel dot edu>
|
||||
Assar Westerlund <assar at sics dot se>
|
||||
Brian Ginsbach <ginsbach at cray dot com>
|
||||
Charles M. Hannum <mycroft at netbsd dot org>
|
||||
Chris G. Demetriou <cgd at netbsd dot org>
|
||||
Chris Lightfoot <cwrl at users dot sourceforge dot net>
|
||||
Chris Maynard <Chris dot Maynard at gtech dot com>
|
||||
Chris Pepper <pepper at mail dot reppep dot com>
|
||||
Christian Bell <csbell at myri dot com>
|
||||
Christian Peron <csjp at freebsd dot org>
|
||||
Daniele Orlandi <daniele at orlandi dot com>
|
||||
Darren Reed <darrenr at sun dot com>
|
||||
David Kaelbling <drk at sgi dot com>
|
||||
David Young <dyoung at ojctech dot com>
|
||||
Dean Gaudet <dean at arctic dot org>
|
||||
Don Ebright <Don dot Ebright at compuware dot com>
|
||||
Dug Song <dugsong at monkey dot org>
|
||||
Dustin Spicuzza <dustin at virtualroadside dot com>
|
||||
Eric Anderson <anderse at hpl dot hp dot com>
|
||||
Erik de Castro Lopo <erik dot de dot castro dot lopo at sensorynetworks dot com>
|
||||
Felix Obenhuber <felix at obenhuber dot de>
|
||||
Florent Drouin <Florent dot Drouin at alcatel-lucent dot fr>
|
||||
Franz Schaefer <schaefer at mond dot at>
|
||||
frederich <frederich at sourceforge dot net>
|
||||
Fulko Hew <fulko dot hew at gmail dot com>
|
||||
Fumiyuki Shimizu <fumifumi at abacustech dot jp>
|
||||
Garrett Cooper <yaberauneya at sourceforge dot net>
|
||||
Gianluca Varenni <gianluca dot varenni at gmail dot com>
|
||||
Gilbert Hoyek <gil_hoyek at hotmail dot com>
|
||||
Gisle Vanem <gvanem at broadpark dot no>
|
||||
Graeme Hewson <ghewson at cix dot compulink dot co dot uk>
|
||||
Greg Stark <gsstark at mit dot edu>
|
||||
Greg Troxel <gdt at ir dot bbn dot com>
|
||||
Gregor Maier <gregor at net dot in dot tum dot de>
|
||||
Guillaume Pelat <endymion_ at users dot sourceforge dot net>
|
||||
Hagen Paul Pfeifer <hagen at jauu dot net>
|
||||
Henri Doreau <hdoreau at sourceforge dot net>
|
||||
Hyung Sik Yoon <hsyn at kr dot ibm dot com>
|
||||
Igor Khristophorov <igor at atdot dot org>
|
||||
Jan-Philip Velders <jpv at veldersjes dot net>
|
||||
Jason R. Thorpe <thorpej at netbsd dot org>
|
||||
Javier Achirica <achirica at ttd dot net>
|
||||
Jean Tourrilhes <jt at hpl dot hp dot com>
|
||||
Jean-Louis Charton <Jean-Louis.CHARTON at oikialog dot com>
|
||||
Jefferson Ogata <jogata at nodc dot noaa dot gov>
|
||||
Jesper Dangaard Brouer <hawk at comx dot dk>
|
||||
Jesper Peterson <jesper at endace dot com>
|
||||
Joerg Mayer <jmayer at loplof dot de>
|
||||
John Bankier <jbankier at rainfinity dot com>
|
||||
Jon Lindgren <jonl at yubyub dot net>
|
||||
Jon Smirl <jonsmirl at gmail dot com>
|
||||
Juergen Schoenwaelder <schoenw at ibr dot cs dot tu-bs dot de>
|
||||
Julien Moutinho <julm at savines dot alpes dot fr dot eu dot org>
|
||||
Jung-uk Kim <jkim at FreeBSD dot org>
|
||||
Kazushi Sugyo <sugyo at pb dot jp dot nec dot com>
|
||||
Klaus Klein <kleink at netbsd dot org>
|
||||
Koryn Grant <koryn at endace dot com>
|
||||
Kris Katterjohn <katterjohn at gmail dot com>
|
||||
Krzysztof Halasa <khc at pm dot waw dot pl>
|
||||
Lorenzo Cavallaro <sullivan at sikurezza dot org>
|
||||
Loris Degioanni <loris at netgroup-serv dot polito dot it>
|
||||
Love Hörnquist-Åstrand <lha at stacken dot kth dot se>
|
||||
Luis MartinGarcia <luis dot mgarc at gmail dot com>
|
||||
Maciej W. Rozycki <macro at ds2 dot pg dot gda dot pl>
|
||||
Marcus Felipe Pereira <marcus at task dot com dot br>
|
||||
Mark C. Brown <mbrown at hp dot com>
|
||||
Mark Pizzolato <List-tcpdump-workers at subscriptions dot pizzolato dot net>
|
||||
Markus Mayer <markus_mayer at sourceforge dot net>
|
||||
Martin Husemann <martin at netbsd dot org>
|
||||
Márton Németh <nm127 at freemail dot hu>
|
||||
Matthew Luckie <mjl at luckie dot org dot nz>
|
||||
Max Laier <max at love2party dot net>
|
||||
Mike Frysinger <vapier at gmail dot com>
|
||||
Mike Kershaw <dragorn at kismetwireless dot net>
|
||||
Mike Wiacek <mike at iroot dot net>
|
||||
Miroslav Lichvar <mlichvar at redhat dot com>
|
||||
Monroe Williams <monroe at pobox dot com>
|
||||
<nvercamm at sourceforge dot net>
|
||||
N. Leiten <nleiten at sourceforge dot net>
|
||||
Nicolas Dade <ndade at nsd dot dyndns dot org>
|
||||
Octavian Cerna <tavy at ylabs dot com>
|
||||
Olaf Kirch <okir at caldera dot de>
|
||||
Ollie Wild <aaw at users dot sourceforge dot net>
|
||||
Onno van der Linden <onno at simplex dot nl>
|
||||
Paolo Abeni <paolo dot abeni at email dot it>
|
||||
Patrick Marie <mycroft at virgaria dot org>
|
||||
Patrick McHardy <kaber at trash not net>
|
||||
Paul Mundt <lethal at linux-sh dot org>
|
||||
Pavel Kankovsky <kan at dcit dot cz>
|
||||
Pawel Pokrywka <publicpp at gmail dot com>
|
||||
Peter Fales <peter at fales-lorenz dot net>
|
||||
Peter Jeremy <peter dot jeremy at alcatel dot com dot au>
|
||||
Peter Volkov <pva at gentoo dot org>
|
||||
Phil Wood <cpw at lanl dot gov>
|
||||
Rafal Maszkowski <rzm at icm dot edu dot pl>
|
||||
<rcb-isis at users dot sourceforge dot net>
|
||||
Richard Stearn <richard at rns-stearn dot demon dot co dot uk>
|
||||
Rick Jones <raj at cup dot hp dot com>
|
||||
Robert Edmonds <stu-42 at sourceforge dot net>
|
||||
Roberto Mariani <jelot-tcpdump at jelot dot it>
|
||||
Romain Francoise <rfrancoise at debian dot org>
|
||||
Sagun Shakya <sagun dot shakya at sun dot com>
|
||||
Scott Barron <sb125499 at ohiou dot edu>
|
||||
Scott Gifford <sgifford at tir dot com>
|
||||
Scott Mcmillan <scott dot a dot mcmillan at intel dot com>
|
||||
Sebastian Krahmer <krahmer at cs dot uni-potsdam dot de>
|
||||
Sebastien Roy <Sebastien dot Roy at Sun dot COM>
|
||||
Sepherosa Ziehau <sepherosa at gmail dot com>
|
||||
Shaun Clowes <delius at progsoc dot uts dot edu dot au>
|
||||
Solomon Peachy <pizza at shaftnet dot org>
|
||||
Stefan Hudson <hudson at mbay dot net>
|
||||
Stephen Donnelly <stephen at endace dot com>
|
||||
Takashi Yamamoto <yamt at mwd dot biglobe dot ne dot jp>
|
||||
Tanaka Shin-ya <zstanaka at archer dot livedoor dot com>
|
||||
Tobias Poschwatta <posch at sourceforge dot net>
|
||||
Tony Li <tli at procket dot com>
|
||||
Torsten Landschoff <torsten at debian dot org>
|
||||
Uns Lider <unslider at miranda dot org>
|
||||
Uwe Girlich <Uwe dot Girlich at philosys dot de>
|
||||
Wesley Shields <wxs at FreeBSD dot org>
|
||||
Xianjie Zhang <xzhang at cup dot hp dot com>
|
||||
Xin Li <delphij at FreeBSD dot org>
|
||||
Yen Yen Lim
|
||||
Yvan Vanhullebus <vanhu at sourceforge dot net>
|
||||
Yoann Vandoorselaere <yoann at prelude-ids dot org>
|
||||
|
||||
The original LBL crew:
|
||||
Steve McCanne
|
||||
Craig Leres
|
||||
Van Jacobson
|
||||
Steve McCanne
|
||||
Craig Leres
|
||||
Van Jacobson
|
||||
|
||||
Past maintainers:
|
||||
Jun-ichiro itojun Hagino <itojun at iijlab dot net>
|
||||
Jun-ichiro itojun Hagino <itojun at iijlab dot net>
|
||||
|
||||
@@ -46,19 +46,21 @@ VPATH = @srcdir@
|
||||
|
||||
LD = /usr/bin/ld
|
||||
CC = @CC@
|
||||
AR = @AR@
|
||||
CCOPT = @V_CCOPT@
|
||||
INCLS = -I. @V_INCLS@
|
||||
DEFS = @DEFS@ @V_DEFS@
|
||||
ADDLOBJS = @ADDLOBJS@
|
||||
ADDLARCHIVEOBJS = @ADDLARCHIVEOBJS@
|
||||
LIBS = @LIBS@
|
||||
CFLAGS = @CFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
DYEXT = @DYEXT@
|
||||
V_RPATH_OPT = @V_RPATH_OPT@
|
||||
PROG=libpcap
|
||||
|
||||
# Standard CFLAGS
|
||||
CFLAGS = @CFLAGS@ $(CCOPT) $(INCLS) $(DEFS)
|
||||
FULL_CFLAGS = $(CCOPT) $(INCLS) $(DEFS) $(CFLAGS)
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
@@ -70,9 +72,9 @@ RANLIB = @RANLIB@
|
||||
# problem if you don't own the file but can write to the directory.
|
||||
.c.o:
|
||||
@rm -f $@
|
||||
$(CC) $(CFLAGS) -c $(srcdir)/$*.c
|
||||
$(CC) $(FULL_CFLAGS) -c $(srcdir)/$*.c
|
||||
|
||||
PSRC = pcap-@V_PCAP@.c @USB_SRC@ @BT_SRC@ @CAN_SRC@
|
||||
PSRC = pcap-@V_PCAP@.c @USB_SRC@ @BT_SRC@ @CAN_SRC@ @NETFILTER_SRC@
|
||||
FSRC = fad-@V_FINDALLDEVS@.c
|
||||
SSRC = @SSRC@
|
||||
CSRC = pcap.c inet.c gencode.c optimize.c nametoaddr.c etherent.c \
|
||||
@@ -115,14 +117,29 @@ HDR = $(PUBHDR) \
|
||||
sf-pcap-ng.h \
|
||||
sunatmpos.h
|
||||
|
||||
TESTS = \
|
||||
filtertest \
|
||||
findalldevstest \
|
||||
nonblocktest \
|
||||
opentest \
|
||||
selpolltest
|
||||
|
||||
TESTS_SRC = \
|
||||
tests/filtertest.c \
|
||||
tests/findalldevstest.c \
|
||||
tests/nonblocktest.c \
|
||||
tests/opentest.c \
|
||||
tests/reactivatetest.c \
|
||||
tests/selpolltest.c
|
||||
|
||||
GENHDR = \
|
||||
scanner.h tokdefs.h version.h
|
||||
|
||||
TAGFILES = \
|
||||
$(SRC) $(HDR)
|
||||
|
||||
CLEANFILES = $(OBJ) libpcap.* filtertest findalldevstest selpolltest \
|
||||
opentest $(PROG)-`cat $(srcdir)/VERSION`.tar.gz \
|
||||
CLEANFILES = $(OBJ) libpcap.* $(TESTS) \
|
||||
$(PROG)-`cat $(srcdir)/VERSION`.tar.gz \
|
||||
lex.yy.c pcap-config
|
||||
|
||||
MAN1 = pcap-config.1
|
||||
@@ -133,8 +150,10 @@ MAN3PCAP_EXPAND = \
|
||||
pcap_datalink.3pcap.in \
|
||||
pcap_dump_open.3pcap.in \
|
||||
pcap_list_datalinks.3pcap.in \
|
||||
pcap_list_tstamp_types.3pcap.in \
|
||||
pcap_open_dead.3pcap.in \
|
||||
pcap_open_offline.3pcap.in
|
||||
pcap_open_offline.3pcap.in \
|
||||
pcap_set_tstamp_type.3pcap.in
|
||||
|
||||
MAN3PCAP_NOEXPAND = \
|
||||
pcap_activate.3pcap \
|
||||
@@ -152,9 +171,7 @@ MAN3PCAP_NOEXPAND = \
|
||||
pcap_file.3pcap \
|
||||
pcap_fileno.3pcap \
|
||||
pcap_findalldevs.3pcap \
|
||||
pcap_freealldevs.3pcap \
|
||||
pcap_freecode.3pcap \
|
||||
pcap_free_datalinks.3pcap \
|
||||
pcap_get_selectable_fd.3pcap \
|
||||
pcap_geterr.3pcap \
|
||||
pcap_inject.3pcap \
|
||||
@@ -179,7 +196,9 @@ MAN3PCAP_NOEXPAND = \
|
||||
pcap_snapshot.3pcap \
|
||||
pcap_stats.3pcap \
|
||||
pcap_statustostr.3pcap \
|
||||
pcap_strerror.3pcap
|
||||
pcap_strerror.3pcap \
|
||||
pcap_tstamp_type_name_to_val.3pcap \
|
||||
pcap_tstamp_type_val_to_name.3pcap
|
||||
|
||||
MAN3PCAP = $(MAN3PCAP_NOEXPAND) $(MAN3PCAP_EXPAND:.in=)
|
||||
|
||||
@@ -188,9 +207,11 @@ MANFILE = \
|
||||
|
||||
MANMISC = \
|
||||
pcap-filter.manmisc.in \
|
||||
pcap-linktype.manmisc.in
|
||||
pcap-linktype.manmisc.in \
|
||||
pcap-tstamp.manmisc.in
|
||||
|
||||
EXTRA_DIST = \
|
||||
$(TESTS_SRC) \
|
||||
CHANGES \
|
||||
ChmodBPF/ChmodBPF \
|
||||
ChmodBPF/StartupParameters.plist \
|
||||
@@ -229,8 +250,6 @@ EXTRA_DIST = \
|
||||
fad-null.c \
|
||||
fad-sita.c \
|
||||
fad-win32.c \
|
||||
filtertest.c \
|
||||
findalldevstest.c \
|
||||
grammar.y \
|
||||
install-sh \
|
||||
lbl/os-aix4.h \
|
||||
@@ -255,7 +274,6 @@ EXTRA_DIST = \
|
||||
msdos/pktdrvr.c \
|
||||
msdos/pktdrvr.h \
|
||||
msdos/readme.dos \
|
||||
opentest.c \
|
||||
org.tcpdump.chmod_bpf.plist \
|
||||
packaging/pcap.spec.in \
|
||||
pcap-bpf.c \
|
||||
@@ -274,6 +292,8 @@ EXTRA_DIST = \
|
||||
pcap-libdlpi.c \
|
||||
pcap-linux.c \
|
||||
pcap-namedb.h \
|
||||
pcap-netfilter-linux.c \
|
||||
pcap-netfilter-linux.h \
|
||||
pcap-nit.c \
|
||||
pcap-null.c \
|
||||
pcap-pf.c \
|
||||
@@ -291,7 +311,6 @@ EXTRA_DIST = \
|
||||
pcap-win32.c \
|
||||
runlex.sh \
|
||||
scanner.l \
|
||||
selpolltest.c \
|
||||
Win32/Include/Gnuc.h \
|
||||
Win32/Include/addrinfo.h \
|
||||
Win32/Include/bittypes.h \
|
||||
@@ -329,7 +348,7 @@ scanner.c:
|
||||
|
||||
libpcap.a: $(OBJ)
|
||||
@rm -f $@
|
||||
ar rc $@ $(OBJ) $(ADDLARCHIVEOBJS)
|
||||
$(AR) rc $@ $(OBJ) $(ADDLARCHIVEOBJS)
|
||||
$(RANLIB) $@
|
||||
|
||||
shared: libpcap.$(DYEXT)
|
||||
@@ -402,7 +421,7 @@ libpcap.sl: $(OBJ)
|
||||
libpcap.shareda: $(OBJ)
|
||||
@rm -f $@ shr.o
|
||||
$(CC) @V_SHLIB_OPT@ -o shr.o $(OBJ) $(ADDLOBJS) $(LDFLAGS) $(LIBS)
|
||||
ar rc $@ shr.o
|
||||
$(AR) rc $@ shr.o
|
||||
|
||||
#
|
||||
# For platforms that don't support shared libraries (or on which we
|
||||
@@ -411,19 +430,19 @@ libpcap.shareda: $(OBJ)
|
||||
libpcap.none:
|
||||
|
||||
scanner.o: scanner.c tokdefs.h
|
||||
$(CC) $(CFLAGS) -c scanner.c
|
||||
$(CC) $(FULL_CFLAGS) -c scanner.c
|
||||
|
||||
pcap.o: version.h
|
||||
|
||||
grammar.o: grammar.c
|
||||
@rm -f $@
|
||||
$(CC) $(CFLAGS) -Dyylval=pcap_lval -c grammar.c
|
||||
$(CC) $(FULL_CFLAGS) -Dyylval=pcap_lval -c grammar.c
|
||||
|
||||
version.o: version.c
|
||||
$(CC) $(CFLAGS) -c version.c
|
||||
$(CC) $(FULL_CFLAGS) -c version.c
|
||||
|
||||
snprintf.o: $(srcdir)/missing/snprintf.c
|
||||
$(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c
|
||||
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c
|
||||
|
||||
version.c: $(srcdir)/VERSION
|
||||
@rm -f $@
|
||||
@@ -457,35 +476,47 @@ bpf_filter.c: $(srcdir)/bpf/net/bpf_filter.c
|
||||
ln -s $(srcdir)/bpf/net/bpf_filter.c bpf_filter.c
|
||||
|
||||
bpf_filter.o: bpf_filter.c
|
||||
$(CC) $(CFLAGS) -c bpf_filter.c
|
||||
$(CC) $(FULL_CFLAGS) -c bpf_filter.c
|
||||
|
||||
#
|
||||
# Generate the pcap-config script.
|
||||
#
|
||||
pcap-config: $(srcdir)/pcap-config.in
|
||||
# Some Makes, e.g. AIX Make and Solaris Make, can't handle "--file=$@.tmp:$<";
|
||||
# for example, the Solaris 9 make man page says
|
||||
#
|
||||
# Because make assigns $< and $* as it would for implicit rules
|
||||
# (according to the suffixes list and the directory contents),
|
||||
# they may be unreliable when used within explicit target entries.
|
||||
#
|
||||
# and this is an explicit target entry.
|
||||
#
|
||||
# Therefore, instead of using $<, we explicitly put in $(srcdir)/pcap-config.in.
|
||||
#
|
||||
pcap-config: $(srcdir)/pcap-config.in ./config.status
|
||||
@rm -f $@ $@.tmp
|
||||
sed -e 's|@includedir[@]|$(includedir)|g' \
|
||||
-e 's|@libdir[@]|$(libdir)|g' \
|
||||
-e 's|@LIBS[@]|$(LIBS)|g' \
|
||||
-e 's|@V_RPATH_OPT[@]|$(V_RPATH_OPT)|g' \
|
||||
$(srcdir)/pcap-config.in >$@.tmp
|
||||
./config.status --file=$@.tmp:$(srcdir)/pcap-config.in
|
||||
mv $@.tmp $@
|
||||
chmod a+x $@
|
||||
|
||||
#
|
||||
# Test programs - not built by default, and not installed.
|
||||
#
|
||||
filtertest: filtertest.c libpcap.a
|
||||
$(CC) $(CFLAGS) -I. -L. -o filtertest $(srcdir)/filtertest.c libpcap.a $(LIBS)
|
||||
tests: $(TESTS)
|
||||
|
||||
findalldevstest: findalldevstest.c libpcap.a
|
||||
$(CC) $(CFLAGS) -I. -L. -o findalldevstest $(srcdir)/findalldevstest.c libpcap.a $(LIBS)
|
||||
filtertest: tests/filtertest.c libpcap.a
|
||||
$(CC) $(FULL_CFLAGS) -I. -L. -o filtertest $(srcdir)/tests/filtertest.c libpcap.a $(LIBS)
|
||||
|
||||
selpolltest: selpolltest.c libpcap.a
|
||||
$(CC) $(CFLAGS) -I. -L. -o selpolltest $(srcdir)/selpolltest.c libpcap.a $(LIBS)
|
||||
findalldevstest: tests/findalldevstest.c libpcap.a
|
||||
$(CC) $(FULL_CFLAGS) -I. -L. -o findalldevstest $(srcdir)/tests/findalldevstest.c libpcap.a $(LIBS)
|
||||
|
||||
opentest: opentest.c libpcap.a
|
||||
$(CC) $(CFLAGS) -I. -L. -o opentest $(srcdir)/opentest.c libpcap.a $(LIBS)
|
||||
nonblocktest: tests/nonblocktest.c libpcap.a
|
||||
$(CC) $(FULL_CFLAGS) -I. -L. -o nonblocktest $(srcdir)/tests/nonblocktest.c libpcap.a $(LIBS)
|
||||
|
||||
opentest: tests/opentest.c libpcap.a
|
||||
$(CC) $(FULL_CFLAGS) -I. -L. -o opentest $(srcdir)/tests/opentest.c libpcap.a $(LIBS)
|
||||
|
||||
selpolltest: tests/selpolltest.c libpcap.a
|
||||
$(CC) $(FULL_CFLAGS) -I. -L. -o selpolltest $(srcdir)/tests/selpolltest.c libpcap.a $(LIBS)
|
||||
|
||||
install: install-shared install-archive pcap-config
|
||||
[ -d $(DESTDIR)$(libdir) ] || \
|
||||
@@ -523,12 +554,21 @@ install: install-shared install-archive pcap-config
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_dump_fopen.3pcap
|
||||
ln $(DESTDIR)$(mandir)/man3/pcap_dump_open.3pcap \
|
||||
$(DESTDIR)$(mandir)/man3/pcap_dump_fopen.3pcap
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_freealldevs.3pcap
|
||||
ln $(DESTDIR)$(mandir)/man3/pcap_findalldevs.3pcap \
|
||||
$(DESTDIR)$(mandir)/man3/pcap_freealldevs.3pcap
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_perror.3pcap
|
||||
ln $(DESTDIR)$(mandir)/man3/pcap_geterr.3pcap \
|
||||
$(DESTDIR)$(mandir)/man3/pcap_perror.3pcap
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_sendpacket.3pcap
|
||||
ln $(DESTDIR)$(mandir)/man3/pcap_inject.3pcap \
|
||||
$(DESTDIR)$(mandir)/man3/pcap_sendpacket.3pcap
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_free_datalinks.3pcap
|
||||
ln $(DESTDIR)$(mandir)/man3/pcap_list_datalinks.3pcap \
|
||||
$(DESTDIR)$(mandir)/man3/pcap_free_datalinks.3pcap
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_free_tstamp_types.3pcap
|
||||
ln $(DESTDIR)$(mandir)/man3/pcap_list_tstamp_types.3pcap \
|
||||
$(DESTDIR)$(mandir)/man3/pcap_free_tstamp_types.3pcap
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_dispatch.3pcap
|
||||
ln $(DESTDIR)$(mandir)/man3/pcap_loop.3pcap \
|
||||
$(DESTDIR)$(mandir)/man3/pcap_dispatch.3pcap
|
||||
@@ -612,8 +652,11 @@ uninstall: uninstall-shared
|
||||
rm -f $(DESTDIR)$(mandir)/man3/$$i; done
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_datalink_val_to_description.3pcap
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_dump_fopen.3pcap
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_freealldevs.3pcap
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_perror.3pcap
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_sendpacket.3pcap
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_free_datalinks.3pcap
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_free_tstamp_types.3pcap
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_dispatch.3pcap
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_minor_version.3pcap
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_next.3pcap
|
||||
@@ -650,7 +693,7 @@ clean:
|
||||
|
||||
distclean: clean
|
||||
rm -f Makefile config.cache config.log config.status \
|
||||
config.h gnuc.h os-proto.h bpf_filter.c pcap-config \
|
||||
config.h gnuc.h net os-proto.h bpf_filter.c pcap-config \
|
||||
stamp-h stamp-h.in
|
||||
rm -f $(MAN3PCAP_EXPAND:.in=) $(MANFILE:.in=) $(MANMISC:.in=)
|
||||
rm -rf autom4te.cache
|
||||
|
||||
@@ -1,249 +0,0 @@
|
||||
o Included this file, renamed directory from libpcap-1.0.0 to libpcap.
|
||||
|
||||
o Added @CFLAGS@ to the CFLAGS definition in Makefile.in to pick up -g
|
||||
if configure determines that it is supported:
|
||||
|
||||
--- Makefile.in.orig 2009-11-04 11:35:44.000000000 -0700
|
||||
+++ Makefile.in 2009-11-04 11:50:02.000000000 -0700
|
||||
@@ -55,7 +55,7 @@
|
||||
PROG=libpcap
|
||||
|
||||
# Standard CFLAGS
|
||||
-CFLAGS = $(CCOPT) $(INCLS) $(DEFS)
|
||||
+CFLAGS = @CFLAGS@ $(CCOPT) $(INCLS) $(DEFS)
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
|
||||
o Eliminated Lex/Yacc requirement and added the generated files:
|
||||
grammar.c
|
||||
scanner.c
|
||||
scanner.h
|
||||
tokdefs.h
|
||||
|
||||
--- Makefile.in.orig 2009-11-04 11:35:44.000000000 -0700
|
||||
+++ Makefile.in 2009-11-04 11:46:43.000000000 -0700
|
||||
@@ -55,21 +55,13 @@
|
||||
PROG=libpcap
|
||||
|
||||
# Standard CFLAGS
|
||||
-CFLAGS = $(CCOPT) $(INCLS) $(DEFS)
|
||||
+CFLAGS = @CFLAGS@ $(CCOPT) $(INCLS) $(DEFS)
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
RANLIB = @RANLIB@
|
||||
|
||||
-#
|
||||
-# Flex and bison allow you to specify the prefixes of the global symbols
|
||||
-# used by the generated parser. This allows programs to use lex/yacc
|
||||
-# and link against libpcap. If you don't have flex or bison, get them.
|
||||
-#
|
||||
-LEX = @V_LEX@
|
||||
-YACC = @V_YACC@
|
||||
-
|
||||
# Explicitly define compilation rule since SunOS 4's make doesn't like gcc.
|
||||
# Also, gcc does not remove the .o before forking 'as', which can be a
|
||||
# problem if you don't own the file but can write to the directory.
|
||||
@@ -122,7 +114,7 @@
|
||||
TAGFILES = \
|
||||
$(SRC) $(HDR) $(TAGHDR)
|
||||
|
||||
-CLEANFILES = $(OBJ) libpcap.a $(GENSRC) $(GENHDR) lex.yy.c
|
||||
+CLEANFILES = $(OBJ) libpcap.a lex.yy.c
|
||||
|
||||
MAN1 = pcap-config.1
|
||||
|
||||
@@ -313,6 +305,15 @@
|
||||
|
||||
all: libpcap.a pcap-config
|
||||
|
||||
+# Inhibit implicit rule Make seems to have for using yacc/lex to
|
||||
+# recompile new scanner.c/grammar.c -- we ship ones which we want to
|
||||
+# use instead.
|
||||
+grammar.c:
|
||||
+ echo "Not rebuilding grammar.c"
|
||||
+
|
||||
+scanner.c:
|
||||
+ echo "Not rebuilding scanner.c"
|
||||
+
|
||||
libpcap.a: $(OBJ)
|
||||
@rm -f $@
|
||||
$(AR) rc $@ $(OBJ) $(LIBS)
|
||||
@@ -344,22 +345,11 @@
|
||||
-compatibility_version 1 \
|
||||
-current_version `sed 's/[^0-9.].*$$//' $(srcdir)/VERSION`
|
||||
|
||||
-scanner.c: $(srcdir)/scanner.l
|
||||
- @rm -f $@
|
||||
- ./runlex.sh $(LEX) -o$@ $<
|
||||
-
|
||||
scanner.o: scanner.c tokdefs.h
|
||||
$(CC) $(CFLAGS) -c scanner.c
|
||||
|
||||
pcap.o: version.h
|
||||
|
||||
-tokdefs.h: grammar.c
|
||||
-grammar.c: $(srcdir)/grammar.y
|
||||
- @rm -f grammar.c tokdefs.h
|
||||
- $(YACC) -d $<
|
||||
- mv y.tab.c grammar.c
|
||||
- mv y.tab.h tokdefs.h
|
||||
-
|
||||
grammar.o: grammar.c
|
||||
@rm -f $@
|
||||
$(CC) $(CFLAGS) -Dyylval=pcap_lval -c grammar.c
|
||||
--- configure.in.orig 2009-10-27 16:20:34.000000000 -0600
|
||||
+++ configure.in 2009-10-27 16:14:32.000000000 -0600
|
||||
@@ -848,24 +848,6 @@
|
||||
fi
|
||||
|
||||
|
||||
-AC_LBL_LEX_AND_YACC(V_LEX, V_YACC, pcap_)
|
||||
-if test "$V_LEX" = lex ; then
|
||||
-# Some versions of lex can't handle the definitions section of scanner.l .
|
||||
-# Try lexing it and complain if it can't deal.
|
||||
- AC_CACHE_CHECK([for capable lex], tcpdump_cv_capable_lex,
|
||||
- if lex -t scanner.l > /dev/null 2>&1; then
|
||||
- tcpdump_cv_capable_lex=yes
|
||||
- else
|
||||
- tcpdump_cv_capable_lex=insufficient
|
||||
- fi)
|
||||
- if test $tcpdump_cv_capable_lex = insufficient ; then
|
||||
- AC_MSG_ERROR([Your operating system's lex is insufficient to compile
|
||||
- libpcap. flex is a lex replacement that has many advantages, including
|
||||
- being able to compile libpcap. For more information, see
|
||||
- http://www.gnu.org/software/flex/flex.html .])
|
||||
- fi
|
||||
-fi
|
||||
-
|
||||
#
|
||||
# Assume a.out/ELF convention for shared library names (".so"), and
|
||||
# V7/BSD convention for man pages (file formats in section 5,
|
||||
@@ -1004,10 +986,8 @@
|
||||
AC_SUBST(V_DEFS)
|
||||
AC_SUBST(V_INCLS)
|
||||
AC_SUBST(V_LIBS)
|
||||
-AC_SUBST(V_LEX)
|
||||
AC_SUBST(V_PCAP)
|
||||
AC_SUBST(V_FINDALLDEVS)
|
||||
-AC_SUBST(V_YACC)
|
||||
AC_SUBST(SSRC)
|
||||
AC_SUBST(DYEXT)
|
||||
AC_SUBST(DAGLIBS)
|
||||
|
||||
o Added a --disable-packet-ring configure option to allow the creation
|
||||
of 32-bit binaries compatible with 64-bit Linux kernels before 2.6.27.
|
||||
|
||||
Index: configure.in
|
||||
===================================================================
|
||||
--- configure.in (revision 17694)
|
||||
+++ configure.in (working copy)
|
||||
@@ -1396,6 +1396,24 @@
|
||||
AC_SUBST(CAN_SRC)
|
||||
fi
|
||||
|
||||
+dnl The packet ring capture facility of Linux, described in
|
||||
+dnl Documentation/networking/packet_mmap.txt, is not 32/64-bit compatible before
|
||||
+dnl version 2.6.27. A 32-bit kernel requires a 32-bit userland, and likewise for
|
||||
+dnl 64-bit. The effect of this is that a 32-bit libpcap binary will not run
|
||||
+dnl correctly on a 64-bit kernel (the binary will use the wrong offsets into a
|
||||
+dnl kernel struct). This problem was solved in Linux 2.6.27. Use
|
||||
+dnl --disable-packet-ring whenever a 32-bit application must run on a 64-bit
|
||||
+dnl target host, and either the build host or the target host run Linux 2.6.26
|
||||
+dnl or earlier.
|
||||
+AC_ARG_ENABLE([packet-ring],
|
||||
+[AC_HELP_STRING([--enable-packet-ring],[enable Linux packet ring support @<:@default=yes@:>@])],
|
||||
+,enable_packet_ring=yes)
|
||||
+
|
||||
+if test "x$enable_packet_ring" != "xno" ; then
|
||||
+ AC_DEFINE(PCAP_SUPPORT_PACKET_RING, 1, [use Linux packet ring capture if available])
|
||||
+ AC_SUBST(PCAP_SUPPORT_PACKET_RING)
|
||||
+fi
|
||||
+
|
||||
AC_PROG_INSTALL
|
||||
|
||||
AC_CONFIG_HEADER(config.h)
|
||||
Index: pcap-linux.c
|
||||
===================================================================
|
||||
--- pcap-linux.c (revision 17694)
|
||||
+++ pcap-linux.c (working copy)
|
||||
@@ -232,17 +232,19 @@
|
||||
# endif /* PACKET_HOST */
|
||||
|
||||
|
||||
- /* check for memory mapped access avaibility. We assume every needed
|
||||
- * struct is defined if the macro TPACKET_HDRLEN is defined, because it
|
||||
- * uses many ring related structs and macros */
|
||||
-# ifdef TPACKET_HDRLEN
|
||||
-# define HAVE_PACKET_RING
|
||||
-# ifdef TPACKET2_HDRLEN
|
||||
-# define HAVE_TPACKET2
|
||||
-# else
|
||||
-# define TPACKET_V1 0
|
||||
-# endif /* TPACKET2_HDRLEN */
|
||||
-# endif /* TPACKET_HDRLEN */
|
||||
+# ifdef PCAP_SUPPORT_PACKET_RING
|
||||
+ /* check for memory mapped access avaibility. We assume every needed
|
||||
+ * struct is defined if the macro TPACKET_HDRLEN is defined, because it
|
||||
+ * uses many ring related structs and macros */
|
||||
+# ifdef TPACKET_HDRLEN
|
||||
+# define HAVE_PACKET_RING
|
||||
+# ifdef TPACKET2_HDRLEN
|
||||
+# define HAVE_TPACKET2
|
||||
+# else
|
||||
+# define TPACKET_V1 0
|
||||
+# endif /* TPACKET2_HDRLEN */
|
||||
+# endif /* TPACKET_HDRLEN */
|
||||
+# endif /* PCAP_SUPPORT_PACKET_RING */
|
||||
#endif /* PF_PACKET */
|
||||
|
||||
#ifdef SO_ATTACH_FILTER
|
||||
|
||||
o Regenerated configure.
|
||||
|
||||
o Added a memset() call that removes a Valgrind error. More info at:
|
||||
<http://seclists.org/nmap-dev/2010/q3/796>
|
||||
|
||||
Index: pcap-linux.c
|
||||
===================================================================
|
||||
--- pcap-linux.c (revision 20314)
|
||||
+++ pcap-linux.c (working copy)
|
||||
@@ -2148,6 +2148,7 @@
|
||||
struct sock_fprog fcode;
|
||||
int can_filter_in_kernel;
|
||||
int err = 0;
|
||||
+ memset(&fcode, 0, sizeof(struct sock_fprog));
|
||||
#endif
|
||||
|
||||
if (!handle)
|
||||
|
||||
o Moved the inclusion of config.h to the top of scanner.c to work
|
||||
around _LARGE_FILES definition difficulties on AIX.
|
||||
|
||||
--- libpcap/scanner.l
|
||||
+++ libpcap/scanner.l
|
||||
@@ -1,3 +1,10 @@
|
||||
+%top{
|
||||
+/* Must come first for _LARGE_FILE_API on AIX. */
|
||||
+#ifdef HAVE_CONFIG_H
|
||||
+#include "config.h"
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
%{
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
|
||||
@@ -25,10 +32,6 @@ static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/scanner.l,v 1.112 2008-02-06 10:21:30 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
-#ifdef HAVE_CONFIG_H
|
||||
-#include "config.h"
|
||||
-#endif
|
||||
-
|
||||
#ifdef WIN32
|
||||
#include <pcap-stdinc.h>
|
||||
#else /* WIN32 */
|
||||
|
||||
@@ -63,13 +63,14 @@ added overhead (especially, for selective filters). Ideally, libpcap
|
||||
would translate BPF filters into a filter program that is compatible
|
||||
with the underlying kernel subsystem, but this is not yet implemented.
|
||||
|
||||
BPF is standard in 4.4BSD, BSD/OS, NetBSD, FreeBSD, and OpenBSD. DEC
|
||||
OSF/1/Digital UNIX/Tru64 UNIX uses the packetfilter interface but has
|
||||
been extended to accept BPF filters (which libpcap utilizes). Also, you
|
||||
can add BPF filter support to Ultrix using the kernel source and/or
|
||||
object patches available in:
|
||||
BPF is standard in 4.4BSD, BSD/OS, NetBSD, FreeBSD, OpenBSD, DragonFly
|
||||
BSD, and Mac OS X; an older, modified and undocumented version is
|
||||
standard in AIX. {DEC OSF/1, Digital UNIX, Tru64 UNIX} uses the
|
||||
packetfilter interface but has been extended to accept BPF filters
|
||||
(which libpcap utilizes). Also, you can add BPF filter support to
|
||||
Ultrix using the kernel source and/or object patches available in:
|
||||
|
||||
ftp://gatekeeper.dec.com/pub/DEC/net/bpfext42.tar.Z.
|
||||
http://www.tcpdump.org/other/bpfext42.tar.Z
|
||||
|
||||
Linux, in the 2.2 kernel and later kernels, has a "Socket Filter"
|
||||
mechanism that accepts BPF filters; see the README.linux file for
|
||||
|
||||
@@ -97,12 +97,12 @@ reported by pcap_stats on Linux are as follows:
|
||||
2.2.x
|
||||
=====
|
||||
ps_recv Number of packets that were accepted by the pcap filter
|
||||
ps_drops Always 0, this statistic is not gatherd on this platform
|
||||
ps_drop Always 0, this statistic is not gatherd on this platform
|
||||
|
||||
2.4.x
|
||||
=====
|
||||
ps_rec Number of packets that were accepted by the pcap filter
|
||||
ps_drops Number of packets that had passed filtering but were not
|
||||
ps_recv Number of packets that were accepted by the pcap filter
|
||||
ps_drop Number of packets that had passed filtering but were not
|
||||
passed on to pcap due to things like buffer shortage, etc.
|
||||
This is useful because these are packets you are interested in
|
||||
but won't be reported by, for example, tcpdump output.
|
||||
This is useful because these are packets you are interested in
|
||||
but won't be reported by, for example, tcpdump output.
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.1.1
|
||||
1.2.1
|
||||
|
||||
46
libpcap/Win32/Include/Gnuc.h
Normal file
46
libpcap/Win32/Include/Gnuc.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/* @(#) $Header: /tcpdump/master/libpcap/Win32/Include/Gnuc.h,v 1.1 2002-08-01 08:33:05 risso Exp $ (LBL) */
|
||||
|
||||
/* Define __P() macro, if necessary */
|
||||
|
||||
#ifndef __P
|
||||
#if __STDC__
|
||||
#define __P(protos) protos
|
||||
#else
|
||||
#define __P(protos) ()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* inline foo */
|
||||
#ifndef __cplusplus
|
||||
#ifdef __GNUC__
|
||||
#define inline __inline
|
||||
#else
|
||||
#define inline
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Handle new and old "dead" routine prototypes
|
||||
*
|
||||
* For example:
|
||||
*
|
||||
* __dead void foo(void) __attribute__((volatile));
|
||||
*
|
||||
*/
|
||||
#ifdef __GNUC__
|
||||
#ifndef __dead
|
||||
#define __dead volatile
|
||||
#endif
|
||||
#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
|
||||
#ifndef __attribute__
|
||||
#define __attribute__(args)
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#ifndef __dead
|
||||
#define __dead
|
||||
#endif
|
||||
#ifndef __attribute__
|
||||
#define __attribute__(args)
|
||||
#endif
|
||||
#endif
|
||||
146
libpcap/Win32/Include/addrinfo.h
Normal file
146
libpcap/Win32/Include/addrinfo.h
Normal file
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the project nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* $Id: addrinfo.h,v 1.1 2002-08-01 08:33:05 risso Exp $ */
|
||||
|
||||
#ifndef HAVE_ADDRINFO
|
||||
|
||||
/*
|
||||
* Error return codes from getaddrinfo()
|
||||
*/
|
||||
#define EAI_ADDRFAMILY 1 /* address family for hostname not supported */
|
||||
#define EAI_AGAIN 2 /* temporary failure in name resolution */
|
||||
#define EAI_BADFLAGS 3 /* invalid value for ai_flags */
|
||||
#define EAI_FAIL 4 /* non-recoverable failure in name resolution */
|
||||
#define EAI_FAMILY 5 /* ai_family not supported */
|
||||
#define EAI_MEMORY 6 /* memory allocation failure */
|
||||
#define EAI_NODATA 7 /* no address associated with hostname */
|
||||
#define EAI_NONAME 8 /* hostname nor servname provided, or not known */
|
||||
#define EAI_SERVICE 9 /* servname not supported for ai_socktype */
|
||||
#define EAI_SOCKTYPE 10 /* ai_socktype not supported */
|
||||
#define EAI_SYSTEM 11 /* system error returned in errno */
|
||||
#define EAI_BADHINTS 12
|
||||
#define EAI_PROTOCOL 13
|
||||
#define EAI_MAX 14
|
||||
|
||||
/* internal error */
|
||||
#define NETDB_INTERNAL -1 /* see errno */
|
||||
|
||||
/*
|
||||
* Flag values for getaddrinfo()
|
||||
*/
|
||||
#define AI_PASSIVE 0x00000001 /* get address to use bind() */
|
||||
#define AI_CANONNAME 0x00000002 /* fill ai_canonname */
|
||||
#define AI_NUMERICHOST 0x00000004 /* prevent name resolution */
|
||||
/* valid flags for addrinfo */
|
||||
#define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
|
||||
|
||||
#define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
|
||||
#define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */
|
||||
#define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */
|
||||
#define AI_V4MAPPED 0x00000800 /* accept IPv4-mapped IPv6 address */
|
||||
/* special recommended flags for getipnodebyname */
|
||||
#define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG)
|
||||
|
||||
struct addrinfo {
|
||||
int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
|
||||
int ai_family; /* PF_xxx */
|
||||
int ai_socktype; /* SOCK_xxx */
|
||||
int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
|
||||
size_t ai_addrlen; /* length of ai_addr */
|
||||
char *ai_canonname; /* canonical name for hostname */
|
||||
struct sockaddr *ai_addr; /* binary address */
|
||||
struct addrinfo *ai_next; /* next structure in linked list */
|
||||
};
|
||||
|
||||
extern void freeaddrinfo (struct addrinfo *);
|
||||
extern void freehostent (struct hostent *);
|
||||
extern char *gai_strerror (int);
|
||||
extern int getaddrinfo (const char *, const char *,
|
||||
const struct addrinfo *, struct addrinfo **);
|
||||
extern int getnameinfo (const struct sockaddr *, size_t, char *,
|
||||
size_t, char *, size_t, int);
|
||||
extern struct hostent *getipnodebyaddr (const void *, size_t, int, int *);
|
||||
extern struct hostent *getipnodebyname (const char *, int, int, int *);
|
||||
extern int inet_pton (int, const char *, void *);
|
||||
extern const char *inet_ntop (int, const void *, char *, size_t);
|
||||
#else
|
||||
|
||||
#ifndef EAI_BADHINTS
|
||||
#define EAI_BADHINTS 12
|
||||
#endif
|
||||
|
||||
#ifndef EAI_PROTOCOL
|
||||
#define EAI_PROTOCOL 13
|
||||
#endif
|
||||
|
||||
#ifndef EAI_MAX
|
||||
#define EAI_MAX 14
|
||||
#endif
|
||||
|
||||
#ifndef NETDB_INTERNAL
|
||||
#define NETDB_INTERNAL -1 /* see errno */
|
||||
#endif
|
||||
|
||||
#ifndef AI_MASK
|
||||
/* valid flags for addrinfo */
|
||||
#define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
|
||||
#endif
|
||||
|
||||
#endif /* HAVE_ADDRINFO */
|
||||
|
||||
/*
|
||||
* Constants for getnameinfo()
|
||||
*/
|
||||
#ifndef NI_MAXHOST
|
||||
#define NI_MAXHOST 1025
|
||||
#endif
|
||||
#ifndef NI_MAXSERV
|
||||
#define NI_MAXSERV 32
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Flag values for getnameinfo()
|
||||
*/
|
||||
#ifndef NI_NOFQDN
|
||||
#define NI_NOFQDN 0x00000001
|
||||
#endif
|
||||
#ifndef NI_NUMERICHOST
|
||||
#define NI_NUMERICHOST 0x00000002
|
||||
#endif
|
||||
#ifndef NI_NAMEREQD
|
||||
#define NI_NAMEREQD 0x00000004
|
||||
#endif
|
||||
#ifndef NI_NUMERICSERV
|
||||
#define NI_NUMERICSERV 0x00000008
|
||||
#endif
|
||||
#ifndef NI_DGRAM
|
||||
#define NI_DGRAM 0x00000010
|
||||
#endif
|
||||
|
||||
349
libpcap/Win32/Include/arpa/nameser.h
Normal file
349
libpcap/Win32/Include/arpa/nameser.h
Normal file
@@ -0,0 +1,349 @@
|
||||
/*
|
||||
* ++Copyright++ 1983, 1989, 1993
|
||||
* -
|
||||
* Copyright (c) 1983, 1989, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* -
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
* -
|
||||
* --Copyright--
|
||||
*/
|
||||
|
||||
/*
|
||||
* @(#)nameser.h 8.1 (Berkeley) 6/2/93
|
||||
* nameser.h,v 1.2 1995/05/06 14:23:54 hjl Exp
|
||||
*/
|
||||
|
||||
#ifndef _NAMESER_H_
|
||||
#define _NAMESER_H_
|
||||
|
||||
#ifndef WIN32
|
||||
#include <sys/param.h>
|
||||
#if (!defined(BSD)) || (BSD < 199306)
|
||||
# include <sys/bitypes.h>
|
||||
#else
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
#include <sys/cdefs.h>
|
||||
#else
|
||||
#include <pcap-stdinc.h>
|
||||
#define __LITTLE_ENDIAN 1
|
||||
#define __BYTE_ORDER __LITTLE_ENDIAN
|
||||
#endif
|
||||
|
||||
/*
|
||||
* revision information. this is the release date in YYYYMMDD format.
|
||||
* it can change every day so the right thing to do with it is use it
|
||||
* in preprocessor commands such as "#if (__BIND > 19931104)". do not
|
||||
* compare for equality; rather, use it to determine whether your resolver
|
||||
* is new enough to contain a certain feature.
|
||||
*/
|
||||
|
||||
#define __BIND 19940417 /* interface version stamp */
|
||||
|
||||
/*
|
||||
* Define constants based on rfc883
|
||||
*/
|
||||
#define PACKETSZ 512 /* maximum packet size */
|
||||
#define MAXDNAME 256 /* maximum domain name */
|
||||
#define MAXCDNAME 255 /* maximum compressed domain name */
|
||||
#define MAXLABEL 63 /* maximum length of domain label */
|
||||
#define HFIXEDSZ 12 /* #/bytes of fixed data in header */
|
||||
#define QFIXEDSZ 4 /* #/bytes of fixed data in query */
|
||||
#define RRFIXEDSZ 10 /* #/bytes of fixed data in r record */
|
||||
#define INT32SZ 4 /* for systems without 32-bit ints */
|
||||
#define INT16SZ 2 /* for systems without 16-bit ints */
|
||||
#define INADDRSZ 4 /* for sizeof(struct inaddr) != 4 */
|
||||
|
||||
/*
|
||||
* Internet nameserver port number
|
||||
*/
|
||||
#define NAMESERVER_PORT 53
|
||||
|
||||
/*
|
||||
* Currently defined opcodes
|
||||
*/
|
||||
#define QUERY 0x0 /* standard query */
|
||||
#define IQUERY 0x1 /* inverse query */
|
||||
#define STATUS 0x2 /* nameserver status query */
|
||||
/*#define xxx 0x3 *//* 0x3 reserved */
|
||||
#define NS_NOTIFY_OP 0x4 /* notify secondary of SOA change */
|
||||
#ifdef ALLOW_UPDATES
|
||||
/* non standard - supports ALLOW_UPDATES stuff from Mike Schwartz */
|
||||
# define UPDATEA 0x9 /* add resource record */
|
||||
# define UPDATED 0xa /* delete a specific resource record */
|
||||
# define UPDATEDA 0xb /* delete all named resource record */
|
||||
# define UPDATEM 0xc /* modify a specific resource record */
|
||||
# define UPDATEMA 0xd /* modify all named resource record */
|
||||
# define ZONEINIT 0xe /* initial zone transfer */
|
||||
# define ZONEREF 0xf /* incremental zone referesh */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Currently defined response codes
|
||||
*/
|
||||
#ifdef HAVE_ADDRINFO
|
||||
#define NOERROR 0 /* no error */
|
||||
#endif /* HAVE_ADDRINFO */
|
||||
#define FORMERR 1 /* format error */
|
||||
#define SERVFAIL 2 /* server failure */
|
||||
#define NXDOMAIN 3 /* non existent domain */
|
||||
#define NOTIMP 4 /* not implemented */
|
||||
#define REFUSED 5 /* query refused */
|
||||
#ifdef ALLOW_UPDATES
|
||||
/* non standard */
|
||||
# define NOCHANGE 0xf /* update failed to change db */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Type values for resources and queries
|
||||
*/
|
||||
#define T_A 1 /* host address */
|
||||
#define T_NS 2 /* authoritative server */
|
||||
#define T_MD 3 /* mail destination */
|
||||
#define T_MF 4 /* mail forwarder */
|
||||
#define T_CNAME 5 /* canonical name */
|
||||
#define T_SOA 6 /* start of authority zone */
|
||||
#define T_MB 7 /* mailbox domain name */
|
||||
#define T_MG 8 /* mail group member */
|
||||
#define T_MR 9 /* mail rename name */
|
||||
#define T_NULL 10 /* null resource record */
|
||||
#define T_WKS 11 /* well known service */
|
||||
#define T_PTR 12 /* domain name pointer */
|
||||
#define T_HINFO 13 /* host information */
|
||||
#define T_MINFO 14 /* mailbox information */
|
||||
#define T_MX 15 /* mail routing information */
|
||||
#define T_TXT 16 /* text strings */
|
||||
#define T_RP 17 /* responsible person */
|
||||
#define T_AFSDB 18 /* AFS cell database */
|
||||
#define T_X25 19 /* X_25 calling address */
|
||||
#define T_ISDN 20 /* ISDN calling address */
|
||||
#define T_RT 21 /* router */
|
||||
#define T_NSAP 22 /* NSAP address */
|
||||
#define T_NSAP_PTR 23 /* reverse NSAP lookup (deprecated) */
|
||||
#define T_SIG 24 /* security signature */
|
||||
#define T_KEY 25 /* security key */
|
||||
#define T_PX 26 /* X.400 mail mapping */
|
||||
#define T_GPOS 27 /* geographical position (withdrawn) */
|
||||
#define T_AAAA 28 /* IP6 Address */
|
||||
#define T_LOC 29 /* Location Information */
|
||||
/* non standard */
|
||||
#define T_UINFO 100 /* user (finger) information */
|
||||
#define T_UID 101 /* user ID */
|
||||
#define T_GID 102 /* group ID */
|
||||
#define T_UNSPEC 103 /* Unspecified format (binary data) */
|
||||
/* Query type values which do not appear in resource records */
|
||||
#define T_AXFR 252 /* transfer zone of authority */
|
||||
#define T_MAILB 253 /* transfer mailbox records */
|
||||
#define T_MAILA 254 /* transfer mail agent records */
|
||||
#define T_ANY 255 /* wildcard match */
|
||||
|
||||
/*
|
||||
* Values for class field
|
||||
*/
|
||||
|
||||
#define C_IN 1 /* the arpa internet */
|
||||
#define C_CHAOS 3 /* for chaos net (MIT) */
|
||||
#define C_HS 4 /* for Hesiod name server (MIT) (XXX) */
|
||||
/* Query class values which do not appear in resource records */
|
||||
#define C_ANY 255 /* wildcard match */
|
||||
|
||||
/*
|
||||
* Status return codes for T_UNSPEC conversion routines
|
||||
*/
|
||||
#define CONV_SUCCESS 0
|
||||
#define CONV_OVERFLOW (-1)
|
||||
#define CONV_BADFMT (-2)
|
||||
#define CONV_BADCKSUM (-3)
|
||||
#define CONV_BADBUFLEN (-4)
|
||||
|
||||
#ifndef __BYTE_ORDER
|
||||
#if (BSD >= 199103)
|
||||
# include <machine/endian.h>
|
||||
#else
|
||||
#ifdef linux
|
||||
# include <endian.h>
|
||||
#else
|
||||
#define __LITTLE_ENDIAN 1234 /* least-significant byte first (vax, pc) */
|
||||
#define __BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */
|
||||
#define __PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp)*/
|
||||
|
||||
#if defined(vax) || defined(ns32000) || defined(sun386) || defined(i386) || \
|
||||
defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || \
|
||||
defined(__alpha__) || defined(__alpha)
|
||||
#define __BYTE_ORDER __LITTLE_ENDIAN
|
||||
#endif
|
||||
|
||||
#if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \
|
||||
defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \
|
||||
defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || defined(DGUX) ||\
|
||||
defined(apollo) || defined(__convex__) || defined(_CRAY) || \
|
||||
defined(__hppa) || defined(__hp9000) || \
|
||||
defined(__hp9000s300) || defined(__hp9000s700) || \
|
||||
defined (BIT_ZERO_ON_LEFT) || defined(m68k)
|
||||
#define __BYTE_ORDER __BIG_ENDIAN
|
||||
#endif
|
||||
#endif /* linux */
|
||||
#endif /* BSD */
|
||||
#endif /* __BYTE_ORDER */
|
||||
|
||||
#if !defined(__BYTE_ORDER) || \
|
||||
(__BYTE_ORDER != __BIG_ENDIAN && __BYTE_ORDER != __LITTLE_ENDIAN && \
|
||||
__BYTE_ORDER != __PDP_ENDIAN)
|
||||
/* you must determine what the correct bit order is for
|
||||
* your compiler - the next line is an intentional error
|
||||
* which will force your compiles to bomb until you fix
|
||||
* the above macros.
|
||||
*/
|
||||
error "Undefined or invalid __BYTE_ORDER";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Structure for query header. The order of the fields is machine- and
|
||||
* compiler-dependent, depending on the byte/bit order and the layout
|
||||
* of bit fields. We use bit fields only in int variables, as this
|
||||
* is all ANSI requires. This requires a somewhat confusing rearrangement.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
unsigned id :16; /* query identification number */
|
||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||
/* fields in third byte */
|
||||
unsigned qr: 1; /* response flag */
|
||||
unsigned opcode: 4; /* purpose of message */
|
||||
unsigned aa: 1; /* authoritive answer */
|
||||
unsigned tc: 1; /* truncated message */
|
||||
unsigned rd: 1; /* recursion desired */
|
||||
/* fields in fourth byte */
|
||||
unsigned ra: 1; /* recursion available */
|
||||
unsigned pr: 1; /* primary server req'd (!standard) */
|
||||
unsigned unused :2; /* unused bits (MBZ as of 4.9.3a3) */
|
||||
unsigned rcode :4; /* response code */
|
||||
#endif
|
||||
#if __BYTE_ORDER == __LITTLE_ENDIAN || __BYTE_ORDER == __PDP_ENDIAN
|
||||
/* fields in third byte */
|
||||
unsigned rd :1; /* recursion desired */
|
||||
unsigned tc :1; /* truncated message */
|
||||
unsigned aa :1; /* authoritive answer */
|
||||
unsigned opcode :4; /* purpose of message */
|
||||
unsigned qr :1; /* response flag */
|
||||
/* fields in fourth byte */
|
||||
unsigned rcode :4; /* response code */
|
||||
unsigned unused :2; /* unused bits (MBZ as of 4.9.3a3) */
|
||||
unsigned pr :1; /* primary server req'd (!standard) */
|
||||
unsigned ra :1; /* recursion available */
|
||||
#endif
|
||||
/* remaining bytes */
|
||||
unsigned qdcount :16; /* number of question entries */
|
||||
unsigned ancount :16; /* number of answer entries */
|
||||
unsigned nscount :16; /* number of authority entries */
|
||||
unsigned arcount :16; /* number of resource entries */
|
||||
} HEADER;
|
||||
|
||||
/*
|
||||
* Defines for handling compressed domain names
|
||||
*/
|
||||
#define INDIR_MASK 0xc0
|
||||
|
||||
/*
|
||||
* Structure for passing resource records around.
|
||||
*/
|
||||
struct rrec {
|
||||
int16_t r_zone; /* zone number */
|
||||
int16_t r_class; /* class number */
|
||||
int16_t r_type; /* type number */
|
||||
u_int32_t r_ttl; /* time to live */
|
||||
int r_size; /* size of data area */
|
||||
char *r_data; /* pointer to data */
|
||||
};
|
||||
|
||||
//extern u_int16_t _getshort __P((const u_char *));
|
||||
//extern u_int32_t _getlong __P((const u_char *));
|
||||
|
||||
/*
|
||||
* Inline versions of get/put short/long. Pointer is advanced.
|
||||
*
|
||||
* These macros demonstrate the property of C whereby it can be
|
||||
* portable or it can be elegant but rarely both.
|
||||
*/
|
||||
#define GETSHORT(s, cp) { \
|
||||
register u_char *t_cp = (u_char *)(cp); \
|
||||
(s) = ((u_int16_t)t_cp[0] << 8) \
|
||||
| ((u_int16_t)t_cp[1]) \
|
||||
; \
|
||||
(cp) += INT16SZ; \
|
||||
}
|
||||
|
||||
#define GETLONG(l, cp) { \
|
||||
register u_char *t_cp = (u_char *)(cp); \
|
||||
(l) = ((u_int32_t)t_cp[0] << 24) \
|
||||
| ((u_int32_t)t_cp[1] << 16) \
|
||||
| ((u_int32_t)t_cp[2] << 8) \
|
||||
| ((u_int32_t)t_cp[3]) \
|
||||
; \
|
||||
(cp) += INT32SZ; \
|
||||
}
|
||||
|
||||
#define PUTSHORT(s, cp) { \
|
||||
register u_int16_t t_s = (u_int16_t)(s); \
|
||||
register u_char *t_cp = (u_char *)(cp); \
|
||||
*t_cp++ = t_s >> 8; \
|
||||
*t_cp = t_s; \
|
||||
(cp) += INT16SZ; \
|
||||
}
|
||||
|
||||
#define PUTLONG(l, cp) { \
|
||||
register u_int32_t t_l = (u_int32_t)(l); \
|
||||
register u_char *t_cp = (u_char *)(cp); \
|
||||
*t_cp++ = t_l >> 24; \
|
||||
*t_cp++ = t_l >> 16; \
|
||||
*t_cp++ = t_l >> 8; \
|
||||
*t_cp = t_l; \
|
||||
(cp) += INT32SZ; \
|
||||
}
|
||||
|
||||
#endif /* !_NAMESER_H_ */
|
||||
89
libpcap/Win32/Include/bittypes.h
Normal file
89
libpcap/Win32/Include/bittypes.h
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (C) 1999 WIDE Project.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the project nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef _BITTYPES_H
|
||||
#define _BITTYPES_H
|
||||
|
||||
#ifndef HAVE_U_INT8_T
|
||||
typedef unsigned char u_int8_t;
|
||||
typedef signed char int8_t;
|
||||
#endif /* HAVE_U_INT8_T */
|
||||
|
||||
#ifndef HAVE_U_INT16_T
|
||||
typedef unsigned short u_int16_t;
|
||||
typedef signed short int16_t;
|
||||
#endif /* HAVE_U_INT16_T */
|
||||
|
||||
#ifndef HAVE_U_INT32_T
|
||||
typedef unsigned int u_int32_t;
|
||||
typedef signed int int32_t;
|
||||
#endif /* HAVE_U_INT32_T */
|
||||
|
||||
#ifndef HAVE_U_INT64_T
|
||||
#ifdef _MSC_EXTENSIONS
|
||||
typedef unsigned _int64 u_int64_t;
|
||||
typedef _int64 int64_t;
|
||||
#else /* _MSC_EXTENSIONS */
|
||||
typedef unsigned long long u_int64_t;
|
||||
typedef long long int64_t;
|
||||
#endif /* _MSC_EXTENSIONS */
|
||||
#endif /* HAVE_U_INT64_T */
|
||||
|
||||
#ifndef PRId64
|
||||
#ifdef _MSC_EXTENSIONS
|
||||
#define PRId64 "I64d"
|
||||
#else /* _MSC_EXTENSIONS */
|
||||
#define PRId64 "lld"
|
||||
#endif /* _MSC_EXTENSIONS */
|
||||
#endif /* PRId64 */
|
||||
|
||||
#ifndef PRIo64
|
||||
#ifdef _MSC_EXTENSIONS
|
||||
#define PRIo64 "I64o"
|
||||
#else /* _MSC_EXTENSIONS */
|
||||
#define PRIo64 "llo"
|
||||
#endif /* _MSC_EXTENSIONS */
|
||||
#endif /* PRIo64 */
|
||||
|
||||
#ifndef PRIx64
|
||||
#ifdef _MSC_EXTENSIONS
|
||||
#define PRIx64 "I64x"
|
||||
#else /* _MSC_EXTENSIONS */
|
||||
#define PRIx64 "llx"
|
||||
#endif /* _MSC_EXTENSIONS */
|
||||
#endif /* PRIx64 */
|
||||
|
||||
#ifndef PRIu64
|
||||
#ifdef _MSC_EXTENSIONS
|
||||
#define PRIu64 "I64u"
|
||||
#else /* _MSC_EXTENSIONS */
|
||||
#define PRIu64 "llu"
|
||||
#endif /* _MSC_EXTENSIONS */
|
||||
#endif /* PRIu64 */
|
||||
|
||||
#endif /* _BITTYPES_H */
|
||||
37
libpcap/Win32/Include/cdecl_ext.h
Normal file
37
libpcap/Win32/Include/cdecl_ext.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 1999 WIDE Project.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the project nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef HAVE_PORTABLE_PROTOTYPE
|
||||
|
||||
#if defined(__STDC__) || defined(__cplusplus)
|
||||
#define __P(protos) protos /* full-blown ANSI C */
|
||||
#else
|
||||
#define __P(protos) () /* traditional C preprocessor */
|
||||
#endif
|
||||
|
||||
#endif /* !HAVE_PORTABLE_PROTOTYPE */
|
||||
67
libpcap/Win32/Include/inetprivate.h
Normal file
67
libpcap/Win32/Include/inetprivate.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 1999 - 2003
|
||||
* NetGroup, Politecnico di Torino (Italy)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Politecnico di Torino nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <net/netdb.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <arpa/nameser.h>
|
||||
|
||||
extern void _sethtent(int f);
|
||||
extern void _endhtent(void);
|
||||
extern struct hostent *_gethtent(void);
|
||||
extern struct hostent *_gethtbyname(const char *name);
|
||||
extern struct hostent *_gethtbyaddr(const char *addr, int len,
|
||||
int type);
|
||||
extern int _validuser(FILE *hostf, const char *rhost,
|
||||
const char *luser, const char *ruser, int baselen);
|
||||
extern int _checkhost(const char *rhost, const char *lhost, int len);
|
||||
#if 0
|
||||
extern void putlong(u_long l, u_char *msgp);
|
||||
extern void putshort(u_short l, u_char *msgp);
|
||||
extern u_int32_t _getlong(register const u_char *msgp);
|
||||
extern u_int16_t _getshort(register const u_char *msgp);
|
||||
extern void p_query(char *msg);
|
||||
extern void fp_query(char *msg, FILE *file);
|
||||
extern char *p_cdname(char *cp, char *msg, FILE *file);
|
||||
extern char *p_rr(char *cp, char *msg, FILE *file);
|
||||
extern char *p_type(int type);
|
||||
extern char * p_class(int class);
|
||||
extern char *p_time(u_long value);
|
||||
#endif
|
||||
extern char * hostalias(const char *name);
|
||||
extern void sethostfile(char *name);
|
||||
extern void _res_close (void);
|
||||
extern void ruserpass(const char *host, char **aname, char **apass);
|
||||
163
libpcap/Win32/Include/ip6_misc.h
Normal file
163
libpcap/Win32/Include/ip6_misc.h
Normal file
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
* Copyright (c) 1993, 1994, 1997
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that: (1) source code distributions
|
||||
* retain the above copyright notice and this paragraph in its entirety, (2)
|
||||
* distributions including binary code include the above copyright notice and
|
||||
* this paragraph in its entirety in the documentation or other materials
|
||||
* provided with the distribution, and (3) all advertising materials mentioning
|
||||
* features or use of this software display the following acknowledgement:
|
||||
* ``This product includes software developed by the University of California,
|
||||
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
|
||||
* the University nor the names of its contributors may be used to endorse
|
||||
* or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* @(#) $Header: /tcpdump/master/libpcap/Win32/Include/ip6_misc.h,v 1.5 2006-01-22 18:02:18 gianluca Exp $ (LBL)
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file contains a collage of declarations for IPv6 from FreeBSD not present in Windows
|
||||
*/
|
||||
|
||||
#include <winsock2.h>
|
||||
|
||||
#include <ws2tcpip.h>
|
||||
|
||||
#ifndef __MINGW32__
|
||||
#define IN_MULTICAST(a) IN_CLASSD(a)
|
||||
#endif
|
||||
|
||||
#define IN_EXPERIMENTAL(a) ((((u_int32_t) (a)) & 0xf0000000) == 0xf0000000)
|
||||
|
||||
#define IN_LOOPBACKNET 127
|
||||
|
||||
#if defined(__MINGW32__) && defined(DEFINE_ADDITIONAL_IPV6_STUFF)
|
||||
/* IPv6 address */
|
||||
struct in6_addr
|
||||
{
|
||||
union
|
||||
{
|
||||
u_int8_t u6_addr8[16];
|
||||
u_int16_t u6_addr16[8];
|
||||
u_int32_t u6_addr32[4];
|
||||
} in6_u;
|
||||
#define s6_addr in6_u.u6_addr8
|
||||
#define s6_addr16 in6_u.u6_addr16
|
||||
#define s6_addr32 in6_u.u6_addr32
|
||||
#define s6_addr64 in6_u.u6_addr64
|
||||
};
|
||||
|
||||
#define IN6ADDR_ANY_INIT { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
|
||||
#define IN6ADDR_LOOPBACK_INIT { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }
|
||||
#endif /* __MINGW32__ */
|
||||
|
||||
|
||||
#if (defined _MSC_VER) || (defined(__MINGW32__) && defined(DEFINE_ADDITIONAL_IPV6_STUFF))
|
||||
typedef unsigned short sa_family_t;
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__MINGW32__) && defined(DEFINE_ADDITIONAL_IPV6_STUFF)
|
||||
|
||||
#define __SOCKADDR_COMMON(sa_prefix) \
|
||||
sa_family_t sa_prefix##family
|
||||
|
||||
/* Ditto, for IPv6. */
|
||||
struct sockaddr_in6
|
||||
{
|
||||
__SOCKADDR_COMMON (sin6_);
|
||||
u_int16_t sin6_port; /* Transport layer port # */
|
||||
u_int32_t sin6_flowinfo; /* IPv6 flow information */
|
||||
struct in6_addr sin6_addr; /* IPv6 address */
|
||||
};
|
||||
|
||||
#define IN6_IS_ADDR_V4MAPPED(a) \
|
||||
((((u_int32_t *) (a))[0] == 0) && (((u_int32_t *) (a))[1] == 0) && \
|
||||
(((u_int32_t *) (a))[2] == htonl (0xffff)))
|
||||
|
||||
#define IN6_IS_ADDR_MULTICAST(a) (((u_int8_t *) (a))[0] == 0xff)
|
||||
|
||||
#define IN6_IS_ADDR_LINKLOCAL(a) \
|
||||
((((u_int32_t *) (a))[0] & htonl (0xffc00000)) == htonl (0xfe800000))
|
||||
|
||||
#define IN6_IS_ADDR_LOOPBACK(a) \
|
||||
(((u_int32_t *) (a))[0] == 0 && ((u_int32_t *) (a))[1] == 0 && \
|
||||
((u_int32_t *) (a))[2] == 0 && ((u_int32_t *) (a))[3] == htonl (1))
|
||||
#endif /* __MINGW32__ */
|
||||
|
||||
#define ip6_vfc ip6_ctlun.ip6_un2_vfc
|
||||
#define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow
|
||||
#define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen
|
||||
#define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt
|
||||
#define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim
|
||||
#define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim
|
||||
|
||||
#define nd_rd_type nd_rd_hdr.icmp6_type
|
||||
#define nd_rd_code nd_rd_hdr.icmp6_code
|
||||
#define nd_rd_cksum nd_rd_hdr.icmp6_cksum
|
||||
#define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
|
||||
|
||||
/*
|
||||
* IPV6 extension headers
|
||||
*/
|
||||
#define IPPROTO_HOPOPTS 0 /* IPv6 hop-by-hop options */
|
||||
#define IPPROTO_IPV6 41 /* IPv6 header. */
|
||||
#define IPPROTO_ROUTING 43 /* IPv6 routing header */
|
||||
#define IPPROTO_FRAGMENT 44 /* IPv6 fragmentation header */
|
||||
#define IPPROTO_ESP 50 /* encapsulating security payload */
|
||||
#define IPPROTO_AH 51 /* authentication header */
|
||||
#define IPPROTO_ICMPV6 58 /* ICMPv6 */
|
||||
#define IPPROTO_NONE 59 /* IPv6 no next header */
|
||||
#define IPPROTO_DSTOPTS 60 /* IPv6 destination options */
|
||||
#define IPPROTO_PIM 103 /* Protocol Independent Multicast. */
|
||||
|
||||
#define IPV6_RTHDR_TYPE_0 0
|
||||
|
||||
/* Option types and related macros */
|
||||
#define IP6OPT_PAD1 0x00 /* 00 0 00000 */
|
||||
#define IP6OPT_PADN 0x01 /* 00 0 00001 */
|
||||
#define IP6OPT_JUMBO 0xC2 /* 11 0 00010 = 194 */
|
||||
#define IP6OPT_JUMBO_LEN 6
|
||||
#define IP6OPT_ROUTER_ALERT 0x05 /* 00 0 00101 */
|
||||
|
||||
#define IP6OPT_RTALERT_LEN 4
|
||||
#define IP6OPT_RTALERT_MLD 0 /* Datagram contains an MLD message */
|
||||
#define IP6OPT_RTALERT_RSVP 1 /* Datagram contains an RSVP message */
|
||||
#define IP6OPT_RTALERT_ACTNET 2 /* contains an Active Networks msg */
|
||||
#define IP6OPT_MINLEN 2
|
||||
|
||||
#define IP6OPT_BINDING_UPDATE 0xc6 /* 11 0 00110 */
|
||||
#define IP6OPT_BINDING_ACK 0x07 /* 00 0 00111 */
|
||||
#define IP6OPT_BINDING_REQ 0x08 /* 00 0 01000 */
|
||||
#define IP6OPT_HOME_ADDRESS 0xc9 /* 11 0 01001 */
|
||||
#define IP6OPT_EID 0x8a /* 10 0 01010 */
|
||||
|
||||
#define IP6OPT_TYPE(o) ((o) & 0xC0)
|
||||
#define IP6OPT_TYPE_SKIP 0x00
|
||||
#define IP6OPT_TYPE_DISCARD 0x40
|
||||
#define IP6OPT_TYPE_FORCEICMP 0x80
|
||||
#define IP6OPT_TYPE_ICMP 0xC0
|
||||
|
||||
#define IP6OPT_MUTABLE 0x20
|
||||
|
||||
|
||||
#if defined(__MINGW32__) && defined(DEFINE_ADDITIONAL_IPV6_STUFF)
|
||||
#ifndef EAI_ADDRFAMILY
|
||||
struct addrinfo {
|
||||
int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
|
||||
int ai_family; /* PF_xxx */
|
||||
int ai_socktype; /* SOCK_xxx */
|
||||
int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
|
||||
size_t ai_addrlen; /* length of ai_addr */
|
||||
char *ai_canonname; /* canonical name for hostname */
|
||||
struct sockaddr *ai_addr; /* binary address */
|
||||
struct addrinfo *ai_next; /* next structure in linked list */
|
||||
};
|
||||
#endif
|
||||
#endif /* __MINGW32__ */
|
||||
230
libpcap/Win32/Include/net/if.h
Normal file
230
libpcap/Win32/Include/net/if.h
Normal file
@@ -0,0 +1,230 @@
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)if.h 8.1 (Berkeley) 6/10/93
|
||||
* $FreeBSD: src/sys/net/if.h,v 1.49.2.1 1999/08/29 16:28:15 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef _NET_IF_H_
|
||||
#define _NET_IF_H_
|
||||
|
||||
/*
|
||||
* <net/if.h> does not depend on <sys/time.h> on most other systems. This
|
||||
* helps userland compatability. (struct timeval ifi_lastchange)
|
||||
*/
|
||||
#ifndef KERNEL
|
||||
#include <pcap-stdinc.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Structure describing information about an interface
|
||||
* which may be of interest to management entities.
|
||||
*/
|
||||
struct if_data {
|
||||
/* generic interface information */
|
||||
u_char ifi_type; /* ethernet, tokenring, etc */
|
||||
u_char ifi_physical; /* e.g., AUI, Thinnet, 10base-T, etc */
|
||||
u_char ifi_addrlen; /* media address length */
|
||||
u_char ifi_hdrlen; /* media header length */
|
||||
u_char ifi_recvquota; /* polling quota for receive intrs */
|
||||
u_char ifi_xmitquota; /* polling quota for xmit intrs */
|
||||
u_long ifi_mtu; /* maximum transmission unit */
|
||||
u_long ifi_metric; /* routing metric (external only) */
|
||||
u_long ifi_baudrate; /* linespeed */
|
||||
/* volatile statistics */
|
||||
u_long ifi_ipackets; /* packets received on interface */
|
||||
u_long ifi_ierrors; /* input errors on interface */
|
||||
u_long ifi_opackets; /* packets sent on interface */
|
||||
u_long ifi_oerrors; /* output errors on interface */
|
||||
u_long ifi_collisions; /* collisions on csma interfaces */
|
||||
u_long ifi_ibytes; /* total number of octets received */
|
||||
u_long ifi_obytes; /* total number of octets sent */
|
||||
u_long ifi_imcasts; /* packets received via multicast */
|
||||
u_long ifi_omcasts; /* packets sent via multicast */
|
||||
u_long ifi_iqdrops; /* dropped on input, this interface */
|
||||
u_long ifi_noproto; /* destined for unsupported protocol */
|
||||
u_long ifi_recvtiming; /* usec spent receiving when timing */
|
||||
u_long ifi_xmittiming; /* usec spent xmitting when timing */
|
||||
struct timeval ifi_lastchange; /* time of last administrative change */
|
||||
};
|
||||
|
||||
/* ws2tcpip.h has interface flags: IFF_* */
|
||||
#if 0
|
||||
#define IFF_UP 0x1 /* interface is up */
|
||||
#define IFF_BROADCAST 0x2 /* broadcast address valid */
|
||||
#define IFF_DEBUG 0x4 /* turn on debugging */
|
||||
#define IFF_LOOPBACK 0x8 /* is a loopback net */
|
||||
#define IFF_POINTOPOINT 0x10 /* interface is point-to-point link */
|
||||
/*#define IFF_NOTRAILERS 0x20 * obsolete: avoid use of trailers */
|
||||
#define IFF_RUNNING 0x40 /* resources allocated */
|
||||
#define IFF_NOARP 0x80 /* no address resolution protocol */
|
||||
#define IFF_PROMISC 0x100 /* receive all packets */
|
||||
#define IFF_ALLMULTI 0x200 /* receive all multicast packets */
|
||||
#define IFF_OACTIVE 0x400 /* transmission in progress */
|
||||
#define IFF_SIMPLEX 0x800 /* can't hear own transmissions */
|
||||
#define IFF_LINK0 0x1000 /* per link layer defined bit */
|
||||
#define IFF_LINK1 0x2000 /* per link layer defined bit */
|
||||
#define IFF_LINK2 0x4000 /* per link layer defined bit */
|
||||
#define IFF_ALTPHYS IFF_LINK2 /* use alternate physical connection */
|
||||
#define IFF_MULTICAST 0x8000 /* supports multicast */
|
||||
#endif /* 0 */
|
||||
|
||||
/* flags set internally only: */
|
||||
#define IFF_CANTCHANGE \
|
||||
(IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\
|
||||
IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI)
|
||||
|
||||
#define IFQ_MAXLEN 50
|
||||
#define IFNET_SLOWHZ 1 /* granularity is 1 second */
|
||||
|
||||
/*
|
||||
* Message format for use in obtaining information about interfaces
|
||||
* from getkerninfo and the routing socket
|
||||
*/
|
||||
struct if_msghdr {
|
||||
u_short ifm_msglen; /* to skip over non-understood messages */
|
||||
u_char ifm_version; /* future binary compatability */
|
||||
u_char ifm_type; /* message type */
|
||||
int ifm_addrs; /* like rtm_addrs */
|
||||
int ifm_flags; /* value of if_flags */
|
||||
u_short ifm_index; /* index for associated ifp */
|
||||
struct if_data ifm_data;/* statistics and other data about if */
|
||||
};
|
||||
|
||||
/*
|
||||
* Message format for use in obtaining information about interface addresses
|
||||
* from getkerninfo and the routing socket
|
||||
*/
|
||||
struct ifa_msghdr {
|
||||
u_short ifam_msglen; /* to skip over non-understood messages */
|
||||
u_char ifam_version; /* future binary compatability */
|
||||
u_char ifam_type; /* message type */
|
||||
int ifam_addrs; /* like rtm_addrs */
|
||||
int ifam_flags; /* value of ifa_flags */
|
||||
u_short ifam_index; /* index for associated ifp */
|
||||
int ifam_metric; /* value of ifa_metric */
|
||||
};
|
||||
|
||||
/*
|
||||
* Message format for use in obtaining information about multicast addresses
|
||||
* from the routing socket
|
||||
*/
|
||||
struct ifma_msghdr {
|
||||
u_short ifmam_msglen; /* to skip over non-understood messages */
|
||||
u_char ifmam_version; /* future binary compatability */
|
||||
u_char ifmam_type; /* message type */
|
||||
int ifmam_addrs; /* like rtm_addrs */
|
||||
int ifmam_flags; /* value of ifa_flags */
|
||||
u_short ifmam_index; /* index for associated ifp */
|
||||
};
|
||||
|
||||
/*
|
||||
* Interface request structure used for socket
|
||||
* ioctl's. All interface ioctl's must have parameter
|
||||
* definitions which begin with ifr_name. The
|
||||
* remainder may be interface specific.
|
||||
*/
|
||||
struct ifreq {
|
||||
#define IFNAMSIZ 16
|
||||
char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */
|
||||
union {
|
||||
struct sockaddr ifru_addr;
|
||||
struct sockaddr ifru_dstaddr;
|
||||
struct sockaddr ifru_broadaddr;
|
||||
short ifru_flags;
|
||||
int ifru_metric;
|
||||
int ifru_mtu;
|
||||
int ifru_phys;
|
||||
int ifru_media;
|
||||
caddr_t ifru_data;
|
||||
} ifr_ifru;
|
||||
#define ifr_addr ifr_ifru.ifru_addr /* address */
|
||||
#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */
|
||||
#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
|
||||
#define ifr_flags ifr_ifru.ifru_flags /* flags */
|
||||
#define ifr_metric ifr_ifru.ifru_metric /* metric */
|
||||
#define ifr_mtu ifr_ifru.ifru_mtu /* mtu */
|
||||
#define ifr_phys ifr_ifru.ifru_phys /* physical wire */
|
||||
#define ifr_media ifr_ifru.ifru_media /* physical media */
|
||||
#define ifr_data ifr_ifru.ifru_data /* for use by interface */
|
||||
};
|
||||
|
||||
#define _SIZEOF_ADDR_IFREQ(ifr) \
|
||||
((ifr).ifr_addr.sa_len > sizeof(struct sockaddr) ? \
|
||||
(sizeof(struct ifreq) - sizeof(struct sockaddr) + \
|
||||
(ifr).ifr_addr.sa_len) : sizeof(struct ifreq))
|
||||
|
||||
struct ifaliasreq {
|
||||
char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */
|
||||
struct sockaddr ifra_addr;
|
||||
struct sockaddr ifra_broadaddr;
|
||||
struct sockaddr ifra_mask;
|
||||
};
|
||||
|
||||
struct ifmediareq {
|
||||
char ifm_name[IFNAMSIZ]; /* if name, e.g. "en0" */
|
||||
int ifm_current; /* current media options */
|
||||
int ifm_mask; /* don't care mask */
|
||||
int ifm_status; /* media status */
|
||||
int ifm_active; /* active options */
|
||||
int ifm_count; /* # entries in ifm_ulist array */
|
||||
int *ifm_ulist; /* media words */
|
||||
};
|
||||
/*
|
||||
* Structure used in SIOCGIFCONF request.
|
||||
* Used to retrieve interface configuration
|
||||
* for machine (useful for programs which
|
||||
* must know all networks accessible).
|
||||
*/
|
||||
struct ifconf {
|
||||
int ifc_len; /* size of associated buffer */
|
||||
union {
|
||||
caddr_t ifcu_buf;
|
||||
struct ifreq *ifcu_req;
|
||||
} ifc_ifcu;
|
||||
#define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */
|
||||
#define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */
|
||||
};
|
||||
|
||||
#ifdef KERNEL
|
||||
#ifdef MALLOC_DECLARE
|
||||
MALLOC_DECLARE(M_IFADDR);
|
||||
MALLOC_DECLARE(M_IFMADDR);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* XXX - this should go away soon */
|
||||
#ifdef KERNEL
|
||||
#include <net/if_var.h>
|
||||
#endif
|
||||
|
||||
#endif /* !_NET_IF_H_ */
|
||||
164
libpcap/Win32/Include/net/netdb.h
Normal file
164
libpcap/Win32/Include/net/netdb.h
Normal file
@@ -0,0 +1,164 @@
|
||||
/*-
|
||||
* Copyright (c) 1980, 1983, 1988, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)netdb.h 8.1 (Berkeley) 6/2/93
|
||||
* netdb.h,v 1.4 1995/08/14 04:05:04 hjl Exp
|
||||
* -
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
* -
|
||||
* --Copyright--
|
||||
*/
|
||||
|
||||
#ifndef _NETDB_H_
|
||||
#define _NETDB_H_
|
||||
|
||||
#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) || defined(_REENTRANT)
|
||||
#include <stdio.h>
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
#include <winsock2.h>
|
||||
#include <net/paths.h>
|
||||
|
||||
#define _PATH_HEQUIV __PATH_ETC_INET"/hosts.equiv"
|
||||
#define _PATH_HOSTS __PATH_ETC_INET"/hosts"
|
||||
#define _PATH_NETWORKS __PATH_ETC_INET"/networks"
|
||||
#define _PATH_PROTOCOLS __PATH_ETC_INET"/protocols"
|
||||
#define _PATH_SERVICES __PATH_ETC_INET"/services"
|
||||
#define _PATH_RESCONF __PATH_ETC_INET"/resolv.conf"
|
||||
#define _PATH_RPC __PATH_ETC_INET"/rpc"
|
||||
|
||||
struct rpcent {
|
||||
char *r_name; /* name of server for this rpc program */
|
||||
char **r_aliases; /* alias list */
|
||||
int r_number; /* rpc program number */
|
||||
};
|
||||
|
||||
#ifndef WIN32
|
||||
#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) || defined(_REENTRANT)
|
||||
|
||||
#define __NETDB_MAXALIASES 35
|
||||
#define __NETDB_MAXADDRS 35
|
||||
|
||||
/*
|
||||
* Error return codes from gethostbyname() and gethostbyaddr()
|
||||
* (left in extern int h_errno).
|
||||
*/
|
||||
#define h_errno (*__h_errno_location ())
|
||||
#else
|
||||
extern int h_errno;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define NETDB_INTERNAL -1 /* see errno */
|
||||
#define NETDB_SUCCESS 0 /* no problem */
|
||||
|
||||
//#include <features.h>
|
||||
|
||||
void endhostent (void);
|
||||
void endnetent (void);
|
||||
void endprotoent (void);
|
||||
void endservent (void);
|
||||
void endrpcent (void);
|
||||
struct hostent *gethostent (void);
|
||||
struct netent *getnetbyaddr (long, int); /* u_long? */
|
||||
struct netent *getnetbyname (const char *);
|
||||
struct netent *getnetent (void);
|
||||
struct protoent *getprotoent (void);
|
||||
struct servent *getservent (void);
|
||||
struct rpcent *getrpcent (void);
|
||||
struct rpcent *getrpcbyname (const char *);
|
||||
struct rpcent *getrpcbynumber (int);
|
||||
void herror (const char *);
|
||||
void sethostent (int);
|
||||
/* void sethostfile (const char *); */
|
||||
void setnetent (int);
|
||||
void setprotoent (int);
|
||||
void setservent (int);
|
||||
void setrpcent (int);
|
||||
|
||||
#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) || defined(_REENTRANT)
|
||||
struct hostent *gethostbyaddr_r (const char *__addr,
|
||||
int __length, int __type,
|
||||
struct hostent *__result,
|
||||
char *__buffer, int __buflen, int *__h_errnop);
|
||||
struct hostent *gethostbyname_r (const char * __name,
|
||||
struct hostent *__result, char *__buffer,
|
||||
int __buflen, int *__h_errnop);
|
||||
struct hostent *gethostent_r (struct hostent *__result,
|
||||
char *__buffer, int __buflen, int *__h_errnop);
|
||||
struct netent *getnetbyaddr_r (long __net, int __type,
|
||||
struct netent *__result, char *__buffer,
|
||||
int __buflen);
|
||||
struct netent *getnetbyname_r (const char * __name,
|
||||
struct netent *__result, char *__buffer,
|
||||
int __buflen);
|
||||
struct netent *getnetent_r (struct netent *__result,
|
||||
char *__buffer, int __buflen);
|
||||
struct protoent *getprotobyname_r (const char * __name,
|
||||
struct protoent *__result, char *__buffer,
|
||||
int __buflen);
|
||||
struct protoent *getprotobynumber_r (int __proto,
|
||||
struct protoent *__result, char *__buffer,
|
||||
int __buflen);
|
||||
struct protoent *getprotoent_r (struct protoent *__result,
|
||||
char *__buffer, int __buflen);
|
||||
struct servent *getservbyname_r (const char * __name,
|
||||
const char *__proto, struct servent *__result,
|
||||
char *__buffer, int __buflen);
|
||||
struct servent *getservbyport_r (int __port,
|
||||
const char *__proto, struct servent *__result,
|
||||
char *__buffer, int __buflen);
|
||||
struct servent *getservent_r (struct servent *__result,
|
||||
char *__buffer, int __buflen);
|
||||
|
||||
int *__h_errno_location (void);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* !_NETDB_H_ */
|
||||
105
libpcap/Win32/Include/net/paths.h
Normal file
105
libpcap/Win32/Include/net/paths.h
Normal file
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright (c) 1989 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)paths.h 5.15 (Berkeley) 5/29/91
|
||||
*/
|
||||
|
||||
#ifndef _PATHS_H_
|
||||
#define _PATHS_H_
|
||||
|
||||
#if 0
|
||||
#define __PATH_ETC_INET "/usr/etc/inet"
|
||||
#else
|
||||
#define __PATH_ETC_INET "/etc"
|
||||
#endif
|
||||
|
||||
/* Default search path. */
|
||||
#define _PATH_DEFPATH "/usr/local/bin:/usr/bin:/bin:."
|
||||
#define _PATH_DEFPATH_ROOT "/sbin:/bin:/usr/sbin:/usr/bin"
|
||||
|
||||
#define _PATH_BSHELL "/bin/sh"
|
||||
#define _PATH_CONSOLE "/dev/console"
|
||||
#define _PATH_CSHELL "/bin/csh"
|
||||
#define _PATH_DEVDB "/var/run/dev.db"
|
||||
#define _PATH_DEVNULL "/dev/null"
|
||||
#define _PATH_DRUM "/dev/drum"
|
||||
#define _PATH_HEQUIV __PATH_ETC_INET"/hosts.equiv"
|
||||
#define _PATH_KMEM "/dev/kmem"
|
||||
#define _PATH_MAILDIR "/var/spool/mail"
|
||||
#define _PATH_MAN "/usr/man"
|
||||
#define _PATH_MEM "/dev/mem"
|
||||
#define _PATH_LOGIN "/bin/login"
|
||||
#define _PATH_NOLOGIN "/etc/nologin"
|
||||
#define _PATH_SENDMAIL "/usr/sbin/sendmail"
|
||||
#define _PATH_SHELLS "/etc/shells"
|
||||
#define _PATH_TTY "/dev/tty"
|
||||
#define _PATH_UNIX "/vmlinux"
|
||||
#define _PATH_VI "/usr/bin/vi"
|
||||
|
||||
/* Provide trailing slash, since mostly used for building pathnames. */
|
||||
#define _PATH_DEV "/dev/"
|
||||
#define _PATH_TMP "/tmp/"
|
||||
#define _PATH_VARRUN "/var/run/"
|
||||
#define _PATH_VARTMP "/var/tmp/"
|
||||
|
||||
#define _PATH_KLOG "/proc/kmsg"
|
||||
#define _PATH_LOGCONF __PATH_ETC_INET"/syslog.conf"
|
||||
#if 0
|
||||
#define _PATH_LOGPID __PATH_ETC_INET"/syslog.pid"
|
||||
#else
|
||||
#define _PATH_LOGPID "/var/run/syslog.pid"
|
||||
#endif
|
||||
#define _PATH_LOG "/dev/log"
|
||||
#define _PATH_CONSOLE "/dev/console"
|
||||
|
||||
#if 0
|
||||
#define _PATH_UTMP "/var/adm/utmp"
|
||||
#define _PATH_WTMP "/var/adm/wtmp"
|
||||
#define _PATH_LASTLOG "/var/adm/lastlog"
|
||||
#else
|
||||
#define _PATH_UTMP "/var/run/utmp"
|
||||
#define _PATH_WTMP "/var/log/wtmp"
|
||||
#define _PATH_LASTLOG "/var/log/lastlog"
|
||||
#endif
|
||||
|
||||
#define _PATH_LOCALE "/usr/lib/locale"
|
||||
|
||||
#define _PATH_RWHODIR "/var/spool/rwho"
|
||||
|
||||
#if _MIT_POSIX_THREADS
|
||||
/* For the MIT pthreads */
|
||||
#define _PATH_PTY "/dev/"
|
||||
#define _PATH_TZDIR "/usr/lib/zoneinfo"
|
||||
#define _PATH_TZFILE "/usr/lib/zoneinfo/localtime"
|
||||
#endif
|
||||
|
||||
#endif /* !_PATHS_H_ */
|
||||
38
libpcap/Win32/Include/sockstorage.h
Normal file
38
libpcap/Win32/Include/sockstorage.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 1999 WIDE Project.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the project nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
struct sockaddr_storage {
|
||||
#ifdef HAVE_SOCKADDR_SA_LEN
|
||||
u_int8_t __ss_len;
|
||||
u_int8_t __ss_family;
|
||||
u_int8_t fill[126];
|
||||
#else
|
||||
u_int8_t __ss_family;
|
||||
u_int8_t fill[127];
|
||||
#endif /* HAVE_SOCKADDR_SA_LEN */
|
||||
};
|
||||
168
libpcap/Win32/Prj/libpcap.dsp
Normal file
168
libpcap/Win32/Prj/libpcap.dsp
Normal file
@@ -0,0 +1,168 @@
|
||||
# Microsoft Developer Studio Project File - Name="libpcap" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
|
||||
CFG=libpcap - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "libpcap.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "libpcap.mak" CFG="libpcap - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "libpcap - Win32 Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "libpcap - Win32 Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "libpcap - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../../" /I "../../lbl/" /I "../../bpf/" /I "../include/" /I "../../../../common" /I "../../../../dag/include" /I "../../../../dag/drv/windows" /D "NDEBUG" /D "YY_NEVER_INTERACTIVE" /D yylval=pcap_lval /D "_USRDLL" /D "LIBPCAP_EXPORTS" /D "HAVE_STRERROR" /D "__STDC__" /D "INET6" /D "_WINDOWS" /D "_MBCS" /D "HAVE_ADDRINFO" /D "WIN32" /D _U_= /D "HAVE_SNPRINTF" /D "HAVE_VSNPRINTF" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
|
||||
!ELSEIF "$(CFG)" == "libpcap - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../" /I "../../lbl/" /I "../../bpf/" /I "../include/" /I "../../../../common" /I "../../../../dag/include" /I "../../../../dag/drv/windows" /D "_DEBUG" /D "YY_NEVER_INTERACTIVE" /D yylval=pcap_lval /D "_USRDLL" /D "LIBPCAP_EXPORTS" /D "HAVE_STRERROR" /D "__STDC__" /D "INET6" /D "_WINDOWS" /D "_MBCS" /D "HAVE_ADDRINFO" /D "WIN32" /D _U_= /D "HAVE_SNPRINTF" /D "HAVE_VSNPRINTF" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "libpcap - Win32 Release"
|
||||
# Name "libpcap - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\bpf_dump.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\bpf\net\bpf_filter.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\bpf_image.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\etherent.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\..\fad-win32.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Src\ffs.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\gencode.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Src\getnetbynm.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Src\getnetent.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Src\getservent.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\grammar.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\inet.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Src\inet_aton.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Src\inet_net.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Src\inet_pton.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\nametoaddr.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\optimize.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\..\Pcap-win32.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\pcap.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\savefile.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\scanner.c
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
29
libpcap/Win32/Prj/libpcap.dsw
Normal file
29
libpcap/Win32/Prj/libpcap.dsw
Normal file
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "libpcap"=".\libpcap.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
54
libpcap/Win32/Src/ffs.c
Normal file
54
libpcap/Win32/Src/ffs.c
Normal file
@@ -0,0 +1,54 @@
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)ffs.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
* ffs -- vax ffs instruction
|
||||
*/
|
||||
int
|
||||
ffs(mask)
|
||||
register int mask;
|
||||
{
|
||||
register int bit;
|
||||
|
||||
if (mask == 0)
|
||||
return(0);
|
||||
for (bit = 1; !(mask & 1); bit++)
|
||||
mask >>= 1;
|
||||
return(bit);
|
||||
}
|
||||
83
libpcap/Win32/Src/gai_strerror.c
Normal file
83
libpcap/Win32/Src/gai_strerror.c
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the project nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__FBSDID("$FreeBSD: /repoman/r/ncvs/src/lib/libc/net/gai_strerror.c,v 1.1 2005/04/06 12:45:51 ume Exp $");
|
||||
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
#include <ws2tcpip.h>
|
||||
|
||||
#else
|
||||
|
||||
#include <netdb.h>
|
||||
|
||||
#endif
|
||||
|
||||
/* Entries EAI_ADDRFAMILY (1) and EAI_NODATA (7) are obsoleted, but left */
|
||||
/* for backward compatibility with userland code prior to 2553bis-02 */
|
||||
static char *ai_errlist[] = {
|
||||
"Success", /* 0 */
|
||||
"Address family for hostname not supported", /* 1 */
|
||||
"Temporary failure in name resolution", /* EAI_AGAIN */
|
||||
"Invalid value for ai_flags", /* EAI_BADFLAGS */
|
||||
"Non-recoverable failure in name resolution", /* EAI_FAIL */
|
||||
"ai_family not supported", /* EAI_FAMILY */
|
||||
"Memory allocation failure", /* EAI_MEMORY */
|
||||
"No address associated with hostname", /* 7 */
|
||||
"hostname nor servname provided, or not known", /* EAI_NONAME */
|
||||
"servname not supported for ai_socktype", /* EAI_SERVICE */
|
||||
"ai_socktype not supported", /* EAI_SOCKTYPE */
|
||||
"System error returned in errno", /* EAI_SYSTEM */
|
||||
"Invalid value for hints", /* EAI_BADHINTS */
|
||||
"Resolved protocol is unknown" /* EAI_PROTOCOL */
|
||||
};
|
||||
|
||||
#ifndef EAI_MAX
|
||||
#define EAI_MAX (sizeof(ai_errlist)/sizeof(ai_errlist[0]))
|
||||
#endif
|
||||
|
||||
/* on MingW, gai_strerror is available.
|
||||
We need to compile gai_strerrorA only for Cygwin
|
||||
*/
|
||||
#ifndef gai_strerror
|
||||
|
||||
char *
|
||||
WSAAPI gai_strerrorA(int ecode)
|
||||
{
|
||||
if (ecode >= 0 && ecode < EAI_MAX)
|
||||
return ai_errlist[ecode];
|
||||
return "Unknown error";
|
||||
}
|
||||
|
||||
#endif /* gai_strerror */
|
||||
1129
libpcap/Win32/Src/getaddrinfo.c
Normal file
1129
libpcap/Win32/Src/getaddrinfo.c
Normal file
File diff suppressed because it is too large
Load Diff
44
libpcap/Win32/Src/getnetbynm.c
Normal file
44
libpcap/Win32/Src/getnetbynm.c
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by the University of California, Berkeley. The name of the
|
||||
* University may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)getnetbyname.c 5.5 (Berkeley) 6/27/88";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "inetprivate.h"
|
||||
|
||||
extern int _net_stayopen;
|
||||
|
||||
struct netent *
|
||||
getnetbyname(const char *name)
|
||||
{
|
||||
register struct netent *p;
|
||||
register char **cp;
|
||||
|
||||
setnetent(_net_stayopen);
|
||||
while (p = getnetent()) {
|
||||
if (strcmp(p->n_name, name) == 0)
|
||||
break;
|
||||
for (cp = p->n_aliases; *cp != 0; cp++)
|
||||
if (strcmp(*cp, name) == 0)
|
||||
goto found;
|
||||
}
|
||||
found:
|
||||
if (!_net_stayopen)
|
||||
endnetent();
|
||||
return (p);
|
||||
}
|
||||
119
libpcap/Win32/Src/getnetent.c
Normal file
119
libpcap/Win32/Src/getnetent.c
Normal file
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by the University of California, Berkeley. The name of the
|
||||
* University may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)getnetent.c 5.5 (Berkeley) 6/27/88";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "inetprivate.h"
|
||||
|
||||
#define MAXALIASES 35
|
||||
|
||||
static char NETDB[] = _PATH_NETWORKS;
|
||||
static FILE *netf = NULL;
|
||||
static char line[BUFSIZ+1];
|
||||
static struct netent net;
|
||||
static char *net_aliases[MAXALIASES];
|
||||
static char *any(char *, char *);
|
||||
|
||||
int _net_stayopen;
|
||||
extern u_int32_t inet_network(const char *cp);
|
||||
|
||||
void
|
||||
setnetent(f)
|
||||
int f;
|
||||
{
|
||||
if (netf == NULL)
|
||||
netf = fopen(NETDB, "r" );
|
||||
else
|
||||
rewind(netf);
|
||||
_net_stayopen |= f;
|
||||
}
|
||||
|
||||
void
|
||||
endnetent()
|
||||
{
|
||||
if (netf) {
|
||||
fclose(netf);
|
||||
netf = NULL;
|
||||
}
|
||||
_net_stayopen = 0;
|
||||
}
|
||||
|
||||
struct netent *
|
||||
getnetent()
|
||||
{
|
||||
char *p;
|
||||
register char *cp, **q;
|
||||
|
||||
if (netf == NULL && (netf = fopen(NETDB, "r" )) == NULL)
|
||||
return (NULL);
|
||||
again:
|
||||
p = fgets(line, BUFSIZ, netf);
|
||||
if (p == NULL)
|
||||
return (NULL);
|
||||
if (*p == '#')
|
||||
goto again;
|
||||
cp = any(p, "#\n");
|
||||
if (cp == NULL)
|
||||
goto again;
|
||||
*cp = '\0';
|
||||
net.n_name = p;
|
||||
cp = any(p, " \t");
|
||||
if (cp == NULL)
|
||||
goto again;
|
||||
*cp++ = '\0';
|
||||
while (*cp == ' ' || *cp == '\t')
|
||||
cp++;
|
||||
p = any(cp, " \t");
|
||||
if (p != NULL)
|
||||
*p++ = '\0';
|
||||
net.n_net = inet_network(cp);
|
||||
net.n_addrtype = AF_INET;
|
||||
q = net.n_aliases = net_aliases;
|
||||
if (p != NULL)
|
||||
cp = p;
|
||||
while (cp && *cp) {
|
||||
if (*cp == ' ' || *cp == '\t') {
|
||||
cp++;
|
||||
continue;
|
||||
}
|
||||
if (q < &net_aliases[MAXALIASES - 1])
|
||||
*q++ = cp;
|
||||
cp = any(cp, " \t");
|
||||
if (cp != NULL)
|
||||
*cp++ = '\0';
|
||||
}
|
||||
*q = NULL;
|
||||
return (&net);
|
||||
}
|
||||
|
||||
static char *
|
||||
any(cp, match)
|
||||
register char *cp;
|
||||
char *match;
|
||||
{
|
||||
register char *mp, c;
|
||||
|
||||
while (c = *cp) {
|
||||
for (mp = match; *mp; mp++)
|
||||
if (*mp == c)
|
||||
return (cp);
|
||||
cp++;
|
||||
}
|
||||
return ((char *)0);
|
||||
}
|
||||
121
libpcap/Win32/Src/getopt.c
Normal file
121
libpcap/Win32/Src/getopt.c
Normal file
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright (c) 1987, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int opterr = 1, /* if error message should be printed */
|
||||
optind = 1, /* index into parent argv vector */
|
||||
optopt, /* character checked for validity */
|
||||
optreset; /* reset getopt */
|
||||
char *optarg; /* argument associated with option */
|
||||
|
||||
#define BADCH (int)'?'
|
||||
#define BADARG (int)':'
|
||||
#define EMSG ""
|
||||
|
||||
/*
|
||||
* getopt --
|
||||
* Parse argc/argv argument vector.
|
||||
*/
|
||||
int
|
||||
getopt(nargc, nargv, ostr)
|
||||
int nargc;
|
||||
char * const *nargv;
|
||||
const char *ostr;
|
||||
{
|
||||
#ifdef WIN32
|
||||
char *__progname="windump";
|
||||
#else
|
||||
extern char *__progname;
|
||||
#endif
|
||||
static char *place = EMSG; /* option letter processing */
|
||||
char *oli; /* option letter list index */
|
||||
|
||||
if (optreset || !*place) { /* update scanning pointer */
|
||||
optreset = 0;
|
||||
if (optind >= nargc || *(place = nargv[optind]) != '-') {
|
||||
place = EMSG;
|
||||
return (-1);
|
||||
}
|
||||
if (place[1] && *++place == '-') { /* found "--" */
|
||||
++optind;
|
||||
place = EMSG;
|
||||
return (-1);
|
||||
}
|
||||
} /* option letter okay? */
|
||||
if ((optopt = (int)*place++) == (int)':' ||
|
||||
!(oli = strchr(ostr, optopt))) {
|
||||
/*
|
||||
* if the user didn't specify '-' as an option,
|
||||
* assume it means -1.
|
||||
*/
|
||||
if (optopt == (int)'-')
|
||||
return (-1);
|
||||
if (!*place)
|
||||
++optind;
|
||||
if (opterr && *ostr != ':')
|
||||
(void)fprintf(stderr,
|
||||
"%s: illegal option -- %c\n", __progname, optopt);
|
||||
return (BADCH);
|
||||
}
|
||||
if (*++oli != ':') { /* don't need argument */
|
||||
optarg = NULL;
|
||||
if (!*place)
|
||||
++optind;
|
||||
}
|
||||
else { /* need an argument */
|
||||
if (*place) /* no white space */
|
||||
optarg = place;
|
||||
else if (nargc <= ++optind) { /* no arg */
|
||||
place = EMSG;
|
||||
if (*ostr == ':')
|
||||
return (BADARG);
|
||||
if (opterr)
|
||||
(void)fprintf(stderr,
|
||||
"%s: option requires an argument -- %c\n",
|
||||
__progname, optopt);
|
||||
return (BADCH);
|
||||
}
|
||||
else /* white space */
|
||||
optarg = nargv[optind];
|
||||
place = EMSG;
|
||||
++optind;
|
||||
}
|
||||
return (optopt); /* dump back option letter */
|
||||
}
|
||||
125
libpcap/Win32/Src/getservent.c
Normal file
125
libpcap/Win32/Src/getservent.c
Normal file
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)getservent.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <net/netdb.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <arpa/nameser.h>
|
||||
|
||||
#define MAXALIASES 35
|
||||
|
||||
static char SERVDB[] = _PATH_SERVICES;
|
||||
static FILE *servf = NULL;
|
||||
static char line[BUFSIZ+1];
|
||||
static struct servent serv;
|
||||
static char *serv_aliases[MAXALIASES];
|
||||
int _serv_stayopen;
|
||||
|
||||
void
|
||||
setservent(f)
|
||||
int f;
|
||||
{
|
||||
if (servf == NULL)
|
||||
servf = fopen(SERVDB, "r" );
|
||||
else
|
||||
rewind(servf);
|
||||
_serv_stayopen |= f;
|
||||
}
|
||||
|
||||
void
|
||||
endservent()
|
||||
{
|
||||
if (servf) {
|
||||
fclose(servf);
|
||||
servf = NULL;
|
||||
}
|
||||
_serv_stayopen = 0;
|
||||
}
|
||||
|
||||
struct servent *
|
||||
getservent()
|
||||
{
|
||||
char *p;
|
||||
register char *cp, **q;
|
||||
|
||||
if (servf == NULL && (servf = fopen(SERVDB, "r" )) == NULL)
|
||||
return (NULL);
|
||||
again:
|
||||
if ((p = fgets(line, BUFSIZ, servf)) == NULL)
|
||||
return (NULL);
|
||||
if (*p == '#')
|
||||
goto again;
|
||||
cp = strpbrk(p, "#\n");
|
||||
if (cp == NULL)
|
||||
goto again;
|
||||
*cp = '\0';
|
||||
serv.s_name = p;
|
||||
p = strpbrk(p, " \t");
|
||||
if (p == NULL)
|
||||
goto again;
|
||||
*p++ = '\0';
|
||||
while (*p == ' ' || *p == '\t')
|
||||
p++;
|
||||
cp = strpbrk(p, ",/");
|
||||
if (cp == NULL)
|
||||
goto again;
|
||||
*cp++ = '\0';
|
||||
serv.s_port = htons((u_short)atoi(p));
|
||||
serv.s_proto = cp;
|
||||
q = serv.s_aliases = serv_aliases;
|
||||
cp = strpbrk(cp, " \t");
|
||||
if (cp != NULL)
|
||||
*cp++ = '\0';
|
||||
while (cp && *cp) {
|
||||
if (*cp == ' ' || *cp == '\t') {
|
||||
cp++;
|
||||
continue;
|
||||
}
|
||||
if (q < &serv_aliases[MAXALIASES - 1])
|
||||
*q++ = cp;
|
||||
cp = strpbrk(cp, " \t");
|
||||
if (cp != NULL)
|
||||
*cp++ = '\0';
|
||||
}
|
||||
*q = NULL;
|
||||
return (&serv);
|
||||
}
|
||||
61
libpcap/Win32/Src/inet_aton.c
Normal file
61
libpcap/Win32/Src/inet_aton.c
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 1996, 1997 Kungliga Tekniska H<>gskolan
|
||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the Kungliga Tekniska
|
||||
* H<>gskolan and its contributors.
|
||||
*
|
||||
* 4. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* $Id: inet_aton.c,v 1.2 2003-11-15 23:24:06 guy Exp $ */
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/Win32/Src/inet_aton.c,v 1.2 2003-11-15 23:24:06 guy Exp $";
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <pcap-stdinc.h>
|
||||
|
||||
/* Minimal implementation of inet_aton.
|
||||
* Cannot distinguish between failure and a local broadcast address. */
|
||||
|
||||
#ifndef INADDR_NONE
|
||||
#define INADDR_NONE 0xffffffff
|
||||
#endif
|
||||
|
||||
int
|
||||
inet_aton(const char *cp, struct in_addr *addr)
|
||||
{
|
||||
addr->s_addr = inet_addr(cp);
|
||||
return (addr->s_addr == INADDR_NONE) ? 0 : 1;
|
||||
}
|
||||
101
libpcap/Win32/Src/inet_net.c
Normal file
101
libpcap/Win32/Src/inet_net.c
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)inet_network.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "inetprivate.h"
|
||||
|
||||
/*
|
||||
* Internet network address interpretation routine.
|
||||
* The library routines call this routine to interpret
|
||||
* network numbers.
|
||||
*/
|
||||
u_int32_t
|
||||
inet_network(const char *cp)
|
||||
{
|
||||
register u_long val, base, n;
|
||||
register char c;
|
||||
u_long parts[4], *pp = parts;
|
||||
register int i;
|
||||
|
||||
again:
|
||||
/*
|
||||
* Collect number up to ``.''.
|
||||
* Values are specified as for C:
|
||||
* 0x=hex, 0=octal, other=decimal.
|
||||
*/
|
||||
val = 0; base = 10;
|
||||
/*
|
||||
* The 4.4BSD version of this file also accepts 'x__' as a hexa
|
||||
* number. I don't think this is correct. -- Uli
|
||||
*/
|
||||
if (*cp == '0') {
|
||||
if (*++cp == 'x' || *cp == 'X')
|
||||
base = 16, cp++;
|
||||
else
|
||||
base = 8;
|
||||
}
|
||||
while ((c = *cp)) {
|
||||
if (isdigit(c)) {
|
||||
val = (val * base) + (c - '0');
|
||||
cp++;
|
||||
continue;
|
||||
}
|
||||
if (base == 16 && isxdigit(c)) {
|
||||
val = (val << 4) + (c + 10 - (islower(c) ? 'a' : 'A'));
|
||||
cp++;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (*cp == '.') {
|
||||
if (pp >= parts + 4)
|
||||
return (INADDR_NONE);
|
||||
*pp++ = val, cp++;
|
||||
goto again;
|
||||
}
|
||||
if (*cp && !isspace(*cp))
|
||||
return (INADDR_NONE);
|
||||
*pp++ = val;
|
||||
n = pp - parts;
|
||||
if (n > 4)
|
||||
return (INADDR_NONE);
|
||||
for (val = 0, i = 0; i < (int)n; i++) {
|
||||
val <<= 8;
|
||||
val |= parts[i] & 0xff;
|
||||
}
|
||||
return (val);
|
||||
}
|
||||
71
libpcap/Win32/Src/inet_pton.c
Normal file
71
libpcap/Win32/Src/inet_pton.c
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 1999 Kungliga Tekniska H<>gskolan
|
||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the Kungliga Tekniska
|
||||
* H<>gskolan and its contributors.
|
||||
*
|
||||
* 4. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* $Id: inet_pton.c,v 1.3 2007-09-27 18:02:20 gianluca Exp $ */
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/Win32/Src/inet_pton.c,v 1.3 2007-09-27 18:02:20 gianluca Exp $";
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#ifndef EAFNOSUPPORT
|
||||
#define EAFNOSUPPORT 97 /* not present in errno.h provided with VC */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __MINGW32__
|
||||
int* _errno();
|
||||
#define errno (*_errno())
|
||||
#endif /* __MINGW32__ */
|
||||
|
||||
#include <pcap-stdinc.h>
|
||||
|
||||
int inet_aton(const char *cp, struct in_addr *addr);
|
||||
|
||||
int
|
||||
inet_pton(int af, const char *src, void *dst)
|
||||
{
|
||||
if (af != AF_INET) {
|
||||
errno = EAFNOSUPPORT;
|
||||
return -1;
|
||||
}
|
||||
return inet_aton (src, dst);
|
||||
}
|
||||
22
libpcap/aclocal.m4
vendored
22
libpcap/aclocal.m4
vendored
@@ -245,7 +245,24 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT,
|
||||
# or accepts command-line arguments like
|
||||
# those the GNU linker accepts.
|
||||
#
|
||||
V_CCOPT="$V_CCOPT -fpic"
|
||||
# Some instruction sets require -fPIC on some
|
||||
# operating systems. Check for them. If you
|
||||
# have a combination that requires it, add it
|
||||
# here.
|
||||
#
|
||||
PIC_OPT=-fpic
|
||||
case "$host_cpu" in
|
||||
|
||||
sparc64*)
|
||||
case "$host_os" in
|
||||
|
||||
freebsd*)
|
||||
PIC_OPT=-fPIC
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
V_CCOPT="$V_CCOPT $PIC_OPT"
|
||||
V_SONAME_OPT="-Wl,-soname,"
|
||||
V_RPATH_OPT="-Wl,-rpath,"
|
||||
;;
|
||||
@@ -978,8 +995,9 @@ dnl code that would use that member, or we wouldn't compile in any case).
|
||||
dnl
|
||||
AC_DEFUN(AC_LBL_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI,
|
||||
[AC_MSG_CHECKING(if tpacket_auxdata struct has tp_vlan_tci member)
|
||||
AC_CACHE_VAL(ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1,
|
||||
AC_CACHE_VAL(ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci,
|
||||
AC_TRY_COMPILE([
|
||||
# include <sys/types.h>
|
||||
# include <linux/if_packet.h>],
|
||||
[u_int i = sizeof(((struct tpacket_auxdata *)0)->tp_vlan_tci)],
|
||||
ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci=yes,
|
||||
|
||||
@@ -405,7 +405,18 @@ bpf_filter(pc, p, wirelen, buflen)
|
||||
continue;
|
||||
|
||||
case BPF_JMP|BPF_JA:
|
||||
#if defined(KERNEL) || defined(_KERNEL)
|
||||
/*
|
||||
* No backward jumps allowed.
|
||||
*/
|
||||
pc += pc->k;
|
||||
#else
|
||||
/*
|
||||
* XXX - we currently implement "ip6 protochain"
|
||||
* with backward jumps, so sign-extend pc->k.
|
||||
*/
|
||||
pc += (bpf_int32)pc->k;
|
||||
#endif
|
||||
continue;
|
||||
|
||||
case BPF_JMP|BPF_JGT|BPF_K:
|
||||
@@ -608,7 +619,7 @@ bpf_validate(f, len)
|
||||
/*
|
||||
* Check for constant division by 0.
|
||||
*/
|
||||
if (BPF_RVAL(p->code) == BPF_K && p->k == 0)
|
||||
if (BPF_SRC(p->code) == BPF_K && p->k == 0)
|
||||
return 0;
|
||||
break;
|
||||
default:
|
||||
|
||||
1502
libpcap/config.guess
vendored
Executable file
1502
libpcap/config.guess
vendored
Executable file
File diff suppressed because it is too large
Load Diff
@@ -18,6 +18,9 @@
|
||||
/* define if you have streams capable DAG API */
|
||||
#undef HAVE_DAG_STREAMS_API
|
||||
|
||||
/* define if you have vdag_set_device_info() */
|
||||
#undef HAVE_DAG_VDAG
|
||||
|
||||
/* Define to 1 if you have the declaration of `ether_hostton', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_ETHER_HOSTTON
|
||||
@@ -52,15 +55,30 @@
|
||||
/* if libnl exists */
|
||||
#undef HAVE_LIBNL
|
||||
|
||||
/* if libnl exists and is version 2.x */
|
||||
#undef HAVE_LIBNL_2_x
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#undef HAVE_LIMITS_H
|
||||
|
||||
/* Define to 1 if you have the <linux/compiler.h> header file. */
|
||||
#undef HAVE_LINUX_COMPILER_H
|
||||
|
||||
/* Define to 1 if you have the <linux/ethtool.h> header file. */
|
||||
#undef HAVE_LINUX_ETHTOOL_H
|
||||
|
||||
/* Define to 1 if you have the <linux/if_packet.h> header file. */
|
||||
#undef HAVE_LINUX_IF_PACKET_H
|
||||
|
||||
/* Define to 1 if you have the <linux/net_tstamp.h> header file. */
|
||||
#undef HAVE_LINUX_NET_TSTAMP_H
|
||||
|
||||
/* if tp_vlan_tci exists */
|
||||
#undef HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI
|
||||
|
||||
/* Define to 1 if you have the <linux/types.h> header file. */
|
||||
#undef HAVE_LINUX_TYPES_H
|
||||
|
||||
/* Define to 1 if you have the <linux/usbdevice_fs.h> header file. */
|
||||
#undef HAVE_LINUX_USBDEVICE_FS_H
|
||||
|
||||
@@ -76,6 +94,12 @@
|
||||
/* Define to 1 if you have the <netinet/if_ether.h> header file. */
|
||||
#undef HAVE_NETINET_IF_ETHER_H
|
||||
|
||||
/* Define to 1 if you have the <netpacket/if_packet.h> header file. */
|
||||
#undef HAVE_NETPACKET_IF_PACKET_H
|
||||
|
||||
/* Define to 1 if you have the <netpacket/packet.h> header file. */
|
||||
#undef HAVE_NETPACKET_PACKET_H
|
||||
|
||||
/* Define to 1 if you have the <net/if_media.h> header file. */
|
||||
#undef HAVE_NET_IF_MEDIA_H
|
||||
|
||||
@@ -220,8 +244,8 @@
|
||||
/* target host supports CAN sniffing */
|
||||
#undef PCAP_SUPPORT_CAN
|
||||
|
||||
/* use Linux packet ring capture if available */
|
||||
#undef PCAP_SUPPORT_PACKET_RING
|
||||
/* target host supports netfilter sniffing */
|
||||
#undef PCAP_SUPPORT_NETFILTER
|
||||
|
||||
/* target host supports USB sniffing */
|
||||
#undef PCAP_SUPPORT_USB
|
||||
|
||||
1708
libpcap/config.sub
vendored
Executable file
1708
libpcap/config.sub
vendored
Executable file
File diff suppressed because it is too large
Load Diff
1345
libpcap/configure
vendored
1345
libpcap/configure
vendored
File diff suppressed because it is too large
Load Diff
@@ -103,6 +103,8 @@ dnl and set "HAVE_SYS_IOCCOM_H" if we have it, otherwise
|
||||
dnl "AC_LBL_FIXINCLUDES" wouldn't work on some platforms such as Solaris.
|
||||
dnl
|
||||
AC_CHECK_HEADERS(sys/ioccom.h sys/sockio.h limits.h paths.h)
|
||||
AC_CHECK_HEADERS(linux/types.h)
|
||||
AC_CHECK_HEADERS(linux/if_packet.h netpacket/packet.h netpacket/if_packet.h)
|
||||
AC_CHECK_HEADERS(net/pfvar.h, , , [#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <net/if.h>])
|
||||
@@ -152,7 +154,7 @@ needsnprintf=no
|
||||
AC_CHECK_FUNCS(vsnprintf snprintf,,
|
||||
[needsnprintf=yes])
|
||||
if test $needsnprintf = yes; then
|
||||
AC_LIBOBJ(snprintf)
|
||||
AC_LIBOBJ([snprintf])
|
||||
fi
|
||||
|
||||
#
|
||||
@@ -410,23 +412,6 @@ dlpi)
|
||||
;;
|
||||
|
||||
linux)
|
||||
AC_MSG_CHECKING(Linux kernel version)
|
||||
if test "$cross_compiling" = yes; then
|
||||
AC_CACHE_VAL(ac_cv_linux_vers,
|
||||
ac_cv_linux_vers=unknown)
|
||||
else
|
||||
AC_CACHE_VAL(ac_cv_linux_vers,
|
||||
ac_cv_linux_vers=`uname -r 2>&1 | \
|
||||
sed -n -e '$s/.* //' -e '$s/\..*//p'`)
|
||||
fi
|
||||
AC_MSG_RESULT($ac_cv_linux_vers)
|
||||
if test $ac_cv_linux_vers = unknown ; then
|
||||
AC_MSG_ERROR(cannot determine linux version when cross-compiling)
|
||||
fi
|
||||
if test $ac_cv_linux_vers -lt 2 ; then
|
||||
AC_MSG_ERROR(version 2 or higher required; see the INSTALL doc for more info)
|
||||
fi
|
||||
|
||||
#
|
||||
# Do we have the wireless extensions?
|
||||
#
|
||||
@@ -445,15 +430,46 @@ linux)
|
||||
with_libnl=$withval,,)
|
||||
|
||||
if test x$with_libnl != xno ; then
|
||||
AC_CHECK_LIB(nl, nl_handle_alloc,
|
||||
LIBS="-lnl $LIBS"
|
||||
AC_DEFINE(HAVE_LIBNL,1,[if libnl exists]),
|
||||
if test x$with_libnl = xyes ; then
|
||||
AC_MSG_ERROR([libnl support requested but libnl not found])
|
||||
fi
|
||||
)
|
||||
#
|
||||
# Try libnl 2.x first.
|
||||
#
|
||||
AC_CHECK_LIB(nl, nl_socket_alloc,
|
||||
[
|
||||
#
|
||||
# Yes, we have libnl 2.x.
|
||||
#
|
||||
LIBS="-lnl-genl -lnl $LIBS"
|
||||
AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
|
||||
AC_DEFINE(HAVE_LIBNL_2_x,1,[if libnl exists and is version 2.x])
|
||||
],
|
||||
[
|
||||
#
|
||||
# No, we don't; do we have libnl 1.x?
|
||||
#
|
||||
AC_CHECK_LIB(nl, nl_handle_alloc,
|
||||
[
|
||||
#
|
||||
# Yes.
|
||||
#
|
||||
LIBS="-lnl $LIBS"
|
||||
AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
|
||||
],
|
||||
[
|
||||
#
|
||||
# No, we don't have libnl at all.
|
||||
#
|
||||
if test x$with_libnl = xyes ; then
|
||||
AC_MSG_ERROR([libnl support requested but libnl not found])
|
||||
fi
|
||||
])
|
||||
])
|
||||
fi
|
||||
|
||||
AC_CHECK_HEADERS(linux/ethtool.h,,,
|
||||
[
|
||||
AC_INCLUDES_DEFAULT
|
||||
#include <linux/types.h>
|
||||
])
|
||||
AC_LBL_TPACKET_STATS
|
||||
AC_LBL_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI
|
||||
;;
|
||||
@@ -727,7 +743,7 @@ if test "$want_dag" != no; then
|
||||
|
||||
if test -z "$dag_tools_dir"; then
|
||||
dag_tools_dir="$dag_root/tools"
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -r $dag_include_dir/dagapi.h; then
|
||||
ac_cv_lbl_dag_api=yes
|
||||
@@ -735,131 +751,9 @@ if test "$want_dag" != no; then
|
||||
AC_MSG_RESULT([$ac_cv_lbl_dag_api ($dag_include_dir)])
|
||||
fi
|
||||
|
||||
if test $ac_cv_lbl_dag_api = yes; then
|
||||
|
||||
AC_MSG_CHECKING([dagapi.o])
|
||||
dagapi_obj=no
|
||||
if test -r $dag_tools_dir/dagapi.o; then
|
||||
# 2.4.x.
|
||||
dagapi_obj=$dag_tools_dir/dagapi.o
|
||||
elif test -r $dag_lib_dir/dagapi.o; then
|
||||
# 2.5.x.
|
||||
dagapi_obj=$dag_lib_dir/dagapi.o
|
||||
elif test -r $dag_lib_dir/libdag.a; then
|
||||
# 2.5.x.
|
||||
ar x $dag_lib_dir/libdag.a dagapi.o 2>/dev/null
|
||||
if test -r ./dagapi.o; then
|
||||
dagapi_obj=./dagapi.o
|
||||
else
|
||||
ar x $dag_lib_dir/libdag.a libdag_la-dagapi.o 2>/dev/null
|
||||
if test -r ./libdag_la-dagapi.o; then
|
||||
dagapi_obj=./libdag_la-dagapi.o
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $dagapi_obj = no; then
|
||||
AC_MSG_RESULT([no (checked $dag_lib_dir $dag_tools_dir $dag_lib_dir/libdag.a)])
|
||||
ac_cv_lbl_dag_api=no
|
||||
else
|
||||
AC_MSG_RESULT([yes ($dagapi_obj)])
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $ac_cv_lbl_dag_api = yes; then
|
||||
|
||||
AC_MSG_CHECKING([dagopts.o])
|
||||
dagopts_obj=no
|
||||
if test -r $dag_tools_dir/dagopts.o; then
|
||||
# 2.4.x.
|
||||
dagopts_obj=$dag_tools_dir/dagopts.o
|
||||
elif test -r $dag_lib_dir/dagopts.o; then
|
||||
# 2.5.x.
|
||||
dagopts_obj=$dag_lib_dir/dagopts.o
|
||||
elif test -r $dag_lib_dir/libdag.a; then
|
||||
# 2.5.x.
|
||||
ar x $dag_lib_dir/libdag.a dagopts.o 2>/dev/null
|
||||
if test -r ./dagopts.o; then
|
||||
dagopts_obj=./dagopts.o
|
||||
else
|
||||
ar x $dag_lib_dir/libdag.a libdag_la-dagopts.o 2>/dev/null
|
||||
if test -r ./libdag_la-dagopts.o; then
|
||||
dagopts_obj=./libdag_la-dagopts.o
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $dagopts_obj = no; then
|
||||
AC_MSG_RESULT([no (checked $dag_lib_dir $dag_tools_dir $dag_lib_dir/libdag.a)])
|
||||
ac_cv_lbl_dag_api=no
|
||||
else
|
||||
AC_MSG_RESULT([yes ($dagopts_obj)])
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $ac_cv_lbl_dag_api = yes; then
|
||||
# Under 2.5.x only we need to add dagreg.o.
|
||||
if test -r $dag_include_dir/dagreg.h; then
|
||||
AC_MSG_CHECKING([dagreg.o])
|
||||
dagreg_obj=no
|
||||
if test -r $dag_lib_dir/dagreg.o; then
|
||||
# Object file is ready and waiting.
|
||||
dagreg_obj=$dag_lib_dir/dagreg.o
|
||||
elif test -r $dag_lib_dir/libdag.a; then
|
||||
# Extract from libdag.a.
|
||||
ar x $dag_lib_dir/libdag.a dagreg.o 2>/dev/null
|
||||
if test -r ./dagreg.o; then
|
||||
dagreg_obj=./dagreg.o
|
||||
else
|
||||
ar x $dag_lib_dir/libdag.a libdag_la-dagreg.o 2>/dev/null
|
||||
if test -r ./libdag_la-dagreg.o; then
|
||||
dagreg_obj=./libdag_la-dagreg.o
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $dagreg_obj = no; then
|
||||
AC_MSG_RESULT([no (checked $dag_lib_dir $dag_lib_dir/libdag.a)])
|
||||
ac_cv_lbl_dag_api=no
|
||||
else
|
||||
AC_MSG_RESULT([yes ($dagreg_obj)])
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $ac_cv_lbl_dag_api = yes; then
|
||||
# Under 2.5.x only we need to add dagutil.o.
|
||||
if test -r $dag_include_dir/dagutil.h; then
|
||||
AC_MSG_CHECKING([dagutil.o])
|
||||
dagutil_obj=no
|
||||
if test -r $dag_lib_dir/dagutil.o; then
|
||||
# Object file is ready and waiting.
|
||||
dagutil_obj=$dag_lib_dir/dagutil.o
|
||||
elif test -r $dag_lib_dir/libdag.a; then
|
||||
# Extract from libdag.a.
|
||||
ar x $dag_lib_dir/libdag.a dagutil.o 2>/dev/null
|
||||
if test -r ./dagutil.o; then
|
||||
dagutil_obj=./dagutil.o
|
||||
else
|
||||
ar x $dag_lib_dir/libdag.a libdag_la-dagutil.o 2>/dev/null
|
||||
if test -r ./libdag_la-dagutil.o; then
|
||||
dagutil_obj=./libdag_la-dagutil.o
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $dagutil_obj = no; then
|
||||
AC_MSG_RESULT([no (checked $dag_lib_dir $dag_lib_dir/libdag.a)])
|
||||
ac_cv_lbl_dag_api=no
|
||||
else
|
||||
AC_MSG_RESULT([yes ($dagutil_obj)])
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $ac_cv_lbl_dag_api = yes; then
|
||||
V_INCLS="$V_INCLS -I$dag_include_dir"
|
||||
ADDLARCHIVEOBJS="$ADDLARCHIVEOBJS $dagapi_obj $dagopts_obj $dagreg_obj $dagutil_obj"
|
||||
|
||||
if test $V_PCAP != dag ; then
|
||||
SSRC="pcap-dag.c"
|
||||
fi
|
||||
@@ -874,11 +768,19 @@ if test $ac_cv_lbl_dag_api = yes; then
|
||||
AC_DEFINE(HAVE_DAG_GET_ERF_TYPES, 1, [define if you have dag_get_erf_types()])])
|
||||
AC_CHECK_LIB([dag],[dag_get_stream_erf_types], [
|
||||
AC_DEFINE(HAVE_DAG_GET_STREAM_ERF_TYPES, 1, [define if you have dag_get_stream_erf_types()])])
|
||||
|
||||
LDFLAGS=$saved_ldflags
|
||||
|
||||
if test "$dag_streams" = 1; then
|
||||
AC_DEFINE(HAVE_DAG_STREAMS_API, 1, [define if you have streams capable DAG API])
|
||||
LIBS="$LIBS -ldag"
|
||||
LDFLAGS="$LDFLAGS -L$dag_lib_dir"
|
||||
|
||||
AC_CHECK_LIB([vdag],[vdag_set_device_info], [ac_dag_have_vdag="1"], [ac_dag_have_vdag="0"])
|
||||
if test "$ac_dag_have_vdag" = 1; then
|
||||
AC_DEFINE(HAVE_DAG_VDAG, 1, [define if you have vdag_set_device_info()])
|
||||
LIBS="$LIBS -lpthread"
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API])
|
||||
@@ -1151,6 +1053,46 @@ aix*)
|
||||
darwin*)
|
||||
DYEXT="dylib"
|
||||
V_CCOPT="$V_CCOPT -fno-common"
|
||||
AC_ARG_ENABLE(universal,
|
||||
AC_HELP_STRING([--disable-universal],[don't build universal on OS X]))
|
||||
if test "$enable_universal" != "no"; then
|
||||
case "$host_os" in
|
||||
|
||||
darwin9.*)
|
||||
#
|
||||
# Leopard. Build for 32-bit PowerPC, 64-bit
|
||||
# PowerPC, x86, and x86-64, with 32-bit PowerPC
|
||||
# first. (That's what Apple does.)
|
||||
#
|
||||
V_CCOPT="$V_CCOPT -arch ppc -arch ppc64 -arch i386 -arch x86_64"
|
||||
LDFLAGS="$LDFLAGS -arch ppc -arch ppc64 -arch i386 -arch x86_64"
|
||||
;;
|
||||
|
||||
darwin10.*)
|
||||
#
|
||||
# Snow Leopard. Build for x86-64, x86, and
|
||||
# 32-bit PowerPC, with x86-64 first. (That's
|
||||
# what Apple does, even though Snow Leopard
|
||||
# doesn't run on PPC, so PPC libpcap runs under
|
||||
# Rosetta, and Rosetta doesn't support BPF
|
||||
# ioctls, so PPC programs can't do live
|
||||
# captures.)
|
||||
#
|
||||
V_CCOPT="$V_CCOPT -arch x86_64 -arch i386 -arch ppc"
|
||||
LDFLAGS="$LDFLAGS -arch x86_64 -arch i386 -arch ppc"
|
||||
;;
|
||||
|
||||
darwin11.*)
|
||||
#
|
||||
# Lion. Build for x86-64 and x86, with x86-64
|
||||
# first. (That's probably what Apple does,
|
||||
# given that Rosetta is gone.)
|
||||
#
|
||||
V_CCOPT="$V_CCOPT -arch x86_64 -arch i386"
|
||||
LDFLAGS="$LDFLAGS -arch x86_64 -arch i386"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
;;
|
||||
|
||||
hpux9*)
|
||||
@@ -1216,7 +1158,7 @@ irix*)
|
||||
MAN_MISC_INFO=5
|
||||
;;
|
||||
|
||||
linux*|freebsd*|netbsd*|openbsd*|dragonfly*)
|
||||
linux*|freebsd*|netbsd*|openbsd*|dragonfly*|kfreebsd*|gnu*)
|
||||
DYEXT="so"
|
||||
|
||||
#
|
||||
@@ -1265,6 +1207,7 @@ solaris*)
|
||||
esac
|
||||
|
||||
AC_PROG_RANLIB
|
||||
AC_CHECK_TOOL([AR], [ar])
|
||||
|
||||
AC_LBL_DEVEL(V_CCOPT)
|
||||
|
||||
@@ -1305,38 +1248,38 @@ dnl check for USB sniffing support
|
||||
AC_MSG_CHECKING(for USB sniffing support)
|
||||
case "$host_os" in
|
||||
linux*)
|
||||
AC_DEFINE(PCAP_SUPPORT_USB, 1, [target host supports USB sniffing])
|
||||
USB_SRC=pcap-usb-linux.c
|
||||
AC_MSG_RESULT(yes)
|
||||
ac_usb_dev_name=`udevinfo -q name -p /sys/class/usb_device/usbmon 2>/dev/null`
|
||||
if test $? -ne 0 ; then
|
||||
ac_usb_dev_name="usbmon"
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED(LINUX_USB_MON_DEV, "/dev/$ac_usb_dev_name", [path for device for USB sniffing])
|
||||
AC_MSG_NOTICE(Device for USB sniffing is /dev/$ac_usb_dev_name)
|
||||
#
|
||||
# Do we have a version of <linux/compiler.h> available?
|
||||
# If so, we might need it for <linux/usbdevice_fs.h>.
|
||||
#
|
||||
AC_CHECK_HEADERS(linux/compiler.h)
|
||||
if test "$ac_cv_header_linux_compiler_h" = yes; then
|
||||
#
|
||||
# Yes - include it when testing for <linux/usbdevice_fs.h>.
|
||||
#
|
||||
AC_CHECK_HEADERS(linux/usbdevice_fs.h,,,[#include <linux/compiler.h>])
|
||||
else
|
||||
AC_CHECK_HEADERS(linux/usbdevice_fs.h)
|
||||
fi
|
||||
if test "$ac_cv_header_linux_usbdevice_fs_h" = yes; then
|
||||
#
|
||||
# OK, does it define bRequestType? Older versions of the kernel
|
||||
# define fields with names like "requesttype, "request", and
|
||||
# "value", rather than "bRequestType", "bRequest", and
|
||||
# "wValue".
|
||||
#
|
||||
AC_MSG_CHECKING(if usbdevfs_ctrltransfer struct has bRequestType member)
|
||||
AC_CACHE_VAL(ac_cv_usbdevfs_ctrltransfer_has_bRequestType,
|
||||
AC_TRY_COMPILE([
|
||||
AC_DEFINE(PCAP_SUPPORT_USB, 1, [target host supports USB sniffing])
|
||||
USB_SRC=pcap-usb-linux.c
|
||||
AC_MSG_RESULT(yes)
|
||||
ac_usb_dev_name=`udevinfo -q name -p /sys/class/usb_device/usbmon 2>/dev/null`
|
||||
if test $? -ne 0 ; then
|
||||
ac_usb_dev_name="usbmon"
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED(LINUX_USB_MON_DEV, "/dev/$ac_usb_dev_name", [path for device for USB sniffing])
|
||||
AC_MSG_NOTICE(Device for USB sniffing is /dev/$ac_usb_dev_name)
|
||||
#
|
||||
# Do we have a version of <linux/compiler.h> available?
|
||||
# If so, we might need it for <linux/usbdevice_fs.h>.
|
||||
#
|
||||
AC_CHECK_HEADERS(linux/compiler.h)
|
||||
if test "$ac_cv_header_linux_compiler_h" = yes; then
|
||||
#
|
||||
# Yes - include it when testing for <linux/usbdevice_fs.h>.
|
||||
#
|
||||
AC_CHECK_HEADERS(linux/usbdevice_fs.h,,,[#include <linux/compiler.h>])
|
||||
else
|
||||
AC_CHECK_HEADERS(linux/usbdevice_fs.h)
|
||||
fi
|
||||
if test "$ac_cv_header_linux_usbdevice_fs_h" = yes; then
|
||||
#
|
||||
# OK, does it define bRequestType? Older versions of the kernel
|
||||
# define fields with names like "requesttype, "request", and
|
||||
# "value", rather than "bRequestType", "bRequest", and
|
||||
# "wValue".
|
||||
#
|
||||
AC_MSG_CHECKING(if usbdevfs_ctrltransfer struct has bRequestType member)
|
||||
AC_CACHE_VAL(ac_cv_usbdevfs_ctrltransfer_has_bRequestType,
|
||||
AC_TRY_COMPILE([
|
||||
AC_INCLUDES_DEFAULT
|
||||
#ifdef HAVE_SYS_BITYPES_H
|
||||
#include <sys/bitypes.h>
|
||||
@@ -1344,24 +1287,64 @@ AC_INCLUDES_DEFAULT
|
||||
#ifdef HAVE_LINUX_COMPILER_H
|
||||
#include <linux/compiler.h>
|
||||
#endif
|
||||
# include <linux/usbdevice_fs.h>],
|
||||
[u_int i = sizeof(((struct usbdevfs_ctrltransfer *)0)->bRequestType)],
|
||||
ac_cv_usbdevfs_ctrltransfer_has_bRequestType=yes,
|
||||
ac_cv_usbdevfs_ctrltransfer_has_bRequestType=no))
|
||||
AC_MSG_RESULT($ac_cv_usbdevfs_ctrltransfer_has_bRequestType)
|
||||
if test $ac_cv_usbdevfs_ctrltransfer_has_bRequestType = yes ; then
|
||||
AC_DEFINE(HAVE_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE,1,
|
||||
[if struct usbdevfs_ctrltransfer has bRequestType])
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
#include <linux/usbdevice_fs.h>],
|
||||
[u_int i = sizeof(((struct usbdevfs_ctrltransfer *)0)->bRequestType)],
|
||||
ac_cv_usbdevfs_ctrltransfer_has_bRequestType=yes,
|
||||
ac_cv_usbdevfs_ctrltransfer_has_bRequestType=no))
|
||||
AC_MSG_RESULT($ac_cv_usbdevfs_ctrltransfer_has_bRequestType)
|
||||
if test $ac_cv_usbdevfs_ctrltransfer_has_bRequestType = yes ; then
|
||||
AC_DEFINE(HAVE_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE,1,
|
||||
[if struct usbdevfs_ctrltransfer has bRequestType])
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
AC_MSG_RESULT(no)
|
||||
;;
|
||||
AC_MSG_RESULT(no)
|
||||
;;
|
||||
esac
|
||||
AC_SUBST(PCAP_SUPPORT_USB)
|
||||
AC_SUBST(USB_SRC)
|
||||
|
||||
dnl check for netfilter sniffing support
|
||||
AC_MSG_CHECKING(whether the platform could support netfilter sniffing)
|
||||
case "$host_os" in
|
||||
linux*)
|
||||
AC_MSG_RESULT(yes)
|
||||
#
|
||||
# Life's too short to deal with trying to get this to compile
|
||||
# if you don't get the right types defined with
|
||||
# __KERNEL_STRICT_NAMES getting defined by some other include.
|
||||
#
|
||||
# Check whether the includes Just Work. If not, don't turn on
|
||||
# netfilter support.
|
||||
#
|
||||
AC_MSG_CHECKING(whether we can compile the netfilter support)
|
||||
AC_CACHE_VAL(ac_cv_netfilter_can_compile,
|
||||
AC_TRY_COMPILE([
|
||||
AC_INCLUDES_DEFAULT
|
||||
#include <sys/socket.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
#include <linux/netlink.h>
|
||||
#include <linux/netfilter/nfnetlink.h>
|
||||
#include <linux/netfilter/nfnetlink_log.h>],
|
||||
[],
|
||||
ac_cv_netfilter_can_compile=yes,
|
||||
ac_cv_netfilter_can_compile=no))
|
||||
AC_MSG_RESULT($ac_cv_netfilter_can_compile)
|
||||
if test $ac_cv_netfilter_can_compile = yes ; then
|
||||
AC_DEFINE(PCAP_SUPPORT_NETFILTER, 1,
|
||||
[target host supports netfilter sniffing])
|
||||
NETFILTER_SRC=pcap-netfilter-linux.c
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
AC_MSG_RESULT(no)
|
||||
;;
|
||||
esac
|
||||
AC_SUBST(PCAP_SUPPORT_NETFILTER)
|
||||
AC_SUBST(NETFILTER_SRC)
|
||||
|
||||
AC_ARG_ENABLE([bluetooth],
|
||||
[AC_HELP_STRING([--enable-bluetooth],[enable Bluetooth support @<:@default=yes, if support available@:>@])],
|
||||
,enable_bluetooth=yes)
|
||||
@@ -1370,18 +1353,18 @@ if test "x$enable_bluetooth" != "xno" ; then
|
||||
dnl check for Bluetooth sniffing support
|
||||
case "$host_os" in
|
||||
linux*)
|
||||
AC_CHECK_HEADER(bluetooth/bluetooth.h,
|
||||
[
|
||||
AC_CHECK_HEADER(bluetooth/bluetooth.h,
|
||||
[
|
||||
AC_DEFINE(PCAP_SUPPORT_BT, 1, [target host supports Bluetooth sniffing])
|
||||
BT_SRC=pcap-bt-linux.c
|
||||
AC_MSG_NOTICE(Bluetooth sniffing is supported)
|
||||
BT_SRC=pcap-bt-linux.c
|
||||
AC_MSG_NOTICE(Bluetooth sniffing is supported)
|
||||
],
|
||||
AC_MSG_NOTICE(Bluetooth sniffing is not supported; install bluez-lib devel to enable it)
|
||||
)
|
||||
;;
|
||||
)
|
||||
;;
|
||||
*)
|
||||
AC_MSG_NOTICE(no Bluetooth sniffing support implemented for $host_os)
|
||||
;;
|
||||
AC_MSG_NOTICE(no Bluetooth sniffing support implemented for $host_os)
|
||||
;;
|
||||
esac
|
||||
AC_SUBST(PCAP_SUPPORT_BT)
|
||||
AC_SUBST(BT_SRC)
|
||||
@@ -1411,6 +1394,16 @@ if test "x$enable_can" != "xno" ; then
|
||||
AC_SUBST(CAN_SRC)
|
||||
fi
|
||||
|
||||
dnl check for hardware timestamp support
|
||||
case "$host_os" in
|
||||
linux*)
|
||||
AC_CHECK_HEADERS([linux/net_tstamp.h])
|
||||
;;
|
||||
*)
|
||||
AC_MSG_NOTICE(no hardware timestamp support implemented for $host_os)
|
||||
;;
|
||||
esac
|
||||
|
||||
dnl The packet ring capture facility of Linux, described in
|
||||
dnl Documentation/networking/packet_mmap.txt, is not 32/64-bit compatible before
|
||||
dnl version 2.6.27. A 32-bit kernel requires a 32-bit userland, and likewise for
|
||||
@@ -1434,10 +1427,11 @@ AC_PROG_INSTALL
|
||||
AC_CONFIG_HEADER(config.h)
|
||||
|
||||
AC_OUTPUT(Makefile pcap-filter.manmisc pcap-linktype.manmisc
|
||||
pcap-savefile.manfile pcap.3pcap pcap_compile.3pcap
|
||||
pcap_datalink.3pcap pcap_dump_open.3pcap
|
||||
pcap_list_datalinks.3pcap pcap_open_dead.3pcap
|
||||
pcap_open_offline.3pcap)
|
||||
pcap-tstamp.manmisc pcap-savefile.manfile pcap.3pcap
|
||||
pcap_compile.3pcap pcap_datalink.3pcap pcap_dump_open.3pcap
|
||||
pcap_list_datalinks.3pcap pcap_list_tstamp_types.3pcap
|
||||
pcap_open_dead.3pcap pcap_open_offline.3pcap
|
||||
pcap_set_tstamp_type.3pcap)
|
||||
|
||||
if test -f .devel ; then
|
||||
make depend
|
||||
|
||||
@@ -117,3 +117,6 @@
|
||||
#ifndef ETHERTYPE_LOOPBACK
|
||||
#define ETHERTYPE_LOOPBACK 0x9000
|
||||
#endif
|
||||
#ifndef ETHERTYPE_8021QINQ
|
||||
#define ETHERTYPE_8021QINQ 0x9100
|
||||
#endif
|
||||
|
||||
@@ -61,15 +61,21 @@ static const char rcsid[] _U_ =
|
||||
#endif
|
||||
|
||||
#ifdef AF_PACKET
|
||||
# ifdef HAVE_NETPACKET_PACKET_H
|
||||
/* Solaris 11 and later, Linux distributions with newer glibc */
|
||||
# include <netpacket/packet.h>
|
||||
# else /* HAVE_NETPACKET_PACKET_H */
|
||||
/* LynxOS, Linux distributions with older glibc */
|
||||
# ifdef __Lynx__
|
||||
/* LynxOS */
|
||||
# include <netpacket/if_packet.h>
|
||||
# else
|
||||
# else /* __Lynx__ */
|
||||
/* Linux */
|
||||
# include <linux/types.h>
|
||||
# include <linux/if_packet.h>
|
||||
# endif
|
||||
#endif
|
||||
# endif /* __Lynx__ */
|
||||
# endif /* HAVE_NETPACKET_PACKET_H */
|
||||
#endif /* AF_PACKET */
|
||||
|
||||
/*
|
||||
* This is fun.
|
||||
|
||||
@@ -47,7 +47,7 @@ static const char rcsid[] _U_ =
|
||||
* XXX - why was this included even on UNIX?
|
||||
*/
|
||||
#ifdef __MINGW32__
|
||||
#include "IP6_misc.h"
|
||||
#include "ip6_misc.h"
|
||||
#endif
|
||||
|
||||
#ifndef WIN32
|
||||
@@ -772,7 +772,8 @@ static int reg_off_ll;
|
||||
* This is the offset of the beginning of the MAC-layer header from
|
||||
* the beginning of the link-layer header.
|
||||
* It's usually 0, except for ATM LANE, where it's the offset, relative
|
||||
* to the beginning of the raw packet data, of the Ethernet header.
|
||||
* to the beginning of the raw packet data, of the Ethernet header, and
|
||||
* for Ethernet with various additional information.
|
||||
*/
|
||||
static u_int off_mac;
|
||||
|
||||
@@ -1238,26 +1239,6 @@ init_linktype(p)
|
||||
off_nl_nosnap = 0; /* no 802.2 LLC */
|
||||
return;
|
||||
|
||||
case DLT_LINUX_IRDA:
|
||||
/*
|
||||
* Currently, only raw "link[N:M]" filtering is supported.
|
||||
*/
|
||||
off_linktype = -1;
|
||||
off_macpl = -1;
|
||||
off_nl = -1;
|
||||
off_nl_nosnap = -1;
|
||||
return;
|
||||
|
||||
case DLT_DOCSIS:
|
||||
/*
|
||||
* Currently, only raw "link[N:M]" filtering is supported.
|
||||
*/
|
||||
off_linktype = -1;
|
||||
off_macpl = -1;
|
||||
off_nl = -1;
|
||||
off_nl_nosnap = -1;
|
||||
return;
|
||||
|
||||
case DLT_SYMANTEC_FIREWALL:
|
||||
off_linktype = 6;
|
||||
off_macpl = 44;
|
||||
@@ -1366,6 +1347,16 @@ init_linktype(p)
|
||||
off_nl_nosnap = -1;
|
||||
return;
|
||||
|
||||
case DLT_JUNIPER_VS:
|
||||
case DLT_JUNIPER_SRX_E2E:
|
||||
case DLT_JUNIPER_FIBRECHANNEL:
|
||||
case DLT_JUNIPER_ATM_CEMIC:
|
||||
off_linktype = 8;
|
||||
off_macpl = -1;
|
||||
off_nl = -1;
|
||||
off_nl_nosnap = -1;
|
||||
return;
|
||||
|
||||
case DLT_MTP2:
|
||||
off_li = 2;
|
||||
off_sio = 3;
|
||||
@@ -1411,126 +1402,6 @@ init_linktype(p)
|
||||
return;
|
||||
#endif
|
||||
|
||||
case DLT_LINUX_LAPD:
|
||||
/*
|
||||
* Currently, only raw "link[N:M]" filtering is supported.
|
||||
*/
|
||||
off_linktype = -1;
|
||||
off_macpl = -1;
|
||||
off_nl = -1;
|
||||
off_nl_nosnap = -1;
|
||||
return;
|
||||
|
||||
case DLT_USB:
|
||||
/*
|
||||
* Currently, only raw "link[N:M]" filtering is supported.
|
||||
*/
|
||||
off_linktype = -1;
|
||||
off_macpl = -1;
|
||||
off_nl = -1;
|
||||
off_nl_nosnap = -1;
|
||||
return;
|
||||
|
||||
case DLT_BLUETOOTH_HCI_H4:
|
||||
/*
|
||||
* Currently, only raw "link[N:M]" filtering is supported.
|
||||
*/
|
||||
off_linktype = -1;
|
||||
off_macpl = -1;
|
||||
off_nl = -1;
|
||||
off_nl_nosnap = -1;
|
||||
return;
|
||||
|
||||
case DLT_USB_LINUX:
|
||||
/*
|
||||
* Currently, only raw "link[N:M]" filtering is supported.
|
||||
*/
|
||||
off_linktype = -1;
|
||||
off_macpl = -1;
|
||||
off_nl = -1;
|
||||
off_nl_nosnap = -1;
|
||||
return;
|
||||
|
||||
case DLT_CAN20B:
|
||||
/*
|
||||
* Currently, only raw "link[N:M]" filtering is supported.
|
||||
*/
|
||||
off_linktype = -1;
|
||||
off_macpl = -1;
|
||||
off_nl = -1;
|
||||
off_nl_nosnap = -1;
|
||||
return;
|
||||
|
||||
case DLT_IEEE802_15_4_LINUX:
|
||||
/*
|
||||
* Currently, only raw "link[N:M]" filtering is supported.
|
||||
*/
|
||||
off_linktype = -1;
|
||||
off_macpl = -1;
|
||||
off_nl = -1;
|
||||
off_nl_nosnap = -1;
|
||||
return;
|
||||
|
||||
case DLT_IEEE802_16_MAC_CPS_RADIO:
|
||||
/*
|
||||
* Currently, only raw "link[N:M]" filtering is supported.
|
||||
*/
|
||||
off_linktype = -1;
|
||||
off_macpl = -1;
|
||||
off_nl = -1;
|
||||
off_nl_nosnap = -1;
|
||||
return;
|
||||
|
||||
case DLT_IEEE802_15_4:
|
||||
/*
|
||||
* Currently, only raw "link[N:M]" filtering is supported.
|
||||
*/
|
||||
off_linktype = -1;
|
||||
off_macpl = -1;
|
||||
off_nl = -1;
|
||||
off_nl_nosnap = -1;
|
||||
return;
|
||||
|
||||
case DLT_SITA:
|
||||
/*
|
||||
* Currently, only raw "link[N:M]" filtering is supported.
|
||||
*/
|
||||
off_linktype = -1;
|
||||
off_macpl = -1;
|
||||
off_nl = -1;
|
||||
off_nl_nosnap = -1;
|
||||
return;
|
||||
|
||||
case DLT_RAIF1:
|
||||
/*
|
||||
* Currently, only raw "link[N:M]" filtering is supported.
|
||||
*/
|
||||
off_linktype = -1;
|
||||
off_macpl = -1;
|
||||
off_nl = -1;
|
||||
off_nl_nosnap = -1;
|
||||
return;
|
||||
|
||||
case DLT_IPMB:
|
||||
/*
|
||||
* Currently, only raw "link[N:M]" filtering is supported.
|
||||
*/
|
||||
off_linktype = -1;
|
||||
off_macpl = -1;
|
||||
off_nl = -1;
|
||||
off_nl_nosnap = -1;
|
||||
return;
|
||||
|
||||
case DLT_BLUETOOTH_HCI_H4_WITH_PHDR:
|
||||
/*
|
||||
* Currently, only raw "link[N:M]" filtering is supported.
|
||||
*/
|
||||
off_linktype = -1;
|
||||
off_macpl = -1;
|
||||
off_nl = -1;
|
||||
off_nl_nosnap = -1;
|
||||
return;
|
||||
|
||||
case DLT_AX25_KISS:
|
||||
/*
|
||||
* Currently, only raw "link[N:M]" filtering is supported.
|
||||
@@ -1542,52 +1413,43 @@ init_linktype(p)
|
||||
off_mac = 1; /* step over the kiss length byte */
|
||||
return;
|
||||
|
||||
case DLT_IEEE802_15_4_NONASK_PHY:
|
||||
/*
|
||||
* Currently, only raw "link[N:M]" filtering is supported.
|
||||
*/
|
||||
off_linktype = -1;
|
||||
off_macpl = -1;
|
||||
off_nl = -1;
|
||||
off_nl_nosnap = -1;
|
||||
return;
|
||||
|
||||
case DLT_MPLS:
|
||||
/*
|
||||
* Currently, only raw "link[N:M]" filtering is supported.
|
||||
*/
|
||||
off_linktype = -1;
|
||||
off_macpl = -1;
|
||||
off_nl = -1;
|
||||
off_nl_nosnap = -1;
|
||||
return;
|
||||
|
||||
case DLT_USB_LINUX_MMAPPED:
|
||||
/*
|
||||
* Currently, only raw "link[N:M]" filtering is supported.
|
||||
*/
|
||||
off_linktype = -1;
|
||||
off_macpl = -1;
|
||||
off_nl = -1;
|
||||
off_nl_nosnap = -1;
|
||||
return;
|
||||
|
||||
case DLT_CAN_SOCKETCAN:
|
||||
/*
|
||||
* Currently, only raw "link[N:M]" filtering is supported.
|
||||
*/
|
||||
off_linktype = -1;
|
||||
off_macpl = -1;
|
||||
off_nl = -1;
|
||||
off_nl_nosnap = -1;
|
||||
return;
|
||||
|
||||
case DLT_IPNET:
|
||||
off_linktype = 1;
|
||||
off_macpl = 24; /* ipnet header length */
|
||||
off_nl = 0;
|
||||
off_nl_nosnap = -1;
|
||||
return;
|
||||
|
||||
case DLT_NETANALYZER:
|
||||
off_mac = 4; /* MAC header is past 4-byte pseudo-header */
|
||||
off_linktype = 16; /* includes 4-byte pseudo-header */
|
||||
off_macpl = 18; /* pseudo-header+Ethernet header length */
|
||||
off_nl = 0; /* Ethernet II */
|
||||
off_nl_nosnap = 3; /* 802.3+802.2 */
|
||||
return;
|
||||
|
||||
case DLT_NETANALYZER_TRANSPARENT:
|
||||
off_mac = 12; /* MAC header is past 4-byte pseudo-header, preamble, and SFD */
|
||||
off_linktype = 24; /* includes 4-byte pseudo-header+preamble+SFD */
|
||||
off_macpl = 26; /* pseudo-header+preamble+SFD+Ethernet header length */
|
||||
off_nl = 0; /* Ethernet II */
|
||||
off_nl_nosnap = 3; /* 802.3+802.2 */
|
||||
return;
|
||||
|
||||
default:
|
||||
/*
|
||||
* For values in the range in which we've assigned new
|
||||
* DLT_ values, only raw "link[N:M]" filtering is supported.
|
||||
*/
|
||||
if (linktype >= DLT_MATCHING_MIN &&
|
||||
linktype <= DLT_MATCHING_MAX) {
|
||||
off_linktype = -1;
|
||||
off_macpl = -1;
|
||||
off_nl = -1;
|
||||
off_nl_nosnap = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
bpf_error("unknown data link type %d", linktype);
|
||||
/* NOTREACHED */
|
||||
@@ -3059,6 +2921,8 @@ gen_linktype(proto)
|
||||
switch (linktype) {
|
||||
|
||||
case DLT_EN10MB:
|
||||
case DLT_NETANALYZER:
|
||||
case DLT_NETANALYZER_TRANSPARENT:
|
||||
return gen_ether_linktype(proto);
|
||||
/*NOTREACHED*/
|
||||
break;
|
||||
@@ -3462,6 +3326,11 @@ gen_linktype(proto)
|
||||
case DLT_JUNIPER_VP:
|
||||
case DLT_JUNIPER_ST:
|
||||
case DLT_JUNIPER_ISM:
|
||||
case DLT_JUNIPER_VS:
|
||||
case DLT_JUNIPER_SRX_E2E:
|
||||
case DLT_JUNIPER_FIBRECHANNEL:
|
||||
case DLT_JUNIPER_ATM_CEMIC:
|
||||
|
||||
/* just lets verify the magic number for now -
|
||||
* on ATM we may have up to 6 different encapsulations on the wire
|
||||
* and need a lot of heuristics to figure out that the payload
|
||||
@@ -3511,6 +3380,7 @@ gen_linktype(proto)
|
||||
case DLT_IEEE802_15_4:
|
||||
case DLT_IEEE802_15_4_LINUX:
|
||||
case DLT_IEEE802_15_4_NONASK_PHY:
|
||||
case DLT_IEEE802_15_4_NOFCS:
|
||||
bpf_error("IEEE 802.15.4 link-layer type filtering not implemented");
|
||||
|
||||
case DLT_IEEE802_16_MAC_CPS_RADIO:
|
||||
@@ -3785,6 +3655,30 @@ gen_ehostop(eaddr, dir)
|
||||
b1 = gen_ehostop(eaddr, Q_DST);
|
||||
gen_or(b0, b1);
|
||||
return b1;
|
||||
|
||||
case Q_ADDR1:
|
||||
bpf_error("'addr1' is only supported on 802.11 with 802.11 headers");
|
||||
break;
|
||||
|
||||
case Q_ADDR2:
|
||||
bpf_error("'addr2' is only supported on 802.11 with 802.11 headers");
|
||||
break;
|
||||
|
||||
case Q_ADDR3:
|
||||
bpf_error("'addr3' is only supported on 802.11 with 802.11 headers");
|
||||
break;
|
||||
|
||||
case Q_ADDR4:
|
||||
bpf_error("'addr4' is only supported on 802.11 with 802.11 headers");
|
||||
break;
|
||||
|
||||
case Q_RA:
|
||||
bpf_error("'ra' is only supported on 802.11 with 802.11 headers");
|
||||
break;
|
||||
|
||||
case Q_TA:
|
||||
bpf_error("'ta' is only supported on 802.11 with 802.11 headers");
|
||||
break;
|
||||
}
|
||||
abort();
|
||||
/* NOTREACHED */
|
||||
@@ -3827,6 +3721,30 @@ gen_fhostop(eaddr, dir)
|
||||
b1 = gen_fhostop(eaddr, Q_DST);
|
||||
gen_or(b0, b1);
|
||||
return b1;
|
||||
|
||||
case Q_ADDR1:
|
||||
bpf_error("'addr1' is only supported on 802.11");
|
||||
break;
|
||||
|
||||
case Q_ADDR2:
|
||||
bpf_error("'addr2' is only supported on 802.11");
|
||||
break;
|
||||
|
||||
case Q_ADDR3:
|
||||
bpf_error("'addr3' is only supported on 802.11");
|
||||
break;
|
||||
|
||||
case Q_ADDR4:
|
||||
bpf_error("'addr4' is only supported on 802.11");
|
||||
break;
|
||||
|
||||
case Q_RA:
|
||||
bpf_error("'ra' is only supported on 802.11");
|
||||
break;
|
||||
|
||||
case Q_TA:
|
||||
bpf_error("'ta' is only supported on 802.11");
|
||||
break;
|
||||
}
|
||||
abort();
|
||||
/* NOTREACHED */
|
||||
@@ -3861,6 +3779,30 @@ gen_thostop(eaddr, dir)
|
||||
b1 = gen_thostop(eaddr, Q_DST);
|
||||
gen_or(b0, b1);
|
||||
return b1;
|
||||
|
||||
case Q_ADDR1:
|
||||
bpf_error("'addr1' is only supported on 802.11");
|
||||
break;
|
||||
|
||||
case Q_ADDR2:
|
||||
bpf_error("'addr2' is only supported on 802.11");
|
||||
break;
|
||||
|
||||
case Q_ADDR3:
|
||||
bpf_error("'addr3' is only supported on 802.11");
|
||||
break;
|
||||
|
||||
case Q_ADDR4:
|
||||
bpf_error("'addr4' is only supported on 802.11");
|
||||
break;
|
||||
|
||||
case Q_RA:
|
||||
bpf_error("'ra' is only supported on 802.11");
|
||||
break;
|
||||
|
||||
case Q_TA:
|
||||
bpf_error("'ta' is only supported on 802.11");
|
||||
break;
|
||||
}
|
||||
abort();
|
||||
/* NOTREACHED */
|
||||
@@ -4154,8 +4096,79 @@ gen_wlanhostop(eaddr, dir)
|
||||
gen_and(b1, b0);
|
||||
return b0;
|
||||
|
||||
case Q_RA:
|
||||
/*
|
||||
* Not present in management frames; addr1 in other
|
||||
* frames.
|
||||
*/
|
||||
|
||||
/*
|
||||
* If the high-order bit of the type value is 0, this
|
||||
* is a management frame.
|
||||
* I.e, check "(link[0] & 0x08)".
|
||||
*/
|
||||
s = gen_load_a(OR_LINK, 0, BPF_B);
|
||||
b1 = new_block(JMP(BPF_JSET));
|
||||
b1->s.k = 0x08;
|
||||
b1->stmts = s;
|
||||
|
||||
/*
|
||||
* Check addr1.
|
||||
*/
|
||||
b0 = gen_bcmp(OR_LINK, 4, 6, eaddr);
|
||||
|
||||
/*
|
||||
* AND that with the check of addr1.
|
||||
*/
|
||||
gen_and(b1, b0);
|
||||
return (b0);
|
||||
|
||||
case Q_TA:
|
||||
/*
|
||||
* Not present in management frames; addr2, if present,
|
||||
* in other frames.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Not present in CTS or ACK control frames.
|
||||
*/
|
||||
b0 = gen_mcmp(OR_LINK, 0, BPF_B, IEEE80211_FC0_TYPE_CTL,
|
||||
IEEE80211_FC0_TYPE_MASK);
|
||||
gen_not(b0);
|
||||
b1 = gen_mcmp(OR_LINK, 0, BPF_B, IEEE80211_FC0_SUBTYPE_CTS,
|
||||
IEEE80211_FC0_SUBTYPE_MASK);
|
||||
gen_not(b1);
|
||||
b2 = gen_mcmp(OR_LINK, 0, BPF_B, IEEE80211_FC0_SUBTYPE_ACK,
|
||||
IEEE80211_FC0_SUBTYPE_MASK);
|
||||
gen_not(b2);
|
||||
gen_and(b1, b2);
|
||||
gen_or(b0, b2);
|
||||
|
||||
/*
|
||||
* If the high-order bit of the type value is 0, this
|
||||
* is a management frame.
|
||||
* I.e, check "(link[0] & 0x08)".
|
||||
*/
|
||||
s = gen_load_a(OR_LINK, 0, BPF_B);
|
||||
b1 = new_block(JMP(BPF_JSET));
|
||||
b1->s.k = 0x08;
|
||||
b1->stmts = s;
|
||||
|
||||
/*
|
||||
* AND that with the check for frames other than
|
||||
* CTS and ACK frames.
|
||||
*/
|
||||
gen_and(b1, b2);
|
||||
|
||||
/*
|
||||
* Check addr2.
|
||||
*/
|
||||
b1 = gen_bcmp(OR_LINK, 10, 6, eaddr);
|
||||
gen_and(b2, b1);
|
||||
return b1;
|
||||
|
||||
/*
|
||||
* XXX - add RA, TA, and BSSID keywords?
|
||||
* XXX - add BSSID keyword?
|
||||
*/
|
||||
case Q_ADDR1:
|
||||
return (gen_bcmp(OR_LINK, 4, 6, eaddr));
|
||||
@@ -4251,6 +4264,30 @@ gen_ipfchostop(eaddr, dir)
|
||||
b1 = gen_ipfchostop(eaddr, Q_DST);
|
||||
gen_or(b0, b1);
|
||||
return b1;
|
||||
|
||||
case Q_ADDR1:
|
||||
bpf_error("'addr1' is only supported on 802.11");
|
||||
break;
|
||||
|
||||
case Q_ADDR2:
|
||||
bpf_error("'addr2' is only supported on 802.11");
|
||||
break;
|
||||
|
||||
case Q_ADDR3:
|
||||
bpf_error("'addr3' is only supported on 802.11");
|
||||
break;
|
||||
|
||||
case Q_ADDR4:
|
||||
bpf_error("'addr4' is only supported on 802.11");
|
||||
break;
|
||||
|
||||
case Q_RA:
|
||||
bpf_error("'ra' is only supported on 802.11");
|
||||
break;
|
||||
|
||||
case Q_TA:
|
||||
bpf_error("'ta' is only supported on 802.11");
|
||||
break;
|
||||
}
|
||||
abort();
|
||||
/* NOTREACHED */
|
||||
@@ -4444,6 +4481,9 @@ gen_host(addr, mask, proto, dir, type)
|
||||
case Q_VRRP:
|
||||
bpf_error("'vrrp' modifier applied to %s", typestr);
|
||||
|
||||
case Q_CARP:
|
||||
bpf_error("'carp' modifier applied to %s", typestr);
|
||||
|
||||
case Q_ATALK:
|
||||
bpf_error("ATALK host filtering not implemented");
|
||||
|
||||
@@ -4563,6 +4603,9 @@ gen_host6(addr, mask, proto, dir, type)
|
||||
case Q_VRRP:
|
||||
bpf_error("'vrrp' modifier applied to %s", typestr);
|
||||
|
||||
case Q_CARP:
|
||||
bpf_error("'carp' modifier applied to %s", typestr);
|
||||
|
||||
case Q_ATALK:
|
||||
bpf_error("ATALK host filtering not implemented");
|
||||
|
||||
@@ -4647,6 +4690,8 @@ gen_gateway(eaddr, alist, proto, dir)
|
||||
case Q_RARP:
|
||||
switch (linktype) {
|
||||
case DLT_EN10MB:
|
||||
case DLT_NETANALYZER:
|
||||
case DLT_NETANALYZER_TRANSPARENT:
|
||||
b0 = gen_ehostop(eaddr, Q_OR);
|
||||
break;
|
||||
case DLT_FDDI:
|
||||
@@ -4776,6 +4821,14 @@ gen_proto_abbrev(proto)
|
||||
b1 = gen_proto(IPPROTO_VRRP, Q_IP, Q_DEFAULT);
|
||||
break;
|
||||
|
||||
#ifndef IPPROTO_CARP
|
||||
#define IPPROTO_CARP 112
|
||||
#endif
|
||||
|
||||
case Q_CARP:
|
||||
b1 = gen_proto(IPPROTO_CARP, Q_IP, Q_DEFAULT);
|
||||
break;
|
||||
|
||||
case Q_IP:
|
||||
b1 = gen_linktype(ETHERTYPE_IP);
|
||||
break;
|
||||
@@ -4957,7 +5010,7 @@ gen_ipfrag()
|
||||
struct slist *s;
|
||||
struct block *b;
|
||||
|
||||
/* not ip frag */
|
||||
/* not IPv4 frag other than the first frag */
|
||||
s = gen_load_a(OR_NET, 6, BPF_H);
|
||||
b = new_block(JMP(BPF_JSET));
|
||||
b->s.k = 0x1fff;
|
||||
@@ -5000,7 +5053,7 @@ gen_portop(port, proto, dir)
|
||||
{
|
||||
struct block *b0, *b1, *tmp;
|
||||
|
||||
/* ip proto 'proto' */
|
||||
/* ip proto 'proto' and not a fragment other than the first fragment */
|
||||
tmp = gen_cmp(OR_NET, 9, BPF_B, (bpf_int32)proto);
|
||||
b0 = gen_ipfrag();
|
||||
gen_and(tmp, b0);
|
||||
@@ -5092,6 +5145,7 @@ gen_portop6(port, proto, dir)
|
||||
struct block *b0, *b1, *tmp;
|
||||
|
||||
/* ip6 proto 'proto' */
|
||||
/* XXX - catch the first fragment of a fragmented packet? */
|
||||
b0 = gen_cmp(OR_NET, 6, BPF_B, (bpf_int32)proto);
|
||||
|
||||
switch (dir) {
|
||||
@@ -5193,7 +5247,7 @@ gen_portrangeop(port1, port2, proto, dir)
|
||||
{
|
||||
struct block *b0, *b1, *tmp;
|
||||
|
||||
/* ip proto 'proto' */
|
||||
/* ip proto 'proto' and not a fragment other than the first fragment */
|
||||
tmp = gen_cmp(OR_NET, 9, BPF_B, (bpf_int32)proto);
|
||||
b0 = gen_ipfrag();
|
||||
gen_and(tmp, b0);
|
||||
@@ -5297,6 +5351,7 @@ gen_portrangeop6(port1, port2, proto, dir)
|
||||
struct block *b0, *b1, *tmp;
|
||||
|
||||
/* ip6 proto 'proto' */
|
||||
/* XXX - catch the first fragment of a fragmented packet? */
|
||||
b0 = gen_cmp(OR_NET, 6, BPF_B, (bpf_int32)proto);
|
||||
|
||||
switch (dir) {
|
||||
@@ -5574,12 +5629,9 @@ gen_protochain(v, proto, dir)
|
||||
|
||||
/*
|
||||
* in short,
|
||||
* A = P[X];
|
||||
* X = X + (P[X + 1] + 1) * 8;
|
||||
* A = P[X + packet head];
|
||||
* X = X + (P[X + packet head + 1] + 1) * 8;
|
||||
*/
|
||||
/* A = X */
|
||||
s[i] = new_stmt(BPF_MISC|BPF_TXA);
|
||||
i++;
|
||||
/* A = P[X + packet head] */
|
||||
s[i] = new_stmt(BPF_LD|BPF_IND|BPF_B);
|
||||
s[i]->s.k = off_macpl + off_nl;
|
||||
@@ -5588,19 +5640,9 @@ gen_protochain(v, proto, dir)
|
||||
s[i] = new_stmt(BPF_ST);
|
||||
s[i]->s.k = reg2;
|
||||
i++;
|
||||
/* A = X */
|
||||
s[i] = new_stmt(BPF_MISC|BPF_TXA);
|
||||
i++;
|
||||
/* A += 1 */
|
||||
s[i] = new_stmt(BPF_ALU|BPF_ADD|BPF_K);
|
||||
s[i]->s.k = 1;
|
||||
i++;
|
||||
/* X = A */
|
||||
s[i] = new_stmt(BPF_MISC|BPF_TAX);
|
||||
i++;
|
||||
/* A = P[X + packet head]; */
|
||||
/* A = P[X + packet head + 1]; */
|
||||
s[i] = new_stmt(BPF_LD|BPF_IND|BPF_B);
|
||||
s[i]->s.k = off_macpl + off_nl;
|
||||
s[i]->s.k = off_macpl + off_nl + 1;
|
||||
i++;
|
||||
/* A += 1 */
|
||||
s[i] = new_stmt(BPF_ALU|BPF_ADD|BPF_K);
|
||||
@@ -5610,6 +5652,10 @@ gen_protochain(v, proto, dir)
|
||||
s[i] = new_stmt(BPF_ALU|BPF_MUL|BPF_K);
|
||||
s[i]->s.k = 8;
|
||||
i++;
|
||||
/* A += X */
|
||||
s[i] = new_stmt(BPF_ALU|BPF_ADD|BPF_X);
|
||||
s[i]->s.k = 0;
|
||||
i++;
|
||||
/* X = A; */
|
||||
s[i] = new_stmt(BPF_MISC|BPF_TAX);
|
||||
i++;
|
||||
@@ -5933,6 +5979,10 @@ gen_proto(v, proto, dir)
|
||||
bpf_error("'vrrp proto' is bogus");
|
||||
/* NOTREACHED */
|
||||
|
||||
case Q_CARP:
|
||||
bpf_error("'carp proto' is bogus");
|
||||
/* NOTREACHED */
|
||||
|
||||
#ifdef INET6
|
||||
case Q_IPV6:
|
||||
b0 = gen_linktype(ETHERTYPE_IPV6);
|
||||
@@ -6016,6 +6066,8 @@ gen_scode(name, q)
|
||||
switch (linktype) {
|
||||
|
||||
case DLT_EN10MB:
|
||||
case DLT_NETANALYZER:
|
||||
case DLT_NETANALYZER_TRANSPARENT:
|
||||
eaddr = pcap_ether_hostton(name);
|
||||
if (eaddr == NULL)
|
||||
bpf_error(
|
||||
@@ -6197,6 +6249,10 @@ gen_scode(name, q)
|
||||
/* override PROTO_UNDEF */
|
||||
real_proto = IPPROTO_SCTP;
|
||||
}
|
||||
if (port < 0)
|
||||
bpf_error("illegal port number %d < 0", port);
|
||||
if (port > 65535)
|
||||
bpf_error("illegal port number %d > 65535", port);
|
||||
#ifndef INET6
|
||||
return gen_port(port, real_proto, dir);
|
||||
#else
|
||||
@@ -6238,6 +6294,15 @@ gen_scode(name, q)
|
||||
/* override PROTO_UNDEF */
|
||||
real_proto = IPPROTO_SCTP;
|
||||
}
|
||||
if (port1 < 0)
|
||||
bpf_error("illegal port number %d < 0", port1);
|
||||
if (port1 > 65535)
|
||||
bpf_error("illegal port number %d > 65535", port1);
|
||||
if (port2 < 0)
|
||||
bpf_error("illegal port number %d < 0", port2);
|
||||
if (port2 > 65535)
|
||||
bpf_error("illegal port number %d > 65535", port2);
|
||||
|
||||
#ifndef INET6
|
||||
return gen_portrange(port1, port2, real_proto, dir);
|
||||
#else
|
||||
@@ -6389,6 +6454,9 @@ gen_ncode(s, v, q)
|
||||
else
|
||||
bpf_error("illegal qualifier of 'port'");
|
||||
|
||||
if (v > 65535)
|
||||
bpf_error("illegal port number %u > 65535", v);
|
||||
|
||||
#ifndef INET6
|
||||
return gen_port((int)v, proto, dir);
|
||||
#else
|
||||
@@ -6412,6 +6480,9 @@ gen_ncode(s, v, q)
|
||||
else
|
||||
bpf_error("illegal qualifier of 'portrange'");
|
||||
|
||||
if (v > 65535)
|
||||
bpf_error("illegal port number %u > 65535", v);
|
||||
|
||||
#ifndef INET6
|
||||
return gen_portrange((int)v, (int)v, proto, dir);
|
||||
#else
|
||||
@@ -6516,6 +6587,8 @@ gen_ecode(eaddr, q)
|
||||
if ((q.addr == Q_HOST || q.addr == Q_DEFAULT) && q.proto == Q_LINK) {
|
||||
switch (linktype) {
|
||||
case DLT_EN10MB:
|
||||
case DLT_NETANALYZER:
|
||||
case DLT_NETANALYZER_TRANSPARENT:
|
||||
return gen_ehostop(eaddr, (int)q.dir);
|
||||
case DLT_FDDI:
|
||||
return gen_fhostop(eaddr, (int)q.dir);
|
||||
@@ -6645,7 +6718,7 @@ gen_load(proto, inst, size)
|
||||
|
||||
/*
|
||||
* Load into the X register the offset computed into the
|
||||
* register specifed by "index".
|
||||
* register specified by "index".
|
||||
*/
|
||||
s = xfer_to_x(inst);
|
||||
|
||||
@@ -6677,7 +6750,7 @@ gen_load(proto, inst, size)
|
||||
* the link-layer header. Add to it the offset computed
|
||||
* into the register specified by "index", and move that
|
||||
* into the X register. Otherwise, just load into the X
|
||||
* register the offset computed into the register specifed
|
||||
* register the offset computed into the register specified
|
||||
* by "index".
|
||||
*/
|
||||
if (s != NULL) {
|
||||
@@ -6726,7 +6799,7 @@ gen_load(proto, inst, size)
|
||||
* payload. Add to it the offset computed into the
|
||||
* register specified by "index", and move that into
|
||||
* the X register. Otherwise, just load into the X
|
||||
* register the offset computed into the register specifed
|
||||
* register the offset computed into the register specified
|
||||
* by "index".
|
||||
*/
|
||||
if (s != NULL) {
|
||||
@@ -6771,6 +6844,7 @@ gen_load(proto, inst, size)
|
||||
case Q_IGRP:
|
||||
case Q_PIM:
|
||||
case Q_VRRP:
|
||||
case Q_CARP:
|
||||
/*
|
||||
* The offset is relative to the beginning of
|
||||
* the transport-layer header.
|
||||
@@ -7119,6 +7193,8 @@ gen_broadcast(proto)
|
||||
case DLT_ARCNET_LINUX:
|
||||
return gen_ahostop(abroadcast, Q_DST);
|
||||
case DLT_EN10MB:
|
||||
case DLT_NETANALYZER:
|
||||
case DLT_NETANALYZER_TRANSPARENT:
|
||||
return gen_ehostop(ebroadcast, Q_DST);
|
||||
case DLT_FDDI:
|
||||
return gen_fhostop(ebroadcast, Q_DST);
|
||||
@@ -7214,6 +7290,8 @@ gen_multicast(proto)
|
||||
/* all ARCnet multicasts use the same address */
|
||||
return gen_ahostop(abroadcast, Q_DST);
|
||||
case DLT_EN10MB:
|
||||
case DLT_NETANALYZER:
|
||||
case DLT_NETANALYZER_TRANSPARENT:
|
||||
/* ether[0] & 1 != 0 */
|
||||
return gen_mac_multicast(0);
|
||||
case DLT_FDDI:
|
||||
@@ -7477,6 +7555,11 @@ gen_inbound(dir)
|
||||
case DLT_JUNIPER_VP:
|
||||
case DLT_JUNIPER_ST:
|
||||
case DLT_JUNIPER_ISM:
|
||||
case DLT_JUNIPER_VS:
|
||||
case DLT_JUNIPER_SRX_E2E:
|
||||
case DLT_JUNIPER_FIBRECHANNEL:
|
||||
case DLT_JUNIPER_ATM_CEMIC:
|
||||
|
||||
/* juniper flags (including direction) are stored
|
||||
* the byte after the 3-byte magic number */
|
||||
if (dir) {
|
||||
@@ -7757,6 +7840,30 @@ gen_ahostop(eaddr, dir)
|
||||
b1 = gen_ahostop(eaddr, Q_DST);
|
||||
gen_or(b0, b1);
|
||||
return b1;
|
||||
|
||||
case Q_ADDR1:
|
||||
bpf_error("'addr1' is only supported on 802.11");
|
||||
break;
|
||||
|
||||
case Q_ADDR2:
|
||||
bpf_error("'addr2' is only supported on 802.11");
|
||||
break;
|
||||
|
||||
case Q_ADDR3:
|
||||
bpf_error("'addr3' is only supported on 802.11");
|
||||
break;
|
||||
|
||||
case Q_ADDR4:
|
||||
bpf_error("'addr4' is only supported on 802.11");
|
||||
break;
|
||||
|
||||
case Q_RA:
|
||||
bpf_error("'ra' is only supported on 802.11");
|
||||
break;
|
||||
|
||||
case Q_TA:
|
||||
bpf_error("'ta' is only supported on 802.11");
|
||||
break;
|
||||
}
|
||||
abort();
|
||||
/* NOTREACHED */
|
||||
@@ -7811,9 +7918,15 @@ gen_vlan(vlan_num)
|
||||
switch (linktype) {
|
||||
|
||||
case DLT_EN10MB:
|
||||
/* check for VLAN */
|
||||
case DLT_NETANALYZER:
|
||||
case DLT_NETANALYZER_TRANSPARENT:
|
||||
/* check for VLAN, including QinQ */
|
||||
b0 = gen_cmp(OR_LINK, off_linktype, BPF_H,
|
||||
(bpf_int32)ETHERTYPE_8021Q);
|
||||
b1 = gen_cmp(OR_LINK, off_linktype, BPF_H,
|
||||
(bpf_int32)ETHERTYPE_8021QINQ);
|
||||
gen_or(b0,b1);
|
||||
b0 = b1;
|
||||
|
||||
/* If a specific VLAN is requested, check VLAN id */
|
||||
if (vlan_num >= 0) {
|
||||
@@ -7874,6 +7987,8 @@ gen_mpls(label_num)
|
||||
|
||||
case DLT_C_HDLC: /* fall through */
|
||||
case DLT_EN10MB:
|
||||
case DLT_NETANALYZER:
|
||||
case DLT_NETANALYZER_TRANSPARENT:
|
||||
b0 = gen_linktype(ETHERTYPE_MPLS);
|
||||
break;
|
||||
|
||||
|
||||
@@ -126,6 +126,8 @@
|
||||
|
||||
#define Q_RADIO 40
|
||||
|
||||
#define Q_CARP 41
|
||||
|
||||
/* Directional qualifiers. */
|
||||
|
||||
#define Q_SRC 1
|
||||
@@ -136,6 +138,8 @@
|
||||
#define Q_ADDR2 6
|
||||
#define Q_ADDR3 7
|
||||
#define Q_ADDR4 8
|
||||
#define Q_RA 9
|
||||
#define Q_TA 10
|
||||
|
||||
#define Q_DEFAULT 0
|
||||
#define Q_UNDEF 255
|
||||
|
||||
2354
libpcap/grammar.c
2354
libpcap/grammar.c
File diff suppressed because it is too large
Load Diff
@@ -272,12 +272,12 @@ pfaction_to_num(const char *action)
|
||||
|
||||
%token DST SRC HOST GATEWAY
|
||||
%token NET NETMASK PORT PORTRANGE LESS GREATER PROTO PROTOCHAIN CBYTE
|
||||
%token ARP RARP IP SCTP TCP UDP ICMP IGMP IGRP PIM VRRP
|
||||
%token ARP RARP IP SCTP TCP UDP ICMP IGMP IGRP PIM VRRP CARP
|
||||
%token ATALK AARP DECNET LAT SCA MOPRC MOPDL
|
||||
%token TK_BROADCAST TK_MULTICAST
|
||||
%token NUM INBOUND OUTBOUND
|
||||
%token PF_IFNAME PF_RSET PF_RNR PF_SRNR PF_REASON PF_ACTION
|
||||
%token TYPE SUBTYPE DIR ADDR1 ADDR2 ADDR3 ADDR4
|
||||
%token TYPE SUBTYPE DIR ADDR1 ADDR2 ADDR3 ADDR4 RA TA
|
||||
%token LINK
|
||||
%token GEQ LEQ NEQ
|
||||
%token ID EID HID HID6 AID
|
||||
@@ -442,6 +442,8 @@ dqual: SRC { $$ = Q_SRC; }
|
||||
| ADDR2 { $$ = Q_ADDR2; }
|
||||
| ADDR3 { $$ = Q_ADDR3; }
|
||||
| ADDR4 { $$ = Q_ADDR4; }
|
||||
| RA { $$ = Q_RA; }
|
||||
| TA { $$ = Q_TA; }
|
||||
;
|
||||
/* address type qualifiers */
|
||||
aqual: HOST { $$ = Q_HOST; }
|
||||
@@ -464,6 +466,7 @@ pname: LINK { $$ = Q_LINK; }
|
||||
| IGRP { $$ = Q_IGRP; }
|
||||
| PIM { $$ = Q_PIM; }
|
||||
| VRRP { $$ = Q_VRRP; }
|
||||
| CARP { $$ = Q_CARP; }
|
||||
| ATALK { $$ = Q_ATALK; }
|
||||
| AARP { $$ = Q_AARP; }
|
||||
| DECNET { $$ = Q_DECNET; }
|
||||
|
||||
@@ -133,6 +133,7 @@ add_or_find_if(pcap_if_t **curdev_ret, pcap_if_t **alldevs, const char *name,
|
||||
pcap_t *p;
|
||||
pcap_if_t *curdev, *prevdev, *nextdev;
|
||||
int this_instance;
|
||||
char open_errbuf[PCAP_ERRBUF_SIZE];
|
||||
|
||||
/*
|
||||
* Is there already an entry in the list for this interface?
|
||||
@@ -192,11 +193,11 @@ add_or_find_if(pcap_if_t **curdev_ret, pcap_if_t **alldevs, const char *name,
|
||||
}
|
||||
strcpy(en_name, "en");
|
||||
strcat(en_name, name + 3);
|
||||
p = pcap_open_live(en_name, 68, 0, 0, errbuf);
|
||||
p = pcap_open_live(en_name, 68, 0, 0, open_errbuf);
|
||||
free(en_name);
|
||||
} else
|
||||
#endif /* __APPLE */
|
||||
p = pcap_open_live(name, 68, 0, 0, errbuf);
|
||||
p = pcap_open_live(name, 68, 0, 0, open_errbuf);
|
||||
if (p == NULL) {
|
||||
/*
|
||||
* No. Don't bother including it.
|
||||
@@ -431,26 +432,53 @@ add_addr_to_iflist(pcap_if_t **alldevs, const char *name, u_int flags,
|
||||
strlcpy(ifrdesc.ifr_name, name, sizeof ifrdesc.ifr_name);
|
||||
s = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (s >= 0) {
|
||||
#ifdef __FreeBSD__
|
||||
/*
|
||||
* On FreeBSD, if the buffer isn't big enough for the
|
||||
* description, the ioctl succeeds, but the description
|
||||
* isn't copied, ifr_buffer.length is set to the description
|
||||
* length, and ifr_buffer.buffer is set to NULL.
|
||||
*/
|
||||
for (;;) {
|
||||
free(description);
|
||||
if ((description = malloc(descrlen)) != NULL) {
|
||||
#ifdef __FreeBSD__
|
||||
ifrdesc.ifr_buffer.buffer = description;
|
||||
ifrdesc.ifr_buffer.length = descrlen;
|
||||
#else /* __FreeBSD__ */
|
||||
ifrdesc.ifr_data = (caddr_t)description;
|
||||
#endif /* __FreeBSD__ */
|
||||
if (ioctl(s, SIOCGIFDESCR, &ifrdesc) == 0)
|
||||
break;
|
||||
#ifdef __FreeBSD__
|
||||
else if (errno == ENAMETOOLONG)
|
||||
descrlen = ifrdesc.ifr_buffer.length;
|
||||
#endif /* __FreeBSD__ */
|
||||
else
|
||||
if (ioctl(s, SIOCGIFDESCR, &ifrdesc) == 0) {
|
||||
if (ifrdesc.ifr_buffer.buffer ==
|
||||
description)
|
||||
break;
|
||||
else
|
||||
descrlen = ifrdesc.ifr_buffer.length;
|
||||
} else {
|
||||
/*
|
||||
* Failed to get interface description.
|
||||
*/
|
||||
free(description);
|
||||
description = NULL;
|
||||
break;
|
||||
}
|
||||
} else
|
||||
break;
|
||||
}
|
||||
#else /* __FreeBSD__ */
|
||||
/*
|
||||
* The only other OS that currently supports
|
||||
* SIOCGIFDESCR is OpenBSD, and it has no way
|
||||
* to get the description length - it's clamped
|
||||
* to a maximum of IFDESCRSIZE.
|
||||
*/
|
||||
if ((description = malloc(descrlen)) != NULL) {
|
||||
ifrdesc.ifr_data = (caddr_t)description;
|
||||
if (ioctl(s, SIOCGIFDESCR, &ifrdesc) != 0) {
|
||||
/*
|
||||
* Failed to get interface description.
|
||||
*/
|
||||
free(description);
|
||||
description = NULL;
|
||||
}
|
||||
}
|
||||
#endif /* __FreeBSD__ */
|
||||
close(s);
|
||||
if (description != NULL && strlen(description) == 0) {
|
||||
free(description);
|
||||
@@ -850,8 +878,10 @@ pcap_lookupdev(errbuf)
|
||||
*/
|
||||
while(NAdapts--)
|
||||
{
|
||||
strcpy((char*)tUstr, tAstr);
|
||||
(char*)tUstr += strlen(tAstr) + 1;;
|
||||
char* tmp = (char*)tUstr;
|
||||
strcpy(tmp, tAstr);
|
||||
tmp += strlen(tAstr) + 1;
|
||||
tUstr = (WCHAR*)tmp;
|
||||
tAstr += strlen(tAstr) + 1;
|
||||
}
|
||||
|
||||
|
||||
250
libpcap/install-sh
Executable file
250
libpcap/install-sh
Executable file
@@ -0,0 +1,250 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
# install - install a program, script, or datafile
|
||||
# This comes from X11R5 (mit/util/scripts/install.sh).
|
||||
#
|
||||
# Copyright 1991 by the Massachusetts Institute of Technology
|
||||
#
|
||||
# Permission to use, copy, modify, distribute, and sell this software and its
|
||||
# documentation for any purpose is hereby granted without fee, provided that
|
||||
# the above copyright notice appear in all copies and that both that
|
||||
# copyright notice and this permission notice appear in supporting
|
||||
# documentation, and that the name of M.I.T. not be used in advertising or
|
||||
# publicity pertaining to distribution of the software without specific,
|
||||
# written prior permission. M.I.T. makes no representations about the
|
||||
# suitability of this software for any purpose. It is provided "as is"
|
||||
# without express or implied warranty.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# `make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch. It can only install one file at a time, a restriction
|
||||
# shared with many OS's install programs.
|
||||
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit="${DOITPROG-}"
|
||||
|
||||
|
||||
# put in absolute paths if you don't have them in your path; or use env. vars.
|
||||
|
||||
mvprog="${MVPROG-mv}"
|
||||
cpprog="${CPPROG-cp}"
|
||||
chmodprog="${CHMODPROG-chmod}"
|
||||
chownprog="${CHOWNPROG-chown}"
|
||||
chgrpprog="${CHGRPPROG-chgrp}"
|
||||
stripprog="${STRIPPROG-strip}"
|
||||
rmprog="${RMPROG-rm}"
|
||||
mkdirprog="${MKDIRPROG-mkdir}"
|
||||
|
||||
transformbasename=""
|
||||
transform_arg=""
|
||||
instcmd="$mvprog"
|
||||
chmodcmd="$chmodprog 0755"
|
||||
chowncmd=""
|
||||
chgrpcmd=""
|
||||
stripcmd=""
|
||||
rmcmd="$rmprog -f"
|
||||
mvcmd="$mvprog"
|
||||
src=""
|
||||
dst=""
|
||||
dir_arg=""
|
||||
|
||||
while [ x"$1" != x ]; do
|
||||
case $1 in
|
||||
-c) instcmd="$cpprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-d) dir_arg=true
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-m) chmodcmd="$chmodprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-s) stripcmd="$stripprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
*) if [ x"$src" = x ]
|
||||
then
|
||||
src=$1
|
||||
else
|
||||
# this colon is to work around a 386BSD /bin/sh bug
|
||||
:
|
||||
dst=$1
|
||||
fi
|
||||
shift
|
||||
continue;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ x"$src" = x ]
|
||||
then
|
||||
echo "install: no input file specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]; then
|
||||
dst=$src
|
||||
src=""
|
||||
|
||||
if [ -d $dst ]; then
|
||||
instcmd=:
|
||||
else
|
||||
instcmd=mkdir
|
||||
fi
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
|
||||
if [ -f $src -o -d $src ]
|
||||
then
|
||||
true
|
||||
else
|
||||
echo "install: $src does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ x"$dst" = x ]
|
||||
then
|
||||
echo "install: no destination specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# If destination is a directory, append the input filename; if your system
|
||||
# does not like double slashes in filenames, you may need to add some logic
|
||||
|
||||
if [ -d $dst ]
|
||||
then
|
||||
dst="$dst"/`basename $src`
|
||||
else
|
||||
true
|
||||
fi
|
||||
fi
|
||||
|
||||
## this sed command emulates the dirname command
|
||||
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
||||
|
||||
# Make sure that the destination directory exists.
|
||||
# this part is taken from Noah Friedman's mkinstalldirs script
|
||||
|
||||
# Skip lots of stat calls in the usual case.
|
||||
if [ ! -d "$dstdir" ]; then
|
||||
defaultIFS='
|
||||
'
|
||||
IFS="${IFS-${defaultIFS}}"
|
||||
|
||||
oIFS="${IFS}"
|
||||
# Some sh's can't handle IFS=/ for some reason.
|
||||
IFS='%'
|
||||
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
|
||||
IFS="${oIFS}"
|
||||
|
||||
pathcomp=''
|
||||
|
||||
while [ $# -ne 0 ] ; do
|
||||
pathcomp="${pathcomp}${1}"
|
||||
shift
|
||||
|
||||
if [ ! -d "${pathcomp}" ] ;
|
||||
then
|
||||
$mkdirprog "${pathcomp}"
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
pathcomp="${pathcomp}/"
|
||||
done
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]
|
||||
then
|
||||
$doit $instcmd $dst &&
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
|
||||
else
|
||||
|
||||
# If we're going to rename the final executable, determine the name now.
|
||||
|
||||
if [ x"$transformarg" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
dstfile=`basename $dst $transformbasename |
|
||||
sed $transformarg`$transformbasename
|
||||
fi
|
||||
|
||||
# don't allow the sed command to completely eliminate the filename
|
||||
|
||||
if [ x"$dstfile" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# Make a temp file name in the proper directory.
|
||||
|
||||
dsttmp=$dstdir/#inst.$$#
|
||||
|
||||
# Move or copy the file name to the temp name
|
||||
|
||||
$doit $instcmd $src $dsttmp &&
|
||||
|
||||
trap "rm -f ${dsttmp}" 0 &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits
|
||||
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $instcmd $src $dsttmp" command.
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
|
||||
$doit $rmcmd -f $dstdir/$dstfile &&
|
||||
$doit $mvcmd $dsttmp $dstdir/$dstfile
|
||||
|
||||
fi &&
|
||||
|
||||
|
||||
exit 0
|
||||
43
libpcap/msdos/bin2c.c
Normal file
43
libpcap/msdos/bin2c.c
Normal file
@@ -0,0 +1,43 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <time.h>
|
||||
|
||||
static void Abort (char *fmt,...)
|
||||
{
|
||||
va_list args;
|
||||
va_start (args, fmt);
|
||||
vfprintf (stderr, fmt, args);
|
||||
va_end (args);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
FILE *inFile;
|
||||
FILE *outFile = stdout;
|
||||
time_t now = time (NULL);
|
||||
int ch, i;
|
||||
|
||||
if (argc != 2)
|
||||
Abort ("Usage: %s bin-file [> result]", argv[0]);
|
||||
|
||||
if ((inFile = fopen(argv[1],"rb")) == NULL)
|
||||
Abort ("Cannot open %s\n", argv[1]);
|
||||
|
||||
fprintf (outFile,
|
||||
"/* data statements for file %s at %.24s */\n"
|
||||
"/* Generated by BIN2C, G.Vanem 1995 */\n",
|
||||
argv[1], ctime(&now));
|
||||
|
||||
i = 0;
|
||||
while ((ch = fgetc(inFile)) != EOF)
|
||||
{
|
||||
if (i++ % 12 == 0)
|
||||
fputs ("\n ", outFile);
|
||||
fprintf (outFile, "0x%02X,", ch);
|
||||
}
|
||||
fputc ('\n', outFile);
|
||||
fclose (inFile);
|
||||
return (0);
|
||||
}
|
||||
80
libpcap/msdos/common.dj
Normal file
80
libpcap/msdos/common.dj
Normal file
@@ -0,0 +1,80 @@
|
||||
#
|
||||
# Common defines for libpcap and 16/32-bit network drivers (djgpp)
|
||||
#
|
||||
# @(#) $Header: /tcpdump/master/libpcap/msdos/common.dj,v 1.2 2004-12-19 19:36:33 guy Exp $ (LBL)
|
||||
|
||||
.SUFFIXES: .exe .wlm .dxe .l .y
|
||||
.PHONY: check_gcclib
|
||||
|
||||
default: check_gcclib all
|
||||
|
||||
GCCLIB = /djgpp/lib/gcc-lib/djgpp/3.31
|
||||
MAKEFILE = Makefile.dj
|
||||
|
||||
#
|
||||
# DLX 2.91+ lib. Change path to suite.
|
||||
# Not used anymore. Uses DXE3 now.
|
||||
#
|
||||
# DLX_LIB = $(DJDIR)/contrib/dlx.291/libdlx.a
|
||||
# DLX_LINK = $(DJDIR)/bin/dlxgen.exe
|
||||
|
||||
WATT32_ROOT = $(subst \,/,$(WATT_ROOT))
|
||||
|
||||
|
||||
ifeq ($(wildcard $(GCCLIB)/libgcc.a),)
|
||||
check_gcclib:
|
||||
@echo libgcc.a not found. Set \"$(GCCLIB)\" to \"/djgpp/lib/gcc-lib/djgpp/3.X\"
|
||||
endif
|
||||
|
||||
|
||||
#
|
||||
# Include 32-bit driver support
|
||||
#
|
||||
USE_32BIT_DRIVERS = 0
|
||||
|
||||
#
|
||||
# Use loadable driver modules instead of statically linking
|
||||
# all drivers.
|
||||
#
|
||||
USE_32BIT_MODULES = 0
|
||||
|
||||
#
|
||||
# Put interrupt sensitive code/data in locked sections
|
||||
# Do `make clean' in all affected directories after changing this.
|
||||
#
|
||||
USE_SECTION_LOCKING = 0
|
||||
|
||||
#
|
||||
# Set to 1 to use exception handler lib (only for me)
|
||||
#
|
||||
USE_EXCEPT = 0
|
||||
|
||||
CC = gcc.exe
|
||||
LD = ld.exe
|
||||
ASM = nasm.exe -fbin -dDEBUG
|
||||
YACC = bison.exe
|
||||
LEX = flex.exe
|
||||
|
||||
CFLAGS = -g -gcoff -O2 -Wall -I. -I$(WATT32_ROOT)/inc
|
||||
|
||||
ifeq ($(USE_EXCEPT),1)
|
||||
CFLAGS += -DUSE_EXCEPT
|
||||
EXC_LIB = d:/prog/mw/except/lib/libexc.a
|
||||
endif
|
||||
|
||||
ifeq ($(USE_SECTION_LOCKING),1)
|
||||
CFLAGS += -DUSE_SECTION_LOCKING
|
||||
endif
|
||||
|
||||
ifeq ($(USE_32BIT_DRIVERS),1)
|
||||
CFLAGS += -DUSE_32BIT_DRIVERS
|
||||
endif
|
||||
|
||||
%.o: %.c
|
||||
$(CC) -c $(CFLAGS) $<
|
||||
@echo
|
||||
|
||||
%.o: %.s
|
||||
$(CC) -c $(CFLAGS) -x assembler-with-cpp -o $@ $<
|
||||
@echo
|
||||
|
||||
184
libpcap/msdos/makefile
Normal file
184
libpcap/msdos/makefile
Normal file
@@ -0,0 +1,184 @@
|
||||
#
|
||||
# Makefile for dos-libpcap. NB. This makefile requires a Borland
|
||||
# compatible make tool.
|
||||
#
|
||||
# Targets:
|
||||
# Borland C 4.0+ (DOS large model)
|
||||
# Metaware HighC 3.3+ (PharLap 386|DosX)
|
||||
#
|
||||
|
||||
.AUTODEPEND
|
||||
.SWAP
|
||||
|
||||
!if "$(WATT_ROOT)" == ""
|
||||
!error Environment variable "WATT_ROOT" not set.
|
||||
!endif
|
||||
|
||||
WATT_INC = $(WATT_ROOT)\inc
|
||||
|
||||
DEFS = -DMSDOS -DDEBUG -DNDIS_DEBUG -D_U_= -Dinline= \
|
||||
-DHAVE_STRERROR -DHAVE_LIMITS_H
|
||||
|
||||
ASM = tasm.exe -t -l -mx -m2 -DDEBUG
|
||||
|
||||
SOURCE = grammar.c scanner.c bpf_filt.c bpf_imag.c bpf_dump.c \
|
||||
etherent.c gencode.c nametoad.c pcap-dos.c optimize.c \
|
||||
savefile.c pcap.c inet.c msdos\ndis2.c msdos\pktdrvr.c \
|
||||
missing\snprintf.c
|
||||
|
||||
BORLAND_OBJ = $(SOURCE:.c=.obj) msdos\pkt_rx0.obj msdos\ndis_0.obj
|
||||
|
||||
HIGHC_OBJ = $(SOURCE:.c=.o32) msdos\pkt_rx0.o32
|
||||
|
||||
all:
|
||||
@echo Usage: make pcap_bc.lib or pcap_hc.lib
|
||||
|
||||
|
||||
pcap_bc.lib: bcc.arg $(BORLAND_OBJ) pcap_bc
|
||||
|
||||
|
||||
pcap_hc.lib: hc386.arg $(HIGHC_OBJ)
|
||||
386lib $< @&&|
|
||||
-nowarn -nobackup -twocase -replace $(HIGHC_OBJ)
|
||||
|
|
||||
|
||||
pcap_bc: $(BORLAND_OBJ)
|
||||
@tlib pcap_bc.lib /C @&&|
|
||||
-+$(**:.obj=-+)
|
||||
|
|
||||
|
||||
.c.obj:
|
||||
bcc.exe @bcc.arg -o$*.obj $*.c
|
||||
|
||||
.c.o32:
|
||||
hc386.exe @hc386.arg -o $*.o32 $*.c
|
||||
|
||||
.asm.obj:
|
||||
$(ASM) $*.asm, $*.obj
|
||||
|
||||
.asm.o32:
|
||||
$(ASM) -DDOSX=1 $*.asm, $*.o32
|
||||
|
||||
scanner.c: scanner.l
|
||||
flex -Ppcap_ -7 -oscanner.c scanner.l
|
||||
|
||||
grammar.c tokdefs.h: grammar.y
|
||||
bison --name-prefix=pcap_ --yacc --defines grammar.y
|
||||
- @del grammar.c
|
||||
- @del tokdefs.h
|
||||
ren y_tab.c grammar.c
|
||||
ren y_tab.h tokdefs.h
|
||||
|
||||
bcc.arg: msdos\Makefile
|
||||
@copy &&|
|
||||
$(DEFS) -ml -c -v -3 -O2 -po -RT- -w-
|
||||
-I$(WATT_INC) -I. -I.\msdos\pm_drvr -H=$(TEMP)\bcc.sym
|
||||
| $<
|
||||
|
||||
hc386.arg: msdos\Makefile
|
||||
@copy &&|
|
||||
# -DUSE_32BIT_DRIVERS
|
||||
$(DEFS) -DDOSX=1 -w3 -c -g -O5
|
||||
-I$(WATT_INC) -I. -I.\msdos\pm_drvr
|
||||
-Hsuffix=.o32
|
||||
-Hnocopyr
|
||||
-Hpragma=Offwarn(491,553,572)
|
||||
-Hon=Recognize_library # make memcpy/strlen etc. inline
|
||||
-Hoff=Behaved # turn off some optimiser warnings
|
||||
| $<
|
||||
|
||||
clean:
|
||||
@del *.obj
|
||||
@del *.o32
|
||||
@del *.lst
|
||||
@del *.map
|
||||
@del bcc.arg
|
||||
@del hc386.arg
|
||||
@del grammar.c
|
||||
@del tokdefs.h
|
||||
@del scanner.c
|
||||
@echo Cleaned
|
||||
|
||||
#
|
||||
# dependencies
|
||||
#
|
||||
pkt_rx0.obj: msdos\pkt_rx0.asm
|
||||
|
||||
bpf_filt.obj: bpf_filt.c pcap-int.h pcap.h pcap-bpf.h gnuc.h
|
||||
|
||||
bpf_imag.obj: bpf_imag.c pcap-int.h pcap.h pcap-bpf.h
|
||||
|
||||
bpf_dump.obj: bpf_dump.c pcap.h pcap-bpf.h
|
||||
|
||||
etherent.obj: etherent.c pcap-int.h pcap.h pcap-bpf.h pcap-namedb.h
|
||||
|
||||
optimize.obj: optimize.c pcap-int.h pcap.h pcap-bpf.h gencode.h
|
||||
|
||||
savefile.obj: savefile.c pcap-int.h pcap.h pcap-bpf.h
|
||||
|
||||
pcap.obj: pcap.c pcap-dos.h pcap-int.h pcap.h pcap-bpf.h
|
||||
|
||||
inet.obj: inet.c pcap-int.h pcap.h pcap-bpf.h
|
||||
|
||||
grammar.obj: grammar.c pcap-int.h pcap.h pcap-bpf.h gencode.h \
|
||||
pf.h pcap-namedb.h
|
||||
|
||||
scanner.obj: scanner.c pcap-int.h pcap.h pcap-bpf.h gencode.h \
|
||||
pcap-namedb.h tokdefs.h
|
||||
|
||||
gencode.obj: gencode.c pcap-dos.h pcap-int.h pcap.h pcap-bpf.h \
|
||||
ethertype.h nlpid.h llc.h gencode.h atmuni31.h sunatmpos.h ppp.h sll.h \
|
||||
arcnet.h pf.h pcap-namedb.h
|
||||
|
||||
nametoad.obj: nametoad.c pcap-int.h pcap.h pcap-bpf.h gencode.h \
|
||||
pcap-namedb.h ethertype.h
|
||||
|
||||
pcap-dos.obj: pcap-dos.c pcap.h pcap-bpf.h pcap-dos.h pcap-int.h \
|
||||
msdos\pktdrvr.h
|
||||
|
||||
pktdrvr.obj: msdos\pktdrvr.c gnuc.h pcap-dos.h pcap-int.h \
|
||||
pcap.h pcap-bpf.h msdos\pktdrvr.h msdos\pkt_stub.inc
|
||||
|
||||
ndis2.obj: msdos\ndis2.c pcap-dos.h pcap-int.h pcap.h pcap-bpf.h \
|
||||
msdos\ndis2.h
|
||||
|
||||
pkt_rx0.o32: msdos\pkt_rx0.asm
|
||||
|
||||
bpf_filt.o32: bpf_filt.c pcap-int.h pcap.h pcap-bpf.h gnuc.h
|
||||
|
||||
bpf_imag.o32: bpf_imag.c pcap-int.h pcap.h pcap-bpf.h
|
||||
|
||||
bpf_dump.o32: bpf_dump.c pcap.h pcap-bpf.h
|
||||
|
||||
etherent.o32: etherent.c pcap-int.h pcap.h pcap-bpf.h pcap-namedb.h
|
||||
|
||||
optimize.o32: optimize.c pcap-int.h pcap.h pcap-bpf.h gencode.h
|
||||
|
||||
savefile.o32: savefile.c pcap-int.h pcap.h pcap-bpf.h
|
||||
|
||||
pcap.o32: pcap.c pcap-dos.h pcap-int.h pcap.h pcap-bpf.h
|
||||
|
||||
inet.o32: inet.c pcap-int.h pcap.h pcap-bpf.h
|
||||
|
||||
grammar.o32: grammar.c pcap-int.h pcap.h pcap-bpf.h gencode.h \
|
||||
pf.h pcap-namedb.h
|
||||
|
||||
scanner.o32: scanner.c pcap-int.h pcap.h pcap-bpf.h gencode.h \
|
||||
pcap-namedb.h tokdefs.h
|
||||
|
||||
gencode.o32: gencode.c pcap-dos.h pcap-int.h pcap.h pcap-bpf.h \
|
||||
ethertype.h nlpid.h llc.h gencode.h atmuni31.h sunatmpos.h ppp.h sll.h \
|
||||
arcnet.h pf.h pcap-namedb.h
|
||||
|
||||
nametoad.o32: nametoad.c pcap-int.h pcap.h pcap-bpf.h gencode.h \
|
||||
pcap-namedb.h ethertype.h
|
||||
|
||||
pcap-dos.o32: pcap-dos.c pcap.h pcap-bpf.h pcap-dos.h pcap-int.h \
|
||||
msdos\pktdrvr.h
|
||||
|
||||
pktdrvr.o32: msdos\pktdrvr.c gnuc.h pcap-dos.h pcap-int.h \
|
||||
pcap.h pcap-bpf.h msdos\pktdrvr.h msdos\pkt_stub.inc
|
||||
|
||||
ndis2.o32: msdos\ndis2.c pcap-dos.h pcap-int.h pcap.h pcap-bpf.h \
|
||||
msdos\ndis2.h
|
||||
|
||||
152
libpcap/msdos/makefile.dj
Normal file
152
libpcap/msdos/makefile.dj
Normal file
@@ -0,0 +1,152 @@
|
||||
#
|
||||
# GNU Makefile for DOS-libpcap. djgpp version.
|
||||
#
|
||||
# Use this makefile from the libpcap root directory.
|
||||
# E.g. like this:
|
||||
#
|
||||
# c:\net\pcap> make -f msdos/makefile.dj
|
||||
#
|
||||
# @(#) $Header: /tcpdump/master/libpcap/msdos/makefile.dj,v 1.2 2004-12-19 19:41:06 guy Exp $ (LBL)
|
||||
|
||||
VPATH = missing msdos
|
||||
|
||||
PREREQUISITES = scanner.c grammar.c tokdefs.h version.h msdos/pkt_stub.inc
|
||||
|
||||
include msdos/common.dj
|
||||
|
||||
DRIVER_DIR = ./msdos/pm_drvr
|
||||
|
||||
CFLAGS += -DDEBUG -DNDIS_DEBUG -DHAVE_LIMITS_H -DHAVE_STRERROR \
|
||||
-D_U_='__attribute__((unused))' -DHAVE_VERSION_H
|
||||
|
||||
# CFLAGS += -Dyylval=pcap_lval -DBDEBUG -DNDEBUG
|
||||
|
||||
SOURCES = grammar.c scanner.c bpf_filt.c bpf_imag.c bpf_dump.c \
|
||||
etherent.c gencode.c nametoad.c pcap-dos.c optimize.c \
|
||||
savefile.c pcap.c inet.c msdos\pktdrvr.c msdos/ndis2.c \
|
||||
missing/snprintf.c
|
||||
|
||||
OBJECTS = $(notdir $(SOURCES:.c=.o))
|
||||
TEMPBIN = tmp.bin
|
||||
|
||||
ifeq ($(USE_32BIT_DRIVERS),1)
|
||||
PM_OBJECTS = $(addprefix $(DRIVER_DIR)/, \
|
||||
printk.o pci.o pci-scan.o bios32.o dma.o irq.o intwrap.o \
|
||||
lock.o kmalloc.o quirks.o timer.o net_init.o)
|
||||
#
|
||||
# Static link of drivers
|
||||
#
|
||||
ifeq ($(USE_32BIT_MODULES),0)
|
||||
PM_OBJECTS += $(addprefix $(DRIVER_DIR)/, \
|
||||
accton.o 8390.o 3c503.o 3c509.o 3c59x.o 3c515.o \
|
||||
3c575_cb.o 3c90x.o ne.o wd.o cs89x0.o rtl8139.o)
|
||||
endif
|
||||
endif
|
||||
|
||||
all: libpcap.a
|
||||
|
||||
ifeq ($(USE_32BIT_DRIVERS),1)
|
||||
$(PM_OBJECTS):
|
||||
$(MAKE) -f Makefile.dj -C $(DRIVER_DIR) $(notdir $@)
|
||||
endif
|
||||
|
||||
libpcap.a: version.h $(OBJECTS) $(PM_OBJECTS)
|
||||
rm -f $@
|
||||
ar rs $@ $^
|
||||
|
||||
msdos/pkt_stub.inc: msdos/bin2c.exe msdos/pkt_rx1.S
|
||||
$(ASM) -o $(TEMPBIN) -lmsdos/pkt_rx1.lst msdos/pkt_rx1.S
|
||||
./msdos/bin2c $(TEMPBIN) > $@
|
||||
rm -f $(TEMPBIN)
|
||||
|
||||
grammar.c tokdefs.h: grammar.y
|
||||
rm -f grammar.c tokdefs.h
|
||||
$(YACC) --name-prefix=pcap_ --yacc --defines grammar.y
|
||||
mv -f y_tab.c grammar.c
|
||||
mv -f y_tab.h tokdefs.h
|
||||
|
||||
version.h: ./VERSION
|
||||
@echo '/* Generated from VERSION. Do not edit */' > $@
|
||||
sed -e 's/.*/static char pcap_version_string[] = "libpcap (&)";/' ./VERSION >> $@
|
||||
|
||||
scanner.c: scanner.l
|
||||
$(LEX) -Ppcap_ -7 -t $^ > $@
|
||||
@echo
|
||||
|
||||
msdos/bin2c.exe: msdos/bin2c.c
|
||||
$(CC) $*.c -o $*.exe
|
||||
|
||||
clean:
|
||||
$(MAKE) -f Makefile.dj -C $(DRIVER_DIR) clean
|
||||
$(MAKE) -f Makefile.dj -C libcpcap clean
|
||||
rm -f $(OBJECTS) msdos/pkt_rx1.lst Makefile.bak $(PREREQUISITES)
|
||||
|
||||
vclean: clean
|
||||
rm -f libpcap.a msdos/bin2c.exe
|
||||
|
||||
#
|
||||
# Generated dependencies; Due to some hacks in gcc 2.95 and djgpp 2.03
|
||||
# we must prevent "$(DJDIR)/bin/../include/sys/version.h" from beeing
|
||||
# included in dependency output (or else this makefile cannot be used on
|
||||
# another machine). We therefore use a special 'specs' file during
|
||||
# pre-processing.
|
||||
#
|
||||
MM_SPECS = specs.tmp
|
||||
MAKEFILE = msdos/Makefile.dj
|
||||
|
||||
depend: $(PREREQUISITES)
|
||||
@echo Generating dependencies..
|
||||
@cp $(MAKEFILE) Makefile.bak
|
||||
@echo "*cpp: %(cpp_cpu) %{posix:-D_POSIX_SOURCE} -remap" > $(MM_SPECS)
|
||||
sed -e "/^# DO NOT DELETE THIS LINE/,$$d" < Makefile.bak > $(MAKEFILE)
|
||||
echo "# DO NOT DELETE THIS LINE" >> $(MAKEFILE)
|
||||
$(CC) -MM -specs=$(MM_SPECS) $(CFLAGS) $(SOURCES) >> $(MAKEFILE)
|
||||
rm -f $(MM_SPECS)
|
||||
|
||||
#
|
||||
# Manually generated dependencies
|
||||
#
|
||||
msdos/pktdrvr.c: msdos/pkt_stub.inc
|
||||
scanner.c: scanner.l
|
||||
grammar.c tokdefs.h: grammar.y
|
||||
grammar.h: grammar.y
|
||||
scanner.l: pcap-int.h pcap-namedb.h gencode.h grammar.h gnuc.h
|
||||
grammar.y: pcap-int.h gencode.h pcap-namedb.h gnuc.h
|
||||
|
||||
#
|
||||
# Automatically generated dependencies
|
||||
#
|
||||
# DO NOT DELETE THIS LINE
|
||||
grammar.o: grammar.c pcap-int.h pcap.h pcap-bpf.h gencode.h pf.h \
|
||||
pcap-namedb.h
|
||||
scanner.o: scanner.c pcap-int.h pcap.h pcap-bpf.h gencode.h pcap-namedb.h \
|
||||
tokdefs.h
|
||||
bpf_filt.o: bpf_filt.c pcap-int.h pcap.h pcap-bpf.h gnuc.h
|
||||
bpf_imag.o: bpf_imag.c pcap-int.h pcap.h pcap-bpf.h
|
||||
bpf_dump.o: bpf_dump.c pcap.h pcap-bpf.h
|
||||
etherent.o: etherent.c pcap-int.h pcap.h pcap-bpf.h pcap-namedb.h
|
||||
gencode.o: gencode.c pcap-dos.h msdos/pm_drvr/lock.h pcap-int.h pcap.h \
|
||||
pcap-bpf.h ethertype.h nlpid.h llc.h gencode.h atmuni31.h sunatmpos.h \
|
||||
ppp.h sll.h arcnet.h pf.h pcap-namedb.h
|
||||
nametoad.o: nametoad.c pcap-int.h pcap.h pcap-bpf.h gencode.h \
|
||||
pcap-namedb.h ethertype.h
|
||||
pcap-dos.o: pcap-dos.c msdos/pm_drvr/pmdrvr.h msdos/pm_drvr/iface.h \
|
||||
msdos/pm_drvr/lock.h msdos/pm_drvr/ioport.h pcap-dos.h pcap-int.h \
|
||||
pcap.h pcap-bpf.h msdos/pm_drvr/kmalloc.h msdos/pm_drvr/bitops.h \
|
||||
msdos/pm_drvr/timer.h msdos/pm_drvr/dma.h msdos/pm_drvr/irq.h \
|
||||
msdos/pm_drvr/printk.h msdos/pm_drvr/pci.h msdos/pm_drvr/bios32.h \
|
||||
msdos/pm_drvr/module.h msdos/pm_drvr/3c501.h msdos/pm_drvr/3c503.h \
|
||||
msdos/pm_drvr/3c509.h msdos/pm_drvr/3c59x.h msdos/pm_drvr/3c515.h \
|
||||
msdos/pm_drvr/3c90x.h msdos/pm_drvr/3c575_cb.h msdos/pm_drvr/ne.h \
|
||||
msdos/pm_drvr/wd.h msdos/pm_drvr/accton.h msdos/pm_drvr/cs89x0.h \
|
||||
msdos/pm_drvr/rtl8139.h msdos/pm_drvr/ne2k-pci.h msdos/pktdrvr.h
|
||||
optimize.o: optimize.c pcap-int.h pcap.h pcap-bpf.h gencode.h
|
||||
savefile.o: savefile.c pcap-int.h pcap.h pcap-bpf.h
|
||||
pcap.o: pcap.c pcap-dos.h msdos/pm_drvr/lock.h pcap-int.h pcap.h \
|
||||
pcap-bpf.h
|
||||
inet.o: inet.c pcap-int.h pcap.h pcap-bpf.h
|
||||
pktdrvr.o: msdos/pktdrvr.c gnuc.h pcap-dos.h msdos/pm_drvr/lock.h \
|
||||
pcap-int.h pcap.h pcap-bpf.h msdos/pktdrvr.h msdos/pkt_stub.inc
|
||||
ndis2.o: msdos/ndis2.c pcap-dos.h msdos/pm_drvr/lock.h pcap-int.h pcap.h \
|
||||
pcap-bpf.h msdos/ndis2.h
|
||||
snprintf.o: missing/snprintf.c pcap-int.h pcap.h pcap-bpf.h
|
||||
131
libpcap/msdos/makefile.wc
Normal file
131
libpcap/msdos/makefile.wc
Normal file
@@ -0,0 +1,131 @@
|
||||
#
|
||||
# Watcom Makefile for dos-libpcap.
|
||||
#
|
||||
# Specify MODEL = `3r' or `3s'
|
||||
# Specify TARGET = `pharlap' or `dos4g'
|
||||
#
|
||||
# Use this makefile from the libpcap root directory.
|
||||
# E.g. like this:
|
||||
#
|
||||
# c:\net\pcap> wmake -f msdos\makefile.wc
|
||||
#
|
||||
|
||||
MODEL = 3s
|
||||
TARGET = dos4g
|
||||
|
||||
OBJDIR = msdos\$(TARGET).w$(MODEL)
|
||||
LIB = $(OBJDIR)\pcap.lib
|
||||
|
||||
.EXTENSIONS: .l .y
|
||||
|
||||
DEFS = -dDEBUG -dNDIS_DEBUG -d_U_= -dHAVE_LIMITS_H -dHAVE_STRERROR &
|
||||
-dHAVE_SNPRINTF -dHAVE_VSNPRINTF
|
||||
|
||||
CC = wcc386.exe
|
||||
ASM = wasm.exe -$(MODEL) $(DEFS) -dDOSX -dDOS4GW -zq -bt=dos -fr=nul -d3 -s
|
||||
|
||||
OBJS = $(OBJDIR)\grammar.obj $(OBJDIR)\scanner.obj $(OBJDIR)\pcap.obj &
|
||||
$(OBJDIR)\bpf_filt.obj $(OBJDIR)\bpf_imag.obj $(OBJDIR)\bpf_dump.obj &
|
||||
$(OBJDIR)\etherent.obj $(OBJDIR)\gencode.obj $(OBJDIR)\nametoad.obj &
|
||||
$(OBJDIR)\pcap-dos.obj $(OBJDIR)\pktdrvr.obj $(OBJDIR)\optimize.obj &
|
||||
$(OBJDIR)\savefile.obj $(OBJDIR)\inet.obj $(OBJDIR)\ndis2.obj
|
||||
|
||||
CFLAGS = $(DEFS) $(YYDEFS) -I. -I$(%watt_root)\inc -I.\msdos\pm_drvr &
|
||||
-$(MODEL) -mf -zff -zgf -zq -bt=dos -fr=nul -w6 -fpi &
|
||||
-oilrtf -zm
|
||||
|
||||
TEMPBIN = tmp.bin
|
||||
|
||||
all: $(OBJDIR) $(OBJDIR)\pcap.lib
|
||||
|
||||
$(OBJDIR):
|
||||
- mkdir $(OBJDIR)
|
||||
|
||||
$(OBJDIR)\pcap.lib: $(OBJS) wlib.arg
|
||||
wlib -q -b -c $(OBJDIR)\pcap.lib @wlib.arg
|
||||
|
||||
wlib.arg: msdos\makefile.wc
|
||||
%create $^@
|
||||
for %f in ($(OBJS)) do %append $^@ +- %f
|
||||
|
||||
$(OBJDIR)\pktdrvr.obj: msdos\pkt_stub.inc msdos\pktdrvr.c gnuc.h &
|
||||
pcap-dos.h pcap-int.h pcap.h msdos\pktdrvr.h
|
||||
*$(CC) $(CFLAGS) msdos\pktdrvr.c -fo=$@
|
||||
|
||||
$(OBJDIR)\ndis2.obj: msdos\ndis2.c
|
||||
*$(CC) $(CFLAGS) msdos\ndis2.c -fo=$@
|
||||
|
||||
.ERASE
|
||||
.c{$(OBJDIR)}.obj:
|
||||
*$(CC) $(CFLAGS) $[@ -fo=$@
|
||||
|
||||
grammar.c tokdefs.h: grammar.y
|
||||
bison --name-prefix=pcap_ --yacc --defines $[@
|
||||
- @del grammar.c
|
||||
- @del tokdefs.h
|
||||
ren y_tab.c grammar.c
|
||||
ren y_tab.h tokdefs.h
|
||||
|
||||
scanner.c: scanner.l
|
||||
flex -Ppcap_ -7 -o$@ $[@
|
||||
|
||||
msdos\pkt_stub.inc: bin2c.exe msdos\pkt_rx1.S
|
||||
nasm -fbin -dDEBUG -o $(TEMPBIN) -lmsdos\pkt_rx1.lst msdos\pkt_rx1.S
|
||||
bin2c.exe $(TEMPBIN) > $@
|
||||
@del $(TEMPBIN)
|
||||
|
||||
bin2c.exe: msdos\bin2c.c
|
||||
wcl $[@
|
||||
|
||||
clean realclean vclean: .SYMBOLIC
|
||||
for %f in (dos4g.w3r dos4g.w3s pharlap.w3r pharlap.w3s) do &
|
||||
@del %f\*.obj
|
||||
@del grammar.c
|
||||
@del tokdefs.h
|
||||
@del scanner.c
|
||||
@del bin2c.exe
|
||||
@del bin2c.obj
|
||||
@del msdos\pkt_stub.inc
|
||||
@echo Cleaned
|
||||
|
||||
#
|
||||
# dependencies
|
||||
#
|
||||
$(OBJDIR)\bpf_filt.obj: bpf_filt.c pcap-int.h pcap.h pcap-bpf.h gnuc.h
|
||||
|
||||
$(OBJDIR)\bpf_imag.obj: bpf_imag.c pcap-int.h pcap.h pcap-bpf.h
|
||||
|
||||
$(OBJDIR)\bpf_dump.obj: bpf_dump.c pcap.h pcap-bpf.h
|
||||
|
||||
$(OBJDIR)\etherent.obj: etherent.c pcap-int.h pcap.h pcap-bpf.h pcap-nam.h
|
||||
|
||||
$(OBJDIR)\optimize.obj: optimize.c pcap-int.h pcap.h pcap-bpf.h gencode.h
|
||||
|
||||
$(OBJDIR)\savefile.obj: savefile.c pcap-int.h pcap.h pcap-bpf.h
|
||||
|
||||
$(OBJDIR)\pcap.obj: pcap.c pcap-dos.h pcap-int.h pcap.h pcap-bpf.h
|
||||
|
||||
$(OBJDIR)\inet.obj: inet.c pcap-int.h pcap.h pcap-bpf.h
|
||||
|
||||
$(OBJDIR)\grammar.obj: grammar.c pcap-int.h pcap.h pcap-bpf.h gencode.h &
|
||||
pf.h pcap-nam.h
|
||||
|
||||
$(OBJDIR)\scanner.obj: scanner.c pcap-int.h pcap.h pcap-bpf.h gencode.h &
|
||||
pcap-nam.h tokdefs.h
|
||||
|
||||
$(OBJDIR)\gencode.obj: gencode.c pcap-dos.h pcap-int.h pcap.h pcap-bpf.h &
|
||||
ethertyp.h nlpid.h llc.h gencode.h atmuni31.h sunatmpo.h ppp.h sll.h &
|
||||
arcnet.h pf.h pcap-nam.h
|
||||
|
||||
$(OBJDIR)\nametoad.obj: nametoad.c pcap-int.h pcap.h pcap-bpf.h gencode.h &
|
||||
pcap-nam.h ethertyp.h
|
||||
|
||||
$(OBJDIR)\pcap-dos.obj: pcap-dos.c pcap.h pcap-bpf.h pcap-dos.h pcap-int.h &
|
||||
msdos\pktdrvr.h
|
||||
|
||||
$(OBJDIR)\pktdrvr.obj: msdos\pktdrvr.c gnuc.h pcap-dos.h pcap-int.h &
|
||||
pcap.h pcap-bpf.h msdos\pktdrvr.h msdos\pkt_stub.inc
|
||||
|
||||
$(OBJDIR)\ndis2.obj: msdos\ndis2.c pcap-dos.h pcap-int.h pcap.h pcap-bpf.h &
|
||||
msdos\ndis2.h
|
||||
|
||||
860
libpcap/msdos/ndis2.c
Normal file
860
libpcap/msdos/ndis2.c
Normal file
@@ -0,0 +1,860 @@
|
||||
/*
|
||||
* Copyright (c) 1993,1994
|
||||
* Texas A&M University. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Texas A&M University
|
||||
* and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* Developers:
|
||||
* David K. Hess, Douglas Lee Schales, David R. Safford
|
||||
*
|
||||
* Heavily modified for Metaware HighC + GNU C 2.8+
|
||||
* Gisle Vanem 1998
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <dos.h>
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "pcap-dos.h"
|
||||
#include "pcap-int.h"
|
||||
#include "msdos/ndis2.h"
|
||||
|
||||
#if defined(USE_NDIS2)
|
||||
|
||||
/*
|
||||
* Packet buffer handling
|
||||
*/
|
||||
extern int FreePktBuf (PktBuf *buf);
|
||||
extern int EnquePktBuf (PktBuf *buf);
|
||||
extern PktBuf* AllocPktBuf (void);
|
||||
|
||||
/*
|
||||
* Various defines
|
||||
*/
|
||||
#define MAX_NUM_DEBUG_STRINGS 90
|
||||
#define DEBUG_STRING_LENGTH 80
|
||||
#define STACK_POOL_SIZE 6
|
||||
#define STACK_SIZE 256
|
||||
|
||||
#define MEDIA_FDDI 1
|
||||
#define MEDIA_ETHERNET 2
|
||||
#define MEDIA_TOKEN 3
|
||||
|
||||
static int startDebug = 0;
|
||||
static int stopDebug = 0;
|
||||
|
||||
static DWORD droppedPackets = 0L;
|
||||
static WORD frameSize = 0;
|
||||
static WORD headerSize = 0;
|
||||
static int mediaType = 0;
|
||||
static char *lastErr = NULL;
|
||||
|
||||
static BYTE debugStrings [MAX_NUM_DEBUG_STRINGS][DEBUG_STRING_LENGTH];
|
||||
static BYTE *freeStacks [STACK_POOL_SIZE];
|
||||
static int freeStackPtr = STACK_POOL_SIZE - 1;
|
||||
|
||||
static ProtMan protManEntry = NULL;
|
||||
static WORD protManDS = 0;
|
||||
static volatile int xmitPending;
|
||||
|
||||
static struct _PktBuf *txBufPending;
|
||||
static struct _CardHandle *handle;
|
||||
static struct _CommonChars common;
|
||||
static struct _ProtocolChars protChars;
|
||||
static struct _ProtDispatch lowerTable;
|
||||
|
||||
static struct _FailingModules failingModules;
|
||||
static struct _BindingsList bindings;
|
||||
|
||||
static struct {
|
||||
WORD err_num;
|
||||
char *err_text;
|
||||
} ndis_errlist[] = {
|
||||
|
||||
{ ERR_SUCCESS,
|
||||
"The function completed successfully.\n" },
|
||||
|
||||
{ ERR_WAIT_FOR_RELEASE,
|
||||
"The ReceiveChain completed successfully but the protocol has\n"
|
||||
"retained control of the buffer.\n" },
|
||||
|
||||
{ ERR_REQUEST_QUEUED,
|
||||
"The current request has been queued.\n" },
|
||||
|
||||
{ ERR_FRAME_NOT_RECOGNIZED,
|
||||
"Frame not recognized.\n" },
|
||||
|
||||
{ ERR_FRAME_REJECTED,
|
||||
"Frame was discarded.\n" },
|
||||
|
||||
{ ERR_FORWARD_FRAME,
|
||||
"Protocol wishes to forward frame to another protocol.\n" },
|
||||
|
||||
{ ERR_OUT_OF_RESOURCE,
|
||||
"Out of resource.\n" },
|
||||
|
||||
{ ERR_INVALID_PARAMETER,
|
||||
"Invalid parameter.\n" },
|
||||
|
||||
{ ERR_INVALID_FUNCTION,
|
||||
"Invalid function.\n" },
|
||||
|
||||
{ ERR_NOT_SUPPORTED,
|
||||
"Not supported.\n" },
|
||||
|
||||
{ ERR_HARDWARE_ERROR,
|
||||
"Hardware error.\n" },
|
||||
|
||||
{ ERR_TRANSMIT_ERROR,
|
||||
"The packet was not transmitted due to an error.\n" },
|
||||
|
||||
{ ERR_NO_SUCH_DESTINATION,
|
||||
"Token ring packet was not recognized when transmitted.\n" },
|
||||
|
||||
{ ERR_BUFFER_TOO_SMALL,
|
||||
"Provided buffer was too small.\n" },
|
||||
|
||||
{ ERR_ALREADY_STARTED,
|
||||
"Network drivers already started.\n" },
|
||||
|
||||
{ ERR_INCOMPLETE_BINDING,
|
||||
"Protocol driver could not complete its bindings.\n" },
|
||||
|
||||
{ ERR_DRIVER_NOT_INITIALIZED,
|
||||
"MAC did not initialize properly.\n" },
|
||||
|
||||
{ ERR_HARDWARE_NOT_FOUND,
|
||||
"Hardware not found.\n" },
|
||||
|
||||
{ ERR_HARDWARE_FAILURE,
|
||||
"Hardware failure.\n" },
|
||||
|
||||
{ ERR_CONFIGURATION_FAILURE,
|
||||
"Configuration failure.\n" },
|
||||
|
||||
{ ERR_INTERRUPT_CONFLICT,
|
||||
"Interrupt conflict.\n" },
|
||||
|
||||
{ ERR_INCOMPATIBLE_MAC,
|
||||
"The MAC is not compatible with the protocol.\n" },
|
||||
|
||||
{ ERR_INITIALIZATION_FAILED,
|
||||
"Initialization failed.\n" },
|
||||
|
||||
{ ERR_NO_BINDING,
|
||||
"Binding did not occur.\n" },
|
||||
|
||||
{ ERR_NETWORK_MAY_NOT_BE_CONNECTED,
|
||||
"The network may not be connected to the adapter.\n" },
|
||||
|
||||
{ ERR_INCOMPATIBLE_OS_VERSION,
|
||||
"The version of the operating system is incompatible with the protocol.\n" },
|
||||
|
||||
{ ERR_ALREADY_REGISTERED,
|
||||
"The protocol is already registered.\n" },
|
||||
|
||||
{ ERR_PATH_NOT_FOUND,
|
||||
"PROTMAN.EXE could not be found.\n" },
|
||||
|
||||
{ ERR_INSUFFICIENT_MEMORY,
|
||||
"Insufficient memory.\n" },
|
||||
|
||||
{ ERR_INFO_NOT_FOUND,
|
||||
"Protocol Mananger info structure is lost or corrupted.\n" },
|
||||
|
||||
{ ERR_GENERAL_FAILURE,
|
||||
"General failure.\n" }
|
||||
};
|
||||
|
||||
/*
|
||||
* Some handy macros
|
||||
*/
|
||||
#define PERROR(str) printf("%s (%d): %s\n", __FILE__,__LINE__,str)
|
||||
#define DEBUG_RING() (debugStrings[stopDebug+1 == MAX_NUM_DEBUG_STRINGS ? \
|
||||
stopDebug = 0 : ++stopDebug])
|
||||
|
||||
/*
|
||||
* needs rewrite for DOSX
|
||||
*/
|
||||
#define MAC_DISPATCH(hnd) ((struct _MacUpperDispatch*)(hnd)->common->upperDispatchTable)
|
||||
#define MAC_STATUS(hnd) ((struct _MacStatusTable*) (hnd)->common->serviceStatus)
|
||||
#define MAC_CHAR(hnd) ((struct _MacChars*) (hnd)->common->serviceChars)
|
||||
|
||||
#ifdef NDIS_DEBUG
|
||||
#define DEBUG0(str) printf (str)
|
||||
#define DEBUG1(fmt,a) printf (fmt,a)
|
||||
#define DEBUG2(fmt,a,b) printf (fmt,a,b)
|
||||
#define TRACE0(str) sprintf (DEBUG_RING(),str)
|
||||
#define TRACE1(fmt,a) sprintf (DEBUG_RING(),fmt,a)
|
||||
#else
|
||||
#define DEBUG0(str) ((void)0)
|
||||
#define DEBUG1(fmt,a) ((void)0)
|
||||
#define DEBUG2(fmt,a,b) ((void)0)
|
||||
#define TRACE0(str) ((void)0)
|
||||
#define TRACE1(fmt,a) ((void)0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This routine is called from both threads
|
||||
*/
|
||||
void NdisFreeStack (BYTE *aStack)
|
||||
{
|
||||
GUARD();
|
||||
|
||||
if (freeStackPtr == STACK_POOL_SIZE - 1)
|
||||
PERROR ("tried to free too many stacks");
|
||||
|
||||
freeStacks[++freeStackPtr] = aStack;
|
||||
|
||||
if (freeStackPtr == 0)
|
||||
TRACE0 ("freeStackPtr went positive\n");
|
||||
|
||||
UNGUARD();
|
||||
}
|
||||
|
||||
/*
|
||||
* This routine is called from callbacks to allocate local data
|
||||
*/
|
||||
BYTE *NdisAllocStack (void)
|
||||
{
|
||||
BYTE *stack;
|
||||
|
||||
GUARD();
|
||||
|
||||
if (freeStackPtr < 0)
|
||||
{
|
||||
/* Ran out of stack buffers. Return NULL which will start
|
||||
* dropping packets
|
||||
*/
|
||||
TRACE0 ("freeStackPtr went negative\n");
|
||||
stack = 0;
|
||||
}
|
||||
else
|
||||
stack = freeStacks[freeStackPtr--];
|
||||
|
||||
UNGUARD();
|
||||
return (stack);
|
||||
}
|
||||
|
||||
CALLBACK (NdisSystemRequest (DWORD param1, DWORD param2, WORD param3,
|
||||
WORD opcode, WORD targetDS))
|
||||
{
|
||||
static int bindEntry = 0;
|
||||
struct _CommonChars *macCommon;
|
||||
volatile WORD result;
|
||||
|
||||
switch (opcode)
|
||||
{
|
||||
case REQ_INITIATE_BIND:
|
||||
macCommon = (struct _CommonChars*) param2;
|
||||
if (macCommon == NULL)
|
||||
{
|
||||
printf ("There is an NDIS misconfiguration.\n");
|
||||
result = ERR_GENERAL_FAILURE;
|
||||
break;
|
||||
}
|
||||
DEBUG2 ("module name %s\n"
|
||||
"module type %s\n",
|
||||
macCommon->moduleName,
|
||||
((MacChars*) macCommon->serviceChars)->macName);
|
||||
|
||||
/* Binding to the MAC */
|
||||
result = macCommon->systemRequest ((DWORD)&common, (DWORD)&macCommon,
|
||||
0, REQ_BIND,
|
||||
macCommon->moduleDS);
|
||||
|
||||
if (!strcmp(bindings.moduleName[bindEntry], handle->moduleName))
|
||||
handle->common = macCommon;
|
||||
else PERROR ("unknown module");
|
||||
++bindEntry;
|
||||
break;
|
||||
|
||||
case REQ_INITIATE_UNBIND:
|
||||
macCommon = (struct _CommonChars*) param2;
|
||||
result = macCommon->systemRequest ((DWORD)&common, 0,
|
||||
0, REQ_UNBIND,
|
||||
macCommon->moduleDS);
|
||||
break;
|
||||
|
||||
default:
|
||||
result = ERR_GENERAL_FAILURE;
|
||||
break;
|
||||
}
|
||||
ARGSUSED (param1);
|
||||
ARGSUSED (param3);
|
||||
ARGSUSED (targetDS);
|
||||
return (result);
|
||||
}
|
||||
|
||||
CALLBACK (NdisRequestConfirm (WORD protId, WORD macId, WORD reqHandle,
|
||||
WORD status, WORD request, WORD protDS))
|
||||
{
|
||||
ARGSUSED (protId); ARGSUSED (macId);
|
||||
ARGSUSED (reqHandle); ARGSUSED (status);
|
||||
ARGSUSED (request); ARGSUSED (protDS);
|
||||
return (ERR_SUCCESS);
|
||||
}
|
||||
|
||||
CALLBACK (NdisTransmitConfirm (WORD protId, WORD macId, WORD reqHandle,
|
||||
WORD status, WORD protDS))
|
||||
{
|
||||
xmitPending--;
|
||||
FreePktBuf (txBufPending); /* Add passed ECB back to the free list */
|
||||
|
||||
ARGSUSED (reqHandle);
|
||||
ARGSUSED (status);
|
||||
ARGSUSED (protDS);
|
||||
return (ERR_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* The primary function for receiving packets
|
||||
*/
|
||||
CALLBACK (NdisReceiveLookahead (WORD macId, WORD frameSize,
|
||||
WORD bytesAvail, BYTE *buffer,
|
||||
BYTE *indicate, WORD protDS))
|
||||
{
|
||||
int result;
|
||||
PktBuf *pktBuf;
|
||||
WORD bytesCopied;
|
||||
struct _TDBufDescr tDBufDescr;
|
||||
|
||||
#if 0
|
||||
TRACE1 ("lookahead length = %d, ", bytesAvail);
|
||||
TRACE1 ("ecb = %08lX, ", *ecb);
|
||||
TRACE1 ("count = %08lX\n", count);
|
||||
TRACE1 ("offset = %08lX, ", offset);
|
||||
TRACE1 ("timesAllowed = %d, ", timesAllowed);
|
||||
TRACE1 ("packet size = %d\n", look->dataLookAheadLen);
|
||||
#endif
|
||||
|
||||
/* Allocate a buffer for the packet
|
||||
*/
|
||||
if ((pktBuf = AllocPktBuf()) == NULL)
|
||||
{
|
||||
droppedPackets++;
|
||||
return (ERR_FRAME_REJECTED);
|
||||
}
|
||||
|
||||
/*
|
||||
* Now kludge things. Note we will have to undo this later. This will
|
||||
* make the packet contiguous after the MLID has done the requested copy.
|
||||
*/
|
||||
|
||||
tDBufDescr.tDDataCount = 1;
|
||||
tDBufDescr.tDBufDescrRec[0].tDPtrType = NDIS_PTR_PHYSICAL;
|
||||
tDBufDescr.tDBufDescrRec[0].tDDataPtr = pktBuf->buffer;
|
||||
tDBufDescr.tDBufDescrRec[0].tDDataLen = pktBuf->length;
|
||||
tDBufDescr.tDBufDescrRec[0].dummy = 0;
|
||||
|
||||
result = MAC_DISPATCH(handle)->transferData (&bytesCopied, 0, &tDBufDescr,
|
||||
handle->common->moduleDS);
|
||||
pktBuf->packetLength = bytesCopied;
|
||||
|
||||
if (result == ERR_SUCCESS)
|
||||
EnquePktBuf(pktBuf);
|
||||
else FreePktBuf (pktBuf);
|
||||
|
||||
ARGSUSED (frameSize);
|
||||
ARGSUSED (bytesAvail);
|
||||
ARGSUSED (indicate);
|
||||
ARGSUSED (protDS);
|
||||
|
||||
return (ERR_SUCCESS);
|
||||
}
|
||||
|
||||
CALLBACK (NdisIndicationComplete (WORD macId, WORD protDS))
|
||||
{
|
||||
ARGSUSED (macId);
|
||||
ARGSUSED (protDS);
|
||||
|
||||
/* We don't give a hoot about these. Just return
|
||||
*/
|
||||
return (ERR_SUCCESS);
|
||||
}
|
||||
|
||||
/*
|
||||
* This is the OTHER way we may receive packets
|
||||
*/
|
||||
CALLBACK (NdisReceiveChain (WORD macId, WORD frameSize, WORD reqHandle,
|
||||
struct _RxBufDescr *rxBufDescr,
|
||||
BYTE *indicate, WORD protDS))
|
||||
{
|
||||
struct _PktBuf *pktBuf;
|
||||
int i;
|
||||
|
||||
/*
|
||||
* For now we copy the entire packet over to a PktBuf structure. This may be
|
||||
* a performance hit but this routine probably isn't called very much, and
|
||||
* it is a lot of work to do it otherwise. Also if it is a filter protocol
|
||||
* packet we could end up sucking up MAC buffes.
|
||||
*/
|
||||
|
||||
if ((pktBuf = AllocPktBuf()) == NULL)
|
||||
{
|
||||
droppedPackets++;
|
||||
return (ERR_FRAME_REJECTED);
|
||||
}
|
||||
pktBuf->packetLength = 0;
|
||||
|
||||
/* Copy the packet to the buffer
|
||||
*/
|
||||
for (i = 0; i < rxBufDescr->rxDataCount; ++i)
|
||||
{
|
||||
struct _RxBufDescrRec *rxDescr = &rxBufDescr->rxBufDescrRec[i];
|
||||
|
||||
memcpy (pktBuf->buffer + pktBuf->packetLength,
|
||||
rxDescr->rxDataPtr, rxDescr->rxDataLen);
|
||||
pktBuf->packetLength += rxDescr->rxDataLen;
|
||||
}
|
||||
|
||||
EnquePktBuf (pktBuf);
|
||||
|
||||
ARGSUSED (frameSize);
|
||||
ARGSUSED (reqHandle);
|
||||
ARGSUSED (indicate);
|
||||
ARGSUSED (protDS);
|
||||
|
||||
/* This frees up the buffer for the MAC to use
|
||||
*/
|
||||
return (ERR_SUCCESS);
|
||||
}
|
||||
|
||||
CALLBACK (NdisStatusProc (WORD macId, WORD param1, BYTE *indicate,
|
||||
WORD opcode, WORD protDS))
|
||||
{
|
||||
switch (opcode)
|
||||
{
|
||||
case STATUS_RING_STATUS:
|
||||
break;
|
||||
case STATUS_ADAPTER_CHECK:
|
||||
break;
|
||||
case STATUS_START_RESET:
|
||||
break;
|
||||
case STATUS_INTERRUPT:
|
||||
break;
|
||||
case STATUS_END_RESET:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
ARGSUSED (macId);
|
||||
ARGSUSED (param1);
|
||||
ARGSUSED (indicate);
|
||||
ARGSUSED (opcode);
|
||||
ARGSUSED (protDS);
|
||||
|
||||
/* We don't need to do anything about this stuff yet
|
||||
*/
|
||||
return (ERR_SUCCESS);
|
||||
}
|
||||
|
||||
/*
|
||||
* Tell the NDIS driver to start the delivery of the packet
|
||||
*/
|
||||
int NdisSendPacket (struct _PktBuf *pktBuf, int macId)
|
||||
{
|
||||
struct _TxBufDescr txBufDescr;
|
||||
int result;
|
||||
|
||||
xmitPending++;
|
||||
txBufPending = pktBuf; /* we only have 1 pending Tx at a time */
|
||||
|
||||
txBufDescr.txImmedLen = 0;
|
||||
txBufDescr.txImmedPtr = NULL;
|
||||
txBufDescr.txDataCount = 1;
|
||||
txBufDescr.txBufDescrRec[0].txPtrType = NDIS_PTR_PHYSICAL;
|
||||
txBufDescr.txBufDescrRec[0].dummy = 0;
|
||||
txBufDescr.txBufDescrRec[0].txDataLen = pktBuf->packetLength;
|
||||
txBufDescr.txBufDescrRec[0].txDataPtr = pktBuf->buffer;
|
||||
|
||||
result = MAC_DISPATCH(handle)->transmitChain (common.moduleId,
|
||||
pktBuf->handle,
|
||||
&txBufDescr,
|
||||
handle->common->moduleDS);
|
||||
switch (result)
|
||||
{
|
||||
case ERR_OUT_OF_RESOURCE:
|
||||
/* Note that this should not happen but if it does there is not
|
||||
* much we can do about it
|
||||
*/
|
||||
printf ("ERROR: transmit queue overflowed\n");
|
||||
return (0);
|
||||
|
||||
case ERR_SUCCESS:
|
||||
/* Everything was hunky dory and synchronous. Free up the
|
||||
* packet buffer
|
||||
*/
|
||||
xmitPending--;
|
||||
FreePktBuf (pktBuf);
|
||||
return (1);
|
||||
|
||||
case ERR_REQUEST_QUEUED:
|
||||
/* Everything was hunky dory and asynchronous. Do nothing
|
||||
*/
|
||||
return (1);
|
||||
|
||||
default:
|
||||
printf ("Tx fail, code = %04X\n", result);
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int ndis_nerr = sizeof(ndis_errlist) / sizeof(ndis_errlist[0]);
|
||||
|
||||
static char *Ndis_strerror (WORD errorCode)
|
||||
{
|
||||
static char buf[30];
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ndis_nerr; i++)
|
||||
if (errorCode == ndis_errlist[i].err_num)
|
||||
return (ndis_errlist[i].err_text);
|
||||
|
||||
sprintf (buf,"unknown error %d",errorCode);
|
||||
return (buf);
|
||||
}
|
||||
|
||||
|
||||
char *NdisLastError (void)
|
||||
{
|
||||
char *errStr = lastErr;
|
||||
lastErr = NULL;
|
||||
return (errStr);
|
||||
}
|
||||
|
||||
int NdisOpen (void)
|
||||
{
|
||||
struct _ReqBlock reqBlock;
|
||||
int result;
|
||||
int ndisFd = open (NDIS_PATH, O_RDONLY);
|
||||
|
||||
if (ndisFd < 0)
|
||||
{
|
||||
printf ("Could not open NDIS Protocol Manager device.\n");
|
||||
return (0);
|
||||
}
|
||||
|
||||
memset (&reqBlock, 0, sizeof(ReqBlock));
|
||||
|
||||
reqBlock.opcode = PM_GET_PROTOCOL_MANAGER_LINKAGE;
|
||||
|
||||
result = NdisGetLinkage (ndisFd, (char*)&reqBlock, sizeof(ReqBlock));
|
||||
if (result != 0)
|
||||
{
|
||||
printf ("Could not get Protocol Manager linkage.\n");
|
||||
close (ndisFd);
|
||||
return (0);
|
||||
}
|
||||
|
||||
close (ndisFd);
|
||||
protManEntry = (ProtMan) reqBlock.pointer1;
|
||||
protManDS = reqBlock.word1;
|
||||
|
||||
DEBUG2 ("Entry Point = %04X:%04X\n", FP_SEG(protManEntry),FP_OFF(protManEntry));
|
||||
DEBUG1 ("ProtMan DS = %04X\n", protManDS);
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
||||
int NdisRegisterAndBind (int promis)
|
||||
{
|
||||
struct _ReqBlock reqBlock;
|
||||
WORD result;
|
||||
|
||||
memset (&common,0,sizeof(common));
|
||||
|
||||
common.tableSize = sizeof (common);
|
||||
|
||||
common.majorNdisVersion = 2;
|
||||
common.minorNdisVersion = 0;
|
||||
common.majorModuleVersion = 2;
|
||||
common.minorModuleVersion = 0;
|
||||
|
||||
/* Indicates binding from below and dynamically loaded
|
||||
*/
|
||||
common.moduleFlags = 0x00000006L;
|
||||
|
||||
strcpy (common.moduleName, "PCAP");
|
||||
|
||||
common.protocolLevelUpper = 0xFF;
|
||||
common.protocolLevelLower = 1;
|
||||
common.interfaceLower = 1;
|
||||
#ifdef __DJGPP__
|
||||
common.moduleDS = _dos_ds; /* the callback data segment */
|
||||
#else
|
||||
common.moduleDS = _DS;
|
||||
#endif
|
||||
|
||||
common.systemRequest = (SystemRequest) systemRequestGlue;
|
||||
common.serviceChars = (BYTE*) &protChars;
|
||||
common.serviceStatus = NULL;
|
||||
common.upperDispatchTable = NULL;
|
||||
common.lowerDispatchTable = (BYTE*) &lowerTable;
|
||||
|
||||
protChars.length = sizeof (protChars);
|
||||
protChars.name[0] = 0;
|
||||
protChars.type = 0;
|
||||
|
||||
lowerTable.backPointer = &common;
|
||||
lowerTable.requestConfirm = requestConfirmGlue;
|
||||
lowerTable.transmitConfirm = transmitConfirmGlue;
|
||||
lowerTable.receiveLookahead = receiveLookaheadGlue;
|
||||
lowerTable.indicationComplete = indicationCompleteGlue;
|
||||
lowerTable.receiveChain = receiveChainGlue;
|
||||
lowerTable.status = statusGlue;
|
||||
lowerTable.flags = 3;
|
||||
if (promis)
|
||||
lowerTable.flags |= 4; /* promiscous mode (receive everything) */
|
||||
|
||||
bindings.numBindings = 1;
|
||||
strcpy (bindings.moduleName[0], handle->moduleName);
|
||||
|
||||
/* Register ourselves with NDIS
|
||||
*/
|
||||
reqBlock.opcode = PM_REGISTER_MODULE;
|
||||
reqBlock.pointer1 = (BYTE FAR*) &common;
|
||||
reqBlock.pointer2 = (BYTE FAR*) &bindings;
|
||||
|
||||
result = (*protManEntry) (&reqBlock, protManDS);
|
||||
if (result)
|
||||
{
|
||||
printf ("Protman registering failed: %s\n", Ndis_strerror(result));
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Start the binding process
|
||||
*/
|
||||
reqBlock.opcode = PM_BIND_AND_START;
|
||||
reqBlock.pointer1 = (BYTE FAR*) &failingModules;
|
||||
|
||||
result = (*protManEntry) (&reqBlock, protManDS);
|
||||
if (result)
|
||||
{
|
||||
printf ("Start binding failed: %s\n", Ndis_strerror(result));
|
||||
return (0);
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int CheckMacFeatures (CardHandle *card)
|
||||
{
|
||||
DWORD serviceFlags;
|
||||
BYTE _far *mediaString;
|
||||
BYTE _far *mac_addr;
|
||||
|
||||
DEBUG2 ("checking card features\n"
|
||||
"common table address = %08lX, macId = %d\n",
|
||||
card->common, card->common->moduleId);
|
||||
|
||||
serviceFlags = MAC_CHAR (handle)->serviceFlags;
|
||||
|
||||
if ((serviceFlags & SF_PROMISCUOUS) == 0)
|
||||
{
|
||||
printf ("The MAC %s does not support promiscuous mode.\n",
|
||||
card->moduleName);
|
||||
return (0);
|
||||
}
|
||||
|
||||
mediaString = MAC_CHAR (handle)->macName;
|
||||
|
||||
DEBUG1 ("media type = %s\n",mediaString);
|
||||
|
||||
/* Get the media type. And set the header size
|
||||
*/
|
||||
if (!strncmp(mediaString,"802.3",5) ||
|
||||
!strncmp(mediaString,"DIX",3) ||
|
||||
!strncmp(mediaString,"DIX+802.3",9))
|
||||
headerSize = sizeof (EthernetIIHeader);
|
||||
|
||||
else if (!strncmp(mediaString,"FDDI",4))
|
||||
headerSize = sizeof (FddiHeader) +
|
||||
sizeof (Ieee802Dot2SnapHeader);
|
||||
else
|
||||
{
|
||||
printf ("Unsupported MAC type: `%s'\n", mediaString);
|
||||
return (0);
|
||||
}
|
||||
|
||||
frameSize = MAC_CHAR (handle)->maxFrameSize;
|
||||
mac_addr = MAC_CHAR (handle)->currentAddress;
|
||||
|
||||
printf ("Hardware address: %02X:%02X:%02X:%02X:%02X:%02X\n",
|
||||
mac_addr[0], mac_addr[1], mac_addr[2],
|
||||
mac_addr[3], mac_addr[4], mac_addr[5]);
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int NdisStartMac (CardHandle *card)
|
||||
{
|
||||
WORD result;
|
||||
|
||||
/* Set the lookahead length
|
||||
*/
|
||||
result = MAC_DISPATCH(handle)->request (common.moduleId, 0,
|
||||
headerSize, 0,
|
||||
REQ_SET_LOOKAHEAD,
|
||||
card->common->moduleDS);
|
||||
|
||||
/* We assume that if we got INVALID PARAMETER then either this
|
||||
* is not supported or will work anyway. NE2000 does this.
|
||||
*/
|
||||
if (result != ERR_SUCCESS && result != ERR_INVALID_PARAMETER)
|
||||
{
|
||||
DEBUG1 ("Set lookahead failed: %s\n", Ndis_strerror(result));
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Set the packet filter. Note that for some medias and drivers we
|
||||
* must specify all three flags or the card(s) will not operate correctly.
|
||||
*/
|
||||
result = MAC_DISPATCH(handle)->request (common.moduleId, 0,
|
||||
/* all packets */ FILTER_PROMISCUOUS |
|
||||
/* packets to us */ FILTER_DIRECTED |
|
||||
/* broadcasts */ FILTER_BROADCAST,
|
||||
0, REQ_SET_PACKET_FILTER,
|
||||
card->common->moduleDS);
|
||||
if (result != ERR_SUCCESS)
|
||||
{
|
||||
DEBUG1 ("Set packet filter failed: %s\n", Ndis_strerror(result));
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* If OPEN/CLOSE supported then open the adapter
|
||||
*/
|
||||
if (MAC_CHAR(handle)->serviceFlags & SF_OPEN_CLOSE)
|
||||
{
|
||||
result = MAC_DISPATCH(handle)->request (common.moduleId, 0, 0, NULL,
|
||||
REQ_OPEN_ADAPTER,
|
||||
card->common->moduleDS);
|
||||
if (result != ERR_SUCCESS)
|
||||
{
|
||||
DEBUG1 ("Opening the MAC failed: %s\n", Ndis_strerror(result));
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
void NdisShutdown (void)
|
||||
{
|
||||
struct _ReqBlock reqBlock;
|
||||
int result, i;
|
||||
|
||||
if (!handle)
|
||||
return;
|
||||
|
||||
/* If the adapters support open and are open then close them
|
||||
*/
|
||||
if ((MAC_CHAR(handle)->serviceFlags & SF_OPEN_CLOSE) &&
|
||||
(MAC_STATUS(handle)->macStatus & MAC_OPEN))
|
||||
{
|
||||
result = MAC_DISPATCH(handle)->request (common.moduleId, 0, 0, 0,
|
||||
REQ_CLOSE_ADAPTER,
|
||||
handle->common->moduleDS);
|
||||
if (result != ERR_SUCCESS)
|
||||
{
|
||||
printf ("Closing the MAC failed: %s\n", Ndis_strerror(result));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Tell the Protocol Manager to unbind and stop
|
||||
*/
|
||||
reqBlock.opcode = PM_UNBIND_AND_STOP;
|
||||
reqBlock.pointer1 = (BYTE FAR*) &failingModules;
|
||||
reqBlock.pointer2 = NULL;
|
||||
|
||||
result = (*protManEntry) (&reqBlock, protManDS);
|
||||
if (result)
|
||||
printf ("Unbind failed: %s\n", Ndis_strerror(result));
|
||||
|
||||
for (i = 0; i < STACK_POOL_SIZE; ++i)
|
||||
free (freeStacks[i] - STACK_SIZE);
|
||||
|
||||
handle = NULL;
|
||||
}
|
||||
|
||||
int NdisInit (int promis)
|
||||
{
|
||||
int i, result;
|
||||
|
||||
/* Allocate the real mode stacks used for NDIS callbacks
|
||||
*/
|
||||
for (i = 0; i < STACK_POOL_SIZE; ++i)
|
||||
{
|
||||
freeStacks[i] = malloc (STACK_SIZE);
|
||||
if (!freeStacks[i])
|
||||
return (0);
|
||||
freeStacks[i] += STACK_SIZE;
|
||||
}
|
||||
|
||||
if (!NdisOpen())
|
||||
return (0);
|
||||
|
||||
if (!NdisRegisterAndBind(promis))
|
||||
return (0);
|
||||
|
||||
DEBUG1 ("My module id: %d\n", common.moduleId);
|
||||
DEBUG1 ("Handle id; %d\n", handle->common->moduleId);
|
||||
DEBUG1 ("MAC card: %-16s - ", handle->moduleName);
|
||||
|
||||
atexit (NdisShutdown);
|
||||
|
||||
if (!CheckMacFeatures(&handle))
|
||||
return (0);
|
||||
|
||||
switch (mediaType)
|
||||
{
|
||||
case MEDIA_FDDI:
|
||||
DEBUG0 ("Media type: FDDI");
|
||||
break;
|
||||
case MEDIA_ETHERNET:
|
||||
DEBUG0 ("Media type: ETHERNET");
|
||||
break;
|
||||
default:
|
||||
DEBUG0 ("Unsupported media.\n");
|
||||
return (0);
|
||||
}
|
||||
|
||||
DEBUG1 (" - Frame size: %d\n", frameSize);
|
||||
|
||||
if (!NdisStartMac(&handle))
|
||||
return (0);
|
||||
return (1);
|
||||
}
|
||||
#endif /* USE_NDIS2 */
|
||||
|
||||
559
libpcap/msdos/ndis2.h
Normal file
559
libpcap/msdos/ndis2.h
Normal file
@@ -0,0 +1,559 @@
|
||||
/*
|
||||
* Copyright (c) 1993,1994
|
||||
* Texas A&M University. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Texas A&M University
|
||||
* and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* Developers:
|
||||
* David K. Hess, Douglas Lee Schales, David R. Safford
|
||||
*
|
||||
* Heavily modified for Metaware HighC + GNU C 2.8+
|
||||
* Gisle Vanem 1998
|
||||
*/
|
||||
|
||||
#ifndef __PCAP_NDIS_H
|
||||
#define __PCAP_NDIS_H
|
||||
|
||||
#if defined (__HIGHC__)
|
||||
#define pascal _CC(_CALLEE_POPS_STACK & ~_REVERSE_PARMS) /* calling convention */
|
||||
#define CALLBACK(foo) pascal WORD foo
|
||||
#define PAS_PTR(x,arg) typedef FAR WORD pascal (*x) arg
|
||||
#define GUARD() _inline (0x9C,0xFA) /* pushfd, cli */
|
||||
#define UNGUARD() _inline (0x9D) /* popfd */
|
||||
#define FAR _far
|
||||
|
||||
#elif defined(__GNUC__)
|
||||
#define CALLBACK(foo) WORD foo __attribute__((stdcall))
|
||||
#define PAS_PTR(x,arg) typedef WORD (*x) arg __attribute__((stdcall))
|
||||
#define GUARD() __asm__ __volatile__ ("pushfd; cli")
|
||||
#define UNGUARD() __asm__ __volatile__ ("popfd")
|
||||
#define FAR
|
||||
|
||||
#elif defined (__TURBOC__)
|
||||
#define CALLBACK(foo) WORD pascal foo
|
||||
#define PAS_PTR(x,arg) typedef WORD pascal (_far *x) arg
|
||||
#define GUARD() _asm { pushf; cli }
|
||||
#define UNGUARD() _asm { popf }
|
||||
#define FAR _far
|
||||
|
||||
#elif defined (__WATCOMC__)
|
||||
#define CALLBACK(foo) WORD pascal foo
|
||||
#define PAS_PTR(x,arg) typedef WORD pascal (_far *x) arg
|
||||
#define GUARD() _disable()
|
||||
#define UNGUARD() _enable()
|
||||
#define FAR _far
|
||||
|
||||
#else
|
||||
#error Unsupported compiler
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Forwards
|
||||
*/
|
||||
struct _ReqBlock;
|
||||
struct _TxBufDescr;
|
||||
struct _TDBufDescr;
|
||||
|
||||
/*
|
||||
* Protocol Manager API
|
||||
*/
|
||||
PAS_PTR (ProtMan, (struct _ReqBlock FAR*, WORD));
|
||||
|
||||
/*
|
||||
* System request
|
||||
*/
|
||||
PAS_PTR (SystemRequest, (DWORD, DWORD, WORD, WORD, WORD));
|
||||
|
||||
/*
|
||||
* MAC API
|
||||
*/
|
||||
PAS_PTR (TransmitChain, (WORD, WORD, struct _TxBufDescr FAR*, WORD));
|
||||
PAS_PTR (TransferData, (WORD*,WORD, struct _TDBufDescr FAR*, WORD));
|
||||
PAS_PTR (Request, (WORD, WORD, WORD, DWORD, WORD, WORD));
|
||||
PAS_PTR (ReceiveRelease,(WORD, WORD));
|
||||
PAS_PTR (IndicationOn, (WORD));
|
||||
PAS_PTR (IndicationOff, (WORD));
|
||||
|
||||
|
||||
typedef enum {
|
||||
HARDWARE_NOT_INSTALLED = 0,
|
||||
HARDWARE_FAILED_DIAG = 1,
|
||||
HARDWARE_FAILED_CONFIG = 2,
|
||||
HARDWARE_HARD_FAULT = 3,
|
||||
HARDWARE_SOFT_FAULT = 4,
|
||||
HARDWARE_OK = 7,
|
||||
HARDWARE_MASK = 0x0007,
|
||||
MAC_BOUND = 0x0008,
|
||||
MAC_OPEN = 0x0010,
|
||||
DIAG_IN_PROGRESS = 0x0020
|
||||
} NdisMacStatus;
|
||||
|
||||
typedef enum {
|
||||
STATUS_RING_STATUS = 1,
|
||||
STATUS_ADAPTER_CHECK = 2,
|
||||
STATUS_START_RESET = 3,
|
||||
STATUS_INTERRUPT = 4,
|
||||
STATUS_END_RESET = 5
|
||||
} NdisStatus;
|
||||
|
||||
typedef enum {
|
||||
FILTER_DIRECTED = 1,
|
||||
FILTER_BROADCAST = 2,
|
||||
FILTER_PROMISCUOUS = 4,
|
||||
FILTER_SOURCE_ROUTE = 8
|
||||
} NdisPacketFilter;
|
||||
|
||||
typedef enum {
|
||||
REQ_INITIATE_DIAGNOSTICS = 1,
|
||||
REQ_READ_ERROR_LOG = 2,
|
||||
REQ_SET_STATION_ADDRESS = 3,
|
||||
REQ_OPEN_ADAPTER = 4,
|
||||
REQ_CLOSE_ADAPTER = 5,
|
||||
REQ_RESET_MAC = 6,
|
||||
REQ_SET_PACKET_FILTER = 7,
|
||||
REQ_ADD_MULTICAST_ADDRESS = 8,
|
||||
REQ_DELETE_MULTICAST_ADDRESS = 9,
|
||||
REQ_UPDATE_STATISTICS = 10,
|
||||
REQ_CLEAR_STATISTICS = 11,
|
||||
REQ_INTERRUPT_REQUEST = 12,
|
||||
REQ_SET_FUNCTIONAL_ADDRESS = 13,
|
||||
REQ_SET_LOOKAHEAD = 14
|
||||
} NdisGeneralRequest;
|
||||
|
||||
typedef enum {
|
||||
SF_BROADCAST = 0x00000001L,
|
||||
SF_MULTICAST = 0x00000002L,
|
||||
SF_FUNCTIONAL = 0x00000004L,
|
||||
SF_PROMISCUOUS = 0x00000008L,
|
||||
SF_SOFT_ADDRESS = 0x00000010L,
|
||||
SF_STATS_CURRENT = 0x00000020L,
|
||||
SF_INITIATE_DIAGS = 0x00000040L,
|
||||
SF_LOOPBACK = 0x00000080L,
|
||||
SF_RECEIVE_CHAIN = 0x00000100L,
|
||||
SF_SOURCE_ROUTING = 0x00000200L,
|
||||
SF_RESET_MAC = 0x00000400L,
|
||||
SF_OPEN_CLOSE = 0x00000800L,
|
||||
SF_INTERRUPT_REQUEST = 0x00001000L,
|
||||
SF_SOURCE_ROUTING_BRIDGE = 0x00002000L,
|
||||
SF_VIRTUAL_ADDRESSES = 0x00004000L
|
||||
} NdisMacServiceFlags;
|
||||
|
||||
typedef enum {
|
||||
REQ_INITIATE_BIND = 1,
|
||||
REQ_BIND = 2,
|
||||
REQ_INITIATE_PREBIND = 3,
|
||||
REQ_INITIATE_UNBIND = 4,
|
||||
REQ_UNBIND = 5
|
||||
} NdisSysRequest;
|
||||
|
||||
typedef enum {
|
||||
PM_GET_PROTOCOL_MANAGER_INFO = 1,
|
||||
PM_REGISTER_MODULE = 2,
|
||||
PM_BIND_AND_START = 3,
|
||||
PM_GET_PROTOCOL_MANAGER_LINKAGE = 4,
|
||||
PM_GET_PROTOCOL_INI_PATH = 5,
|
||||
PM_REGISTER_PROTOCOL_MANAGER_INFO = 6,
|
||||
PM_INIT_AND_REGISTER = 7,
|
||||
PM_UNBIND_AND_STOP = 8,
|
||||
PM_BIND_STATUS = 9,
|
||||
PM_REGISTER_STATUS = 10
|
||||
} NdisProtManager;
|
||||
|
||||
|
||||
typedef enum {
|
||||
ERR_SUCCESS = 0x00,
|
||||
ERR_WAIT_FOR_RELEASE = 0x01,
|
||||
ERR_REQUEST_QUEUED = 0x02,
|
||||
ERR_FRAME_NOT_RECOGNIZED = 0x03,
|
||||
ERR_FRAME_REJECTED = 0x04,
|
||||
ERR_FORWARD_FRAME = 0x05,
|
||||
ERR_OUT_OF_RESOURCE = 0x06,
|
||||
ERR_INVALID_PARAMETER = 0x07,
|
||||
ERR_INVALID_FUNCTION = 0x08,
|
||||
ERR_NOT_SUPPORTED = 0x09,
|
||||
ERR_HARDWARE_ERROR = 0x0A,
|
||||
ERR_TRANSMIT_ERROR = 0x0B,
|
||||
ERR_NO_SUCH_DESTINATION = 0x0C,
|
||||
ERR_BUFFER_TOO_SMALL = 0x0D,
|
||||
ERR_ALREADY_STARTED = 0x20,
|
||||
ERR_INCOMPLETE_BINDING = 0x21,
|
||||
ERR_DRIVER_NOT_INITIALIZED = 0x22,
|
||||
ERR_HARDWARE_NOT_FOUND = 0x23,
|
||||
ERR_HARDWARE_FAILURE = 0x24,
|
||||
ERR_CONFIGURATION_FAILURE = 0x25,
|
||||
ERR_INTERRUPT_CONFLICT = 0x26,
|
||||
ERR_INCOMPATIBLE_MAC = 0x27,
|
||||
ERR_INITIALIZATION_FAILED = 0x28,
|
||||
ERR_NO_BINDING = 0x29,
|
||||
ERR_NETWORK_MAY_NOT_BE_CONNECTED = 0x2A,
|
||||
ERR_INCOMPATIBLE_OS_VERSION = 0x2B,
|
||||
ERR_ALREADY_REGISTERED = 0x2C,
|
||||
ERR_PATH_NOT_FOUND = 0x2D,
|
||||
ERR_INSUFFICIENT_MEMORY = 0x2E,
|
||||
ERR_INFO_NOT_FOUND = 0x2F,
|
||||
ERR_GENERAL_FAILURE = 0xFF
|
||||
} NdisError;
|
||||
|
||||
#define NDIS_PARAM_INTEGER 0
|
||||
#define NDIS_PARAM_STRING 1
|
||||
|
||||
#define NDIS_TX_BUF_LENGTH 8
|
||||
#define NDIS_TD_BUF_LENGTH 1
|
||||
#define NDIS_RX_BUF_LENGTH 8
|
||||
|
||||
#define NDIS_PTR_PHYSICAL 0
|
||||
#define NDIS_PTR_VIRTUAL 2
|
||||
|
||||
#define NDIS_PATH "PROTMAN$"
|
||||
|
||||
|
||||
typedef struct _CommonChars {
|
||||
WORD tableSize;
|
||||
BYTE majorNdisVersion; /* 2 - Latest version */
|
||||
BYTE minorNdisVersion; /* 0 */
|
||||
WORD reserved1;
|
||||
BYTE majorModuleVersion;
|
||||
BYTE minorModuleVersion;
|
||||
DWORD moduleFlags;
|
||||
/* 0 - Binding at upper boundary supported
|
||||
* 1 - Binding at lower boundary supported
|
||||
* 2 - Dynamically bound.
|
||||
* 3-31 - Reserved, must be zero.
|
||||
*/
|
||||
BYTE moduleName[16];
|
||||
BYTE protocolLevelUpper;
|
||||
/* 1 - MAC
|
||||
* 2 - Data Link
|
||||
* 3 - Network
|
||||
* 4 - Transport
|
||||
* 5 - Session
|
||||
* -1 - Not specified
|
||||
*/
|
||||
BYTE interfaceUpper;
|
||||
BYTE protocolLevelLower;
|
||||
/* 0 - Physical
|
||||
* 1 - MAC
|
||||
* 2 - Data Link
|
||||
* 3 - Network
|
||||
* 4 - Transport
|
||||
* 5 - Session
|
||||
* -1 - Not specified
|
||||
*/
|
||||
BYTE interfaceLower;
|
||||
WORD moduleId;
|
||||
WORD moduleDS;
|
||||
SystemRequest systemRequest;
|
||||
BYTE *serviceChars;
|
||||
BYTE *serviceStatus;
|
||||
BYTE *upperDispatchTable;
|
||||
BYTE *lowerDispatchTable;
|
||||
BYTE *reserved2; /* Must be NULL */
|
||||
BYTE *reserved3; /* Must be NULL */
|
||||
} CommonChars;
|
||||
|
||||
|
||||
typedef struct _MulticastList {
|
||||
WORD maxMulticastAddresses;
|
||||
WORD numberMulticastAddresses;
|
||||
BYTE multicastAddress[16][16];
|
||||
} MulticastList;
|
||||
|
||||
|
||||
typedef struct _MacChars {
|
||||
WORD tableSize;
|
||||
BYTE macName[16];
|
||||
WORD addressLength;
|
||||
BYTE permanentAddress[16];
|
||||
BYTE currentAddress[16];
|
||||
DWORD currentFunctionalAddress;
|
||||
MulticastList *multicastList;
|
||||
DWORD linkSpeed;
|
||||
DWORD serviceFlags;
|
||||
WORD maxFrameSize;
|
||||
DWORD txBufferSize;
|
||||
WORD txBufferAllocSize;
|
||||
DWORD rxBufferSize;
|
||||
WORD rxBufferAllocSize;
|
||||
BYTE ieeeVendor[3];
|
||||
BYTE vendorAdapter;
|
||||
BYTE *vendorAdapterDescription;
|
||||
WORD interruptLevel;
|
||||
WORD txQueueDepth;
|
||||
WORD maxDataBlocks;
|
||||
} MacChars;
|
||||
|
||||
|
||||
typedef struct _ProtocolChars {
|
||||
WORD length;
|
||||
BYTE name[16];
|
||||
WORD type;
|
||||
} ProtocolChars;
|
||||
|
||||
|
||||
typedef struct _MacUpperDispatch {
|
||||
CommonChars *backPointer;
|
||||
Request request;
|
||||
TransmitChain transmitChain;
|
||||
TransferData transferData;
|
||||
ReceiveRelease receiveRelease;
|
||||
IndicationOn indicationOn;
|
||||
IndicationOff indicationOff;
|
||||
} MacUpperDispatch;
|
||||
|
||||
|
||||
typedef struct _MacStatusTable {
|
||||
WORD tableSize;
|
||||
DWORD lastDiag;
|
||||
DWORD macStatus;
|
||||
WORD packetFilter;
|
||||
BYTE *mediaSpecificStats;
|
||||
DWORD lastClear;
|
||||
DWORD totalFramesRx;
|
||||
DWORD totalFramesCrc;
|
||||
DWORD totalBytesRx;
|
||||
DWORD totalDiscardBufSpaceRx;
|
||||
DWORD totalMulticastRx;
|
||||
DWORD totalBroadcastRx;
|
||||
DWORD obsolete1[5];
|
||||
DWORD totalDiscardHwErrorRx;
|
||||
DWORD totalFramesTx;
|
||||
DWORD totalBytesTx;
|
||||
DWORD totalMulticastTx;
|
||||
DWORD totalBroadcastTx;
|
||||
DWORD obsolete2[2];
|
||||
DWORD totalDiscardTimeoutTx;
|
||||
DWORD totalDiscardHwErrorTx;
|
||||
} MacStatusTable;
|
||||
|
||||
|
||||
typedef struct _ProtDispatch {
|
||||
CommonChars *backPointer;
|
||||
DWORD flags;
|
||||
/* 0 - handles non-LLC frames
|
||||
* 1 - handles specific-LSAP LLC frames
|
||||
* 2 - handles specific-LSAP LLC frames
|
||||
* 3-31 - reserved must be 0
|
||||
*/
|
||||
void (*requestConfirm) (void);
|
||||
void (*transmitConfirm) (void);
|
||||
void (*receiveLookahead) (void);
|
||||
void (*indicationComplete) (void);
|
||||
void (*receiveChain) (void);
|
||||
void (*status) (void);
|
||||
} ProtDispatch;
|
||||
|
||||
|
||||
typedef struct _ReqBlock {
|
||||
WORD opcode;
|
||||
WORD status;
|
||||
BYTE FAR *pointer1;
|
||||
BYTE FAR *pointer2;
|
||||
WORD word1;
|
||||
} ReqBlock;
|
||||
|
||||
|
||||
typedef struct _TxBufDescrRec {
|
||||
BYTE txPtrType;
|
||||
BYTE dummy;
|
||||
WORD txDataLen;
|
||||
BYTE *txDataPtr;
|
||||
} TxBufDescrRec;
|
||||
|
||||
|
||||
typedef struct _TxBufDescr {
|
||||
WORD txImmedLen;
|
||||
BYTE *txImmedPtr;
|
||||
WORD txDataCount;
|
||||
TxBufDescrRec txBufDescrRec[NDIS_TX_BUF_LENGTH];
|
||||
} TxBufDescr;
|
||||
|
||||
|
||||
typedef struct _TDBufDescrRec {
|
||||
BYTE tDPtrType;
|
||||
BYTE dummy;
|
||||
WORD tDDataLen;
|
||||
BYTE *tDDataPtr;
|
||||
} TDBufDescrRec;
|
||||
|
||||
|
||||
typedef struct _TDBufDescr {
|
||||
WORD tDDataCount;
|
||||
TDBufDescrRec tDBufDescrRec[NDIS_TD_BUF_LENGTH];
|
||||
} TDBufDescr;
|
||||
|
||||
|
||||
typedef struct _RxBufDescrRec {
|
||||
WORD rxDataLen;
|
||||
BYTE *rxDataPtr;
|
||||
} RxBufDescrRec;
|
||||
|
||||
|
||||
typedef struct _RxBufDescr {
|
||||
WORD rxDataCount;
|
||||
RxBufDescrRec rxBufDescrRec[NDIS_RX_BUF_LENGTH];
|
||||
} RxBufDescr;
|
||||
|
||||
|
||||
typedef struct _PktBuf {
|
||||
struct _PktBuf *nextLink;
|
||||
struct _PktBuf *prevLink;
|
||||
int handle;
|
||||
int length;
|
||||
int packetLength;
|
||||
DWORD sequence;
|
||||
BYTE *buffer;
|
||||
} PktBuf;
|
||||
|
||||
|
||||
typedef struct _CardHandle {
|
||||
BYTE moduleName[16];
|
||||
CommonChars *common;
|
||||
} CardHandle;
|
||||
|
||||
|
||||
typedef struct _BindingsList {
|
||||
WORD numBindings;
|
||||
BYTE moduleName[2][16];
|
||||
} BindingsList;
|
||||
|
||||
|
||||
typedef struct _FailingModules {
|
||||
BYTE upperModuleName[16];
|
||||
BYTE lowerModuleName[16];
|
||||
} FailingModules;
|
||||
|
||||
|
||||
typedef union _HardwareAddress {
|
||||
BYTE bytes[6];
|
||||
WORD words[3];
|
||||
struct {
|
||||
BYTE bytes[6];
|
||||
} addr;
|
||||
} HardwareAddress;
|
||||
|
||||
|
||||
typedef struct _FddiHeader {
|
||||
BYTE frameControl;
|
||||
HardwareAddress etherDestHost;
|
||||
HardwareAddress etherSrcHost;
|
||||
} FddiHeader;
|
||||
|
||||
|
||||
typedef struct _EthernetIIHeader {
|
||||
HardwareAddress etherDestHost;
|
||||
HardwareAddress etherSrcHost;
|
||||
WORD etherType;
|
||||
} EthernetIIHeader;
|
||||
|
||||
|
||||
typedef struct _Ieee802Dot5Header {
|
||||
HardwareAddress etherDestHost;
|
||||
HardwareAddress etherSrcHost;
|
||||
BYTE routeInfo[30];
|
||||
} Ieee802Dot5Header;
|
||||
|
||||
|
||||
typedef struct _Ieee802Dot2SnapHeader {
|
||||
BYTE dsap; /* 0xAA */
|
||||
BYTE ssap; /* 0xAA */
|
||||
BYTE control; /* 3 */
|
||||
BYTE protocolId[5];
|
||||
} Ieee802Dot2SnapHeader;
|
||||
|
||||
|
||||
/*
|
||||
* Prototypes
|
||||
*/
|
||||
extern char *NdisLastError (void);
|
||||
extern int NdisOpen (void);
|
||||
extern int NdisInit (int promis);
|
||||
extern int NdisRegisterAndBind (int promis);
|
||||
extern void NdisShutdown (void);
|
||||
extern void NdisCheckMacFeatures (struct _CardHandle *card);
|
||||
extern int NdisSendPacket (struct _PktBuf *pktBuf, int macId);
|
||||
|
||||
/*
|
||||
* Assembly "glue" functions
|
||||
*/
|
||||
extern int systemRequestGlue();
|
||||
extern int requestConfirmGlue();
|
||||
extern int transmitConfirmGlue();
|
||||
extern int receiveLookaheadGlue();
|
||||
extern int indicationCompleteGlue();
|
||||
extern int receiveChainGlue();
|
||||
extern int statusGlue();
|
||||
|
||||
/*
|
||||
* IOCTL function
|
||||
*/
|
||||
#ifdef __SMALL__
|
||||
extern int _far NdisGetLinkage (int handle, char *data, int size);
|
||||
#else
|
||||
extern int NdisGetLinkage (int handle, char *data, int size);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* NDIS callback handlers
|
||||
*/
|
||||
CALLBACK (NdisSystemRequest (DWORD,DWORD, WORD, WORD, WORD));
|
||||
CALLBACK (NdisRequestConfirm ( WORD, WORD, WORD, WORD, WORD,WORD));
|
||||
CALLBACK (NdisTransmitConfirm ( WORD, WORD, WORD, WORD, WORD));
|
||||
CALLBACK (NdisReceiveLookahead ( WORD, WORD, WORD, BYTE*, BYTE*, WORD));
|
||||
CALLBACK (NdisReceiveChain ( WORD, WORD, WORD, struct _RxBufDescr*, BYTE*, WORD));
|
||||
CALLBACK (NdisStatusProc ( WORD, WORD, BYTE*, WORD,WORD));
|
||||
CALLBACK (NdisIndicationComplete( WORD, WORD));
|
||||
|
||||
BYTE *NdisAllocStack (void);
|
||||
void NdisFreeStack (BYTE*);
|
||||
|
||||
#ifdef __HIGHC__
|
||||
#define RENAME_ASM_SYM(x) pragma Alias(x,"@" #x "") /* prepend `@' */
|
||||
#define RENAME_C_SYM(x) pragma Alias(x,"_" #x "") /* prepend `_' */
|
||||
|
||||
RENAME_ASM_SYM (systemRequestGlue);
|
||||
RENAME_ASM_SYM (requestConfirmGlue);
|
||||
RENAME_ASM_SYM (transmitConfirmGlue);
|
||||
RENAME_ASM_SYM (receiveLookaheadGlue);
|
||||
RENAME_ASM_SYM (indicationCompleteGlue);
|
||||
RENAME_ASM_SYM (receiveChainGlue);
|
||||
RENAME_ASM_SYM (statusGlue);
|
||||
RENAME_ASM_SYM (NdisGetLinkage);
|
||||
RENAME_C_SYM (NdisSystemRequest);
|
||||
RENAME_C_SYM (NdisRequestConfirm);
|
||||
RENAME_C_SYM (NdisTransmitConfirm);
|
||||
RENAME_C_SYM (NdisReceiveLookahead);
|
||||
RENAME_C_SYM (NdisIndicationComplete);
|
||||
RENAME_C_SYM (NdisReceiveChain);
|
||||
RENAME_C_SYM (NdisStatusProc);
|
||||
RENAME_C_SYM (NdisAllocStack);
|
||||
RENAME_C_SYM (NdisFreeStack);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
188
libpcap/msdos/ndis_0.asm
Normal file
188
libpcap/msdos/ndis_0.asm
Normal file
@@ -0,0 +1,188 @@
|
||||
PAGE 60,132
|
||||
NAME NDIS_0
|
||||
|
||||
ifdef DOSX
|
||||
.386
|
||||
_TEXT SEGMENT PUBLIC DWORD USE16 'CODE'
|
||||
_TEXT ENDS
|
||||
_DATA SEGMENT PUBLIC DWORD USE16 'CODE'
|
||||
_DATA ENDS
|
||||
_TEXT32 SEGMENT PUBLIC BYTE USE32 'CODE'
|
||||
_TEXT32 ENDS
|
||||
CB_DSEG EQU <CS> ; DOSX is tiny-model
|
||||
D_SEG EQU <_TEXT SEGMENT>
|
||||
D_END EQU <_TEXT ENDS>
|
||||
ASSUME CS:_TEXT,DS:_TEXT
|
||||
|
||||
PUSHREGS equ <pushad>
|
||||
POPREGS equ <popad>
|
||||
|
||||
PUBPROC macro name
|
||||
align 4
|
||||
public @&name
|
||||
@&name label near
|
||||
endm
|
||||
else
|
||||
.286
|
||||
_TEXT SEGMENT PUBLIC DWORD 'CODE'
|
||||
_TEXT ENDS
|
||||
_DATA SEGMENT PUBLIC DWORD 'DATA'
|
||||
_DATA ENDS
|
||||
CB_DSEG EQU <SEG _DATA> ; 16bit is small/large model
|
||||
D_SEG EQU <_DATA SEGMENT>
|
||||
D_END EQU <_DATA ENDS>
|
||||
ASSUME CS:_TEXT,DS:_DATA
|
||||
|
||||
PUSHREGS equ <pusha>
|
||||
POPREGS equ <popa>
|
||||
|
||||
PUBPROC macro name
|
||||
public _&name
|
||||
_&name label far
|
||||
endm
|
||||
endif
|
||||
|
||||
;-------------------------------------------
|
||||
|
||||
D_SEG
|
||||
|
||||
D_END
|
||||
|
||||
|
||||
_TEXT SEGMENT
|
||||
|
||||
EXTRN _NdisSystemRequest : near
|
||||
EXTRN _NdisRequestConfirm : near
|
||||
EXTRN _NdisTransmitConfirm : near
|
||||
EXTRN _NdisReceiveLookahead : near
|
||||
EXTRN _NdisIndicationComplete : near
|
||||
EXTRN _NdisReceiveChain : near
|
||||
EXTRN _NdisStatusProc : near
|
||||
EXTRN _NdisAllocStack : near
|
||||
EXTRN _NdisFreeStack : near
|
||||
|
||||
;
|
||||
; *ALL* interrupt threads come through this macro.
|
||||
;
|
||||
CALLBACK macro callbackProc, argsSize
|
||||
|
||||
pushf
|
||||
PUSHREGS ;; Save the registers
|
||||
|
||||
push es
|
||||
push ds
|
||||
mov ax,CB_DSEG ;; Load DS
|
||||
mov ds,ax
|
||||
call _NdisAllocStack ;; Get and install a stack.
|
||||
|
||||
mov bx,ss ;; Save off the old stack in other regs
|
||||
mov cx,sp
|
||||
mov ss,dx ;; Install the new one
|
||||
mov sp,ax
|
||||
push bx ;; Save the old one on to the new stack
|
||||
push cx
|
||||
sub sp,&argsSize ;; Allocate space for arguments on the stack
|
||||
|
||||
mov ax,ss ;; Set up the destination for the move
|
||||
mov es,ax
|
||||
mov di,sp
|
||||
mov ds,bx ;; Set up the source for the move.
|
||||
mov si,cx
|
||||
add si,4+6+32
|
||||
|
||||
mov cx,&argsSize ;; Move the arguments to the stack.
|
||||
shr cx,1
|
||||
cld
|
||||
rep movsw
|
||||
|
||||
mov ax,CB_DSEG ;; Set my data segment again.
|
||||
mov ds,ax
|
||||
|
||||
call &callbackProc ;; Call the real callback.
|
||||
pop di ;; Pop off the old stack
|
||||
pop si
|
||||
mov bx,ss ;; Save off the current allocated stack.
|
||||
mov cx,sp
|
||||
mov ss,si ;; Restore the old stack
|
||||
mov sp,di
|
||||
push ax ;; Save the return code
|
||||
push bx ;; Free the stack. Push the pointer to it
|
||||
push cx
|
||||
call _NdisFreeStack
|
||||
add sp,4
|
||||
pop ax ;; Get the return code back
|
||||
add di,32 ;; Get a pointer to ax on the stack
|
||||
mov word ptr ss:[di],ax
|
||||
pop ds
|
||||
pop es
|
||||
|
||||
POPREGS
|
||||
popf
|
||||
endm
|
||||
|
||||
;
|
||||
; Define all of the callbacks for the NDIS procs.
|
||||
;
|
||||
|
||||
PUBPROC systemRequestGlue
|
||||
CALLBACK _NdisSystemRequest,14
|
||||
RETF
|
||||
|
||||
PUBPROC requestConfirmGlue
|
||||
CALLBACK _NdisRequestConfirm,12
|
||||
RETF
|
||||
|
||||
PUBPROC transmitConfirmGlue
|
||||
CALLBACK _NdisTransmitConfirm,10
|
||||
RETF
|
||||
|
||||
PUBPROC receiveLookaheadGlue
|
||||
CALLBACK _NdisReceiveLookahead,16
|
||||
RETF
|
||||
|
||||
PUBPROC indicationCompleteGlue
|
||||
CALLBACK _NdisIndicationComplete,4
|
||||
RETF
|
||||
|
||||
PUBPROC receiveChainGlue
|
||||
CALLBACK _NdisReceiveChain,16
|
||||
RETF
|
||||
|
||||
PUBPROC statusGlue
|
||||
CALLBACK _NdisStatusProc,12
|
||||
RETF
|
||||
|
||||
;
|
||||
; int FAR NdisGetLinkage (int handle, char *data, int size);
|
||||
;
|
||||
|
||||
ifdef DOSX
|
||||
PUBPROC NdisGetLinkage
|
||||
push ebx
|
||||
mov ebx, [esp+8] ; device handle
|
||||
mov eax, 4402h ; IOCTRL read function
|
||||
mov edx, [esp+12] ; DS:EDX -> result data
|
||||
mov ecx, [esp+16] ; ECX = length
|
||||
int 21h
|
||||
pop ebx
|
||||
jc @fail
|
||||
xor eax, eax
|
||||
@fail: ret
|
||||
|
||||
else
|
||||
PUBPROC NdisGetLinkage
|
||||
enter 0, 0
|
||||
mov bx, [bp+6]
|
||||
mov ax, 4402h
|
||||
mov dx, [bp+8]
|
||||
mov cx, [bp+12]
|
||||
int 21h
|
||||
jc @fail
|
||||
xor ax, ax
|
||||
@fail: leave
|
||||
retf
|
||||
endif
|
||||
|
||||
ENDS
|
||||
|
||||
END
|
||||
197
libpcap/msdos/pkt_rx0.asm
Normal file
197
libpcap/msdos/pkt_rx0.asm
Normal file
@@ -0,0 +1,197 @@
|
||||
PAGE 60,132
|
||||
NAME PKT_RX
|
||||
|
||||
ifdef ??version ; using TASM
|
||||
masm
|
||||
jumps
|
||||
endif
|
||||
|
||||
PUBLIC _pktDrop, _pktRxBuf, _pktTxBuf, _pktTemp
|
||||
PUBLIC _rxOutOfs, _rxInOfs, _PktReceiver, _pktRxEnd
|
||||
|
||||
;
|
||||
; these sizes MUST be equal to the sizes in PKTDRVR.H
|
||||
;
|
||||
|
||||
RX_BUF_SIZE = 1500 ; max message size on Ethernet
|
||||
TX_BUF_SIZE = 1500
|
||||
|
||||
ifdef DOSX
|
||||
.386
|
||||
NUM_RX_BUF = 32 ; # of RX element buffers
|
||||
_TEXT SEGMENT PUBLIC DWORD USE16 'CODE'
|
||||
_TEXT ENDS
|
||||
_DATA SEGMENT PUBLIC DWORD USE16 'CODE'
|
||||
_DATA ENDS
|
||||
D_SEG EQU <_TEXT SEGMENT>
|
||||
D_END EQU <_TEXT ENDS>
|
||||
ASSUME CS:_TEXT,DS:_TEXT
|
||||
else
|
||||
.286
|
||||
NUM_RX_BUF = 10
|
||||
_TEXT SEGMENT PUBLIC DWORD 'CODE'
|
||||
_TEXT ENDS
|
||||
_DATA SEGMENT PUBLIC DWORD 'DATA'
|
||||
_DATA ENDS
|
||||
D_SEG EQU <_DATA SEGMENT>
|
||||
D_END EQU <_DATA ENDS>
|
||||
ASSUME CS:_TEXT,DS:_DATA
|
||||
endif
|
||||
|
||||
;-------------------------------------------
|
||||
|
||||
D_SEG
|
||||
|
||||
RX_ELEMENT STRUC
|
||||
firstCount dw 0 ; # of bytes on 1st call
|
||||
secondCount dw 0 ; # of bytes on 2nd call
|
||||
handle dw 0 ; handle for upcall
|
||||
destinAdr db 6 dup (0) ; packet destination address
|
||||
sourceAdr db 6 dup (0) ; packet source address
|
||||
protocol dw 0 ; packet protocol number
|
||||
rxBuffer db RX_BUF_SIZE dup (0) ; RX buffer
|
||||
ENDS
|
||||
align 4
|
||||
_rxOutOfs dw offset _pktRxBuf ; ring buffer offsets
|
||||
_rxInOfs dw offset _pktRxBuf ; into _pktRxBuf
|
||||
_pktDrop dw 0,0 ; packet drop counter
|
||||
_pktTemp db 20 dup (0) ; temp work area
|
||||
_pktTxBuf db (TX_BUF_SIZE+14) dup (0) ; TX buffer
|
||||
_pktRxBuf RX_ELEMENT NUM_RX_BUF dup (<>) ; RX structures
|
||||
LAST_OFS = offset $
|
||||
|
||||
screenSeg dw 0B800h
|
||||
newInOffset dw 0
|
||||
|
||||
fanChars db '-\|/'
|
||||
fanIndex dw 0
|
||||
|
||||
D_END
|
||||
|
||||
_TEXT SEGMENT
|
||||
|
||||
|
||||
SHOW_RX MACRO
|
||||
push es
|
||||
push bx
|
||||
mov bx, screenSeg
|
||||
mov es, bx ;; r-mode segment of colour screen
|
||||
mov di, 158 ;; upper right corner - 1
|
||||
mov bx, fanIndex
|
||||
mov al, fanChars[bx] ;; get write char
|
||||
mov ah, 15 ;; and white colour
|
||||
stosw ;; write to screen at ES:EDI
|
||||
inc fanIndex ;; update next index
|
||||
and fanIndex, 3
|
||||
pop bx
|
||||
pop es
|
||||
ENDM
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; This macro return ES:DI to tail of Rx queue
|
||||
|
||||
ENQUEUE MACRO
|
||||
LOCAL @noWrap
|
||||
mov ax, _rxInOfs ;; DI = current in-offset
|
||||
add ax, SIZE RX_ELEMENT ;; point to next _pktRxBuf buffer
|
||||
cmp ax, LAST_OFS ;; pointing past last ?
|
||||
jb @noWrap ;; no - jump
|
||||
lea ax, _pktRxBuf ;; yes, point to 1st buffer
|
||||
align 4
|
||||
@noWrap: cmp ax, _rxOutOfs ;; in-ofs = out-ofs ?
|
||||
je @dump ;; yes, queue is full
|
||||
mov di, _rxInOfs ;; ES:DI -> buffer at queue input
|
||||
mov newInOffset, ax ;; remember new input offset
|
||||
|
||||
;; NOTE. rxInOfs is updated after the packet has been copied
|
||||
;; to ES:DI (= DS:SI on 2nd call) by the packet driver
|
||||
|
||||
ENDM
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; This routine gets called by the packet driver twice:
|
||||
; 1st time (AX=0) it requests an address where to put the packet
|
||||
;
|
||||
; 2nd time (AX=1) the packet has been copied to this location (DS:SI)
|
||||
; BX has client handle (stored in RX_ELEMENT.handle).
|
||||
; CX has # of bytes in packet on both call. They should be equal.
|
||||
;
|
||||
; A test for equality is done by putting CX in _pktRxBuf [n].firstCount
|
||||
; and _pktRxBuf[n].secondCount, and CL on first call in
|
||||
; _pktRxBuf[n].rxBuffer[CX]. These values are checked in "PktReceive"
|
||||
; (PKTDRVR.C)
|
||||
;
|
||||
;---------------------------------------------------------------------
|
||||
|
||||
_PktReceiver:
|
||||
pushf
|
||||
cli ; no distraction wanted !
|
||||
push ds
|
||||
push bx
|
||||
ifdef DOSX
|
||||
mov bx, cs
|
||||
else
|
||||
mov bx, SEG _DATA
|
||||
endif
|
||||
mov ds, bx
|
||||
mov es, bx ; ES = DS = CS or seg _DATA
|
||||
pop bx ; restore handle
|
||||
|
||||
cmp ax, 0 ; first call? (AX=0)
|
||||
jne @post ; AX=1: second call, do post process
|
||||
|
||||
ifdef DEBUG
|
||||
SHOW_RX ; show that a packet is received
|
||||
endif
|
||||
cmp cx, RX_BUF_SIZE+14 ; size OK ?
|
||||
ja @skip ; no, packet to large for us
|
||||
|
||||
ENQUEUE ; ES:DI -> _pktRxBuf[n]
|
||||
|
||||
mov [di].firstCount, cx ; remember the first count.
|
||||
mov [di].handle, bx ; remember the handle.
|
||||
add di, 6 ; ES:DI -> _pktRxBuf[n].destinAdr
|
||||
pop ds
|
||||
popf
|
||||
retf ; far return to driver with ES:DI
|
||||
|
||||
align 4
|
||||
@dump: inc _pktDrop[0] ; discard the packet on 1st call
|
||||
adc _pktDrop[2], 0 ; increment packets lost
|
||||
|
||||
@skip: xor di, di ; return ES:DI = NIL pointer
|
||||
xor ax, ax
|
||||
mov es, ax
|
||||
pop ds
|
||||
popf
|
||||
retf
|
||||
|
||||
align 4
|
||||
@post: or si, si ; DS:SI->_pktRxBuf[n][n].destinAdr
|
||||
jz @discard ; make sure we don't use NULL-pointer
|
||||
|
||||
sub si, 6 ; DS:SI -> _pktRxBuf[n].destinAdr
|
||||
;
|
||||
; push si
|
||||
; push [si].firstCount
|
||||
; call bpf_filter_match ; run the filter here some day?
|
||||
; add sp, 4
|
||||
; cmp ax, 0
|
||||
; je @discard
|
||||
|
||||
mov [si].secondCount, cx
|
||||
mov ax, newInOffset
|
||||
mov _rxInOfs, ax ; update _pktRxBuf input offset
|
||||
|
||||
align 4
|
||||
@discard:pop ds
|
||||
popf
|
||||
retf
|
||||
|
||||
_pktRxEnd db 0 ; marker for end of r-mode code/data
|
||||
|
||||
_TEXT ENDS
|
||||
|
||||
END
|
||||
155
libpcap/msdos/pkt_rx1.s
Normal file
155
libpcap/msdos/pkt_rx1.s
Normal file
@@ -0,0 +1,155 @@
|
||||
;
|
||||
; This file requires NASM 0.97+ to assemble
|
||||
;
|
||||
; Currently used only for djgpp + DOS4GW targets
|
||||
;
|
||||
; these sizes MUST be equal to the sizes in PKTDRVR.H
|
||||
;
|
||||
%define ETH_MTU 1500 ; max data size on Ethernet
|
||||
%define ETH_MIN 60 ; min/max total frame size
|
||||
%define ETH_MAX (ETH_MTU+2*6+2)
|
||||
%define NUM_RX_BUF 32 ; # of RX element buffers
|
||||
%define RX_SIZE (ETH_MAX+6) ; sizeof(RX_ELEMENT) = 1514+6
|
||||
%idefine offset
|
||||
|
||||
struc RX_ELEMENT
|
||||
.firstCount resw 1 ; # of bytes on 1st call
|
||||
.secondCount resw 1 ; # of bytes on 2nd call
|
||||
.handle resw 1 ; handle for upcall
|
||||
; .timeStamp resw 4 ; 64-bit RDTSC value
|
||||
.destinAdr resb 6 ; packet destination address
|
||||
.sourceAdr resb 6 ; packet source address
|
||||
.protocol resw 1 ; packet protocol number
|
||||
.rxBuffer resb ETH_MTU ; RX buffer
|
||||
endstruc
|
||||
|
||||
;-------------------------------------------
|
||||
|
||||
[org 0] ; assemble to .bin file
|
||||
|
||||
_rxOutOfs dw offset _pktRxBuf ; ring buffer offsets
|
||||
_rxInOfs dw offset _pktRxBuf ; into _pktRxBuf
|
||||
_pktDrop dw 0,0 ; packet drop counter
|
||||
_pktTemp resb 20 ; temp work area
|
||||
_pktTxBuf resb (ETH_MAX) ; TX buffer
|
||||
_pktRxBuf resb (RX_SIZE*NUM_RX_BUF) ; RX structures
|
||||
LAST_OFS equ $
|
||||
|
||||
screenSeg dw 0B800h
|
||||
newInOffset dw 0
|
||||
|
||||
fanChars db '-\|/'
|
||||
fanIndex dw 0
|
||||
|
||||
%macro SHOW_RX 0
|
||||
push es
|
||||
push bx
|
||||
mov bx, [screenSeg]
|
||||
mov es, bx ;; r-mode segment of colour screen
|
||||
mov di, 158 ;; upper right corner - 1
|
||||
mov bx, [fanIndex]
|
||||
mov al, [fanChars+bx] ;; get write char
|
||||
mov ah, 15 ;; and white colour
|
||||
cld ;; Needed?
|
||||
stosw ;; write to screen at ES:EDI
|
||||
inc word [fanIndex] ;; update next index
|
||||
and word [fanIndex], 3
|
||||
pop bx
|
||||
pop es
|
||||
%endmacro
|
||||
|
||||
;PutTimeStamp
|
||||
; rdtsc
|
||||
; mov [si].timeStamp, eax
|
||||
; mov [si+4].timeStamp, edx
|
||||
; ret
|
||||
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
;
|
||||
; This routine gets called by the packet driver twice:
|
||||
; 1st time (AX=0) it requests an address where to put the packet
|
||||
;
|
||||
; 2nd time (AX=1) the packet has been copied to this location (DS:SI)
|
||||
; BX has client handle (stored in RX_ELEMENT.handle).
|
||||
; CX has # of bytes in packet on both call. They should be equal.
|
||||
; A test for equality is done by putting CX in _pktRxBuf [n].firstCount
|
||||
; and _pktRxBuf[n].secondCount, and CL on first call in
|
||||
; _pktRxBuf[n].rxBuffer[CX]. These values are checked in "PktReceive"
|
||||
; (PKTDRVR.C)
|
||||
;
|
||||
;---------------------------------------------------------------------
|
||||
|
||||
_PktReceiver:
|
||||
pushf
|
||||
cli ; no distraction wanted !
|
||||
push ds
|
||||
push bx
|
||||
mov bx, cs
|
||||
mov ds, bx
|
||||
mov es, bx ; ES = DS = CS or seg _DATA
|
||||
pop bx ; restore handle
|
||||
|
||||
cmp ax, 0 ; first call? (AX=0)
|
||||
jne @post ; AX=1: second call, do post process
|
||||
|
||||
%ifdef DEBUG
|
||||
SHOW_RX ; show that a packet is received
|
||||
%endif
|
||||
|
||||
cmp cx, ETH_MAX ; size OK ?
|
||||
ja @skip ; no, too big
|
||||
|
||||
mov ax, [_rxInOfs]
|
||||
add ax, RX_SIZE
|
||||
cmp ax, LAST_OFS
|
||||
jb @noWrap
|
||||
mov ax, offset _pktRxBuf
|
||||
@noWrap:
|
||||
cmp ax, [_rxOutOfs]
|
||||
je @dump
|
||||
mov di, [_rxInOfs] ; ES:DI -> _pktRxBuf[n]
|
||||
mov [newInOffset], ax
|
||||
|
||||
mov [di], cx ; remember firstCount.
|
||||
mov [di+4], bx ; remember handle.
|
||||
add di, 6 ; ES:DI -> _pktRxBuf[n].destinAdr
|
||||
pop ds
|
||||
popf
|
||||
retf ; far return to driver with ES:DI
|
||||
|
||||
@dump: add word [_pktDrop+0], 1 ; discard the packet on 1st call
|
||||
adc word [_pktDrop+2], 0 ; increment packets lost
|
||||
|
||||
@skip: xor di, di ; return ES:DI = NIL pointer
|
||||
xor ax, ax
|
||||
mov es, ax
|
||||
pop ds
|
||||
popf
|
||||
retf
|
||||
|
||||
@post: or si, si ; DS:SI->_pktRxBuf[n][n].destinAdr
|
||||
jz @discard ; make sure we don't use NULL-pointer
|
||||
|
||||
;
|
||||
; push si
|
||||
; call bpf_filter_match ; run the filter here some day
|
||||
; pop si
|
||||
; cmp ax, 0
|
||||
; je @discard
|
||||
|
||||
mov [si-6+2], cx ; store _pktRxBuf[n].secondCount
|
||||
mov ax, [newInOffset]
|
||||
mov [_rxInOfs], ax ; update _pktRxBuf input offset
|
||||
|
||||
; call PutTimeStamp
|
||||
|
||||
@discard:
|
||||
pop ds
|
||||
popf
|
||||
retf
|
||||
|
||||
_pktRxEnd db 0 ; marker for end of r-mode code/data
|
||||
|
||||
END
|
||||
|
||||
1436
libpcap/msdos/pktdrvr.c
Normal file
1436
libpcap/msdos/pktdrvr.c
Normal file
File diff suppressed because it is too large
Load Diff
153
libpcap/msdos/pktdrvr.h
Normal file
153
libpcap/msdos/pktdrvr.h
Normal file
@@ -0,0 +1,153 @@
|
||||
#ifndef __PKTDRVR_H
|
||||
#define __PKTDRVR_H
|
||||
|
||||
#define PUBLIC
|
||||
#define LOCAL static
|
||||
|
||||
#define RX_BUF_SIZE ETH_MTU /* buffer size variables. NB !! */
|
||||
#define TX_BUF_SIZE ETH_MTU /* must be same as in pkt_rx*.* */
|
||||
|
||||
#ifdef __HIGHC__
|
||||
#pragma Off(Align_members)
|
||||
#else
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
|
||||
typedef enum { /* Packet-driver classes */
|
||||
PD_ETHER = 1,
|
||||
PD_PRONET10 = 2,
|
||||
PD_IEEE8025 = 3,
|
||||
PD_OMNINET = 4,
|
||||
PD_APPLETALK = 5,
|
||||
PD_SLIP = 6,
|
||||
PD_STARTLAN = 7,
|
||||
PD_ARCNET = 8,
|
||||
PD_AX25 = 9,
|
||||
PD_KISS = 10,
|
||||
PD_IEEE8023_2 = 11,
|
||||
PD_FDDI8022 = 12,
|
||||
PD_X25 = 13,
|
||||
PD_LANstar = 14,
|
||||
PD_PPP = 18
|
||||
} PKT_CLASS;
|
||||
|
||||
typedef enum { /* Packet-driver receive modes */
|
||||
PDRX_OFF = 1, /* turn off receiver */
|
||||
PDRX_DIRECT, /* receive only to this interface */
|
||||
PDRX_BROADCAST, /* DIRECT + broadcast packets */
|
||||
PDRX_MULTICAST1, /* BROADCAST + limited multicast */
|
||||
PDRX_MULTICAST2, /* BROADCAST + all multicast */
|
||||
PDRX_ALL_PACKETS, /* receive all packets on network */
|
||||
} PKT_RX_MODE;
|
||||
|
||||
typedef struct {
|
||||
char type[8];
|
||||
char len;
|
||||
} PKT_FRAME;
|
||||
|
||||
|
||||
typedef struct {
|
||||
BYTE class; /* = 1 for DEC/Interl/Xerox Ethernet */
|
||||
BYTE number; /* = 0 for single LAN adapter */
|
||||
WORD type; /* = 13 for 3C523 */
|
||||
BYTE funcs; /* Basic/Extended/HiPerf functions */
|
||||
WORD intr; /* user interrupt vector number */
|
||||
WORD handle; /* Handle associated with session */
|
||||
BYTE name [15]; /* Name of adapter interface,ie.3C523*/
|
||||
BOOL quiet; /* (don't) print errors to stdout */
|
||||
const char *error; /* address of error string */
|
||||
BYTE majVer; /* Major driver implementation ver. */
|
||||
BYTE minVer; /* Minor driver implementation ver. */
|
||||
BYTE dummyLen; /* length of following data */
|
||||
WORD MAClength; /* HiPerformance data, N/A */
|
||||
WORD MTU; /* HiPerformance data, N/A */
|
||||
WORD multicast; /* HiPerformance data, N/A */
|
||||
WORD rcvrBuffers; /* valid for */
|
||||
WORD UMTbufs; /* High Performance drivers only */
|
||||
WORD postEOIintr; /* Usage ?? */
|
||||
} PKT_INFO;
|
||||
|
||||
#define PKT_PARAM_SIZE 14 /* members majVer - postEOIintr */
|
||||
|
||||
|
||||
typedef struct {
|
||||
DWORD inPackets; /* # of packets received */
|
||||
DWORD outPackets; /* # of packets transmitted */
|
||||
DWORD inBytes; /* # of bytes received */
|
||||
DWORD outBytes; /* # of bytes transmitted */
|
||||
DWORD inErrors; /* # of reception errors */
|
||||
DWORD outErrors; /* # of transmission errors */
|
||||
DWORD lost; /* # of packets lost (RX) */
|
||||
} PKT_STAT;
|
||||
|
||||
|
||||
typedef struct {
|
||||
ETHER destin;
|
||||
ETHER source;
|
||||
WORD proto;
|
||||
BYTE data [TX_BUF_SIZE];
|
||||
} TX_ELEMENT;
|
||||
|
||||
typedef struct {
|
||||
WORD firstCount; /* # of bytes on 1st */
|
||||
WORD secondCount; /* and 2nd upcall */
|
||||
WORD handle; /* instance that upcalled */
|
||||
ETHER destin; /* E-net destination address */
|
||||
ETHER source; /* E-net source address */
|
||||
WORD proto; /* protocol number */
|
||||
BYTE data [RX_BUF_SIZE];
|
||||
} RX_ELEMENT;
|
||||
|
||||
|
||||
#ifdef __HIGHC__
|
||||
#pragma pop(Align_members)
|
||||
#else
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Prototypes for publics
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern PKT_STAT pktStat; /* statistics for packets */
|
||||
extern PKT_INFO pktInfo; /* packet-driver information */
|
||||
|
||||
extern PKT_RX_MODE receiveMode;
|
||||
extern ETHER myAddress, ethBroadcast;
|
||||
|
||||
extern BOOL PktInitDriver (PKT_RX_MODE mode);
|
||||
extern BOOL PktExitDriver (void);
|
||||
|
||||
extern const char *PktGetErrorStr (int errNum);
|
||||
extern const char *PktGetClassName (WORD class);
|
||||
extern const char *PktRXmodeStr (PKT_RX_MODE mode);
|
||||
extern BOOL PktSearchDriver (void);
|
||||
extern int PktReceive (BYTE *buf, int max);
|
||||
extern BOOL PktTransmit (const void *eth, int len);
|
||||
extern DWORD PktRxDropped (void);
|
||||
extern BOOL PktReleaseHandle (WORD handle);
|
||||
extern BOOL PktTerminHandle (WORD handle);
|
||||
extern BOOL PktResetInterface (WORD handle);
|
||||
extern BOOL PktSetReceiverMode(PKT_RX_MODE mode);
|
||||
extern BOOL PktGetReceiverMode(PKT_RX_MODE *mode);
|
||||
extern BOOL PktGetStatistics (WORD handle);
|
||||
extern BOOL PktSessStatistics (WORD handle);
|
||||
extern BOOL PktResetStatistics(WORD handle);
|
||||
extern BOOL PktGetAddress (ETHER *addr);
|
||||
extern BOOL PktSetAddress (const ETHER *addr);
|
||||
extern BOOL PktGetDriverInfo (void);
|
||||
extern BOOL PktGetDriverParam (void);
|
||||
extern void PktQueueBusy (BOOL busy);
|
||||
extern WORD PktBuffersUsed (void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __PKTDRVR_H */
|
||||
|
||||
162
libpcap/msdos/readme.dos
Normal file
162
libpcap/msdos/readme.dos
Normal file
@@ -0,0 +1,162 @@
|
||||
@(#) $Header: /tcpdump/master/libpcap/msdos/readme.dos,v 1.3 2004-12-19 19:47:01 guy Exp $ (LBL)
|
||||
|
||||
libpcap for DOS
|
||||
---------------
|
||||
|
||||
This file contains some notes on building and using libpcap for MS-DOS.
|
||||
Look in `README' and `pcap.man' for usage and details. These targets are
|
||||
supported:
|
||||
|
||||
- Borland C 4.0+ small or large model.
|
||||
- Metaware HighC 3.1+ with PharLap DOS-extender
|
||||
- GNU C 2.7+ with djgpp 2.01+ DOS extender
|
||||
- Watcom C 11.x with DOS4GW extender
|
||||
|
||||
Note: the files in the libpcap.zip contains short trucated filenames.
|
||||
So for djgpp to work with these, disable the use of long file names by
|
||||
setting "LFN=n" in the environment.
|
||||
|
||||
Files specific to DOS are pcap-dos.[ch] and the assembly and C files in
|
||||
the MSDOS sub-directory. Remember to built lipcap libraries from the top
|
||||
install directory. And not from the MSDOS sub-directory.
|
||||
|
||||
Note for djgpp users:
|
||||
If you got the libpcap from the official site www.tcpdump, then that
|
||||
distribution does NOT contain any sources for building 32-bit drivers.
|
||||
Instead get the full version at
|
||||
http://www.bgnett.no/~giva/pcap/libpcap.zip
|
||||
|
||||
and set "USE_32BIT_DRIVERS = 1" in msdos\common.dj.
|
||||
|
||||
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
DOS-libpcap currently only works reliably with a real-mode Ethernet packet-
|
||||
driver. This driver must be installed prior to using any program (e.g.
|
||||
tcpdump) compiled with libpcap. Work is underway to implement protected-
|
||||
mode drivers for 32-bit targets (djgpp only). The 3Com 3c509 driver is
|
||||
working almost perfectly. Due to lack of LAN-cards, I've not had the
|
||||
opportunity to test other drivers. These 32-bit drivers are modified
|
||||
Linux drivers.
|
||||
|
||||
|
||||
Required packages
|
||||
-----------------
|
||||
|
||||
The following packages and tools must be present for all targets.
|
||||
|
||||
1. Watt-32 tcp/ip library. This library is *not* used to send or
|
||||
receive network data. It's mostly used to access the 'hosts'
|
||||
file and other <netdb.h> features. Get 'watt32s*.zip' at:
|
||||
|
||||
http://www.bgnett.no/~giva/
|
||||
|
||||
2. Exception handler and disassember library (libexc.a) is needed if
|
||||
"USE_EXCEPT = 1" in common.dj. Available at:
|
||||
|
||||
http://www.bgnett.no/~giva/misc/exc_dx07.zip
|
||||
|
||||
3. Flex & Bison is used to generate parser for the filter handler
|
||||
pcap_compile:
|
||||
|
||||
ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/flx254b.zip
|
||||
ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bsn128b.zip
|
||||
|
||||
4. NASM assembler v 0.98 or later is required when building djgpp and
|
||||
Watcom targets:
|
||||
|
||||
ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2tk/nasm098p.zip
|
||||
|
||||
5. sed (Stream Editor) is required for doing `make depend'.
|
||||
It's available at
|
||||
ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/sed*.zip
|
||||
|
||||
A touch tool to update the time-stamp of a file. E.g.
|
||||
ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/grep*.zip
|
||||
|
||||
6. For djgpp rm.exe and cp.exe are required. These should already be
|
||||
part of your djgpp installation. Also required (experimental at the
|
||||
time) for djgpp is DLX 2.91 or later. This tool is for the generation
|
||||
of dynamically loadable modules.
|
||||
|
||||
|
||||
Compiling libpcap
|
||||
-----------------
|
||||
|
||||
Follow these steps in building libpcap:
|
||||
|
||||
1. Make sure you've installed Watt-32 properly (see it's `INSTALL' file).
|
||||
During that installation a environment variable `WATT_ROOT' is set.
|
||||
This variable is used for building libpcap also (`WATT_INC' is
|
||||
deducted from `WATT_ROOT'). djgpp users should also define environment
|
||||
variables `C_INCLUDE_PATH' and `LIBRARY_PATH' to point to the include
|
||||
directory and library directory respectively. E.g. put this in your
|
||||
AUTOEXEC.BAT:
|
||||
set C_INCLUDE_PATH=c:/net/watt/inc
|
||||
set LIBRARY_PATH=c:/net/watt/lib
|
||||
|
||||
2. Revise the msdos/common.dj file for your djgpp/gcc installation;
|
||||
- change the value of `GCCLIB' to match location of libgcc.a.
|
||||
- set `USE_32BIT_DRIVERS = 1' to build 32-bit driver objects.
|
||||
|
||||
|
||||
3. Build pcap by using appropriate makefile. For djgpp, use:
|
||||
`make -f msdos/makefile.dj' (i.e. GNU `make')
|
||||
|
||||
For a Watcom target say:
|
||||
`wmake -f msdos\makefile.wc'
|
||||
|
||||
For a Borland target say:
|
||||
`maker -f msdos\Makefile pcap_bc.lib' (Borland's `maker.exe')
|
||||
|
||||
And for a HighC/Pharlap target say:
|
||||
`maker -f msdos\Makefile pcap_hc.lib' (Borland's `maker.exe')
|
||||
|
||||
You might like to change some `CFLAGS' -- only `DEBUG' define currently
|
||||
have any effect. It shows a rotating "fan" in upper right corner of
|
||||
screen. Remove `DEBUG' if you don't like it. You could add
|
||||
`-fomit-frame-pointer' to `CFLAGS' to speed up the generated code.
|
||||
But note, this makes debugging and crash-traceback difficult. Only
|
||||
add it if you're fully confident your application is 100% stable.
|
||||
|
||||
Note: Code in `USE_NDIS2' does not work at the moment.
|
||||
|
||||
4. The resulting libraries are put in current directory. There's no
|
||||
test-program for `libpcap'. Linking the library with `tcpdump' is
|
||||
the ultimate test anyway.
|
||||
|
||||
|
||||
|
||||
Extensions to libpcap
|
||||
---------------------
|
||||
|
||||
I've included some extra functions to DOS-libpcap:
|
||||
|
||||
`pcap_config_hook (const char *name, const char *value)'
|
||||
|
||||
Allows an application to set values of internal libpcap variables.
|
||||
`name' is typically a left-side keyword with an associated `value'
|
||||
that is called from application's configure process (see tcpdump's
|
||||
config.c file). libpcap keeps a set of tables that are searched for
|
||||
a name/value match. Currently only used to set debug-levels and
|
||||
parameters for the 32-bit network drivers.
|
||||
|
||||
`pcap_set_wait (pcap_t *, void (*)(void), int)' :
|
||||
|
||||
Only effective when reading offline traffic from dump-files.
|
||||
Function `pcap_offline_read()' will wait (and optionally yield)
|
||||
before printing next packet. This will simulate the pace the packets
|
||||
where actually recorded.
|
||||
|
||||
|
||||
|
||||
Happy sniffing !
|
||||
|
||||
|
||||
Gisle Vanem <giva@bgnett.no>
|
||||
<gvanem@broadpark.no>
|
||||
|
||||
October 1999, 2004
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
./bpf/net
|
||||
75
libpcap/packaging/pcap.spec.in
Normal file
75
libpcap/packaging/pcap.spec.in
Normal file
@@ -0,0 +1,75 @@
|
||||
%define prefix /usr
|
||||
%define version @VERSION@
|
||||
|
||||
Summary: A system-independent interface for user-level packet capture
|
||||
Name: libpcap
|
||||
Version: %version
|
||||
Release: 1
|
||||
Group: Development/Libraries
|
||||
License: BSD with advertising
|
||||
Source: @NAME@.tar.gz
|
||||
BuildRoot: /tmp/%{name}-buildroot
|
||||
URL: http://www.tcpdump.org
|
||||
|
||||
Source: http://www.tcpdump.org/release/%{name}-%{version}.tar.gz
|
||||
|
||||
%description
|
||||
Libpcap provides a portable framework for low-level network
|
||||
monitoring. Libpcap can provide network statistics collection,
|
||||
security monitoring and network debugging. Since almost every system
|
||||
vendor provides a different interface for packet capture, the libpcap
|
||||
authors created this system-independent API to ease in porting and to
|
||||
alleviate the need for several system-dependent packet capture modules
|
||||
in each application.
|
||||
|
||||
Install libpcap if you need to do low-level network traffic monitoring
|
||||
on your network.
|
||||
|
||||
%package devel
|
||||
Summary: Libraries and header files for the libpcap library
|
||||
Group: Development/Libraries
|
||||
|
||||
%description devel
|
||||
Libpcap provides a portable framework for low-level network
|
||||
monitoring. Libpcap can provide network statistics collection,
|
||||
security monitoring and network debugging. Since almost every system
|
||||
vendor provides a different interface for packet capture, the libpcap
|
||||
authors created this system-independent API to ease in porting and to
|
||||
alleviate the need for several system-dependent packet capture modules
|
||||
in each application.
|
||||
|
||||
This package provides the libraries, include files, and other
|
||||
resources needed for developing libpcap applications.
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
|
||||
%build
|
||||
export CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing"
|
||||
%configure
|
||||
make %{?_smp_mflags}
|
||||
|
||||
%install
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
make DESTDIR=$RPM_BUILD_ROOT install
|
||||
|
||||
%clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%files
|
||||
%defattr(-,root,root)
|
||||
%doc LICENSE README CHANGES INSTALL.txt README.linux TODO VERSION CREDITS packaging/pcap.spec
|
||||
%{_libdir}/libpcap.so.*
|
||||
%{_mandir}/man7/pcap*.7*
|
||||
|
||||
%files devel
|
||||
%defattr(-,root,root)
|
||||
%{_bindir}/pcap-config
|
||||
%{_includedir}/pcap*.h
|
||||
%{_includedir}/pcap.h
|
||||
%{_libdir}/libpcap.so
|
||||
%{_libdir}/libpcap.a
|
||||
%{_mandir}/man1/pcap-config.1*
|
||||
%{_mandir}/man3/pcap*.3*
|
||||
%{_mandir}/man5/pcap*.5*
|
||||
@@ -31,8 +31,8 @@ static const char rcsid[] _U_ =
|
||||
#ifdef HAVE_ZEROCOPY_BPF
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
#include <sys/time.h>
|
||||
#include <sys/socket.h>
|
||||
#include <time.h>
|
||||
/*
|
||||
* <net/bpf.h> defines ioctls, but doesn't include <sys/ioccom.h>.
|
||||
*
|
||||
@@ -186,77 +186,67 @@ static int pcap_setfilter_bpf(pcap_t *p, struct bpf_program *fp);
|
||||
static int pcap_setdirection_bpf(pcap_t *, pcap_direction_t);
|
||||
static int pcap_set_datalink_bpf(pcap_t *p, int dlt);
|
||||
|
||||
#ifdef HAVE_ZEROCOPY_BPF
|
||||
/*
|
||||
* For zerocopy bpf, we need to override the setnonblock/getnonblock routines
|
||||
* so we don't call select(2) if the pcap handle is in non-blocking mode. We
|
||||
* preserve the timeout supplied by pcap_open functions to make sure it
|
||||
* does not get clobbered if the pcap handle moves between blocking and non-
|
||||
* blocking mode.
|
||||
* For zerocopy bpf, the setnonblock/getnonblock routines need to modify
|
||||
* p->md.timeout so we don't call select(2) if the pcap handle is in non-
|
||||
* blocking mode. We preserve the timeout supplied by pcap_open functions
|
||||
* to make sure it does not get clobbered if the pcap handle moves between
|
||||
* blocking and non-blocking mode.
|
||||
*/
|
||||
static int
|
||||
pcap_getnonblock_zbuf(pcap_t *p, char *errbuf)
|
||||
pcap_getnonblock_bpf(pcap_t *p, char *errbuf)
|
||||
{
|
||||
/*
|
||||
* Use a negative value for the timeout to represent that the
|
||||
* pcap handle is in non-blocking mode.
|
||||
*/
|
||||
return (p->md.timeout < 0);
|
||||
#ifdef HAVE_ZEROCOPY_BPF
|
||||
if (p->md.zerocopy) {
|
||||
/*
|
||||
* Use a negative value for the timeout to represent that the
|
||||
* pcap handle is in non-blocking mode.
|
||||
*/
|
||||
return (p->md.timeout < 0);
|
||||
}
|
||||
#endif
|
||||
return (pcap_getnonblock_fd(p, errbuf));
|
||||
}
|
||||
|
||||
static int
|
||||
pcap_setnonblock_zbuf(pcap_t *p, int nonblock, char *errbuf)
|
||||
pcap_setnonblock_bpf(pcap_t *p, int nonblock, char *errbuf)
|
||||
{
|
||||
/*
|
||||
* Map each value to the corresponding 2's complement, to
|
||||
* preserve the timeout value provided with pcap_set_timeout.
|
||||
* (from pcap-linux.c).
|
||||
*/
|
||||
if (nonblock) {
|
||||
if (p->md.timeout >= 0) {
|
||||
/*
|
||||
* Timeout is non-negative, so we're not already
|
||||
* in non-blocking mode; set it to the 2's
|
||||
* complement, to make it negative, as an
|
||||
* indication that we're in non-blocking mode.
|
||||
*/
|
||||
p->md.timeout = p->md.timeout * -1 - 1;
|
||||
}
|
||||
} else {
|
||||
if (p->md.timeout < 0) {
|
||||
/*
|
||||
* Timeout is negative, so we're not already
|
||||
* in blocking mode; reverse the previous
|
||||
* operation, to make the timeout non-negative
|
||||
* again.
|
||||
*/
|
||||
p->md.timeout = (p->md.timeout + 1) * -1;
|
||||
#ifdef HAVE_ZEROCOPY_BPF
|
||||
if (p->md.zerocopy) {
|
||||
/*
|
||||
* Map each value to the corresponding 2's complement, to
|
||||
* preserve the timeout value provided with pcap_set_timeout.
|
||||
* (from pcap-linux.c).
|
||||
*/
|
||||
if (nonblock) {
|
||||
if (p->md.timeout >= 0) {
|
||||
/*
|
||||
* Timeout is non-negative, so we're not
|
||||
* currently in non-blocking mode; set it
|
||||
* to the 2's complement, to make it
|
||||
* negative, as an indication that we're
|
||||
* in non-blocking mode.
|
||||
*/
|
||||
p->md.timeout = p->md.timeout * -1 - 1;
|
||||
}
|
||||
} else {
|
||||
if (p->md.timeout < 0) {
|
||||
/*
|
||||
* Timeout is negative, so we're currently
|
||||
* in blocking mode; reverse the previous
|
||||
* operation, to make the timeout non-negative
|
||||
* again.
|
||||
*/
|
||||
p->md.timeout = (p->md.timeout + 1) * -1;
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Zero-copy specific close method. Un-map the shared buffers then call
|
||||
* pcap_cleanup_live_common.
|
||||
*/
|
||||
static void
|
||||
pcap_cleanup_zbuf(pcap_t *p)
|
||||
{
|
||||
/*
|
||||
* Delete the mappings. Note that p->buffer gets initialized to one
|
||||
* of the mmapped regions in this case, so do not try and free it
|
||||
* directly; null it out so that pcap_cleanup_live_common() doesn't
|
||||
* try to free it.
|
||||
*/
|
||||
if (p->md.zbuf1 != MAP_FAILED && p->md.zbuf1 != NULL)
|
||||
(void) munmap(p->md.zbuf1, p->md.zbufsize);
|
||||
if (p->md.zbuf2 != MAP_FAILED && p->md.zbuf2 != NULL)
|
||||
(void) munmap(p->md.zbuf2, p->md.zbufsize);
|
||||
p->buffer = NULL;
|
||||
pcap_cleanup_live_common(p);
|
||||
#endif
|
||||
return (pcap_setnonblock_fd(p, nonblock, errbuf));
|
||||
}
|
||||
|
||||
#ifdef HAVE_ZEROCOPY_BPF
|
||||
/*
|
||||
* Zero-copy BPF buffer routines to check for and acknowledge BPF data in
|
||||
* shared memory buffers.
|
||||
@@ -410,7 +400,7 @@ pcap_ack_zbuf(pcap_t *p)
|
||||
p->buffer = NULL;
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
#endif /* HAVE_ZEROCOPY_BPF */
|
||||
|
||||
pcap_t *
|
||||
pcap_create(const char *device, char *ebuf)
|
||||
@@ -435,6 +425,10 @@ pcap_create(const char *device, char *ebuf)
|
||||
return (p);
|
||||
}
|
||||
|
||||
/*
|
||||
* On success, returns a file descriptor for a BPF device.
|
||||
* On failure, returns a PCAP_ERROR_ value, and sets p->errbuf.
|
||||
*/
|
||||
static int
|
||||
bpf_open(pcap_t *p)
|
||||
{
|
||||
@@ -495,12 +489,52 @@ bpf_open(pcap_t *p)
|
||||
* XXX better message for all minors used
|
||||
*/
|
||||
if (fd < 0) {
|
||||
if (errno == EACCES)
|
||||
fd = PCAP_ERROR_PERM_DENIED;
|
||||
else
|
||||
switch (errno) {
|
||||
|
||||
case ENOENT:
|
||||
fd = PCAP_ERROR;
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "(no devices found) %s: %s",
|
||||
device, pcap_strerror(errno));
|
||||
if (n == 1) {
|
||||
/*
|
||||
* /dev/bpf0 doesn't exist, which
|
||||
* means we probably have no BPF
|
||||
* devices.
|
||||
*/
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"(there are no BPF devices)");
|
||||
} else {
|
||||
/*
|
||||
* We got EBUSY on at least one
|
||||
* BPF device, so we have BPF
|
||||
* devices, but all the ones
|
||||
* that exist are busy.
|
||||
*/
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"(all BPF devices are busy)");
|
||||
}
|
||||
break;
|
||||
|
||||
case EACCES:
|
||||
/*
|
||||
* Got EACCES on the last device we tried,
|
||||
* and EBUSY on all devices before that,
|
||||
* if any.
|
||||
*/
|
||||
fd = PCAP_ERROR_PERM_DENIED;
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"(cannot open BPF device) %s: %s", device,
|
||||
pcap_strerror(errno));
|
||||
break;
|
||||
|
||||
default:
|
||||
/*
|
||||
* Some other problem.
|
||||
*/
|
||||
fd = PCAP_ERROR;
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"(cannot open BPF device) %s: %s", device,
|
||||
pcap_strerror(errno));
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -673,14 +707,23 @@ pcap_can_set_rfmon_bpf(pcap_t *p)
|
||||
*/
|
||||
fd = bpf_open(p);
|
||||
if (fd < 0)
|
||||
return (fd);
|
||||
return (fd); /* fd is the appropriate error code */
|
||||
|
||||
/*
|
||||
* Now bind to the device.
|
||||
*/
|
||||
(void)strncpy(ifr.ifr_name, p->opt.source, sizeof(ifr.ifr_name));
|
||||
if (ioctl(fd, BIOCSETIF, (caddr_t)&ifr) < 0) {
|
||||
if (errno == ENETDOWN) {
|
||||
switch (errno) {
|
||||
|
||||
case ENXIO:
|
||||
/*
|
||||
* There's no such device.
|
||||
*/
|
||||
close(fd);
|
||||
return (PCAP_ERROR_NO_SUCH_DEVICE);
|
||||
|
||||
case ENETDOWN:
|
||||
/*
|
||||
* Return a "network down" indication, so that
|
||||
* the application can report that rather than
|
||||
@@ -690,7 +733,8 @@ pcap_can_set_rfmon_bpf(pcap_t *p)
|
||||
*/
|
||||
close(fd);
|
||||
return (PCAP_ERROR_IFACE_NOT_UP);
|
||||
} else {
|
||||
|
||||
default:
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"BIOCSETIF: %s: %s",
|
||||
p->opt.source, pcap_strerror(errno));
|
||||
@@ -911,14 +955,28 @@ pcap_read_bpf(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
|
||||
* processed so far.
|
||||
*/
|
||||
if (p->break_loop) {
|
||||
p->bp = bp;
|
||||
p->cc = ep - bp;
|
||||
/*
|
||||
* ep is set based on the return value of read(),
|
||||
* but read() from a BPF device doesn't necessarily
|
||||
* return a value that's a multiple of the alignment
|
||||
* value for BPF_WORDALIGN(). However, whenever we
|
||||
* increment bp, we round up the increment value by
|
||||
* a value rounded up by BPF_WORDALIGN(), so we
|
||||
* could increment bp past ep after processing the
|
||||
* last packet in the buffer.
|
||||
*
|
||||
* We treat ep < bp as an indication that this
|
||||
* happened, and just set p->cc to 0.
|
||||
*/
|
||||
if (p->cc < 0)
|
||||
p->cc = 0;
|
||||
if (n == 0) {
|
||||
p->break_loop = 0;
|
||||
return (PCAP_ERROR_BREAK);
|
||||
} else {
|
||||
p->bp = bp;
|
||||
p->cc = ep - bp;
|
||||
} else
|
||||
return (n);
|
||||
}
|
||||
}
|
||||
|
||||
caplen = bhp->bh_caplen;
|
||||
@@ -970,6 +1028,11 @@ pcap_read_bpf(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
|
||||
if (++n >= cnt && cnt > 0) {
|
||||
p->bp = bp;
|
||||
p->cc = ep - bp;
|
||||
/*
|
||||
* See comment above about p->cc < 0.
|
||||
*/
|
||||
if (p->cc < 0)
|
||||
p->cc = 0;
|
||||
return (n);
|
||||
}
|
||||
} else {
|
||||
@@ -1270,15 +1333,19 @@ pcap_cleanup_bpf(pcap_t *p)
|
||||
}
|
||||
|
||||
#ifdef HAVE_ZEROCOPY_BPF
|
||||
/*
|
||||
* In zero-copy mode, p->buffer is just a pointer into one of the two
|
||||
* memory-mapped buffers, so no need to free it.
|
||||
*/
|
||||
if (p->md.zerocopy) {
|
||||
/*
|
||||
* Delete the mappings. Note that p->buffer gets
|
||||
* initialized to one of the mmapped regions in
|
||||
* this case, so do not try and free it directly;
|
||||
* null it out so that pcap_cleanup_live_common()
|
||||
* doesn't try to free it.
|
||||
*/
|
||||
if (p->md.zbuf1 != MAP_FAILED && p->md.zbuf1 != NULL)
|
||||
munmap(p->md.zbuf1, p->md.zbufsize);
|
||||
(void) munmap(p->md.zbuf1, p->md.zbufsize);
|
||||
if (p->md.zbuf2 != MAP_FAILED && p->md.zbuf2 != NULL)
|
||||
munmap(p->md.zbuf2, p->md.zbufsize);
|
||||
(void) munmap(p->md.zbuf2, p->md.zbufsize);
|
||||
p->buffer = NULL;
|
||||
}
|
||||
#endif
|
||||
if (p->md.device != NULL) {
|
||||
@@ -1392,7 +1459,15 @@ pcap_activate_bpf(pcap_t *p)
|
||||
{
|
||||
int status = 0;
|
||||
int fd;
|
||||
#ifdef LIFNAMSIZ
|
||||
struct lifreq ifr;
|
||||
char *ifrname = ifr.lifr_name;
|
||||
const size_t ifnamsiz = sizeof(ifr.lifr_name);
|
||||
#else
|
||||
struct ifreq ifr;
|
||||
char *ifrname = ifr.ifr_name;
|
||||
const size_t ifnamsiz = sizeof(ifr.ifr_name);
|
||||
#endif
|
||||
struct bpf_version bv;
|
||||
#ifdef __APPLE__
|
||||
int sockfd;
|
||||
@@ -1484,9 +1559,8 @@ pcap_activate_bpf(pcap_t *p)
|
||||
*/
|
||||
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (sockfd != -1) {
|
||||
strlcpy(ifr.ifr_name,
|
||||
p->opt.source,
|
||||
sizeof(ifr.ifr_name));
|
||||
strlcpy(ifrname,
|
||||
p->opt.source, ifnamsiz);
|
||||
if (ioctl(sockfd, SIOCGIFFLAGS,
|
||||
(char *)&ifr) < 0) {
|
||||
/*
|
||||
@@ -1551,14 +1625,6 @@ pcap_activate_bpf(pcap_t *p)
|
||||
*/
|
||||
p->md.zerocopy = 1;
|
||||
|
||||
/*
|
||||
* Set the cleanup and set/get nonblocking mode ops
|
||||
* as appropriate for zero-copy mode.
|
||||
*/
|
||||
p->cleanup_op = pcap_cleanup_zbuf;
|
||||
p->setnonblock_op = pcap_setnonblock_zbuf;
|
||||
p->getnonblock_op = pcap_getnonblock_zbuf;
|
||||
|
||||
/*
|
||||
* How to pick a buffer size: first, query the maximum buffer
|
||||
* size supported by zero-copy. This also lets us quickly
|
||||
@@ -1608,7 +1674,7 @@ pcap_activate_bpf(pcap_t *p)
|
||||
pcap_strerror(errno));
|
||||
goto bad;
|
||||
}
|
||||
(void)strncpy(ifr.ifr_name, p->opt.source, sizeof(ifr.ifr_name));
|
||||
(void)strncpy(ifrname, p->opt.source, ifnamsiz);
|
||||
if (ioctl(fd, BIOCSETIF, (caddr_t)&ifr) < 0) {
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCSETIF: %s: %s",
|
||||
p->opt.source, pcap_strerror(errno));
|
||||
@@ -1638,9 +1704,13 @@ pcap_activate_bpf(pcap_t *p)
|
||||
/*
|
||||
* Now bind to the device.
|
||||
*/
|
||||
(void)strncpy(ifr.ifr_name, p->opt.source,
|
||||
sizeof(ifr.ifr_name));
|
||||
if (ioctl(fd, BIOCSETIF, (caddr_t)&ifr) < 0) {
|
||||
(void)strncpy(ifrname, p->opt.source, ifnamsiz);
|
||||
#ifdef BIOCSETLIF
|
||||
if (ioctl(fd, BIOCSETLIF, (caddr_t)&ifr) < 0)
|
||||
#else
|
||||
if (ioctl(fd, BIOCSETIF, (caddr_t)&ifr) < 0)
|
||||
#endif
|
||||
{
|
||||
status = check_setif_failure(p, errno);
|
||||
goto bad;
|
||||
}
|
||||
@@ -1667,9 +1737,12 @@ pcap_activate_bpf(pcap_t *p)
|
||||
*/
|
||||
(void) ioctl(fd, BIOCSBLEN, (caddr_t)&v);
|
||||
|
||||
(void)strncpy(ifr.ifr_name, p->opt.source,
|
||||
sizeof(ifr.ifr_name));
|
||||
(void)strncpy(ifrname, p->opt.source, ifnamsiz);
|
||||
#ifdef BIOCSETLIF
|
||||
if (ioctl(fd, BIOCSETLIF, (caddr_t)&ifr) >= 0)
|
||||
#else
|
||||
if (ioctl(fd, BIOCSETIF, (caddr_t)&ifr) >= 0)
|
||||
#endif
|
||||
break; /* that size worked; we're done */
|
||||
|
||||
if (errno != ENOBUFS) {
|
||||
@@ -2160,8 +2233,8 @@ pcap_activate_bpf(pcap_t *p)
|
||||
p->setfilter_op = pcap_setfilter_bpf;
|
||||
p->setdirection_op = pcap_setdirection_bpf;
|
||||
p->set_datalink_op = pcap_set_datalink_bpf;
|
||||
p->getnonblock_op = pcap_getnonblock_fd;
|
||||
p->setnonblock_op = pcap_setnonblock_fd;
|
||||
p->getnonblock_op = pcap_getnonblock_bpf;
|
||||
p->setnonblock_op = pcap_setnonblock_bpf;
|
||||
p->stats_op = pcap_stats_bpf;
|
||||
p->cleanup_op = pcap_cleanup_bpf;
|
||||
|
||||
@@ -2214,17 +2287,28 @@ monitor_mode(pcap_t *p, int set)
|
||||
/*
|
||||
* Can't get the media types.
|
||||
*/
|
||||
if (errno == EINVAL) {
|
||||
switch (errno) {
|
||||
|
||||
case ENXIO:
|
||||
/*
|
||||
* There's no such device.
|
||||
*/
|
||||
close(sock);
|
||||
return (PCAP_ERROR_NO_SUCH_DEVICE);
|
||||
|
||||
case EINVAL:
|
||||
/*
|
||||
* Interface doesn't support SIOC{G,S}IFMEDIA.
|
||||
*/
|
||||
close(sock);
|
||||
return (PCAP_ERROR_RFMON_NOTSUP);
|
||||
|
||||
default:
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"SIOCGIFMEDIA 1: %s", pcap_strerror(errno));
|
||||
close(sock);
|
||||
return (PCAP_ERROR);
|
||||
}
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "SIOCGIFMEDIA 1: %s",
|
||||
pcap_strerror(errno));
|
||||
close(sock);
|
||||
return (PCAP_ERROR);
|
||||
}
|
||||
if (req.ifm_count == 0) {
|
||||
/*
|
||||
|
||||
@@ -85,8 +85,8 @@ bt_platform_finddevs(pcap_if_t **alldevsp, char *err_str)
|
||||
/* if bluetooth is not supported this this is not fatal*/
|
||||
if (errno == EAFNOSUPPORT)
|
||||
return 0;
|
||||
snprintf(err_str, PCAP_ERRBUF_SIZE, "Can't open raw Bluetooth socket %d:%s",
|
||||
errno, strerror(errno));
|
||||
snprintf(err_str, PCAP_ERRBUF_SIZE,
|
||||
"Can't open raw Bluetooth socket: %s", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -103,8 +103,9 @@ bt_platform_finddevs(pcap_if_t **alldevsp, char *err_str)
|
||||
|
||||
if (ioctl(sock, HCIGETDEVLIST, (void *) dev_list) < 0)
|
||||
{
|
||||
snprintf(err_str, PCAP_ERRBUF_SIZE, "Can't get Bluetooth device list via ioctl %d:%s",
|
||||
errno, strerror(errno));
|
||||
snprintf(err_str, PCAP_ERRBUF_SIZE,
|
||||
"Can't get Bluetooth device list via ioctl: %s",
|
||||
strerror(errno));
|
||||
ret = -1;
|
||||
goto free;
|
||||
}
|
||||
@@ -182,8 +183,8 @@ bt_activate(pcap_t* handle)
|
||||
/* Create HCI socket */
|
||||
handle->fd = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
|
||||
if (handle->fd < 0) {
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't create raw socket %d:%s",
|
||||
errno, strerror(errno));
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Can't create raw socket: %s", strerror(errno));
|
||||
return PCAP_ERROR;
|
||||
}
|
||||
|
||||
@@ -196,15 +197,15 @@ bt_activate(pcap_t* handle)
|
||||
|
||||
opt = 1;
|
||||
if (setsockopt(handle->fd, SOL_HCI, HCI_DATA_DIR, &opt, sizeof(opt)) < 0) {
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't enable data direction info %d:%s",
|
||||
errno, strerror(errno));
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Can't enable data direction info: %s", strerror(errno));
|
||||
goto close_fail;
|
||||
}
|
||||
|
||||
opt = 1;
|
||||
if (setsockopt(handle->fd, SOL_HCI, HCI_TIME_STAMP, &opt, sizeof(opt)) < 0) {
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't enable time stamp %d:%s",
|
||||
errno, strerror(errno));
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Can't enable time stamp: %s", strerror(errno));
|
||||
goto close_fail;
|
||||
}
|
||||
|
||||
@@ -214,8 +215,8 @@ bt_activate(pcap_t* handle)
|
||||
memset((void *) &flt.type_mask, 0xff, sizeof(flt.type_mask));
|
||||
memset((void *) &flt.event_mask, 0xff, sizeof(flt.event_mask));
|
||||
if (setsockopt(handle->fd, SOL_HCI, HCI_FILTER, &flt, sizeof(flt)) < 0) {
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't set filter %d:%s",
|
||||
errno, strerror(errno));
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Can't set filter: %s", strerror(errno));
|
||||
goto close_fail;
|
||||
}
|
||||
|
||||
@@ -224,8 +225,9 @@ bt_activate(pcap_t* handle)
|
||||
addr.hci_family = AF_BLUETOOTH;
|
||||
addr.hci_dev = handle->md.ifindex;
|
||||
if (bind(handle->fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't attach to device %d %d:%s",
|
||||
handle->md.ifindex, errno, strerror(errno));
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Can't attach to device %d: %s", handle->md.ifindex,
|
||||
strerror(errno));
|
||||
goto close_fail;
|
||||
}
|
||||
|
||||
@@ -237,7 +239,7 @@ bt_activate(pcap_t* handle)
|
||||
goto close_fail;
|
||||
}
|
||||
|
||||
if (handle->opt.buffer_size == 0) {
|
||||
if (handle->opt.buffer_size != 0) {
|
||||
/*
|
||||
* Set the socket buffer size to the specified value.
|
||||
*/
|
||||
@@ -264,6 +266,7 @@ bt_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_char *us
|
||||
struct cmsghdr *cmsg;
|
||||
struct msghdr msg;
|
||||
struct iovec iv;
|
||||
ssize_t ret;
|
||||
struct pcap_pkthdr pkth;
|
||||
pcap_bluetooth_h4_header* bthdr;
|
||||
|
||||
@@ -279,21 +282,22 @@ bt_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_char *us
|
||||
|
||||
/* ignore interrupt system call error */
|
||||
do {
|
||||
pkth.caplen = recvmsg(handle->fd, &msg, 0);
|
||||
ret = recvmsg(handle->fd, &msg, 0);
|
||||
if (handle->break_loop)
|
||||
{
|
||||
handle->break_loop = 0;
|
||||
return -2;
|
||||
}
|
||||
} while ((pkth.caplen == -1) && (errno == EINTR));
|
||||
} while ((ret == -1) && (errno == EINTR));
|
||||
|
||||
|
||||
if (pkth.caplen < 0) {
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't receive packet %d:%s",
|
||||
errno, strerror(errno));
|
||||
if (ret < 0) {
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Can't receive packet: %s", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
pkth.caplen = ret;
|
||||
|
||||
/* get direction and timestamp*/
|
||||
cmsg = CMSG_FIRSTHDR(&msg);
|
||||
int in=0;
|
||||
@@ -342,14 +346,14 @@ bt_stats_linux(pcap_t *handle, struct pcap_stat *stats)
|
||||
struct hci_dev_stats * s = &dev_info.stat;
|
||||
dev_info.dev_id = handle->md.ifindex;
|
||||
|
||||
/* ingnore eintr */
|
||||
/* ignore eintr */
|
||||
do {
|
||||
ret = ioctl(handle->fd, HCIGETDEVINFO, (void *)&dev_info);
|
||||
} while ((ret == -1) && (errno == EINTR));
|
||||
|
||||
if (ret < 0) {
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "can get stats"
|
||||
" via ioctl %d:%s", errno, strerror(errno));
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Can't get stats via ioctl: %s", strerror(errno));
|
||||
return (-1);
|
||||
|
||||
}
|
||||
|
||||
@@ -18,21 +18,9 @@
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* savefile.c - supports offline use of tcpdump
|
||||
* Extraction/creation by Jeffrey Mogul, DECWRL
|
||||
* Modified by Steve McCanne, LBL.
|
||||
*
|
||||
* Used to save the received packet headers, after filtering, to
|
||||
* a file, and then read them later.
|
||||
* The first record in the file contains saved values for the machine
|
||||
* dependent values so we can print the dump file on any architecture.
|
||||
* pcap-common.c - common code for pcap and pcap-ng files
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/savefile.c,v 1.183 2008-12-23 20:13:29 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
@@ -106,6 +94,23 @@ static const char rcsid[] _U_ =
|
||||
* file, and new values after that one might have been assigned. Also,
|
||||
* do *NOT* use any values below 100 - those might already have been
|
||||
* taken by one (or more!) organizations.
|
||||
*
|
||||
* Any platform that defines additional DLT_* codes should:
|
||||
*
|
||||
* request a LINKTYPE_* code and value from tcpdump.org,
|
||||
* as per the above;
|
||||
*
|
||||
* add, in their version of libpcap, an entry to map
|
||||
* those DLT_* codes to the corresponding LINKTYPE_*
|
||||
* code;
|
||||
*
|
||||
* redefine, in their "net/bpf.h", any DLT_* values
|
||||
* that collide with the values used by their additional
|
||||
* DLT_* codes, to remove those collisions (but without
|
||||
* making them collide with any of the LINKTYPE_*
|
||||
* values equal to 50 or above; they should also avoid
|
||||
* defining DLT_* values that collide with those
|
||||
* LINKTYPE_* values, either).
|
||||
*/
|
||||
#define LINKTYPE_NULL DLT_NULL
|
||||
#define LINKTYPE_ETHERNET DLT_EN10MB /* also for 100Mb and up */
|
||||
@@ -114,7 +119,7 @@ static const char rcsid[] _U_ =
|
||||
#define LINKTYPE_PRONET DLT_PRONET
|
||||
#define LINKTYPE_CHAOS DLT_CHAOS
|
||||
#define LINKTYPE_TOKEN_RING DLT_IEEE802 /* DLT_IEEE802 is used for Token Ring */
|
||||
#define LINKTYPE_ARCNET DLT_ARCNET /* BSD-style headers */
|
||||
#define LINKTYPE_ARCNET_BSD DLT_ARCNET /* BSD-style headers */
|
||||
#define LINKTYPE_SLIP DLT_SLIP
|
||||
#define LINKTYPE_PPP DLT_PPP
|
||||
#define LINKTYPE_FDDI DLT_FDDI
|
||||
@@ -140,10 +145,29 @@ static const char rcsid[] _U_ =
|
||||
|
||||
#define LINKTYPE_SYMANTEC_FIREWALL 99 /* Symantec Enterprise Firewall */
|
||||
|
||||
/*
|
||||
* These correspond to DLT_s that have different values on different
|
||||
* platforms; we map between these values in capture files and
|
||||
* the DLT_ values as returned by pcap_datalink() and passed to
|
||||
* pcap_open_dead().
|
||||
*/
|
||||
#define LINKTYPE_ATM_RFC1483 100 /* LLC/SNAP-encapsulated ATM */
|
||||
#define LINKTYPE_RAW 101 /* raw IP */
|
||||
#define LINKTYPE_SLIP_BSDOS 102 /* BSD/OS SLIP BPF header */
|
||||
#define LINKTYPE_PPP_BSDOS 103 /* BSD/OS PPP BPF header */
|
||||
|
||||
/*
|
||||
* Values starting with 104 are used for newly-assigned link-layer
|
||||
* header type values; for those link-layer header types, the DLT_
|
||||
* value returned by pcap_datalink() and passed to pcap_open_dead(),
|
||||
* and the LINKTYPE_ value that appears in capture files, are the
|
||||
* same.
|
||||
*
|
||||
* LINKTYPE_MATCHING_MIN is the lowest such value; LINKTYPE_MATCHING_MAX
|
||||
* is the highest such value.
|
||||
*/
|
||||
#define LINKTYPE_MATCHING_MIN 104 /* lowest value in the "matching" range */
|
||||
|
||||
#define LINKTYPE_C_HDLC 104 /* Cisco HDLC */
|
||||
#define LINKTYPE_IEEE802_11 105 /* IEEE 802.11 (wireless) */
|
||||
#define LINKTYPE_ATM_CLIP 106 /* Linux Classical IP over ATM */
|
||||
@@ -544,39 +568,39 @@ static const char rcsid[] _U_ =
|
||||
* IPMB with a Linux-specific pseudo-header; as requested by Alexey Neyman
|
||||
* <avn@pigeonpoint.com>.
|
||||
*/
|
||||
#define LINKTYPE_IPMB_LINUX 209
|
||||
#define LINKTYPE_IPMB_LINUX 209
|
||||
|
||||
/*
|
||||
* FlexRay automotive bus - http://www.flexray.com/ - as requested
|
||||
* by Hannes Kaelber <hannes.kaelber@x2e.de>.
|
||||
*/
|
||||
#define LINKTYPE_FLEXRAY 210
|
||||
#define LINKTYPE_FLEXRAY 210
|
||||
|
||||
/*
|
||||
* Media Oriented Systems Transport (MOST) bus for multimedia
|
||||
* transport - http://www.mostcooperation.com/ - as requested
|
||||
* by Hannes Kaelber <hannes.kaelber@x2e.de>.
|
||||
*/
|
||||
#define LINKTYPE_MOST 211
|
||||
#define LINKTYPE_MOST 211
|
||||
|
||||
/*
|
||||
* Local Interconnect Network (LIN) bus for vehicle networks -
|
||||
* http://www.lin-subbus.org/ - as requested by Hannes Kaelber
|
||||
* <hannes.kaelber@x2e.de>.
|
||||
*/
|
||||
#define LINKTYPE_LIN 212
|
||||
#define LINKTYPE_LIN 212
|
||||
|
||||
/*
|
||||
* X2E-private data link type used for serial line capture,
|
||||
* as requested by Hannes Kaelber <hannes.kaelber@x2e.de>.
|
||||
*/
|
||||
#define LINKTYPE_X2E_SERIAL 213
|
||||
#define LINKTYPE_X2E_SERIAL 213
|
||||
|
||||
/*
|
||||
* X2E-private data link type used for the Xoraya data logger
|
||||
* family, as requested by Hannes Kaelber <hannes.kaelber@x2e.de>.
|
||||
*/
|
||||
#define LINKTYPE_X2E_XORAYA 214
|
||||
#define LINKTYPE_X2E_XORAYA 214
|
||||
|
||||
/*
|
||||
* IEEE 802.15.4, exactly as it appears in the spec (no padding, no
|
||||
@@ -595,22 +619,22 @@ static const char rcsid[] _U_ =
|
||||
* is used to communicate keystrokes and mouse movements from the
|
||||
* Linux kernel to display systems, such as Xorg.
|
||||
*/
|
||||
#define LINKTYPE_LINUX_EVDEV 216
|
||||
#define LINKTYPE_LINUX_EVDEV 216
|
||||
|
||||
/*
|
||||
* GSM Um and Abis interfaces, preceded by a "gsmtap" header.
|
||||
*
|
||||
* Requested by Harald Welte <laforge@gnumonks.org>.
|
||||
*/
|
||||
#define LINKTYPE_GSMTAP_UM 217
|
||||
#define LINKTYPE_GSMTAP_ABIS 218
|
||||
#define LINKTYPE_GSMTAP_UM 217
|
||||
#define LINKTYPE_GSMTAP_ABIS 218
|
||||
|
||||
/*
|
||||
* MPLS, with an MPLS label as the link-layer header.
|
||||
* Requested by Michele Marchetto <michele@openbsd.org> on behalf
|
||||
* of OpenBSD.
|
||||
*/
|
||||
#define LINKTYPE_MPLS 219
|
||||
#define LINKTYPE_MPLS 219
|
||||
|
||||
/*
|
||||
* USB packets, beginning with a Linux USB header, with the USB header
|
||||
@@ -622,7 +646,7 @@ static const char rcsid[] _U_ =
|
||||
* DECT packets, with a pseudo-header; requested by
|
||||
* Matthias Wenzel <tcpdump@mazzoo.de>.
|
||||
*/
|
||||
#define LINKTYPE_DECT 221
|
||||
#define LINKTYPE_DECT 221
|
||||
|
||||
/*
|
||||
* From: "Lidwa, Eric (GSFC-582.0)[SGT INC]" <eric.lidwa-1@nasa.gov>
|
||||
@@ -633,7 +657,7 @@ static const char rcsid[] _U_ =
|
||||
* legal before I can submit a patch.
|
||||
*
|
||||
*/
|
||||
#define LINKTYPE_AOS 222
|
||||
#define LINKTYPE_AOS 222
|
||||
|
||||
/*
|
||||
* Wireless HART (Highway Addressable Remote Transducer)
|
||||
@@ -642,13 +666,13 @@ static const char rcsid[] _U_ =
|
||||
*
|
||||
* Requested by Sam Roberts <vieuxtech@gmail.com>.
|
||||
*/
|
||||
#define LINKTYPE_WIHART 223
|
||||
#define LINKTYPE_WIHART 223
|
||||
|
||||
/*
|
||||
* Fibre Channel FC-2 frames, beginning with a Frame_Header.
|
||||
* Requested by Kahou Lei <kahou82@gmail.com>.
|
||||
*/
|
||||
#define LINKTYPE_FC_2 224
|
||||
#define LINKTYPE_FC_2 224
|
||||
|
||||
/*
|
||||
* Fibre Channel FC-2 frames, beginning with an encoding of the
|
||||
@@ -710,7 +734,7 @@ static const char rcsid[] _U_ =
|
||||
* An IPv4 or IPv6 datagram follows the pseudo-header; dli_family indicates
|
||||
* which of those it is.
|
||||
*/
|
||||
#define LINKTYPE_IPNET 226
|
||||
#define LINKTYPE_IPNET 226
|
||||
|
||||
/*
|
||||
* CAN (Controller Area Network) frames, with a pseudo-header as supplied
|
||||
@@ -719,15 +743,114 @@ static const char rcsid[] _U_ =
|
||||
*
|
||||
* Requested by Felix Obenhuber <felix@obenhuber.de>.
|
||||
*/
|
||||
#define LINKTYPE_CAN_SOCKETCAN 227
|
||||
#define LINKTYPE_CAN_SOCKETCAN 227
|
||||
|
||||
/*
|
||||
* Raw IPv4/IPv6; different from DLT_RAW in that the DLT_ value specifies
|
||||
* whether it's v4 or v6. Requested by Darren Reed <Darren.Reed@Sun.COM>.
|
||||
*/
|
||||
#define LINKTYPE_IPV4 228
|
||||
#define LINKTYPE_IPV6 229
|
||||
#define LINKTYPE_IPV4 228
|
||||
#define LINKTYPE_IPV6 229
|
||||
|
||||
/*
|
||||
* IEEE 802.15.4, exactly as it appears in the spec (no padding, no
|
||||
* nothing), and with no FCS at the end of the frame; requested by
|
||||
* Jon Smirl <jonsmirl@gmail.com>.
|
||||
*/
|
||||
#define LINKTYPE_IEEE802_15_4_NOFCS 230
|
||||
|
||||
/*
|
||||
* Raw D-Bus:
|
||||
*
|
||||
* http://www.freedesktop.org/wiki/Software/dbus
|
||||
*
|
||||
* messages:
|
||||
*
|
||||
* http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-messages
|
||||
*
|
||||
* starting with the endianness flag, followed by the message type, etc.,
|
||||
* but without the authentication handshake before the message sequence:
|
||||
*
|
||||
* http://dbus.freedesktop.org/doc/dbus-specification.html#auth-protocol
|
||||
*
|
||||
* Requested by Martin Vidner <martin@vidner.net>.
|
||||
*/
|
||||
#define LINKTYPE_DBUS 231
|
||||
|
||||
/*
|
||||
* Juniper-private data link type, as per request from
|
||||
* Hannes Gredler <hannes@juniper.net>.
|
||||
*/
|
||||
#define LINKTYPE_JUNIPER_VS 232
|
||||
#define LINKTYPE_JUNIPER_SRX_E2E 233
|
||||
#define LINKTYPE_JUNIPER_FIBRECHANNEL 234
|
||||
|
||||
/*
|
||||
* DVB-CI (DVB Common Interface for communication between a PC Card
|
||||
* module and a DVB receiver). See
|
||||
*
|
||||
* http://www.kaiser.cx/pcap-dvbci.html
|
||||
*
|
||||
* for the specification.
|
||||
*
|
||||
* Requested by Martin Kaiser <martin@kaiser.cx>.
|
||||
*/
|
||||
#define LINKTYPE_DVB_CI 235
|
||||
|
||||
/*
|
||||
* Variant of 3GPP TS 27.010 multiplexing protocol. Requested
|
||||
* by Hans-Christoph Schemmel <hans-christoph.schemmel@cinterion.com>.
|
||||
*/
|
||||
#define LINKTYPE_MUX27010 236
|
||||
|
||||
/*
|
||||
* STANAG 5066 D_PDUs. Requested by M. Baris Demiray
|
||||
* <barisdemiray@gmail.com>.
|
||||
*/
|
||||
#define LINKTYPE_STANAG_5066_D_PDU 237
|
||||
|
||||
/*
|
||||
* Juniper-private data link type, as per request from
|
||||
* Hannes Gredler <hannes@juniper.net>.
|
||||
*/
|
||||
#define LINKTYPE_JUNIPER_ATM_CEMIC 238
|
||||
|
||||
/*
|
||||
* NetFilter LOG messages
|
||||
* (payload of netlink NFNL_SUBSYS_ULOG/NFULNL_MSG_PACKET packets)
|
||||
*
|
||||
* Requested by Jakub Zawadzki <darkjames-ws@darkjames.pl>
|
||||
*/
|
||||
#define LINKTYPE_NFLOG 239
|
||||
|
||||
/*
|
||||
* Hilscher Gesellschaft fuer Systemautomation mbH link-layer type
|
||||
* for Ethernet packets with a 4-byte pseudo-header and always
|
||||
* with the payload including the FCS, as supplied by their
|
||||
* netANALYZER hardware and software.
|
||||
*
|
||||
* Requested by Holger P. Frommer <HPfrommer@hilscher.com>
|
||||
*/
|
||||
#define LINKTYPE_NETANALYZER 240
|
||||
|
||||
/*
|
||||
* Hilscher Gesellschaft fuer Systemautomation mbH link-layer type
|
||||
* for Ethernet packets with a 4-byte pseudo-header and FCS and
|
||||
* 1 byte of SFD, as supplied by their netANALYZER hardware and
|
||||
* software.
|
||||
*
|
||||
* Requested by Holger P. Frommer <HPfrommer@hilscher.com>
|
||||
*/
|
||||
#define LINKTYPE_NETANALYZER_TRANSPARENT 241
|
||||
|
||||
/*
|
||||
* IP-over-Infiniband, as specified by RFC 4391.
|
||||
*
|
||||
* Requested by Petr Sumbera <petr.sumbera@oracle.com>.
|
||||
*/
|
||||
#define LINKTYPE_IPOIB 242
|
||||
|
||||
#define LINKTYPE_MATCHING_MAX 242 /* highest value in the "matching" range */
|
||||
|
||||
static struct linktype_map {
|
||||
int dlt;
|
||||
@@ -744,7 +867,7 @@ static struct linktype_map {
|
||||
{ DLT_PRONET, LINKTYPE_PRONET },
|
||||
{ DLT_CHAOS, LINKTYPE_CHAOS },
|
||||
{ DLT_IEEE802, LINKTYPE_TOKEN_RING },
|
||||
{ DLT_ARCNET, LINKTYPE_ARCNET },
|
||||
{ DLT_ARCNET, LINKTYPE_ARCNET_BSD },
|
||||
{ DLT_SLIP, LINKTYPE_SLIP },
|
||||
{ DLT_PPP, LINKTYPE_PPP },
|
||||
{ DLT_FDDI, LINKTYPE_FDDI },
|
||||
@@ -785,295 +908,12 @@ static struct linktype_map {
|
||||
/* NetBSD PPP over Ethernet */
|
||||
{ DLT_PPP_ETHER, LINKTYPE_PPP_ETHER },
|
||||
|
||||
/* IEEE 802.11 wireless */
|
||||
{ DLT_IEEE802_11, LINKTYPE_IEEE802_11 },
|
||||
|
||||
/* Frame Relay */
|
||||
{ DLT_FRELAY, LINKTYPE_FRELAY },
|
||||
|
||||
/* OpenBSD loopback */
|
||||
{ DLT_LOOP, LINKTYPE_LOOP },
|
||||
|
||||
/* OpenBSD IPSEC enc */
|
||||
{ DLT_ENC, LINKTYPE_ENC },
|
||||
|
||||
/* Linux cooked socket capture */
|
||||
{ DLT_LINUX_SLL, LINKTYPE_LINUX_SLL },
|
||||
|
||||
/* Apple LocalTalk hardware */
|
||||
{ DLT_LTALK, LINKTYPE_LTALK },
|
||||
|
||||
/* Acorn Econet */
|
||||
{ DLT_ECONET, LINKTYPE_ECONET },
|
||||
|
||||
/* OpenBSD DLT_PFLOG */
|
||||
{ DLT_PFLOG, LINKTYPE_PFLOG },
|
||||
|
||||
/* For Cisco-internal use */
|
||||
{ DLT_CISCO_IOS, LINKTYPE_CISCO_IOS },
|
||||
|
||||
/* Prism II monitor-mode header plus 802.11 header */
|
||||
{ DLT_PRISM_HEADER, LINKTYPE_PRISM_HEADER },
|
||||
|
||||
/* FreeBSD Aironet driver stuff */
|
||||
{ DLT_AIRONET_HEADER, LINKTYPE_AIRONET_HEADER },
|
||||
|
||||
/* Siemens HiPath HDLC */
|
||||
{ DLT_HHDLC, LINKTYPE_HHDLC },
|
||||
|
||||
/* RFC 2625 IP-over-Fibre Channel */
|
||||
{ DLT_IP_OVER_FC, LINKTYPE_IP_OVER_FC },
|
||||
|
||||
/* Solaris+SunATM */
|
||||
{ DLT_SUNATM, LINKTYPE_SUNATM },
|
||||
|
||||
/* RapidIO */
|
||||
{ DLT_RIO, LINKTYPE_RIO },
|
||||
|
||||
/* PCI Express */
|
||||
{ DLT_PCI_EXP, LINKTYPE_PCI_EXP },
|
||||
|
||||
/* Xilinx Aurora link layer */
|
||||
{ DLT_AURORA, LINKTYPE_AURORA },
|
||||
|
||||
/* 802.11 plus BSD radio header */
|
||||
{ DLT_IEEE802_11_RADIO, LINKTYPE_IEEE802_11_RADIO },
|
||||
|
||||
/* Tazmen Sniffer Protocol */
|
||||
{ DLT_TZSP, LINKTYPE_TZSP },
|
||||
|
||||
/* Arcnet with Linux-style link-layer headers */
|
||||
{ DLT_ARCNET_LINUX, LINKTYPE_ARCNET_LINUX },
|
||||
|
||||
/* Juniper-internal chassis encapsulation */
|
||||
{ DLT_JUNIPER_MLPPP, LINKTYPE_JUNIPER_MLPPP },
|
||||
{ DLT_JUNIPER_MLFR, LINKTYPE_JUNIPER_MLFR },
|
||||
{ DLT_JUNIPER_ES, LINKTYPE_JUNIPER_ES },
|
||||
{ DLT_JUNIPER_GGSN, LINKTYPE_JUNIPER_GGSN },
|
||||
{ DLT_JUNIPER_MFR, LINKTYPE_JUNIPER_MFR },
|
||||
{ DLT_JUNIPER_ATM2, LINKTYPE_JUNIPER_ATM2 },
|
||||
{ DLT_JUNIPER_SERVICES, LINKTYPE_JUNIPER_SERVICES },
|
||||
{ DLT_JUNIPER_ATM1, LINKTYPE_JUNIPER_ATM1 },
|
||||
|
||||
/* Apple IP-over-IEEE 1394 cooked header */
|
||||
{ DLT_APPLE_IP_OVER_IEEE1394, LINKTYPE_APPLE_IP_OVER_IEEE1394 },
|
||||
|
||||
/* SS7 */
|
||||
{ DLT_MTP2_WITH_PHDR, LINKTYPE_MTP2_WITH_PHDR },
|
||||
{ DLT_MTP2, LINKTYPE_MTP2 },
|
||||
{ DLT_MTP3, LINKTYPE_MTP3 },
|
||||
{ DLT_SCCP, LINKTYPE_SCCP },
|
||||
|
||||
/* DOCSIS MAC frames */
|
||||
{ DLT_DOCSIS, LINKTYPE_DOCSIS },
|
||||
|
||||
/* IrDA IrLAP packets + Linux-cooked header */
|
||||
{ DLT_LINUX_IRDA, LINKTYPE_LINUX_IRDA },
|
||||
|
||||
/* IBM SP and Next Federation switches */
|
||||
{ DLT_IBM_SP, LINKTYPE_IBM_SP },
|
||||
{ DLT_IBM_SN, LINKTYPE_IBM_SN },
|
||||
|
||||
/* 802.11 plus AVS radio header */
|
||||
{ DLT_IEEE802_11_RADIO_AVS, LINKTYPE_IEEE802_11_RADIO_AVS },
|
||||
|
||||
/*
|
||||
* Any platform that defines additional DLT_* codes should:
|
||||
*
|
||||
* request a LINKTYPE_* code and value from tcpdump.org,
|
||||
* as per the above;
|
||||
*
|
||||
* add, in their version of libpcap, an entry to map
|
||||
* those DLT_* codes to the corresponding LINKTYPE_*
|
||||
* code;
|
||||
*
|
||||
* redefine, in their "net/bpf.h", any DLT_* values
|
||||
* that collide with the values used by their additional
|
||||
* DLT_* codes, to remove those collisions (but without
|
||||
* making them collide with any of the LINKTYPE_*
|
||||
* values equal to 50 or above; they should also avoid
|
||||
* defining DLT_* values that collide with those
|
||||
* LINKTYPE_* values, either).
|
||||
* All LINKTYPE_ values between LINKTYPE_MATCHING_MIN
|
||||
* and LINKTYPE_MATCHING_MAX are mapped to identical
|
||||
* DLT_ values.
|
||||
*/
|
||||
|
||||
/* Juniper-internal chassis encapsulation */
|
||||
{ DLT_JUNIPER_MONITOR, LINKTYPE_JUNIPER_MONITOR },
|
||||
|
||||
/* BACnet MS/TP */
|
||||
{ DLT_BACNET_MS_TP, LINKTYPE_BACNET_MS_TP },
|
||||
|
||||
/* PPP for pppd, with direction flag in the PPP header */
|
||||
{ DLT_PPP_PPPD, LINKTYPE_PPP_PPPD},
|
||||
|
||||
/* Juniper-internal chassis encapsulation */
|
||||
{ DLT_JUNIPER_PPPOE, LINKTYPE_JUNIPER_PPPOE },
|
||||
{ DLT_JUNIPER_PPPOE_ATM,LINKTYPE_JUNIPER_PPPOE_ATM },
|
||||
|
||||
/* GPRS LLC */
|
||||
{ DLT_GPRS_LLC, LINKTYPE_GPRS_LLC },
|
||||
|
||||
/* Transparent Generic Framing Procedure (ITU-T G.7041/Y.1303) */
|
||||
{ DLT_GPF_T, LINKTYPE_GPF_T },
|
||||
|
||||
/* Framed Generic Framing Procedure (ITU-T G.7041/Y.1303) */
|
||||
{ DLT_GPF_F, LINKTYPE_GPF_F },
|
||||
|
||||
{ DLT_GCOM_T1E1, LINKTYPE_GCOM_T1E1 },
|
||||
{ DLT_GCOM_SERIAL, LINKTYPE_GCOM_SERIAL },
|
||||
|
||||
/* Juniper-internal chassis encapsulation */
|
||||
{ DLT_JUNIPER_PIC_PEER, LINKTYPE_JUNIPER_PIC_PEER },
|
||||
|
||||
/* Endace types */
|
||||
{ DLT_ERF_ETH, LINKTYPE_ERF_ETH },
|
||||
{ DLT_ERF_POS, LINKTYPE_ERF_POS },
|
||||
|
||||
/* viSDN LAPD */
|
||||
{ DLT_LINUX_LAPD, LINKTYPE_LINUX_LAPD },
|
||||
|
||||
/* Juniper meta-information before Ether, PPP, Frame Relay, C-HDLC Frames */
|
||||
{ DLT_JUNIPER_ETHER, LINKTYPE_JUNIPER_ETHER },
|
||||
{ DLT_JUNIPER_PPP, LINKTYPE_JUNIPER_PPP },
|
||||
{ DLT_JUNIPER_FRELAY, LINKTYPE_JUNIPER_FRELAY },
|
||||
{ DLT_JUNIPER_CHDLC, LINKTYPE_JUNIPER_CHDLC },
|
||||
|
||||
/* Multi Link Frame Relay (FRF.16) */
|
||||
{ DLT_MFR, LINKTYPE_MFR },
|
||||
|
||||
/* Juniper Voice PIC */
|
||||
{ DLT_JUNIPER_VP, LINKTYPE_JUNIPER_VP },
|
||||
|
||||
/* Controller Area Network (CAN) v2.0B */
|
||||
{ DLT_A429, LINKTYPE_A429 },
|
||||
|
||||
/* Arinc 653 Interpartition Communication messages */
|
||||
{ DLT_A653_ICM, LINKTYPE_A653_ICM },
|
||||
|
||||
/* USB */
|
||||
{ DLT_USB, LINKTYPE_USB },
|
||||
|
||||
/* Bluetooth HCI UART transport layer */
|
||||
{ DLT_BLUETOOTH_HCI_H4, LINKTYPE_BLUETOOTH_HCI_H4 },
|
||||
|
||||
/* IEEE 802.16 MAC Common Part Sublayer */
|
||||
{ DLT_IEEE802_16_MAC_CPS, LINKTYPE_IEEE802_16_MAC_CPS },
|
||||
|
||||
/* USB with Linux header */
|
||||
{ DLT_USB_LINUX, LINKTYPE_USB_LINUX },
|
||||
|
||||
/* Controller Area Network (CAN) v2.0B */
|
||||
{ DLT_CAN20B, LINKTYPE_CAN20B },
|
||||
|
||||
/* IEEE 802.15.4 with address fields padded */
|
||||
{ DLT_IEEE802_15_4_LINUX, LINKTYPE_IEEE802_15_4_LINUX },
|
||||
|
||||
/* Per Packet Information encapsulated packets */
|
||||
{ DLT_PPI, LINKTYPE_PPI },
|
||||
|
||||
/* IEEE 802.16 MAC Common Part Sublayer plus radiotap header */
|
||||
{ DLT_IEEE802_16_MAC_CPS_RADIO, LINKTYPE_IEEE802_16_MAC_CPS_RADIO },
|
||||
|
||||
/* Juniper Voice ISM */
|
||||
{ DLT_JUNIPER_ISM, LINKTYPE_JUNIPER_ISM },
|
||||
|
||||
/* IEEE 802.15.4 exactly as it appears in the spec */
|
||||
{ DLT_IEEE802_15_4, LINKTYPE_IEEE802_15_4 },
|
||||
|
||||
/* Various link-layer types for SITA */
|
||||
{ DLT_SITA, LINKTYPE_SITA },
|
||||
|
||||
/* Various link-layer types for Endace */
|
||||
{ DLT_ERF, LINKTYPE_ERF },
|
||||
|
||||
/* Special header for u10 Networks boards */
|
||||
{ DLT_RAIF1, LINKTYPE_RAIF1 },
|
||||
|
||||
/* IPMB */
|
||||
{ DLT_IPMB, LINKTYPE_IPMB },
|
||||
|
||||
/* Juniper Secure Tunnel */
|
||||
{ DLT_JUNIPER_ST, LINKTYPE_JUNIPER_ST },
|
||||
|
||||
/* Bluetooth HCI UART transport layer, with pseudo-header */
|
||||
{ DLT_BLUETOOTH_HCI_H4_WITH_PHDR, LINKTYPE_BLUETOOTH_HCI_H4_WITH_PHDR },
|
||||
|
||||
/* AX.25 with KISS header */
|
||||
{ DLT_AX25_KISS, LINKTYPE_AX25_KISS },
|
||||
|
||||
/* Raw LAPD, with no pseudo-header */
|
||||
{ DLT_LAPD, LINKTYPE_LAPD },
|
||||
|
||||
/* PPP with one-byte pseudo-header giving direction */
|
||||
{ DLT_PPP_WITH_DIR, LINKTYPE_PPP_WITH_DIR },
|
||||
|
||||
/* Cisco HDLC with one-byte pseudo-header giving direction */
|
||||
{ DLT_C_HDLC_WITH_DIR, LINKTYPE_C_HDLC_WITH_DIR },
|
||||
|
||||
/* Frame Relay with one-byte pseudo-header giving direction */
|
||||
{ DLT_FRELAY_WITH_DIR, LINKTYPE_FRELAY_WITH_DIR },
|
||||
|
||||
/* LAPB with one-byte pseudo-header giving direction */
|
||||
{ DLT_LAPB_WITH_DIR, LINKTYPE_LAPB_WITH_DIR },
|
||||
|
||||
/* IPMB with Linux pseudo-header */
|
||||
{ DLT_IPMB_LINUX, LINKTYPE_IPMB_LINUX },
|
||||
|
||||
/* FlexRay */
|
||||
{ DLT_FLEXRAY, LINKTYPE_FLEXRAY },
|
||||
|
||||
/* MOST */
|
||||
{ DLT_MOST, LINKTYPE_MOST },
|
||||
|
||||
/* LIN */
|
||||
{ DLT_LIN, LINKTYPE_LIN },
|
||||
|
||||
/* X2E-private serial line capture */
|
||||
{ DLT_X2E_SERIAL, LINKTYPE_X2E_SERIAL },
|
||||
|
||||
/* X2E-private for Xoraya data logger family */
|
||||
{ DLT_X2E_XORAYA, LINKTYPE_X2E_XORAYA },
|
||||
|
||||
/* IEEE 802.15.4 with PHY data for non-ASK PHYs */
|
||||
{ DLT_IEEE802_15_4_NONASK_PHY, LINKTYPE_IEEE802_15_4_NONASK_PHY },
|
||||
|
||||
/* Input device events from Linux /dev/input/eventN devices */
|
||||
{ DLT_LINUX_EVDEV, LINKTYPE_LINUX_EVDEV },
|
||||
|
||||
/* GSM types */
|
||||
{ DLT_GSMTAP_UM, LINKTYPE_GSMTAP_UM },
|
||||
{ DLT_GSMTAP_ABIS, LINKTYPE_GSMTAP_ABIS },
|
||||
|
||||
/* MPLS, with an MPLS label as the link-layer header */
|
||||
{ DLT_MPLS, LINKTYPE_MPLS },
|
||||
|
||||
/* USB with padded Linux header */
|
||||
{ DLT_USB_LINUX_MMAPPED, LINKTYPE_USB_LINUX_MMAPPED },
|
||||
|
||||
/* DECT packets with a pseudo-header */
|
||||
{ DLT_DECT, LINKTYPE_DECT },
|
||||
|
||||
/* AOS Space Data Link Protocol */
|
||||
{ DLT_AOS, LINKTYPE_AOS },
|
||||
|
||||
/* Wireless HART */
|
||||
{ DLT_WIHART, LINKTYPE_WIHART },
|
||||
|
||||
/* Fibre Channel FC-2 frames without SOF or EOF */
|
||||
{ DLT_FC_2, LINKTYPE_FC_2 },
|
||||
|
||||
/* Fibre Channel FC-2 frames with SOF and EOF */
|
||||
{ DLT_FC_2_WITH_FRAME_DELIMS, LINKTYPE_FC_2_WITH_FRAME_DELIMS },
|
||||
|
||||
/* Solaris IPNET */
|
||||
{ DLT_IPNET, LINKTYPE_IPNET },
|
||||
|
||||
/* CAN frames with SocketCAN headers */
|
||||
{ DLT_CAN_SOCKETCAN, LINKTYPE_CAN_SOCKETCAN },
|
||||
|
||||
/* Raw IPv4/IPv6 */
|
||||
{ DLT_IPV4, LINKTYPE_IPV4 },
|
||||
{ DLT_IPV6, LINKTYPE_IPV6 },
|
||||
|
||||
{ -1, -1 }
|
||||
};
|
||||
|
||||
@@ -1082,6 +922,15 @@ dlt_to_linktype(int dlt)
|
||||
{
|
||||
int i;
|
||||
|
||||
/*
|
||||
* Map the values in the matching range.
|
||||
*/
|
||||
if (dlt >= DLT_MATCHING_MIN && dlt <= DLT_MATCHING_MAX)
|
||||
return (dlt);
|
||||
|
||||
/*
|
||||
* Map the values outside that range.
|
||||
*/
|
||||
for (i = 0; map[i].dlt != -1; i++) {
|
||||
if (map[i].dlt == dlt)
|
||||
return (map[i].linktype);
|
||||
@@ -1089,8 +938,8 @@ dlt_to_linktype(int dlt)
|
||||
|
||||
/*
|
||||
* If we don't have a mapping for this DLT_ code, return an
|
||||
* error; that means that the table above needs to have an
|
||||
* entry added.
|
||||
* error; that means that this is a value with no corresponding
|
||||
* LINKTYPE_ code, and we need to assign one.
|
||||
*/
|
||||
return (-1);
|
||||
}
|
||||
@@ -1100,6 +949,16 @@ linktype_to_dlt(int linktype)
|
||||
{
|
||||
int i;
|
||||
|
||||
/*
|
||||
* Map the values in the matching range.
|
||||
*/
|
||||
if (linktype >= LINKTYPE_MATCHING_MIN &&
|
||||
linktype <= LINKTYPE_MATCHING_MAX)
|
||||
return (linktype);
|
||||
|
||||
/*
|
||||
* Map the values outside that range.
|
||||
*/
|
||||
for (i = 0; map[i].linktype != -1; i++) {
|
||||
if (map[i].linktype == linktype)
|
||||
return (map[i].dlt);
|
||||
@@ -1127,33 +986,72 @@ swap_linux_usb_header(const struct pcap_pkthdr *hdr, u_char *buf,
|
||||
int header_len_64_bytes)
|
||||
{
|
||||
pcap_usb_header_mmapped *uhdr = (pcap_usb_header_mmapped *)buf;
|
||||
bpf_u_int32 offset = 0;
|
||||
usb_isodesc *pisodesc;
|
||||
int32_t numdesc, i;
|
||||
|
||||
/*
|
||||
* "offset" is the offset *past* the field we're swapping;
|
||||
* we skip the field *before* checking to make sure
|
||||
* the captured data length includes the entire field.
|
||||
*/
|
||||
|
||||
/*
|
||||
* The URB id is a totally opaque value; do we really need to
|
||||
* convert it to the reading host's byte order???
|
||||
*/
|
||||
if (hdr->caplen < 8)
|
||||
offset += 8; /* skip past id */
|
||||
if (hdr->caplen < offset)
|
||||
return;
|
||||
uhdr->id = SWAPLL(uhdr->id);
|
||||
if (hdr->caplen < 14)
|
||||
|
||||
offset += 4; /* skip past various 1-byte fields */
|
||||
|
||||
offset += 2; /* skip past bus_id */
|
||||
if (hdr->caplen < offset)
|
||||
return;
|
||||
uhdr->bus_id = SWAPSHORT(uhdr->bus_id);
|
||||
if (hdr->caplen < 24)
|
||||
|
||||
offset += 2; /* skip past various 1-byte fields */
|
||||
|
||||
offset += 8; /* skip past ts_sec */
|
||||
if (hdr->caplen < offset)
|
||||
return;
|
||||
uhdr->ts_sec = SWAPLL(uhdr->ts_sec);
|
||||
if (hdr->caplen < 28)
|
||||
|
||||
offset += 4; /* skip past ts_usec */
|
||||
if (hdr->caplen < offset)
|
||||
return;
|
||||
uhdr->ts_usec = SWAPLONG(uhdr->ts_usec);
|
||||
if (hdr->caplen < 32)
|
||||
|
||||
offset += 4; /* skip past status */
|
||||
if (hdr->caplen < offset)
|
||||
return;
|
||||
uhdr->status = SWAPLONG(uhdr->status);
|
||||
if (hdr->caplen < 36)
|
||||
|
||||
offset += 4; /* skip past urb_len */
|
||||
if (hdr->caplen < offset)
|
||||
return;
|
||||
uhdr->urb_len = SWAPLONG(uhdr->urb_len);
|
||||
if (hdr->caplen < 40)
|
||||
|
||||
offset += 4; /* skip past data_len */
|
||||
if (hdr->caplen < offset)
|
||||
return;
|
||||
uhdr->data_len = SWAPLONG(uhdr->data_len);
|
||||
|
||||
if (uhdr->transfer_type == URB_ISOCHRONOUS) {
|
||||
offset += 4; /* skip past s.iso.error_count */
|
||||
if (hdr->caplen < offset)
|
||||
return;
|
||||
uhdr->s.iso.error_count = SWAPLONG(uhdr->s.iso.error_count);
|
||||
|
||||
offset += 4; /* skip past s.iso.numdesc */
|
||||
if (hdr->caplen < offset)
|
||||
return;
|
||||
uhdr->s.iso.numdesc = SWAPLONG(uhdr->s.iso.numdesc);
|
||||
} else
|
||||
offset += 8; /* skip USB setup header */
|
||||
|
||||
if (header_len_64_bytes) {
|
||||
/*
|
||||
* This is either the "version 1" header, with
|
||||
@@ -1163,17 +1061,50 @@ swap_linux_usb_header(const struct pcap_pkthdr *hdr, u_char *buf,
|
||||
* at the end. Byte swap them as if this were
|
||||
* a "version 1" header.
|
||||
*/
|
||||
if (hdr->caplen < 52)
|
||||
offset += 4; /* skip past interval */
|
||||
if (hdr->caplen < offset)
|
||||
return;
|
||||
uhdr->interval = SWAPLONG(uhdr->interval);
|
||||
if (hdr->caplen < 56)
|
||||
|
||||
offset += 4; /* skip past start_frame */
|
||||
if (hdr->caplen < offset)
|
||||
return;
|
||||
uhdr->start_frame = SWAPLONG(uhdr->start_frame);
|
||||
if (hdr->caplen < 60)
|
||||
|
||||
offset += 4; /* skip past xfer_flags */
|
||||
if (hdr->caplen < offset)
|
||||
return;
|
||||
uhdr->xfer_flags = SWAPLONG(uhdr->xfer_flags);
|
||||
if (hdr->caplen < 64)
|
||||
|
||||
offset += 4; /* skip past ndesc */
|
||||
if (hdr->caplen < offset)
|
||||
return;
|
||||
uhdr->ndesc = SWAPLONG(uhdr->ndesc);
|
||||
}
|
||||
|
||||
if (uhdr->transfer_type == URB_ISOCHRONOUS) {
|
||||
/* swap the values in struct linux_usb_isodesc */
|
||||
pisodesc = (usb_isodesc *)(void *)(buf+offset);
|
||||
numdesc = uhdr->s.iso.numdesc;
|
||||
for (i = 0; i < numdesc; i++) {
|
||||
offset += 4; /* skip past status */
|
||||
if (hdr->caplen < offset)
|
||||
return;
|
||||
pisodesc->status = SWAPLONG(pisodesc->status);
|
||||
|
||||
offset += 4; /* skip past offset */
|
||||
if (hdr->caplen < offset)
|
||||
return;
|
||||
pisodesc->offset = SWAPLONG(pisodesc->offset);
|
||||
|
||||
offset += 4; /* skip past len */
|
||||
if (hdr->caplen < offset)
|
||||
return;
|
||||
pisodesc->len = SWAPLONG(pisodesc->len);
|
||||
|
||||
offset += 4; /* skip past padding */
|
||||
|
||||
pisodesc++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,13 @@
|
||||
# Script to give the appropriate compiler flags and linker flags
|
||||
# to use when building code that uses libpcap.
|
||||
#
|
||||
prefix="@prefix@"
|
||||
exec_prefix="@exec_prefix@"
|
||||
includedir="@includedir@"
|
||||
libdir="@libdir@"
|
||||
V_RPATH_OPT="@V_RPATH_OPT@"
|
||||
LIBS="@LIBS@"
|
||||
|
||||
static=0
|
||||
show_cflags=0
|
||||
show_libs=0
|
||||
@@ -29,14 +36,14 @@ do
|
||||
esac
|
||||
shift
|
||||
done
|
||||
if [ "@V_RPATH_OPT@" != "" ]
|
||||
if [ "$V_RPATH_OPT" != "" ]
|
||||
then
|
||||
#
|
||||
# If libdir isn't /usr/lib, add it to the run-time linker path.
|
||||
#
|
||||
if [ "@libdir@" != "/usr/lib" ]
|
||||
if [ "$libdir" != "/usr/lib" ]
|
||||
then
|
||||
RPATH=@V_RPATH_OPT@@libdir@
|
||||
RPATH=$V_RPATH_OPT$libdir
|
||||
fi
|
||||
fi
|
||||
if [ "$static" = 1 ]
|
||||
@@ -47,19 +54,19 @@ then
|
||||
#
|
||||
if [ "$show_cflags" = 1 -a "$show_libs" = 1 ]
|
||||
then
|
||||
echo "-I@includedir@ -L@libdir@ -lpcap @LIBS@"
|
||||
echo "-I$includedir -L$libdir -lpcap $LIBS"
|
||||
elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ]
|
||||
then
|
||||
echo "-I@includedir@ -L@libdir@ @LIBS@"
|
||||
echo "-I$includedir -L$libdir $LIBS"
|
||||
elif [ "$show_cflags" = 1 ]
|
||||
then
|
||||
echo "-I@includedir@"
|
||||
echo "-I$includedir"
|
||||
elif [ "$show_libs" = 1 ]
|
||||
then
|
||||
echo "-L@libdir@ -lpcap @LIBS@"
|
||||
echo "-L$libdir -lpcap $LIBS"
|
||||
elif [ "$show_additional_libs" = 1 ]
|
||||
then
|
||||
echo "@LIBS@"
|
||||
echo "$LIBS"
|
||||
fi
|
||||
else
|
||||
#
|
||||
@@ -68,15 +75,15 @@ else
|
||||
#
|
||||
if [ "$show_cflags" = 1 -a "$show_libs" = 1 ]
|
||||
then
|
||||
echo "-I@includedir@ -L@libdir@ $RPATH -lpcap"
|
||||
echo "-I$includedir -L$libdir $RPATH -lpcap"
|
||||
elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ]
|
||||
then
|
||||
echo "-I@includedir@"
|
||||
echo "-I$includedir"
|
||||
elif [ "$show_cflags" = 1 ]
|
||||
then
|
||||
echo "-I@includedir@"
|
||||
echo "-I$includedir"
|
||||
elif [ "$show_libs" = 1 ]
|
||||
then
|
||||
echo "-L@libdir@ $RPATH -lpcap"
|
||||
echo "-L$libdir $RPATH -lpcap"
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -879,8 +879,8 @@ dag_platform_finddevs(pcap_if_t **devlistp, char *errbuf)
|
||||
int dagstream;
|
||||
int dagfd;
|
||||
|
||||
/* Try all the DAGs 0-9 */
|
||||
for (c = 0; c < 9; c++) {
|
||||
/* Try all the DAGs 0-31 */
|
||||
for (c = 0; c < 32; c++) {
|
||||
snprintf(name, 12, "dag%d", c);
|
||||
if (-1 == dag_parse_name(name, dagname, DAGNAME_BUFSIZE, &dagstream))
|
||||
{
|
||||
@@ -897,7 +897,7 @@ dag_platform_finddevs(pcap_if_t **devlistp, char *errbuf)
|
||||
{
|
||||
int stream, rxstreams;
|
||||
rxstreams = dag_rx_get_stream_count(dagfd);
|
||||
for(stream=0;stream<16;stream+=2) {
|
||||
for(stream=0;stream<DAG_STREAM_MAX;stream+=2) {
|
||||
if (0 == dag_attach_stream(dagfd, stream, 0, 0)) {
|
||||
dag_detach_stream(dagfd, stream);
|
||||
|
||||
@@ -908,6 +908,11 @@ dag_platform_finddevs(pcap_if_t **devlistp, char *errbuf)
|
||||
*/
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
rxstreams--;
|
||||
if(rxstreams <= 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,10 +143,9 @@ static int dl_doattach(int, int, char *);
|
||||
#ifdef DL_HP_RAWDLS
|
||||
static int dl_dohpuxbind(int, char *);
|
||||
#endif
|
||||
static int dlattachreq(int, bpf_u_int32, char *);
|
||||
static int dlpromiscon(pcap_t *, bpf_u_int32);
|
||||
static int dlbindreq(int, bpf_u_int32, char *);
|
||||
static int dlbindack(int, char *, char *, int *);
|
||||
static int dlpromisconreq(int, bpf_u_int32, char *);
|
||||
static int dlokack(int, const char *, char *, char *);
|
||||
static int dlinforeq(int, char *);
|
||||
static int dlinfoack(int, char *, char *);
|
||||
@@ -450,7 +449,7 @@ pcap_activate_dlpi(pcap_t *p)
|
||||
/* Try device without unit number */
|
||||
if ((p->fd = open(dname, O_RDWR)) < 0) {
|
||||
if (errno != ENOENT) {
|
||||
if (errno == EACCES)
|
||||
if (errno == EPERM || errno == EACCES)
|
||||
status = PCAP_ERROR_PERM_DENIED;
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "%s: %s", dname,
|
||||
pcap_strerror(errno));
|
||||
@@ -486,7 +485,7 @@ pcap_activate_dlpi(pcap_t *p)
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"%s: No DLPI device found", p->opt.source);
|
||||
} else {
|
||||
if (errno == EACCES)
|
||||
if (errno == EPERM || errno == EACCES)
|
||||
status = PCAP_ERROR_PERM_DENIED;
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "%s: %s",
|
||||
dname2, pcap_strerror(errno));
|
||||
@@ -610,9 +609,12 @@ pcap_activate_dlpi(pcap_t *p)
|
||||
/*
|
||||
** Enable promiscuous (not necessary on send FD)
|
||||
*/
|
||||
if (dlpromisconreq(p->fd, DL_PROMISC_PHYS, p->errbuf) < 0 ||
|
||||
dlokack(p->fd, "promisc_phys", (char *)buf, p->errbuf) < 0)
|
||||
status = dlpromiscon(p, DL_PROMISC_PHYS);
|
||||
if (status < 0) {
|
||||
if (status == PCAP_ERROR_PERM_DENIED)
|
||||
status = PCAP_ERROR_PROMISC_PERM_DENIED;
|
||||
goto bad;
|
||||
}
|
||||
|
||||
/*
|
||||
** Try to enable multicast (you would have thought
|
||||
@@ -620,8 +622,8 @@ pcap_activate_dlpi(pcap_t *p)
|
||||
** HP-UX or SINIX) (Not necessary on send FD)
|
||||
*/
|
||||
#if !defined(__hpux) && !defined(sinix)
|
||||
if (dlpromisconreq(p->fd, DL_PROMISC_MULTI, p->errbuf) < 0 ||
|
||||
dlokack(p->fd, "promisc_multi", (char *)buf, p->errbuf) < 0)
|
||||
status = dlpromiscon(p, DL_PROMISC_MULTI);
|
||||
if (status < 0)
|
||||
status = PCAP_WARNING;
|
||||
#endif
|
||||
}
|
||||
@@ -631,20 +633,27 @@ pcap_activate_dlpi(pcap_t *p)
|
||||
** under SINIX) (Not necessary on send FD)
|
||||
*/
|
||||
#ifndef sinix
|
||||
if (
|
||||
#ifdef __hpux
|
||||
!p->opt.promisc &&
|
||||
#if defined(__hpux)
|
||||
/* HP-UX - only do this when not in promiscuous mode */
|
||||
if (!p->opt.promisc) {
|
||||
#elif defined(HAVE_SOLARIS)
|
||||
/* Solaris - don't do this on SunATM devices */
|
||||
if (!isatm) {
|
||||
#else
|
||||
/* Everything else (except for SINIX) - always do this */
|
||||
{
|
||||
#endif
|
||||
#ifdef HAVE_SOLARIS
|
||||
!isatm &&
|
||||
#endif
|
||||
(dlpromisconreq(p->fd, DL_PROMISC_SAP, p->errbuf) < 0 ||
|
||||
dlokack(p->fd, "promisc_sap", (char *)buf, p->errbuf) < 0)) {
|
||||
/* Not fatal if promisc since the DL_PROMISC_PHYS worked */
|
||||
if (p->opt.promisc)
|
||||
status = PCAP_WARNING;
|
||||
else
|
||||
goto bad;
|
||||
status = dlpromiscon(p, DL_PROMISC_SAP);
|
||||
if (status < 0) {
|
||||
/*
|
||||
* Not fatal, since the DL_PROMISC_PHYS mode worked.
|
||||
* Report it as a warning, however.
|
||||
*/
|
||||
if (p->opt.promisc)
|
||||
status = PCAP_WARNING;
|
||||
else
|
||||
goto bad;
|
||||
}
|
||||
}
|
||||
#endif /* sinix */
|
||||
|
||||
@@ -815,11 +824,15 @@ split_dname(char *device, int *unitp, char *ebuf)
|
||||
static int
|
||||
dl_doattach(int fd, int ppa, char *ebuf)
|
||||
{
|
||||
dl_attach_req_t req;
|
||||
bpf_u_int32 buf[MAXDLBUF];
|
||||
int err;
|
||||
|
||||
if (dlattachreq(fd, ppa, ebuf) < 0)
|
||||
req.dl_primitive = DL_ATTACH_REQ;
|
||||
req.dl_ppa = ppa;
|
||||
if (send_request(fd, (char *)&req, sizeof(req), "attach", ebuf) < 0)
|
||||
return (PCAP_ERROR);
|
||||
|
||||
err = dlokack(fd, "attach", (char *)buf, ebuf);
|
||||
if (err < 0)
|
||||
return (err);
|
||||
@@ -877,6 +890,27 @@ dl_dohpuxbind(int fd, char *ebuf)
|
||||
}
|
||||
#endif
|
||||
|
||||
#define STRINGIFY(n) #n
|
||||
|
||||
static int
|
||||
dlpromiscon(pcap_t *p, bpf_u_int32 level)
|
||||
{
|
||||
dl_promiscon_req_t req;
|
||||
bpf_u_int32 buf[MAXDLBUF];
|
||||
int err;
|
||||
|
||||
req.dl_primitive = DL_PROMISCON_REQ;
|
||||
req.dl_level = level;
|
||||
if (send_request(p->fd, (char *)&req, sizeof(req), "promiscon",
|
||||
p->errbuf) < 0)
|
||||
return (PCAP_ERROR);
|
||||
err = dlokack(p->fd, "promiscon" STRINGIFY(level), (char *)buf,
|
||||
p->errbuf);
|
||||
if (err < 0)
|
||||
return (err);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
pcap_platform_finddevs(pcap_if_t **alldevsp, char *errbuf)
|
||||
{
|
||||
@@ -986,7 +1020,8 @@ recv_ack(int fd, int size, const char *what, char *bufp, char *ebuf, int *uerror
|
||||
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||
"recv_ack: %s: UNIX error - %s",
|
||||
what, pcap_strerror(dlp->error_ack.dl_unix_errno));
|
||||
if (dlp->error_ack.dl_unix_errno == EACCES)
|
||||
if (dlp->error_ack.dl_unix_errno == EPERM ||
|
||||
dlp->error_ack.dl_unix_errno == EACCES)
|
||||
return (PCAP_ERROR_PERM_DENIED);
|
||||
break;
|
||||
|
||||
@@ -1221,17 +1256,6 @@ dlprim(bpf_u_int32 prim)
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
dlattachreq(int fd, bpf_u_int32 ppa, char *ebuf)
|
||||
{
|
||||
dl_attach_req_t req;
|
||||
|
||||
req.dl_primitive = DL_ATTACH_REQ;
|
||||
req.dl_ppa = ppa;
|
||||
|
||||
return (send_request(fd, (char *)&req, sizeof(req), "attach", ebuf));
|
||||
}
|
||||
|
||||
static int
|
||||
dlbindreq(int fd, bpf_u_int32 sap, char *ebuf)
|
||||
{
|
||||
@@ -1259,17 +1283,6 @@ dlbindack(int fd, char *bufp, char *ebuf, int *uerror)
|
||||
return (recv_ack(fd, DL_BIND_ACK_SIZE, "bind", bufp, ebuf, uerror));
|
||||
}
|
||||
|
||||
static int
|
||||
dlpromisconreq(int fd, bpf_u_int32 level, char *ebuf)
|
||||
{
|
||||
dl_promiscon_req_t req;
|
||||
|
||||
req.dl_primitive = DL_PROMISCON_REQ;
|
||||
req.dl_level = level;
|
||||
|
||||
return (send_request(fd, (char *)&req, sizeof(req), "promiscon", ebuf));
|
||||
}
|
||||
|
||||
static int
|
||||
dlokack(int fd, const char *what, char *bufp, char *ebuf)
|
||||
{
|
||||
|
||||
@@ -65,6 +65,8 @@ Possible directions are
|
||||
.BR dst ,
|
||||
.BR "src or dst" ,
|
||||
.BR "src and dst" ,
|
||||
.BR ra ,
|
||||
.BR ta ,
|
||||
.BR addr1 ,
|
||||
.BR addr2 ,
|
||||
.BR addr3 ,
|
||||
@@ -76,6 +78,8 @@ there is no dir qualifier,
|
||||
.B "src or dst"
|
||||
is assumed.
|
||||
The
|
||||
.BR ra ,
|
||||
.BR ta ,
|
||||
.BR addr1 ,
|
||||
.BR addr2 ,
|
||||
.BR addr3 ,
|
||||
@@ -472,6 +476,15 @@ and
|
||||
.B scrub
|
||||
(applies only to packets logged by OpenBSD's or FreeBSD's
|
||||
.BR pf (4)).
|
||||
.IP "\fBwlan ra \fIehost\fR"
|
||||
True if the IEEE 802.11 RA is
|
||||
.IR ehost .
|
||||
The RA field is used in all frames except for management frames.
|
||||
.IP "\fBwlan ta \fIehost\fR"
|
||||
True if the IEEE 802.11 TA is
|
||||
.IR ehost .
|
||||
The TA field is used in all frames except for management frames and
|
||||
CTS (Clear To Send) and ACK (Acknowledgment) control frames.
|
||||
.IP "\fBwlan addr1 \fIehost\fR"
|
||||
True if the first IEEE 802.11 address is
|
||||
.IR ehost .
|
||||
@@ -490,7 +503,7 @@ True if the fourth IEEE 802.11 address, if present, is
|
||||
.IR ehost .
|
||||
The fourth address field is only used for
|
||||
WDS (Wireless Distribution System) frames.
|
||||
.IP "\fBip\fR, \fBip6\fR, \fBarp\fR, \fBrarp\fR, \fBatalk\fR, \fBaarp\fR, \fBdecnet\fR, \fBiso\fR, \fBstp\fR, \fBipx\fR, \fInetbeui\fP"
|
||||
.IP "\fBip\fR, \fBip6\fR, \fBarp\fR, \fBrarp\fR, \fBatalk\fR, \fBaarp\fR, \fBdecnet\fR, \fBiso\fR, \fBstp\fR, \fBipx\fR, \fBnetbeui\fP"
|
||||
Abbreviations for:
|
||||
.in +.5i
|
||||
.nf
|
||||
|
||||
@@ -209,6 +209,7 @@ struct pcap_opt {
|
||||
char *source;
|
||||
int promisc;
|
||||
int rfmon;
|
||||
int tstamp_type;
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -331,6 +332,8 @@ struct pcap {
|
||||
char errbuf[PCAP_ERRBUF_SIZE + 1];
|
||||
int dlt_count;
|
||||
u_int *dlt_list;
|
||||
int tstamp_type_count;
|
||||
u_int *tstamp_type_list;
|
||||
|
||||
struct pcap_pkthdr pcap_header; /* This is needed for the pcap_next_ex() to work */
|
||||
};
|
||||
|
||||
@@ -49,6 +49,7 @@ static const char rcsid[] _U_ =
|
||||
#include "dlpisubs.h"
|
||||
|
||||
/* Forwards. */
|
||||
static int dlpromiscon(pcap_t *, bpf_u_int32);
|
||||
static int pcap_read_libdlpi(pcap_t *, int, pcap_handler, u_char *);
|
||||
static int pcap_inject_libdlpi(pcap_t *, const void *, size_t);
|
||||
static void pcap_close_libdlpi(pcap_t *);
|
||||
@@ -114,7 +115,8 @@ pcap_activate_libdlpi(pcap_t *p)
|
||||
if (retv != DLPI_SUCCESS) {
|
||||
if (retv == DLPI_ELINKNAMEINVAL || retv == DLPI_ENOLINK)
|
||||
err = PCAP_ERROR_NO_SUCH_DEVICE;
|
||||
else if (retv == DL_SYSERR && errno == EACCES)
|
||||
else if (retv == DL_SYSERR &&
|
||||
(errno == EPERM || errno == EACCES))
|
||||
err = PCAP_ERROR_PERM_DENIED;
|
||||
pcap_libdlpi_err(p->opt.source, "dlpi_open", retv,
|
||||
p->errbuf);
|
||||
@@ -139,34 +141,43 @@ pcap_activate_libdlpi(pcap_t *p)
|
||||
|
||||
/* Enable promiscuous mode. */
|
||||
if (p->opt.promisc) {
|
||||
retv = dlpi_promiscon(p->dlpi_hd, DL_PROMISC_PHYS);
|
||||
if (retv != DLPI_SUCCESS) {
|
||||
pcap_libdlpi_err(p->opt.source,
|
||||
"dlpi_promisc(PHYSICAL)", retv, p->errbuf);
|
||||
err = dlpromiscon(p, DL_PROMISC_PHYS);
|
||||
if (err < 0) {
|
||||
/*
|
||||
* "You don't have permission to capture on
|
||||
* this device" and "you don't have permission
|
||||
* to capture in promiscuous mode on this
|
||||
* device" are different; let the user know,
|
||||
* so if they can't get permission to
|
||||
* capture in promiscuous mode, they can at
|
||||
* least try to capture in non-promiscuous
|
||||
* mode.
|
||||
*
|
||||
* XXX - you might have to capture in
|
||||
* promiscuous mode to see outgoing packets.
|
||||
*/
|
||||
if (err == PCAP_ERROR_PERM_DENIED)
|
||||
err = PCAP_ERROR_PROMISC_PERM_DENIED;
|
||||
goto bad;
|
||||
}
|
||||
} else {
|
||||
/* Try to enable multicast. */
|
||||
retv = dlpi_promiscon(p->dlpi_hd, DL_PROMISC_MULTI);
|
||||
if (retv != DLPI_SUCCESS) {
|
||||
pcap_libdlpi_err(p->opt.source, "dlpi_promisc(MULTI)",
|
||||
retv, p->errbuf);
|
||||
err = dlpromiscon(p, DL_PROMISC_MULTI);
|
||||
if (err < 0)
|
||||
goto bad;
|
||||
}
|
||||
}
|
||||
|
||||
/* Try to enable SAP promiscuity. */
|
||||
retv = dlpi_promiscon(p->dlpi_hd, DL_PROMISC_SAP);
|
||||
if (retv != DLPI_SUCCESS) {
|
||||
if (p->opt.promisc) {
|
||||
pcap_libdlpi_err(p->opt.source, "dlpi_promisc(SAP)",
|
||||
retv, p->errbuf);
|
||||
err = dlpromiscon(p, DL_PROMISC_SAP);
|
||||
if (err < 0) {
|
||||
/*
|
||||
* Not fatal, since the DL_PROMISC_PHYS mode worked.
|
||||
* Report it as a warning, however.
|
||||
*/
|
||||
if (p->opt.promisc)
|
||||
err = PCAP_WARNING;
|
||||
else
|
||||
goto bad;
|
||||
}
|
||||
|
||||
/* Not fatal, since the DL_PROMISC_PHYS mode worked. */
|
||||
fprintf(stderr, "WARNING: dlpi_promisc(SAP) failed on"
|
||||
" %s:(%s)\n", p->opt.source, dlpi_strerror(retv));
|
||||
}
|
||||
|
||||
/* Determine link type. */
|
||||
@@ -219,6 +230,27 @@ bad:
|
||||
return (err);
|
||||
}
|
||||
|
||||
#define STRINGIFY(n) #n
|
||||
|
||||
static int
|
||||
dlpromiscon(pcap_t *p, bpf_u_int32 level)
|
||||
{
|
||||
int err;
|
||||
|
||||
retv = dlpi_promiscon(p->hd, level);
|
||||
if (retv != DLPI_SUCCESS) {
|
||||
if (retv == DL_SYSERR &&
|
||||
(errno == EPERM || errno == EACCES))
|
||||
err = PCAP_ERROR_PERM_DENIED;
|
||||
else
|
||||
err = PCAP_ERROR;
|
||||
pcap_libdlpi_err(p->opt.source, "dlpi_promiscon" STRINGIFY(level),
|
||||
retv, p->errbuf);
|
||||
return (err);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* In Solaris, the "standard" mechanism" i.e SIOCGLIFCONF will only find
|
||||
* network links that are plumbed and are up. dlpi_walk(3DLPI) will find
|
||||
|
||||
@@ -44,241 +44,7 @@ by
|
||||
The names for those values begin with
|
||||
.BR LINKTYPE_ .
|
||||
.PP
|
||||
The link-layer header types supported by libpcap are listed here. The
|
||||
value corresponding to
|
||||
.B LINKTYPE_
|
||||
names are given; the value corresponding to
|
||||
.B DLT_
|
||||
values are, in some cases, platform dependent, and are not given;
|
||||
applications should check for particular
|
||||
.B DLT_
|
||||
values by name.
|
||||
.RS 5
|
||||
.TP 5
|
||||
.BR DLT_NULL "; " LINKTYPE_NULL = 0
|
||||
BSD loopback encapsulation; the link-layer header is a 4-byte field, in
|
||||
.I host
|
||||
byte order, containing a PF_ value from
|
||||
.B socket.h
|
||||
for the network-layer protocol of the packet.
|
||||
.IP
|
||||
Note that ``host byte order'' is the byte order of the machine on which
|
||||
the packets are captured, and the PF_ values are for the OS of the
|
||||
machine on which the packets are captured; if a live capture is being
|
||||
done, ``host byte order'' is the byte order of the machine capturing the
|
||||
packets, and the PF_ values are those of the OS of the machine capturing
|
||||
the packets, but if a ``savefile'' is being read, the byte order and PF_
|
||||
values are
|
||||
.I not
|
||||
necessarily those of the machine reading the capture file.
|
||||
.TP 5
|
||||
.BR DLT_EN10MB "; " LINKTYPE_ETHERNET = 1
|
||||
Ethernet (10Mb, 100Mb, 1000Mb, and up); the
|
||||
.B 10MB
|
||||
in the
|
||||
.B DLT_
|
||||
name is historical.
|
||||
.TP 5
|
||||
.BR DLT_IEEE802 "; " LINKTYPE_TOKEN_RING = 6
|
||||
IEEE 802.5 Token Ring; the
|
||||
.B IEEE802
|
||||
in the
|
||||
.B DLT_
|
||||
name is historical.
|
||||
.TP 5
|
||||
.BR DLT_ARCNET "; " LINKTYPE_ARCNET = 7
|
||||
ARCNET
|
||||
.TP 5
|
||||
.BR DLT_SLIP "; " LINKTYPE_SLIP = 8
|
||||
SLIP; the link-layer header contains, in order:
|
||||
.RS 10
|
||||
.LP
|
||||
a 1-byte flag, which is 0 for packets received by the machine and 1 for
|
||||
packets sent by the machine;
|
||||
.LP
|
||||
a 1-byte field, the upper 4 bits of which indicate the type of packet,
|
||||
as per RFC 1144:
|
||||
.RS 5
|
||||
.TP 5
|
||||
0x40
|
||||
an unmodified IP datagram (TYPE_IP);
|
||||
.TP 5
|
||||
0x70
|
||||
an uncompressed-TCP IP datagram (UNCOMPRESSED_TCP), with that byte being
|
||||
the first byte of the raw IP header on the wire, containing the
|
||||
connection number in the protocol field;
|
||||
.TP 5
|
||||
0x80
|
||||
a compressed-TCP IP datagram (COMPRESSED_TCP), with that byte being the
|
||||
first byte of the compressed TCP/IP datagram header;
|
||||
.RE
|
||||
.LP
|
||||
for UNCOMPRESSED_TCP, the rest of the modified IP header, and for
|
||||
COMPRESSED_TCP, the compressed TCP/IP datagram header;
|
||||
.RE
|
||||
.RS 5
|
||||
.LP
|
||||
for a total of 16 bytes; the uncompressed IP datagram follows the header.
|
||||
.RE
|
||||
.TP 5
|
||||
.BR DLT_PPP "; " LINKTYPE_PPP = 9
|
||||
PPP; if the first 2 bytes are 0xff and 0x03, it's PPP in HDLC-like
|
||||
framing, with the PPP header following those two bytes, otherwise it's
|
||||
PPP without framing, and the packet begins with the PPP header.
|
||||
.TP 5
|
||||
.BR DLT_FDDI "; " LINKTYPE_FDDI = 10
|
||||
FDDI
|
||||
.TP 5
|
||||
.BR DLT_ATM_RFC1483 "; " LINKTYPE_ATM_RFC1483 = 100
|
||||
RFC 1483 LLC/SNAP-encapsulated ATM; the packet begins with an IEEE 802.2
|
||||
LLC header.
|
||||
.TP 5
|
||||
.BR DLT_RAW "; " LINKTYPE_RAW = 101
|
||||
raw IP; the packet begins with an IP header.
|
||||
.TP 5
|
||||
.BR DLT_PPP_SERIAL "; " LINKTYPE_PPP_HDLC = 50
|
||||
PPP in HDLC-like framing, as per RFC 1662, or Cisco PPP with HDLC
|
||||
framing, as per section 4.3.1 of RFC 1547; the first byte will be 0xFF
|
||||
for PPP in HDLC-like framing, and will be 0x0F or 0x8F for Cisco PPP
|
||||
with HDLC framing.
|
||||
.TP 5
|
||||
.BR DLT_PPP_ETHER "; " LINKTYPE_PPP_ETHER = 51
|
||||
PPPoE; the packet begins with a PPPoE header, as per RFC 2516.
|
||||
.TP 5
|
||||
.BR DLT_C_HDLC "; " LINKTYPE_C_HDLC = 104
|
||||
Cisco PPP with HDLC framing, as per section 4.3.1 of RFC 1547.
|
||||
.TP 5
|
||||
.BR DLT_IEEE802_11 "; " LINKTYPE_IEEE802_11 = 105
|
||||
IEEE 802.11 wireless LAN
|
||||
.TP 5
|
||||
.BR DLT_FRELAY "; " LINKTYPE_FRELAY = 107
|
||||
Frame Relay
|
||||
.TP 5
|
||||
.BR DLT_LOOP "; " LINKTYPE_LOOP = 108
|
||||
OpenBSD loopback encapsulation; the link-layer header is a 4-byte field, in
|
||||
.I network
|
||||
byte order, containing a PF_ value from OpenBSD's
|
||||
.B socket.h
|
||||
for the network-layer protocol of the packet.
|
||||
.IP
|
||||
Note that, if a ``savefile'' is being read, those PF_ values are
|
||||
.I not
|
||||
necessarily those of the machine reading the capture file.
|
||||
.TP 5
|
||||
.BR DLT_LINUX_SLL "; " LINKTYPE_LINUX_SLL = 113
|
||||
Linux "cooked" capture encapsulation; the link-layer header contains, in
|
||||
order:
|
||||
.RS 10
|
||||
.LP
|
||||
a 2-byte "packet type", in network byte order, which is one of:
|
||||
.RS 5
|
||||
.TP 5
|
||||
0
|
||||
packet was sent to us by somebody else
|
||||
.TP 5
|
||||
1
|
||||
packet was broadcast by somebody else
|
||||
.TP 5
|
||||
2
|
||||
packet was multicast, but not broadcast, by somebody else
|
||||
.TP 5
|
||||
3
|
||||
packet was sent by somebody else to somebody else
|
||||
.TP 5
|
||||
4
|
||||
packet was sent by us
|
||||
.RE
|
||||
.LP
|
||||
a 2-byte field, in network byte order, containing a Linux ARPHRD_ value
|
||||
for the link-layer device type;
|
||||
.LP
|
||||
a 2-byte field, in network byte order, containing the length of the
|
||||
link-layer address of the sender of the packet (which could be 0);
|
||||
.LP
|
||||
an 8-byte field containing that number of bytes of the link-layer
|
||||
address of the sender (if there are more than 8 bytes, only the first
|
||||
8 are present, and if there are fewer than 8 bytes, there are padding
|
||||
bytes after the address to pad the field to 8 bytes);
|
||||
.LP
|
||||
a 2-byte field containing an Ethernet protocol type, in network byte
|
||||
order, or containing 1 for Novell 802.3 frames without an 802.2 LLC
|
||||
header or 4 for frames beginning with an 802.2 LLC header.
|
||||
.RE
|
||||
.TP 5
|
||||
.BR DLT_LTALK "; " LINKTYPE_LTALK = 104
|
||||
Apple LocalTalk; the packet begins with an AppleTalk LLAP header.
|
||||
.TP 5
|
||||
.BR DLT_PFLOG "; " LINKTYPE_PFLOG = 117
|
||||
OpenBSD pflog; the link-layer header contains a
|
||||
.B "struct pfloghdr"
|
||||
structure, as defined by the host on which the file was saved. (This
|
||||
differs from operating system to operating system and release to
|
||||
release; there is nothing in the file to indicate what the layout of
|
||||
that structure is.)
|
||||
.TP 5
|
||||
.BR DLT_PRISM_HEADER "; " LINKTYPE_PRISM_HEADER = 119
|
||||
Prism monitor mode information followed by an 802.11 header.
|
||||
.TP 5
|
||||
.BR DLT_IP_OVER_FC "; " LINKTYPE_IP_OVER_FC = 122
|
||||
RFC 2625 IP-over-Fibre Channel, with the link-layer header being the
|
||||
Network_Header as described in that RFC.
|
||||
.TP 5
|
||||
.BR DLT_SUNATM "; " LINKTYPE_SUNATM = 123
|
||||
SunATM devices; the link-layer header contains, in order:
|
||||
.RS 10
|
||||
.LP
|
||||
a 1-byte flag field, containing a direction flag in the uppermost bit,
|
||||
which is set for packets transmitted by the machine and clear for
|
||||
packets received by the machine, and a 4-byte traffic type in the
|
||||
low-order 4 bits, which is one of:
|
||||
.RS 5
|
||||
.TP 5
|
||||
0
|
||||
raw traffic
|
||||
.TP 5
|
||||
1
|
||||
LANE traffic
|
||||
.TP 5
|
||||
2
|
||||
LLC-encapsulated traffic
|
||||
.TP 5
|
||||
3
|
||||
MARS traffic
|
||||
.TP 5
|
||||
4
|
||||
IFMP traffic
|
||||
.TP 5
|
||||
5
|
||||
ILMI traffic
|
||||
.TP 5
|
||||
6
|
||||
Q.2931 traffic
|
||||
.RE
|
||||
.LP
|
||||
a 1-byte VPI value;
|
||||
.LP
|
||||
a 2-byte VCI field, in network byte order.
|
||||
.RE
|
||||
.TP 5
|
||||
.BR DLT_IEEE802_11_RADIO "; " LINKTYPE_IEEE802_11_RADIO = 127
|
||||
link-layer information followed by an 802.11 header - see
|
||||
http://www.shaftnet.org/~pizza/software/capturefrm.txt for a description
|
||||
of the link-layer information.
|
||||
.TP 5
|
||||
.BR DLT_ARCNET_LINUX "; " LINKTYPE_ARCNET_LINUX = 129
|
||||
ARCNET, with no exception frames, reassembled packets rather than raw
|
||||
frames, and an extra 16-bit offset field between the destination host
|
||||
and type bytes.
|
||||
.TP 5
|
||||
.BR DLT_LINUX_IRDA "; " LINKTYPE_LINUX_IRDA = 144
|
||||
Linux-IrDA packets, with a
|
||||
.B DLT_LINUX_SLL
|
||||
header followed by the IrLAP header.
|
||||
.TP 5
|
||||
.BR DLT_LINUX_LAPD "; " LINKTYPE_LINUX_LAPD = 177
|
||||
LAPD (Q.921) frames, with a
|
||||
.B DLT_LINUX_SLL
|
||||
header captured via vISDN.
|
||||
.RE
|
||||
The link-layer header types supported by libpcap are described at
|
||||
http://www.tcpdump.org/linktypes.html.
|
||||
.SH SEE ALSO
|
||||
pcap_datalink(3PCAP)
|
||||
|
||||
1376
libpcap/pcap-linux.c
1376
libpcap/pcap-linux.c
File diff suppressed because it is too large
Load Diff
468
libpcap/pcap-netfilter-linux.c
Normal file
468
libpcap/pcap-netfilter-linux.c
Normal file
@@ -0,0 +1,468 @@
|
||||
/*
|
||||
* Copyright (c) 2011 Jakub Zawadzki
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "pcap-int.h"
|
||||
|
||||
#ifdef NEED_STRERROR_H
|
||||
#include "strerror.h"
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <netinet/in.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
#include <linux/netlink.h>
|
||||
#include <linux/netfilter/nfnetlink.h>
|
||||
#include <linux/netfilter/nfnetlink_log.h>
|
||||
|
||||
#include "pcap-netfilter-linux.h"
|
||||
|
||||
#define HDR_LENGTH (NLMSG_LENGTH(NLMSG_ALIGN(sizeof(struct nfgenmsg))))
|
||||
|
||||
#define NFLOG_IFACE "nflog"
|
||||
|
||||
static int
|
||||
nflog_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_char *user)
|
||||
{
|
||||
const unsigned char *buf;
|
||||
int count = 0;
|
||||
int len;
|
||||
|
||||
/* ignore interrupt system call error */
|
||||
do {
|
||||
len = recv(handle->fd, handle->buffer, handle->bufsize, 0);
|
||||
if (handle->break_loop) {
|
||||
handle->break_loop = 0;
|
||||
return -2;
|
||||
}
|
||||
} while ((len == -1) && (errno == EINTR));
|
||||
|
||||
if (len < 0) {
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't receive packet %d:%s", errno, pcap_strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
buf = handle->buffer;
|
||||
while (len >= NLMSG_SPACE(0)) {
|
||||
const struct nlmsghdr *nlh = (const struct nlmsghdr *) buf;
|
||||
u_int32_t msg_len;
|
||||
|
||||
if (nlh->nlmsg_len < sizeof(struct nlmsghdr) || len < nlh->nlmsg_len) {
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Message truncated: (got: %d) (nlmsg_len: %u)", len, nlh->nlmsg_len);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (NFNL_SUBSYS_ID(nlh->nlmsg_type) == NFNL_SUBSYS_ULOG &&
|
||||
NFNL_MSG_TYPE(nlh->nlmsg_type) == NFULNL_MSG_PACKET)
|
||||
{
|
||||
const unsigned char *payload = NULL;
|
||||
struct pcap_pkthdr pkth;
|
||||
|
||||
if (handle->linktype != DLT_NFLOG) {
|
||||
const struct nfattr *payload_attr = NULL;
|
||||
|
||||
if (nlh->nlmsg_len < HDR_LENGTH) {
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Malformed message: (nlmsg_len: %u)", nlh->nlmsg_len);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (nlh->nlmsg_len > HDR_LENGTH) {
|
||||
struct nfattr *attr = NFM_NFA(NLMSG_DATA(nlh));
|
||||
int attr_len = nlh->nlmsg_len - NLMSG_ALIGN(HDR_LENGTH);
|
||||
|
||||
while (NFA_OK(attr, attr_len)) {
|
||||
switch (NFA_TYPE(attr)) {
|
||||
case NFULA_PAYLOAD:
|
||||
payload_attr = attr;
|
||||
break;
|
||||
}
|
||||
attr = NFA_NEXT(attr, attr_len);
|
||||
}
|
||||
}
|
||||
|
||||
if (payload_attr) {
|
||||
payload = NFA_DATA(payload_attr);
|
||||
pkth.len = pkth.caplen = NFA_PAYLOAD(payload_attr);
|
||||
}
|
||||
|
||||
} else {
|
||||
payload = NLMSG_DATA(nlh);
|
||||
pkth.caplen = pkth.len = nlh->nlmsg_len-NLMSG_ALIGN(sizeof(struct nlmsghdr));
|
||||
}
|
||||
|
||||
if (payload) {
|
||||
/* pkth.caplen = min (payload_len, handle->snapshot); */
|
||||
|
||||
gettimeofday(&pkth.ts, NULL);
|
||||
if (handle->fcode.bf_insns == NULL ||
|
||||
bpf_filter(handle->fcode.bf_insns, payload, pkth.len, pkth.caplen))
|
||||
{
|
||||
handle->md.packets_read++;
|
||||
callback(user, &pkth, payload);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
msg_len = NLMSG_ALIGN(nlh->nlmsg_len);
|
||||
if (msg_len > len)
|
||||
msg_len = len;
|
||||
|
||||
len -= msg_len;
|
||||
buf += msg_len;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
static int
|
||||
netfilter_set_datalink(pcap_t *handle, int dlt)
|
||||
{
|
||||
handle->linktype = dlt;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
netfilter_stats_linux(pcap_t *handle, struct pcap_stat *stats)
|
||||
{
|
||||
stats->ps_recv = handle->md.packets_read;
|
||||
stats->ps_drop = 0;
|
||||
stats->ps_ifdrop = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
netfilter_inject_linux(pcap_t *handle, const void *buf, size_t size)
|
||||
{
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "inject not supported on netfilter devices");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
struct my_nfattr {
|
||||
u_int16_t nfa_len;
|
||||
u_int16_t nfa_type;
|
||||
void *data;
|
||||
};
|
||||
|
||||
static int
|
||||
nflog_send_config_msg(const pcap_t *handle, u_int8_t family, u_int16_t res_id, const struct my_nfattr *mynfa)
|
||||
{
|
||||
char buf[1024] __attribute__ ((aligned));
|
||||
|
||||
struct nlmsghdr *nlh = (struct nlmsghdr *) buf;
|
||||
struct nfgenmsg *nfg = (struct nfgenmsg *) (buf + sizeof(struct nlmsghdr));
|
||||
|
||||
struct sockaddr_nl snl;
|
||||
static unsigned int seq_id;
|
||||
|
||||
if (!seq_id)
|
||||
seq_id = time(NULL);
|
||||
++seq_id;
|
||||
|
||||
nlh->nlmsg_len = NLMSG_LENGTH(sizeof(struct nfgenmsg));
|
||||
nlh->nlmsg_type = (NFNL_SUBSYS_ULOG << 8) | NFULNL_MSG_CONFIG;
|
||||
nlh->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;
|
||||
nlh->nlmsg_pid = 0; /* to kernel */
|
||||
nlh->nlmsg_seq = seq_id;
|
||||
|
||||
nfg->nfgen_family = family;
|
||||
nfg->version = NFNETLINK_V0;
|
||||
nfg->res_id = htons(res_id);
|
||||
|
||||
if (mynfa) {
|
||||
struct nfattr *nfa = (struct nfattr *) (buf + NLMSG_ALIGN(nlh->nlmsg_len));
|
||||
|
||||
nfa->nfa_type = mynfa->nfa_type;
|
||||
nfa->nfa_len = NFA_LENGTH(mynfa->nfa_len);
|
||||
memcpy(NFA_DATA(nfa), mynfa->data, mynfa->nfa_len);
|
||||
nlh->nlmsg_len = NLMSG_ALIGN(nlh->nlmsg_len) + NFA_ALIGN(nfa->nfa_len);
|
||||
}
|
||||
|
||||
memset(&snl, 0, sizeof(snl));
|
||||
snl.nl_family = AF_NETLINK;
|
||||
|
||||
if (sendto(handle->fd, nlh, nlh->nlmsg_len, 0, (struct sockaddr *) &snl, sizeof(snl)) == -1)
|
||||
return -1;
|
||||
|
||||
/* waiting for reply loop */
|
||||
do {
|
||||
socklen_t addrlen = sizeof(snl);
|
||||
int len;
|
||||
|
||||
/* ignore interrupt system call error */
|
||||
do {
|
||||
len = recvfrom(handle->fd, buf, sizeof(buf), 0, (struct sockaddr *) &snl, &addrlen);
|
||||
} while ((len == -1) && (errno == EINTR));
|
||||
|
||||
if (len <= 0)
|
||||
return len;
|
||||
|
||||
if (addrlen != sizeof(snl) || snl.nl_family != AF_NETLINK) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
nlh = (struct nlmsghdr *) buf;
|
||||
if (snl.nl_pid != 0 || seq_id != nlh->nlmsg_seq) /* if not from kernel or wrong sequence skip */
|
||||
continue;
|
||||
|
||||
while (len >= NLMSG_SPACE(0) && NLMSG_OK(nlh, len)) {
|
||||
if (nlh->nlmsg_type == NLMSG_ERROR || (nlh->nlmsg_type == NLMSG_DONE && nlh->nlmsg_flags & NLM_F_MULTI)) {
|
||||
if (nlh->nlmsg_len < NLMSG_ALIGN(sizeof(struct nlmsgerr))) {
|
||||
errno = EBADMSG;
|
||||
return -1;
|
||||
}
|
||||
errno = -(*((int *)NLMSG_DATA(nlh)));
|
||||
return (errno == 0) ? 0 : -1;
|
||||
}
|
||||
nlh = NLMSG_NEXT(nlh, len);
|
||||
}
|
||||
} while (1);
|
||||
|
||||
return -1; /* never here */
|
||||
}
|
||||
|
||||
static int
|
||||
nflog_send_config_cmd(const pcap_t *handle, u_int16_t group_id, u_int8_t cmd, u_int8_t family)
|
||||
{
|
||||
struct nfulnl_msg_config_cmd msg;
|
||||
struct my_nfattr nfa;
|
||||
|
||||
msg.command = cmd;
|
||||
|
||||
nfa.data = &msg;
|
||||
nfa.nfa_type = NFULA_CFG_CMD;
|
||||
nfa.nfa_len = sizeof(msg);
|
||||
|
||||
return nflog_send_config_msg(handle, family, group_id, &nfa);
|
||||
}
|
||||
|
||||
static int
|
||||
nflog_send_config_mode(const pcap_t *handle, u_int16_t group_id, u_int8_t copy_mode, u_int32_t copy_range)
|
||||
{
|
||||
struct nfulnl_msg_config_mode msg;
|
||||
struct my_nfattr nfa;
|
||||
|
||||
msg.copy_range = htonl(copy_range);
|
||||
msg.copy_mode = copy_mode;
|
||||
|
||||
nfa.data = &msg;
|
||||
nfa.nfa_type = NFULA_CFG_MODE;
|
||||
nfa.nfa_len = sizeof(msg);
|
||||
|
||||
return nflog_send_config_msg(handle, AF_UNSPEC, group_id, &nfa);
|
||||
}
|
||||
|
||||
static int
|
||||
nflog_activate(pcap_t* handle)
|
||||
{
|
||||
const char *dev = handle->opt.source;
|
||||
unsigned short groups[32];
|
||||
int group_count = 0;
|
||||
int i;
|
||||
|
||||
if (strncmp(dev, NFLOG_IFACE, strlen(NFLOG_IFACE)) == 0) {
|
||||
dev += strlen(NFLOG_IFACE);
|
||||
|
||||
/* nflog:30,33,42 looks nice, allow it */
|
||||
if (*dev == ':')
|
||||
dev++;
|
||||
|
||||
while (*dev) {
|
||||
long int group_id;
|
||||
char *end_dev;
|
||||
|
||||
if (group_count == 32) {
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Maximum 32 netfilter groups! dev: %s",
|
||||
handle->opt.source);
|
||||
return PCAP_ERROR;
|
||||
}
|
||||
|
||||
group_id = strtol(dev, &end_dev, 0);
|
||||
if (end_dev != dev) {
|
||||
if (group_id < 0 || group_id > 65535) {
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Netfilter group range from 0 to 65535 (got %ld)",
|
||||
group_id);
|
||||
return PCAP_ERROR;
|
||||
}
|
||||
|
||||
groups[group_count++] = (unsigned short) group_id;
|
||||
dev = end_dev;
|
||||
}
|
||||
if (*dev != ',')
|
||||
break;
|
||||
dev++;
|
||||
}
|
||||
}
|
||||
|
||||
if (*dev) {
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Can't get netfilter group(s) index from %s",
|
||||
handle->opt.source);
|
||||
return PCAP_ERROR;
|
||||
}
|
||||
|
||||
/* if no groups, add default: 0 */
|
||||
if (!group_count) {
|
||||
groups[0] = 0;
|
||||
group_count = 1;
|
||||
}
|
||||
|
||||
/* Initialize some components of the pcap structure. */
|
||||
handle->bufsize = 128 + handle->snapshot;
|
||||
handle->offset = 0;
|
||||
handle->linktype = DLT_NFLOG;
|
||||
handle->read_op = nflog_read_linux;
|
||||
handle->inject_op = netfilter_inject_linux;
|
||||
handle->setfilter_op = install_bpf_program; /* no kernel filtering */
|
||||
handle->setdirection_op = NULL;
|
||||
handle->set_datalink_op = NULL;
|
||||
handle->set_datalink_op = netfilter_set_datalink;
|
||||
handle->getnonblock_op = pcap_getnonblock_fd;
|
||||
handle->setnonblock_op = pcap_setnonblock_fd;
|
||||
handle->stats_op = netfilter_stats_linux;
|
||||
|
||||
/* Create netlink socket */
|
||||
handle->fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_NETFILTER);
|
||||
if (handle->fd < 0) {
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't create raw socket %d:%s", errno, pcap_strerror(errno));
|
||||
return PCAP_ERROR;
|
||||
}
|
||||
|
||||
handle->dlt_list = (u_int *) malloc(sizeof(u_int) * 2);
|
||||
if (handle->dlt_list != NULL) {
|
||||
handle->dlt_list[0] = DLT_NFLOG;
|
||||
handle->dlt_list[1] = DLT_IPV4;
|
||||
handle->dlt_count = 2;
|
||||
}
|
||||
|
||||
handle->buffer = malloc(handle->bufsize);
|
||||
if (!handle->buffer) {
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't allocate dump buffer: %s", pcap_strerror(errno));
|
||||
goto close_fail;
|
||||
}
|
||||
|
||||
if (nflog_send_config_cmd(handle, 0, NFULNL_CFG_CMD_PF_UNBIND, AF_INET) < 0) {
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "NFULNL_CFG_CMD_PF_UNBIND: %s", pcap_strerror(errno));
|
||||
goto close_fail;
|
||||
}
|
||||
|
||||
if (nflog_send_config_cmd(handle, 0, NFULNL_CFG_CMD_PF_BIND, AF_INET) < 0) {
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "NFULNL_CFG_CMD_PF_BIND: %s", pcap_strerror(errno));
|
||||
goto close_fail;
|
||||
}
|
||||
|
||||
/* Bind socket to the nflog groups */
|
||||
for (i = 0; i < group_count; i++) {
|
||||
if (nflog_send_config_cmd(handle, groups[i], NFULNL_CFG_CMD_BIND, AF_UNSPEC) < 0) {
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't listen on group group index: %s", pcap_strerror(errno));
|
||||
goto close_fail;
|
||||
}
|
||||
|
||||
if (nflog_send_config_mode(handle, groups[i], NFULNL_COPY_PACKET, handle->snapshot) < 0) {
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "NFULNL_COPY_PACKET: %s", pcap_strerror(errno));
|
||||
goto close_fail;
|
||||
}
|
||||
}
|
||||
|
||||
if (handle->opt.rfmon) {
|
||||
/*
|
||||
* Monitor mode doesn't apply to netfilter devices.
|
||||
*/
|
||||
pcap_cleanup_live_common(handle);
|
||||
return PCAP_ERROR_RFMON_NOTSUP;
|
||||
}
|
||||
|
||||
if (handle->opt.buffer_size != 0) {
|
||||
/*
|
||||
* Set the socket buffer size to the specified value.
|
||||
*/
|
||||
if (setsockopt(handle->fd, SOL_SOCKET, SO_RCVBUF, &handle->opt.buffer_size, sizeof(handle->opt.buffer_size)) == -1) {
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "SO_RCVBUF: %s", pcap_strerror(errno));
|
||||
goto close_fail;
|
||||
}
|
||||
}
|
||||
|
||||
handle->selectable_fd = handle->fd;
|
||||
return 0;
|
||||
|
||||
close_fail:
|
||||
pcap_cleanup_live_common(handle);
|
||||
return PCAP_ERROR;
|
||||
}
|
||||
|
||||
pcap_t *
|
||||
nflog_create(const char *device, char *ebuf)
|
||||
{
|
||||
pcap_t *p;
|
||||
|
||||
p = pcap_create_common(device, ebuf);
|
||||
if (p == NULL)
|
||||
return (NULL);
|
||||
|
||||
p->activate_op = nflog_activate;
|
||||
return (p);
|
||||
}
|
||||
|
||||
int
|
||||
netfilter_platform_finddevs(pcap_if_t **alldevsp, char *err_str)
|
||||
{
|
||||
pcap_if_t *found_dev = *alldevsp;
|
||||
int sock;
|
||||
|
||||
sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_NETFILTER);
|
||||
if (sock < 0) {
|
||||
/* if netlink is not supported this this is not fatal */
|
||||
if (errno == EAFNOSUPPORT)
|
||||
return 0;
|
||||
snprintf(err_str, PCAP_ERRBUF_SIZE, "Can't open netlink socket %d:%s",
|
||||
errno, pcap_strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
close(sock);
|
||||
|
||||
if (pcap_add_if(&found_dev, NFLOG_IFACE, 0, "Linux netfilter log (NFLOG) interface", err_str) < 0)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
35
libpcap/pcap-netfilter-linux.h
Normal file
35
libpcap/pcap-netfilter-linux.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2011 Jakub Zawadzki
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Prototypes for netlink-related functions
|
||||
*/
|
||||
int netfilter_platform_finddevs(pcap_if_t **alldevsp, char *err_str);
|
||||
pcap_t *nflog_create(const char *device, char *ebuf);
|
||||
@@ -33,13 +33,6 @@
|
||||
#ifndef pcap_stdinc_h
|
||||
#define pcap_stdinc_h
|
||||
|
||||
#define SIZEOF_CHAR 1
|
||||
#define SIZEOF_SHORT 2
|
||||
#define SIZEOF_INT 4
|
||||
#ifndef _MSC_EXTENSIONS
|
||||
#define SIZEOF_LONG_LONG 8
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Avoids a compiler warning in case this was already defined
|
||||
* (someone defined _WINSOCKAPI_ when including 'windows.h', in order
|
||||
|
||||
132
libpcap/pcap-tstamp.manmisc.in
Normal file
132
libpcap/pcap-tstamp.manmisc.in
Normal file
@@ -0,0 +1,132 @@
|
||||
.\"
|
||||
.\" Copyright (c) 1987, 1988, 1989, 1990, 1991, 1992, 1994, 1995, 1996, 1997
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that: (1) source code distributions
|
||||
.\" retain the above copyright notice and this paragraph in its entirety, (2)
|
||||
.\" distributions including binary code include the above copyright notice and
|
||||
.\" this paragraph in its entirety in the documentation or other materials
|
||||
.\" provided with the distribution, and (3) all advertising materials mentioning
|
||||
.\" features or use of this software display the following acknowledgement:
|
||||
.\" ``This product includes software developed by the University of California,
|
||||
.\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
|
||||
.\" the University nor the names of its contributors may be used to endorse
|
||||
.\" or promote products derived from this software without specific prior
|
||||
.\" written permission.
|
||||
.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
.\"
|
||||
.TH PCAP-TSTAMP @MAN_MISC_INFO@ "22 August 2010"
|
||||
.SH NAME
|
||||
pcap-tstamp \- packet time stamps in libpcap
|
||||
.SH DESCRIPTION
|
||||
When capturing traffic, each packet is given a time stamp representing,
|
||||
for incoming packets, the arrival time of the packet and, for outgoing
|
||||
packets, the transmission time of the packet. This time is an
|
||||
approximation of the arrival or transmission time. If it is supplied by
|
||||
the operating system running on the host on which the capture is being
|
||||
done, there are several reasons why it might not precisely represent the
|
||||
arrival or transmission time:
|
||||
.IP
|
||||
if the time stamp is applied to the packet when the networking stack
|
||||
receives the packet, the networking stack might not see the packet until
|
||||
an interrupt is delivered for the packet or a timer event causes the
|
||||
networking device driver to poll for packets, and the time stamp might
|
||||
not be applied until the packet has had some processing done by other
|
||||
code in the networking stack, so there might be a significant delay
|
||||
between the time when the last bit of the packet is received by the
|
||||
capture device and when the networking stack time-stamps the packet;
|
||||
.IP
|
||||
the timer used to generate the time stamps might have low resolution,
|
||||
for example, it might be a timer updated once per host operating system
|
||||
timer tick, with the host operating system timer ticking once every few
|
||||
milliseconds;
|
||||
.IP
|
||||
a high-resolution timer might use a counter that runs at a rate
|
||||
dependent on the processor clock speed, and that clock speed might be
|
||||
adjusted upwards or downwards over time and the timer might not be able
|
||||
to compensate for all those adjustments;
|
||||
.IP
|
||||
the host operating system's clock might be adjusted over time to match a
|
||||
time standard to which the host is being synchronized, which might be
|
||||
done by temporarily slowing down or speeding up the clock or by making a
|
||||
single adjustment;
|
||||
.IP
|
||||
different CPU cores on a multi-core or multi-processor system might be
|
||||
running at different speeds, or might not have time counters all
|
||||
synchronized, so packets time-stamped by different cores might not have
|
||||
consistent time stamps.
|
||||
.LP
|
||||
In addition, packets time-stamped by different cores might be
|
||||
time-stamped in one order and added to the queue of packets for libpcap
|
||||
to read in another order, so time stamps might not be monotonically
|
||||
increasing.
|
||||
.LP
|
||||
Some capture devices on some platforms can provide time stamps for
|
||||
packets; those time stamps are usually high-resolution time stamps, and
|
||||
are usually applied to the packet when the first or last bit of the
|
||||
packet arrives, and are thus more accurate than time stamps provided by
|
||||
the host operating system. Those time stamps might not, however, be
|
||||
synchronized with the host operating system's clock, so that, for
|
||||
example, the time stamp of a packet might not correspond to the time
|
||||
stamp of an event on the host triggered by the arrival of that packet.
|
||||
.LP
|
||||
Depending on the capture device and the software on the host, libpcap
|
||||
might allow different types of time stamp to be used. The
|
||||
.BR pcap_list_tstamp_types (3PCAP)
|
||||
routine provides, for a packet capture handle created by
|
||||
.BR pcap_create (3PCAP)
|
||||
but not yet activated by
|
||||
.BR pcap_activate (3PCAP),
|
||||
a list of time stamp types supported by the capture device for that
|
||||
handle.
|
||||
The list might be empty, in which case no choice of time stamp type is
|
||||
offered for that capture device. If the list is not empty, the
|
||||
.BR pcap_set_tstamp_type (3PCAP)
|
||||
routine can be used after a
|
||||
.B pcap_create()
|
||||
call and before a
|
||||
.B pcap_activate()
|
||||
call to specify the type of time stamp to be used on the device.
|
||||
The time stamp types are listed here; the first value is the #define to
|
||||
use in code, the second value is the value returned by
|
||||
.B pcap_tstamp_type_val_to_name()
|
||||
and accepted by
|
||||
.BR pcap_tstamp_name_to_val() .
|
||||
.RS 5
|
||||
.TP 5
|
||||
.BR PCAP_TSTAMP_HOST " - " host
|
||||
Time stamp provided by the host on which the capture is being done. The
|
||||
precision of this time stamp is unspecified; it might or might not be
|
||||
synchronized with the host operating system's clock.
|
||||
.TP 5
|
||||
.BR PCAP_TSTAMP_HOST_LOWPREC " - " host_lowprec
|
||||
Time stamp provided by the host on which the capture is being done.
|
||||
This is a low-precision time stamp, synchronized with the host operating
|
||||
system's clock.
|
||||
.TP 5
|
||||
.BR PCAP_TSTAMP_HOST_HIPREC " - " host_hiprec
|
||||
Time stamp provided by the host on which the capture is being done.
|
||||
This is a high-precision time stamp; it might or might not be
|
||||
synchronized with the host operating system's clock. It might be more
|
||||
expensive to fetch than
|
||||
.BR PCAP_TSTAMP_HOST_LOWPREC .
|
||||
.TP 5
|
||||
.BR PCAP_TSTAMP_ADAPTER " - " adapter
|
||||
Time stamp provided by the network adapter on which the capture is being
|
||||
done. This is a high-precision time stamp, synchronized with the host
|
||||
operating system's clock.
|
||||
.TP 5
|
||||
.BR PCAP_TSTAMP_ADAPTER_UNSYNCED " - " adapter_unsynced
|
||||
Time stamp provided by the network adapter on which the capture is being
|
||||
done. This is a high-precision time stamp; it is not synchronized with
|
||||
the host operating system's clock.
|
||||
.RE
|
||||
.SH SEE ALSO
|
||||
pcap_set_tstamp_type(3PCAP),
|
||||
pcap_list_tstamp_types(3PCAP),
|
||||
pcap_tstamp_type_val_to_name(3PCAP),
|
||||
pcap_tstamp_name_to_val(3PCAP)
|
||||
@@ -39,7 +39,12 @@ static const char rcsid[] _U_ =
|
||||
#include <pcap-int.h>
|
||||
#include <Packet32.h>
|
||||
#ifdef __MINGW32__
|
||||
#ifdef __MINGW64__
|
||||
#include <ntddndis.h>
|
||||
#else /*__MINGW64__*/
|
||||
#include <ddk/ntddndis.h>
|
||||
#include <ddk/ndis.h>
|
||||
#endif /*__MINGW64__*/
|
||||
#else /*__MINGW32__*/
|
||||
#include <ntddndis.h>
|
||||
#endif /*__MINGW32__*/
|
||||
@@ -232,7 +237,7 @@ pcap_read_win32_npf(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
|
||||
* XXX A bpf_hdr matches a pcap_pkthdr.
|
||||
*/
|
||||
(*callback)(user, (struct pcap_pkthdr*)bp, bp + hdrlen);
|
||||
bp += BPF_WORDALIGN(caplen + hdrlen);
|
||||
bp += Packet_WORDALIGN(caplen + hdrlen);
|
||||
if (++n >= cnt && cnt > 0) {
|
||||
p->bp = bp;
|
||||
p->cc = ep - bp;
|
||||
|
||||
@@ -37,22 +37,51 @@ on the network, even those destined for other hosts, are accessible
|
||||
through this mechanism.
|
||||
It also supports saving captured packets to a ``savefile'', and reading
|
||||
packets from a ``savefile''.
|
||||
.PP
|
||||
To open a handle for a live capture, call
|
||||
.BR pcap_create() ,
|
||||
.SS Opening a capture handle for reading
|
||||
To open a handle for a live capture, given the name of the network or
|
||||
other interface on which the capture should be done, call
|
||||
.BR pcap_create (),
|
||||
set the appropriate options on the handle, and then activate it with
|
||||
.BR pcap_activate() .
|
||||
To open a handle for a ``savefile'' with captured packets, call
|
||||
.BR pcap_open_offline() .
|
||||
Both
|
||||
.B pcap_create()
|
||||
.BR pcap_activate ().
|
||||
.PP
|
||||
To obtain a list of devices that can be opened for a live capture, call
|
||||
.BR pcap_findalldevs ();
|
||||
to free the list returned by
|
||||
.BR pcap_findalldevs (),
|
||||
call
|
||||
.BR pcap_freealldevs ().
|
||||
.BR pcap_lookupdev ()
|
||||
will return the first device on that list that is not a ``loopback``
|
||||
network interface.
|
||||
.PP
|
||||
To open a handle for a ``savefile'' from which to read packets, given the
|
||||
pathname of the ``savefile'', call
|
||||
.BR pcap_open_offline ();
|
||||
to set up a handle for a ``savefile'', given a
|
||||
.B "FILE\ *"
|
||||
referring to a file already opened for reading, call
|
||||
.BR pcap_fopen_offline ().
|
||||
.PP
|
||||
In order to get a ``fake''
|
||||
.B pcap_t
|
||||
for use in routines that require a
|
||||
.B pcap_t
|
||||
as an argument, such as routines to open a ``savefile'' for writing and
|
||||
to compile a filter expression, call
|
||||
.BR pcap_open_dead ().
|
||||
.PP
|
||||
.BR pcap_create (),
|
||||
.BR pcap_open_offline (),
|
||||
.BR pcap_fopen_offline (),
|
||||
and
|
||||
.B pcap_open_offline()
|
||||
.BR pcap_open_dead ()
|
||||
return a pointer to a
|
||||
.BR pcap_t ,
|
||||
which is the handle used for reading packets from the capture stream or
|
||||
the ``savefile'', and for finding out information about the capture
|
||||
stream or ``savefile''.
|
||||
To close a handle, use
|
||||
.BR pcap_close ().
|
||||
.PP
|
||||
The options that can be set on a capture handle include
|
||||
.IP "snapshot length"
|
||||
@@ -75,7 +104,7 @@ A snapshot length of 65535 should be sufficient, on most if not all
|
||||
networks, to capture all the data available from the packet.
|
||||
.IP
|
||||
The snapshot length is set with
|
||||
.BR pcap_set_snaplen() .
|
||||
.BR pcap_set_snaplen ().
|
||||
.IP "promiscuous mode"
|
||||
On broadcast LANs such as Ethernet, if the network isn't switched, or if
|
||||
the adapter is connected to a "mirror port" on a switch to which all
|
||||
@@ -97,7 +126,7 @@ For now, this doesn't work on the "any" device; if an argument of "any"
|
||||
or NULL is supplied, the setting of promiscuous mode is ignored.
|
||||
.IP
|
||||
Promiscuous mode is set with
|
||||
.BR pcap_set_promisc() .
|
||||
.BR pcap_set_promisc ().
|
||||
.IP "monitor mode"
|
||||
On IEEE 802.11 wireless LANs, even if an adapter is in promiscuous mode,
|
||||
it will supply to the host only frames for the network with which it's
|
||||
@@ -118,9 +147,9 @@ if you are capturing in monitor mode and are not connected to another
|
||||
network with another adapter.
|
||||
.IP
|
||||
Monitor mode is set with
|
||||
.BR pcap_set_rfmon() ,
|
||||
.BR pcap_set_rfmon (),
|
||||
and
|
||||
.B pcap_can_set_rfmon()
|
||||
.BR pcap_can_set_rfmon ()
|
||||
can be used to determine whether an adapter can be put into monitor
|
||||
mode.
|
||||
.IP "read timeout"
|
||||
@@ -162,7 +191,7 @@ guarantee that a call reading packets will return after the timeout
|
||||
expires even if no packets have arrived.
|
||||
.IP
|
||||
The read timeout is set with
|
||||
.BR pcap_set_timeout() .
|
||||
.BR pcap_set_timeout ().
|
||||
.IP "buffer size"
|
||||
Packets that arrive for a capture are stored in a buffer, so that they
|
||||
do not have to be read by the application as soon as they arrive. On
|
||||
@@ -175,7 +204,17 @@ non-pageable operating system memory than is necessary to prevent
|
||||
packets from being dropped.
|
||||
.IP
|
||||
The buffer size is set with
|
||||
.BR pcap_set_buffer_size() .
|
||||
.BR pcap_set_buffer_size ().
|
||||
.IP "timestamp type"
|
||||
On some platforms, the time stamp given to packets on live captures can
|
||||
come from different sources that can have different resolutions or that
|
||||
can have different relationships to the time values for the current time
|
||||
supplied by routines on the native operating system. See
|
||||
.BR pcap-tstamp (@MAN_MISC_INFO@)
|
||||
for a list of time stamp types.
|
||||
.IP
|
||||
The time stamp type is set with
|
||||
.BR pcap_set_tstamp_type ().
|
||||
.PP
|
||||
Reading packets from a network interface may require that you have
|
||||
special privileges:
|
||||
@@ -260,26 +299,193 @@ have to find some other way to make that happen at boot time.
|
||||
.PP
|
||||
Reading a saved packet file doesn't require special privileges.
|
||||
.PP
|
||||
To open a ``savefile`` to which to write packets, call
|
||||
.BR pcap_dump_open() .
|
||||
It returns a pointer to a
|
||||
.BR pcap_dumper_t ,
|
||||
which is the handle used for writing packets to the ``savefile''.
|
||||
The packets read from the handle may include a ``pseudo-header''
|
||||
containing various forms of packet meta-data, and probably includes a
|
||||
link-layer header whose contents can differ for different network
|
||||
interfaces. To determine the format of the packets supplied by the
|
||||
handle, call
|
||||
.BR pcap_datalink ();
|
||||
.I http://www.tcpdump.org/linktypes.html
|
||||
lists the values it returns and describes the packet formats that
|
||||
correspond to those values.
|
||||
.PP
|
||||
To obtain the
|
||||
.B "FILE\ *"
|
||||
corresponding to a
|
||||
.B pcap_t
|
||||
opened for a ``savefile'', call
|
||||
.BR pcap_file ().
|
||||
.TP
|
||||
.B Routines
|
||||
.RS
|
||||
.TP
|
||||
.BR pcap_create (3PCAP)
|
||||
get a
|
||||
.B pcap_t
|
||||
for live capture
|
||||
.TP
|
||||
.BR pcap_activate (3PCAP)
|
||||
activate a
|
||||
.B pcap_t
|
||||
for live capture
|
||||
.TP
|
||||
.BR pcap_findalldevs (3PCAP)
|
||||
get a list of devices that can be opened for a live capture
|
||||
.TP
|
||||
.BR pcap_freealldevs (3PCAP)
|
||||
free list of devices
|
||||
.TP
|
||||
.BR pcap_lookupdev (3PCAP)
|
||||
get first non-loopback device on that list
|
||||
.TP
|
||||
.BR pcap_open_offline (3PCAP)
|
||||
open a
|
||||
.B pcap_t
|
||||
for a ``savefile'', given a pathname
|
||||
.TP
|
||||
.BR pcap_fopen_offline (3PCAP)
|
||||
open a
|
||||
.B pcap_t
|
||||
for a ``savefile'', given a
|
||||
.B "FILE\ *"
|
||||
.TP
|
||||
.BR pcap_open_dead (3PCAP)
|
||||
create a ``fake''
|
||||
.B pcap_t
|
||||
.TP
|
||||
.BR pcap_close (3PCAP)
|
||||
close a
|
||||
.B pcap_t
|
||||
.TP
|
||||
.BR pcap_set_snaplen (3PCAP)
|
||||
set the snapshot length for a not-yet-activated
|
||||
.B pcap_t
|
||||
for live capture
|
||||
.TP
|
||||
.BR pcap_snapshot (3PCAP)
|
||||
get the snapshot length for a
|
||||
.B pcap_t
|
||||
.TP
|
||||
.BR pcap_set_promisc (3PCAP)
|
||||
set promiscuous mode for a not-yet-activated
|
||||
.B pcap_t
|
||||
for live capture
|
||||
.TP
|
||||
.BR pcap_set_rfmon (3PCAP)
|
||||
set monitor mode for a not-yet-activated
|
||||
.B pcap_t
|
||||
for live capture
|
||||
.TP
|
||||
.BR pcap_can_set_rfmon (3PCAP)
|
||||
determine whether monitor mode can be set for a
|
||||
.B pcap_t
|
||||
for live capture
|
||||
.TP
|
||||
.BR pcap_set_timeout (3PCAP)
|
||||
set read timeout for a not-yet-activated
|
||||
.B pcap_t
|
||||
for live capture
|
||||
.TP
|
||||
.BR pcap_set_buffer_size (3PCAP)
|
||||
set buffer size for a not-yet-activated
|
||||
.B pcap_t
|
||||
for live capture
|
||||
.TP
|
||||
.BR pcap_set_tstamp_type (3PCAP)
|
||||
set time stamp type for a not-yet-activated
|
||||
.B pcap_t
|
||||
for live capture
|
||||
.TP
|
||||
.BR pcap_list_tstamp_types (3PCAP)
|
||||
get list of available time stamp types for a not-yet-activated
|
||||
.B pcap_t
|
||||
for live capture
|
||||
.TP
|
||||
.BR pcap_free_tstamp_types (3PCAP)
|
||||
free list of available time stamp types
|
||||
.TP
|
||||
.BR pcap_tstamp_type_val_to_name (3PCAP)
|
||||
get name for a time stamp type
|
||||
.TP
|
||||
.BR pcap_tstamp_type_val_to_description (3PCAP)
|
||||
get description for a time stamp type
|
||||
.TP
|
||||
.BR pcap_tstamp_name_to_val (3PCAP)
|
||||
get time stamp type corresponding to a name
|
||||
.TP
|
||||
.BR pcap_datalink (3PCAP)
|
||||
get link-layer header type for a
|
||||
.B pcap_t
|
||||
.TP
|
||||
.BR pcap_file (3PCAP)
|
||||
get the
|
||||
.B "FILE\ *"
|
||||
for a
|
||||
.B pcap_t
|
||||
opened for a ``savefile''
|
||||
.TP
|
||||
.BR pcap_is_swapped (3PCAP)
|
||||
determine whether a ``savefile'' being read came from a machine with the
|
||||
opposite byte order
|
||||
.TP
|
||||
.BR pcap_major_version (3PCAP)
|
||||
.PD 0
|
||||
.TP
|
||||
.BR pcap_minor_version (3PCAP)
|
||||
get the major and minor version of the file format version for a
|
||||
``savefile''
|
||||
.PD
|
||||
.RE
|
||||
.SS Selecting a link-layer header type for a live capture
|
||||
Some devices may provide more than one link-layer header type. To
|
||||
obtain a list of all link-layer header types provided by a device, call
|
||||
.BR pcap_list_datalinks ()
|
||||
on an activated
|
||||
.B pcap_t
|
||||
for the device.
|
||||
To free a list of link-layer header types, call
|
||||
.BR pcap_free_datalinks ().
|
||||
To set the link-layer header type for a device, call
|
||||
.BR pcap_set_datalink ().
|
||||
This should be done after the device has been activated but before any
|
||||
packets are read and before any filters are compiled or installed.
|
||||
.TP
|
||||
.B Routines
|
||||
.RS
|
||||
.TP
|
||||
.BR pcap_list_datalinks (3PCAP)
|
||||
get a list of link-layer header types for a device
|
||||
.TP
|
||||
.BR pcap_free_datalinks (3PCAP)
|
||||
free list of link-layer header types
|
||||
.TP
|
||||
.BR pcap_set_datalink (3PCAP)
|
||||
set link-layer header type for a device
|
||||
.TP
|
||||
.BR pcap_datalink_val_to_name (3PCAP)
|
||||
get name for a link-layer header type
|
||||
.TP
|
||||
.BR pcap_datalink_val_to_description (3PCAP)
|
||||
get description for a link-layer header type
|
||||
.TP
|
||||
.BR pcap_datalink_name_to_val (3PCAP)
|
||||
get link-layer header type corresponding to a name
|
||||
.RE
|
||||
.SS Reading packets
|
||||
Packets are read with
|
||||
.B pcap_dispatch()
|
||||
.BR pcap_dispatch ()
|
||||
or
|
||||
.BR pcap_loop() ,
|
||||
.BR pcap_loop (),
|
||||
which process one or more packets, calling a callback routine for each
|
||||
packet, or with
|
||||
.B pcap_next()
|
||||
.BR pcap_next ()
|
||||
or
|
||||
.BR pcap_next_ex() ,
|
||||
.BR pcap_next_ex (),
|
||||
which return the next packet.
|
||||
The callback for
|
||||
.B pcap_dispatch()
|
||||
.BR pcap_dispatch ()
|
||||
and
|
||||
.BR pcap_loop()
|
||||
.BR pcap_loop ()
|
||||
is supplied a pointer to a
|
||||
.IR "struct pcap_pkthdr" ,
|
||||
which includes the following members:
|
||||
@@ -304,9 +510,9 @@ number of bytes available from the capture, if the length of the packet
|
||||
is larger than the maximum number of bytes to capture).
|
||||
.RE
|
||||
.PP
|
||||
.B pcap_next_ex()
|
||||
.BR pcap_next_ex ()
|
||||
supplies that pointer through a pointer argument.
|
||||
.B pcap_next()
|
||||
.BR pcap_next ()
|
||||
is passed an argument that points to a
|
||||
.I struct pcap_pkthdr
|
||||
structure, and fills it in.
|
||||
@@ -323,15 +529,306 @@ packet; to capture the entire packet, you will have to provide a value
|
||||
for
|
||||
.I snaplen
|
||||
in your call to
|
||||
.B pcap_open_live()
|
||||
.BR pcap_set_snaplen ()
|
||||
that is sufficiently large to get all of the packet's data - a value of
|
||||
65535 should be sufficient on most if not all networks). When reading
|
||||
from a ``savefile'', the snapshot length specified when the capture was
|
||||
performed will limit the amount of packet data available.
|
||||
.B pcap_next()
|
||||
.BR pcap_next ()
|
||||
returns that pointer;
|
||||
.B pcap_next_ex()
|
||||
.BR pcap_next_ex ()
|
||||
supplies that pointer through a pointer argument.
|
||||
.PP
|
||||
To force the loop in
|
||||
.BR pcap_dispatch ()
|
||||
or
|
||||
.BR pcap_loop ()
|
||||
to terminate, call
|
||||
.BR pcap_breakloop ().
|
||||
.PP
|
||||
By default, when reading packets from an interface opened for a live
|
||||
capture,
|
||||
.BR pcap_dispatch (),
|
||||
.BR pcap_next (),
|
||||
and
|
||||
.BR pcap_next_ex ()
|
||||
will, if no packets are currently available to be read, block waiting
|
||||
for packets to become available. On some, but
|
||||
.I not
|
||||
all, platforms, if a read timeout was specified, the wait will terminate
|
||||
after the read timeout expires; applications should be prepared for
|
||||
this, as it happens on some platforms, but should not rely on it, as it
|
||||
does not happen on other platforms.
|
||||
.PP
|
||||
A handle can be put into ``non-blocking mode'', so that those routines
|
||||
will, rather than blocking, return an indication that no packets are
|
||||
available to read. Call
|
||||
.BR pcap_setnonblock ()
|
||||
to put a handle into non-blocking mode or to take it out of non-blocking
|
||||
mode; call
|
||||
.BR pcap_getnonblock ()
|
||||
to determine whether a handle is in non-blocking mode. Note that
|
||||
non-blocking mode does not work correctly in Mac OS X 10.6.
|
||||
.PP
|
||||
Non-blocking mode is often combined with routines such as
|
||||
.BR select (2)
|
||||
or
|
||||
.BR poll (2)
|
||||
or other routines a platform offers to wait for the availability of data
|
||||
on any of a set of descriptors. To obtain, for a handle, a descriptor
|
||||
that can be used in those routines, call
|
||||
.BR pcap_get_selectable_fd ().
|
||||
Not all handles have such a descriptor available;
|
||||
.BR pcap_get_selectable_fd ()
|
||||
will return \-1 if no such descriptor exists. In addition, for various
|
||||
reasons, one or more of those routines will not work properly with the
|
||||
descriptor; the documentation for
|
||||
.BR pcap_get_selectable_fd ()
|
||||
gives details.
|
||||
.TP
|
||||
.B Routines
|
||||
.RS
|
||||
.TP
|
||||
.BR pcap_dispatch (3PCAP)
|
||||
read a bufferful of packets from a
|
||||
.B pcap_t
|
||||
open for a live capture or the full set of packets from a
|
||||
.B pcap_t
|
||||
open for a ``savefile''
|
||||
.TP
|
||||
.BR pcap_loop (3PCAP)
|
||||
read packets from a
|
||||
.B pcap_t
|
||||
until an interrupt or error occurs
|
||||
.TP
|
||||
.BR pcap_next (3PCAP)
|
||||
read the next packet from a
|
||||
.B pcap_t
|
||||
without an indication whether an error occurred
|
||||
.TP
|
||||
.BR pcap_next_ex (3PCAP)
|
||||
read the next packet from a
|
||||
.B pcap_t
|
||||
with an error indication on an error
|
||||
.TP
|
||||
.BR pcap_breakloop (3PCAP)
|
||||
prematurely terminate the loop in
|
||||
.BR pcap_dispatch ()
|
||||
or
|
||||
.BR pcap_loop ()
|
||||
.TP
|
||||
.BR pcap_setnonblock (3PCAP)
|
||||
set or clear non-blocking mode on a
|
||||
.B pcap_t
|
||||
.TP
|
||||
.BR pcap_getnonblock (3PCAP)
|
||||
get the state of non-blocking mode for a
|
||||
.B pcap_t
|
||||
.TP
|
||||
.BR pcap_get_selectable_fd (3PCAP)
|
||||
attempt to get a descriptor for a
|
||||
.B pcap_t
|
||||
that can be used in calls such as
|
||||
.BR select (2)
|
||||
and
|
||||
.BR poll (2)
|
||||
.RE
|
||||
.SS Filters
|
||||
In order to cause only certain packets to be returned when reading
|
||||
packets, a filter can be set on a handle. For a live capture, the
|
||||
filtering will be performed in kernel mode, if possible, to avoid
|
||||
copying ``uninteresting'' packets from the kernel to user mode.
|
||||
.PP
|
||||
A filter can be specified as a text string; the syntax and semantics of
|
||||
the string are as described by
|
||||
.BR pcap-filter (@MAN_MISC_INFO@).
|
||||
A filter string is compiled into a program in a pseudo-machine-language
|
||||
by
|
||||
.BR pcap_compile ()
|
||||
and the resulting program can be made a filter for a handle with
|
||||
.BR pcap_setfilter ().
|
||||
The result of
|
||||
.BR pcap_compile ()
|
||||
can be freed with a call to
|
||||
.BR pcap_freecode ().
|
||||
.BR pcap_compile ()
|
||||
may require a network mask for certain expressions in the filter string;
|
||||
.BR pcap_lookupnet ()
|
||||
can be used to find the network address and network mask for a given
|
||||
capture device.
|
||||
.PP
|
||||
A compiled filter can also be applied directly to a packet that has been
|
||||
read using
|
||||
.BR pcap_offline_filter ().
|
||||
.TP
|
||||
.B Routines
|
||||
.RS
|
||||
.TP
|
||||
.BR pcap_compile (3PCAP)
|
||||
compile filter expression to a pseudo-machine-language code program
|
||||
.TP
|
||||
.BR pcap_freecode (3PCAP)
|
||||
free a filter program
|
||||
.TP
|
||||
.BR pcap_setfilter (3PCAP)
|
||||
set filter for a
|
||||
.B pcap_t
|
||||
.TP
|
||||
.BR pcap_lookupnet (3PCAP)
|
||||
get network address and network mask for a capture device
|
||||
.TP
|
||||
.BR pcap_offline_filter (3PCAP)
|
||||
apply a filter program to a packet
|
||||
.RE
|
||||
.SS Incoming and outgoing packets
|
||||
By default, libpcap will attempt to capture both packets sent by the
|
||||
machine and packets received by the machine. To limit it to capturing
|
||||
only packets received by the machine or, if possible, only packets sent
|
||||
by the machine, call
|
||||
.BR pcap_setdirection ().
|
||||
.TP
|
||||
.BR Routines
|
||||
.RS
|
||||
.TP
|
||||
.BR pcap_setdirection (3PCAP)
|
||||
specify whether to capture incoming packets, outgoing packets, or both
|
||||
.RE
|
||||
.SS Capture statistics
|
||||
To get statistics about packets received and dropped in a live capture,
|
||||
call
|
||||
.BR pcap_stats ().
|
||||
.TP
|
||||
.B Routines
|
||||
.RS
|
||||
.TP
|
||||
.BR pcap_stats (3PCAP)
|
||||
get capture statistics
|
||||
.RE
|
||||
.SS Opening a handle for writing captured packets
|
||||
To open a ``savefile`` to which to write packets, given the pathname the
|
||||
``savefile'' should have, call
|
||||
.BR pcap_dump_open ().
|
||||
To open a ``savefile`` to which to write packets, given the pathname the
|
||||
``savefile'' should have, call
|
||||
.BR pcap_dump_open ();
|
||||
to set up a handle for a ``savefile'', given a
|
||||
.B "FILE\ *"
|
||||
referring to a file already opened for writing, call
|
||||
.BR pcap_dump_fopen ().
|
||||
They each return pointers to a
|
||||
.BR pcap_dumper_t ,
|
||||
which is the handle used for writing packets to the ``savefile''. If it
|
||||
succeeds, it will have created the file if it doesn't exist and
|
||||
truncated the file if it does exist.
|
||||
To close a
|
||||
.BR pcap_dumper_t ,
|
||||
call
|
||||
.BR pcap_dump_close ().
|
||||
.TP
|
||||
.B Routines
|
||||
.RS
|
||||
.TP
|
||||
.BR pcap_dump_open (3PCAP)
|
||||
open a
|
||||
.B pcap_dumper_t
|
||||
for a ``savefile``, given a pathname
|
||||
.TP
|
||||
.BR pcap_dump_fopen (3PCAP)
|
||||
open a
|
||||
.B pcap_dumper_t
|
||||
for a ``savefile``, given a
|
||||
.B "FILE\ *"
|
||||
.TP
|
||||
.BR pcap_dump_close (3PCAP)
|
||||
close a
|
||||
.B pcap_dumper_t
|
||||
.TP
|
||||
.BR pcap_dump_file (3PCAP)
|
||||
get the
|
||||
.B "FILE\ *"
|
||||
for a
|
||||
.B pcap_dumper_t
|
||||
opened for a ``savefile''
|
||||
.RE
|
||||
.SS Writing packets
|
||||
To write a packet to a
|
||||
.BR pcap_dumper_t ,
|
||||
call
|
||||
.BR pcap_dump ().
|
||||
Packets written with
|
||||
.BR pcap_dump ()
|
||||
may be buffered, rather than being immediately written to the
|
||||
``savefile''. Closing the
|
||||
.B pcap_dumper_t
|
||||
will cause all buffered-but-not-yet-written packets to be written to the
|
||||
``savefile''.
|
||||
To force all packets written to the
|
||||
.BR pcap_dumper_t ,
|
||||
and not yet written to the ``savefile'' because they're buffered by the
|
||||
.BR pcap_dumper_t ,
|
||||
to be written to the ``savefile'', without closing the
|
||||
.BR pcap_dumper_t ,
|
||||
call
|
||||
.BR pcap_dump_flush ().
|
||||
.TP
|
||||
.B Routines
|
||||
.RS
|
||||
.TP
|
||||
.BR pcap_dump (3PCAP)
|
||||
write packet to a
|
||||
.B pcap_dumper_t
|
||||
.TP
|
||||
.BR pcap_dump_flush (3PCAP)
|
||||
flush buffered packets written to a
|
||||
.B pcap_dumper_t
|
||||
to the ``savefile''
|
||||
.TP
|
||||
.BR pcap_dump_ftell (3PCAP)
|
||||
get current file position for a
|
||||
.B pcap_dumper_t
|
||||
.RE
|
||||
.SS Injecting packets
|
||||
If you have the required privileges, you can inject packets onto a
|
||||
network with a
|
||||
.B pcap_t
|
||||
for a live capture, using
|
||||
.BR pcap_inject ()
|
||||
or
|
||||
.BR pcap_sendpacket ().
|
||||
(The two routines exist for compatibility with both OpenBSD and WinPcap;
|
||||
they perform the same function, but have different return values.)
|
||||
.TP
|
||||
.B Routines
|
||||
.RS
|
||||
.TP
|
||||
.BR pcap_inject (3PCAP)
|
||||
.PD 0
|
||||
.TP
|
||||
.BR pcap_sendpacket (3PCAP)
|
||||
transmit a packet
|
||||
.PD
|
||||
.RE
|
||||
.SS Reporting errors
|
||||
Some routines return error or warning status codes; to convert them to a
|
||||
string, use
|
||||
.BR pcap_statustostr ().
|
||||
.TP
|
||||
.B Routines
|
||||
.RS
|
||||
.TP
|
||||
.BR pcap_statustostr (3PCAP)
|
||||
get a string for an error or warning status code
|
||||
.RE
|
||||
.SS Getting library version information
|
||||
To get a string giving version information about libpcap, call
|
||||
.BR pcap_library_version ().
|
||||
.TP
|
||||
.B Routines
|
||||
.RS
|
||||
.TP
|
||||
.BR pcap_library_version (3PCAP)
|
||||
get library version string
|
||||
.RE
|
||||
.SH BACKWARDS COMPATIBILITY
|
||||
.PP
|
||||
In versions of libpcap prior to 1.0, the
|
||||
@@ -346,18 +843,18 @@ which will include
|
||||
for you, rather than including
|
||||
.BR <pcap/pcap.h> .
|
||||
.PP
|
||||
.B pcap_create()
|
||||
.BR pcap_create ()
|
||||
and
|
||||
.B pcap_activate()
|
||||
.BR pcap_activate ()
|
||||
were not available in versions of libpcap prior to 1.0; if you are
|
||||
writing an application that must work on versions of libpcap prior to
|
||||
1.0, either use
|
||||
.B pcap_open_live()
|
||||
.BR pcap_open_live ()
|
||||
to get a handle for a live capture or, if you want to be able to use the
|
||||
additional capabilities offered by using
|
||||
.B pcap_create()
|
||||
.BR pcap_create ()
|
||||
and
|
||||
.BR pcap_activate() ,
|
||||
.BR pcap_activate (),
|
||||
use an
|
||||
.BR autoconf (1)
|
||||
script or some other configuration script to check whether the libpcap
|
||||
|
||||
440
libpcap/pcap.c
440
libpcap/pcap.c
@@ -57,7 +57,7 @@ static const char rcsid[] _U_ =
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#if !defined(_MSC_VER) && !defined(__BORLANDC__)
|
||||
#if !defined(_MSC_VER) && !defined(__BORLANDC__) && !defined(__MINGW32__)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
@@ -82,7 +82,7 @@ int
|
||||
pcap_not_initialized(pcap_t *pcap)
|
||||
{
|
||||
/* this means 'not initialized' */
|
||||
return PCAP_ERROR_NOT_ACTIVATED;
|
||||
return (PCAP_ERROR_NOT_ACTIVATED);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -104,6 +104,56 @@ pcap_cant_set_rfmon(pcap_t *p _U_)
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets *tstamp_typesp to point to an array 1 or more supported time stamp
|
||||
* types; the return value is the number of supported time stamp types.
|
||||
* The list should be freed by a call to pcap_free_tstamp_types() when
|
||||
* you're done with it.
|
||||
*
|
||||
* A return value of 0 means "you don't get a choice of time stamp type",
|
||||
* in which case *tstamp_typesp is set to null.
|
||||
*
|
||||
* PCAP_ERROR is returned on error.
|
||||
*/
|
||||
int
|
||||
pcap_list_tstamp_types(pcap_t *p, int **tstamp_typesp)
|
||||
{
|
||||
if (p->tstamp_type_count == 0) {
|
||||
/*
|
||||
* We don't support multiple time stamp types.
|
||||
*/
|
||||
*tstamp_typesp = NULL;
|
||||
} else {
|
||||
*tstamp_typesp = (int*)calloc(sizeof(**tstamp_typesp),
|
||||
p->tstamp_type_count);
|
||||
if (*tstamp_typesp == NULL) {
|
||||
(void)snprintf(p->errbuf, sizeof(p->errbuf),
|
||||
"malloc: %s", pcap_strerror(errno));
|
||||
return (PCAP_ERROR);
|
||||
}
|
||||
(void)memcpy(*tstamp_typesp, p->tstamp_type_list,
|
||||
sizeof(**tstamp_typesp) * p->tstamp_type_count);
|
||||
}
|
||||
return (p->tstamp_type_count);
|
||||
}
|
||||
|
||||
/*
|
||||
* In Windows, you might have a library built with one version of the
|
||||
* C runtime library and an application built with another version of
|
||||
* the C runtime library, which means that the library might use one
|
||||
* version of malloc() and free() and the application might use another
|
||||
* version of malloc() and free(). If so, that means something
|
||||
* allocated by the library cannot be freed by the application, so we
|
||||
* need to have a pcap_free_tstamp_types() routine to free up the list
|
||||
* allocated by pcap_list_tstamp_types(), even though it's just a wrapper
|
||||
* around free().
|
||||
*/
|
||||
void
|
||||
pcap_free_tstamp_types(int *tstamp_type_list)
|
||||
{
|
||||
free(tstamp_type_list);
|
||||
}
|
||||
|
||||
/*
|
||||
* Default one-shot callback; overridden for capture types where the
|
||||
* packet data cannot be guaranteed to be available after the callback
|
||||
@@ -149,7 +199,8 @@ pcap_next_ex(pcap_t *p, struct pcap_pkthdr **pkt_header,
|
||||
int status;
|
||||
|
||||
/* We are on an offline capture */
|
||||
status = pcap_offline_read(p, 1, pcap_oneshot, (u_char *)&s);
|
||||
status = pcap_offline_read(p, 1, p->oneshot_callback,
|
||||
(u_char *)&s);
|
||||
|
||||
/*
|
||||
* Return codes for pcap_offline_read() are:
|
||||
@@ -178,7 +229,7 @@ pcap_next_ex(pcap_t *p, struct pcap_pkthdr **pkt_header,
|
||||
* The first one ('0') conflicts with the return code of 0 from
|
||||
* pcap_offline_read() meaning "end of file".
|
||||
*/
|
||||
return (p->read_op(p, 1, pcap_oneshot, (u_char *)&s));
|
||||
return (p->read_op(p, 1, p->oneshot_callback, (u_char *)&s));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -258,6 +309,7 @@ pcap_create_common(const char *source, char *ebuf)
|
||||
pcap_set_snaplen(p, 65535); /* max packet size */
|
||||
p->opt.promisc = 0;
|
||||
p->opt.buffer_size = 0;
|
||||
p->opt.tstamp_type = -1; /* default to not setting time stamp type */
|
||||
return (p);
|
||||
}
|
||||
|
||||
@@ -267,54 +319,89 @@ pcap_check_activated(pcap_t *p)
|
||||
if (p->activated) {
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "can't perform "
|
||||
" operation on activated capture");
|
||||
return -1;
|
||||
return (-1);
|
||||
}
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
pcap_set_snaplen(pcap_t *p, int snaplen)
|
||||
{
|
||||
if (pcap_check_activated(p))
|
||||
return PCAP_ERROR_ACTIVATED;
|
||||
return (PCAP_ERROR_ACTIVATED);
|
||||
p->snapshot = snaplen;
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
pcap_set_promisc(pcap_t *p, int promisc)
|
||||
{
|
||||
if (pcap_check_activated(p))
|
||||
return PCAP_ERROR_ACTIVATED;
|
||||
return (PCAP_ERROR_ACTIVATED);
|
||||
p->opt.promisc = promisc;
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
pcap_set_rfmon(pcap_t *p, int rfmon)
|
||||
{
|
||||
if (pcap_check_activated(p))
|
||||
return PCAP_ERROR_ACTIVATED;
|
||||
return (PCAP_ERROR_ACTIVATED);
|
||||
p->opt.rfmon = rfmon;
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
pcap_set_timeout(pcap_t *p, int timeout_ms)
|
||||
{
|
||||
if (pcap_check_activated(p))
|
||||
return PCAP_ERROR_ACTIVATED;
|
||||
return (PCAP_ERROR_ACTIVATED);
|
||||
p->md.timeout = timeout_ms;
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
pcap_set_tstamp_type(pcap_t *p, int tstamp_type)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (pcap_check_activated(p))
|
||||
return (PCAP_ERROR_ACTIVATED);
|
||||
|
||||
/*
|
||||
* If p->tstamp_type_count is 0, we don't support setting
|
||||
* the time stamp type at all.
|
||||
*/
|
||||
if (p->tstamp_type_count == 0)
|
||||
return (PCAP_ERROR_CANTSET_TSTAMP_TYPE);
|
||||
|
||||
/*
|
||||
* Check whether we claim to support this type of time stamp.
|
||||
*/
|
||||
for (i = 0; i < p->tstamp_type_count; i++) {
|
||||
if (p->tstamp_type_list[i] == tstamp_type) {
|
||||
/*
|
||||
* Yes.
|
||||
*/
|
||||
p->opt.tstamp_type = tstamp_type;
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* No. We support setting the time stamp type, but not to this
|
||||
* particular value.
|
||||
*/
|
||||
return (PCAP_WARNING_TSTAMP_TYPE_NOTSUP);
|
||||
}
|
||||
|
||||
int
|
||||
pcap_set_buffer_size(pcap_t *p, int buffer_size)
|
||||
{
|
||||
if (pcap_check_activated(p))
|
||||
return PCAP_ERROR_ACTIVATED;
|
||||
return (PCAP_ERROR_ACTIVATED);
|
||||
p->opt.buffer_size = buffer_size;
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
@@ -322,6 +409,15 @@ pcap_activate(pcap_t *p)
|
||||
{
|
||||
int status;
|
||||
|
||||
/*
|
||||
* Catch attempts to re-activate an already-activated
|
||||
* pcap_t; this should, for example, catch code that
|
||||
* calls pcap_open_live() followed by pcap_activate(),
|
||||
* as some code that showed up in a Stack Exchange
|
||||
* question did.
|
||||
*/
|
||||
if (pcap_check_activated(p))
|
||||
return (PCAP_ERROR_ACTIVATED);
|
||||
status = p->activate_op(p);
|
||||
if (status >= 0)
|
||||
p->activated = 1;
|
||||
@@ -384,7 +480,8 @@ fail:
|
||||
snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s", source,
|
||||
p->errbuf);
|
||||
else if (status == PCAP_ERROR_NO_SUCH_DEVICE ||
|
||||
status == PCAP_ERROR_PERM_DENIED)
|
||||
status == PCAP_ERROR_PERM_DENIED ||
|
||||
status == PCAP_ERROR_PROMISC_PERM_DENIED)
|
||||
snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s (%s)", source,
|
||||
pcap_statustostr(status), p->errbuf);
|
||||
else
|
||||
@@ -397,7 +494,7 @@ fail:
|
||||
int
|
||||
pcap_dispatch(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
|
||||
{
|
||||
return p->read_op(p, cnt, callback, user);
|
||||
return (p->read_op(p, cnt, callback, user));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -407,7 +504,7 @@ int
|
||||
pcap_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
|
||||
{
|
||||
|
||||
return p->read_op(p, cnt, callback, user);
|
||||
return (p->read_op(p, cnt, callback, user));
|
||||
}
|
||||
|
||||
int
|
||||
@@ -571,111 +668,6 @@ unsupported:
|
||||
return (-1);
|
||||
}
|
||||
|
||||
struct dlt_choice {
|
||||
const char *name;
|
||||
const char *description;
|
||||
int dlt;
|
||||
};
|
||||
|
||||
#define DLT_CHOICE(code, description) { #code, description, code }
|
||||
#define DLT_CHOICE_SENTINEL { NULL, NULL, 0 }
|
||||
|
||||
static struct dlt_choice dlt_choices[] = {
|
||||
DLT_CHOICE(DLT_NULL, "BSD loopback"),
|
||||
DLT_CHOICE(DLT_EN10MB, "Ethernet"),
|
||||
DLT_CHOICE(DLT_IEEE802, "Token ring"),
|
||||
DLT_CHOICE(DLT_ARCNET, "BSD ARCNET"),
|
||||
DLT_CHOICE(DLT_SLIP, "SLIP"),
|
||||
DLT_CHOICE(DLT_PPP, "PPP"),
|
||||
DLT_CHOICE(DLT_FDDI, "FDDI"),
|
||||
DLT_CHOICE(DLT_ATM_RFC1483, "RFC 1483 LLC-encapsulated ATM"),
|
||||
DLT_CHOICE(DLT_RAW, "Raw IP"),
|
||||
DLT_CHOICE(DLT_SLIP_BSDOS, "BSD/OS SLIP"),
|
||||
DLT_CHOICE(DLT_PPP_BSDOS, "BSD/OS PPP"),
|
||||
DLT_CHOICE(DLT_ATM_CLIP, "Linux Classical IP-over-ATM"),
|
||||
DLT_CHOICE(DLT_PPP_SERIAL, "PPP over serial"),
|
||||
DLT_CHOICE(DLT_PPP_ETHER, "PPPoE"),
|
||||
DLT_CHOICE(DLT_SYMANTEC_FIREWALL, "Symantec Firewall"),
|
||||
DLT_CHOICE(DLT_C_HDLC, "Cisco HDLC"),
|
||||
DLT_CHOICE(DLT_IEEE802_11, "802.11"),
|
||||
DLT_CHOICE(DLT_FRELAY, "Frame Relay"),
|
||||
DLT_CHOICE(DLT_LOOP, "OpenBSD loopback"),
|
||||
DLT_CHOICE(DLT_ENC, "OpenBSD encapsulated IP"),
|
||||
DLT_CHOICE(DLT_LINUX_SLL, "Linux cooked"),
|
||||
DLT_CHOICE(DLT_LTALK, "Localtalk"),
|
||||
DLT_CHOICE(DLT_PFLOG, "OpenBSD pflog file"),
|
||||
DLT_CHOICE(DLT_PRISM_HEADER, "802.11 plus Prism header"),
|
||||
DLT_CHOICE(DLT_IP_OVER_FC, "RFC 2625 IP-over-Fibre Channel"),
|
||||
DLT_CHOICE(DLT_SUNATM, "Sun raw ATM"),
|
||||
DLT_CHOICE(DLT_IEEE802_11_RADIO, "802.11 plus radiotap header"),
|
||||
DLT_CHOICE(DLT_ARCNET_LINUX, "Linux ARCNET"),
|
||||
DLT_CHOICE(DLT_JUNIPER_MLPPP, "Juniper Multi-Link PPP"),
|
||||
DLT_CHOICE(DLT_JUNIPER_MLFR, "Juniper Multi-Link Frame Relay"),
|
||||
DLT_CHOICE(DLT_JUNIPER_ES, "Juniper Encryption Services PIC"),
|
||||
DLT_CHOICE(DLT_JUNIPER_GGSN, "Juniper GGSN PIC"),
|
||||
DLT_CHOICE(DLT_JUNIPER_MFR, "Juniper FRF.16 Frame Relay"),
|
||||
DLT_CHOICE(DLT_JUNIPER_ATM2, "Juniper ATM2 PIC"),
|
||||
DLT_CHOICE(DLT_JUNIPER_SERVICES, "Juniper Advanced Services PIC"),
|
||||
DLT_CHOICE(DLT_JUNIPER_ATM1, "Juniper ATM1 PIC"),
|
||||
DLT_CHOICE(DLT_APPLE_IP_OVER_IEEE1394, "Apple IP-over-IEEE 1394"),
|
||||
DLT_CHOICE(DLT_MTP2_WITH_PHDR, "SS7 MTP2 with Pseudo-header"),
|
||||
DLT_CHOICE(DLT_MTP2, "SS7 MTP2"),
|
||||
DLT_CHOICE(DLT_MTP3, "SS7 MTP3"),
|
||||
DLT_CHOICE(DLT_SCCP, "SS7 SCCP"),
|
||||
DLT_CHOICE(DLT_DOCSIS, "DOCSIS"),
|
||||
DLT_CHOICE(DLT_LINUX_IRDA, "Linux IrDA"),
|
||||
DLT_CHOICE(DLT_IEEE802_11_RADIO_AVS, "802.11 plus AVS radio information header"),
|
||||
DLT_CHOICE(DLT_JUNIPER_MONITOR, "Juniper Passive Monitor PIC"),
|
||||
DLT_CHOICE(DLT_PPP_PPPD, "PPP for pppd, with direction flag"),
|
||||
DLT_CHOICE(DLT_JUNIPER_PPPOE, "Juniper PPPoE"),
|
||||
DLT_CHOICE(DLT_JUNIPER_PPPOE_ATM, "Juniper PPPoE/ATM"),
|
||||
DLT_CHOICE(DLT_GPRS_LLC, "GPRS LLC"),
|
||||
DLT_CHOICE(DLT_GPF_T, "GPF-T"),
|
||||
DLT_CHOICE(DLT_GPF_F, "GPF-F"),
|
||||
DLT_CHOICE(DLT_JUNIPER_PIC_PEER, "Juniper PIC Peer"),
|
||||
DLT_CHOICE(DLT_ERF_ETH, "Ethernet with Endace ERF header"),
|
||||
DLT_CHOICE(DLT_ERF_POS, "Packet-over-SONET with Endace ERF header"),
|
||||
DLT_CHOICE(DLT_LINUX_LAPD, "Linux vISDN LAPD"),
|
||||
DLT_CHOICE(DLT_JUNIPER_ETHER, "Juniper Ethernet"),
|
||||
DLT_CHOICE(DLT_JUNIPER_PPP, "Juniper PPP"),
|
||||
DLT_CHOICE(DLT_JUNIPER_FRELAY, "Juniper Frame Relay"),
|
||||
DLT_CHOICE(DLT_JUNIPER_CHDLC, "Juniper C-HDLC"),
|
||||
DLT_CHOICE(DLT_MFR, "FRF.16 Frame Relay"),
|
||||
DLT_CHOICE(DLT_JUNIPER_VP, "Juniper Voice PIC"),
|
||||
DLT_CHOICE(DLT_A429, "Arinc 429"),
|
||||
DLT_CHOICE(DLT_A653_ICM, "Arinc 653 Interpartition Communication"),
|
||||
DLT_CHOICE(DLT_USB, "USB"),
|
||||
DLT_CHOICE(DLT_BLUETOOTH_HCI_H4, "Bluetooth HCI UART transport layer"),
|
||||
DLT_CHOICE(DLT_IEEE802_16_MAC_CPS, "IEEE 802.16 MAC Common Part Sublayer"),
|
||||
DLT_CHOICE(DLT_USB_LINUX, "USB with Linux header"),
|
||||
DLT_CHOICE(DLT_CAN20B, "Controller Area Network (CAN) v. 2.0B"),
|
||||
DLT_CHOICE(DLT_IEEE802_15_4_LINUX, "IEEE 802.15.4 with Linux padding"),
|
||||
DLT_CHOICE(DLT_PPI, "Per-Packet Information"),
|
||||
DLT_CHOICE(DLT_IEEE802_16_MAC_CPS_RADIO, "IEEE 802.16 MAC Common Part Sublayer plus radiotap header"),
|
||||
DLT_CHOICE(DLT_JUNIPER_ISM, "Juniper Integrated Service Module"),
|
||||
DLT_CHOICE(DLT_IEEE802_15_4, "IEEE 802.15.4"),
|
||||
DLT_CHOICE(DLT_SITA, "SITA pseudo-header"),
|
||||
DLT_CHOICE(DLT_ERF, "Endace ERF header"),
|
||||
DLT_CHOICE(DLT_RAIF1, "Ethernet with u10 Networks pseudo-header"),
|
||||
DLT_CHOICE(DLT_IPMB, "IPMB"),
|
||||
DLT_CHOICE(DLT_JUNIPER_ST, "Juniper Secure Tunnel"),
|
||||
DLT_CHOICE(DLT_BLUETOOTH_HCI_H4_WITH_PHDR, "Bluetooth HCI UART transport layer plus pseudo-header"),
|
||||
DLT_CHOICE(DLT_AX25_KISS, "AX.25 with KISS header"),
|
||||
DLT_CHOICE(DLT_IEEE802_15_4_NONASK_PHY, "IEEE 802.15.4 with non-ASK PHY data"),
|
||||
DLT_CHOICE(DLT_MPLS, "MPLS with label as link-layer header"),
|
||||
DLT_CHOICE(DLT_USB_LINUX_MMAPPED, "USB with padded Linux header"),
|
||||
DLT_CHOICE(DLT_DECT, "DECT"),
|
||||
DLT_CHOICE(DLT_AOS, "AOS Space Data Link protocol"),
|
||||
DLT_CHOICE(DLT_WIHART, "Wireless HART"),
|
||||
DLT_CHOICE(DLT_FC_2, "Fibre Channel FC-2"),
|
||||
DLT_CHOICE(DLT_FC_2_WITH_FRAME_DELIMS, "Fibre Channel FC-2 with frame delimiters"),
|
||||
DLT_CHOICE(DLT_IPNET, "Solaris ipnet"),
|
||||
DLT_CHOICE(DLT_CAN_SOCKETCAN, "CAN-bus with SocketCAN headers"),
|
||||
DLT_CHOICE(DLT_IPV4, "Raw IPv4"),
|
||||
DLT_CHOICE(DLT_IPV6, "Raw IPv6"),
|
||||
DLT_CHOICE_SENTINEL
|
||||
};
|
||||
|
||||
/*
|
||||
* This array is designed for mapping upper and lower case letter
|
||||
* together for a case independent comparison. The mappings are
|
||||
@@ -761,6 +753,121 @@ pcap_strcasecmp(const char *s1, const char *s2)
|
||||
return (cm[*us1] - cm[*--us2]);
|
||||
}
|
||||
|
||||
struct dlt_choice {
|
||||
const char *name;
|
||||
const char *description;
|
||||
int dlt;
|
||||
};
|
||||
|
||||
#define DLT_CHOICE(code, description) { #code, description, code }
|
||||
#define DLT_CHOICE_SENTINEL { NULL, NULL, 0 }
|
||||
|
||||
static struct dlt_choice dlt_choices[] = {
|
||||
DLT_CHOICE(DLT_NULL, "BSD loopback"),
|
||||
DLT_CHOICE(DLT_EN10MB, "Ethernet"),
|
||||
DLT_CHOICE(DLT_IEEE802, "Token ring"),
|
||||
DLT_CHOICE(DLT_ARCNET, "BSD ARCNET"),
|
||||
DLT_CHOICE(DLT_SLIP, "SLIP"),
|
||||
DLT_CHOICE(DLT_PPP, "PPP"),
|
||||
DLT_CHOICE(DLT_FDDI, "FDDI"),
|
||||
DLT_CHOICE(DLT_ATM_RFC1483, "RFC 1483 LLC-encapsulated ATM"),
|
||||
DLT_CHOICE(DLT_RAW, "Raw IP"),
|
||||
DLT_CHOICE(DLT_SLIP_BSDOS, "BSD/OS SLIP"),
|
||||
DLT_CHOICE(DLT_PPP_BSDOS, "BSD/OS PPP"),
|
||||
DLT_CHOICE(DLT_ATM_CLIP, "Linux Classical IP-over-ATM"),
|
||||
DLT_CHOICE(DLT_PPP_SERIAL, "PPP over serial"),
|
||||
DLT_CHOICE(DLT_PPP_ETHER, "PPPoE"),
|
||||
DLT_CHOICE(DLT_SYMANTEC_FIREWALL, "Symantec Firewall"),
|
||||
DLT_CHOICE(DLT_C_HDLC, "Cisco HDLC"),
|
||||
DLT_CHOICE(DLT_IEEE802_11, "802.11"),
|
||||
DLT_CHOICE(DLT_FRELAY, "Frame Relay"),
|
||||
DLT_CHOICE(DLT_LOOP, "OpenBSD loopback"),
|
||||
DLT_CHOICE(DLT_ENC, "OpenBSD encapsulated IP"),
|
||||
DLT_CHOICE(DLT_LINUX_SLL, "Linux cooked"),
|
||||
DLT_CHOICE(DLT_LTALK, "Localtalk"),
|
||||
DLT_CHOICE(DLT_PFLOG, "OpenBSD pflog file"),
|
||||
DLT_CHOICE(DLT_PRISM_HEADER, "802.11 plus Prism header"),
|
||||
DLT_CHOICE(DLT_IP_OVER_FC, "RFC 2625 IP-over-Fibre Channel"),
|
||||
DLT_CHOICE(DLT_SUNATM, "Sun raw ATM"),
|
||||
DLT_CHOICE(DLT_IEEE802_11_RADIO, "802.11 plus radiotap header"),
|
||||
DLT_CHOICE(DLT_ARCNET_LINUX, "Linux ARCNET"),
|
||||
DLT_CHOICE(DLT_JUNIPER_MLPPP, "Juniper Multi-Link PPP"),
|
||||
DLT_CHOICE(DLT_JUNIPER_MLFR, "Juniper Multi-Link Frame Relay"),
|
||||
DLT_CHOICE(DLT_JUNIPER_ES, "Juniper Encryption Services PIC"),
|
||||
DLT_CHOICE(DLT_JUNIPER_GGSN, "Juniper GGSN PIC"),
|
||||
DLT_CHOICE(DLT_JUNIPER_MFR, "Juniper FRF.16 Frame Relay"),
|
||||
DLT_CHOICE(DLT_JUNIPER_ATM2, "Juniper ATM2 PIC"),
|
||||
DLT_CHOICE(DLT_JUNIPER_SERVICES, "Juniper Advanced Services PIC"),
|
||||
DLT_CHOICE(DLT_JUNIPER_ATM1, "Juniper ATM1 PIC"),
|
||||
DLT_CHOICE(DLT_APPLE_IP_OVER_IEEE1394, "Apple IP-over-IEEE 1394"),
|
||||
DLT_CHOICE(DLT_MTP2_WITH_PHDR, "SS7 MTP2 with Pseudo-header"),
|
||||
DLT_CHOICE(DLT_MTP2, "SS7 MTP2"),
|
||||
DLT_CHOICE(DLT_MTP3, "SS7 MTP3"),
|
||||
DLT_CHOICE(DLT_SCCP, "SS7 SCCP"),
|
||||
DLT_CHOICE(DLT_DOCSIS, "DOCSIS"),
|
||||
DLT_CHOICE(DLT_LINUX_IRDA, "Linux IrDA"),
|
||||
DLT_CHOICE(DLT_IEEE802_11_RADIO_AVS, "802.11 plus AVS radio information header"),
|
||||
DLT_CHOICE(DLT_JUNIPER_MONITOR, "Juniper Passive Monitor PIC"),
|
||||
DLT_CHOICE(DLT_PPP_PPPD, "PPP for pppd, with direction flag"),
|
||||
DLT_CHOICE(DLT_JUNIPER_PPPOE, "Juniper PPPoE"),
|
||||
DLT_CHOICE(DLT_JUNIPER_PPPOE_ATM, "Juniper PPPoE/ATM"),
|
||||
DLT_CHOICE(DLT_GPRS_LLC, "GPRS LLC"),
|
||||
DLT_CHOICE(DLT_GPF_T, "GPF-T"),
|
||||
DLT_CHOICE(DLT_GPF_F, "GPF-F"),
|
||||
DLT_CHOICE(DLT_JUNIPER_PIC_PEER, "Juniper PIC Peer"),
|
||||
DLT_CHOICE(DLT_ERF_ETH, "Ethernet with Endace ERF header"),
|
||||
DLT_CHOICE(DLT_ERF_POS, "Packet-over-SONET with Endace ERF header"),
|
||||
DLT_CHOICE(DLT_LINUX_LAPD, "Linux vISDN LAPD"),
|
||||
DLT_CHOICE(DLT_JUNIPER_ETHER, "Juniper Ethernet"),
|
||||
DLT_CHOICE(DLT_JUNIPER_PPP, "Juniper PPP"),
|
||||
DLT_CHOICE(DLT_JUNIPER_FRELAY, "Juniper Frame Relay"),
|
||||
DLT_CHOICE(DLT_JUNIPER_CHDLC, "Juniper C-HDLC"),
|
||||
DLT_CHOICE(DLT_MFR, "FRF.16 Frame Relay"),
|
||||
DLT_CHOICE(DLT_JUNIPER_VP, "Juniper Voice PIC"),
|
||||
DLT_CHOICE(DLT_A429, "Arinc 429"),
|
||||
DLT_CHOICE(DLT_A653_ICM, "Arinc 653 Interpartition Communication"),
|
||||
DLT_CHOICE(DLT_USB, "USB"),
|
||||
DLT_CHOICE(DLT_BLUETOOTH_HCI_H4, "Bluetooth HCI UART transport layer"),
|
||||
DLT_CHOICE(DLT_IEEE802_16_MAC_CPS, "IEEE 802.16 MAC Common Part Sublayer"),
|
||||
DLT_CHOICE(DLT_USB_LINUX, "USB with Linux header"),
|
||||
DLT_CHOICE(DLT_CAN20B, "Controller Area Network (CAN) v. 2.0B"),
|
||||
DLT_CHOICE(DLT_IEEE802_15_4_LINUX, "IEEE 802.15.4 with Linux padding"),
|
||||
DLT_CHOICE(DLT_PPI, "Per-Packet Information"),
|
||||
DLT_CHOICE(DLT_IEEE802_16_MAC_CPS_RADIO, "IEEE 802.16 MAC Common Part Sublayer plus radiotap header"),
|
||||
DLT_CHOICE(DLT_JUNIPER_ISM, "Juniper Integrated Service Module"),
|
||||
DLT_CHOICE(DLT_IEEE802_15_4, "IEEE 802.15.4 with FCS"),
|
||||
DLT_CHOICE(DLT_SITA, "SITA pseudo-header"),
|
||||
DLT_CHOICE(DLT_ERF, "Endace ERF header"),
|
||||
DLT_CHOICE(DLT_RAIF1, "Ethernet with u10 Networks pseudo-header"),
|
||||
DLT_CHOICE(DLT_IPMB, "IPMB"),
|
||||
DLT_CHOICE(DLT_JUNIPER_ST, "Juniper Secure Tunnel"),
|
||||
DLT_CHOICE(DLT_BLUETOOTH_HCI_H4_WITH_PHDR, "Bluetooth HCI UART transport layer plus pseudo-header"),
|
||||
DLT_CHOICE(DLT_AX25_KISS, "AX.25 with KISS header"),
|
||||
DLT_CHOICE(DLT_IEEE802_15_4_NONASK_PHY, "IEEE 802.15.4 with non-ASK PHY data"),
|
||||
DLT_CHOICE(DLT_MPLS, "MPLS with label as link-layer header"),
|
||||
DLT_CHOICE(DLT_USB_LINUX_MMAPPED, "USB with padded Linux header"),
|
||||
DLT_CHOICE(DLT_DECT, "DECT"),
|
||||
DLT_CHOICE(DLT_AOS, "AOS Space Data Link protocol"),
|
||||
DLT_CHOICE(DLT_WIHART, "Wireless HART"),
|
||||
DLT_CHOICE(DLT_FC_2, "Fibre Channel FC-2"),
|
||||
DLT_CHOICE(DLT_FC_2_WITH_FRAME_DELIMS, "Fibre Channel FC-2 with frame delimiters"),
|
||||
DLT_CHOICE(DLT_IPNET, "Solaris ipnet"),
|
||||
DLT_CHOICE(DLT_CAN_SOCKETCAN, "CAN-bus with SocketCAN headers"),
|
||||
DLT_CHOICE(DLT_IPV4, "Raw IPv4"),
|
||||
DLT_CHOICE(DLT_IPV6, "Raw IPv6"),
|
||||
DLT_CHOICE(DLT_IEEE802_15_4_NOFCS, "IEEE 802.15.4 without FCS"),
|
||||
DLT_CHOICE(DLT_JUNIPER_VS, "Juniper Virtual Server"),
|
||||
DLT_CHOICE(DLT_JUNIPER_SRX_E2E, "Juniper SRX E2E"),
|
||||
DLT_CHOICE(DLT_JUNIPER_FIBRECHANNEL, "Juniper Fibre Channel"),
|
||||
DLT_CHOICE(DLT_DVB_CI, "DVB-CI"),
|
||||
DLT_CHOICE(DLT_JUNIPER_ATM_CEMIC, "Juniper ATM CEMIC"),
|
||||
DLT_CHOICE(DLT_NFLOG, "Linux netfilter log messages"),
|
||||
DLT_CHOICE(DLT_NETANALYZER, "Ethernet with Hilscher netANALYZER pseudo-header"),
|
||||
DLT_CHOICE(DLT_NETANALYZER_TRANSPARENT, "Ethernet with Hilscher netANALYZER pseudo-header and with preamble and SFD"),
|
||||
DLT_CHOICE(DLT_IPOIB, "RFC 4391 IP-over-Infiniband"),
|
||||
DLT_CHOICE_SENTINEL
|
||||
};
|
||||
|
||||
int
|
||||
pcap_datalink_name_to_val(const char *name)
|
||||
{
|
||||
@@ -798,6 +905,57 @@ pcap_datalink_val_to_description(int dlt)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
struct tstamp_type_choice {
|
||||
const char *name;
|
||||
const char *description;
|
||||
int type;
|
||||
};
|
||||
|
||||
static struct tstamp_type_choice tstamp_type_choices[] = {
|
||||
{ "host", "Host", PCAP_TSTAMP_HOST },
|
||||
{ "host_lowprec", "Host, low precision", PCAP_TSTAMP_HOST_LOWPREC },
|
||||
{ "host_hiprec", "Host, high precision", PCAP_TSTAMP_HOST_HIPREC },
|
||||
{ "adapter", "Adapter", PCAP_TSTAMP_ADAPTER },
|
||||
{ "adapter_unsynced", "Adapter, not synced with system time", PCAP_TSTAMP_ADAPTER_UNSYNCED },
|
||||
{ NULL, NULL, 0 }
|
||||
};
|
||||
|
||||
int
|
||||
pcap_tstamp_type_name_to_val(const char *name)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; tstamp_type_choices[i].name != NULL; i++) {
|
||||
if (pcap_strcasecmp(tstamp_type_choices[i].name, name) == 0)
|
||||
return (tstamp_type_choices[i].type);
|
||||
}
|
||||
return (PCAP_ERROR);
|
||||
}
|
||||
|
||||
const char *
|
||||
pcap_tstamp_type_val_to_name(int tstamp_type)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; tstamp_type_choices[i].name != NULL; i++) {
|
||||
if (tstamp_type_choices[i].type == tstamp_type)
|
||||
return (tstamp_type_choices[i].name);
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
const char *
|
||||
pcap_tstamp_type_val_to_description(int tstamp_type)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; tstamp_type_choices[i].name != NULL; i++) {
|
||||
if (tstamp_type_choices[i].type == tstamp_type)
|
||||
return (tstamp_type_choices[i].description);
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
int
|
||||
pcap_snapshot(pcap_t *p)
|
||||
{
|
||||
@@ -864,7 +1022,7 @@ pcap_geterr(pcap_t *p)
|
||||
int
|
||||
pcap_getnonblock(pcap_t *p, char *errbuf)
|
||||
{
|
||||
return p->getnonblock_op(p, errbuf);
|
||||
return (p->getnonblock_op(p, errbuf));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -896,7 +1054,7 @@ pcap_getnonblock_fd(pcap_t *p, char *errbuf)
|
||||
int
|
||||
pcap_setnonblock(pcap_t *p, int nonblock, char *errbuf)
|
||||
{
|
||||
return p->setnonblock_op(p, nonblock, errbuf);
|
||||
return (p->setnonblock_op(p, nonblock, errbuf));
|
||||
}
|
||||
|
||||
#if !defined(WIN32) && !defined(MSDOS)
|
||||
@@ -976,6 +1134,9 @@ pcap_statustostr(int errnum)
|
||||
case PCAP_WARNING:
|
||||
return("Generic warning");
|
||||
|
||||
case PCAP_WARNING_TSTAMP_TYPE_NOTSUP:
|
||||
return ("That type of time stamp is not supported by that device");
|
||||
|
||||
case PCAP_WARNING_PROMISC_NOTSUP:
|
||||
return ("That device doesn't support promiscuous mode");
|
||||
|
||||
@@ -1005,6 +1166,12 @@ pcap_statustostr(int errnum)
|
||||
|
||||
case PCAP_ERROR_IFACE_NOT_UP:
|
||||
return ("That device is not up");
|
||||
|
||||
case PCAP_ERROR_CANTSET_TSTAMP_TYPE:
|
||||
return ("That device doesn't support setting the time stamp type");
|
||||
|
||||
case PCAP_ERROR_PROMISC_PERM_DENIED:
|
||||
return ("You don't have permission to capture in promiscuous mode on that device");
|
||||
}
|
||||
(void)snprintf(ebuf, sizeof ebuf, "Unknown error: %d", errnum);
|
||||
return(ebuf);
|
||||
@@ -1033,7 +1200,7 @@ pcap_strerror(int errnum)
|
||||
int
|
||||
pcap_setfilter(pcap_t *p, struct bpf_program *fp)
|
||||
{
|
||||
return p->setfilter_op(p, fp);
|
||||
return (p->setfilter_op(p, fp));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1048,15 +1215,15 @@ pcap_setdirection(pcap_t *p, pcap_direction_t d)
|
||||
if (p->setdirection_op == NULL) {
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Setting direction is not implemented on this platform");
|
||||
return -1;
|
||||
return (-1);
|
||||
} else
|
||||
return p->setdirection_op(p, d);
|
||||
return (p->setdirection_op(p, d));
|
||||
}
|
||||
|
||||
int
|
||||
pcap_stats(pcap_t *p, struct pcap_stat *ps)
|
||||
{
|
||||
return p->stats_op(p, ps);
|
||||
return (p->stats_op(p, ps));
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -1071,7 +1238,7 @@ pcap_stats_dead(pcap_t *p, struct pcap_stat *ps _U_)
|
||||
int
|
||||
pcap_setbuff(pcap_t *p, int dim)
|
||||
{
|
||||
return p->setbuff_op(p, dim);
|
||||
return (p->setbuff_op(p, dim));
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -1085,7 +1252,7 @@ pcap_setbuff_dead(pcap_t *p, int dim)
|
||||
int
|
||||
pcap_setmode(pcap_t *p, int mode)
|
||||
{
|
||||
return p->setmode_op(p, mode);
|
||||
return (p->setmode_op(p, mode));
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -1099,7 +1266,7 @@ pcap_setmode_dead(pcap_t *p, int mode)
|
||||
int
|
||||
pcap_setmintocopy(pcap_t *p, int size)
|
||||
{
|
||||
return p->setmintocopy_op(p, size);
|
||||
return (p->setmintocopy_op(p, size));
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -1212,6 +1379,11 @@ pcap_cleanup_live_common(pcap_t *p)
|
||||
p->dlt_list = NULL;
|
||||
p->dlt_count = 0;
|
||||
}
|
||||
if (p->tstamp_type_list != NULL) {
|
||||
free(p->tstamp_type_list);
|
||||
p->tstamp_type_list = NULL;
|
||||
p->tstamp_type_count = 0;
|
||||
}
|
||||
pcap_freecode(&p->fcode);
|
||||
#if !defined(WIN32) && !defined(MSDOS)
|
||||
if (p->fd >= 0) {
|
||||
@@ -1248,7 +1420,7 @@ pcap_open_dead(int linktype, int snaplen)
|
||||
#endif
|
||||
p->cleanup_op = pcap_cleanup_dead;
|
||||
p->activated = 1;
|
||||
return p;
|
||||
return (p);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -48,10 +48,30 @@
|
||||
* "pcap-bpf.c" will include the native OS version, as it deals with
|
||||
* the OS's BPF implementation.
|
||||
*
|
||||
* XXX - should this all just be moved to "pcap.h"?
|
||||
* At least two programs found by Google Code Search explicitly includes
|
||||
* <pcap/bpf.h> (even though <pcap.h>/<pcap/pcap.h> includes it for you),
|
||||
* so moving that stuff to <pcap/pcap.h> would break the build for some
|
||||
* programs.
|
||||
*/
|
||||
|
||||
#ifndef BPF_MAJOR_VERSION
|
||||
/*
|
||||
* If we've already included <net/bpf.h>, don't re-define this stuff.
|
||||
* We assume BSD-style multiple-include protection in <net/bpf.h>,
|
||||
* which is true of all but the oldest versions of FreeBSD and NetBSD,
|
||||
* or Tru64 UNIX-style multiple-include protection (or, at least,
|
||||
* Tru64 UNIX 5.x-style; I don't have earlier versions available to check),
|
||||
* or AIX-style multiple-include protection (or, at least, AIX 5.x-style;
|
||||
* I don't have earlier versions available to check).
|
||||
*
|
||||
* We do not check for BPF_MAJOR_VERSION, as that's defined by
|
||||
* <linux/filter.h>, which is directly or indirectly included in some
|
||||
* programs that also include pcap.h, and <linux/filter.h> doesn't
|
||||
* define stuff we need.
|
||||
*
|
||||
* This also provides our own multiple-include protection.
|
||||
*/
|
||||
#if !defined(_NET_BPF_H_) && !defined(_BPF_H_) && !defined(_H_BPF) && !defined(lib_pcap_bpf_h)
|
||||
#define lib_pcap_bpf_h
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -70,7 +90,9 @@ typedef u_int bpf_u_int32;
|
||||
|
||||
/*
|
||||
* Alignment macros. BPF_WORDALIGN rounds up to the next
|
||||
* even multiple of BPF_ALIGNMENT.
|
||||
* even multiple of BPF_ALIGNMENT.
|
||||
*
|
||||
* Tcpdump's print-pflog.c uses this, so we define it here.
|
||||
*/
|
||||
#ifndef __NetBSD__
|
||||
#define BPF_ALIGNMENT sizeof(bpf_int32)
|
||||
@@ -79,9 +101,6 @@ typedef u_int bpf_u_int32;
|
||||
#endif
|
||||
#define BPF_WORDALIGN(x) (((x)+(BPF_ALIGNMENT-1))&~(BPF_ALIGNMENT-1))
|
||||
|
||||
#define BPF_MAXBUFSIZE 0x8000
|
||||
#define BPF_MINBUFSIZE 32
|
||||
|
||||
/*
|
||||
* Structure for "pcap_compile()", "pcap_setfilter()", etc..
|
||||
*/
|
||||
@@ -91,26 +110,7 @@ struct bpf_program {
|
||||
};
|
||||
|
||||
/*
|
||||
* Struct return by BIOCVERSION. This represents the version number of
|
||||
* the filter language described by the instruction encodings below.
|
||||
* bpf understands a program iff kernel_major == filter_major &&
|
||||
* kernel_minor >= filter_minor, that is, if the value returned by the
|
||||
* running kernel has the same major number and a minor number equal
|
||||
* equal to or less than the filter being downloaded. Otherwise, the
|
||||
* results are undefined, meaning an error may be returned or packets
|
||||
* may be accepted haphazardly.
|
||||
* It has nothing to do with the source code version.
|
||||
*/
|
||||
struct bpf_version {
|
||||
u_short bv_major;
|
||||
u_short bv_minor;
|
||||
};
|
||||
/* Current version number of filter architecture. */
|
||||
#define BPF_MAJOR_VERSION 1
|
||||
#define BPF_MINOR_VERSION 1
|
||||
|
||||
/*
|
||||
* Data-link level type codes.
|
||||
* Link-layer header type codes.
|
||||
*
|
||||
* Do *NOT* add new values to this list without asking
|
||||
* "tcpdump-workers@lists.tcpdump.org" for a value. Otherwise, you run
|
||||
@@ -119,6 +119,12 @@ struct bpf_version {
|
||||
* being able to handle captures with your new DLT_ value, with no hope
|
||||
* that they will ever be changed to do so (as that would destroy their
|
||||
* ability to read captures using that value for that other purpose).
|
||||
*
|
||||
* See
|
||||
*
|
||||
* http://www.tcpdump.org/linktypes.html
|
||||
*
|
||||
* for detailed descriptions of some of these link-layer header types.
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -203,10 +209,23 @@ struct bpf_version {
|
||||
|
||||
/*
|
||||
* Values between 100 and 103 are used in capture file headers as
|
||||
* link-layer types corresponding to DLT_ types that differ
|
||||
* between platforms; don't use those values for new DLT_ new types.
|
||||
* link-layer header type LINKTYPE_ values corresponding to DLT_ types
|
||||
* that differ between platforms; don't use those values for new DLT_
|
||||
* new types.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Values starting with 104 are used for newly-assigned link-layer
|
||||
* header type values; for those link-layer header types, the DLT_
|
||||
* value returned by pcap_datalink() and passed to pcap_open_dead(),
|
||||
* and the LINKTYPE_ value that appears in capture files, are the
|
||||
* same.
|
||||
*
|
||||
* DLT_MATCHING_MIN is the lowest such value; DLT_MATCHING_MAX is
|
||||
* the highest such value.
|
||||
*/
|
||||
#define DLT_MATCHING_MIN 104
|
||||
|
||||
/*
|
||||
* This value was defined by libpcap 0.5; platforms that have defined
|
||||
* it with a different value should define it here with that value -
|
||||
@@ -697,6 +716,8 @@ struct bpf_version {
|
||||
/*
|
||||
* IEEE 802.15.4, exactly as it appears in the spec (no padding, no
|
||||
* nothing); requested by Mikko Saarnivala <mikko.saarnivala@sensinode.com>.
|
||||
* For this one, we expect the FCS to be present at the end of the frame;
|
||||
* if the frame has no FCS, DLT_IEEE802_15_4_NOFCS should be used.
|
||||
*/
|
||||
#define DLT_IEEE802_15_4 195
|
||||
|
||||
@@ -942,7 +963,7 @@ struct bpf_version {
|
||||
* An IPv4 or IPv6 datagram follows the pseudo-header; dli_family indicates
|
||||
* which of those it is.
|
||||
*/
|
||||
#define DLT_IPNET 226
|
||||
#define DLT_IPNET 226
|
||||
|
||||
/*
|
||||
* CAN (Controller Area Network) frames, with a pseudo-header as supplied
|
||||
@@ -951,14 +972,116 @@ struct bpf_version {
|
||||
*
|
||||
* Requested by Felix Obenhuber <felix@obenhuber.de>.
|
||||
*/
|
||||
#define DLT_CAN_SOCKETCAN 227
|
||||
#define DLT_CAN_SOCKETCAN 227
|
||||
|
||||
/*
|
||||
* Raw IPv4/IPv6; different from DLT_RAW in that the DLT_ value specifies
|
||||
* whether it's v4 or v6. Requested by Darren Reed <Darren.Reed@Sun.COM>.
|
||||
*/
|
||||
#define DLT_IPV4 228
|
||||
#define DLT_IPV6 229
|
||||
#define DLT_IPV4 228
|
||||
#define DLT_IPV6 229
|
||||
|
||||
/*
|
||||
* IEEE 802.15.4, exactly as it appears in the spec (no padding, no
|
||||
* nothing), and with no FCS at the end of the frame; requested by
|
||||
* Jon Smirl <jonsmirl@gmail.com>.
|
||||
*/
|
||||
#define DLT_IEEE802_15_4_NOFCS 230
|
||||
|
||||
/*
|
||||
* Raw D-Bus:
|
||||
*
|
||||
* http://www.freedesktop.org/wiki/Software/dbus
|
||||
*
|
||||
* messages:
|
||||
*
|
||||
* http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-messages
|
||||
*
|
||||
* starting with the endianness flag, followed by the message type, etc.,
|
||||
* but without the authentication handshake before the message sequence:
|
||||
*
|
||||
* http://dbus.freedesktop.org/doc/dbus-specification.html#auth-protocol
|
||||
*
|
||||
* Requested by Martin Vidner <martin@vidner.net>.
|
||||
*/
|
||||
#define DLT_DBUS 231
|
||||
|
||||
/*
|
||||
* Juniper-private data link type, as per request from
|
||||
* Hannes Gredler <hannes@juniper.net>.
|
||||
*/
|
||||
#define DLT_JUNIPER_VS 232
|
||||
#define DLT_JUNIPER_SRX_E2E 233
|
||||
#define DLT_JUNIPER_FIBRECHANNEL 234
|
||||
|
||||
/*
|
||||
* DVB-CI (DVB Common Interface for communication between a PC Card
|
||||
* module and a DVB receiver). See
|
||||
*
|
||||
* http://www.kaiser.cx/pcap-dvbci.html
|
||||
*
|
||||
* for the specification.
|
||||
*
|
||||
* Requested by Martin Kaiser <martin@kaiser.cx>.
|
||||
*/
|
||||
#define DLT_DVB_CI 235
|
||||
|
||||
/*
|
||||
* Variant of 3GPP TS 27.010 multiplexing protocol (similar to, but
|
||||
* *not* the same as, 27.010). Requested by Hans-Christoph Schemmel
|
||||
* <hans-christoph.schemmel@cinterion.com>.
|
||||
*/
|
||||
#define DLT_MUX27010 236
|
||||
|
||||
/*
|
||||
* STANAG 5066 D_PDUs. Requested by M. Baris Demiray
|
||||
* <barisdemiray@gmail.com>.
|
||||
*/
|
||||
#define DLT_STANAG_5066_D_PDU 237
|
||||
|
||||
/*
|
||||
* Juniper-private data link type, as per request from
|
||||
* Hannes Gredler <hannes@juniper.net>.
|
||||
*/
|
||||
#define DLT_JUNIPER_ATM_CEMIC 238
|
||||
|
||||
/*
|
||||
* NetFilter LOG messages
|
||||
* (payload of netlink NFNL_SUBSYS_ULOG/NFULNL_MSG_PACKET packets)
|
||||
*
|
||||
* Requested by Jakub Zawadzki <darkjames-ws@darkjames.pl>
|
||||
*/
|
||||
#define DLT_NFLOG 239
|
||||
|
||||
/*
|
||||
* Hilscher Gesellschaft fuer Systemautomation mbH link-layer type
|
||||
* for Ethernet packets with a 4-byte pseudo-header and always
|
||||
* with the payload including the FCS, as supplied by their
|
||||
* netANALYZER hardware and software.
|
||||
*
|
||||
* Requested by Holger P. Frommer <HPfrommer@hilscher.com>
|
||||
*/
|
||||
#define DLT_NETANALYZER 240
|
||||
|
||||
/*
|
||||
* Hilscher Gesellschaft fuer Systemautomation mbH link-layer type
|
||||
* for Ethernet packets with a 4-byte pseudo-header and FCS and
|
||||
* with the Ethernet header preceded by 7 bytes of preamble and
|
||||
* 1 byte of SFD, as supplied by their netANALYZER hardware and
|
||||
* software.
|
||||
*
|
||||
* Requested by Holger P. Frommer <HPfrommer@hilscher.com>
|
||||
*/
|
||||
#define DLT_NETANALYZER_TRANSPARENT 241
|
||||
|
||||
/*
|
||||
* IP-over-Infiniband, as specified by RFC 4391.
|
||||
*
|
||||
* Requested by Petr Sumbera <petr.sumbera@oracle.com>.
|
||||
*/
|
||||
#define DLT_IPOIB 242
|
||||
|
||||
#define DLT_MATCHING_MAX 242 /* highest value in the "matching" range */
|
||||
|
||||
/*
|
||||
* DLT and savefile link type values are split into a class and
|
||||
@@ -1069,4 +1192,4 @@ extern u_int bpf_filter();
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif /* !defined(_NET_BPF_H_) && !defined(_BPF_H_) && !defined(_H_BPF) && !defined(lib_pcap_bpf_h) */
|
||||
|
||||
@@ -251,6 +251,8 @@ typedef void (*pcap_handler)(u_char *, const struct pcap_pkthdr *,
|
||||
#define PCAP_ERROR_NOT_RFMON -7 /* operation supported only in monitor mode */
|
||||
#define PCAP_ERROR_PERM_DENIED -8 /* no permission to open the device */
|
||||
#define PCAP_ERROR_IFACE_NOT_UP -9 /* interface isn't up */
|
||||
#define PCAP_ERROR_CANTSET_TSTAMP_TYPE -10 /* this device doesn't support setting the time stamp type */
|
||||
#define PCAP_ERROR_PROMISC_PERM_DENIED -11 /* you don't have permission to capture in promiscuous mode */
|
||||
|
||||
/*
|
||||
* Warning codes for the pcap API.
|
||||
@@ -259,6 +261,7 @@ typedef void (*pcap_handler)(u_char *, const struct pcap_pkthdr *,
|
||||
*/
|
||||
#define PCAP_WARNING 1 /* generic warning code */
|
||||
#define PCAP_WARNING_PROMISC_NOTSUP 2 /* this device doesn't support promiscuous mode */
|
||||
#define PCAP_WARNING_TSTAMP_TYPE_NOTSUP 3 /* the requested time stamp type is not supported */
|
||||
|
||||
/*
|
||||
* Value to pass to pcap_compile() as the netmask if you don't know what
|
||||
@@ -275,9 +278,60 @@ int pcap_set_promisc(pcap_t *, int);
|
||||
int pcap_can_set_rfmon(pcap_t *);
|
||||
int pcap_set_rfmon(pcap_t *, int);
|
||||
int pcap_set_timeout(pcap_t *, int);
|
||||
int pcap_set_tstamp_type(pcap_t *, int);
|
||||
int pcap_set_buffer_size(pcap_t *, int);
|
||||
int pcap_activate(pcap_t *);
|
||||
|
||||
int pcap_list_tstamp_types(pcap_t *, int **);
|
||||
void pcap_free_tstamp_types(int *);
|
||||
int pcap_tstamp_type_name_to_val(const char *);
|
||||
const char *pcap_tstamp_type_val_to_name(int);
|
||||
const char *pcap_tstamp_type_val_to_description(int);
|
||||
|
||||
/*
|
||||
* Time stamp types.
|
||||
* Not all systems and interfaces will necessarily support all of these.
|
||||
*
|
||||
* A system that supports PCAP_TSTAMP_HOST is offering time stamps
|
||||
* provided by the host machine, rather than by the capture device,
|
||||
* but not committing to any characteristics of the time stamp;
|
||||
* it will not offer any of the PCAP_TSTAMP_HOST_ subtypes.
|
||||
*
|
||||
* PCAP_TSTAMP_HOST_LOWPREC is a time stamp, provided by the host machine,
|
||||
* that's low-precision but relatively cheap to fetch; it's normally done
|
||||
* using the system clock, so it's normally synchronized with times you'd
|
||||
* fetch from system calls.
|
||||
*
|
||||
* PCAP_TSTAMP_HOST_HIPREC is a time stamp, provided by the host machine,
|
||||
* that's high-precision; it might be more expensive to fetch. It might
|
||||
* or might not be synchronized with the system clock, and might have
|
||||
* problems with time stamps for packets received on different CPUs,
|
||||
* depending on the platform.
|
||||
*
|
||||
* PCAP_TSTAMP_ADAPTER is a high-precision time stamp supplied by the
|
||||
* capture device; it's synchronized with the system clock.
|
||||
*
|
||||
* PCAP_TSTAMP_ADAPTER_UNSYNCED is a high-precision time stamp supplied by
|
||||
* the capture device; it's not synchronized with the system clock.
|
||||
*
|
||||
* Note that time stamps synchronized with the system clock can go
|
||||
* backwards, as the system clock can go backwards. If a clock is
|
||||
* not in sync with the system clock, that could be because the
|
||||
* system clock isn't keeping accurate time, because the other
|
||||
* clock isn't keeping accurate time, or both.
|
||||
*
|
||||
* Note that host-provided time stamps generally correspond to the
|
||||
* time when the time-stamping code sees the packet; this could
|
||||
* be some unknown amount of time after the first or last bit of
|
||||
* the packet is received by the network adapter, due to batching
|
||||
* of interrupts for packet arrival, queueing delays, etc..
|
||||
*/
|
||||
#define PCAP_TSTAMP_HOST 0 /* host-provided, unknown characteristics */
|
||||
#define PCAP_TSTAMP_HOST_LOWPREC 1 /* host-provided, low precision */
|
||||
#define PCAP_TSTAMP_HOST_HIPREC 2 /* host-provided, high precision */
|
||||
#define PCAP_TSTAMP_ADAPTER 3 /* device-provided, synced with the system clock */
|
||||
#define PCAP_TSTAMP_ADAPTER_UNSYNCED 4 /* device-provided, not synced with the system clock */
|
||||
|
||||
pcap_t *pcap_open_live(const char *, int, int, int, char *);
|
||||
pcap_t *pcap_open_dead(int, int);
|
||||
pcap_t *pcap_open_offline(const char *, char *);
|
||||
@@ -348,8 +402,16 @@ void pcap_freealldevs(pcap_if_t *);
|
||||
|
||||
const char *pcap_lib_version(void);
|
||||
|
||||
/* XXX this guy lives in the bpf tree */
|
||||
/*
|
||||
* On at least some versions of NetBSD, we don't want to declare
|
||||
* bpf_filter() here, as it's also be declared in <net/bpf.h>, with a
|
||||
* different signature, but, on other BSD-flavored UN*Xes, it's not
|
||||
* declared in <net/bpf.h>, so we *do* want to declare it here, so it's
|
||||
* declared when we build pcap-bpf.c.
|
||||
*/
|
||||
#ifndef __NetBSD__
|
||||
u_int bpf_filter(const struct bpf_insn *, const u_char *, u_int, u_int);
|
||||
#endif
|
||||
int bpf_validate(const struct bpf_insn *f, int len);
|
||||
char *bpf_image(const struct bpf_insn *, int);
|
||||
void bpf_dump(const struct bpf_program *, int);
|
||||
@@ -397,4 +459,4 @@ int pcap_get_selectable_fd(pcap_t *);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif /* lib_pcap_pcap_h */
|
||||
|
||||
@@ -43,6 +43,11 @@ returns 0 on success without warnings,
|
||||
.B PCAP_WARNING_PROMISC_NOTSUP
|
||||
on success on a device that doesn't support promiscuous mode if
|
||||
promiscuous mode was requested,
|
||||
.B PCAP_WARNING_TSTAMP_TYPE_NOTSUP
|
||||
on success if the time stamp type specified in a previous
|
||||
.B pcap_set_tstamp_type()
|
||||
call isn't supported by the capture source (the time stamp type is
|
||||
left as the default),
|
||||
.B PCAP_WARNING
|
||||
on success with any other warning,
|
||||
.B PCAP_ERROR_ACTIVATED
|
||||
@@ -52,6 +57,9 @@ if the capture source specified when the handle was created doesn't
|
||||
exist,
|
||||
.B PCAP_ERROR_PERM_DENIED
|
||||
if the process doesn't have permission to open the capture source,
|
||||
.B PCAP_ERROR_PROMISC_PERM_DENIED
|
||||
if the process has permission to open the capture source but doesn't
|
||||
have permission to put it into promiscuous mode,
|
||||
.B PCAP_ERROR_RFMON_NOTSUP
|
||||
if monitor mode was specified but the capture source doesn't support
|
||||
monitor mode,
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
.\"
|
||||
.TH PCAP_CAN_SET_RFMON 3PCAP "5 April 2008"
|
||||
.TH PCAP_CAN_SET_RFMON 3PCAP "18 May 2010"
|
||||
.SH NAME
|
||||
pcap_can_set_rfmon \- check whether monitor mode can be set for a
|
||||
not-yet-activated capture handle
|
||||
@@ -37,11 +37,15 @@ int pcap_can_set_rfmon(pcap_t *p);
|
||||
checks whether monitor mode could be set on a capture handle when
|
||||
the handle is activated.
|
||||
.SH RETURN VALUE
|
||||
.B pcap_set_rfmon()
|
||||
.B pcap_can_set_rfmon()
|
||||
returns 0 if monitor mode could not be set,
|
||||
1 if monitor mode could be set,
|
||||
.B PCAP_ERROR_NO_SUCH_DEVICE
|
||||
if the device specified when the handle was created doesn't exist,
|
||||
if the capture source specified when the handle was created doesn't
|
||||
exist,
|
||||
.B PCAP_ERROR_PERM_DENIED
|
||||
if the process doesn't have permission to check whether monitor mode
|
||||
could be supported,
|
||||
.B PCAP_ERROR_ACTIVATED
|
||||
if called on a capture handle that has been activated, or
|
||||
.B PCAP_ERROR
|
||||
|
||||
@@ -55,7 +55,7 @@ the filter program. If the netmask of the network on which packets are
|
||||
being captured isn't known to the program, or if packets are being
|
||||
captured on the Linux "any" pseudo-interface that can capture on more
|
||||
than one network, a value of PCAP_NETMASK_UNKNOWN can be supplied; tests
|
||||
for IPv4 broadcast addreses will fail to compile, but all other tests in
|
||||
for IPv4 broadcast addresses will fail to compile, but all other tests in
|
||||
the filter program will be OK.
|
||||
.SH RETURN VALUE
|
||||
.B pcap_compile()
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
.\"
|
||||
.TH PCAP_DATALINK 3PCAP "5 April 2008"
|
||||
.TH PCAP_DATALINK 3PCAP "22 August 2010"
|
||||
.SH NAME
|
||||
pcap_datalink \- get the link-layer header type
|
||||
.SH SYNOPSIS
|
||||
@@ -34,7 +34,7 @@ int pcap_datalink(pcap_t *p);
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
.B pcap_datalink()
|
||||
returns the link layer type for the live capture or ``savefile''
|
||||
returns the link-layer header type for the live capture or ``savefile''
|
||||
specified by
|
||||
.IR p .
|
||||
.SH SEE ALSO
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
.\"
|
||||
.TH PCAP_DATALINK_NAME_TO_VAL 3PCAP "5 April 2008"
|
||||
.TH PCAP_DATALINK_NAME_TO_VAL 3PCAP "22 August 2010"
|
||||
.SH NAME
|
||||
pcap_datalink_name_to_val \- get the link-layer header type value
|
||||
corresponding to a header type name
|
||||
@@ -35,12 +35,12 @@ int pcap_datalink_name_to_val(const char *name);
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
.B pcap_datalink_name_to_val()
|
||||
translates a data link type name, which is a
|
||||
translates a link-layer header type name, which is a
|
||||
.B DLT_
|
||||
name with the
|
||||
.B DLT_
|
||||
removed, to the corresponding data link type value. The translation
|
||||
is case-insensitive.
|
||||
removed, to the corresponding link-layer header type value. The
|
||||
translation is case-insensitive.
|
||||
.SH RETURN VALUE
|
||||
.B pcap_datalink_name_to_val()
|
||||
returns 0 on success and \-1 on failure.
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
.\"
|
||||
.TH PCAP_DATALINK_VAL_TO_NAME 3PCAP "24 December 2008"
|
||||
.TH PCAP_DATALINK_VAL_TO_NAME 3PCAP "22 August 2010"
|
||||
.SH NAME
|
||||
pcap_datalink_val_to_name, pcap_datalink_val_to_description \- get a
|
||||
name or description for a link-layer header type value
|
||||
@@ -36,9 +36,9 @@ const char *pcap_datalink_val_to_description(int dlt);
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
.B pcap_datalink_val_to_name()
|
||||
translates a data link type value to the corresponding data link type
|
||||
name. NULL is returned on failure.
|
||||
translates a link-layer header type value to the corresponding
|
||||
link-layer header type name. NULL is returned on failure.
|
||||
.PP
|
||||
.B pcap_datalink_val_to_description()
|
||||
translates a data link type value to a short description of that data
|
||||
link type. NULL is returned on failure.
|
||||
translates a link-layer header type value to a short description of that
|
||||
link-layer header type. NULL is returned on failure.
|
||||
|
||||
@@ -47,7 +47,7 @@ returns the file descriptor from which captured packets are read.
|
||||
.LP
|
||||
If
|
||||
.I p
|
||||
refers to a ``savefile'' that was opened using fuctions such as
|
||||
refers to a ``savefile'' that was opened using functions such as
|
||||
.BR pcap_open_offline()
|
||||
or
|
||||
.BR pcap_fopen_offline() ,
|
||||
|
||||
@@ -19,9 +19,10 @@
|
||||
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
.\"
|
||||
.TH PCAP_FINDALLDEVS 3PCAP "5 April 2008"
|
||||
.TH PCAP_FINDALLDEVS 3PCAP "22 August 2010"
|
||||
.SH NAME
|
||||
pcap_findalldevs \- get a list of capture devices
|
||||
pcap_findalldevs, pcap_freealldevs \- get a list of capture devices, and
|
||||
free that list
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
.ft B
|
||||
@@ -35,6 +36,7 @@ char errbuf[PCAP_ERRBUF_SIZE];
|
||||
.LP
|
||||
.ft B
|
||||
int pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf);
|
||||
void pcap_freealldevs(pcap_if_t *alldevs);
|
||||
.ft
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
@@ -48,12 +50,17 @@ or with
|
||||
(Note that there may be network devices that cannot be opened by the
|
||||
process calling
|
||||
.BR pcap_findalldevs() ,
|
||||
because, for example, that process might not have sufficient privileges
|
||||
because, for example, that process does not have sufficient privileges
|
||||
to open them for capturing; if so, those devices will not appear on the
|
||||
list.)
|
||||
If
|
||||
.B pcap_findalldevs()
|
||||
succeeds, the pointer pointed to by
|
||||
.I alldevsp
|
||||
is set to point to the first element of the list; each element of the
|
||||
list is of type
|
||||
is set to point to the first element of the list, or to
|
||||
.B NULL
|
||||
if no devices were found (this is considered success).
|
||||
Each element of the list is of type
|
||||
.BR pcap_if_t ,
|
||||
and has the following members:
|
||||
.RS
|
||||
@@ -75,14 +82,18 @@ if not
|
||||
a pointer to a string giving a human-readable description of the device
|
||||
.TP
|
||||
.B addresses
|
||||
a pointer to the first element of a list of addresses for the interface
|
||||
a pointer to the first element of a list of network addresses for the
|
||||
device,
|
||||
or
|
||||
.B NULL
|
||||
if the device has no addresses
|
||||
.TP
|
||||
.B flags
|
||||
interface flags:
|
||||
device flags:
|
||||
.RS
|
||||
.TP
|
||||
.B PCAP_IF_LOOPBACK
|
||||
set if the interface is a loopback interface
|
||||
set if the device is a loopback interface
|
||||
.RE
|
||||
.RE
|
||||
.PP
|
||||
@@ -119,7 +130,7 @@ a pointer to a
|
||||
that contains the broadcast address corresponding to the address pointed
|
||||
to by
|
||||
.BR addr ;
|
||||
may be null if the interface doesn't support broadcasts
|
||||
may be null if the device doesn't support broadcasts
|
||||
.TP
|
||||
.B dstaddr
|
||||
if not
|
||||
@@ -129,21 +140,40 @@ a pointer to a
|
||||
that contains the destination address corresponding to the address pointed
|
||||
to by
|
||||
.BR addr ;
|
||||
may be null if the interface isn't a point-to-point interface
|
||||
may be null if the device isn't a point-to-point interface
|
||||
.RE
|
||||
.PP
|
||||
Note that not all the addresses in the list of addresses are
|
||||
necessarily IPv4 or IPv6 addresses - you must check the
|
||||
Note that the addresses in the list of addresses might be IPv4
|
||||
addresses, IPv6 addresses, or some other type of addresses, so you must
|
||||
check the
|
||||
.B sa_family
|
||||
member of the
|
||||
.B "struct sockaddr"
|
||||
before interpreting the contents of the address.
|
||||
before interpreting the contents of the address; do not assume that the
|
||||
addresses are all IPv4 addresses, or even all IPv4 or IPv6 addresses.
|
||||
IPv4 addresses have the value
|
||||
.BR AF_INET ,
|
||||
IPv6 addresses have the value
|
||||
.B AF_INET6
|
||||
(which older operating systems that don't support IPv6 might not
|
||||
define), and other addresses have other values. Whether other addresses
|
||||
are returned, and what types they might have is platform-dependent.
|
||||
For IPv4 addresses, the
|
||||
.B "struct sockaddr"
|
||||
pointer can be interpreted as if it pointed to a
|
||||
.BR "struct sockaddr_in" ;
|
||||
for IPv6 addresses, it can be interpreted as if it pointed to a
|
||||
.BR "struct sockaddr_in6".
|
||||
.PP
|
||||
The list of devices must be freed with
|
||||
.BR pcap_freealldevs() .
|
||||
.BR pcap_freealldevs() ,
|
||||
whch frees the list pointed to by
|
||||
.IR alldevs .
|
||||
.SH RETURN VALUE
|
||||
.B pcap_findalldevs()
|
||||
returns 0 on success and \-1 on failure.
|
||||
returns 0 on success and \-1 on failure; as indicated, finding no
|
||||
devices is considered success, rather than failure, so 0 will be
|
||||
returned in that case.
|
||||
If \-1 is returned,
|
||||
.I errbuf
|
||||
is filled in with an appropriate error message.
|
||||
@@ -153,4 +183,4 @@ is assumed to be able to hold at least
|
||||
chars.
|
||||
.SH SEE ALSO
|
||||
pcap(3PCAP), pcap_create(3PCAP), pcap_activate(3PCAP),
|
||||
pcap_open_live(3PCAP), pcap_freealldevs(3PCAP)
|
||||
pcap_open_live(3PCAP)
|
||||
|
||||
@@ -56,19 +56,29 @@ or
|
||||
(for example, regular network devices on FreeBSD 4.3 and 4.4, and Endace
|
||||
DAG devices), so \-1 is returned for those devices.
|
||||
.PP
|
||||
Note that on most versions of most BSDs (including Mac OS X)
|
||||
Note that in:
|
||||
.IP
|
||||
FreeBSD prior to FreeBSD 4.6;
|
||||
.IP
|
||||
NetBSD prior to NetBSD 3.0;
|
||||
.IP
|
||||
OpenBSD prior to OpenBSD 2.4;
|
||||
.IP
|
||||
Mac OS X prior to Mac OS X 10.7;
|
||||
.PP
|
||||
.B select()
|
||||
and
|
||||
.B poll()
|
||||
do not work correctly on BPF devices;
|
||||
.B pcap_get_selectable_fd()
|
||||
will return a file descriptor on most of those versions (the exceptions
|
||||
being FreeBSD 4.3 and 4.4), a simple
|
||||
being FreeBSD 4.3 and 4.4), but a simple
|
||||
.B select()
|
||||
or
|
||||
.B poll()
|
||||
will not return even after the read timeout expires. To work around
|
||||
this, an application that uses
|
||||
will not indicate that the descriptor is readable until a full buffer's
|
||||
worth of packets is received, even if the read timeout expires before
|
||||
then. To work around this, an application that uses
|
||||
.B select()
|
||||
or
|
||||
.B poll()
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
.\"
|
||||
.TH PCAP_LIST_DATALINKS 3PCAP "5 April 2008"
|
||||
.TH PCAP_LIST_DATALINKS 3PCAP "22 August 2010"
|
||||
.SH NAME
|
||||
pcap_list_datalinks \- get a list of link-layer header types supported
|
||||
by a capture device
|
||||
pcap_list_datalinks, pcap_free_datalinks \- get a list of link-layer header
|
||||
types supported by a capture device, and free that list
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
.ft B
|
||||
@@ -31,21 +31,26 @@ by a capture device
|
||||
.LP
|
||||
.ft B
|
||||
int pcap_list_datalinks(pcap_t *p, int **dlt_buf);
|
||||
void pcap_free_datalinks(int *dlt_list);
|
||||
.ft
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
.B pcap_list_datalinks()
|
||||
is used to get a list of the supported data link types of the interface
|
||||
associated with the pcap descriptor.
|
||||
is used to get a list of the supported link-layer header types of the
|
||||
interface associated with the pcap descriptor.
|
||||
.B pcap_list_datalinks()
|
||||
allocates an array to hold the list and sets
|
||||
.IR *dlt_buf .
|
||||
.IR *dlt_buf
|
||||
to point to that array.
|
||||
.LP
|
||||
The caller is responsible for freeing the array with
|
||||
.BR pcap_free_datalinks (3PCAP).
|
||||
.BR pcap_free_datalinks() ,
|
||||
which frees the list of link-layer header types pointed to by
|
||||
.IR dlt_list .
|
||||
.SH RETURN VALUE
|
||||
.B pcap_list_datalinks()
|
||||
returns the number of data link types in the array on success and \-1
|
||||
on failure.
|
||||
returns the number of link-layer header types in the array on success
|
||||
and \-1 on failure.
|
||||
If \-1 is returned,
|
||||
.B pcap_geterr()
|
||||
or
|
||||
@@ -54,5 +59,6 @@ may be called with
|
||||
.I p
|
||||
as an argument to fetch or display the error text.
|
||||
.SH SEE ALSO
|
||||
pcap(3PCAP), pcap_geterr(3PCAP), pcap_free_datalinks(3PCAP),
|
||||
pcap(3PCAP), pcap_geterr(3PCAP),
|
||||
pcap_datalink_val_to_name(3PCAP),
|
||||
pcap-linktype(@MAN_MISC_INFO@)
|
||||
|
||||
70
libpcap/pcap_list_tstamp_types.3pcap.in
Normal file
70
libpcap/pcap_list_tstamp_types.3pcap.in
Normal file
@@ -0,0 +1,70 @@
|
||||
.\"
|
||||
.\" Copyright (c) 1994, 1996, 1997
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that: (1) source code distributions
|
||||
.\" retain the above copyright notice and this paragraph in its entirety, (2)
|
||||
.\" distributions including binary code include the above copyright notice and
|
||||
.\" this paragraph in its entirety in the documentation or other materials
|
||||
.\" provided with the distribution, and (3) all advertising materials mentioning
|
||||
.\" features or use of this software display the following acknowledgement:
|
||||
.\" ``This product includes software developed by the University of California,
|
||||
.\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
|
||||
.\" the University nor the names of its contributors may be used to endorse
|
||||
.\" or promote products derived from this software without specific prior
|
||||
.\" written permission.
|
||||
.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
.\"
|
||||
.TH PCAP_LIST_TSTAMP_TYPES 3PCAP "21 August 2010"
|
||||
.SH NAME
|
||||
pcap_list_tstamp_types, pcap_free_tstamp_types \- get a list of time
|
||||
stamp types supported by a capture device, and free that list
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
.ft B
|
||||
#include <pcap/pcap.h>
|
||||
.ft
|
||||
.LP
|
||||
.ft B
|
||||
int pcap_list_tstamp_types(pcap_t *p, int **tstamp_typesp);
|
||||
void pcap_free_tstamp_types(int *tstamp_types);
|
||||
.ft
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
.B pcap_list_tstamp_types()
|
||||
is used to get a list of the supported time stamp types of the interface
|
||||
associated with the pcap descriptor.
|
||||
.B pcap_list_tstamp_types()
|
||||
allocates an array to hold the list and sets
|
||||
.I *tstamp_typesp
|
||||
to point to the array.
|
||||
See
|
||||
.BR pcap-tstamp (@MAN_MISC_INFO@)
|
||||
for a list of all the time stamp types.
|
||||
.PP
|
||||
The caller is responsible for freeing the array with
|
||||
.BR pcap_free_tstamp_types() ,
|
||||
which frees the list pointed to by
|
||||
.IR tstamp_types .
|
||||
.SH RETURN VALUE
|
||||
.B pcap_list_tstamp_types()
|
||||
returns the number of time stamp types in the array on success and
|
||||
.B PCAP_ERROR
|
||||
on failure.
|
||||
A return value of zero means that you cannot specify a time stamp type;
|
||||
you are limited to the capture device's default time stamp type.
|
||||
If
|
||||
.B PCAP_ERROR
|
||||
is returned,
|
||||
.B pcap_geterr()
|
||||
or
|
||||
.B pcap_perror()
|
||||
may be called with
|
||||
.I p
|
||||
as an argument to fetch or display the error text.
|
||||
.SH SEE ALSO
|
||||
pcap(3PCAP), pcap_geterr(3PCAP), pcap_tstamp_type_val_to_name(3PCAP),
|
||||
pcap-tstamp(@MAN_MISC_INFO@)
|
||||
@@ -109,7 +109,12 @@ pointer to the first
|
||||
(as given in the
|
||||
.I struct pcap_pkthdr
|
||||
a pointer to which is passed to the callback routine)
|
||||
bytes of data from the packet.
|
||||
bytes of data from the packet. The
|
||||
.I struct pcap_pkthdr
|
||||
and the packet data are not to be freed by the callback routine, and are
|
||||
not guaranteed to be valid after the callback routine returns; if the
|
||||
code needs them to be valid after the callback, it must make a copy of
|
||||
them.
|
||||
.SH RETURN VALUE
|
||||
.B pcap_loop()
|
||||
returns 0 if
|
||||
|
||||
@@ -36,12 +36,14 @@ int pcap_minor_version(pcap_t *p);
|
||||
.SH DESCRIPTION
|
||||
If
|
||||
.I p
|
||||
refers to a savefile,
|
||||
refers to a ``savefile'',
|
||||
.B pcap_major_version()
|
||||
returns the major number of the file format of the savefile and
|
||||
returns the major number of the file format of the ``savefile'' and
|
||||
.B pcap_minor_version()
|
||||
returns the minor number of the file format of the savefile. The
|
||||
version number is stored in the header of the savefile.
|
||||
returns the minor number of the file format of the ``savefile''. The
|
||||
version number is stored in the ``savefile''; note that the meaning of
|
||||
its values depends on the type of ``savefile'' (for example, pcap or
|
||||
pcap-NG).
|
||||
.PP
|
||||
If
|
||||
.I p
|
||||
|
||||
@@ -45,7 +45,16 @@ argument is set to point to the
|
||||
struct for the packet, and the
|
||||
pointer pointed to by the
|
||||
.I pkt_data
|
||||
argument is set to point to the data in the packet.
|
||||
argument is set to point to the data in the packet. The
|
||||
.I struct pcap_pkthdr
|
||||
and the packet data are not to be freed by the caller, and are not
|
||||
guaranteed to be valid after the next call to
|
||||
.BR pcap_next_ex() ,
|
||||
.BR pcap_next() ,
|
||||
.BR pcap_loop() ,
|
||||
or
|
||||
.BR pcap_dispatch() ;
|
||||
if the code needs them to remain valid, it must make a copy of them.
|
||||
.PP
|
||||
.B pcap_next()
|
||||
reads the next packet (by calling
|
||||
@@ -54,7 +63,15 @@ with a
|
||||
.I cnt
|
||||
of 1) and returns a
|
||||
.I u_char
|
||||
pointer to the data in that packet.
|
||||
pointer to the data in that packet. The
|
||||
packet data is not to be freed by the caller, and is not
|
||||
guaranteed to be valid after the next call to
|
||||
.BR pcap_next_ex() ,
|
||||
.BR pcap_next() ,
|
||||
.BR pcap_loop() ,
|
||||
or
|
||||
.BR pcap_dispatch() ;
|
||||
if the code needs it to remain valid, it must make a copy of it.
|
||||
The
|
||||
.I pcap_pkthdr
|
||||
structure pointed to by
|
||||
@@ -78,13 +95,13 @@ as an argument to fetch or display the error text.
|
||||
.B pcap_next()
|
||||
returns a pointer to the packet data on success, and returns
|
||||
.B NULL
|
||||
if an error occured, or if no packets were read from a live
|
||||
if an error occurred, or if no packets were read from a live
|
||||
capture (if, for example, they were discarded because they didn't pass
|
||||
the packet filter, or if, on platforms that support a read timeout that
|
||||
starts before any packets arrive, the timeout expires before any packets
|
||||
arrive, or if the file descriptor for the capture device is in
|
||||
non-blocking mode and no packets were available to be read), or if no
|
||||
more packets are available in a ``savefile.'' Unfortunately, there is
|
||||
no way to determine whether an error occured or not.
|
||||
no way to determine whether an error occurred or not.
|
||||
.SH SEE ALSO
|
||||
pcap(3PCAP), pcap_geterr(3PCAP), pcap_dispatch(3PCAP)
|
||||
|
||||
@@ -74,7 +74,7 @@ is filled in with an appropriate error message.
|
||||
.I errbuf
|
||||
may also be set to warning text when
|
||||
.B pcap_open_live()
|
||||
succeds; to detect this case the caller should store a zero-length string in
|
||||
succeeds; to detect this case the caller should store a zero-length string in
|
||||
.I errbuf
|
||||
before calling
|
||||
.B pcap_open_live()
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
.\"
|
||||
.TH PCAP_SET_DATALINK 3PCAP "5 April 2008"
|
||||
.TH PCAP_SET_DATALINK 3PCAP "22 August 2010"
|
||||
.SH NAME
|
||||
pcap_set_datalink \- set the link-layer header type to be used by a
|
||||
capture device
|
||||
@@ -35,7 +35,7 @@ int pcap_set_datalink(pcap_t *p, int dlt);
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
.B pcap_set_datalink()
|
||||
is used to set the current data link type of the pcap descriptor
|
||||
is used to set the current link-layer header type of the pcap descriptor
|
||||
to the type specified by
|
||||
.IR dlt .
|
||||
.SH RETURN VALUE
|
||||
@@ -49,4 +49,5 @@ may be called with
|
||||
.I p
|
||||
as an argument to fetch or display the error text.
|
||||
.SH SEE ALSO
|
||||
pcap(3PCAP), pcap_geterr(3PCAP)
|
||||
pcap(3PCAP), pcap_geterr(3PCAP),
|
||||
pcap_datalink_name_to_val(3PCAP)
|
||||
|
||||
65
libpcap/pcap_set_tstamp_type.3pcap.in
Normal file
65
libpcap/pcap_set_tstamp_type.3pcap.in
Normal file
@@ -0,0 +1,65 @@
|
||||
.\"
|
||||
.\" Copyright (c) 1994, 1996, 1997
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that: (1) source code distributions
|
||||
.\" retain the above copyright notice and this paragraph in its entirety, (2)
|
||||
.\" distributions including binary code include the above copyright notice and
|
||||
.\" this paragraph in its entirety in the documentation or other materials
|
||||
.\" provided with the distribution, and (3) all advertising materials mentioning
|
||||
.\" features or use of this software display the following acknowledgement:
|
||||
.\" ``This product includes software developed by the University of California,
|
||||
.\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
|
||||
.\" the University nor the names of its contributors may be used to endorse
|
||||
.\" or promote products derived from this software without specific prior
|
||||
.\" written permission.
|
||||
.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
.\"
|
||||
.TH PCAP_SET_TSTAMP_TYPE 3PCAP "21 August 2010"
|
||||
.SH NAME
|
||||
pcap_set_tstamp_type \- set the time stamp type to be used by a
|
||||
capture device
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
.ft B
|
||||
#include <pcap/pcap.h>
|
||||
.ft
|
||||
.LP
|
||||
.ft B
|
||||
int pcap_set_tstamp_type(pcap_t *p, int tstamp_type);
|
||||
.ft
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
.B pcap_set_tstamp_type()
|
||||
sets the the type of time stamp desired for packets captured on the pcap
|
||||
descriptor to the type specified by
|
||||
.IR tstamp_type .
|
||||
It must be called on a pcap descriptor created by
|
||||
.B pcap_create()
|
||||
that has not yet been activated by
|
||||
.BR pcap_activate() .
|
||||
.B pcap_list_tstamp_types()
|
||||
will give a list of the time stamp types supported by a given capture
|
||||
device.
|
||||
See
|
||||
.BR pcap-tstamp (@MAN_MISC_INFO@)
|
||||
for a list of all the time stamp types.
|
||||
.SH RETURN VALUE
|
||||
.B pcap_set_tstamp_type()
|
||||
returns 0 on success if the specified time stamp type is expected to be
|
||||
supported by the capture device,
|
||||
.B PCAP_WARNING_TSTAMP_TYPE_NOTSUP
|
||||
on success if the specified time stamp type is not supported by the
|
||||
capture device,
|
||||
.B PCAP_ERROR_ACTIVATED
|
||||
if called on a capture handle that has been activated, and
|
||||
.B PCAP_ERROR_CANTSET_TSTAMP_TYPE
|
||||
if the capture device doesn't support setting the time stamp type.
|
||||
.SH SEE ALSO
|
||||
pcap(3PCAP),
|
||||
pcap_list_tstamp_types(3PCAP),
|
||||
pcap_tstamp_type_name_to_val(3PCAP),
|
||||
pcap-tstamp(@MAN_MISC_INFO@)
|
||||
@@ -1,4 +1,3 @@
|
||||
.\" @(#) $Header: /tcpdump/master/libpcap/pcap_free_datalinks.3pcap,v 1.1 2008-05-26 19:58:06 guy Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1994, 1996, 1997
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@@ -19,10 +18,10 @@
|
||||
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
.\"
|
||||
.TH PCAP_FREE_DATALINKS 3PCAP "26 May 2008"
|
||||
.TH PCAP_TSTAMP_TYPE_NAME_TO_VAL 3PCAP "21 August 2010"
|
||||
.SH NAME
|
||||
pcap_free_datalinks \- free a list of link-layer header types from
|
||||
pcap_get_datalinks()
|
||||
pcap_tstamp_type_name_to_val \- get the time stamp type value
|
||||
corresponding to a time stamp type name
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
.ft B
|
||||
@@ -30,12 +29,17 @@ pcap_get_datalinks()
|
||||
.ft
|
||||
.LP
|
||||
.ft B
|
||||
void pcap_free_datalinks(int *dlt_list);
|
||||
int pcap_tstamp_type_name_to_val(const char *name);
|
||||
.ft
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
.B pcap_free_datalinks()
|
||||
is used to free a list of supported data link types returned by
|
||||
.BR pcap_list_datalinks() .
|
||||
.B pcap_tstamp_type_name_to_val()
|
||||
translates a time stamp type name to the corresponding time stamp type
|
||||
value. The translation is case-insensitive.
|
||||
.SH RETURN VALUE
|
||||
.B pcap_tstamp_type_name_to_val()
|
||||
returns 0 on success and
|
||||
.B PCAP_ERROR
|
||||
on failure.
|
||||
.SH SEE ALSO
|
||||
pcap(3PCAP), pcap_list_datalinks(3PCAP)
|
||||
pcap(3PCAP), pcap_tstamp_type_val_to_name(3PCAP)
|
||||
@@ -1,4 +1,3 @@
|
||||
.\" @(#) $Header: /tcpdump/master/libpcap/pcap_freealldevs.3pcap,v 1.3 2008-04-06 02:53:22 guy Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1994, 1996, 1997
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@@ -19,22 +18,28 @@
|
||||
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
.\"
|
||||
.TH PCAP_FREEALLDEVS 3PCAP "5 April 2008"
|
||||
.TH PCAP_TSTAMP_TYPE_VAL_TO_NAME 3PCAP "21 August 2010"
|
||||
.SH NAME
|
||||
pcap_freealldevs \- free a list of capture devices
|
||||
pcap_tstamp_type_val_to_name, pcap_tstamp_type_val_to_description \- get
|
||||
a name or description for a time stamp type value
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
.ft B
|
||||
#include <pcap/pcap.h>
|
||||
#include <pcap.h>
|
||||
.ft
|
||||
.LP
|
||||
.ft B
|
||||
void pcap_freealldevs(pcap_if_t *alldevs);
|
||||
const char *pcap_tstamp_type_val_to_name(int tstamp_type);
|
||||
const char *pcap_tstamp_type_val_to_description(int tstamp_type);
|
||||
.ft
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
.B pcap_freealldevs()
|
||||
is used to free a list allocated by
|
||||
.BR pcap_findalldevs() .
|
||||
.B pcap_tstamp_type_val_to_name()
|
||||
translates a time stamp type value to the corresponding time stamp type
|
||||
name. NULL is returned on failure.
|
||||
.PP
|
||||
.B pcap_tstamp_type_val_to_description()
|
||||
translates a time stamp type value to a short description of that time
|
||||
stamp type. NULL is returned on failure.
|
||||
.SH SEE ALSO
|
||||
pcap(3PCAP), pcap_findalldevs(3PCAP)
|
||||
pcap(3PCAP), pcap_tstamp_type_name_to_val(3PCAP)
|
||||
@@ -94,10 +94,16 @@ static int
|
||||
sf_setnonblock(pcap_t *p, int nonblock, char *errbuf)
|
||||
{
|
||||
/*
|
||||
* This is a savefile, not a live capture file, so ignore
|
||||
* requests to put it in non-blocking mode.
|
||||
* This is a savefile, not a live capture file, so reject
|
||||
* requests to put it in non-blocking mode. (If it's a
|
||||
* pipe, it could be put in non-blocking mode, but that
|
||||
* would significantly complicate the code to read packets,
|
||||
* as it would have to handle reading partial packets and
|
||||
* keeping the state of the read.)
|
||||
*/
|
||||
return (0);
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Savefiles cannot be put into non-blocking mode");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -161,6 +167,7 @@ sf_cleanup(pcap_t *p)
|
||||
(void)fclose(p->sf.rfile);
|
||||
if (p->buffer != NULL)
|
||||
free(p->buffer);
|
||||
pcap_freecode(&p->fcode);
|
||||
}
|
||||
|
||||
pcap_t *
|
||||
@@ -376,7 +383,7 @@ pcap_offline_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
|
||||
}
|
||||
|
||||
if ((fcode = p->fcode.bf_insns) == NULL ||
|
||||
bpf_filter(fcode, p->buffer, h.len, h.caplen)) {
|
||||
bpf_filter(fcode, data, h.len, h.caplen)) {
|
||||
(*callback)(user, &h, data);
|
||||
if (++n >= cnt && cnt > 0)
|
||||
break;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user