mirror of
https://github.com/bettercap/bettercap.git
synced 2025-03-12 04:36:03 -07:00
fix: too many drugs ... or not enough yet
This commit is contained in:
parent
8516f5075d
commit
3ce75555da
libpcap-1.8.1.tar.gz
libpcap-1.8.1
CHANGESCMakeLists.txtCREDITS
ChmodBPF
GenVersion.batINSTALL.txtLICENSEMakefileMakefile-devel-addsMakefile.inREADMEREADME.Win32README.aixREADME.dagREADME.hpuxREADME.linuxREADME.macosxREADME.septelREADME.sitaREADME.tru64SUNOS4
TODOVERSIONWin32
aclocal.m4arcnet.hatmuni31.hbpf/net
bpf_dump.cbpf_dump.obpf_filter.cbpf_filter.obpf_image.cbpf_image.ochmod_bpfcmake
cmakeconfig.h.inconfig.guessconfig.hconfig.h.inconfig.logconfig.statusconfig.subconfig
configureconfigure.acdlpisubs.cdlpisubs.hetherent.cetherent.oethertype.hextract.hfad-getad.cfad-getad.ofad-gifc.cfad-glifc.cfad-helpers.cfad-helpers.ogen_version_c.shgen_version_header.shgencode.cgencode.hgencode.ogrammar.cgrammar.hgrammar.ogrammar.yieee80211.hinet.cinet.oinstall-shlbl
libpcap.alibpcap.so.1.8.1llc.hmissing
mkdepmsdos
Binary file not shown.
@ -1,837 +0,0 @@
|
||||
Tuesday, Oct. 25, 2016 mcr@sandelman.ca
|
||||
Summary for 1.8.1 libpcap release
|
||||
Add a target in Makefile.in for Exuberant Ctags use: 'extags'.
|
||||
Rename configure.in to configure.ac: autoconf 2.59
|
||||
Clean up the name-to-DLT mapping table.
|
||||
Add some newer DLT_ values: IPMI_HPM_2,ZWAVE_R1_R2,ZWAVE_R3,WATTSTOPPER_DLM,ISO_14443,RDS
|
||||
Clarify what the return values are for both success and failure.
|
||||
Many changes to build on windows
|
||||
Check for the "break the loop" condition in the inner loop for TPACKET_V3.
|
||||
Fix handling of packet count in the TPACKET_V3 inner loop: GitHub issue #493.
|
||||
Filter out duplicate looped back CAN frames.
|
||||
Fix the handling of loopback filters for IPv6 packets.
|
||||
Add a link-layer header type for RDS (IEC 62106) groups.
|
||||
Use different intermediate folders for x86 and x64 builds on Windows.
|
||||
On Linux, handle all CAN captures with pcap-linux.c, in cooked mode.
|
||||
Removes the need for the "host-endian" link-layer header type.
|
||||
Compile with '-Wused-but-marked-unused' in devel mode if supported
|
||||
Have separate DLTs for big-endian and host-endian SocketCAN headers.
|
||||
Reflect version.h being renamed to pcap_version.h.
|
||||
Require that version.h be generated: all build procedures we support generate version.h (autoconf, CMake, MSVC)!
|
||||
Properly check for sock_recv() errors.
|
||||
Re-impose some of Winsock's limitations on sock_recv().
|
||||
Replace sprintf() with pcap_snprintf().
|
||||
Fix signature of pcap_stats_ex_remote().
|
||||
Initial cmake support for remote packet capture.
|
||||
Have rpcap_remoteact_getsock() return a SOCKET and supply an "is active" flag.
|
||||
Clean up {DAG, Septel, Myricom SNF}-only builds.
|
||||
Do UTF-16-to-ASCII conversion into the right place.
|
||||
pcap_create_interface() needs the interface name on Linux.
|
||||
Clean up hardware time stamp support: the "any" device does not support any time stamp types.
|
||||
Add support for capturing on FreeBSD usbusN interfaces.
|
||||
Add a LINKTYPE/DLT_ value for FreeBSD USB.
|
||||
Go back to using PCAP_API on Windows.
|
||||
CMake support
|
||||
Add TurboCap support from WinPcap.
|
||||
Recognize 802.1ad nested VLAN tag in vlan filter.
|
||||
|
||||
Thursday Sep. 3, 2015 guy@alum.mit.edu
|
||||
Summary for 1.7.5 libpcap release
|
||||
Man page cleanups.
|
||||
Add some allocation failure checks.
|
||||
Fix a number of Linux/ucLinux configure/build issues.
|
||||
Fix some memory leaks.
|
||||
Recognize 802.1ad nested VLAN tag in vlan filter.
|
||||
Fix building Bluetooth Linux Monitor support with BlueZ 5.1+
|
||||
|
||||
Saturday Jun. 27, 2015 mcr@sandelman.ca
|
||||
Summary for 1.7.4 libpcap release
|
||||
Include fix for GitHub issue #424 -- out of tree builds.
|
||||
|
||||
Friday Apr. 10, 2015 guy@alum.mit.edu
|
||||
Summary for 1.7.3 libpcap release
|
||||
Work around a Linux bonding driver bug.
|
||||
|
||||
Thursday Feb. 12, 2015 guy@alum.mit.edu/mcr@sandelman.ca
|
||||
Summary for 1.7.2 libpcap release
|
||||
Support for filtering Geneve encapsulated packets.
|
||||
Generalize encapsulation handling, fixing some bugs.
|
||||
Don't add null addresses to address lists.
|
||||
Add pcap_dump_open_append() to open for appending.
|
||||
Fix the swapping of isochronous descriptors in Linux USB.
|
||||
Attempt to handle TPACKET_V1 with 32-bit userland and 64-bit kernel.
|
||||
|
||||
Wednesday Nov. 12, 2014 guy@alum.mit.edu/mcr@sandelman.ca
|
||||
Summary for 1.7.0 libpcap release
|
||||
Fix handling of zones for BPF on Solaris
|
||||
new DLT for ZWAVE
|
||||
clarifications for read timeouts.
|
||||
Use BPF extensions in compiled filters, fixing VLAN filters
|
||||
some fixes to compilation without stdint.h
|
||||
EBUSY can now be returned by SNFv3 code.
|
||||
Fix the range checks in BPF loads
|
||||
Various DAG fixes.
|
||||
Various Linux fixes.
|
||||
|
||||
Monday Aug. 12, 2014 guy@alum.mit.edu
|
||||
Summary for 1.6.2 libpcap release
|
||||
Don't crash on filters testing a non-existent link-layer type
|
||||
field.
|
||||
Fix sending in non-blocking mode on Linux with memory-mapped
|
||||
capture.
|
||||
Fix timestamps when reading pcap-ng files on big-endian
|
||||
machines.
|
||||
|
||||
Saturday Jul. 19, 2014 mcr@sandelman.ca
|
||||
Summary for 1.6.1 libpcap release
|
||||
some fixes for the any device
|
||||
changes for how --enable-XXX (--enable-sniffing, --enable-can) works
|
||||
|
||||
Wednesday Jul. 2, 2014 mcr@sandelman.ca
|
||||
Summary for 1.6.0 libpcap release
|
||||
Don't support D-Bus sniffing on OS X
|
||||
fixes for byte order issues with NFLOG captures
|
||||
Handle using cooked mode for DLT_NETLINK in activate_new().
|
||||
on platforms where you can not capture on down interfaces, do not list them
|
||||
but: do list interfaces which are down, if you can capture on them!
|
||||
|
||||
Wednesday December 18, 2013 guy@alum.mit.edu
|
||||
Summary for 1.5.3 libpcap release
|
||||
Don't let packets that don't match the current filter get to the
|
||||
application when TPACKET_V3 is used. (GitHub issue #331)
|
||||
Fix handling of pcap_loop()/pcap_dispatch() with a packet count
|
||||
of 0 on some platforms (including Linux with TPACKET_V3).
|
||||
(GitHub issue #333)
|
||||
Work around TPACKET_V3 deficiency that causes packets to be lost
|
||||
when a timeout of 0 is specified. (GitHub issue #335)
|
||||
Man page formatting fixes.
|
||||
|
||||
Wednesday December 4, 2013 guy@alum.mit.edu
|
||||
Summary for 1.5.2 libpcap release
|
||||
Fix libpcap to work when compiled with TPACKET_V3 support and
|
||||
running on a kernel without TPACKET_V3 support. (GitHub
|
||||
issue #329)
|
||||
|
||||
Wednesday November 20, 2013 guy@alum.mit.edu
|
||||
Summary for 1.5.1 libpcap release
|
||||
Report an error, rather than crashing, if an IPv6 address is
|
||||
used for link-layer filtering. (Wireshark bug 9376)
|
||||
|
||||
Wednesday October 30, 2013 guy@alum.mit.edu
|
||||
Summary for 1.5.0 libpcap release
|
||||
TPACKET_V3 support added for Linux
|
||||
Point users to the the-tcpdump-group repository on GitHub rather
|
||||
than the mcr repository
|
||||
Checks added for malloc()/realloc()/etc. failures
|
||||
Fixed build on Solaris 11
|
||||
Support filtering filtering E1 SS7 traffic on MTP2 layer Annex A
|
||||
Use "ln -s" to link man pages by default
|
||||
Add support for getting nanosecond-resolution time stamps when
|
||||
capturing and reading capture files
|
||||
Many changes to autoconf to deal better with non-GCC compilers
|
||||
added many new DLT types
|
||||
|
||||
Saturday April 6, 2013 guy@alum.mit.edu
|
||||
Summary for 1.4.0 libpcap release
|
||||
Add netfilter/nfqueue interface.
|
||||
If we don't have support for IPv6 address resolution, support,
|
||||
in filter expressions, what IPv6 stuff we can.
|
||||
Fix pcap-config to include -lpthread if canusb support is
|
||||
present
|
||||
Try to fix "pcap_parse not defined" problems when --without-flex
|
||||
and --without-bison are used when you have Flex and Bison
|
||||
Fix some issues with the pcap_loop man page.
|
||||
Fix pcap_getnonblock() and pcap_setnonblock() to fill in the
|
||||
supplied error message buffer
|
||||
Fix typo that, it appeared, would cause pcap-libdlpi.c not to
|
||||
compile (perhaps systems with libdlpi also have BPF and use
|
||||
that instead)
|
||||
Catch attempts to call pcap_compile() on a non-activated pcap_t
|
||||
Fix crash on Linux with CAN-USB support without usbfs
|
||||
Fix addition of VLAN tags for Linux cooked captures
|
||||
Check for both EOPNOTSUPP and EINVAL after SIOCETHTOOL ioctl, so
|
||||
that the driver can report either one if it doesn't support
|
||||
SIOCETHTOOL
|
||||
Add DLT_INFINIBAND and DLT_SCTP
|
||||
Describe "proto XXX" and "protochain XXX" in the pcap-filter man
|
||||
page
|
||||
Handle either directories, or symlinks to directories, that
|
||||
correspond to interfaces in /sys/class/net
|
||||
Fix handling of VLAN tag insertion to check, on Linux 3.x
|
||||
kernels, for VLAN tag valid flag
|
||||
Clean up some man pages
|
||||
Support libnl3 as well as libnl1 and libnl2 on Linux
|
||||
Fix handling of Bluetooth devices on 3.x Linux kernels
|
||||
|
||||
Friday March 30, 2012. mcr@sandelman.ca
|
||||
Summary for 1.3.0 libpcap release
|
||||
Handle DLT_PFSYNC in {FreeBSD, other *BSD+Mac OS X, other}.
|
||||
Linux: Don't fail if netfilter isn't enabled in the kernel.
|
||||
Add new link-layer type for NFC Forum LLCP.
|
||||
Put the CANUSB stuff into EXTRA_DIST, so it shows up in the release tarball.
|
||||
Add LINKTYPE_NG40/DLT_NG40.
|
||||
Add DLT_MPEG_2_TS/LINKTYPE_MPEG_2_TS for MPEG-2 transport streams.
|
||||
[PATCH] Fix AIX-3.5 crash with read failure during stress
|
||||
AIX fixes.
|
||||
Introduce --disable-shared configure option.
|
||||
Added initial support for canusb devices.
|
||||
Include the pcap(3PCAP) additions as 1.2.1 changes.
|
||||
many updates to documentation: pcap.3pcap.in
|
||||
Improve 'inbound'/'outbound' capture filters under Linux.
|
||||
Note the cleanup of handling of new DLT_/LINKTYPE_ values.
|
||||
On Lion, don't build for PPC.
|
||||
For mac80211 devices we need to clean up monitor mode on exit.
|
||||
|
||||
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.
|
||||
Fix build on RHEL5.
|
||||
Fix shared library build on AIX.
|
||||
|
||||
Thu. March 11, 2010. ken@netfunctional.ca/guy@alum.mit.edu.
|
||||
Summary for 1.1.0 libpcap release
|
||||
Add SocketCAN capture support
|
||||
Add Myricom SNF API support
|
||||
Update Endace DAG and ERF support
|
||||
Add support for shared libraries on Solaris, HP-UX, and AIX
|
||||
Build, install, and un-install shared libraries by default;
|
||||
don't build/install shared libraries on platforms we don't support
|
||||
Fix building from a directory other than the source directory
|
||||
Fix compiler warnings and builds on some platforms
|
||||
Update config.guess and config.sub
|
||||
Support monitor mode on mac80211 devices on Linux
|
||||
Fix USB memory-mapped capturing on Linux; it requires a new DLT_
|
||||
value
|
||||
On Linux, scan /sys/class/net for devices if we have it; scan
|
||||
it, or /proc/net/dev if we don't have /sys/class/net, even if
|
||||
we have getifaddrs(), as it'll find interfaces with no
|
||||
addresses
|
||||
Add limited support for reading pcap-ng files
|
||||
Fix BPF driver-loading error handling on AIX
|
||||
Support getting the full-length interface description on FreeBSD
|
||||
In the lexical analyzer, free up any addrinfo structure we got back
|
||||
from getaddrinfo().
|
||||
Add support for BPF and libdlpi in OpenSolaris (and SXCE)
|
||||
Hyphenate "link-layer" everywhere
|
||||
Add /sys/kernel/debug/usb/usbmon to the list of usbmon locations
|
||||
In pcap_read_linux_mmap(), if there are no frames available, call
|
||||
poll() even if we're in non-blocking mode, so we pick up
|
||||
errors, and check for the errors in question.
|
||||
Note that poll() works on BPF devices is Snow Leopard
|
||||
If an ENXIO or ENETDOWN is received, it may mean the device has
|
||||
gone away. Deal with it.
|
||||
For BPF, raise the default capture buffer size to from 32k to 512k
|
||||
Support ps_ifdrop on Linux
|
||||
Added a bunch of #ifdef directives to make wpcap.dll (WinPcap) compile
|
||||
under cygwin.
|
||||
Changes to Linux mmapped captures.
|
||||
Fix bug where create_ring would fail for particular snaplen and
|
||||
buffer size combinations
|
||||
Update pcap-config so that it handles libpcap requiring
|
||||
additional libraries
|
||||
Add workaround for threadsafeness on Windows
|
||||
Add missing mapping for DLT_ENC <-> LINKTYPE_ENC
|
||||
DLT: Add DLT_CAN_SOCKETCAN
|
||||
DLT: Add Solaris ipnet
|
||||
Don't check for DLT_IPNET if it's not defined
|
||||
Add link-layer types for Fibre Channel FC-2
|
||||
Add link-layer types for Wireless HART
|
||||
Add link-layer types for AOS
|
||||
Add link-layer types for DECT
|
||||
Autoconf fixes (AIX, HP-UX, OSF/1, Tru64 cleanups)
|
||||
Install headers unconditionally, and include vlan.h/bluetooth.h if
|
||||
enabled
|
||||
Autoconf fixes+cleanup
|
||||
Support enabling/disabling bluetooth (--{en,dis}able-bluetooth)
|
||||
Support disabling SITA support (--without-sita)
|
||||
Return -1 on failure to create packet ring (if supported but
|
||||
creation failed)
|
||||
Fix handling of 'any' device, so that it can be opened, and no longer
|
||||
attempt to open it in Monitor mode
|
||||
Add support for snapshot length for USB Memory-Mapped Interface
|
||||
Fix configure and build on recent Linux kernels
|
||||
Fix memory-mapped Linux capture to support pcap_next() and
|
||||
pcap_next_ex()
|
||||
Fixes for Linux USB capture
|
||||
DLT: Add DLT_LINUX_EVDEV
|
||||
DLT: Add DLT_GSMTAP_UM
|
||||
DLT: Add DLT_GSMTAP_ABIS
|
||||
|
||||
Mon. October 27, 2008. ken@netfunctional.ca. Summary for 1.0.0 libpcap release
|
||||
Compile with IPv6 support by default
|
||||
Compile with large file support on by default
|
||||
Add pcap-config script, which deals with -I/-L flags for compiling
|
||||
DLT: Add IPMB
|
||||
DLT: Add LAPD
|
||||
DLT: Add AX25 (AX.25 w/KISS header)
|
||||
DLT: Add JUNIPER_ST
|
||||
802.15.4 support
|
||||
Variable length 802.11 header support
|
||||
X2E data type support
|
||||
SITA ACN Interface support - see README.sita
|
||||
Support for memory-mapped capture on Linux
|
||||
Support for zerocopy BPF on platforms that support it
|
||||
Support for setting buffer size when opening devices
|
||||
Support for setting monitor mode when opening 802.11 devices
|
||||
Better support for dealing with VLAN tagging/stripping on Linux
|
||||
Fix dynamic library support on OSX
|
||||
Return PCAP_ERROR_IFACE_NOT_UP if the interface isn't 'UP', so applications
|
||||
can print better diagnostic information
|
||||
Return PCAP_ERROR_PERM_DENIED if we don't have permission to open a device, so
|
||||
applications can tell the user they need to go play with permissions
|
||||
On Linux, ignore ENETDOWN so we can continue to capture packets if the
|
||||
interface goes down and comes back up again.
|
||||
On Linux, support new tpacket frame headers (2.6.27+)
|
||||
On Mac OS X, add scripts for changing permissions on /dev/bpf* and launchd plist
|
||||
On Solaris, support 'passive mode' on systems that support it
|
||||
Fixes to autoconf and general build environment
|
||||
Man page reorganization + cleanup
|
||||
Autogenerate VERSION numbers better
|
||||
|
||||
Mon. September 10, 2007. ken@xelerance.com. Summary for 0.9.8 libpcap release
|
||||
Change build process to put public libpcap headers into pcap subir
|
||||
DLT: Add value for IPMI IPMB packets
|
||||
DLT: Add value for u10 Networks boards
|
||||
Require <net/pfvar.h> for pf definitions - allows reading of pflog formatted
|
||||
libpcap files on an OS other than where the file was generated
|
||||
|
||||
Wed. April 25, 2007. ken@xelerance.com. Summary for 0.9.6 libpcap release
|
||||
|
||||
Put the public libpcap headers into a pcap subdirectory in both the
|
||||
source directory and the target include directory, and have include
|
||||
files at the top-level directory to include those headers, for
|
||||
backwards compatibility.
|
||||
Add Bluetooth support
|
||||
Add USB capturing support on Linux
|
||||
Add support for the binary USB sniffing interface in Linux
|
||||
Add support for new FreeBSD BIOCSDIRECTION ioctl
|
||||
Add additional filter operations for 802.11 frame types
|
||||
Add support for filtering on MTP2 frame types
|
||||
Propagate some changes from the main branch, so the x.9 branch has
|
||||
all the DLT_ and LINKTYPE_ values that the main branch does
|
||||
Reserved a DLT_ and SAVEFILE_ value for PPI (Per Packet Info)
|
||||
encapsulated packets
|
||||
Add LINKTYPE_ for IEEE 802.15.4, with address fields padded as done
|
||||
by Linux drivers
|
||||
Add LINKTYPE_ value corresponding to DLT_IEEE802_16_MAC_CPS.
|
||||
Add DLT for IEEE 802.16 (WiMAX) MAC Common Part Sublayer
|
||||
Add DLT for Bluetooth HCI UART transport layer
|
||||
When building a shared library, build with "-fPIC" on Linux to support x86_64
|
||||
Link with "$(CC) -shared" rather than "ld -shared" when building a
|
||||
".so" shared library
|
||||
Add support for autoconf 2.60
|
||||
Fixes to discard unread packets when changing filters
|
||||
Changes to handle name changes in the DAG library resulting from
|
||||
switching to libtool.
|
||||
Add support for new DAG ERF types.
|
||||
Add an explicit "-ldag" when building the shared library, so the DAG
|
||||
library dependency is explicit.
|
||||
Mac OSX fixes for dealing with "wlt" devices
|
||||
Fixes in add_or_find_if() & pcap_findalldevs() to optimize generating
|
||||
device lists
|
||||
Fixed a bug in pcap_open_live(). The return value of PacketSetHwFilter
|
||||
was not checked.
|
||||
|
||||
Tue. September 19, 2006. ken@xelerance.com. Summary for 0.9.5 libpcap release
|
||||
|
||||
Support for LAPD frames with vISDN
|
||||
Support for ERF on channelized T1/E1 cards via DAG API
|
||||
Fix capitalization that caused issues crossc compiling on Linux
|
||||
Better failure detection on PacketGetAdapterNames()
|
||||
Fixes for MPLS packet generation (link layer)
|
||||
OP_PACKET now matches the beginning of the packet, instead of
|
||||
beginning+link-layer
|
||||
Add DLT/LINKTYPE for carrying FRF.16 Multi-link Frame Relay
|
||||
Fix allocation of buffer for list of link-layer types
|
||||
Added a new DLT and LINKTYPE value for ARINC 653 Interpartition Communcation Messages
|
||||
Fixed a typo in a DLT value: it should start with DLT_ and not LINKTYPE_
|
||||
Redefined DLT_CAN20B and LINKTYPE_CAN20B as #190 (as this is the right value for CAN).
|
||||
Added definition for DLT_A429 and LINKTYPE_A429 as #184.
|
||||
Added a new DLT and LINKTYPE value for CAN v2.0B frames.
|
||||
Add support for DLT_JUNIPER_VP.
|
||||
Don't double-count received packets on Linux systems that
|
||||
support the PACKET_STATISTICS getsockopt() argument on
|
||||
PF_PACKET sockets.
|
||||
Add support for DLT_IEEE802_11 and DLT_IEEE802_11_RADIO link
|
||||
layers in Windows
|
||||
Add support to build libpcap.lib and wpcap.dll under Cygnus and
|
||||
MingW32.
|
||||
|
||||
Mon. September 5, 2005. ken@xelerance.com. Summary for 0.9.4 libpcap release
|
||||
|
||||
Support for radiotap on Linux (Mike Kershaw)
|
||||
Fixes for HP-UX
|
||||
Support for additional Juniper link-layer types
|
||||
Fixes for filters on MPLS-encapsulated packets
|
||||
"vlan" filter fixed
|
||||
"pppoed" and "pppoes" filters added; the latter modifies later
|
||||
parts of the filter expression to look at the PPP headers and
|
||||
headers in the PPP payload
|
||||
|
||||
Tue. July 5, 2005. ken@xelerance.com. Summary for 0.9.3 libpcap release
|
||||
|
||||
Fixes for compiling on nearly every platform,
|
||||
including improved 64bit support
|
||||
MSDOS Support
|
||||
Add support for sending packets
|
||||
OpenBSD pf format support
|
||||
IrDA capture (Linux only)
|
||||
|
||||
Tue. March 30, 2004. mcr@sandelman.ottawa.on.ca. Summary for 3.8.3 release
|
||||
|
||||
Fixed minor problem in gencode.c that would appear on 64-bit
|
||||
platforms.
|
||||
Version number is now sane.
|
||||
|
||||
Mon. March 29, 2004. mcr@sandelman.ottawa.on.ca. Summary for 3.8.2 release
|
||||
|
||||
updates for autoconf 2.5
|
||||
fixes for ppp interfaces for freebsd 4.1
|
||||
pcap gencode can generate code for 802.11, IEEE1394, and pflog.
|
||||
|
||||
Wed. November 12, 2003. mcr@sandelman.ottawa.on.ca. Summary for 0.8 release
|
||||
|
||||
added pcap_findalldevs()
|
||||
Win32 patches from NetGroup, Politecnico di Torino (Italy)
|
||||
OpenBSD pf, DLT_PFLOG added
|
||||
Many changes to ATM support.
|
||||
lookup pcap_lookupnet()
|
||||
Added DLT_ARCNET_LINUX, DLT_ENC, DLT_IEEE802_11_RADIO, DLT_SUNATM,
|
||||
DLT_IP_OVER_FC, DLT_FRELAY, others.
|
||||
Sigh. More AIX wonderfulness.
|
||||
Document updates.
|
||||
Changes to API: pcap_next_ex(), pcap_breakloop(), pcap_dump_flush(),
|
||||
pcap_list_datalinks(), pcap_set_datalink(),
|
||||
pcap_lib_version(), pcap_datalink_val_to_name(),
|
||||
pcap_datalink_name_to_val(), new error returns.
|
||||
|
||||
Tuesday, February 25, 2003. fenner@research.att.com. 0.7.2 release
|
||||
|
||||
Support link types that use 802.2 always, never, and sometimes.
|
||||
Don't decrease the size of the BPF buffer from the default.
|
||||
Support frame relay.
|
||||
Handle 32-bit timestamps in DLPI, and pass the right buffer size.
|
||||
Handle Linux systems with modern kernel but without
|
||||
SOL_PACKET in the userland headers.
|
||||
Linux support for ARPHRD_RAWHDLC.
|
||||
Handle 32-bit timestamps in snoop.
|
||||
Support eg (Octane/O2xxx/O3xxx Gigabit) devices.
|
||||
Add new reserved DLT types.
|
||||
|
||||
Monday October 23, 2001. mcr@sandelman.ottawa.on.ca. Summary for 0.7 release
|
||||
|
||||
Added pcap_findalldevs() call to get list of interfaces in a MI way.
|
||||
|
||||
pcap_stats() has been documented as to what its counters mean on
|
||||
each platform.
|
||||
|
||||
Tuesday January 9, 2001. guy@alum.mit.edu. Summary for 0.6 release
|
||||
|
||||
New Linux libpcap implementation, which, in 2.2 and later
|
||||
kernels, uses PF_PACKET sockets and supports kernel packet
|
||||
filtering (if compiled into the kernel), and supports the "any"
|
||||
device for capturing on all interfaces. Cleans up promiscuous
|
||||
mode better on pre-2.2 kernels, and has various other fixes
|
||||
(handles 2.4 ARPHRD_IEEE802_TR, handles ISDN devices better,
|
||||
doesn't show duplicate packets on loopback interface, etc.).
|
||||
|
||||
Fixed HP-UX libpcap implementation to correctly get the PPA for
|
||||
an interface, to allow interfaces to be opened by interface name.
|
||||
|
||||
libpcap savefiles have system-independent link-layer type values
|
||||
in the header, rather than sometimes platform-dependent DLT_
|
||||
values, to make it easier to exchange capture files between
|
||||
different OSes.
|
||||
|
||||
Non-standard capture files produced by some Linux tcpdumps, e.g.
|
||||
the one from Red Hat Linux 6.2 and later, can now be read.
|
||||
|
||||
Updated autoconf stock files.
|
||||
|
||||
Filter expressions can filter on VLAN IDs and various OSI
|
||||
protocols, and work on Token Ring (with non-source-routed
|
||||
packets).
|
||||
|
||||
"pcap_open_dead()" added to allow compiling filter expressions
|
||||
to pcap code without opening a capture device or capture file.
|
||||
|
||||
Header files fixed to allow use in C++ programs.
|
||||
|
||||
Removed dependancy on native headers for packet layout.
|
||||
Removed Linux specific headers that were shipped.
|
||||
|
||||
Security fixes: Strcpy replaced with strlcpy, sprintf replaced
|
||||
with snprintf.
|
||||
|
||||
Fixed bug that could cause subsequent "pcap_compile()"s to fail
|
||||
erroneously after one compile failed.
|
||||
|
||||
Assorted other bug fixes.
|
||||
|
||||
README.aix and README.linux files added to describe
|
||||
platform-specific issues.
|
||||
|
||||
"getifaddrs()" rather than SIOCGIFCONF used, if available.
|
||||
|
||||
v0.5 Sat Jun 10 11:09:15 PDT 2000
|
||||
|
||||
itojun@iijlab.net
|
||||
- Brought in KAME IPv6/IPsec bpf compiler.
|
||||
- Fixes for NetBSD.
|
||||
- Support added for OpenBSD DLT_LOOP and BSD/OS DLT_C_HDLC (Cisco HDLC),
|
||||
and changes to work around different BSDs having different DLT_ types
|
||||
with the same numeric value.
|
||||
|
||||
Assar Westerlund <assar@sics.se>
|
||||
- Building outside the source code tree fixed.
|
||||
- Changed to write out time stamps with 32-bit seconds and microseconds
|
||||
fields, regardless of whether those fields are 32 bits or 64 bits in
|
||||
the OS's native "struct timeval".
|
||||
- Changed "pcap_lookupdev()" to dynamically grow the buffer into which
|
||||
the list of interfaces is read as necessary in order to hold the
|
||||
entire list.
|
||||
|
||||
Greg Troxel <gdt@ir.bbn.com>
|
||||
- Added a new "pcap_compile_nopcap()", which lets you compile a filter
|
||||
expression into a BPF program without having an open live capture or
|
||||
capture file.
|
||||
|
||||
v0.4 Sat Jul 25 12:40:09 PDT 1998
|
||||
|
||||
- Fix endian problem with DLT_NULL devices. From FreeBSD via Bill
|
||||
Fenner (fenner@parc.xerox.com)
|
||||
|
||||
- Fix alignment problem with FDDI under DLPI. This was causing core
|
||||
dumps under Solaris.
|
||||
|
||||
- Added configure options to disable flex and bison. Resulted from a
|
||||
bug report by barnett@grymoire.crd.ge.com (Bruce Barnett). Also added
|
||||
options to disable gcc and to force a particular packet capture type.
|
||||
|
||||
- Added support for Fore ATM interfaces (qaa and fa) under IRIX. Thanks
|
||||
to John Hawkinson (jhawk@mit.edu)
|
||||
|
||||
- Change Linux PPP and SLIP to use DLT_RAW since the kernel does not
|
||||
supply any "link layer" data.
|
||||
|
||||
- Change Linux to use SIOCGIFHWADDR ioctl to determine link layer type.
|
||||
Thanks to Thomas Sailer (sailer@ife.ee.ethz.ch)
|
||||
|
||||
- Change IRIX PPP to use DLT_RAW since the kernel does not supply any
|
||||
"link layer" data.
|
||||
|
||||
- Modified to support the new BSD/OS 2.1 PPP and SLIP link layer header
|
||||
formats.
|
||||
|
||||
- Added some new SGI snoop interface types. Thanks to Steve Alexander
|
||||
(sca@refugee.engr.sgi.com)
|
||||
|
||||
- Fixes for HP-UX 10.20 (which is similar to HP-UX 9). Thanks to
|
||||
Richard Allen (ra@hp.is) and Steinar Haug (sthaug@nethelp.no)
|
||||
|
||||
- Fddi supports broadcast as reported by Jeff Macdonald
|
||||
(jeff@iacnet.com). Also correct ieee802 and arcnet.
|
||||
|
||||
- Determine Linux pcap buffer size at run time or else it might not be
|
||||
big enough for some interface types (e.g. FDDI). Thanks to Jes
|
||||
Sorensen (Jes.Sorensen@cern.ch)
|
||||
|
||||
- Fix some linux alignment problems.
|
||||
|
||||
- Document promisc argument to pcap_open_live(). Reported by Ian Marsh
|
||||
(ianm@sics.se)
|
||||
|
||||
- Support Metricom radio packets under Linux. Thanks to Kevin Lai
|
||||
(laik@gunpowder.stanford.edu)
|
||||
|
||||
- Bind to interface name under Linux to avoid packets from multiple
|
||||
interfaces on multi-homed hosts. Thanks to Kevin Lai
|
||||
(laik@gunpowder.stanford.edu)
|
||||
|
||||
- Change L_SET to SEEK_SET for HP-UX. Thanks to Roland Roberts
|
||||
(rroberts@muller.com)
|
||||
|
||||
- Fixed an uninitialized memory reference found by Kent Vander Velden
|
||||
(graphix@iastate.edu)
|
||||
|
||||
- Fixed lex pattern for IDs to allow leading digits. As reported by
|
||||
Theo de Raadt (deraadt@cvs.openbsd.org)
|
||||
|
||||
- Fixed Linux include file problems when using GNU libc.
|
||||
|
||||
- Ifdef ARPHRD_FDDI since not all versions of the Linux kernel have it.
|
||||
Reported reported by Eric Jacksch (jacksch@tenebris.ca)
|
||||
|
||||
- Fixed bug in pcap_dispatch() that kept it from returning on packet
|
||||
timeouts.
|
||||
|
||||
- Changed ISLOOPBACK() macro when IFF_LOOPBACK isn't available to check
|
||||
for "lo" followed by an eos or digit (newer versions of Linux
|
||||
apparently call the loopback "lo" instead of "lo0").
|
||||
|
||||
- Fixed Linux networking include files to use ints instead of longs to
|
||||
avoid problems with 64 bit longs on the alpha. Thanks to Cristian
|
||||
Gafton (gafton@redhat.com)
|
||||
|
||||
v0.3 Sat Nov 30 20:56:27 PST 1996
|
||||
|
||||
- Added Linux support.
|
||||
|
||||
- Fixed savefile bugs.
|
||||
|
||||
- Solaris x86 fix from Tim Rylance (t.rylance@elsevier.nl)
|
||||
|
||||
- Add support for bpf kernel port filters.
|
||||
|
||||
- Remove duplicate atalk protocol table entry. Thanks to Christian
|
||||
Hopps (chopps@water.emich.edu)
|
||||
|
||||
- Fixed pcap_lookupdev() to ignore nonexistent devices. This was
|
||||
reported to happen under BSD/OS by David Vincenzetti
|
||||
(vince@cryptonet.it)
|
||||
|
||||
- Avoid solaris compiler warnings. Thanks to Bruce Barnett
|
||||
(barnett@grymoire.crd.ge.com)
|
||||
|
||||
v0.2.1 Sun Jul 14 03:02:26 PDT 1996
|
||||
|
||||
- Fixes for HP-UX 10. Thanks in part to to Thomas Wolfram
|
||||
(wolf@prz.tu-berlin.de) and Rick Jones (raj@hpisrdq.cup.hp.com)
|
||||
|
||||
- Added support for SINIX. Thanks to Andrej Borsenkow
|
||||
(borsenkow.msk@sni.de)
|
||||
|
||||
- Fixes for AIX (although this system is not yet supported). Thanks to
|
||||
John Hawkinson (jhawk@mit.edu)
|
||||
|
||||
- Use autoconf's idea of the top level directory in install targets.
|
||||
Thanks to John Hawkinson.
|
||||
|
||||
- Add missing autoconf packet capture result message. Thanks to Bill
|
||||
Fenner (fenner@parc.xerox.com)
|
||||
|
||||
- Fixed padding problems in the pf module.
|
||||
|
||||
- Fixed some more alignment problems on the alpha.
|
||||
|
||||
- Added explicit netmask support. Thanks to Steve Nuchia
|
||||
(steve@research.oknet.com)
|
||||
|
||||
- Fixed to handle raw ip addresses such as 0.0.0.1 without "left
|
||||
justifing"
|
||||
|
||||
- Add "sca" keyword (for DEC cluster services) as suggested by Terry
|
||||
Kennedy (terry@spcvxa.spc.edu)
|
||||
|
||||
- Add "atalk" keyword as suggested by John Hawkinson.
|
||||
|
||||
- Add "igrp" keyword.
|
||||
|
||||
- Fixed HID definition in grammar.y to be a string, not a value.
|
||||
|
||||
- Use $CC when checking gcc version. Thanks to Carl Lindberg
|
||||
(carl_lindberg@blacksmith.com)
|
||||
|
||||
- Removed obsolete reference to pcap_immediate() from the man page.
|
||||
Michael Stolarchuk (mts@terminator.rs.itd.umich.edu)
|
||||
|
||||
- DLT_NULL has a 4 byte family header. Thanks to Jeffrey Honig
|
||||
(jch@bsdi.com)
|
||||
|
||||
v0.2 Sun Jun 23 02:28:42 PDT 1996
|
||||
|
||||
- Add support for HP-UX. Resulted from code contributed by Tom Murray
|
||||
(tmurray@hpindck.cup.hp.com) and Philippe-Andri Prindeville
|
||||
(philipp@res.enst.fr)
|
||||
|
||||
- Update INSTALL with a reminder to install include files. Thanks to
|
||||
Mark Andrews (mandrews@aw.sgi.com)
|
||||
|
||||
- Fix bpf compiler alignment bug on the alpha.
|
||||
|
||||
- Use autoconf to detect architectures that can't handle misaligned
|
||||
accesses.
|
||||
|
||||
- Added loopback support for snoop. Resulted from report Steve
|
||||
Alexander (sca@engr.sgi.com)
|
||||
|
||||
v0.1 Fri Apr 28 18:11:03 PDT 1995
|
||||
|
||||
- Fixed compiler and optimizer bugs. The BPF filter engine uses unsigned
|
||||
comparison operators, while the code generator and optimizer assumed
|
||||
signed semantics in several places. Thanks to Charlie Slater
|
||||
(cslater@imatek.com) for pointing this out.
|
||||
|
||||
- Removed FDDI ifdef's, they aren't really needed. Resulted from report
|
||||
by Gary Veum (veum@boa.gsfc.nasa.gov).
|
||||
|
||||
- Add pcap-null.c which allows offline use of libpcap on systems that
|
||||
don't support live package capture. This feature resulting from a
|
||||
request from Jan van Oorschot (j.p.m.voorschot@et.tudelft.nl).
|
||||
|
||||
- Make bpf_compile() reentrant. Fix thanks to Pascal Hennequin
|
||||
(Pascal.Hennequin@hugo.int-evry.fr).
|
||||
|
||||
- Port to GNU autoconf.
|
||||
|
||||
- Fix pcap-dlpi.c to work with isdn. Resulted from report by Flemming
|
||||
Johansen (fsj@csd.cri.dk).
|
||||
|
||||
- Handle multi-digit interface unit numbers (aka ppa's) under dlpi.
|
||||
Resulted from report by Daniel Ehrlich (ehrlich@cse.psu.edu).
|
||||
|
||||
- Fix pcap-dlpi.c to work in non-promiscuous mode. Resulted from report
|
||||
by Jeff Murphy (jcmurphy@acsu.buffalo.edu).
|
||||
|
||||
- Add support for "long jumps". Thanks to Jeffrey Mogul
|
||||
(mogul@pa.dec.com).
|
||||
|
||||
- Fix minor problems when compiling with BDEBUG as noticed by Scott
|
||||
Bertilson (scott@unet.umn.edu).
|
||||
|
||||
- Declare sys_errlist "const char *const" to avoid problems under
|
||||
FreeBSD. Resulted from report by jher@eden.com.
|
||||
|
||||
v0.0.6 Fri Apr 28 04:07:13 PDT 1995
|
||||
|
||||
- Add missing variable declaration missing from 0.0.6
|
||||
|
||||
v0.0.5 Fri Apr 28 00:22:21 PDT 1995
|
||||
|
||||
- Workaround for problems when pcap_read() returns 0 due to the timeout
|
||||
expiring.
|
||||
|
||||
v0.0.4 Thu Apr 20 20:41:48 PDT 1995
|
||||
|
||||
- Change configuration to not use gcc v2 flags with gcc v1.
|
||||
|
||||
- Fixed a bug in pcap_next(); if pcap_dispatch() returns 0, pcap_next()
|
||||
should also return 0. Thanks to Richard Stevens (rstevens@noao.edu).
|
||||
|
||||
- Fixed configure to test for snoop before dlpi to avoid problems under
|
||||
IRIX 5. Thanks to J. Eric Townsend (jet@abulafia.genmagic.com).
|
||||
|
||||
- Hack around deficiency in Ultrix's make.
|
||||
|
||||
- Fix two bugs related to the Solaris pre-5.3.2 bufmod bug; handle
|
||||
savefiles that have more than snapshot bytes of data in them (so we
|
||||
can read old savefiles) and avoid writing such files.
|
||||
|
||||
- Added checkioctl which is used with gcc to check that the
|
||||
"fixincludes" script has been run.
|
||||
|
||||
v0.0.3 Tue Oct 18 18:13:46 PDT 1994
|
||||
|
||||
- Fixed configure to test for snoop before dlpi to avoid problems under
|
||||
IRIX 5. Thanks to J. Eric Townsend (jet@abulafia.genmagic.com).
|
||||
|
||||
v0.0.2 Wed Oct 12 20:56:37 PDT 1994
|
||||
|
||||
- Implement timeout in the dlpi pcap_open_live(). Thanks to Richard
|
||||
Stevens.
|
||||
|
||||
- Determine pcap link type from dlpi media type. Resulted from report
|
||||
by Mahesh Jethanandani (mahesh@npix.com).
|
||||
|
||||
v0.0.1 Fri Jun 24 14:50:57 PDT 1994
|
||||
|
||||
- Fixed bug in nit_setflags() in pcap-snit.c. The streams ioctl timeout
|
||||
wasn't being initialized sometimes resulting in an "NIOCSFLAGS:
|
||||
Invalid argument" error under OSF/1. Reported by Matt Day
|
||||
(mday@artisoft.com) and Danny Mitzel (dmitzel@whitney.hitc.com).
|
||||
|
||||
- Turn on FDDI support by default.
|
||||
|
||||
v0.0 Mon Jun 20 19:20:16 PDT 1994
|
||||
|
||||
- Initial release.
|
||||
|
||||
- Fixed bug with greater/less keywords, reported by Mark Andrews
|
||||
(mandrews@alias.com).
|
||||
|
||||
- Fix bug where '|' was defined as BPF_AND instead of BPF_OR, reported
|
||||
by Elan Amir (elan@leeb.cs.berkeley.edu).
|
||||
|
||||
- Machines with little-endian byte ordering are supported thanks to
|
||||
Jeff Mogul.
|
||||
|
||||
- Add hack for version 2.3 savefiles which don't have caplen and len
|
||||
swapped thanks to Vern Paxson.
|
||||
|
||||
- Added "&&" and "||" aliases for "and" and "or" thanks to Vern Paxson.
|
||||
|
||||
- Added length, inbound and outbound keywords.
|
@ -1,520 +0,0 @@
|
||||
cmake_minimum_required( VERSION 2.8.8 )
|
||||
|
||||
project( pcap )
|
||||
#
|
||||
# Call the library "wpcap" on Windows, for backwards compatibility.
|
||||
#
|
||||
if( WIN32 )
|
||||
set( LIBRARY_NAME wpcap )
|
||||
else()
|
||||
set( LIBRARY_NAME pcap )
|
||||
endif()
|
||||
|
||||
###################################################################
|
||||
# Parameters
|
||||
###################################################################
|
||||
|
||||
option (INET6 "Enable IPv6" ON)
|
||||
if( MSVC )
|
||||
option (USE_STATIC_RT "Use static Runtime" ON)
|
||||
endif( MSVC )
|
||||
option (BUILD_SHARED_LIBS "Build shared libraries" ON)
|
||||
if( WIN32 )
|
||||
set(PACKET_DLL_DIR "" CACHE PATH "Path to directory with include and lib subdirectories for packet.dll")
|
||||
endif( WIN32 )
|
||||
|
||||
#
|
||||
# XXX - this should be an option, defaulting to "yes" for Windows and to
|
||||
# "no", for now, on UN*X.
|
||||
#
|
||||
if( WIN32 )
|
||||
set( HAVE_REMOTE 1 )
|
||||
endif( WIN32 )
|
||||
|
||||
######################################
|
||||
# Project settings
|
||||
######################################
|
||||
|
||||
add_definitions( -DHAVE_CONFIG_H )
|
||||
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${pcap_SOURCE_DIR}
|
||||
)
|
||||
|
||||
if( WIN32 )
|
||||
if( NOT "${PACKET_DLL_DIR}" STREQUAL "" )
|
||||
include_directories("${PACKET_DLL_DIR}/Include")
|
||||
if( CMAKE_CL_64 )
|
||||
link_directories("${PACKET_DLL_DIR}/Lib/x64")
|
||||
else( CMAKE_CL_64 )
|
||||
link_directories("${PACKET_DLL_DIR}/Lib")
|
||||
endif( CMAKE_CL_64 )
|
||||
endif()
|
||||
include_directories(
|
||||
../Common/
|
||||
Win32/Include
|
||||
)
|
||||
endif( WIN32)
|
||||
|
||||
add_definitions( -DBUILDING_PCAP )
|
||||
|
||||
if( MSVC )
|
||||
add_definitions( -D__STDC__ )
|
||||
add_definitions( -D_CRT_SECURE_NO_WARNINGS )
|
||||
add_definitions( "-D_U_=" )
|
||||
elseif( CMAKE_COMPILER_IS_GNUCXX )
|
||||
add_definitions( "-D_U_=__attribute__((unused))" )
|
||||
else(MSVC)
|
||||
add_definitions( "-D_U_=" )
|
||||
endif( MSVC )
|
||||
|
||||
if( MSVC )
|
||||
if (USE_STATIC_RT)
|
||||
MESSAGE( STATUS "Use STATIC runtime" )
|
||||
set(NAME_RT MT)
|
||||
set (CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MT")
|
||||
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MT")
|
||||
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
|
||||
|
||||
set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MT")
|
||||
set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MT")
|
||||
set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
|
||||
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
|
||||
else (USE_STATIC_RT)
|
||||
MESSAGE( STATUS "Use DYNAMIC runtime" )
|
||||
set(NAME_RT MD)
|
||||
set (CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MD")
|
||||
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MD")
|
||||
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD")
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")
|
||||
|
||||
set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MD")
|
||||
set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MD")
|
||||
set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MD")
|
||||
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MDd")
|
||||
endif (USE_STATIC_RT)
|
||||
endif( MSVC )
|
||||
|
||||
###################################################################
|
||||
# Detect available platform features
|
||||
###################################################################
|
||||
|
||||
include(CheckIncludeFile)
|
||||
include(CheckFunctionExists)
|
||||
include(CheckStructHasMember)
|
||||
include(CheckTypeSize)
|
||||
|
||||
#
|
||||
# Header files.
|
||||
#
|
||||
check_include_file( inttypes.h HAVE_INTTYPES_H )
|
||||
check_include_file( stdint.h HAVE_STDINT_H )
|
||||
check_include_file( unistd.h HAVE_UNISTD_H )
|
||||
if( NOT HAVE_UNISTD_H )
|
||||
add_definitions( -DYY_NO_UNISTD_H )
|
||||
endif( NOT HAVE_UNISTD_H )
|
||||
check_include_file( bitypes.h HAVE_SYS_BITYPES_H )
|
||||
check_include_file( limits.h HAVE_LIMITS_H )
|
||||
|
||||
#
|
||||
# Functions.
|
||||
#
|
||||
check_function_exists( strerror HAVE_STRERROR )
|
||||
check_function_exists( strlcpy HAVE_STRLCPY )
|
||||
check_function_exists( snprintf HAVE_SNPRINTF )
|
||||
check_function_exists( vsnprintf HAVE_VSNPRINTF )
|
||||
check_function_exists( strtok_r HAVE_STRTOK_R )
|
||||
|
||||
if (WIN32)
|
||||
#
|
||||
# Check for Windows-only functions, such as packet.dll functions.
|
||||
#
|
||||
check_function_exists( PacketIsLoopbackAdapter HAVE_PACKET_IS_LOOPBACK_ADAPTER )
|
||||
endif()
|
||||
|
||||
#
|
||||
# Data types.
|
||||
#
|
||||
# XXX - there's no check_struct() macro that's like check_struct_has_member()
|
||||
# except that it only checks for the existence of the structure type,
|
||||
# so we use check_struct_has_member() and look for ss_family.
|
||||
#
|
||||
check_struct_has_member("struct sockaddr_storage" ss_family sys/socket.h HAVE_SOCKADDR_STORAGE)
|
||||
set(CMAKE_EXTRA_INCLUDE_FILES unistd.h sys/socket.h)
|
||||
check_type_size("socklen_t" SOCKLEN_T)
|
||||
set(CMAKE_EXTRA_INCLUDE_FILES unistd.h)
|
||||
|
||||
#
|
||||
# Structure fields.
|
||||
#
|
||||
check_struct_has_member("struct sockaddr" sa_len sys/socket.h HAVE_SOCKADDR_SA_LEN )
|
||||
|
||||
if( INET6 )
|
||||
MESSAGE( STATUS "Use IPv6" )
|
||||
endif( INET6 )
|
||||
|
||||
if( WIN32 )
|
||||
add_definitions( -DHAVE_ADDRINFO )
|
||||
endif( WIN32 )
|
||||
|
||||
######################################
|
||||
# External dependencies
|
||||
######################################
|
||||
|
||||
######################################
|
||||
# Input files
|
||||
######################################
|
||||
|
||||
set(PROJECT_SOURCE_LIST_C
|
||||
bpf_dump.c
|
||||
bpf_image.c
|
||||
etherent.c
|
||||
fad-helpers.c
|
||||
gencode.c
|
||||
inet.c
|
||||
nametoaddr.c
|
||||
optimize.c
|
||||
pcap-common.c
|
||||
pcap.c
|
||||
savefile.c
|
||||
sf-pcap-ng.c
|
||||
sf-pcap.c
|
||||
bpf/net/bpf_filter.c
|
||||
)
|
||||
|
||||
if( WIN32 )
|
||||
set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} missing/win_snprintf.c )
|
||||
else()
|
||||
if( NOT HAVE_SNPRINTF )
|
||||
set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} missing/snprintf.c )
|
||||
endif( NOT HAVE_SNPRINTF )
|
||||
if( NOT HAVE_STRTOK_R )
|
||||
set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} missing/strtok_r.c )
|
||||
endif( NOT HAVE_STRTOK_R )
|
||||
endif( WIN32 )
|
||||
|
||||
if( HAVE_REMOTE )
|
||||
set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C}
|
||||
pcap-new.c pcap-rpcap.c sockutils.c)
|
||||
endif( HAVE_REMOTE )
|
||||
|
||||
#
|
||||
# Determine the main pcap-XXX.c file to use.
|
||||
#
|
||||
if( WIN32 )
|
||||
#
|
||||
# WinPcap.
|
||||
#
|
||||
set( PCAP_TYPE win32 )
|
||||
else()
|
||||
#
|
||||
# UN*X - figure out what type of packet capture mechanism we
|
||||
# have.
|
||||
#
|
||||
if( EXISTS /dev/bpf )
|
||||
#
|
||||
# Cloning BPF device.
|
||||
#
|
||||
set( PCAP_TYPE bpf )
|
||||
AC_DEFINE(HAVE_CLONING_BPF,1,[define if you have a cloning BPF device])
|
||||
elseif( EXISTS /dev/bpf0 )
|
||||
set( PCAP_TYPE bpf )
|
||||
|
||||
#
|
||||
# XXX - many more BPF checks.
|
||||
#
|
||||
elseif( EXISTS /usr/include/net/pfilt.h )
|
||||
#
|
||||
# DEC OSF/1, Digital UNIX, Tru64 UNIX
|
||||
#
|
||||
set( PCAP_TYPE pf )
|
||||
elseif( EXISTS /dev/enet )
|
||||
set( PCAP_TYPE enet )
|
||||
elseif( EXISTS /dev/nit )
|
||||
set( PCAP_TYPE snit )
|
||||
elseif( EXISTS /usr/include/sys/net/nit.h )
|
||||
set( PCAP_TYPE nit )
|
||||
elseif( EXISTS /usr/include/linux/socket.h )
|
||||
set( PCAP_TYPE linux )
|
||||
|
||||
#
|
||||
# Do we have the wireless extensions?
|
||||
#
|
||||
check_include_file( linux/wireless.h HAVE_LINUX_WIRELESS_H )
|
||||
|
||||
#
|
||||
# XXX - many more Linux checks.
|
||||
#
|
||||
elseif( EXISTS /usr/include/net/raw.h )
|
||||
set( PCAP_TYPE snoop )
|
||||
elseif( EXISTS /usr/include/odmi.h )
|
||||
#
|
||||
# On AIX, the BPF devices might not yet be present - they're
|
||||
# created the first time libpcap runs after booting.
|
||||
# We check for odmi.h instead.
|
||||
#
|
||||
set( PCAP_TYPE bpf )
|
||||
elseif( /usr/include/sys/dlpi.h )
|
||||
set( PCAP_TYPE dlpi )
|
||||
|
||||
#
|
||||
# XXX - many more DLPI checks.
|
||||
#
|
||||
else()
|
||||
set( PCAP_TYPE null )
|
||||
endif()
|
||||
endif( WIN32 )
|
||||
message(STATUS "Packet capture mechanism type: ${PCAP_TYPE}")
|
||||
set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-${PCAP_TYPE}.c)
|
||||
|
||||
#
|
||||
# Now figure out how we get a list of interfaces and addresses,
|
||||
# if we support capturing. Don't bother if we don't support
|
||||
# capturing.
|
||||
#
|
||||
if( NOT WIN32 )
|
||||
#
|
||||
# UN*X - figure out what type of interface list mechanism we
|
||||
# have.
|
||||
#
|
||||
if( ${PCAP_TYPE} STREQUAL "null" )
|
||||
#
|
||||
# We can't capture, so we can't open any capture
|
||||
# devices, so we won't return any interfaces.
|
||||
#
|
||||
set( FINDALLDEVS_TYPE null )
|
||||
else()
|
||||
check_function_exists( getifaddrs HAVE_GETIFADDRS )
|
||||
if( ${HAVE_GETIFADDRS} )
|
||||
#
|
||||
# We have "getifaddrs()"; make sure we have <ifaddrs.h>
|
||||
# as well, just in case some platform is really weird.
|
||||
#
|
||||
check_include_file( ifaddrs.h HAVE_IFADDRS_H )
|
||||
if( ${HAVE_IFADDRS_H} )
|
||||
#
|
||||
# We have the header, so we use "getifaddrs()" to
|
||||
# get the list of interfaces.
|
||||
#
|
||||
set( FINDALLDEVS_TYPE getad )
|
||||
else()
|
||||
#
|
||||
# We don't have the header - give up.
|
||||
# XXX - we could also fall back on some other
|
||||
# mechanism, but, for now, this'll catch this
|
||||
# problem so that we can at least try to figure
|
||||
# out something to do on systems with "getifaddrs()"
|
||||
# but without "ifaddrs.h", if there is something
|
||||
# we can do on those systems.
|
||||
#
|
||||
message(FATAL_ERROR "Your system has getifaddrs() but doesn't have a usable <ifaddrs.h>." )
|
||||
endif()
|
||||
else()
|
||||
#
|
||||
# Well, we don't have "getifaddrs()", so we have to use
|
||||
# some other mechanism; determine what that mechanism is.
|
||||
#
|
||||
# The first thing we use is the type of capture mechanism,
|
||||
# which is somewhat of a proxy for the OS we're using.
|
||||
#
|
||||
if( ${PCAP_TYPE} STREQUAL "dlpi" OR ${PCAP_TYPE} STREQUAL "libdlpi" )
|
||||
#
|
||||
# This might be Solaris 8 or later, with
|
||||
# SIOCGLIFCONF, or it might be some other OS
|
||||
# or some older version of Solaris, with
|
||||
# just SIOCGIFCONF.
|
||||
#
|
||||
try_compile( HAVE_SIOCGLIFCONF ${CMAKE_CURRENT_BINARY_DIR} "${pcap_SOURCE_DIR}/config/have_siocglifconf.c" )
|
||||
message( STATUS "HAVE_SIOCGLIFCONF = ${HAVE_SIOCGLIFCONF}" )
|
||||
if( HAVE_SIOCGLIFCONF )
|
||||
set( FINDALLDEVS_TYPE glifc )
|
||||
else()
|
||||
set( FINDALLDEVS_TYPE gifc )
|
||||
endif()
|
||||
else()
|
||||
#
|
||||
# Assume we just have SIOCGIFCONF.
|
||||
# (XXX - on at least later Linux kernels, there's
|
||||
# another mechanism, and we should be using that
|
||||
# instead.)
|
||||
#
|
||||
set( FINDALLDEVS_TYPE gifc )
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
message(STATUS "Find-interfaces mechanism type: ${FINDALLDEVS_TYPE}")
|
||||
set( PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} fad-${FINDALLDEVS_TYPE}.c )
|
||||
endif()
|
||||
|
||||
file(GLOB PROJECT_SOURCE_LIST_CORE_H
|
||||
*.h
|
||||
pcap/*.h
|
||||
)
|
||||
set( PROJECT_SOURCE_LIST_H ${PROJECT_SOURCE_LIST_H} ${PROJECT_SOURCE_LIST_CORE_H} )
|
||||
|
||||
if( WIN32 )
|
||||
file(GLOB PROJECT_SOURCE_LIST_WIN32_H
|
||||
Win32/Include/*.h
|
||||
)
|
||||
set( PROJECT_SOURCE_LIST_H ${PROJECT_SOURCE_LIST_H} ${PROJECT_SOURCE_LIST_WIN32_H} )
|
||||
endif( WIN32 )
|
||||
|
||||
#
|
||||
# {Flex} and YACC/Berkeley YACC/Bison.
|
||||
# From a mail message to the CMake mailing list by Andy Cedilnik of
|
||||
# Kitware.
|
||||
#
|
||||
|
||||
#
|
||||
# Try to find Flex, a Windows version of Flex, or Lex.
|
||||
#
|
||||
find_program(LEX_EXECUTABLE NAMES flex win_flex lex)
|
||||
if( ${LEX_EXECUTABLE} STREQUAL "LEX_EXECUTABLE-NOTFOUND" )
|
||||
message(FATAL_ERROR "Neither flex nor win_flex nor lex was found." )
|
||||
endif()
|
||||
message(STATUS "Lexical analyzer generator: ${LEX_EXECUTABLE}")
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/scanner.c ${CMAKE_CURRENT_BINARY_DIR}/scanner.h
|
||||
SOURCE ${pcap_SOURCE_DIR}/scanner.l
|
||||
COMMAND ${LEX_EXECUTABLE} -P pcap_ --header-file=scanner.h --nounput -o${CMAKE_CURRENT_BINARY_DIR}/scanner.c ${pcap_SOURCE_DIR}/scanner.l
|
||||
DEPENDS ${pcap_SOURCE_DIR}/scanner.l
|
||||
)
|
||||
|
||||
#
|
||||
# Since scanner.c does not exist yet when cmake is run, mark
|
||||
# it as generated.
|
||||
#
|
||||
# Since scanner.c includes grammar.h, mark that as a dependency.
|
||||
#
|
||||
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/scanner.c PROPERTIES
|
||||
GENERATED TRUE
|
||||
OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/scanner.h
|
||||
)
|
||||
|
||||
#
|
||||
# Add scanner.c to the list of sources.
|
||||
#
|
||||
#set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} ${CMAKE_CURRENT_BINARY_DIR}/scanner.c)
|
||||
|
||||
#
|
||||
# Try to find YACC or Bison.
|
||||
#
|
||||
find_program(YACC_EXECUTABLE NAMES bison win_bison byacc yacc)
|
||||
if( ${YACC_EXECUTABLE} STREQUAL "YACC_EXECUTABLE-NOTFOUND" )
|
||||
message(FATAL_ERROR "Neither bison nor win_bison nor byacc nor yacc was found." )
|
||||
endif()
|
||||
message(STATUS "Parser generator: ${YACC_EXECUTABLE}")
|
||||
|
||||
#
|
||||
# Create custom command for the scanner.
|
||||
# Find out whether it's Bison or notby looking at the last component
|
||||
# of the path (without a .exe extension, if this is Windows).
|
||||
#
|
||||
get_filename_component(YACC_NAME ${YACC_EXECUTABLE} NAME_WE)
|
||||
if( "${YACC_NAME}" STREQUAL "bison" OR "${YACC_NAME}" STREQUAL "win_bison" )
|
||||
set( YACC_COMPATIBILITY_FLAG "-y" )
|
||||
endif()
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/grammar.c ${CMAKE_CURRENT_BINARY_DIR}/grammar.h
|
||||
SOURCE ${pcap_SOURCE_DIR}/grammar.y
|
||||
COMMAND ${YACC_EXECUTABLE} ${YACC_COMPATIBILITY_FLAG} -p pcap_ -o ${CMAKE_CURRENT_BINARY_DIR}/grammar.c -d ${pcap_SOURCE_DIR}/grammar.y
|
||||
DEPENDS ${pcap_SOURCE_DIR}/grammar.y
|
||||
)
|
||||
|
||||
#
|
||||
# Since grammar.c does not exists yet when cmake is run, mark
|
||||
# it as generated.
|
||||
#
|
||||
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/grammar.c PROPERTIES
|
||||
GENERATED TRUE
|
||||
)
|
||||
|
||||
#
|
||||
# Add grammar.c to the list of sources.
|
||||
#
|
||||
#set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} ${CMAKE_CURRENT_BINARY_DIR}/grammar.c)
|
||||
|
||||
if( WIN32 )
|
||||
#
|
||||
# CMake does not love Windows.
|
||||
#
|
||||
file(TO_NATIVE_PATH "${pcap_SOURCE_DIR}/GenVersion.bat" GenVersion_path)
|
||||
file(TO_NATIVE_PATH "${pcap_SOURCE_DIR}/VERSION" VERSION_path)
|
||||
file(TO_NATIVE_PATH "${pcap_SOURCE_DIR}/pcap_version.h.in" version_h_in_path)
|
||||
file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}/pcap_version.h" version_h_path)
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pcap_version.h
|
||||
SOURCE ${pcap_SOURCE_DIR}/VERSION ${pcap_SOURCE_DIR}/pcap_version.h.in
|
||||
COMMAND ${GenVersion_path} ${VERSION_path} ${version_h_in_path} ${version_h_path}
|
||||
DEPENDS ${pcap_SOURCE_DIR}/VERSION ${pcap_SOURCE_DIR}/pcap_version.h.in
|
||||
)
|
||||
else( WIN32 )
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version.c
|
||||
SOURCE ${pcap_SOURCE_DIR}/VERSION
|
||||
COMMAND ${pcap_SOURCE_DIR}/gen_version_c.sh ${pcap_SOURCE_DIR}/VERSION ${CMAKE_CURRENT_BINARY_DIR}/version.c
|
||||
DEPENDS ${pcap_SOURCE_DIR}/VERSION
|
||||
)
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pcap_version.h
|
||||
SOURCE ${pcap_SOURCE_DIR}/VERSION
|
||||
COMMAND ${pcap_SOURCE_DIR}/gen_version_header.sh ${pcap_SOURCE_DIR}/VERSION ${pcap_SOURCE_DIR}/pcap_version.h.in ${CMAKE_CURRENT_BINARY_DIR}/pcap_version.h
|
||||
DEPENDS ${pcap_SOURCE_DIR}/VERSION
|
||||
)
|
||||
|
||||
#
|
||||
# Since version.c does not exists yet when cmake is run, mark
|
||||
# it as generated.
|
||||
#
|
||||
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/version.c PROPERTIES
|
||||
GENERATED TRUE
|
||||
)
|
||||
|
||||
#
|
||||
# Add version.c to the list of sources.
|
||||
#
|
||||
set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} ${CMAKE_CURRENT_BINARY_DIR}/version.c)
|
||||
endif( WIN32 )
|
||||
|
||||
#
|
||||
# Since pcap_version.h does not exists yet when cmake is run, mark
|
||||
# it as generated.
|
||||
#
|
||||
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/pcap_version.h PROPERTIES
|
||||
GENERATED TRUE
|
||||
)
|
||||
|
||||
#
|
||||
# Add pcap_version.h to the list of headers.
|
||||
#
|
||||
set(PROJECT_SOURCE_LIST_H ${PROJECT_SOURCE_LIST_H} ${CMAKE_CURRENT_BINARY_DIR}/pcap_version.h)
|
||||
|
||||
source_group("Source Files" FILES ${PROJECT_SOURCE_LIST_C})
|
||||
source_group("Header Files" FILES ${PROJECT_SOURCE_LIST_H})
|
||||
|
||||
######################################
|
||||
# Register targets
|
||||
######################################
|
||||
|
||||
add_library(${LIBRARY_NAME}
|
||||
${PROJECT_SOURCE_LIST_C}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/grammar.c
|
||||
${CMAKE_CURRENT_BINARY_DIR}/scanner.c
|
||||
${PROJECT_SOURCE_LIST_H}
|
||||
)
|
||||
|
||||
if( WIN32 )
|
||||
target_link_libraries ( ${LIBRARY_NAME}
|
||||
packet
|
||||
ws2_32
|
||||
)
|
||||
endif( WIN32 )
|
||||
|
||||
######################################
|
||||
# Write out the config.h file
|
||||
######################################
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
@ -1,180 +0,0 @@
|
||||
This file lists people who have contributed to libpcap:
|
||||
|
||||
The current maintainers:
|
||||
Bill Fenner <fenner at research dot att dot com>
|
||||
Denis Ovsienko <denis at ovsienko dot info>
|
||||
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>
|
||||
Francois-Xavier Le Bail <fx dot lebail at yahoo dot com>
|
||||
|
||||
Additional people who have contributed patches:
|
||||
|
||||
Akos Vandra <axos88 at gmail dot com>
|
||||
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>
|
||||
Andres Perera <andres dot p at zoho dot com>
|
||||
Andrew Brown <atatat at atatdot dot net>
|
||||
<andy-1 at sourceforge dot net>
|
||||
Ani Sinha <ani at aristanetworks dot com>
|
||||
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>
|
||||
Bill Parker <wp02855 at gmail dot com>
|
||||
Brent Cook <brent at boundary dot com>
|
||||
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>
|
||||
Christian Svensson <blue at cmd dot nu>
|
||||
Daniele Orlandi <daniele at orlandi dot com>
|
||||
Darren Lim <darren dot lim at endace dot com>
|
||||
Darren Reed <darrenr at sun dot com>
|
||||
David Clark <david dot clark at datasoft dot com>
|
||||
David Kaelbling <drk at sgi dot com>
|
||||
David Ward <david dot ward at ll dot mit dot edu>
|
||||
David Young <dyoung at ojctech dot com>
|
||||
Dean Gaudet <dean at arctic dot org>
|
||||
dhruv <rsrivat at sourceforge dot net>
|
||||
Don Ebright <Don dot Ebright at compuware dot com>
|
||||
Dug Song <dugsong at monkey dot org>
|
||||
Dustin Spicuzza <dustin at virtualroadside dot com>
|
||||
dzejarczech <dzejarczech at sourceforge dot net>
|
||||
Edward Sheldrake <ejs1920 at sourceforge dot net>
|
||||
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>
|
||||
Gabor Tatarka <gabor dot tatarka at ericsson dot com>
|
||||
Garrett Cooper <yaberauneya at sourceforge dot net>
|
||||
George Neville-Neil <gnn at freebsd dot org>
|
||||
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>
|
||||
Gregor Maier <gregor at net dot in dot tum dot de>
|
||||
Greg Stark <gsstark at mit dot edu>
|
||||
Greg Troxel <gdt at ir dot bbn dot com>
|
||||
Guillaume Pelat <endymion_ at users dot sourceforge dot net>
|
||||
Gustavo Zacarias <gustavo at zacarias dot com dot ar>
|
||||
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>
|
||||
Jakub Zawadzki <darkjames at darkjames dot pl>
|
||||
Jan-Philip Velders <jpv at veldersjes dot net>
|
||||
Jason R. Thorpe <thorpej at netbsd dot org>
|
||||
Javier Achirica <achirica at ttd dot net>
|
||||
Jean-Louis Charton <Jean-Louis dot CHARTON at oikialog dot com>
|
||||
Jean Tourrilhes <jt at hpl dot hp 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>
|
||||
Jesse Gross <jesse at nicira dot com>
|
||||
Jiri Slaby <jirislaby at gmail 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>
|
||||
Jorge Boncompte [DTI2] <jorge at dti2 dot net>
|
||||
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>
|
||||
Mansour Behabadi <mansour at oxplot dot com>
|
||||
Marcus Felipe Pereira <marcus at task dot com dot br>
|
||||
Mark C. Brown <mbrown at hp dot com>
|
||||
Mark Johnston <markjdb at gmail 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>
|
||||
Michal Labedzki <michal dot labedzki at tieto dot com>
|
||||
Michal Sekletar <msekleta at redhat dot com>
|
||||
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>
|
||||
Nicolas Dade <ndade at nsd dot dyndns dot org>
|
||||
Niko Delarich <niko dot delarich at gmail dot com>
|
||||
N. Leiten <nleiten at sourceforge dot net>
|
||||
<nvercamm at sourceforge dot net>
|
||||
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
|
||||
Yoann Vandoorselaere <yoann at prelude-ids dot org>
|
||||
Yvan Vanhullebus <vanhu at sourceforge dot net>
|
||||
|
||||
The original LBL crew:
|
||||
Steve McCanne
|
||||
Craig Leres
|
||||
Van Jacobson
|
||||
|
||||
Past maintainers:
|
||||
Jun-ichiro itojun Hagino <itojun at iijlab dot net> Also see: http://www.wide.ad.jp/itojun-award/
|
@ -1,33 +0,0 @@
|
||||
#! /bin/sh
|
||||
|
||||
. /etc/rc.common
|
||||
|
||||
StartService ()
|
||||
{
|
||||
#
|
||||
# Unfortunately, Mac OS X's devfs is based on the old FreeBSD
|
||||
# one, not the current one, so there's no way to configure it
|
||||
# to create BPF devices with particular owners or groups.
|
||||
# This startup item will make it owned by the admin group,
|
||||
# with permissions rw-rw----, so that anybody in the admin
|
||||
# group can use programs that capture or send raw packets.
|
||||
#
|
||||
# Change this as appropriate for your site, e.g. to make
|
||||
# it owned by a particular user without changing the permissions,
|
||||
# so only that user and the super-user can capture or send raw
|
||||
# packets, or give it the permissions rw-r-----, so that
|
||||
# only the super-user can send raw packets but anybody in the
|
||||
# admin group can capture packets.
|
||||
#
|
||||
chgrp admin /dev/bpf*
|
||||
chmod g+rw /dev/bpf*
|
||||
}
|
||||
|
||||
StopService ()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
RestartService () { StartService; }
|
||||
|
||||
RunService "$1"
|
@ -1,4 +0,0 @@
|
||||
{
|
||||
Description = "Change BPF permissions";
|
||||
Provides = ("ChmodBPF");
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
REM
|
||||
REM Automatically generate pcap_version.h based on pcap_version.h.in
|
||||
REM for Windows
|
||||
REM The version string comes from VERSION
|
||||
REM @echo off
|
||||
REM
|
||||
|
||||
setlocal enableextensions disabledelayedexpansion
|
||||
|
||||
set "search=%%%%LIBPCAP_VERSION%%%%"
|
||||
set /p replace=<%1
|
||||
|
||||
if exist %3 del %3 2>nul
|
||||
|
||||
for /f "delims=" %%i in ('type %2' ) do (
|
||||
set "line=%%i"
|
||||
setlocal enabledelayedexpansion
|
||||
set "line=!line:%search%=%replace%!"
|
||||
>>%3 echo(!line!
|
||||
endlocal
|
||||
)
|
||||
|
||||
echo pcap_version.h generated
|
@ -1,374 +0,0 @@
|
||||
To build libpcap, run "./configure" (a shell script). The configure
|
||||
script will determine your system attributes and generate an
|
||||
appropriate Makefile from Makefile.in. Next run "make". If everything
|
||||
goes well you can su to root and run "make install". However, you need
|
||||
not install libpcap if you just want to build tcpdump; just make sure
|
||||
the tcpdump and libpcap directory trees have the same parent
|
||||
directory.
|
||||
|
||||
If configure says:
|
||||
|
||||
configure: warning: cannot determine packet capture interface
|
||||
configure: warning: (see INSTALL for more info)
|
||||
|
||||
then your system either does not support packet capture or your system
|
||||
does support packet capture but libpcap does not support that
|
||||
particular type. (If you have HP-UX, see below.) If your system uses a
|
||||
packet capture not supported by libpcap, please send us patches; don't
|
||||
forget to include an autoconf fragment suitable for use in
|
||||
configure.ac.
|
||||
|
||||
It is possible to override the default packet capture type, although
|
||||
the circumstance where this works are limited. For example if you have
|
||||
installed bpf under SunOS 4 and wish to build a snit libpcap:
|
||||
|
||||
./configure --with-pcap=snit
|
||||
|
||||
Another example is to force a supported packet capture type in the case
|
||||
where the configure scripts fails to detect it.
|
||||
|
||||
You will need an ANSI C compiler to build libpcap. The configure script
|
||||
will abort if your compiler is not ANSI compliant. If this happens, use
|
||||
the generally available GNU C compiler (GCC).
|
||||
|
||||
You will need either Flex 2.5.31 or later, or a version of Lex
|
||||
compatible with it (if any exist), to build libpcap. The configure
|
||||
script will abort if there isn't any such program. If you have an older
|
||||
version of Flex, or don't have a compatible version of Lex, the current
|
||||
version of flex is available at flex.sourceforge.net.
|
||||
|
||||
You will need either Bison, Berkeley YACC, or a version of YACC
|
||||
compatible with them (if any exist), to build libpcap. The configure
|
||||
script will abort if there isn't any such program. If you don't have
|
||||
any such program, the current version of Bison can be found at
|
||||
http://ftp.gnu.org/gnu/bison/ and the current version of Berkeley YACC
|
||||
can be found at http://invisible-island.net/byacc/.
|
||||
|
||||
Sometimes the stock C compiler does not interact well with Flex and
|
||||
Bison. The list of problems includes undefined references for alloca.
|
||||
You can get around this by installing GCC.
|
||||
|
||||
If you use Solaris, there is a bug with bufmod(7) that is fixed in
|
||||
Solaris 2.3.2 (aka SunOS 5.3.2). Setting a snapshot length with the
|
||||
broken bufmod(7) results in data be truncated from the FRONT of the
|
||||
packet instead of the end. The work around is to not set a snapshot
|
||||
length but this results in performance problems since the entire packet
|
||||
is copied to user space. If you must run an older version of Solaris,
|
||||
there is a patch available from Sun; ask for bugid 1149065. After
|
||||
installing the patch, use "setenv BUFMOD_FIXED" to enable use of
|
||||
bufmod(7). However, we recommend you run a more current release of
|
||||
Solaris.
|
||||
|
||||
If you use the SPARCompiler, you must be careful to not use the
|
||||
/usr/ucb/cc interface. If you do, you will get bogus warnings and
|
||||
perhaps errors. Either make sure your path has /opt/SUNWspro/bin
|
||||
before /usr/ucb or else:
|
||||
|
||||
setenv CC /opt/SUNWspro/bin/cc
|
||||
|
||||
before running configure. (You might have to do a "make distclean"
|
||||
if you already ran configure once).
|
||||
|
||||
Also note that "make depend" won't work; while all of the known
|
||||
universe uses -M, the SPARCompiler uses -xM to generate makefile
|
||||
dependencies.
|
||||
|
||||
If you are trying to do packet capture with a FORE ATM card, you may or
|
||||
may not be able to. They usually only release their driver in object
|
||||
code so unless their driver supports packet capture, there's not much
|
||||
libpcap can do.
|
||||
|
||||
If you get an error like:
|
||||
|
||||
tcpdump: recv_ack: bind error 0x???
|
||||
|
||||
when using DLPI, look for the DL_ERROR_ACK error return values, usually
|
||||
in /usr/include/sys/dlpi.h, and find the corresponding value.
|
||||
|
||||
Under {DEC OSF/1, Digital UNIX, Tru64 UNIX}, packet capture must be
|
||||
enabled before it can be used. For instructions on how to enable packet
|
||||
filter support, see:
|
||||
|
||||
ftp://ftp.digital.com/pub/Digital/dec-faq/Digital-UNIX
|
||||
|
||||
Look for the "How do I configure the Berkeley Packet Filter and capture
|
||||
tcpdump traces?" item.
|
||||
|
||||
Once you enable packet filter support, your OSF system will support bpf
|
||||
natively.
|
||||
|
||||
Under Ultrix, packet capture must be enabled before it can be used. For
|
||||
instructions on how to enable packet filter support, see:
|
||||
|
||||
ftp://ftp.digital.com/pub/Digital/dec-faq/ultrix
|
||||
|
||||
If you use HP-UX, you must have at least version 9 and either the
|
||||
version of cc that supports ANSI C (cc -Aa) or else use the GNU C
|
||||
compiler. You must also buy the optional streams package. If you don't
|
||||
have:
|
||||
|
||||
/usr/include/sys/dlpi.h
|
||||
/usr/include/sys/dlpi_ext.h
|
||||
|
||||
then you don't have the streams package. In addition, we believe you
|
||||
need to install the "9.X LAN and DLPI drivers cumulative" patch
|
||||
(PHNE_6855) to make the version 9 DLPI work with libpcap.
|
||||
|
||||
The DLPI streams package is standard starting with HP-UX 10.
|
||||
|
||||
The HP implementation of DLPI is a little bit eccentric. Unlike
|
||||
Solaris, you must attach /dev/dlpi instead of the specific /dev/*
|
||||
network pseudo device entry in order to capture packets. The PPA is
|
||||
based on the ifnet "index" number. Under HP-UX 9, it is necessary to
|
||||
read /dev/kmem and the kernel symbol file (/hp-ux). Under HP-UX 10,
|
||||
DLPI can provide information for determining the PPA. It does not seem
|
||||
to be possible to trace the loopback interface. Unlike other DLPI
|
||||
implementations, PHYS implies MULTI and SAP and you get an error if you
|
||||
try to enable more than one promiscuous mode at a time.
|
||||
|
||||
It is impossible to capture outbound packets on HP-UX 9. To do so on
|
||||
HP-UX 10, you will, apparently, need a late "LAN products cumulative
|
||||
patch" (at one point, it was claimed that this would be PHNE_18173 for
|
||||
s700/10.20; at another point, it was claimed that the required patches
|
||||
were PHNE_20892, PHNE_20725 and PHCO_10947, or newer patches), and to do
|
||||
so on HP-UX 11 you will, apparently, need the latest lancommon/DLPI
|
||||
patches and the latest driver patch for the interface(s) in use on HP-UX
|
||||
11 (at one point, it was claimed that patches PHNE_19766, PHNE_19826,
|
||||
PHNE_20008, and PHNE_20735 did the trick).
|
||||
|
||||
Furthermore, on HP-UX 10, you will need to turn on a kernel switch by
|
||||
doing
|
||||
|
||||
echo 'lanc_outbound_promisc_flag/W 1' | adb -w /stand/vmunix /dev/mem
|
||||
|
||||
You would have to arrange that this happen on reboots; the right way to
|
||||
do that would probably be to put it into an executable script file
|
||||
"/sbin/init.d/outbound_promisc" and making
|
||||
"/sbin/rc2.d/S350outbound_promisc" a symbolic link to that script.
|
||||
|
||||
Finally, testing shows that there can't be more than one simultaneous
|
||||
DLPI user per network interface.
|
||||
|
||||
If you use Linux, this version of libpcap is known to compile and run
|
||||
under Red Hat 4.0 with the 2.0.25 kernel. It may work with earlier 2.X
|
||||
versions but is guaranteed not to work with 1.X kernels. Running more
|
||||
than one libpcap program at a time, on a system with a 2.0.X kernel, can
|
||||
cause problems since promiscuous mode is implemented by twiddling the
|
||||
interface flags from the libpcap application; the packet capture
|
||||
mechanism in the 2.2 and later kernels doesn't have this problem. Also,
|
||||
packet timestamps aren't very good. This appears to be due to haphazard
|
||||
handling of the timestamp in the kernel.
|
||||
|
||||
Note well: there is rumoured to be a version of tcpdump floating around
|
||||
called 3.0.3 that includes libpcap and is supposed to support Linux.
|
||||
You should be advised that neither the Network Research Group at LBNL
|
||||
nor the Tcpdump Group ever generated a release with this version number.
|
||||
The LBNL Network Research Group notes with interest that a standard
|
||||
cracker trick to get people to install trojans is to distribute bogus
|
||||
packages that have a version number higher than the current release.
|
||||
They also noted with annoyance that 90% of the Linux related bug reports
|
||||
they got are due to changes made to unofficial versions of their page.
|
||||
If you are having trouble but aren't using a version that came from
|
||||
tcpdump.org, please try that before submitting a bug report!
|
||||
|
||||
On Linux, libpcap will not work if the kernel does not have the packet
|
||||
socket option enabled; see the README.linux file for information about
|
||||
this.
|
||||
|
||||
If you use AIX, you may not be able to build libpcap from this release.
|
||||
We do not have an AIX system in house so it's impossible for us to test
|
||||
AIX patches submitted to us. We are told that you must link against
|
||||
/lib/pse.exp, that you must use AIX cc or a GNU C compiler newer than
|
||||
2.7.2, and that you may need to run strload before running a libpcap
|
||||
application.
|
||||
|
||||
Read the README.aix file for information on installing libpcap and
|
||||
configuring your system to be able to support libpcap.
|
||||
|
||||
If you use NeXTSTEP, you will not be able to build libpcap from this
|
||||
release.
|
||||
|
||||
If you use SINIX, you should be able to build libpcap from this
|
||||
release. It is known to compile and run on SINIX-Y/N 5.42 with the C-DS
|
||||
V1.0 or V1.1 compiler. But note that in some releases of SINIX, yacc
|
||||
emits incorrect code; if grammar.y fails to compile, change every
|
||||
occurence of:
|
||||
|
||||
#ifdef YYDEBUG
|
||||
|
||||
to:
|
||||
#if YYDEBUG
|
||||
|
||||
Another workaround is to use flex and bison.
|
||||
|
||||
If you use SCO, you might have trouble building libpcap from this
|
||||
release. We do not have a machine running SCO and have not had reports
|
||||
of anyone successfully building on it; the current release of libpcap
|
||||
does not compile on SCO OpenServer 5. Although SCO apparently supports
|
||||
DLPI to some extent, the DLPI in OpenServer 5 is very non-standard, and
|
||||
it appears that completely new code would need to be written to capture
|
||||
network traffic. SCO do not appear to provide tcpdump binaries for
|
||||
OpenServer 5 or OpenServer 6 as part of SCO Skunkware:
|
||||
|
||||
http://www.sco.com/skunkware/
|
||||
|
||||
If you use UnixWare, you might be able to build libpcap from this
|
||||
release, or you might not. We do not have a machine running UnixWare,
|
||||
so we have not tested it; however, SCO provide packages for libpcap
|
||||
0.6.2 and tcpdump 3.7.1 in the UnixWare 7/Open UNIX 8 part of SCO
|
||||
Skunkware, and the source package for libpcap 0.6.2 is not changed from
|
||||
the libpcap 0.6.2 source release, so this release of libpcap might also
|
||||
build without changes on UnixWare 7.
|
||||
|
||||
If linking tcpdump fails with "Undefined: _alloca" when using bison on
|
||||
a Sun4, your version of Bison is broken. In any case version 1.16 or
|
||||
higher is recommended (1.14 is known to cause problems 1.16 is known to
|
||||
work). Either pick up a current version from:
|
||||
|
||||
http://ftp.gnu.org/gnu/bison/
|
||||
|
||||
or hack around it by inserting the lines:
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define alloca __builtin_alloca
|
||||
#else
|
||||
#ifdef sparc
|
||||
#include <alloca.h>
|
||||
#else
|
||||
char *alloca ();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
right after the (100 line!) GNU license comment in bison.simple, remove
|
||||
grammar.[co] and fire up make again.
|
||||
|
||||
If you use SunOS 4, your kernel must support streams NIT. If you run a
|
||||
libpcap program and it dies with:
|
||||
|
||||
/dev/nit: No such device
|
||||
|
||||
You must add streams NIT support to your kernel configuration, run
|
||||
config and boot the new kernel.
|
||||
|
||||
If you are running a version of SunOS earlier than 4.1, you will need
|
||||
to replace the Sun supplied /sys/sun{3,4,4c}/OBJ/nit_if.o with the
|
||||
appropriate version from this distribution's SUNOS4 subdirectory and
|
||||
build a new kernel:
|
||||
|
||||
nit_if.o.sun3-sunos4 (any flavor of sun3)
|
||||
nit_if.o.sun4c-sunos4.0.3c (SS1, SS1+, IPC, SLC, etc.)
|
||||
nit_if.o.sun4-sunos4 (Sun4's not covered by
|
||||
nit_if.o.sun4c-sunos4.0.3c)
|
||||
|
||||
These nit replacements fix a bug that makes nit essentially unusable in
|
||||
pre-SunOS 4.1. In addition, our sun4c-sunos4.0.3c nit gives you
|
||||
timestamps to the resolution of the SS-1 clock (1 us) rather than the
|
||||
lousy 20ms timestamps Sun gives you (tcpdump will print out the full
|
||||
timestamp resolution if it finds it's running on a SS-1).
|
||||
|
||||
FILES
|
||||
-----
|
||||
CHANGES - description of differences between releases
|
||||
ChmodBPF/* - Mac OS X startup item to set ownership and permissions
|
||||
on /dev/bpf*
|
||||
CMakeLists.txt - CMake file
|
||||
CREDITS - people that have helped libpcap along
|
||||
INSTALL.txt - this file
|
||||
LICENSE - the license under which tcpdump is distributed
|
||||
Makefile.in - compilation rules (input to the configure script)
|
||||
README - description of distribution
|
||||
README.aix - notes on using libpcap on AIX
|
||||
README.dag - notes on using libpcap to capture on Endace DAG devices
|
||||
README.hpux - notes on using libpcap on HP-UX
|
||||
README.linux - notes on using libpcap on Linux
|
||||
README.macosx - notes on using libpcap on Mac OS X
|
||||
README.septel - notes on using libpcap to capture on Intel/Septel devices
|
||||
README.sita - notes on using libpcap to capture on SITA devices
|
||||
README.tru64 - notes on using libpcap on Digital/Tru64 UNIX
|
||||
README.Win32 - notes on using libpcap on Win32 systems (with WinPcap)
|
||||
SUNOS4 - pre-SunOS 4.1 replacement kernel nit modules
|
||||
VERSION - version of this release
|
||||
acconfig.h - support for post-2.13 autoconf
|
||||
aclocal.m4 - autoconf macros
|
||||
arcnet.h - ARCNET definitions
|
||||
atmuni31.h - ATM Q.2931 definitions
|
||||
bpf/net - copy of bpf_filter.c
|
||||
bpf_dump.c - BPF program printing routines
|
||||
bpf_filter.c - symlink to bpf/net/bpf_filter.c
|
||||
bpf_image.c - BPF disassembly routine
|
||||
config.guess - autoconf support
|
||||
config.h.in - autoconf input
|
||||
config.sub - autoconf support
|
||||
configure - configure script (run this first)
|
||||
configure.ac - configure script source
|
||||
dlpisubs.c - DLPI-related functions for pcap-dlpi.c and pcap-libdlpi.c
|
||||
dlpisubs.h - DLPI-related function declarations
|
||||
etherent.c - /etc/ethers support routines
|
||||
ethertype.h - Ethernet protocol types and names definitions
|
||||
fad-getad.c - pcap_findalldevs() for systems with getifaddrs()
|
||||
fad-gifc.c - pcap_findalldevs() for systems with only SIOCGIFLIST
|
||||
fad-glifc.c - pcap_findalldevs() for systems with SIOCGLIFCONF
|
||||
filtertest.c - test program for BPF compiler
|
||||
findalldevstest.c - test program for pcap_findalldevs()
|
||||
gencode.c - BPF code generation routines
|
||||
gencode.h - BPF code generation definitions
|
||||
grammar.y - filter string grammar
|
||||
ieee80211.h - 802.11 definitions
|
||||
inet.c - network routines
|
||||
install-sh - BSD style install script
|
||||
lbl/os-*.h - OS-dependent defines and prototypes
|
||||
llc.h - 802.2 LLC SAP definitions
|
||||
missing/* - replacements for missing library functions
|
||||
mkdep - construct Makefile dependency list
|
||||
msdos/* - drivers for MS-DOS capture support
|
||||
nametoaddr.c - hostname to address routines
|
||||
nlpid.h - OSI network layer protocol identifier definitions
|
||||
net - symlink to bpf/net
|
||||
optimize.c - BPF optimization routines
|
||||
pcap/bluetooth.h - public definition of DLT_BLUETOOTH_HCI_H4_WITH_PHDR header
|
||||
pcap/bpf.h - BPF definitions
|
||||
pcap/namedb.h - public libpcap name database definitions
|
||||
pcap/pcap.h - public libpcap definitions
|
||||
pcap/sll.h - public definition of DLT_LINUX_SLL header
|
||||
pcap/usb.h - public definition of DLT_USB header
|
||||
pcap-bpf.c - BSD Packet Filter support
|
||||
pcap-bpf.h - header for backwards compatibility
|
||||
pcap-bt-linux.c - Bluetooth capture support for Linux
|
||||
pcap-bt-linux.h - Bluetooth capture support for Linux
|
||||
pcap-dag.c - Endace DAG device capture support
|
||||
pcap-dag.h - Endace DAG device capture support
|
||||
pcap-dlpi.c - Data Link Provider Interface support
|
||||
pcap-dos.c - MS-DOS capture support
|
||||
pcap-dos.h - headers for MS-DOS capture support
|
||||
pcap-enet.c - enet support
|
||||
pcap-int.h - internal libpcap definitions
|
||||
pcap-libdlpi.c - Data Link Provider Interface support for systems with libdlpi
|
||||
pcap-linux.c - Linux packet socket support
|
||||
pcap-namedb.h - header for backwards compatibility
|
||||
pcap-nit.c - SunOS Network Interface Tap support
|
||||
pcap-nit.h - SunOS Network Interface Tap definitions
|
||||
pcap-null.c - dummy monitor support (allows offline use of libpcap)
|
||||
pcap-pf.c - Ultrix and Digital/Tru64 UNIX Packet Filter support
|
||||
pcap-pf.h - Ultrix and Digital/Tru64 UNIX Packet Filter definitions
|
||||
pcap-septel.c - Intel/Septel device capture support
|
||||
pcap-septel.h - Intel/Septel device capture support
|
||||
pcap-sita.c - SITA device capture support
|
||||
pcap-sita.h - SITA device capture support
|
||||
pcap-sita.html - SITA device capture documentation
|
||||
pcap-stdinc.h - includes and #defines for compiling on Win32 systems
|
||||
pcap-snit.c - SunOS 4.x STREAMS-based Network Interface Tap support
|
||||
pcap-snoop.c - IRIX Snoop network monitoring support
|
||||
pcap-usb-linux.c - USB capture support for Linux
|
||||
pcap-usb-linux.h - USB capture support for Linux
|
||||
pcap-win32.c - WinPcap capture support
|
||||
pcap.3pcap - manual entry for the library
|
||||
pcap.c - pcap utility routines
|
||||
pcap.h - header for backwards compatibility
|
||||
pcap_*.3pcap - manual entries for library functions
|
||||
pcap-filter.4 - manual entry for filter syntax
|
||||
pcap-linktype.4 - manual entry for link-layer header types
|
||||
ppp.h - Point to Point Protocol definitions
|
||||
savefile.c - offline support
|
||||
scanner.l - filter string scanner
|
||||
sunatmpos.h - definitions for SunATM capturing
|
||||
Win32 - headers and routines for building on Win32 systems
|
@ -1,19 +0,0 @@
|
||||
License: BSD
|
||||
|
||||
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 names of the authors 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 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
@ -1,752 +0,0 @@
|
||||
# Copyright (c) 1993, 1994, 1995, 1996
|
||||
# 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.
|
||||
|
||||
#
|
||||
# Various configurable paths (remember to edit Makefile.in, not Makefile)
|
||||
#
|
||||
|
||||
# Top level hierarchy
|
||||
prefix = /usr/local
|
||||
exec_prefix = ${prefix}
|
||||
datarootdir = ${prefix}/share
|
||||
# Pathname of directory to install the configure program
|
||||
bindir = ${exec_prefix}/bin
|
||||
# Pathname of directory to install the include files
|
||||
includedir = ${prefix}/include
|
||||
# Pathname of directory to install the library
|
||||
libdir = ${exec_prefix}/lib
|
||||
# Pathname of directory to install the man pages
|
||||
mandir = ${datarootdir}/man
|
||||
|
||||
# VPATH
|
||||
srcdir = .
|
||||
|
||||
|
||||
#
|
||||
# You shouldn't need to edit anything below.
|
||||
#
|
||||
|
||||
LD = /usr/bin/ld
|
||||
CC = arm-linux-gnueabi-gcc
|
||||
AR = ar
|
||||
LN_S = ln -s
|
||||
MKDEP =
|
||||
CCOPT = -fvisibility=hidden -fpic
|
||||
INCLS = -I.
|
||||
DEFS = -DBUILDING_PCAP -DHAVE_CONFIG_H -D_U_="__attribute__((unused))"
|
||||
ADDLOBJS =
|
||||
ADDLARCHIVEOBJS =
|
||||
LIBS =
|
||||
CROSSFLAGS=
|
||||
CFLAGS = -g -O2 ${CROSSFLAGS}
|
||||
LDFLAGS = ${CROSSFLAGS}
|
||||
DYEXT = so
|
||||
V_RPATH_OPT = -Wl,-rpath,
|
||||
DEPENDENCY_CFLAG =
|
||||
PROG=libpcap
|
||||
|
||||
# Standard CFLAGS
|
||||
FULL_CFLAGS = $(CCOPT) $(INCLS) $(DEFS) $(CFLAGS)
|
||||
|
||||
INSTALL = /usr/bin/install -c
|
||||
INSTALL_PROGRAM = ${INSTALL}
|
||||
INSTALL_DATA = ${INSTALL} -m 644
|
||||
RANLIB = ranlib
|
||||
|
||||
LEX = flex
|
||||
YACC = bison -y
|
||||
|
||||
# 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.
|
||||
.c.o:
|
||||
@rm -f $@
|
||||
$(CC) $(FULL_CFLAGS) -c $(srcdir)/$*.c
|
||||
|
||||
PSRC = pcap-linux.c pcap-usb-linux.c pcap-bt-linux.c pcap-bt-monitor-linux.c pcap-netfilter-linux.c
|
||||
FSRC = fad-getad.c
|
||||
SSRC =
|
||||
CSRC = pcap.c inet.c fad-helpers.c gencode.c optimize.c nametoaddr.c \
|
||||
etherent.c savefile.c sf-pcap.c sf-pcap-ng.c pcap-common.c \
|
||||
bpf_image.c bpf_dump.c
|
||||
GENSRC = scanner.c grammar.c bpf_filter.c version.c
|
||||
LIBOBJS =
|
||||
|
||||
SRC = $(PSRC) $(FSRC) $(CSRC) $(SSRC) $(GENSRC)
|
||||
|
||||
# We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot
|
||||
# hack the extra indirection
|
||||
OBJ = $(PSRC:.c=.o) $(FSRC:.c=.o) $(CSRC:.c=.o) $(SSRC:.c=.o) $(GENSRC:.c=.o) $(LIBOBJS)
|
||||
PUBHDR = \
|
||||
pcap.h \
|
||||
pcap-bpf.h \
|
||||
pcap-namedb.h \
|
||||
pcap/bpf.h \
|
||||
pcap/bluetooth.h \
|
||||
pcap/can_socketcan.h \
|
||||
pcap/dlt.h \
|
||||
pcap/export-defs.h \
|
||||
pcap/ipnet.h \
|
||||
pcap/namedb.h \
|
||||
pcap/nflog.h \
|
||||
pcap/pcap.h \
|
||||
pcap/sll.h \
|
||||
pcap/vlan.h \
|
||||
pcap/usb.h
|
||||
|
||||
HDR = $(PUBHDR) \
|
||||
arcnet.h \
|
||||
atmuni31.h \
|
||||
ethertype.h \
|
||||
extract.h \
|
||||
gencode.h \
|
||||
ieee80211.h \
|
||||
llc.h \
|
||||
nametoaddr.h \
|
||||
nlpid.h \
|
||||
pcap-common.h \
|
||||
pcap-int.h \
|
||||
pcap-stdinc.h \
|
||||
portability.h \
|
||||
ppp.h \
|
||||
sf-pcap.h \
|
||||
sf-pcap-ng.h \
|
||||
sunatmpos.h
|
||||
|
||||
TESTS = \
|
||||
\
|
||||
capturetest \
|
||||
can_set_rfmon_test \
|
||||
filtertest \
|
||||
findalldevstest \
|
||||
opentest \
|
||||
reactivatetest \
|
||||
selpolltest
|
||||
|
||||
TESTS_SRC = \
|
||||
tests/valgrindtest.c \
|
||||
tests/capturetest.c \
|
||||
tests/can_set_rfmon_test.c \
|
||||
tests/filtertest.c \
|
||||
tests/findalldevstest.c \
|
||||
tests/opentest.c \
|
||||
tests/reactivatetest.c \
|
||||
tests/selpolltest.c
|
||||
|
||||
GENHDR = \
|
||||
scanner.h grammar.h pcap_version.h
|
||||
|
||||
TAGFILES = \
|
||||
$(SRC) $(HDR)
|
||||
|
||||
CLEANFILES = $(OBJ) libpcap.* $(TESTS) \
|
||||
$(PROG)-`cat $(srcdir)/VERSION`.tar.gz $(GENSRC) $(GENHDR) \
|
||||
lex.yy.c pcap-config
|
||||
|
||||
MAN1 = pcap-config.1
|
||||
|
||||
MAN3PCAP_EXPAND = \
|
||||
pcap.3pcap.in \
|
||||
pcap_compile.3pcap.in \
|
||||
pcap_datalink.3pcap.in \
|
||||
pcap_dump_open.3pcap.in \
|
||||
pcap_get_tstamp_precision.3pcap.in \
|
||||
pcap_list_datalinks.3pcap.in \
|
||||
pcap_list_tstamp_types.3pcap.in \
|
||||
pcap_open_dead.3pcap.in \
|
||||
pcap_open_offline.3pcap.in \
|
||||
pcap_set_tstamp_precision.3pcap.in \
|
||||
pcap_set_tstamp_type.3pcap.in
|
||||
|
||||
MAN3PCAP_NOEXPAND = \
|
||||
pcap_activate.3pcap \
|
||||
pcap_breakloop.3pcap \
|
||||
pcap_can_set_rfmon.3pcap \
|
||||
pcap_close.3pcap \
|
||||
pcap_create.3pcap \
|
||||
pcap_datalink_name_to_val.3pcap \
|
||||
pcap_datalink_val_to_name.3pcap \
|
||||
pcap_dump.3pcap \
|
||||
pcap_dump_close.3pcap \
|
||||
pcap_dump_file.3pcap \
|
||||
pcap_dump_flush.3pcap \
|
||||
pcap_dump_ftell.3pcap \
|
||||
pcap_file.3pcap \
|
||||
pcap_fileno.3pcap \
|
||||
pcap_findalldevs.3pcap \
|
||||
pcap_freecode.3pcap \
|
||||
pcap_get_selectable_fd.3pcap \
|
||||
pcap_geterr.3pcap \
|
||||
pcap_inject.3pcap \
|
||||
pcap_is_swapped.3pcap \
|
||||
pcap_lib_version.3pcap \
|
||||
pcap_lookupdev.3pcap \
|
||||
pcap_lookupnet.3pcap \
|
||||
pcap_loop.3pcap \
|
||||
pcap_major_version.3pcap \
|
||||
pcap_next_ex.3pcap \
|
||||
pcap_offline_filter.3pcap \
|
||||
pcap_open_live.3pcap \
|
||||
pcap_set_buffer_size.3pcap \
|
||||
pcap_set_datalink.3pcap \
|
||||
pcap_set_immediate_mode.3pcap \
|
||||
pcap_set_promisc.3pcap \
|
||||
pcap_set_rfmon.3pcap \
|
||||
pcap_set_snaplen.3pcap \
|
||||
pcap_set_timeout.3pcap \
|
||||
pcap_setdirection.3pcap \
|
||||
pcap_setfilter.3pcap \
|
||||
pcap_setnonblock.3pcap \
|
||||
pcap_snapshot.3pcap \
|
||||
pcap_stats.3pcap \
|
||||
pcap_statustostr.3pcap \
|
||||
pcap_strerror.3pcap \
|
||||
pcap_tstamp_type_name_to_val.3pcap \
|
||||
pcap_tstamp_type_val_to_name.3pcap
|
||||
|
||||
MAN3PCAP = $(MAN3PCAP_NOEXPAND) $(MAN3PCAP_EXPAND:.in=)
|
||||
|
||||
MANFILE = \
|
||||
pcap-savefile.manfile.in
|
||||
|
||||
MANMISC = \
|
||||
pcap-filter.manmisc.in \
|
||||
pcap-linktype.manmisc.in \
|
||||
pcap-tstamp.manmisc.in
|
||||
|
||||
EXTRA_DIST = \
|
||||
$(TESTS_SRC) \
|
||||
CHANGES \
|
||||
ChmodBPF/ChmodBPF \
|
||||
ChmodBPF/StartupParameters.plist \
|
||||
CREDITS \
|
||||
CMakeLists.txt \
|
||||
GenVersion.bat \
|
||||
INSTALL.txt \
|
||||
LICENSE \
|
||||
Makefile.in \
|
||||
Makefile-devel-adds \
|
||||
README \
|
||||
README.aix \
|
||||
README.dag \
|
||||
README.hpux \
|
||||
README.linux \
|
||||
README.macosx \
|
||||
README.septel \
|
||||
README.sita \
|
||||
README.tru64 \
|
||||
README.Win32 \
|
||||
SUNOS4/nit_if.o.sparc \
|
||||
SUNOS4/nit_if.o.sun3 \
|
||||
SUNOS4/nit_if.o.sun4c.4.0.3c \
|
||||
TODO \
|
||||
VERSION \
|
||||
aclocal.m4 \
|
||||
bpf/net/bpf_filter.c \
|
||||
chmod_bpf \
|
||||
cmakeconfig.h.in \
|
||||
cmake/preconfigure.cmake \
|
||||
config/have_siocglifconf.c \
|
||||
config.guess \
|
||||
config.h.in \
|
||||
config.sub \
|
||||
configure \
|
||||
configure.ac \
|
||||
dlpisubs.c \
|
||||
dlpisubs.h \
|
||||
fad-getad.c \
|
||||
fad-gifc.c \
|
||||
fad-glifc.c \
|
||||
fad-helpers.c \
|
||||
gen_version_c.sh \
|
||||
gen_version_header.sh \
|
||||
grammar.y \
|
||||
install-sh \
|
||||
lbl/os-aix4.h \
|
||||
lbl/os-aix7.h \
|
||||
lbl/os-hpux11.h \
|
||||
lbl/os-osf4.h \
|
||||
lbl/os-osf5.h \
|
||||
lbl/os-solaris2.h \
|
||||
lbl/os-sunos4.h \
|
||||
lbl/os-ultrix4.h \
|
||||
missing/getopt.c \
|
||||
missing/getopt.h \
|
||||
missing/snprintf.c \
|
||||
missing/strtok_r.c \
|
||||
missing/win_snprintf.c \
|
||||
mkdep \
|
||||
msdos/bin2c.c \
|
||||
msdos/common.dj \
|
||||
msdos/makefile \
|
||||
msdos/makefile.dj \
|
||||
msdos/makefile.wc \
|
||||
msdos/ndis2.c \
|
||||
msdos/ndis2.h \
|
||||
msdos/ndis_0.asm \
|
||||
msdos/pkt_rx0.asm \
|
||||
msdos/pkt_rx1.s \
|
||||
msdos/pktdrvr.c \
|
||||
msdos/pktdrvr.h \
|
||||
msdos/readme.dos \
|
||||
org.tcpdump.chmod_bpf.plist \
|
||||
pcap-bpf.c \
|
||||
pcap-bt-linux.c \
|
||||
pcap-bt-linux.h \
|
||||
pcap-bt-monitor-linux.c \
|
||||
pcap-bt-monitor-linux.h \
|
||||
pcap-config.in \
|
||||
pcap-dag.c \
|
||||
pcap-dag.h \
|
||||
pcap-dbus.c \
|
||||
pcap-dbus.h \
|
||||
pcap-dlpi.c \
|
||||
pcap-dos.c \
|
||||
pcap-dos.h \
|
||||
pcap-enet.c \
|
||||
pcap-int.h \
|
||||
pcap-libdlpi.c \
|
||||
pcap-linux.c \
|
||||
pcap-namedb.h \
|
||||
pcap-new.c \
|
||||
pcap-netfilter-linux.c \
|
||||
pcap-netfilter-linux.h \
|
||||
pcap-nit.c \
|
||||
pcap-null.c \
|
||||
pcap-pf.c \
|
||||
pcap-rpcap.c \
|
||||
pcap-rpcap.h \
|
||||
pcap-septel.c \
|
||||
pcap-septel.h \
|
||||
pcap-sita.h \
|
||||
pcap-sita.c \
|
||||
pcap-sita.html \
|
||||
pcap-snf.c \
|
||||
pcap-snf.h \
|
||||
pcap-snit.c \
|
||||
pcap-snoop.c \
|
||||
pcap-tc.c \
|
||||
pcap-tc.h \
|
||||
pcap-usb-linux.c \
|
||||
pcap-usb-linux.h \
|
||||
pcap-win32.c \
|
||||
remote-ext.h \
|
||||
sockutils.c \
|
||||
sockutils.h \
|
||||
scanner.l \
|
||||
tests/CMakeLists.txt \
|
||||
pcap_version.h.in \
|
||||
Win32/Include/Gnuc.h \
|
||||
Win32/Include/net/if.h \
|
||||
Win32/Prj/wpcap.sln \
|
||||
Win32/Prj/wpcap.vcxproj \
|
||||
Win32/Prj/wpcap.vcxproj.filters
|
||||
|
||||
all: libpcap.a shared pcap-config
|
||||
|
||||
libpcap.a: $(OBJ)
|
||||
@rm -f $@
|
||||
$(AR) rc $@ $(OBJ) $(ADDLARCHIVEOBJS)
|
||||
$(RANLIB) $@
|
||||
|
||||
shared: libpcap.$(DYEXT)
|
||||
|
||||
libpcap.so: $(OBJ)
|
||||
@rm -f $@
|
||||
VER=`cat $(srcdir)/VERSION`; \
|
||||
MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
|
||||
$(CC) -shared -Wl,-soname,$@.$$MAJOR_VER $(LDFLAGS) \
|
||||
-o $@.$$VER $(OBJ) $(ADDLOBJS) $(LIBS)
|
||||
|
||||
#
|
||||
# The following rule succeeds, but the result is untested.
|
||||
#
|
||||
# In Mac OS X, the libpcap dylib has the name "libpcap.A.dylib", with
|
||||
# its full path as the install_name, and with the compatibility and
|
||||
# current version both set to 1. The compatibility version is set to
|
||||
# 1 so that programs built with a newer version of the library will run
|
||||
# against older versions; multi-platform software probably will fail if
|
||||
# it uses APIs added in the newer version, but Mac OS X-specific software
|
||||
# will use weak linking and check at run time whether those APIs are
|
||||
# available.
|
||||
#
|
||||
# We also use "A" as the major version, and 1 as the compatibility version,
|
||||
# but set the current version to the value in VERSION, with any non-numeric
|
||||
# stuff stripped off (the compatibility and current version must be of the
|
||||
# form X[.Y[.Z]], with Y and Z possibly absent, and with all components
|
||||
# numeric).
|
||||
#
|
||||
libpcap.dylib: $(OBJ)
|
||||
rm -f libpcap*.dylib
|
||||
VER=`cat $(srcdir)/VERSION`; \
|
||||
MAJOR_VER=A; \
|
||||
COMPAT_VER=1; \
|
||||
CURRENT_VER=`sed 's/[^0-9.].*$$//' $(srcdir)/VERSION`; \
|
||||
$(CC) -dynamiclib -undefined error $(LDFLAGS) \
|
||||
-o libpcap.$$VER.dylib $(OBJ) $(ADDLOBJS) $(LIBS) \
|
||||
-install_name $(libdir)/libpcap.$$MAJOR_VER.dylib \
|
||||
-compatibility_version $$COMPAT_VER \
|
||||
-current_version $$CURRENT_VER
|
||||
|
||||
#
|
||||
# The HP-UX linker manual says that the convention for a versioned library
|
||||
# is libXXX.{number}, not libXXX.sl.{number}. That appears to be the case
|
||||
# on at least one HP-UX 11.00 system; libXXX.sl is a symlink to
|
||||
# libXXX.{number}.
|
||||
#
|
||||
# The manual also says "library-level versioning" (think "sonames") was
|
||||
# added in HP-UX 10.0.
|
||||
#
|
||||
# XXX - this assumes we're using the HP linker, rather than the GNU
|
||||
# linker, even with GCC.
|
||||
#
|
||||
libpcap.sl: $(OBJ)
|
||||
@MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
|
||||
rm -f libpcap.$$MAJOR_VER
|
||||
MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
|
||||
ld -b $(LDFLAGS) -o libpcap.$$MAJOR_VER +h libpcap.$$MAJOR_VER \
|
||||
$(OBJ) $(ADDLOBJS) $(LIBS)
|
||||
|
||||
#
|
||||
# AIX is different from everybody else. A shared library is an archive
|
||||
# library with one or more shared-object components. We still build a
|
||||
# normal static archive library on AIX, for the benefit of the traditional
|
||||
# scheme of building libpcap and tcpdump in subdirectories of the
|
||||
# same directory, with tcpdump statically linked with the libpcap
|
||||
# in question, but we also build a shared library as "libpcap.shareda"
|
||||
# and install *it*, rather than the static library, as "libpcap.a".
|
||||
#
|
||||
libpcap.shareda: $(OBJ)
|
||||
@rm -f $@ shr.o
|
||||
$(CC) -shared -o shr.o $(OBJ) $(ADDLOBJS) $(LDFLAGS) $(LIBS)
|
||||
$(AR) rc $@ shr.o
|
||||
|
||||
#
|
||||
# For platforms that don't support shared libraries (or on which we
|
||||
# don't support shared libraries).
|
||||
#
|
||||
libpcap.none:
|
||||
|
||||
scanner.c: $(srcdir)/scanner.l
|
||||
$(LEX) -P pcap_ --header-file=scanner.h --nounput -o scanner.c $<
|
||||
scanner.h: scanner.c
|
||||
## Recover from the removal of $@
|
||||
@if test -f $@; then :; else \
|
||||
rm -f scanner.c; \
|
||||
$(MAKE) $(MAKEFLAGS) scanner.c; \
|
||||
fi
|
||||
|
||||
scanner.o: scanner.c grammar.h
|
||||
$(CC) $(FULL_CFLAGS) -c scanner.c
|
||||
|
||||
pcap.o: pcap_version.h
|
||||
|
||||
grammar.c: $(srcdir)/grammar.y
|
||||
$(YACC) -p pcap_ -o grammar.c -d $<
|
||||
grammar.h: grammar.c
|
||||
## Recover from the removal of $@
|
||||
@if test -f $@; then :; else \
|
||||
rm -f grammar.c; \
|
||||
$(MAKE) $(MAKEFLAGS) grammar.c; \
|
||||
fi
|
||||
|
||||
grammar.o: grammar.c
|
||||
$(CC) $(FULL_CFLAGS) -c grammar.c
|
||||
|
||||
gencode.o: $(srcdir)/gencode.c grammar.h scanner.h
|
||||
$(CC) $(FULL_CFLAGS) -c $(srcdir)/gencode.c
|
||||
|
||||
version.o: version.c
|
||||
$(CC) $(FULL_CFLAGS) -c version.c
|
||||
|
||||
snprintf.o: $(srcdir)/missing/snprintf.c
|
||||
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c
|
||||
|
||||
strtok_r.o: $(srcdir)/missing/strtok_r.c
|
||||
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strtok_r.c
|
||||
|
||||
version.c: $(srcdir)/VERSION $(srcdir)/gen_version_c.sh
|
||||
#
|
||||
# Older programs import this if they want to show the
|
||||
# libpcap version number, rather than calling
|
||||
# pcap_lib_version(), so we need to export it.
|
||||
#
|
||||
@rm -f $@
|
||||
$(srcdir)/gen_version_c.sh $(srcdir)/VERSION $@
|
||||
|
||||
pcap_version.h: $(srcdir)/VERSION $(srcdir)/pcap_version.h.in $(srcdir)/gen_version_header.sh
|
||||
@rm -f $@
|
||||
$(srcdir)/gen_version_header.sh $(srcdir)/VERSION $(srcdir)/pcap_version.h.in $@
|
||||
|
||||
bpf_filter.c: $(srcdir)/bpf/net/bpf_filter.c
|
||||
rm -f bpf_filter.c
|
||||
ln -s $(srcdir)/bpf/net/bpf_filter.c bpf_filter.c
|
||||
|
||||
bpf_filter.o: bpf_filter.c
|
||||
$(CC) $(FULL_CFLAGS) -c bpf_filter.c
|
||||
|
||||
#
|
||||
# Generate the pcap-config script.
|
||||
#
|
||||
# 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
|
||||
./config.status --file=$@.tmp:$(srcdir)/pcap-config.in
|
||||
mv $@.tmp $@
|
||||
chmod a+x $@
|
||||
|
||||
#
|
||||
# Test programs - not built by default, and not installed.
|
||||
#
|
||||
tests: $(TESTS)
|
||||
|
||||
capturetest: tests/capturetest.c libpcap.a
|
||||
$(CC) $(FULL_CFLAGS) -I. -L. -o capturetest $(srcdir)/tests/capturetest.c libpcap.a $(LIBS)
|
||||
|
||||
can_set_rfmon_test: tests/can_set_rfmon_test.c libpcap.a
|
||||
$(CC) $(FULL_CFLAGS) -I. -L. -o can_set_rfmon_test $(srcdir)/tests/can_set_rfmon_test.c libpcap.a $(LIBS)
|
||||
|
||||
filtertest: tests/filtertest.c libpcap.a
|
||||
$(CC) $(FULL_CFLAGS) -I. -L. -o filtertest $(srcdir)/tests/filtertest.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: tests/opentest.c libpcap.a
|
||||
$(CC) $(FULL_CFLAGS) -I. -L. -o opentest $(srcdir)/tests/opentest.c libpcap.a $(LIBS)
|
||||
|
||||
reactivatetest: tests/reactivatetest.c libpcap.a
|
||||
$(CC) $(FULL_CFLAGS) -I. -L. -o reactivatetest $(srcdir)/tests/reactivatetest.c libpcap.a $(LIBS)
|
||||
|
||||
selpolltest: tests/selpolltest.c libpcap.a
|
||||
$(CC) $(FULL_CFLAGS) -I. -L. -o selpolltest $(srcdir)/tests/selpolltest.c libpcap.a $(LIBS)
|
||||
|
||||
valgrindtest: tests/valgrindtest.c libpcap.a
|
||||
$(CC) $(FULL_CFLAGS) -I. -L. -o valgrindtest $(srcdir)/tests/valgrindtest.c libpcap.a $(LIBS)
|
||||
|
||||
install: install-shared install-archive pcap-config
|
||||
[ -d $(DESTDIR)$(libdir) ] || \
|
||||
(mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
|
||||
[ -d $(DESTDIR)$(includedir) ] || \
|
||||
(mkdir -p $(DESTDIR)$(includedir); chmod 755 $(DESTDIR)$(includedir))
|
||||
[ -d $(DESTDIR)$(includedir)/pcap ] || \
|
||||
(mkdir -p $(DESTDIR)$(includedir)/pcap; chmod 755 $(DESTDIR)$(includedir)/pcap)
|
||||
[ -d $(DESTDIR)$(mandir)/man1 ] || \
|
||||
(mkdir -p $(DESTDIR)$(mandir)/man1; chmod 755 $(DESTDIR)$(mandir)/man1)
|
||||
[ -d $(DESTDIR)$(mandir)/man3 ] || \
|
||||
(mkdir -p $(DESTDIR)$(mandir)/man3; chmod 755 $(DESTDIR)$(mandir)/man3)
|
||||
[ -d $(DESTDIR)$(mandir)/man5 ] || \
|
||||
(mkdir -p $(DESTDIR)$(mandir)/man5; chmod 755 $(DESTDIR)$(mandir)/man5)
|
||||
[ -d $(DESTDIR)$(mandir)/man7 ] || \
|
||||
(mkdir -p $(DESTDIR)$(mandir)/man7; chmod 755 $(DESTDIR)$(mandir)/man7)
|
||||
for i in $(PUBHDR); do \
|
||||
$(INSTALL_DATA) $(srcdir)/$$i \
|
||||
$(DESTDIR)$(includedir)/$$i; done
|
||||
[ -d $(DESTDIR)$(bindir) ] || \
|
||||
(mkdir -p $(DESTDIR)$(bindir); chmod 755 $(DESTDIR)$(bindir))
|
||||
$(INSTALL_PROGRAM) pcap-config $(DESTDIR)$(bindir)/pcap-config
|
||||
for i in $(MAN1); do \
|
||||
$(INSTALL_DATA) $(srcdir)/$$i \
|
||||
$(DESTDIR)$(mandir)/man1/$$i; done
|
||||
for i in $(MAN3PCAP_NOEXPAND); do \
|
||||
$(INSTALL_DATA) $(srcdir)/$$i \
|
||||
$(DESTDIR)$(mandir)/man3/$$i; done
|
||||
for i in $(MAN3PCAP_EXPAND:.in=); do \
|
||||
$(INSTALL_DATA) $$i \
|
||||
$(DESTDIR)$(mandir)/man3/$$i; done
|
||||
(cd $(DESTDIR)$(mandir)/man3 && \
|
||||
rm -f pcap_datalink_val_to_description.3pcap && \
|
||||
$(LN_S) pcap_datalink_val_to_name.3pcap \
|
||||
pcap_datalink_val_to_description.3pcap && \
|
||||
rm -f pcap_dump_fopen.3pcap && \
|
||||
$(LN_S) pcap_dump_open.3pcap pcap_dump_fopen.3pcap && \
|
||||
rm -f pcap_freealldevs.3pcap && \
|
||||
$(LN_S) pcap_findalldevs.3pcap pcap_freealldevs.3pcap && \
|
||||
rm -f pcap_perror.3pcap && \
|
||||
$(LN_S) pcap_geterr.3pcap pcap_perror.3pcap && \
|
||||
rm -f pcap_sendpacket.3pcap && \
|
||||
$(LN_S) pcap_inject.3pcap pcap_sendpacket.3pcap && \
|
||||
rm -f pcap_free_datalinks.3pcap && \
|
||||
$(LN_S) pcap_list_datalinks.3pcap pcap_free_datalinks.3pcap && \
|
||||
rm -f pcap_free_tstamp_types.3pcap && \
|
||||
$(LN_S) pcap_list_tstamp_types.3pcap pcap_free_tstamp_types.3pcap && \
|
||||
rm -f pcap_dispatch.3pcap && \
|
||||
$(LN_S) pcap_loop.3pcap pcap_dispatch.3pcap && \
|
||||
rm -f pcap_minor_version.3pcap && \
|
||||
$(LN_S) pcap_major_version.3pcap pcap_minor_version.3pcap && \
|
||||
rm -f pcap_next.3pcap && \
|
||||
$(LN_S) pcap_next_ex.3pcap pcap_next.3pcap && \
|
||||
rm -f pcap_open_dead_with_tstamp_precision.3pcap && \
|
||||
$(LN_S) pcap_open_dead.3pcap \
|
||||
pcap_open_dead_with_tstamp_precision.3pcap && \
|
||||
rm -f pcap_open_offline_with_tstamp_precision.3pcap && \
|
||||
$(LN_S) pcap_open_offline.3pcap pcap_open_offline_with_tstamp_precision.3pcap && \
|
||||
rm -f pcap_fopen_offline.3pcap && \
|
||||
$(LN_S) pcap_open_offline.3pcap pcap_fopen_offline.3pcap && \
|
||||
rm -f pcap_fopen_offline_with_tstamp_precision.3pcap && \
|
||||
$(LN_S) pcap_open_offline.3pcap pcap_fopen_offline_with_tstamp_precision.3pcap && \
|
||||
rm -f pcap_tstamp_type_val_to_description.3pcap && \
|
||||
$(LN_S) pcap_tstamp_type_val_to_name.3pcap pcap_tstamp_type_val_to_description.3pcap && \
|
||||
rm -f pcap_getnonblock.3pcap && \
|
||||
$(LN_S) pcap_setnonblock.3pcap pcap_getnonblock.3pcap)
|
||||
for i in $(MANFILE); do \
|
||||
$(INSTALL_DATA) `echo $$i | sed 's/.manfile.in/.manfile/'` \
|
||||
$(DESTDIR)$(mandir)/man5/`echo $$i | sed 's/.manfile.in/.5/'`; done
|
||||
for i in $(MANMISC); do \
|
||||
$(INSTALL_DATA) `echo $$i | sed 's/.manmisc.in/.manmisc/'` \
|
||||
$(DESTDIR)$(mandir)/man7/`echo $$i | sed 's/.manmisc.in/.7/'`; done
|
||||
|
||||
install-shared: install-shared-$(DYEXT)
|
||||
install-shared-so: libpcap.so
|
||||
[ -d $(DESTDIR)$(libdir) ] || \
|
||||
(mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
|
||||
VER=`cat $(srcdir)/VERSION`; \
|
||||
MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
|
||||
$(INSTALL_PROGRAM) libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$VER; \
|
||||
ln -sf libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$MAJOR_VER; \
|
||||
ln -sf libpcap.so.$$MAJOR_VER $(DESTDIR)$(libdir)/libpcap.so
|
||||
install-shared-dylib: libpcap.dylib
|
||||
[ -d $(DESTDIR)$(libdir) ] || \
|
||||
(mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
|
||||
VER=`cat $(srcdir)/VERSION`; \
|
||||
MAJOR_VER=A; \
|
||||
$(INSTALL_PROGRAM) libpcap.$$VER.dylib $(DESTDIR)$(libdir)/libpcap.$$VER.dylib; \
|
||||
ln -sf libpcap.$$VER.dylib $(DESTDIR)$(libdir)/libpcap.$$MAJOR_VER.dylib; \
|
||||
ln -sf libpcap.$$MAJOR_VER.dylib $(DESTDIR)$(libdir)/libpcap.dylib
|
||||
install-shared-sl: libpcap.sl
|
||||
[ -d $(DESTDIR)$(libdir) ] || \
|
||||
(mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
|
||||
MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
|
||||
$(INSTALL_PROGRAM) libpcap.$$MAJOR_VER $(DESTDIR)$(libdir)
|
||||
ln -sf libpcap.$$MAJOR_VER $(DESTDIR)$(libdir)/libpcap.sl
|
||||
install-shared-shareda: libpcap.shareda
|
||||
#
|
||||
# AIX shared libraries are weird. They're archive libraries
|
||||
# with one or more shared object components.
|
||||
#
|
||||
[ -d $(DESTDIR)$(libdir) ] || \
|
||||
(mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
|
||||
$(INSTALL_PROGRAM) libpcap.shareda $(DESTDIR)$(libdir)/libpcap.a
|
||||
install-shared-none:
|
||||
|
||||
install-archive: install-archive-$(DYEXT)
|
||||
install-archive-so install-archive-dylib install-archive-sl install-archive-none: libpcap.a
|
||||
#
|
||||
# Most platforms have separate suffixes for shared and
|
||||
# archive libraries, so we install both.
|
||||
#
|
||||
[ -d $(DESTDIR)$(libdir) ] || \
|
||||
(mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
|
||||
$(INSTALL_DATA) libpcap.a $(DESTDIR)$(libdir)/libpcap.a
|
||||
$(RANLIB) $(DESTDIR)$(libdir)/libpcap.a
|
||||
install-archive-shareda:
|
||||
#
|
||||
# AIX, however, doesn't, so we don't install the archive
|
||||
# library on AIX.
|
||||
#
|
||||
|
||||
uninstall: uninstall-shared
|
||||
rm -f $(DESTDIR)$(libdir)/libpcap.a
|
||||
for i in $(PUBHDR); do \
|
||||
rm -f $(DESTDIR)$(includedir)/$$i; done
|
||||
-rmdir $(DESTDIR)$(includedir)/pcap
|
||||
rm -f $(DESTDIR)/$(bindir)/pcap-config
|
||||
for i in $(MAN1); do \
|
||||
rm -f $(DESTDIR)$(mandir)/man1/$$i; done
|
||||
for i in $(MAN3PCAP); do \
|
||||
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
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_open_dead_with_tstamp_precision.3pcap
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_open_offline_with_tstamp_precision.3pcap
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_fopen_offline.3pcap
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_fopen_offline_with_tstamp_precision.3pcap
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_getnonblock.3pcap
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_tstamp_type_val_to_description.3pcap
|
||||
for i in $(MANFILE); do \
|
||||
rm -f $(DESTDIR)$(mandir)/man5/`echo $$i | sed 's/.manfile.in/.5/'`; done
|
||||
for i in $(MANMISC); do \
|
||||
rm -f $(DESTDIR)$(mandir)/man7/`echo $$i | sed 's/.manmisc.in/.7/'`; done
|
||||
|
||||
uninstall-shared: uninstall-shared-$(DYEXT)
|
||||
uninstall-shared-so:
|
||||
VER=`cat $(srcdir)/VERSION`; \
|
||||
MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
|
||||
rm -f $(DESTDIR)$(libdir)/libpcap.so.$$VER; \
|
||||
rm -f $(DESTDIR)$(libdir)/libpcap.so.$$MAJOR_VER; \
|
||||
rm -f $(DESTDIR)$(libdir)/libpcap.so
|
||||
uninstall-shared-dylib:
|
||||
VER=`cat $(srcdir)/VERSION`; \
|
||||
MAJOR_VER=A; \
|
||||
rm -f $(DESTDIR)$(libdir)/libpcap.$$VER.dylib; \
|
||||
rm -f $(DESTDIR)$(libdir)/libpcap.$$MAJOR_VER.dylib; \
|
||||
rm -f $(DESTDIR)$(libdir)/libpcap.dylib
|
||||
uninstall-shared-sl:
|
||||
MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
|
||||
rm -f $(DESTDIR)$(libdir)/libpcap.$$MAJOR_VER; \
|
||||
rm -f $(DESTDIR)$(libdir)/libpcap.sl
|
||||
uninstall-shared-shareda:
|
||||
rm -f $(DESTDIR)$(libdir)/libpcap.a
|
||||
uninstall-shared-none:
|
||||
|
||||
clean:
|
||||
rm -f $(CLEANFILES)
|
||||
|
||||
distclean: clean
|
||||
rm -f Makefile config.cache config.log config.status \
|
||||
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
|
||||
|
||||
extags: $(TAGFILES)
|
||||
ctags $(TAGFILES)
|
||||
|
||||
tags: $(TAGFILES)
|
||||
ctags -wtd $(TAGFILES)
|
||||
|
||||
releasetar:
|
||||
@cwd=`pwd` ; dir=`basename $$cwd` ; name=$(PROG)-`cat VERSION` ; \
|
||||
mkdir $$name; \
|
||||
tar cf - $(CSRC) $(HDR) $(MAN1) $(MAN3PCAP_EXPAND) \
|
||||
$(MAN3PCAP_NOEXPAND) $(MANFILE) $(MANMISC) $(EXTRA_DIST) | \
|
||||
(cd $$name; tar xf -); \
|
||||
tar -c -z -f $$name.tar.gz $$name; \
|
||||
rm -rf $$name
|
||||
|
||||
depend: $(GENSRC) $(GENHDR) bpf_filter.c
|
||||
$(MKDEP) -c $(CC) -m $(CFLAGS) $(DEPENDENCY_CFLAG) $(DEFS) $(INCLS) $(SRC)
|
@ -1,22 +0,0 @@
|
||||
#
|
||||
# Auto-regenerate configure script or Makefile when things change.
|
||||
# From autoconf.info . Works best with GNU Make.
|
||||
#
|
||||
${srcdir}/configure: configure.ac aclocal.m4
|
||||
cd ${srcdir} && autoconf
|
||||
|
||||
# autoheader might not change config.h.in, so touch a stamp file.
|
||||
${srcdir}/config.h.in: ${srcdir}/stamp-h.in
|
||||
${srcdir}/stamp-h.in: configure.ac aclocal.m4
|
||||
cd ${srcdir} && autoheader
|
||||
echo timestamp > ${srcdir}/stamp-h.in
|
||||
|
||||
config.h: stamp-h
|
||||
stamp-h: ${srcdir}/config.h.in config.status
|
||||
./config.status
|
||||
|
||||
Makefile: Makefile.in config.status
|
||||
./config.status
|
||||
|
||||
config.status: ${srcdir}/configure
|
||||
./config.status --recheck
|
@ -1,752 +0,0 @@
|
||||
# Copyright (c) 1993, 1994, 1995, 1996
|
||||
# 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.
|
||||
|
||||
#
|
||||
# Various configurable paths (remember to edit Makefile.in, not Makefile)
|
||||
#
|
||||
|
||||
# Top level hierarchy
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
datarootdir = @datarootdir@
|
||||
# Pathname of directory to install the configure program
|
||||
bindir = @bindir@
|
||||
# Pathname of directory to install the include files
|
||||
includedir = @includedir@
|
||||
# Pathname of directory to install the library
|
||||
libdir = @libdir@
|
||||
# Pathname of directory to install the man pages
|
||||
mandir = @mandir@
|
||||
|
||||
# VPATH
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
#
|
||||
# You shouldn't need to edit anything below.
|
||||
#
|
||||
|
||||
LD = /usr/bin/ld
|
||||
CC = @CC@
|
||||
AR = @AR@
|
||||
LN_S = @LN_S@
|
||||
MKDEP = @MKDEP@
|
||||
CCOPT = @V_CCOPT@
|
||||
INCLS = -I. @V_INCLS@
|
||||
DEFS = -DBUILDING_PCAP @DEFS@ @V_DEFS@
|
||||
ADDLOBJS = @ADDLOBJS@
|
||||
ADDLARCHIVEOBJS = @ADDLARCHIVEOBJS@
|
||||
LIBS = @LIBS@
|
||||
CROSSFLAGS=
|
||||
CFLAGS = @CFLAGS@ ${CROSSFLAGS}
|
||||
LDFLAGS = @LDFLAGS@ ${CROSSFLAGS}
|
||||
DYEXT = @DYEXT@
|
||||
V_RPATH_OPT = @V_RPATH_OPT@
|
||||
DEPENDENCY_CFLAG = @DEPENDENCY_CFLAG@
|
||||
PROG=libpcap
|
||||
|
||||
# Standard CFLAGS
|
||||
FULL_CFLAGS = $(CCOPT) $(INCLS) $(DEFS) $(CFLAGS)
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
RANLIB = @RANLIB@
|
||||
|
||||
LEX = @LEX@
|
||||
YACC = @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.
|
||||
.c.o:
|
||||
@rm -f $@
|
||||
$(CC) $(FULL_CFLAGS) -c $(srcdir)/$*.c
|
||||
|
||||
PSRC = pcap-@V_PCAP@.c @USB_SRC@ @BT_SRC@ @BT_MONITOR_SRC@ @NETFILTER_SRC@ @DBUS_SRC@
|
||||
FSRC = @V_FINDALLDEVS@
|
||||
SSRC = @SSRC@
|
||||
CSRC = pcap.c inet.c fad-helpers.c gencode.c optimize.c nametoaddr.c \
|
||||
etherent.c savefile.c sf-pcap.c sf-pcap-ng.c pcap-common.c \
|
||||
bpf_image.c bpf_dump.c
|
||||
GENSRC = scanner.c grammar.c bpf_filter.c version.c
|
||||
LIBOBJS = @LIBOBJS@
|
||||
|
||||
SRC = $(PSRC) $(FSRC) $(CSRC) $(SSRC) $(GENSRC)
|
||||
|
||||
# We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot
|
||||
# hack the extra indirection
|
||||
OBJ = $(PSRC:.c=.o) $(FSRC:.c=.o) $(CSRC:.c=.o) $(SSRC:.c=.o) $(GENSRC:.c=.o) $(LIBOBJS)
|
||||
PUBHDR = \
|
||||
pcap.h \
|
||||
pcap-bpf.h \
|
||||
pcap-namedb.h \
|
||||
pcap/bpf.h \
|
||||
pcap/bluetooth.h \
|
||||
pcap/can_socketcan.h \
|
||||
pcap/dlt.h \
|
||||
pcap/export-defs.h \
|
||||
pcap/ipnet.h \
|
||||
pcap/namedb.h \
|
||||
pcap/nflog.h \
|
||||
pcap/pcap.h \
|
||||
pcap/sll.h \
|
||||
pcap/vlan.h \
|
||||
pcap/usb.h
|
||||
|
||||
HDR = $(PUBHDR) \
|
||||
arcnet.h \
|
||||
atmuni31.h \
|
||||
ethertype.h \
|
||||
extract.h \
|
||||
gencode.h \
|
||||
ieee80211.h \
|
||||
llc.h \
|
||||
nametoaddr.h \
|
||||
nlpid.h \
|
||||
pcap-common.h \
|
||||
pcap-int.h \
|
||||
pcap-stdinc.h \
|
||||
portability.h \
|
||||
ppp.h \
|
||||
sf-pcap.h \
|
||||
sf-pcap-ng.h \
|
||||
sunatmpos.h
|
||||
|
||||
TESTS = \
|
||||
@VALGRINDTEST@ \
|
||||
capturetest \
|
||||
can_set_rfmon_test \
|
||||
filtertest \
|
||||
findalldevstest \
|
||||
opentest \
|
||||
reactivatetest \
|
||||
selpolltest
|
||||
|
||||
TESTS_SRC = \
|
||||
tests/valgrindtest.c \
|
||||
tests/capturetest.c \
|
||||
tests/can_set_rfmon_test.c \
|
||||
tests/filtertest.c \
|
||||
tests/findalldevstest.c \
|
||||
tests/opentest.c \
|
||||
tests/reactivatetest.c \
|
||||
tests/selpolltest.c
|
||||
|
||||
GENHDR = \
|
||||
scanner.h grammar.h pcap_version.h
|
||||
|
||||
TAGFILES = \
|
||||
$(SRC) $(HDR)
|
||||
|
||||
CLEANFILES = $(OBJ) libpcap.* $(TESTS) \
|
||||
$(PROG)-`cat $(srcdir)/VERSION`.tar.gz $(GENSRC) $(GENHDR) \
|
||||
lex.yy.c pcap-config
|
||||
|
||||
MAN1 = pcap-config.1
|
||||
|
||||
MAN3PCAP_EXPAND = \
|
||||
pcap.3pcap.in \
|
||||
pcap_compile.3pcap.in \
|
||||
pcap_datalink.3pcap.in \
|
||||
pcap_dump_open.3pcap.in \
|
||||
pcap_get_tstamp_precision.3pcap.in \
|
||||
pcap_list_datalinks.3pcap.in \
|
||||
pcap_list_tstamp_types.3pcap.in \
|
||||
pcap_open_dead.3pcap.in \
|
||||
pcap_open_offline.3pcap.in \
|
||||
pcap_set_tstamp_precision.3pcap.in \
|
||||
pcap_set_tstamp_type.3pcap.in
|
||||
|
||||
MAN3PCAP_NOEXPAND = \
|
||||
pcap_activate.3pcap \
|
||||
pcap_breakloop.3pcap \
|
||||
pcap_can_set_rfmon.3pcap \
|
||||
pcap_close.3pcap \
|
||||
pcap_create.3pcap \
|
||||
pcap_datalink_name_to_val.3pcap \
|
||||
pcap_datalink_val_to_name.3pcap \
|
||||
pcap_dump.3pcap \
|
||||
pcap_dump_close.3pcap \
|
||||
pcap_dump_file.3pcap \
|
||||
pcap_dump_flush.3pcap \
|
||||
pcap_dump_ftell.3pcap \
|
||||
pcap_file.3pcap \
|
||||
pcap_fileno.3pcap \
|
||||
pcap_findalldevs.3pcap \
|
||||
pcap_freecode.3pcap \
|
||||
pcap_get_selectable_fd.3pcap \
|
||||
pcap_geterr.3pcap \
|
||||
pcap_inject.3pcap \
|
||||
pcap_is_swapped.3pcap \
|
||||
pcap_lib_version.3pcap \
|
||||
pcap_lookupdev.3pcap \
|
||||
pcap_lookupnet.3pcap \
|
||||
pcap_loop.3pcap \
|
||||
pcap_major_version.3pcap \
|
||||
pcap_next_ex.3pcap \
|
||||
pcap_offline_filter.3pcap \
|
||||
pcap_open_live.3pcap \
|
||||
pcap_set_buffer_size.3pcap \
|
||||
pcap_set_datalink.3pcap \
|
||||
pcap_set_immediate_mode.3pcap \
|
||||
pcap_set_promisc.3pcap \
|
||||
pcap_set_rfmon.3pcap \
|
||||
pcap_set_snaplen.3pcap \
|
||||
pcap_set_timeout.3pcap \
|
||||
pcap_setdirection.3pcap \
|
||||
pcap_setfilter.3pcap \
|
||||
pcap_setnonblock.3pcap \
|
||||
pcap_snapshot.3pcap \
|
||||
pcap_stats.3pcap \
|
||||
pcap_statustostr.3pcap \
|
||||
pcap_strerror.3pcap \
|
||||
pcap_tstamp_type_name_to_val.3pcap \
|
||||
pcap_tstamp_type_val_to_name.3pcap
|
||||
|
||||
MAN3PCAP = $(MAN3PCAP_NOEXPAND) $(MAN3PCAP_EXPAND:.in=)
|
||||
|
||||
MANFILE = \
|
||||
pcap-savefile.manfile.in
|
||||
|
||||
MANMISC = \
|
||||
pcap-filter.manmisc.in \
|
||||
pcap-linktype.manmisc.in \
|
||||
pcap-tstamp.manmisc.in
|
||||
|
||||
EXTRA_DIST = \
|
||||
$(TESTS_SRC) \
|
||||
CHANGES \
|
||||
ChmodBPF/ChmodBPF \
|
||||
ChmodBPF/StartupParameters.plist \
|
||||
CREDITS \
|
||||
CMakeLists.txt \
|
||||
GenVersion.bat \
|
||||
INSTALL.txt \
|
||||
LICENSE \
|
||||
Makefile.in \
|
||||
Makefile-devel-adds \
|
||||
README \
|
||||
README.aix \
|
||||
README.dag \
|
||||
README.hpux \
|
||||
README.linux \
|
||||
README.macosx \
|
||||
README.septel \
|
||||
README.sita \
|
||||
README.tru64 \
|
||||
README.Win32 \
|
||||
SUNOS4/nit_if.o.sparc \
|
||||
SUNOS4/nit_if.o.sun3 \
|
||||
SUNOS4/nit_if.o.sun4c.4.0.3c \
|
||||
TODO \
|
||||
VERSION \
|
||||
aclocal.m4 \
|
||||
bpf/net/bpf_filter.c \
|
||||
chmod_bpf \
|
||||
cmakeconfig.h.in \
|
||||
cmake/preconfigure.cmake \
|
||||
config/have_siocglifconf.c \
|
||||
config.guess \
|
||||
config.h.in \
|
||||
config.sub \
|
||||
configure \
|
||||
configure.ac \
|
||||
dlpisubs.c \
|
||||
dlpisubs.h \
|
||||
fad-getad.c \
|
||||
fad-gifc.c \
|
||||
fad-glifc.c \
|
||||
fad-helpers.c \
|
||||
gen_version_c.sh \
|
||||
gen_version_header.sh \
|
||||
grammar.y \
|
||||
install-sh \
|
||||
lbl/os-aix4.h \
|
||||
lbl/os-aix7.h \
|
||||
lbl/os-hpux11.h \
|
||||
lbl/os-osf4.h \
|
||||
lbl/os-osf5.h \
|
||||
lbl/os-solaris2.h \
|
||||
lbl/os-sunos4.h \
|
||||
lbl/os-ultrix4.h \
|
||||
missing/getopt.c \
|
||||
missing/getopt.h \
|
||||
missing/snprintf.c \
|
||||
missing/strtok_r.c \
|
||||
missing/win_snprintf.c \
|
||||
mkdep \
|
||||
msdos/bin2c.c \
|
||||
msdos/common.dj \
|
||||
msdos/makefile \
|
||||
msdos/makefile.dj \
|
||||
msdos/makefile.wc \
|
||||
msdos/ndis2.c \
|
||||
msdos/ndis2.h \
|
||||
msdos/ndis_0.asm \
|
||||
msdos/pkt_rx0.asm \
|
||||
msdos/pkt_rx1.s \
|
||||
msdos/pktdrvr.c \
|
||||
msdos/pktdrvr.h \
|
||||
msdos/readme.dos \
|
||||
org.tcpdump.chmod_bpf.plist \
|
||||
pcap-bpf.c \
|
||||
pcap-bt-linux.c \
|
||||
pcap-bt-linux.h \
|
||||
pcap-bt-monitor-linux.c \
|
||||
pcap-bt-monitor-linux.h \
|
||||
pcap-config.in \
|
||||
pcap-dag.c \
|
||||
pcap-dag.h \
|
||||
pcap-dbus.c \
|
||||
pcap-dbus.h \
|
||||
pcap-dlpi.c \
|
||||
pcap-dos.c \
|
||||
pcap-dos.h \
|
||||
pcap-enet.c \
|
||||
pcap-int.h \
|
||||
pcap-libdlpi.c \
|
||||
pcap-linux.c \
|
||||
pcap-namedb.h \
|
||||
pcap-new.c \
|
||||
pcap-netfilter-linux.c \
|
||||
pcap-netfilter-linux.h \
|
||||
pcap-nit.c \
|
||||
pcap-null.c \
|
||||
pcap-pf.c \
|
||||
pcap-rpcap.c \
|
||||
pcap-rpcap.h \
|
||||
pcap-septel.c \
|
||||
pcap-septel.h \
|
||||
pcap-sita.h \
|
||||
pcap-sita.c \
|
||||
pcap-sita.html \
|
||||
pcap-snf.c \
|
||||
pcap-snf.h \
|
||||
pcap-snit.c \
|
||||
pcap-snoop.c \
|
||||
pcap-tc.c \
|
||||
pcap-tc.h \
|
||||
pcap-usb-linux.c \
|
||||
pcap-usb-linux.h \
|
||||
pcap-win32.c \
|
||||
remote-ext.h \
|
||||
sockutils.c \
|
||||
sockutils.h \
|
||||
scanner.l \
|
||||
tests/CMakeLists.txt \
|
||||
pcap_version.h.in \
|
||||
Win32/Include/Gnuc.h \
|
||||
Win32/Include/net/if.h \
|
||||
Win32/Prj/wpcap.sln \
|
||||
Win32/Prj/wpcap.vcxproj \
|
||||
Win32/Prj/wpcap.vcxproj.filters
|
||||
|
||||
all: libpcap.a shared pcap-config
|
||||
|
||||
libpcap.a: $(OBJ)
|
||||
@rm -f $@
|
||||
$(AR) rc $@ $(OBJ) $(ADDLARCHIVEOBJS)
|
||||
$(RANLIB) $@
|
||||
|
||||
shared: libpcap.$(DYEXT)
|
||||
|
||||
libpcap.so: $(OBJ)
|
||||
@rm -f $@
|
||||
VER=`cat $(srcdir)/VERSION`; \
|
||||
MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
|
||||
@V_SHLIB_CMD@ @V_SHLIB_OPT@ @V_SONAME_OPT@$@.$$MAJOR_VER $(LDFLAGS) \
|
||||
-o $@.$$VER $(OBJ) $(ADDLOBJS) $(LIBS)
|
||||
|
||||
#
|
||||
# The following rule succeeds, but the result is untested.
|
||||
#
|
||||
# In Mac OS X, the libpcap dylib has the name "libpcap.A.dylib", with
|
||||
# its full path as the install_name, and with the compatibility and
|
||||
# current version both set to 1. The compatibility version is set to
|
||||
# 1 so that programs built with a newer version of the library will run
|
||||
# against older versions; multi-platform software probably will fail if
|
||||
# it uses APIs added in the newer version, but Mac OS X-specific software
|
||||
# will use weak linking and check at run time whether those APIs are
|
||||
# available.
|
||||
#
|
||||
# We also use "A" as the major version, and 1 as the compatibility version,
|
||||
# but set the current version to the value in VERSION, with any non-numeric
|
||||
# stuff stripped off (the compatibility and current version must be of the
|
||||
# form X[.Y[.Z]], with Y and Z possibly absent, and with all components
|
||||
# numeric).
|
||||
#
|
||||
libpcap.dylib: $(OBJ)
|
||||
rm -f libpcap*.dylib
|
||||
VER=`cat $(srcdir)/VERSION`; \
|
||||
MAJOR_VER=A; \
|
||||
COMPAT_VER=1; \
|
||||
CURRENT_VER=`sed 's/[^0-9.].*$$//' $(srcdir)/VERSION`; \
|
||||
$(CC) -dynamiclib -undefined error $(LDFLAGS) \
|
||||
-o libpcap.$$VER.dylib $(OBJ) $(ADDLOBJS) $(LIBS) \
|
||||
-install_name $(libdir)/libpcap.$$MAJOR_VER.dylib \
|
||||
-compatibility_version $$COMPAT_VER \
|
||||
-current_version $$CURRENT_VER
|
||||
|
||||
#
|
||||
# The HP-UX linker manual says that the convention for a versioned library
|
||||
# is libXXX.{number}, not libXXX.sl.{number}. That appears to be the case
|
||||
# on at least one HP-UX 11.00 system; libXXX.sl is a symlink to
|
||||
# libXXX.{number}.
|
||||
#
|
||||
# The manual also says "library-level versioning" (think "sonames") was
|
||||
# added in HP-UX 10.0.
|
||||
#
|
||||
# XXX - this assumes we're using the HP linker, rather than the GNU
|
||||
# linker, even with GCC.
|
||||
#
|
||||
libpcap.sl: $(OBJ)
|
||||
@MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
|
||||
rm -f libpcap.$$MAJOR_VER
|
||||
MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
|
||||
ld -b $(LDFLAGS) -o libpcap.$$MAJOR_VER +h libpcap.$$MAJOR_VER \
|
||||
$(OBJ) $(ADDLOBJS) $(LIBS)
|
||||
|
||||
#
|
||||
# AIX is different from everybody else. A shared library is an archive
|
||||
# library with one or more shared-object components. We still build a
|
||||
# normal static archive library on AIX, for the benefit of the traditional
|
||||
# scheme of building libpcap and tcpdump in subdirectories of the
|
||||
# same directory, with tcpdump statically linked with the libpcap
|
||||
# in question, but we also build a shared library as "libpcap.shareda"
|
||||
# and install *it*, rather than the static library, as "libpcap.a".
|
||||
#
|
||||
libpcap.shareda: $(OBJ)
|
||||
@rm -f $@ shr.o
|
||||
$(CC) @V_SHLIB_OPT@ -o shr.o $(OBJ) $(ADDLOBJS) $(LDFLAGS) $(LIBS)
|
||||
$(AR) rc $@ shr.o
|
||||
|
||||
#
|
||||
# For platforms that don't support shared libraries (or on which we
|
||||
# don't support shared libraries).
|
||||
#
|
||||
libpcap.none:
|
||||
|
||||
scanner.c: $(srcdir)/scanner.l
|
||||
$(LEX) -P pcap_ --header-file=scanner.h --nounput -o scanner.c $<
|
||||
scanner.h: scanner.c
|
||||
## Recover from the removal of $@
|
||||
@if test -f $@; then :; else \
|
||||
rm -f scanner.c; \
|
||||
$(MAKE) $(MAKEFLAGS) scanner.c; \
|
||||
fi
|
||||
|
||||
scanner.o: scanner.c grammar.h
|
||||
$(CC) $(FULL_CFLAGS) -c scanner.c
|
||||
|
||||
pcap.o: pcap_version.h
|
||||
|
||||
grammar.c: $(srcdir)/grammar.y
|
||||
$(YACC) -p pcap_ -o grammar.c -d $<
|
||||
grammar.h: grammar.c
|
||||
## Recover from the removal of $@
|
||||
@if test -f $@; then :; else \
|
||||
rm -f grammar.c; \
|
||||
$(MAKE) $(MAKEFLAGS) grammar.c; \
|
||||
fi
|
||||
|
||||
grammar.o: grammar.c
|
||||
$(CC) $(FULL_CFLAGS) -c grammar.c
|
||||
|
||||
gencode.o: $(srcdir)/gencode.c grammar.h scanner.h
|
||||
$(CC) $(FULL_CFLAGS) -c $(srcdir)/gencode.c
|
||||
|
||||
version.o: version.c
|
||||
$(CC) $(FULL_CFLAGS) -c version.c
|
||||
|
||||
snprintf.o: $(srcdir)/missing/snprintf.c
|
||||
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c
|
||||
|
||||
strtok_r.o: $(srcdir)/missing/strtok_r.c
|
||||
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strtok_r.c
|
||||
|
||||
version.c: $(srcdir)/VERSION $(srcdir)/gen_version_c.sh
|
||||
#
|
||||
# Older programs import this if they want to show the
|
||||
# libpcap version number, rather than calling
|
||||
# pcap_lib_version(), so we need to export it.
|
||||
#
|
||||
@rm -f $@
|
||||
$(srcdir)/gen_version_c.sh $(srcdir)/VERSION $@
|
||||
|
||||
pcap_version.h: $(srcdir)/VERSION $(srcdir)/pcap_version.h.in $(srcdir)/gen_version_header.sh
|
||||
@rm -f $@
|
||||
$(srcdir)/gen_version_header.sh $(srcdir)/VERSION $(srcdir)/pcap_version.h.in $@
|
||||
|
||||
bpf_filter.c: $(srcdir)/bpf/net/bpf_filter.c
|
||||
rm -f bpf_filter.c
|
||||
ln -s $(srcdir)/bpf/net/bpf_filter.c bpf_filter.c
|
||||
|
||||
bpf_filter.o: bpf_filter.c
|
||||
$(CC) $(FULL_CFLAGS) -c bpf_filter.c
|
||||
|
||||
#
|
||||
# Generate the pcap-config script.
|
||||
#
|
||||
# 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
|
||||
./config.status --file=$@.tmp:$(srcdir)/pcap-config.in
|
||||
mv $@.tmp $@
|
||||
chmod a+x $@
|
||||
|
||||
#
|
||||
# Test programs - not built by default, and not installed.
|
||||
#
|
||||
tests: $(TESTS)
|
||||
|
||||
capturetest: tests/capturetest.c libpcap.a
|
||||
$(CC) $(FULL_CFLAGS) -I. -L. -o capturetest $(srcdir)/tests/capturetest.c libpcap.a $(LIBS)
|
||||
|
||||
can_set_rfmon_test: tests/can_set_rfmon_test.c libpcap.a
|
||||
$(CC) $(FULL_CFLAGS) -I. -L. -o can_set_rfmon_test $(srcdir)/tests/can_set_rfmon_test.c libpcap.a $(LIBS)
|
||||
|
||||
filtertest: tests/filtertest.c libpcap.a
|
||||
$(CC) $(FULL_CFLAGS) -I. -L. -o filtertest $(srcdir)/tests/filtertest.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: tests/opentest.c libpcap.a
|
||||
$(CC) $(FULL_CFLAGS) -I. -L. -o opentest $(srcdir)/tests/opentest.c libpcap.a $(LIBS)
|
||||
|
||||
reactivatetest: tests/reactivatetest.c libpcap.a
|
||||
$(CC) $(FULL_CFLAGS) -I. -L. -o reactivatetest $(srcdir)/tests/reactivatetest.c libpcap.a $(LIBS)
|
||||
|
||||
selpolltest: tests/selpolltest.c libpcap.a
|
||||
$(CC) $(FULL_CFLAGS) -I. -L. -o selpolltest $(srcdir)/tests/selpolltest.c libpcap.a $(LIBS)
|
||||
|
||||
valgrindtest: tests/valgrindtest.c libpcap.a
|
||||
$(CC) $(FULL_CFLAGS) -I. -L. -o valgrindtest $(srcdir)/tests/valgrindtest.c libpcap.a $(LIBS)
|
||||
|
||||
install: install-shared install-archive pcap-config
|
||||
[ -d $(DESTDIR)$(libdir) ] || \
|
||||
(mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
|
||||
[ -d $(DESTDIR)$(includedir) ] || \
|
||||
(mkdir -p $(DESTDIR)$(includedir); chmod 755 $(DESTDIR)$(includedir))
|
||||
[ -d $(DESTDIR)$(includedir)/pcap ] || \
|
||||
(mkdir -p $(DESTDIR)$(includedir)/pcap; chmod 755 $(DESTDIR)$(includedir)/pcap)
|
||||
[ -d $(DESTDIR)$(mandir)/man1 ] || \
|
||||
(mkdir -p $(DESTDIR)$(mandir)/man1; chmod 755 $(DESTDIR)$(mandir)/man1)
|
||||
[ -d $(DESTDIR)$(mandir)/man3 ] || \
|
||||
(mkdir -p $(DESTDIR)$(mandir)/man3; chmod 755 $(DESTDIR)$(mandir)/man3)
|
||||
[ -d $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@ ] || \
|
||||
(mkdir -p $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@; chmod 755 $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@)
|
||||
[ -d $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@ ] || \
|
||||
(mkdir -p $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@; chmod 755 $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@)
|
||||
for i in $(PUBHDR); do \
|
||||
$(INSTALL_DATA) $(srcdir)/$$i \
|
||||
$(DESTDIR)$(includedir)/$$i; done
|
||||
[ -d $(DESTDIR)$(bindir) ] || \
|
||||
(mkdir -p $(DESTDIR)$(bindir); chmod 755 $(DESTDIR)$(bindir))
|
||||
$(INSTALL_PROGRAM) pcap-config $(DESTDIR)$(bindir)/pcap-config
|
||||
for i in $(MAN1); do \
|
||||
$(INSTALL_DATA) $(srcdir)/$$i \
|
||||
$(DESTDIR)$(mandir)/man1/$$i; done
|
||||
for i in $(MAN3PCAP_NOEXPAND); do \
|
||||
$(INSTALL_DATA) $(srcdir)/$$i \
|
||||
$(DESTDIR)$(mandir)/man3/$$i; done
|
||||
for i in $(MAN3PCAP_EXPAND:.in=); do \
|
||||
$(INSTALL_DATA) $$i \
|
||||
$(DESTDIR)$(mandir)/man3/$$i; done
|
||||
(cd $(DESTDIR)$(mandir)/man3 && \
|
||||
rm -f pcap_datalink_val_to_description.3pcap && \
|
||||
$(LN_S) pcap_datalink_val_to_name.3pcap \
|
||||
pcap_datalink_val_to_description.3pcap && \
|
||||
rm -f pcap_dump_fopen.3pcap && \
|
||||
$(LN_S) pcap_dump_open.3pcap pcap_dump_fopen.3pcap && \
|
||||
rm -f pcap_freealldevs.3pcap && \
|
||||
$(LN_S) pcap_findalldevs.3pcap pcap_freealldevs.3pcap && \
|
||||
rm -f pcap_perror.3pcap && \
|
||||
$(LN_S) pcap_geterr.3pcap pcap_perror.3pcap && \
|
||||
rm -f pcap_sendpacket.3pcap && \
|
||||
$(LN_S) pcap_inject.3pcap pcap_sendpacket.3pcap && \
|
||||
rm -f pcap_free_datalinks.3pcap && \
|
||||
$(LN_S) pcap_list_datalinks.3pcap pcap_free_datalinks.3pcap && \
|
||||
rm -f pcap_free_tstamp_types.3pcap && \
|
||||
$(LN_S) pcap_list_tstamp_types.3pcap pcap_free_tstamp_types.3pcap && \
|
||||
rm -f pcap_dispatch.3pcap && \
|
||||
$(LN_S) pcap_loop.3pcap pcap_dispatch.3pcap && \
|
||||
rm -f pcap_minor_version.3pcap && \
|
||||
$(LN_S) pcap_major_version.3pcap pcap_minor_version.3pcap && \
|
||||
rm -f pcap_next.3pcap && \
|
||||
$(LN_S) pcap_next_ex.3pcap pcap_next.3pcap && \
|
||||
rm -f pcap_open_dead_with_tstamp_precision.3pcap && \
|
||||
$(LN_S) pcap_open_dead.3pcap \
|
||||
pcap_open_dead_with_tstamp_precision.3pcap && \
|
||||
rm -f pcap_open_offline_with_tstamp_precision.3pcap && \
|
||||
$(LN_S) pcap_open_offline.3pcap pcap_open_offline_with_tstamp_precision.3pcap && \
|
||||
rm -f pcap_fopen_offline.3pcap && \
|
||||
$(LN_S) pcap_open_offline.3pcap pcap_fopen_offline.3pcap && \
|
||||
rm -f pcap_fopen_offline_with_tstamp_precision.3pcap && \
|
||||
$(LN_S) pcap_open_offline.3pcap pcap_fopen_offline_with_tstamp_precision.3pcap && \
|
||||
rm -f pcap_tstamp_type_val_to_description.3pcap && \
|
||||
$(LN_S) pcap_tstamp_type_val_to_name.3pcap pcap_tstamp_type_val_to_description.3pcap && \
|
||||
rm -f pcap_getnonblock.3pcap && \
|
||||
$(LN_S) pcap_setnonblock.3pcap pcap_getnonblock.3pcap)
|
||||
for i in $(MANFILE); do \
|
||||
$(INSTALL_DATA) `echo $$i | sed 's/.manfile.in/.manfile/'` \
|
||||
$(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@/`echo $$i | sed 's/.manfile.in/.@MAN_FILE_FORMATS@/'`; done
|
||||
for i in $(MANMISC); do \
|
||||
$(INSTALL_DATA) `echo $$i | sed 's/.manmisc.in/.manmisc/'` \
|
||||
$(DESTDIR)$(mandir)/man@MAN_MISC_INFO@/`echo $$i | sed 's/.manmisc.in/.@MAN_MISC_INFO@/'`; done
|
||||
|
||||
install-shared: install-shared-$(DYEXT)
|
||||
install-shared-so: libpcap.so
|
||||
[ -d $(DESTDIR)$(libdir) ] || \
|
||||
(mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
|
||||
VER=`cat $(srcdir)/VERSION`; \
|
||||
MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
|
||||
$(INSTALL_PROGRAM) libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$VER; \
|
||||
ln -sf libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$MAJOR_VER; \
|
||||
ln -sf libpcap.so.$$MAJOR_VER $(DESTDIR)$(libdir)/libpcap.so
|
||||
install-shared-dylib: libpcap.dylib
|
||||
[ -d $(DESTDIR)$(libdir) ] || \
|
||||
(mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
|
||||
VER=`cat $(srcdir)/VERSION`; \
|
||||
MAJOR_VER=A; \
|
||||
$(INSTALL_PROGRAM) libpcap.$$VER.dylib $(DESTDIR)$(libdir)/libpcap.$$VER.dylib; \
|
||||
ln -sf libpcap.$$VER.dylib $(DESTDIR)$(libdir)/libpcap.$$MAJOR_VER.dylib; \
|
||||
ln -sf libpcap.$$MAJOR_VER.dylib $(DESTDIR)$(libdir)/libpcap.dylib
|
||||
install-shared-sl: libpcap.sl
|
||||
[ -d $(DESTDIR)$(libdir) ] || \
|
||||
(mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
|
||||
MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
|
||||
$(INSTALL_PROGRAM) libpcap.$$MAJOR_VER $(DESTDIR)$(libdir)
|
||||
ln -sf libpcap.$$MAJOR_VER $(DESTDIR)$(libdir)/libpcap.sl
|
||||
install-shared-shareda: libpcap.shareda
|
||||
#
|
||||
# AIX shared libraries are weird. They're archive libraries
|
||||
# with one or more shared object components.
|
||||
#
|
||||
[ -d $(DESTDIR)$(libdir) ] || \
|
||||
(mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
|
||||
$(INSTALL_PROGRAM) libpcap.shareda $(DESTDIR)$(libdir)/libpcap.a
|
||||
install-shared-none:
|
||||
|
||||
install-archive: install-archive-$(DYEXT)
|
||||
install-archive-so install-archive-dylib install-archive-sl install-archive-none: libpcap.a
|
||||
#
|
||||
# Most platforms have separate suffixes for shared and
|
||||
# archive libraries, so we install both.
|
||||
#
|
||||
[ -d $(DESTDIR)$(libdir) ] || \
|
||||
(mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
|
||||
$(INSTALL_DATA) libpcap.a $(DESTDIR)$(libdir)/libpcap.a
|
||||
$(RANLIB) $(DESTDIR)$(libdir)/libpcap.a
|
||||
install-archive-shareda:
|
||||
#
|
||||
# AIX, however, doesn't, so we don't install the archive
|
||||
# library on AIX.
|
||||
#
|
||||
|
||||
uninstall: uninstall-shared
|
||||
rm -f $(DESTDIR)$(libdir)/libpcap.a
|
||||
for i in $(PUBHDR); do \
|
||||
rm -f $(DESTDIR)$(includedir)/$$i; done
|
||||
-rmdir $(DESTDIR)$(includedir)/pcap
|
||||
rm -f $(DESTDIR)/$(bindir)/pcap-config
|
||||
for i in $(MAN1); do \
|
||||
rm -f $(DESTDIR)$(mandir)/man1/$$i; done
|
||||
for i in $(MAN3PCAP); do \
|
||||
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
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_open_dead_with_tstamp_precision.3pcap
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_open_offline_with_tstamp_precision.3pcap
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_fopen_offline.3pcap
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_fopen_offline_with_tstamp_precision.3pcap
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_getnonblock.3pcap
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_tstamp_type_val_to_description.3pcap
|
||||
for i in $(MANFILE); do \
|
||||
rm -f $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@/`echo $$i | sed 's/.manfile.in/.@MAN_FILE_FORMATS@/'`; done
|
||||
for i in $(MANMISC); do \
|
||||
rm -f $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@/`echo $$i | sed 's/.manmisc.in/.@MAN_MISC_INFO@/'`; done
|
||||
|
||||
uninstall-shared: uninstall-shared-$(DYEXT)
|
||||
uninstall-shared-so:
|
||||
VER=`cat $(srcdir)/VERSION`; \
|
||||
MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
|
||||
rm -f $(DESTDIR)$(libdir)/libpcap.so.$$VER; \
|
||||
rm -f $(DESTDIR)$(libdir)/libpcap.so.$$MAJOR_VER; \
|
||||
rm -f $(DESTDIR)$(libdir)/libpcap.so
|
||||
uninstall-shared-dylib:
|
||||
VER=`cat $(srcdir)/VERSION`; \
|
||||
MAJOR_VER=A; \
|
||||
rm -f $(DESTDIR)$(libdir)/libpcap.$$VER.dylib; \
|
||||
rm -f $(DESTDIR)$(libdir)/libpcap.$$MAJOR_VER.dylib; \
|
||||
rm -f $(DESTDIR)$(libdir)/libpcap.dylib
|
||||
uninstall-shared-sl:
|
||||
MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
|
||||
rm -f $(DESTDIR)$(libdir)/libpcap.$$MAJOR_VER; \
|
||||
rm -f $(DESTDIR)$(libdir)/libpcap.sl
|
||||
uninstall-shared-shareda:
|
||||
rm -f $(DESTDIR)$(libdir)/libpcap.a
|
||||
uninstall-shared-none:
|
||||
|
||||
clean:
|
||||
rm -f $(CLEANFILES)
|
||||
|
||||
distclean: clean
|
||||
rm -f Makefile config.cache config.log config.status \
|
||||
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
|
||||
|
||||
extags: $(TAGFILES)
|
||||
ctags $(TAGFILES)
|
||||
|
||||
tags: $(TAGFILES)
|
||||
ctags -wtd $(TAGFILES)
|
||||
|
||||
releasetar:
|
||||
@cwd=`pwd` ; dir=`basename $$cwd` ; name=$(PROG)-`cat VERSION` ; \
|
||||
mkdir $$name; \
|
||||
tar cf - $(CSRC) $(HDR) $(MAN1) $(MAN3PCAP_EXPAND) \
|
||||
$(MAN3PCAP_NOEXPAND) $(MANFILE) $(MANMISC) $(EXTRA_DIST) | \
|
||||
(cd $$name; tar xf -); \
|
||||
tar -c -z -f $$name.tar.gz $$name; \
|
||||
rm -rf $$name
|
||||
|
||||
depend: $(GENSRC) $(GENHDR) bpf_filter.c
|
||||
$(MKDEP) -c $(CC) -m $(CFLAGS) $(DEPENDENCY_CFLAG) $(DEFS) $(INCLS) $(SRC)
|
@ -1,106 +0,0 @@
|
||||
LIBPCAP 1.x.y
|
||||
|
||||
www.tcpdump.org
|
||||
|
||||
Please send inquiries/comments/reports to:
|
||||
tcpdump-workers@lists.tcpdump.org
|
||||
|
||||
Anonymous Git is available via:
|
||||
git clone git://bpf.tcpdump.org/libpcap
|
||||
|
||||
Please submit patches by forking the branch on GitHub at
|
||||
|
||||
http://github.com/the-tcpdump-group/libpcap/tree/master
|
||||
|
||||
and issuing a pull request.
|
||||
|
||||
formerly from Lawrence Berkeley National Laboratory
|
||||
Network Research Group <libpcap@ee.lbl.gov>
|
||||
ftp://ftp.ee.lbl.gov/old/libpcap-0.4a7.tar.Z
|
||||
|
||||
This directory contains source code for libpcap, a system-independent
|
||||
interface for user-level packet capture. libpcap provides a portable
|
||||
framework for low-level network monitoring. Applications include
|
||||
network statistics collection, security monitoring, network debugging,
|
||||
etc. Since almost every system vendor provides a different interface
|
||||
for packet capture, and since we've developed several tools that
|
||||
require this functionality, we've created this system-independent API
|
||||
to ease in porting and to alleviate the need for several
|
||||
system-dependent packet capture modules in each application.
|
||||
|
||||
For some platforms there are README.{system} files that discuss issues
|
||||
with the OS's interface for packet capture on those platforms, such as
|
||||
how to enable support for that interface in the OS, if it's not built in
|
||||
by default.
|
||||
|
||||
The libpcap interface supports a filtering mechanism based on the
|
||||
architecture in the BSD packet filter. BPF is described in the 1993
|
||||
Winter Usenix paper ``The BSD Packet Filter: A New Architecture for
|
||||
User-level Packet Capture''. A compressed PostScript version can be
|
||||
found at
|
||||
|
||||
ftp://ftp.ee.lbl.gov/papers/bpf-usenix93.ps.Z
|
||||
|
||||
or
|
||||
|
||||
http://www.tcpdump.org/papers/bpf-usenix93.ps.Z
|
||||
|
||||
and a gzipped version can be found at
|
||||
|
||||
http://www.tcpdump.org/papers/bpf-usenix93.ps.gz
|
||||
|
||||
A PDF version can be found at
|
||||
|
||||
http://www.tcpdump.org/papers/bpf-usenix93.pdf
|
||||
|
||||
Although most packet capture interfaces support in-kernel filtering,
|
||||
libpcap utilizes in-kernel filtering only for the BPF interface.
|
||||
On systems that don't have BPF, all packets are read into user-space
|
||||
and the BPF filters are evaluated in the libpcap library, incurring
|
||||
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, 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:
|
||||
|
||||
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
|
||||
information on configuring that option.
|
||||
|
||||
Note to Linux distributions and *BSD systems that include libpcap:
|
||||
|
||||
There's now a rule to make a shared library, which should work on Linux
|
||||
and *BSD, among other platforms.
|
||||
|
||||
It sets the soname of the library to "libpcap.so.1"; this is what it
|
||||
should be, *NOT* libpcap.so.1.x or libpcap.so.1.x.y or something such as
|
||||
that.
|
||||
|
||||
We've been maintaining binary compatibility between libpcap releases for
|
||||
quite a while; there's no reason to tie a binary linked with libpcap to
|
||||
a particular release of libpcap.
|
||||
|
||||
Problems, bugs, questions, desirable enhancements, etc. should be sent
|
||||
to the address "tcpdump-workers@lists.tcpdump.org". Bugs, support
|
||||
requests, and feature requests may also be submitted on the GitHub issue
|
||||
tracker for libpcap at
|
||||
|
||||
https://github.com/the-tcpdump-group/libpcap/issues
|
||||
|
||||
Source code contributions, etc. should be sent to the email address
|
||||
above or submitted by forking the branch on GitHub at
|
||||
|
||||
http://github.com/the-tcpdump-group/libpcap/tree/master
|
||||
|
||||
and issuing a pull request.
|
||||
|
||||
Current versions can be found at www.tcpdump.org.
|
||||
|
||||
- The TCPdump team
|
@ -1,46 +0,0 @@
|
||||
Under Win32, libpcap is integrated in the WinPcap packet capture system.
|
||||
WinPcap provides a framework that allows libpcap to capture the packets
|
||||
under Windows 95, Windows 98, Windows ME, Windows NT 4, Windows 2000
|
||||
and Windows XP.
|
||||
WinPcap binaries and source code can be found at http://winpcap.polito.it:
|
||||
they include also a developer's pack with all the necessary to compile
|
||||
libpcap-based applications under Windows.
|
||||
|
||||
How to compile libpcap with Visual Studio
|
||||
-----------------------------------------
|
||||
|
||||
In order to compile libpcap you will need:
|
||||
|
||||
- version 6 (or higher) of Microsoft Visual Studio
|
||||
- The November 2001 (or later) edition of Microsoft Platform
|
||||
Software Development Kit (SDK), that contains some necessary includes
|
||||
for IPv6 support. You can download it from http://www.microsoft.com/sdk
|
||||
- the latest WinPcap sources from http://winpcap.polito.it/install
|
||||
|
||||
The WinPcap source code already contains a recent (usually the latest
|
||||
stable) version of libpcap. If you need to compile a different one,
|
||||
simply download it from www.tcpdump.org and copy the sources in the
|
||||
winpcap\wpcap\libpcap folder of the WinPcap distribution. If you want to
|
||||
compile a libpcap source retrieved from the tcpdump.org Git, you will
|
||||
have to create the scanner and the grammar by hand (with lex and yacc)
|
||||
or with the cygnus makefile, since The Visual Studio project is not able
|
||||
to build them.
|
||||
|
||||
Open the project file winpcap\wpcap\prj\wpcap.dsw with Visual Studio and
|
||||
build wpcap.dll. wpcap.lib, the library file to link with the applications,
|
||||
will be generated in winpcap\wpcap\lib\. wpcap.dll will be generated in
|
||||
winpcap\wpcap\prj\release or winpcap\wpcap\prj\debug depending on the type
|
||||
of binary that is being created.
|
||||
|
||||
How to compile libpcap with Cygnus
|
||||
----------------------------------
|
||||
|
||||
To build wpcap.dll, cd to the directory WPCAP/PRJ of the WinPcap source code
|
||||
distribution and type "make". libwpcap.a, the library file to link with the
|
||||
applications, will be generated in winpcap\wpcap\lib\. wpcap.dll will be
|
||||
generated in winpcap\wpcap\prj.
|
||||
|
||||
Remember, you CANNOT use the MSVC-generated .lib files with gcc, use
|
||||
libwpcap.a instead.
|
||||
|
||||
"make install" installs wpcap.dll in the Windows system folder.
|
@ -1,88 +0,0 @@
|
||||
Using BPF:
|
||||
|
||||
(1) AIX 4.x's version of BPF is undocumented and somewhat unstandard; the
|
||||
current BPF support code includes changes that should work around
|
||||
that; it appears to compile and work on at least one AIX 4.3.3
|
||||
machine.
|
||||
|
||||
Note that the BPF driver and the "/dev/bpf" devices might not exist
|
||||
on your machine; AIX's tcpdump loads the driver and creates the
|
||||
devices if they don't already exist. Our libpcap should do the
|
||||
same, and the configure script should detect that it's on an AIX
|
||||
system and choose BPF even if the devices aren't there.
|
||||
|
||||
Also note that tcpdump _binary_ compiled on AIX 4 may have a problem
|
||||
doing the initial loading of the BPF driver if copied to AIX 5 and
|
||||
run there (GH #52). tcpdump binary natively compiled on AIX 5 should
|
||||
not have this issue.
|
||||
|
||||
(2) If libpcap doesn't compile on your machine when configured to use
|
||||
BPF, or if the workarounds fail to make it work correctly, you
|
||||
should send to tcpdump-workers@lists.tcpdump.org a detailed bug
|
||||
report (if the compile fails, send us the compile error messages;
|
||||
if it compiles but fails to work correctly, send us as detailed as
|
||||
possible a description of the symptoms, including indications of the
|
||||
network link-layer type being wrong or time stamps being wrong).
|
||||
|
||||
If you fix the problems yourself, please submit a patch by forking
|
||||
the branch at
|
||||
|
||||
https://github.com/the-tcpdump-group/libpcap/issues
|
||||
|
||||
and issuing a pull request, so we can incorporate the fixes into the
|
||||
next release.
|
||||
|
||||
If you don't fix the problems yourself, you can, as a workaround,
|
||||
make libpcap use DLPI instead of BPF.
|
||||
|
||||
This can be done by specifying the flag:
|
||||
|
||||
--with-pcap=dlpi
|
||||
|
||||
to the "configure" script for libpcap.
|
||||
|
||||
If you use DLPI:
|
||||
|
||||
(1) It is a good idea to have the latest version of the DLPI driver on
|
||||
your system, since certain versions may be buggy and cause your AIX
|
||||
system to crash. DLPI is included in the fileset bos.rte.tty. I
|
||||
found that the DLPI driver that came with AIX 4.3.2 was buggy, and
|
||||
had to upgrade to bos.rte.tty 4.3.2.4:
|
||||
|
||||
lslpp -l bos.rte.tty
|
||||
|
||||
bos.rte.tty 4.3.2.4 COMMITTED Base TTY Support and Commands
|
||||
|
||||
Updates for AIX filesets can be obtained from:
|
||||
ftp://service.software.ibm.com/aix/fixes/
|
||||
|
||||
These updates can be installed with the smit program.
|
||||
|
||||
(2) After compiling libpcap, you need to make sure that the DLPI driver
|
||||
is loaded. Type:
|
||||
|
||||
strload -q -d dlpi
|
||||
|
||||
If the result is:
|
||||
|
||||
dlpi: yes
|
||||
|
||||
then the DLPI driver is loaded correctly.
|
||||
|
||||
If it is:
|
||||
|
||||
dlpi: no
|
||||
|
||||
Then you need to type:
|
||||
|
||||
strload -f /etc/dlpi.conf
|
||||
|
||||
Check again with strload -q -d dlpi that the dlpi driver is loaded.
|
||||
|
||||
Alternatively, you can uncomment the lines for DLPI in
|
||||
/etc/pse.conf and reboot the machine; this way DLPI will always
|
||||
be loaded when you boot your system.
|
||||
|
||||
(3) There appears to be a problem in the DLPI code in some versions of
|
||||
AIX, causing a warning about DL_PROMISC_MULTI failing; this might
|
||||
be responsible for DLPI not being able to capture outgoing packets.
|
@ -1,122 +0,0 @@
|
||||
|
||||
The following instructions apply if you have a Linux or FreeBSD platform and
|
||||
want libpcap to support the DAG range of passive network monitoring cards from
|
||||
Endace (http://www.endace.com, see below for further contact details).
|
||||
|
||||
1) Install and build the DAG software distribution by following the
|
||||
instructions supplied with that package. Current Endace customers can download
|
||||
the DAG software distibution from https://www.endace.com
|
||||
|
||||
2) Configure libcap. To allow the 'configure' script to locate the DAG
|
||||
software distribution use the '--with-dag' option:
|
||||
|
||||
./configure --with-dag=DIR
|
||||
|
||||
Where DIR is the root of the DAG software distribution, for example
|
||||
/var/src/dag. If the DAG software is correctly detected 'configure' will
|
||||
report:
|
||||
|
||||
checking whether we have DAG API... yes
|
||||
|
||||
If 'configure' reports that there is no DAG API, the directory may have been
|
||||
incorrectly specified or the DAG software was not built before configuring
|
||||
libpcap.
|
||||
|
||||
See also the libpcap INSTALL.txt file for further libpcap configuration
|
||||
options.
|
||||
|
||||
Building libpcap at this stage will include support for both the native packet
|
||||
capture stream (linux or bpf) and for capturing from DAG cards. To build
|
||||
libpcap with only DAG support specify the capture type as 'dag' when
|
||||
configuring libpcap:
|
||||
|
||||
./configure --with-dag=DIR --with-pcap=dag
|
||||
|
||||
Applications built with libpcap configured in this way will only detect DAG
|
||||
cards and will not capture from the native OS packet stream.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Libpcap when built for DAG cards against dag-2.5.1 or later releases:
|
||||
|
||||
Timeouts are supported. pcap_dispatch() will return after to_ms milliseconds
|
||||
regardless of how many packets are received. If to_ms is zero pcap_dispatch()
|
||||
will block waiting for data indefinitely.
|
||||
|
||||
pcap_dispatch() will block on and process a minimum of 64kB of data (before
|
||||
filtering) for efficiency. This can introduce high latencies on quiet
|
||||
interfaces unless a timeout value is set. The timeout expiring will override
|
||||
the 64kB minimum causing pcap_dispatch() to process any available data and
|
||||
return.
|
||||
|
||||
pcap_setnonblock is supported. When nonblock is set, pcap_dispatch() will
|
||||
check once for available data, process any data available up to count, then
|
||||
return immediately.
|
||||
|
||||
pcap_findalldevs() is supported, e.g. dag0, dag1...
|
||||
|
||||
Some DAG cards can provide more than one 'stream' of received data.
|
||||
This can be data from different physical ports, or separated by filtering
|
||||
or load balancing mechanisms. Receive streams have even numbers, e.g.
|
||||
dag0:0, dag0:2 etc. Specifying transmit streams for capture is not supported.
|
||||
|
||||
pcap_setfilter() is supported, BPF programs run in userspace.
|
||||
|
||||
pcap_setdirection() is not supported. Only received traffic is captured.
|
||||
DAG cards normally do not have IP or link layer addresses assigned as
|
||||
they are used to passively monitor links.
|
||||
|
||||
pcap_breakloop() is supported.
|
||||
|
||||
pcap_datalink() and pcap_list_datalinks() are supported. The DAG card does
|
||||
not attempt to set the correct datalink type automatically where more than
|
||||
one type is possible.
|
||||
|
||||
pcap_stats() is supported. ps_drop is the number of packets dropped due to
|
||||
RX stream buffer overflow, this count is before filters are applied (it will
|
||||
include packets that would have been dropped by the filter). The RX stream
|
||||
buffer size is user configurable outside libpcap, typically 16-512MB.
|
||||
|
||||
pcap_get_selectable_fd() is not supported, as DAG cards do not support
|
||||
poll/select methods.
|
||||
|
||||
pcap_inject() and pcap_sendpacket() are not supported.
|
||||
|
||||
Some DAG cards now support capturing to multiple virtual interfaces, called
|
||||
streams. Capture streams have even numbers. These are available via libpcap
|
||||
as separate interfaces, e.g. dag0:0, dag0:2, dag0:4 etc. dag0:0 is the same
|
||||
as dag0. These are visible via pcap_findalldevs().
|
||||
|
||||
libpcap now does NOT set the card's hardware snaplen (slen). This must now be
|
||||
set using the appropriate DAG coniguration program, e.g. dagthree, dagfour,
|
||||
dagsix, dagconfig. This is because the snaplen is currently shared between
|
||||
all of the streams. In future this may change if per-stream slen is
|
||||
implemented.
|
||||
|
||||
DAG cards by default capture entire packets including the L2
|
||||
CRC/FCS. If the card is not configured to discard the CRC/FCS, this
|
||||
can confuse applications that use libpcap if they're not prepared for
|
||||
packets to have an FCS.
|
||||
|
||||
Libpcap now reads the environment variable ERF_FCS_BITS to determine
|
||||
how many bits of CRC/FCS to strip from the end of the captured
|
||||
frame. This defaults to 32 for use with Ethernet. If the card is
|
||||
configured to strip the CRC/FCS, then set ERF_FCS_BITS=0. If used with
|
||||
a HDLC/PoS/PPP/Frame Relay link with 16 bit CRC/FCS, then set
|
||||
ERF_FCS_BITS=16.
|
||||
|
||||
If you wish to create a pcap file that DOES contain the Ethernet FCS,
|
||||
specify the environment variable ERF_DONT_STRIP_FCS. This will cause
|
||||
the existing FCS to be captured into the pcap file. Note some
|
||||
applications may incorrectly report capture errors or oversize packets
|
||||
when reading these files.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Please submit bug reports via <support@endace.com>.
|
||||
|
||||
Please also visit our Web site at:
|
||||
|
||||
http://www.endace.com/
|
||||
|
||||
For more information about Endace DAG cards contact <sales@endace.com>.
|
@ -1,254 +0,0 @@
|
||||
For HP-UX 11i (11.11) and later, there are no known issues with
|
||||
promiscuous mode under HP-UX. If you are using a earlier version of
|
||||
HP-UX and cannot upgrade, please continue reading.
|
||||
|
||||
HP-UX patches to fix packet capture problems
|
||||
|
||||
Note that packet-capture programs such as tcpdump may, on HP-UX, not be
|
||||
able to see packets sent from the machine on which they're running.
|
||||
Some articles on groups.google.com discussing this are:
|
||||
|
||||
http://groups.google.com/groups?selm=82ld3v%2480i%241%40mamenchi.zrz.TU-Berlin.DE
|
||||
|
||||
which says:
|
||||
|
||||
Newsgroups: comp.sys.hp.hpux
|
||||
Subject: Re: Did someone made tcpdump working on 10.20 ?
|
||||
Date: 12/08/1999
|
||||
From: Lutz Jaenicke <jaenicke@emserv1.ee.TU-Berlin.DE>
|
||||
|
||||
In article <82ks5i$5vc$1@news1.dti.ne.jp>, mtsat <mtsat@iris.dti.ne.jp>
|
||||
wrote:
|
||||
>Hello,
|
||||
>
|
||||
>I downloaded and compiled tcpdump3.4 a couple of week ago. I tried to use
|
||||
>it, but I can only see incoming data, never outgoing.
|
||||
>Someone (raj) explained me that a patch was missing, and that this patch
|
||||
>must me "patched" (poked) in order to see outbound data in promiscuous mode.
|
||||
>Many things to do .... So the question is : did someone has already this
|
||||
>"ready to use" PHNE_**** patch ?
|
||||
|
||||
Two things:
|
||||
1. You do need a late "LAN products cumulative patch" (e.g. PHNE_18173
|
||||
for s700/10.20).
|
||||
2. You must use
|
||||
echo 'lanc_outbound_promisc_flag/W1' | /usr/bin/adb -w /stand/vmunix /dev/kmem
|
||||
You can insert this e.g. into /sbin/init.d/lan
|
||||
|
||||
Best regards,
|
||||
Lutz
|
||||
|
||||
and
|
||||
|
||||
http://groups.google.com/groups?selm=88cf4t%24p03%241%40web1.cup.hp.com
|
||||
|
||||
which says:
|
||||
|
||||
Newsgroups: comp.sys.hp.hpux
|
||||
Subject: Re: tcpdump only shows incoming packets
|
||||
Date: 02/15/2000
|
||||
From: Rick Jones <foo@bar.baz.invalid>
|
||||
|
||||
Harald Skotnes <harald@cc.uit.no> wrote:
|
||||
> I am running HPUX 11.0 on a C200 hanging on a 100Mb switch. I have
|
||||
> compiled libpcap-0.4 an tcpdump-3.4 and it seems to work. But at a
|
||||
> closer look I only get to see the incoming packets not the
|
||||
> outgoing. I have tried tcpflow-0.12 which also uses libpcap and the
|
||||
> same thing happens. Could someone please give me a hint on how to
|
||||
> get this right?
|
||||
|
||||
Search/Read the archives ?-)
|
||||
|
||||
What you are seeing is expected, un-patched, behaviour for an HP-UX
|
||||
system. On 11.00, you need to install the latest lancommon/DLPI
|
||||
patches, and then the latest driver patch for the interface(s) in use.
|
||||
At that point, a miracle happens and you should start seeing outbound
|
||||
traffic.
|
||||
|
||||
[That article also mentions the patch that appears below.]
|
||||
|
||||
and
|
||||
|
||||
http://groups.google.com/groups?selm=38AA973E.96BE7DF7%40cc.uit.no
|
||||
|
||||
which says:
|
||||
|
||||
Newsgroups: comp.sys.hp.hpux
|
||||
Subject: Re: tcpdump only shows incoming packets
|
||||
Date: 02/16/2000
|
||||
From: Harald Skotnes <harald@cc.uit.no>
|
||||
|
||||
Rick Jones wrote:
|
||||
|
||||
...
|
||||
|
||||
> What you are seeing is expected, un-patched, behaviour for an HP-UX
|
||||
> system. On 11.00, you need to install the latest lancommon/DLPI
|
||||
> patches, and then the latest driver patch for the interface(s) in
|
||||
> use. At that point, a miracle happens and you should start seeing
|
||||
> outbound traffic.
|
||||
|
||||
Thanks a lot. I have this problem on several machines running HPUX
|
||||
10.20 and 11.00. The machines where patched up before y2k so did not
|
||||
know what to think. Anyway I have now installed PHNE_19766,
|
||||
PHNE_19826, PHNE_20008, PHNE_20735 on the C200 and now I can see the
|
||||
outbound traffic too. Thanks again.
|
||||
|
||||
(although those patches may not be the ones to install - there may be
|
||||
later patches).
|
||||
|
||||
And another message to tcpdump-workers@tcpdump.org, from Rick Jones:
|
||||
|
||||
Date: Mon, 29 Apr 2002 15:59:55 -0700
|
||||
From: Rick Jones
|
||||
To: tcpdump-workers@tcpdump.org
|
||||
Subject: Re: [tcpdump-workers] I Can't Capture the Outbound Traffic
|
||||
|
||||
...
|
||||
|
||||
http://itrc.hp.com/ would be one place to start in a search for the most
|
||||
up-to-date patches for DLPI and the lan driver(s) used on your system (I
|
||||
cannot guess because 9000/800 is too generic - one hs to use the "model"
|
||||
command these days and/or an ioscan command (see manpage) to guess what
|
||||
the drivers (btlan[3456], gelan, etc) might be involved in addition to
|
||||
DLPI.
|
||||
|
||||
Another option is to upgrade to 11i as outbound promiscuous mode support
|
||||
is there in the base OS, no patches required.
|
||||
|
||||
Another posting:
|
||||
|
||||
http://groups.google.com/groups?selm=7d6gvn%24b3%241%40ocean.cup.hp.com
|
||||
|
||||
indicates that you need to install the optional STREAMS product to do
|
||||
captures on HP-UX 9.x:
|
||||
|
||||
Newsgroups: comp.sys.hp.hpux
|
||||
Subject: Re: tcpdump HP/UX 9.x
|
||||
Date: 03/22/1999
|
||||
From: Rick Jones <foo@bar.baz>
|
||||
|
||||
Dave Barr (barr@cis.ohio-state.edu) wrote:
|
||||
: Has anyone ported tcpdump (or something similar) to HP/UX 9.x?
|
||||
|
||||
I'm reasonably confident that any port of tcpdump to 9.X would require
|
||||
the (then optional) STREAMS product. This would bring DLPI, which is
|
||||
what one uses to access interfaces in promiscuous mode.
|
||||
|
||||
I'm not sure that HP even sells the 9.X STREAMS product any longer,
|
||||
since HP-UX 9.X is off the pricelist (well, maybe 9.10 for the old 68K
|
||||
devices).
|
||||
|
||||
Your best bet is to be up on 10.20 or better if that is at all
|
||||
possible. If your hardware is supported by it, I'd go with HP-UX 11.
|
||||
If you want to see the system's own outbound traffic, you'll never get
|
||||
that functionality on 9.X, but it might happen at some point for 10.20
|
||||
and 11.X.
|
||||
|
||||
rick jones
|
||||
|
||||
(as per other messages cited here, the ability to see the system's own
|
||||
outbound traffic did happen).
|
||||
|
||||
Rick Jones reports that HP-UX 11i needs no patches for outbound
|
||||
promiscuous mode support.
|
||||
|
||||
An additional note, from Jost Martin, for HP-UX 10.20:
|
||||
|
||||
Q: How do I get ethereral on HPUX to capture the _outgoing_ packets
|
||||
of an interface
|
||||
A: You need to get PHNE_20892,PHNE_20725 and PHCO_10947 (or
|
||||
newer, this is as of 4.4.00) and its dependencies. Then you can
|
||||
enable the feature as descibed below:
|
||||
|
||||
Patch Name: PHNE_20892
|
||||
Patch Description: s700 10.20 PCI 100Base-T cumulative patch
|
||||
To trace the outbound packets, please do the following
|
||||
to turn on a global promiscuous switch before running
|
||||
the promiscuous applications like snoop or tcpdump:
|
||||
|
||||
adb -w /stand/vmunix /dev/mem
|
||||
lanc_outbound_promisc_flag/W 1
|
||||
(adb will echo the result showing that the flag has
|
||||
been changed)
|
||||
$quit
|
||||
(Thanks for this part to HP-support, Ratingen)
|
||||
|
||||
The attached hack does this and some security-related stuff
|
||||
(thanks to hildeb@www.stahl.bau.tu-bs.de (Ralf Hildebrandt) who
|
||||
posted the security-part some time ago)
|
||||
|
||||
<<hack_ip_stack>>
|
||||
|
||||
(Don't switch IP-forwarding off, if you need it !)
|
||||
Install the hack as /sbin/init.d/hacl_ip_stack (adjust
|
||||
permissions !) and make a sequencing-symlink
|
||||
/sbin/rc2.d/S350hack_ip_stack pointing to this script.
|
||||
Now all this is done on every reboot.
|
||||
|
||||
According to Rick Jones, the global promiscuous switch also has to be
|
||||
turned on for HP-UX 11.00, but not for 11i - and, in fact, the switch
|
||||
doesn't even exist on 11i.
|
||||
|
||||
Here's the "hack_ip_stack" script:
|
||||
|
||||
-----------------------------------Cut Here-------------------------------------
|
||||
#!/sbin/sh
|
||||
#
|
||||
# nettune: hack kernel parms for safety
|
||||
|
||||
OKAY=0
|
||||
ERROR=-1
|
||||
|
||||
# /usr/contrib/bin fuer nettune auf Pfad
|
||||
PATH=/sbin:/usr/sbin:/usr/bin:/usr/contrib/bin
|
||||
export PATH
|
||||
|
||||
|
||||
##########
|
||||
# main #
|
||||
##########
|
||||
|
||||
case $1 in
|
||||
start_msg)
|
||||
print "Tune IP-Stack for security"
|
||||
exit $OKAY
|
||||
;;
|
||||
|
||||
stop_msg)
|
||||
print "This action is not applicable"
|
||||
exit $OKAY
|
||||
;;
|
||||
|
||||
stop)
|
||||
exit $OKAY
|
||||
;;
|
||||
|
||||
start)
|
||||
;; # fall through
|
||||
|
||||
*)
|
||||
print "USAGE: $0 {start_msg | stop_msg | start | stop}" >&2
|
||||
exit $ERROR
|
||||
;;
|
||||
esac
|
||||
|
||||
###########
|
||||
# start #
|
||||
###########
|
||||
|
||||
#
|
||||
# tcp-Sequence-Numbers nicht mehr inkrementieren sondern random
|
||||
# Syn-Flood-Protection an
|
||||
# ip_forwarding aus
|
||||
# Source-Routing aus
|
||||
# Ausgehende Packets an ethereal/tcpdump etc.
|
||||
|
||||
/usr/contrib/bin/nettune -s tcp_random_seq 2 || exit $ERROR
|
||||
/usr/contrib/bin/nettune -s hp_syn_protect 1 || exit $ERROR
|
||||
/usr/contrib/bin/nettune -s ip_forwarding 0 || exit $ERROR
|
||||
echo 'ip_block_source_routed/W1' | /usr/bin/adb -w /stand/vmunix /dev/kmem || exit $ERROR
|
||||
echo 'lanc_outbound_promisc_flag/W 1' | adb -w /stand/vmunix /dev/mem || exit $ERROR
|
||||
|
||||
exit $OKAY
|
||||
-----------------------------------Cut Here-------------------------------------
|
@ -1,108 +0,0 @@
|
||||
In order for libpcap to be able to capture packets on a Linux system,
|
||||
the "packet" protocol must be supported by your kernel. If it is not,
|
||||
you may get error messages such as
|
||||
|
||||
modprobe: can't locate module net-pf-17
|
||||
|
||||
in "/var/adm/messages", or may get messages such as
|
||||
|
||||
socket: Address family not supported by protocol
|
||||
|
||||
from applications using libpcap.
|
||||
|
||||
You must configure the kernel with the CONFIG_PACKET option for this
|
||||
protocol; the following note is from the Linux "Configure.help" file for
|
||||
the 2.0[.x] kernel:
|
||||
|
||||
Packet socket
|
||||
CONFIG_PACKET
|
||||
The Packet protocol is used by applications which communicate
|
||||
directly with network devices without an intermediate network
|
||||
protocol implemented in the kernel, e.g. tcpdump. If you want them
|
||||
to work, choose Y.
|
||||
|
||||
This driver is also available as a module called af_packet.o ( =
|
||||
code which can be inserted in and removed from the running kernel
|
||||
whenever you want). If you want to compile it as a module, say M
|
||||
here and read Documentation/modules.txt; if you use modprobe or
|
||||
kmod, you may also want to add "alias net-pf-17 af_packet" to
|
||||
/etc/modules.conf.
|
||||
|
||||
and the note for the 2.2[.x] kernel says:
|
||||
|
||||
Packet socket
|
||||
CONFIG_PACKET
|
||||
The Packet protocol is used by applications which communicate
|
||||
directly with network devices without an intermediate network
|
||||
protocol implemented in the kernel, e.g. tcpdump. If you want them
|
||||
to work, choose Y. This driver is also available as a module called
|
||||
af_packet.o ( = code which can be inserted in and removed from the
|
||||
running kernel whenever you want). If you want to compile it as a
|
||||
module, say M here and read Documentation/modules.txt. You will
|
||||
need to add 'alias net-pf-17 af_packet' to your /etc/conf.modules
|
||||
file for the module version to function automatically. If unsure,
|
||||
say Y.
|
||||
|
||||
In addition, there is an option that, in 2.2 and later kernels, will
|
||||
allow packet capture filters specified to programs such as tcpdump to be
|
||||
executed in the kernel, so that packets that don't pass the filter won't
|
||||
be copied from the kernel to the program, rather than having all packets
|
||||
copied to the program and libpcap doing the filtering in user mode.
|
||||
|
||||
Copying packets from the kernel to the program consumes a significant
|
||||
amount of CPU, so filtering in the kernel can reduce the overhead of
|
||||
capturing packets if a filter has been specified that discards a
|
||||
significant number of packets. (If no filter is specified, it makes no
|
||||
difference whether the filtering isn't performed in the kernel or isn't
|
||||
performed in user mode. :-))
|
||||
|
||||
The option for this is the CONFIG_FILTER option; the "Configure.help"
|
||||
file says:
|
||||
|
||||
Socket filtering
|
||||
CONFIG_FILTER
|
||||
The Linux Socket Filter is derived from the Berkeley Packet Filter.
|
||||
If you say Y here, user-space programs can attach a filter to any
|
||||
socket and thereby tell the kernel that it should allow or disallow
|
||||
certain types of data to get through the socket. Linux Socket
|
||||
Filtering works on all socket types except TCP for now. See the text
|
||||
file linux/Documentation/networking/filter.txt for more information.
|
||||
If unsure, say N.
|
||||
|
||||
Note that, by default, libpcap will, if libnl is present, build with it;
|
||||
it uses libnl to support monitor mode on mac80211 devices. There is a
|
||||
configuration option to disable building with libnl, but, if that option
|
||||
is chosen, the monitor-mode APIs (as used by tcpdump's "-I" flag, and as
|
||||
will probably be used by other applications in the future) won't work
|
||||
properly on mac80211 devices.
|
||||
|
||||
Linux's run-time linker allows shared libraries to be linked with other
|
||||
shared libraries, which means that if an older version of a shared
|
||||
library doesn't require routines from some other shared library, and a
|
||||
later version of the shared library does require those routines, the
|
||||
later version of the shared library can be linked with that other shared
|
||||
library and, if it's otherwise binary-compatible with the older version,
|
||||
can replace that older version without breaking applications built with
|
||||
the older version, and without breaking configure scripts or the build
|
||||
procedure for applications whose configure script doesn't use the
|
||||
pcap-config script if they build with the shared library. (The build
|
||||
procedure for applications whose configure scripts use the pcap-config
|
||||
script if present will not break even if they build with the static
|
||||
library.)
|
||||
|
||||
Statistics:
|
||||
Statistics reported by pcap are platform specific. The statistics
|
||||
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_drop Always 0, this statistic is not gatherd on this platform
|
||||
|
||||
2.4.x
|
||||
=====
|
||||
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.
|
@ -1,74 +0,0 @@
|
||||
As with other systems using BPF, Mac OS X allows users with read access
|
||||
to the BPF devices to capture packets with libpcap and allows users with
|
||||
write access to the BPF devices to send packets with libpcap.
|
||||
|
||||
On some systems that use BPF, the BPF devices live on the root file
|
||||
system, and the permissions and/or ownership on those devices can be
|
||||
changed to give users other than root permission to read or write those
|
||||
devices.
|
||||
|
||||
On newer versions of FreeBSD, the BPF devices live on devfs, and devfs
|
||||
can be configured to set the permissions and/or ownership of those
|
||||
devices to give users other than root permission to read or write those
|
||||
devices.
|
||||
|
||||
On Mac OS X, the BPF devices live on devfs, but the OS X version of
|
||||
devfs is based on an older (non-default) FreeBSD devfs, and that version
|
||||
of devfs cannot be configured to set the permissions and/or ownership of
|
||||
those devices.
|
||||
|
||||
Therefore, we supply:
|
||||
|
||||
a "startup item" for older versions of Mac OS X;
|
||||
|
||||
a launchd daemon for Tiger and later versions of Mac OS X;
|
||||
|
||||
Both of them will change the ownership of the BPF devices so that the
|
||||
"admin" group owns them, and will change the permission of the BPF
|
||||
devices to rw-rw----, so that all users in the "admin" group - i.e., all
|
||||
users with "Allow user to administer this computer" turned on - have
|
||||
both read and write access to them.
|
||||
|
||||
The startup item is in the ChmodBPF directory in the source tree. A
|
||||
/Library/StartupItems directory should be created if it doesn't already
|
||||
exist, and the ChmodBPF directory should be copied to the
|
||||
/Library/StartupItems directory (copy the entire directory, so that
|
||||
there's a /Library/StartupItems/ChmodBPF directory, containing all the
|
||||
files in the source tree's ChmodBPF directory; don't copy the individual
|
||||
items in that directory to /Library/StartupItems). The ChmodBPF
|
||||
directory, and all files under it, must be owned by root. Installing
|
||||
the files won't immediately cause the startup item to be executed; it
|
||||
will be executed on the next reboot. To change the permissions before
|
||||
the reboot, run
|
||||
|
||||
sudo SystemStarter start ChmodBPF
|
||||
|
||||
The launchd daemon is the chmod_bpf script, plus the
|
||||
org.tcpdump.chmod_bpf.plist launchd plist file. chmod_bpf should be
|
||||
installed in /usr/local/bin/chmod_bpf, and org.tcpdump.chmod_bpf.plist
|
||||
should be installed in /Library/LaunchDaemons. chmod_bpf, and
|
||||
org.tcpdump.chmod_bpf.plist, must be owned by root. Installing the
|
||||
script and plist file won't immediately cause the script to be executed;
|
||||
it will be executed on the next reboot. To change the permissions
|
||||
before the reboot, run
|
||||
|
||||
sudo /usr/local/bin/chmod_bpf
|
||||
|
||||
or
|
||||
|
||||
sudo launchctl load /Library/LaunchDaemons/org.tcpdump.chmod_bpf.plist
|
||||
|
||||
If you want to give a particular user permission to access the BPF
|
||||
devices, rather than giving all administrative users permission to
|
||||
access them, you can have the ChmodBPF/ChmodBPF script change the
|
||||
ownership of /dev/bpf* without changing the permissions. If you want to
|
||||
give a particular user permission to read and write the BPF devices and
|
||||
give the administrative users permission to read but not write the BPF
|
||||
devices, you can have the script change the owner to that user, the
|
||||
group to "admin", and the permissions to rw-r-----. Other possibilities
|
||||
are left as an exercise for the reader.
|
||||
|
||||
(NOTE: due to a bug in Snow Leopard, if you change the permissions not
|
||||
to grant write permission to everybody who should be allowed to capture
|
||||
traffic, non-root users who cannot open the BPF devices for writing will
|
||||
not be able to capture outgoing packets.)
|
@ -1,50 +0,0 @@
|
||||
The following instructions apply if you have a Linux platform and want
|
||||
libpcap to support the Septel range of passive network monitoring cards
|
||||
from Intel (http://www.intel.com)
|
||||
|
||||
1) Install and build the Septel software distribution by following the
|
||||
instructions supplied with that package.
|
||||
|
||||
2) Configure libcap. To allow the 'configure' script to locate the Septel
|
||||
software distribution use the '--with-septel' option:
|
||||
|
||||
./configure --with-septel=DIR
|
||||
|
||||
where DIR is the root of the Septel software distribution, for example
|
||||
/var/src/septel.
|
||||
|
||||
By default (if you write only ./configure --with-septel) it takes
|
||||
./../septel as argument for DIR.
|
||||
|
||||
If the Septel software is correctly detected 'configure' will
|
||||
report:
|
||||
|
||||
checking whether we have Septel API... yes
|
||||
|
||||
If 'configure' reports that there is no Septel API, the directory may have been
|
||||
incorrectly specified or the Septel software was not built before configuring
|
||||
libpcap.
|
||||
|
||||
See also the libpcap INSTALL.txt file for further libpcap configuration
|
||||
options.
|
||||
|
||||
Building libpcap at this stage will include support for both the native
|
||||
packet capture stream and for capturing from Septel cards. To build
|
||||
libpcap with only Septel support specify the capture type as 'septel'
|
||||
when configuring libpcap:
|
||||
|
||||
./configure --with-septel=DIR --with-pcap=septel
|
||||
|
||||
Applications built with libpcap configured in this way will only detect Septel
|
||||
cards and will not capture from the native OS packet stream.
|
||||
|
||||
Note: As mentioned in pcap-septel.c we should first edit the system.txt
|
||||
file to change the user part example (UPE) module id to 0xdd instead of
|
||||
0x2d for technical reason. So this change in system.txt is crutial and
|
||||
things will go wrong if it's not done. System.txt along with config.txt
|
||||
are configuration files that are edited by the user before running the
|
||||
gctload program that uses these files for initialising modules and
|
||||
configuring parameters.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
for more information please contact me : gil_hoyek@hotmail.com
|
@ -1,64 +0,0 @@
|
||||
The following instructions apply if you have a Linux platform and want
|
||||
libpcap to support the 'ACN' WAN/LAN router product from from SITA
|
||||
(http://www.sita.aero)
|
||||
|
||||
This might also work on non-Linux Unix-compatible platforms, but that
|
||||
has not been tested.
|
||||
|
||||
See also the libpcap INSTALL.txt file for further libpcap configuration
|
||||
options.
|
||||
|
||||
These additions/extensions have been made to PCAP to allow it to
|
||||
capture packets from a SITA ACN device (and potentially others).
|
||||
|
||||
To enable its support you need to ensure that the distribution has
|
||||
a correct configure.ac file; that can be created if neccessay by
|
||||
using the normal autoconf procedure of:
|
||||
|
||||
aclocal
|
||||
autoconf
|
||||
autoheader
|
||||
automake
|
||||
|
||||
Then run configure with the 'sita' option:
|
||||
|
||||
./configure --with-sita
|
||||
|
||||
Applications built with libpcap configured in this way will only detect SITA
|
||||
ACN interfaces and will not capture from the native OS packet stream.
|
||||
|
||||
The SITA extension provides a remote datascope operation for capturing
|
||||
both WAN and LAN protocols. It effectively splits the operation of
|
||||
PCAP into two halves. The top layer performs the majority of the
|
||||
work, but interfaces via a TCP session to remote agents that
|
||||
provide the lower layer functionality of actual sniffing and
|
||||
filtering. More detailed information regarding the functions and
|
||||
inter-device protocol and naming conventions are described in detail
|
||||
in 'pcap-sita.html'.
|
||||
|
||||
pcap_findalldevs() reads the local system's /etc/hosts file looking
|
||||
for host names that match the format of IOP type devices. ie. aaa_I_x_y
|
||||
and then queries each associated IP address for a list of its WAN and
|
||||
LAN devices. The local system the aggregates the lists obtained from
|
||||
each IOP, sorts it, and provides it (to Wireshark et.al) as the
|
||||
list of monitorable interfaces.
|
||||
|
||||
Once a valid interface has been selected, pcap_open() is called
|
||||
which opens a TCP session (to a well known port) on the target IOP
|
||||
and tells it to start monitoring.
|
||||
|
||||
All captured packets are then forwarded across that TCP session
|
||||
back to the local 'top layer' for forwarding to the actual
|
||||
sniffing program (wireshark...)
|
||||
|
||||
Note that the DLT_SITA link-layer type includes a proprietary header
|
||||
that is documented as part of the SITA dissector of Wireshark and is
|
||||
also described in 'pcap-sita.html' for posterity sake.
|
||||
|
||||
That header provides:
|
||||
- Packet direction (in/out) (1 octet)
|
||||
- Link layer hardware signal status (1 octet)
|
||||
- Transmit/Receive error status (2 octets)
|
||||
- Encapsulated WAN protocol ID (1 octet)
|
||||
|
||||
|
@ -1,49 +0,0 @@
|
||||
The following instructions are applicable to Tru64 UNIX
|
||||
(formerly Digital UNIX (formerly DEC OSF/1)) version 4.0, and
|
||||
probably to later versions as well; at least some options apply to
|
||||
Digital UNIX 3.2 - perhaps all do.
|
||||
|
||||
In order to use kernel packet filtering on this system, you have
|
||||
to configure it in such a way:
|
||||
|
||||
Kernel configuration
|
||||
--------------------
|
||||
|
||||
The packet filtering kernel option must be enabled at kernel
|
||||
installation. If it was not the case, you can rebuild the kernel with
|
||||
"doconfig -c" after adding the following line in the kernel
|
||||
configuration file (/sys/conf/<HOSTNAME>):
|
||||
|
||||
option PACKETFILTER
|
||||
|
||||
or use "doconfig" without any arguments to add the packet filter driver
|
||||
option via the kernel option menu (see the system administration
|
||||
documentation for information on how to do this).
|
||||
|
||||
Device configuration
|
||||
--------------------
|
||||
|
||||
Devices used for packet filtering must be created thanks to
|
||||
the following command (executed in the /dev directory):
|
||||
|
||||
./MAKEDEV pfilt
|
||||
|
||||
Interface configuration
|
||||
-----------------------
|
||||
|
||||
In order to capture all packets on a network, you may want to allow
|
||||
applications to put the interface on that network into "local copy"
|
||||
mode, so that tcpdump can see packets sent by the host on which it's
|
||||
running as well as packets received by that host, and to put the
|
||||
interface into "promiscuous" mode, so that tcpdump can see packets on
|
||||
the network segment not sent to the host on which it's running, by using
|
||||
the pfconfig(1) command:
|
||||
|
||||
pfconfig +c +p <network_device>
|
||||
|
||||
or allow application to put any interface into "local copy" or
|
||||
"promiscuous" mode by using the command:
|
||||
|
||||
pfconfig +c +p -a
|
||||
|
||||
Note: all instructions given require root privileges.
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,35 +0,0 @@
|
||||
TODO list for libpcap
|
||||
=======================
|
||||
|
||||
Important stuff (to be done before the next release)
|
||||
---------------
|
||||
|
||||
General
|
||||
|
||||
- configure should not be in Git. Most open source projects have an
|
||||
autogen.sh script to run autoconf etc. after checkout. I think we
|
||||
should stick to the standard.
|
||||
|
||||
- The source files should be better documented. There is no official
|
||||
design guideline for what is done where. There should be a common coding
|
||||
style (okay, you can guess that by looking at the code) and a guide for
|
||||
what needs to be documented.
|
||||
|
||||
Less urgent items
|
||||
-----------------
|
||||
|
||||
- Better documentation and cleanup of the interface. I am seeing a few
|
||||
problems at the first glance which needs fixing:
|
||||
+ pcap_lookupnet makes little to no sense with protocols != IPv4
|
||||
+ not very well suited for interactive programs (think ethereal). There
|
||||
should be a way for the application to get a file descriptor which it
|
||||
has to monitor and a callback in pcap which has to be called on
|
||||
activity (XXX - "pcap_fileno()" handles the first part, although
|
||||
"select()" and "poll()" don't work on BPF devices on most BSDs, and
|
||||
you can call "pcap_dispatch()" as the dispatch routine after putting
|
||||
the descriptor into non-blocking mode)
|
||||
+ too many functions. There are a lot of functions for everything which
|
||||
violates the KISS principle. Why do we need pcap_strerror, pcap_perror
|
||||
and pcap_geterr?
|
||||
+ the manpage has a brief description of each function but where is the
|
||||
big picture? Seems like you need to buy UNP for that...
|
@ -1 +0,0 @@
|
||||
1.8.1
|
@ -1,8 +0,0 @@
|
||||
/* inline foo */
|
||||
#ifndef __cplusplus
|
||||
#ifdef __GNUC__
|
||||
#define inline __inline
|
||||
#else
|
||||
#define inline
|
||||
#endif
|
||||
#endif
|
@ -1,230 +0,0 @@
|
||||
/*
|
||||
* 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_ */
|
@ -1,28 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.40629.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wpcap", "wpcap.vcxproj", "{8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Debug|x64 = Debug|x64
|
||||
Release|Win32 = Release|Win32
|
||||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Debug|x64.Build.0 = Debug|x64
|
||||
{8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Release|Win32.Build.0 = Release|Win32
|
||||
{8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Release|x64.ActiveCfg = Release|x64
|
||||
{8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
@ -1,234 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<SccProjectName />
|
||||
<SccLocalPath />
|
||||
<ProjectGuid>{8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}</ProjectGuid>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>.\Release\</OutDir>
|
||||
<IntDir>.\Release\</IntDir>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>../../../;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>../../../;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>.\Debug\</OutDir>
|
||||
<IntDir>.\Debug\</IntDir>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>../../../;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>../../../;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
|
||||
<StringPooling>true</StringPooling>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<AdditionalIncludeDirectories>../../;../../lbl/;../../bpf/;../include/;../../../../common;../../../../dag/include;../../../../dag/drv/windows;../../../Win32-Extensions;./;Win32-Extensions;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>HAVE_VERSION_H;__STDC_VERSION__=199901L;HAVE_PACKET_IS_LOOPBACK_ADAPTER;NDEBUG;YY_NEVER_INTERACTIVE;_USRDLL;BUILDING_PCAP;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;HAVE_ADDRINFO;HAVE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>ws2_32.lib;..\..\..\..\packetWin7\Dll\Project\Release No NetMon and AirPcap\Packet.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
<PreBuildEvent>
|
||||
<Command>call ..\..\GenVersion.bat ..\..\VERSION ..\..\pcap_version.h.in ..\..\pcap_version.h
|
||||
win_flex -Ppcap_ -7 --outfile=..\..\scanner.c --header-file=..\..\scanner.h ..\..\scanner.l
|
||||
win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.y</Command>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
|
||||
<StringPooling>true</StringPooling>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<AdditionalIncludeDirectories>../../;../../lbl/;../../bpf/;../include/;../../../../common;../../../../dag/include;../../../../dag/drv/windows;../../../Win32-Extensions;./;Win32-Extensions;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>HAVE_VERSION_H;__STDC_VERSION__=199901L;HAVE_PACKET_IS_LOOPBACK_ADAPTER;NDEBUG;YY_NEVER_INTERACTIVE;_USRDLL;BUILDING_PCAP;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;HAVE_ADDRINFO;HAVE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>ws2_32.lib;..\..\..\..\packetWin7\Dll\Project\x64\Release No NetMon and AirPcap\Packet.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
<PreBuildEvent>
|
||||
<Command>call ..\..\GenVersion.bat ..\..\VERSION ..\..\pcap_version.h.in ..\..\pcap_version.h
|
||||
win_flex -Ppcap_ -7 --outfile=..\..\scanner.c --header-file=..\..\scanner.h ..\..\scanner.l
|
||||
win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.y</Command>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
|
||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<AdditionalIncludeDirectories>../../;../../lbl/;../../bpf/;../include/;../../../../common;../../../../dag/include;../../../../dag/drv/windows;../../../Win32-Extensions;./;Win32-Extensions;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>HAVE_VERSION_H;__STDC_VERSION__=199901L;HAVE_PACKET_IS_LOOPBACK_ADAPTER;_DEBUG;YY_NEVER_INTERACTIVE;_USRDLL;BUILDING_PCAP;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;HAVE_ADDRINFO;HAVE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>ws2_32.lib;..\..\..\..\packetWin7\Dll\Project\Release No NetMon and AirPcap\Packet.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
<PreBuildEvent>
|
||||
<Command>call ..\..\GenVersion.bat ..\..\VERSION ..\..\pcap_version.h.in ..\..\pcap_version.h
|
||||
win_flex -Ppcap_ -7 --outfile=..\..\scanner.c --header-file=..\..\scanner.h ..\..\scanner.l
|
||||
win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.y</Command>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
|
||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<AdditionalIncludeDirectories>../../;../../lbl/;../../bpf/;../include/;../../../../common;../../../../dag/include;../../../../dag/drv/windows;../../../Win32-Extensions;./;Win32-Extensions;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>HAVE_VERSION_H;__STDC_VERSION__=199901L;HAVE_PACKET_IS_LOOPBACK_ADAPTER;_DEBUG;YY_NEVER_INTERACTIVE;_USRDLL;BUILDING_PCAP;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;HAVE_ADDRINFO;HAVE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>ws2_32.lib;..\..\..\..\packetWin7\Dll\Project\x64\Release No NetMon and AirPcap\Packet.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
<PreBuildEvent>
|
||||
<Command>call ..\..\GenVersion.bat ..\..\VERSION ..\..\pcap_version.h.in ..\..\pcap_version.h
|
||||
win_flex -Ppcap_ -7 --outfile=..\..\scanner.c --header-file=..\..\scanner.h ..\..\scanner.l
|
||||
win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.y</Command>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\bpf\net\bpf_filter.c" />
|
||||
<ClCompile Include="..\..\bpf_dump.c" />
|
||||
<ClCompile Include="..\..\bpf_image.c" />
|
||||
<ClCompile Include="..\..\etherent.c" />
|
||||
<ClCompile Include="..\..\fad-helpers.c" />
|
||||
<ClCompile Include="..\..\gencode.c" />
|
||||
<ClCompile Include="..\..\grammar.c" />
|
||||
<ClCompile Include="..\..\inet.c" />
|
||||
<ClCompile Include="..\..\missing\win_snprintf.c" />
|
||||
<ClCompile Include="..\..\nametoaddr.c" />
|
||||
<ClCompile Include="..\..\optimize.c" />
|
||||
<ClCompile Include="..\..\pcap-common.c" />
|
||||
<ClCompile Include="..\..\pcap-new.c" />
|
||||
<ClCompile Include="..\..\pcap-rpcap.c" />
|
||||
<ClCompile Include="..\..\pcap-win32.c" />
|
||||
<ClCompile Include="..\..\pcap.c" />
|
||||
<ClCompile Include="..\..\savefile.c" />
|
||||
<ClCompile Include="..\..\scanner.c" />
|
||||
<ClCompile Include="..\..\sf-pcap-ng.c" />
|
||||
<ClCompile Include="..\..\sf-pcap.c" />
|
||||
<ClCompile Include="..\..\sockutils.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\pcap-common.h" />
|
||||
<ClInclude Include="..\..\pcap-int.h" />
|
||||
<ClInclude Include="..\..\pcap-rpcap.h" />
|
||||
<ClInclude Include="..\..\pcap-stdinc.h" />
|
||||
<ClInclude Include="..\..\pcap.h" />
|
||||
<ClInclude Include="..\..\remote-ext.h" />
|
||||
<ClInclude Include="..\..\sockutils.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="..\..\..\Win32-Extensions\version.rc" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
@ -1,107 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\bpf_dump.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\bpf\net\bpf_filter.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\bpf_image.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\etherent.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\gencode.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\grammar.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\inet.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\nametoaddr.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\optimize.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\pcap.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\pcap-win32.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\savefile.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\scanner.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\sf-pcap.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\sf-pcap-ng.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\pcap-common.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\fad-helpers.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\missing\win_snprintf.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\pcap-new.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\pcap-rpcap.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\sockutils.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{c51dce5e-0da9-4e33-a235-d5c76c76485c}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{5ec9fd4b-10b5-4527-b249-56b53d844fb1}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{c90886f0-8973-436b-a7a1-b9e881544f9a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\pcap-stdinc.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\pcap-common.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\pcap.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\pcap-int.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\pcap-rpcap.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\remote-ext.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\sockutils.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="..\..\..\Win32-Extensions\version.rc">
|
||||
<Filter>Resource Files</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
1253
libpcap-1.8.1/aclocal.m4
vendored
1253
libpcap-1.8.1/aclocal.m4
vendored
File diff suppressed because it is too large
Load Diff
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 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.
|
||||
*
|
||||
* from: NetBSD: if_arc.h,v 1.13 1999/11/19 20:41:19 thorpej Exp
|
||||
*/
|
||||
|
||||
/* RFC 1051 */
|
||||
#define ARCTYPE_IP_OLD 240 /* IP protocol */
|
||||
#define ARCTYPE_ARP_OLD 241 /* address resolution protocol */
|
||||
|
||||
/* RFC 1201 */
|
||||
#define ARCTYPE_IP 212 /* IP protocol */
|
||||
#define ARCTYPE_ARP 213 /* address resolution protocol */
|
||||
#define ARCTYPE_REVARP 214 /* reverse addr resolution protocol */
|
||||
|
||||
#define ARCTYPE_ATALK 221 /* Appletalk */
|
||||
#define ARCTYPE_BANIAN 247 /* Banyan Vines */
|
||||
#define ARCTYPE_IPX 250 /* Novell IPX */
|
||||
|
||||
#define ARCTYPE_INET6 0xc4 /* IPng */
|
||||
#define ARCTYPE_DIAGNOSE 0x80 /* as per ANSI/ATA 878.1 */
|
@ -1,85 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1997 Yen Yen Lim and North Dakota State 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 Yen Yen Lim and
|
||||
North Dakota State University
|
||||
* 4. 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 AUTHOR ``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 AUTHOR 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.
|
||||
*/
|
||||
|
||||
/* Based on UNI3.1 standard by ATM Forum */
|
||||
|
||||
/* ATM traffic types based on VPI=0 and (the following VCI */
|
||||
#define VCI_PPC 0x05 /* Point-to-point signal msg */
|
||||
#define VCI_BCC 0x02 /* Broadcast signal msg */
|
||||
#define VCI_OAMF4SC 0x03 /* Segment OAM F4 flow cell */
|
||||
#define VCI_OAMF4EC 0x04 /* End-to-end OAM F4 flow cell */
|
||||
#define VCI_METAC 0x01 /* Meta signal msg */
|
||||
#define VCI_ILMIC 0x10 /* ILMI msg */
|
||||
|
||||
/* Q.2931 signalling messages */
|
||||
#define CALL_PROCEED 0x02 /* call proceeding */
|
||||
#define CONNECT 0x07 /* connect */
|
||||
#define CONNECT_ACK 0x0f /* connect_ack */
|
||||
#define SETUP 0x05 /* setup */
|
||||
#define RELEASE 0x4d /* release */
|
||||
#define RELEASE_DONE 0x5a /* release_done */
|
||||
#define RESTART 0x46 /* restart */
|
||||
#define RESTART_ACK 0x4e /* restart ack */
|
||||
#define STATUS 0x7d /* status */
|
||||
#define STATUS_ENQ 0x75 /* status ack */
|
||||
#define ADD_PARTY 0x80 /* add party */
|
||||
#define ADD_PARTY_ACK 0x81 /* add party ack */
|
||||
#define ADD_PARTY_REJ 0x82 /* add party rej */
|
||||
#define DROP_PARTY 0x83 /* drop party */
|
||||
#define DROP_PARTY_ACK 0x84 /* drop party ack */
|
||||
|
||||
/* Information Element Parameters in the signalling messages */
|
||||
#define CAUSE 0x08 /* cause */
|
||||
#define ENDPT_REF 0x54 /* endpoint reference */
|
||||
#define AAL_PARA 0x58 /* ATM adaptation layer parameters */
|
||||
#define TRAFF_DESCRIP 0x59 /* atm traffic descriptors */
|
||||
#define CONNECT_ID 0x5a /* connection identifier */
|
||||
#define QOS_PARA 0x5c /* quality of service parameters */
|
||||
#define B_HIGHER 0x5d /* broadband higher layer information */
|
||||
#define B_BEARER 0x5e /* broadband bearer capability */
|
||||
#define B_LOWER 0x5f /* broadband lower information */
|
||||
#define CALLING_PARTY 0x6c /* calling party number */
|
||||
#define CALLED_PARTY 0x70 /* called party nmber */
|
||||
|
||||
#define Q2931 0x09
|
||||
|
||||
/* Q.2931 signalling general messages format */
|
||||
#define PROTO_POS 0 /* offset of protocol discriminator */
|
||||
#define CALL_REF_POS 2 /* offset of call reference value */
|
||||
#define MSG_TYPE_POS 5 /* offset of message type */
|
||||
#define MSG_LEN_POS 7 /* offset of mesage length */
|
||||
#define IE_BEGIN_POS 9 /* offset of first information element */
|
||||
|
||||
/* format of signalling messages */
|
||||
#define TYPE_POS 0
|
||||
#define LEN_POS 2
|
||||
#define FIELD_BEGIN_POS 4
|
@ -1,766 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from the Stanford/CMU enet packet filter,
|
||||
* (net/enet.c) distributed as part of 4.3BSD, and code contributed
|
||||
* to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
|
||||
* Berkeley Laboratory.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @(#)bpf.c 7.5 (Berkeley) 7/15/91
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include <pcap-stdinc.h>
|
||||
|
||||
#else /* _WIN32 */
|
||||
|
||||
#if HAVE_INTTYPES_H
|
||||
#include <inttypes.h>
|
||||
#elif HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_BITYPES_H
|
||||
#include <sys/bitypes.h>
|
||||
#endif
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#define SOLARIS (defined(sun) && (defined(__SVR4) || defined(__svr4__)))
|
||||
#if defined(__hpux) || SOLARIS
|
||||
# include <sys/sysmacros.h>
|
||||
# include <sys/stream.h>
|
||||
# define mbuf msgb
|
||||
# define m_next b_cont
|
||||
# define MLEN(m) ((m)->b_wptr - (m)->b_rptr)
|
||||
# define mtod(m,t) ((t)(m)->b_rptr)
|
||||
#else /* defined(__hpux) || SOLARIS */
|
||||
# define MLEN(m) ((m)->m_len)
|
||||
#endif /* defined(__hpux) || SOLARIS */
|
||||
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#include <pcap/bpf.h>
|
||||
|
||||
#if !defined(KERNEL) && !defined(_KERNEL)
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#define int32 bpf_int32
|
||||
#define u_int32 bpf_u_int32
|
||||
|
||||
#ifndef LBL_ALIGN
|
||||
/*
|
||||
* XXX - IA-64? If not, this probably won't work on Win64 IA-64
|
||||
* systems, unless LBL_ALIGN is defined elsewhere for them.
|
||||
* XXX - SuperH? If not, this probably won't work on WinCE SuperH
|
||||
* systems, unless LBL_ALIGN is defined elsewhere for them.
|
||||
*/
|
||||
#if defined(sparc) || defined(__sparc__) || defined(mips) || \
|
||||
defined(ibm032) || defined(__alpha) || defined(__hpux) || \
|
||||
defined(__arm__)
|
||||
#define LBL_ALIGN
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef LBL_ALIGN
|
||||
#ifndef _WIN32
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
#define EXTRACT_SHORT(p) ((u_short)ntohs(*(u_short *)p))
|
||||
#define EXTRACT_LONG(p) (ntohl(*(u_int32 *)p))
|
||||
#else
|
||||
#define EXTRACT_SHORT(p)\
|
||||
((u_short)\
|
||||
((u_short)*((u_char *)p+0)<<8|\
|
||||
(u_short)*((u_char *)p+1)<<0))
|
||||
#define EXTRACT_LONG(p)\
|
||||
((u_int32)*((u_char *)p+0)<<24|\
|
||||
(u_int32)*((u_char *)p+1)<<16|\
|
||||
(u_int32)*((u_char *)p+2)<<8|\
|
||||
(u_int32)*((u_char *)p+3)<<0)
|
||||
#endif
|
||||
|
||||
#if defined(KERNEL) || defined(_KERNEL)
|
||||
# if !defined(__hpux) && !SOLARIS
|
||||
#include <sys/mbuf.h>
|
||||
# endif
|
||||
#define MINDEX(len, _m, _k) \
|
||||
{ \
|
||||
len = MLEN(m); \
|
||||
while ((_k) >= len) { \
|
||||
(_k) -= len; \
|
||||
(_m) = (_m)->m_next; \
|
||||
if ((_m) == 0) \
|
||||
return 0; \
|
||||
len = MLEN(m); \
|
||||
} \
|
||||
}
|
||||
|
||||
static int
|
||||
m_xword(m, k, err)
|
||||
register struct mbuf *m;
|
||||
register int k, *err;
|
||||
{
|
||||
register int len;
|
||||
register u_char *cp, *np;
|
||||
register struct mbuf *m0;
|
||||
|
||||
MINDEX(len, m, k);
|
||||
cp = mtod(m, u_char *) + k;
|
||||
if (len - k >= 4) {
|
||||
*err = 0;
|
||||
return EXTRACT_LONG(cp);
|
||||
}
|
||||
m0 = m->m_next;
|
||||
if (m0 == 0 || MLEN(m0) + len - k < 4)
|
||||
goto bad;
|
||||
*err = 0;
|
||||
np = mtod(m0, u_char *);
|
||||
switch (len - k) {
|
||||
|
||||
case 1:
|
||||
return (cp[0] << 24) | (np[0] << 16) | (np[1] << 8) | np[2];
|
||||
|
||||
case 2:
|
||||
return (cp[0] << 24) | (cp[1] << 16) | (np[0] << 8) | np[1];
|
||||
|
||||
default:
|
||||
return (cp[0] << 24) | (cp[1] << 16) | (cp[2] << 8) | np[0];
|
||||
}
|
||||
bad:
|
||||
*err = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
m_xhalf(m, k, err)
|
||||
register struct mbuf *m;
|
||||
register int k, *err;
|
||||
{
|
||||
register int len;
|
||||
register u_char *cp;
|
||||
register struct mbuf *m0;
|
||||
|
||||
MINDEX(len, m, k);
|
||||
cp = mtod(m, u_char *) + k;
|
||||
if (len - k >= 2) {
|
||||
*err = 0;
|
||||
return EXTRACT_SHORT(cp);
|
||||
}
|
||||
m0 = m->m_next;
|
||||
if (m0 == 0)
|
||||
goto bad;
|
||||
*err = 0;
|
||||
return (cp[0] << 8) | mtod(m0, u_char *)[0];
|
||||
bad:
|
||||
*err = 1;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
#include <linux/types.h>
|
||||
#include <linux/if_packet.h>
|
||||
#include <linux/filter.h>
|
||||
#endif
|
||||
|
||||
enum {
|
||||
BPF_S_ANC_NONE,
|
||||
BPF_S_ANC_VLAN_TAG,
|
||||
BPF_S_ANC_VLAN_TAG_PRESENT,
|
||||
};
|
||||
|
||||
/*
|
||||
* Execute the filter program starting at pc on the packet p
|
||||
* wirelen is the length of the original packet
|
||||
* buflen is the amount of data present
|
||||
* aux_data is auxiliary data, currently used only when interpreting
|
||||
* filters intended for the Linux kernel in cases where the kernel
|
||||
* rejects the filter; it contains VLAN tag information
|
||||
* For the kernel, p is assumed to be a pointer to an mbuf if buflen is 0,
|
||||
* in all other cases, p is a pointer to a buffer and buflen is its size.
|
||||
*
|
||||
* Thanks to Ani Sinha <ani@arista.com> for providing initial implementation
|
||||
*/
|
||||
u_int
|
||||
bpf_filter_with_aux_data(pc, p, wirelen, buflen, aux_data)
|
||||
register const struct bpf_insn *pc;
|
||||
register const u_char *p;
|
||||
u_int wirelen;
|
||||
register u_int buflen;
|
||||
register const struct bpf_aux_data *aux_data;
|
||||
{
|
||||
register u_int32 A, X;
|
||||
register bpf_u_int32 k;
|
||||
u_int32 mem[BPF_MEMWORDS];
|
||||
#if defined(KERNEL) || defined(_KERNEL)
|
||||
struct mbuf *m, *n;
|
||||
int merr, len;
|
||||
|
||||
if (buflen == 0) {
|
||||
m = (struct mbuf *)p;
|
||||
p = mtod(m, u_char *);
|
||||
buflen = MLEN(m);
|
||||
} else
|
||||
m = NULL;
|
||||
#endif
|
||||
|
||||
if (pc == 0)
|
||||
/*
|
||||
* No filter means accept all.
|
||||
*/
|
||||
return (u_int)-1;
|
||||
A = 0;
|
||||
X = 0;
|
||||
--pc;
|
||||
while (1) {
|
||||
++pc;
|
||||
switch (pc->code) {
|
||||
|
||||
default:
|
||||
#if defined(KERNEL) || defined(_KERNEL)
|
||||
return 0;
|
||||
#else
|
||||
abort();
|
||||
#endif
|
||||
case BPF_RET|BPF_K:
|
||||
return (u_int)pc->k;
|
||||
|
||||
case BPF_RET|BPF_A:
|
||||
return (u_int)A;
|
||||
|
||||
case BPF_LD|BPF_W|BPF_ABS:
|
||||
k = pc->k;
|
||||
if (k > buflen || sizeof(int32_t) > buflen - k) {
|
||||
#if defined(KERNEL) || defined(_KERNEL)
|
||||
if (m == NULL)
|
||||
return 0;
|
||||
A = m_xword(m, k, &merr);
|
||||
if (merr != 0)
|
||||
return 0;
|
||||
continue;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
A = EXTRACT_LONG(&p[k]);
|
||||
continue;
|
||||
|
||||
case BPF_LD|BPF_H|BPF_ABS:
|
||||
k = pc->k;
|
||||
if (k > buflen || sizeof(int16_t) > buflen - k) {
|
||||
#if defined(KERNEL) || defined(_KERNEL)
|
||||
if (m == NULL)
|
||||
return 0;
|
||||
A = m_xhalf(m, k, &merr);
|
||||
if (merr != 0)
|
||||
return 0;
|
||||
continue;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
A = EXTRACT_SHORT(&p[k]);
|
||||
continue;
|
||||
|
||||
case BPF_LD|BPF_B|BPF_ABS:
|
||||
{
|
||||
#if defined(SKF_AD_VLAN_TAG) && defined(SKF_AD_VLAN_TAG_PRESENT)
|
||||
int code = BPF_S_ANC_NONE;
|
||||
#define ANCILLARY(CODE) case SKF_AD_OFF + SKF_AD_##CODE: \
|
||||
code = BPF_S_ANC_##CODE; \
|
||||
if (!aux_data) \
|
||||
return 0; \
|
||||
break;
|
||||
|
||||
switch (pc->k) {
|
||||
ANCILLARY(VLAN_TAG);
|
||||
ANCILLARY(VLAN_TAG_PRESENT);
|
||||
default :
|
||||
#endif
|
||||
k = pc->k;
|
||||
if (k >= buflen) {
|
||||
#if defined(KERNEL) || defined(_KERNEL)
|
||||
if (m == NULL)
|
||||
return 0;
|
||||
n = m;
|
||||
MINDEX(len, n, k);
|
||||
A = mtod(n, u_char *)[k];
|
||||
continue;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
A = p[k];
|
||||
#if defined(SKF_AD_VLAN_TAG) && defined(SKF_AD_VLAN_TAG_PRESENT)
|
||||
}
|
||||
switch (code) {
|
||||
case BPF_S_ANC_VLAN_TAG:
|
||||
if (aux_data)
|
||||
A = aux_data->vlan_tag;
|
||||
break;
|
||||
|
||||
case BPF_S_ANC_VLAN_TAG_PRESENT:
|
||||
if (aux_data)
|
||||
A = aux_data->vlan_tag_present;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
case BPF_LD|BPF_W|BPF_LEN:
|
||||
A = wirelen;
|
||||
continue;
|
||||
|
||||
case BPF_LDX|BPF_W|BPF_LEN:
|
||||
X = wirelen;
|
||||
continue;
|
||||
|
||||
case BPF_LD|BPF_W|BPF_IND:
|
||||
k = X + pc->k;
|
||||
if (pc->k > buflen || X > buflen - pc->k ||
|
||||
sizeof(int32_t) > buflen - k) {
|
||||
#if defined(KERNEL) || defined(_KERNEL)
|
||||
if (m == NULL)
|
||||
return 0;
|
||||
A = m_xword(m, k, &merr);
|
||||
if (merr != 0)
|
||||
return 0;
|
||||
continue;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
A = EXTRACT_LONG(&p[k]);
|
||||
continue;
|
||||
|
||||
case BPF_LD|BPF_H|BPF_IND:
|
||||
k = X + pc->k;
|
||||
if (X > buflen || pc->k > buflen - X ||
|
||||
sizeof(int16_t) > buflen - k) {
|
||||
#if defined(KERNEL) || defined(_KERNEL)
|
||||
if (m == NULL)
|
||||
return 0;
|
||||
A = m_xhalf(m, k, &merr);
|
||||
if (merr != 0)
|
||||
return 0;
|
||||
continue;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
A = EXTRACT_SHORT(&p[k]);
|
||||
continue;
|
||||
|
||||
case BPF_LD|BPF_B|BPF_IND:
|
||||
k = X + pc->k;
|
||||
if (pc->k >= buflen || X >= buflen - pc->k) {
|
||||
#if defined(KERNEL) || defined(_KERNEL)
|
||||
if (m == NULL)
|
||||
return 0;
|
||||
n = m;
|
||||
MINDEX(len, n, k);
|
||||
A = mtod(n, u_char *)[k];
|
||||
continue;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
A = p[k];
|
||||
continue;
|
||||
|
||||
case BPF_LDX|BPF_MSH|BPF_B:
|
||||
k = pc->k;
|
||||
if (k >= buflen) {
|
||||
#if defined(KERNEL) || defined(_KERNEL)
|
||||
if (m == NULL)
|
||||
return 0;
|
||||
n = m;
|
||||
MINDEX(len, n, k);
|
||||
X = (mtod(n, char *)[k] & 0xf) << 2;
|
||||
continue;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
X = (p[pc->k] & 0xf) << 2;
|
||||
continue;
|
||||
|
||||
case BPF_LD|BPF_IMM:
|
||||
A = pc->k;
|
||||
continue;
|
||||
|
||||
case BPF_LDX|BPF_IMM:
|
||||
X = pc->k;
|
||||
continue;
|
||||
|
||||
case BPF_LD|BPF_MEM:
|
||||
A = mem[pc->k];
|
||||
continue;
|
||||
|
||||
case BPF_LDX|BPF_MEM:
|
||||
X = mem[pc->k];
|
||||
continue;
|
||||
|
||||
case BPF_ST:
|
||||
mem[pc->k] = A;
|
||||
continue;
|
||||
|
||||
case BPF_STX:
|
||||
mem[pc->k] = X;
|
||||
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:
|
||||
pc += (A > pc->k) ? pc->jt : pc->jf;
|
||||
continue;
|
||||
|
||||
case BPF_JMP|BPF_JGE|BPF_K:
|
||||
pc += (A >= pc->k) ? pc->jt : pc->jf;
|
||||
continue;
|
||||
|
||||
case BPF_JMP|BPF_JEQ|BPF_K:
|
||||
pc += (A == pc->k) ? pc->jt : pc->jf;
|
||||
continue;
|
||||
|
||||
case BPF_JMP|BPF_JSET|BPF_K:
|
||||
pc += (A & pc->k) ? pc->jt : pc->jf;
|
||||
continue;
|
||||
|
||||
case BPF_JMP|BPF_JGT|BPF_X:
|
||||
pc += (A > X) ? pc->jt : pc->jf;
|
||||
continue;
|
||||
|
||||
case BPF_JMP|BPF_JGE|BPF_X:
|
||||
pc += (A >= X) ? pc->jt : pc->jf;
|
||||
continue;
|
||||
|
||||
case BPF_JMP|BPF_JEQ|BPF_X:
|
||||
pc += (A == X) ? pc->jt : pc->jf;
|
||||
continue;
|
||||
|
||||
case BPF_JMP|BPF_JSET|BPF_X:
|
||||
pc += (A & X) ? pc->jt : pc->jf;
|
||||
continue;
|
||||
|
||||
case BPF_ALU|BPF_ADD|BPF_X:
|
||||
A += X;
|
||||
continue;
|
||||
|
||||
case BPF_ALU|BPF_SUB|BPF_X:
|
||||
A -= X;
|
||||
continue;
|
||||
|
||||
case BPF_ALU|BPF_MUL|BPF_X:
|
||||
A *= X;
|
||||
continue;
|
||||
|
||||
case BPF_ALU|BPF_DIV|BPF_X:
|
||||
if (X == 0)
|
||||
return 0;
|
||||
A /= X;
|
||||
continue;
|
||||
|
||||
case BPF_ALU|BPF_MOD|BPF_X:
|
||||
if (X == 0)
|
||||
return 0;
|
||||
A %= X;
|
||||
continue;
|
||||
|
||||
case BPF_ALU|BPF_AND|BPF_X:
|
||||
A &= X;
|
||||
continue;
|
||||
|
||||
case BPF_ALU|BPF_OR|BPF_X:
|
||||
A |= X;
|
||||
continue;
|
||||
|
||||
case BPF_ALU|BPF_XOR|BPF_X:
|
||||
A ^= X;
|
||||
continue;
|
||||
|
||||
case BPF_ALU|BPF_LSH|BPF_X:
|
||||
A <<= X;
|
||||
continue;
|
||||
|
||||
case BPF_ALU|BPF_RSH|BPF_X:
|
||||
A >>= X;
|
||||
continue;
|
||||
|
||||
case BPF_ALU|BPF_ADD|BPF_K:
|
||||
A += pc->k;
|
||||
continue;
|
||||
|
||||
case BPF_ALU|BPF_SUB|BPF_K:
|
||||
A -= pc->k;
|
||||
continue;
|
||||
|
||||
case BPF_ALU|BPF_MUL|BPF_K:
|
||||
A *= pc->k;
|
||||
continue;
|
||||
|
||||
case BPF_ALU|BPF_DIV|BPF_K:
|
||||
A /= pc->k;
|
||||
continue;
|
||||
|
||||
case BPF_ALU|BPF_MOD|BPF_K:
|
||||
A %= pc->k;
|
||||
continue;
|
||||
|
||||
case BPF_ALU|BPF_AND|BPF_K:
|
||||
A &= pc->k;
|
||||
continue;
|
||||
|
||||
case BPF_ALU|BPF_OR|BPF_K:
|
||||
A |= pc->k;
|
||||
continue;
|
||||
|
||||
case BPF_ALU|BPF_XOR|BPF_K:
|
||||
A ^= pc->k;
|
||||
continue;
|
||||
|
||||
case BPF_ALU|BPF_LSH|BPF_K:
|
||||
A <<= pc->k;
|
||||
continue;
|
||||
|
||||
case BPF_ALU|BPF_RSH|BPF_K:
|
||||
A >>= pc->k;
|
||||
continue;
|
||||
|
||||
case BPF_ALU|BPF_NEG:
|
||||
/*
|
||||
* Most BPF arithmetic is unsigned, but negation
|
||||
* can't be unsigned; throw some casts to
|
||||
* specify what we're trying to do.
|
||||
*/
|
||||
A = (u_int32)(-(int32)A);
|
||||
continue;
|
||||
|
||||
case BPF_MISC|BPF_TAX:
|
||||
X = A;
|
||||
continue;
|
||||
|
||||
case BPF_MISC|BPF_TXA:
|
||||
A = X;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
u_int
|
||||
bpf_filter(pc, p, wirelen, buflen)
|
||||
register const struct bpf_insn *pc;
|
||||
register const u_char *p;
|
||||
u_int wirelen;
|
||||
register u_int buflen;
|
||||
{
|
||||
return bpf_filter_with_aux_data(pc, p, wirelen, buflen, NULL);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Return true if the 'fcode' is a valid filter program.
|
||||
* The constraints are that each jump be forward and to a valid
|
||||
* code, that memory accesses are within valid ranges (to the
|
||||
* extent that this can be checked statically; loads of packet
|
||||
* data have to be, and are, also checked at run time), and that
|
||||
* the code terminates with either an accept or reject.
|
||||
*
|
||||
* The kernel needs to be able to verify an application's filter code.
|
||||
* Otherwise, a bogus program could easily crash the system.
|
||||
*/
|
||||
int
|
||||
bpf_validate(f, len)
|
||||
const struct bpf_insn *f;
|
||||
int len;
|
||||
{
|
||||
u_int i, from;
|
||||
const struct bpf_insn *p;
|
||||
|
||||
if (len < 1)
|
||||
return 0;
|
||||
/*
|
||||
* There's no maximum program length in userland.
|
||||
*/
|
||||
#if defined(KERNEL) || defined(_KERNEL)
|
||||
if (len > BPF_MAXINSNS)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
for (i = 0; i < (u_int)len; ++i) {
|
||||
p = &f[i];
|
||||
switch (BPF_CLASS(p->code)) {
|
||||
/*
|
||||
* Check that memory operations use valid addresses.
|
||||
*/
|
||||
case BPF_LD:
|
||||
case BPF_LDX:
|
||||
switch (BPF_MODE(p->code)) {
|
||||
case BPF_IMM:
|
||||
break;
|
||||
case BPF_ABS:
|
||||
case BPF_IND:
|
||||
case BPF_MSH:
|
||||
/*
|
||||
* There's no maximum packet data size
|
||||
* in userland. The runtime packet length
|
||||
* check suffices.
|
||||
*/
|
||||
#if defined(KERNEL) || defined(_KERNEL)
|
||||
/*
|
||||
* More strict check with actual packet length
|
||||
* is done runtime.
|
||||
*/
|
||||
if (p->k >= bpf_maxbufsize)
|
||||
return 0;
|
||||
#endif
|
||||
break;
|
||||
case BPF_MEM:
|
||||
if (p->k >= BPF_MEMWORDS)
|
||||
return 0;
|
||||
break;
|
||||
case BPF_LEN:
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case BPF_ST:
|
||||
case BPF_STX:
|
||||
if (p->k >= BPF_MEMWORDS)
|
||||
return 0;
|
||||
break;
|
||||
case BPF_ALU:
|
||||
switch (BPF_OP(p->code)) {
|
||||
case BPF_ADD:
|
||||
case BPF_SUB:
|
||||
case BPF_MUL:
|
||||
case BPF_OR:
|
||||
case BPF_AND:
|
||||
case BPF_XOR:
|
||||
case BPF_LSH:
|
||||
case BPF_RSH:
|
||||
case BPF_NEG:
|
||||
break;
|
||||
case BPF_DIV:
|
||||
case BPF_MOD:
|
||||
/*
|
||||
* Check for constant division or modulus
|
||||
* by 0.
|
||||
*/
|
||||
if (BPF_SRC(p->code) == BPF_K && p->k == 0)
|
||||
return 0;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case BPF_JMP:
|
||||
/*
|
||||
* Check that jumps are within the code block,
|
||||
* and that unconditional branches don't go
|
||||
* backwards as a result of an overflow.
|
||||
* Unconditional branches have a 32-bit offset,
|
||||
* so they could overflow; we check to make
|
||||
* sure they don't. Conditional branches have
|
||||
* an 8-bit offset, and the from address is <=
|
||||
* BPF_MAXINSNS, and we assume that BPF_MAXINSNS
|
||||
* is sufficiently small that adding 255 to it
|
||||
* won't overflow.
|
||||
*
|
||||
* We know that len is <= BPF_MAXINSNS, and we
|
||||
* assume that BPF_MAXINSNS is < the maximum size
|
||||
* of a u_int, so that i + 1 doesn't overflow.
|
||||
*
|
||||
* For userland, we don't know that the from
|
||||
* or len are <= BPF_MAXINSNS, but we know that
|
||||
* from <= len, and, except on a 64-bit system,
|
||||
* it's unlikely that len, if it truly reflects
|
||||
* the size of the program we've been handed,
|
||||
* will be anywhere near the maximum size of
|
||||
* a u_int. We also don't check for backward
|
||||
* branches, as we currently support them in
|
||||
* userland for the protochain operation.
|
||||
*/
|
||||
from = i + 1;
|
||||
switch (BPF_OP(p->code)) {
|
||||
case BPF_JA:
|
||||
#if defined(KERNEL) || defined(_KERNEL)
|
||||
if (from + p->k < from || from + p->k >= len)
|
||||
#else
|
||||
if (from + p->k >= (u_int)len)
|
||||
#endif
|
||||
return 0;
|
||||
break;
|
||||
case BPF_JEQ:
|
||||
case BPF_JGT:
|
||||
case BPF_JGE:
|
||||
case BPF_JSET:
|
||||
if (from + p->jt >= (u_int)len || from + p->jf >= (u_int)len)
|
||||
return 0;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case BPF_RET:
|
||||
break;
|
||||
case BPF_MISC:
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return BPF_CLASS(f[len - 1].code) == BPF_RET;
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1992, 1993, 1994, 1995, 1996
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <pcap.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void
|
||||
bpf_dump(const struct bpf_program *p, int option)
|
||||
{
|
||||
const struct bpf_insn *insn;
|
||||
int i;
|
||||
int n = p->bf_len;
|
||||
|
||||
insn = p->bf_insns;
|
||||
if (option > 2) {
|
||||
printf("%d\n", n);
|
||||
for (i = 0; i < n; ++insn, ++i) {
|
||||
printf("%u %u %u %u\n", insn->code,
|
||||
insn->jt, insn->jf, insn->k);
|
||||
}
|
||||
return ;
|
||||
}
|
||||
if (option > 1) {
|
||||
for (i = 0; i < n; ++insn, ++i)
|
||||
printf("{ 0x%x, %d, %d, 0x%08x },\n",
|
||||
insn->code, insn->jt, insn->jf, insn->k);
|
||||
return;
|
||||
}
|
||||
for (i = 0; i < n; ++insn, ++i) {
|
||||
#ifdef BDEBUG
|
||||
extern int bids[];
|
||||
if (bids[i] > 0)
|
||||
printf("[%02d]", bids[i] - 1);
|
||||
else
|
||||
printf(" -- ");
|
||||
#endif
|
||||
puts(bpf_image(insn, i));
|
||||
}
|
||||
}
|
Binary file not shown.
@ -1 +0,0 @@
|
||||
./bpf/net/bpf_filter.c
|
Binary file not shown.
@ -1,320 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1990, 1991, 1992, 1994, 1995, 1996
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <pcap-stdinc.h>
|
||||
#else /* _WIN32 */
|
||||
#if HAVE_INTTYPES_H
|
||||
#include <inttypes.h>
|
||||
#elif HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_BITYPES_H
|
||||
#include <sys/bitypes.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "pcap-int.h"
|
||||
|
||||
#ifdef HAVE_OS_PROTO_H
|
||||
#include "os-proto.h"
|
||||
#endif
|
||||
|
||||
char *
|
||||
bpf_image(p, n)
|
||||
const struct bpf_insn *p;
|
||||
int n;
|
||||
{
|
||||
int v;
|
||||
const char *fmt, *op;
|
||||
static char image[256];
|
||||
char operand[64];
|
||||
|
||||
v = p->k;
|
||||
switch (p->code) {
|
||||
|
||||
default:
|
||||
op = "unimp";
|
||||
fmt = "0x%x";
|
||||
v = p->code;
|
||||
break;
|
||||
|
||||
case BPF_RET|BPF_K:
|
||||
op = "ret";
|
||||
fmt = "#%d";
|
||||
break;
|
||||
|
||||
case BPF_RET|BPF_A:
|
||||
op = "ret";
|
||||
fmt = "";
|
||||
break;
|
||||
|
||||
case BPF_LD|BPF_W|BPF_ABS:
|
||||
op = "ld";
|
||||
fmt = "[%d]";
|
||||
break;
|
||||
|
||||
case BPF_LD|BPF_H|BPF_ABS:
|
||||
op = "ldh";
|
||||
fmt = "[%d]";
|
||||
break;
|
||||
|
||||
case BPF_LD|BPF_B|BPF_ABS:
|
||||
op = "ldb";
|
||||
fmt = "[%d]";
|
||||
break;
|
||||
|
||||
case BPF_LD|BPF_W|BPF_LEN:
|
||||
op = "ld";
|
||||
fmt = "#pktlen";
|
||||
break;
|
||||
|
||||
case BPF_LD|BPF_W|BPF_IND:
|
||||
op = "ld";
|
||||
fmt = "[x + %d]";
|
||||
break;
|
||||
|
||||
case BPF_LD|BPF_H|BPF_IND:
|
||||
op = "ldh";
|
||||
fmt = "[x + %d]";
|
||||
break;
|
||||
|
||||
case BPF_LD|BPF_B|BPF_IND:
|
||||
op = "ldb";
|
||||
fmt = "[x + %d]";
|
||||
break;
|
||||
|
||||
case BPF_LD|BPF_IMM:
|
||||
op = "ld";
|
||||
fmt = "#0x%x";
|
||||
break;
|
||||
|
||||
case BPF_LDX|BPF_IMM:
|
||||
op = "ldx";
|
||||
fmt = "#0x%x";
|
||||
break;
|
||||
|
||||
case BPF_LDX|BPF_MSH|BPF_B:
|
||||
op = "ldxb";
|
||||
fmt = "4*([%d]&0xf)";
|
||||
break;
|
||||
|
||||
case BPF_LD|BPF_MEM:
|
||||
op = "ld";
|
||||
fmt = "M[%d]";
|
||||
break;
|
||||
|
||||
case BPF_LDX|BPF_MEM:
|
||||
op = "ldx";
|
||||
fmt = "M[%d]";
|
||||
break;
|
||||
|
||||
case BPF_ST:
|
||||
op = "st";
|
||||
fmt = "M[%d]";
|
||||
break;
|
||||
|
||||
case BPF_STX:
|
||||
op = "stx";
|
||||
fmt = "M[%d]";
|
||||
break;
|
||||
|
||||
case BPF_JMP|BPF_JA:
|
||||
op = "ja";
|
||||
fmt = "%d";
|
||||
v = n + 1 + p->k;
|
||||
break;
|
||||
|
||||
case BPF_JMP|BPF_JGT|BPF_K:
|
||||
op = "jgt";
|
||||
fmt = "#0x%x";
|
||||
break;
|
||||
|
||||
case BPF_JMP|BPF_JGE|BPF_K:
|
||||
op = "jge";
|
||||
fmt = "#0x%x";
|
||||
break;
|
||||
|
||||
case BPF_JMP|BPF_JEQ|BPF_K:
|
||||
op = "jeq";
|
||||
fmt = "#0x%x";
|
||||
break;
|
||||
|
||||
case BPF_JMP|BPF_JSET|BPF_K:
|
||||
op = "jset";
|
||||
fmt = "#0x%x";
|
||||
break;
|
||||
|
||||
case BPF_JMP|BPF_JGT|BPF_X:
|
||||
op = "jgt";
|
||||
fmt = "x";
|
||||
break;
|
||||
|
||||
case BPF_JMP|BPF_JGE|BPF_X:
|
||||
op = "jge";
|
||||
fmt = "x";
|
||||
break;
|
||||
|
||||
case BPF_JMP|BPF_JEQ|BPF_X:
|
||||
op = "jeq";
|
||||
fmt = "x";
|
||||
break;
|
||||
|
||||
case BPF_JMP|BPF_JSET|BPF_X:
|
||||
op = "jset";
|
||||
fmt = "x";
|
||||
break;
|
||||
|
||||
case BPF_ALU|BPF_ADD|BPF_X:
|
||||
op = "add";
|
||||
fmt = "x";
|
||||
break;
|
||||
|
||||
case BPF_ALU|BPF_SUB|BPF_X:
|
||||
op = "sub";
|
||||
fmt = "x";
|
||||
break;
|
||||
|
||||
case BPF_ALU|BPF_MUL|BPF_X:
|
||||
op = "mul";
|
||||
fmt = "x";
|
||||
break;
|
||||
|
||||
case BPF_ALU|BPF_DIV|BPF_X:
|
||||
op = "div";
|
||||
fmt = "x";
|
||||
break;
|
||||
|
||||
case BPF_ALU|BPF_MOD|BPF_X:
|
||||
op = "mod";
|
||||
fmt = "x";
|
||||
break;
|
||||
|
||||
case BPF_ALU|BPF_AND|BPF_X:
|
||||
op = "and";
|
||||
fmt = "x";
|
||||
break;
|
||||
|
||||
case BPF_ALU|BPF_OR|BPF_X:
|
||||
op = "or";
|
||||
fmt = "x";
|
||||
break;
|
||||
|
||||
case BPF_ALU|BPF_XOR|BPF_X:
|
||||
op = "xor";
|
||||
fmt = "x";
|
||||
break;
|
||||
|
||||
case BPF_ALU|BPF_LSH|BPF_X:
|
||||
op = "lsh";
|
||||
fmt = "x";
|
||||
break;
|
||||
|
||||
case BPF_ALU|BPF_RSH|BPF_X:
|
||||
op = "rsh";
|
||||
fmt = "x";
|
||||
break;
|
||||
|
||||
case BPF_ALU|BPF_ADD|BPF_K:
|
||||
op = "add";
|
||||
fmt = "#%d";
|
||||
break;
|
||||
|
||||
case BPF_ALU|BPF_SUB|BPF_K:
|
||||
op = "sub";
|
||||
fmt = "#%d";
|
||||
break;
|
||||
|
||||
case BPF_ALU|BPF_MUL|BPF_K:
|
||||
op = "mul";
|
||||
fmt = "#%d";
|
||||
break;
|
||||
|
||||
case BPF_ALU|BPF_DIV|BPF_K:
|
||||
op = "div";
|
||||
fmt = "#%d";
|
||||
break;
|
||||
|
||||
case BPF_ALU|BPF_MOD|BPF_K:
|
||||
op = "mod";
|
||||
fmt = "#%d";
|
||||
break;
|
||||
|
||||
case BPF_ALU|BPF_AND|BPF_K:
|
||||
op = "and";
|
||||
fmt = "#0x%x";
|
||||
break;
|
||||
|
||||
case BPF_ALU|BPF_OR|BPF_K:
|
||||
op = "or";
|
||||
fmt = "#0x%x";
|
||||
break;
|
||||
|
||||
case BPF_ALU|BPF_XOR|BPF_K:
|
||||
op = "xor";
|
||||
fmt = "#0x%x";
|
||||
break;
|
||||
|
||||
case BPF_ALU|BPF_LSH|BPF_K:
|
||||
op = "lsh";
|
||||
fmt = "#%d";
|
||||
break;
|
||||
|
||||
case BPF_ALU|BPF_RSH|BPF_K:
|
||||
op = "rsh";
|
||||
fmt = "#%d";
|
||||
break;
|
||||
|
||||
case BPF_ALU|BPF_NEG:
|
||||
op = "neg";
|
||||
fmt = "";
|
||||
break;
|
||||
|
||||
case BPF_MISC|BPF_TAX:
|
||||
op = "tax";
|
||||
fmt = "";
|
||||
break;
|
||||
|
||||
case BPF_MISC|BPF_TXA:
|
||||
op = "txa";
|
||||
fmt = "";
|
||||
break;
|
||||
}
|
||||
(void)pcap_snprintf(operand, sizeof operand, fmt, v);
|
||||
if (BPF_CLASS(p->code) == BPF_JMP && BPF_OP(p->code) != BPF_JA) {
|
||||
(void)pcap_snprintf(image, sizeof image,
|
||||
"(%03d) %-8s %-16s jt %d\tjf %d",
|
||||
n, op, operand, n + 1 + p->jt, n + 1 + p->jf);
|
||||
} else {
|
||||
(void)pcap_snprintf(image, sizeof image,
|
||||
"(%03d) %-8s %s",
|
||||
n, op, operand);
|
||||
}
|
||||
return image;
|
||||
}
|
Binary file not shown.
@ -1,19 +0,0 @@
|
||||
#! /bin/sh
|
||||
|
||||
#
|
||||
# Unfortunately, Mac OS X's devfs is based on the old FreeBSD
|
||||
# one, not the current one, so there's no way to configure it
|
||||
# to create BPF devices with particular owners or groups.
|
||||
# This startup item will make it owned by the admin group,
|
||||
# with permissions rw-rw----, so that anybody in the admin
|
||||
# group can use programs that capture or send raw packets.
|
||||
#
|
||||
# Change this as appropriate for your site, e.g. to make
|
||||
# it owned by a particular user without changing the permissions,
|
||||
# so only that user and the super-user can capture or send raw
|
||||
# packets, or give it the permissions rw-r-----, so that
|
||||
# only the super-user can send raw packets but anybody in the
|
||||
# admin group can capture packets.
|
||||
#
|
||||
chgrp admin /dev/bpf*
|
||||
chmod g+rw /dev/bpf*
|
@ -1,55 +0,0 @@
|
||||
if( NOT LIBPCAP_PRECONFIGURED )
|
||||
set( LIBPCAP_PRECONFIGURED TRUE )
|
||||
|
||||
###################################################################
|
||||
# Parameters
|
||||
###################################################################
|
||||
|
||||
option (USE_STATIC_RT "Use static Runtime" ON)
|
||||
|
||||
######################################
|
||||
# Project setings
|
||||
######################################
|
||||
|
||||
add_definitions( -DBUILDING_PCAP )
|
||||
|
||||
if( MSVC )
|
||||
add_definitions( -D__STDC__ )
|
||||
add_definitions( -D_CRT_SECURE_NO_WARNINGS )
|
||||
add_definitions( "-D_U_=" )
|
||||
elseif( CMAKE_COMPILER_IS_GNUCXX )
|
||||
add_definitions( "-D_U_=__attribute__((unused))" )
|
||||
else(MSVC)
|
||||
add_definitions( "-D_U_=" )
|
||||
endif( MSVC )
|
||||
|
||||
if (USE_STATIC_RT)
|
||||
MESSAGE( STATUS "Use STATIC runtime" )
|
||||
|
||||
if( MSVC )
|
||||
set (CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MT")
|
||||
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MT")
|
||||
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
|
||||
|
||||
set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MT")
|
||||
set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MT")
|
||||
set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
|
||||
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
|
||||
endif( MSVC )
|
||||
else (USE_STATIC_RT)
|
||||
MESSAGE( STATUS "Use DYNAMIC runtime" )
|
||||
|
||||
if( MSVC )
|
||||
set (CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MD")
|
||||
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MD")
|
||||
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD")
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")
|
||||
|
||||
set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MD")
|
||||
set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MD")
|
||||
set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MD")
|
||||
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MDd")
|
||||
endif( MSVC )
|
||||
endif (USE_STATIC_RT)
|
||||
endif( NOT LIBPCAP_PRECONFIGURED )
|
@ -1,345 +0,0 @@
|
||||
/* cmakeconfig.h.in */
|
||||
|
||||
/* Enable optimizer debugging */
|
||||
#cmakedefine BDEBUG 1
|
||||
|
||||
/* define if you have a cloning BPF device */
|
||||
#cmakedefine HAVE_CLONING_BPF 1
|
||||
|
||||
/* define if you have the DAG API */
|
||||
#cmakedefine HAVE_DAG_API 1
|
||||
|
||||
/* define if you have dag_get_erf_types() */
|
||||
#cmakedefine HAVE_DAG_GET_ERF_TYPES 1
|
||||
|
||||
/* define if you have dag_get_stream_erf_types() */
|
||||
#cmakedefine HAVE_DAG_GET_STREAM_ERF_TYPES 1
|
||||
|
||||
/* define if you have streams capable DAG API */
|
||||
#cmakedefine HAVE_DAG_STREAMS_API 1
|
||||
|
||||
/* define if you have vdag_set_device_info() */
|
||||
#cmakedefine HAVE_DAG_VDAG 1
|
||||
|
||||
/* Define to 1 if you have the declaration of `ether_hostton', and to 0 if you
|
||||
don't. */
|
||||
#cmakedefine HAVE_DECL_ETHER_HOSTTON 1
|
||||
|
||||
/* define if you have a /dev/dlpi */
|
||||
#cmakedefine HAVE_DEV_DLPI 1
|
||||
|
||||
/* if passive_req_t primitive exists */
|
||||
#cmakedefine HAVE_DLPI_PASSIVE 1
|
||||
|
||||
/* Define to 1 if you have the `ether_hostton' function. */
|
||||
#cmakedefine HAVE_ETHER_HOSTTON 1
|
||||
|
||||
/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
|
||||
#cmakedefine HAVE_FSEEKO 1
|
||||
|
||||
/* on HP-UX 10.20 or later */
|
||||
#cmakedefine HAVE_HPUX10_20_OR_LATER 1
|
||||
|
||||
/* on HP-UX 9.x */
|
||||
#cmakedefine HAVE_HPUX9 1
|
||||
|
||||
/* if ppa_info_t_dl_module_id exists */
|
||||
#cmakedefine HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#cmakedefine HAVE_INTTYPES_H 1
|
||||
|
||||
/* if libdlpi exists */
|
||||
#cmakedefine HAVE_LIBDLPI 1
|
||||
|
||||
/* if libnl exists */
|
||||
#cmakedefine HAVE_LIBNL 1
|
||||
|
||||
/* if libnl exists and is version 2.x */
|
||||
#cmakedefine HAVE_LIBNL_2_x 1
|
||||
|
||||
/* if libnl exists and is version 3.x */
|
||||
#cmakedefine HAVE_LIBNL_3_x 1
|
||||
|
||||
/* libnl has NLE_FAILURE */
|
||||
#cmakedefine HAVE_LIBNL_NLE 1
|
||||
|
||||
/* libnl has new-style socket api */
|
||||
#cmakedefine HAVE_LIBNL_SOCKETS 1
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#cmakedefine HAVE_LIMITS_H 1
|
||||
|
||||
/* Define to 1 if you have the <linux/compiler.h> header file. */
|
||||
#cmakedefine HAVE_LINUX_COMPILER_H 1
|
||||
|
||||
/* Define to 1 if you have the <linux/ethtool.h> header file. */
|
||||
#cmakedefine HAVE_LINUX_ETHTOOL_H 1
|
||||
|
||||
/* Define to 1 if you have the <linux/if_bonding.h> header file. */
|
||||
#cmakedefine HAVE_LINUX_IF_BONDING_H 1
|
||||
|
||||
/* Define to 1 if you have the <linux/if_packet.h> header file. */
|
||||
#cmakedefine HAVE_LINUX_IF_PACKET_H 1
|
||||
|
||||
/* Define to 1 if you have the <linux/net_tstamp.h> header file. */
|
||||
#cmakedefine HAVE_LINUX_NET_TSTAMP_H 1
|
||||
|
||||
/* Define to 1 if you have the <linux/sockios.h> header file. */
|
||||
#cmakedefine HAVE_LINUX_SOCKIOS_H 1
|
||||
|
||||
/* if tp_vlan_tci exists */
|
||||
#cmakedefine HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI 1
|
||||
|
||||
/* Define to 1 if you have the <linux/types.h> header file. */
|
||||
#cmakedefine HAVE_LINUX_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <linux/usbdevice_fs.h> header file. */
|
||||
#cmakedefine HAVE_LINUX_USBDEVICE_FS_H 1
|
||||
|
||||
/* Define to 1 if you have the <linux/wireless.h> header file. */
|
||||
#cmakedefine HAVE_LINUX_WIRELESS_H 1
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#cmakedefine HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the <netinet/ether.h> header file. */
|
||||
#cmakedefine HAVE_NETINET_ETHER_H 1
|
||||
|
||||
/* Define to 1 if you have the <netinet/if_ether.h> header file. */
|
||||
#cmakedefine HAVE_NETINET_IF_ETHER_H 1
|
||||
|
||||
/* Define to 1 if you have the <netpacket/if_packet.h> header file. */
|
||||
#cmakedefine HAVE_NETPACKET_IF_PACKET_H 1
|
||||
|
||||
/* Define to 1 if you have the <netpacket/packet.h> header file. */
|
||||
#cmakedefine HAVE_NETPACKET_PACKET_H 1
|
||||
|
||||
/* Define to 1 if you have the <net/if_media.h> header file. */
|
||||
#cmakedefine HAVE_NET_IF_MEDIA_H 1
|
||||
|
||||
/* Define to 1 if you have the <net/pfvar.h> header file. */
|
||||
#cmakedefine HAVE_NET_PFVAR_H 1
|
||||
|
||||
/* if there's an os_proto.h for this platform, to use additional prototypes */
|
||||
#cmakedefine HAVE_OS_PROTO_H 1
|
||||
|
||||
/* Define to 1 if remote packet capture is to be supported */
|
||||
#cmakedefine HAVE_REMOTE 1
|
||||
|
||||
/* Define to 1 if you have the <paths.h> header file. */
|
||||
#cmakedefine HAVE_PATHS_H 1
|
||||
|
||||
/* define if net/pfvar.h defines PF_NAT through PF_NORDR */
|
||||
#cmakedefine HAVE_PF_NAT_THROUGH_PF_NORDR 1
|
||||
|
||||
/* define if you have the Septel API */
|
||||
#cmakedefine HAVE_SEPTEL_API 1
|
||||
|
||||
/* define if you have the Myricom SNF API */
|
||||
#cmakedefine HAVE_SNF_API 1
|
||||
|
||||
/* Define to 1 if you have the `snprintf' function. */
|
||||
#cmakedefine HAVE_SNPRINTF 1
|
||||
|
||||
/* if struct sockaddr has the sa_len member */
|
||||
#cmakedefine HAVE_SOCKADDR_SA_LEN 1
|
||||
|
||||
/* if struct sockaddr_storage exists */
|
||||
#cmakedefine HAVE_SOCKADDR_STORAGE 1
|
||||
|
||||
/* define if socklen_t is defined */
|
||||
#cmakedefine HAVE_SOCKLEN_T 1
|
||||
|
||||
/* On solaris */
|
||||
#cmakedefine HAVE_SOLARIS 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#cmakedefine HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#cmakedefine HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the `strerror' function. */
|
||||
#cmakedefine HAVE_STRERROR 1
|
||||
|
||||
/* Define to 1 if you have the `strlcpy' function. */
|
||||
#cmakedefine HAVE_STRLCPY 1
|
||||
|
||||
/* Define to 1 if the system has the type `struct BPF_TIMEVAL'. */
|
||||
#cmakedefine HAVE_STRUCT_BPF_TIMEVAL 1
|
||||
|
||||
/* Define to 1 if the system has the type `struct ether_addr'. */
|
||||
#cmakedefine HAVE_STRUCT_ETHER_ADDR 1
|
||||
|
||||
/* Define to 1 if you have the <sys/bitypes.h> header file. */
|
||||
#cmakedefine HAVE_SYS_BITYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/bufmod.h> header file. */
|
||||
#cmakedefine HAVE_SYS_BUFMOD_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/dlpi_ext.h> header file. */
|
||||
#cmakedefine HAVE_SYS_DLPI_EXT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/ioccom.h> header file. */
|
||||
#cmakedefine HAVE_SYS_IOCCOM_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/sockio.h> header file. */
|
||||
#cmakedefine HAVE_SYS_SOCKIO_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#cmakedefine HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#cmakedefine HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* define if you have the TurboCap API */
|
||||
#cmakedefine HAVE_TC_API 1
|
||||
|
||||
/* if if_packet.h has tpacket_stats defined */
|
||||
#cmakedefine HAVE_TPACKET_STATS 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#cmakedefine HAVE_UNISTD_H 1
|
||||
|
||||
/* if struct usbdevfs_ctrltransfer has bRequestType */
|
||||
#cmakedefine HAVE_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE 1
|
||||
|
||||
/* Define to 1 if you have the `vsnprintf' function. */
|
||||
#cmakedefine HAVE_VSNPRINTF 1
|
||||
|
||||
/* Define to 1 if you have the `PacketIsLoopbackAdapter' function. */
|
||||
#cmakedefine HAVE_PACKET_IS_LOOPBACK_ADAPTER 1
|
||||
|
||||
/* define if the system supports zerocopy BPF */
|
||||
#cmakedefine HAVE_ZEROCOPY_BPF 1
|
||||
|
||||
/* define if your compiler has __attribute__ */
|
||||
#cmakedefine HAVE___ATTRIBUTE__ 1
|
||||
|
||||
/* IPv6 */
|
||||
#cmakedefine INET6 1
|
||||
|
||||
/* if unaligned access fails */
|
||||
#cmakedefine LBL_ALIGN 1
|
||||
|
||||
/* path for device for USB sniffing */
|
||||
#cmakedefine LINUX_USB_MON_DEV 1
|
||||
|
||||
/* if we need a pcap_parse wrapper around yyparse */
|
||||
#cmakedefine NEED_YYPARSE_WRAPPER 1
|
||||
|
||||
/* Define to 1 if netinet/ether.h declares `ether_hostton' */
|
||||
#cmakedefine NETINET_ETHER_H_DECLARES_ETHER_HOSTTON 1
|
||||
|
||||
/* Define to 1 if netinet/if_ether.h declares `ether_hostton' */
|
||||
#cmakedefine NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON 1
|
||||
|
||||
/* do not use protochain */
|
||||
#cmakedefine NO_PROTOCHAIN 1
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#cmakedefine PACKAGE_BUGREPORT 1
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#cmakedefine PACKAGE_NAME 1
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#cmakedefine PACKAGE_STRING 1
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#cmakedefine PACKAGE_TARNAME 1
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#cmakedefine PACKAGE_URL 1
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#cmakedefine PACKAGE_VERSION 1
|
||||
|
||||
/* /dev/dlpi directory */
|
||||
#cmakedefine PCAP_DEV_PREFIX 1
|
||||
|
||||
/* target host supports Bluetooth sniffing */
|
||||
#cmakedefine PCAP_SUPPORT_BT 1
|
||||
|
||||
/* target host supports Bluetooth Monitor */
|
||||
#cmakedefine PCAP_SUPPORT_BT_MONITOR 1
|
||||
|
||||
/* support D-Bus sniffing */
|
||||
#cmakedefine PCAP_SUPPORT_DBUS 1
|
||||
|
||||
/* target host supports netfilter sniffing */
|
||||
#cmakedefine PCAP_SUPPORT_NETFILTER 1
|
||||
|
||||
/* use Linux packet ring capture if available */
|
||||
#cmakedefine PCAP_SUPPORT_PACKET_RING 1
|
||||
|
||||
/* target host supports USB sniffing */
|
||||
#cmakedefine PCAP_SUPPORT_USB 1
|
||||
|
||||
/* include ACN support */
|
||||
#cmakedefine SITA 1
|
||||
|
||||
/* if struct sockaddr_hci has hci_channel member */
|
||||
#cmakedefine SOCKADDR_HCI_HAS_HCI_CHANNEL 1
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#cmakedefine STDC_HEADERS 1
|
||||
|
||||
/* Enable parser debugging */
|
||||
#cmakedefine YYDEBUG 1
|
||||
|
||||
/* Enable large inode numbers on Mac OS X 10.5. */
|
||||
#ifndef _DARWIN_USE_64_BIT_INODE
|
||||
# define _DARWIN_USE_64_BIT_INODE 1
|
||||
#endif
|
||||
|
||||
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||
#cmakedefine _FILE_OFFSET_BITS 1
|
||||
|
||||
/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
|
||||
#cmakedefine _LARGEFILE_SOURCE 1
|
||||
|
||||
/* Define for large files, on AIX-style hosts. */
|
||||
#cmakedefine _LARGE_FILES 1
|
||||
|
||||
/* define on AIX to get certain functions */
|
||||
#cmakedefine _SUN 1
|
||||
|
||||
/* define if your compiler allows __attribute__((format)) without a warning */
|
||||
#cmakedefine __ATTRIBUTE___FORMAT_OK 1
|
||||
|
||||
#if 0
|
||||
/* to handle Ultrix compilers that don't support const in prototypes */
|
||||
#cmakedefine const 1
|
||||
|
||||
/* Define as token for inline if inlining supported */
|
||||
#cmakedefine inline 1
|
||||
|
||||
/* Define to `short' if int16_t not defined. */
|
||||
#cmakedefine int16_t 1
|
||||
|
||||
/* Define to `int' if int32_t not defined. */
|
||||
#cmakedefine int32_t 1
|
||||
|
||||
/* Define to `long long' if int64_t not defined. */
|
||||
#cmakedefine int64_t 1
|
||||
|
||||
/* Define to `signed char' if int8_t not defined. */
|
||||
#cmakedefine int8_t 1
|
||||
|
||||
/* on sinix */
|
||||
#cmakedefine sinix 1
|
||||
|
||||
/* Define to `unsigned short' if u_int16_t not defined. */
|
||||
#cmakedefine u_int16_t 1
|
||||
|
||||
/* Define to `unsigned int' if u_int32_t not defined. */
|
||||
#cmakedefine u_int32_t 1
|
||||
|
||||
/* Define to `unsigned long long' if u_int64_t not defined. */
|
||||
#cmakedefine u_int64_t 1
|
||||
|
||||
/* Define to `unsigned char' if u_int8_t not defined. */
|
||||
#cmakedefine u_int8_t 1
|
||||
#endif
|
1435
libpcap-1.8.1/config.guess
vendored
1435
libpcap-1.8.1/config.guess
vendored
File diff suppressed because it is too large
Load Diff
@ -1,348 +0,0 @@
|
||||
/* config.h. Generated from config.h.in by configure. */
|
||||
/* config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Enable optimizer debugging */
|
||||
/* #undef BDEBUG */
|
||||
|
||||
/* define if you have a cloning BPF device */
|
||||
/* #undef HAVE_CLONING_BPF */
|
||||
|
||||
/* define if you have the DAG API */
|
||||
/* #undef HAVE_DAG_API */
|
||||
|
||||
/* define if you have dag_get_erf_types() */
|
||||
/* #undef HAVE_DAG_GET_ERF_TYPES */
|
||||
|
||||
/* define if you have dag_get_stream_erf_types() */
|
||||
/* #undef HAVE_DAG_GET_STREAM_ERF_TYPES */
|
||||
|
||||
/* 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. */
|
||||
#define HAVE_DECL_ETHER_HOSTTON 1
|
||||
|
||||
/* define if you have a /dev/dlpi */
|
||||
/* #undef HAVE_DEV_DLPI */
|
||||
|
||||
/* if passive_req_t primitive exists */
|
||||
/* #undef HAVE_DLPI_PASSIVE */
|
||||
|
||||
/* Define to 1 if you have the `ether_hostton' function. */
|
||||
#define HAVE_ETHER_HOSTTON 1
|
||||
|
||||
/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
|
||||
#define HAVE_FSEEKO 1
|
||||
|
||||
/* on HP-UX 10.20 or later */
|
||||
/* #undef HAVE_HPUX10_20_OR_LATER */
|
||||
|
||||
/* on HP-UX 9.x */
|
||||
/* #undef HAVE_HPUX9 */
|
||||
|
||||
/* if ppa_info_t_dl_module_id exists */
|
||||
/* #undef HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1 */
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* if libdlpi exists */
|
||||
/* #undef HAVE_LIBDLPI */
|
||||
|
||||
/* if libnl exists */
|
||||
/* #undef HAVE_LIBNL */
|
||||
|
||||
/* if libnl exists and is version 2.x */
|
||||
/* #undef HAVE_LIBNL_2_x */
|
||||
|
||||
/* if libnl exists and is version 3.x */
|
||||
/* #undef HAVE_LIBNL_3_x */
|
||||
|
||||
/* libnl has NLE_FAILURE */
|
||||
/* #undef HAVE_LIBNL_NLE */
|
||||
|
||||
/* libnl has new-style socket api */
|
||||
/* #undef HAVE_LIBNL_SOCKETS */
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#define HAVE_LIMITS_H 1
|
||||
|
||||
/* 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. */
|
||||
#define HAVE_LINUX_ETHTOOL_H 1
|
||||
|
||||
/* Define to 1 if you have the <linux/if_bonding.h> header file. */
|
||||
#define HAVE_LINUX_IF_BONDING_H 1
|
||||
|
||||
/* Define to 1 if you have the <linux/if_packet.h> header file. */
|
||||
#define HAVE_LINUX_IF_PACKET_H 1
|
||||
|
||||
/* Define to 1 if you have the <linux/net_tstamp.h> header file. */
|
||||
#define HAVE_LINUX_NET_TSTAMP_H 1
|
||||
|
||||
/* Define to 1 if you have the <linux/sockios.h> header file. */
|
||||
#define HAVE_LINUX_SOCKIOS_H 1
|
||||
|
||||
/* if tp_vlan_tci exists */
|
||||
#define HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI 1
|
||||
|
||||
/* Define to 1 if you have the <linux/types.h> header file. */
|
||||
#define HAVE_LINUX_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <linux/usbdevice_fs.h> header file. */
|
||||
#define HAVE_LINUX_USBDEVICE_FS_H 1
|
||||
|
||||
/* Define to 1 if you have the <linux/wireless.h> header file. */
|
||||
#define HAVE_LINUX_WIRELESS_H 1
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the <netinet/ether.h> header file. */
|
||||
#define HAVE_NETINET_ETHER_H 1
|
||||
|
||||
/* Define to 1 if you have the <netinet/if_ether.h> header file. */
|
||||
#define HAVE_NETINET_IF_ETHER_H 1
|
||||
|
||||
/* 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. */
|
||||
#define HAVE_NETPACKET_PACKET_H 1
|
||||
|
||||
/* Define to 1 if you have the <net/if_media.h> header file. */
|
||||
/* #undef HAVE_NET_IF_MEDIA_H */
|
||||
|
||||
/* Define to 1 if you have the <net/pfvar.h> header file. */
|
||||
/* #undef HAVE_NET_PFVAR_H */
|
||||
|
||||
/* if there's an os_proto.h for this platform, to use additional prototypes */
|
||||
/* #undef HAVE_OS_PROTO_H */
|
||||
|
||||
/* define if net/pfvar.h defines PF_NAT through PF_NORDR */
|
||||
/* #undef HAVE_PF_NAT_THROUGH_PF_NORDR */
|
||||
|
||||
/* define if you have the Septel API */
|
||||
/* #undef HAVE_SEPTEL_API */
|
||||
|
||||
/* define if you have the Myricom SNF API */
|
||||
/* #undef HAVE_SNF_API */
|
||||
|
||||
/* Define to 1 if you have the `snprintf' function. */
|
||||
#define HAVE_SNPRINTF 1
|
||||
|
||||
/* if struct sockaddr has the sa_len member */
|
||||
/* #undef HAVE_SOCKADDR_SA_LEN */
|
||||
|
||||
/* if struct sockaddr_storage exists */
|
||||
#define HAVE_SOCKADDR_STORAGE 1
|
||||
|
||||
/* define if socklen_t is defined */
|
||||
#define HAVE_SOCKLEN_T 1
|
||||
|
||||
/* On solaris */
|
||||
/* #undef HAVE_SOLARIS */
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the `strerror' function. */
|
||||
#define HAVE_STRERROR 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the `strlcpy' function. */
|
||||
/* #undef HAVE_STRLCPY */
|
||||
|
||||
/* Define to 1 if you have the `strtok_r' function. */
|
||||
#define HAVE_STRTOK_R 1
|
||||
|
||||
/* Define to 1 if the system has the type `struct BPF_TIMEVAL'. */
|
||||
/* #undef HAVE_STRUCT_BPF_TIMEVAL */
|
||||
|
||||
/* Define to 1 if the system has the type `struct ether_addr'. */
|
||||
/* #undef HAVE_STRUCT_ETHER_ADDR */
|
||||
|
||||
/* Define to 1 if you have the <sys/bitypes.h> header file. */
|
||||
#define HAVE_SYS_BITYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/bufmod.h> header file. */
|
||||
/* #undef HAVE_SYS_BUFMOD_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/dlpi_ext.h> header file. */
|
||||
/* #undef HAVE_SYS_DLPI_EXT_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/ioccom.h> header file. */
|
||||
/* #undef HAVE_SYS_IOCCOM_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/select.h> header file. */
|
||||
#define HAVE_SYS_SELECT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/sockio.h> header file. */
|
||||
/* #undef HAVE_SYS_SOCKIO_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* define if you have the TurboCap API */
|
||||
/* #undef HAVE_TC_API */
|
||||
|
||||
/* if if_packet.h has tpacket_stats defined */
|
||||
#define HAVE_TPACKET_STATS 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* if struct usbdevfs_ctrltransfer has bRequestType */
|
||||
#define HAVE_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE 1
|
||||
|
||||
/* Define to 1 if you have the `vsnprintf' function. */
|
||||
#define HAVE_VSNPRINTF 1
|
||||
|
||||
/* define if the system supports zerocopy BPF */
|
||||
/* #undef HAVE_ZEROCOPY_BPF */
|
||||
|
||||
/* define if your compiler has __attribute__ */
|
||||
#define HAVE___ATTRIBUTE__ 1
|
||||
|
||||
/* IPv6 */
|
||||
#define INET6 1
|
||||
|
||||
/* if unaligned access fails */
|
||||
#define LBL_ALIGN 1
|
||||
|
||||
/* path for device for USB sniffing */
|
||||
#define LINUX_USB_MON_DEV "/dev/usbmon"
|
||||
|
||||
/* Define to 1 if netinet/ether.h declares `ether_hostton' */
|
||||
#define NETINET_ETHER_H_DECLARES_ETHER_HOSTTON /**/
|
||||
|
||||
/* Define to 1 if netinet/if_ether.h declares `ether_hostton' */
|
||||
/* #undef NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON */
|
||||
|
||||
/* do not use protochain */
|
||||
/* #undef NO_PROTOCHAIN */
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT ""
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME ""
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING ""
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME ""
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#define PACKAGE_URL ""
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION ""
|
||||
|
||||
/* /dev/dlpi directory */
|
||||
/* #undef PCAP_DEV_PREFIX */
|
||||
|
||||
/* target host supports Bluetooth sniffing */
|
||||
#define PCAP_SUPPORT_BT 1
|
||||
|
||||
/* target host supports Bluetooth Monitor */
|
||||
#define PCAP_SUPPORT_BT_MONITOR /**/
|
||||
|
||||
/* support D-Bus sniffing */
|
||||
/* #undef PCAP_SUPPORT_DBUS */
|
||||
|
||||
/* target host supports netfilter sniffing */
|
||||
#define PCAP_SUPPORT_NETFILTER 1
|
||||
|
||||
/* use Linux packet ring capture if available */
|
||||
#define PCAP_SUPPORT_PACKET_RING 1
|
||||
|
||||
/* target host supports USB sniffing */
|
||||
#define PCAP_SUPPORT_USB 1
|
||||
|
||||
/* include ACN support */
|
||||
/* #undef SITA */
|
||||
|
||||
/* if struct sockaddr_hci has hci_channel member */
|
||||
#define SOCKADDR_HCI_HAS_HCI_CHANNEL /**/
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Enable parser debugging */
|
||||
/* #undef YYDEBUG */
|
||||
|
||||
/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
|
||||
`char[]'. */
|
||||
/* #undef YYTEXT_POINTER */
|
||||
|
||||
/* Enable large inode numbers on Mac OS X 10.5. */
|
||||
#ifndef _DARWIN_USE_64_BIT_INODE
|
||||
# define _DARWIN_USE_64_BIT_INODE 1
|
||||
#endif
|
||||
|
||||
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
|
||||
/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
|
||||
/* #undef _LARGEFILE_SOURCE */
|
||||
|
||||
/* Define for large files, on AIX-style hosts. */
|
||||
/* #undef _LARGE_FILES */
|
||||
|
||||
/* define on AIX to get certain functions */
|
||||
/* #undef _SUN */
|
||||
|
||||
/* define if your compiler allows __attribute__((format)) without a warning */
|
||||
#define __ATTRIBUTE___FORMAT_OK 1
|
||||
|
||||
/* to handle Ultrix compilers that don't support const in prototypes */
|
||||
/* #undef const */
|
||||
|
||||
/* Define as token for inline if inlining supported */
|
||||
#define inline inline
|
||||
|
||||
/* Define to `short' if int16_t not defined. */
|
||||
/* #undef int16_t */
|
||||
|
||||
/* Define to `int' if int32_t not defined. */
|
||||
/* #undef int32_t */
|
||||
|
||||
/* Define to `long long' if int64_t not defined. */
|
||||
/* #undef int64_t */
|
||||
|
||||
/* Define to `signed char' if int8_t not defined. */
|
||||
/* #undef int8_t */
|
||||
|
||||
/* on sinix */
|
||||
/* #undef sinix */
|
||||
|
||||
/* Define to `unsigned short' if u_int16_t not defined. */
|
||||
/* #undef u_int16_t */
|
||||
|
||||
/* Define to `unsigned int' if u_int32_t not defined. */
|
||||
/* #undef u_int32_t */
|
||||
|
||||
/* Define to `unsigned long long' if u_int64_t not defined. */
|
||||
/* #undef u_int64_t */
|
||||
|
||||
/* Define to `unsigned char' if u_int8_t not defined. */
|
||||
/* #undef u_int8_t */
|
@ -1,347 +0,0 @@
|
||||
/* config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Enable optimizer debugging */
|
||||
#undef BDEBUG
|
||||
|
||||
/* define if you have a cloning BPF device */
|
||||
#undef HAVE_CLONING_BPF
|
||||
|
||||
/* define if you have the DAG API */
|
||||
#undef HAVE_DAG_API
|
||||
|
||||
/* define if you have dag_get_erf_types() */
|
||||
#undef HAVE_DAG_GET_ERF_TYPES
|
||||
|
||||
/* define if you have dag_get_stream_erf_types() */
|
||||
#undef HAVE_DAG_GET_STREAM_ERF_TYPES
|
||||
|
||||
/* 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
|
||||
|
||||
/* define if you have a /dev/dlpi */
|
||||
#undef HAVE_DEV_DLPI
|
||||
|
||||
/* if passive_req_t primitive exists */
|
||||
#undef HAVE_DLPI_PASSIVE
|
||||
|
||||
/* Define to 1 if you have the `ether_hostton' function. */
|
||||
#undef HAVE_ETHER_HOSTTON
|
||||
|
||||
/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
|
||||
#undef HAVE_FSEEKO
|
||||
|
||||
/* on HP-UX 10.20 or later */
|
||||
#undef HAVE_HPUX10_20_OR_LATER
|
||||
|
||||
/* on HP-UX 9.x */
|
||||
#undef HAVE_HPUX9
|
||||
|
||||
/* if ppa_info_t_dl_module_id exists */
|
||||
#undef HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* if libdlpi exists */
|
||||
#undef HAVE_LIBDLPI
|
||||
|
||||
/* if libnl exists */
|
||||
#undef HAVE_LIBNL
|
||||
|
||||
/* if libnl exists and is version 2.x */
|
||||
#undef HAVE_LIBNL_2_x
|
||||
|
||||
/* if libnl exists and is version 3.x */
|
||||
#undef HAVE_LIBNL_3_x
|
||||
|
||||
/* libnl has NLE_FAILURE */
|
||||
#undef HAVE_LIBNL_NLE
|
||||
|
||||
/* libnl has new-style socket api */
|
||||
#undef HAVE_LIBNL_SOCKETS
|
||||
|
||||
/* 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_bonding.h> header file. */
|
||||
#undef HAVE_LINUX_IF_BONDING_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
|
||||
|
||||
/* Define to 1 if you have the <linux/sockios.h> header file. */
|
||||
#undef HAVE_LINUX_SOCKIOS_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
|
||||
|
||||
/* Define to 1 if you have the <linux/wireless.h> header file. */
|
||||
#undef HAVE_LINUX_WIRELESS_H
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if you have the <netinet/ether.h> header file. */
|
||||
#undef HAVE_NETINET_ETHER_H
|
||||
|
||||
/* 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
|
||||
|
||||
/* Define to 1 if you have the <net/pfvar.h> header file. */
|
||||
#undef HAVE_NET_PFVAR_H
|
||||
|
||||
/* if there's an os_proto.h for this platform, to use additional prototypes */
|
||||
#undef HAVE_OS_PROTO_H
|
||||
|
||||
/* define if net/pfvar.h defines PF_NAT through PF_NORDR */
|
||||
#undef HAVE_PF_NAT_THROUGH_PF_NORDR
|
||||
|
||||
/* define if you have the Septel API */
|
||||
#undef HAVE_SEPTEL_API
|
||||
|
||||
/* define if you have the Myricom SNF API */
|
||||
#undef HAVE_SNF_API
|
||||
|
||||
/* Define to 1 if you have the `snprintf' function. */
|
||||
#undef HAVE_SNPRINTF
|
||||
|
||||
/* if struct sockaddr has the sa_len member */
|
||||
#undef HAVE_SOCKADDR_SA_LEN
|
||||
|
||||
/* if struct sockaddr_storage exists */
|
||||
#undef HAVE_SOCKADDR_STORAGE
|
||||
|
||||
/* define if socklen_t is defined */
|
||||
#undef HAVE_SOCKLEN_T
|
||||
|
||||
/* On solaris */
|
||||
#undef HAVE_SOLARIS
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Define to 1 if you have the `strerror' function. */
|
||||
#undef HAVE_STRERROR
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
/* Define to 1 if you have the `strlcpy' function. */
|
||||
#undef HAVE_STRLCPY
|
||||
|
||||
/* Define to 1 if you have the `strtok_r' function. */
|
||||
#undef HAVE_STRTOK_R
|
||||
|
||||
/* Define to 1 if the system has the type `struct BPF_TIMEVAL'. */
|
||||
#undef HAVE_STRUCT_BPF_TIMEVAL
|
||||
|
||||
/* Define to 1 if the system has the type `struct ether_addr'. */
|
||||
#undef HAVE_STRUCT_ETHER_ADDR
|
||||
|
||||
/* Define to 1 if you have the <sys/bitypes.h> header file. */
|
||||
#undef HAVE_SYS_BITYPES_H
|
||||
|
||||
/* Define to 1 if you have the <sys/bufmod.h> header file. */
|
||||
#undef HAVE_SYS_BUFMOD_H
|
||||
|
||||
/* Define to 1 if you have the <sys/dlpi_ext.h> header file. */
|
||||
#undef HAVE_SYS_DLPI_EXT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/ioccom.h> header file. */
|
||||
#undef HAVE_SYS_IOCCOM_H
|
||||
|
||||
/* Define to 1 if you have the <sys/select.h> header file. */
|
||||
#undef HAVE_SYS_SELECT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/sockio.h> header file. */
|
||||
#undef HAVE_SYS_SOCKIO_H
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
/* define if you have the TurboCap API */
|
||||
#undef HAVE_TC_API
|
||||
|
||||
/* if if_packet.h has tpacket_stats defined */
|
||||
#undef HAVE_TPACKET_STATS
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* if struct usbdevfs_ctrltransfer has bRequestType */
|
||||
#undef HAVE_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE
|
||||
|
||||
/* Define to 1 if you have the `vsnprintf' function. */
|
||||
#undef HAVE_VSNPRINTF
|
||||
|
||||
/* define if the system supports zerocopy BPF */
|
||||
#undef HAVE_ZEROCOPY_BPF
|
||||
|
||||
/* define if your compiler has __attribute__ */
|
||||
#undef HAVE___ATTRIBUTE__
|
||||
|
||||
/* IPv6 */
|
||||
#undef INET6
|
||||
|
||||
/* if unaligned access fails */
|
||||
#undef LBL_ALIGN
|
||||
|
||||
/* path for device for USB sniffing */
|
||||
#undef LINUX_USB_MON_DEV
|
||||
|
||||
/* Define to 1 if netinet/ether.h declares `ether_hostton' */
|
||||
#undef NETINET_ETHER_H_DECLARES_ETHER_HOSTTON
|
||||
|
||||
/* Define to 1 if netinet/if_ether.h declares `ether_hostton' */
|
||||
#undef NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON
|
||||
|
||||
/* do not use protochain */
|
||||
#undef NO_PROTOCHAIN
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#undef PACKAGE_NAME
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#undef PACKAGE_STRING
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#undef PACKAGE_URL
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* /dev/dlpi directory */
|
||||
#undef PCAP_DEV_PREFIX
|
||||
|
||||
/* target host supports Bluetooth sniffing */
|
||||
#undef PCAP_SUPPORT_BT
|
||||
|
||||
/* target host supports Bluetooth Monitor */
|
||||
#undef PCAP_SUPPORT_BT_MONITOR
|
||||
|
||||
/* support D-Bus sniffing */
|
||||
#undef PCAP_SUPPORT_DBUS
|
||||
|
||||
/* target host supports netfilter sniffing */
|
||||
#undef PCAP_SUPPORT_NETFILTER
|
||||
|
||||
/* use Linux packet ring capture if available */
|
||||
#undef PCAP_SUPPORT_PACKET_RING
|
||||
|
||||
/* target host supports USB sniffing */
|
||||
#undef PCAP_SUPPORT_USB
|
||||
|
||||
/* include ACN support */
|
||||
#undef SITA
|
||||
|
||||
/* if struct sockaddr_hci has hci_channel member */
|
||||
#undef SOCKADDR_HCI_HAS_HCI_CHANNEL
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* Enable parser debugging */
|
||||
#undef YYDEBUG
|
||||
|
||||
/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
|
||||
`char[]'. */
|
||||
#undef YYTEXT_POINTER
|
||||
|
||||
/* Enable large inode numbers on Mac OS X 10.5. */
|
||||
#ifndef _DARWIN_USE_64_BIT_INODE
|
||||
# define _DARWIN_USE_64_BIT_INODE 1
|
||||
#endif
|
||||
|
||||
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||
#undef _FILE_OFFSET_BITS
|
||||
|
||||
/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
|
||||
#undef _LARGEFILE_SOURCE
|
||||
|
||||
/* Define for large files, on AIX-style hosts. */
|
||||
#undef _LARGE_FILES
|
||||
|
||||
/* define on AIX to get certain functions */
|
||||
#undef _SUN
|
||||
|
||||
/* define if your compiler allows __attribute__((format)) without a warning */
|
||||
#undef __ATTRIBUTE___FORMAT_OK
|
||||
|
||||
/* to handle Ultrix compilers that don't support const in prototypes */
|
||||
#undef const
|
||||
|
||||
/* Define as token for inline if inlining supported */
|
||||
#undef inline
|
||||
|
||||
/* Define to `short' if int16_t not defined. */
|
||||
#undef int16_t
|
||||
|
||||
/* Define to `int' if int32_t not defined. */
|
||||
#undef int32_t
|
||||
|
||||
/* Define to `long long' if int64_t not defined. */
|
||||
#undef int64_t
|
||||
|
||||
/* Define to `signed char' if int8_t not defined. */
|
||||
#undef int8_t
|
||||
|
||||
/* on sinix */
|
||||
#undef sinix
|
||||
|
||||
/* Define to `unsigned short' if u_int16_t not defined. */
|
||||
#undef u_int16_t
|
||||
|
||||
/* Define to `unsigned int' if u_int32_t not defined. */
|
||||
#undef u_int32_t
|
||||
|
||||
/* Define to `unsigned long long' if u_int64_t not defined. */
|
||||
#undef u_int64_t
|
||||
|
||||
/* Define to `unsigned char' if u_int8_t not defined. */
|
||||
#undef u_int8_t
|
10057
libpcap-1.8.1/config.log
10057
libpcap-1.8.1/config.log
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1807
libpcap-1.8.1/config.sub
vendored
1807
libpcap-1.8.1/config.sub
vendored
File diff suppressed because it is too large
Load Diff
@ -1,6 +0,0 @@
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/sockio.h>
|
||||
int main() {
|
||||
ioctl(0, SIOCGLIFCONF, (char *)0);
|
||||
}
|
10359
libpcap-1.8.1/configure
vendored
10359
libpcap-1.8.1/configure
vendored
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,388 +0,0 @@
|
||||
/*
|
||||
* This code is derived from code formerly in pcap-dlpi.c, originally
|
||||
* contributed by Atanu Ghosh (atanu@cs.ucl.ac.uk), University College
|
||||
* London, and subsequently modified by Guy Harris (guy@alum.mit.edu),
|
||||
* Mark Pizzolato <List-tcpdump-workers@subscriptions.pizzolato.net>,
|
||||
* Mark C. Brown (mbrown@hp.com), and Sagun Shakya <Sagun.Shakya@Sun.COM>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file contains dlpi/libdlpi related common functions used
|
||||
* by pcap-[dlpi,libdlpi].c.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifndef DL_IPATM
|
||||
#define DL_IPATM 0x12 /* ATM Classical IP interface */
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_BUFMOD_H
|
||||
/*
|
||||
* Size of a bufmod chunk to pass upstream; that appears to be the
|
||||
* biggest value to which you can set it, and setting it to that value
|
||||
* (which is bigger than what appears to be the Solaris default of 8192)
|
||||
* reduces the number of packet drops.
|
||||
*/
|
||||
#define CHUNKSIZE 65536
|
||||
|
||||
/*
|
||||
* Size of the buffer to allocate for packet data we read; it must be
|
||||
* large enough to hold a chunk.
|
||||
*/
|
||||
#define PKTBUFSIZE CHUNKSIZE
|
||||
|
||||
#else /* HAVE_SYS_BUFMOD_H */
|
||||
|
||||
/*
|
||||
* Size of the buffer to allocate for packet data we read; this is
|
||||
* what the value used to be - there's no particular reason why it
|
||||
* should be tied to MAXDLBUF, but we'll leave it as this for now.
|
||||
*/
|
||||
#define MAXDLBUF 8192
|
||||
#define PKTBUFSIZE (MAXDLBUF * sizeof(bpf_u_int32))
|
||||
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#ifdef HAVE_SYS_BUFMOD_H
|
||||
#include <sys/bufmod.h>
|
||||
#endif
|
||||
#include <sys/dlpi.h>
|
||||
#include <sys/stream.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <memory.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stropts.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef HAVE_LIBDLPI
|
||||
#include <libdlpi.h>
|
||||
#endif
|
||||
|
||||
#include "pcap-int.h"
|
||||
#include "dlpisubs.h"
|
||||
|
||||
#ifdef HAVE_SYS_BUFMOD_H
|
||||
static void pcap_stream_err(const char *, int, char *);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Get the packet statistics.
|
||||
*/
|
||||
int
|
||||
pcap_stats_dlpi(pcap_t *p, struct pcap_stat *ps)
|
||||
{
|
||||
struct pcap_dlpi *pd = p->priv;
|
||||
|
||||
/*
|
||||
* "ps_recv" counts packets handed to the filter, not packets
|
||||
* that passed the filter. As filtering is done in userland,
|
||||
* this would not include packets dropped because we ran out
|
||||
* of buffer space; in order to make this more like other
|
||||
* platforms (Linux 2.4 and later, BSDs with BPF), where the
|
||||
* "packets received" count includes packets received but dropped
|
||||
* due to running out of buffer space, and to keep from confusing
|
||||
* applications that, for example, compute packet drop percentages,
|
||||
* we also make it count packets dropped by "bufmod" (otherwise we
|
||||
* might run the risk of the packet drop count being bigger than
|
||||
* the received-packet count).
|
||||
*
|
||||
* "ps_drop" counts packets dropped by "bufmod" because of
|
||||
* flow control requirements or resource exhaustion; it doesn't
|
||||
* count packets dropped by the interface driver, or packets
|
||||
* dropped upstream. As filtering is done in userland, it counts
|
||||
* packets regardless of whether they would've passed the filter.
|
||||
*
|
||||
* These statistics don't include packets not yet read from
|
||||
* the kernel by libpcap, but they may include packets not
|
||||
* yet read from libpcap by the application.
|
||||
*/
|
||||
*ps = pd->stat;
|
||||
|
||||
/*
|
||||
* Add in the drop count, as per the above comment.
|
||||
*/
|
||||
ps->ps_recv += ps->ps_drop;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Loop through the packets and call the callback for each packet.
|
||||
* Return the number of packets read.
|
||||
*/
|
||||
int
|
||||
pcap_process_pkts(pcap_t *p, pcap_handler callback, u_char *user,
|
||||
int count, u_char *bufp, int len)
|
||||
{
|
||||
struct pcap_dlpi *pd = p->priv;
|
||||
int n, caplen, origlen;
|
||||
u_char *ep, *pk;
|
||||
struct pcap_pkthdr pkthdr;
|
||||
#ifdef HAVE_SYS_BUFMOD_H
|
||||
struct sb_hdr *sbp;
|
||||
#ifdef LBL_ALIGN
|
||||
struct sb_hdr sbhdr;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Loop through packets */
|
||||
ep = bufp + len;
|
||||
n = 0;
|
||||
|
||||
#ifdef HAVE_SYS_BUFMOD_H
|
||||
while (bufp < ep) {
|
||||
/*
|
||||
* Has "pcap_breakloop()" been called?
|
||||
* If so, return immediately - if we haven't read any
|
||||
* packets, clear the flag and return -2 to indicate
|
||||
* that we were told to break out of the loop, otherwise
|
||||
* leave the flag set, so that the *next* call will break
|
||||
* out of the loop without having read any packets, and
|
||||
* return the number of packets we've processed so far.
|
||||
*/
|
||||
if (p->break_loop) {
|
||||
if (n == 0) {
|
||||
p->break_loop = 0;
|
||||
return (-2);
|
||||
} else {
|
||||
p->bp = bufp;
|
||||
p->cc = ep - bufp;
|
||||
return (n);
|
||||
}
|
||||
}
|
||||
#ifdef LBL_ALIGN
|
||||
if ((long)bufp & 3) {
|
||||
sbp = &sbhdr;
|
||||
memcpy(sbp, bufp, sizeof(*sbp));
|
||||
} else
|
||||
#endif
|
||||
sbp = (struct sb_hdr *)bufp;
|
||||
pd->stat.ps_drop = sbp->sbh_drops;
|
||||
pk = bufp + sizeof(*sbp);
|
||||
bufp += sbp->sbh_totlen;
|
||||
origlen = sbp->sbh_origlen;
|
||||
caplen = sbp->sbh_msglen;
|
||||
#else
|
||||
origlen = len;
|
||||
caplen = min(p->snapshot, len);
|
||||
pk = bufp;
|
||||
bufp += caplen;
|
||||
#endif
|
||||
++pd->stat.ps_recv;
|
||||
if (bpf_filter(p->fcode.bf_insns, pk, origlen, caplen)) {
|
||||
#ifdef HAVE_SYS_BUFMOD_H
|
||||
pkthdr.ts.tv_sec = sbp->sbh_timestamp.tv_sec;
|
||||
pkthdr.ts.tv_usec = sbp->sbh_timestamp.tv_usec;
|
||||
#else
|
||||
(void) gettimeofday(&pkthdr.ts, NULL);
|
||||
#endif
|
||||
pkthdr.len = origlen;
|
||||
pkthdr.caplen = caplen;
|
||||
/* Insure caplen does not exceed snapshot */
|
||||
if (pkthdr.caplen > (bpf_u_int32)p->snapshot)
|
||||
pkthdr.caplen = (bpf_u_int32)p->snapshot;
|
||||
(*callback)(user, &pkthdr, pk);
|
||||
if (++n >= count && !PACKET_COUNT_IS_UNLIMITED(count)) {
|
||||
p->cc = ep - bufp;
|
||||
p->bp = bufp;
|
||||
return (n);
|
||||
}
|
||||
}
|
||||
#ifdef HAVE_SYS_BUFMOD_H
|
||||
}
|
||||
#endif
|
||||
p->cc = 0;
|
||||
return (n);
|
||||
}
|
||||
|
||||
/*
|
||||
* Process the mac type. Returns -1 if no matching mac type found, otherwise 0.
|
||||
*/
|
||||
int
|
||||
pcap_process_mactype(pcap_t *p, u_int mactype)
|
||||
{
|
||||
int retv = 0;
|
||||
|
||||
switch (mactype) {
|
||||
|
||||
case DL_CSMACD:
|
||||
case DL_ETHER:
|
||||
p->linktype = DLT_EN10MB;
|
||||
p->offset = 2;
|
||||
/*
|
||||
* This is (presumably) a real Ethernet capture; give it a
|
||||
* link-layer-type list with DLT_EN10MB and DLT_DOCSIS, so
|
||||
* that an application can let you choose it, in case you're
|
||||
* capturing DOCSIS traffic that a Cisco Cable Modem
|
||||
* Termination System is putting out onto an Ethernet (it
|
||||
* doesn't put an Ethernet header onto the wire, it puts raw
|
||||
* DOCSIS frames out on the wire inside the low-level
|
||||
* Ethernet framing).
|
||||
*/
|
||||
p->dlt_list = (u_int *)malloc(sizeof(u_int) * 2);
|
||||
/*
|
||||
* If that fails, just leave the list empty.
|
||||
*/
|
||||
if (p->dlt_list != NULL) {
|
||||
p->dlt_list[0] = DLT_EN10MB;
|
||||
p->dlt_list[1] = DLT_DOCSIS;
|
||||
p->dlt_count = 2;
|
||||
}
|
||||
break;
|
||||
|
||||
case DL_FDDI:
|
||||
p->linktype = DLT_FDDI;
|
||||
p->offset = 3;
|
||||
break;
|
||||
|
||||
case DL_TPR:
|
||||
/* XXX - what about DL_TPB? Is that Token Bus? */
|
||||
p->linktype = DLT_IEEE802;
|
||||
p->offset = 2;
|
||||
break;
|
||||
|
||||
#ifdef HAVE_SOLARIS
|
||||
case DL_IPATM:
|
||||
p->linktype = DLT_SUNATM;
|
||||
p->offset = 0; /* works for LANE and LLC encapsulation */
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef DL_IPV4
|
||||
case DL_IPV4:
|
||||
p->linktype = DLT_IPV4;
|
||||
p->offset = 0;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef DL_IPV6
|
||||
case DL_IPV6:
|
||||
p->linktype = DLT_IPV6;
|
||||
p->offset = 0;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef DL_IPNET
|
||||
case DL_IPNET:
|
||||
p->linktype = DLT_IPNET;
|
||||
p->offset = 0;
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "unknown mactype 0x%x",
|
||||
mactype);
|
||||
retv = -1;
|
||||
}
|
||||
|
||||
return (retv);
|
||||
}
|
||||
|
||||
#ifdef HAVE_SYS_BUFMOD_H
|
||||
/*
|
||||
* Push and configure the buffer module. Returns -1 for error, otherwise 0.
|
||||
*/
|
||||
int
|
||||
pcap_conf_bufmod(pcap_t *p, int snaplen)
|
||||
{
|
||||
struct timeval to;
|
||||
bpf_u_int32 ss, chunksize;
|
||||
|
||||
/* Non-standard call to get the data nicely buffered. */
|
||||
if (ioctl(p->fd, I_PUSH, "bufmod") != 0) {
|
||||
pcap_stream_err("I_PUSH bufmod", errno, p->errbuf);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
ss = snaplen;
|
||||
if (ss > 0 &&
|
||||
strioctl(p->fd, SBIOCSSNAP, sizeof(ss), (char *)&ss) != 0) {
|
||||
pcap_stream_err("SBIOCSSNAP", errno, p->errbuf);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (p->opt.immediate) {
|
||||
/* Set the timeout to zero, for immediate delivery. */
|
||||
to.tv_sec = 0;
|
||||
to.tv_usec = 0;
|
||||
if (strioctl(p->fd, SBIOCSTIME, sizeof(to), (char *)&to) != 0) {
|
||||
pcap_stream_err("SBIOCSTIME", errno, p->errbuf);
|
||||
return (-1);
|
||||
}
|
||||
} else {
|
||||
/* Set up the bufmod timeout. */
|
||||
if (p->opt.timeout != 0) {
|
||||
to.tv_sec = p->opt.timeout / 1000;
|
||||
to.tv_usec = (p->opt.timeout * 1000) % 1000000;
|
||||
if (strioctl(p->fd, SBIOCSTIME, sizeof(to), (char *)&to) != 0) {
|
||||
pcap_stream_err("SBIOCSTIME", errno, p->errbuf);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the chunk length. */
|
||||
chunksize = CHUNKSIZE;
|
||||
if (strioctl(p->fd, SBIOCSCHUNK, sizeof(chunksize), (char *)&chunksize)
|
||||
!= 0) {
|
||||
pcap_stream_err("SBIOCSCHUNKP", errno, p->errbuf);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
#endif /* HAVE_SYS_BUFMOD_H */
|
||||
|
||||
/*
|
||||
* Allocate data buffer. Returns -1 if memory allocation fails, else 0.
|
||||
*/
|
||||
int
|
||||
pcap_alloc_databuf(pcap_t *p)
|
||||
{
|
||||
p->bufsize = PKTBUFSIZE;
|
||||
p->buffer = malloc(p->bufsize + p->offset);
|
||||
if (p->buffer == NULL) {
|
||||
strlcpy(p->errbuf, pcap_strerror(errno), PCAP_ERRBUF_SIZE);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Issue a STREAMS I_STR ioctl. Returns -1 on error, otherwise
|
||||
* length of returned data on success.
|
||||
*/
|
||||
int
|
||||
strioctl(int fd, int cmd, int len, char *dp)
|
||||
{
|
||||
struct strioctl str;
|
||||
int retv;
|
||||
|
||||
str.ic_cmd = cmd;
|
||||
str.ic_timout = -1;
|
||||
str.ic_len = len;
|
||||
str.ic_dp = dp;
|
||||
if ((retv = ioctl(fd, I_STR, &str)) < 0)
|
||||
return (retv);
|
||||
|
||||
return (str.ic_len);
|
||||
}
|
||||
|
||||
#ifdef HAVE_SYS_BUFMOD_H
|
||||
/*
|
||||
* Write stream error message to errbuf.
|
||||
*/
|
||||
static void
|
||||
pcap_stream_err(const char *func, int err, char *errbuf)
|
||||
{
|
||||
pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s", func, pcap_strerror(err));
|
||||
}
|
||||
#endif
|
@ -1,38 +0,0 @@
|
||||
#ifndef dlpisubs_h
|
||||
#define dlpisubs_h
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Private data for capturing on DLPI devices.
|
||||
*/
|
||||
struct pcap_dlpi {
|
||||
#ifdef HAVE_LIBDLPI
|
||||
dlpi_handle_t dlpi_hd;
|
||||
#endif /* HAVE_LIBDLPI */
|
||||
#ifdef DL_HP_RAWDLS
|
||||
int send_fd;
|
||||
#endif /* DL_HP_RAWDLS */
|
||||
|
||||
struct pcap_stat stat;
|
||||
};
|
||||
|
||||
/*
|
||||
* Functions defined by dlpisubs.c.
|
||||
*/
|
||||
int pcap_stats_dlpi(pcap_t *, struct pcap_stat *);
|
||||
int pcap_process_pkts(pcap_t *, pcap_handler, u_char *, int, u_char *, int);
|
||||
int pcap_process_mactype(pcap_t *, u_int);
|
||||
#ifdef HAVE_SYS_BUFMOD_H
|
||||
int pcap_conf_bufmod(pcap_t *, int);
|
||||
#endif
|
||||
int pcap_alloc_databuf(pcap_t *);
|
||||
int strioctl(int, int, int, char *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,169 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1990, 1993, 1994, 1995, 1996
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <pcap-stdinc.h>
|
||||
#else /* _WIN32 */
|
||||
#if HAVE_INTTYPES_H
|
||||
#include <inttypes.h>
|
||||
#elif HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_BITYPES_H
|
||||
#include <sys/bitypes.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#include <ctype.h>
|
||||
#include <memory.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "pcap-int.h"
|
||||
|
||||
#include <pcap/namedb.h>
|
||||
|
||||
#ifdef HAVE_OS_PROTO_H
|
||||
#include "os-proto.h"
|
||||
#endif
|
||||
|
||||
static inline int xdtoi(int);
|
||||
static inline int skip_space(FILE *);
|
||||
static inline int skip_line(FILE *);
|
||||
|
||||
/* Hex digit to integer. */
|
||||
static inline int
|
||||
xdtoi(c)
|
||||
register int c;
|
||||
{
|
||||
if (isdigit(c))
|
||||
return c - '0';
|
||||
else if (islower(c))
|
||||
return c - 'a' + 10;
|
||||
else
|
||||
return c - 'A' + 10;
|
||||
}
|
||||
|
||||
static inline int
|
||||
skip_space(f)
|
||||
FILE *f;
|
||||
{
|
||||
int c;
|
||||
|
||||
do {
|
||||
c = getc(f);
|
||||
} while (isspace(c) && c != '\n');
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
static inline int
|
||||
skip_line(f)
|
||||
FILE *f;
|
||||
{
|
||||
int c;
|
||||
|
||||
do
|
||||
c = getc(f);
|
||||
while (c != '\n' && c != EOF);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
struct pcap_etherent *
|
||||
pcap_next_etherent(FILE *fp)
|
||||
{
|
||||
register int c, d, i;
|
||||
char *bp;
|
||||
static struct pcap_etherent e;
|
||||
|
||||
memset((char *)&e, 0, sizeof(e));
|
||||
do {
|
||||
/* Find addr */
|
||||
c = skip_space(fp);
|
||||
if (c == '\n')
|
||||
continue;
|
||||
|
||||
/* If this is a comment, or first thing on line
|
||||
cannot be etehrnet address, skip the line. */
|
||||
if (!isxdigit(c)) {
|
||||
c = skip_line(fp);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* must be the start of an address */
|
||||
for (i = 0; i < 6; i += 1) {
|
||||
d = xdtoi(c);
|
||||
c = getc(fp);
|
||||
if (isxdigit(c)) {
|
||||
d <<= 4;
|
||||
d |= xdtoi(c);
|
||||
c = getc(fp);
|
||||
}
|
||||
e.addr[i] = d;
|
||||
if (c != ':')
|
||||
break;
|
||||
c = getc(fp);
|
||||
}
|
||||
if (c == EOF)
|
||||
break;
|
||||
|
||||
/* Must be whitespace */
|
||||
if (!isspace(c)) {
|
||||
c = skip_line(fp);
|
||||
continue;
|
||||
}
|
||||
c = skip_space(fp);
|
||||
|
||||
/* hit end of line... */
|
||||
if (c == '\n')
|
||||
continue;
|
||||
|
||||
if (c == '#') {
|
||||
c = skip_line(fp);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* pick up name */
|
||||
bp = e.name;
|
||||
/* Use 'd' to prevent buffer overflow. */
|
||||
d = sizeof(e.name) - 1;
|
||||
do {
|
||||
*bp++ = c;
|
||||
c = getc(fp);
|
||||
} while (!isspace(c) && c != EOF && --d > 0);
|
||||
*bp = '\0';
|
||||
|
||||
/* Eat trailing junk */
|
||||
if (c != '\n')
|
||||
(void)skip_line(fp);
|
||||
|
||||
return &e;
|
||||
|
||||
} while (c != EOF);
|
||||
|
||||
return (NULL);
|
||||
}
|
Binary file not shown.
@ -1,123 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1993, 1994, 1996
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Ethernet types.
|
||||
*
|
||||
* We wrap the declarations with #ifdef, so that if a file includes
|
||||
* <netinet/if_ether.h>, which may declare some of these, we don't
|
||||
* get a bunch of complaints from the C compiler about redefinitions
|
||||
* of these values.
|
||||
*
|
||||
* We declare all of them here so that no file has to include
|
||||
* <netinet/if_ether.h> if all it needs are ETHERTYPE_ values.
|
||||
*/
|
||||
|
||||
#ifndef ETHERTYPE_PUP
|
||||
#define ETHERTYPE_PUP 0x0200 /* PUP protocol */
|
||||
#endif
|
||||
#ifndef ETHERTYPE_IP
|
||||
#define ETHERTYPE_IP 0x0800 /* IP protocol */
|
||||
#endif
|
||||
#ifndef ETHERTYPE_ARP
|
||||
#define ETHERTYPE_ARP 0x0806 /* Addr. resolution protocol */
|
||||
#endif
|
||||
#ifndef ETHERTYPE_REVARP
|
||||
#define ETHERTYPE_REVARP 0x8035 /* reverse Addr. resolution protocol */
|
||||
#endif
|
||||
#ifndef ETHERTYPE_NS
|
||||
#define ETHERTYPE_NS 0x0600
|
||||
#endif
|
||||
#ifndef ETHERTYPE_SPRITE
|
||||
#define ETHERTYPE_SPRITE 0x0500
|
||||
#endif
|
||||
#ifndef ETHERTYPE_TRAIL
|
||||
#define ETHERTYPE_TRAIL 0x1000
|
||||
#endif
|
||||
#ifndef ETHERTYPE_MOPDL
|
||||
#define ETHERTYPE_MOPDL 0x6001
|
||||
#endif
|
||||
#ifndef ETHERTYPE_MOPRC
|
||||
#define ETHERTYPE_MOPRC 0x6002
|
||||
#endif
|
||||
#ifndef ETHERTYPE_DN
|
||||
#define ETHERTYPE_DN 0x6003
|
||||
#endif
|
||||
#ifndef ETHERTYPE_LAT
|
||||
#define ETHERTYPE_LAT 0x6004
|
||||
#endif
|
||||
#ifndef ETHERTYPE_SCA
|
||||
#define ETHERTYPE_SCA 0x6007
|
||||
#endif
|
||||
#ifndef ETHERTYPE_REVARP
|
||||
#define ETHERTYPE_REVARP 0x8035
|
||||
#endif
|
||||
#ifndef ETHERTYPE_LANBRIDGE
|
||||
#define ETHERTYPE_LANBRIDGE 0x8038
|
||||
#endif
|
||||
#ifndef ETHERTYPE_DECDNS
|
||||
#define ETHERTYPE_DECDNS 0x803c
|
||||
#endif
|
||||
#ifndef ETHERTYPE_DECDTS
|
||||
#define ETHERTYPE_DECDTS 0x803e
|
||||
#endif
|
||||
#ifndef ETHERTYPE_VEXP
|
||||
#define ETHERTYPE_VEXP 0x805b
|
||||
#endif
|
||||
#ifndef ETHERTYPE_VPROD
|
||||
#define ETHERTYPE_VPROD 0x805c
|
||||
#endif
|
||||
#ifndef ETHERTYPE_ATALK
|
||||
#define ETHERTYPE_ATALK 0x809b
|
||||
#endif
|
||||
#ifndef ETHERTYPE_AARP
|
||||
#define ETHERTYPE_AARP 0x80f3
|
||||
#endif
|
||||
#ifndef ETHERTYPE_8021Q
|
||||
#define ETHERTYPE_8021Q 0x8100
|
||||
#endif
|
||||
#ifndef ETHERTYPE_IPX
|
||||
#define ETHERTYPE_IPX 0x8137
|
||||
#endif
|
||||
#ifndef ETHERTYPE_IPV6
|
||||
#define ETHERTYPE_IPV6 0x86dd
|
||||
#endif
|
||||
#ifndef ETHERTYPE_MPLS
|
||||
#define ETHERTYPE_MPLS 0x8847
|
||||
#endif
|
||||
#ifndef ETHERTYPE_MPLS_MULTI
|
||||
#define ETHERTYPE_MPLS_MULTI 0x8848
|
||||
#endif
|
||||
#ifndef ETHERTYPE_PPPOED
|
||||
#define ETHERTYPE_PPPOED 0x8863
|
||||
#endif
|
||||
#ifndef ETHERTYPE_PPPOES
|
||||
#define ETHERTYPE_PPPOES 0x8864
|
||||
#endif
|
||||
#ifndef ETHERTYPE_8021AD
|
||||
#define ETHERTYPE_8021AD 0x88a8
|
||||
#endif
|
||||
#ifndef ETHERTYPE_LOOPBACK
|
||||
#define ETHERTYPE_LOOPBACK 0x9000
|
||||
#endif
|
||||
#ifndef ETHERTYPE_8021QINQ
|
||||
#define ETHERTYPE_8021QINQ 0x9100
|
||||
#endif
|
@ -1,221 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1992, 1993, 1994, 1995, 1996
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Macros to extract possibly-unaligned big-endian integral values.
|
||||
*/
|
||||
#ifdef LBL_ALIGN
|
||||
/*
|
||||
* The processor doesn't natively handle unaligned loads.
|
||||
*/
|
||||
#if defined(__GNUC__) && defined(HAVE___ATTRIBUTE__) && \
|
||||
(defined(__alpha) || defined(__alpha__) || \
|
||||
defined(__mips) || defined(__mips__))
|
||||
|
||||
/*
|
||||
* This is a GCC-compatible compiler and we have __attribute__, which
|
||||
* we assume that mean we have __attribute__((packed)), and this is
|
||||
* MIPS or Alpha, which has instructions that can help when doing
|
||||
* unaligned loads.
|
||||
*
|
||||
* Declare packed structures containing a uint16_t and a uint32_t,
|
||||
* cast the pointer to point to one of those, and fetch through it;
|
||||
* the GCC manual doesn't appear to explicitly say that
|
||||
* __attribute__((packed)) causes the compiler to generate unaligned-safe
|
||||
* code, but it apppears to do so.
|
||||
*
|
||||
* We do this in case the compiler can generate code using those
|
||||
* instructions to do an unaligned load and pass stuff to "ntohs()" or
|
||||
* "ntohl()", which might be better than than the code to fetch the
|
||||
* bytes one at a time and assemble them. (That might not be the
|
||||
* case on a little-endian platform, such as DEC's MIPS machines and
|
||||
* Alpha machines, where "ntohs()" and "ntohl()" might not be done
|
||||
* inline.)
|
||||
*
|
||||
* We do this only for specific architectures because, for example,
|
||||
* at least some versions of GCC, when compiling for 64-bit SPARC,
|
||||
* generate code that assumes alignment if we do this.
|
||||
*
|
||||
* XXX - add other architectures and compilers as possible and
|
||||
* appropriate.
|
||||
*
|
||||
* HP's C compiler, indicated by __HP_cc being defined, supports
|
||||
* "#pragma unaligned N" in version A.05.50 and later, where "N"
|
||||
* specifies a number of bytes at which the typedef on the next
|
||||
* line is aligned, e.g.
|
||||
*
|
||||
* #pragma unalign 1
|
||||
* typedef uint16_t unaligned_uint16_t;
|
||||
*
|
||||
* to define unaligned_uint16_t as a 16-bit unaligned data type.
|
||||
* This could be presumably used, in sufficiently recent versions of
|
||||
* the compiler, with macros similar to those below. This would be
|
||||
* useful only if that compiler could generate better code for PA-RISC
|
||||
* or Itanium than would be generated by a bunch of shifts-and-ORs.
|
||||
*
|
||||
* DEC C, indicated by __DECC being defined, has, at least on Alpha,
|
||||
* an __unaligned qualifier that can be applied to pointers to get the
|
||||
* compiler to generate code that does unaligned loads and stores when
|
||||
* dereferencing the pointer in question.
|
||||
*
|
||||
* XXX - what if the native C compiler doesn't support
|
||||
* __attribute__((packed))? How can we get it to generate unaligned
|
||||
* accesses for *specific* items?
|
||||
*/
|
||||
typedef struct {
|
||||
uint16_t val;
|
||||
} __attribute__((packed)) unaligned_uint16_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t val;
|
||||
} __attribute__((packed)) unaligned_uint32_t;
|
||||
|
||||
static inline uint16_t
|
||||
EXTRACT_16BITS(const void *p)
|
||||
{
|
||||
return ((uint16_t)ntohs(((const unaligned_uint16_t *)(p))->val));
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
EXTRACT_32BITS(const void *p)
|
||||
{
|
||||
return ((uint32_t)ntohl(((const unaligned_uint32_t *)(p))->val));
|
||||
}
|
||||
|
||||
static inline uint64_t
|
||||
EXTRACT_64BITS(const void *p)
|
||||
{
|
||||
return ((uint64_t)(((uint64_t)ntohl(((const unaligned_uint32_t *)(p) + 0)->val)) << 32 | \
|
||||
((uint64_t)ntohl(((const unaligned_uint32_t *)(p) + 1)->val)) << 0));
|
||||
}
|
||||
|
||||
#else /* have to do it a byte at a time */
|
||||
/*
|
||||
* This isn't a GCC-compatible compiler, we don't have __attribute__,
|
||||
* or we do but we don't know of any better way with this instruction
|
||||
* set to do unaligned loads, so do unaligned loads of big-endian
|
||||
* quantities the hard way - fetch the bytes one at a time and
|
||||
* assemble them.
|
||||
*/
|
||||
#define EXTRACT_16BITS(p) \
|
||||
((uint16_t)(((uint16_t)(*((const uint8_t *)(p) + 0)) << 8) | \
|
||||
((uint16_t)(*((const uint8_t *)(p) + 1)) << 0)))
|
||||
#define EXTRACT_32BITS(p) \
|
||||
((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 0)) << 24) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 1)) << 16) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 2)) << 8) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 3)) << 0)))
|
||||
#define EXTRACT_64BITS(p) \
|
||||
((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 56) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 1)) << 48) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 2)) << 40) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 3)) << 32) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 4)) << 24) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 5)) << 16) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 6)) << 8) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 7)) << 0)))
|
||||
#endif /* must special-case unaligned accesses */
|
||||
#else /* LBL_ALIGN */
|
||||
/*
|
||||
* The processor natively handles unaligned loads, so we can just
|
||||
* cast the pointer and fetch through it.
|
||||
*/
|
||||
static inline uint16_t
|
||||
EXTRACT_16BITS(const void *p)
|
||||
{
|
||||
return ((uint16_t)ntohs(*(const uint16_t *)(p)));
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
EXTRACT_32BITS(const void *p)
|
||||
{
|
||||
return ((uint32_t)ntohl(*(const uint32_t *)(p)));
|
||||
}
|
||||
|
||||
static inline uint64_t
|
||||
EXTRACT_64BITS(const void *p)
|
||||
{
|
||||
return ((uint64_t)(((uint64_t)ntohl(*((const uint32_t *)(p) + 0))) << 32 | \
|
||||
((uint64_t)ntohl(*((const uint32_t *)(p) + 1))) << 0));
|
||||
|
||||
}
|
||||
|
||||
#endif /* LBL_ALIGN */
|
||||
|
||||
#define EXTRACT_24BITS(p) \
|
||||
((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 0)) << 16) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 1)) << 8) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 2)) << 0)))
|
||||
|
||||
#define EXTRACT_40BITS(p) \
|
||||
((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 32) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 1)) << 24) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 2)) << 16) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 3)) << 8) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 4)) << 0)))
|
||||
|
||||
#define EXTRACT_48BITS(p) \
|
||||
((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 40) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 1)) << 32) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 2)) << 24) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 3)) << 16) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 4)) << 8) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 5)) << 0)))
|
||||
|
||||
#define EXTRACT_56BITS(p) \
|
||||
((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 48) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 1)) << 40) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 2)) << 32) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 3)) << 24) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 4)) << 16) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 5)) << 8) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 6)) << 0)))
|
||||
|
||||
/*
|
||||
* Macros to extract possibly-unaligned little-endian integral values.
|
||||
* XXX - do loads on little-endian machines that support unaligned loads?
|
||||
*/
|
||||
#define EXTRACT_LE_8BITS(p) (*(p))
|
||||
#define EXTRACT_LE_16BITS(p) \
|
||||
((uint16_t)(((uint16_t)(*((const uint8_t *)(p) + 1)) << 8) | \
|
||||
((uint16_t)(*((const uint8_t *)(p) + 0)) << 0)))
|
||||
#define EXTRACT_LE_32BITS(p) \
|
||||
((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 3)) << 24) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 2)) << 16) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 1)) << 8) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 0)) << 0)))
|
||||
#define EXTRACT_LE_24BITS(p) \
|
||||
((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 2)) << 16) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 1)) << 8) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 0)) << 0)))
|
||||
#define EXTRACT_LE_64BITS(p) \
|
||||
((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 7)) << 56) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 6)) << 48) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 5)) << 40) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 4)) << 32) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 3)) << 24) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 2)) << 16) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 1)) << 8) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 0)) << 0)))
|
@ -1,292 +0,0 @@
|
||||
/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */
|
||||
/*
|
||||
* Copyright (c) 1994, 1995, 1996, 1997, 1998
|
||||
* 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 Computer Systems
|
||||
* Engineering Group at Lawrence Berkeley Laboratory.
|
||||
* 4. Neither the name of the University nor of the Laboratory 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <net/if.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ifaddrs.h>
|
||||
|
||||
#include "pcap-int.h"
|
||||
|
||||
#ifdef HAVE_OS_PROTO_H
|
||||
#include "os-proto.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* We don't do this on Solaris 11 and later, as it appears there aren't
|
||||
* any AF_PACKET addresses on interfaces, so we don't need this, and
|
||||
* we end up including both the OS's <net/bpf.h> and our <pcap/bpf.h>,
|
||||
* and their definitions of some data structures collide.
|
||||
*/
|
||||
#if (defined(linux) || defined(__Lynx__)) && defined(AF_PACKET)
|
||||
# ifdef HAVE_NETPACKET_PACKET_H
|
||||
/* 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 /* __Lynx__ */
|
||||
/* Linux */
|
||||
# include <linux/types.h>
|
||||
# include <linux/if_packet.h>
|
||||
# endif /* __Lynx__ */
|
||||
# endif /* HAVE_NETPACKET_PACKET_H */
|
||||
#endif /* (defined(linux) || defined(__Lynx__)) && defined(AF_PACKET) */
|
||||
|
||||
/*
|
||||
* This is fun.
|
||||
*
|
||||
* In older BSD systems, socket addresses were fixed-length, and
|
||||
* "sizeof (struct sockaddr)" gave the size of the structure.
|
||||
* All addresses fit within a "struct sockaddr".
|
||||
*
|
||||
* In newer BSD systems, the socket address is variable-length, and
|
||||
* there's an "sa_len" field giving the length of the structure;
|
||||
* this allows socket addresses to be longer than 2 bytes of family
|
||||
* and 14 bytes of data.
|
||||
*
|
||||
* Some commercial UNIXes use the old BSD scheme, some use the RFC 2553
|
||||
* variant of the old BSD scheme (with "struct sockaddr_storage" rather
|
||||
* than "struct sockaddr"), and some use the new BSD scheme.
|
||||
*
|
||||
* Some versions of GNU libc use neither scheme, but has an "SA_LEN()"
|
||||
* macro that determines the size based on the address family. Other
|
||||
* versions don't have "SA_LEN()" (as it was in drafts of RFC 2553
|
||||
* but not in the final version). On the latter systems, we explicitly
|
||||
* check the AF_ type to determine the length; we assume that on
|
||||
* all those systems we have "struct sockaddr_storage".
|
||||
*/
|
||||
#ifndef SA_LEN
|
||||
#ifdef HAVE_SOCKADDR_SA_LEN
|
||||
#define SA_LEN(addr) ((addr)->sa_len)
|
||||
#else /* HAVE_SOCKADDR_SA_LEN */
|
||||
#ifdef HAVE_SOCKADDR_STORAGE
|
||||
static size_t
|
||||
get_sa_len(struct sockaddr *addr)
|
||||
{
|
||||
switch (addr->sa_family) {
|
||||
|
||||
#ifdef AF_INET
|
||||
case AF_INET:
|
||||
return (sizeof (struct sockaddr_in));
|
||||
#endif
|
||||
|
||||
#ifdef AF_INET6
|
||||
case AF_INET6:
|
||||
return (sizeof (struct sockaddr_in6));
|
||||
#endif
|
||||
|
||||
#if (defined(linux) || defined(__Lynx__)) && defined(AF_PACKET)
|
||||
case AF_PACKET:
|
||||
return (sizeof (struct sockaddr_ll));
|
||||
#endif
|
||||
|
||||
default:
|
||||
return (sizeof (struct sockaddr));
|
||||
}
|
||||
}
|
||||
#define SA_LEN(addr) (get_sa_len(addr))
|
||||
#else /* HAVE_SOCKADDR_STORAGE */
|
||||
#define SA_LEN(addr) (sizeof (struct sockaddr))
|
||||
#endif /* HAVE_SOCKADDR_STORAGE */
|
||||
#endif /* HAVE_SOCKADDR_SA_LEN */
|
||||
#endif /* SA_LEN */
|
||||
|
||||
/*
|
||||
* Get a list of all interfaces that are up and that we can open.
|
||||
* Returns -1 on error, 0 otherwise.
|
||||
* The list, as returned through "alldevsp", may be null if no interfaces
|
||||
* could be opened.
|
||||
*/
|
||||
int
|
||||
pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf,
|
||||
int (*check_usable)(const char *))
|
||||
{
|
||||
pcap_if_t *devlist = NULL;
|
||||
struct ifaddrs *ifap, *ifa;
|
||||
struct sockaddr *addr, *netmask, *broadaddr, *dstaddr;
|
||||
size_t addr_size, broadaddr_size, dstaddr_size;
|
||||
int ret = 0;
|
||||
char *p, *q;
|
||||
|
||||
/*
|
||||
* Get the list of interface addresses.
|
||||
*
|
||||
* Note: this won't return information about interfaces
|
||||
* with no addresses, so, if a platform has interfaces
|
||||
* with no interfaces on which traffic can be captured,
|
||||
* we must check for those interfaces as well (see, for
|
||||
* example, what's done on Linux).
|
||||
*
|
||||
* LAN interfaces will probably have link-layer
|
||||
* addresses; I don't know whether all implementations
|
||||
* of "getifaddrs()" now, or in the future, will return
|
||||
* those.
|
||||
*/
|
||||
if (getifaddrs(&ifap) != 0) {
|
||||
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"getifaddrs: %s", pcap_strerror(errno));
|
||||
return (-1);
|
||||
}
|
||||
for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) {
|
||||
/*
|
||||
* If this entry has a colon followed by a number at
|
||||
* the end, we assume it's a logical interface. Those
|
||||
* are just the way you assign multiple IP addresses to
|
||||
* a real interface on Linux, so an entry for a logical
|
||||
* interface should be treated like the entry for the
|
||||
* real interface; we do that by stripping off the ":"
|
||||
* and the number.
|
||||
*
|
||||
* XXX - should we do this only on Linux?
|
||||
*/
|
||||
p = strchr(ifa->ifa_name, ':');
|
||||
if (p != NULL) {
|
||||
/*
|
||||
* We have a ":"; is it followed by a number?
|
||||
*/
|
||||
q = p + 1;
|
||||
while (isdigit((unsigned char)*q))
|
||||
q++;
|
||||
if (*q == '\0') {
|
||||
/*
|
||||
* All digits after the ":" until the end.
|
||||
* Strip off the ":" and everything after
|
||||
* it.
|
||||
*/
|
||||
*p = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Can we capture on this device?
|
||||
*/
|
||||
if (!(*check_usable)(ifa->ifa_name)) {
|
||||
/*
|
||||
* No.
|
||||
*/
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* "ifa_addr" was apparently null on at least one
|
||||
* interface on some system. Therefore, we supply
|
||||
* the address and netmask only if "ifa_addr" is
|
||||
* non-null (if there's no address, there's obviously
|
||||
* no netmask).
|
||||
*/
|
||||
if (ifa->ifa_addr != NULL) {
|
||||
addr = ifa->ifa_addr;
|
||||
addr_size = SA_LEN(addr);
|
||||
netmask = ifa->ifa_netmask;
|
||||
} else {
|
||||
addr = NULL;
|
||||
addr_size = 0;
|
||||
netmask = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Note that, on some platforms, ifa_broadaddr and
|
||||
* ifa_dstaddr could be the same field (true on at
|
||||
* least some versions of *BSD and OS X), so we
|
||||
* can't just check whether the broadcast address
|
||||
* is null and add it if so and check whether the
|
||||
* destination address is null and add it if so.
|
||||
*
|
||||
* Therefore, we must also check the IFF_BROADCAST
|
||||
* flag, and only add a broadcast address if it's
|
||||
* set, and check the IFF_POINTTOPOINT flag, and
|
||||
* only add a destination address if it's set (as
|
||||
* per man page recommendations on some of those
|
||||
* platforms).
|
||||
*/
|
||||
if (ifa->ifa_flags & IFF_BROADCAST &&
|
||||
ifa->ifa_broadaddr != NULL) {
|
||||
broadaddr = ifa->ifa_broadaddr;
|
||||
broadaddr_size = SA_LEN(broadaddr);
|
||||
} else {
|
||||
broadaddr = NULL;
|
||||
broadaddr_size = 0;
|
||||
}
|
||||
if (ifa->ifa_flags & IFF_POINTOPOINT &&
|
||||
ifa->ifa_dstaddr != NULL) {
|
||||
dstaddr = ifa->ifa_dstaddr;
|
||||
dstaddr_size = SA_LEN(ifa->ifa_dstaddr);
|
||||
} else {
|
||||
dstaddr = NULL;
|
||||
dstaddr_size = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add information for this address to the list.
|
||||
*/
|
||||
if (add_addr_to_iflist(&devlist, ifa->ifa_name,
|
||||
if_flags_to_pcap_flags(ifa->ifa_name, ifa->ifa_flags),
|
||||
addr, addr_size, netmask, addr_size,
|
||||
broadaddr, broadaddr_size, dstaddr, dstaddr_size,
|
||||
errbuf) < 0) {
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
freeifaddrs(ifap);
|
||||
|
||||
if (ret == -1) {
|
||||
/*
|
||||
* We had an error; free the list we've been constructing.
|
||||
*/
|
||||
if (devlist != NULL) {
|
||||
pcap_freealldevs(devlist);
|
||||
devlist = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
*alldevsp = devlist;
|
||||
return (ret);
|
||||
}
|
Binary file not shown.
@ -1,428 +0,0 @@
|
||||
/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */
|
||||
/*
|
||||
* Copyright (c) 1994, 1995, 1996, 1997, 1998
|
||||
* 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 Computer Systems
|
||||
* Engineering Group at Lawrence Berkeley Laboratory.
|
||||
* 4. Neither the name of the University nor of the Laboratory 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#ifdef HAVE_SYS_SOCKIO_H
|
||||
#include <sys/sockio.h>
|
||||
#endif
|
||||
#include <sys/time.h> /* concession to AIX */
|
||||
|
||||
struct mbuf; /* Squelch compiler warnings on some platforms for */
|
||||
struct rtentry; /* declarations in <net/if.h> */
|
||||
#include <net/if.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <memory.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "pcap-int.h"
|
||||
|
||||
#ifdef HAVE_OS_PROTO_H
|
||||
#include "os-proto.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This is fun.
|
||||
*
|
||||
* In older BSD systems, socket addresses were fixed-length, and
|
||||
* "sizeof (struct sockaddr)" gave the size of the structure.
|
||||
* All addresses fit within a "struct sockaddr".
|
||||
*
|
||||
* In newer BSD systems, the socket address is variable-length, and
|
||||
* there's an "sa_len" field giving the length of the structure;
|
||||
* this allows socket addresses to be longer than 2 bytes of family
|
||||
* and 14 bytes of data.
|
||||
*
|
||||
* Some commercial UNIXes use the old BSD scheme, some use the RFC 2553
|
||||
* variant of the old BSD scheme (with "struct sockaddr_storage" rather
|
||||
* than "struct sockaddr"), and some use the new BSD scheme.
|
||||
*
|
||||
* Some versions of GNU libc use neither scheme, but has an "SA_LEN()"
|
||||
* macro that determines the size based on the address family. Other
|
||||
* versions don't have "SA_LEN()" (as it was in drafts of RFC 2553
|
||||
* but not in the final version).
|
||||
*
|
||||
* We assume that a UNIX that doesn't have "getifaddrs()" and doesn't have
|
||||
* SIOCGLIFCONF, but has SIOCGIFCONF, uses "struct sockaddr" for the
|
||||
* address in an entry returned by SIOCGIFCONF.
|
||||
*/
|
||||
#ifndef SA_LEN
|
||||
#ifdef HAVE_SOCKADDR_SA_LEN
|
||||
#define SA_LEN(addr) ((addr)->sa_len)
|
||||
#else /* HAVE_SOCKADDR_SA_LEN */
|
||||
#define SA_LEN(addr) (sizeof (struct sockaddr))
|
||||
#endif /* HAVE_SOCKADDR_SA_LEN */
|
||||
#endif /* SA_LEN */
|
||||
|
||||
/*
|
||||
* This is also fun.
|
||||
*
|
||||
* There is no ioctl that returns the amount of space required for all
|
||||
* the data that SIOCGIFCONF could return, and if a buffer is supplied
|
||||
* that's not large enough for all the data SIOCGIFCONF could return,
|
||||
* on at least some platforms it just returns the data that'd fit with
|
||||
* no indication that there wasn't enough room for all the data, much
|
||||
* less an indication of how much more room is required.
|
||||
*
|
||||
* The only way to ensure that we got all the data is to pass a buffer
|
||||
* large enough that the amount of space in the buffer *not* filled in
|
||||
* is greater than the largest possible entry.
|
||||
*
|
||||
* We assume that's "sizeof(ifreq.ifr_name)" plus 255, under the assumption
|
||||
* that no address is more than 255 bytes (on systems where the "sa_len"
|
||||
* field in a "struct sockaddr" is 1 byte, e.g. newer BSDs, that's the
|
||||
* case, and addresses are unlikely to be bigger than that in any case).
|
||||
*/
|
||||
#define MAX_SA_LEN 255
|
||||
|
||||
/*
|
||||
* Get a list of all interfaces that are up and that we can open.
|
||||
* Returns -1 on error, 0 otherwise.
|
||||
* The list, as returned through "alldevsp", may be null if no interfaces
|
||||
* were up and could be opened.
|
||||
*
|
||||
* This is the implementation used on platforms that have SIOCGIFCONF but
|
||||
* don't have any other mechanism for getting a list of interfaces.
|
||||
*
|
||||
* XXX - or platforms that have other, better mechanisms but for which
|
||||
* we don't yet have code to use that mechanism; I think there's a better
|
||||
* way on Linux, for example, but if that better way is "getifaddrs()",
|
||||
* we already have that.
|
||||
*/
|
||||
int
|
||||
pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf,
|
||||
int (*check_usable)(const char *))
|
||||
{
|
||||
pcap_if_t *devlist = NULL;
|
||||
register int fd;
|
||||
register struct ifreq *ifrp, *ifend, *ifnext;
|
||||
size_t n;
|
||||
struct ifconf ifc;
|
||||
char *buf = NULL;
|
||||
unsigned buf_size;
|
||||
#if defined (HAVE_SOLARIS) || defined (HAVE_HPUX10_20_OR_LATER)
|
||||
char *p, *q;
|
||||
#endif
|
||||
struct ifreq ifrflags, ifrnetmask, ifrbroadaddr, ifrdstaddr;
|
||||
struct sockaddr *netmask, *broadaddr, *dstaddr;
|
||||
size_t netmask_size, broadaddr_size, dstaddr_size;
|
||||
int ret = 0;
|
||||
|
||||
/*
|
||||
* Create a socket from which to fetch the list of interfaces.
|
||||
*/
|
||||
fd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (fd < 0) {
|
||||
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"socket: %s", pcap_strerror(errno));
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Start with an 8K buffer, and keep growing the buffer until
|
||||
* we have more than "sizeof(ifrp->ifr_name) + MAX_SA_LEN"
|
||||
* bytes left over in the buffer or we fail to get the
|
||||
* interface list for some reason other than EINVAL (which is
|
||||
* presumed here to mean "buffer is too small").
|
||||
*/
|
||||
buf_size = 8192;
|
||||
for (;;) {
|
||||
buf = malloc(buf_size);
|
||||
if (buf == NULL) {
|
||||
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"malloc: %s", pcap_strerror(errno));
|
||||
(void)close(fd);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
ifc.ifc_len = buf_size;
|
||||
ifc.ifc_buf = buf;
|
||||
memset(buf, 0, buf_size);
|
||||
if (ioctl(fd, SIOCGIFCONF, (char *)&ifc) < 0
|
||||
&& errno != EINVAL) {
|
||||
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"SIOCGIFCONF: %s", pcap_strerror(errno));
|
||||
(void)close(fd);
|
||||
free(buf);
|
||||
return (-1);
|
||||
}
|
||||
if (ifc.ifc_len < buf_size &&
|
||||
(buf_size - ifc.ifc_len) > sizeof(ifrp->ifr_name) + MAX_SA_LEN)
|
||||
break;
|
||||
free(buf);
|
||||
buf_size *= 2;
|
||||
}
|
||||
|
||||
ifrp = (struct ifreq *)buf;
|
||||
ifend = (struct ifreq *)(buf + ifc.ifc_len);
|
||||
|
||||
for (; ifrp < ifend; ifrp = ifnext) {
|
||||
/*
|
||||
* XXX - what if this isn't an IPv4 address? Can
|
||||
* we still get the netmask, etc. with ioctls on
|
||||
* an IPv4 socket?
|
||||
*
|
||||
* The answer is probably platform-dependent, and
|
||||
* if the answer is "no" on more than one platform,
|
||||
* the way you work around it is probably platform-
|
||||
* dependent as well.
|
||||
*/
|
||||
n = SA_LEN(&ifrp->ifr_addr) + sizeof(ifrp->ifr_name);
|
||||
if (n < sizeof(*ifrp))
|
||||
ifnext = ifrp + 1;
|
||||
else
|
||||
ifnext = (struct ifreq *)((char *)ifrp + n);
|
||||
|
||||
/*
|
||||
* XXX - The 32-bit compatibility layer for Linux on IA-64
|
||||
* is slightly broken. It correctly converts the structures
|
||||
* to and from kernel land from 64 bit to 32 bit but
|
||||
* doesn't update ifc.ifc_len, leaving it larger than the
|
||||
* amount really used. This means we read off the end
|
||||
* of the buffer and encounter an interface with an
|
||||
* "empty" name. Since this is highly unlikely to ever
|
||||
* occur in a valid case we can just finish looking for
|
||||
* interfaces if we see an empty name.
|
||||
*/
|
||||
if (!(*ifrp->ifr_name))
|
||||
break;
|
||||
|
||||
/*
|
||||
* Skip entries that begin with "dummy".
|
||||
* XXX - what are these? Is this Linux-specific?
|
||||
* Are there platforms on which we shouldn't do this?
|
||||
*/
|
||||
if (strncmp(ifrp->ifr_name, "dummy", 5) == 0)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* Can we capture on this device?
|
||||
*/
|
||||
if (!(*check_usable)(ifrp->ifr_name)) {
|
||||
/*
|
||||
* No.
|
||||
*/
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the flags for this interface.
|
||||
*/
|
||||
strncpy(ifrflags.ifr_name, ifrp->ifr_name,
|
||||
sizeof(ifrflags.ifr_name));
|
||||
if (ioctl(fd, SIOCGIFFLAGS, (char *)&ifrflags) < 0) {
|
||||
if (errno == ENXIO)
|
||||
continue;
|
||||
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"SIOCGIFFLAGS: %.*s: %s",
|
||||
(int)sizeof(ifrflags.ifr_name),
|
||||
ifrflags.ifr_name,
|
||||
pcap_strerror(errno));
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the netmask for this address on this interface.
|
||||
*/
|
||||
strncpy(ifrnetmask.ifr_name, ifrp->ifr_name,
|
||||
sizeof(ifrnetmask.ifr_name));
|
||||
memcpy(&ifrnetmask.ifr_addr, &ifrp->ifr_addr,
|
||||
sizeof(ifrnetmask.ifr_addr));
|
||||
if (ioctl(fd, SIOCGIFNETMASK, (char *)&ifrnetmask) < 0) {
|
||||
if (errno == EADDRNOTAVAIL) {
|
||||
/*
|
||||
* Not available.
|
||||
*/
|
||||
netmask = NULL;
|
||||
netmask_size = 0;
|
||||
} else {
|
||||
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"SIOCGIFNETMASK: %.*s: %s",
|
||||
(int)sizeof(ifrnetmask.ifr_name),
|
||||
ifrnetmask.ifr_name,
|
||||
pcap_strerror(errno));
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
netmask = &ifrnetmask.ifr_addr;
|
||||
netmask_size = SA_LEN(netmask);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the broadcast address for this address on this
|
||||
* interface (if any).
|
||||
*/
|
||||
if (ifrflags.ifr_flags & IFF_BROADCAST) {
|
||||
strncpy(ifrbroadaddr.ifr_name, ifrp->ifr_name,
|
||||
sizeof(ifrbroadaddr.ifr_name));
|
||||
memcpy(&ifrbroadaddr.ifr_addr, &ifrp->ifr_addr,
|
||||
sizeof(ifrbroadaddr.ifr_addr));
|
||||
if (ioctl(fd, SIOCGIFBRDADDR,
|
||||
(char *)&ifrbroadaddr) < 0) {
|
||||
if (errno == EADDRNOTAVAIL) {
|
||||
/*
|
||||
* Not available.
|
||||
*/
|
||||
broadaddr = NULL;
|
||||
broadaddr_size = 0;
|
||||
} else {
|
||||
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"SIOCGIFBRDADDR: %.*s: %s",
|
||||
(int)sizeof(ifrbroadaddr.ifr_name),
|
||||
ifrbroadaddr.ifr_name,
|
||||
pcap_strerror(errno));
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
broadaddr = &ifrbroadaddr.ifr_broadaddr;
|
||||
broadaddr_size = SA_LEN(broadaddr);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Not a broadcast interface, so no broadcast
|
||||
* address.
|
||||
*/
|
||||
broadaddr = NULL;
|
||||
broadaddr_size = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the destination address for this address on this
|
||||
* interface (if any).
|
||||
*/
|
||||
if (ifrflags.ifr_flags & IFF_POINTOPOINT) {
|
||||
strncpy(ifrdstaddr.ifr_name, ifrp->ifr_name,
|
||||
sizeof(ifrdstaddr.ifr_name));
|
||||
memcpy(&ifrdstaddr.ifr_addr, &ifrp->ifr_addr,
|
||||
sizeof(ifrdstaddr.ifr_addr));
|
||||
if (ioctl(fd, SIOCGIFDSTADDR,
|
||||
(char *)&ifrdstaddr) < 0) {
|
||||
if (errno == EADDRNOTAVAIL) {
|
||||
/*
|
||||
* Not available.
|
||||
*/
|
||||
dstaddr = NULL;
|
||||
dstaddr_size = 0;
|
||||
} else {
|
||||
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"SIOCGIFDSTADDR: %.*s: %s",
|
||||
(int)sizeof(ifrdstaddr.ifr_name),
|
||||
ifrdstaddr.ifr_name,
|
||||
pcap_strerror(errno));
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
dstaddr = &ifrdstaddr.ifr_dstaddr;
|
||||
dstaddr_size = SA_LEN(dstaddr);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Not a point-to-point interface, so no destination
|
||||
* address.
|
||||
*/
|
||||
dstaddr = NULL;
|
||||
dstaddr_size = 0;
|
||||
}
|
||||
|
||||
#if defined (HAVE_SOLARIS) || defined (HAVE_HPUX10_20_OR_LATER)
|
||||
/*
|
||||
* If this entry has a colon followed by a number at
|
||||
* the end, it's a logical interface. Those are just
|
||||
* the way you assign multiple IP addresses to a real
|
||||
* interface, so an entry for a logical interface should
|
||||
* be treated like the entry for the real interface;
|
||||
* we do that by stripping off the ":" and the number.
|
||||
*/
|
||||
p = strchr(ifrp->ifr_name, ':');
|
||||
if (p != NULL) {
|
||||
/*
|
||||
* We have a ":"; is it followed by a number?
|
||||
*/
|
||||
q = p + 1;
|
||||
while (isdigit((unsigned char)*q))
|
||||
q++;
|
||||
if (*q == '\0') {
|
||||
/*
|
||||
* All digits after the ":" until the end.
|
||||
* Strip off the ":" and everything after
|
||||
* it.
|
||||
*/
|
||||
*p = '\0';
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Add information for this address to the list.
|
||||
*/
|
||||
if (add_addr_to_iflist(&devlist, ifrp->ifr_name,
|
||||
if_flags_to_pcap_flags(ifrp->ifr_name, ifrflags.ifr_flags),
|
||||
&ifrp->ifr_addr, SA_LEN(&ifrp->ifr_addr),
|
||||
netmask, netmask_size, broadaddr, broadaddr_size,
|
||||
dstaddr, dstaddr_size, errbuf) < 0) {
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
free(buf);
|
||||
(void)close(fd);
|
||||
|
||||
if (ret == -1) {
|
||||
/*
|
||||
* We had an error; free the list we've been constructing.
|
||||
*/
|
||||
if (devlist != NULL) {
|
||||
pcap_freealldevs(devlist);
|
||||
devlist = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
*alldevsp = devlist;
|
||||
return (ret);
|
||||
}
|
@ -1,359 +0,0 @@
|
||||
/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */
|
||||
/*
|
||||
* Copyright (c) 1994, 1995, 1996, 1997, 1998
|
||||
* 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 Computer Systems
|
||||
* Engineering Group at Lawrence Berkeley Laboratory.
|
||||
* 4. Neither the name of the University nor of the Laboratory 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#ifdef HAVE_SYS_SOCKIO_H
|
||||
#include <sys/sockio.h>
|
||||
#endif
|
||||
#include <sys/time.h> /* concession to AIX */
|
||||
|
||||
struct mbuf; /* Squelch compiler warnings on some platforms for */
|
||||
struct rtentry; /* declarations in <net/if.h> */
|
||||
#include <net/if.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <memory.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "pcap-int.h"
|
||||
|
||||
#ifdef HAVE_OS_PROTO_H
|
||||
#include "os-proto.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Get a list of all interfaces that are up and that we can open.
|
||||
* Returns -1 on error, 0 otherwise.
|
||||
* The list, as returned through "alldevsp", may be null if no interfaces
|
||||
* were up and could be opened.
|
||||
*
|
||||
* This is the implementation used on platforms that have SIOCGLIFCONF
|
||||
* but don't have "getifaddrs()". (Solaris 8 and later; we use
|
||||
* SIOCGLIFCONF rather than SIOCGIFCONF in order to get IPv6 addresses.)
|
||||
*/
|
||||
int
|
||||
pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf,
|
||||
int (*check_usable)(const char *))
|
||||
{
|
||||
pcap_if_t *devlist = NULL;
|
||||
register int fd4, fd6, fd;
|
||||
register struct lifreq *ifrp, *ifend;
|
||||
struct lifnum ifn;
|
||||
struct lifconf ifc;
|
||||
char *buf = NULL;
|
||||
unsigned buf_size;
|
||||
#ifdef HAVE_SOLARIS
|
||||
char *p, *q;
|
||||
#endif
|
||||
struct lifreq ifrflags, ifrnetmask, ifrbroadaddr, ifrdstaddr;
|
||||
struct sockaddr *netmask, *broadaddr, *dstaddr;
|
||||
int ret = 0;
|
||||
|
||||
/*
|
||||
* Create a socket from which to fetch the list of interfaces,
|
||||
* and from which to fetch IPv4 information.
|
||||
*/
|
||||
fd4 = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (fd4 < 0) {
|
||||
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"socket: %s", pcap_strerror(errno));
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Create a socket from which to fetch IPv6 information.
|
||||
*/
|
||||
fd6 = socket(AF_INET6, SOCK_DGRAM, 0);
|
||||
if (fd6 < 0) {
|
||||
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"socket: %s", pcap_strerror(errno));
|
||||
(void)close(fd4);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* How many entries will SIOCGLIFCONF return?
|
||||
*/
|
||||
ifn.lifn_family = AF_UNSPEC;
|
||||
ifn.lifn_flags = 0;
|
||||
ifn.lifn_count = 0;
|
||||
if (ioctl(fd4, SIOCGLIFNUM, (char *)&ifn) < 0) {
|
||||
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"SIOCGLIFNUM: %s", pcap_strerror(errno));
|
||||
(void)close(fd6);
|
||||
(void)close(fd4);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate a buffer for those entries.
|
||||
*/
|
||||
buf_size = ifn.lifn_count * sizeof (struct lifreq);
|
||||
buf = malloc(buf_size);
|
||||
if (buf == NULL) {
|
||||
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"malloc: %s", pcap_strerror(errno));
|
||||
(void)close(fd6);
|
||||
(void)close(fd4);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the entries.
|
||||
*/
|
||||
ifc.lifc_len = buf_size;
|
||||
ifc.lifc_buf = buf;
|
||||
ifc.lifc_family = AF_UNSPEC;
|
||||
ifc.lifc_flags = 0;
|
||||
memset(buf, 0, buf_size);
|
||||
if (ioctl(fd4, SIOCGLIFCONF, (char *)&ifc) < 0) {
|
||||
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"SIOCGLIFCONF: %s", pcap_strerror(errno));
|
||||
(void)close(fd6);
|
||||
(void)close(fd4);
|
||||
free(buf);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Loop over the entries.
|
||||
*/
|
||||
ifrp = (struct lifreq *)buf;
|
||||
ifend = (struct lifreq *)(buf + ifc.lifc_len);
|
||||
|
||||
for (; ifrp < ifend; ifrp++) {
|
||||
/*
|
||||
* Skip entries that begin with "dummy".
|
||||
* XXX - what are these? Is this Linux-specific?
|
||||
* Are there platforms on which we shouldn't do this?
|
||||
*/
|
||||
if (strncmp(ifrp->lifr_name, "dummy", 5) == 0)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* Can we capture on this device?
|
||||
*/
|
||||
if (!(*check_usable)(ifrp->lifr_name)) {
|
||||
/*
|
||||
* No.
|
||||
*/
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* IPv6 or not?
|
||||
*/
|
||||
if (((struct sockaddr *)&ifrp->lifr_addr)->sa_family == AF_INET6)
|
||||
fd = fd6;
|
||||
else
|
||||
fd = fd4;
|
||||
|
||||
/*
|
||||
* Get the flags for this interface.
|
||||
*/
|
||||
strncpy(ifrflags.lifr_name, ifrp->lifr_name,
|
||||
sizeof(ifrflags.lifr_name));
|
||||
if (ioctl(fd, SIOCGLIFFLAGS, (char *)&ifrflags) < 0) {
|
||||
if (errno == ENXIO)
|
||||
continue;
|
||||
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"SIOCGLIFFLAGS: %.*s: %s",
|
||||
(int)sizeof(ifrflags.lifr_name),
|
||||
ifrflags.lifr_name,
|
||||
pcap_strerror(errno));
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the netmask for this address on this interface.
|
||||
*/
|
||||
strncpy(ifrnetmask.lifr_name, ifrp->lifr_name,
|
||||
sizeof(ifrnetmask.lifr_name));
|
||||
memcpy(&ifrnetmask.lifr_addr, &ifrp->lifr_addr,
|
||||
sizeof(ifrnetmask.lifr_addr));
|
||||
if (ioctl(fd, SIOCGLIFNETMASK, (char *)&ifrnetmask) < 0) {
|
||||
if (errno == EADDRNOTAVAIL) {
|
||||
/*
|
||||
* Not available.
|
||||
*/
|
||||
netmask = NULL;
|
||||
} else {
|
||||
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"SIOCGLIFNETMASK: %.*s: %s",
|
||||
(int)sizeof(ifrnetmask.lifr_name),
|
||||
ifrnetmask.lifr_name,
|
||||
pcap_strerror(errno));
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
} else
|
||||
netmask = (struct sockaddr *)&ifrnetmask.lifr_addr;
|
||||
|
||||
/*
|
||||
* Get the broadcast address for this address on this
|
||||
* interface (if any).
|
||||
*/
|
||||
if (ifrflags.lifr_flags & IFF_BROADCAST) {
|
||||
strncpy(ifrbroadaddr.lifr_name, ifrp->lifr_name,
|
||||
sizeof(ifrbroadaddr.lifr_name));
|
||||
memcpy(&ifrbroadaddr.lifr_addr, &ifrp->lifr_addr,
|
||||
sizeof(ifrbroadaddr.lifr_addr));
|
||||
if (ioctl(fd, SIOCGLIFBRDADDR,
|
||||
(char *)&ifrbroadaddr) < 0) {
|
||||
if (errno == EADDRNOTAVAIL) {
|
||||
/*
|
||||
* Not available.
|
||||
*/
|
||||
broadaddr = NULL;
|
||||
} else {
|
||||
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"SIOCGLIFBRDADDR: %.*s: %s",
|
||||
(int)sizeof(ifrbroadaddr.lifr_name),
|
||||
ifrbroadaddr.lifr_name,
|
||||
pcap_strerror(errno));
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
} else
|
||||
broadaddr = (struct sockaddr *)&ifrbroadaddr.lifr_broadaddr;
|
||||
} else {
|
||||
/*
|
||||
* Not a broadcast interface, so no broadcast
|
||||
* address.
|
||||
*/
|
||||
broadaddr = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the destination address for this address on this
|
||||
* interface (if any).
|
||||
*/
|
||||
if (ifrflags.lifr_flags & IFF_POINTOPOINT) {
|
||||
strncpy(ifrdstaddr.lifr_name, ifrp->lifr_name,
|
||||
sizeof(ifrdstaddr.lifr_name));
|
||||
memcpy(&ifrdstaddr.lifr_addr, &ifrp->lifr_addr,
|
||||
sizeof(ifrdstaddr.lifr_addr));
|
||||
if (ioctl(fd, SIOCGLIFDSTADDR,
|
||||
(char *)&ifrdstaddr) < 0) {
|
||||
if (errno == EADDRNOTAVAIL) {
|
||||
/*
|
||||
* Not available.
|
||||
*/
|
||||
dstaddr = NULL;
|
||||
} else {
|
||||
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"SIOCGLIFDSTADDR: %.*s: %s",
|
||||
(int)sizeof(ifrdstaddr.lifr_name),
|
||||
ifrdstaddr.lifr_name,
|
||||
pcap_strerror(errno));
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
} else
|
||||
dstaddr = (struct sockaddr *)&ifrdstaddr.lifr_dstaddr;
|
||||
} else
|
||||
dstaddr = NULL;
|
||||
|
||||
#ifdef HAVE_SOLARIS
|
||||
/*
|
||||
* If this entry has a colon followed by a number at
|
||||
* the end, it's a logical interface. Those are just
|
||||
* the way you assign multiple IP addresses to a real
|
||||
* interface, so an entry for a logical interface should
|
||||
* be treated like the entry for the real interface;
|
||||
* we do that by stripping off the ":" and the number.
|
||||
*/
|
||||
p = strchr(ifrp->lifr_name, ':');
|
||||
if (p != NULL) {
|
||||
/*
|
||||
* We have a ":"; is it followed by a number?
|
||||
*/
|
||||
q = p + 1;
|
||||
while (isdigit((unsigned char)*q))
|
||||
q++;
|
||||
if (*q == '\0') {
|
||||
/*
|
||||
* All digits after the ":" until the end.
|
||||
* Strip off the ":" and everything after
|
||||
* it.
|
||||
*/
|
||||
*p = '\0';
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Add information for this address to the list.
|
||||
*/
|
||||
if (add_addr_to_iflist(&devlist, ifrp->lifr_name,
|
||||
if_flags_to_pcap_flags(ifrp->lifr_name, ifrflags.lifr_flags),
|
||||
(struct sockaddr *)&ifrp->lifr_addr,
|
||||
sizeof (struct sockaddr_storage),
|
||||
netmask, sizeof (struct sockaddr_storage),
|
||||
broadaddr, sizeof (struct sockaddr_storage),
|
||||
dstaddr, sizeof (struct sockaddr_storage), errbuf) < 0) {
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
free(buf);
|
||||
(void)close(fd6);
|
||||
(void)close(fd4);
|
||||
|
||||
if (ret == -1) {
|
||||
/*
|
||||
* We had an error; free the list we've been constructing.
|
||||
*/
|
||||
if (devlist != NULL) {
|
||||
pcap_freealldevs(devlist);
|
||||
devlist = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
*alldevsp = devlist;
|
||||
return (ret);
|
||||
}
|
@ -1,884 +0,0 @@
|
||||
/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */
|
||||
/*
|
||||
* Copyright (c) 1994, 1995, 1996, 1997, 1998
|
||||
* 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 Computer Systems
|
||||
* Engineering Group at Lawrence Berkeley Laboratory.
|
||||
* 4. Neither the name of the University nor of the Laboratory 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <pcap-stdinc.h>
|
||||
#else /* _WIN32 */
|
||||
|
||||
#include <sys/param.h>
|
||||
#ifndef MSDOS
|
||||
#include <sys/file.h>
|
||||
#endif
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#ifdef HAVE_SYS_SOCKIO_H
|
||||
#include <sys/sockio.h>
|
||||
#endif
|
||||
|
||||
struct mbuf; /* Squelch compiler warnings on some platforms for */
|
||||
struct rtentry; /* declarations in <net/if.h> */
|
||||
#include <net/if.h>
|
||||
#include <netinet/in.h>
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <memory.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#if !defined(_WIN32) && !defined(__BORLANDC__)
|
||||
#include <unistd.h>
|
||||
#endif /* !_WIN32 && !__BORLANDC__ */
|
||||
#ifdef HAVE_LIMITS_H
|
||||
#include <limits.h>
|
||||
#else
|
||||
#define INT_MAX 2147483647
|
||||
#endif
|
||||
|
||||
#include "pcap-int.h"
|
||||
|
||||
#ifdef HAVE_OS_PROTO_H
|
||||
#include "os-proto.h"
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
/* Not all systems have IFF_LOOPBACK */
|
||||
#ifdef IFF_LOOPBACK
|
||||
#define ISLOOPBACK(name, flags) ((flags) & IFF_LOOPBACK)
|
||||
#else
|
||||
#define ISLOOPBACK(name, flags) ((name)[0] == 'l' && (name)[1] == 'o' && \
|
||||
(isdigit((unsigned char)((name)[2])) || (name)[2] == '\0'))
|
||||
#endif
|
||||
|
||||
#ifdef IFF_UP
|
||||
#define ISUP(flags) ((flags) & IFF_UP)
|
||||
#else
|
||||
#define ISUP(flags) 0
|
||||
#endif
|
||||
|
||||
#ifdef IFF_RUNNING
|
||||
#define ISRUNNING(flags) ((flags) & IFF_RUNNING)
|
||||
#else
|
||||
#define ISRUNNING(flags) 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Map UN*X-style interface flags to libpcap flags.
|
||||
*/
|
||||
bpf_u_int32
|
||||
if_flags_to_pcap_flags(const char *name _U_, u_int if_flags)
|
||||
{
|
||||
bpf_u_int32 pcap_flags;
|
||||
|
||||
pcap_flags = 0;
|
||||
if (ISLOOPBACK(name, if_flags))
|
||||
pcap_flags |= PCAP_IF_LOOPBACK;
|
||||
if (ISUP(if_flags))
|
||||
pcap_flags |= PCAP_IF_UP;
|
||||
if (ISRUNNING(if_flags))
|
||||
pcap_flags |= PCAP_IF_RUNNING;
|
||||
return (pcap_flags);
|
||||
}
|
||||
#endif
|
||||
|
||||
static struct sockaddr *
|
||||
dup_sockaddr(struct sockaddr *sa, size_t sa_length)
|
||||
{
|
||||
struct sockaddr *newsa;
|
||||
|
||||
if ((newsa = malloc(sa_length)) == NULL)
|
||||
return (NULL);
|
||||
return (memcpy(newsa, sa, sa_length));
|
||||
}
|
||||
|
||||
/*
|
||||
* Construct a "figure of merit" for an interface, for use when sorting
|
||||
* the list of interfaces, in which interfaces that are up are superior
|
||||
* to interfaces that aren't up, interfaces that are up and running are
|
||||
* superior to interfaces that are up but not running, and non-loopback
|
||||
* interfaces that are up and running are superior to loopback interfaces,
|
||||
* and interfaces with the same flags have a figure of merit that's higher
|
||||
* the lower the instance number.
|
||||
*
|
||||
* The goal is to try to put the interfaces most likely to be useful for
|
||||
* capture at the beginning of the list.
|
||||
*
|
||||
* The figure of merit, which is lower the "better" the interface is,
|
||||
* has the uppermost bit set if the interface isn't running, the bit
|
||||
* below that set if the interface isn't up, the bit below that set
|
||||
* if the interface is a loopback interface, and the interface index
|
||||
* in the 29 bits below that. (Yes, we assume u_int is 32 bits.)
|
||||
*/
|
||||
static u_int
|
||||
get_figure_of_merit(pcap_if_t *dev)
|
||||
{
|
||||
const char *cp;
|
||||
u_int n;
|
||||
|
||||
if (strcmp(dev->name, "any") == 0) {
|
||||
/*
|
||||
* Give the "any" device an artificially high instance
|
||||
* number, so it shows up after all other non-loopback
|
||||
* interfaces.
|
||||
*/
|
||||
n = 0x1FFFFFFF; /* 29 all-1 bits */
|
||||
} else {
|
||||
/*
|
||||
* A number at the end of the device name string is
|
||||
* assumed to be a unit number.
|
||||
*/
|
||||
cp = dev->name + strlen(dev->name) - 1;
|
||||
while (cp-1 >= dev->name && *(cp-1) >= '0' && *(cp-1) <= '9')
|
||||
cp--;
|
||||
if (*cp >= '0' && *cp <= '9')
|
||||
n = atoi(cp);
|
||||
else
|
||||
n = 0;
|
||||
}
|
||||
if (!(dev->flags & PCAP_IF_RUNNING))
|
||||
n |= 0x80000000;
|
||||
if (!(dev->flags & PCAP_IF_UP))
|
||||
n |= 0x40000000;
|
||||
if (dev->flags & PCAP_IF_LOOPBACK)
|
||||
n |= 0x20000000;
|
||||
return (n);
|
||||
}
|
||||
|
||||
/*
|
||||
* Try to get a description for a given device.
|
||||
* Returns a mallocated description if it could and NULL if it couldn't.
|
||||
*
|
||||
* XXX - on FreeBSDs that support it, should it get the sysctl named
|
||||
* "dev.{adapter family name}.{adapter unit}.%desc" to get a description
|
||||
* of the adapter? Note that "dev.an.0.%desc" is "Aironet PC4500/PC4800"
|
||||
* with my Cisco 350 card, so the name isn't entirely descriptive. The
|
||||
* "dev.an.0.%pnpinfo" has a better description, although one might argue
|
||||
* that the problem is really a driver bug - if it can find out that it's
|
||||
* a Cisco 340 or 350, rather than an old Aironet card, it should use
|
||||
* that in the description.
|
||||
*
|
||||
* Do NetBSD, DragonflyBSD, or OpenBSD support this as well? FreeBSD
|
||||
* and OpenBSD let you get a description, but it's not generated by the OS,
|
||||
* it's set with another ioctl that ifconfig supports; we use that to get
|
||||
* a description in FreeBSD and OpenBSD, but if there is no such
|
||||
* description available, it still might be nice to get some description
|
||||
* string based on the device type or something such as that.
|
||||
*
|
||||
* In OS X, the System Configuration framework can apparently return
|
||||
* names in 10.4 and later.
|
||||
*
|
||||
* It also appears that freedesktop.org's HAL offers an "info.product"
|
||||
* string, but the HAL specification says it "should not be used in any
|
||||
* UI" and "subsystem/capability specific properties" should be used
|
||||
* instead and, in any case, I think HAL is being deprecated in
|
||||
* favor of other stuff such as DeviceKit. DeviceKit doesn't appear
|
||||
* to have any obvious product information for devices, but maybe
|
||||
* I haven't looked hard enough.
|
||||
*
|
||||
* Using the System Configuration framework, or HAL, or DeviceKit, or
|
||||
* whatever, would require that libpcap applications be linked with
|
||||
* the frameworks/libraries in question. That shouldn't be a problem
|
||||
* for programs linking with the shared version of libpcap (unless
|
||||
* you're running on AIX - which I think is the only UN*X that doesn't
|
||||
* support linking a shared library with other libraries on which it
|
||||
* depends, and having an executable linked only with the first shared
|
||||
* library automatically pick up the other libraries when started -
|
||||
* and using HAL or whatever). Programs linked with the static
|
||||
* version of libpcap would have to use pcap-config with the --static
|
||||
* flag in order to get the right linker flags in order to pick up
|
||||
* the additional libraries/frameworks; those programs need that anyway
|
||||
* for libpcap 1.1 and beyond on Linux, as, by default, it requires
|
||||
* -lnl.
|
||||
*
|
||||
* Do any other UN*Xes, or desktop environments support getting a
|
||||
* description?
|
||||
*/
|
||||
static char *
|
||||
get_if_description(const char *name)
|
||||
{
|
||||
#ifdef SIOCGIFDESCR
|
||||
char *description = NULL;
|
||||
int s;
|
||||
struct ifreq ifrdesc;
|
||||
#ifndef IFDESCRSIZE
|
||||
size_t descrlen = 64;
|
||||
#else
|
||||
size_t descrlen = IFDESCRSIZE;
|
||||
#endif /* IFDESCRSIZE */
|
||||
|
||||
/*
|
||||
* Get the description for the interface.
|
||||
*/
|
||||
memset(&ifrdesc, 0, sizeof ifrdesc);
|
||||
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) {
|
||||
ifrdesc.ifr_buffer.buffer = description;
|
||||
ifrdesc.ifr_buffer.length = descrlen;
|
||||
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) {
|
||||
/*
|
||||
* Description is empty, so discard it.
|
||||
*/
|
||||
free(description);
|
||||
description = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
/*
|
||||
* For FreeBSD, if we didn't get a description, and this is
|
||||
* a device with a name of the form usbusN, label it as a USB
|
||||
* bus.
|
||||
*/
|
||||
if (description == NULL) {
|
||||
if (strncmp(name, "usbus", 5) == 0) {
|
||||
/*
|
||||
* OK, it begins with "usbus".
|
||||
*/
|
||||
long busnum;
|
||||
char *p;
|
||||
|
||||
errno = 0;
|
||||
busnum = strtol(name + 5, &p, 10);
|
||||
if (errno == 0 && p != name + 5 && *p == '\0' &&
|
||||
busnum >= 0 && busnum <= INT_MAX) {
|
||||
/*
|
||||
* OK, it's a valid number that's not
|
||||
* bigger than INT_MAX. Construct
|
||||
* a description from it.
|
||||
*/
|
||||
static const char descr_prefix[] = "USB bus number ";
|
||||
size_t descr_size;
|
||||
|
||||
/*
|
||||
* Allow enough room for a 32-bit bus number.
|
||||
* sizeof (descr_prefix) includes the
|
||||
* terminating NUL.
|
||||
*/
|
||||
descr_size = sizeof (descr_prefix) + 10;
|
||||
description = malloc(descr_size);
|
||||
if (description != NULL) {
|
||||
pcap_snprintf(description, descr_size,
|
||||
"%s%ld", descr_prefix, busnum);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return (description);
|
||||
#else /* SIOCGIFDESCR */
|
||||
return (NULL);
|
||||
#endif /* SIOCGIFDESCR */
|
||||
}
|
||||
|
||||
/*
|
||||
* Look for a given device in the specified list of devices.
|
||||
*
|
||||
* If we find it, return 0 and set *curdev_ret to point to it.
|
||||
*
|
||||
* If we don't find it, check whether we can open it:
|
||||
*
|
||||
* If that fails with PCAP_ERROR_NO_SUCH_DEVICE or
|
||||
* PCAP_ERROR_IFACE_NOT_UP, don't attempt to add an entry for
|
||||
* it, as that probably means it exists but doesn't support
|
||||
* packet capture.
|
||||
*
|
||||
* Otherwise, attempt to add an entry for it, with the specified
|
||||
* ifnet flags and description, and, if that succeeds, return 0
|
||||
* and set *curdev_ret to point to the new entry, otherwise
|
||||
* return PCAP_ERROR and set errbuf to an error message. If we
|
||||
* weren't given a description, try to get one.
|
||||
*/
|
||||
int
|
||||
add_or_find_if(pcap_if_t **curdev_ret, pcap_if_t **alldevs, const char *name,
|
||||
bpf_u_int32 flags, const char *description, char *errbuf)
|
||||
{
|
||||
pcap_t *p;
|
||||
pcap_if_t *curdev, *prevdev, *nextdev;
|
||||
u_int this_figure_of_merit, nextdev_figure_of_merit;
|
||||
char open_errbuf[PCAP_ERRBUF_SIZE];
|
||||
int ret;
|
||||
|
||||
/*
|
||||
* Is there already an entry in the list for this interface?
|
||||
*/
|
||||
for (curdev = *alldevs; curdev != NULL; curdev = curdev->next) {
|
||||
if (strcmp(name, curdev->name) == 0)
|
||||
break; /* yes, we found it */
|
||||
}
|
||||
|
||||
if (curdev == NULL) {
|
||||
/*
|
||||
* No, we didn't find it.
|
||||
*
|
||||
* Can we open this interface for live capture?
|
||||
*
|
||||
* We do this check so that interfaces that are
|
||||
* supplied by the interface enumeration mechanism
|
||||
* we're using but that don't support packet capture
|
||||
* aren't included in the list. Loopback interfaces
|
||||
* on Solaris are an example of this; we don't just
|
||||
* omit loopback interfaces on all platforms because
|
||||
* you *can* capture on loopback interfaces on some
|
||||
* OSes.
|
||||
*
|
||||
* On OS X, we don't do this check if the device
|
||||
* name begins with "wlt"; at least some versions
|
||||
* of OS X offer monitor mode capturing by having
|
||||
* a separate "monitor mode" device for each wireless
|
||||
* adapter, rather than by implementing the ioctls
|
||||
* that {Free,Net,Open,DragonFly}BSD provide.
|
||||
* Opening that device puts the adapter into monitor
|
||||
* mode, which, at least for some adapters, causes
|
||||
* them to deassociate from the network with which
|
||||
* they're associated.
|
||||
*
|
||||
* Instead, we try to open the corresponding "en"
|
||||
* device (so that we don't end up with, for users
|
||||
* without sufficient privilege to open capture
|
||||
* devices, a list of adapters that only includes
|
||||
* the wlt devices).
|
||||
*/
|
||||
#ifdef __APPLE__
|
||||
if (strncmp(name, "wlt", 3) == 0) {
|
||||
char *en_name;
|
||||
size_t en_name_len;
|
||||
|
||||
/*
|
||||
* Try to allocate a buffer for the "en"
|
||||
* device's name.
|
||||
*/
|
||||
en_name_len = strlen(name) - 1;
|
||||
en_name = malloc(en_name_len + 1);
|
||||
if (en_name == NULL) {
|
||||
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"malloc: %s", pcap_strerror(errno));
|
||||
return (-1);
|
||||
}
|
||||
strcpy(en_name, "en");
|
||||
strcat(en_name, name + 3);
|
||||
p = pcap_create(en_name, open_errbuf);
|
||||
free(en_name);
|
||||
} else
|
||||
#endif /* __APPLE */
|
||||
p = pcap_create(name, open_errbuf);
|
||||
if (p == NULL) {
|
||||
/*
|
||||
* The attempt to create the pcap_t failed;
|
||||
* that's probably an indication that we're
|
||||
* out of memory.
|
||||
*
|
||||
* Don't bother including this interface,
|
||||
* but don't treat it as an error.
|
||||
*/
|
||||
*curdev_ret = NULL;
|
||||
return (0);
|
||||
}
|
||||
/* Small snaplen, so we don't try to allocate much memory. */
|
||||
pcap_set_snaplen(p, 68);
|
||||
ret = pcap_activate(p);
|
||||
pcap_close(p);
|
||||
switch (ret) {
|
||||
|
||||
case PCAP_ERROR_NO_SUCH_DEVICE:
|
||||
case PCAP_ERROR_IFACE_NOT_UP:
|
||||
/*
|
||||
* We expect these two errors - they're the
|
||||
* reason we try to open the device.
|
||||
*
|
||||
* PCAP_ERROR_NO_SUCH_DEVICE typically means
|
||||
* "there's no such device *known to the
|
||||
* OS's capture mechanism*", so, even though
|
||||
* it might be a valid network interface, you
|
||||
* can't capture on it (e.g., the loopback
|
||||
* device in Solaris up to Solaris 10, or
|
||||
* the vmnet devices in OS X with VMware
|
||||
* Fusion). We don't include those devices
|
||||
* in our list of devices, as there's no
|
||||
* point in doing so - they're not available
|
||||
* for capture.
|
||||
*
|
||||
* PCAP_ERROR_IFACE_NOT_UP means that the
|
||||
* OS's capture mechanism doesn't work on
|
||||
* interfaces not marked as up; some capture
|
||||
* mechanisms *do* support that, so we no
|
||||
* longer reject those interfaces out of hand,
|
||||
* but we *do* want to reject them if they
|
||||
* can't be opened for capture.
|
||||
*/
|
||||
*curdev_ret = NULL;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Yes, we can open it, or we can't, for some other
|
||||
* reason.
|
||||
*
|
||||
* If we can open it, we want to offer it for
|
||||
* capture, as you can capture on it. If we can't,
|
||||
* we want to offer it for capture, so that, if
|
||||
* the user tries to capture on it, they'll get
|
||||
* an error and they'll know why they can't
|
||||
* capture on it (e.g., insufficient permissions)
|
||||
* or they'll report it as a problem (and then
|
||||
* have the error message to provide as information).
|
||||
*
|
||||
* Allocate a new entry.
|
||||
*/
|
||||
curdev = malloc(sizeof(pcap_if_t));
|
||||
if (curdev == NULL) {
|
||||
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"malloc: %s", pcap_strerror(errno));
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Fill in the entry.
|
||||
*/
|
||||
curdev->next = NULL;
|
||||
curdev->name = strdup(name);
|
||||
if (curdev->name == NULL) {
|
||||
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"malloc: %s", pcap_strerror(errno));
|
||||
free(curdev);
|
||||
return (-1);
|
||||
}
|
||||
if (description == NULL) {
|
||||
/*
|
||||
* We weren't handed a description for the
|
||||
* interface, so see if we can generate one
|
||||
* ourselves.
|
||||
*/
|
||||
curdev->description = get_if_description(name);
|
||||
} else {
|
||||
/*
|
||||
* We were handed a description; make a copy.
|
||||
*/
|
||||
curdev->description = strdup(description);
|
||||
if (curdev->description == NULL) {
|
||||
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"malloc: %s", pcap_strerror(errno));
|
||||
free(curdev->name);
|
||||
free(curdev);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
curdev->addresses = NULL; /* list starts out as empty */
|
||||
curdev->flags = flags;
|
||||
|
||||
/*
|
||||
* Add it to the list, in the appropriate location.
|
||||
* First, get the "figure of merit" for this
|
||||
* interface.
|
||||
*/
|
||||
this_figure_of_merit = get_figure_of_merit(curdev);
|
||||
|
||||
/*
|
||||
* Now look for the last interface with an figure of merit
|
||||
* less than or equal to the new interface's figure of
|
||||
* merit.
|
||||
*
|
||||
* We start with "prevdev" being NULL, meaning we're before
|
||||
* the first element in the list.
|
||||
*/
|
||||
prevdev = NULL;
|
||||
for (;;) {
|
||||
/*
|
||||
* Get the interface after this one.
|
||||
*/
|
||||
if (prevdev == NULL) {
|
||||
/*
|
||||
* The next element is the first element.
|
||||
*/
|
||||
nextdev = *alldevs;
|
||||
} else
|
||||
nextdev = prevdev->next;
|
||||
|
||||
/*
|
||||
* Are we at the end of the list?
|
||||
*/
|
||||
if (nextdev == NULL) {
|
||||
/*
|
||||
* Yes - we have to put the new entry
|
||||
* after "prevdev".
|
||||
*/
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Is the new interface's figure of merit less
|
||||
* than the next interface's figure of merit,
|
||||
* meaning that the new interface is better
|
||||
* than the next interface?
|
||||
*/
|
||||
nextdev_figure_of_merit = get_figure_of_merit(nextdev);
|
||||
if (this_figure_of_merit < nextdev_figure_of_merit) {
|
||||
/*
|
||||
* Yes - we should put the new entry
|
||||
* before "nextdev", i.e. after "prevdev".
|
||||
*/
|
||||
break;
|
||||
}
|
||||
|
||||
prevdev = nextdev;
|
||||
}
|
||||
|
||||
/*
|
||||
* Insert before "nextdev".
|
||||
*/
|
||||
curdev->next = nextdev;
|
||||
|
||||
/*
|
||||
* Insert after "prevdev" - unless "prevdev" is null,
|
||||
* in which case this is the first interface.
|
||||
*/
|
||||
if (prevdev == NULL) {
|
||||
/*
|
||||
* This is the first interface. Pass back a
|
||||
* pointer to it, and put "curdev" before
|
||||
* "nextdev".
|
||||
*/
|
||||
*alldevs = curdev;
|
||||
} else
|
||||
prevdev->next = curdev;
|
||||
}
|
||||
|
||||
*curdev_ret = curdev;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Try to get a description for a given device, and then look for that
|
||||
* device in the specified list of devices.
|
||||
*
|
||||
* If we find it, then, if the specified address isn't null, add it to
|
||||
* the list of addresses for the device and return 0.
|
||||
*
|
||||
* If we don't find it, check whether we can open it:
|
||||
*
|
||||
* If that fails with PCAP_ERROR_NO_SUCH_DEVICE or
|
||||
* PCAP_ERROR_IFACE_NOT_UP, don't attempt to add an entry for
|
||||
* it, as that probably means it exists but doesn't support
|
||||
* packet capture.
|
||||
*
|
||||
* Otherwise, attempt to add an entry for it, with the specified
|
||||
* ifnet flags, and, if that succeeds, add the specified address
|
||||
* to its list of addresses if that address is non-null, set
|
||||
* *curdev_ret to point to the new entry, and return 0, otherwise
|
||||
* return PCAP_ERROR and set errbuf to an error message.
|
||||
*
|
||||
* (We can get called with a null address because we might get a list
|
||||
* of interface name/address combinations from the underlying OS, with
|
||||
* the address being absent in some cases, rather than a list of
|
||||
* interfaces with each interface having a list of addresses, so this
|
||||
* call may be the only call made to add to the list, and we want to
|
||||
* add interfaces even if they have no addresses.)
|
||||
*/
|
||||
int
|
||||
add_addr_to_iflist(pcap_if_t **alldevs, const char *name, bpf_u_int32 flags,
|
||||
struct sockaddr *addr, size_t addr_size,
|
||||
struct sockaddr *netmask, size_t netmask_size,
|
||||
struct sockaddr *broadaddr, size_t broadaddr_size,
|
||||
struct sockaddr *dstaddr, size_t dstaddr_size,
|
||||
char *errbuf)
|
||||
{
|
||||
pcap_if_t *curdev;
|
||||
|
||||
if (add_or_find_if(&curdev, alldevs, name, flags, NULL, errbuf) == -1) {
|
||||
/*
|
||||
* Error - give up.
|
||||
*/
|
||||
return (-1);
|
||||
}
|
||||
if (curdev == NULL) {
|
||||
/*
|
||||
* Device wasn't added because it can't be opened.
|
||||
* Not a fatal error.
|
||||
*/
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (addr == NULL) {
|
||||
/*
|
||||
* There's no address to add; this entry just meant
|
||||
* "here's a new interface".
|
||||
*/
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* "curdev" is an entry for this interface, and we have an
|
||||
* address for it; add an entry for that address to the
|
||||
* interface's list of addresses.
|
||||
*
|
||||
* Allocate the new entry and fill it in.
|
||||
*/
|
||||
return (add_addr_to_dev(curdev, addr, addr_size, netmask,
|
||||
netmask_size, broadaddr, broadaddr_size, dstaddr,
|
||||
dstaddr_size, errbuf));
|
||||
}
|
||||
|
||||
/*
|
||||
* Add an entry to the list of addresses for an interface.
|
||||
* "curdev" is the entry for that interface.
|
||||
* If this is the first IP address added to the interface, move it
|
||||
* in the list as appropriate.
|
||||
*/
|
||||
int
|
||||
add_addr_to_dev(pcap_if_t *curdev,
|
||||
struct sockaddr *addr, size_t addr_size,
|
||||
struct sockaddr *netmask, size_t netmask_size,
|
||||
struct sockaddr *broadaddr, size_t broadaddr_size,
|
||||
struct sockaddr *dstaddr, size_t dstaddr_size,
|
||||
char *errbuf)
|
||||
{
|
||||
pcap_addr_t *curaddr, *prevaddr, *nextaddr;
|
||||
|
||||
curaddr = malloc(sizeof(pcap_addr_t));
|
||||
if (curaddr == NULL) {
|
||||
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"malloc: %s", pcap_strerror(errno));
|
||||
return (-1);
|
||||
}
|
||||
|
||||
curaddr->next = NULL;
|
||||
if (addr != NULL) {
|
||||
curaddr->addr = dup_sockaddr(addr, addr_size);
|
||||
if (curaddr->addr == NULL) {
|
||||
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"malloc: %s", pcap_strerror(errno));
|
||||
free(curaddr);
|
||||
return (-1);
|
||||
}
|
||||
} else
|
||||
curaddr->addr = NULL;
|
||||
|
||||
if (netmask != NULL) {
|
||||
curaddr->netmask = dup_sockaddr(netmask, netmask_size);
|
||||
if (curaddr->netmask == NULL) {
|
||||
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"malloc: %s", pcap_strerror(errno));
|
||||
if (curaddr->addr != NULL)
|
||||
free(curaddr->addr);
|
||||
free(curaddr);
|
||||
return (-1);
|
||||
}
|
||||
} else
|
||||
curaddr->netmask = NULL;
|
||||
|
||||
if (broadaddr != NULL) {
|
||||
curaddr->broadaddr = dup_sockaddr(broadaddr, broadaddr_size);
|
||||
if (curaddr->broadaddr == NULL) {
|
||||
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"malloc: %s", pcap_strerror(errno));
|
||||
if (curaddr->netmask != NULL)
|
||||
free(curaddr->netmask);
|
||||
if (curaddr->addr != NULL)
|
||||
free(curaddr->addr);
|
||||
free(curaddr);
|
||||
return (-1);
|
||||
}
|
||||
} else
|
||||
curaddr->broadaddr = NULL;
|
||||
|
||||
if (dstaddr != NULL) {
|
||||
curaddr->dstaddr = dup_sockaddr(dstaddr, dstaddr_size);
|
||||
if (curaddr->dstaddr == NULL) {
|
||||
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"malloc: %s", pcap_strerror(errno));
|
||||
if (curaddr->broadaddr != NULL)
|
||||
free(curaddr->broadaddr);
|
||||
if (curaddr->netmask != NULL)
|
||||
free(curaddr->netmask);
|
||||
if (curaddr->addr != NULL)
|
||||
free(curaddr->addr);
|
||||
free(curaddr);
|
||||
return (-1);
|
||||
}
|
||||
} else
|
||||
curaddr->dstaddr = NULL;
|
||||
|
||||
/*
|
||||
* Find the end of the list of addresses.
|
||||
*/
|
||||
for (prevaddr = curdev->addresses; prevaddr != NULL; prevaddr = nextaddr) {
|
||||
nextaddr = prevaddr->next;
|
||||
if (nextaddr == NULL) {
|
||||
/*
|
||||
* This is the end of the list.
|
||||
*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (prevaddr == NULL) {
|
||||
/*
|
||||
* The list was empty; this is the first member.
|
||||
*/
|
||||
curdev->addresses = curaddr;
|
||||
} else {
|
||||
/*
|
||||
* "prevaddr" is the last member of the list; append
|
||||
* this member to it.
|
||||
*/
|
||||
prevaddr->next = curaddr;
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Look for a given device in the specified list of devices.
|
||||
*
|
||||
* If we find it, return 0.
|
||||
*
|
||||
* If we don't find it, check whether we can open it:
|
||||
*
|
||||
* If that fails with PCAP_ERROR_NO_SUCH_DEVICE or
|
||||
* PCAP_ERROR_IFACE_NOT_UP, don't attempt to add an entry for
|
||||
* it, as that probably means it exists but doesn't support
|
||||
* packet capture.
|
||||
*
|
||||
* Otherwise, attempt to add an entry for it, with the specified
|
||||
* ifnet flags and description, and, if that succeeds, return 0
|
||||
* and set *curdev_ret to point to the new entry, otherwise
|
||||
* return PCAP_ERROR and set errbuf to an error message.
|
||||
*/
|
||||
int
|
||||
pcap_add_if(pcap_if_t **devlist, const char *name, u_int flags,
|
||||
const char *description, char *errbuf)
|
||||
{
|
||||
pcap_if_t *curdev;
|
||||
|
||||
return (add_or_find_if(&curdev, devlist, name, flags, description,
|
||||
errbuf));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Free a list of interfaces.
|
||||
*/
|
||||
void
|
||||
pcap_freealldevs(pcap_if_t *alldevs)
|
||||
{
|
||||
pcap_if_t *curdev, *nextdev;
|
||||
pcap_addr_t *curaddr, *nextaddr;
|
||||
|
||||
for (curdev = alldevs; curdev != NULL; curdev = nextdev) {
|
||||
nextdev = curdev->next;
|
||||
|
||||
/*
|
||||
* Free all addresses.
|
||||
*/
|
||||
for (curaddr = curdev->addresses; curaddr != NULL; curaddr = nextaddr) {
|
||||
nextaddr = curaddr->next;
|
||||
if (curaddr->addr)
|
||||
free(curaddr->addr);
|
||||
if (curaddr->netmask)
|
||||
free(curaddr->netmask);
|
||||
if (curaddr->broadaddr)
|
||||
free(curaddr->broadaddr);
|
||||
if (curaddr->dstaddr)
|
||||
free(curaddr->dstaddr);
|
||||
free(curaddr);
|
||||
}
|
||||
|
||||
/*
|
||||
* Free the name string.
|
||||
*/
|
||||
free(curdev->name);
|
||||
|
||||
/*
|
||||
* Free the description string, if any.
|
||||
*/
|
||||
if (curdev->description != NULL)
|
||||
free(curdev->description);
|
||||
|
||||
/*
|
||||
* Free the interface.
|
||||
*/
|
||||
free(curdev);
|
||||
}
|
||||
}
|
Binary file not shown.
@ -1,11 +0,0 @@
|
||||
#! /bin/sh
|
||||
echo '#include <pcap/export-defs.h>' > "$2"
|
||||
echo 'PCAP_API_DEF' >> "$2"
|
||||
if grep GIT "$1" >/dev/null; then
|
||||
read ver <"$1"
|
||||
echo $ver | tr -d '\012'
|
||||
date +_%Y_%m_%d
|
||||
else
|
||||
cat "$1"
|
||||
fi | sed -e 's/.*/char pcap_version[] = "&";/' >> "$2"
|
||||
|
@ -1,19 +0,0 @@
|
||||
#! /bin/sh
|
||||
print_version_string()
|
||||
{
|
||||
if grep GIT "$1" >/dev/null
|
||||
then
|
||||
read ver <"$1"
|
||||
echo $ver | tr -d '\012'
|
||||
date +_%Y_%m_%d
|
||||
else
|
||||
cat "$1"
|
||||
fi
|
||||
}
|
||||
if test $# != 3
|
||||
then
|
||||
echo "Usage: gen_version_header.sh <version file> <template> <output file>" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
version_string=`print_version_string "$1"`
|
||||
sed "s/%%LIBPCAP_VERSION%%/$version_string/" "$2" >"$3"
|
File diff suppressed because it is too large
Load Diff
@ -1,395 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* ATM support:
|
||||
*
|
||||
* Copyright (c) 1997 Yen Yen Lim and North Dakota State 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 Yen Yen Lim and
|
||||
* North Dakota State University
|
||||
* 4. 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 AUTHOR ``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 AUTHOR 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___ATTRIBUTE__
|
||||
#define __attribute__(x)
|
||||
#endif /* HAVE___ATTRIBUTE__ */
|
||||
|
||||
/* Address qualifiers. */
|
||||
|
||||
#define Q_HOST 1
|
||||
#define Q_NET 2
|
||||
#define Q_PORT 3
|
||||
#define Q_GATEWAY 4
|
||||
#define Q_PROTO 5
|
||||
#define Q_PROTOCHAIN 6
|
||||
#define Q_PORTRANGE 7
|
||||
|
||||
/* Protocol qualifiers. */
|
||||
|
||||
#define Q_LINK 1
|
||||
#define Q_IP 2
|
||||
#define Q_ARP 3
|
||||
#define Q_RARP 4
|
||||
#define Q_SCTP 5
|
||||
#define Q_TCP 6
|
||||
#define Q_UDP 7
|
||||
#define Q_ICMP 8
|
||||
#define Q_IGMP 9
|
||||
#define Q_IGRP 10
|
||||
|
||||
|
||||
#define Q_ATALK 11
|
||||
#define Q_DECNET 12
|
||||
#define Q_LAT 13
|
||||
#define Q_SCA 14
|
||||
#define Q_MOPRC 15
|
||||
#define Q_MOPDL 16
|
||||
|
||||
|
||||
#define Q_IPV6 17
|
||||
#define Q_ICMPV6 18
|
||||
#define Q_AH 19
|
||||
#define Q_ESP 20
|
||||
|
||||
#define Q_PIM 21
|
||||
#define Q_VRRP 22
|
||||
|
||||
#define Q_AARP 23
|
||||
|
||||
#define Q_ISO 24
|
||||
#define Q_ESIS 25
|
||||
#define Q_ISIS 26
|
||||
#define Q_CLNP 27
|
||||
|
||||
#define Q_STP 28
|
||||
|
||||
#define Q_IPX 29
|
||||
|
||||
#define Q_NETBEUI 30
|
||||
|
||||
/* IS-IS Levels */
|
||||
#define Q_ISIS_L1 31
|
||||
#define Q_ISIS_L2 32
|
||||
/* PDU types */
|
||||
#define Q_ISIS_IIH 33
|
||||
#define Q_ISIS_LAN_IIH 34
|
||||
#define Q_ISIS_PTP_IIH 35
|
||||
#define Q_ISIS_SNP 36
|
||||
#define Q_ISIS_CSNP 37
|
||||
#define Q_ISIS_PSNP 38
|
||||
#define Q_ISIS_LSP 39
|
||||
|
||||
#define Q_RADIO 40
|
||||
|
||||
#define Q_CARP 41
|
||||
|
||||
/* Directional qualifiers. */
|
||||
|
||||
#define Q_SRC 1
|
||||
#define Q_DST 2
|
||||
#define Q_OR 3
|
||||
#define Q_AND 4
|
||||
#define Q_ADDR1 5
|
||||
#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
|
||||
|
||||
/* ATM types */
|
||||
#define A_METAC 22 /* Meta signalling Circuit */
|
||||
#define A_BCC 23 /* Broadcast Circuit */
|
||||
#define A_OAMF4SC 24 /* Segment OAM F4 Circuit */
|
||||
#define A_OAMF4EC 25 /* End-to-End OAM F4 Circuit */
|
||||
#define A_SC 26 /* Signalling Circuit*/
|
||||
#define A_ILMIC 27 /* ILMI Circuit */
|
||||
#define A_OAM 28 /* OAM cells : F4 only */
|
||||
#define A_OAMF4 29 /* OAM F4 cells: Segment + End-to-end */
|
||||
#define A_LANE 30 /* LANE traffic */
|
||||
#define A_LLC 31 /* LLC-encapsulated traffic */
|
||||
|
||||
/* Based on Q.2931 signalling protocol */
|
||||
#define A_SETUP 41 /* Setup message */
|
||||
#define A_CALLPROCEED 42 /* Call proceeding message */
|
||||
#define A_CONNECT 43 /* Connect message */
|
||||
#define A_CONNECTACK 44 /* Connect Ack message */
|
||||
#define A_RELEASE 45 /* Release message */
|
||||
#define A_RELEASE_DONE 46 /* Release message */
|
||||
|
||||
/* ATM field types */
|
||||
#define A_VPI 51
|
||||
#define A_VCI 52
|
||||
#define A_PROTOTYPE 53
|
||||
#define A_MSGTYPE 54
|
||||
#define A_CALLREFTYPE 55
|
||||
|
||||
#define A_CONNECTMSG 70 /* returns Q.2931 signalling messages for
|
||||
establishing and destroying switched
|
||||
virtual connection */
|
||||
#define A_METACONNECT 71 /* returns Q.2931 signalling messages for
|
||||
establishing and destroying predefined
|
||||
virtual circuits, such as broadcast
|
||||
circuit, oamf4 segment circuit, oamf4
|
||||
end-to-end circuits, ILMI circuits or
|
||||
connection signalling circuit. */
|
||||
|
||||
/* MTP2 types */
|
||||
#define M_FISU 22 /* FISU */
|
||||
#define M_LSSU 23 /* LSSU */
|
||||
#define M_MSU 24 /* MSU */
|
||||
|
||||
/* MTP2 HSL types */
|
||||
#define MH_FISU 25 /* FISU for HSL */
|
||||
#define MH_LSSU 26 /* LSSU */
|
||||
#define MH_MSU 27 /* MSU */
|
||||
|
||||
/* MTP3 field types */
|
||||
#define M_SIO 1
|
||||
#define M_OPC 2
|
||||
#define M_DPC 3
|
||||
#define M_SLS 4
|
||||
|
||||
/* MTP3 field types in case of MTP2 HSL */
|
||||
#define MH_SIO 5
|
||||
#define MH_OPC 6
|
||||
#define MH_DPC 7
|
||||
#define MH_SLS 8
|
||||
|
||||
|
||||
struct slist;
|
||||
|
||||
struct stmt {
|
||||
int code;
|
||||
struct slist *jt; /*only for relative jump in block*/
|
||||
struct slist *jf; /*only for relative jump in block*/
|
||||
bpf_int32 k;
|
||||
};
|
||||
|
||||
struct slist {
|
||||
struct stmt s;
|
||||
struct slist *next;
|
||||
};
|
||||
|
||||
/*
|
||||
* A bit vector to represent definition sets. We assume TOT_REGISTERS
|
||||
* is smaller than 8*sizeof(atomset).
|
||||
*/
|
||||
typedef bpf_u_int32 atomset;
|
||||
#define ATOMMASK(n) (1 << (n))
|
||||
#define ATOMELEM(d, n) (d & ATOMMASK(n))
|
||||
|
||||
/*
|
||||
* An unbounded set.
|
||||
*/
|
||||
typedef bpf_u_int32 *uset;
|
||||
|
||||
/*
|
||||
* Total number of atomic entities, including accumulator (A) and index (X).
|
||||
* We treat all these guys similarly during flow analysis.
|
||||
*/
|
||||
#define N_ATOMS (BPF_MEMWORDS+2)
|
||||
|
||||
struct edge {
|
||||
int id;
|
||||
int code;
|
||||
uset edom;
|
||||
struct block *succ;
|
||||
struct block *pred;
|
||||
struct edge *next; /* link list of incoming edges for a node */
|
||||
};
|
||||
|
||||
struct block {
|
||||
int id;
|
||||
struct slist *stmts; /* side effect stmts */
|
||||
struct stmt s; /* branch stmt */
|
||||
int mark;
|
||||
u_int longjt; /* jt branch requires long jump */
|
||||
u_int longjf; /* jf branch requires long jump */
|
||||
int level;
|
||||
int offset;
|
||||
int sense;
|
||||
struct edge et;
|
||||
struct edge ef;
|
||||
struct block *head;
|
||||
struct block *link; /* link field used by optimizer */
|
||||
uset dom;
|
||||
uset closure;
|
||||
struct edge *in_edges;
|
||||
atomset def, kill;
|
||||
atomset in_use;
|
||||
atomset out_use;
|
||||
int oval;
|
||||
int val[N_ATOMS];
|
||||
};
|
||||
|
||||
struct arth {
|
||||
struct block *b; /* protocol checks */
|
||||
struct slist *s; /* stmt list */
|
||||
int regno; /* virtual register number of result */
|
||||
};
|
||||
|
||||
struct qual {
|
||||
unsigned char addr;
|
||||
unsigned char proto;
|
||||
unsigned char dir;
|
||||
unsigned char pad;
|
||||
};
|
||||
|
||||
struct _compiler_state;
|
||||
|
||||
typedef struct _compiler_state compiler_state_t;
|
||||
|
||||
struct arth *gen_loadi(compiler_state_t *, int);
|
||||
struct arth *gen_load(compiler_state_t *, int, struct arth *, int);
|
||||
struct arth *gen_loadlen(compiler_state_t *);
|
||||
struct arth *gen_neg(compiler_state_t *, struct arth *);
|
||||
struct arth *gen_arth(compiler_state_t *, int, struct arth *, struct arth *);
|
||||
|
||||
void gen_and(struct block *, struct block *);
|
||||
void gen_or(struct block *, struct block *);
|
||||
void gen_not(struct block *);
|
||||
|
||||
struct block *gen_scode(compiler_state_t *, const char *, struct qual);
|
||||
struct block *gen_ecode(compiler_state_t *, const u_char *, struct qual);
|
||||
struct block *gen_acode(compiler_state_t *, const u_char *, struct qual);
|
||||
struct block *gen_mcode(compiler_state_t *, const char *, const char *,
|
||||
unsigned int, struct qual);
|
||||
#ifdef INET6
|
||||
struct block *gen_mcode6(compiler_state_t *, const char *, const char *,
|
||||
unsigned int, struct qual);
|
||||
#endif
|
||||
struct block *gen_ncode(compiler_state_t *, const char *, bpf_u_int32,
|
||||
struct qual);
|
||||
struct block *gen_proto_abbrev(compiler_state_t *, int);
|
||||
struct block *gen_relation(compiler_state_t *, int, struct arth *,
|
||||
struct arth *, int);
|
||||
struct block *gen_less(compiler_state_t *, int);
|
||||
struct block *gen_greater(compiler_state_t *, int);
|
||||
struct block *gen_byteop(compiler_state_t *, int, int, int);
|
||||
struct block *gen_broadcast(compiler_state_t *, int);
|
||||
struct block *gen_multicast(compiler_state_t *, int);
|
||||
struct block *gen_inbound(compiler_state_t *, int);
|
||||
|
||||
struct block *gen_llc(compiler_state_t *);
|
||||
struct block *gen_llc_i(compiler_state_t *);
|
||||
struct block *gen_llc_s(compiler_state_t *);
|
||||
struct block *gen_llc_u(compiler_state_t *);
|
||||
struct block *gen_llc_s_subtype(compiler_state_t *, bpf_u_int32);
|
||||
struct block *gen_llc_u_subtype(compiler_state_t *, bpf_u_int32);
|
||||
|
||||
struct block *gen_vlan(compiler_state_t *, int);
|
||||
struct block *gen_mpls(compiler_state_t *, int);
|
||||
|
||||
struct block *gen_pppoed(compiler_state_t *);
|
||||
struct block *gen_pppoes(compiler_state_t *, int);
|
||||
|
||||
struct block *gen_geneve(compiler_state_t *, int);
|
||||
|
||||
struct block *gen_atmfield_code(compiler_state_t *, int, bpf_int32,
|
||||
bpf_u_int32, int);
|
||||
struct block *gen_atmtype_abbrev(compiler_state_t *, int type);
|
||||
struct block *gen_atmmulti_abbrev(compiler_state_t *, int type);
|
||||
|
||||
struct block *gen_mtp2type_abbrev(compiler_state_t *, int type);
|
||||
struct block *gen_mtp3field_code(compiler_state_t *, int, bpf_u_int32,
|
||||
bpf_u_int32, int);
|
||||
|
||||
struct block *gen_pf_ifname(compiler_state_t *, const char *);
|
||||
struct block *gen_pf_rnr(compiler_state_t *, int);
|
||||
struct block *gen_pf_srnr(compiler_state_t *, int);
|
||||
struct block *gen_pf_ruleset(compiler_state_t *, char *);
|
||||
struct block *gen_pf_reason(compiler_state_t *, int);
|
||||
struct block *gen_pf_action(compiler_state_t *, int);
|
||||
|
||||
struct block *gen_p80211_type(compiler_state_t *, int, int);
|
||||
struct block *gen_p80211_fcdir(compiler_state_t *, int);
|
||||
|
||||
/*
|
||||
* Representation of a program as a tree of blocks, plus current mark.
|
||||
* A block is marked if only if its mark equals the current mark.
|
||||
* Rather than traverse the code array, marking each item, 'cur_mark'
|
||||
* is incremented. This automatically makes each element unmarked.
|
||||
*/
|
||||
#define isMarked(icp, p) ((p)->mark == (icp)->cur_mark)
|
||||
#define unMarkAll(icp) (icp)->cur_mark += 1
|
||||
#define Mark(icp, p) ((p)->mark = (icp)->cur_mark)
|
||||
|
||||
struct icode {
|
||||
struct block *root;
|
||||
int cur_mark;
|
||||
};
|
||||
|
||||
void bpf_optimize(compiler_state_t *, struct icode *ic);
|
||||
void bpf_syntax_error(compiler_state_t *, const char *);
|
||||
void bpf_error(compiler_state_t *, const char *, ...)
|
||||
__attribute__((noreturn))
|
||||
#ifdef __ATTRIBUTE___FORMAT_OK
|
||||
__attribute__((format (printf, 2, 3)))
|
||||
#endif /* __ATTRIBUTE___FORMAT_OK */
|
||||
;
|
||||
|
||||
void finish_parse(compiler_state_t *, struct block *);
|
||||
char *sdup(compiler_state_t *, const char *);
|
||||
|
||||
struct _opt_state;
|
||||
typedef struct _opt_state opt_state_t;
|
||||
|
||||
struct bpf_insn *icode_to_fcode(compiler_state_t *, struct icode *,
|
||||
struct block *, u_int *);
|
||||
void sappend(struct slist *, struct slist *);
|
||||
|
||||
/*
|
||||
* Older versions of Bison don't put this declaration in
|
||||
* grammar.h.
|
||||
*/
|
||||
int pcap_parse(void *, compiler_state_t *);
|
||||
|
||||
/* XXX */
|
||||
#define JT(b) ((b)->et.succ)
|
||||
#define JF(b) ((b)->ef.succ)
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -1,323 +0,0 @@
|
||||
/* A Bison parser, made by GNU Bison 3.0.4. */
|
||||
|
||||
/* Bison interface for Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* As a special exception, you may create a larger work that contains
|
||||
part or all of the Bison parser skeleton and distribute that work
|
||||
under terms of your choice, so long as that work isn't itself a
|
||||
parser generator using the skeleton or a modified version thereof
|
||||
as a parser skeleton. Alternatively, if you modify or redistribute
|
||||
the parser skeleton itself, you may (at your option) remove this
|
||||
special exception, which will cause the skeleton and the resulting
|
||||
Bison output files to be licensed under the GNU General Public
|
||||
License without this special exception.
|
||||
|
||||
This special exception was added by the Free Software Foundation in
|
||||
version 2.2 of Bison. */
|
||||
|
||||
#ifndef YY_PCAP_GRAMMAR_H_INCLUDED
|
||||
# define YY_PCAP_GRAMMAR_H_INCLUDED
|
||||
/* Debug traces. */
|
||||
#ifndef YYDEBUG
|
||||
# define YYDEBUG 0
|
||||
#endif
|
||||
#if YYDEBUG
|
||||
extern int pcap_debug;
|
||||
#endif
|
||||
|
||||
/* Token type. */
|
||||
#ifndef YYTOKENTYPE
|
||||
# define YYTOKENTYPE
|
||||
enum yytokentype
|
||||
{
|
||||
DST = 258,
|
||||
SRC = 259,
|
||||
HOST = 260,
|
||||
GATEWAY = 261,
|
||||
NET = 262,
|
||||
NETMASK = 263,
|
||||
PORT = 264,
|
||||
PORTRANGE = 265,
|
||||
LESS = 266,
|
||||
GREATER = 267,
|
||||
PROTO = 268,
|
||||
PROTOCHAIN = 269,
|
||||
CBYTE = 270,
|
||||
ARP = 271,
|
||||
RARP = 272,
|
||||
IP = 273,
|
||||
SCTP = 274,
|
||||
TCP = 275,
|
||||
UDP = 276,
|
||||
ICMP = 277,
|
||||
IGMP = 278,
|
||||
IGRP = 279,
|
||||
PIM = 280,
|
||||
VRRP = 281,
|
||||
CARP = 282,
|
||||
ATALK = 283,
|
||||
AARP = 284,
|
||||
DECNET = 285,
|
||||
LAT = 286,
|
||||
SCA = 287,
|
||||
MOPRC = 288,
|
||||
MOPDL = 289,
|
||||
TK_BROADCAST = 290,
|
||||
TK_MULTICAST = 291,
|
||||
NUM = 292,
|
||||
INBOUND = 293,
|
||||
OUTBOUND = 294,
|
||||
PF_IFNAME = 295,
|
||||
PF_RSET = 296,
|
||||
PF_RNR = 297,
|
||||
PF_SRNR = 298,
|
||||
PF_REASON = 299,
|
||||
PF_ACTION = 300,
|
||||
TYPE = 301,
|
||||
SUBTYPE = 302,
|
||||
DIR = 303,
|
||||
ADDR1 = 304,
|
||||
ADDR2 = 305,
|
||||
ADDR3 = 306,
|
||||
ADDR4 = 307,
|
||||
RA = 308,
|
||||
TA = 309,
|
||||
LINK = 310,
|
||||
GEQ = 311,
|
||||
LEQ = 312,
|
||||
NEQ = 313,
|
||||
ID = 314,
|
||||
EID = 315,
|
||||
HID = 316,
|
||||
HID6 = 317,
|
||||
AID = 318,
|
||||
LSH = 319,
|
||||
RSH = 320,
|
||||
LEN = 321,
|
||||
IPV6 = 322,
|
||||
ICMPV6 = 323,
|
||||
AH = 324,
|
||||
ESP = 325,
|
||||
VLAN = 326,
|
||||
MPLS = 327,
|
||||
PPPOED = 328,
|
||||
PPPOES = 329,
|
||||
GENEVE = 330,
|
||||
ISO = 331,
|
||||
ESIS = 332,
|
||||
CLNP = 333,
|
||||
ISIS = 334,
|
||||
L1 = 335,
|
||||
L2 = 336,
|
||||
IIH = 337,
|
||||
LSP = 338,
|
||||
SNP = 339,
|
||||
CSNP = 340,
|
||||
PSNP = 341,
|
||||
STP = 342,
|
||||
IPX = 343,
|
||||
NETBEUI = 344,
|
||||
LANE = 345,
|
||||
LLC = 346,
|
||||
METAC = 347,
|
||||
BCC = 348,
|
||||
SC = 349,
|
||||
ILMIC = 350,
|
||||
OAMF4EC = 351,
|
||||
OAMF4SC = 352,
|
||||
OAM = 353,
|
||||
OAMF4 = 354,
|
||||
CONNECTMSG = 355,
|
||||
METACONNECT = 356,
|
||||
VPI = 357,
|
||||
VCI = 358,
|
||||
RADIO = 359,
|
||||
FISU = 360,
|
||||
LSSU = 361,
|
||||
MSU = 362,
|
||||
HFISU = 363,
|
||||
HLSSU = 364,
|
||||
HMSU = 365,
|
||||
SIO = 366,
|
||||
OPC = 367,
|
||||
DPC = 368,
|
||||
SLS = 369,
|
||||
HSIO = 370,
|
||||
HOPC = 371,
|
||||
HDPC = 372,
|
||||
HSLS = 373,
|
||||
OR = 374,
|
||||
AND = 375,
|
||||
UMINUS = 376
|
||||
};
|
||||
#endif
|
||||
/* Tokens. */
|
||||
#define DST 258
|
||||
#define SRC 259
|
||||
#define HOST 260
|
||||
#define GATEWAY 261
|
||||
#define NET 262
|
||||
#define NETMASK 263
|
||||
#define PORT 264
|
||||
#define PORTRANGE 265
|
||||
#define LESS 266
|
||||
#define GREATER 267
|
||||
#define PROTO 268
|
||||
#define PROTOCHAIN 269
|
||||
#define CBYTE 270
|
||||
#define ARP 271
|
||||
#define RARP 272
|
||||
#define IP 273
|
||||
#define SCTP 274
|
||||
#define TCP 275
|
||||
#define UDP 276
|
||||
#define ICMP 277
|
||||
#define IGMP 278
|
||||
#define IGRP 279
|
||||
#define PIM 280
|
||||
#define VRRP 281
|
||||
#define CARP 282
|
||||
#define ATALK 283
|
||||
#define AARP 284
|
||||
#define DECNET 285
|
||||
#define LAT 286
|
||||
#define SCA 287
|
||||
#define MOPRC 288
|
||||
#define MOPDL 289
|
||||
#define TK_BROADCAST 290
|
||||
#define TK_MULTICAST 291
|
||||
#define NUM 292
|
||||
#define INBOUND 293
|
||||
#define OUTBOUND 294
|
||||
#define PF_IFNAME 295
|
||||
#define PF_RSET 296
|
||||
#define PF_RNR 297
|
||||
#define PF_SRNR 298
|
||||
#define PF_REASON 299
|
||||
#define PF_ACTION 300
|
||||
#define TYPE 301
|
||||
#define SUBTYPE 302
|
||||
#define DIR 303
|
||||
#define ADDR1 304
|
||||
#define ADDR2 305
|
||||
#define ADDR3 306
|
||||
#define ADDR4 307
|
||||
#define RA 308
|
||||
#define TA 309
|
||||
#define LINK 310
|
||||
#define GEQ 311
|
||||
#define LEQ 312
|
||||
#define NEQ 313
|
||||
#define ID 314
|
||||
#define EID 315
|
||||
#define HID 316
|
||||
#define HID6 317
|
||||
#define AID 318
|
||||
#define LSH 319
|
||||
#define RSH 320
|
||||
#define LEN 321
|
||||
#define IPV6 322
|
||||
#define ICMPV6 323
|
||||
#define AH 324
|
||||
#define ESP 325
|
||||
#define VLAN 326
|
||||
#define MPLS 327
|
||||
#define PPPOED 328
|
||||
#define PPPOES 329
|
||||
#define GENEVE 330
|
||||
#define ISO 331
|
||||
#define ESIS 332
|
||||
#define CLNP 333
|
||||
#define ISIS 334
|
||||
#define L1 335
|
||||
#define L2 336
|
||||
#define IIH 337
|
||||
#define LSP 338
|
||||
#define SNP 339
|
||||
#define CSNP 340
|
||||
#define PSNP 341
|
||||
#define STP 342
|
||||
#define IPX 343
|
||||
#define NETBEUI 344
|
||||
#define LANE 345
|
||||
#define LLC 346
|
||||
#define METAC 347
|
||||
#define BCC 348
|
||||
#define SC 349
|
||||
#define ILMIC 350
|
||||
#define OAMF4EC 351
|
||||
#define OAMF4SC 352
|
||||
#define OAM 353
|
||||
#define OAMF4 354
|
||||
#define CONNECTMSG 355
|
||||
#define METACONNECT 356
|
||||
#define VPI 357
|
||||
#define VCI 358
|
||||
#define RADIO 359
|
||||
#define FISU 360
|
||||
#define LSSU 361
|
||||
#define MSU 362
|
||||
#define HFISU 363
|
||||
#define HLSSU 364
|
||||
#define HMSU 365
|
||||
#define SIO 366
|
||||
#define OPC 367
|
||||
#define DPC 368
|
||||
#define SLS 369
|
||||
#define HSIO 370
|
||||
#define HOPC 371
|
||||
#define HDPC 372
|
||||
#define HSLS 373
|
||||
#define OR 374
|
||||
#define AND 375
|
||||
#define UMINUS 376
|
||||
|
||||
/* Value type. */
|
||||
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
||||
|
||||
union YYSTYPE
|
||||
{
|
||||
#line 271 "grammar.y" /* yacc.c:1909 */
|
||||
|
||||
int i;
|
||||
bpf_u_int32 h;
|
||||
u_char *e;
|
||||
char *s;
|
||||
struct stmt *stmt;
|
||||
struct arth *a;
|
||||
struct {
|
||||
struct qual q;
|
||||
int atmfieldtype;
|
||||
int mtp3fieldtype;
|
||||
struct block *b;
|
||||
} blk;
|
||||
struct block *rblk;
|
||||
|
||||
#line 312 "grammar.h" /* yacc.c:1909 */
|
||||
};
|
||||
|
||||
typedef union YYSTYPE YYSTYPE;
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
# define YYSTYPE_IS_DECLARED 1
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
int pcap_parse (void *yyscanner, compiler_state_t *cstate);
|
||||
|
||||
#endif /* !YY_PCAP_GRAMMAR_H_INCLUDED */
|
Binary file not shown.
@ -1,768 +0,0 @@
|
||||
/*
|
||||
* We want a reentrant parser.
|
||||
*/
|
||||
%pure-parser
|
||||
|
||||
/*
|
||||
* We also want a reentrant scanner, so we have to pass the
|
||||
* handle for the reentrant scanner to the parser, and the
|
||||
* parser has to pass it to the lexical analyzer.
|
||||
*
|
||||
* We use void * rather than yyscan_t because, at least with some
|
||||
* versions of Flex and Bison, if you use yyscan_t in %parse-param and
|
||||
* %lex-param, you have to include scanner.h before grammar.h to get
|
||||
* yyscan_t declared, and you have to include grammar.h before scanner.h
|
||||
* to get YYSTYPE declared. Using void * breaks the cycle; the Flex
|
||||
* documentation says yyscan_t is just a void *.
|
||||
*/
|
||||
%parse-param {void *yyscanner}
|
||||
%lex-param {void *yyscanner}
|
||||
|
||||
/*
|
||||
* And we need to pass the compiler state to the scanner.
|
||||
*/
|
||||
%parse-param {compiler_state_t *cstate}
|
||||
|
||||
%{
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <pcap-stdinc.h>
|
||||
#else /* _WIN32 */
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
#if __STDC__
|
||||
struct mbuf;
|
||||
struct rtentry;
|
||||
#endif
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "pcap-int.h"
|
||||
|
||||
#include "gencode.h"
|
||||
#include "grammar.h"
|
||||
#include "scanner.h"
|
||||
|
||||
#ifdef HAVE_NET_PFVAR_H
|
||||
#include <net/if.h>
|
||||
#include <net/pfvar.h>
|
||||
#include <net/if_pflog.h>
|
||||
#endif
|
||||
#include "llc.h"
|
||||
#include "ieee80211.h"
|
||||
#include <pcap/namedb.h>
|
||||
|
||||
#ifdef HAVE_OS_PROTO_H
|
||||
#include "os-proto.h"
|
||||
#endif
|
||||
|
||||
#define QSET(q, p, d, a) (q).proto = (p),\
|
||||
(q).dir = (d),\
|
||||
(q).addr = (a)
|
||||
|
||||
struct tok {
|
||||
int v; /* value */
|
||||
const char *s; /* string */
|
||||
};
|
||||
|
||||
static const struct tok ieee80211_types[] = {
|
||||
{ IEEE80211_FC0_TYPE_DATA, "data" },
|
||||
{ IEEE80211_FC0_TYPE_MGT, "mgt" },
|
||||
{ IEEE80211_FC0_TYPE_MGT, "management" },
|
||||
{ IEEE80211_FC0_TYPE_CTL, "ctl" },
|
||||
{ IEEE80211_FC0_TYPE_CTL, "control" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
static const struct tok ieee80211_mgt_subtypes[] = {
|
||||
{ IEEE80211_FC0_SUBTYPE_ASSOC_REQ, "assocreq" },
|
||||
{ IEEE80211_FC0_SUBTYPE_ASSOC_REQ, "assoc-req" },
|
||||
{ IEEE80211_FC0_SUBTYPE_ASSOC_RESP, "assocresp" },
|
||||
{ IEEE80211_FC0_SUBTYPE_ASSOC_RESP, "assoc-resp" },
|
||||
{ IEEE80211_FC0_SUBTYPE_REASSOC_REQ, "reassocreq" },
|
||||
{ IEEE80211_FC0_SUBTYPE_REASSOC_REQ, "reassoc-req" },
|
||||
{ IEEE80211_FC0_SUBTYPE_REASSOC_RESP, "reassocresp" },
|
||||
{ IEEE80211_FC0_SUBTYPE_REASSOC_RESP, "reassoc-resp" },
|
||||
{ IEEE80211_FC0_SUBTYPE_PROBE_REQ, "probereq" },
|
||||
{ IEEE80211_FC0_SUBTYPE_PROBE_REQ, "probe-req" },
|
||||
{ IEEE80211_FC0_SUBTYPE_PROBE_RESP, "proberesp" },
|
||||
{ IEEE80211_FC0_SUBTYPE_PROBE_RESP, "probe-resp" },
|
||||
{ IEEE80211_FC0_SUBTYPE_BEACON, "beacon" },
|
||||
{ IEEE80211_FC0_SUBTYPE_ATIM, "atim" },
|
||||
{ IEEE80211_FC0_SUBTYPE_DISASSOC, "disassoc" },
|
||||
{ IEEE80211_FC0_SUBTYPE_DISASSOC, "disassociation" },
|
||||
{ IEEE80211_FC0_SUBTYPE_AUTH, "auth" },
|
||||
{ IEEE80211_FC0_SUBTYPE_AUTH, "authentication" },
|
||||
{ IEEE80211_FC0_SUBTYPE_DEAUTH, "deauth" },
|
||||
{ IEEE80211_FC0_SUBTYPE_DEAUTH, "deauthentication" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
static const struct tok ieee80211_ctl_subtypes[] = {
|
||||
{ IEEE80211_FC0_SUBTYPE_PS_POLL, "ps-poll" },
|
||||
{ IEEE80211_FC0_SUBTYPE_RTS, "rts" },
|
||||
{ IEEE80211_FC0_SUBTYPE_CTS, "cts" },
|
||||
{ IEEE80211_FC0_SUBTYPE_ACK, "ack" },
|
||||
{ IEEE80211_FC0_SUBTYPE_CF_END, "cf-end" },
|
||||
{ IEEE80211_FC0_SUBTYPE_CF_END_ACK, "cf-end-ack" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
static const struct tok ieee80211_data_subtypes[] = {
|
||||
{ IEEE80211_FC0_SUBTYPE_DATA, "data" },
|
||||
{ IEEE80211_FC0_SUBTYPE_CF_ACK, "data-cf-ack" },
|
||||
{ IEEE80211_FC0_SUBTYPE_CF_POLL, "data-cf-poll" },
|
||||
{ IEEE80211_FC0_SUBTYPE_CF_ACPL, "data-cf-ack-poll" },
|
||||
{ IEEE80211_FC0_SUBTYPE_NODATA, "null" },
|
||||
{ IEEE80211_FC0_SUBTYPE_NODATA_CF_ACK, "cf-ack" },
|
||||
{ IEEE80211_FC0_SUBTYPE_NODATA_CF_POLL, "cf-poll" },
|
||||
{ IEEE80211_FC0_SUBTYPE_NODATA_CF_ACPL, "cf-ack-poll" },
|
||||
{ IEEE80211_FC0_SUBTYPE_QOS|IEEE80211_FC0_SUBTYPE_DATA, "qos-data" },
|
||||
{ IEEE80211_FC0_SUBTYPE_QOS|IEEE80211_FC0_SUBTYPE_CF_ACK, "qos-data-cf-ack" },
|
||||
{ IEEE80211_FC0_SUBTYPE_QOS|IEEE80211_FC0_SUBTYPE_CF_POLL, "qos-data-cf-poll" },
|
||||
{ IEEE80211_FC0_SUBTYPE_QOS|IEEE80211_FC0_SUBTYPE_CF_ACPL, "qos-data-cf-ack-poll" },
|
||||
{ IEEE80211_FC0_SUBTYPE_QOS|IEEE80211_FC0_SUBTYPE_NODATA, "qos" },
|
||||
{ IEEE80211_FC0_SUBTYPE_QOS|IEEE80211_FC0_SUBTYPE_NODATA_CF_POLL, "qos-cf-poll" },
|
||||
{ IEEE80211_FC0_SUBTYPE_QOS|IEEE80211_FC0_SUBTYPE_NODATA_CF_ACPL, "qos-cf-ack-poll" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
static const struct tok llc_s_subtypes[] = {
|
||||
{ LLC_RR, "rr" },
|
||||
{ LLC_RNR, "rnr" },
|
||||
{ LLC_REJ, "rej" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
static const struct tok llc_u_subtypes[] = {
|
||||
{ LLC_UI, "ui" },
|
||||
{ LLC_UA, "ua" },
|
||||
{ LLC_DISC, "disc" },
|
||||
{ LLC_DM, "dm" },
|
||||
{ LLC_SABME, "sabme" },
|
||||
{ LLC_TEST, "test" },
|
||||
{ LLC_XID, "xid" },
|
||||
{ LLC_FRMR, "frmr" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
struct type2tok {
|
||||
int type;
|
||||
const struct tok *tok;
|
||||
};
|
||||
static const struct type2tok ieee80211_type_subtypes[] = {
|
||||
{ IEEE80211_FC0_TYPE_MGT, ieee80211_mgt_subtypes },
|
||||
{ IEEE80211_FC0_TYPE_CTL, ieee80211_ctl_subtypes },
|
||||
{ IEEE80211_FC0_TYPE_DATA, ieee80211_data_subtypes },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static int
|
||||
str2tok(const char *str, const struct tok *toks)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; toks[i].s != NULL; i++) {
|
||||
if (pcap_strcasecmp(toks[i].s, str) == 0)
|
||||
return (toks[i].v);
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
|
||||
static struct qual qerr = { Q_UNDEF, Q_UNDEF, Q_UNDEF, Q_UNDEF };
|
||||
|
||||
static void
|
||||
yyerror(void *yyscanner, compiler_state_t *cstate, const char *msg)
|
||||
{
|
||||
bpf_syntax_error(cstate, msg);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
#ifdef HAVE_NET_PFVAR_H
|
||||
static int
|
||||
pfreason_to_num(compiler_state_t *cstate, const char *reason)
|
||||
{
|
||||
const char *reasons[] = PFRES_NAMES;
|
||||
int i;
|
||||
|
||||
for (i = 0; reasons[i]; i++) {
|
||||
if (pcap_strcasecmp(reason, reasons[i]) == 0)
|
||||
return (i);
|
||||
}
|
||||
bpf_error(cstate, "unknown PF reason");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
static int
|
||||
pfaction_to_num(compiler_state_t *cstate, const char *action)
|
||||
{
|
||||
if (pcap_strcasecmp(action, "pass") == 0 ||
|
||||
pcap_strcasecmp(action, "accept") == 0)
|
||||
return (PF_PASS);
|
||||
else if (pcap_strcasecmp(action, "drop") == 0 ||
|
||||
pcap_strcasecmp(action, "block") == 0)
|
||||
return (PF_DROP);
|
||||
#if HAVE_PF_NAT_THROUGH_PF_NORDR
|
||||
else if (pcap_strcasecmp(action, "rdr") == 0)
|
||||
return (PF_RDR);
|
||||
else if (pcap_strcasecmp(action, "nat") == 0)
|
||||
return (PF_NAT);
|
||||
else if (pcap_strcasecmp(action, "binat") == 0)
|
||||
return (PF_BINAT);
|
||||
else if (pcap_strcasecmp(action, "nordr") == 0)
|
||||
return (PF_NORDR);
|
||||
#endif
|
||||
else {
|
||||
bpf_error(cstate, "unknown PF action");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
}
|
||||
#else /* !HAVE_NET_PFVAR_H */
|
||||
static int
|
||||
pfreason_to_num(compiler_state_t *cstate, const char *reason)
|
||||
{
|
||||
bpf_error(cstate, "libpcap was compiled on a machine without pf support");
|
||||
/*NOTREACHED*/
|
||||
|
||||
/* this is to make the VC compiler happy */
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
pfaction_to_num(compiler_state_t *cstate, const char *action)
|
||||
{
|
||||
bpf_error(cstate, "libpcap was compiled on a machine without pf support");
|
||||
/*NOTREACHED*/
|
||||
|
||||
/* this is to make the VC compiler happy */
|
||||
return -1;
|
||||
}
|
||||
#endif /* HAVE_NET_PFVAR_H */
|
||||
%}
|
||||
|
||||
%union {
|
||||
int i;
|
||||
bpf_u_int32 h;
|
||||
u_char *e;
|
||||
char *s;
|
||||
struct stmt *stmt;
|
||||
struct arth *a;
|
||||
struct {
|
||||
struct qual q;
|
||||
int atmfieldtype;
|
||||
int mtp3fieldtype;
|
||||
struct block *b;
|
||||
} blk;
|
||||
struct block *rblk;
|
||||
}
|
||||
|
||||
%type <blk> expr id nid pid term rterm qid
|
||||
%type <blk> head
|
||||
%type <i> pqual dqual aqual ndaqual
|
||||
%type <a> arth narth
|
||||
%type <i> byteop pname pnum relop irelop
|
||||
%type <blk> and or paren not null prog
|
||||
%type <rblk> other pfvar p80211 pllc
|
||||
%type <i> atmtype atmmultitype
|
||||
%type <blk> atmfield
|
||||
%type <blk> atmfieldvalue atmvalue atmlistvalue
|
||||
%type <i> mtp2type
|
||||
%type <blk> mtp3field
|
||||
%type <blk> mtp3fieldvalue mtp3value mtp3listvalue
|
||||
|
||||
|
||||
%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 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 RA TA
|
||||
%token LINK
|
||||
%token GEQ LEQ NEQ
|
||||
%token ID EID HID HID6 AID
|
||||
%token LSH RSH
|
||||
%token LEN
|
||||
%token IPV6 ICMPV6 AH ESP
|
||||
%token VLAN MPLS
|
||||
%token PPPOED PPPOES GENEVE
|
||||
%token ISO ESIS CLNP ISIS L1 L2 IIH LSP SNP CSNP PSNP
|
||||
%token STP
|
||||
%token IPX
|
||||
%token NETBEUI
|
||||
%token LANE LLC METAC BCC SC ILMIC OAMF4EC OAMF4SC
|
||||
%token OAM OAMF4 CONNECTMSG METACONNECT
|
||||
%token VPI VCI
|
||||
%token RADIO
|
||||
%token FISU LSSU MSU HFISU HLSSU HMSU
|
||||
%token SIO OPC DPC SLS HSIO HOPC HDPC HSLS
|
||||
|
||||
|
||||
%type <s> ID
|
||||
%type <e> EID
|
||||
%type <e> AID
|
||||
%type <s> HID HID6
|
||||
%type <i> NUM action reason type subtype type_subtype dir
|
||||
|
||||
%left OR AND
|
||||
%nonassoc '!'
|
||||
%left '|'
|
||||
%left '&'
|
||||
%left LSH RSH
|
||||
%left '+' '-'
|
||||
%left '*' '/'
|
||||
%nonassoc UMINUS
|
||||
%%
|
||||
prog: null expr
|
||||
{
|
||||
finish_parse(cstate, $2.b);
|
||||
}
|
||||
| null
|
||||
;
|
||||
null: /* null */ { $$.q = qerr; }
|
||||
;
|
||||
expr: term
|
||||
| expr and term { gen_and($1.b, $3.b); $$ = $3; }
|
||||
| expr and id { gen_and($1.b, $3.b); $$ = $3; }
|
||||
| expr or term { gen_or($1.b, $3.b); $$ = $3; }
|
||||
| expr or id { gen_or($1.b, $3.b); $$ = $3; }
|
||||
;
|
||||
and: AND { $$ = $<blk>0; }
|
||||
;
|
||||
or: OR { $$ = $<blk>0; }
|
||||
;
|
||||
id: nid
|
||||
| pnum { $$.b = gen_ncode(cstate, NULL, (bpf_u_int32)$1,
|
||||
$$.q = $<blk>0.q); }
|
||||
| paren pid ')' { $$ = $2; }
|
||||
;
|
||||
nid: ID { $$.b = gen_scode(cstate, $1, $$.q = $<blk>0.q); }
|
||||
| HID '/' NUM { $$.b = gen_mcode(cstate, $1, NULL, $3,
|
||||
$$.q = $<blk>0.q); }
|
||||
| HID NETMASK HID { $$.b = gen_mcode(cstate, $1, $3, 0,
|
||||
$$.q = $<blk>0.q); }
|
||||
| HID {
|
||||
/* Decide how to parse HID based on proto */
|
||||
$$.q = $<blk>0.q;
|
||||
if ($$.q.addr == Q_PORT)
|
||||
bpf_error(cstate, "'port' modifier applied to ip host");
|
||||
else if ($$.q.addr == Q_PORTRANGE)
|
||||
bpf_error(cstate, "'portrange' modifier applied to ip host");
|
||||
else if ($$.q.addr == Q_PROTO)
|
||||
bpf_error(cstate, "'proto' modifier applied to ip host");
|
||||
else if ($$.q.addr == Q_PROTOCHAIN)
|
||||
bpf_error(cstate, "'protochain' modifier applied to ip host");
|
||||
$$.b = gen_ncode(cstate, $1, 0, $$.q);
|
||||
}
|
||||
| HID6 '/' NUM {
|
||||
#ifdef INET6
|
||||
$$.b = gen_mcode6(cstate, $1, NULL, $3,
|
||||
$$.q = $<blk>0.q);
|
||||
#else
|
||||
bpf_error(cstate, "'ip6addr/prefixlen' not supported "
|
||||
"in this configuration");
|
||||
#endif /*INET6*/
|
||||
}
|
||||
| HID6 {
|
||||
#ifdef INET6
|
||||
$$.b = gen_mcode6(cstate, $1, 0, 128,
|
||||
$$.q = $<blk>0.q);
|
||||
#else
|
||||
bpf_error(cstate, "'ip6addr' not supported "
|
||||
"in this configuration");
|
||||
#endif /*INET6*/
|
||||
}
|
||||
| EID {
|
||||
$$.b = gen_ecode(cstate, $1, $$.q = $<blk>0.q);
|
||||
/*
|
||||
* $1 was allocated by "pcap_ether_aton()",
|
||||
* so we must free it now that we're done
|
||||
* with it.
|
||||
*/
|
||||
free($1);
|
||||
}
|
||||
| AID {
|
||||
$$.b = gen_acode(cstate, $1, $$.q = $<blk>0.q);
|
||||
/*
|
||||
* $1 was allocated by "pcap_ether_aton()",
|
||||
* so we must free it now that we're done
|
||||
* with it.
|
||||
*/
|
||||
free($1);
|
||||
}
|
||||
| not id { gen_not($2.b); $$ = $2; }
|
||||
;
|
||||
not: '!' { $$ = $<blk>0; }
|
||||
;
|
||||
paren: '(' { $$ = $<blk>0; }
|
||||
;
|
||||
pid: nid
|
||||
| qid and id { gen_and($1.b, $3.b); $$ = $3; }
|
||||
| qid or id { gen_or($1.b, $3.b); $$ = $3; }
|
||||
;
|
||||
qid: pnum { $$.b = gen_ncode(cstate, NULL, (bpf_u_int32)$1,
|
||||
$$.q = $<blk>0.q); }
|
||||
| pid
|
||||
;
|
||||
term: rterm
|
||||
| not term { gen_not($2.b); $$ = $2; }
|
||||
;
|
||||
head: pqual dqual aqual { QSET($$.q, $1, $2, $3); }
|
||||
| pqual dqual { QSET($$.q, $1, $2, Q_DEFAULT); }
|
||||
| pqual aqual { QSET($$.q, $1, Q_DEFAULT, $2); }
|
||||
| pqual PROTO { QSET($$.q, $1, Q_DEFAULT, Q_PROTO); }
|
||||
| pqual PROTOCHAIN { QSET($$.q, $1, Q_DEFAULT, Q_PROTOCHAIN); }
|
||||
| pqual ndaqual { QSET($$.q, $1, Q_DEFAULT, $2); }
|
||||
;
|
||||
rterm: head id { $$ = $2; }
|
||||
| paren expr ')' { $$.b = $2.b; $$.q = $1.q; }
|
||||
| pname { $$.b = gen_proto_abbrev(cstate, $1); $$.q = qerr; }
|
||||
| arth relop arth { $$.b = gen_relation(cstate, $2, $1, $3, 0);
|
||||
$$.q = qerr; }
|
||||
| arth irelop arth { $$.b = gen_relation(cstate, $2, $1, $3, 1);
|
||||
$$.q = qerr; }
|
||||
| other { $$.b = $1; $$.q = qerr; }
|
||||
| atmtype { $$.b = gen_atmtype_abbrev(cstate, $1); $$.q = qerr; }
|
||||
| atmmultitype { $$.b = gen_atmmulti_abbrev(cstate, $1); $$.q = qerr; }
|
||||
| atmfield atmvalue { $$.b = $2.b; $$.q = qerr; }
|
||||
| mtp2type { $$.b = gen_mtp2type_abbrev(cstate, $1); $$.q = qerr; }
|
||||
| mtp3field mtp3value { $$.b = $2.b; $$.q = qerr; }
|
||||
;
|
||||
/* protocol level qualifiers */
|
||||
pqual: pname
|
||||
| { $$ = Q_DEFAULT; }
|
||||
;
|
||||
/* 'direction' qualifiers */
|
||||
dqual: SRC { $$ = Q_SRC; }
|
||||
| DST { $$ = Q_DST; }
|
||||
| SRC OR DST { $$ = Q_OR; }
|
||||
| DST OR SRC { $$ = Q_OR; }
|
||||
| SRC AND DST { $$ = Q_AND; }
|
||||
| DST AND SRC { $$ = Q_AND; }
|
||||
| ADDR1 { $$ = Q_ADDR1; }
|
||||
| ADDR2 { $$ = Q_ADDR2; }
|
||||
| ADDR3 { $$ = Q_ADDR3; }
|
||||
| ADDR4 { $$ = Q_ADDR4; }
|
||||
| RA { $$ = Q_RA; }
|
||||
| TA { $$ = Q_TA; }
|
||||
;
|
||||
/* address type qualifiers */
|
||||
aqual: HOST { $$ = Q_HOST; }
|
||||
| NET { $$ = Q_NET; }
|
||||
| PORT { $$ = Q_PORT; }
|
||||
| PORTRANGE { $$ = Q_PORTRANGE; }
|
||||
;
|
||||
/* non-directional address type qualifiers */
|
||||
ndaqual: GATEWAY { $$ = Q_GATEWAY; }
|
||||
;
|
||||
pname: LINK { $$ = Q_LINK; }
|
||||
| IP { $$ = Q_IP; }
|
||||
| ARP { $$ = Q_ARP; }
|
||||
| RARP { $$ = Q_RARP; }
|
||||
| SCTP { $$ = Q_SCTP; }
|
||||
| TCP { $$ = Q_TCP; }
|
||||
| UDP { $$ = Q_UDP; }
|
||||
| ICMP { $$ = Q_ICMP; }
|
||||
| IGMP { $$ = Q_IGMP; }
|
||||
| IGRP { $$ = Q_IGRP; }
|
||||
| PIM { $$ = Q_PIM; }
|
||||
| VRRP { $$ = Q_VRRP; }
|
||||
| CARP { $$ = Q_CARP; }
|
||||
| ATALK { $$ = Q_ATALK; }
|
||||
| AARP { $$ = Q_AARP; }
|
||||
| DECNET { $$ = Q_DECNET; }
|
||||
| LAT { $$ = Q_LAT; }
|
||||
| SCA { $$ = Q_SCA; }
|
||||
| MOPDL { $$ = Q_MOPDL; }
|
||||
| MOPRC { $$ = Q_MOPRC; }
|
||||
| IPV6 { $$ = Q_IPV6; }
|
||||
| ICMPV6 { $$ = Q_ICMPV6; }
|
||||
| AH { $$ = Q_AH; }
|
||||
| ESP { $$ = Q_ESP; }
|
||||
| ISO { $$ = Q_ISO; }
|
||||
| ESIS { $$ = Q_ESIS; }
|
||||
| ISIS { $$ = Q_ISIS; }
|
||||
| L1 { $$ = Q_ISIS_L1; }
|
||||
| L2 { $$ = Q_ISIS_L2; }
|
||||
| IIH { $$ = Q_ISIS_IIH; }
|
||||
| LSP { $$ = Q_ISIS_LSP; }
|
||||
| SNP { $$ = Q_ISIS_SNP; }
|
||||
| PSNP { $$ = Q_ISIS_PSNP; }
|
||||
| CSNP { $$ = Q_ISIS_CSNP; }
|
||||
| CLNP { $$ = Q_CLNP; }
|
||||
| STP { $$ = Q_STP; }
|
||||
| IPX { $$ = Q_IPX; }
|
||||
| NETBEUI { $$ = Q_NETBEUI; }
|
||||
| RADIO { $$ = Q_RADIO; }
|
||||
;
|
||||
other: pqual TK_BROADCAST { $$ = gen_broadcast(cstate, $1); }
|
||||
| pqual TK_MULTICAST { $$ = gen_multicast(cstate, $1); }
|
||||
| LESS NUM { $$ = gen_less(cstate, $2); }
|
||||
| GREATER NUM { $$ = gen_greater(cstate, $2); }
|
||||
| CBYTE NUM byteop NUM { $$ = gen_byteop(cstate, $3, $2, $4); }
|
||||
| INBOUND { $$ = gen_inbound(cstate, 0); }
|
||||
| OUTBOUND { $$ = gen_inbound(cstate, 1); }
|
||||
| VLAN pnum { $$ = gen_vlan(cstate, $2); }
|
||||
| VLAN { $$ = gen_vlan(cstate, -1); }
|
||||
| MPLS pnum { $$ = gen_mpls(cstate, $2); }
|
||||
| MPLS { $$ = gen_mpls(cstate, -1); }
|
||||
| PPPOED { $$ = gen_pppoed(cstate); }
|
||||
| PPPOES pnum { $$ = gen_pppoes(cstate, $2); }
|
||||
| PPPOES { $$ = gen_pppoes(cstate, -1); }
|
||||
| GENEVE pnum { $$ = gen_geneve(cstate, $2); }
|
||||
| GENEVE { $$ = gen_geneve(cstate, -1); }
|
||||
| pfvar { $$ = $1; }
|
||||
| pqual p80211 { $$ = $2; }
|
||||
| pllc { $$ = $1; }
|
||||
;
|
||||
|
||||
pfvar: PF_IFNAME ID { $$ = gen_pf_ifname(cstate, $2); }
|
||||
| PF_RSET ID { $$ = gen_pf_ruleset(cstate, $2); }
|
||||
| PF_RNR NUM { $$ = gen_pf_rnr(cstate, $2); }
|
||||
| PF_SRNR NUM { $$ = gen_pf_srnr(cstate, $2); }
|
||||
| PF_REASON reason { $$ = gen_pf_reason(cstate, $2); }
|
||||
| PF_ACTION action { $$ = gen_pf_action(cstate, $2); }
|
||||
;
|
||||
|
||||
p80211: TYPE type SUBTYPE subtype
|
||||
{ $$ = gen_p80211_type(cstate, $2 | $4,
|
||||
IEEE80211_FC0_TYPE_MASK |
|
||||
IEEE80211_FC0_SUBTYPE_MASK);
|
||||
}
|
||||
| TYPE type { $$ = gen_p80211_type(cstate, $2,
|
||||
IEEE80211_FC0_TYPE_MASK);
|
||||
}
|
||||
| SUBTYPE type_subtype { $$ = gen_p80211_type(cstate, $2,
|
||||
IEEE80211_FC0_TYPE_MASK |
|
||||
IEEE80211_FC0_SUBTYPE_MASK);
|
||||
}
|
||||
| DIR dir { $$ = gen_p80211_fcdir(cstate, $2); }
|
||||
;
|
||||
|
||||
type: NUM
|
||||
| ID { $$ = str2tok($1, ieee80211_types);
|
||||
if ($$ == -1)
|
||||
bpf_error(cstate, "unknown 802.11 type name");
|
||||
}
|
||||
;
|
||||
|
||||
subtype: NUM
|
||||
| ID { const struct tok *types = NULL;
|
||||
int i;
|
||||
for (i = 0;; i++) {
|
||||
if (ieee80211_type_subtypes[i].tok == NULL) {
|
||||
/* Ran out of types */
|
||||
bpf_error(cstate, "unknown 802.11 type");
|
||||
break;
|
||||
}
|
||||
if ($<i>-1 == ieee80211_type_subtypes[i].type) {
|
||||
types = ieee80211_type_subtypes[i].tok;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$$ = str2tok($1, types);
|
||||
if ($$ == -1)
|
||||
bpf_error(cstate, "unknown 802.11 subtype name");
|
||||
}
|
||||
;
|
||||
|
||||
type_subtype: ID { int i;
|
||||
for (i = 0;; i++) {
|
||||
if (ieee80211_type_subtypes[i].tok == NULL) {
|
||||
/* Ran out of types */
|
||||
bpf_error(cstate, "unknown 802.11 type name");
|
||||
break;
|
||||
}
|
||||
$$ = str2tok($1, ieee80211_type_subtypes[i].tok);
|
||||
if ($$ != -1) {
|
||||
$$ |= ieee80211_type_subtypes[i].type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
pllc: LLC { $$ = gen_llc(cstate); }
|
||||
| LLC ID { if (pcap_strcasecmp($2, "i") == 0)
|
||||
$$ = gen_llc_i(cstate);
|
||||
else if (pcap_strcasecmp($2, "s") == 0)
|
||||
$$ = gen_llc_s(cstate);
|
||||
else if (pcap_strcasecmp($2, "u") == 0)
|
||||
$$ = gen_llc_u(cstate);
|
||||
else {
|
||||
int subtype;
|
||||
|
||||
subtype = str2tok($2, llc_s_subtypes);
|
||||
if (subtype != -1)
|
||||
$$ = gen_llc_s_subtype(cstate, subtype);
|
||||
else {
|
||||
subtype = str2tok($2, llc_u_subtypes);
|
||||
if (subtype == -1)
|
||||
bpf_error(cstate, "unknown LLC type name \"%s\"", $2);
|
||||
$$ = gen_llc_u_subtype(cstate, subtype);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* sigh, "rnr" is already a keyword for PF */
|
||||
| LLC PF_RNR { $$ = gen_llc_s_subtype(cstate, LLC_RNR); }
|
||||
;
|
||||
|
||||
dir: NUM
|
||||
| ID { if (pcap_strcasecmp($1, "nods") == 0)
|
||||
$$ = IEEE80211_FC1_DIR_NODS;
|
||||
else if (pcap_strcasecmp($1, "tods") == 0)
|
||||
$$ = IEEE80211_FC1_DIR_TODS;
|
||||
else if (pcap_strcasecmp($1, "fromds") == 0)
|
||||
$$ = IEEE80211_FC1_DIR_FROMDS;
|
||||
else if (pcap_strcasecmp($1, "dstods") == 0)
|
||||
$$ = IEEE80211_FC1_DIR_DSTODS;
|
||||
else
|
||||
bpf_error(cstate, "unknown 802.11 direction");
|
||||
}
|
||||
;
|
||||
|
||||
reason: NUM { $$ = $1; }
|
||||
| ID { $$ = pfreason_to_num(cstate, $1); }
|
||||
;
|
||||
|
||||
action: ID { $$ = pfaction_to_num(cstate, $1); }
|
||||
;
|
||||
|
||||
relop: '>' { $$ = BPF_JGT; }
|
||||
| GEQ { $$ = BPF_JGE; }
|
||||
| '=' { $$ = BPF_JEQ; }
|
||||
;
|
||||
irelop: LEQ { $$ = BPF_JGT; }
|
||||
| '<' { $$ = BPF_JGE; }
|
||||
| NEQ { $$ = BPF_JEQ; }
|
||||
;
|
||||
arth: pnum { $$ = gen_loadi(cstate, $1); }
|
||||
| narth
|
||||
;
|
||||
narth: pname '[' arth ']' { $$ = gen_load(cstate, $1, $3, 1); }
|
||||
| pname '[' arth ':' NUM ']' { $$ = gen_load(cstate, $1, $3, $5); }
|
||||
| arth '+' arth { $$ = gen_arth(cstate, BPF_ADD, $1, $3); }
|
||||
| arth '-' arth { $$ = gen_arth(cstate, BPF_SUB, $1, $3); }
|
||||
| arth '*' arth { $$ = gen_arth(cstate, BPF_MUL, $1, $3); }
|
||||
| arth '/' arth { $$ = gen_arth(cstate, BPF_DIV, $1, $3); }
|
||||
| arth '%' arth { $$ = gen_arth(cstate, BPF_MOD, $1, $3); }
|
||||
| arth '&' arth { $$ = gen_arth(cstate, BPF_AND, $1, $3); }
|
||||
| arth '|' arth { $$ = gen_arth(cstate, BPF_OR, $1, $3); }
|
||||
| arth '^' arth { $$ = gen_arth(cstate, BPF_XOR, $1, $3); }
|
||||
| arth LSH arth { $$ = gen_arth(cstate, BPF_LSH, $1, $3); }
|
||||
| arth RSH arth { $$ = gen_arth(cstate, BPF_RSH, $1, $3); }
|
||||
| '-' arth %prec UMINUS { $$ = gen_neg(cstate, $2); }
|
||||
| paren narth ')' { $$ = $2; }
|
||||
| LEN { $$ = gen_loadlen(cstate); }
|
||||
;
|
||||
byteop: '&' { $$ = '&'; }
|
||||
| '|' { $$ = '|'; }
|
||||
| '<' { $$ = '<'; }
|
||||
| '>' { $$ = '>'; }
|
||||
| '=' { $$ = '='; }
|
||||
;
|
||||
pnum: NUM
|
||||
| paren pnum ')' { $$ = $2; }
|
||||
;
|
||||
atmtype: LANE { $$ = A_LANE; }
|
||||
| METAC { $$ = A_METAC; }
|
||||
| BCC { $$ = A_BCC; }
|
||||
| OAMF4EC { $$ = A_OAMF4EC; }
|
||||
| OAMF4SC { $$ = A_OAMF4SC; }
|
||||
| SC { $$ = A_SC; }
|
||||
| ILMIC { $$ = A_ILMIC; }
|
||||
;
|
||||
atmmultitype: OAM { $$ = A_OAM; }
|
||||
| OAMF4 { $$ = A_OAMF4; }
|
||||
| CONNECTMSG { $$ = A_CONNECTMSG; }
|
||||
| METACONNECT { $$ = A_METACONNECT; }
|
||||
;
|
||||
/* ATM field types quantifier */
|
||||
atmfield: VPI { $$.atmfieldtype = A_VPI; }
|
||||
| VCI { $$.atmfieldtype = A_VCI; }
|
||||
;
|
||||
atmvalue: atmfieldvalue
|
||||
| relop NUM { $$.b = gen_atmfield_code(cstate, $<blk>0.atmfieldtype, (bpf_int32)$2, (bpf_u_int32)$1, 0); }
|
||||
| irelop NUM { $$.b = gen_atmfield_code(cstate, $<blk>0.atmfieldtype, (bpf_int32)$2, (bpf_u_int32)$1, 1); }
|
||||
| paren atmlistvalue ')' { $$.b = $2.b; $$.q = qerr; }
|
||||
;
|
||||
atmfieldvalue: NUM {
|
||||
$$.atmfieldtype = $<blk>0.atmfieldtype;
|
||||
if ($$.atmfieldtype == A_VPI ||
|
||||
$$.atmfieldtype == A_VCI)
|
||||
$$.b = gen_atmfield_code(cstate, $$.atmfieldtype, (bpf_int32) $1, BPF_JEQ, 0);
|
||||
}
|
||||
;
|
||||
atmlistvalue: atmfieldvalue
|
||||
| atmlistvalue or atmfieldvalue { gen_or($1.b, $3.b); $$ = $3; }
|
||||
;
|
||||
/* MTP2 types quantifier */
|
||||
mtp2type: FISU { $$ = M_FISU; }
|
||||
| LSSU { $$ = M_LSSU; }
|
||||
| MSU { $$ = M_MSU; }
|
||||
| HFISU { $$ = MH_FISU; }
|
||||
| HLSSU { $$ = MH_LSSU; }
|
||||
| HMSU { $$ = MH_MSU; }
|
||||
;
|
||||
/* MTP3 field types quantifier */
|
||||
mtp3field: SIO { $$.mtp3fieldtype = M_SIO; }
|
||||
| OPC { $$.mtp3fieldtype = M_OPC; }
|
||||
| DPC { $$.mtp3fieldtype = M_DPC; }
|
||||
| SLS { $$.mtp3fieldtype = M_SLS; }
|
||||
| HSIO { $$.mtp3fieldtype = MH_SIO; }
|
||||
| HOPC { $$.mtp3fieldtype = MH_OPC; }
|
||||
| HDPC { $$.mtp3fieldtype = MH_DPC; }
|
||||
| HSLS { $$.mtp3fieldtype = MH_SLS; }
|
||||
;
|
||||
mtp3value: mtp3fieldvalue
|
||||
| relop NUM { $$.b = gen_mtp3field_code(cstate, $<blk>0.mtp3fieldtype, (u_int)$2, (u_int)$1, 0); }
|
||||
| irelop NUM { $$.b = gen_mtp3field_code(cstate, $<blk>0.mtp3fieldtype, (u_int)$2, (u_int)$1, 1); }
|
||||
| paren mtp3listvalue ')' { $$.b = $2.b; $$.q = qerr; }
|
||||
;
|
||||
mtp3fieldvalue: NUM {
|
||||
$$.mtp3fieldtype = $<blk>0.mtp3fieldtype;
|
||||
if ($$.mtp3fieldtype == M_SIO ||
|
||||
$$.mtp3fieldtype == M_OPC ||
|
||||
$$.mtp3fieldtype == M_DPC ||
|
||||
$$.mtp3fieldtype == M_SLS ||
|
||||
$$.mtp3fieldtype == MH_SIO ||
|
||||
$$.mtp3fieldtype == MH_OPC ||
|
||||
$$.mtp3fieldtype == MH_DPC ||
|
||||
$$.mtp3fieldtype == MH_SLS)
|
||||
$$.b = gen_mtp3field_code(cstate, $$.mtp3fieldtype, (u_int) $1, BPF_JEQ, 0);
|
||||
}
|
||||
;
|
||||
mtp3listvalue: mtp3fieldvalue
|
||||
| mtp3listvalue or mtp3fieldvalue { gen_or($1.b, $3.b); $$ = $3; }
|
||||
;
|
||||
%%
|
@ -1,146 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 2001 Atsushi Onoe
|
||||
* Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
|
||||
* 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.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of the
|
||||
* GNU General Public License ("GPL") version 2 as published by the Free
|
||||
* Software Foundation.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD: src/sys/net80211/ieee80211.h,v 1.10 2005/07/22 16:55:27 sam Exp $
|
||||
*/
|
||||
#ifndef _NET80211_IEEE80211_H_
|
||||
#define _NET80211_IEEE80211_H_
|
||||
|
||||
/*
|
||||
* 802.11 protocol definitions.
|
||||
*/
|
||||
|
||||
#define IEEE80211_FC0_VERSION_MASK 0x03
|
||||
#define IEEE80211_FC0_VERSION_SHIFT 0
|
||||
#define IEEE80211_FC0_VERSION_0 0x00
|
||||
#define IEEE80211_FC0_TYPE_MASK 0x0c
|
||||
#define IEEE80211_FC0_TYPE_SHIFT 2
|
||||
#define IEEE80211_FC0_TYPE_MGT 0x00
|
||||
#define IEEE80211_FC0_TYPE_CTL 0x04
|
||||
#define IEEE80211_FC0_TYPE_DATA 0x08
|
||||
|
||||
#define IEEE80211_FC0_SUBTYPE_MASK 0xf0
|
||||
#define IEEE80211_FC0_SUBTYPE_SHIFT 4
|
||||
/* for TYPE_MGT */
|
||||
#define IEEE80211_FC0_SUBTYPE_ASSOC_REQ 0x00
|
||||
#define IEEE80211_FC0_SUBTYPE_ASSOC_RESP 0x10
|
||||
#define IEEE80211_FC0_SUBTYPE_REASSOC_REQ 0x20
|
||||
#define IEEE80211_FC0_SUBTYPE_REASSOC_RESP 0x30
|
||||
#define IEEE80211_FC0_SUBTYPE_PROBE_REQ 0x40
|
||||
#define IEEE80211_FC0_SUBTYPE_PROBE_RESP 0x50
|
||||
#define IEEE80211_FC0_SUBTYPE_BEACON 0x80
|
||||
#define IEEE80211_FC0_SUBTYPE_ATIM 0x90
|
||||
#define IEEE80211_FC0_SUBTYPE_DISASSOC 0xa0
|
||||
#define IEEE80211_FC0_SUBTYPE_AUTH 0xb0
|
||||
#define IEEE80211_FC0_SUBTYPE_DEAUTH 0xc0
|
||||
/* for TYPE_CTL */
|
||||
#define IEEE80211_FC0_SUBTYPE_PS_POLL 0xa0
|
||||
#define IEEE80211_FC0_SUBTYPE_RTS 0xb0
|
||||
#define IEEE80211_FC0_SUBTYPE_CTS 0xc0
|
||||
#define IEEE80211_FC0_SUBTYPE_ACK 0xd0
|
||||
#define IEEE80211_FC0_SUBTYPE_CF_END 0xe0
|
||||
#define IEEE80211_FC0_SUBTYPE_CF_END_ACK 0xf0
|
||||
/* for TYPE_DATA (bit combination) */
|
||||
#define IEEE80211_FC0_SUBTYPE_DATA 0x00
|
||||
#define IEEE80211_FC0_SUBTYPE_CF_ACK 0x10
|
||||
#define IEEE80211_FC0_SUBTYPE_CF_POLL 0x20
|
||||
#define IEEE80211_FC0_SUBTYPE_CF_ACPL 0x30
|
||||
#define IEEE80211_FC0_SUBTYPE_NODATA 0x40
|
||||
#define IEEE80211_FC0_SUBTYPE_NODATA_CF_ACK 0x50
|
||||
#define IEEE80211_FC0_SUBTYPE_NODATA_CF_POLL 0x60
|
||||
#define IEEE80211_FC0_SUBTYPE_NODATA_CF_ACPL 0x70
|
||||
#define IEEE80211_FC0_SUBTYPE_QOS 0x80
|
||||
#define IEEE80211_FC0_SUBTYPE_QOS_NULL 0xc0
|
||||
|
||||
#define IEEE80211_FC1_DIR_MASK 0x03
|
||||
#define IEEE80211_FC1_DIR_NODS 0x00 /* STA->STA */
|
||||
#define IEEE80211_FC1_DIR_TODS 0x01 /* STA->AP */
|
||||
#define IEEE80211_FC1_DIR_FROMDS 0x02 /* AP ->STA */
|
||||
#define IEEE80211_FC1_DIR_DSTODS 0x03 /* AP ->AP */
|
||||
|
||||
#define IEEE80211_FC1_MORE_FRAG 0x04
|
||||
#define IEEE80211_FC1_RETRY 0x08
|
||||
#define IEEE80211_FC1_PWR_MGT 0x10
|
||||
#define IEEE80211_FC1_MORE_DATA 0x20
|
||||
#define IEEE80211_FC1_WEP 0x40
|
||||
#define IEEE80211_FC1_ORDER 0x80
|
||||
|
||||
#define IEEE80211_SEQ_FRAG_MASK 0x000f
|
||||
#define IEEE80211_SEQ_FRAG_SHIFT 0
|
||||
#define IEEE80211_SEQ_SEQ_MASK 0xfff0
|
||||
#define IEEE80211_SEQ_SEQ_SHIFT 4
|
||||
|
||||
#define IEEE80211_NWID_LEN 32
|
||||
|
||||
#define IEEE80211_QOS_TXOP 0x00ff
|
||||
/* bit 8 is reserved */
|
||||
#define IEEE80211_QOS_ACKPOLICY 0x60
|
||||
#define IEEE80211_QOS_ACKPOLICY_S 5
|
||||
#define IEEE80211_QOS_ESOP 0x10
|
||||
#define IEEE80211_QOS_ESOP_S 4
|
||||
#define IEEE80211_QOS_TID 0x0f
|
||||
|
||||
#define IEEE80211_MGT_SUBTYPE_NAMES { \
|
||||
"assoc-req", "assoc-resp", \
|
||||
"reassoc-req", "reassoc-resp", \
|
||||
"probe-req", "probe-resp", \
|
||||
"reserved#6", "reserved#7", \
|
||||
"beacon", "atim", \
|
||||
"disassoc", "auth", \
|
||||
"deauth", "reserved#13", \
|
||||
"reserved#14", "reserved#15" \
|
||||
}
|
||||
|
||||
#define IEEE80211_CTL_SUBTYPE_NAMES { \
|
||||
"reserved#0", "reserved#1", \
|
||||
"reserved#2", "reserved#3", \
|
||||
"reserved#3", "reserved#5", \
|
||||
"reserved#6", "reserved#7", \
|
||||
"reserved#8", "reserved#9", \
|
||||
"ps-poll", "rts", \
|
||||
"cts", "ack", \
|
||||
"cf-end", "cf-end-ack" \
|
||||
}
|
||||
|
||||
#define IEEE80211_DATA_SUBTYPE_NAMES { \
|
||||
"data", "data-cf-ack", \
|
||||
"data-cf-poll", "data-cf-ack-poll", \
|
||||
"null", "cf-ack", \
|
||||
"cf-poll", "cf-ack-poll", \
|
||||
"qos-data", "qos-data-cf-ack", \
|
||||
"qos-data-cf-poll", "qos-data-cf-ack-poll", \
|
||||
"qos", "reserved#13", \
|
||||
"qos-cf-poll", "qos-cf-ack-poll" \
|
||||
}
|
||||
|
||||
#define IEEE80211_TYPE_NAMES { "mgt", "ctl", "data", "reserved#4" }
|
||||
|
||||
#endif /* _NET80211_IEEE80211_H_ */
|
@ -1,403 +0,0 @@
|
||||
/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */
|
||||
/*
|
||||
* Copyright (c) 1994, 1995, 1996, 1997, 1998
|
||||
* 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 Computer Systems
|
||||
* Engineering Group at Lawrence Berkeley Laboratory.
|
||||
* 4. Neither the name of the University nor of the Laboratory 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <pcap-stdinc.h>
|
||||
#else /* _WIN32 */
|
||||
|
||||
#include <sys/param.h>
|
||||
#ifndef MSDOS
|
||||
#include <sys/file.h>
|
||||
#endif
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#ifdef HAVE_SYS_SOCKIO_H
|
||||
#include <sys/sockio.h>
|
||||
#endif
|
||||
|
||||
struct mbuf; /* Squelch compiler warnings on some platforms for */
|
||||
struct rtentry; /* declarations in <net/if.h> */
|
||||
#include <net/if.h>
|
||||
#include <netinet/in.h>
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#include <errno.h>
|
||||
#include <memory.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#if !defined(_WIN32) && !defined(__BORLANDC__)
|
||||
#include <unistd.h>
|
||||
#endif /* !_WIN32 && !__BORLANDC__ */
|
||||
|
||||
#include "pcap-int.h"
|
||||
|
||||
#ifdef HAVE_OS_PROTO_H
|
||||
#include "os-proto.h"
|
||||
#endif
|
||||
|
||||
#if !defined(_WIN32) && !defined(MSDOS)
|
||||
|
||||
/*
|
||||
* Return the name of a network interface attached to the system, or NULL
|
||||
* if none can be found. The interface must be configured up; the
|
||||
* lowest unit number is preferred; loopback is ignored.
|
||||
*/
|
||||
char *
|
||||
pcap_lookupdev(errbuf)
|
||||
register char *errbuf;
|
||||
{
|
||||
pcap_if_t *alldevs;
|
||||
/* for old BSD systems, including bsdi3 */
|
||||
#ifndef IF_NAMESIZE
|
||||
#define IF_NAMESIZE IFNAMSIZ
|
||||
#endif
|
||||
static char device[IF_NAMESIZE + 1];
|
||||
char *ret;
|
||||
|
||||
if (pcap_findalldevs(&alldevs, errbuf) == -1)
|
||||
return (NULL);
|
||||
|
||||
if (alldevs == NULL || (alldevs->flags & PCAP_IF_LOOPBACK)) {
|
||||
/*
|
||||
* There are no devices on the list, or the first device
|
||||
* on the list is a loopback device, which means there
|
||||
* are no non-loopback devices on the list. This means
|
||||
* we can't return any device.
|
||||
*
|
||||
* XXX - why not return a loopback device? If we can't
|
||||
* capture on it, it won't be on the list, and if it's
|
||||
* on the list, there aren't any non-loopback devices,
|
||||
* so why not just supply it as the default device?
|
||||
*/
|
||||
(void)strlcpy(errbuf, "no suitable device found",
|
||||
PCAP_ERRBUF_SIZE);
|
||||
ret = NULL;
|
||||
} else {
|
||||
/*
|
||||
* Return the name of the first device on the list.
|
||||
*/
|
||||
(void)strlcpy(device, alldevs->name, sizeof(device));
|
||||
ret = device;
|
||||
}
|
||||
|
||||
pcap_freealldevs(alldevs);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
int
|
||||
pcap_lookupnet(device, netp, maskp, errbuf)
|
||||
register const char *device;
|
||||
register bpf_u_int32 *netp, *maskp;
|
||||
register char *errbuf;
|
||||
{
|
||||
register int fd;
|
||||
register struct sockaddr_in *sin4;
|
||||
struct ifreq ifr;
|
||||
|
||||
/*
|
||||
* The pseudo-device "any" listens on all interfaces and therefore
|
||||
* has the network address and -mask "0.0.0.0" therefore catching
|
||||
* all traffic. Using NULL for the interface is the same as "any".
|
||||
*/
|
||||
if (!device || strcmp(device, "any") == 0
|
||||
#ifdef HAVE_DAG_API
|
||||
|| strstr(device, "dag") != NULL
|
||||
#endif
|
||||
#ifdef HAVE_SEPTEL_API
|
||||
|| strstr(device, "septel") != NULL
|
||||
#endif
|
||||
#ifdef PCAP_SUPPORT_BT
|
||||
|| strstr(device, "bluetooth") != NULL
|
||||
#endif
|
||||
#ifdef PCAP_SUPPORT_USB
|
||||
|| strstr(device, "usbmon") != NULL
|
||||
#endif
|
||||
#ifdef HAVE_SNF_API
|
||||
|| strstr(device, "snf") != NULL
|
||||
#endif
|
||||
) {
|
||||
*netp = *maskp = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
fd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (fd < 0) {
|
||||
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "socket: %s",
|
||||
pcap_strerror(errno));
|
||||
return (-1);
|
||||
}
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
#ifdef linux
|
||||
/* XXX Work around Linux kernel bug */
|
||||
ifr.ifr_addr.sa_family = AF_INET;
|
||||
#endif
|
||||
(void)strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
|
||||
if (ioctl(fd, SIOCGIFADDR, (char *)&ifr) < 0) {
|
||||
if (errno == EADDRNOTAVAIL) {
|
||||
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"%s: no IPv4 address assigned", device);
|
||||
} else {
|
||||
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"SIOCGIFADDR: %s: %s",
|
||||
device, pcap_strerror(errno));
|
||||
}
|
||||
(void)close(fd);
|
||||
return (-1);
|
||||
}
|
||||
sin4 = (struct sockaddr_in *)&ifr.ifr_addr;
|
||||
*netp = sin4->sin_addr.s_addr;
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
#ifdef linux
|
||||
/* XXX Work around Linux kernel bug */
|
||||
ifr.ifr_addr.sa_family = AF_INET;
|
||||
#endif
|
||||
(void)strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
|
||||
if (ioctl(fd, SIOCGIFNETMASK, (char *)&ifr) < 0) {
|
||||
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"SIOCGIFNETMASK: %s: %s", device, pcap_strerror(errno));
|
||||
(void)close(fd);
|
||||
return (-1);
|
||||
}
|
||||
(void)close(fd);
|
||||
*maskp = sin4->sin_addr.s_addr;
|
||||
if (*maskp == 0) {
|
||||
if (IN_CLASSA(*netp))
|
||||
*maskp = IN_CLASSA_NET;
|
||||
else if (IN_CLASSB(*netp))
|
||||
*maskp = IN_CLASSB_NET;
|
||||
else if (IN_CLASSC(*netp))
|
||||
*maskp = IN_CLASSC_NET;
|
||||
else {
|
||||
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"inet class for 0x%x unknown", *netp);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
*netp &= *maskp;
|
||||
return (0);
|
||||
}
|
||||
|
||||
#elif defined(_WIN32)
|
||||
|
||||
/*
|
||||
* Return the name of a network interface attached to the system, or NULL
|
||||
* if none can be found. The interface must be configured up; the
|
||||
* lowest unit number is preferred; loopback is ignored.
|
||||
*
|
||||
* In the best of all possible worlds, this would be the same as on
|
||||
* UN*X, but there may be software that expects this to return a
|
||||
* full list of devices after the first device.
|
||||
*/
|
||||
#define ADAPTERSNAME_LEN 8192
|
||||
char *
|
||||
pcap_lookupdev(errbuf)
|
||||
register char *errbuf;
|
||||
{
|
||||
DWORD dwVersion;
|
||||
DWORD dwWindowsMajorVersion;
|
||||
char our_errbuf[PCAP_ERRBUF_SIZE+1];
|
||||
|
||||
#pragma warning (push)
|
||||
#pragma warning (disable: 4996) /* disable MSVC's GetVersion() deprecated warning here */
|
||||
dwVersion = GetVersion(); /* get the OS version */
|
||||
#pragma warning (pop)
|
||||
dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
|
||||
|
||||
if (dwVersion >= 0x80000000 && dwWindowsMajorVersion >= 4) {
|
||||
/*
|
||||
* Windows 95, 98, ME.
|
||||
*/
|
||||
ULONG NameLength = ADAPTERSNAME_LEN;
|
||||
static char AdaptersName[ADAPTERSNAME_LEN];
|
||||
|
||||
if (PacketGetAdapterNames(AdaptersName,&NameLength) )
|
||||
return (AdaptersName);
|
||||
else
|
||||
return NULL;
|
||||
} else {
|
||||
/*
|
||||
* Windows NT (NT 4.0 and later).
|
||||
* Convert the names to Unicode for backward compatibility.
|
||||
*/
|
||||
ULONG NameLength = ADAPTERSNAME_LEN;
|
||||
static WCHAR AdaptersName[ADAPTERSNAME_LEN];
|
||||
size_t BufferSpaceLeft;
|
||||
char *tAstr;
|
||||
WCHAR *Unameptr;
|
||||
char *Adescptr;
|
||||
size_t namelen, i;
|
||||
WCHAR *TAdaptersName = (WCHAR*)malloc(ADAPTERSNAME_LEN * sizeof(WCHAR));
|
||||
int NAdapts = 0;
|
||||
|
||||
if(TAdaptersName == NULL)
|
||||
{
|
||||
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "memory allocation failure");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( !PacketGetAdapterNames((PTSTR)TAdaptersName,&NameLength) )
|
||||
{
|
||||
pcap_win32_err_to_str(GetLastError(), our_errbuf);
|
||||
(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"PacketGetAdapterNames: %s", our_errbuf);
|
||||
free(TAdaptersName);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
BufferSpaceLeft = ADAPTERSNAME_LEN * sizeof(WCHAR);
|
||||
tAstr = (char*)TAdaptersName;
|
||||
Unameptr = AdaptersName;
|
||||
|
||||
/*
|
||||
* Convert the device names to Unicode into AdapterName.
|
||||
*/
|
||||
do {
|
||||
/*
|
||||
* Length of the name, including the terminating
|
||||
* NUL.
|
||||
*/
|
||||
namelen = strlen(tAstr) + 1;
|
||||
|
||||
/*
|
||||
* Do we have room for the name in the Unicode
|
||||
* buffer?
|
||||
*/
|
||||
if (BufferSpaceLeft < namelen * sizeof(WCHAR)) {
|
||||
/*
|
||||
* No.
|
||||
*/
|
||||
goto quit;
|
||||
}
|
||||
BufferSpaceLeft -= namelen * sizeof(WCHAR);
|
||||
|
||||
/*
|
||||
* Copy the name, converting ASCII to Unicode.
|
||||
* namelen includes the NUL, so we copy it as
|
||||
* well.
|
||||
*/
|
||||
for (i = 0; i < namelen; i++)
|
||||
*Unameptr++ = *tAstr++;
|
||||
|
||||
/*
|
||||
* Count this adapter.
|
||||
*/
|
||||
NAdapts++;
|
||||
} while (namelen != 1);
|
||||
|
||||
/*
|
||||
* Copy the descriptions, but don't convert them from
|
||||
* ASCII to Unicode.
|
||||
*/
|
||||
Adescptr = (char *)Unameptr;
|
||||
while(NAdapts--)
|
||||
{
|
||||
size_t desclen;
|
||||
|
||||
desclen = strlen(tAstr) + 1;
|
||||
|
||||
/*
|
||||
* Do we have room for the name in the Unicode
|
||||
* buffer?
|
||||
*/
|
||||
if (BufferSpaceLeft < desclen) {
|
||||
/*
|
||||
* No.
|
||||
*/
|
||||
goto quit;
|
||||
}
|
||||
|
||||
/*
|
||||
* Just copy the ASCII string.
|
||||
* namelen includes the NUL, so we copy it as
|
||||
* well.
|
||||
*/
|
||||
memcpy(Adescptr, tAstr, desclen);
|
||||
Adescptr += desclen;
|
||||
tAstr += desclen;
|
||||
BufferSpaceLeft -= desclen;
|
||||
}
|
||||
|
||||
quit:
|
||||
free(TAdaptersName);
|
||||
return (char *)(AdaptersName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
pcap_lookupnet(device, netp, maskp, errbuf)
|
||||
register const char *device;
|
||||
register bpf_u_int32 *netp, *maskp;
|
||||
register char *errbuf;
|
||||
{
|
||||
/*
|
||||
* We need only the first IPv4 address, so we must scan the array returned by PacketGetNetInfo()
|
||||
* in order to skip non IPv4 (i.e. IPv6 addresses)
|
||||
*/
|
||||
npf_if_addr if_addrs[MAX_NETWORK_ADDRESSES];
|
||||
LONG if_addr_size = 1;
|
||||
struct sockaddr_in *t_addr;
|
||||
unsigned int i;
|
||||
|
||||
if (!PacketGetNetInfoEx((void *)device, if_addrs, &if_addr_size)) {
|
||||
*netp = *maskp = 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
for(i=0; i<MAX_NETWORK_ADDRESSES; i++)
|
||||
{
|
||||
if(if_addrs[i].IPAddress.ss_family == AF_INET)
|
||||
{
|
||||
t_addr = (struct sockaddr_in *) &(if_addrs[i].IPAddress);
|
||||
*netp = t_addr->sin_addr.S_un.S_addr;
|
||||
t_addr = (struct sockaddr_in *) &(if_addrs[i].SubnetMask);
|
||||
*maskp = t_addr->sin_addr.S_un.S_addr;
|
||||
|
||||
*netp &= *maskp;
|
||||
return (0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
*netp = *maskp = 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
#endif /* !_WIN32 && !MSDOS */
|
Binary file not shown.
@ -1,250 +0,0 @@
|
||||
#! /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
|
@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1993, 1994, 1995, 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.
|
||||
*/
|
||||
|
||||
/* Prototypes missing in AIX 4.x */
|
||||
int ffs(int i);
|
@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1993, 1994, 1995, 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.
|
||||
*/
|
||||
|
||||
/* Prototypes missing in AIX 7.x */
|
||||
int ffs(int i);
|
@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1993, 1994, 1995, 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.
|
||||
*/
|
||||
|
||||
/* Prototypes missing in HP-UX 11.x */
|
||||
int ffs(int i);
|
@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1993, 1994, 1995, 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.
|
||||
*/
|
||||
|
||||
/* Prototypes missing in Digital UNIX 4.x */
|
||||
int pcap_snprintf(char *, size_t, const char *, ...);
|
||||
int pcap_vsnprintf(char *, size_t, const char *, va_list);
|
||||
int pfopen(char *, int);
|
||||
|
@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1993, 1994, 1995, 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Prototypes missing in Tru64 UNIX 5.x
|
||||
* XXX - "pcap_snprintf()" and "pcap_vsnprintf()" aren't missing, but you have to
|
||||
* #define the right value to get them defined by <stdio.h>.
|
||||
*/
|
||||
int pcap_snprintf(char *, size_t, const char *, ...);
|
||||
int pcap_vsnprintf(char *, size_t, const char *, va_list);
|
||||
int pfopen(char *, int);
|
||||
|
@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1993, 1994, 1995, 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.
|
||||
*/
|
||||
|
||||
/* Prototypes missing in SunOS 5 */
|
||||
char *strerror(int);
|
||||
int pcap_snprintf(char *, size_t, const char *, ...);
|
@ -1,211 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1989, 1990, 1993, 1994, 1995, 1996
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* Prototypes missing in SunOS 4 */
|
||||
#ifdef FILE
|
||||
int _filbuf(FILE *);
|
||||
int _flsbuf(u_char, FILE *);
|
||||
int fclose(FILE *);
|
||||
int fflush(FILE *);
|
||||
int fgetc(FILE *);
|
||||
int fprintf(FILE *, const char *, ...);
|
||||
int fputc(int, FILE *);
|
||||
int fputs(const char *, FILE *);
|
||||
u_int fread(void *, u_int, u_int, FILE *);
|
||||
int fseek(FILE *, long, int);
|
||||
u_int fwrite(const void *, u_int, u_int, FILE *);
|
||||
int pclose(FILE *);
|
||||
void rewind(FILE *);
|
||||
void setbuf(FILE *, char *);
|
||||
int setlinebuf(FILE *);
|
||||
int ungetc(int, FILE *);
|
||||
int vfprintf(FILE *, const char *, ...);
|
||||
int vprintf(const char *, ...);
|
||||
#endif
|
||||
|
||||
#if __GNUC__ <= 1
|
||||
int read(int, char *, u_int);
|
||||
int write(int, char *, u_int);
|
||||
#endif
|
||||
|
||||
long a64l(const char *);
|
||||
#ifdef __STDC__
|
||||
struct sockaddr;
|
||||
#endif
|
||||
int accept(int, struct sockaddr *, int *);
|
||||
int bind(int, struct sockaddr *, int);
|
||||
int bcmp(const void *, const void *, u_int);
|
||||
void bcopy(const void *, void *, u_int);
|
||||
void bzero(void *, int);
|
||||
int chroot(const char *);
|
||||
int close(int);
|
||||
void closelog(void);
|
||||
int connect(int, struct sockaddr *, int);
|
||||
char *crypt(const char *, const char *);
|
||||
int daemon(int, int);
|
||||
int fchmod(int, int);
|
||||
int fchown(int, int, int);
|
||||
void endgrent(void);
|
||||
void endpwent(void);
|
||||
#ifdef __STDC__
|
||||
struct ether_addr;
|
||||
#endif
|
||||
struct ether_addr *ether_aton(const char *);
|
||||
int flock(int, int);
|
||||
#ifdef __STDC__
|
||||
struct stat;
|
||||
#endif
|
||||
int fstat(int, struct stat *);
|
||||
#ifdef __STDC__
|
||||
struct statfs;
|
||||
#endif
|
||||
int fstatfs(int, struct statfs *);
|
||||
int fsync(int);
|
||||
#ifdef __STDC__
|
||||
struct timeb;
|
||||
#endif
|
||||
int ftime(struct timeb *);
|
||||
int ftruncate(int, off_t);
|
||||
int getdtablesize(void);
|
||||
long gethostid(void);
|
||||
int gethostname(char *, int);
|
||||
int getopt(int, char * const *, const char *);
|
||||
int getpagesize(void);
|
||||
char *getpass(char *);
|
||||
int getpeername(int, struct sockaddr *, int *);
|
||||
int getpriority(int, int);
|
||||
#ifdef __STDC__
|
||||
struct rlimit;
|
||||
#endif
|
||||
int getrlimit(int, struct rlimit *);
|
||||
int getsockname(int, struct sockaddr *, int *);
|
||||
int getsockopt(int, int, int, char *, int *);
|
||||
#ifdef __STDC__
|
||||
struct timeval;
|
||||
struct timezone;
|
||||
#endif
|
||||
int gettimeofday(struct timeval *, struct timezone *);
|
||||
char *getusershell(void);
|
||||
char *getwd(char *);
|
||||
int initgroups(const char *, int);
|
||||
int ioctl(int, int, caddr_t);
|
||||
int iruserok(u_long, int, char *, char *);
|
||||
int isatty(int);
|
||||
int killpg(int, int);
|
||||
int listen(int, int);
|
||||
#ifdef __STDC__
|
||||
struct utmp;
|
||||
#endif
|
||||
void login(struct utmp *);
|
||||
int logout(const char *);
|
||||
off_t lseek(int, off_t, int);
|
||||
int lstat(const char *, struct stat *);
|
||||
int mkstemp(char *);
|
||||
char *mktemp(char *);
|
||||
int munmap(caddr_t, int);
|
||||
void openlog(const char *, int, int);
|
||||
void perror(const char *);
|
||||
int printf(const char *, ...);
|
||||
int puts(const char *);
|
||||
long random(void);
|
||||
int readlink(const char *, char *, int);
|
||||
#ifdef __STDC__
|
||||
struct iovec;
|
||||
#endif
|
||||
int readv(int, struct iovec *, int);
|
||||
int recv(int, char *, u_int, int);
|
||||
int recvfrom(int, char *, u_int, int, struct sockaddr *, int *);
|
||||
int rename(const char *, const char *);
|
||||
int rcmd(char **, u_short, char *, char *, char *, int *);
|
||||
int rresvport(int *);
|
||||
int send(int, char *, u_int, int);
|
||||
int sendto(int, char *, u_int, int, struct sockaddr *, int);
|
||||
int setenv(const char *, const char *, int);
|
||||
int seteuid(int);
|
||||
int setpriority(int, int, int);
|
||||
int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
|
||||
int setpgrp(int, int);
|
||||
void setpwent(void);
|
||||
int setrlimit(int, struct rlimit *);
|
||||
int setsockopt(int, int, int, char *, int);
|
||||
int shutdown(int, int);
|
||||
int sigblock(int);
|
||||
void (*signal (int, void (*) (int))) (int);
|
||||
int sigpause(int);
|
||||
int sigsetmask(int);
|
||||
#ifdef __STDC__
|
||||
struct sigvec;
|
||||
#endif
|
||||
int sigvec(int, struct sigvec *, struct sigvec*);
|
||||
int pcap_snprintf(char *, size_t, const char *, ...);
|
||||
int socket(int, int, int);
|
||||
int socketpair(int, int, int, int *);
|
||||
int symlink(const char *, const char *);
|
||||
void srandom(int);
|
||||
int sscanf(char *, const char *, ...);
|
||||
int stat(const char *, struct stat *);
|
||||
int statfs(char *, struct statfs *);
|
||||
char *strerror(int);
|
||||
int strcasecmp(const char *, const char *);
|
||||
#ifdef __STDC__
|
||||
struct tm;
|
||||
#endif
|
||||
int strftime(char *, int, char *, struct tm *);
|
||||
int strncasecmp(const char *, const char *, int);
|
||||
long strtol(const char *, char **, int);
|
||||
void sync(void);
|
||||
void syslog(int, const char *, ...);
|
||||
int system(const char *);
|
||||
long tell(int);
|
||||
time_t time(time_t *);
|
||||
char *timezone(int, int);
|
||||
int tolower(int);
|
||||
int toupper(int);
|
||||
int truncate(char *, off_t);
|
||||
void unsetenv(const char *);
|
||||
int vfork(void);
|
||||
int vsprintf(char *, const char *, ...);
|
||||
int writev(int, struct iovec *, int);
|
||||
#ifdef __STDC__
|
||||
struct rusage;
|
||||
#endif
|
||||
int utimes(const char *, struct timeval *);
|
||||
#if __GNUC__ <= 1
|
||||
int wait(int *);
|
||||
pid_t wait3(int *, int, struct rusage *);
|
||||
#endif
|
||||
|
||||
/* Ugly signal hacking */
|
||||
#ifdef SIG_ERR
|
||||
#undef SIG_ERR
|
||||
#define SIG_ERR (void (*)(int))-1
|
||||
#undef SIG_DFL
|
||||
#define SIG_DFL (void (*)(int))0
|
||||
#undef SIG_IGN
|
||||
#define SIG_IGN (void (*)(int))1
|
||||
|
||||
#ifdef KERNEL
|
||||
#undef SIG_CATCH
|
||||
#define SIG_CATCH (void (*)(int))2
|
||||
#endif
|
||||
#undef SIG_HOLD
|
||||
#define SIG_HOLD (void (*)(int))3
|
||||
#endif
|
@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1990, 1993, 1994, 1995, 1996
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* Prototypes missing in Ultrix 4 */
|
||||
int bcmp(const char *, const char *, u_int);
|
||||
void bcopy(const void *, void *, u_int);
|
||||
void bzero(void *, u_int);
|
||||
int getopt(int, char * const *, const char *);
|
||||
#ifdef __STDC__
|
||||
struct timeval;
|
||||
struct timezone;
|
||||
#endif
|
||||
int gettimeofday(struct timeval *, struct timezone *);
|
||||
int ioctl(int, int, caddr_t);
|
||||
int pfopen(char *, int);
|
||||
int setlinebuf(FILE *);
|
||||
int socket(int, int, int);
|
||||
int strcasecmp(const char *, const char *);
|
Binary file not shown.
Binary file not shown.
@ -1,98 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Definitions for information in the LLC header.
|
||||
*/
|
||||
|
||||
#define LLC_U_FMT 3
|
||||
#define LLC_GSAP 1
|
||||
#define LLC_IG 1 /* Individual / Group */
|
||||
#define LLC_S_FMT 1
|
||||
|
||||
#define LLC_U_POLL 0x10
|
||||
#define LLC_IS_POLL 0x0100
|
||||
#define LLC_XID_FI 0x81
|
||||
|
||||
#define LLC_U_CMD_MASK 0xef
|
||||
#define LLC_UI 0x03
|
||||
#define LLC_UA 0x63
|
||||
#define LLC_DISC 0x43
|
||||
#define LLC_DM 0x0f
|
||||
#define LLC_SABME 0x6f
|
||||
#define LLC_TEST 0xe3
|
||||
#define LLC_XID 0xaf
|
||||
#define LLC_FRMR 0x87
|
||||
|
||||
#define LLC_S_CMD_MASK 0x0f
|
||||
#define LLC_RR 0x0001
|
||||
#define LLC_RNR 0x0005
|
||||
#define LLC_REJ 0x0009
|
||||
|
||||
#define LLC_IS_NR(is) (((is) >> 9) & 0x7f)
|
||||
#define LLC_I_NS(is) (((is) >> 1) & 0x7f)
|
||||
|
||||
/*
|
||||
* 802.2 LLC SAP values.
|
||||
*/
|
||||
|
||||
#ifndef LLCSAP_NULL
|
||||
#define LLCSAP_NULL 0x00
|
||||
#endif
|
||||
#ifndef LLCSAP_GLOBAL
|
||||
#define LLCSAP_GLOBAL 0xff
|
||||
#endif
|
||||
#ifndef LLCSAP_8021B_I
|
||||
#define LLCSAP_8021B_I 0x02
|
||||
#endif
|
||||
#ifndef LLCSAP_8021B_G
|
||||
#define LLCSAP_8021B_G 0x03
|
||||
#endif
|
||||
#ifndef LLCSAP_IP
|
||||
#define LLCSAP_IP 0x06
|
||||
#endif
|
||||
#ifndef LLCSAP_PROWAYNM
|
||||
#define LLCSAP_PROWAYNM 0x0e
|
||||
#endif
|
||||
#ifndef LLCSAP_8021D
|
||||
#define LLCSAP_8021D 0x42
|
||||
#endif
|
||||
#ifndef LLCSAP_RS511
|
||||
#define LLCSAP_RS511 0x4e
|
||||
#endif
|
||||
#ifndef LLCSAP_ISO8208
|
||||
#define LLCSAP_ISO8208 0x7e
|
||||
#endif
|
||||
#ifndef LLCSAP_PROWAY
|
||||
#define LLCSAP_PROWAY 0x8e
|
||||
#endif
|
||||
#ifndef LLCSAP_SNAP
|
||||
#define LLCSAP_SNAP 0xaa
|
||||
#endif
|
||||
#ifndef LLCSAP_IPX
|
||||
#define LLCSAP_IPX 0xe0
|
||||
#endif
|
||||
#ifndef LLCSAP_NETBEUI
|
||||
#define LLCSAP_NETBEUI 0xf0
|
||||
#endif
|
||||
#ifndef LLCSAP_ISONS
|
||||
#define LLCSAP_ISONS 0xfe
|
||||
#endif
|
@ -1,126 +0,0 @@
|
||||
/*
|
||||
* 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>
|
||||
|
||||
#include "getopt.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;
|
||||
{
|
||||
char *cp;
|
||||
static char *__progname;
|
||||
static char *place = EMSG; /* option letter processing */
|
||||
char *oli; /* option letter list index */
|
||||
|
||||
if (__progname == NULL) {
|
||||
if ((cp = strrchr(nargv[0], '/')) != NULL)
|
||||
__progname = cp + 1;
|
||||
else
|
||||
__progname = nargv[0];
|
||||
}
|
||||
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 */
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
/*
|
||||
* Header for the getopt() we supply if the platform doesn't supply it.
|
||||
*/
|
||||
extern char *optarg; /* getopt(3) external variables */
|
||||
extern int optind, opterr, optopt;
|
||||
|
||||
extern int getopt(int nargc, char * const *nargv, const char *ostr);
|
@ -1,625 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1995-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. 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <pcap-int.h>
|
||||
|
||||
enum format_flags {
|
||||
minus_flag = 1,
|
||||
plus_flag = 2,
|
||||
space_flag = 4,
|
||||
alternate_flag = 8,
|
||||
zero_flag = 16
|
||||
};
|
||||
|
||||
/*
|
||||
* Common state
|
||||
*/
|
||||
|
||||
struct state {
|
||||
unsigned char *str;
|
||||
unsigned char *s;
|
||||
unsigned char *theend;
|
||||
size_t sz;
|
||||
size_t max_sz;
|
||||
int (*append_char)(struct state *, unsigned char);
|
||||
int (*reserve)(struct state *, size_t);
|
||||
/* XXX - methods */
|
||||
};
|
||||
|
||||
#ifndef HAVE_VSNPRINTF
|
||||
static int
|
||||
sn_reserve (struct state *state, size_t n)
|
||||
{
|
||||
return state->s + n > state->theend;
|
||||
}
|
||||
|
||||
static int
|
||||
sn_append_char (struct state *state, unsigned char c)
|
||||
{
|
||||
if (sn_reserve (state, 1)) {
|
||||
return 1;
|
||||
} else {
|
||||
*state->s++ = c;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
static int
|
||||
as_reserve (struct state *state, size_t n)
|
||||
{
|
||||
if (state->s + n > state->theend) {
|
||||
int off = state->s - state->str;
|
||||
unsigned char *tmp;
|
||||
|
||||
if (state->max_sz && state->sz >= state->max_sz)
|
||||
return 1;
|
||||
|
||||
state->sz = max(state->sz * 2, state->sz + n);
|
||||
if (state->max_sz)
|
||||
state->sz = min(state->sz, state->max_sz);
|
||||
tmp = realloc (state->str, state->sz);
|
||||
if (tmp == NULL)
|
||||
return 1;
|
||||
state->str = tmp;
|
||||
state->s = state->str + off;
|
||||
state->theend = state->str + state->sz - 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
as_append_char (struct state *state, unsigned char c)
|
||||
{
|
||||
if(as_reserve (state, 1))
|
||||
return 1;
|
||||
else {
|
||||
*state->s++ = c;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
append_number(struct state *state,
|
||||
unsigned long num, unsigned base, char *rep,
|
||||
int width, int prec, int flags, int minusp)
|
||||
{
|
||||
int len = 0;
|
||||
int i;
|
||||
|
||||
/* given precision, ignore zero flag */
|
||||
if(prec != -1)
|
||||
flags &= ~zero_flag;
|
||||
else
|
||||
prec = 1;
|
||||
/* zero value with zero precision -> "" */
|
||||
if(prec == 0 && num == 0)
|
||||
return 0;
|
||||
do{
|
||||
if((*state->append_char)(state, rep[num % base]))
|
||||
return 1;
|
||||
len++;
|
||||
num /= base;
|
||||
}while(num);
|
||||
prec -= len;
|
||||
/* pad with prec zeros */
|
||||
while(prec-- > 0){
|
||||
if((*state->append_char)(state, '0'))
|
||||
return 1;
|
||||
len++;
|
||||
}
|
||||
/* add length of alternate prefix (added later) to len */
|
||||
if(flags & alternate_flag && (base == 16 || base == 8))
|
||||
len += base / 8;
|
||||
/* pad with zeros */
|
||||
if(flags & zero_flag){
|
||||
width -= len;
|
||||
if(minusp || (flags & space_flag) || (flags & plus_flag))
|
||||
width--;
|
||||
while(width-- > 0){
|
||||
if((*state->append_char)(state, '0'))
|
||||
return 1;
|
||||
len++;
|
||||
}
|
||||
}
|
||||
/* add alternate prefix */
|
||||
if(flags & alternate_flag && (base == 16 || base == 8)){
|
||||
if(base == 16)
|
||||
if((*state->append_char)(state, rep[10] + 23)) /* XXX */
|
||||
return 1;
|
||||
if((*state->append_char)(state, '0'))
|
||||
return 1;
|
||||
}
|
||||
/* add sign */
|
||||
if(minusp){
|
||||
if((*state->append_char)(state, '-'))
|
||||
return 1;
|
||||
len++;
|
||||
} else if(flags & plus_flag) {
|
||||
if((*state->append_char)(state, '+'))
|
||||
return 1;
|
||||
len++;
|
||||
} else if(flags & space_flag) {
|
||||
if((*state->append_char)(state, ' '))
|
||||
return 1;
|
||||
len++;
|
||||
}
|
||||
if(flags & minus_flag)
|
||||
/* swap before padding with spaces */
|
||||
for(i = 0; i < len / 2; i++){
|
||||
char c = state->s[-i-1];
|
||||
state->s[-i-1] = state->s[-len+i];
|
||||
state->s[-len+i] = c;
|
||||
}
|
||||
width -= len;
|
||||
while(width-- > 0){
|
||||
if((*state->append_char)(state, ' '))
|
||||
return 1;
|
||||
len++;
|
||||
}
|
||||
if(!(flags & minus_flag))
|
||||
/* swap after padding with spaces */
|
||||
for(i = 0; i < len / 2; i++){
|
||||
char c = state->s[-i-1];
|
||||
state->s[-i-1] = state->s[-len+i];
|
||||
state->s[-len+i] = c;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
append_string (struct state *state,
|
||||
unsigned char *arg,
|
||||
int width,
|
||||
int prec,
|
||||
int flags)
|
||||
{
|
||||
if(prec != -1)
|
||||
width -= prec;
|
||||
else
|
||||
width -= strlen((char *)arg);
|
||||
if(!(flags & minus_flag))
|
||||
while(width-- > 0)
|
||||
if((*state->append_char) (state, ' '))
|
||||
return 1;
|
||||
if (prec != -1) {
|
||||
while (*arg && prec--)
|
||||
if ((*state->append_char) (state, *arg++))
|
||||
return 1;
|
||||
} else {
|
||||
while (*arg)
|
||||
if ((*state->append_char) (state, *arg++))
|
||||
return 1;
|
||||
}
|
||||
if(flags & minus_flag)
|
||||
while(width-- > 0)
|
||||
if((*state->append_char) (state, ' '))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
append_char(struct state *state,
|
||||
unsigned char arg,
|
||||
int width,
|
||||
int flags)
|
||||
{
|
||||
while(!(flags & minus_flag) && --width > 0)
|
||||
if((*state->append_char) (state, ' '))
|
||||
return 1;
|
||||
|
||||
if((*state->append_char) (state, arg))
|
||||
return 1;
|
||||
while((flags & minus_flag) && --width > 0)
|
||||
if((*state->append_char) (state, ' '))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* This can't be made into a function...
|
||||
*/
|
||||
|
||||
#define PARSE_INT_FORMAT(res, arg, unsig) \
|
||||
if (long_flag) \
|
||||
res = (unsig long)va_arg(arg, unsig long); \
|
||||
else if (short_flag) \
|
||||
res = (unsig short)va_arg(arg, unsig int); \
|
||||
else \
|
||||
res = (unsig int)va_arg(arg, unsig int)
|
||||
|
||||
/*
|
||||
* zyxprintf - return 0 or -1
|
||||
*/
|
||||
|
||||
static int
|
||||
xyzprintf (struct state *state, const char *char_format, va_list ap)
|
||||
{
|
||||
const unsigned char *format = (const unsigned char *)char_format;
|
||||
unsigned char c;
|
||||
|
||||
while((c = *format++)) {
|
||||
if (c == '%') {
|
||||
int flags = 0;
|
||||
int width = 0;
|
||||
int prec = -1;
|
||||
int long_flag = 0;
|
||||
int short_flag = 0;
|
||||
|
||||
/* flags */
|
||||
while((c = *format++)){
|
||||
if(c == '-')
|
||||
flags |= minus_flag;
|
||||
else if(c == '+')
|
||||
flags |= plus_flag;
|
||||
else if(c == ' ')
|
||||
flags |= space_flag;
|
||||
else if(c == '#')
|
||||
flags |= alternate_flag;
|
||||
else if(c == '0')
|
||||
flags |= zero_flag;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if((flags & space_flag) && (flags & plus_flag))
|
||||
flags ^= space_flag;
|
||||
|
||||
if((flags & minus_flag) && (flags & zero_flag))
|
||||
flags ^= zero_flag;
|
||||
|
||||
/* width */
|
||||
if (isdigit(c))
|
||||
do {
|
||||
width = width * 10 + c - '0';
|
||||
c = *format++;
|
||||
} while(isdigit(c));
|
||||
else if(c == '*') {
|
||||
width = va_arg(ap, int);
|
||||
c = *format++;
|
||||
}
|
||||
|
||||
/* precision */
|
||||
if (c == '.') {
|
||||
prec = 0;
|
||||
c = *format++;
|
||||
if (isdigit(c))
|
||||
do {
|
||||
prec = prec * 10 + c - '0';
|
||||
c = *format++;
|
||||
} while(isdigit(c));
|
||||
else if (c == '*') {
|
||||
prec = va_arg(ap, int);
|
||||
c = *format++;
|
||||
}
|
||||
}
|
||||
|
||||
/* size */
|
||||
|
||||
if (c == 'h') {
|
||||
short_flag = 1;
|
||||
c = *format++;
|
||||
} else if (c == 'l') {
|
||||
long_flag = 1;
|
||||
c = *format++;
|
||||
}
|
||||
|
||||
switch (c) {
|
||||
case 'c' :
|
||||
if(append_char(state, va_arg(ap, int), width, flags))
|
||||
return -1;
|
||||
break;
|
||||
case 's' :
|
||||
if (append_string(state,
|
||||
va_arg(ap, unsigned char*),
|
||||
width,
|
||||
prec,
|
||||
flags))
|
||||
return -1;
|
||||
break;
|
||||
case 'd' :
|
||||
case 'i' : {
|
||||
long arg;
|
||||
unsigned long num;
|
||||
int minusp = 0;
|
||||
|
||||
PARSE_INT_FORMAT(arg, ap, signed);
|
||||
|
||||
if (arg < 0) {
|
||||
minusp = 1;
|
||||
num = -arg;
|
||||
} else
|
||||
num = arg;
|
||||
|
||||
if (append_number (state, num, 10, "0123456789",
|
||||
width, prec, flags, minusp))
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
case 'u' : {
|
||||
unsigned long arg;
|
||||
|
||||
PARSE_INT_FORMAT(arg, ap, unsigned);
|
||||
|
||||
if (append_number (state, arg, 10, "0123456789",
|
||||
width, prec, flags, 0))
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
case 'o' : {
|
||||
unsigned long arg;
|
||||
|
||||
PARSE_INT_FORMAT(arg, ap, unsigned);
|
||||
|
||||
if (append_number (state, arg, 010, "01234567",
|
||||
width, prec, flags, 0))
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
case 'x' : {
|
||||
unsigned long arg;
|
||||
|
||||
PARSE_INT_FORMAT(arg, ap, unsigned);
|
||||
|
||||
if (append_number (state, arg, 0x10, "0123456789abcdef",
|
||||
width, prec, flags, 0))
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
case 'X' :{
|
||||
unsigned long arg;
|
||||
|
||||
PARSE_INT_FORMAT(arg, ap, unsigned);
|
||||
|
||||
if (append_number (state, arg, 0x10, "0123456789ABCDEF",
|
||||
width, prec, flags, 0))
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
case 'p' : {
|
||||
unsigned long arg = (unsigned long)va_arg(ap, void*);
|
||||
|
||||
if (append_number (state, arg, 0x10, "0123456789ABCDEF",
|
||||
width, prec, flags, 0))
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
case 'n' : {
|
||||
int *arg = va_arg(ap, int*);
|
||||
*arg = state->s - state->str;
|
||||
break;
|
||||
}
|
||||
case '\0' :
|
||||
--format;
|
||||
/* FALLTHROUGH */
|
||||
case '%' :
|
||||
if ((*state->append_char)(state, c))
|
||||
return -1;
|
||||
break;
|
||||
default :
|
||||
if ( (*state->append_char)(state, '%')
|
||||
|| (*state->append_char)(state, c))
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
} else
|
||||
if ((*state->append_char) (state, c))
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef HAVE_SNPRINTF
|
||||
int
|
||||
pcap_snprintf (char *str, size_t sz, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
int ret;
|
||||
|
||||
va_start(args, format);
|
||||
ret = pcap_vsnprintf (str, sz, format, args);
|
||||
|
||||
#ifdef PARANOIA
|
||||
{
|
||||
int ret2;
|
||||
char *tmp;
|
||||
|
||||
tmp = malloc (sz);
|
||||
if (tmp == NULL)
|
||||
abort ();
|
||||
|
||||
ret2 = pcap_vsprintf (tmp, format, args);
|
||||
if (ret != ret2 || strcmp(str, tmp))
|
||||
abort ();
|
||||
free (tmp);
|
||||
}
|
||||
#endif
|
||||
|
||||
va_end(args);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#ifndef HAVE_ASPRINTF
|
||||
int
|
||||
asprintf (char **ret, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
int val;
|
||||
|
||||
va_start(args, format);
|
||||
val = vasprintf (ret, format, args);
|
||||
|
||||
#ifdef PARANOIA
|
||||
{
|
||||
int ret2;
|
||||
char *tmp;
|
||||
tmp = malloc (val + 1);
|
||||
if (tmp == NULL)
|
||||
abort ();
|
||||
|
||||
ret2 = vsprintf (tmp, format, args);
|
||||
if (val != ret2 || strcmp(*ret, tmp))
|
||||
abort ();
|
||||
free (tmp);
|
||||
}
|
||||
#endif
|
||||
|
||||
va_end(args);
|
||||
return val;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_ASNPRINTF
|
||||
int
|
||||
pcap_asnprintf (char **ret, size_t max_sz, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
int val;
|
||||
|
||||
va_start(args, format);
|
||||
val = pcap_vasnprintf (ret, max_sz, format, args);
|
||||
|
||||
#ifdef PARANOIA
|
||||
{
|
||||
int ret2;
|
||||
char *tmp;
|
||||
tmp = malloc (val + 1);
|
||||
if (tmp == NULL)
|
||||
abort ();
|
||||
|
||||
ret2 = pcap_vsprintf (tmp, format, args);
|
||||
if (val != ret2 || strcmp(*ret, tmp))
|
||||
abort ();
|
||||
free (tmp);
|
||||
}
|
||||
#endif
|
||||
|
||||
va_end(args);
|
||||
return val;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_VASPRINTF
|
||||
int
|
||||
pcap_vasprintf (char **ret, const char *format, va_list args)
|
||||
{
|
||||
return pcap_vasnprintf (ret, 0, format, args);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAVE_VASNPRINTF
|
||||
int
|
||||
pcap_vasnprintf (char **ret, size_t max_sz, const char *format, va_list args)
|
||||
{
|
||||
int st;
|
||||
size_t len;
|
||||
struct state state;
|
||||
|
||||
state.max_sz = max_sz;
|
||||
state.sz = 1;
|
||||
state.str = malloc(state.sz);
|
||||
if (state.str == NULL) {
|
||||
*ret = NULL;
|
||||
return -1;
|
||||
}
|
||||
state.s = state.str;
|
||||
state.theend = state.s + state.sz - 1;
|
||||
state.append_char = as_append_char;
|
||||
state.reserve = as_reserve;
|
||||
|
||||
st = xyzprintf (&state, format, args);
|
||||
if (st) {
|
||||
free (state.str);
|
||||
*ret = NULL;
|
||||
return -1;
|
||||
} else {
|
||||
char *tmp;
|
||||
|
||||
*state.s = '\0';
|
||||
len = state.s - state.str;
|
||||
tmp = realloc (state.str, len+1);
|
||||
if (tmp == NULL) {
|
||||
free (state.str);
|
||||
*ret = NULL;
|
||||
return -1;
|
||||
}
|
||||
*ret = tmp;
|
||||
return len;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_VSNPRINTF
|
||||
int
|
||||
pcap_vsnprintf (char *str, size_t sz, const char *format, va_list args)
|
||||
{
|
||||
struct state state;
|
||||
int ret;
|
||||
unsigned char *ustr = (unsigned char *)str;
|
||||
|
||||
state.max_sz = 0;
|
||||
state.sz = sz;
|
||||
state.str = ustr;
|
||||
state.s = ustr;
|
||||
state.theend = ustr + sz - 1;
|
||||
state.append_char = sn_append_char;
|
||||
state.reserve = sn_reserve;
|
||||
|
||||
ret = xyzprintf (&state, format, args);
|
||||
*state.s = '\0';
|
||||
if (ret)
|
||||
return sz;
|
||||
else
|
||||
return state.s - state.str;
|
||||
}
|
||||
#endif
|
||||
|
@ -1,87 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 1998 Softweyr LLC. All rights reserved.
|
||||
*
|
||||
* strtok_r, from Berkeley strtok
|
||||
* Oct 13, 1998 by Wes Peters <wes@softweyr.com>
|
||||
*
|
||||
* Copyright (c) 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
|
||||
* notices, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notices, 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 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 SOFTWEYR LLC, 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 SOFTWEYR LLC, 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.
|
||||
*
|
||||
* From: @(#)strtok.c 8.1 (Berkeley) 6/4/93
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "portability.h"
|
||||
|
||||
char *
|
||||
pcap_strtok_r(char *s, const char *delim, char **last)
|
||||
{
|
||||
char *spanp, *tok;
|
||||
int c, sc;
|
||||
|
||||
if (s == NULL && (s = *last) == NULL)
|
||||
return (NULL);
|
||||
|
||||
/*
|
||||
* Skip (span) leading delimiters (s += strspn(s, delim), sort of).
|
||||
*/
|
||||
cont:
|
||||
c = *s++;
|
||||
for (spanp = (char *)delim; (sc = *spanp++) != 0;) {
|
||||
if (c == sc)
|
||||
goto cont;
|
||||
}
|
||||
|
||||
if (c == 0) { /* no non-delimiter characters */
|
||||
*last = NULL;
|
||||
return (NULL);
|
||||
}
|
||||
tok = s - 1;
|
||||
|
||||
/*
|
||||
* Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
|
||||
* Note that delim must have one NUL; we stop if we see that, too.
|
||||
*/
|
||||
for (;;) {
|
||||
c = *s++;
|
||||
spanp = (char *)delim;
|
||||
do {
|
||||
if ((sc = *spanp++) == c) {
|
||||
if (c == 0)
|
||||
s = NULL;
|
||||
else
|
||||
s[-1] = '\0';
|
||||
*last = s;
|
||||
return (tok);
|
||||
}
|
||||
} while (sc != 0);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
int
|
||||
pcap_vsnprintf(char *str, size_t str_size, const char *format, va_list args)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = _vsnprintf_s(str, str_size, _TRUNCATE, format, args);
|
||||
|
||||
/*
|
||||
* XXX - _vsnprintf() and _snprintf() do *not* guarantee
|
||||
* that str is null-terminated, but C99's vsnprintf()
|
||||
* and snprintf() do, and we want to offer C99 behavior,
|
||||
* so forcibly null-terminate the string.
|
||||
*/
|
||||
str[str_size - 1] = '\0';
|
||||
return (ret);
|
||||
}
|
||||
|
||||
int
|
||||
pcap_snprintf(char *str, size_t str_size, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
int ret;
|
||||
|
||||
va_start(args, format);
|
||||
ret = pcap_vsnprintf(str, str_size, format, args);
|
||||
va_end(args);
|
||||
return (ret);
|
||||
}
|
@ -1,112 +0,0 @@
|
||||
#!/bin/sh -
|
||||
#
|
||||
# Copyright (c) 1994, 1996
|
||||
# The Regents of the University of California. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms are permitted
|
||||
# provided that this notice is preserved and that due credit is given
|
||||
# to the University of California at 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'' without express or implied warranty.
|
||||
#
|
||||
# @(#)mkdep.sh 5.11 (Berkeley) 5/5/88
|
||||
#
|
||||
|
||||
MAKE=Makefile # default makefile name is "Makefile"
|
||||
CC=cc # default C compiler is "cc"
|
||||
DEPENDENCY_CFLAG=-M # default dependency-generation flag is -M
|
||||
|
||||
while :
|
||||
do case "$1" in
|
||||
# -c allows you to specify the C compiler
|
||||
-c)
|
||||
CC=$2
|
||||
shift; shift ;;
|
||||
|
||||
# -f allows you to select a makefile name
|
||||
-f)
|
||||
MAKE=$2
|
||||
shift; shift ;;
|
||||
|
||||
# -m allows you to specify the dependency-generation flag
|
||||
-m)
|
||||
DEPENDENCY_CFLAG=$2
|
||||
shift; shift ;;
|
||||
|
||||
# the -p flag produces "program: program.c" style dependencies
|
||||
# so .o's don't get produced
|
||||
-p)
|
||||
SED='s;\.o;;'
|
||||
shift ;;
|
||||
*)
|
||||
break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ $# = 0 ] ; then
|
||||
echo 'usage: mkdep [-p] [-c cc] [-f makefile] [-m dependency-cflag] [flags] file ...'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -w $MAKE ]; then
|
||||
echo "mkdep: no writeable file \"$MAKE\""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TMP=/tmp/mkdep$$
|
||||
|
||||
trap 'rm -f $TMP ; exit 1' 1 2 3 13 15
|
||||
|
||||
cp $MAKE ${MAKE}.bak
|
||||
|
||||
sed -e '/DO NOT DELETE THIS LINE/,$d' < $MAKE > $TMP
|
||||
|
||||
cat << _EOF_ >> $TMP
|
||||
# DO NOT DELETE THIS LINE -- mkdep uses it.
|
||||
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
|
||||
|
||||
_EOF_
|
||||
|
||||
# If your compiler doesn't have -M, add it. If you can't, the next two
|
||||
# lines will try and replace the "cc -M". The real problem is that this
|
||||
# hack can't deal with anything that requires a search path, and doesn't
|
||||
# even try for anything using bracket (<>) syntax.
|
||||
#
|
||||
# egrep '^#include[ ]*".*"' /dev/null $* |
|
||||
# sed -e 's/:[^"]*"\([^"]*\)".*/: \1/' -e 's/\.c/.o/' |
|
||||
|
||||
# XXX this doesn't work with things like "-DDECLWAITSTATUS=union\ wait"
|
||||
$CC $DEPENDENCY_CFLAG $* |
|
||||
sed "
|
||||
s; \./; ;g
|
||||
$SED" |
|
||||
awk '{
|
||||
if ($1 != prev) {
|
||||
if (rec != "")
|
||||
print rec;
|
||||
rec = $0;
|
||||
prev = $1;
|
||||
}
|
||||
else {
|
||||
if (length(rec $2) > 78) {
|
||||
print rec;
|
||||
rec = $0;
|
||||
}
|
||||
else
|
||||
rec = rec " " $2
|
||||
}
|
||||
}
|
||||
END {
|
||||
print rec
|
||||
}' >> $TMP
|
||||
|
||||
cat << _EOF_ >> $TMP
|
||||
|
||||
# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
|
||||
_EOF_
|
||||
|
||||
# copy to preserve permissions
|
||||
cp $TMP $MAKE
|
||||
rm -f ${MAKE}.bak $TMP
|
||||
exit 0
|
@ -1,43 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <time.h>
|
||||
|
||||
static void Abort (const 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);
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
#
|
||||
# Common defines for libpcap and 16/32-bit network drivers (djgpp)
|
||||
#
|
||||
|
||||
.SUFFIXES: .exe .wlm .dxe .l .y
|
||||
.PHONY: check_gcclib
|
||||
|
||||
default: check_gcclib all
|
||||
|
||||
#
|
||||
# This value is normally not important. Used by 'dxe3gen' in
|
||||
# msdos/pm_drvr/makefile.dj to make "dynamically loaded modules".
|
||||
# But this is not finished.
|
||||
#
|
||||
#GCC_LIB = $(shell gcc -print-libgcc-file-name)
|
||||
GCC_LIB = .
|
||||
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))
|
||||
|
||||
OBJ_DIR = djgpp.obj
|
||||
|
||||
ifeq ($(wildcard $(GCC_LIB)),)
|
||||
check_gcclib:
|
||||
@echo libgcc.a not found. Set \"$(GCC_LIB)\" to \"/djgpp/lib/gcc/djgpp/4.X/libgcc.a\"
|
||||
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 -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) -o $@ $<
|
||||
@echo
|
||||
|
||||
%.o: %.s
|
||||
$(CC) -c $(CFLAGS) -x assembler-with-cpp -o $@ $<
|
||||
@echo
|
||||
|
@ -1,184 +0,0 @@
|
||||
#
|
||||
# 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
|
||||
|
@ -1,127 +0,0 @@
|
||||
#
|
||||
# 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
|
||||
#
|
||||
# Note: you should do a "set LFN=y" before running this makefile.
|
||||
#
|
||||
|
||||
VPATH = missing msdos bpf/net
|
||||
|
||||
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 -DHAVE_SNPRINTF -DHAVE_VSNPRINTF\
|
||||
-D_U_='__attribute__((unused))'
|
||||
|
||||
CFLAGS += -Dyylval=pcap_lval # -DBDEBUG -DNDEBUG
|
||||
|
||||
SOURCES = grammar.c scanner.c bpf/net/bpf_filter.c bpf_image.c bpf_dump.c \
|
||||
etherent.c gencode.c nametoaddr.c pcap-common.c pcap-dos.c optimize.c \
|
||||
savefile.c pcap.c sf-pcap.c sf-pcap-ng.c inet.c \
|
||||
msdos/pktdrvr.c msdos/ndis2.c # missing/snprintf.c
|
||||
|
||||
OBJECTS = $(addprefix $(OBJ_DIR)/, $(notdir $(SOURCES:.c=.o)))
|
||||
TEMPBIN = tmp.bin
|
||||
|
||||
ifeq ($(USE_32BIT_DRIVERS),1)
|
||||
PM_OBJECTS = $(addprefix $(OBJ_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 $(OBJ_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
|
||||
|
||||
TARGETS = msdos/bin2c.exe libpcap.a filtertest.exe findalldevstest.exe \
|
||||
nonblocktest.exe opentest.exe
|
||||
|
||||
all: $(TARGETS)
|
||||
@echo 'Welcome to libpcap/djgpp with samples.'
|
||||
|
||||
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 $@ $^
|
||||
|
||||
filtertest.exe: tests/filtertest.c libpcap.a
|
||||
$(CC) $(CFLAGS) -Din_addr_t=u_long -o $@ $^ $(WATT32_ROOT)/lib/libwatt.a
|
||||
@echo
|
||||
|
||||
findalldevstest.exe: tests/findalldevstest.c libpcap.a
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(WATT32_ROOT)/lib/libwatt.a
|
||||
@echo
|
||||
|
||||
nonblocktest.exe: tests/nonblocktest.c libpcap.a
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(WATT32_ROOT)/lib/libwatt.a
|
||||
@echo
|
||||
|
||||
opentest.exe: tests/opentest.c libpcap.a
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(WATT32_ROOT)/lib/libwatt.a
|
||||
@echo
|
||||
|
||||
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:
|
||||
rm -f $(OBJECTS) msdos/pkt_rx1.lst Makefile.bak .depend.dj $(PREREQUISITES)
|
||||
# $(MAKE) -f Makefile.dj -C $(DRIVER_DIR) clean
|
||||
|
||||
vclean: clean
|
||||
rm -f $(TARGETS)
|
||||
-rmdir $(OBJ_DIR)
|
||||
|
||||
#
|
||||
# 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
|
||||
grammar.y: pcap-int.h gencode.h pcap-namedb.h
|
||||
|
||||
#
|
||||
# Generate dependencies.
|
||||
#
|
||||
REPLACE = sed -e 's/\(.*\)\.o: /\n$$(OBJ_DIR)\/\1.o: /'
|
||||
|
||||
depend: $(PREREQUISITES)
|
||||
$(CC) -MM $(CFLAGS) $(SOURCES) | $(REPLACE) > .depend.dj
|
||||
|
||||
-include .depend.dj
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user