mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
removed libpcap dir
This commit is contained in:
@@ -1,10 +0,0 @@
|
|||||||
config.log
|
|
||||||
config.cache
|
|
||||||
config.status
|
|
||||||
config.h
|
|
||||||
.devel
|
|
||||||
Makefile
|
|
||||||
scanner.c
|
|
||||||
grammar.c
|
|
||||||
tokdefs.h
|
|
||||||
version.c
|
|
||||||
395
libpcap/CHANGES
395
libpcap/CHANGES
@@ -1,395 +0,0 @@
|
|||||||
@(#) $Header: /tcpdump/master/libpcap/CHANGES,v 1.59.2.3 2005/07/11 20:09:47 mcr Exp $ (LBL)
|
|
||||||
|
|
||||||
Tue. July 5, 2005. ken@xelerance.com. Summary for 0.9.x libpcap
|
|
||||||
|
|
||||||
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.
|
|
||||||
100
libpcap/CREDITS
100
libpcap/CREDITS
@@ -1,100 +0,0 @@
|
|||||||
This file lists people who have contributed to libpcap:
|
|
||||||
|
|
||||||
The current maintainers:
|
|
||||||
Bill Fenner <fenner@research.att.com>
|
|
||||||
Fulvio Risso <risso@polito.it>
|
|
||||||
Guy Harris <guy@alum.mit.edu>
|
|
||||||
Hannes Gredler <hannes@juniper.net>
|
|
||||||
Jun-ichiro itojun Hagino <itojun@iijlab.net>
|
|
||||||
Michael Richardson <mcr@sandelman.ottawa.on.ca>
|
|
||||||
|
|
||||||
Additional people who have contributed patches:
|
|
||||||
|
|
||||||
Alan Bawden <Alan@LCS.MIT.EDU>
|
|
||||||
Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
|
|
||||||
Albert Chin <china@thewrittenword.com>
|
|
||||||
Andrew Brown <atatat@atatdot.net>
|
|
||||||
Antti Kantee <pooka@netbsd.org>
|
|
||||||
Arkadiusz Miskiewicz <misiek@pld.org.pl>
|
|
||||||
Armando L. Caro Jr. <acaro@mail.eecis.udel.edu>
|
|
||||||
Assar Westerlund <assar@sics.se>
|
|
||||||
Brian Ginsbach <ginsbach@cray.com>
|
|
||||||
Charles M. Hannum <mycroft@netbsd.org>
|
|
||||||
Chris G. Demetriou <cgd@netbsd.org>
|
|
||||||
Chris Lightfoot <cwrl@users.sourceforge.net>
|
|
||||||
Chris Pepper <pepper@mail.reppep.com>
|
|
||||||
Darren Reed <darrenr@reed.wattle.id.au>
|
|
||||||
David Kaelbling <drk@sgi.com>
|
|
||||||
David Young <dyoung@ojctech.com>
|
|
||||||
Dean Gaudet <dean@arctic.org>
|
|
||||||
Don Ebright <Don.Ebright@compuware.com>
|
|
||||||
Dug Song <dugsong@monkey.org>
|
|
||||||
Eric Anderson <anderse@hpl.hp.com>
|
|
||||||
Erik de Castro Lopo <erik.de.castro.lopo@sensorynetworks.com>
|
|
||||||
Franz Schaefer <schaefer@mond.at>
|
|
||||||
Gianluca Varenni <varenni@netgroup-serv.polito.it>
|
|
||||||
Gilbert Hoyek <gil_hoyek@hotmail.com>
|
|
||||||
Gisle Vanem <giva@bgnett.no>
|
|
||||||
Graeme Hewson <ghewson@cix.compulink.co.uk>
|
|
||||||
Greg Stark <gsstark@mit.edu>
|
|
||||||
Greg Troxel <gdt@ir.bbn.com>
|
|
||||||
Guillaume Pelat <endymion_@users.sourceforge.net>
|
|
||||||
Hyung Sik Yoon <hsyn@kr.ibm.com>
|
|
||||||
Igor Khristophorov <igor@atdot.org>
|
|
||||||
Jan-Philip Velders <jpv@veldersjes.net>
|
|
||||||
Jason R. Thorpe <thorpej@netbsd.org>
|
|
||||||
Javier Achirica <achirica@ttd.net>
|
|
||||||
Jean Tourrilhes <jt@hpl.hp.com>
|
|
||||||
Jefferson Ogata <jogata@nodc.noaa.gov>
|
|
||||||
Jesper Peterson <jesper@endace.com>
|
|
||||||
John Bankier <jbankier@rainfinity.com>
|
|
||||||
Jon Lindgren <jonl@yubyub.net>
|
|
||||||
Juergen Schoenwaelder <schoenw@ibr.cs.tu-bs.de>
|
|
||||||
Kazushi Sugyo <sugyo@pb.jp.nec.com>
|
|
||||||
Klaus Klein <kleink@netbsd.org>
|
|
||||||
Koryn Grant <koryn@endace.com>
|
|
||||||
Krzysztof Halasa <khc@pm.waw.pl>
|
|
||||||
Lorenzo Cavallaro <sullivan@sikurezza.org>
|
|
||||||
Loris Degioanni <loris@netgroup-serv.polito.it>
|
|
||||||
Love H<>rnquist-<2D>strand <lha@stacken.kth.se>
|
|
||||||
Maciej W. Rozycki <macro@ds2.pg.gda.pl>
|
|
||||||
Marcus Felipe Pereira <marcus@task.com.br>
|
|
||||||
Mark C. Brown <mbrown@hp.com>
|
|
||||||
Mark Pizzolato <List-tcpdump-workers@subscriptions.pizzolato.net>
|
|
||||||
Martin Husemann <martin@netbsd.org>
|
|
||||||
Matthew Luckie <mjl@luckie.org.nz>
|
|
||||||
Mike Wiacek <mike@iroot.net>
|
|
||||||
Monroe Williams <monroe@pobox.com>
|
|
||||||
Nicolas Dade <ndade@nsd.dyndns.org>
|
|
||||||
Octavian Cerna <tavy@ylabs.com>
|
|
||||||
Olaf Kirch <okir@caldera.de>
|
|
||||||
Onno van der Linden <onno@simplex.nl>
|
|
||||||
Patrick Marie <mycroft@virgaria.org>
|
|
||||||
Paul Mundt <lethal@linux-sh.org>
|
|
||||||
Pavel Kankovsky <kan@dcit.cz>
|
|
||||||
Pawel Pokrywka <publicpp@gmail.com>
|
|
||||||
Peter Fales <peter@fales-lorenz.net>
|
|
||||||
Peter Jeremy <peter.jeremy@alcatel.com.au>
|
|
||||||
Phil Wood <cpw@lanl.gov>
|
|
||||||
Rafal Maszkowski <rzm@icm.edu.pl>
|
|
||||||
Rick Jones <raj@cup.hp.com>
|
|
||||||
Scott Barron <sb125499@ohiou.edu>
|
|
||||||
Scott Gifford <sgifford@tir.com>
|
|
||||||
Sebastian Krahmer <krahmer@cs.uni-potsdam.de>
|
|
||||||
Shaun Clowes <delius@progsoc.uts.edu.au>
|
|
||||||
Solomon Peachy <pizza@shaftnet.org>
|
|
||||||
Stefan Hudson <hudson@mbay.net>
|
|
||||||
Takashi Yamamoto <yamt@mwd.biglobe.ne.jp>
|
|
||||||
Tanaka Shin-ya <zstanaka@archer.livedoor.com>
|
|
||||||
Tony Li <tli@procket.com>
|
|
||||||
Torsten Landschoff <torsten@debian.org>
|
|
||||||
Uns Lider <unslider@miranda.org>
|
|
||||||
Uwe Girlich <Uwe.Girlich@philosys.de>
|
|
||||||
Xianjie Zhang <xzhang@cup.hp.com>
|
|
||||||
Yen Yen Lim
|
|
||||||
Yoann Vandoorselaere <yoann@prelude-ids.org>
|
|
||||||
|
|
||||||
The original LBL crew:
|
|
||||||
Steve McCanne
|
|
||||||
Craig Leres
|
|
||||||
Van Jacobson
|
|
||||||
@@ -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 = ("Non-root permission to capture or send raw packets");
|
|
||||||
}
|
|
||||||
125
libpcap/FILES
125
libpcap/FILES
@@ -1,125 +0,0 @@
|
|||||||
CHANGES
|
|
||||||
ChmodBPF/ChmodBPF
|
|
||||||
ChmodBPF/StartupParameters.plist
|
|
||||||
CREDITS
|
|
||||||
FILES
|
|
||||||
INSTALL.txt
|
|
||||||
LICENSE
|
|
||||||
Makefile.in
|
|
||||||
README
|
|
||||||
README.aix
|
|
||||||
README.dag
|
|
||||||
README.hpux
|
|
||||||
README.linux
|
|
||||||
README.macosx
|
|
||||||
README.septel
|
|
||||||
README.tru64
|
|
||||||
README.Win32
|
|
||||||
SUNOS4/nit_if.o.sparc
|
|
||||||
SUNOS4/nit_if.o.sun3
|
|
||||||
SUNOS4/nit_if.o.sun4c.4.0.3c
|
|
||||||
TODO
|
|
||||||
VERSION
|
|
||||||
acconfig.h
|
|
||||||
aclocal.m4
|
|
||||||
arcnet.h
|
|
||||||
atmuni31.h
|
|
||||||
bpf/net/bpf_filter.c
|
|
||||||
bpf_dump.c
|
|
||||||
bpf_image.c
|
|
||||||
config.guess
|
|
||||||
config.h.in
|
|
||||||
config.sub
|
|
||||||
configure
|
|
||||||
configure.in
|
|
||||||
etherent.c
|
|
||||||
ethertype.h
|
|
||||||
fad-getad.c
|
|
||||||
fad-gifc.c
|
|
||||||
fad-glifc.c
|
|
||||||
fad-null.c
|
|
||||||
fad-win32.c
|
|
||||||
gencode.c
|
|
||||||
gencode.h
|
|
||||||
grammar.y
|
|
||||||
inet.c
|
|
||||||
install-sh
|
|
||||||
lbl/os-aix4.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
|
|
||||||
llc.h
|
|
||||||
missing/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
|
|
||||||
nametoaddr.c
|
|
||||||
nlpid.h
|
|
||||||
optimize.c
|
|
||||||
packaging/pcap.spec
|
|
||||||
packaging/pcap.spec.in
|
|
||||||
pcap-bpf.c
|
|
||||||
pcap-bpf.h
|
|
||||||
pcap-dag.c
|
|
||||||
pcap-dag.h
|
|
||||||
pcap-dlpi.c
|
|
||||||
pcap-dos.c
|
|
||||||
pcap-dos.h
|
|
||||||
pcap-enet.c
|
|
||||||
pcap-int.h
|
|
||||||
pcap-linux.c
|
|
||||||
pcap-namedb.h
|
|
||||||
pcap-nit.c
|
|
||||||
pcap-nit.h
|
|
||||||
pcap-null.c
|
|
||||||
pcap-pf.c
|
|
||||||
pcap-pf.h
|
|
||||||
pcap-septel.c
|
|
||||||
pcap-septel.h
|
|
||||||
pcap-stdinc.h
|
|
||||||
pcap-snit.c
|
|
||||||
pcap-snoop.c
|
|
||||||
pcap-win32.c
|
|
||||||
pcap.3
|
|
||||||
pcap.c
|
|
||||||
pcap.h
|
|
||||||
pf.h
|
|
||||||
ppp.h
|
|
||||||
savefile.c
|
|
||||||
scanner.l
|
|
||||||
sll.h
|
|
||||||
sunatmpos.h
|
|
||||||
Win32/Include/Gnuc.h
|
|
||||||
Win32/Include/addrinfo.h
|
|
||||||
Win32/Include/bittypes.h
|
|
||||||
Win32/Include/cdecl_ext.h
|
|
||||||
Win32/Include/inetprivate.h
|
|
||||||
Win32/Include/ip6_misc.h
|
|
||||||
Win32/Include/sockstorage.h
|
|
||||||
Win32/Include/arpa/nameser.h
|
|
||||||
Win32/Include/net/if.h
|
|
||||||
Win32/Include/net/netdb.h
|
|
||||||
Win32/Include/net/paths.h
|
|
||||||
Win32/Src/ffs.c
|
|
||||||
Win32/Src/getaddrinfo.c
|
|
||||||
Win32/Src/getnetbynm.c
|
|
||||||
Win32/Src/getnetent.c
|
|
||||||
Win32/Src/getopt.c
|
|
||||||
Win32/Src/getservent.c
|
|
||||||
Win32/Src/inet_aton.c
|
|
||||||
Win32/Src/inet_net.c
|
|
||||||
Win32/Src/inet_pton.c
|
|
||||||
@@ -1,383 +0,0 @@
|
|||||||
@(#) $Header$ (LBL)
|
|
||||||
|
|
||||||
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.in.
|
|
||||||
|
|
||||||
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 GNU C compiler, available via anonymous ftp:
|
|
||||||
|
|
||||||
ftp://ftp.gnu.org/pub/gnu/gcc/
|
|
||||||
|
|
||||||
If you use flex, you must use version 2.4.6 or higher. The configure
|
|
||||||
script automatically detects the version of flex and will not use it
|
|
||||||
unless it is new enough. You can use "flex -V" to see what version you
|
|
||||||
have (unless it's really old). The current version of flex is available
|
|
||||||
via anonymous ftp:
|
|
||||||
|
|
||||||
ftp://ftp.ee.lbl.gov/flex-*.tar.Z
|
|
||||||
|
|
||||||
As of this writing, the current version is 2.5.4.
|
|
||||||
|
|
||||||
If you use bison, you must use flex (and visa versa). The configure
|
|
||||||
script automatically falls back to lex and yacc if both flex and bison
|
|
||||||
are not found.
|
|
||||||
|
|
||||||
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 or manually disabling flex
|
|
||||||
and bison with:
|
|
||||||
|
|
||||||
./configure --without-flex --without-bison
|
|
||||||
|
|
||||||
If your system only has AT&T lex, this is okay unless your libpcap
|
|
||||||
program uses other lex/yacc generated code. (Although it's possible to
|
|
||||||
map the yy* identifiers with a script, we use flex and bison so we
|
|
||||||
don't feel this is necessary.)
|
|
||||||
|
|
||||||
Some systems support the Berkeley Packet Filter natively; for example
|
|
||||||
out of the box OSF and BSD/OS have bpf. If your system does not support
|
|
||||||
bpf, you will need to pick up:
|
|
||||||
|
|
||||||
ftp://ftp.ee.lbl.gov/bpf-*.tar.Z
|
|
||||||
|
|
||||||
Note well: you MUST have kernel source for your operating system in
|
|
||||||
order to install bpf. An exception is SunOS 4; the bpf distribution
|
|
||||||
includes replacement kernel objects for some of the standard SunOS 4
|
|
||||||
network device drivers. See the bpf INSTALL document for more
|
|
||||||
information.
|
|
||||||
|
|
||||||
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. We hope to support this operating system in some future
|
|
||||||
release of libpcap.
|
|
||||||
|
|
||||||
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. Since SCO apparently supports
|
|
||||||
DLPI, it's possible the current version works. Meanwhile, SCO provides
|
|
||||||
a tcpdump binary as part of their "Network/Security Tools" package:
|
|
||||||
|
|
||||||
http://www.sco.com/technology/internet/goodies/#SECURITY
|
|
||||||
|
|
||||||
There is also a README that explains how to enable packet capture.
|
|
||||||
|
|
||||||
If you use UnixWare, you will not be able to build libpcap from this
|
|
||||||
release. We hope to support this operating system in some future
|
|
||||||
release of libpcap. Meanwhile, there appears to be an UnixWare port of
|
|
||||||
libpcap 0.0 (and tcpdump 3.0) in:
|
|
||||||
|
|
||||||
ftp://ftp1.freebird.org/pub/mirror/freebird/internet/systools/
|
|
||||||
|
|
||||||
UnixWare appears to use a hacked version of DLPI.
|
|
||||||
|
|
||||||
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:
|
|
||||||
|
|
||||||
ftp://ftp.gnu.org/pub/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*
|
|
||||||
CREDITS - people that have helped libpcap along
|
|
||||||
FILES - list of files exported as part of the distribution
|
|
||||||
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.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.in - configure script source
|
|
||||||
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
|
|
||||||
fad-null.c - pcap_findalldevs() for systems without capture support
|
|
||||||
fad-win32.c - pcap_findalldevs() for WinPcap
|
|
||||||
gencode.c - BPF code generation routines
|
|
||||||
gencode.h - BPF code generation definitions
|
|
||||||
grammar.y - filter string grammar
|
|
||||||
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
|
|
||||||
packaging - packaging information for building libpcap RPMs
|
|
||||||
pcap-bpf.c - BSD Packet Filter support
|
|
||||||
pcap-bpf.h - BPF definitions
|
|
||||||
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-linux.c - Linux packet socket support
|
|
||||||
pcap-namedb.h - public libpcap name database definitions
|
|
||||||
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-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-win32.c - WinPcap capture support
|
|
||||||
pcap.3 - manual entry
|
|
||||||
pcap.c - pcap utility routines
|
|
||||||
pcap.h - public libpcap definitions
|
|
||||||
pf.h - OpenBSD DLT_PFLOG definitions
|
|
||||||
ppp.h - Point to Point Protocol definitions
|
|
||||||
rawss7.h - information on DLT_ types for SS7
|
|
||||||
savefile.c - offline support
|
|
||||||
scanner.l - filter string scanner
|
|
||||||
sll.h - definitions for Linux cooked mode fake link-layer header
|
|
||||||
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,239 +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.
|
|
||||||
#
|
|
||||||
# @(#) $Header$ (LBL)
|
|
||||||
|
|
||||||
#
|
|
||||||
# Various configurable paths (remember to edit Makefile.in, not Makefile)
|
|
||||||
#
|
|
||||||
|
|
||||||
# Top level hierarchy
|
|
||||||
prefix = @prefix@
|
|
||||||
exec_prefix = @exec_prefix@
|
|
||||||
# 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 page
|
|
||||||
mandir = @mandir@
|
|
||||||
|
|
||||||
# VPATH
|
|
||||||
srcdir = @srcdir@
|
|
||||||
VPATH = @srcdir@
|
|
||||||
|
|
||||||
#
|
|
||||||
# You shouldn't need to edit anything below.
|
|
||||||
#
|
|
||||||
|
|
||||||
CC = @CC@
|
|
||||||
CCOPT = @V_CCOPT@
|
|
||||||
INCLS = -I. @V_INCLS@
|
|
||||||
DEFS = @DEFS@ @V_DEFS@
|
|
||||||
LIBS = @V_LIBS@
|
|
||||||
DYEXT = @DYEXT@
|
|
||||||
|
|
||||||
# Standard CFLAGS
|
|
||||||
CFLAGS = $(CCOPT) $(INCLS) $(DEFS)
|
|
||||||
|
|
||||||
INSTALL = @INSTALL@
|
|
||||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
|
||||||
INSTALL_DATA = @INSTALL_DATA@
|
|
||||||
RANLIB = @RANLIB@
|
|
||||||
|
|
||||||
#
|
|
||||||
# Flex and bison allow you to specify the prefixes of the global symbols
|
|
||||||
# used by the generated parser. This allows programs to use lex/yacc
|
|
||||||
# and link against libpcap. If you don't have flex or bison, get them.
|
|
||||||
#
|
|
||||||
LEX = flex
|
|
||||||
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) $(CFLAGS) -c $(srcdir)/$*.c
|
|
||||||
|
|
||||||
PSRC = pcap-@V_PCAP@.c
|
|
||||||
FSRC = fad-@V_FINDALLDEVS@.c
|
|
||||||
SSRC = @SSRC@
|
|
||||||
CSRC = pcap.c inet.c gencode.c optimize.c nametoaddr.c \
|
|
||||||
etherent.c savefile.c bpf_filter.c bpf_image.c bpf_dump.c
|
|
||||||
GENSRC = scanner.c grammar.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)
|
|
||||||
HDR = pcap.h pcap-int.h pcap-namedb.h pcap-nit.h pcap-pf.h \
|
|
||||||
ethertype.h gencode.h gnuc.h
|
|
||||||
GENHDR = \
|
|
||||||
tokdefs.h version.h
|
|
||||||
|
|
||||||
TAGHDR = \
|
|
||||||
pcap-bpf.h
|
|
||||||
|
|
||||||
TAGFILES = \
|
|
||||||
$(SRC) $(HDR) $(TAGHDR)
|
|
||||||
|
|
||||||
CLEANFILES = $(OBJ) libpcap.a version.c lex.yy.c
|
|
||||||
|
|
||||||
all: libpcap.a
|
|
||||||
|
|
||||||
libpcap.a: $(OBJ)
|
|
||||||
@rm -f $@
|
|
||||||
ar rc $@ $(OBJ) $(LIBS)
|
|
||||||
$(RANLIB) $@
|
|
||||||
|
|
||||||
shared: libpcap.$(DYEXT)
|
|
||||||
|
|
||||||
#
|
|
||||||
# XXX - this works with GNU ld, but won't necessarily work with native
|
|
||||||
# ld on, for example, various SVR4-flavored platforms, or Digital UNIX.
|
|
||||||
#
|
|
||||||
libpcap.so: $(OBJ)
|
|
||||||
@rm -f $@
|
|
||||||
ld -shared -o $@.`cat VERSION` $(OBJ)
|
|
||||||
|
|
||||||
# the following rule succeeds, but the result is untested.
|
|
||||||
libpcap.dylib: $(OBJ)
|
|
||||||
rm -f libpcap*.dylib
|
|
||||||
$(CC) -dynamiclib -undefined error -o libpcap.`cat VERSION`.dylib $(OBJ) \
|
|
||||||
-install_name $(libdir)/libpcap.0.dylib -compatibility_version `cat VERSION` \
|
|
||||||
-current_version `cat VERSION`
|
|
||||||
|
|
||||||
|
|
||||||
scanner.c: $(srcdir)/scanner.l
|
|
||||||
@rm -f $@
|
|
||||||
$(LEX) -t $< > $$$$.$@; mv $$$$.$@ $@
|
|
||||||
|
|
||||||
scanner.o: scanner.c tokdefs.h
|
|
||||||
$(CC) $(CFLAGS) -c scanner.c
|
|
||||||
|
|
||||||
pcap.o: version.h
|
|
||||||
|
|
||||||
tokdefs.h: grammar.c
|
|
||||||
grammar.c: $(srcdir)/grammar.y
|
|
||||||
@rm -f grammar.c tokdefs.h
|
|
||||||
$(YACC) -d $<
|
|
||||||
mv y.tab.c grammar.c
|
|
||||||
mv y.tab.h tokdefs.h
|
|
||||||
|
|
||||||
grammar.o: grammar.c
|
|
||||||
@rm -f $@
|
|
||||||
$(CC) $(CFLAGS) -Dyylval=pcap_lval -c grammar.c
|
|
||||||
|
|
||||||
version.o: version.c
|
|
||||||
$(CC) $(CFLAGS) -c version.c
|
|
||||||
|
|
||||||
snprintf.o: $(srcdir)/missing/snprintf.c
|
|
||||||
$(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c
|
|
||||||
|
|
||||||
version.c: $(srcdir)/VERSION
|
|
||||||
@rm -f $@
|
|
||||||
sed -e 's/.*/char pcap_version[] = "&";/' $(srcdir)/VERSION > $@
|
|
||||||
|
|
||||||
#
|
|
||||||
# NOTE: this really is supposed to be static; importing a string
|
|
||||||
# from a shared library does not work very well on many
|
|
||||||
# versions of UNIX (Solaris, Linux, and the BSDs, for example),
|
|
||||||
# so we make the version string static and return it from
|
|
||||||
# a function, which does work.
|
|
||||||
#
|
|
||||||
version.h: $(srcdir)/VERSION
|
|
||||||
@rm -f $@
|
|
||||||
sed -e 's/.*/static const char pcap_version_string[] = "libpcap version &";/' $(srcdir)/VERSION > $@
|
|
||||||
|
|
||||||
bpf_filter.c: $(srcdir)/bpf/net/bpf_filter.c
|
|
||||||
rm -f bpf_filter.c
|
|
||||||
ln -s $(srcdir)/bpf/net/bpf_filter.c bpf_filter.c
|
|
||||||
|
|
||||||
bpf_filter.o: bpf_filter.c
|
|
||||||
$(CC) $(CFLAGS) -c bpf_filter.c
|
|
||||||
|
|
||||||
install: libpcap.a
|
|
||||||
[ -d $(DESTDIR)$(libdir) ] || \
|
|
||||||
(mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
|
|
||||||
$(INSTALL_DATA) libpcap.a $(DESTDIR)$(libdir)/libpcap.a
|
|
||||||
$(RANLIB) $(DESTDIR)$(libdir)/libpcap.a
|
|
||||||
[ -d $(DESTDIR)$(includedir) ] || \
|
|
||||||
(mkdir -p $(DESTDIR)$(includedir); chmod 755 $(DESTDIR)$(includedir))
|
|
||||||
$(INSTALL_DATA) $(srcdir)/pcap.h $(DESTDIR)$(includedir)/pcap.h
|
|
||||||
$(INSTALL_DATA) $(srcdir)/pcap-bpf.h \
|
|
||||||
$(DESTDIR)$(includedir)/pcap-bpf.h
|
|
||||||
$(INSTALL_DATA) $(srcdir)/pcap-namedb.h \
|
|
||||||
$(DESTDIR)$(includedir)/pcap-namedb.h
|
|
||||||
[ -d $(DESTDIR)$(mandir)/man3 ] || \
|
|
||||||
(mkdir -p $(DESTDIR)$(mandir)/man3; chmod 755 $(DESTDIR)$(mandir)/man3)
|
|
||||||
$(INSTALL_DATA) $(srcdir)/pcap.3 \
|
|
||||||
$(DESTDIR)$(mandir)/man3/pcap.3
|
|
||||||
|
|
||||||
install-shared: install-shared-$(DYEXT)
|
|
||||||
install-shared-so: libpcap.so
|
|
||||||
$(INSTALL_PROGRAM) libpcap.so.`cat VERSION` $(DESTDIR)$(libdir)/libpcap.so.`cat VERSION`
|
|
||||||
install-shared-dylib: libpcap.dylib
|
|
||||||
$(INSTALL_PROGRAM) libpcap.`cat VERSION`.dylib $(DESTDIR)$(libdir)/libpcap.`cat VERSION`.dylib
|
|
||||||
VER=`cat VERSION`; cd $(DESTDIR)$(libdir) && ln -sf libpcap.$$VER.dylib libpcap.0.dylib; ln -sf libpcap.0.dylib libpcap.dylib
|
|
||||||
|
|
||||||
uninstall:
|
|
||||||
rm -f $(DESTDIR)$(libdir)/libpcap.a
|
|
||||||
rm -f $(DESTDIR)$(includedir)/pcap.h
|
|
||||||
rm -f $(DESTDIR)$(includedir)/pcap-bpf.h
|
|
||||||
rm -f $(DESTDIR)$(includedir)/pcap-namedb.h
|
|
||||||
rm -f $(DESTDIR)$(mandir)/man3/pcap.3
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f $(CLEANFILES) libpcap*.dylib libpcap.so*
|
|
||||||
|
|
||||||
distclean: clean
|
|
||||||
rm -f Makefile config.cache config.log config.status \
|
|
||||||
config.h gnuc.h os-proto.h bpf_filter.c stamp-h stamp-h.in net
|
|
||||||
rm -rf autom4te.cache
|
|
||||||
|
|
||||||
tags: $(TAGFILES)
|
|
||||||
ctags -wtd $(TAGFILES)
|
|
||||||
|
|
||||||
packaging/pcap.spec: packaging/pcap.spec.in VERSION
|
|
||||||
RPMVERSION=`cat VERSION | sed s/-.*//g`; \
|
|
||||||
sed -e s/@VERSION@/$$RPMVERSION/ -e s/@NAME@/libpcap-`cat VERSION`/ $< > $@
|
|
||||||
|
|
||||||
tar: Makefile packaging/pcap.spec
|
|
||||||
@cwd=`pwd` ; dir=`basename $$cwd` ; name=libpcap-`cat VERSION` ; \
|
|
||||||
list="" ; tar="tar chf" ; \
|
|
||||||
for i in `cat FILES` ; do list="$$list $$name/$$i" ; done; \
|
|
||||||
echo \
|
|
||||||
"rm -f ../$$name; ln -s $$dir ../$$name" ; \
|
|
||||||
rm -f ../$$name; ln -s $$dir ../$$name ; \
|
|
||||||
echo \
|
|
||||||
"(cd .. ; $$tar - [lots of files]) | gzip -c > /tmp/$$name.tar.gz" ; \
|
|
||||||
(cd .. ; $$tar - $$list) | gzip -c > /tmp/$$name.tar.gz ; \
|
|
||||||
echo \
|
|
||||||
"rm -f ../$$name" ; \
|
|
||||||
rm -f ../$$name
|
|
||||||
|
|
||||||
depend: $(GENSRC) $(GENHDR) bpf_filter.c
|
|
||||||
./mkdep -c $(CC) $(DEFS) $(INCLS) $(SRC)
|
|
||||||
|
|
||||||
Makefile: Makefile.in config.status
|
|
||||||
./config.status
|
|
||||||
@echo your Makefile was out of date, now run $(MAKE) again
|
|
||||||
exit 1
|
|
||||||
@@ -1,294 +0,0 @@
|
|||||||
NOTE: This has been upgraded to pcap 0.9.3 since the instructions
|
|
||||||
below were written. That upgrade was done by applying a diff
|
|
||||||
between pcap 0.8.3 and 0.9.3 to the Nmap libpcap dir.
|
|
||||||
|
|
||||||
Nmap currently includes a modified version of the tcpdump.org release
|
|
||||||
of libpcap version 0.8.3 (released March 30, 2004). My
|
|
||||||
(fyodor@insecure.org) modifications are as follows:
|
|
||||||
|
|
||||||
o Included this file, renamed directory from libpcap-0.8.3 to
|
|
||||||
libpcap.
|
|
||||||
|
|
||||||
o Renamed configure.in to configure.ac, which is the name now
|
|
||||||
recommended by the autoconf project.
|
|
||||||
|
|
||||||
o Removed the .cvsignore file, all 'CVS' directories, the 'packaging' directory, and the install-sh script.
|
|
||||||
|
|
||||||
o Rewrote Win32 version of eth_open() as the previous verson didn't
|
|
||||||
work on any of my Windows machines.
|
|
||||||
|
|
||||||
o Added the gcc debugging flag (-g) to aclocal.m4 if gcc is being used:
|
|
||||||
--- libpcap-0.8.3/aclocal.m4 2003-11-16 01:45:51.000000000 -0800
|
|
||||||
+++ libpcap/aclocal.m4 2004-07-31 22:34:47.000000000 -0700
|
|
||||||
@@ -1,4 +1,4 @@
|
|
||||||
-dnl @(#) $Header$ (LBL)
|
|
||||||
+dnl @(#) $Header$ (LBL)
|
|
||||||
dnl
|
|
||||||
dnl Copyright (c) 1995, 1996, 1997, 1998
|
|
||||||
dnl The Regents of the University of California. All rights reserved.
|
|
||||||
@@ -76,7 +76,7 @@
|
|
||||||
if test "$GCC" = yes ; then
|
|
||||||
if test "$SHLICC2" = yes ; then
|
|
||||||
ac_cv_lbl_gcc_vers=2
|
|
||||||
- $1="-O2"
|
|
||||||
+ $1="-g -O2"
|
|
||||||
else
|
|
||||||
AC_MSG_CHECKING(gcc version)
|
|
||||||
AC_CACHE_VAL(ac_cv_lbl_gcc_vers,
|
|
||||||
@@ -87,7 +87,7 @@
|
|
||||||
-e 's/\..*//'`)
|
|
||||||
AC_MSG_RESULT($ac_cv_lbl_gcc_vers)
|
|
||||||
if test $ac_cv_lbl_gcc_vers -gt 1 ; then
|
|
||||||
- $1="-O2"
|
|
||||||
+ $1="-g -O2"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
|
|
||||||
o The config.sub and config.guess have been upgraded (in the distribution
|
|
||||||
file they are just symlinks to the corresponding files in the nmap dir
|
|
||||||
|
|
||||||
o Changed pcap-linux.c by adding a select() call guarding recvfrom()
|
|
||||||
to insure that it returns after the timeout period specified in
|
|
||||||
pcap_open_live() rather than blocking forever.
|
|
||||||
--- libpcap-0.8.3/pcap-linux.c 2003-11-21 02:20:46.000000000 -0800
|
|
||||||
+++ libpcap/pcap-linux.c 2004-07-31 22:34:47.000000000 -0700
|
|
||||||
@@ -27,7 +27,7 @@
|
|
||||||
|
|
||||||
#ifndef lint
|
|
||||||
static const char rcsid[] _U_ =
|
|
||||||
- "@(#) $Header$ (LBL)";
|
|
||||||
+ "@(#) $Header$ (LBL)";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
@@ -96,6 +96,7 @@
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <linux/if_ether.h>
|
|
||||||
#include <net/if_arp.h>
|
|
||||||
+#include <assert.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If PF_PACKET is defined, we can use {SOCK_RAW,SOCK_DGRAM}/PF_PACKET
|
|
||||||
@@ -483,6 +484,32 @@
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
fromlen = sizeof(from);
|
|
||||||
+ /* If the user specified a timeout in pcap_open_live(),
|
|
||||||
+ we will honor the timeout and return even if no packets
|
|
||||||
+ have arrived */
|
|
||||||
+ if (handle->md.timeout > 0) {
|
|
||||||
+ fd_set readfs;
|
|
||||||
+ struct timeval tv;
|
|
||||||
+ int res;
|
|
||||||
+
|
|
||||||
+ FD_ZERO(&readfs);
|
|
||||||
+ FD_SET(handle->fd, &readfs);
|
|
||||||
+ bzero((void *) &tv, sizeof(tv));
|
|
||||||
+ tv.tv_sec = handle->md.timeout / 1000;
|
|
||||||
+ tv.tv_usec = (handle->md.timeout % 1000 ) * 1000;
|
|
||||||
+ do {
|
|
||||||
+ /* since this is in pcap-linux.c, we can assume
|
|
||||||
+ Linux select() behavior WRT decrementing tv */
|
|
||||||
+ res = select(handle->fd + 1, &readfs, NULL, NULL, &tv);
|
|
||||||
+ if (res == 1) break;
|
|
||||||
+ if (res == 0) return 0;
|
|
||||||
+ assert(res == -1);
|
|
||||||
+ if (errno == EINTR) continue;
|
|
||||||
+ snprintf(handle->errbuf, sizeof(handle->errbuf), "select: %s", pcap_strerror(errno));
|
|
||||||
+ return -1;
|
|
||||||
+ } while (1);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
packet_len = recvfrom(
|
|
||||||
handle->fd, bp + offset,
|
|
||||||
handle->bufsize - offset, MSG_TRUNC,
|
|
||||||
|
|
||||||
o Eliminated Lex/Yacc requirement (I now ship the generated .c files).
|
|
||||||
This involved:
|
|
||||||
|
|
||||||
o Changes to Makefile.in
|
|
||||||
--- libpcap-0.8.3/Makefile.in 2003-12-14 17:42:23.000000000 -0800
|
|
||||||
+++ libpcap/Makefile.in 2004-07-31 22:34:47.000000000 -0700
|
|
||||||
@@ -17,7 +17,7 @@
|
|
||||||
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
|
||||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
#
|
|
||||||
-# @(#) $Header$ (LBL)
|
|
||||||
+# @(#) $Header$ (LBL)
|
|
||||||
|
|
||||||
#
|
|
||||||
# Various configurable paths (remember to edit Makefile.in, not Makefile)
|
|
||||||
@@ -60,8 +60,8 @@
|
|
||||||
# used by the generated parser. This allows programs to use lex/yacc
|
|
||||||
# and link against libpcap. If you don't have flex or bison, get them.
|
|
||||||
#
|
|
||||||
-LEX = @V_LEX@
|
|
||||||
-YACC = @V_YACC@
|
|
||||||
+LEX = flex
|
|
||||||
+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
|
|
||||||
@@ -94,7 +94,7 @@
|
|
||||||
TAGFILES = \
|
|
||||||
$(SRC) $(HDR) $(TAGHDR)
|
|
||||||
|
|
||||||
-CLEANFILES = $(OBJ) libpcap.a $(GENSRC) $(GENHDR) lex.yy.c
|
|
||||||
+CLEANFILES = $(OBJ) libpcap.a version.c lex.yy.c
|
|
||||||
|
|
||||||
all: libpcap.a
|
|
||||||
|
|
||||||
o Ripped LEX/YACC detection code from configure.in:
|
|
||||||
--- libpcap-0.8.3/configure.in 2004-03-28 13:43:34.000000000 -0800
|
|
||||||
+++ libpcap/configure.ac 2004-07-31 22:34:47.000000000 -0700
|
|
||||||
@@ -1,4 +1,4 @@
|
|
||||||
-dnl @(#) $Header$ (LBL)
|
|
||||||
+dnl @(#) $Header$ (LBL)
|
|
||||||
dnl
|
|
||||||
dnl Copyright (c) 1994, 1995, 1996, 1997
|
|
||||||
dnl The Regents of the University of California. All rights reserved.
|
|
||||||
@@ -6,7 +6,7 @@
|
|
||||||
dnl Process this file with autoconf to produce a configure script.
|
|
||||||
dnl
|
|
||||||
|
|
||||||
-AC_REVISION($Revision$)
|
|
||||||
+AC_REVISION($Revision$)
|
|
||||||
AC_PREREQ(2.50)
|
|
||||||
AC_INIT(pcap.c)
|
|
||||||
|
|
||||||
@@ -341,25 +341,6 @@
|
|
||||||
AC_MSG_ERROR(Specifying the capture type as 'dag' requires the DAG API to be present; use --with-dag=DIR)
|
|
||||||
fi
|
|
||||||
|
|
||||||
-
|
|
||||||
-AC_LBL_LEX_AND_YACC(V_LEX, V_YACC, pcap_)
|
|
||||||
-if test "$V_LEX" = lex ; then
|
|
||||||
-# Some versions of lex can't handle the definitions section of scanner.l .
|
|
||||||
-# Try lexing it and complain if it can't deal.
|
|
||||||
- AC_CACHE_CHECK([for capable lex], tcpdump_cv_capable_lex,
|
|
||||||
- if lex -t scanner.l > /dev/null 2>&1; then
|
|
||||||
- tcpdump_cv_capable_lex=yes
|
|
||||||
- else
|
|
||||||
- tcpdump_cv_capable_lex=insufficient
|
|
||||||
- fi)
|
|
||||||
- if test $tcpdump_cv_capable_lex = insufficient ; then
|
|
||||||
- AC_MSG_ERROR([Your operating system's lex is insufficient to compile
|
|
||||||
- libpcap. flex is a lex replacement that has many advantages, including
|
|
||||||
- being able to compile libpcap. For more information, see
|
|
||||||
- http://www.gnu.org/software/flex/flex.html .])
|
|
||||||
- fi
|
|
||||||
-fi
|
|
||||||
-
|
|
||||||
case "$host_os" in
|
|
||||||
|
|
||||||
aix*)
|
|
||||||
@@ -420,11 +401,9 @@
|
|
||||||
AC_SUBST(V_DEFS)
|
|
||||||
AC_SUBST(V_INCLS)
|
|
||||||
AC_SUBST(V_LIBS)
|
|
||||||
-AC_SUBST(V_LEX)
|
|
||||||
AC_SUBST(V_PCAP)
|
|
||||||
AC_SUBST(V_FINDALLDEVS)
|
|
||||||
AC_SUBST(V_RANLIB)
|
|
||||||
-AC_SUBST(V_YACC)
|
|
||||||
AC_SUBST(SSRC)
|
|
||||||
|
|
||||||
AC_PROG_INSTALL
|
|
||||||
|
|
||||||
o An OpenBSD portability fix to make loopback work:
|
|
||||||
diff -w -u -r1.1 pcap-bpf.h
|
|
||||||
--- pcap-bpf.h 1 Aug 2004 05:34:47 -0000 1.1
|
|
||||||
+++ pcap-bpf.h 29 Jan 2005 20:32:24 -0000
|
|
||||||
@@ -235,12 +235,14 @@
|
|
||||||
* OpenBSD DLT_LOOP, for loopback devices; it's like DLT_NULL, except
|
|
||||||
* that the AF_ type in the link-layer header is in network byte order.
|
|
||||||
*
|
|
||||||
- * OpenBSD defines it as 12, but that collides with DLT_RAW, so we
|
|
||||||
- * define it as 108 here. If OpenBSD picks up this file, it should
|
|
||||||
- * define DLT_LOOP as 12 in its version, as per the comment above -
|
|
||||||
- * and should not use 108 as a DLT_ value.
|
|
||||||
+ * OpenBSD defines it as 12, but that collides with DLT_RAW, so 108 is
|
|
||||||
+ * used for other platforms.
|
|
||||||
*/
|
|
||||||
+#ifdef __OpenBSD__
|
|
||||||
+#define DLT_LOOP 12
|
|
||||||
+#else
|
|
||||||
#define DLT_LOOP 108
|
|
||||||
+#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Encapsulated packets for IPsec; DLT_ENC is 13 in OpenBSD, but that's
|
|
||||||
|
|
||||||
|
|
||||||
The following patch removes some code that apparently causes libpcap on
|
|
||||||
Solaris to wait for 64K chunks before returning in some cases, regardless of
|
|
||||||
the timeout values. Problem report and patch came from
|
|
||||||
Ben Harris (bjh21(a)cam.ac.uk)
|
|
||||||
|
|
||||||
--- pcap-dlpi.c 1 Aug 2004 05:34:47 -0000 1.4
|
|
||||||
+++ pcap-dlpi.c 1 Feb 2005 20:29:29 -0000
|
|
||||||
@@ -675,16 +675,6 @@
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- /*
|
|
||||||
- ** Set the chunk length.
|
|
||||||
- */
|
|
||||||
- chunksize = CHUNKSIZE;
|
|
||||||
- if (strioctl(p->fd, SBIOCSCHUNK, sizeof(chunksize), (char *)&chunksize)
|
|
||||||
- != 0) {
|
|
||||||
- snprintf(ebuf, PCAP_ERRBUF_SIZE, "SBIOCSCHUNKP: %s",
|
|
||||||
- pcap_strerror(errno));
|
|
||||||
- goto bad;
|
|
||||||
- }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
o Removed packaging/pcap.spec because it conflicted with the Nmap spec file when building RPMs from the tarball.
|
|
||||||
|
|
||||||
o Changed the configure.ac to enable -fno-strict-aliasing when GCC 4+
|
|
||||||
is in use. Here is that patch:
|
|
||||||
--- configure.ac (revision 2864)
|
|
||||||
+++ configure.ac (working copy)
|
|
||||||
@@ -741,6 +741,39 @@
|
|
||||||
|
|
||||||
AC_LBL_UNALIGNED_ACCESS
|
|
||||||
|
|
||||||
+pcap_gcc_major_version=0
|
|
||||||
+AC_MSG_CHECKING([whether the compiler is gcc 4 or greater])
|
|
||||||
+if test x"$GCC" = xno; then
|
|
||||||
+ AC_MSG_RESULT([no])
|
|
||||||
+else
|
|
||||||
+ # new major versions must be added here
|
|
||||||
+ case `$CC --version | sed -e 's,\..*,.,' -e q` in
|
|
||||||
+ *4.)
|
|
||||||
+ pcap_gcc_major_version=4
|
|
||||||
+ ;;
|
|
||||||
+ *3.)
|
|
||||||
+ pcap_gcc_major_version=3
|
|
||||||
+ ;;
|
|
||||||
+ *2.)
|
|
||||||
+ pcap_gcc_major_version=2
|
|
||||||
+ ;;
|
|
||||||
+ *1.)
|
|
||||||
+ pcap_gcc_major_version=1
|
|
||||||
+ ;;
|
|
||||||
+ esac
|
|
||||||
+ if test "$pcap_gcc_major_version" -ge 4; then
|
|
||||||
+ AC_MSG_RESULT([yes])
|
|
||||||
+ else
|
|
||||||
+ AC_MSG_RESULT([no - $pcap_gcc_major_version ; $CC ; $GCC])
|
|
||||||
+ fi
|
|
||||||
+fi
|
|
||||||
+
|
|
||||||
+# Remember that all following tests will run with this CXXFLAGS by default
|
|
||||||
+if test "$pcap_gcc_major_version" -ge 4; then
|
|
||||||
+ V_CCOPT="$V_CCOPT -fno-strict-aliasing"
|
|
||||||
+fi
|
|
||||||
+
|
|
||||||
+
|
|
||||||
#
|
|
||||||
# Makefile.in includes rules to generate version.h, so we assume
|
|
||||||
# that it will be generated if autoconf is used.
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
@(#) $Header: /tcpdump/master/libpcap/README,v 1.30 2004/10/12 02:02:28 guy Exp $ (LBL)
|
|
||||||
|
|
||||||
LIBPCAP 0.9
|
|
||||||
Now maintained by "The Tcpdump Group"
|
|
||||||
See www.tcpdump.org
|
|
||||||
|
|
||||||
Please send inquiries/comments/reports to tcpdump-workers@tcpdump.org
|
|
||||||
|
|
||||||
Anonymous CVS is available via:
|
|
||||||
cvs -d :pserver:tcpdump@cvs.tcpdump.org:/tcpdump/master login
|
|
||||||
(password "anoncvs")
|
|
||||||
cvs -d :pserver:tcpdump@cvs.tcpdump.org:/tcpdump/master checkout libpcap
|
|
||||||
|
|
||||||
Version 0.9 of LIBPCAP can be retrieved with the CVS tag "libpcap_0_9rel1":
|
|
||||||
cvs -d :pserver:tcpdump@cvs.tcpdump.org:/tcpdump/master checkout -r libpcap_0_9rel1 libpcap
|
|
||||||
|
|
||||||
Please send patches against the master copy to patches@tcpdump.org.
|
|
||||||
|
|
||||||
formerly from Lawrence Berkeley National Laboratory
|
|
||||||
Network Research Group <libpcap@ee.lbl.gov>
|
|
||||||
ftp://ftp.ee.lbl.gov/libpcap.tar.Z (0.4)
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
Note well: this interface is new and is likely to change.
|
|
||||||
|
|
||||||
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, and OpenBSD. DEC
|
|
||||||
OSF/1/Digital UNIX/Tru64 UNIX uses the packetfilter interface but has
|
|
||||||
been extended to accept BPF filters (which libpcap utilizes). Also, you
|
|
||||||
can add BPF filter support to Ultrix using the kernel source and/or
|
|
||||||
object patches available in:
|
|
||||||
|
|
||||||
ftp://gatekeeper.dec.com/pub/DEC/net/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.
|
|
||||||
|
|
||||||
Problems, bugs, questions, desirable enhancements, etc. should be sent
|
|
||||||
to the address "tcpdump-workers@tcpdump.org". Bugs, support requests,
|
|
||||||
and feature requests may also be submitted on the SourceForge site for
|
|
||||||
libpcap at
|
|
||||||
|
|
||||||
http://sourceforge.net/projects/libpcap/
|
|
||||||
|
|
||||||
Source code contributions, etc. should be sent to the email address
|
|
||||||
"patches@tcpdump.org", or submitted as patches on the SourceForge site
|
|
||||||
for libpcap.
|
|
||||||
|
|
||||||
Current versions can be found at www.tcpdump.org, or the SourceForge
|
|
||||||
site for libpcap.
|
|
||||||
|
|
||||||
- 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 CVS, 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,78 +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.
|
|
||||||
|
|
||||||
(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@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 send to patches@tcpdump.org
|
|
||||||
a patch, so we can incorporate them 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,93 +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, DAG cards do not support
|
|
||||||
poll/select methods.
|
|
||||||
|
|
||||||
pcap_inject() and pcap_sendpacket() are not supported.
|
|
||||||
|
|
||||||
----------------------------------------------------------------------
|
|
||||||
|
|
||||||
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,88 +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.
|
|
||||||
|
|
||||||
|
|
||||||
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_drops Always 0, this statistic is not gatherd on this platform
|
|
||||||
|
|
||||||
2.4.x
|
|
||||||
=====
|
|
||||||
ps_rec Number of packets that were accepted by the pcap filter
|
|
||||||
ps_drops Number of packets that had passed filtering but were not
|
|
||||||
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,43 +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 OS X that 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).
|
|
||||||
|
|
||||||
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.
|
|
||||||
@@ -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,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.
42
libpcap/TODO
42
libpcap/TODO
@@ -1,42 +0,0 @@
|
|||||||
TODO list for libpcap
|
|
||||||
=======================
|
|
||||||
|
|
||||||
Important stuff (to be done before the next release)
|
|
||||||
---------------
|
|
||||||
|
|
||||||
General
|
|
||||||
|
|
||||||
- configure should not be in the CVS. 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.
|
|
||||||
|
|
||||||
Linux kernel interface
|
|
||||||
|
|
||||||
- Currently there is a race condition in that a socket is activated at the
|
|
||||||
same time it is opened - before applying a filter. This has to
|
|
||||||
be corrected so that capture starts when pcap_read is called for the
|
|
||||||
first time.
|
|
||||||
|
|
||||||
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 @@
|
|||||||
0.9.2
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
/* @(#) $Header$ (LBL) */
|
|
||||||
|
|
||||||
/* Define __P() macro, if necessary */
|
|
||||||
|
|
||||||
#ifndef __P
|
|
||||||
#if __STDC__
|
|
||||||
#define __P(protos) protos
|
|
||||||
#else
|
|
||||||
#define __P(protos) ()
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* inline foo */
|
|
||||||
#ifndef __cplusplus
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#define inline __inline
|
|
||||||
#else
|
|
||||||
#define inline
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Handle new and old "dead" routine prototypes
|
|
||||||
*
|
|
||||||
* For example:
|
|
||||||
*
|
|
||||||
* __dead void foo(void) __attribute__((volatile));
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#ifndef __dead
|
|
||||||
#define __dead volatile
|
|
||||||
#endif
|
|
||||||
#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
|
|
||||||
#ifndef __attribute__
|
|
||||||
#define __attribute__(args)
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#ifndef __dead
|
|
||||||
#define __dead
|
|
||||||
#endif
|
|
||||||
#ifndef __attribute__
|
|
||||||
#define __attribute__(args)
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
@@ -1,122 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. Neither the name of the project nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* $Id$ */
|
|
||||||
|
|
||||||
#ifndef HAVE_ADDRINFO
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Error return codes from getaddrinfo()
|
|
||||||
*/
|
|
||||||
#define EAI_ADDRFAMILY 1 /* address family for hostname not supported */
|
|
||||||
#define EAI_AGAIN 2 /* temporary failure in name resolution */
|
|
||||||
#define EAI_BADFLAGS 3 /* invalid value for ai_flags */
|
|
||||||
#define EAI_FAIL 4 /* non-recoverable failure in name resolution */
|
|
||||||
#define EAI_FAMILY 5 /* ai_family not supported */
|
|
||||||
#define EAI_MEMORY 6 /* memory allocation failure */
|
|
||||||
#define EAI_NODATA 7 /* no address associated with hostname */
|
|
||||||
#define EAI_NONAME 8 /* hostname nor servname provided, or not known */
|
|
||||||
#define EAI_SERVICE 9 /* servname not supported for ai_socktype */
|
|
||||||
#define EAI_SOCKTYPE 10 /* ai_socktype not supported */
|
|
||||||
#define EAI_SYSTEM 11 /* system error returned in errno */
|
|
||||||
#define EAI_BADHINTS 12
|
|
||||||
#define EAI_PROTOCOL 13
|
|
||||||
#define EAI_MAX 14
|
|
||||||
|
|
||||||
/* internal error */
|
|
||||||
#define NETDB_INTERNAL -1 /* see errno */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Flag values for getaddrinfo()
|
|
||||||
*/
|
|
||||||
#define AI_PASSIVE 0x00000001 /* get address to use bind() */
|
|
||||||
#define AI_CANONNAME 0x00000002 /* fill ai_canonname */
|
|
||||||
#define AI_NUMERICHOST 0x00000004 /* prevent name resolution */
|
|
||||||
/* valid flags for addrinfo */
|
|
||||||
#define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
|
|
||||||
|
|
||||||
#define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
|
|
||||||
#define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */
|
|
||||||
#define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */
|
|
||||||
#define AI_V4MAPPED 0x00000800 /* accept IPv4-mapped IPv6 address */
|
|
||||||
/* special recommended flags for getipnodebyname */
|
|
||||||
#define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG)
|
|
||||||
|
|
||||||
struct addrinfo {
|
|
||||||
int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
|
|
||||||
int ai_family; /* PF_xxx */
|
|
||||||
int ai_socktype; /* SOCK_xxx */
|
|
||||||
int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
|
|
||||||
size_t ai_addrlen; /* length of ai_addr */
|
|
||||||
char *ai_canonname; /* canonical name for hostname */
|
|
||||||
struct sockaddr *ai_addr; /* binary address */
|
|
||||||
struct addrinfo *ai_next; /* next structure in linked list */
|
|
||||||
};
|
|
||||||
|
|
||||||
extern void freeaddrinfo (struct addrinfo *);
|
|
||||||
extern void freehostent (struct hostent *);
|
|
||||||
extern char *gai_strerror (int);
|
|
||||||
extern int getaddrinfo (const char *, const char *,
|
|
||||||
const struct addrinfo *, struct addrinfo **);
|
|
||||||
extern int getnameinfo (const struct sockaddr *, size_t, char *,
|
|
||||||
size_t, char *, size_t, int);
|
|
||||||
extern struct hostent *getipnodebyaddr (const void *, size_t, int, int *);
|
|
||||||
extern struct hostent *getipnodebyname (const char *, int, int, int *);
|
|
||||||
extern int inet_pton (int, const char *, void *);
|
|
||||||
extern const char *inet_ntop (int, const void *, char *, size_t);
|
|
||||||
#endif /* HAVE_ADDRINFO */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Constants for getnameinfo()
|
|
||||||
*/
|
|
||||||
#ifndef NI_MAXHOST
|
|
||||||
#define NI_MAXHOST 1025
|
|
||||||
#endif
|
|
||||||
#ifndef NI_MAXSERV
|
|
||||||
#define NI_MAXSERV 32
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Flag values for getnameinfo()
|
|
||||||
*/
|
|
||||||
#ifndef NI_NOFQDN
|
|
||||||
#define NI_NOFQDN 0x00000001
|
|
||||||
#endif
|
|
||||||
#ifndef NI_NUMERICHOST
|
|
||||||
#define NI_NUMERICHOST 0x00000002
|
|
||||||
#endif
|
|
||||||
#ifndef NI_NAMEREQD
|
|
||||||
#define NI_NAMEREQD 0x00000004
|
|
||||||
#endif
|
|
||||||
#ifndef NI_NUMERICSERV
|
|
||||||
#define NI_NUMERICSERV 0x00000008
|
|
||||||
#endif
|
|
||||||
#ifndef NI_DGRAM
|
|
||||||
#define NI_DGRAM 0x00000010
|
|
||||||
#endif
|
|
||||||
@@ -1,349 +0,0 @@
|
|||||||
/*
|
|
||||||
* ++Copyright++ 1983, 1989, 1993
|
|
||||||
* -
|
|
||||||
* Copyright (c) 1983, 1989, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by the University of
|
|
||||||
* California, Berkeley and its contributors.
|
|
||||||
* 4. Neither the name of the University nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
* -
|
|
||||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies, and that
|
|
||||||
* the name of Digital Equipment Corporation not be used in advertising or
|
|
||||||
* publicity pertaining to distribution of the document or software without
|
|
||||||
* specific, written prior permission.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
|
||||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
|
||||||
* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
|
||||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
|
||||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
|
||||||
* SOFTWARE.
|
|
||||||
* -
|
|
||||||
* --Copyright--
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @(#)nameser.h 8.1 (Berkeley) 6/2/93
|
|
||||||
* nameser.h,v 1.2 1995/05/06 14:23:54 hjl Exp
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _NAMESER_H_
|
|
||||||
#define _NAMESER_H_
|
|
||||||
|
|
||||||
#ifndef WIN32
|
|
||||||
#include <sys/param.h>
|
|
||||||
#if (!defined(BSD)) || (BSD < 199306)
|
|
||||||
# include <sys/bitypes.h>
|
|
||||||
#else
|
|
||||||
# include <sys/types.h>
|
|
||||||
#endif
|
|
||||||
#include <sys/cdefs.h>
|
|
||||||
#else
|
|
||||||
#include <pcap-stdinc.h>
|
|
||||||
#define __LITTLE_ENDIAN 1
|
|
||||||
#define __BYTE_ORDER __LITTLE_ENDIAN
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* revision information. this is the release date in YYYYMMDD format.
|
|
||||||
* it can change every day so the right thing to do with it is use it
|
|
||||||
* in preprocessor commands such as "#if (__BIND > 19931104)". do not
|
|
||||||
* compare for equality; rather, use it to determine whether your resolver
|
|
||||||
* is new enough to contain a certain feature.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define __BIND 19940417 /* interface version stamp */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Define constants based on rfc883
|
|
||||||
*/
|
|
||||||
#define PACKETSZ 512 /* maximum packet size */
|
|
||||||
#define MAXDNAME 256 /* maximum domain name */
|
|
||||||
#define MAXCDNAME 255 /* maximum compressed domain name */
|
|
||||||
#define MAXLABEL 63 /* maximum length of domain label */
|
|
||||||
#define HFIXEDSZ 12 /* #/bytes of fixed data in header */
|
|
||||||
#define QFIXEDSZ 4 /* #/bytes of fixed data in query */
|
|
||||||
#define RRFIXEDSZ 10 /* #/bytes of fixed data in r record */
|
|
||||||
#define INT32SZ 4 /* for systems without 32-bit ints */
|
|
||||||
#define INT16SZ 2 /* for systems without 16-bit ints */
|
|
||||||
#define INADDRSZ 4 /* for sizeof(struct inaddr) != 4 */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Internet nameserver port number
|
|
||||||
*/
|
|
||||||
#define NAMESERVER_PORT 53
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Currently defined opcodes
|
|
||||||
*/
|
|
||||||
#define QUERY 0x0 /* standard query */
|
|
||||||
#define IQUERY 0x1 /* inverse query */
|
|
||||||
#define STATUS 0x2 /* nameserver status query */
|
|
||||||
/*#define xxx 0x3 *//* 0x3 reserved */
|
|
||||||
#define NS_NOTIFY_OP 0x4 /* notify secondary of SOA change */
|
|
||||||
#ifdef ALLOW_UPDATES
|
|
||||||
/* non standard - supports ALLOW_UPDATES stuff from Mike Schwartz */
|
|
||||||
# define UPDATEA 0x9 /* add resource record */
|
|
||||||
# define UPDATED 0xa /* delete a specific resource record */
|
|
||||||
# define UPDATEDA 0xb /* delete all named resource record */
|
|
||||||
# define UPDATEM 0xc /* modify a specific resource record */
|
|
||||||
# define UPDATEMA 0xd /* modify all named resource record */
|
|
||||||
# define ZONEINIT 0xe /* initial zone transfer */
|
|
||||||
# define ZONEREF 0xf /* incremental zone referesh */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Currently defined response codes
|
|
||||||
*/
|
|
||||||
#ifdef HAVE_ADDRINFO
|
|
||||||
#define NOERROR 0 /* no error */
|
|
||||||
#endif /* HAVE_ADDRINFO */
|
|
||||||
#define FORMERR 1 /* format error */
|
|
||||||
#define SERVFAIL 2 /* server failure */
|
|
||||||
#define NXDOMAIN 3 /* non existent domain */
|
|
||||||
#define NOTIMP 4 /* not implemented */
|
|
||||||
#define REFUSED 5 /* query refused */
|
|
||||||
#ifdef ALLOW_UPDATES
|
|
||||||
/* non standard */
|
|
||||||
# define NOCHANGE 0xf /* update failed to change db */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Type values for resources and queries
|
|
||||||
*/
|
|
||||||
#define T_A 1 /* host address */
|
|
||||||
#define T_NS 2 /* authoritative server */
|
|
||||||
#define T_MD 3 /* mail destination */
|
|
||||||
#define T_MF 4 /* mail forwarder */
|
|
||||||
#define T_CNAME 5 /* canonical name */
|
|
||||||
#define T_SOA 6 /* start of authority zone */
|
|
||||||
#define T_MB 7 /* mailbox domain name */
|
|
||||||
#define T_MG 8 /* mail group member */
|
|
||||||
#define T_MR 9 /* mail rename name */
|
|
||||||
#define T_NULL 10 /* null resource record */
|
|
||||||
#define T_WKS 11 /* well known service */
|
|
||||||
#define T_PTR 12 /* domain name pointer */
|
|
||||||
#define T_HINFO 13 /* host information */
|
|
||||||
#define T_MINFO 14 /* mailbox information */
|
|
||||||
#define T_MX 15 /* mail routing information */
|
|
||||||
#define T_TXT 16 /* text strings */
|
|
||||||
#define T_RP 17 /* responsible person */
|
|
||||||
#define T_AFSDB 18 /* AFS cell database */
|
|
||||||
#define T_X25 19 /* X_25 calling address */
|
|
||||||
#define T_ISDN 20 /* ISDN calling address */
|
|
||||||
#define T_RT 21 /* router */
|
|
||||||
#define T_NSAP 22 /* NSAP address */
|
|
||||||
#define T_NSAP_PTR 23 /* reverse NSAP lookup (deprecated) */
|
|
||||||
#define T_SIG 24 /* security signature */
|
|
||||||
#define T_KEY 25 /* security key */
|
|
||||||
#define T_PX 26 /* X.400 mail mapping */
|
|
||||||
#define T_GPOS 27 /* geographical position (withdrawn) */
|
|
||||||
#define T_AAAA 28 /* IP6 Address */
|
|
||||||
#define T_LOC 29 /* Location Information */
|
|
||||||
/* non standard */
|
|
||||||
#define T_UINFO 100 /* user (finger) information */
|
|
||||||
#define T_UID 101 /* user ID */
|
|
||||||
#define T_GID 102 /* group ID */
|
|
||||||
#define T_UNSPEC 103 /* Unspecified format (binary data) */
|
|
||||||
/* Query type values which do not appear in resource records */
|
|
||||||
#define T_AXFR 252 /* transfer zone of authority */
|
|
||||||
#define T_MAILB 253 /* transfer mailbox records */
|
|
||||||
#define T_MAILA 254 /* transfer mail agent records */
|
|
||||||
#define T_ANY 255 /* wildcard match */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Values for class field
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define C_IN 1 /* the arpa internet */
|
|
||||||
#define C_CHAOS 3 /* for chaos net (MIT) */
|
|
||||||
#define C_HS 4 /* for Hesiod name server (MIT) (XXX) */
|
|
||||||
/* Query class values which do not appear in resource records */
|
|
||||||
#define C_ANY 255 /* wildcard match */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Status return codes for T_UNSPEC conversion routines
|
|
||||||
*/
|
|
||||||
#define CONV_SUCCESS 0
|
|
||||||
#define CONV_OVERFLOW (-1)
|
|
||||||
#define CONV_BADFMT (-2)
|
|
||||||
#define CONV_BADCKSUM (-3)
|
|
||||||
#define CONV_BADBUFLEN (-4)
|
|
||||||
|
|
||||||
#ifndef __BYTE_ORDER
|
|
||||||
#if (BSD >= 199103)
|
|
||||||
# include <machine/endian.h>
|
|
||||||
#else
|
|
||||||
#ifdef linux
|
|
||||||
# include <endian.h>
|
|
||||||
#else
|
|
||||||
#define __LITTLE_ENDIAN 1234 /* least-significant byte first (vax, pc) */
|
|
||||||
#define __BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */
|
|
||||||
#define __PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp)*/
|
|
||||||
|
|
||||||
#if defined(vax) || defined(ns32000) || defined(sun386) || defined(i386) || \
|
|
||||||
defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || \
|
|
||||||
defined(__alpha__) || defined(__alpha)
|
|
||||||
#define __BYTE_ORDER __LITTLE_ENDIAN
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \
|
|
||||||
defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \
|
|
||||||
defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || defined(DGUX) ||\
|
|
||||||
defined(apollo) || defined(__convex__) || defined(_CRAY) || \
|
|
||||||
defined(__hppa) || defined(__hp9000) || \
|
|
||||||
defined(__hp9000s300) || defined(__hp9000s700) || \
|
|
||||||
defined (BIT_ZERO_ON_LEFT) || defined(m68k)
|
|
||||||
#define __BYTE_ORDER __BIG_ENDIAN
|
|
||||||
#endif
|
|
||||||
#endif /* linux */
|
|
||||||
#endif /* BSD */
|
|
||||||
#endif /* __BYTE_ORDER */
|
|
||||||
|
|
||||||
#if !defined(__BYTE_ORDER) || \
|
|
||||||
(__BYTE_ORDER != __BIG_ENDIAN && __BYTE_ORDER != __LITTLE_ENDIAN && \
|
|
||||||
__BYTE_ORDER != __PDP_ENDIAN)
|
|
||||||
/* you must determine what the correct bit order is for
|
|
||||||
* your compiler - the next line is an intentional error
|
|
||||||
* which will force your compiles to bomb until you fix
|
|
||||||
* the above macros.
|
|
||||||
*/
|
|
||||||
error "Undefined or invalid __BYTE_ORDER";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Structure for query header. The order of the fields is machine- and
|
|
||||||
* compiler-dependent, depending on the byte/bit order and the layout
|
|
||||||
* of bit fields. We use bit fields only in int variables, as this
|
|
||||||
* is all ANSI requires. This requires a somewhat confusing rearrangement.
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
unsigned id :16; /* query identification number */
|
|
||||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
|
||||||
/* fields in third byte */
|
|
||||||
unsigned qr: 1; /* response flag */
|
|
||||||
unsigned opcode: 4; /* purpose of message */
|
|
||||||
unsigned aa: 1; /* authoritive answer */
|
|
||||||
unsigned tc: 1; /* truncated message */
|
|
||||||
unsigned rd: 1; /* recursion desired */
|
|
||||||
/* fields in fourth byte */
|
|
||||||
unsigned ra: 1; /* recursion available */
|
|
||||||
unsigned pr: 1; /* primary server req'd (!standard) */
|
|
||||||
unsigned unused :2; /* unused bits (MBZ as of 4.9.3a3) */
|
|
||||||
unsigned rcode :4; /* response code */
|
|
||||||
#endif
|
|
||||||
#if __BYTE_ORDER == __LITTLE_ENDIAN || __BYTE_ORDER == __PDP_ENDIAN
|
|
||||||
/* fields in third byte */
|
|
||||||
unsigned rd :1; /* recursion desired */
|
|
||||||
unsigned tc :1; /* truncated message */
|
|
||||||
unsigned aa :1; /* authoritive answer */
|
|
||||||
unsigned opcode :4; /* purpose of message */
|
|
||||||
unsigned qr :1; /* response flag */
|
|
||||||
/* fields in fourth byte */
|
|
||||||
unsigned rcode :4; /* response code */
|
|
||||||
unsigned unused :2; /* unused bits (MBZ as of 4.9.3a3) */
|
|
||||||
unsigned pr :1; /* primary server req'd (!standard) */
|
|
||||||
unsigned ra :1; /* recursion available */
|
|
||||||
#endif
|
|
||||||
/* remaining bytes */
|
|
||||||
unsigned qdcount :16; /* number of question entries */
|
|
||||||
unsigned ancount :16; /* number of answer entries */
|
|
||||||
unsigned nscount :16; /* number of authority entries */
|
|
||||||
unsigned arcount :16; /* number of resource entries */
|
|
||||||
} HEADER;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Defines for handling compressed domain names
|
|
||||||
*/
|
|
||||||
#define INDIR_MASK 0xc0
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Structure for passing resource records around.
|
|
||||||
*/
|
|
||||||
struct rrec {
|
|
||||||
int16_t r_zone; /* zone number */
|
|
||||||
int16_t r_class; /* class number */
|
|
||||||
int16_t r_type; /* type number */
|
|
||||||
u_int32_t r_ttl; /* time to live */
|
|
||||||
int r_size; /* size of data area */
|
|
||||||
char *r_data; /* pointer to data */
|
|
||||||
};
|
|
||||||
|
|
||||||
//extern u_int16_t _getshort __P((const u_char *));
|
|
||||||
//extern u_int32_t _getlong __P((const u_char *));
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Inline versions of get/put short/long. Pointer is advanced.
|
|
||||||
*
|
|
||||||
* These macros demonstrate the property of C whereby it can be
|
|
||||||
* portable or it can be elegant but rarely both.
|
|
||||||
*/
|
|
||||||
#define GETSHORT(s, cp) { \
|
|
||||||
register u_char *t_cp = (u_char *)(cp); \
|
|
||||||
(s) = ((u_int16_t)t_cp[0] << 8) \
|
|
||||||
| ((u_int16_t)t_cp[1]) \
|
|
||||||
; \
|
|
||||||
(cp) += INT16SZ; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define GETLONG(l, cp) { \
|
|
||||||
register u_char *t_cp = (u_char *)(cp); \
|
|
||||||
(l) = ((u_int32_t)t_cp[0] << 24) \
|
|
||||||
| ((u_int32_t)t_cp[1] << 16) \
|
|
||||||
| ((u_int32_t)t_cp[2] << 8) \
|
|
||||||
| ((u_int32_t)t_cp[3]) \
|
|
||||||
; \
|
|
||||||
(cp) += INT32SZ; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define PUTSHORT(s, cp) { \
|
|
||||||
register u_int16_t t_s = (u_int16_t)(s); \
|
|
||||||
register u_char *t_cp = (u_char *)(cp); \
|
|
||||||
*t_cp++ = t_s >> 8; \
|
|
||||||
*t_cp = t_s; \
|
|
||||||
(cp) += INT16SZ; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define PUTLONG(l, cp) { \
|
|
||||||
register u_int32_t t_l = (u_int32_t)(l); \
|
|
||||||
register u_char *t_cp = (u_char *)(cp); \
|
|
||||||
*t_cp++ = t_l >> 24; \
|
|
||||||
*t_cp++ = t_l >> 16; \
|
|
||||||
*t_cp++ = t_l >> 8; \
|
|
||||||
*t_cp = t_l; \
|
|
||||||
(cp) += INT32SZ; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* !_NAMESER_H_ */
|
|
||||||
@@ -1,135 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 1999 WIDE Project.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. Neither the name of the project nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
#ifndef _BITTYPES_H
|
|
||||||
#define _BITTYPES_H
|
|
||||||
|
|
||||||
#ifndef HAVE_U_INT8_T
|
|
||||||
|
|
||||||
#if SIZEOF_CHAR == 1
|
|
||||||
typedef unsigned char u_int8_t;
|
|
||||||
typedef signed char int8_t;
|
|
||||||
#elif SIZEOF_INT == 1
|
|
||||||
typedef unsigned int u_int8_t;
|
|
||||||
typedef signed int int8_t;
|
|
||||||
#else /* XXX */
|
|
||||||
#error "there's no appropriate type for u_int8_t"
|
|
||||||
#endif
|
|
||||||
#define HAVE_U_INT8_T 1
|
|
||||||
#define HAVE_INT8_T 1
|
|
||||||
|
|
||||||
#endif /* HAVE_U_INT8_T */
|
|
||||||
|
|
||||||
#ifndef HAVE_U_INT16_T
|
|
||||||
|
|
||||||
#if SIZEOF_SHORT == 2
|
|
||||||
typedef unsigned short u_int16_t;
|
|
||||||
typedef signed short int16_t;
|
|
||||||
#elif SIZEOF_INT == 2
|
|
||||||
typedef unsigned int u_int16_t;
|
|
||||||
typedef signed int int16_t;
|
|
||||||
#elif SIZEOF_CHAR == 2
|
|
||||||
typedef unsigned char u_int16_t;
|
|
||||||
typedef signed char int16_t;
|
|
||||||
#else /* XXX */
|
|
||||||
#error "there's no appropriate type for u_int16_t"
|
|
||||||
#endif
|
|
||||||
#define HAVE_U_INT16_T 1
|
|
||||||
#define HAVE_INT16_T 1
|
|
||||||
|
|
||||||
#endif /* HAVE_U_INT16_T */
|
|
||||||
|
|
||||||
#ifndef HAVE_U_INT32_T
|
|
||||||
|
|
||||||
#if SIZEOF_INT == 4
|
|
||||||
typedef unsigned int u_int32_t;
|
|
||||||
typedef signed int int32_t;
|
|
||||||
#elif SIZEOF_LONG == 4
|
|
||||||
typedef unsigned long u_int32_t;
|
|
||||||
typedef signed long int32_t;
|
|
||||||
#elif SIZEOF_SHORT == 4
|
|
||||||
typedef unsigned short u_int32_t;
|
|
||||||
typedef signed short int32_t;
|
|
||||||
#else /* XXX */
|
|
||||||
#error "there's no appropriate type for u_int32_t"
|
|
||||||
#endif
|
|
||||||
#define HAVE_U_INT32_T 1
|
|
||||||
#define HAVE_INT32_T 1
|
|
||||||
|
|
||||||
#endif /* HAVE_U_INT32_T */
|
|
||||||
|
|
||||||
#ifndef HAVE_U_INT64_T
|
|
||||||
#if SIZEOF_LONG_LONG == 8
|
|
||||||
typedef unsigned long long u_int64_t;
|
|
||||||
#elif defined(_MSC_EXTENSIONS)
|
|
||||||
typedef unsigned _int64 u_int64_t;
|
|
||||||
#elif SIZEOF_INT == 8
|
|
||||||
typedef unsigned int u_int64_t;
|
|
||||||
#elif SIZEOF_LONG == 8
|
|
||||||
typedef unsigned long u_int64_t;
|
|
||||||
#elif SIZEOF_SHORT == 8
|
|
||||||
typedef unsigned short u_int64_t;
|
|
||||||
#else /* XXX */
|
|
||||||
#error "there's no appropriate type for u_int64_t"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* HAVE_U_INT64_T */
|
|
||||||
|
|
||||||
#ifndef PRId64
|
|
||||||
#ifdef _MSC_EXTENSIONS
|
|
||||||
#define PRId64 "I64d"
|
|
||||||
#else /* _MSC_EXTENSIONS */
|
|
||||||
#define PRId64 "lld"
|
|
||||||
#endif /* _MSC_EXTENSIONS */
|
|
||||||
#endif /* PRId64 */
|
|
||||||
|
|
||||||
#ifndef PRIo64
|
|
||||||
#ifdef _MSC_EXTENSIONS
|
|
||||||
#define PRIo64 "I64o"
|
|
||||||
#else /* _MSC_EXTENSIONS */
|
|
||||||
#define PRIo64 "llo"
|
|
||||||
#endif /* _MSC_EXTENSIONS */
|
|
||||||
#endif /* PRIo64 */
|
|
||||||
|
|
||||||
#ifndef PRIx64
|
|
||||||
#ifdef _MSC_EXTENSIONS
|
|
||||||
#define PRIx64 "I64x"
|
|
||||||
#else /* _MSC_EXTENSIONS */
|
|
||||||
#define PRIx64 "llx"
|
|
||||||
#endif /* _MSC_EXTENSIONS */
|
|
||||||
#endif /* PRIx64 */
|
|
||||||
|
|
||||||
#ifndef PRIu64
|
|
||||||
#ifdef _MSC_EXTENSIONS
|
|
||||||
#define PRIu64 "I64u"
|
|
||||||
#else /* _MSC_EXTENSIONS */
|
|
||||||
#define PRIu64 "llu"
|
|
||||||
#endif /* _MSC_EXTENSIONS */
|
|
||||||
#endif /* PRIu64 */
|
|
||||||
|
|
||||||
#endif /* _BITTYPES_H */
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 1999 WIDE Project.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. Neither the name of the project nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
#ifndef HAVE_PORTABLE_PROTOTYPE
|
|
||||||
|
|
||||||
#if defined(__STDC__) || defined(__cplusplus)
|
|
||||||
#define __P(protos) protos /* full-blown ANSI C */
|
|
||||||
#else
|
|
||||||
#define __P(protos) () /* traditional C preprocessor */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* !HAVE_PORTABLE_PROTOTYPE */
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1999 - 2003
|
|
||||||
* NetGroup, Politecnico di Torino (Italy)
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. Neither the name of the Politecnico di Torino nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <net/netdb.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <arpa/nameser.h>
|
|
||||||
|
|
||||||
extern void _sethtent(int f);
|
|
||||||
extern void _endhtent(void);
|
|
||||||
extern struct hostent *_gethtent(void);
|
|
||||||
extern struct hostent *_gethtbyname(const char *name);
|
|
||||||
extern struct hostent *_gethtbyaddr(const char *addr, int len,
|
|
||||||
int type);
|
|
||||||
extern int _validuser(FILE *hostf, const char *rhost,
|
|
||||||
const char *luser, const char *ruser, int baselen);
|
|
||||||
extern int _checkhost(const char *rhost, const char *lhost, int len);
|
|
||||||
#if 0
|
|
||||||
extern void putlong(u_long l, u_char *msgp);
|
|
||||||
extern void putshort(u_short l, u_char *msgp);
|
|
||||||
extern u_int32_t _getlong(register const u_char *msgp);
|
|
||||||
extern u_int16_t _getshort(register const u_char *msgp);
|
|
||||||
extern void p_query(char *msg);
|
|
||||||
extern void fp_query(char *msg, FILE *file);
|
|
||||||
extern char *p_cdname(char *cp, char *msg, FILE *file);
|
|
||||||
extern char *p_rr(char *cp, char *msg, FILE *file);
|
|
||||||
extern char *p_type(int type);
|
|
||||||
extern char * p_class(int class);
|
|
||||||
extern char *p_time(u_long value);
|
|
||||||
#endif
|
|
||||||
extern char * hostalias(const char *name);
|
|
||||||
extern void sethostfile(char *name);
|
|
||||||
extern void _res_close (void);
|
|
||||||
extern void ruserpass(const char *host, char **aname, char **apass);
|
|
||||||
@@ -1,163 +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.
|
|
||||||
*
|
|
||||||
* @(#) $Header$ (LBL)
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file contains a collage of declarations for IPv6 from FreeBSD not present in Windows
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <winsock2.h>
|
|
||||||
|
|
||||||
#ifndef __MINGW32__
|
|
||||||
#include <ws2tcpip.h>
|
|
||||||
#endif /* __MINGW32__ */
|
|
||||||
|
|
||||||
#define IN_MULTICAST(a) IN_CLASSD(a)
|
|
||||||
|
|
||||||
#define IN_EXPERIMENTAL(a) ((((u_int32_t) (a)) & 0xf0000000) == 0xf0000000)
|
|
||||||
|
|
||||||
#define IN_LOOPBACKNET 127
|
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
|
||||||
/* IPv6 address */
|
|
||||||
struct in6_addr
|
|
||||||
{
|
|
||||||
union
|
|
||||||
{
|
|
||||||
u_int8_t u6_addr8[16];
|
|
||||||
u_int16_t u6_addr16[8];
|
|
||||||
u_int32_t u6_addr32[4];
|
|
||||||
} in6_u;
|
|
||||||
#define s6_addr in6_u.u6_addr8
|
|
||||||
#define s6_addr16 in6_u.u6_addr16
|
|
||||||
#define s6_addr32 in6_u.u6_addr32
|
|
||||||
#define s6_addr64 in6_u.u6_addr64
|
|
||||||
};
|
|
||||||
|
|
||||||
#define IN6ADDR_ANY_INIT { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
|
|
||||||
#define IN6ADDR_LOOPBACK_INIT { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }
|
|
||||||
#endif /* __MINGW32__ */
|
|
||||||
|
|
||||||
|
|
||||||
#if (defined WIN32) || (defined __MINGW32__)
|
|
||||||
typedef unsigned short sa_family_t;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
|
||||||
|
|
||||||
#define __SOCKADDR_COMMON(sa_prefix) \
|
|
||||||
sa_family_t sa_prefix##family
|
|
||||||
|
|
||||||
/* Ditto, for IPv6. */
|
|
||||||
struct sockaddr_in6
|
|
||||||
{
|
|
||||||
__SOCKADDR_COMMON (sin6_);
|
|
||||||
u_int16_t sin6_port; /* Transport layer port # */
|
|
||||||
u_int32_t sin6_flowinfo; /* IPv6 flow information */
|
|
||||||
struct in6_addr sin6_addr; /* IPv6 address */
|
|
||||||
};
|
|
||||||
|
|
||||||
#define IN6_IS_ADDR_V4MAPPED(a) \
|
|
||||||
((((u_int32_t *) (a))[0] == 0) && (((u_int32_t *) (a))[1] == 0) && \
|
|
||||||
(((u_int32_t *) (a))[2] == htonl (0xffff)))
|
|
||||||
|
|
||||||
#define IN6_IS_ADDR_MULTICAST(a) (((u_int8_t *) (a))[0] == 0xff)
|
|
||||||
|
|
||||||
#define IN6_IS_ADDR_LINKLOCAL(a) \
|
|
||||||
((((u_int32_t *) (a))[0] & htonl (0xffc00000)) == htonl (0xfe800000))
|
|
||||||
|
|
||||||
#define IN6_IS_ADDR_LOOPBACK(a) \
|
|
||||||
(((u_int32_t *) (a))[0] == 0 && ((u_int32_t *) (a))[1] == 0 && \
|
|
||||||
((u_int32_t *) (a))[2] == 0 && ((u_int32_t *) (a))[3] == htonl (1))
|
|
||||||
#endif /* __MINGW32__ */
|
|
||||||
|
|
||||||
#define ip6_vfc ip6_ctlun.ip6_un2_vfc
|
|
||||||
#define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow
|
|
||||||
#define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen
|
|
||||||
#define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt
|
|
||||||
#define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim
|
|
||||||
#define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim
|
|
||||||
|
|
||||||
#define nd_rd_type nd_rd_hdr.icmp6_type
|
|
||||||
#define nd_rd_code nd_rd_hdr.icmp6_code
|
|
||||||
#define nd_rd_cksum nd_rd_hdr.icmp6_cksum
|
|
||||||
#define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
|
|
||||||
|
|
||||||
/*
|
|
||||||
* IPV6 extension headers
|
|
||||||
*/
|
|
||||||
#define IPPROTO_HOPOPTS 0 /* IPv6 hop-by-hop options */
|
|
||||||
#define IPPROTO_IPV6 41 /* IPv6 header. */
|
|
||||||
#define IPPROTO_ROUTING 43 /* IPv6 routing header */
|
|
||||||
#define IPPROTO_FRAGMENT 44 /* IPv6 fragmentation header */
|
|
||||||
#define IPPROTO_ESP 50 /* encapsulating security payload */
|
|
||||||
#define IPPROTO_AH 51 /* authentication header */
|
|
||||||
#define IPPROTO_ICMPV6 58 /* ICMPv6 */
|
|
||||||
#define IPPROTO_NONE 59 /* IPv6 no next header */
|
|
||||||
#define IPPROTO_DSTOPTS 60 /* IPv6 destination options */
|
|
||||||
#define IPPROTO_PIM 103 /* Protocol Independent Multicast. */
|
|
||||||
|
|
||||||
#define IPV6_RTHDR_TYPE_0 0
|
|
||||||
|
|
||||||
/* Option types and related macros */
|
|
||||||
#define IP6OPT_PAD1 0x00 /* 00 0 00000 */
|
|
||||||
#define IP6OPT_PADN 0x01 /* 00 0 00001 */
|
|
||||||
#define IP6OPT_JUMBO 0xC2 /* 11 0 00010 = 194 */
|
|
||||||
#define IP6OPT_JUMBO_LEN 6
|
|
||||||
#define IP6OPT_ROUTER_ALERT 0x05 /* 00 0 00101 */
|
|
||||||
|
|
||||||
#define IP6OPT_RTALERT_LEN 4
|
|
||||||
#define IP6OPT_RTALERT_MLD 0 /* Datagram contains an MLD message */
|
|
||||||
#define IP6OPT_RTALERT_RSVP 1 /* Datagram contains an RSVP message */
|
|
||||||
#define IP6OPT_RTALERT_ACTNET 2 /* contains an Active Networks msg */
|
|
||||||
#define IP6OPT_MINLEN 2
|
|
||||||
|
|
||||||
#define IP6OPT_BINDING_UPDATE 0xc6 /* 11 0 00110 */
|
|
||||||
#define IP6OPT_BINDING_ACK 0x07 /* 00 0 00111 */
|
|
||||||
#define IP6OPT_BINDING_REQ 0x08 /* 00 0 01000 */
|
|
||||||
#define IP6OPT_HOME_ADDRESS 0xc9 /* 11 0 01001 */
|
|
||||||
#define IP6OPT_EID 0x8a /* 10 0 01010 */
|
|
||||||
|
|
||||||
#define IP6OPT_TYPE(o) ((o) & 0xC0)
|
|
||||||
#define IP6OPT_TYPE_SKIP 0x00
|
|
||||||
#define IP6OPT_TYPE_DISCARD 0x40
|
|
||||||
#define IP6OPT_TYPE_FORCEICMP 0x80
|
|
||||||
#define IP6OPT_TYPE_ICMP 0xC0
|
|
||||||
|
|
||||||
#define IP6OPT_MUTABLE 0x20
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
|
||||||
#ifndef EAI_ADDRFAMILY
|
|
||||||
struct addrinfo {
|
|
||||||
int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
|
|
||||||
int ai_family; /* PF_xxx */
|
|
||||||
int ai_socktype; /* SOCK_xxx */
|
|
||||||
int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
|
|
||||||
size_t ai_addrlen; /* length of ai_addr */
|
|
||||||
char *ai_canonname; /* canonical name for hostname */
|
|
||||||
struct sockaddr *ai_addr; /* binary address */
|
|
||||||
struct addrinfo *ai_next; /* next structure in linked list */
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
#endif /* __MINGW32__ */
|
|
||||||
@@ -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,164 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 1980, 1983, 1988, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by the University of
|
|
||||||
* California, Berkeley and its contributors.
|
|
||||||
* 4. Neither the name of the University nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* @(#)netdb.h 8.1 (Berkeley) 6/2/93
|
|
||||||
* netdb.h,v 1.4 1995/08/14 04:05:04 hjl Exp
|
|
||||||
* -
|
|
||||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies, and that
|
|
||||||
* the name of Digital Equipment Corporation not be used in advertising or
|
|
||||||
* publicity pertaining to distribution of the document or software without
|
|
||||||
* specific, written prior permission.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
|
||||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
|
||||||
* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
|
||||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
|
||||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
|
||||||
* SOFTWARE.
|
|
||||||
* -
|
|
||||||
* --Copyright--
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _NETDB_H_
|
|
||||||
#define _NETDB_H_
|
|
||||||
|
|
||||||
#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) || defined(_REENTRANT)
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <winsock2.h>
|
|
||||||
#include <net/paths.h>
|
|
||||||
|
|
||||||
#define _PATH_HEQUIV __PATH_ETC_INET"/hosts.equiv"
|
|
||||||
#define _PATH_HOSTS __PATH_ETC_INET"/hosts"
|
|
||||||
#define _PATH_NETWORKS __PATH_ETC_INET"/networks"
|
|
||||||
#define _PATH_PROTOCOLS __PATH_ETC_INET"/protocols"
|
|
||||||
#define _PATH_SERVICES __PATH_ETC_INET"/services"
|
|
||||||
#define _PATH_RESCONF __PATH_ETC_INET"/resolv.conf"
|
|
||||||
#define _PATH_RPC __PATH_ETC_INET"/rpc"
|
|
||||||
|
|
||||||
struct rpcent {
|
|
||||||
char *r_name; /* name of server for this rpc program */
|
|
||||||
char **r_aliases; /* alias list */
|
|
||||||
int r_number; /* rpc program number */
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifndef WIN32
|
|
||||||
#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) || defined(_REENTRANT)
|
|
||||||
|
|
||||||
#define __NETDB_MAXALIASES 35
|
|
||||||
#define __NETDB_MAXADDRS 35
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Error return codes from gethostbyname() and gethostbyaddr()
|
|
||||||
* (left in extern int h_errno).
|
|
||||||
*/
|
|
||||||
#define h_errno (*__h_errno_location ())
|
|
||||||
#else
|
|
||||||
extern int h_errno;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define NETDB_INTERNAL -1 /* see errno */
|
|
||||||
#define NETDB_SUCCESS 0 /* no problem */
|
|
||||||
|
|
||||||
//#include <features.h>
|
|
||||||
|
|
||||||
void endhostent (void);
|
|
||||||
void endnetent (void);
|
|
||||||
void endprotoent (void);
|
|
||||||
void endservent (void);
|
|
||||||
void endrpcent (void);
|
|
||||||
struct hostent *gethostent (void);
|
|
||||||
struct netent *getnetbyaddr (long, int); /* u_long? */
|
|
||||||
struct netent *getnetbyname (const char *);
|
|
||||||
struct netent *getnetent (void);
|
|
||||||
struct protoent *getprotoent (void);
|
|
||||||
struct servent *getservent (void);
|
|
||||||
struct rpcent *getrpcent (void);
|
|
||||||
struct rpcent *getrpcbyname (const char *);
|
|
||||||
struct rpcent *getrpcbynumber (int);
|
|
||||||
void herror (const char *);
|
|
||||||
void sethostent (int);
|
|
||||||
/* void sethostfile (const char *); */
|
|
||||||
void setnetent (int);
|
|
||||||
void setprotoent (int);
|
|
||||||
void setservent (int);
|
|
||||||
void setrpcent (int);
|
|
||||||
|
|
||||||
#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) || defined(_REENTRANT)
|
|
||||||
struct hostent *gethostbyaddr_r (const char *__addr,
|
|
||||||
int __length, int __type,
|
|
||||||
struct hostent *__result,
|
|
||||||
char *__buffer, int __buflen, int *__h_errnop);
|
|
||||||
struct hostent *gethostbyname_r (const char * __name,
|
|
||||||
struct hostent *__result, char *__buffer,
|
|
||||||
int __buflen, int *__h_errnop);
|
|
||||||
struct hostent *gethostent_r (struct hostent *__result,
|
|
||||||
char *__buffer, int __buflen, int *__h_errnop);
|
|
||||||
struct netent *getnetbyaddr_r (long __net, int __type,
|
|
||||||
struct netent *__result, char *__buffer,
|
|
||||||
int __buflen);
|
|
||||||
struct netent *getnetbyname_r (const char * __name,
|
|
||||||
struct netent *__result, char *__buffer,
|
|
||||||
int __buflen);
|
|
||||||
struct netent *getnetent_r (struct netent *__result,
|
|
||||||
char *__buffer, int __buflen);
|
|
||||||
struct protoent *getprotobyname_r (const char * __name,
|
|
||||||
struct protoent *__result, char *__buffer,
|
|
||||||
int __buflen);
|
|
||||||
struct protoent *getprotobynumber_r (int __proto,
|
|
||||||
struct protoent *__result, char *__buffer,
|
|
||||||
int __buflen);
|
|
||||||
struct protoent *getprotoent_r (struct protoent *__result,
|
|
||||||
char *__buffer, int __buflen);
|
|
||||||
struct servent *getservbyname_r (const char * __name,
|
|
||||||
const char *__proto, struct servent *__result,
|
|
||||||
char *__buffer, int __buflen);
|
|
||||||
struct servent *getservbyport_r (int __port,
|
|
||||||
const char *__proto, struct servent *__result,
|
|
||||||
char *__buffer, int __buflen);
|
|
||||||
struct servent *getservent_r (struct servent *__result,
|
|
||||||
char *__buffer, int __buflen);
|
|
||||||
|
|
||||||
int *__h_errno_location (void);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* !_NETDB_H_ */
|
|
||||||
@@ -1,105 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1989 The Regents of the University of California.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by the University of
|
|
||||||
* California, Berkeley and its contributors.
|
|
||||||
* 4. Neither the name of the University nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* @(#)paths.h 5.15 (Berkeley) 5/29/91
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _PATHS_H_
|
|
||||||
#define _PATHS_H_
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
#define __PATH_ETC_INET "/usr/etc/inet"
|
|
||||||
#else
|
|
||||||
#define __PATH_ETC_INET "/etc"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Default search path. */
|
|
||||||
#define _PATH_DEFPATH "/usr/local/bin:/usr/bin:/bin:."
|
|
||||||
#define _PATH_DEFPATH_ROOT "/sbin:/bin:/usr/sbin:/usr/bin"
|
|
||||||
|
|
||||||
#define _PATH_BSHELL "/bin/sh"
|
|
||||||
#define _PATH_CONSOLE "/dev/console"
|
|
||||||
#define _PATH_CSHELL "/bin/csh"
|
|
||||||
#define _PATH_DEVDB "/var/run/dev.db"
|
|
||||||
#define _PATH_DEVNULL "/dev/null"
|
|
||||||
#define _PATH_DRUM "/dev/drum"
|
|
||||||
#define _PATH_HEQUIV __PATH_ETC_INET"/hosts.equiv"
|
|
||||||
#define _PATH_KMEM "/dev/kmem"
|
|
||||||
#define _PATH_MAILDIR "/var/spool/mail"
|
|
||||||
#define _PATH_MAN "/usr/man"
|
|
||||||
#define _PATH_MEM "/dev/mem"
|
|
||||||
#define _PATH_LOGIN "/bin/login"
|
|
||||||
#define _PATH_NOLOGIN "/etc/nologin"
|
|
||||||
#define _PATH_SENDMAIL "/usr/sbin/sendmail"
|
|
||||||
#define _PATH_SHELLS "/etc/shells"
|
|
||||||
#define _PATH_TTY "/dev/tty"
|
|
||||||
#define _PATH_UNIX "/vmlinux"
|
|
||||||
#define _PATH_VI "/usr/bin/vi"
|
|
||||||
|
|
||||||
/* Provide trailing slash, since mostly used for building pathnames. */
|
|
||||||
#define _PATH_DEV "/dev/"
|
|
||||||
#define _PATH_TMP "/tmp/"
|
|
||||||
#define _PATH_VARRUN "/var/run/"
|
|
||||||
#define _PATH_VARTMP "/var/tmp/"
|
|
||||||
|
|
||||||
#define _PATH_KLOG "/proc/kmsg"
|
|
||||||
#define _PATH_LOGCONF __PATH_ETC_INET"/syslog.conf"
|
|
||||||
#if 0
|
|
||||||
#define _PATH_LOGPID __PATH_ETC_INET"/syslog.pid"
|
|
||||||
#else
|
|
||||||
#define _PATH_LOGPID "/var/run/syslog.pid"
|
|
||||||
#endif
|
|
||||||
#define _PATH_LOG "/dev/log"
|
|
||||||
#define _PATH_CONSOLE "/dev/console"
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
#define _PATH_UTMP "/var/adm/utmp"
|
|
||||||
#define _PATH_WTMP "/var/adm/wtmp"
|
|
||||||
#define _PATH_LASTLOG "/var/adm/lastlog"
|
|
||||||
#else
|
|
||||||
#define _PATH_UTMP "/var/run/utmp"
|
|
||||||
#define _PATH_WTMP "/var/log/wtmp"
|
|
||||||
#define _PATH_LASTLOG "/var/log/lastlog"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define _PATH_LOCALE "/usr/lib/locale"
|
|
||||||
|
|
||||||
#define _PATH_RWHODIR "/var/spool/rwho"
|
|
||||||
|
|
||||||
#if _MIT_POSIX_THREADS
|
|
||||||
/* For the MIT pthreads */
|
|
||||||
#define _PATH_PTY "/dev/"
|
|
||||||
#define _PATH_TZDIR "/usr/lib/zoneinfo"
|
|
||||||
#define _PATH_TZFILE "/usr/lib/zoneinfo/localtime"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* !_PATHS_H_ */
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 1999 WIDE Project.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. Neither the name of the project nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
struct sockaddr_storage {
|
|
||||||
#ifdef HAVE_SOCKADDR_SA_LEN
|
|
||||||
u_int8_t __ss_len;
|
|
||||||
u_int8_t __ss_family;
|
|
||||||
u_int8_t fill[126];
|
|
||||||
#else
|
|
||||||
u_int8_t __ss_family;
|
|
||||||
u_int8_t fill[127];
|
|
||||||
#endif /* HAVE_SOCKADDR_SA_LEN */
|
|
||||||
};
|
|
||||||
@@ -1,168 +0,0 @@
|
|||||||
# Microsoft Developer Studio Project File - Name="libpcap" - Package Owner=<4>
|
|
||||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
|
||||||
# ** DO NOT EDIT **
|
|
||||||
|
|
||||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
|
||||||
|
|
||||||
CFG=libpcap - Win32 Debug
|
|
||||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
|
||||||
!MESSAGE use the Export Makefile command and run
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "libpcap.mak".
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE You can specify a configuration when running NMAKE
|
|
||||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "libpcap.mak" CFG="libpcap - Win32 Debug"
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE Possible choices for configuration are:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE "libpcap - Win32 Release" (based on "Win32 (x86) Static Library")
|
|
||||||
!MESSAGE "libpcap - Win32 Debug" (based on "Win32 (x86) Static Library")
|
|
||||||
!MESSAGE
|
|
||||||
|
|
||||||
# Begin Project
|
|
||||||
# PROP AllowPerConfigDependencies 0
|
|
||||||
# PROP Scc_ProjName ""
|
|
||||||
# PROP Scc_LocalPath ""
|
|
||||||
CPP=cl.exe
|
|
||||||
RSC=rc.exe
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "libpcap - Win32 Release"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 0
|
|
||||||
# PROP BASE Output_Dir "Release"
|
|
||||||
# PROP BASE Intermediate_Dir "Release"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 0
|
|
||||||
# PROP Output_Dir "Release"
|
|
||||||
# PROP Intermediate_Dir "Release"
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
|
|
||||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../../" /I "../../lbl/" /I "../../bpf/" /I "../include/" /I "../../../../common" /I "../../../../dag/include" /I "../../../../dag/drv/windows" /D "NDEBUG" /D "YY_NEVER_INTERACTIVE" /D yylval=pcap_lval /D "_USRDLL" /D "LIBPCAP_EXPORTS" /D "HAVE_STRERROR" /D "__STDC__" /D "INET6" /D "_WINDOWS" /D "_MBCS" /D SIZEOF_CHAR=1 /D SIZEOF_SHORT=2 /D SIZEOF_INT=4 /D "HAVE_ADDRINFO" /D "WIN32" /D _U_= /D "HAVE_SNPRINTF" /D "HAVE_VSNPRINTF" /YX /FD /c
|
|
||||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
|
||||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
LIB32=link.exe -lib
|
|
||||||
# ADD BASE LIB32 /nologo
|
|
||||||
# ADD LIB32 /nologo
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "libpcap - Win32 Debug"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 1
|
|
||||||
# PROP BASE Output_Dir "Debug"
|
|
||||||
# PROP BASE Intermediate_Dir "Debug"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 1
|
|
||||||
# PROP Output_Dir "Debug"
|
|
||||||
# PROP Intermediate_Dir "Debug"
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
|
||||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../" /I "../../lbl/" /I "../../bpf/" /I "../include/" /I "../../../../common" /I "../../../../dag/include" /I "../../../../dag/drv/windows" /D "_DEBUG" /D "YY_NEVER_INTERACTIVE" /D yylval=pcap_lval /D "_USRDLL" /D "LIBPCAP_EXPORTS" /D "HAVE_STRERROR" /D "__STDC__" /D "INET6" /D "_WINDOWS" /D "_MBCS" /D SIZEOF_CHAR=1 /D SIZEOF_SHORT=2 /D SIZEOF_INT=4 /D "HAVE_ADDRINFO" /D "WIN32" /D _U_= /D "HAVE_SNPRINTF" /D "HAVE_VSNPRINTF" /YX /FD /GZ /c
|
|
||||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
|
||||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
LIB32=link.exe -lib
|
|
||||||
# ADD BASE LIB32 /nologo
|
|
||||||
# ADD LIB32 /nologo
|
|
||||||
|
|
||||||
!ENDIF
|
|
||||||
|
|
||||||
# Begin Target
|
|
||||||
|
|
||||||
# Name "libpcap - Win32 Release"
|
|
||||||
# Name "libpcap - Win32 Debug"
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\bpf_dump.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\bpf\net\bpf_filter.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\bpf_image.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\etherent.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE="..\..\fad-win32.c"
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\Src\ffs.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\gencode.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\Src\getnetbynm.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\Src\getnetent.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\Src\getservent.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\grammar.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\inet.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\Src\inet_aton.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\Src\inet_net.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\Src\inet_pton.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\nametoaddr.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\optimize.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE="..\..\Pcap-win32.c"
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\pcap.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\savefile.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\scanner.c
|
|
||||||
# End Source File
|
|
||||||
# End Target
|
|
||||||
# End Project
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
|
||||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
Project: "libpcap"=".\libpcap.dsp" - Package Owner=<4>
|
|
||||||
|
|
||||||
Package=<5>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
Package=<4>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
Global:
|
|
||||||
|
|
||||||
Package=<5>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
Package=<3>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 1990, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by the University of
|
|
||||||
* California, Berkeley and its contributors.
|
|
||||||
* 4. Neither the name of the University nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(LIBC_SCCS) && !defined(lint)
|
|
||||||
static char sccsid[] = "@(#)ffs.c 8.1 (Berkeley) 6/4/93";
|
|
||||||
#endif /* LIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ffs -- vax ffs instruction
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
ffs(mask)
|
|
||||||
register int mask;
|
|
||||||
{
|
|
||||||
register int bit;
|
|
||||||
|
|
||||||
if (mask == 0)
|
|
||||||
return(0);
|
|
||||||
for (bit = 1; !(mask & 1); bit++)
|
|
||||||
mask >>= 1;
|
|
||||||
return(bit);
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,44 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1983 Regents of the University of California.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms are permitted
|
|
||||||
* provided that the above copyright notice and this paragraph are
|
|
||||||
* duplicated in all such forms and that any documentation,
|
|
||||||
* advertising materials, and other materials related to such
|
|
||||||
* distribution and use acknowledge that the software was developed
|
|
||||||
* by the University of California, Berkeley. The name of the
|
|
||||||
* University may not be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(LIBC_SCCS) && !defined(lint)
|
|
||||||
static char sccsid[] = "@(#)getnetbyname.c 5.5 (Berkeley) 6/27/88";
|
|
||||||
#endif /* LIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
#include "inetprivate.h"
|
|
||||||
|
|
||||||
extern int _net_stayopen;
|
|
||||||
|
|
||||||
struct netent *
|
|
||||||
getnetbyname(const char *name)
|
|
||||||
{
|
|
||||||
register struct netent *p;
|
|
||||||
register char **cp;
|
|
||||||
|
|
||||||
setnetent(_net_stayopen);
|
|
||||||
while (p = getnetent()) {
|
|
||||||
if (strcmp(p->n_name, name) == 0)
|
|
||||||
break;
|
|
||||||
for (cp = p->n_aliases; *cp != 0; cp++)
|
|
||||||
if (strcmp(*cp, name) == 0)
|
|
||||||
goto found;
|
|
||||||
}
|
|
||||||
found:
|
|
||||||
if (!_net_stayopen)
|
|
||||||
endnetent();
|
|
||||||
return (p);
|
|
||||||
}
|
|
||||||
@@ -1,119 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1983 Regents of the University of California.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms are permitted
|
|
||||||
* provided that the above copyright notice and this paragraph are
|
|
||||||
* duplicated in all such forms and that any documentation,
|
|
||||||
* advertising materials, and other materials related to such
|
|
||||||
* distribution and use acknowledge that the software was developed
|
|
||||||
* by the University of California, Berkeley. The name of the
|
|
||||||
* University may not be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(LIBC_SCCS) && !defined(lint)
|
|
||||||
static char sccsid[] = "@(#)getnetent.c 5.5 (Berkeley) 6/27/88";
|
|
||||||
#endif /* LIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
#include "inetprivate.h"
|
|
||||||
|
|
||||||
#define MAXALIASES 35
|
|
||||||
|
|
||||||
static char NETDB[] = _PATH_NETWORKS;
|
|
||||||
static FILE *netf = NULL;
|
|
||||||
static char line[BUFSIZ+1];
|
|
||||||
static struct netent net;
|
|
||||||
static char *net_aliases[MAXALIASES];
|
|
||||||
static char *any(char *, char *);
|
|
||||||
|
|
||||||
int _net_stayopen;
|
|
||||||
extern u_int32_t inet_network(const char *cp);
|
|
||||||
|
|
||||||
void
|
|
||||||
setnetent(f)
|
|
||||||
int f;
|
|
||||||
{
|
|
||||||
if (netf == NULL)
|
|
||||||
netf = fopen(NETDB, "r" );
|
|
||||||
else
|
|
||||||
rewind(netf);
|
|
||||||
_net_stayopen |= f;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
endnetent()
|
|
||||||
{
|
|
||||||
if (netf) {
|
|
||||||
fclose(netf);
|
|
||||||
netf = NULL;
|
|
||||||
}
|
|
||||||
_net_stayopen = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct netent *
|
|
||||||
getnetent()
|
|
||||||
{
|
|
||||||
char *p;
|
|
||||||
register char *cp, **q;
|
|
||||||
|
|
||||||
if (netf == NULL && (netf = fopen(NETDB, "r" )) == NULL)
|
|
||||||
return (NULL);
|
|
||||||
again:
|
|
||||||
p = fgets(line, BUFSIZ, netf);
|
|
||||||
if (p == NULL)
|
|
||||||
return (NULL);
|
|
||||||
if (*p == '#')
|
|
||||||
goto again;
|
|
||||||
cp = any(p, "#\n");
|
|
||||||
if (cp == NULL)
|
|
||||||
goto again;
|
|
||||||
*cp = '\0';
|
|
||||||
net.n_name = p;
|
|
||||||
cp = any(p, " \t");
|
|
||||||
if (cp == NULL)
|
|
||||||
goto again;
|
|
||||||
*cp++ = '\0';
|
|
||||||
while (*cp == ' ' || *cp == '\t')
|
|
||||||
cp++;
|
|
||||||
p = any(cp, " \t");
|
|
||||||
if (p != NULL)
|
|
||||||
*p++ = '\0';
|
|
||||||
net.n_net = inet_network(cp);
|
|
||||||
net.n_addrtype = AF_INET;
|
|
||||||
q = net.n_aliases = net_aliases;
|
|
||||||
if (p != NULL)
|
|
||||||
cp = p;
|
|
||||||
while (cp && *cp) {
|
|
||||||
if (*cp == ' ' || *cp == '\t') {
|
|
||||||
cp++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (q < &net_aliases[MAXALIASES - 1])
|
|
||||||
*q++ = cp;
|
|
||||||
cp = any(cp, " \t");
|
|
||||||
if (cp != NULL)
|
|
||||||
*cp++ = '\0';
|
|
||||||
}
|
|
||||||
*q = NULL;
|
|
||||||
return (&net);
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *
|
|
||||||
any(cp, match)
|
|
||||||
register char *cp;
|
|
||||||
char *match;
|
|
||||||
{
|
|
||||||
register char *mp, c;
|
|
||||||
|
|
||||||
while (c = *cp) {
|
|
||||||
for (mp = match; *mp; mp++)
|
|
||||||
if (*mp == c)
|
|
||||||
return (cp);
|
|
||||||
cp++;
|
|
||||||
}
|
|
||||||
return ((char *)0);
|
|
||||||
}
|
|
||||||
@@ -1,121 +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>
|
|
||||||
|
|
||||||
int opterr = 1, /* if error message should be printed */
|
|
||||||
optind = 1, /* index into parent argv vector */
|
|
||||||
optopt, /* character checked for validity */
|
|
||||||
optreset; /* reset getopt */
|
|
||||||
char *optarg; /* argument associated with option */
|
|
||||||
|
|
||||||
#define BADCH (int)'?'
|
|
||||||
#define BADARG (int)':'
|
|
||||||
#define EMSG ""
|
|
||||||
|
|
||||||
/*
|
|
||||||
* getopt --
|
|
||||||
* Parse argc/argv argument vector.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
getopt(nargc, nargv, ostr)
|
|
||||||
int nargc;
|
|
||||||
char * const *nargv;
|
|
||||||
const char *ostr;
|
|
||||||
{
|
|
||||||
#ifdef WIN32
|
|
||||||
char *__progname="windump";
|
|
||||||
#else
|
|
||||||
extern char *__progname;
|
|
||||||
#endif
|
|
||||||
static char *place = EMSG; /* option letter processing */
|
|
||||||
char *oli; /* option letter list index */
|
|
||||||
|
|
||||||
if (optreset || !*place) { /* update scanning pointer */
|
|
||||||
optreset = 0;
|
|
||||||
if (optind >= nargc || *(place = nargv[optind]) != '-') {
|
|
||||||
place = EMSG;
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
if (place[1] && *++place == '-') { /* found "--" */
|
|
||||||
++optind;
|
|
||||||
place = EMSG;
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
} /* option letter okay? */
|
|
||||||
if ((optopt = (int)*place++) == (int)':' ||
|
|
||||||
!(oli = strchr(ostr, optopt))) {
|
|
||||||
/*
|
|
||||||
* if the user didn't specify '-' as an option,
|
|
||||||
* assume it means -1.
|
|
||||||
*/
|
|
||||||
if (optopt == (int)'-')
|
|
||||||
return (-1);
|
|
||||||
if (!*place)
|
|
||||||
++optind;
|
|
||||||
if (opterr && *ostr != ':')
|
|
||||||
(void)fprintf(stderr,
|
|
||||||
"%s: illegal option -- %c\n", __progname, optopt);
|
|
||||||
return (BADCH);
|
|
||||||
}
|
|
||||||
if (*++oli != ':') { /* don't need argument */
|
|
||||||
optarg = NULL;
|
|
||||||
if (!*place)
|
|
||||||
++optind;
|
|
||||||
}
|
|
||||||
else { /* need an argument */
|
|
||||||
if (*place) /* no white space */
|
|
||||||
optarg = place;
|
|
||||||
else if (nargc <= ++optind) { /* no arg */
|
|
||||||
place = EMSG;
|
|
||||||
if (*ostr == ':')
|
|
||||||
return (BADARG);
|
|
||||||
if (opterr)
|
|
||||||
(void)fprintf(stderr,
|
|
||||||
"%s: option requires an argument -- %c\n",
|
|
||||||
__progname, optopt);
|
|
||||||
return (BADCH);
|
|
||||||
}
|
|
||||||
else /* white space */
|
|
||||||
optarg = nargv[optind];
|
|
||||||
place = EMSG;
|
|
||||||
++optind;
|
|
||||||
}
|
|
||||||
return (optopt); /* dump back option letter */
|
|
||||||
}
|
|
||||||
@@ -1,125 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1983, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by the University of
|
|
||||||
* California, Berkeley and its contributors.
|
|
||||||
* 4. Neither the name of the University nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(LIBC_SCCS) && !defined(lint)
|
|
||||||
static char sccsid[] = "@(#)getservent.c 8.1 (Berkeley) 6/4/93";
|
|
||||||
#endif /* LIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <net/netdb.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <arpa/nameser.h>
|
|
||||||
|
|
||||||
#define MAXALIASES 35
|
|
||||||
|
|
||||||
static char SERVDB[] = _PATH_SERVICES;
|
|
||||||
static FILE *servf = NULL;
|
|
||||||
static char line[BUFSIZ+1];
|
|
||||||
static struct servent serv;
|
|
||||||
static char *serv_aliases[MAXALIASES];
|
|
||||||
int _serv_stayopen;
|
|
||||||
|
|
||||||
void
|
|
||||||
setservent(f)
|
|
||||||
int f;
|
|
||||||
{
|
|
||||||
if (servf == NULL)
|
|
||||||
servf = fopen(SERVDB, "r" );
|
|
||||||
else
|
|
||||||
rewind(servf);
|
|
||||||
_serv_stayopen |= f;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
endservent()
|
|
||||||
{
|
|
||||||
if (servf) {
|
|
||||||
fclose(servf);
|
|
||||||
servf = NULL;
|
|
||||||
}
|
|
||||||
_serv_stayopen = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct servent *
|
|
||||||
getservent()
|
|
||||||
{
|
|
||||||
char *p;
|
|
||||||
register char *cp, **q;
|
|
||||||
|
|
||||||
if (servf == NULL && (servf = fopen(SERVDB, "r" )) == NULL)
|
|
||||||
return (NULL);
|
|
||||||
again:
|
|
||||||
if ((p = fgets(line, BUFSIZ, servf)) == NULL)
|
|
||||||
return (NULL);
|
|
||||||
if (*p == '#')
|
|
||||||
goto again;
|
|
||||||
cp = strpbrk(p, "#\n");
|
|
||||||
if (cp == NULL)
|
|
||||||
goto again;
|
|
||||||
*cp = '\0';
|
|
||||||
serv.s_name = p;
|
|
||||||
p = strpbrk(p, " \t");
|
|
||||||
if (p == NULL)
|
|
||||||
goto again;
|
|
||||||
*p++ = '\0';
|
|
||||||
while (*p == ' ' || *p == '\t')
|
|
||||||
p++;
|
|
||||||
cp = strpbrk(p, ",/");
|
|
||||||
if (cp == NULL)
|
|
||||||
goto again;
|
|
||||||
*cp++ = '\0';
|
|
||||||
serv.s_port = htons((u_short)atoi(p));
|
|
||||||
serv.s_proto = cp;
|
|
||||||
q = serv.s_aliases = serv_aliases;
|
|
||||||
cp = strpbrk(cp, " \t");
|
|
||||||
if (cp != NULL)
|
|
||||||
*cp++ = '\0';
|
|
||||||
while (cp && *cp) {
|
|
||||||
if (*cp == ' ' || *cp == '\t') {
|
|
||||||
cp++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (q < &serv_aliases[MAXALIASES - 1])
|
|
||||||
*q++ = cp;
|
|
||||||
cp = strpbrk(cp, " \t");
|
|
||||||
if (cp != NULL)
|
|
||||||
*cp++ = '\0';
|
|
||||||
}
|
|
||||||
*q = NULL;
|
|
||||||
return (&serv);
|
|
||||||
}
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1995, 1996, 1997 Kungliga Tekniska H<>gskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by the Kungliga Tekniska
|
|
||||||
* H<>gskolan and its contributors.
|
|
||||||
*
|
|
||||||
* 4. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* $Id$ */
|
|
||||||
|
|
||||||
#ifndef lint
|
|
||||||
static const char rcsid[] _U_ =
|
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/Win32/Src/inet_aton.c,v 1.2 2003/11/15 23:24:06 guy Exp $";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <pcap-stdinc.h>
|
|
||||||
|
|
||||||
/* Minimal implementation of inet_aton.
|
|
||||||
* Cannot distinguish between failure and a local broadcast address. */
|
|
||||||
|
|
||||||
#ifndef INADDR_NONE
|
|
||||||
#define INADDR_NONE 0xffffffff
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int
|
|
||||||
inet_aton(const char *cp, struct in_addr *addr)
|
|
||||||
{
|
|
||||||
addr->s_addr = inet_addr(cp);
|
|
||||||
return (addr->s_addr == INADDR_NONE) ? 0 : 1;
|
|
||||||
}
|
|
||||||
@@ -1,101 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1983, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by the University of
|
|
||||||
* California, Berkeley and its contributors.
|
|
||||||
* 4. Neither the name of the University nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(LIBC_SCCS) && !defined(lint)
|
|
||||||
static char sccsid[] = "@(#)inet_network.c 8.1 (Berkeley) 6/4/93";
|
|
||||||
#endif /* LIBC_SCCS and not lint */
|
|
||||||
|
|
||||||
#include "inetprivate.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Internet network address interpretation routine.
|
|
||||||
* The library routines call this routine to interpret
|
|
||||||
* network numbers.
|
|
||||||
*/
|
|
||||||
u_int32_t
|
|
||||||
inet_network(const char *cp)
|
|
||||||
{
|
|
||||||
register u_long val, base, n;
|
|
||||||
register char c;
|
|
||||||
u_long parts[4], *pp = parts;
|
|
||||||
register int i;
|
|
||||||
|
|
||||||
again:
|
|
||||||
/*
|
|
||||||
* Collect number up to ``.''.
|
|
||||||
* Values are specified as for C:
|
|
||||||
* 0x=hex, 0=octal, other=decimal.
|
|
||||||
*/
|
|
||||||
val = 0; base = 10;
|
|
||||||
/*
|
|
||||||
* The 4.4BSD version of this file also accepts 'x__' as a hexa
|
|
||||||
* number. I don't think this is correct. -- Uli
|
|
||||||
*/
|
|
||||||
if (*cp == '0') {
|
|
||||||
if (*++cp == 'x' || *cp == 'X')
|
|
||||||
base = 16, cp++;
|
|
||||||
else
|
|
||||||
base = 8;
|
|
||||||
}
|
|
||||||
while ((c = *cp)) {
|
|
||||||
if (isdigit(c)) {
|
|
||||||
val = (val * base) + (c - '0');
|
|
||||||
cp++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (base == 16 && isxdigit(c)) {
|
|
||||||
val = (val << 4) + (c + 10 - (islower(c) ? 'a' : 'A'));
|
|
||||||
cp++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (*cp == '.') {
|
|
||||||
if (pp >= parts + 4)
|
|
||||||
return (INADDR_NONE);
|
|
||||||
*pp++ = val, cp++;
|
|
||||||
goto again;
|
|
||||||
}
|
|
||||||
if (*cp && !isspace(*cp))
|
|
||||||
return (INADDR_NONE);
|
|
||||||
*pp++ = val;
|
|
||||||
n = pp - parts;
|
|
||||||
if (n > 4)
|
|
||||||
return (INADDR_NONE);
|
|
||||||
for (val = 0, i = 0; i < (int)n; i++) {
|
|
||||||
val <<= 8;
|
|
||||||
val |= parts[i] & 0xff;
|
|
||||||
}
|
|
||||||
return (val);
|
|
||||||
}
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1999 Kungliga Tekniska H<>gskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by the Kungliga Tekniska
|
|
||||||
* H<>gskolan and its contributors.
|
|
||||||
*
|
|
||||||
* 4. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* $Id$ */
|
|
||||||
|
|
||||||
#ifndef lint
|
|
||||||
static const char rcsid[] _U_ =
|
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/Win32/Src/inet_pton.c,v 1.2 2003/11/15 23:24:06 guy Exp $";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
#ifndef EAFNOSUPPORT
|
|
||||||
#define EAFNOSUPPORT 97 /* not present in errno.h provided with VC */
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
|
||||||
int* _errno();
|
|
||||||
#define errno (*_errno())
|
|
||||||
#endif /* __MINGW32__ */
|
|
||||||
|
|
||||||
#include <pcap-stdinc.h>
|
|
||||||
|
|
||||||
int
|
|
||||||
inet_pton(int af, const char *src, void *dst)
|
|
||||||
{
|
|
||||||
if (af != AF_INET) {
|
|
||||||
errno = EAFNOSUPPORT;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return inet_aton (src, dst);
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
/* Long story short: aclocal.m4 depends on autoconf 2.13
|
|
||||||
* implementation details wrt "const"; newer versions
|
|
||||||
* have different implementation details so for now we
|
|
||||||
* put "const" here. This may cause duplicate definitions
|
|
||||||
* in config.h but that should be OK since they're the same.
|
|
||||||
*/
|
|
||||||
#undef const
|
|
||||||
900
libpcap/aclocal.m4
vendored
900
libpcap/aclocal.m4
vendored
@@ -1,900 +0,0 @@
|
|||||||
dnl @(#) $Header$ (LBL)
|
|
||||||
dnl
|
|
||||||
dnl Copyright (c) 1995, 1996, 1997, 1998
|
|
||||||
dnl The Regents of the University of California. All rights reserved.
|
|
||||||
dnl
|
|
||||||
dnl Redistribution and use in source and binary forms, with or without
|
|
||||||
dnl modification, are permitted provided that: (1) source code distributions
|
|
||||||
dnl retain the above copyright notice and this paragraph in its entirety, (2)
|
|
||||||
dnl distributions including binary code include the above copyright notice and
|
|
||||||
dnl this paragraph in its entirety in the documentation or other materials
|
|
||||||
dnl provided with the distribution, and (3) all advertising materials mentioning
|
|
||||||
dnl features or use of this software display the following acknowledgement:
|
|
||||||
dnl ``This product includes software developed by the University of California,
|
|
||||||
dnl Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
|
|
||||||
dnl the University nor the names of its contributors may be used to endorse
|
|
||||||
dnl or promote products derived from this software without specific prior
|
|
||||||
dnl written permission.
|
|
||||||
dnl THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
|
||||||
dnl WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
|
||||||
dnl MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
dnl
|
|
||||||
dnl LBL autoconf macros
|
|
||||||
dnl
|
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl Determine which compiler we're using (cc or gcc)
|
|
||||||
dnl If using gcc, determine the version number
|
|
||||||
dnl If using cc, require that it support ansi prototypes
|
|
||||||
dnl If using gcc, use -O2 (otherwise use -O)
|
|
||||||
dnl If using cc, explicitly specify /usr/local/include
|
|
||||||
dnl
|
|
||||||
dnl usage:
|
|
||||||
dnl
|
|
||||||
dnl AC_LBL_C_INIT(copt, incls)
|
|
||||||
dnl
|
|
||||||
dnl results:
|
|
||||||
dnl
|
|
||||||
dnl $1 (copt set)
|
|
||||||
dnl $2 (incls set)
|
|
||||||
dnl CC
|
|
||||||
dnl LDFLAGS
|
|
||||||
dnl ac_cv_lbl_gcc_vers
|
|
||||||
dnl LBL_CFLAGS
|
|
||||||
dnl
|
|
||||||
AC_DEFUN(AC_LBL_C_INIT,
|
|
||||||
[AC_PREREQ(2.12)
|
|
||||||
AC_BEFORE([$0], [AC_PROG_CC])
|
|
||||||
AC_BEFORE([$0], [AC_LBL_FIXINCLUDES])
|
|
||||||
AC_BEFORE([$0], [AC_LBL_DEVEL])
|
|
||||||
AC_ARG_WITH(gcc, [ --without-gcc don't use gcc])
|
|
||||||
$1="-O"
|
|
||||||
$2=""
|
|
||||||
if test "${srcdir}" != "." ; then
|
|
||||||
$2="-I\$(srcdir)"
|
|
||||||
fi
|
|
||||||
if test "${CFLAGS+set}" = set; then
|
|
||||||
LBL_CFLAGS="$CFLAGS"
|
|
||||||
fi
|
|
||||||
if test -z "$CC" ; then
|
|
||||||
case "$target_os" in
|
|
||||||
|
|
||||||
bsdi*)
|
|
||||||
AC_CHECK_PROG(SHLICC2, shlicc2, yes, no)
|
|
||||||
if test $SHLICC2 = yes ; then
|
|
||||||
CC=shlicc2
|
|
||||||
export CC
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
if test -z "$CC" -a "$with_gcc" = no ; then
|
|
||||||
CC=cc
|
|
||||||
export CC
|
|
||||||
fi
|
|
||||||
AC_PROG_CC
|
|
||||||
if test "$GCC" = yes ; then
|
|
||||||
if test "$SHLICC2" = yes ; then
|
|
||||||
ac_cv_lbl_gcc_vers=2
|
|
||||||
$1="-g -O2"
|
|
||||||
else
|
|
||||||
AC_MSG_CHECKING(gcc version)
|
|
||||||
AC_CACHE_VAL(ac_cv_lbl_gcc_vers,
|
|
||||||
ac_cv_lbl_gcc_vers=`$CC -v 2>&1 | \
|
|
||||||
sed -e '/^gcc version /!d' \
|
|
||||||
-e 's/^gcc version //' \
|
|
||||||
-e 's/ .*//' -e 's/^[[[^0-9]]]*//' \
|
|
||||||
-e 's/\..*//'`)
|
|
||||||
AC_MSG_RESULT($ac_cv_lbl_gcc_vers)
|
|
||||||
if test $ac_cv_lbl_gcc_vers -gt 1 ; then
|
|
||||||
$1="-g -O2"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
AC_MSG_CHECKING(that $CC handles ansi prototypes)
|
|
||||||
AC_CACHE_VAL(ac_cv_lbl_cc_ansi_prototypes,
|
|
||||||
AC_TRY_COMPILE(
|
|
||||||
[#include <sys/types.h>],
|
|
||||||
[int frob(int, char *)],
|
|
||||||
ac_cv_lbl_cc_ansi_prototypes=yes,
|
|
||||||
ac_cv_lbl_cc_ansi_prototypes=no))
|
|
||||||
AC_MSG_RESULT($ac_cv_lbl_cc_ansi_prototypes)
|
|
||||||
if test $ac_cv_lbl_cc_ansi_prototypes = no ; then
|
|
||||||
case "$target_os" in
|
|
||||||
|
|
||||||
hpux*)
|
|
||||||
AC_MSG_CHECKING(for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE))
|
|
||||||
savedcflags="$CFLAGS"
|
|
||||||
CFLAGS="-Aa -D_HPUX_SOURCE $CFLAGS"
|
|
||||||
AC_CACHE_VAL(ac_cv_lbl_cc_hpux_cc_aa,
|
|
||||||
AC_TRY_COMPILE(
|
|
||||||
[#include <sys/types.h>],
|
|
||||||
[int frob(int, char *)],
|
|
||||||
ac_cv_lbl_cc_hpux_cc_aa=yes,
|
|
||||||
ac_cv_lbl_cc_hpux_cc_aa=no))
|
|
||||||
AC_MSG_RESULT($ac_cv_lbl_cc_hpux_cc_aa)
|
|
||||||
if test $ac_cv_lbl_cc_hpux_cc_aa = no ; then
|
|
||||||
AC_MSG_ERROR(see the INSTALL doc for more info)
|
|
||||||
fi
|
|
||||||
CFLAGS="$savedcflags"
|
|
||||||
V_CCOPT="-Aa $V_CCOPT"
|
|
||||||
AC_DEFINE(_HPUX_SOURCE,1,[needed on HP-UX])
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
AC_MSG_ERROR(see the INSTALL doc for more info)
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
$2="$$2 -I/usr/local/include"
|
|
||||||
LDFLAGS="$LDFLAGS -L/usr/local/lib"
|
|
||||||
|
|
||||||
case "$target_os" in
|
|
||||||
|
|
||||||
irix*)
|
|
||||||
V_CCOPT="$V_CCOPT -xansi -signed -g3"
|
|
||||||
;;
|
|
||||||
|
|
||||||
osf*)
|
|
||||||
V_CCOPT="$V_CCOPT -std1 -g3"
|
|
||||||
;;
|
|
||||||
|
|
||||||
ultrix*)
|
|
||||||
AC_MSG_CHECKING(that Ultrix $CC hacks const in prototypes)
|
|
||||||
AC_CACHE_VAL(ac_cv_lbl_cc_const_proto,
|
|
||||||
AC_TRY_COMPILE(
|
|
||||||
[#include <sys/types.h>],
|
|
||||||
[struct a { int b; };
|
|
||||||
void c(const struct a *)],
|
|
||||||
ac_cv_lbl_cc_const_proto=yes,
|
|
||||||
ac_cv_lbl_cc_const_proto=no))
|
|
||||||
AC_MSG_RESULT($ac_cv_lbl_cc_const_proto)
|
|
||||||
if test $ac_cv_lbl_cc_const_proto = no ; then
|
|
||||||
AC_DEFINE(const,)
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
])
|
|
||||||
|
|
||||||
#
|
|
||||||
# Try compiling a sample of the type of code that appears in
|
|
||||||
# gencode.c with "inline", "__inline__", and "__inline".
|
|
||||||
#
|
|
||||||
# Autoconf's AC_C_INLINE, at least in autoconf 2.13, isn't good enough,
|
|
||||||
# as it just tests whether a function returning "int" can be inlined;
|
|
||||||
# at least some versions of HP's C compiler can inline that, but can't
|
|
||||||
# inline a function that returns a struct pointer.
|
|
||||||
#
|
|
||||||
# Make sure we use the V_CCOPT flags, because some of those might
|
|
||||||
# disable inlining.
|
|
||||||
#
|
|
||||||
AC_DEFUN(AC_LBL_C_INLINE,
|
|
||||||
[AC_MSG_CHECKING(for inline)
|
|
||||||
save_CFLAGS="$CFLAGS"
|
|
||||||
CFLAGS="$V_CCOPT"
|
|
||||||
AC_CACHE_VAL(ac_cv_lbl_inline, [
|
|
||||||
ac_cv_lbl_inline=""
|
|
||||||
ac_lbl_cc_inline=no
|
|
||||||
for ac_lbl_inline in inline __inline__ __inline
|
|
||||||
do
|
|
||||||
AC_TRY_COMPILE(
|
|
||||||
[#define inline $ac_lbl_inline
|
|
||||||
static inline struct iltest *foo(void);
|
|
||||||
struct iltest {
|
|
||||||
int iltest1;
|
|
||||||
int iltest2;
|
|
||||||
};
|
|
||||||
|
|
||||||
static inline struct iltest *
|
|
||||||
foo()
|
|
||||||
{
|
|
||||||
static struct iltest xxx;
|
|
||||||
|
|
||||||
return &xxx;
|
|
||||||
}],,ac_lbl_cc_inline=yes,)
|
|
||||||
if test "$ac_lbl_cc_inline" = yes ; then
|
|
||||||
break;
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if test "$ac_lbl_cc_inline" = yes ; then
|
|
||||||
ac_cv_lbl_inline=$ac_lbl_inline
|
|
||||||
fi])
|
|
||||||
CFLAGS="$save_CFLAGS"
|
|
||||||
if test ! -z "$ac_cv_lbl_inline" ; then
|
|
||||||
AC_MSG_RESULT($ac_cv_lbl_inline)
|
|
||||||
else
|
|
||||||
AC_MSG_RESULT(no)
|
|
||||||
fi
|
|
||||||
AC_DEFINE_UNQUOTED(inline, $ac_cv_lbl_inline, [Define as token for inline if inlining supported])])
|
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl Use pfopen.c if available and pfopen() not in standard libraries
|
|
||||||
dnl Require libpcap
|
|
||||||
dnl Look for libpcap in ..
|
|
||||||
dnl Use the installed libpcap if there is no local version
|
|
||||||
dnl
|
|
||||||
dnl usage:
|
|
||||||
dnl
|
|
||||||
dnl AC_LBL_LIBPCAP(pcapdep, incls)
|
|
||||||
dnl
|
|
||||||
dnl results:
|
|
||||||
dnl
|
|
||||||
dnl $1 (pcapdep set)
|
|
||||||
dnl $2 (incls appended)
|
|
||||||
dnl LIBS
|
|
||||||
dnl LBL_LIBS
|
|
||||||
dnl
|
|
||||||
AC_DEFUN(AC_LBL_LIBPCAP,
|
|
||||||
[AC_REQUIRE([AC_LBL_LIBRARY_NET])
|
|
||||||
dnl
|
|
||||||
dnl save a copy before locating libpcap.a
|
|
||||||
dnl
|
|
||||||
LBL_LIBS="$LIBS"
|
|
||||||
pfopen=/usr/examples/packetfilter/pfopen.c
|
|
||||||
if test -f $pfopen ; then
|
|
||||||
AC_CHECK_FUNCS(pfopen)
|
|
||||||
if test $ac_cv_func_pfopen = "no" ; then
|
|
||||||
AC_MSG_RESULT(Using $pfopen)
|
|
||||||
LIBS="$LIBS $pfopen"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
AC_MSG_CHECKING(for local pcap library)
|
|
||||||
libpcap=FAIL
|
|
||||||
lastdir=FAIL
|
|
||||||
places=`ls .. | sed -e 's,/$,,' -e 's,^,../,' | \
|
|
||||||
egrep '/libpcap-[[0-9]]*\.[[0-9]]*(\.[[0-9]]*)?([[ab]][[0-9]]*)?$'`
|
|
||||||
for dir in $places ../libpcap libpcap ; do
|
|
||||||
basedir=`echo $dir | sed -e 's/[[ab]][[0-9]]*$//'`
|
|
||||||
if test $lastdir = $basedir ; then
|
|
||||||
dnl skip alphas when an actual release is present
|
|
||||||
continue;
|
|
||||||
fi
|
|
||||||
lastdir=$dir
|
|
||||||
if test -r $dir/pcap.c ; then
|
|
||||||
libpcap=$dir/libpcap.a
|
|
||||||
d=$dir
|
|
||||||
dnl continue and select the last one that exists
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if test $libpcap = FAIL ; then
|
|
||||||
AC_MSG_RESULT(not found)
|
|
||||||
AC_CHECK_LIB(pcap, main, libpcap="-lpcap")
|
|
||||||
if test $libpcap = FAIL ; then
|
|
||||||
AC_MSG_ERROR(see the INSTALL doc for more info)
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
$1=$libpcap
|
|
||||||
$2="-I$d $$2"
|
|
||||||
AC_MSG_RESULT($libpcap)
|
|
||||||
fi
|
|
||||||
LIBS="$libpcap $LIBS"
|
|
||||||
case "$target_os" in
|
|
||||||
|
|
||||||
aix*)
|
|
||||||
pseexe="/lib/pse.exp"
|
|
||||||
AC_MSG_CHECKING(for $pseexe)
|
|
||||||
if test -f $pseexe ; then
|
|
||||||
AC_MSG_RESULT(yes)
|
|
||||||
LIBS="$LIBS -I:$pseexe"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac])
|
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl Define RETSIGTYPE and RETSIGVAL
|
|
||||||
dnl
|
|
||||||
dnl usage:
|
|
||||||
dnl
|
|
||||||
dnl AC_LBL_TYPE_SIGNAL
|
|
||||||
dnl
|
|
||||||
dnl results:
|
|
||||||
dnl
|
|
||||||
dnl RETSIGTYPE (defined)
|
|
||||||
dnl RETSIGVAL (defined)
|
|
||||||
dnl
|
|
||||||
AC_DEFUN(AC_LBL_TYPE_SIGNAL,
|
|
||||||
[AC_BEFORE([$0], [AC_LBL_LIBPCAP])
|
|
||||||
AC_TYPE_SIGNAL
|
|
||||||
if test "$ac_cv_type_signal" = void ; then
|
|
||||||
AC_DEFINE(RETSIGVAL,[],[return value of signal handlers])
|
|
||||||
else
|
|
||||||
AC_DEFINE(RETSIGVAL,(0),[return value of signal handlers])
|
|
||||||
fi
|
|
||||||
case "$target_os" in
|
|
||||||
|
|
||||||
irix*)
|
|
||||||
AC_DEFINE(_BSD_SIGNALS,1,[get BSD semantics on Irix])
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
dnl prefer sigset() to sigaction()
|
|
||||||
AC_CHECK_FUNCS(sigset)
|
|
||||||
if test $ac_cv_func_sigset = no ; then
|
|
||||||
AC_CHECK_FUNCS(sigaction)
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac])
|
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl If using gcc, make sure we have ANSI ioctl definitions
|
|
||||||
dnl
|
|
||||||
dnl usage:
|
|
||||||
dnl
|
|
||||||
dnl AC_LBL_FIXINCLUDES
|
|
||||||
dnl
|
|
||||||
AC_DEFUN(AC_LBL_FIXINCLUDES,
|
|
||||||
[if test "$GCC" = yes ; then
|
|
||||||
AC_MSG_CHECKING(for ANSI ioctl definitions)
|
|
||||||
AC_CACHE_VAL(ac_cv_lbl_gcc_fixincludes,
|
|
||||||
AC_TRY_COMPILE(
|
|
||||||
[/*
|
|
||||||
* This generates a "duplicate case value" when fixincludes
|
|
||||||
* has not be run.
|
|
||||||
*/
|
|
||||||
# include <sys/types.h>
|
|
||||||
# include <sys/time.h>
|
|
||||||
# include <sys/ioctl.h>
|
|
||||||
# ifdef HAVE_SYS_IOCCOM_H
|
|
||||||
# include <sys/ioccom.h>
|
|
||||||
# endif],
|
|
||||||
[switch (0) {
|
|
||||||
case _IO('A', 1):;
|
|
||||||
case _IO('B', 1):;
|
|
||||||
}],
|
|
||||||
ac_cv_lbl_gcc_fixincludes=yes,
|
|
||||||
ac_cv_lbl_gcc_fixincludes=no))
|
|
||||||
AC_MSG_RESULT($ac_cv_lbl_gcc_fixincludes)
|
|
||||||
if test $ac_cv_lbl_gcc_fixincludes = no ; then
|
|
||||||
# Don't cache failure
|
|
||||||
unset ac_cv_lbl_gcc_fixincludes
|
|
||||||
AC_MSG_ERROR(see the INSTALL for more info)
|
|
||||||
fi
|
|
||||||
fi])
|
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl Check for flex, default to lex
|
|
||||||
dnl Require flex 2.4 or higher
|
|
||||||
dnl Check for bison, default to yacc
|
|
||||||
dnl Default to lex/yacc if both flex and bison are not available
|
|
||||||
dnl Define the yy prefix string if using flex and bison
|
|
||||||
dnl
|
|
||||||
dnl usage:
|
|
||||||
dnl
|
|
||||||
dnl AC_LBL_LEX_AND_YACC(lex, yacc, yyprefix)
|
|
||||||
dnl
|
|
||||||
dnl results:
|
|
||||||
dnl
|
|
||||||
dnl $1 (lex set)
|
|
||||||
dnl $2 (yacc appended)
|
|
||||||
dnl $3 (optional flex and bison -P prefix)
|
|
||||||
dnl
|
|
||||||
AC_DEFUN(AC_LBL_LEX_AND_YACC,
|
|
||||||
[AC_ARG_WITH(flex, [ --without-flex don't use flex])
|
|
||||||
AC_ARG_WITH(bison, [ --without-bison don't use bison])
|
|
||||||
if test "$with_flex" = no ; then
|
|
||||||
$1=lex
|
|
||||||
else
|
|
||||||
AC_CHECK_PROGS($1, flex, lex)
|
|
||||||
fi
|
|
||||||
if test "$$1" = flex ; then
|
|
||||||
# The -V flag was added in 2.4
|
|
||||||
AC_MSG_CHECKING(for flex 2.4 or higher)
|
|
||||||
AC_CACHE_VAL(ac_cv_lbl_flex_v24,
|
|
||||||
if flex -V >/dev/null 2>&1; then
|
|
||||||
ac_cv_lbl_flex_v24=yes
|
|
||||||
else
|
|
||||||
ac_cv_lbl_flex_v24=no
|
|
||||||
fi)
|
|
||||||
AC_MSG_RESULT($ac_cv_lbl_flex_v24)
|
|
||||||
if test $ac_cv_lbl_flex_v24 = no ; then
|
|
||||||
s="2.4 or higher required"
|
|
||||||
AC_MSG_WARN(ignoring obsolete flex executable ($s))
|
|
||||||
$1=lex
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if test "$with_bison" = no ; then
|
|
||||||
$2=yacc
|
|
||||||
else
|
|
||||||
AC_CHECK_PROGS($2, bison, yacc)
|
|
||||||
fi
|
|
||||||
if test "$$2" = bison ; then
|
|
||||||
$2="$$2 -y"
|
|
||||||
fi
|
|
||||||
if test "$$1" != lex -a "$$2" = yacc -o "$$1" = lex -a "$$2" != yacc ; then
|
|
||||||
AC_MSG_WARN(don't have both flex and bison; reverting to lex/yacc)
|
|
||||||
$1=lex
|
|
||||||
$2=yacc
|
|
||||||
fi
|
|
||||||
if test "$$1" = flex -a -n "$3" ; then
|
|
||||||
$1="$$1 -P$3"
|
|
||||||
$2="$$2 -p $3"
|
|
||||||
fi])
|
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl Checks to see if union wait is used with WEXITSTATUS()
|
|
||||||
dnl
|
|
||||||
dnl usage:
|
|
||||||
dnl
|
|
||||||
dnl AC_LBL_UNION_WAIT
|
|
||||||
dnl
|
|
||||||
dnl results:
|
|
||||||
dnl
|
|
||||||
dnl DECLWAITSTATUS (defined)
|
|
||||||
dnl
|
|
||||||
AC_DEFUN(AC_LBL_UNION_WAIT,
|
|
||||||
[AC_MSG_CHECKING(if union wait is used)
|
|
||||||
AC_CACHE_VAL(ac_cv_lbl_union_wait,
|
|
||||||
AC_TRY_COMPILE([
|
|
||||||
# include <sys/types.h>
|
|
||||||
# include <sys/wait.h>],
|
|
||||||
[int status;
|
|
||||||
u_int i = WEXITSTATUS(status);
|
|
||||||
u_int j = waitpid(0, &status, 0);],
|
|
||||||
ac_cv_lbl_union_wait=no,
|
|
||||||
ac_cv_lbl_union_wait=yes))
|
|
||||||
AC_MSG_RESULT($ac_cv_lbl_union_wait)
|
|
||||||
if test $ac_cv_lbl_union_wait = yes ; then
|
|
||||||
AC_DEFINE(DECLWAITSTATUS,union wait,[type for wait])
|
|
||||||
else
|
|
||||||
AC_DEFINE(DECLWAITSTATUS,int,[type for wait])
|
|
||||||
fi])
|
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl Checks to see if the sockaddr struct has the 4.4 BSD sa_len member
|
|
||||||
dnl
|
|
||||||
dnl usage:
|
|
||||||
dnl
|
|
||||||
dnl AC_LBL_SOCKADDR_SA_LEN
|
|
||||||
dnl
|
|
||||||
dnl results:
|
|
||||||
dnl
|
|
||||||
dnl HAVE_SOCKADDR_SA_LEN (defined)
|
|
||||||
dnl
|
|
||||||
AC_DEFUN(AC_LBL_SOCKADDR_SA_LEN,
|
|
||||||
[AC_MSG_CHECKING(if sockaddr struct has sa_len member)
|
|
||||||
AC_CACHE_VAL(ac_cv_lbl_sockaddr_has_sa_len,
|
|
||||||
AC_TRY_COMPILE([
|
|
||||||
# include <sys/types.h>
|
|
||||||
# include <sys/socket.h>],
|
|
||||||
[u_int i = sizeof(((struct sockaddr *)0)->sa_len)],
|
|
||||||
ac_cv_lbl_sockaddr_has_sa_len=yes,
|
|
||||||
ac_cv_lbl_sockaddr_has_sa_len=no))
|
|
||||||
AC_MSG_RESULT($ac_cv_lbl_sockaddr_has_sa_len)
|
|
||||||
if test $ac_cv_lbl_sockaddr_has_sa_len = yes ; then
|
|
||||||
AC_DEFINE(HAVE_SOCKADDR_SA_LEN,1,[if struct sockaddr has sa_len])
|
|
||||||
fi])
|
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl Checks to see if there's a sockaddr_storage structure
|
|
||||||
dnl
|
|
||||||
dnl usage:
|
|
||||||
dnl
|
|
||||||
dnl AC_LBL_SOCKADDR_STORAGE
|
|
||||||
dnl
|
|
||||||
dnl results:
|
|
||||||
dnl
|
|
||||||
dnl HAVE_SOCKADDR_STORAGE (defined)
|
|
||||||
dnl
|
|
||||||
AC_DEFUN(AC_LBL_SOCKADDR_STORAGE,
|
|
||||||
[AC_MSG_CHECKING(if sockaddr_storage struct exists)
|
|
||||||
AC_CACHE_VAL(ac_cv_lbl_has_sockaddr_storage,
|
|
||||||
AC_TRY_COMPILE([
|
|
||||||
# include <sys/types.h>
|
|
||||||
# include <sys/socket.h>],
|
|
||||||
[u_int i = sizeof (struct sockaddr_storage)],
|
|
||||||
ac_cv_lbl_has_sockaddr_storage=yes,
|
|
||||||
ac_cv_lbl_has_sockaddr_storage=no))
|
|
||||||
AC_MSG_RESULT($ac_cv_lbl_has_sockaddr_storage)
|
|
||||||
if test $ac_cv_lbl_has_sockaddr_storage = yes ; then
|
|
||||||
AC_DEFINE(HAVE_SOCKADDR_STORAGE,1,[if struct sockaddr_storage exists])
|
|
||||||
fi])
|
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl Checks to see if the dl_hp_ppa_info_t struct has the HP-UX 11.00
|
|
||||||
dnl dl_module_id_1 member
|
|
||||||
dnl
|
|
||||||
dnl usage:
|
|
||||||
dnl
|
|
||||||
dnl AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1
|
|
||||||
dnl
|
|
||||||
dnl results:
|
|
||||||
dnl
|
|
||||||
dnl HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1 (defined)
|
|
||||||
dnl
|
|
||||||
dnl NOTE: any compile failure means we conclude that it doesn't have
|
|
||||||
dnl that member, so if we don't have DLPI, don't have a <sys/dlpi_ext.h>
|
|
||||||
dnl header, or have one that doesn't declare a dl_hp_ppa_info_t type,
|
|
||||||
dnl we conclude it doesn't have that member (which is OK, as either we
|
|
||||||
dnl won't be using code that would use that member, or we wouldn't
|
|
||||||
dnl compile in any case).
|
|
||||||
dnl
|
|
||||||
AC_DEFUN(AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1,
|
|
||||||
[AC_MSG_CHECKING(if dl_hp_ppa_info_t struct has dl_module_id_1 member)
|
|
||||||
AC_CACHE_VAL(ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1,
|
|
||||||
AC_TRY_COMPILE([
|
|
||||||
# include <sys/types.h>
|
|
||||||
# include <sys/dlpi.h>
|
|
||||||
# include <sys/dlpi_ext.h>],
|
|
||||||
[u_int i = sizeof(((dl_hp_ppa_info_t *)0)->dl_module_id_1)],
|
|
||||||
ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=yes,
|
|
||||||
ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=no))
|
|
||||||
AC_MSG_RESULT($ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1)
|
|
||||||
if test $ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1 = yes ; then
|
|
||||||
AC_DEFINE(HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1,1,[if ppa_info_t_dl_module_id exists])
|
|
||||||
fi])
|
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl Checks to see if -R is used
|
|
||||||
dnl
|
|
||||||
dnl usage:
|
|
||||||
dnl
|
|
||||||
dnl AC_LBL_HAVE_RUN_PATH
|
|
||||||
dnl
|
|
||||||
dnl results:
|
|
||||||
dnl
|
|
||||||
dnl ac_cv_lbl_have_run_path (yes or no)
|
|
||||||
dnl
|
|
||||||
AC_DEFUN(AC_LBL_HAVE_RUN_PATH,
|
|
||||||
[AC_MSG_CHECKING(for ${CC-cc} -R)
|
|
||||||
AC_CACHE_VAL(ac_cv_lbl_have_run_path,
|
|
||||||
[echo 'main(){}' > conftest.c
|
|
||||||
${CC-cc} -o conftest conftest.c -R/a1/b2/c3 >conftest.out 2>&1
|
|
||||||
if test ! -s conftest.out ; then
|
|
||||||
ac_cv_lbl_have_run_path=yes
|
|
||||||
else
|
|
||||||
ac_cv_lbl_have_run_path=no
|
|
||||||
fi
|
|
||||||
rm -f conftest*])
|
|
||||||
AC_MSG_RESULT($ac_cv_lbl_have_run_path)
|
|
||||||
])
|
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl Due to the stupid way it's implemented, AC_CHECK_TYPE is nearly useless.
|
|
||||||
dnl
|
|
||||||
dnl usage:
|
|
||||||
dnl
|
|
||||||
dnl AC_LBL_CHECK_TYPE
|
|
||||||
dnl
|
|
||||||
dnl results:
|
|
||||||
dnl
|
|
||||||
dnl int32_t (defined)
|
|
||||||
dnl u_int32_t (defined)
|
|
||||||
dnl
|
|
||||||
AC_DEFUN(AC_LBL_CHECK_TYPE,
|
|
||||||
[AC_MSG_CHECKING(for $1 using $CC)
|
|
||||||
AC_CACHE_VAL(ac_cv_lbl_have_$1,
|
|
||||||
AC_TRY_COMPILE([
|
|
||||||
# include "confdefs.h"
|
|
||||||
# include <sys/types.h>
|
|
||||||
# if STDC_HEADERS
|
|
||||||
# include <stdlib.h>
|
|
||||||
# include <stddef.h>
|
|
||||||
# endif],
|
|
||||||
[$1 i],
|
|
||||||
ac_cv_lbl_have_$1=yes,
|
|
||||||
ac_cv_lbl_have_$1=no))
|
|
||||||
AC_MSG_RESULT($ac_cv_lbl_have_$1)
|
|
||||||
if test $ac_cv_lbl_have_$1 = no ; then
|
|
||||||
AC_DEFINE($1, $2, [if we have $1])
|
|
||||||
fi])
|
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl Checks to see if unaligned memory accesses fail
|
|
||||||
dnl
|
|
||||||
dnl usage:
|
|
||||||
dnl
|
|
||||||
dnl AC_LBL_UNALIGNED_ACCESS
|
|
||||||
dnl
|
|
||||||
dnl results:
|
|
||||||
dnl
|
|
||||||
dnl LBL_ALIGN (DEFINED)
|
|
||||||
dnl
|
|
||||||
AC_DEFUN(AC_LBL_UNALIGNED_ACCESS,
|
|
||||||
[AC_MSG_CHECKING(if unaligned accesses fail)
|
|
||||||
AC_CACHE_VAL(ac_cv_lbl_unaligned_fail,
|
|
||||||
[case "$host_cpu" in
|
|
||||||
|
|
||||||
#
|
|
||||||
# These are CPU types where:
|
|
||||||
#
|
|
||||||
# the CPU faults on an unaligned access, but at least some
|
|
||||||
# OSes that support that CPU catch the fault and simulate
|
|
||||||
# the unaligned access (e.g., Alpha/{Digital,Tru64} UNIX) -
|
|
||||||
# the simulation is slow, so we don't want to use it;
|
|
||||||
#
|
|
||||||
# the CPU, I infer (from the old
|
|
||||||
#
|
|
||||||
# XXX: should also check that they don't do weird things (like on arm)
|
|
||||||
#
|
|
||||||
# comment) doesn't fault on unaligned accesses, but doesn't
|
|
||||||
# do a normal unaligned fetch, either (e.g., presumably, ARM);
|
|
||||||
#
|
|
||||||
# for whatever reason, the test program doesn't work
|
|
||||||
# (this has been claimed to be the case for several of those
|
|
||||||
# CPUs - I don't know what the problem is; the problem
|
|
||||||
# was reported as "the test program dumps core" for SuperH,
|
|
||||||
# but that's what the test program is *supposed* to do -
|
|
||||||
# it dumps core before it writes anything, so the test
|
|
||||||
# for an empty output file should find an empty output
|
|
||||||
# file and conclude that unaligned accesses don't work).
|
|
||||||
#
|
|
||||||
# This run-time test won't work if you're cross-compiling, so
|
|
||||||
# in order to support cross-compiling for a particular CPU,
|
|
||||||
# we have to wire in the list of CPU types anyway, as far as
|
|
||||||
# I know, so perhaps we should just have a set of CPUs on
|
|
||||||
# which we know it doesn't work, a set of CPUs on which we
|
|
||||||
# know it does work, and have the script just fail on other
|
|
||||||
# cpu types and update it when such a failure occurs.
|
|
||||||
#
|
|
||||||
alpha*|arm*|hp*|mips*|sh*|sparc*|ia64|nv1)
|
|
||||||
ac_cv_lbl_unaligned_fail=yes
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
cat >conftest.c <<EOF
|
|
||||||
# include <sys/types.h>
|
|
||||||
# include <sys/wait.h>
|
|
||||||
# include <stdio.h>
|
|
||||||
unsigned char a[[5]] = { 1, 2, 3, 4, 5 };
|
|
||||||
main() {
|
|
||||||
unsigned int i;
|
|
||||||
pid_t pid;
|
|
||||||
int status;
|
|
||||||
/* avoid "core dumped" message */
|
|
||||||
pid = fork();
|
|
||||||
if (pid < 0)
|
|
||||||
exit(2);
|
|
||||||
if (pid > 0) {
|
|
||||||
/* parent */
|
|
||||||
pid = waitpid(pid, &status, 0);
|
|
||||||
if (pid < 0)
|
|
||||||
exit(3);
|
|
||||||
exit(!WIFEXITED(status));
|
|
||||||
}
|
|
||||||
/* child */
|
|
||||||
i = *(unsigned int *)&a[[1]];
|
|
||||||
printf("%d\n", i);
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \
|
|
||||||
conftest.c $LIBS >/dev/null 2>&1
|
|
||||||
if test ! -x conftest ; then
|
|
||||||
dnl failed to compile for some reason
|
|
||||||
ac_cv_lbl_unaligned_fail=yes
|
|
||||||
else
|
|
||||||
./conftest >conftest.out
|
|
||||||
if test ! -s conftest.out ; then
|
|
||||||
ac_cv_lbl_unaligned_fail=yes
|
|
||||||
else
|
|
||||||
ac_cv_lbl_unaligned_fail=no
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
rm -f conftest* core core.conftest
|
|
||||||
;;
|
|
||||||
esac])
|
|
||||||
AC_MSG_RESULT($ac_cv_lbl_unaligned_fail)
|
|
||||||
if test $ac_cv_lbl_unaligned_fail = yes ; then
|
|
||||||
AC_DEFINE(LBL_ALIGN,1,[if unaligned access fails])
|
|
||||||
fi])
|
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl If using gcc and the file .devel exists:
|
|
||||||
dnl Compile with -g (if supported) and -Wall
|
|
||||||
dnl If using gcc 2, do extra prototype checking
|
|
||||||
dnl If an os prototype include exists, symlink os-proto.h to it
|
|
||||||
dnl
|
|
||||||
dnl usage:
|
|
||||||
dnl
|
|
||||||
dnl AC_LBL_DEVEL(copt)
|
|
||||||
dnl
|
|
||||||
dnl results:
|
|
||||||
dnl
|
|
||||||
dnl $1 (copt appended)
|
|
||||||
dnl HAVE_OS_PROTO_H (defined)
|
|
||||||
dnl os-proto.h (symlinked)
|
|
||||||
dnl
|
|
||||||
AC_DEFUN(AC_LBL_DEVEL,
|
|
||||||
[rm -f os-proto.h
|
|
||||||
if test "${LBL_CFLAGS+set}" = set; then
|
|
||||||
$1="$$1 ${LBL_CFLAGS}"
|
|
||||||
fi
|
|
||||||
if test -f .devel ; then
|
|
||||||
if test "$GCC" = yes ; then
|
|
||||||
if test "${LBL_CFLAGS+set}" != set; then
|
|
||||||
if test "$ac_cv_prog_cc_g" = yes ; then
|
|
||||||
$1="-g $$1"
|
|
||||||
fi
|
|
||||||
$1="$$1 -Wall"
|
|
||||||
if test $ac_cv_lbl_gcc_vers -gt 1 ; then
|
|
||||||
$1="$$1 -Wmissing-prototypes -Wstrict-prototypes"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
case "$target_os" in
|
|
||||||
|
|
||||||
irix6*)
|
|
||||||
V_CCOPT="$V_CCOPT -n32"
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
os=`echo $target_os | sed -e 's/\([[0-9]][[0-9]]*\)[[^0-9]].*$/\1/'`
|
|
||||||
name="lbl/os-$os.h"
|
|
||||||
if test -f $name ; then
|
|
||||||
ln -s $name os-proto.h
|
|
||||||
AC_DEFINE(HAVE_OS_PROTO_H,1,[if there's an os_proto.h])
|
|
||||||
else
|
|
||||||
AC_MSG_WARN(can't find $name)
|
|
||||||
fi
|
|
||||||
fi])
|
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl Improved version of AC_CHECK_LIB
|
|
||||||
dnl
|
|
||||||
dnl Thanks to John Hawkinson (jhawk@mit.edu)
|
|
||||||
dnl
|
|
||||||
dnl usage:
|
|
||||||
dnl
|
|
||||||
dnl AC_LBL_CHECK_LIB(LIBRARY, FUNCTION [, ACTION-IF-FOUND [,
|
|
||||||
dnl ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
|
|
||||||
dnl
|
|
||||||
dnl results:
|
|
||||||
dnl
|
|
||||||
dnl LIBS
|
|
||||||
dnl
|
|
||||||
|
|
||||||
define(AC_LBL_CHECK_LIB,
|
|
||||||
[AC_MSG_CHECKING([for $2 in -l$1])
|
|
||||||
dnl Use a cache variable name containing both the library and function name,
|
|
||||||
dnl because the test really is for library $1 defining function $2, not
|
|
||||||
dnl just for library $1. Separate tests with the same $1 and different $2's
|
|
||||||
dnl may have different results.
|
|
||||||
ac_lib_var=`echo $1['_']$2['_']$5 | sed 'y%./+- %__p__%'`
|
|
||||||
AC_CACHE_VAL(ac_cv_lbl_lib_$ac_lib_var,
|
|
||||||
[ac_save_LIBS="$LIBS"
|
|
||||||
LIBS="-l$1 $5 $LIBS"
|
|
||||||
AC_TRY_LINK(dnl
|
|
||||||
ifelse([$2], [main], , dnl Avoid conflicting decl of main.
|
|
||||||
[/* Override any gcc2 internal prototype to avoid an error. */
|
|
||||||
]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
#endif
|
|
||||||
])dnl
|
|
||||||
[/* We use char because int might match the return type of a gcc2
|
|
||||||
builtin and then its argument prototype would still apply. */
|
|
||||||
char $2();
|
|
||||||
]),
|
|
||||||
[$2()],
|
|
||||||
eval "ac_cv_lbl_lib_$ac_lib_var=yes",
|
|
||||||
eval "ac_cv_lbl_lib_$ac_lib_var=no")
|
|
||||||
LIBS="$ac_save_LIBS"
|
|
||||||
])dnl
|
|
||||||
if eval "test \"`echo '$ac_cv_lbl_lib_'$ac_lib_var`\" = yes"; then
|
|
||||||
AC_MSG_RESULT(yes)
|
|
||||||
ifelse([$3], ,
|
|
||||||
[changequote(, )dnl
|
|
||||||
ac_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \
|
|
||||||
-e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
|
|
||||||
changequote([, ])dnl
|
|
||||||
AC_DEFINE_UNQUOTED($ac_tr_lib)
|
|
||||||
LIBS="-l$1 $LIBS"
|
|
||||||
], [$3])
|
|
||||||
else
|
|
||||||
AC_MSG_RESULT(no)
|
|
||||||
ifelse([$4], , , [$4
|
|
||||||
])dnl
|
|
||||||
fi
|
|
||||||
])
|
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl AC_LBL_LIBRARY_NET
|
|
||||||
dnl
|
|
||||||
dnl This test is for network applications that need socket() and
|
|
||||||
dnl gethostbyname() -ish functions. Under Solaris, those applications
|
|
||||||
dnl need to link with "-lsocket -lnsl". Under IRIX, they need to link
|
|
||||||
dnl with "-lnsl" but should *not* link with "-lsocket" because
|
|
||||||
dnl libsocket.a breaks a number of things (for instance:
|
|
||||||
dnl gethostbyname() under IRIX 5.2, and snoop sockets under most
|
|
||||||
dnl versions of IRIX).
|
|
||||||
dnl
|
|
||||||
dnl Unfortunately, many application developers are not aware of this,
|
|
||||||
dnl and mistakenly write tests that cause -lsocket to be used under
|
|
||||||
dnl IRIX. It is also easy to write tests that cause -lnsl to be used
|
|
||||||
dnl under operating systems where neither are necessary (or useful),
|
|
||||||
dnl such as SunOS 4.1.4, which uses -lnsl for TLI.
|
|
||||||
dnl
|
|
||||||
dnl This test exists so that every application developer does not test
|
|
||||||
dnl this in a different, and subtly broken fashion.
|
|
||||||
|
|
||||||
dnl It has been argued that this test should be broken up into two
|
|
||||||
dnl seperate tests, one for the resolver libraries, and one for the
|
|
||||||
dnl libraries necessary for using Sockets API. Unfortunately, the two
|
|
||||||
dnl are carefully intertwined and allowing the autoconf user to use
|
|
||||||
dnl them independantly potentially results in unfortunate ordering
|
|
||||||
dnl dependancies -- as such, such component macros would have to
|
|
||||||
dnl carefully use indirection and be aware if the other components were
|
|
||||||
dnl executed. Since other autoconf macros do not go to this trouble,
|
|
||||||
dnl and almost no applications use sockets without the resolver, this
|
|
||||||
dnl complexity has not been implemented.
|
|
||||||
dnl
|
|
||||||
dnl The check for libresolv is in case you are attempting to link
|
|
||||||
dnl statically and happen to have a libresolv.a lying around (and no
|
|
||||||
dnl libnsl.a).
|
|
||||||
dnl
|
|
||||||
AC_DEFUN(AC_LBL_LIBRARY_NET, [
|
|
||||||
# Most operating systems have gethostbyname() in the default searched
|
|
||||||
# libraries (i.e. libc):
|
|
||||||
# Some OSes (eg. Solaris) place it in libnsl
|
|
||||||
# Some strange OSes (SINIX) have it in libsocket:
|
|
||||||
AC_SEARCH_LIBS(gethostbyname, nsl socket resolv)
|
|
||||||
# Unfortunately libsocket sometimes depends on libnsl and
|
|
||||||
# AC_SEARCH_LIBS isn't up to the task of handling dependencies like this.
|
|
||||||
if test "$ac_cv_search_gethostbyname" = "no"
|
|
||||||
then
|
|
||||||
AC_CHECK_LIB(socket, gethostbyname,
|
|
||||||
LIBS="-lsocket -lnsl $LIBS", , -lnsl)
|
|
||||||
fi
|
|
||||||
AC_SEARCH_LIBS(socket, socket, ,
|
|
||||||
AC_CHECK_LIB(socket, socket, LIBS="-lsocket -lnsl $LIBS", , -lnsl))
|
|
||||||
# DLPI needs putmsg under HPUX so test for -lstr while we're at it
|
|
||||||
AC_SEARCH_LIBS(putmsg, str)
|
|
||||||
])
|
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl Test for __attribute__
|
|
||||||
dnl
|
|
||||||
|
|
||||||
AC_DEFUN(AC_C___ATTRIBUTE__, [
|
|
||||||
AC_MSG_CHECKING(for __attribute__)
|
|
||||||
AC_CACHE_VAL(ac_cv___attribute__, [
|
|
||||||
AC_COMPILE_IFELSE(
|
|
||||||
AC_LANG_SOURCE([[
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
static void foo(void) __attribute__ ((noreturn));
|
|
||||||
|
|
||||||
static void
|
|
||||||
foo(void)
|
|
||||||
{
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
foo();
|
|
||||||
}
|
|
||||||
]]),
|
|
||||||
ac_cv___attribute__=yes,
|
|
||||||
ac_cv___attribute__=no)])
|
|
||||||
if test "$ac_cv___attribute__" = "yes"; then
|
|
||||||
AC_DEFINE(HAVE___ATTRIBUTE__, 1, [define if your compiler has __attribute__])
|
|
||||||
V_DEFS="$V_DEFS -D_U_=\"__attribute__((unused))\""
|
|
||||||
else
|
|
||||||
V_DEFS="$V_DEFS -D_U_=\"\""
|
|
||||||
fi
|
|
||||||
AC_MSG_RESULT($ac_cv___attribute__)
|
|
||||||
])
|
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl Checks to see if tpacket_stats is defined in linux/if_packet.h
|
|
||||||
dnl If so then pcap-linux.c can use this to report proper statistics.
|
|
||||||
dnl
|
|
||||||
dnl -Scott Barron
|
|
||||||
dnl
|
|
||||||
AC_DEFUN(AC_LBL_TPACKET_STATS,
|
|
||||||
[AC_MSG_CHECKING(if if_packet.h has tpacket_stats defined)
|
|
||||||
AC_CACHE_VAL(ac_cv_lbl_tpacket_stats,
|
|
||||||
AC_TRY_COMPILE([
|
|
||||||
# include <linux/if_packet.h>],
|
|
||||||
[struct tpacket_stats stats],
|
|
||||||
ac_cv_lbl_tpacket_stats=yes,
|
|
||||||
ac_cv_lbl_tpacket_stats=no))
|
|
||||||
AC_MSG_RESULT($ac_cv_lbl_tpacket_stats)
|
|
||||||
if test $ac_cv_lbl_tpacket_stats = yes; then
|
|
||||||
AC_DEFINE(HAVE_TPACKET_STATS,1,[if if_packet.h has tpacket_stats defined])
|
|
||||||
fi])
|
|
||||||
@@ -1,52 +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.
|
|
||||||
*
|
|
||||||
* @(#) $Id$ (LBL)
|
|
||||||
*
|
|
||||||
* 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,87 +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.
|
|
||||||
*
|
|
||||||
* @(#) $Header$ (LBL)
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Based on UNI3.1 standard by ATM Forum */
|
|
||||||
|
|
||||||
/* ATM traffic types based on VPI=0 and (the following VCI */
|
|
||||||
#define PPC 0x05 /* Point-to-point signal msg */
|
|
||||||
#define BCC 0x02 /* Broadcast signal msg */
|
|
||||||
#define OAMF4SC 0x03 /* Segment OAM F4 flow cell */
|
|
||||||
#define OAMF4EC 0x04 /* End-to-end OAM F4 flow cell */
|
|
||||||
#define METAC 0x01 /* Meta signal msg */
|
|
||||||
#define 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,463 +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.h 7.1 (Berkeley) 5/7/91
|
|
||||||
*
|
|
||||||
* @(#) $Header$ (LBL)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef BPF_MAJOR_VERSION
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* BSD style release date */
|
|
||||||
#define BPF_RELEASE 199606
|
|
||||||
|
|
||||||
typedef int bpf_int32;
|
|
||||||
typedef u_int bpf_u_int32;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Alignment macros. BPF_WORDALIGN rounds up to the next
|
|
||||||
* even multiple of BPF_ALIGNMENT.
|
|
||||||
*/
|
|
||||||
#ifndef __NetBSD__
|
|
||||||
#define BPF_ALIGNMENT sizeof(bpf_int32)
|
|
||||||
#else
|
|
||||||
#define BPF_ALIGNMENT sizeof(long)
|
|
||||||
#endif
|
|
||||||
#define BPF_WORDALIGN(x) (((x)+(BPF_ALIGNMENT-1))&~(BPF_ALIGNMENT-1))
|
|
||||||
|
|
||||||
#define BPF_MAXINSNS 512
|
|
||||||
#define BPF_MAXBUFSIZE 0x8000
|
|
||||||
#define BPF_MINBUFSIZE 32
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Structure for BIOCSETF.
|
|
||||||
*/
|
|
||||||
struct bpf_program {
|
|
||||||
u_int bf_len;
|
|
||||||
struct bpf_insn *bf_insns;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Struct returned by BIOCGSTATS.
|
|
||||||
*/
|
|
||||||
struct bpf_stat {
|
|
||||||
u_int bs_recv; /* number of packets received */
|
|
||||||
u_int bs_drop; /* number of packets dropped */
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Struct return by BIOCVERSION. This represents the version number of
|
|
||||||
* the filter language described by the instruction encodings below.
|
|
||||||
* bpf understands a program iff kernel_major == filter_major &&
|
|
||||||
* kernel_minor >= filter_minor, that is, if the value returned by the
|
|
||||||
* running kernel has the same major number and a minor number equal
|
|
||||||
* equal to or less than the filter being downloaded. Otherwise, the
|
|
||||||
* results are undefined, meaning an error may be returned or packets
|
|
||||||
* may be accepted haphazardly.
|
|
||||||
* It has nothing to do with the source code version.
|
|
||||||
*/
|
|
||||||
struct bpf_version {
|
|
||||||
u_short bv_major;
|
|
||||||
u_short bv_minor;
|
|
||||||
};
|
|
||||||
/* Current version number of filter architecture. */
|
|
||||||
#define BPF_MAJOR_VERSION 1
|
|
||||||
#define BPF_MINOR_VERSION 1
|
|
||||||
|
|
||||||
/*
|
|
||||||
* BPF ioctls
|
|
||||||
*
|
|
||||||
* The first set is for compatibility with Sun's pcc style
|
|
||||||
* header files. If your using gcc, we assume that you
|
|
||||||
* have run fixincludes so the latter set should work.
|
|
||||||
*/
|
|
||||||
#if (defined(sun) || defined(ibm032)) && !defined(__GNUC__)
|
|
||||||
#define BIOCGBLEN _IOR(B,102, u_int)
|
|
||||||
#define BIOCSBLEN _IOWR(B,102, u_int)
|
|
||||||
#define BIOCSETF _IOW(B,103, struct bpf_program)
|
|
||||||
#define BIOCFLUSH _IO(B,104)
|
|
||||||
#define BIOCPROMISC _IO(B,105)
|
|
||||||
#define BIOCGDLT _IOR(B,106, u_int)
|
|
||||||
#define BIOCGETIF _IOR(B,107, struct ifreq)
|
|
||||||
#define BIOCSETIF _IOW(B,108, struct ifreq)
|
|
||||||
#define BIOCSRTIMEOUT _IOW(B,109, struct timeval)
|
|
||||||
#define BIOCGRTIMEOUT _IOR(B,110, struct timeval)
|
|
||||||
#define BIOCGSTATS _IOR(B,111, struct bpf_stat)
|
|
||||||
#define BIOCIMMEDIATE _IOW(B,112, u_int)
|
|
||||||
#define BIOCVERSION _IOR(B,113, struct bpf_version)
|
|
||||||
#define BIOCSTCPF _IOW(B,114, struct bpf_program)
|
|
||||||
#define BIOCSUDPF _IOW(B,115, struct bpf_program)
|
|
||||||
#else
|
|
||||||
#define BIOCGBLEN _IOR('B',102, u_int)
|
|
||||||
#define BIOCSBLEN _IOWR('B',102, u_int)
|
|
||||||
#define BIOCSETF _IOW('B',103, struct bpf_program)
|
|
||||||
#define BIOCFLUSH _IO('B',104)
|
|
||||||
#define BIOCPROMISC _IO('B',105)
|
|
||||||
#define BIOCGDLT _IOR('B',106, u_int)
|
|
||||||
#define BIOCGETIF _IOR('B',107, struct ifreq)
|
|
||||||
#define BIOCSETIF _IOW('B',108, struct ifreq)
|
|
||||||
#define BIOCSRTIMEOUT _IOW('B',109, struct timeval)
|
|
||||||
#define BIOCGRTIMEOUT _IOR('B',110, struct timeval)
|
|
||||||
#define BIOCGSTATS _IOR('B',111, struct bpf_stat)
|
|
||||||
#define BIOCIMMEDIATE _IOW('B',112, u_int)
|
|
||||||
#define BIOCVERSION _IOR('B',113, struct bpf_version)
|
|
||||||
#define BIOCSTCPF _IOW('B',114, struct bpf_program)
|
|
||||||
#define BIOCSUDPF _IOW('B',115, struct bpf_program)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Structure prepended to each packet.
|
|
||||||
*/
|
|
||||||
struct bpf_hdr {
|
|
||||||
struct timeval bh_tstamp; /* time stamp */
|
|
||||||
bpf_u_int32 bh_caplen; /* length of captured portion */
|
|
||||||
bpf_u_int32 bh_datalen; /* original length of packet */
|
|
||||||
u_short bh_hdrlen; /* length of bpf header (this struct
|
|
||||||
plus alignment padding) */
|
|
||||||
};
|
|
||||||
/*
|
|
||||||
* Because the structure above is not a multiple of 4 bytes, some compilers
|
|
||||||
* will insist on inserting padding; hence, sizeof(struct bpf_hdr) won't work.
|
|
||||||
* Only the kernel needs to know about it; applications use bh_hdrlen.
|
|
||||||
*/
|
|
||||||
#if defined(KERNEL) || defined(_KERNEL)
|
|
||||||
#define SIZEOF_BPF_HDR 18
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Data-link level type codes.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* These are the types that are the same on all platforms; on other
|
|
||||||
* platforms, a <net/bpf.h> should be supplied that defines the additional
|
|
||||||
* DLT_* codes appropriately for that platform (the BSDs, for example,
|
|
||||||
* should not just pick up this version of "bpf.h"; they should also define
|
|
||||||
* the additional DLT_* codes used by their kernels, as well as the values
|
|
||||||
* defined here - and, if the values they use for particular DLT_ types
|
|
||||||
* differ from those here, they should use their values, not the ones
|
|
||||||
* here).
|
|
||||||
*/
|
|
||||||
#define DLT_NULL 0 /* no link-layer encapsulation */
|
|
||||||
#define DLT_EN10MB 1 /* Ethernet (10Mb) */
|
|
||||||
#define DLT_EN3MB 2 /* Experimental Ethernet (3Mb) */
|
|
||||||
#define DLT_AX25 3 /* Amateur Radio AX.25 */
|
|
||||||
#define DLT_PRONET 4 /* Proteon ProNET Token Ring */
|
|
||||||
#define DLT_CHAOS 5 /* Chaos */
|
|
||||||
#define DLT_IEEE802 6 /* IEEE 802 Networks */
|
|
||||||
#define DLT_ARCNET 7 /* ARCNET */
|
|
||||||
#define DLT_SLIP 8 /* Serial Line IP */
|
|
||||||
#define DLT_PPP 9 /* Point-to-point Protocol */
|
|
||||||
#define DLT_FDDI 10 /* FDDI */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* These are values from the traditional libpcap "bpf.h".
|
|
||||||
* Ports of this to particular platforms should replace these definitions
|
|
||||||
* with the ones appropriate to that platform, if the values are
|
|
||||||
* different on that platform.
|
|
||||||
*/
|
|
||||||
#define DLT_ATM_RFC1483 11 /* LLC/SNAP encapsulated atm */
|
|
||||||
#define DLT_RAW 12 /* raw IP */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* These are values from BSD/OS's "bpf.h".
|
|
||||||
* These are not the same as the values from the traditional libpcap
|
|
||||||
* "bpf.h"; however, these values shouldn't be generated by any
|
|
||||||
* OS other than BSD/OS, so the correct values to use here are the
|
|
||||||
* BSD/OS values.
|
|
||||||
*
|
|
||||||
* Platforms that have already assigned these values to other
|
|
||||||
* DLT_ codes, however, should give these codes the values
|
|
||||||
* from that platform, so that programs that use these codes will
|
|
||||||
* continue to compile - even though they won't correctly read
|
|
||||||
* files of these types.
|
|
||||||
*/
|
|
||||||
#ifdef __NetBSD__
|
|
||||||
#ifndef DLT_SLIP_BSDOS
|
|
||||||
#define DLT_SLIP_BSDOS 13 /* BSD/OS Serial Line IP */
|
|
||||||
#define DLT_PPP_BSDOS 14 /* BSD/OS Point-to-point Protocol */
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#define DLT_SLIP_BSDOS 15 /* BSD/OS Serial Line IP */
|
|
||||||
#define DLT_PPP_BSDOS 16 /* BSD/OS Point-to-point Protocol */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define DLT_ATM_CLIP 19 /* Linux Classical-IP over ATM */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* These values are defined by NetBSD; other platforms should refrain from
|
|
||||||
* using them for other purposes, so that NetBSD savefiles with link
|
|
||||||
* types of 50 or 51 can be read as this type on all platforms.
|
|
||||||
*/
|
|
||||||
#define DLT_PPP_SERIAL 50 /* PPP over serial with HDLC encapsulation */
|
|
||||||
#define DLT_PPP_ETHER 51 /* PPP over Ethernet */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Values between 100 and 103 are used in capture file headers as
|
|
||||||
* link-layer types corresponding to DLT_ types that differ
|
|
||||||
* between platforms; don't use those values for new DLT_ new types.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This value was defined by libpcap 0.5; platforms that have defined
|
|
||||||
* it with a different value should define it here with that value -
|
|
||||||
* a link type of 104 in a save file will be mapped to DLT_C_HDLC,
|
|
||||||
* whatever value that happens to be, so programs will correctly
|
|
||||||
* handle files with that link type regardless of the value of
|
|
||||||
* DLT_C_HDLC.
|
|
||||||
*
|
|
||||||
* The name DLT_C_HDLC was used by BSD/OS; we use that name for source
|
|
||||||
* compatibility with programs written for BSD/OS.
|
|
||||||
*
|
|
||||||
* libpcap 0.5 defined it as DLT_CHDLC; we define DLT_CHDLC as well,
|
|
||||||
* for source compatibility with programs written for libpcap 0.5.
|
|
||||||
*/
|
|
||||||
#define DLT_C_HDLC 104 /* Cisco HDLC */
|
|
||||||
#define DLT_CHDLC DLT_C_HDLC
|
|
||||||
|
|
||||||
#define DLT_IEEE802_11 105 /* IEEE 802.11 wireless */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 106 is reserved for Linux Classical IP over ATM; it's like DLT_RAW,
|
|
||||||
* except when it isn't. (I.e., sometimes it's just raw IP, and
|
|
||||||
* sometimes it isn't.) We currently handle it as DLT_LINUX_SLL,
|
|
||||||
* so that we don't have to worry about the link-layer header.)
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Reserved for Frame Relay; BSD/OS has a DLT_FR, with a value of 11,
|
|
||||||
* but that collides with other values. DLT_FR and DLT_FRELAY packets
|
|
||||||
* start with the Frame Relay header (DLCI, etc.).
|
|
||||||
*/
|
|
||||||
#define DLT_FRELAY 107
|
|
||||||
|
|
||||||
/*
|
|
||||||
* OpenBSD DLT_LOOP, for loopback devices; it's like DLT_NULL, except
|
|
||||||
* that the AF_ type in the link-layer header is in network byte order.
|
|
||||||
*
|
|
||||||
* OpenBSD defines it as 12, but that collides with DLT_RAW, so we
|
|
||||||
* define it as 108 here. If OpenBSD picks up this file, it should
|
|
||||||
* define DLT_LOOP as 12 in its version, as per the comment above -
|
|
||||||
* and should not use 108 as a DLT_ value.
|
|
||||||
*/
|
|
||||||
#define DLT_LOOP 108
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Values between 109 and 112 are used in capture file headers as
|
|
||||||
* link-layer types corresponding to DLT_ types that might differ
|
|
||||||
* between platforms; don't use those values for new DLT_ types
|
|
||||||
* other than the corresponding DLT_ types.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This is for Linux cooked sockets.
|
|
||||||
*/
|
|
||||||
#define DLT_LINUX_SLL 113
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Apple LocalTalk hardware.
|
|
||||||
*/
|
|
||||||
#define DLT_LTALK 114
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Acorn Econet.
|
|
||||||
*/
|
|
||||||
#define DLT_ECONET 115
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Reserved for use with OpenBSD ipfilter.
|
|
||||||
*/
|
|
||||||
#define DLT_IPFILTER 116
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Reserved for use in capture-file headers as a link-layer type
|
|
||||||
* corresponding to OpenBSD DLT_PFLOG; DLT_PFLOG is 17 in OpenBSD,
|
|
||||||
* but that's DLT_LANE8023 in SuSE 6.3, so we can't use 17 for it
|
|
||||||
* in capture-file headers.
|
|
||||||
*/
|
|
||||||
#define DLT_PFLOG 117
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Registered for Cisco-internal use.
|
|
||||||
*/
|
|
||||||
#define DLT_CISCO_IOS 118
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Reserved for 802.11 cards using the Prism II chips, with a link-layer
|
|
||||||
* header including Prism monitor mode information plus an 802.11
|
|
||||||
* header.
|
|
||||||
*/
|
|
||||||
#define DLT_PRISM_HEADER 119
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Reserved for Aironet 802.11 cards, with an Aironet link-layer header
|
|
||||||
* (see Doug Ambrisko's FreeBSD patches).
|
|
||||||
*/
|
|
||||||
#define DLT_AIRONET_HEADER 120
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Reserved for Siemens HiPath HDLC.
|
|
||||||
*/
|
|
||||||
#define DLT_HHDLC 121
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Reserved for RFC 2625 IP-over-Fibre Channel, as per a request from
|
|
||||||
* Don Lee <donlee@cray.com>.
|
|
||||||
*
|
|
||||||
* This is not for use with raw Fibre Channel, where the link-layer
|
|
||||||
* header starts with a Fibre Channel frame header; it's for IP-over-FC,
|
|
||||||
* where the link-layer header starts with an RFC 2625 Network_Header
|
|
||||||
* field.
|
|
||||||
*/
|
|
||||||
#define DLT_IP_OVER_FC 122
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Reserved for capturing on Solaris with SunATM.
|
|
||||||
*/
|
|
||||||
#define DLT_SUNATM 123 /* Solaris+SunATM */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The instruction encodings.
|
|
||||||
*/
|
|
||||||
/* instruction classes */
|
|
||||||
#define BPF_CLASS(code) ((code) & 0x07)
|
|
||||||
#define BPF_LD 0x00
|
|
||||||
#define BPF_LDX 0x01
|
|
||||||
#define BPF_ST 0x02
|
|
||||||
#define BPF_STX 0x03
|
|
||||||
#define BPF_ALU 0x04
|
|
||||||
#define BPF_JMP 0x05
|
|
||||||
#define BPF_RET 0x06
|
|
||||||
#define BPF_MISC 0x07
|
|
||||||
|
|
||||||
/* ld/ldx fields */
|
|
||||||
#define BPF_SIZE(code) ((code) & 0x18)
|
|
||||||
#define BPF_W 0x00
|
|
||||||
#define BPF_H 0x08
|
|
||||||
#define BPF_B 0x10
|
|
||||||
#define BPF_MODE(code) ((code) & 0xe0)
|
|
||||||
#define BPF_IMM 0x00
|
|
||||||
#define BPF_ABS 0x20
|
|
||||||
#define BPF_IND 0x40
|
|
||||||
#define BPF_MEM 0x60
|
|
||||||
#define BPF_LEN 0x80
|
|
||||||
#define BPF_MSH 0xa0
|
|
||||||
|
|
||||||
/* alu/jmp fields */
|
|
||||||
#define BPF_OP(code) ((code) & 0xf0)
|
|
||||||
#define BPF_ADD 0x00
|
|
||||||
#define BPF_SUB 0x10
|
|
||||||
#define BPF_MUL 0x20
|
|
||||||
#define BPF_DIV 0x30
|
|
||||||
#define BPF_OR 0x40
|
|
||||||
#define BPF_AND 0x50
|
|
||||||
#define BPF_LSH 0x60
|
|
||||||
#define BPF_RSH 0x70
|
|
||||||
#define BPF_NEG 0x80
|
|
||||||
#define BPF_JA 0x00
|
|
||||||
#define BPF_JEQ 0x10
|
|
||||||
#define BPF_JGT 0x20
|
|
||||||
#define BPF_JGE 0x30
|
|
||||||
#define BPF_JSET 0x40
|
|
||||||
#define BPF_SRC(code) ((code) & 0x08)
|
|
||||||
#define BPF_K 0x00
|
|
||||||
#define BPF_X 0x08
|
|
||||||
|
|
||||||
/* ret - BPF_K and BPF_X also apply */
|
|
||||||
#define BPF_RVAL(code) ((code) & 0x18)
|
|
||||||
#define BPF_A 0x10
|
|
||||||
|
|
||||||
/* misc */
|
|
||||||
#define BPF_MISCOP(code) ((code) & 0xf8)
|
|
||||||
#define BPF_TAX 0x00
|
|
||||||
#define BPF_TXA 0x80
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The instruction data structure.
|
|
||||||
*/
|
|
||||||
struct bpf_insn {
|
|
||||||
u_short code;
|
|
||||||
u_char jt;
|
|
||||||
u_char jf;
|
|
||||||
bpf_int32 k;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Macros for insn array initializers.
|
|
||||||
*/
|
|
||||||
#define BPF_STMT(code, k) { (u_short)(code), 0, 0, k }
|
|
||||||
#define BPF_JUMP(code, k, jt, jf) { (u_short)(code), jt, jf, k }
|
|
||||||
|
|
||||||
#if defined(BSD) && (defined(KERNEL) || defined(_KERNEL))
|
|
||||||
/*
|
|
||||||
* Systems based on non-BSD kernels don't have ifnet's (or they don't mean
|
|
||||||
* anything if it is in <net/if.h>) and won't work like this.
|
|
||||||
*/
|
|
||||||
# if __STDC__
|
|
||||||
extern void bpf_tap(struct ifnet *, u_char *, u_int);
|
|
||||||
extern void bpf_mtap(struct ifnet *, struct mbuf *);
|
|
||||||
extern void bpfattach(struct ifnet *, u_int, u_int);
|
|
||||||
extern void bpfilterattach(int);
|
|
||||||
# else
|
|
||||||
extern void bpf_tap();
|
|
||||||
extern void bpf_mtap();
|
|
||||||
extern void bpfattach();
|
|
||||||
extern void bpfilterattach();
|
|
||||||
# endif /* __STDC__ */
|
|
||||||
#endif /* BSD && (_KERNEL || KERNEL) */
|
|
||||||
#if __STDC__ || defined(__cplusplus)
|
|
||||||
extern int bpf_validate(struct bpf_insn *, int);
|
|
||||||
extern u_int bpf_filter(struct bpf_insn *, u_char *, u_int, u_int);
|
|
||||||
#else
|
|
||||||
extern int bpf_validate();
|
|
||||||
extern u_int bpf_filter();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Number of scratch memory words (for BPF_LD|BPF_MEM and BPF_ST).
|
|
||||||
*/
|
|
||||||
#define BPF_MEMWORDS 16
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,565 +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
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if !(defined(lint) || defined(KERNEL) || defined(_KERNEL))
|
|
||||||
static const char rcsid[] _U_ =
|
|
||||||
"@(#) $Header$ (LBL)";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
|
|
||||||
#include <pcap-stdinc.h>
|
|
||||||
|
|
||||||
#else /* WIN32 */
|
|
||||||
|
|
||||||
#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
|
|
||||||
# define MLEN(m) ((m)->m_len)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
u_int
|
|
||||||
bpf_filter(pc, p, wirelen, buflen)
|
|
||||||
register struct bpf_insn *pc;
|
|
||||||
register u_char *p;
|
|
||||||
u_int wirelen;
|
|
||||||
register u_int buflen;
|
|
||||||
{
|
|
||||||
register u_int32 A, X;
|
|
||||||
register int k;
|
|
||||||
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 + sizeof(int32) > buflen) {
|
|
||||||
#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 + sizeof(short) > buflen) {
|
|
||||||
#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:
|
|
||||||
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];
|
|
||||||
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 (k + sizeof(int32) > buflen) {
|
|
||||||
#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 (k + sizeof(short) > buflen) {
|
|
||||||
#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 (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];
|
|
||||||
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:
|
|
||||||
pc += pc->k;
|
|
||||||
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_AND|BPF_X:
|
|
||||||
A &= X;
|
|
||||||
continue;
|
|
||||||
|
|
||||||
case BPF_ALU|BPF_OR|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_AND|BPF_K:
|
|
||||||
A &= pc->k;
|
|
||||||
continue;
|
|
||||||
|
|
||||||
case BPF_ALU|BPF_OR|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:
|
|
||||||
A = -A;
|
|
||||||
continue;
|
|
||||||
|
|
||||||
case BPF_MISC|BPF_TAX:
|
|
||||||
X = A;
|
|
||||||
continue;
|
|
||||||
|
|
||||||
case BPF_MISC|BPF_TXA:
|
|
||||||
A = X;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Return true if the 'fcode' is a valid filter program.
|
|
||||||
* The constraints are that each jump be forward and to a valid
|
|
||||||
* code. The code must terminate with either an accept or reject.
|
|
||||||
* 'valid' is an array for use by the routine (it must be at least
|
|
||||||
* 'len' bytes long).
|
|
||||||
*
|
|
||||||
* 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)
|
|
||||||
struct bpf_insn *f;
|
|
||||||
int len;
|
|
||||||
{
|
|
||||||
register int i;
|
|
||||||
register struct bpf_insn *p;
|
|
||||||
|
|
||||||
for (i = 0; i < len; ++i) {
|
|
||||||
/*
|
|
||||||
* Check that that jumps are forward, and within
|
|
||||||
* the code block.
|
|
||||||
*/
|
|
||||||
p = &f[i];
|
|
||||||
if (BPF_CLASS(p->code) == BPF_JMP) {
|
|
||||||
register int from = i + 1;
|
|
||||||
|
|
||||||
if (BPF_OP(p->code) == BPF_JA) {
|
|
||||||
if (from + p->k >= (unsigned)len)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else if (from + p->jt >= len || from + p->jf >= len)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* Check that memory operations use valid addresses.
|
|
||||||
*/
|
|
||||||
if ((BPF_CLASS(p->code) == BPF_ST ||
|
|
||||||
(BPF_CLASS(p->code) == BPF_LD &&
|
|
||||||
(p->code & 0xe0) == BPF_MEM)) &&
|
|
||||||
(p->k >= BPF_MEMWORDS || p->k < 0))
|
|
||||||
return 0;
|
|
||||||
/*
|
|
||||||
* Check for constant division by 0.
|
|
||||||
*/
|
|
||||||
if (p->code == (BPF_ALU|BPF_DIV|BPF_K) && p->k == 0)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return BPF_CLASS(f[len - 1].code) == BPF_RET;
|
|
||||||
}
|
|
||||||
@@ -1,62 +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 lint
|
|
||||||
static const char rcsid[] _U_ =
|
|
||||||
"@(#) $Header$ (LBL)";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <pcap.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
void
|
|
||||||
bpf_dump(struct bpf_program *p, int option)
|
|
||||||
{
|
|
||||||
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[];
|
|
||||||
printf(bids[i] > 0 ? "[%02d]" : " -- ", bids[i] - 1);
|
|
||||||
#endif
|
|
||||||
puts(bpf_image(insn, i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
./bpf/net/bpf_filter.c
|
|
||||||
@@ -1,288 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef lint
|
|
||||||
static const char rcsid[] _U_ =
|
|
||||||
"@(#) $Header$ (LBL)";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#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)
|
|
||||||
struct bpf_insn *p;
|
|
||||||
int n;
|
|
||||||
{
|
|
||||||
int v;
|
|
||||||
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_AND|BPF_X:
|
|
||||||
op = "and";
|
|
||||||
fmt = "x";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BPF_ALU|BPF_OR|BPF_X:
|
|
||||||
op = "or";
|
|
||||||
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_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_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)snprintf(operand, sizeof operand, fmt, v);
|
|
||||||
(void)snprintf(image, sizeof image,
|
|
||||||
(BPF_CLASS(p->code) == BPF_JMP &&
|
|
||||||
BPF_OP(p->code) != BPF_JA) ?
|
|
||||||
"(%03d) %-8s %-16s jt %d\tjf %d"
|
|
||||||
: "(%03d) %-8s %s",
|
|
||||||
n, op, operand, n + 1 + p->jt, n + 1 + p->jf);
|
|
||||||
return image;
|
|
||||||
}
|
|
||||||
1476
libpcap/config.guess
vendored
1476
libpcap/config.guess
vendored
File diff suppressed because it is too large
Load Diff
@@ -1,186 +0,0 @@
|
|||||||
/* config.h.in. Generated from configure.in by autoheader. */
|
|
||||||
/* Long story short: aclocal.m4 depends on autoconf 2.13
|
|
||||||
* implementation details wrt "const"; newer versions
|
|
||||||
* have different implementation details so for now we
|
|
||||||
* put "const" here. This may cause duplicate definitions
|
|
||||||
* in config.h but that should be OK since they're the same.
|
|
||||||
*/
|
|
||||||
#undef const
|
|
||||||
|
|
||||||
/* Enable optimizer debugging */
|
|
||||||
#undef BDEBUG
|
|
||||||
|
|
||||||
/* define if you have the DAG API */
|
|
||||||
#undef HAVE_DAG_API
|
|
||||||
|
|
||||||
/* define if you have streams capable DAG API */
|
|
||||||
#undef HAVE_DAG_STREAMS_API
|
|
||||||
|
|
||||||
/* 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
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `ether_hostton' function. */
|
|
||||||
#undef HAVE_ETHER_HOSTTON
|
|
||||||
|
|
||||||
/* 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
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <limits.h> header file. */
|
|
||||||
#undef HAVE_LIMITS_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
|
|
||||||
|
|
||||||
/* if there's an os_proto.h */
|
|
||||||
#undef HAVE_OS_PROTO_H
|
|
||||||
|
|
||||||
/* define if you have a /proc/net/dev */
|
|
||||||
#undef HAVE_PROC_NET_DEV
|
|
||||||
|
|
||||||
/* define if you have a Septel API */
|
|
||||||
#undef HAVE_SEPTEL_API
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `snprintf' function. */
|
|
||||||
#undef HAVE_SNPRINTF
|
|
||||||
|
|
||||||
/* if struct sockaddr has sa_len */
|
|
||||||
#undef HAVE_SOCKADDR_SA_LEN
|
|
||||||
|
|
||||||
/* if struct sockaddr_storage exists */
|
|
||||||
#undef HAVE_SOCKADDR_STORAGE
|
|
||||||
|
|
||||||
/* 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 the system has the type `struct ether_addr'. */
|
|
||||||
#undef HAVE_STRUCT_ETHER_ADDR
|
|
||||||
|
|
||||||
/* 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/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
|
|
||||||
|
|
||||||
/* 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
|
|
||||||
|
|
||||||
/* define if version.h is generated in the build procedure */
|
|
||||||
#undef HAVE_VERSION_H
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `vsnprintf' function. */
|
|
||||||
#undef HAVE_VSNPRINTF
|
|
||||||
|
|
||||||
/* define if your compiler has __attribute__ */
|
|
||||||
#undef HAVE___ATTRIBUTE__
|
|
||||||
|
|
||||||
/* IPv6 */
|
|
||||||
#undef INET6
|
|
||||||
|
|
||||||
/* if unaligned access fails */
|
|
||||||
#undef LBL_ALIGN
|
|
||||||
|
|
||||||
/* 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 version of this package. */
|
|
||||||
#undef PACKAGE_VERSION
|
|
||||||
|
|
||||||
/* /dev/dlpi directory */
|
|
||||||
#undef PCAP_DEV_PREFIX
|
|
||||||
|
|
||||||
/* Define to 1 if you have the ANSI C header files. */
|
|
||||||
#undef STDC_HEADERS
|
|
||||||
|
|
||||||
/* Enable parser debugging */
|
|
||||||
#undef YYDEBUG
|
|
||||||
|
|
||||||
/* needed on HP-UX */
|
|
||||||
#undef _HPUX_SOURCE
|
|
||||||
|
|
||||||
/* define on AIX to get certain functions */
|
|
||||||
#undef _SUN
|
|
||||||
|
|
||||||
/* Define as token for inline if inlining supported */
|
|
||||||
#undef inline
|
|
||||||
|
|
||||||
/* on sinix */
|
|
||||||
#undef sinix
|
|
||||||
|
|
||||||
/* if we have u_int16_t */
|
|
||||||
#undef u_int16_t
|
|
||||||
|
|
||||||
/* if we have u_int32_t */
|
|
||||||
#undef u_int32_t
|
|
||||||
|
|
||||||
/* if we have u_int8_t */
|
|
||||||
#undef u_int8_t
|
|
||||||
1605
libpcap/config.sub
vendored
1605
libpcap/config.sub
vendored
File diff suppressed because it is too large
Load Diff
8198
libpcap/configure
vendored
8198
libpcap/configure
vendored
File diff suppressed because it is too large
Load Diff
@@ -1,805 +0,0 @@
|
|||||||
dnl @(#) $Header$ (LBL)
|
|
||||||
dnl
|
|
||||||
dnl Copyright (c) 1994, 1995, 1996, 1997
|
|
||||||
dnl The Regents of the University of California. All rights reserved.
|
|
||||||
dnl
|
|
||||||
dnl Process this file with autoconf to produce a configure script.
|
|
||||||
dnl
|
|
||||||
|
|
||||||
AC_REVISION($Revision$)
|
|
||||||
AC_PREREQ(2.50)
|
|
||||||
AC_INIT(pcap.c)
|
|
||||||
|
|
||||||
AC_CANONICAL_SYSTEM
|
|
||||||
|
|
||||||
AC_LBL_C_INIT(V_CCOPT, V_INCLS, V_LIBS)
|
|
||||||
AC_LBL_C_INLINE
|
|
||||||
AC_C___ATTRIBUTE__
|
|
||||||
|
|
||||||
AC_LBL_CHECK_TYPE(u_int8_t, u_char)
|
|
||||||
AC_LBL_CHECK_TYPE(u_int16_t, u_short)
|
|
||||||
AC_LBL_CHECK_TYPE(u_int32_t, u_int)
|
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl libpcap doesn't itself use <sys/ioccom.h>; however, the test program
|
|
||||||
dnl in "AC_LBL_FIXINCLUDES" in "aclocal.m4" uses it, so we have to
|
|
||||||
dnl test for it and set "HAVE_SYS_IOCCOM_H" if we have it, otherwise
|
|
||||||
dnl "AC_LBL_FIXINCLUDES" won't work on some platforms such as Solaris.
|
|
||||||
dnl
|
|
||||||
AC_CHECK_HEADERS(sys/ioccom.h sys/sockio.h limits.h)
|
|
||||||
AC_CHECK_HEADERS(netinet/if_ether.h, , , [#include <sys/types.h>
|
|
||||||
#include <sys/socket.h>])
|
|
||||||
if test "$ac_cv_header_netinet_if_ether_h" != yes; then
|
|
||||||
#
|
|
||||||
# The simple test didn't work.
|
|
||||||
# Do we need to include <net/if.h> first?
|
|
||||||
# Unset ac_cv_header_netinet_if_ether_h so we don't
|
|
||||||
# treat the previous failure as a cached value and
|
|
||||||
# suppress the next test.
|
|
||||||
#
|
|
||||||
AC_MSG_NOTICE([Rechecking with some additional includes])
|
|
||||||
unset ac_cv_header_netinet_if_ether_h
|
|
||||||
AC_CHECK_HEADERS(netinet/if_ether.h, , , [#include <sys/types.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
struct mbuf;
|
|
||||||
struct rtentry;
|
|
||||||
#include <net/if.h>])
|
|
||||||
fi
|
|
||||||
|
|
||||||
AC_LBL_FIXINCLUDES
|
|
||||||
|
|
||||||
AC_CHECK_FUNCS(strerror strlcpy)
|
|
||||||
|
|
||||||
needsnprintf=no
|
|
||||||
AC_CHECK_FUNCS(vsnprintf snprintf,,
|
|
||||||
[needsnprintf=yes])
|
|
||||||
if test $needsnprintf = yes; then
|
|
||||||
AC_LIBOBJ(snprintf)
|
|
||||||
fi
|
|
||||||
|
|
||||||
#
|
|
||||||
# Do this before checking for ether_hostton(), as it's a
|
|
||||||
# "gethostbyname() -ish function".
|
|
||||||
#
|
|
||||||
AC_LBL_LIBRARY_NET
|
|
||||||
|
|
||||||
#
|
|
||||||
# You are in a twisty little maze of UN*Xes, all different.
|
|
||||||
# Some might not have ether_hostton().
|
|
||||||
# Some might have it, but not declare it in any header file.
|
|
||||||
# Some might have it, but declare it in <netinet/if_ether.h>.
|
|
||||||
# Some might have it, but declare it in <netinet/ether.h>
|
|
||||||
# (And some might have it but document it as something declared in
|
|
||||||
# <netinet/ethernet.h>, although <netinet/if_ether.h> appears to work.)
|
|
||||||
#
|
|
||||||
# Before you is a C compiler.
|
|
||||||
#
|
|
||||||
AC_CHECK_FUNCS(ether_hostton)
|
|
||||||
if test "$ac_cv_func_ether_hostton" = yes; then
|
|
||||||
#
|
|
||||||
# OK, we have ether_hostton(). Do we have <netinet/if_ether.h>?
|
|
||||||
#
|
|
||||||
if test "$ac_cv_header_netinet_if_ether_h" = yes; then
|
|
||||||
#
|
|
||||||
# Yes. Does it declare ether_hostton()?
|
|
||||||
#
|
|
||||||
AC_CHECK_DECL(ether_hostton,
|
|
||||||
[
|
|
||||||
AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON,,
|
|
||||||
[Define to 1 if netinet/if_ether.h declares `ether_hostton'])
|
|
||||||
],,
|
|
||||||
[
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
struct mbuf;
|
|
||||||
struct rtentry;
|
|
||||||
#include <net/if.h>
|
|
||||||
#include <netinet/if_ether.h>
|
|
||||||
])
|
|
||||||
fi
|
|
||||||
#
|
|
||||||
# Did that succeed?
|
|
||||||
#
|
|
||||||
if test "$ac_cv_have_decl_ether_hostton" != yes; then
|
|
||||||
#
|
|
||||||
# No, how about <netinet/ether.h>, as on Linux?
|
|
||||||
#
|
|
||||||
AC_CHECK_HEADERS(netinet/ether.h)
|
|
||||||
if test "$ac_cv_header_netinet_ether_h" = yes; then
|
|
||||||
#
|
|
||||||
# We have it - does it declare ether_hostton()?
|
|
||||||
# Unset ac_cv_have_decl_ether_hostton so we don't
|
|
||||||
# treat the previous failure as a cached value and
|
|
||||||
# suppress the next test.
|
|
||||||
#
|
|
||||||
unset ac_cv_have_decl_ether_hostton
|
|
||||||
AC_CHECK_DECL(ether_hostton,
|
|
||||||
[
|
|
||||||
AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_HOSTTON,,
|
|
||||||
[Define to 1 if netinet/ether.h declares `ether_hostton'])
|
|
||||||
],,
|
|
||||||
[
|
|
||||||
#include <netinet/ether.h>
|
|
||||||
])
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
#
|
|
||||||
# Is ether_hostton() declared?
|
|
||||||
#
|
|
||||||
if test "$ac_cv_have_decl_ether_hostton" != yes; then
|
|
||||||
#
|
|
||||||
# No, we'll have to declare it ourselves.
|
|
||||||
# Do we have "struct ether_addr"?
|
|
||||||
#
|
|
||||||
AC_CHECK_TYPES(struct ether_addr,,,
|
|
||||||
[
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
struct mbuf;
|
|
||||||
struct rtentry;
|
|
||||||
#include <net/if.h>
|
|
||||||
#include <netinet/if_ether.h>
|
|
||||||
])
|
|
||||||
AC_DEFINE(HAVE_DECL_ETHER_HOSTTON, 0,
|
|
||||||
[Define to 1 if you have the declaration of `ether_hostton', and to 0 if you
|
|
||||||
don't.])
|
|
||||||
else
|
|
||||||
AC_DEFINE(HAVE_DECL_ETHER_HOSTTON, 1,
|
|
||||||
[Define to 1 if you have the declaration of `ether_hostton', and to 0 if you
|
|
||||||
don't.])
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
dnl to pacify those who hate protochain insn
|
|
||||||
AC_MSG_CHECKING(if --disable-protochain option is specified)
|
|
||||||
AC_ARG_ENABLE(protochain, [ --disable-protochain disable \"protochain\" insn])
|
|
||||||
case "x$enable_protochain" in
|
|
||||||
xyes) enable_protochain=enabled ;;
|
|
||||||
xno) enable_protochain=disabled ;;
|
|
||||||
x) enable_protochain=enabled ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if test "$enable_protochain" = "disabled"; then
|
|
||||||
AC_DEFINE(NO_PROTOCHAIN,1,[do not use protochain])
|
|
||||||
fi
|
|
||||||
AC_MSG_RESULT(${enable_protochain})
|
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl Not all versions of test support -c (character special) but it's a
|
|
||||||
dnl better way of testing since the device might be protected. So we
|
|
||||||
dnl check in our normal order using -r and then check the for the /dev
|
|
||||||
dnl guys again using -c.
|
|
||||||
dnl
|
|
||||||
dnl XXX This could be done for cross-compiling, but for now it's not.
|
|
||||||
dnl
|
|
||||||
if test -z "$with_pcap" && test "$cross_compiling" = yes; then
|
|
||||||
AC_MSG_ERROR(pcap type not determined when cross-compiling; use --with-pcap=...)
|
|
||||||
fi
|
|
||||||
AC_ARG_WITH(pcap, [ --with-pcap=TYPE use packet capture TYPE])
|
|
||||||
AC_MSG_CHECKING(packet capture type)
|
|
||||||
if test ! -z "$with_pcap" ; then
|
|
||||||
V_PCAP="$withval"
|
|
||||||
elif test -r /dev/bpf0 ; then
|
|
||||||
V_PCAP=bpf
|
|
||||||
elif test -r /usr/include/net/pfilt.h ; then
|
|
||||||
V_PCAP=pf
|
|
||||||
elif test -r /dev/enet ; then
|
|
||||||
V_PCAP=enet
|
|
||||||
elif test -r /dev/nit ; then
|
|
||||||
V_PCAP=snit
|
|
||||||
elif test -r /usr/include/sys/net/nit.h ; then
|
|
||||||
V_PCAP=nit
|
|
||||||
elif test -r /usr/include/linux/socket.h ; then
|
|
||||||
V_PCAP=linux
|
|
||||||
elif test -r /usr/include/net/raw.h ; then
|
|
||||||
V_PCAP=snoop
|
|
||||||
elif test -r /usr/include/odmi.h ; then
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
#
|
|
||||||
V_PCAP=bpf
|
|
||||||
elif test -r /usr/include/sys/dlpi.h ; then
|
|
||||||
V_PCAP=dlpi
|
|
||||||
elif test -c /dev/bpf0 ; then # check again in case not readable
|
|
||||||
V_PCAP=bpf
|
|
||||||
elif test -c /dev/enet ; then # check again in case not readable
|
|
||||||
V_PCAP=enet
|
|
||||||
elif test -c /dev/nit ; then # check again in case not readable
|
|
||||||
V_PCAP=snit
|
|
||||||
else
|
|
||||||
V_PCAP=null
|
|
||||||
fi
|
|
||||||
AC_MSG_RESULT($V_PCAP)
|
|
||||||
|
|
||||||
dnl
|
|
||||||
dnl Now figure out how we get a list of interfaces and addresses,
|
|
||||||
dnl if we support capturing. Don't bother if we don't support
|
|
||||||
dnl capturing.
|
|
||||||
dnl
|
|
||||||
if test "$V_PCAP" = null
|
|
||||||
then
|
|
||||||
#
|
|
||||||
# We can't capture, so we can't open any capture
|
|
||||||
# devices, so we won't return any interfaces.
|
|
||||||
#
|
|
||||||
V_FINDALLDEVS=null
|
|
||||||
else
|
|
||||||
AC_CHECK_FUNC(getifaddrs,[
|
|
||||||
#
|
|
||||||
# We have "getifaddrs()"; make sure we have <ifaddrs.h>
|
|
||||||
# as well, just in case some platform is really weird.
|
|
||||||
#
|
|
||||||
AC_CHECK_HEADER(ifaddrs.h,[
|
|
||||||
#
|
|
||||||
# We have the header, so we use "getifaddrs()" to
|
|
||||||
# get the list of interfaces.
|
|
||||||
#
|
|
||||||
V_FINDALLDEVS=getad
|
|
||||||
],[
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
#
|
|
||||||
AC_MSG_ERROR([Your system has getifaddrs() but doesn't have a usable <ifaddrs.h>.])
|
|
||||||
])
|
|
||||||
],[
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
#
|
|
||||||
case "$V_PCAP" in
|
|
||||||
|
|
||||||
dlpi)
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
#
|
|
||||||
AC_MSG_CHECKING(whether we have SIOCGLIFCONF)
|
|
||||||
AC_CACHE_VAL(ac_cv_lbl_have_siocglifconf,
|
|
||||||
AC_TRY_COMPILE(
|
|
||||||
[#include <sys/param.h>
|
|
||||||
#include <sys/file.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/sockio.h>],
|
|
||||||
[ioctl(0, SIOCGLIFCONF, (char *)0);],
|
|
||||||
ac_cv_lbl_have_siocglifconf=yes,
|
|
||||||
ac_cv_lbl_have_siocglifconf=no))
|
|
||||||
AC_MSG_RESULT($ac_cv_lbl_have_siocglifconf)
|
|
||||||
if test $ac_cv_lbl_have_siocglifconf = yes ; then
|
|
||||||
V_FINDALLDEVS=glifc
|
|
||||||
else
|
|
||||||
V_FINDALLDEVS=gifc
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
#
|
|
||||||
# Assume we just have SIOCGIFCONF.
|
|
||||||
# (XXX - on at least later Linux kernels, there's
|
|
||||||
# another mechanism, and we should be using that
|
|
||||||
# instead.)
|
|
||||||
#
|
|
||||||
V_FINDALLDEVS=gifc
|
|
||||||
;;
|
|
||||||
esac])
|
|
||||||
fi
|
|
||||||
|
|
||||||
AC_MSG_CHECKING(if --enable-ipv6 option is specified)
|
|
||||||
AC_ARG_ENABLE(ipv6, [ --enable-ipv6 build IPv6-capable version])
|
|
||||||
if test "$enable_ipv6" = "yes"; then
|
|
||||||
AC_DEFINE(INET6,1,[IPv6])
|
|
||||||
fi
|
|
||||||
AC_MSG_RESULT(${enable_ipv6-no})
|
|
||||||
|
|
||||||
AC_MSG_CHECKING(whether to build optimizer debugging code)
|
|
||||||
AC_ARG_ENABLE(optimizer-dbg, [ --enable-optimizer-dbg build optimizer debugging code])
|
|
||||||
if test "$enable_optimizer_dbg" = "yes"; then
|
|
||||||
AC_DEFINE(BDEBUG,1,[Enable optimizer debugging])
|
|
||||||
fi
|
|
||||||
AC_MSG_RESULT(${enable_optimizer_dbg-no})
|
|
||||||
|
|
||||||
AC_MSG_CHECKING(whether to build parser debugging code)
|
|
||||||
AC_ARG_ENABLE(yydebug, [ --enable-yydebug build parser debugging code])
|
|
||||||
if test "$enable_yydebug" = "yes"; then
|
|
||||||
AC_DEFINE(YYDEBUG,1,[Enable parser debugging])
|
|
||||||
fi
|
|
||||||
AC_MSG_RESULT(${enable_yydebug-no})
|
|
||||||
|
|
||||||
case "$V_PCAP" in
|
|
||||||
|
|
||||||
dlpi)
|
|
||||||
AC_CHECK_HEADERS(sys/bufmod.h sys/dlpi_ext.h)
|
|
||||||
AC_MSG_CHECKING(for /dev/dlpi device)
|
|
||||||
if test -c /dev/dlpi ; then
|
|
||||||
AC_MSG_RESULT(yes)
|
|
||||||
AC_DEFINE(HAVE_DEV_DLPI, 1, [define if you have a /dev/dlpi])
|
|
||||||
else
|
|
||||||
AC_MSG_RESULT(no)
|
|
||||||
dir="/dev/dlpi"
|
|
||||||
AC_MSG_CHECKING(for $dir directory)
|
|
||||||
if test -d $dir ; then
|
|
||||||
AC_MSG_RESULT(yes)
|
|
||||||
AC_DEFINE_UNQUOTED(PCAP_DEV_PREFIX, "$dir", [/dev/dlpi directory])
|
|
||||||
else
|
|
||||||
AC_MSG_RESULT(no)
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
|
|
||||||
linux)
|
|
||||||
AC_MSG_CHECKING(Linux kernel version)
|
|
||||||
if test "$cross_compiling" = yes; then
|
|
||||||
AC_CACHE_VAL(ac_cv_linux_vers,
|
|
||||||
ac_cv_linux_vers=unknown)
|
|
||||||
else
|
|
||||||
AC_CACHE_VAL(ac_cv_linux_vers,
|
|
||||||
ac_cv_linux_vers=`uname -r 2>&1 | \
|
|
||||||
sed -n -e '$s/.* //' -e '$s/\..*//p'`)
|
|
||||||
fi
|
|
||||||
AC_MSG_RESULT($ac_cv_linux_vers)
|
|
||||||
if test $ac_cv_linux_vers = unknown ; then
|
|
||||||
AC_MSG_ERROR(cannot determine linux version when cross-compiling)
|
|
||||||
fi
|
|
||||||
if test $ac_cv_linux_vers -lt 2 ; then
|
|
||||||
AC_MSG_ERROR(version 2 or higher required; see the INSTALL doc for more info)
|
|
||||||
fi
|
|
||||||
AC_LBL_TPACKET_STATS
|
|
||||||
;;
|
|
||||||
|
|
||||||
dag)
|
|
||||||
V_DEFS="$V_DEFS -DDAG_ONLY"
|
|
||||||
;;
|
|
||||||
|
|
||||||
septel)
|
|
||||||
V_DEFS="$V_DEFS -DSEPTEL_ONLY"
|
|
||||||
;;
|
|
||||||
|
|
||||||
null)
|
|
||||||
AC_MSG_WARN(cannot determine packet capture interface)
|
|
||||||
AC_MSG_WARN((see the INSTALL doc for more info))
|
|
||||||
;;
|
|
||||||
|
|
||||||
esac
|
|
||||||
|
|
||||||
AC_MSG_CHECKING(whether we have /proc/net/dev)
|
|
||||||
if test -r /proc/net/dev ; then
|
|
||||||
ac_cv_lbl_proc_net_dev=yes
|
|
||||||
else
|
|
||||||
ac_cv_lbl_proc_net_dev=no
|
|
||||||
fi
|
|
||||||
if test $ac_cv_lbl_proc_net_dev = yes; then
|
|
||||||
AC_DEFINE(HAVE_PROC_NET_DEV, 1, [define if you have a /proc/net/dev])
|
|
||||||
fi
|
|
||||||
AC_MSG_RESULT($ac_cv_lbl_proc_net_dev)
|
|
||||||
|
|
||||||
# Check for Endace DAG card support.
|
|
||||||
AC_ARG_WITH([dag], [ --with-dag[[=DIR]] include Endace DAG support ("yes", "no" or DIR; default="yes" on BSD and Linux if present)],
|
|
||||||
[
|
|
||||||
if test "$withval" = no
|
|
||||||
then
|
|
||||||
# User doesn't want DAG support.
|
|
||||||
want_dag=no
|
|
||||||
elif test "$withval" = yes
|
|
||||||
then
|
|
||||||
# User wants DAG support but hasn't specified a directory.
|
|
||||||
want_dag=yes
|
|
||||||
else
|
|
||||||
# User wants DAG support and has specified a directory, so use the provided value.
|
|
||||||
want_dag=yes
|
|
||||||
dag_root=$withval
|
|
||||||
fi
|
|
||||||
],[
|
|
||||||
#
|
|
||||||
# Use DAG API if present, otherwise don't
|
|
||||||
#
|
|
||||||
want_dag=ifpresent
|
|
||||||
])
|
|
||||||
|
|
||||||
AC_ARG_WITH([dag-includes], [ --with-dag-includes=DIR Endace DAG include directory],
|
|
||||||
[
|
|
||||||
# User wants DAG support and has specified a header directory, so use the provided value.
|
|
||||||
want_dag=yes
|
|
||||||
dag_include_dir=$withval
|
|
||||||
],[])
|
|
||||||
|
|
||||||
AC_ARG_WITH([dag-libraries], [ --with-dag-libraries=DIR Endace DAG library directory],
|
|
||||||
[
|
|
||||||
# User wants DAG support and has specified a library directory, so use the provided value.
|
|
||||||
want_dag=yes
|
|
||||||
dag_lib_dir=$withval
|
|
||||||
],[])
|
|
||||||
|
|
||||||
case "$V_PCAP" in
|
|
||||||
linux|bpf|dag)
|
|
||||||
#
|
|
||||||
# We support the DAG API if we're on Linux or BSD, or if we're
|
|
||||||
# building a DAG-only libpcap.
|
|
||||||
#
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
#
|
|
||||||
# If the user explicitly requested DAG, tell them it's not
|
|
||||||
# supported.
|
|
||||||
#
|
|
||||||
# If they expressed no preference, don't include it.
|
|
||||||
#
|
|
||||||
if test $want_dag = yes; then
|
|
||||||
AC_MSG_ERROR([DAG support is only available with 'linux' 'bpf' and 'dag' packet capture types])
|
|
||||||
elif test $want_dag = yes; then
|
|
||||||
want_dag=no
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
ac_cv_lbl_dag_api=no
|
|
||||||
if test "$want_dag" != no; then
|
|
||||||
|
|
||||||
AC_MSG_CHECKING([whether we have DAG API headers])
|
|
||||||
|
|
||||||
# If necessary, set default paths for DAG API headers and libraries.
|
|
||||||
if test -z "$dag_root"; then
|
|
||||||
dag_root=/usr/local
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test -z "$dag_include_dir"; then
|
|
||||||
dag_include_dir="$dag_root/include"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test -z "$dag_lib_dir"; then
|
|
||||||
dag_lib_dir="$dag_root/lib"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test -z "$dag_tools_dir"; then
|
|
||||||
dag_tools_dir="$dag_root/tools"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test -r $dag_include_dir/dagapi.h; then
|
|
||||||
ac_cv_lbl_dag_api=yes
|
|
||||||
fi
|
|
||||||
AC_MSG_RESULT([$ac_cv_lbl_dag_api ($dag_include_dir)])
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test $ac_cv_lbl_dag_api = yes; then
|
|
||||||
|
|
||||||
AC_MSG_CHECKING([dagapi.o])
|
|
||||||
dagapi_obj=no
|
|
||||||
if test -r $dag_tools_dir/dagapi.o; then
|
|
||||||
# 2.4.x.
|
|
||||||
dagapi_obj=$dag_tools_dir/dagapi.o
|
|
||||||
elif test -r $dag_lib_dir/dagapi.o; then
|
|
||||||
# 2.5.x.
|
|
||||||
dagapi_obj=$dag_lib_dir/dagapi.o
|
|
||||||
elif test -r $dag_lib_dir/libdag.a; then
|
|
||||||
# 2.5.x.
|
|
||||||
ar x $dag_lib_dir/libdag.a dagapi.o
|
|
||||||
if test -r ./dagapi.o; then
|
|
||||||
dagapi_obj=./dagapi.o
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test $dagapi_obj = no; then
|
|
||||||
AC_MSG_RESULT([no (checked $dag_lib_dir $dag_tools_dir $dag_lib_dir/libdag.a)])
|
|
||||||
ac_cv_lbl_dag_api=no
|
|
||||||
else
|
|
||||||
AC_MSG_RESULT([yes ($dagapi_obj)])
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test $ac_cv_lbl_dag_api = yes; then
|
|
||||||
|
|
||||||
AC_MSG_CHECKING([dagopts.o])
|
|
||||||
dagopts_obj=no
|
|
||||||
if test -r $dag_tools_dir/dagopts.o; then
|
|
||||||
# 2.4.x.
|
|
||||||
dagopts_obj=$dag_tools_dir/dagopts.o
|
|
||||||
elif test -r $dag_lib_dir/dagopts.o; then
|
|
||||||
# 2.5.x.
|
|
||||||
dagopts_obj=$dag_lib_dir/dagopts.o
|
|
||||||
elif test -r $dag_lib_dir/libdag.a; then
|
|
||||||
# 2.5.x.
|
|
||||||
ar x $dag_lib_dir/libdag.a dagopts.o
|
|
||||||
if test -r ./dagopts.o; then
|
|
||||||
dagopts_obj=./dagopts.o
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test $dagopts_obj = no; then
|
|
||||||
AC_MSG_RESULT([no (checked $dag_lib_dir $dag_tools_dir $dag_lib_dir/libdag.a)])
|
|
||||||
ac_cv_lbl_dag_api=no
|
|
||||||
else
|
|
||||||
AC_MSG_RESULT([yes ($dagopts_obj)])
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test $ac_cv_lbl_dag_api = yes; then
|
|
||||||
# Under 2.5.x only we need to add dagreg.o.
|
|
||||||
if test -r $dag_include_dir/dagreg.h; then
|
|
||||||
AC_MSG_CHECKING([dagreg.o])
|
|
||||||
dagreg_obj=no
|
|
||||||
if test -r $dag_lib_dir/dagreg.o; then
|
|
||||||
# Object file is ready and waiting.
|
|
||||||
dagreg_obj=$dag_lib_dir/dagreg.o
|
|
||||||
elif test -r $dag_lib_dir/libdag.a; then
|
|
||||||
# Extract from libdag.a.
|
|
||||||
ar x $dag_lib_dir/libdag.a dagreg.o
|
|
||||||
if test -r ./dagreg.o; then
|
|
||||||
dagreg_obj=./dagreg.o
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test $dagreg_obj = no; then
|
|
||||||
AC_MSG_RESULT([no (checked $dag_lib_dir $dag_lib_dir/libdag.a)])
|
|
||||||
ac_cv_lbl_dag_api=no
|
|
||||||
else
|
|
||||||
AC_MSG_RESULT([yes ($dagreg_obj)])
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test $ac_cv_lbl_dag_api = yes; then
|
|
||||||
V_INCLS="$V_INCLS -I$dag_include_dir"
|
|
||||||
V_LIBS="$V_LIBS $dagapi_obj $dagopts_obj $dagreg_obj"
|
|
||||||
if test $V_PCAP != dag ; then
|
|
||||||
SSRC="pcap-dag.c"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# See if we can find a general version string.
|
|
||||||
# Don't need to save and restore LIBS to prevent -ldag being
|
|
||||||
# included if there's a found-action (arg 3).
|
|
||||||
saved_ldflags=$LDFLAGS
|
|
||||||
LDFLAGS="-L$dag_lib_dir"
|
|
||||||
AC_CHECK_LIB([dag], [dag_attach_stream], [dag_version="2.5.x"], [dag_version="2.4.x"])
|
|
||||||
LDFLAGS=$saved_ldflags
|
|
||||||
|
|
||||||
if test "$dag_version" = 2.5.x; then
|
|
||||||
AC_DEFINE(HAVE_DAG_STREAMS_API, 1, [define if you have streams capable DAG API])
|
|
||||||
fi
|
|
||||||
|
|
||||||
# See if we can find a specific version string.
|
|
||||||
AC_MSG_CHECKING([the DAG API version])
|
|
||||||
if test -r "$dag_root/VERSION"; then
|
|
||||||
dag_version="`cat $dag_root/VERSION`"
|
|
||||||
fi
|
|
||||||
AC_MSG_RESULT([$dag_version])
|
|
||||||
AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API])
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test $ac_cv_lbl_dag_api = no; then
|
|
||||||
if test "$want_dag" = yes; then
|
|
||||||
# User wanted DAG support but we couldn't find it.
|
|
||||||
AC_MSG_ERROR([DAG API requested, but not found at $dag_root: use --without-dag])
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test "$V_PCAP" = dag; then
|
|
||||||
# User requested "dag" capture type but the DAG API wasn't
|
|
||||||
# found.
|
|
||||||
AC_MSG_ERROR([Specifying the capture type as "dag" requires the DAG API to be present; use the --with-dag options to specify the location. (Try "./configure --help" for more information.)])
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
AC_ARG_WITH(septel, [ --with-septel[[=DIR]] include Septel support (located in directory DIR, if supplied). [default=yes, on Linux, if present]],
|
|
||||||
[
|
|
||||||
if test "$withval" = no
|
|
||||||
then
|
|
||||||
want_septel=no
|
|
||||||
elif test "$withval" = yes
|
|
||||||
then
|
|
||||||
want_septel=yes
|
|
||||||
septel_root=
|
|
||||||
else
|
|
||||||
want_septel=yes
|
|
||||||
septel_root=$withval
|
|
||||||
fi
|
|
||||||
],[
|
|
||||||
#
|
|
||||||
# Use Septel API if present, otherwise don't
|
|
||||||
#
|
|
||||||
want_septel=ifpresent
|
|
||||||
septel_root=./../septel
|
|
||||||
])
|
|
||||||
ac_cv_lbl_septel_api=no
|
|
||||||
case "$V_PCAP" in
|
|
||||||
linux|septel)
|
|
||||||
#
|
|
||||||
# We support the Septel API if we're on Linux, or if we're building
|
|
||||||
# a Septel-only libpcap.
|
|
||||||
#
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
#
|
|
||||||
# If the user explicitly requested Septel, tell them it's not
|
|
||||||
# supported.
|
|
||||||
#
|
|
||||||
# If they expressed no preference, don't include it.
|
|
||||||
#
|
|
||||||
if test $want_septel = yes; then
|
|
||||||
AC_MSG_ERROR(Septel support only available with 'linux' and 'septel' packet capture types)
|
|
||||||
elif test $want_septel = yes; then
|
|
||||||
want_septel=no
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if test "$with_septel" != no; then
|
|
||||||
AC_MSG_CHECKING(whether we have Septel API)
|
|
||||||
|
|
||||||
if test -z "$septel_root"; then
|
|
||||||
septel_root=$srcdir/../septel
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
septel_tools_dir="$septel_root"
|
|
||||||
septel_include_dir="$septel_root/INC"
|
|
||||||
DEF="-DHAVE_SEPTEL_API"
|
|
||||||
|
|
||||||
ac_cv_lbl_septel_api=no
|
|
||||||
if test -r "$septel_include_dir/msg.h"; then
|
|
||||||
V_INCLS="$V_INCLS -I$septel_include_dir"
|
|
||||||
V_DEFS="$V_DEFS $DEF"
|
|
||||||
V_LIBS="$V_LIBS $septel_tools_dir/asciibin.o $septel_tools_dir/bit2byte.o $septel_tools_dir/confirm.o $septel_tools_dir/fmtmsg.o $septel_tools_dir/gct_unix.o $septel_tools_dir/hqueue.o $septel_tools_dir/ident.o $septel_tools_dir/mem.o $septel_tools_dir/pack.o $septel_tools_dir/parse.o $septel_tools_dir/pool.o $septel_tools_dir/sdlsig.o $septel_tools_dir/strtonum.o $septel_tools_dir/timer.o $septel_tools_dir/trace.o "
|
|
||||||
|
|
||||||
if test "$V_PCAP" != septel ; then
|
|
||||||
SSRC="pcap-septel.c"
|
|
||||||
|
|
||||||
fi
|
|
||||||
ac_cv_lbl_septel_api=yes
|
|
||||||
fi
|
|
||||||
|
|
||||||
AC_MSG_RESULT($ac_cv_lbl_septel_api)
|
|
||||||
if test $ac_cv_lbl_septel_api = no; then
|
|
||||||
if test "$want_septel" = yes; then
|
|
||||||
AC_MSG_ERROR(Septel API not found under directory $septel_root; use --without-septel)
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
AC_DEFINE(HAVE_SEPTEL_API, 1, [define if you have a Septel API])
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test "$V_PCAP" = septel -a "$ac_cv_lbl_septel_api" = no; then
|
|
||||||
AC_MSG_ERROR(Specifying the capture type as 'septel' requires the Septel API to be present; use --with-septel=DIR)
|
|
||||||
fi
|
|
||||||
|
|
||||||
DYEXT="so"
|
|
||||||
case "$host_os" in
|
|
||||||
|
|
||||||
aix*)
|
|
||||||
dnl Workaround to enable certain features
|
|
||||||
AC_DEFINE(_SUN,1,[define on AIX to get certain functions])
|
|
||||||
;;
|
|
||||||
|
|
||||||
hpux9*)
|
|
||||||
AC_DEFINE(HAVE_HPUX9,1,[on HP-UX 9.x])
|
|
||||||
;;
|
|
||||||
|
|
||||||
hpux10.0*)
|
|
||||||
;;
|
|
||||||
|
|
||||||
hpux10.1*)
|
|
||||||
;;
|
|
||||||
|
|
||||||
hpux*)
|
|
||||||
dnl HPUX 10.20 and above is similar to HPUX 9, but
|
|
||||||
dnl not the same....
|
|
||||||
dnl
|
|
||||||
dnl XXX - DYEXT should be set to "sl" if this is building
|
|
||||||
dnl for 32-bit PA-RISC, but should be left as "so" for
|
|
||||||
dnl 64-bit PA-RISC or, I suspect, IA-64.
|
|
||||||
AC_DEFINE(HAVE_HPUX10_20_OR_LATER,1,[on HP-UX 10.20 or later])
|
|
||||||
;;
|
|
||||||
|
|
||||||
sinix*)
|
|
||||||
AC_MSG_CHECKING(if SINIX compiler defines sinix)
|
|
||||||
AC_CACHE_VAL(ac_cv_cc_sinix_defined,
|
|
||||||
AC_TRY_COMPILE(
|
|
||||||
[],
|
|
||||||
[int i = sinix;],
|
|
||||||
ac_cv_cc_sinix_defined=yes,
|
|
||||||
ac_cv_cc_sinix_defined=no))
|
|
||||||
AC_MSG_RESULT($ac_cv_cc_sinix_defined)
|
|
||||||
if test $ac_cv_cc_sinix_defined = no ; then
|
|
||||||
AC_DEFINE(sinix,1,[on sinix])
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
|
|
||||||
solaris*)
|
|
||||||
AC_DEFINE(HAVE_SOLARIS,1,[On solaris])
|
|
||||||
;;
|
|
||||||
|
|
||||||
darwin*)
|
|
||||||
DYEXT="dylib"
|
|
||||||
V_CCOPT="$V_CCOPT -fno-common"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
AC_PROG_RANLIB
|
|
||||||
|
|
||||||
AC_LBL_DEVEL(V_CCOPT)
|
|
||||||
|
|
||||||
AC_LBL_SOCKADDR_SA_LEN
|
|
||||||
|
|
||||||
AC_LBL_SOCKADDR_STORAGE
|
|
||||||
|
|
||||||
AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1
|
|
||||||
|
|
||||||
AC_LBL_UNALIGNED_ACCESS
|
|
||||||
|
|
||||||
pcap_gcc_major_version=0
|
|
||||||
AC_MSG_CHECKING([whether the compiler is gcc 4 or greater])
|
|
||||||
if test x"$GCC" = xno; then
|
|
||||||
AC_MSG_RESULT([no])
|
|
||||||
else
|
|
||||||
# new major versions must be added here
|
|
||||||
case `$CC --version | sed -e 's,\..*,.,' -e q` in
|
|
||||||
*4.)
|
|
||||||
pcap_gcc_major_version=4
|
|
||||||
;;
|
|
||||||
*3.)
|
|
||||||
pcap_gcc_major_version=3
|
|
||||||
;;
|
|
||||||
*2.)
|
|
||||||
pcap_gcc_major_version=2
|
|
||||||
;;
|
|
||||||
*1.)
|
|
||||||
pcap_gcc_major_version=1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
if test "$pcap_gcc_major_version" -ge 4; then
|
|
||||||
AC_MSG_RESULT([yes])
|
|
||||||
else
|
|
||||||
AC_MSG_RESULT([no - $pcap_gcc_major_version ; $CC ; $GCC])
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Remember that all following tests will run with this CXXFLAGS by default
|
|
||||||
if test "$pcap_gcc_major_version" -ge 4; then
|
|
||||||
V_CCOPT="$V_CCOPT -fno-strict-aliasing"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Makefile.in includes rules to generate version.h, so we assume
|
|
||||||
# that it will be generated if autoconf is used.
|
|
||||||
#
|
|
||||||
AC_DEFINE(HAVE_VERSION_H, 1, [define if version.h is generated in the build procedure])
|
|
||||||
|
|
||||||
rm -f net
|
|
||||||
ln -s ${srcdir}/bpf/net net
|
|
||||||
|
|
||||||
AC_SUBST(V_CCOPT)
|
|
||||||
AC_SUBST(V_DEFS)
|
|
||||||
AC_SUBST(V_INCLS)
|
|
||||||
AC_SUBST(V_LIBS)
|
|
||||||
AC_SUBST(V_PCAP)
|
|
||||||
AC_SUBST(V_FINDALLDEVS)
|
|
||||||
AC_SUBST(V_RANLIB)
|
|
||||||
AC_SUBST(SSRC)
|
|
||||||
AC_SUBST(DYEXT)
|
|
||||||
|
|
||||||
AC_PROG_INSTALL
|
|
||||||
|
|
||||||
AC_CONFIG_HEADER(config.h)
|
|
||||||
|
|
||||||
AC_OUTPUT(Makefile)
|
|
||||||
|
|
||||||
if test -f .devel ; then
|
|
||||||
make depend
|
|
||||||
fi
|
|
||||||
exit 0
|
|
||||||
@@ -1,997 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html lang="en"><head><title>PCAP New Generation Dump File Format</title>
|
|
||||||
<meta name="description" content="PCAP New Generation Dump File Format">
|
|
||||||
<meta name="keywords" content="Internet-Draft, Libpcap, dump file format">
|
|
||||||
<meta name="generator" content="xml2rfc v1.22 (http://xml.resource.org/)">
|
|
||||||
<style type='text/css'>
|
|
||||||
<!--
|
|
||||||
body {
|
|
||||||
font-family: verdana, charcoal, helvetica, arial, sans-serif;
|
|
||||||
font-size: small ; color: #000000 ; background-color: #ffffff ; }
|
|
||||||
.title { color: #990000; font-size: x-large ;
|
|
||||||
font-weight: bold; text-align: right;
|
|
||||||
font-family: helvetica, monaco, "MS Sans Serif", arial, sans-serif;
|
|
||||||
background-color: transparent; }
|
|
||||||
.filename { color: #666666; font-size: 18px; line-height: 28px;
|
|
||||||
font-weight: bold; text-align: right;
|
|
||||||
font-family: helvetica, arial, sans-serif;
|
|
||||||
background-color: transparent; }
|
|
||||||
td.rfcbug { background-color: #000000 ; width: 30px ; height: 30px ;
|
|
||||||
text-align: justify; vertical-align: middle ; padding-top: 2px ; }
|
|
||||||
td.rfcbug span.RFC { color: #666666; font-weight: bold; text-decoration: none;
|
|
||||||
background-color: #000000 ;
|
|
||||||
font-family: monaco, charcoal, geneva, "MS Sans Serif", helvetica, verdana, sans-serif;
|
|
||||||
font-size: x-small ; }
|
|
||||||
td.rfcbug span.hotText { color: #ffffff; font-weight: normal; text-decoration: none;
|
|
||||||
text-align: center ;
|
|
||||||
font-family: charcoal, monaco, geneva, "MS Sans Serif", helvetica, verdana, sans-serif;
|
|
||||||
font-size: x-small ; background-color: #000000; }
|
|
||||||
|
|
||||||
A { font-weight: bold; }
|
|
||||||
A:link { color: #990000; background-color: transparent ; }
|
|
||||||
A:visited { color: #333333; background-color: transparent ; }
|
|
||||||
A:active { color: #333333; background-color: transparent ; }
|
|
||||||
|
|
||||||
p { margin-left: 2em; margin-right: 2em; }
|
|
||||||
p.copyright { font-size: x-small ; }
|
|
||||||
p.toc { font-size: small ; font-weight: bold ; margin-left: 3em ;}
|
|
||||||
|
|
||||||
span.emph { font-style: italic; }
|
|
||||||
span.strong { font-weight: bold; }
|
|
||||||
span.verb { font-family: "Courier New", Courier, monospace ; }
|
|
||||||
|
|
||||||
ol.text { margin-left: 2em; margin-right: 2em; }
|
|
||||||
ul.text { margin-left: 2em; margin-right: 2em; }
|
|
||||||
li { margin-left: 3em; }
|
|
||||||
|
|
||||||
pre { margin-left: 3em; color: #333333; background-color: transparent;
|
|
||||||
font-family: "Courier New", Courier, monospace ; font-size: small ;
|
|
||||||
}
|
|
||||||
|
|
||||||
h3 { color: #333333; font-size: medium ;
|
|
||||||
font-family: helvetica, arial, sans-serif ;
|
|
||||||
background-color: transparent; }
|
|
||||||
h4 { font-size: small; font-family: helvetica, arial, sans-serif ; }
|
|
||||||
|
|
||||||
table.bug { width: 30px ; height: 15px ; }
|
|
||||||
td.bug { color: #ffffff ; background-color: #990000 ;
|
|
||||||
text-align: center ; width: 30px ; height: 15px ;
|
|
||||||
}
|
|
||||||
td.bug A.link2 { color: #ffffff ; font-weight: bold;
|
|
||||||
text-decoration: none;
|
|
||||||
font-family: monaco, charcoal, geneva, "MS Sans Serif", helvetica, sans-serif;
|
|
||||||
font-size: x-small ; background-color: transparent }
|
|
||||||
|
|
||||||
td.header { color: #ffffff; font-size: x-small ;
|
|
||||||
font-family: arial, helvetica, sans-serif; vertical-align: top;
|
|
||||||
background-color: #666666 ; width: 33% ; }
|
|
||||||
td.author { font-weight: bold; margin-left: 4em; font-size: x-small ; }
|
|
||||||
td.author-text { font-size: x-small; }
|
|
||||||
table.data { vertical-align: top ; border-collapse: collapse ;
|
|
||||||
border-style: solid solid solid solid ;
|
|
||||||
border-color: black black black black ;
|
|
||||||
font-size: small ; text-align: center ; }
|
|
||||||
table.data th { font-weight: bold ;
|
|
||||||
border-style: solid solid solid solid ;
|
|
||||||
border-color: black black black black ; }
|
|
||||||
table.data td {
|
|
||||||
border-style: solid solid solid solid ;
|
|
||||||
border-color: #333333 #333333 #333333 #333333 ; }
|
|
||||||
|
|
||||||
hr { height: 1px }
|
|
||||||
-->
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<table summary="layout" cellpadding="0" cellspacing="2" class="bug" align="right"><tr><td class="bug"><a href="#toc" class="link2"> TOC </a></td></tr></table>
|
|
||||||
<table summary="layout" width="66%" border="0" cellpadding="0" cellspacing="0"><tr><td><table summary="layout" width="100%" border="0" cellpadding="2" cellspacing="1">
|
|
||||||
<tr><td class="header">Network Working Group</td><td class="header">L. Degioanni</td></tr>
|
|
||||||
<tr><td class="header">Internet-Draft</td><td class="header">F. Risso</td></tr>
|
|
||||||
<tr><td class="header">Expires: August 30, 2004</td><td class="header">Politecnico di Torino</td></tr>
|
|
||||||
<tr><td class="header"> </td><td class="header">March 2004</td></tr>
|
|
||||||
</table></td></tr></table>
|
|
||||||
<div align="right"><span class="title"><br />PCAP New Generation Dump File Format</span></div>
|
|
||||||
<div align="right"><span class="title"><br />pcap</span></div>
|
|
||||||
|
|
||||||
<h3>Status of this Memo</h3>
|
|
||||||
<p>
|
|
||||||
This document is an Internet-Draft and is
|
|
||||||
in full conformance with all provisions of Section 10 of RFC2026.</p>
|
|
||||||
<p>
|
|
||||||
Internet-Drafts are working documents of the Internet Engineering
|
|
||||||
Task Force (IETF), its areas, and its working groups.
|
|
||||||
Note that other groups may also distribute working documents as
|
|
||||||
Internet-Drafts.</p>
|
|
||||||
<p>
|
|
||||||
Internet-Drafts are draft documents valid for a maximum of six months
|
|
||||||
and may be updated, replaced, or obsoleted by other documents at any time.
|
|
||||||
It is inappropriate to use Internet-Drafts as reference material or to cite
|
|
||||||
them other than as "work in progress."</p>
|
|
||||||
<p>
|
|
||||||
The list of current Internet-Drafts can be accessed at
|
|
||||||
<a href='http://www.ietf.org/ietf/1id-abstracts.txt'>http://www.ietf.org/ietf/1id-abstracts.txt</a>.</p>
|
|
||||||
<p>
|
|
||||||
The list of Internet-Draft Shadow Directories can be accessed at
|
|
||||||
<a href='http://www.ietf.org/shadow.html'>http://www.ietf.org/shadow.html</a>.</p>
|
|
||||||
<p>
|
|
||||||
This Internet-Draft will expire on August 30, 2004.</p>
|
|
||||||
|
|
||||||
<h3>Copyright Notice</h3>
|
|
||||||
<p>
|
|
||||||
Copyright (C) The Internet Society (2004). All Rights Reserved.</p>
|
|
||||||
|
|
||||||
<h3>Abstract</h3>
|
|
||||||
|
|
||||||
<p>This document describes a format to dump captured packets on a file. This format is extensible and it is currently proposed for implementation in the libpcap/WinPcap packet capture library.
|
|
||||||
</p><a name="toc"></a><br /><hr />
|
|
||||||
<h3>Table of Contents</h3>
|
|
||||||
<p class="toc">
|
|
||||||
<a href="#anchor1">1.</a>
|
|
||||||
Objectives<br />
|
|
||||||
<a href="#anchor2">2.</a>
|
|
||||||
General File Structure<br />
|
|
||||||
<a href="#sectionblock">2.1</a>
|
|
||||||
General Block Structure<br />
|
|
||||||
<a href="#anchor3">2.2</a>
|
|
||||||
Block Types<br />
|
|
||||||
<a href="#anchor4">2.3</a>
|
|
||||||
Block Hierarchy and Precedence<br />
|
|
||||||
<a href="#anchor5">2.4</a>
|
|
||||||
Data format<br />
|
|
||||||
<a href="#anchor6">3.</a>
|
|
||||||
Block Definition<br />
|
|
||||||
<a href="#sectionshb">3.1</a>
|
|
||||||
Section Header Block (mandatory)<br />
|
|
||||||
<a href="#sectionidb">3.2</a>
|
|
||||||
Interface Description Block (mandatory)<br />
|
|
||||||
<a href="#sectionpb">3.3</a>
|
|
||||||
Packet Block (optional)<br />
|
|
||||||
<a href="#anchor7">3.4</a>
|
|
||||||
Simple Packet Block (optional)<br />
|
|
||||||
<a href="#anchor8">3.5</a>
|
|
||||||
Name Resolution Block (optional)<br />
|
|
||||||
<a href="#anchor9">3.6</a>
|
|
||||||
Interface Statistics Block (optional)<br />
|
|
||||||
<a href="#sectionopt">4.</a>
|
|
||||||
Options<br />
|
|
||||||
<a href="#anchor10">5.</a>
|
|
||||||
Experimental Blocks (deserved to a further investigation)<br />
|
|
||||||
<a href="#anchor11">5.1</a>
|
|
||||||
Other Packet Blocks (experimental)<br />
|
|
||||||
<a href="#anchor12">5.2</a>
|
|
||||||
Compression Block (experimental)<br />
|
|
||||||
<a href="#anchor13">5.3</a>
|
|
||||||
Encryption Block (experimental)<br />
|
|
||||||
<a href="#anchor14">5.4</a>
|
|
||||||
Fixed Length Block (experimental)<br />
|
|
||||||
<a href="#anchor15">5.5</a>
|
|
||||||
Directory Block (experimental)<br />
|
|
||||||
<a href="#anchor16">5.6</a>
|
|
||||||
Traffic Statistics and Monitoring Blocks (experimental)<br />
|
|
||||||
<a href="#anchor17">5.7</a>
|
|
||||||
Event/Security Block (experimental)<br />
|
|
||||||
<a href="#anchor18">6.</a>
|
|
||||||
Conclusions<br />
|
|
||||||
<a href="#anchor19">7.</a>
|
|
||||||
Most important open issues<br />
|
|
||||||
<a href="#rfc.copyright">§</a>
|
|
||||||
Intellectual Property and Copyright Statements<br />
|
|
||||||
</p>
|
|
||||||
<br clear="all" />
|
|
||||||
|
|
||||||
<a name="anchor1"></a><br /><hr />
|
|
||||||
<table summary="layout" cellpadding="0" cellspacing="2" class="bug" align="right"><tr><td class="bug"><a href="#toc" class="link2"> TOC </a></td></tr></table>
|
|
||||||
<a name="rfc.section.1"></a><h3>1. Objectives</h3>
|
|
||||||
|
|
||||||
<p>The problem of exchanging packet traces becomes more and more critical every day; unfortunately, no standard solutions exist for this task right now. One of the most accepted packet interchange formats is the one defined by libpcap, which is rather old and does not fit for some of the nowadays applications especially in terms of extensibility.
|
|
||||||
</p>
|
|
||||||
<p>This document proposes a new format for dumping packet traces. The following goals are being pursued:
|
|
||||||
</p>
|
|
||||||
<ul class="text">
|
|
||||||
<li>Extensibility: aside of some common functionalities, third parties should be able to enrich the information embedded in the file with proprietary extensions, which will be ignored by tools that are not able to understand them.
|
|
||||||
</li>
|
|
||||||
<li>Portability: a capture trace must contain all the information needed to read data independently from network, hardware and operating system of the machine that made the capture.
|
|
||||||
</li>
|
|
||||||
<li>Merge/Append data: it should be possible to add data at the end of a given file, and the resulting file must still be readable.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<a name="anchor2"></a><br /><hr />
|
|
||||||
<table summary="layout" cellpadding="0" cellspacing="2" class="bug" align="right"><tr><td class="bug"><a href="#toc" class="link2"> TOC </a></td></tr></table>
|
|
||||||
<a name="rfc.section.2"></a><h3>2. General File Structure</h3>
|
|
||||||
|
|
||||||
<a name="rfc.section.2.1"></a><h4><a name="sectionblock">2.1</a> General Block Structure</h4>
|
|
||||||
|
|
||||||
<p>A capture file is organized in blocks, that are appended one to another to form the file. All the blocks share a common format, which is shown in <a href="#formatblock">Figure 1</a>.
|
|
||||||
</p><br /><hr />
|
|
||||||
<a name="formatblock"></a>
|
|
||||||
<pre>
|
|
||||||
0 1 2 3
|
|
||||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Block Type |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Block Total Length |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
/ Block Body /
|
|
||||||
/ /* variable length, aligned to 32 bits */ /
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Block Total Length |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
</pre>
|
|
||||||
<table border="0" cellpadding="0" cellspacing="2" align="center"><tr><td align="center"><font face="monaco, MS Sans Serif" size="1"><b> Basic block structure. </b></font><br /></td></tr></table><hr size="1" shade="0">
|
|
||||||
|
|
||||||
<p>The fields have the following meaning:
|
|
||||||
</p>
|
|
||||||
<ul class="text">
|
|
||||||
<li>Block Type (32 bits): unique value that identifies the block. Values whose Most Significant Bit (MSB) is equal to 1 are reserved for local use. They allow to save private data to the file and to extend the file format.
|
|
||||||
</li>
|
|
||||||
<li>Block Total Length: total size of this block, in bytes. For instance, a block that does not have a body has a length of 12 bytes.
|
|
||||||
</li>
|
|
||||||
<li>Block Body: content of the block.
|
|
||||||
</li>
|
|
||||||
<li>Block Total Length: total size of this block, in bytes. This field is duplicated for permitting backward file navigation.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<p>This structure, shared among all blocks, makes easy to process a file and to skip unneeded or unknown blocks. Blocks can be nested one inside the others (NOTE: needed?). Some of the blocks are mandatory, i.e. a dump file is not valid if they are not present, other are optional.
|
|
||||||
</p>
|
|
||||||
<p>The structure of the blocks allows to define other blocks if needed. A parser that does non understand them can simply ignore their content.
|
|
||||||
</p>
|
|
||||||
<a name="rfc.section.2.2"></a><h4><a name="anchor3">2.2</a> Block Types</h4>
|
|
||||||
|
|
||||||
<p>The currently defined blocks are the following:
|
|
||||||
</p>
|
|
||||||
<ol class="text">
|
|
||||||
<li>Section Header Block: it defines the most important characteristics of the capture file.
|
|
||||||
</li>
|
|
||||||
<li>Interface Description Block: it defines the most important characteristics of the interface(s) used for capturing traffic.
|
|
||||||
</li>
|
|
||||||
<li>Packet Block: it contains a single captured packet, or a portion of it.
|
|
||||||
</li>
|
|
||||||
<li>Simple Packet Block: it contains a single captured packet, or a portion of it, with only a minimal set of information about it.
|
|
||||||
</li>
|
|
||||||
<li>Name Resolution Block: it defines the mapping from numeric addresses present in the packet dump and the canonical name counterpart.
|
|
||||||
</li>
|
|
||||||
<li>Capture Statistics Block: it defines how to store some statistical data (e.g. packet dropped, etc) which can be useful to undestand the conditions in which the capture has been made.
|
|
||||||
</li>
|
|
||||||
<li>Compression Marker Block: TODO
|
|
||||||
</li>
|
|
||||||
<li>Encryption Marker Block: TODO
|
|
||||||
</li>
|
|
||||||
<li>Fixed Length Marker Block: TODO
|
|
||||||
</li>
|
|
||||||
</ol>
|
|
||||||
<p>The following blocks instead are considered interesting but the authors believe that they deserve more in-depth discussion before being defined:
|
|
||||||
</p>
|
|
||||||
<ol class="text">
|
|
||||||
<li>Further Packet Blocks
|
|
||||||
</li>
|
|
||||||
<li>Directory Block
|
|
||||||
</li>
|
|
||||||
<li>Traffic Statistics and Monitoring Blocks
|
|
||||||
</li>
|
|
||||||
<li>Alert and Security Blocks
|
|
||||||
</li>
|
|
||||||
</ol>
|
|
||||||
<p>TODO Currently standardized Block Type codes are specified in Appendix 1.
|
|
||||||
</p>
|
|
||||||
<a name="rfc.section.2.3"></a><h4><a name="anchor4">2.3</a> Block Hierarchy and Precedence</h4>
|
|
||||||
|
|
||||||
<p>The file must begin with a Section Header Block. However, more than one Section Header Block can be present on the dump, each one covering the data following it till the next one (or the end of file). A Section includes the data delimited by two Section Header Blocks (or by a Section Header Block and the end of the file), including the first Section Header Block.
|
|
||||||
</p>
|
|
||||||
<p>In case an application cannot read a Section because of different version number, it must skip everything until the next Section Header Block. Note that, in order to properly skip the blocks until the next section, all blocks must have the fields Type and Length at the beginning. This is a mandatory requirement that must be maintained in future versions of the block format.
|
|
||||||
</p>
|
|
||||||
<p><a href="#fssample-SHB">Figure 2</a> shows two valid files: the first has a typical configuration, with a single Section Header that covers the whole file. The second one contains three headers, and is normally the result of file concatenation. An application that understands only version 1.0 of the file format skips the intermediate section and restart processing the packets after the third Section Header.
|
|
||||||
</p><br /><hr />
|
|
||||||
<a name="fssample-SHB"></a>
|
|
||||||
<pre>
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| SHB v1.0 | Data |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
Typical configuration with a single Section Header Block
|
|
||||||
|
|
||||||
|
|
||||||
|-- 1st Section --|-- 2nd Section --|-- 3rd Section --|
|
|
||||||
| |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| SHB v1.0 | Data | SHB V1.1 | Data | SHB V1.0 | Data |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
Configuration with three different Section Header Blocks
|
|
||||||
</pre>
|
|
||||||
<table border="0" cellpadding="0" cellspacing="2" align="center"><tr><td align="center"><font face="monaco, MS Sans Serif" size="1"><b> File structure example: the Section Header Block. </b></font><br /></td></tr></table><hr size="1" shade="0">
|
|
||||||
|
|
||||||
<p>NOTE: TO BE COMPLETED with some examples of other blocks
|
|
||||||
</p>
|
|
||||||
<a name="rfc.section.2.4"></a><h4><a name="anchor5">2.4</a> Data format</h4>
|
|
||||||
|
|
||||||
<p>Data contained in each section will always be saved according to the characteristics (little endian / big endian) of the dumping machine. This refers to all fields that are saved as numbers and that span over two or more bytes.
|
|
||||||
</p>
|
|
||||||
<p>The approach of having each section saved in the native format of the generating host is more efficient because it avoids translation of data when reading / writing on the host itself, which is the most common case when generating/processing capture dumps.
|
|
||||||
</p>
|
|
||||||
<p>TODO Probably we have to specify something more here. Is what we're saying enough to avoid any kind of ambiguity?.
|
|
||||||
</p>
|
|
||||||
<a name="anchor6"></a><br /><hr />
|
|
||||||
<table summary="layout" cellpadding="0" cellspacing="2" class="bug" align="right"><tr><td class="bug"><a href="#toc" class="link2"> TOC </a></td></tr></table>
|
|
||||||
<a name="rfc.section.3"></a><h3>3. Block Definition</h3>
|
|
||||||
|
|
||||||
<p>This section details the format of the body of the blocks currently defined.
|
|
||||||
</p>
|
|
||||||
<a name="rfc.section.3.1"></a><h4><a name="sectionshb">3.1</a> Section Header Block (mandatory)</h4>
|
|
||||||
|
|
||||||
<p>The Section Header Block is mandatory. It identifies the beginning of a section of the capture dump file. Its format is shown in <a href="#formatSHB">Figure 3</a>.
|
|
||||||
</p><br /><hr />
|
|
||||||
<a name="formatSHB"></a>
|
|
||||||
<pre>
|
|
||||||
0 1 2 3
|
|
||||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Magic |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Major | Minor |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
/ /
|
|
||||||
/ Options (variable) /
|
|
||||||
/ /
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
</pre>
|
|
||||||
<table border="0" cellpadding="0" cellspacing="2" align="center"><tr><td align="center"><font face="monaco, MS Sans Serif" size="1"><b> Section Header Block format. </b></font><br /></td></tr></table><hr size="1" shade="0">
|
|
||||||
|
|
||||||
<p>The meaning of the fields is:
|
|
||||||
</p>
|
|
||||||
<ul class="text">
|
|
||||||
<li>Magic: magic number, whose value is the hexadecimal number 0x1A2B3C4D. This number can be used to distinguish section that have been saved on little-endian machines from the one saved on big-endian machines.
|
|
||||||
</li>
|
|
||||||
<li>Major: number of the current mayor version of the format. Current value is 1.
|
|
||||||
</li>
|
|
||||||
<li>Minor: number of the current minor version of the format. Current value is 0.
|
|
||||||
</li>
|
|
||||||
<li>Options: optionally, a list of options (formatted according to the rules defined in <a href="#sectionopt">Section 4</a>) can be present.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<p>Aside form the options defined in <a href="#sectionopt">Section 4</a>, the following options are valid within this block:
|
|
||||||
</p><a name="InterfaceOptions1"></a>
|
|
||||||
<table class="data" align="center" border="1" cellpadding="2" cellspacing="2">
|
|
||||||
<tr>
|
|
||||||
<th align="left" width="25%">Name</th>
|
|
||||||
<th align="left" width="25%">Code</th>
|
|
||||||
<th align="left" width="25%">Length</th>
|
|
||||||
<th align="left" width="25%">Description</th>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">Hardware</td>
|
|
||||||
<td align="left">2</td>
|
|
||||||
<td align="left">variable</td>
|
|
||||||
<td align="left">An ascii string containing the description of the hardware used to create this section.</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">Operating System</td>
|
|
||||||
<td align="left">3</td>
|
|
||||||
<td align="left">variable</td>
|
|
||||||
<td align="left">An ascii string containing the name of the operating system used to create this section.</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">User Application</td>
|
|
||||||
<td align="left">3</td>
|
|
||||||
<td align="left">variable</td>
|
|
||||||
<td align="left">An ascii string containing the name of the application used to create this section.</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<p>The Section Header Block does not contain data but it rather identifies a list of blocks (interfaces, packets) that are logically correlated. This block does not contain any reference to the size of the section it is currently delimiting, therefore the reader cannot skip a whole section at once. In case a section must be skipped, the user has to repeatedly skip all the blocks contained within it; this makes the parsing of the file slower but it permits to append several capture dumps at the same file.
|
|
||||||
</p>
|
|
||||||
<a name="rfc.section.3.2"></a><h4><a name="sectionidb">3.2</a> Interface Description Block (mandatory)</h4>
|
|
||||||
|
|
||||||
<p>The Interface Description Block is mandatory. This block is needed to specify the characteristics of the network interface on which the capture has been made. In order to properly associate the captured data to the corresponding interface, the Interface Description Block must be defined before any other block that uses it; therefore, this block is usually placed immediately after the Section Header Block.
|
|
||||||
</p>
|
|
||||||
<p>An Interface Description Block is valid only inside the section which it belongs to. The structure of a Interface Description Block is shown in <a href="#formatidb">Figure 4</a>.
|
|
||||||
</p><br /><hr />
|
|
||||||
<a name="formatidb"></a>
|
|
||||||
<pre>
|
|
||||||
0 1 2 3
|
|
||||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Interface ID | LinkType |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| SnapLen |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
/ /
|
|
||||||
/ Options (variable) /
|
|
||||||
/ /
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
</pre>
|
|
||||||
<table border="0" cellpadding="0" cellspacing="2" align="center"><tr><td align="center"><font face="monaco, MS Sans Serif" size="1"><b> Interface Description Block format. </b></font><br /></td></tr></table><hr size="1" shade="0">
|
|
||||||
|
|
||||||
<p>The meaning of the fields is:
|
|
||||||
</p>
|
|
||||||
<ul class="text">
|
|
||||||
<li>Interface ID: a progressive number that identifies uniquely any interface inside current section. Two Interface Description Blocks can have the same Interface ID only if they are in different sections of the file. The Interface ID is referenced by the packet blocks.
|
|
||||||
</li>
|
|
||||||
<li>LinkType: a value that defines the link layer type of this interface.
|
|
||||||
</li>
|
|
||||||
<li>SnapLen: maximum number of bytes dumped from each packet. The portion of each packet that exceeds this value will not be stored in the file.
|
|
||||||
</li>
|
|
||||||
<li>Options: optionally, a list of options (formatted according to the rules defined in <a href="#sectionopt">Section 4</a>) can be present.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<p>In addition to the options defined in <a href="#sectionopt">Section 4</a>, the following options are valid within this block:
|
|
||||||
</p><a name="InterfaceOptions2"></a>
|
|
||||||
<table class="data" align="center" border="1" cellpadding="2" cellspacing="2">
|
|
||||||
<tr>
|
|
||||||
<th align="left" width="25%">Name</th>
|
|
||||||
<th align="left" width="25%">Code</th>
|
|
||||||
<th align="left" width="25%">Length</th>
|
|
||||||
<th align="left" width="25%">Description</th>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">if_name</td>
|
|
||||||
<td align="left">2</td>
|
|
||||||
<td align="left">Variable</td>
|
|
||||||
<td align="left">Name of the device used to capture data.</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">if_IPv4addr</td>
|
|
||||||
<td align="left">3</td>
|
|
||||||
<td align="left">8</td>
|
|
||||||
<td align="left">Interface network address and netmask.</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">if_IPv6addr</td>
|
|
||||||
<td align="left">4</td>
|
|
||||||
<td align="left">17</td>
|
|
||||||
<td align="left">Interface network address and prefix length (stored in the last byte).</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">if_MACaddr</td>
|
|
||||||
<td align="left">5</td>
|
|
||||||
<td align="left">6</td>
|
|
||||||
<td align="left">Interface Hardware MAC address (48 bits).</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">if_EUIaddr</td>
|
|
||||||
<td align="left">6</td>
|
|
||||||
<td align="left">8</td>
|
|
||||||
<td align="left">Interface Hardware EUI address (64 bits), if available.</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">if_speed</td>
|
|
||||||
<td align="left">7</td>
|
|
||||||
<td align="left">8</td>
|
|
||||||
<td align="left">Interface speed (in bps).</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">if_tsaccur</td>
|
|
||||||
<td align="left">8</td>
|
|
||||||
<td align="left">1</td>
|
|
||||||
<td align="left">Precision of timestamps. If the Most Significant Bit is equal to zero, the remaining bits indicates the accuracy as as a negative power of 10 (e.g. 6 means microsecond accuracy). If the Most Significant Bit is equal to zero, the remaining bits indicates the accuracy as as negative power of 2 (e.g. 10 means 1/1024 of second). If this option is not present, a precision of 10^-6 is assumed.</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">if_tzone</td>
|
|
||||||
<td align="left">9</td>
|
|
||||||
<td align="left">4</td>
|
|
||||||
<td align="left">Time zone for GMT support (TODO: specify better).</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">if_flags</td>
|
|
||||||
<td align="left">10</td>
|
|
||||||
<td align="left">4</td>
|
|
||||||
<td align="left">Interface flags. (TODO: specify better. Possible flags: promiscuous, inbound/outbound, traffic filtered during capture).</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">if_filter</td>
|
|
||||||
<td align="left">11</td>
|
|
||||||
<td align="left">variable</td>
|
|
||||||
<td align="left">The filter (e.g. "capture only TCP traffic") used to capture traffic. The first byte of the Option Data keeps a code of the filter used (e.g. if this is a libpcap string, or BPF bytecode, and more). More details about this format will be presented in Appendix XXX (TODO).</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">if_opersystem</td>
|
|
||||||
<td align="left">12</td>
|
|
||||||
<td align="left">variable</td>
|
|
||||||
<td align="left">An ascii string containing the name of the operating system of the machine that hosts this interface. This can be different from the same information that can be contained by the Section Header Block (<a href="#sectionshb">Section 3.1</a>) because the capture can have been done on a remote machine.</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<a name="rfc.section.3.3"></a><h4><a name="sectionpb">3.3</a> Packet Block (optional)</h4>
|
|
||||||
|
|
||||||
<p>A Packet Block is the standard container for storing the packets coming from the network. The Packet Block is optional because packets can be stored either by means of this block or the Simple Packet Block, which can be used to speed up dump generation. The format of a packet block is shown in <a href="#formatpb">Figure 5</a>.
|
|
||||||
</p><br /><hr />
|
|
||||||
<a name="formatpb"></a>
|
|
||||||
<pre>
|
|
||||||
0 1 2 3
|
|
||||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Interface ID | Drops Count |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Timestamp (High) |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Timestamp (Low) |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Captured Len |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Packet Len |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| |
|
|
||||||
| Packet Data |
|
|
||||||
| |
|
|
||||||
| /* variable length, byte-aligned */ |
|
|
||||||
| |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
/ /
|
|
||||||
/ Options (variable) /
|
|
||||||
/ /
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
</pre>
|
|
||||||
<table border="0" cellpadding="0" cellspacing="2" align="center"><tr><td align="center"><font face="monaco, MS Sans Serif" size="1"><b> Packet Block format. </b></font><br /></td></tr></table><hr size="1" shade="0">
|
|
||||||
|
|
||||||
<p>The Packet Block has the following fields:
|
|
||||||
</p>
|
|
||||||
<ul class="text">
|
|
||||||
<li>Interface ID: Specifies the interface this packet comes from, and corresponds to the ID of one of the Interface Description Blocks present in this section of the file (see <a href="#formatidb">Figure 4</a>).
|
|
||||||
</li>
|
|
||||||
<li>Drops Count: a local drop counter. It specified the number of packets lost (by the interface and the operating system) between this packet and the preceding one. The value xFFFF (in hexadecimal) is reserved for those systems in which this information is not available.
|
|
||||||
</li>
|
|
||||||
<li>Timestamp (High): the most significative part of the timestamp. in standard Unix format, i.e. from 1/1/1970.
|
|
||||||
</li>
|
|
||||||
<li>Timestamp (Low): the less significative part of the timestamp. The way to interpret this field is specified by the 'ts_accur' option (see <a href="#formatidb">Figure 4</a>) of the Interface Description block referenced by this packet. If the Interface Description block does not contain a 'ts_accur' option, then this field is expressed in microseconds.
|
|
||||||
</li>
|
|
||||||
<li>Captured Len: number of bytes captured from the packet (i.e. the length of the Packet Data field). It will be the minimum value among the actual Packet Length and the snapshot length (defined in <a href="#formatidb">Figure 4</a>).
|
|
||||||
</li>
|
|
||||||
<li>Packet Len: actual length of the packet when it was transmitted on the network. Can be different from Captured Len if the user wants only a snapshot of the packet.
|
|
||||||
</li>
|
|
||||||
<li>Packet Data: the data coming from the network, including link-layer headers. The length of this field is Captured Len. The format of the link-layer headers depends on the LinkType field specified in the Interface Description Block (see <a href="#sectionidb">Section 3.2</a>) and it is specified in Appendix XXX (TODO).
|
|
||||||
</li>
|
|
||||||
<li>Options: optionally, a list of options (formatted according to the rules defined in <a href="#sectionopt">Section 4</a>) can be present.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<p>
|
|
||||||
</p>
|
|
||||||
<a name="rfc.section.3.4"></a><h4><a name="anchor7">3.4</a> Simple Packet Block (optional)</h4>
|
|
||||||
|
|
||||||
<p>The Simple Packet Block is a lightweight container for storing the packets coming from the network. Its presence is optional.
|
|
||||||
</p>
|
|
||||||
<p>A Simple Packet Block is similar to a Packet Block (see <a href="#sectionpb">Section 3.3</a>), but it is smaller, simpler to process and contains only a minimal set of information. This block is preferred to the standard Packet Block when performance or space occupation are critical factors, such as in sustained traffic dump applications. A capture file can contain both Packet Blocks and Simple Packet Blocks: for example, a capture tool could switch from Packet Blocks to Simple Packet Blocks when the hardware resources become critical.
|
|
||||||
</p>
|
|
||||||
<p>The Simple Packet Block does not contain the Interface ID field. Therefore, it must be assumed that all the Simple Packet Blocks have been captured on the interface previously specified in the Interface Description Block.
|
|
||||||
</p>
|
|
||||||
<p><a href="#formatpbs">Figure 6</a> shows the format of the Simple Packet Block.
|
|
||||||
</p><br /><hr />
|
|
||||||
<a name="formatpbs"></a>
|
|
||||||
<pre>
|
|
||||||
0 1 2 3
|
|
||||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Packet Len |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| |
|
|
||||||
| Packet Data |
|
|
||||||
| |
|
|
||||||
| /* variable length, byte-aligned */ |
|
|
||||||
| |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
</pre>
|
|
||||||
<table border="0" cellpadding="0" cellspacing="2" align="center"><tr><td align="center"><font face="monaco, MS Sans Serif" size="1"><b> Simple Packet Block format. </b></font><br /></td></tr></table><hr size="1" shade="0">
|
|
||||||
|
|
||||||
<p>The Packet Block has the following fields:
|
|
||||||
</p>
|
|
||||||
<ul class="text">
|
|
||||||
<li>Packet Len: actual length of the packet when it was transmitted on the network. Can be different from captured len if the packet has been truncated.
|
|
||||||
</li>
|
|
||||||
<li>Packet data: the data coming from the network, including link-layers headers. The length of this field can be derived from the field Block Total Length, present in the Block Header.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<p>The Simple Packet Block does not contain the timestamp because this is one of the most costly operations on PCs. Additionally, there are applications that do not require it; e.g. an Intrusion Detection System is interested in packets, not in their timestamp.
|
|
||||||
</p>
|
|
||||||
<p>The Simple Packet Block is very efficient in term of disk space: a snapshot of length 100 bytes requires only 16 bytes of overhead, which corresponds to an efficiency of more than 86%.
|
|
||||||
</p>
|
|
||||||
<a name="rfc.section.3.5"></a><h4><a name="anchor8">3.5</a> Name Resolution Block (optional)</h4>
|
|
||||||
|
|
||||||
<p>The Name Resolution Block is used to support the correlation of numeric addresses (present in the captured packets) and their corresponding canonical names and it is optional. Having the literal names saved in the file, this prevents the need of a name resolution in a delayed time, when the association between names and addresses can be different from the one in use at capture time. Moreover, The Name Resolution Block avoids the need of issuing a lot of DNS requests every time the trace capture is opened, and allows to have name resolution also when reading the capture with a machine not connected to the network.
|
|
||||||
</p>
|
|
||||||
<p>The format of the Name Resolution Block is shown in <a href="#formatnrb">Figure 7</a>.
|
|
||||||
</p><br /><hr />
|
|
||||||
<a name="formatnrb"></a>
|
|
||||||
<pre>
|
|
||||||
0 1 2 3
|
|
||||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Record Type | Record Length |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Record Value |
|
|
||||||
| /* variable length, byte-aligned */ |
|
|
||||||
| + + + + + + + + + + + + + + + + + + + + + + + + +
|
|
||||||
| | | | |
|
|
||||||
+-+-+-+-+-+-+-+-+ + + + + + + + + + + + + + + + + + + + + + + + +
|
|
||||||
. . . other records . . .
|
|
||||||
| Record Type == end_of_recs | Record Length == 00 |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
/ /
|
|
||||||
/ Options (variable) /
|
|
||||||
/ /
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
</pre>
|
|
||||||
<table border="0" cellpadding="0" cellspacing="2" align="center"><tr><td align="center"><font face="monaco, MS Sans Serif" size="1"><b> Name Resolution Block format. </b></font><br /></td></tr></table><hr size="1" shade="0">
|
|
||||||
|
|
||||||
<p>A Name Resolution Block is a zero-terminated list of records (in the TLV format), each of which contains an association between a network address and a name. There are three possible types of records:
|
|
||||||
</p><a name="nrrecords"></a>
|
|
||||||
<table class="data" align="center" border="1" cellpadding="2" cellspacing="2">
|
|
||||||
<tr>
|
|
||||||
<th align="left" width="25%">Name</th>
|
|
||||||
<th align="left" width="25%">Code</th>
|
|
||||||
<th align="left" width="25%">Length</th>
|
|
||||||
<th align="left" width="25%">Description</th>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">end_of_recs</td>
|
|
||||||
<td align="left">0</td>
|
|
||||||
<td align="left">0</td>
|
|
||||||
<td align="left">End of records</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">ip4_rec</td>
|
|
||||||
<td align="left">1</td>
|
|
||||||
<td align="left">Variable</td>
|
|
||||||
<td align="left">Specifies an IPv4 address (contained in the first 4 bytes), followed by one or more zero-terminated strings containing the DNS entries for that address.</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">ip6_rec</td>
|
|
||||||
<td align="left">1</td>
|
|
||||||
<td align="left">Variable</td>
|
|
||||||
<td align="left">Specifies an IPv6 address (contained in the first 16 bytes), followed by one or more zero-terminated strings containing the DNS entries for that address.</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<p>After the list or Name Resolution Records, optionally, a list of options (formatted according to the rules defined in <a href="#sectionopt">Section 4</a>) can be present.
|
|
||||||
</p>
|
|
||||||
<p>A Name Resolution Block is normally placed at the beginning of the file, but no assumptions can be taken about its position. Name Resolution Blocks can be added in a second time by tools that process the file, like network analyzers.
|
|
||||||
</p>
|
|
||||||
<p>In addiction to the options defined in <a href="#sectionopt">Section 4</a>, the following options are valid within this block:
|
|
||||||
</p><table class="data" align="center" border="1" cellpadding="2" cellspacing="2">
|
|
||||||
<tr>
|
|
||||||
<th align="left" width="25%">Name</th>
|
|
||||||
<th align="left" width="25%">Code</th>
|
|
||||||
<th align="left" width="25%">Length</th>
|
|
||||||
<th align="left" width="25%">Description</th>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">ns_dnsname</td>
|
|
||||||
<td align="left">2</td>
|
|
||||||
<td align="left">Variable</td>
|
|
||||||
<td align="left">An ascii string containing the name of the machine (DNS server) used to perform the name resolution.</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<a name="rfc.section.3.6"></a><h4><a name="anchor9">3.6</a> Interface Statistics Block (optional)</h4>
|
|
||||||
|
|
||||||
<p>The Interface Statistics Block contains the capture statistics for a given interface and it is optional. The statistics are referred to the interface defined in the current Section identified by the Interface ID field.
|
|
||||||
</p>
|
|
||||||
<p>The format of the Interface Statistics Block is shown in <a href="#formatisb">Figure 8</a>.
|
|
||||||
</p><br /><hr />
|
|
||||||
<a name="formatisb"></a>
|
|
||||||
<pre>
|
|
||||||
0 1 2 3
|
|
||||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| IfRecv |
|
|
||||||
| (high + low) |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| IfDrop |
|
|
||||||
| (high + low) |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| FilterAccept |
|
|
||||||
| (high + low) |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| OSDrop |
|
|
||||||
| (high + low) |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| UsrDelivered |
|
|
||||||
| (high + low) |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Interface ID | Reserved |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
/ /
|
|
||||||
/ Options (variable) /
|
|
||||||
/ /
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
</pre>
|
|
||||||
<table border="0" cellpadding="0" cellspacing="2" align="center"><tr><td align="center"><font face="monaco, MS Sans Serif" size="1"><b> Interface Statistics Block format. </b></font><br /></td></tr></table><hr size="1" shade="0">
|
|
||||||
|
|
||||||
<p>The fields have the following meaning:
|
|
||||||
</p>
|
|
||||||
<ul class="text">
|
|
||||||
<li>IfRecv: number of packets received from the interface during the capture. This number is reported as a 64 bits value, in which the most significat bits are located in the first four bytes of the field.
|
|
||||||
</li>
|
|
||||||
<li>IfDrop: number of packets dropped by the interface during the capture due to lack of resources.
|
|
||||||
</li>
|
|
||||||
<li>FilterAccept: number of packets accepeted by filter during current capture.
|
|
||||||
</li>
|
|
||||||
<li>OSDrop: number of packets dropped by the operating system during the capture.
|
|
||||||
</li>
|
|
||||||
<li>UsrDelivered: number of packets delivered to the user. UsrDelivered can be different from the value 'FilterAccept - OSDropped' because some packets could still lay in the OS buffers when the capture ended.
|
|
||||||
</li>
|
|
||||||
<li>Interface ID: reference to an Interface Description Block.
|
|
||||||
</li>
|
|
||||||
<li>Reserved: Reserved to future use.
|
|
||||||
</li>
|
|
||||||
<li>Options: optionally, a list of options (formatted according to the rules defined in <a href="#sectionopt">Section 4</a>) can be present.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<p>In addiction to the options defined in <a href="#sectionopt">Section 4</a>, the following options are valid within this block:
|
|
||||||
</p><table class="data" align="center" border="1" cellpadding="2" cellspacing="2">
|
|
||||||
<tr>
|
|
||||||
<th align="left" width="25%">Name</th>
|
|
||||||
<th align="left" width="25%">Code</th>
|
|
||||||
<th align="left" width="25%">Length</th>
|
|
||||||
<th align="left" width="25%">Description</th>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">isb_starttime</td>
|
|
||||||
<td align="left">2</td>
|
|
||||||
<td align="left">8</td>
|
|
||||||
<td align="left">Time in which the capture started; time will be stored in two blocks of four bytes each, containing the timestamp in seconds and nanoseconds.</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">isb_endtime</td>
|
|
||||||
<td align="left">3</td>
|
|
||||||
<td align="left">8</td>
|
|
||||||
<td align="left">Time in which the capture started; time will be stored in two blocks of four bytes each, containing the timestamp in seconds and nanoseconds.</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<a name="sectionopt"></a><br /><hr />
|
|
||||||
<table summary="layout" cellpadding="0" cellspacing="2" class="bug" align="right"><tr><td class="bug"><a href="#toc" class="link2"> TOC </a></td></tr></table>
|
|
||||||
<a name="rfc.section.4"></a><h3>4. Options</h3>
|
|
||||||
|
|
||||||
<p>Almost all blocks have the possibility to embed optional fields. Optional fields can be used to insert some information that may be useful when reading data, but that it is not really needed for packet processing. Therefore, each tool can be either read the content of the optional fields (if any), or skip them at once.
|
|
||||||
</p>
|
|
||||||
<p>Skipping all the optional fields at once is straightforward because most of the blocks have a fixed length, therefore the field Block Length (present in the General Block Structure, see <a href="#sectionblock">Section 2.1</a>) can be used to skip everything till the next block.
|
|
||||||
</p>
|
|
||||||
<p>Options are a list of Type - Length - Value fields, each one containing a single value:
|
|
||||||
</p>
|
|
||||||
<ul class="text">
|
|
||||||
<li>Option Type (2 bytes): it contains the code that specifies the type of the current TLV record. Option types whose Most Significant Bit is equal to one are reserved for local use; therefore, there is no guarantee that the code used is unique among all capture files (generated by other applications). In case of vendor-specific extensions that have to be identified uniquely, vendors must request an Option Code whose MSB is equal to zero.
|
|
||||||
</li>
|
|
||||||
<li>Option Length (2 bytes): it contains the length of the following 'Option Value' field.
|
|
||||||
</li>
|
|
||||||
<li>Option Value (variable length): it contains the value of the given option. The length of this field as been specified by the Option Length field.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<p>Options may be repeated several times (e.g. an interface that has several IP addresses associated to it). The option list is terminated by a special code which is the 'End of Option'.
|
|
||||||
</p>
|
|
||||||
<p>The format of the optional fields is shown in <a href="#formatopt">Figure 9</a>.
|
|
||||||
</p><br /><hr />
|
|
||||||
<a name="formatopt"></a>
|
|
||||||
<pre>
|
|
||||||
0 1 2 3
|
|
||||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Option Code | Option Length |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Option Value |
|
|
||||||
| /* variable length, byte-aligned */ |
|
|
||||||
| + + + + + + + + + + + + + + + + + + + + + + + + +
|
|
||||||
| / / / |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
/ /
|
|
||||||
/ . . . other options . . . /
|
|
||||||
/ /
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Option Code == opt_endofopt | Option Length == 0 |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
</pre>
|
|
||||||
<table border="0" cellpadding="0" cellspacing="2" align="center"><tr><td align="center"><font face="monaco, MS Sans Serif" size="1"><b> Options format. </b></font><br /></td></tr></table><hr size="1" shade="0">
|
|
||||||
|
|
||||||
<p>The following codes can always be present in any optional field:
|
|
||||||
</p><table class="data" align="center" border="1" cellpadding="2" cellspacing="2">
|
|
||||||
<tr>
|
|
||||||
<th align="left" width="25%">Name</th>
|
|
||||||
<th align="left" width="25%">Code</th>
|
|
||||||
<th align="left" width="25%">Length</th>
|
|
||||||
<th align="left" width="25%">Description</th>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">opt_endofopt</td>
|
|
||||||
<td align="left">0</td>
|
|
||||||
<td align="left">0</td>
|
|
||||||
<td align="left">End of options: it is used to delimit the end of the optional fields. This block cannot be repeated within a given list of options.</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="left">opt_comment</td>
|
|
||||||
<td align="left">1</td>
|
|
||||||
<td align="left">variable</td>
|
|
||||||
<td align="left">Comment: it is an ascii string containing a comment that is associated to the current block.</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<a name="anchor10"></a><br /><hr />
|
|
||||||
<table summary="layout" cellpadding="0" cellspacing="2" class="bug" align="right"><tr><td class="bug"><a href="#toc" class="link2"> TOC </a></td></tr></table>
|
|
||||||
<a name="rfc.section.5"></a><h3>5. Experimental Blocks (deserved to a further investigation)</h3>
|
|
||||||
|
|
||||||
<a name="rfc.section.5.1"></a><h4><a name="anchor11">5.1</a> Other Packet Blocks (experimental)</h4>
|
|
||||||
|
|
||||||
<p>Can some other packet blocks (besides the two described in the previous paragraphs) be useful?
|
|
||||||
</p>
|
|
||||||
<a name="rfc.section.5.2"></a><h4><a name="anchor12">5.2</a> Compression Block (experimental)</h4>
|
|
||||||
|
|
||||||
<p>The Compression Block is optional. A file can contain an arbitrary number of these blocks. A Compression Block, as the name says, is used to store compressed data. Its format is shown in <a href="#formatcb">Figure 10</a>.
|
|
||||||
</p><br /><hr />
|
|
||||||
<a name="formatcb"></a>
|
|
||||||
<pre>
|
|
||||||
0 1 2 3
|
|
||||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Compr. Type | |
|
|
||||||
+-+-+-+-+-+-+-+-+ |
|
|
||||||
| |
|
|
||||||
| Compressed Data |
|
|
||||||
| |
|
|
||||||
| /* variable length, byte-aligned */ |
|
|
||||||
| |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
</pre>
|
|
||||||
<table border="0" cellpadding="0" cellspacing="2" align="center"><tr><td align="center"><font face="monaco, MS Sans Serif" size="1"><b> Compression Block format. </b></font><br /></td></tr></table><hr size="1" shade="0">
|
|
||||||
|
|
||||||
<p>The fields have the following meaning:
|
|
||||||
</p>
|
|
||||||
<ul class="text">
|
|
||||||
<li>Compression Type: specifies the compression algorithm. Possible values for this field are 0 (uncompressed), 1 (Lempel Ziv), 2 (Gzip), other?? Probably some kind of dumb and fast compression algorithm could be effective with some types of traffic (for example web), but which?
|
|
||||||
</li>
|
|
||||||
<li>Compressed Data: data of this block. Once decompressed, it is made of other blocks.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<a name="rfc.section.5.3"></a><h4><a name="anchor13">5.3</a> Encryption Block (experimental)</h4>
|
|
||||||
|
|
||||||
<p>The Encryption Block is optional. A file can contain an arbitrary number of these blocks. An Encryption Block is used to sotre encrypted data. Its format is shown in <a href="#formateb">Figure 11</a>.
|
|
||||||
</p><br /><hr />
|
|
||||||
<a name="formateb"></a>
|
|
||||||
<pre>
|
|
||||||
0 1 2 3
|
|
||||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Encr. Type | |
|
|
||||||
+-+-+-+-+-+-+-+-+ |
|
|
||||||
| |
|
|
||||||
| Compressed Data |
|
|
||||||
| |
|
|
||||||
| /* variable length, byte-aligned */ |
|
|
||||||
| |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
</pre>
|
|
||||||
<table border="0" cellpadding="0" cellspacing="2" align="center"><tr><td align="center"><font face="monaco, MS Sans Serif" size="1"><b> Encryption Block format. </b></font><br /></td></tr></table><hr size="1" shade="0">
|
|
||||||
|
|
||||||
<p>The fields have the following meaning:
|
|
||||||
</p>
|
|
||||||
<ul class="text">
|
|
||||||
<li>Compression Type: specifies the encryption algorithm. Possible values for this field are ??? NOTE: this block should probably contain other fields, depending on the encryption algorithm. To be define precisely.
|
|
||||||
</li>
|
|
||||||
<li>Encrypted Data: data of this block. Once decripted, it consists of other blocks.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<a name="rfc.section.5.4"></a><h4><a name="anchor14">5.4</a> Fixed Length Block (experimental)</h4>
|
|
||||||
|
|
||||||
<p>The Fixed Length Block is optional. A file can contain an arbitrary number of these blocks. A Fixed Length Block can be used to optimize the access to the file. Its format is shown in <a href="#formatflm">Figure 12</a>.
|
|
||||||
A Fixed Length Block stores records with constant size. It contains a set of Blocks (normally Packet Blocks or Simple Packet Blocks), of wihich it specifies the size. Knowing this size a priori helps to scan the file and to load some portions of it without truncating a block, and is particularly useful with cell-based networks like ATM.
|
|
||||||
</p><br /><hr />
|
|
||||||
<a name="formatflm"></a>
|
|
||||||
<pre>
|
|
||||||
0 1 2 3
|
|
||||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Cell Size | |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
|
||||||
| |
|
|
||||||
| Fixed Size Data |
|
|
||||||
| |
|
|
||||||
| /* variable length, byte-aligned */ |
|
|
||||||
| |
|
|
||||||
| |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
</pre>
|
|
||||||
<table border="0" cellpadding="0" cellspacing="2" align="center"><tr><td align="center"><font face="monaco, MS Sans Serif" size="1"><b> Fixed Length Block format. </b></font><br /></td></tr></table><hr size="1" shade="0">
|
|
||||||
|
|
||||||
<p>The fields have the following meaning:
|
|
||||||
</p>
|
|
||||||
<ul class="text">
|
|
||||||
<li>Cell size: the size of the blocks contained in the data field.
|
|
||||||
</li>
|
|
||||||
<li>Fixed Size Data: data of this block.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<a name="rfc.section.5.5"></a><h4><a name="anchor15">5.5</a> Directory Block (experimental)</h4>
|
|
||||||
|
|
||||||
<p>If present, this block contains the following information:
|
|
||||||
</p>
|
|
||||||
<ul class="text">
|
|
||||||
<li>number of indexed packets (N)
|
|
||||||
</li>
|
|
||||||
<li>table with position and length of any indexed packet (N entries)
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<p>A directory block must be followed by at least N packets, otherwise it must be considered invalid. It can be used to efficiently load portions of the file to memory and to support operations on memory mapped files. This block can be added by tools like network analyzers as a consequence of file processing.
|
|
||||||
</p>
|
|
||||||
<a name="rfc.section.5.6"></a><h4><a name="anchor16">5.6</a> Traffic Statistics and Monitoring Blocks (experimental)</h4>
|
|
||||||
|
|
||||||
<p>One or more blocks could be defined to contain network statistics or traffic monitoring information. They could be use to store data collected from RMON or Netflow probes, or from other network monitoring tools.
|
|
||||||
</p>
|
|
||||||
<a name="rfc.section.5.7"></a><h4><a name="anchor17">5.7</a> Event/Security Block (experimental)</h4>
|
|
||||||
|
|
||||||
<p>This block could be used to store events. Events could contain generic information (for example network load over 50%, server down...) or security alerts. An event could be:
|
|
||||||
</p>
|
|
||||||
<ul class="text">
|
|
||||||
<li>skipped, if the application doesn't know how to do with it
|
|
||||||
</li>
|
|
||||||
<li>processed independently by the packets. In other words, the applications skips the packets and processes only the alerts
|
|
||||||
</li>
|
|
||||||
<li>processed in relation to packets: for example, a security tool could load only the packets of the file that are near a security alert; a monitorg tool could skip the packets captured while the server was down.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<a name="anchor18"></a><br /><hr />
|
|
||||||
<table summary="layout" cellpadding="0" cellspacing="2" class="bug" align="right"><tr><td class="bug"><a href="#toc" class="link2"> TOC </a></td></tr></table>
|
|
||||||
<a name="rfc.section.6"></a><h3>6. Conclusions</h3>
|
|
||||||
|
|
||||||
<p>The file format proposed in this document should be very versatile and satisfy a wide range of applications.
|
|
||||||
In the simplest case, it can contain a raw dump of the network data, made of a series of Simple Packet Blocks.
|
|
||||||
In the most complex case, it can be used as a repository for heterogeneous information.
|
|
||||||
In every case, the file remains easy to parse and an application can always skip the data it is not interested in; at the same time, different applications can share the file, and each of them can benfit of the information produced by the others.
|
|
||||||
Two or more files can be concatenated obtaining another valid file.
|
|
||||||
</p>
|
|
||||||
<a name="anchor19"></a><br /><hr />
|
|
||||||
<table summary="layout" cellpadding="0" cellspacing="2" class="bug" align="right"><tr><td class="bug"><a href="#toc" class="link2"> TOC </a></td></tr></table>
|
|
||||||
<a name="rfc.section.7"></a><h3>7. Most important open issues</h3>
|
|
||||||
|
|
||||||
<ul class="text">
|
|
||||||
<li>Data, in the file, must be byte or word aligned? Currently, the structure of this document is not consistent with respect to this point.
|
|
||||||
</li>
|
|
||||||
</ul><a name="rfc.copyright"></a><br /><hr />
|
|
||||||
<table summary="layout" cellpadding="0" cellspacing="2" class="bug" align="right"><tr><td class="bug"><a href="#toc" class="link2"> TOC </a></td></tr></table>
|
|
||||||
<h3>Intellectual Property Statement</h3>
|
|
||||||
<p class='copyright'>
|
|
||||||
The IETF takes no position regarding the validity or scope of
|
|
||||||
any intellectual property or other rights that might be claimed
|
|
||||||
to pertain to the implementation or use of the technology
|
|
||||||
described in this document or the extent to which any license
|
|
||||||
under such rights might or might not be available; neither does
|
|
||||||
it represent that it has made any effort to identify any such
|
|
||||||
rights. Information on the IETF's procedures with respect to
|
|
||||||
rights in standards-track and standards-related documentation
|
|
||||||
can be found in BCP-11. Copies of claims of rights made
|
|
||||||
available for publication and any assurances of licenses to
|
|
||||||
be made available, or the result of an attempt made
|
|
||||||
to obtain a general license or permission for the use of such
|
|
||||||
proprietary rights by implementors or users of this
|
|
||||||
specification can be obtained from the IETF Secretariat.</p>
|
|
||||||
<p class='copyright'>
|
|
||||||
The IETF invites any interested party to bring to its
|
|
||||||
attention any copyrights, patents or patent applications, or
|
|
||||||
other proprietary rights which may cover technology that may be
|
|
||||||
required to practice this standard. Please address the
|
|
||||||
information to the IETF Executive Director.</p>
|
|
||||||
<h3>Full Copyright Statement</h3>
|
|
||||||
<p class='copyright'>
|
|
||||||
Copyright (C) The Internet Society (2004). All Rights Reserved.</p>
|
|
||||||
<p class='copyright'>
|
|
||||||
This document and translations of it may be copied and furnished to
|
|
||||||
others, and derivative works that comment on or otherwise explain it
|
|
||||||
or assist in its implementation may be prepared, copied, published and
|
|
||||||
distributed, in whole or in part, without restriction of any kind,
|
|
||||||
provided that the above copyright notice and this paragraph are
|
|
||||||
included on all such copies and derivative works. However, this
|
|
||||||
document itself may not be modified in any way, such as by removing
|
|
||||||
the copyright notice or references to the Internet Society or other
|
|
||||||
Internet organizations, except as needed for the purpose of
|
|
||||||
developing Internet standards in which case the procedures for
|
|
||||||
copyrights defined in the Internet Standards process must be
|
|
||||||
followed, or as required to translate it into languages other than
|
|
||||||
English.</p>
|
|
||||||
<p class='copyright'>
|
|
||||||
The limited permissions granted above are perpetual and will not be
|
|
||||||
revoked by the Internet Society or its successors or assignees.</p>
|
|
||||||
<p class='copyright'>
|
|
||||||
This document and the information contained herein is provided on an
|
|
||||||
"AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
|
|
||||||
TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
|
|
||||||
BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
|
|
||||||
HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.</p>
|
|
||||||
<h3>Acknowledgment</h3>
|
|
||||||
<p class='copyright'>
|
|
||||||
Funding for the RFC Editor function is currently provided by the
|
|
||||||
Internet Society.</p>
|
|
||||||
</body></html>
|
|
||||||
1680
libpcap/doc/pcap.txt
1680
libpcap/doc/pcap.txt
File diff suppressed because it is too large
Load Diff
@@ -1,746 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
|
|
||||||
|
|
||||||
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
|
|
||||||
<?rfc toc="yes"?>
|
|
||||||
<rfc ipr="full2026" docname="draft-libpcap-dump-format-00.txt">
|
|
||||||
<front>
|
|
||||||
<title>PCAP New Generation Dump File Format</title>
|
|
||||||
<author initials="L." surname="Degioanni" fullname="Loris Degioanni">
|
|
||||||
<organization>Politecnico di Torino</organization>
|
|
||||||
<address>
|
|
||||||
<postal>
|
|
||||||
<street>Corso Duca degli Abruzzi, 24</street>
|
|
||||||
<city>Torino</city>
|
|
||||||
<code>10129</code>
|
|
||||||
<country>Italy</country>
|
|
||||||
</postal>
|
|
||||||
<phone>+39 011 564 7008</phone>
|
|
||||||
<email>loris.degioanni@polito.it</email>
|
|
||||||
<uri>http://netgroup.polito.it/loris/</uri>
|
|
||||||
</address>
|
|
||||||
</author>
|
|
||||||
<author initials="F." surname="Risso" fullname="Fulvio Risso">
|
|
||||||
<organization>Politecnico di Torino</organization>
|
|
||||||
<address>
|
|
||||||
<postal>
|
|
||||||
<street>Corso Duca degli Abruzzi, 24</street>
|
|
||||||
<city>Torino</city>
|
|
||||||
<code>10129</code>
|
|
||||||
<country>Italy</country>
|
|
||||||
</postal>
|
|
||||||
<phone>+39 011 564 7008</phone>
|
|
||||||
<email>fulvio.risso@polito.it</email>
|
|
||||||
<uri>http://netgroup.polito.it/fulvio.risso/</uri>
|
|
||||||
</address>
|
|
||||||
</author>
|
|
||||||
|
|
||||||
<!-- Other authors go here -->
|
|
||||||
|
|
||||||
<date month="March" year="2004"/>
|
|
||||||
<area>General</area>
|
|
||||||
<!--
|
|
||||||
<workgroup>
|
|
||||||
-->
|
|
||||||
<keyword>Internet-Draft</keyword>
|
|
||||||
<keyword>Libpcap, dump file format</keyword>
|
|
||||||
<abstract>
|
|
||||||
<t>This document describes a format to dump captured packets on a file. This format is extensible and it is currently proposed for implementation in the libpcap/WinPcap packet capture library.</t>
|
|
||||||
</abstract>
|
|
||||||
<!--
|
|
||||||
<note ...>
|
|
||||||
-->
|
|
||||||
</front>
|
|
||||||
<middle>
|
|
||||||
|
|
||||||
<section title="Objectives">
|
|
||||||
<t>The problem of exchanging packet traces becomes more and more critical every day; unfortunately, no standard solutions exist for this task right now. One of the most accepted packet interchange formats is the one defined by libpcap, which is rather old and does not fit for some of the nowadays applications especially in terms of extensibility.</t>
|
|
||||||
<t>This document proposes a new format for dumping packet traces. The following goals are being pursued:</t>
|
|
||||||
<list style="symbols">
|
|
||||||
<t>Extensibility: aside of some common functionalities, third parties should be able to enrich the information embedded in the file with proprietary extensions, which will be ignored by tools that are not able to understand them.</t>
|
|
||||||
<t>Portability: a capture trace must contain all the information needed to read data independently from network, hardware and operating system of the machine that made the capture.</t>
|
|
||||||
<t>Merge/Append data: it should be possible to add data at the end of a given file, and the resulting file must still be readable.</t>
|
|
||||||
</list>
|
|
||||||
|
|
||||||
</section>
|
|
||||||
|
|
||||||
|
|
||||||
<section title="General File Structure">
|
|
||||||
|
|
||||||
<section anchor="sectionblock" title="General Block Structure">
|
|
||||||
<t>A capture file is organized in blocks, that are appended one to another to form the file. All the blocks share a common format, which is shown in <xref target="formatblock"/>.</t>
|
|
||||||
|
|
||||||
<figure anchor="formatblock" title="Basic block structure.">
|
|
||||||
<artwork>
|
|
||||||
0 1 2 3
|
|
||||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Block Type |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Block Total Length |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
/ Block Body /
|
|
||||||
/ /* variable length, aligned to 32 bits */ /
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Block Total Length |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
</artwork>
|
|
||||||
</figure>
|
|
||||||
|
|
||||||
<t>The fields have the following meaning:</t>
|
|
||||||
|
|
||||||
<list style="symbols">
|
|
||||||
<t>Block Type (32 bits): unique value that identifies the block. Values whose Most Significant Bit (MSB) is equal to 1 are reserved for local use. They allow to save private data to the file and to extend the file format.</t>
|
|
||||||
<t>Block Total Length: total size of this block, in bytes. For instance, a block that does not have a body has a length of 12 bytes.</t>
|
|
||||||
<t>Block Body: content of the block.</t>
|
|
||||||
<t>Block Total Length: total size of this block, in bytes. This field is duplicated for permitting backward file navigation.</t>
|
|
||||||
</list>
|
|
||||||
|
|
||||||
<t>This structure, shared among all blocks, makes easy to process a file and to skip unneeded or unknown blocks. Blocks can be nested one inside the others (NOTE: needed?). Some of the blocks are mandatory, i.e. a dump file is not valid if they are not present, other are optional.</t>
|
|
||||||
<t>The structure of the blocks allows to define other blocks if needed. A parser that does non understand them can simply ignore their content.</t>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section title="Block Types">
|
|
||||||
<t>The currently defined blocks are the following:</t>
|
|
||||||
<list style="numbers">
|
|
||||||
<t>Section Header Block: it defines the most important characteristics of the capture file.</t>
|
|
||||||
<t>Interface Description Block: it defines the most important characteristics of the interface(s) used for capturing traffic.</t>
|
|
||||||
<t>Packet Block: it contains a single captured packet, or a portion of it.</t>
|
|
||||||
<t>Simple Packet Block: it contains a single captured packet, or a portion of it, with only a minimal set of information about it.</t>
|
|
||||||
<t>Name Resolution Block: it defines the mapping from numeric addresses present in the packet dump and the canonical name counterpart.</t>
|
|
||||||
<t>Capture Statistics Block: it defines how to store some statistical data (e.g. packet dropped, etc) which can be useful to undestand the conditions in which the capture has been made.</t>
|
|
||||||
<t>Compression Marker Block: TODO</t>
|
|
||||||
<t>Encryption Marker Block: TODO</t>
|
|
||||||
<t>Fixed Length Marker Block: TODO</t>
|
|
||||||
</list>
|
|
||||||
|
|
||||||
<t>The following blocks instead are considered interesting but the authors believe that they deserve more in-depth discussion before being defined:</t>
|
|
||||||
<list style="numbers">
|
|
||||||
<t>Further Packet Blocks</t>
|
|
||||||
<t>Directory Block</t>
|
|
||||||
<t>Traffic Statistics and Monitoring Blocks</t>
|
|
||||||
<t>Alert and Security Blocks</t>
|
|
||||||
</list>
|
|
||||||
|
|
||||||
<t>TODO Currently standardized Block Type codes are specified in Appendix 1.</t>
|
|
||||||
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section title="Block Hierarchy and Precedence">
|
|
||||||
<t>The file must begin with a Section Header Block. However, more than one Section Header Block can be present on the dump, each one covering the data following it till the next one (or the end of file). A Section includes the data delimited by two Section Header Blocks (or by a Section Header Block and the end of the file), including the first Section Header Block.</t>
|
|
||||||
<t>In case an application cannot read a Section because of different version number, it must skip everything until the next Section Header Block. Note that, in order to properly skip the blocks until the next section, all blocks must have the fields Type and Length at the beginning. This is a mandatory requirement that must be maintained in future versions of the block format.</t>
|
|
||||||
<t><xref target="fssample-SHB"/> shows two valid files: the first has a typical configuration, with a single Section Header that covers the whole file. The second one contains three headers, and is normally the result of file concatenation. An application that understands only version 1.0 of the file format skips the intermediate section and restart processing the packets after the third Section Header.</t>
|
|
||||||
|
|
||||||
<figure anchor="fssample-SHB" title="File structure example: the Section Header Block.">
|
|
||||||
<artwork>
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| SHB v1.0 | Data |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
Typical configuration with a single Section Header Block
|
|
||||||
|
|
||||||
|
|
||||||
|-- 1st Section --|-- 2nd Section --|-- 3rd Section --|
|
|
||||||
| |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| SHB v1.0 | Data | SHB V1.1 | Data | SHB V1.0 | Data |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
Configuration with three different Section Header Blocks
|
|
||||||
</artwork>
|
|
||||||
</figure>
|
|
||||||
|
|
||||||
<t>NOTE: TO BE COMPLETED with some examples of other blocks</t>
|
|
||||||
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section title="Data format">
|
|
||||||
<t>Data contained in each section will always be saved according to the characteristics (little endian / big endian) of the dumping machine. This refers to all fields that are saved as numbers and that span over two or more bytes.</t>
|
|
||||||
<t>The approach of having each section saved in the native format of the generating host is more efficient because it avoids translation of data when reading / writing on the host itself, which is the most common case when generating/processing capture dumps.</t>
|
|
||||||
<t>TODO Probably we have to specify something more here. Is what we're saying enough to avoid any kind of ambiguity?.</t>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
</section>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<section title="Block Definition">
|
|
||||||
<t>This section details the format of the body of the blocks currently defined.</t>
|
|
||||||
|
|
||||||
<section anchor="sectionshb" title="Section Header Block (mandatory)">
|
|
||||||
<t>The Section Header Block is mandatory. It identifies the beginning of a section of the capture dump file. Its format is shown in <xref target="formatSHB"/>.</t>
|
|
||||||
<figure anchor="formatSHB" title="Section Header Block format.">
|
|
||||||
<artwork>
|
|
||||||
0 1 2 3
|
|
||||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Magic |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Major | Minor |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
/ /
|
|
||||||
/ Options (variable) /
|
|
||||||
/ /
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
</artwork>
|
|
||||||
</figure>
|
|
||||||
|
|
||||||
<t>The meaning of the fields is:</t>
|
|
||||||
<list style="symbols">
|
|
||||||
<t>Magic: magic number, whose value is the hexadecimal number 0x1A2B3C4D. This number can be used to distinguish section that have been saved on little-endian machines from the one saved on big-endian machines.</t>
|
|
||||||
<t>Major: number of the current mayor version of the format. Current value is 1.</t>
|
|
||||||
<t>Minor: number of the current minor version of the format. Current value is 0.</t>
|
|
||||||
<t>Options: optionally, a list of options (formatted according to the rules defined in <xref target="sectionopt"/>) can be present.</t>
|
|
||||||
</list>
|
|
||||||
|
|
||||||
<t>Aside form the options defined in <xref target="sectionopt"/>, the following options are valid within this block:</t>
|
|
||||||
|
|
||||||
<texttable anchor="InterfaceOptions1">
|
|
||||||
<ttcol>Name</ttcol>
|
|
||||||
<ttcol>Code</ttcol>
|
|
||||||
<ttcol>Length</ttcol>
|
|
||||||
<ttcol>Description</ttcol>
|
|
||||||
|
|
||||||
<c>Hardware</c>
|
|
||||||
<c>2</c>
|
|
||||||
<c>variable</c>
|
|
||||||
<c>An ascii string containing the description of the hardware used to create this section.</c>
|
|
||||||
|
|
||||||
<c>Operating System</c>
|
|
||||||
<c>3</c>
|
|
||||||
<c>variable</c>
|
|
||||||
<c>An ascii string containing the name of the operating system used to create this section.</c>
|
|
||||||
|
|
||||||
<c>User Application</c>
|
|
||||||
<c>3</c>
|
|
||||||
<c>variable</c>
|
|
||||||
<c>An ascii string containing the name of the application used to create this section.</c>
|
|
||||||
</texttable>
|
|
||||||
|
|
||||||
|
|
||||||
<t>The Section Header Block does not contain data but it rather identifies a list of blocks (interfaces, packets) that are logically correlated. This block does not contain any reference to the size of the section it is currently delimiting, therefore the reader cannot skip a whole section at once. In case a section must be skipped, the user has to repeatedly skip all the blocks contained within it; this makes the parsing of the file slower but it permits to append several capture dumps at the same file.</t>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section anchor="sectionidb" title="Interface Description Block (mandatory)">
|
|
||||||
<t>The Interface Description Block is mandatory. This block is needed to specify the characteristics of the network interface on which the capture has been made. In order to properly associate the captured data to the corresponding interface, the Interface Description Block must be defined before any other block that uses it; therefore, this block is usually placed immediately after the Section Header Block.</t>
|
|
||||||
|
|
||||||
<t>An Interface Description Block is valid only inside the section which it belongs to. The structure of a Interface Description Block is shown in <xref target="formatidb"/>.</t>
|
|
||||||
|
|
||||||
<figure anchor="formatidb" title="Interface Description Block format.">
|
|
||||||
<artwork>
|
|
||||||
0 1 2 3
|
|
||||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Interface ID | LinkType |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| SnapLen |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
/ /
|
|
||||||
/ Options (variable) /
|
|
||||||
/ /
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
</artwork>
|
|
||||||
</figure>
|
|
||||||
|
|
||||||
<t>The meaning of the fields is:</t>
|
|
||||||
<list style="symbols">
|
|
||||||
<t>Interface ID: a progressive number that identifies uniquely any interface inside current section. Two Interface Description Blocks can have the same Interface ID only if they are in different sections of the file. The Interface ID is referenced by the packet blocks.</t>
|
|
||||||
<t>LinkType: a value that defines the link layer type of this interface.</t>
|
|
||||||
<t>SnapLen: maximum number of bytes dumped from each packet. The portion of each packet that exceeds this value will not be stored in the file.</t>
|
|
||||||
<t>Options: optionally, a list of options (formatted according to the rules defined in <xref target="sectionopt"/>) can be present.</t>
|
|
||||||
</list>
|
|
||||||
|
|
||||||
<t>In addition to the options defined in <xref target="sectionopt"/>, the following options are valid within this block:</t>
|
|
||||||
|
|
||||||
<texttable anchor="InterfaceOptions2">
|
|
||||||
<ttcol>Name</ttcol>
|
|
||||||
<ttcol>Code</ttcol>
|
|
||||||
<ttcol>Length</ttcol>
|
|
||||||
<ttcol>Description</ttcol>
|
|
||||||
|
|
||||||
<c>if_name</c>
|
|
||||||
<c>2</c>
|
|
||||||
<c>Variable</c>
|
|
||||||
<c>Name of the device used to capture data.</c>
|
|
||||||
|
|
||||||
<c>if_IPv4addr</c>
|
|
||||||
<c>3</c>
|
|
||||||
<c>8</c>
|
|
||||||
<c>Interface network address and netmask.</c>
|
|
||||||
|
|
||||||
<c>if_IPv6addr</c>
|
|
||||||
<c>4</c>
|
|
||||||
<c>17</c>
|
|
||||||
<c>Interface network address and prefix length (stored in the last byte).</c>
|
|
||||||
|
|
||||||
<c>if_MACaddr</c>
|
|
||||||
<c>5</c>
|
|
||||||
<c>6</c>
|
|
||||||
<c>Interface Hardware MAC address (48 bits).</c>
|
|
||||||
|
|
||||||
<c>if_EUIaddr</c>
|
|
||||||
<c>6</c>
|
|
||||||
<c>8</c>
|
|
||||||
<c>Interface Hardware EUI address (64 bits), if available.</c>
|
|
||||||
|
|
||||||
<c>if_speed</c>
|
|
||||||
<c>7</c>
|
|
||||||
<c>8</c>
|
|
||||||
<c>Interface speed (in bps).</c>
|
|
||||||
|
|
||||||
<c>if_tsaccur</c>
|
|
||||||
<c>8</c>
|
|
||||||
<c>1</c>
|
|
||||||
<c>Precision of timestamps. If the Most Significant Bit is equal to zero, the remaining bits indicates the accuracy as as a negative power of 10 (e.g. 6 means microsecond accuracy). If the Most Significant Bit is equal to zero, the remaining bits indicates the accuracy as as negative power of 2 (e.g. 10 means 1/1024 of second). If this option is not present, a precision of 10^-6 is assumed.</c>
|
|
||||||
|
|
||||||
<c>if_tzone</c>
|
|
||||||
<c>9</c>
|
|
||||||
<c>4</c>
|
|
||||||
<c>Time zone for GMT support (TODO: specify better).</c>
|
|
||||||
|
|
||||||
<c>if_flags</c>
|
|
||||||
<c>10</c>
|
|
||||||
<c>4</c>
|
|
||||||
<c>Interface flags. (TODO: specify better. Possible flags: promiscuous, inbound/outbound, traffic filtered during capture).</c>
|
|
||||||
|
|
||||||
<c>if_filter</c>
|
|
||||||
<c>11</c>
|
|
||||||
<c>variable</c>
|
|
||||||
<c>The filter (e.g. "capture only TCP traffic") used to capture traffic. The first byte of the Option Data keeps a code of the filter used (e.g. if this is a libpcap string, or BPF bytecode, and more). More details about this format will be presented in Appendix XXX (TODO).</c>
|
|
||||||
|
|
||||||
<c>if_opersystem</c>
|
|
||||||
<c>12</c>
|
|
||||||
<c>variable</c>
|
|
||||||
<c>An ascii string containing the name of the operating system of the machine that hosts this interface. This can be different from the same information that can be contained by the Section Header Block (<xref target="sectionshb"/>) because the capture can have been done on a remote machine.</c>
|
|
||||||
|
|
||||||
</texttable>
|
|
||||||
|
|
||||||
</section>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<section anchor="sectionpb" title="Packet Block (optional)">
|
|
||||||
<t>A Packet Block is the standard container for storing the packets coming from the network. The Packet Block is optional because packets can be stored either by means of this block or the Simple Packet Block, which can be used to speed up dump generation. The format of a packet block is shown in <xref target="formatpb"/>.</t>
|
|
||||||
|
|
||||||
<figure anchor="formatpb" title="Packet Block format.">
|
|
||||||
<artwork>
|
|
||||||
0 1 2 3
|
|
||||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Interface ID | Drops Count |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Timestamp (High) |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Timestamp (Low) |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Captured Len |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Packet Len |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| |
|
|
||||||
| Packet Data |
|
|
||||||
| |
|
|
||||||
| /* variable length, byte-aligned */ |
|
|
||||||
| |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
/ /
|
|
||||||
/ Options (variable) /
|
|
||||||
/ /
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
</artwork>
|
|
||||||
</figure>
|
|
||||||
|
|
||||||
<t>The Packet Block has the following fields:</t>
|
|
||||||
|
|
||||||
<list style="symbols">
|
|
||||||
<t>Interface ID: Specifies the interface this packet comes from, and corresponds to the ID of one of the Interface Description Blocks present in this section of the file (see <xref target="formatidb"/>).</t>
|
|
||||||
<t>Drops Count: a local drop counter. It specified the number of packets lost (by the interface and the operating system) between this packet and the preceding one. The value xFFFF (in hexadecimal) is reserved for those systems in which this information is not available.</t>
|
|
||||||
<t>Timestamp (High): the most significative part of the timestamp. in standard Unix format, i.e. from 1/1/1970.</t>
|
|
||||||
<t>Timestamp (Low): the less significative part of the timestamp. The way to interpret this field is specified by the 'ts_accur' option (see <xref target="formatidb"/>) of the Interface Description block referenced by this packet. If the Interface Description block does not contain a 'ts_accur' option, then this field is expressed in microseconds.</t>
|
|
||||||
<t>Captured Len: number of bytes captured from the packet (i.e. the length of the Packet Data field). It will be the minimum value among the actual Packet Length and the snapshot length (defined in <xref target="formatidb"/>).</t>
|
|
||||||
<t>Packet Len: actual length of the packet when it was transmitted on the network. Can be different from Captured Len if the user wants only a snapshot of the packet.</t>
|
|
||||||
<t>Packet Data: the data coming from the network, including link-layer headers. The length of this field is Captured Len. The format of the link-layer headers depends on the LinkType field specified in the Interface Description Block (see <xref target="sectionidb"/>) and it is specified in Appendix XXX (TODO).</t>
|
|
||||||
<t>Options: optionally, a list of options (formatted according to the rules defined in <xref target="sectionopt"/>) can be present.</t>
|
|
||||||
</list>
|
|
||||||
|
|
||||||
<t></t>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
|
|
||||||
<section title="Simple Packet Block (optional)">
|
|
||||||
<t>The Simple Packet Block is a lightweight container for storing the packets coming from the network. Its presence is optional.</t>
|
|
||||||
<t>A Simple Packet Block is similar to a Packet Block (see <xref target="sectionpb"/>), but it is smaller, simpler to process and contains only a minimal set of information. This block is preferred to the standard Packet Block when performance or space occupation are critical factors, such as in sustained traffic dump applications. A capture file can contain both Packet Blocks and Simple Packet Blocks: for example, a capture tool could switch from Packet Blocks to Simple Packet Blocks when the hardware resources become critical.</t>
|
|
||||||
<t>The Simple Packet Block does not contain the Interface ID field. Therefore, it must be assumed that all the Simple Packet Blocks have been captured on the interface previously specified in the Interface Description Block.</t>
|
|
||||||
<t><xref target="formatpbs"/> shows the format of the Simple Packet Block.</t>
|
|
||||||
|
|
||||||
<figure anchor="formatpbs" title="Simple Packet Block format.">
|
|
||||||
<artwork>
|
|
||||||
0 1 2 3
|
|
||||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Packet Len |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| |
|
|
||||||
| Packet Data |
|
|
||||||
| |
|
|
||||||
| /* variable length, byte-aligned */ |
|
|
||||||
| |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
</artwork>
|
|
||||||
</figure>
|
|
||||||
|
|
||||||
<t>The Packet Block has the following fields:</t>
|
|
||||||
<list style="symbols">
|
|
||||||
<t>Packet Len: actual length of the packet when it was transmitted on the network. Can be different from captured len if the packet has been truncated.</t>
|
|
||||||
<t>Packet data: the data coming from the network, including link-layers headers. The length of this field can be derived from the field Block Total Length, present in the Block Header.</t>
|
|
||||||
</list>
|
|
||||||
|
|
||||||
<t>The Simple Packet Block does not contain the timestamp because this is one of the most costly operations on PCs. Additionally, there are applications that do not require it; e.g. an Intrusion Detection System is interested in packets, not in their timestamp.</t>
|
|
||||||
|
|
||||||
<t>The Simple Packet Block is very efficient in term of disk space: a snapshot of length 100 bytes requires only 16 bytes of overhead, which corresponds to an efficiency of more than 86%.</t>
|
|
||||||
|
|
||||||
</section>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<section title="Name Resolution Block (optional)">
|
|
||||||
<t>The Name Resolution Block is used to support the correlation of numeric addresses (present in the captured packets) and their corresponding canonical names and it is optional. Having the literal names saved in the file, this prevents the need of a name resolution in a delayed time, when the association between names and addresses can be different from the one in use at capture time. Moreover, The Name Resolution Block avoids the need of issuing a lot of DNS requests every time the trace capture is opened, and allows to have name resolution also when reading the capture with a machine not connected to the network.</t>
|
|
||||||
<t>The format of the Name Resolution Block is shown in <xref target="formatnrb"/>.</t>
|
|
||||||
|
|
||||||
<figure anchor="formatnrb" title="Name Resolution Block format.">
|
|
||||||
<artwork>
|
|
||||||
0 1 2 3
|
|
||||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Record Type | Record Length |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Record Value |
|
|
||||||
| /* variable length, byte-aligned */ |
|
|
||||||
| + + + + + + + + + + + + + + + + + + + + + + + + +
|
|
||||||
| | | | |
|
|
||||||
+-+-+-+-+-+-+-+-+ + + + + + + + + + + + + + + + + + + + + + + + +
|
|
||||||
. . . other records . . .
|
|
||||||
| Record Type == end_of_recs | Record Length == 00 |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
/ /
|
|
||||||
/ Options (variable) /
|
|
||||||
/ /
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
</artwork>
|
|
||||||
</figure>
|
|
||||||
|
|
||||||
<t>A Name Resolution Block is a zero-terminated list of records (in the TLV format), each of which contains an association between a network address and a name. There are three possible types of records:</t>
|
|
||||||
|
|
||||||
<texttable anchor="nrrecords">
|
|
||||||
<ttcol>Name</ttcol>
|
|
||||||
<ttcol>Code</ttcol>
|
|
||||||
<ttcol>Length</ttcol>
|
|
||||||
<ttcol>Description</ttcol>
|
|
||||||
|
|
||||||
<c>end_of_recs</c>
|
|
||||||
<c>0</c>
|
|
||||||
<c>0</c>
|
|
||||||
<c>End of records</c>
|
|
||||||
|
|
||||||
<c>ip4_rec</c>
|
|
||||||
<c>1</c>
|
|
||||||
<c>Variable</c>
|
|
||||||
<c>Specifies an IPv4 address (contained in the first 4 bytes), followed by one or more zero-terminated strings containing the DNS entries for that address.</c>
|
|
||||||
|
|
||||||
<c>ip6_rec</c>
|
|
||||||
<c>1</c>
|
|
||||||
<c>Variable</c>
|
|
||||||
<c>Specifies an IPv6 address (contained in the first 16 bytes), followed by one or more zero-terminated strings containing the DNS entries for that address.</c>
|
|
||||||
</texttable>
|
|
||||||
|
|
||||||
<t>After the list or Name Resolution Records, optionally, a list of options (formatted according to the rules defined in <xref target="sectionopt"/>) can be present.</t>
|
|
||||||
|
|
||||||
<t>A Name Resolution Block is normally placed at the beginning of the file, but no assumptions can be taken about its position. Name Resolution Blocks can be added in a second time by tools that process the file, like network analyzers.</t>
|
|
||||||
|
|
||||||
<t>In addiction to the options defined in <xref target="sectionopt"/>, the following options are valid within this block:</t>
|
|
||||||
|
|
||||||
<texttable>
|
|
||||||
<ttcol>Name</ttcol>
|
|
||||||
<ttcol>Code</ttcol>
|
|
||||||
<ttcol>Length</ttcol>
|
|
||||||
<ttcol>Description</ttcol>
|
|
||||||
|
|
||||||
<c>ns_dnsname</c>
|
|
||||||
<c>2</c>
|
|
||||||
<c>Variable</c>
|
|
||||||
<c>An ascii string containing the name of the machine (DNS server) used to perform the name resolution.</c>
|
|
||||||
</texttable>
|
|
||||||
|
|
||||||
</section>
|
|
||||||
|
|
||||||
|
|
||||||
<section title="Interface Statistics Block (optional)">
|
|
||||||
<t>The Interface Statistics Block contains the capture statistics for a given interface and it is optional. The statistics are referred to the interface defined in the current Section identified by the Interface ID field.</t>
|
|
||||||
<t>The format of the Interface Statistics Block is shown in <xref target="formatisb"/>.</t>
|
|
||||||
|
|
||||||
<figure anchor="formatisb" title="Interface Statistics Block format.">
|
|
||||||
<artwork>
|
|
||||||
0 1 2 3
|
|
||||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| IfRecv |
|
|
||||||
| (high + low) |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| IfDrop |
|
|
||||||
| (high + low) |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| FilterAccept |
|
|
||||||
| (high + low) |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| OSDrop |
|
|
||||||
| (high + low) |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| UsrDelivered |
|
|
||||||
| (high + low) |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Interface ID | Reserved |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
/ /
|
|
||||||
/ Options (variable) /
|
|
||||||
/ /
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
</artwork>
|
|
||||||
</figure>
|
|
||||||
|
|
||||||
<t>The fields have the following meaning:</t>
|
|
||||||
|
|
||||||
<list style="symbols">
|
|
||||||
<t>IfRecv: number of packets received from the interface during the capture. This number is reported as a 64 bits value, in which the most significat bits are located in the first four bytes of the field.</t>
|
|
||||||
<t>IfDrop: number of packets dropped by the interface during the capture due to lack of resources.</t>
|
|
||||||
<t>FilterAccept: number of packets accepeted by filter during current capture.</t>
|
|
||||||
<t>OSDrop: number of packets dropped by the operating system during the capture.</t>
|
|
||||||
<t>UsrDelivered: number of packets delivered to the user. UsrDelivered can be different from the value 'FilterAccept - OSDropped' because some packets could still lay in the OS buffers when the capture ended.</t>
|
|
||||||
<t>Interface ID: reference to an Interface Description Block.</t>
|
|
||||||
<t>Reserved: Reserved to future use.</t>
|
|
||||||
<t>Options: optionally, a list of options (formatted according to the rules defined in <xref target="sectionopt"/>) can be present.</t>
|
|
||||||
</list>
|
|
||||||
|
|
||||||
<t>In addiction to the options defined in <xref target="sectionopt"/>, the following options are valid within this block:</t>
|
|
||||||
|
|
||||||
<texttable>
|
|
||||||
<ttcol>Name</ttcol>
|
|
||||||
<ttcol>Code</ttcol>
|
|
||||||
<ttcol>Length</ttcol>
|
|
||||||
<ttcol>Description</ttcol>
|
|
||||||
|
|
||||||
<c>isb_starttime</c>
|
|
||||||
<c>2</c>
|
|
||||||
<c>8</c>
|
|
||||||
<c>Time in which the capture started; time will be stored in two blocks of four bytes each, containing the timestamp in seconds and nanoseconds.</c>
|
|
||||||
|
|
||||||
<c>isb_endtime</c>
|
|
||||||
<c>3</c>
|
|
||||||
<c>8</c>
|
|
||||||
<c>Time in which the capture started; time will be stored in two blocks of four bytes each, containing the timestamp in seconds and nanoseconds.</c>
|
|
||||||
</texttable>
|
|
||||||
|
|
||||||
</section>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<section anchor="sectionopt" title="Options">
|
|
||||||
<t>Almost all blocks have the possibility to embed optional fields. Optional fields can be used to insert some information that may be useful when reading data, but that it is not really needed for packet processing. Therefore, each tool can be either read the content of the optional fields (if any), or skip them at once.</t>
|
|
||||||
<t>Skipping all the optional fields at once is straightforward because most of the blocks have a fixed length, therefore the field Block Length (present in the General Block Structure, see <xref target="sectionblock"/>) can be used to skip everything till the next block.</t>
|
|
||||||
|
|
||||||
<t>Options are a list of Type - Length - Value fields, each one containing a single value:</t>
|
|
||||||
|
|
||||||
<list style="symbols">
|
|
||||||
<t>Option Type (2 bytes): it contains the code that specifies the type of the current TLV record. Option types whose Most Significant Bit is equal to one are reserved for local use; therefore, there is no guarantee that the code used is unique among all capture files (generated by other applications). In case of vendor-specific extensions that have to be identified uniquely, vendors must request an Option Code whose MSB is equal to zero.</t>
|
|
||||||
<t>Option Length (2 bytes): it contains the length of the following 'Option Value' field.</t>
|
|
||||||
<t>Option Value (variable length): it contains the value of the given option. The length of this field as been specified by the Option Length field.</t>
|
|
||||||
</list>
|
|
||||||
|
|
||||||
<t>Options may be repeated several times (e.g. an interface that has several IP addresses associated to it). The option list is terminated by a special code which is the 'End of Option'.</t>
|
|
||||||
|
|
||||||
<t>The format of the optional fields is shown in <xref target="formatopt"/>.</t>
|
|
||||||
|
|
||||||
<figure anchor="formatopt" title="Options format.">
|
|
||||||
<artwork>
|
|
||||||
0 1 2 3
|
|
||||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Option Code | Option Length |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Option Value |
|
|
||||||
| /* variable length, byte-aligned */ |
|
|
||||||
| + + + + + + + + + + + + + + + + + + + + + + + + +
|
|
||||||
| / / / |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
/ /
|
|
||||||
/ . . . other options . . . /
|
|
||||||
/ /
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Option Code == opt_endofopt | Option Length == 0 |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
</artwork>
|
|
||||||
</figure>
|
|
||||||
|
|
||||||
<t>The following codes can always be present in any optional field:</t>
|
|
||||||
|
|
||||||
<texttable>
|
|
||||||
<ttcol>Name</ttcol>
|
|
||||||
<ttcol>Code</ttcol>
|
|
||||||
<ttcol>Length</ttcol>
|
|
||||||
<ttcol>Description</ttcol>
|
|
||||||
|
|
||||||
<c>opt_endofopt</c>
|
|
||||||
<c>0</c>
|
|
||||||
<c>0</c>
|
|
||||||
<c>End of options: it is used to delimit the end of the optional fields. This block cannot be repeated within a given list of options.</c>
|
|
||||||
|
|
||||||
<c>opt_comment</c>
|
|
||||||
<c>1</c>
|
|
||||||
<c>variable</c>
|
|
||||||
<c>Comment: it is an ascii string containing a comment that is associated to the current block.</c>
|
|
||||||
</texttable>
|
|
||||||
|
|
||||||
</section>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<section title="Experimental Blocks (deserved to a further investigation)">
|
|
||||||
|
|
||||||
<section title="Other Packet Blocks (experimental)">
|
|
||||||
<t>Can some other packet blocks (besides the two described in the previous paragraphs) be useful?</t>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section title="Compression Block (experimental)">
|
|
||||||
<t>The Compression Block is optional. A file can contain an arbitrary number of these blocks. A Compression Block, as the name says, is used to store compressed data. Its format is shown in <xref target="formatcb"/>.</t>
|
|
||||||
|
|
||||||
<figure anchor="formatcb" title="Compression Block format.">
|
|
||||||
<artwork>
|
|
||||||
0 1 2 3
|
|
||||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Compr. Type | |
|
|
||||||
+-+-+-+-+-+-+-+-+ |
|
|
||||||
| |
|
|
||||||
| Compressed Data |
|
|
||||||
| |
|
|
||||||
| /* variable length, byte-aligned */ |
|
|
||||||
| |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
</artwork>
|
|
||||||
</figure>
|
|
||||||
|
|
||||||
<t>The fields have the following meaning:</t>
|
|
||||||
|
|
||||||
<list style="symbols">
|
|
||||||
<t>Compression Type: specifies the compression algorithm. Possible values for this field are 0 (uncompressed), 1 (Lempel Ziv), 2 (Gzip), other?? Probably some kind of dumb and fast compression algorithm could be effective with some types of traffic (for example web), but which?</t>
|
|
||||||
<t>Compressed Data: data of this block. Once decompressed, it is made of other blocks.</t>
|
|
||||||
</list>
|
|
||||||
|
|
||||||
</section>
|
|
||||||
|
|
||||||
|
|
||||||
<section title="Encryption Block (experimental)">
|
|
||||||
<t>The Encryption Block is optional. A file can contain an arbitrary number of these blocks. An Encryption Block is used to sotre encrypted data. Its format is shown in <xref target="formateb"/>.</t>
|
|
||||||
|
|
||||||
<figure anchor="formateb" title="Encryption Block format.">
|
|
||||||
<artwork>
|
|
||||||
0 1 2 3
|
|
||||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Encr. Type | |
|
|
||||||
+-+-+-+-+-+-+-+-+ |
|
|
||||||
| |
|
|
||||||
| Compressed Data |
|
|
||||||
| |
|
|
||||||
| /* variable length, byte-aligned */ |
|
|
||||||
| |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
</artwork>
|
|
||||||
</figure>
|
|
||||||
|
|
||||||
<t>The fields have the following meaning:</t>
|
|
||||||
<list style="symbols">
|
|
||||||
<t>Compression Type: specifies the encryption algorithm. Possible values for this field are ??? NOTE: this block should probably contain other fields, depending on the encryption algorithm. To be define precisely.</t>
|
|
||||||
<t>Encrypted Data: data of this block. Once decripted, it consists of other blocks.</t>
|
|
||||||
</list>
|
|
||||||
|
|
||||||
</section>
|
|
||||||
|
|
||||||
|
|
||||||
<section title="Fixed Length Block (experimental)">
|
|
||||||
<t>The Fixed Length Block is optional. A file can contain an arbitrary number of these blocks. A Fixed Length Block can be used to optimize the access to the file. Its format is shown in <xref target="formatflm"/>.
|
|
||||||
A Fixed Length Block stores records with constant size. It contains a set of Blocks (normally Packet Blocks or Simple Packet Blocks), of wihich it specifies the size. Knowing this size a priori helps to scan the file and to load some portions of it without truncating a block, and is particularly useful with cell-based networks like ATM.</t>
|
|
||||||
|
|
||||||
<figure anchor="formatflm" title="Fixed Length Block format.">
|
|
||||||
<artwork>
|
|
||||||
0 1 2 3
|
|
||||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
| Cell Size | |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
|
||||||
| |
|
|
||||||
| Fixed Size Data |
|
|
||||||
| |
|
|
||||||
| /* variable length, byte-aligned */ |
|
|
||||||
| |
|
|
||||||
| |
|
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
||||||
</artwork>
|
|
||||||
</figure>
|
|
||||||
|
|
||||||
<t>The fields have the following meaning:</t>
|
|
||||||
<list style="symbols">
|
|
||||||
<t>Cell size: the size of the blocks contained in the data field.</t>
|
|
||||||
<t>Fixed Size Data: data of this block.</t>
|
|
||||||
</list>
|
|
||||||
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section title="Directory Block (experimental)">
|
|
||||||
<t>If present, this block contains the following information:</t>
|
|
||||||
<list style="symbols">
|
|
||||||
<t>number of indexed packets (N)</t>
|
|
||||||
<t>table with position and length of any indexed packet (N entries)</t>
|
|
||||||
</list>
|
|
||||||
|
|
||||||
<t>A directory block must be followed by at least N packets, otherwise it must be considered invalid. It can be used to efficiently load portions of the file to memory and to support operations on memory mapped files. This block can be added by tools like network analyzers as a consequence of file processing.</t>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section title="Traffic Statistics and Monitoring Blocks (experimental)">
|
|
||||||
<t>One or more blocks could be defined to contain network statistics or traffic monitoring information. They could be use to store data collected from RMON or Netflow probes, or from other network monitoring tools.</t>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section title="Event/Security Block (experimental)">
|
|
||||||
<t>This block could be used to store events. Events could contain generic information (for example network load over 50%, server down...) or security alerts. An event could be:</t>
|
|
||||||
|
|
||||||
<list style="symbols">
|
|
||||||
<t>skipped, if the application doesn't know how to do with it</t>
|
|
||||||
<t>processed independently by the packets. In other words, the applications skips the packets and processes only the alerts</t>
|
|
||||||
<t>processed in relation to packets: for example, a security tool could load only the packets of the file that are near a security alert; a monitorg tool could skip the packets captured while the server was down.</t>
|
|
||||||
</list>
|
|
||||||
|
|
||||||
</section>
|
|
||||||
|
|
||||||
</section>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<section title="Conclusions">
|
|
||||||
<t>The file format proposed in this document should be very versatile and satisfy a wide range of applications.
|
|
||||||
In the simplest case, it can contain a raw dump of the network data, made of a series of Simple Packet Blocks.
|
|
||||||
In the most complex case, it can be used as a repository for heterogeneous information.
|
|
||||||
In every case, the file remains easy to parse and an application can always skip the data it is not interested in; at the same time, different applications can share the file, and each of them can benfit of the information produced by the others.
|
|
||||||
Two or more files can be concatenated obtaining another valid file.</t>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
|
|
||||||
<section title="Most important open issues">
|
|
||||||
<list style="symbols">
|
|
||||||
<t>Data, in the file, must be byte or word aligned? Currently, the structure of this document is not consistent with respect to this point.</t>
|
|
||||||
</list>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
</middle>
|
|
||||||
|
|
||||||
</rfc>
|
|
||||||
@@ -1,162 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef lint
|
|
||||||
static const char rcsid[] _U_ =
|
|
||||||
"@(#) $Header$ (LBL)";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#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);
|
|
||||||
}
|
|
||||||
@@ -1,113 +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.
|
|
||||||
*
|
|
||||||
* @(#) $Header$ (LBL)
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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_LOOPBACK
|
|
||||||
#define ETHERTYPE_LOOPBACK 0x9000
|
|
||||||
#endif
|
|
||||||
@@ -1,284 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef lint
|
|
||||||
static const char rcsid[] _U_ =
|
|
||||||
"@(#) $Header$ (LBL)";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
||||||
#ifdef AF_PACKET
|
|
||||||
# include <linux/if_packet.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). 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
|
|
||||||
|
|
||||||
#ifdef 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
|
|
||||||
* were up and could be opened.
|
|
||||||
*
|
|
||||||
* This is the implementation used on platforms that have "getifaddrs()".
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf)
|
|
||||||
{
|
|
||||||
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; are there any such interfaces
|
|
||||||
* that would be capable of receiving packets?
|
|
||||||
* (Interfaces incapable of receiving packets aren't
|
|
||||||
* very interesting from libpcap's point of view.)
|
|
||||||
*
|
|
||||||
* 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)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
|
||||||
"getifaddrs: %s", pcap_strerror(errno));
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) {
|
|
||||||
/*
|
|
||||||
* Is this interface up?
|
|
||||||
*/
|
|
||||||
if (!(ifa->ifa_flags & IFF_UP)) {
|
|
||||||
/*
|
|
||||||
* No, so don't add it to the list.
|
|
||||||
*/
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* "ifa_addr" was apparently null on at least one
|
|
||||||
* interface on some system.
|
|
||||||
*
|
|
||||||
* "ifa_broadaddr" may be non-null even on
|
|
||||||
* non-broadcast interfaces, and was null on
|
|
||||||
* at least one OpenBSD 3.4 system on at least
|
|
||||||
* one interface with IFF_BROADCAST set.
|
|
||||||
*
|
|
||||||
* "ifa_dstaddr" was, on at least one FreeBSD 4.1
|
|
||||||
* system, non-null on a non-point-to-point
|
|
||||||
* interface.
|
|
||||||
*
|
|
||||||
* Therefore, we supply the address and netmask only
|
|
||||||
* if "ifa_addr" is non-null (if there's no address,
|
|
||||||
* there's obviously no netmask), and supply the
|
|
||||||
* broadcast and destination addresses if the appropriate
|
|
||||||
* flag is set *and* the appropriate "ifa_" entry doesn't
|
|
||||||
* evaluate to a null pointer.
|
|
||||||
*/
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Add information for this address to the list.
|
|
||||||
*/
|
|
||||||
if (add_addr_to_iflist(&devlist, 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 haven't had any errors yet; do any platform-specific
|
|
||||||
* operations to add devices.
|
|
||||||
*/
|
|
||||||
if (pcap_platform_finddevs(&devlist, errbuf) < 0)
|
|
||||||
ret = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
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,578 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef lint
|
|
||||||
static const char rcsid[] _U_ =
|
|
||||||
"@(#) $Header$ (LBL)";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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
|
|
||||||
|
|
||||||
#ifdef HAVE_PROC_NET_DEV
|
|
||||||
/*
|
|
||||||
* Get from "/proc/net/dev" all interfaces listed there; if they're
|
|
||||||
* already in the list of interfaces we have, that won't add another
|
|
||||||
* instance, but if they're not, that'll add them.
|
|
||||||
*
|
|
||||||
* We don't bother getting any addresses for them; it appears you can't
|
|
||||||
* use SIOCGIFADDR on Linux to get IPv6 addresses for interfaces, and,
|
|
||||||
* although some other types of addresses can be fetched with SIOCGIFADDR,
|
|
||||||
* we don't bother with them for now.
|
|
||||||
*
|
|
||||||
* We also don't fail if we couldn't open "/proc/net/dev"; we just leave
|
|
||||||
* the list of interfaces as is.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
scan_proc_net_dev(pcap_if_t **devlistp, int fd, char *errbuf)
|
|
||||||
{
|
|
||||||
FILE *proc_net_f;
|
|
||||||
char linebuf[512];
|
|
||||||
int linenum;
|
|
||||||
unsigned char *p;
|
|
||||||
char name[512]; /* XXX - pick a size */
|
|
||||||
char *q, *saveq;
|
|
||||||
struct ifreq ifrflags;
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
proc_net_f = fopen("/proc/net/dev", "r");
|
|
||||||
if (proc_net_f == NULL)
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
for (linenum = 1;
|
|
||||||
fgets(linebuf, sizeof linebuf, proc_net_f) != NULL; linenum++) {
|
|
||||||
/*
|
|
||||||
* Skip the first two lines - they're headers.
|
|
||||||
*/
|
|
||||||
if (linenum <= 2)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
p = &linebuf[0];
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Skip leading white space.
|
|
||||||
*/
|
|
||||||
while (*p != '\0' && isspace(*p))
|
|
||||||
p++;
|
|
||||||
if (*p == '\0' || *p == '\n')
|
|
||||||
continue; /* blank line */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get the interface name.
|
|
||||||
*/
|
|
||||||
q = &name[0];
|
|
||||||
while (*p != '\0' && !isspace(*p)) {
|
|
||||||
if (*p == ':') {
|
|
||||||
/*
|
|
||||||
* This could be the separator between a
|
|
||||||
* name and an alias number, or it could be
|
|
||||||
* the separator between a name with no
|
|
||||||
* alias number and the next field.
|
|
||||||
*
|
|
||||||
* If there's a colon after digits, it
|
|
||||||
* separates the name and the alias number,
|
|
||||||
* otherwise it separates the name and the
|
|
||||||
* next field.
|
|
||||||
*/
|
|
||||||
saveq = q;
|
|
||||||
while (isdigit(*p))
|
|
||||||
*q++ = *p++;
|
|
||||||
if (*p != ':') {
|
|
||||||
/*
|
|
||||||
* That was the next field,
|
|
||||||
* not the alias number.
|
|
||||||
*/
|
|
||||||
q = saveq;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
} else
|
|
||||||
*q++ = *p++;
|
|
||||||
}
|
|
||||||
*q = '\0';
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get the flags for this interface, and skip it if
|
|
||||||
* it's not up.
|
|
||||||
*/
|
|
||||||
strncpy(ifrflags.ifr_name, name, sizeof(ifrflags.ifr_name));
|
|
||||||
if (ioctl(fd, SIOCGIFFLAGS, (char *)&ifrflags) < 0) {
|
|
||||||
if (errno == ENXIO)
|
|
||||||
continue;
|
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
|
||||||
"SIOCGIFFLAGS: %.*s: %s",
|
|
||||||
(int)sizeof(ifrflags.ifr_name),
|
|
||||||
ifrflags.ifr_name,
|
|
||||||
pcap_strerror(errno));
|
|
||||||
ret = -1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!(ifrflags.ifr_flags & IFF_UP))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Add an entry for this interface, with no addresses.
|
|
||||||
*/
|
|
||||||
if (pcap_add_if(devlistp, name, ifrflags.ifr_flags, NULL,
|
|
||||||
errbuf) == -1) {
|
|
||||||
/*
|
|
||||||
* Failure.
|
|
||||||
*/
|
|
||||||
ret = -1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ret != -1) {
|
|
||||||
/*
|
|
||||||
* Well, we didn't fail for any other reason; did we
|
|
||||||
* fail due to an error reading the file?
|
|
||||||
*/
|
|
||||||
if (ferror(proc_net_f)) {
|
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
|
||||||
"Error reading /proc/net/dev: %s",
|
|
||||||
pcap_strerror(errno));
|
|
||||||
ret = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
(void)fclose(proc_net_f);
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
#endif /* HAVE_PROC_NET_DEV */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf)
|
|
||||||
{
|
|
||||||
pcap_if_t *devlist = NULL;
|
|
||||||
register int fd;
|
|
||||||
register struct ifreq *ifrp, *ifend, *ifnext;
|
|
||||||
int 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)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)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)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;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get the flags for this interface, and skip it if it's
|
|
||||||
* not up.
|
|
||||||
*/
|
|
||||||
strncpy(ifrflags.ifr_name, ifrp->ifr_name,
|
|
||||||
sizeof(ifrflags.ifr_name));
|
|
||||||
if (ioctl(fd, SIOCGIFFLAGS, (char *)&ifrflags) < 0) {
|
|
||||||
if (errno == ENXIO)
|
|
||||||
continue;
|
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
|
||||||
"SIOCGIFFLAGS: %.*s: %s",
|
|
||||||
(int)sizeof(ifrflags.ifr_name),
|
|
||||||
ifrflags.ifr_name,
|
|
||||||
pcap_strerror(errno));
|
|
||||||
ret = -1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!(ifrflags.ifr_flags & IFF_UP))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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)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)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)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,
|
|
||||||
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);
|
|
||||||
|
|
||||||
#ifdef HAVE_PROC_NET_DEV
|
|
||||||
if (ret != -1) {
|
|
||||||
/*
|
|
||||||
* We haven't had any errors yet; now read "/proc/net/dev",
|
|
||||||
* and add to the list of interfaces all interfaces listed
|
|
||||||
* there that we don't already have, because, on Linux,
|
|
||||||
* SIOCGIFCONF reports only interfaces with IPv4 addresses,
|
|
||||||
* so you need to read "/proc/net/dev" to get the names of
|
|
||||||
* the rest of the interfaces.
|
|
||||||
*/
|
|
||||||
ret = scan_proc_net_dev(&devlist, fd, errbuf);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
(void)close(fd);
|
|
||||||
|
|
||||||
if (ret != -1) {
|
|
||||||
/*
|
|
||||||
* We haven't had any errors yet; do any platform-specific
|
|
||||||
* operations to add devices.
|
|
||||||
*/
|
|
||||||
if (pcap_platform_finddevs(&devlist, errbuf) < 0)
|
|
||||||
ret = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
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,386 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef lint
|
|
||||||
static const char rcsid[] _U_ =
|
|
||||||
"@(#) $Header$ (LBL)";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#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 SIOCLGIFCONF
|
|
||||||
* but don't have "getifaddrs()". (Solaris 8 and later; we use
|
|
||||||
* SIOCLGIFCONF rather than SIOCGIFCONF in order to get IPv6 addresses.)
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf)
|
|
||||||
{
|
|
||||||
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)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)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)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)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)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++) {
|
|
||||||
/*
|
|
||||||
* IPv6 or not?
|
|
||||||
*/
|
|
||||||
if (((struct sockaddr *)&ifrp->lifr_addr)->sa_family == AF_INET6)
|
|
||||||
fd = fd6;
|
|
||||||
else
|
|
||||||
fd = fd4;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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;
|
|
||||||
|
|
||||||
#ifdef HAVE_SOLARIS
|
|
||||||
/*
|
|
||||||
* Skip entries that have a ":" followed by a number
|
|
||||||
* at the end - those are Solaris virtual interfaces
|
|
||||||
* on which you can't capture.
|
|
||||||
*/
|
|
||||||
p = strchr(ifrp->lifr_name, ':');
|
|
||||||
if (p != NULL) {
|
|
||||||
/*
|
|
||||||
* We have a ":"; is it followed by a number?
|
|
||||||
*/
|
|
||||||
while (isdigit((unsigned char)*p))
|
|
||||||
p++;
|
|
||||||
if (*p == '\0') {
|
|
||||||
/*
|
|
||||||
* All digits after the ":" until the end.
|
|
||||||
*/
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get the flags for this interface, and skip it if it's
|
|
||||||
* not up.
|
|
||||||
*/
|
|
||||||
strncpy(ifrflags.lifr_name, ifrp->lifr_name,
|
|
||||||
sizeof(ifrflags.lifr_name));
|
|
||||||
if (ioctl(fd, SIOCGLIFFLAGS, (char *)&ifrflags) < 0) {
|
|
||||||
if (errno == ENXIO)
|
|
||||||
continue;
|
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
|
||||||
"SIOCGLIFFLAGS: %.*s: %s",
|
|
||||||
(int)sizeof(ifrflags.lifr_name),
|
|
||||||
ifrflags.lifr_name,
|
|
||||||
pcap_strerror(errno));
|
|
||||||
ret = -1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!(ifrflags.lifr_flags & IFF_UP))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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)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)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)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,
|
|
||||||
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 haven't had any errors yet; do any platform-specific
|
|
||||||
* operations to add devices.
|
|
||||||
*/
|
|
||||||
if (pcap_platform_finddevs(&devlist, errbuf) < 0)
|
|
||||||
ret = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
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,65 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef lint
|
|
||||||
static const char rcsid[] _U_ =
|
|
||||||
"@(#) $Header$ (LBL)";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <pcap.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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 no support for
|
|
||||||
* packet capture.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Succeed, but don't return any interfaces; we return only those
|
|
||||||
* we can open, and we can't open any if there's no support
|
|
||||||
* for packet capture.
|
|
||||||
*/
|
|
||||||
*alldevsp = NULL;
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
@@ -1,306 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2002 - 2003
|
|
||||||
* NetGroup, Politecnico di Torino (Italy)
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. Neither the name of the Politecnico di Torino nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived from
|
|
||||||
* this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef lint
|
|
||||||
static const char rcsid[] _U_ =
|
|
||||||
"@(#) $Header$ (LBL)";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <pcap.h>
|
|
||||||
#include <pcap-int.h>
|
|
||||||
#include <packet32.h>
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Add an entry to the list of addresses for an interface.
|
|
||||||
* "curdev" is the entry for that interface.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
add_addr_to_list(pcap_if_t *curdev, struct sockaddr *addr,
|
|
||||||
struct sockaddr *netmask, struct sockaddr *broadaddr,
|
|
||||||
struct sockaddr *dstaddr, char *errbuf)
|
|
||||||
{
|
|
||||||
pcap_addr_t *curaddr, *prevaddr, *nextaddr;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Allocate the new entry and fill it in.
|
|
||||||
*/
|
|
||||||
curaddr = (pcap_addr_t*)malloc(sizeof(pcap_addr_t));
|
|
||||||
if (curaddr == NULL) {
|
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
|
||||||
"malloc: %s", pcap_strerror(errno));
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
curaddr->next = NULL;
|
|
||||||
if (addr != NULL) {
|
|
||||||
curaddr->addr = (struct sockaddr*)dup_sockaddr(addr, sizeof(struct sockaddr_storage));
|
|
||||||
if (curaddr->addr == NULL) {
|
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
|
||||||
"malloc: %s", pcap_strerror(errno));
|
|
||||||
free(curaddr);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
curaddr->addr = NULL;
|
|
||||||
|
|
||||||
if (netmask != NULL) {
|
|
||||||
curaddr->netmask = (struct sockaddr*)dup_sockaddr(netmask, sizeof(struct sockaddr_storage));
|
|
||||||
if (curaddr->netmask == NULL) {
|
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
|
||||||
"malloc: %s", pcap_strerror(errno));
|
|
||||||
free(curaddr);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
curaddr->netmask = NULL;
|
|
||||||
|
|
||||||
if (broadaddr != NULL) {
|
|
||||||
curaddr->broadaddr = (struct sockaddr*)dup_sockaddr(broadaddr, sizeof(struct sockaddr_storage));
|
|
||||||
if (curaddr->broadaddr == NULL) {
|
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
|
||||||
"malloc: %s", pcap_strerror(errno));
|
|
||||||
free(curaddr);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
curaddr->broadaddr = NULL;
|
|
||||||
|
|
||||||
if (dstaddr != NULL) {
|
|
||||||
curaddr->dstaddr = (struct sockaddr*)dup_sockaddr(dstaddr, sizeof(struct sockaddr_storage));
|
|
||||||
if (curaddr->dstaddr == NULL) {
|
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
|
||||||
"malloc: %s", pcap_strerror(errno));
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
|
||||||
pcap_add_if_win32(pcap_if_t **devlist, char *name, const char *desc,
|
|
||||||
char *errbuf)
|
|
||||||
{
|
|
||||||
pcap_if_t *curdev;
|
|
||||||
npf_if_addr if_addrs[MAX_NETWORK_ADDRESSES];
|
|
||||||
LONG if_addr_size;
|
|
||||||
int res = 0;
|
|
||||||
|
|
||||||
if_addr_size = MAX_NETWORK_ADDRESSES;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Add an entry for this interface, with no addresses.
|
|
||||||
*/
|
|
||||||
if (add_or_find_if(&curdev, devlist, name, 0, desc, errbuf) == -1) {
|
|
||||||
/*
|
|
||||||
* Failure.
|
|
||||||
*/
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get the list of addresses for the interface.
|
|
||||||
*/
|
|
||||||
if (!PacketGetNetInfoEx((void *)name, if_addrs, &if_addr_size)) {
|
|
||||||
/*
|
|
||||||
* Failure.
|
|
||||||
*
|
|
||||||
* We don't return an error, because this can happen with
|
|
||||||
* NdisWan interfaces, and we want to supply them even
|
|
||||||
* if we can't supply their addresses.
|
|
||||||
*
|
|
||||||
* We return an entry with an empty address list.
|
|
||||||
*/
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Now add the addresses.
|
|
||||||
*/
|
|
||||||
while (if_addr_size-- > 0) {
|
|
||||||
/*
|
|
||||||
* "curdev" is an entry for this interface; add an entry for
|
|
||||||
* this address to its list of addresses.
|
|
||||||
*/
|
|
||||||
if(curdev == NULL)
|
|
||||||
break;
|
|
||||||
res = add_addr_to_list(curdev,
|
|
||||||
(struct sockaddr *)&if_addrs[if_addr_size].IPAddress,
|
|
||||||
(struct sockaddr *)&if_addrs[if_addr_size].SubnetMask,
|
|
||||||
(struct sockaddr *)&if_addrs[if_addr_size].Broadcast,
|
|
||||||
NULL,
|
|
||||||
errbuf);
|
|
||||||
if (res == -1) {
|
|
||||||
/*
|
|
||||||
* Failure.
|
|
||||||
*/
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (res);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* Win32 implementation, based on WinPcap
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf)
|
|
||||||
{
|
|
||||||
pcap_if_t *devlist = NULL;
|
|
||||||
int ret = 0;
|
|
||||||
const char *desc;
|
|
||||||
char *AdaptersName;
|
|
||||||
ULONG NameLength;
|
|
||||||
char *name;
|
|
||||||
|
|
||||||
PacketGetAdapterNames(NULL, &NameLength);
|
|
||||||
|
|
||||||
if (NameLength > 0)
|
|
||||||
AdaptersName = (char*) malloc(NameLength);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*alldevsp = NULL;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (AdaptersName == NULL)
|
|
||||||
{
|
|
||||||
snprintf(errbuf, PCAP_ERRBUF_SIZE, "Cannot allocate enough memory to list the adapters.");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!PacketGetAdapterNames(AdaptersName, &NameLength)) {
|
|
||||||
snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
|
||||||
"PacketGetAdapterNames: %s",
|
|
||||||
pcap_win32strerror());
|
|
||||||
free(AdaptersName);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* "PacketGetAdapterNames()" returned a list of
|
|
||||||
* null-terminated ASCII interface name strings,
|
|
||||||
* terminated by a null string, followed by a list
|
|
||||||
* of null-terminated ASCII interface description
|
|
||||||
* strings, terminated by a null string.
|
|
||||||
* This means there are two ASCII nulls at the end
|
|
||||||
* of the first list.
|
|
||||||
*
|
|
||||||
* Find the end of the first list; that's the
|
|
||||||
* beginning of the second list.
|
|
||||||
*/
|
|
||||||
desc = &AdaptersName[0];
|
|
||||||
while (*desc != '\0' || *(desc + 1) != '\0')
|
|
||||||
desc++;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Found it - "desc" points to the first of the two
|
|
||||||
* nulls at the end of the list of names, so the
|
|
||||||
* first byte of the list of descriptions is two bytes
|
|
||||||
* after it.
|
|
||||||
*/
|
|
||||||
desc += 2;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Loop over the elements in the first list.
|
|
||||||
*/
|
|
||||||
name = &AdaptersName[0];
|
|
||||||
while (*name != '\0') {
|
|
||||||
/*
|
|
||||||
* Add an entry for this interface.
|
|
||||||
*/
|
|
||||||
if (pcap_add_if_win32(&devlist, name, desc, errbuf) == -1) {
|
|
||||||
/*
|
|
||||||
* Failure.
|
|
||||||
*/
|
|
||||||
ret = -1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
name += strlen(name) + 1;
|
|
||||||
desc += strlen(desc) + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret == -1) {
|
|
||||||
/*
|
|
||||||
* We had an error; free the list we've been constructing.
|
|
||||||
*/
|
|
||||||
if (devlist != NULL) {
|
|
||||||
pcap_freealldevs(devlist);
|
|
||||||
devlist = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*alldevsp = devlist;
|
|
||||||
free(AdaptersName);
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
6716
libpcap/gencode.c
6716
libpcap/gencode.c
File diff suppressed because it is too large
Load Diff
@@ -1,323 +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.
|
|
||||||
*
|
|
||||||
* @(#) $Header$ (LBL)
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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
|
|
||||||
|
|
||||||
/* Directional qualifiers. */
|
|
||||||
|
|
||||||
#define Q_SRC 1
|
|
||||||
#define Q_DST 2
|
|
||||||
#define Q_OR 3
|
|
||||||
#define Q_AND 4
|
|
||||||
|
|
||||||
#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. */
|
|
||||||
|
|
||||||
/*MTP3 field types */
|
|
||||||
#define M_SIO 1
|
|
||||||
#define M_OPC 2
|
|
||||||
#define M_DPC 3
|
|
||||||
#define M_SLS 4
|
|
||||||
|
|
||||||
|
|
||||||
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;
|
|
||||||
int longjt; /* jt branch requires long jump */
|
|
||||||
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 arth *gen_loadi(int);
|
|
||||||
struct arth *gen_load(int, struct arth *, int);
|
|
||||||
struct arth *gen_loadlen(void);
|
|
||||||
struct arth *gen_neg(struct arth *);
|
|
||||||
struct arth *gen_arth(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(const char *, struct qual);
|
|
||||||
struct block *gen_ecode(const u_char *, struct qual);
|
|
||||||
struct block *gen_acode(const u_char *, struct qual);
|
|
||||||
struct block *gen_mcode(const char *, const char *, int, struct qual);
|
|
||||||
#ifdef INET6
|
|
||||||
struct block *gen_mcode6(const char *, const char *, int, struct qual);
|
|
||||||
#endif
|
|
||||||
struct block *gen_ncode(const char *, bpf_u_int32, struct qual);
|
|
||||||
struct block *gen_proto_abbrev(int);
|
|
||||||
struct block *gen_relation(int, struct arth *, struct arth *, int);
|
|
||||||
struct block *gen_less(int);
|
|
||||||
struct block *gen_greater(int);
|
|
||||||
struct block *gen_byteop(int, int, int);
|
|
||||||
struct block *gen_broadcast(int);
|
|
||||||
struct block *gen_multicast(int);
|
|
||||||
struct block *gen_inbound(int);
|
|
||||||
|
|
||||||
struct block *gen_vlan(int);
|
|
||||||
struct block *gen_mpls(int);
|
|
||||||
|
|
||||||
struct block *gen_atmfield_code(int atmfield, bpf_int32 jvalue, bpf_u_int32 jtype, int reverse);
|
|
||||||
struct block *gen_atmtype_abbrev(int type);
|
|
||||||
struct block *gen_atmmulti_abbrev(int type);
|
|
||||||
|
|
||||||
struct block *gen_mtp3field_code(int mtp3field, bpf_u_int32 jvalue, bpf_u_int32 jtype, int reverse);
|
|
||||||
|
|
||||||
struct block *gen_pf_ifname(const char *);
|
|
||||||
struct block *gen_pf_rnr(int);
|
|
||||||
struct block *gen_pf_srnr(int);
|
|
||||||
struct block *gen_pf_ruleset(char *);
|
|
||||||
struct block *gen_pf_reason(int);
|
|
||||||
struct block *gen_pf_action(int);
|
|
||||||
struct block *gen_pf_dir(int);
|
|
||||||
|
|
||||||
void bpf_optimize(struct block **);
|
|
||||||
void bpf_error(const char *, ...)
|
|
||||||
__attribute__((noreturn, format (printf, 1, 2)));
|
|
||||||
|
|
||||||
void finish_parse(struct block *);
|
|
||||||
char *sdup(const char *);
|
|
||||||
|
|
||||||
struct bpf_insn *icode_to_fcode(struct block *, int *);
|
|
||||||
int pcap_parse(void);
|
|
||||||
void lex_init(char *);
|
|
||||||
void lex_cleanup(void);
|
|
||||||
void sappend(struct slist *, struct slist *);
|
|
||||||
|
|
||||||
/* XXX */
|
|
||||||
#define JT(b) ((b)->et.succ)
|
|
||||||
#define JF(b) ((b)->ef.succ)
|
|
||||||
|
|
||||||
extern int no_optimize;
|
|
||||||
1776
libpcap/grammar.c
1776
libpcap/grammar.c
File diff suppressed because it is too large
Load Diff
@@ -1,462 +0,0 @@
|
|||||||
%{
|
|
||||||
/*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#ifndef lint
|
|
||||||
static const char rcsid[] _U_ =
|
|
||||||
"@(#) $Header$ (LBL)";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#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>
|
|
||||||
#endif /* WIN32 */
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "pcap-int.h"
|
|
||||||
|
|
||||||
#include "gencode.h"
|
|
||||||
#include "pf.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)
|
|
||||||
|
|
||||||
int n_errors = 0;
|
|
||||||
|
|
||||||
static struct qual qerr = { Q_UNDEF, Q_UNDEF, Q_UNDEF, Q_UNDEF };
|
|
||||||
|
|
||||||
static void
|
|
||||||
yyerror(char *msg)
|
|
||||||
{
|
|
||||||
++n_errors;
|
|
||||||
bpf_error("%s", msg);
|
|
||||||
/* NOTREACHED */
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef YYBISON
|
|
||||||
int yyparse(void);
|
|
||||||
|
|
||||||
int
|
|
||||||
pcap_parse()
|
|
||||||
{
|
|
||||||
return (yyparse());
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
%}
|
|
||||||
|
|
||||||
%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
|
|
||||||
%type <i> atmtype atmmultitype
|
|
||||||
%type <blk> atmfield
|
|
||||||
%type <blk> atmfieldvalue atmvalue atmlistvalue
|
|
||||||
%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
|
|
||||||
%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 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 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 SIO OPC DPC SLS
|
|
||||||
|
|
||||||
%type <s> ID
|
|
||||||
%type <e> EID
|
|
||||||
%type <e> AID
|
|
||||||
%type <s> HID HID6
|
|
||||||
%type <i> NUM action reason
|
|
||||||
|
|
||||||
%left OR AND
|
|
||||||
%nonassoc '!'
|
|
||||||
%left '|'
|
|
||||||
%left '&'
|
|
||||||
%left LSH RSH
|
|
||||||
%left '+' '-'
|
|
||||||
%left '*' '/'
|
|
||||||
%nonassoc UMINUS
|
|
||||||
%%
|
|
||||||
prog: null expr
|
|
||||||
{
|
|
||||||
finish_parse($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(NULL, (bpf_u_int32)$1,
|
|
||||||
$$.q = $<blk>0.q); }
|
|
||||||
| paren pid ')' { $$ = $2; }
|
|
||||||
;
|
|
||||||
nid: ID { $$.b = gen_scode($1, $$.q = $<blk>0.q); }
|
|
||||||
| HID '/' NUM { $$.b = gen_mcode($1, NULL, $3,
|
|
||||||
$$.q = $<blk>0.q); }
|
|
||||||
| HID NETMASK HID { $$.b = gen_mcode($1, $3, 0,
|
|
||||||
$$.q = $<blk>0.q); }
|
|
||||||
| HID {
|
|
||||||
/* Decide how to parse HID based on proto */
|
|
||||||
$$.q = $<blk>0.q;
|
|
||||||
$$.b = gen_ncode($1, 0, $$.q);
|
|
||||||
}
|
|
||||||
| HID6 '/' NUM {
|
|
||||||
#ifdef INET6
|
|
||||||
$$.b = gen_mcode6($1, NULL, $3,
|
|
||||||
$$.q = $<blk>0.q);
|
|
||||||
#else
|
|
||||||
bpf_error("'ip6addr/prefixlen' not supported "
|
|
||||||
"in this configuration");
|
|
||||||
#endif /*INET6*/
|
|
||||||
}
|
|
||||||
| HID6 {
|
|
||||||
#ifdef INET6
|
|
||||||
$$.b = gen_mcode6($1, 0, 128,
|
|
||||||
$$.q = $<blk>0.q);
|
|
||||||
#else
|
|
||||||
bpf_error("'ip6addr' not supported "
|
|
||||||
"in this configuration");
|
|
||||||
#endif /*INET6*/
|
|
||||||
}
|
|
||||||
| EID {
|
|
||||||
$$.b = gen_ecode($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($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(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($1); $$.q = qerr; }
|
|
||||||
| arth relop arth { $$.b = gen_relation($2, $1, $3, 0);
|
|
||||||
$$.q = qerr; }
|
|
||||||
| arth irelop arth { $$.b = gen_relation($2, $1, $3, 1);
|
|
||||||
$$.q = qerr; }
|
|
||||||
| other { $$.b = $1; $$.q = qerr; }
|
|
||||||
| atmtype { $$.b = gen_atmtype_abbrev($1); $$.q = qerr; }
|
|
||||||
| atmmultitype { $$.b = gen_atmmulti_abbrev($1); $$.q = qerr; }
|
|
||||||
| atmfield atmvalue { $$.b = $2.b; $$.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; }
|
|
||||||
;
|
|
||||||
/* 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; }
|
|
||||||
| 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($1); }
|
|
||||||
| pqual TK_MULTICAST { $$ = gen_multicast($1); }
|
|
||||||
| LESS NUM { $$ = gen_less($2); }
|
|
||||||
| GREATER NUM { $$ = gen_greater($2); }
|
|
||||||
| CBYTE NUM byteop NUM { $$ = gen_byteop($3, $2, $4); }
|
|
||||||
| INBOUND { $$ = gen_inbound(0); }
|
|
||||||
| OUTBOUND { $$ = gen_inbound(1); }
|
|
||||||
| VLAN pnum { $$ = gen_vlan($2); }
|
|
||||||
| VLAN { $$ = gen_vlan(-1); }
|
|
||||||
| MPLS pnum { $$ = gen_mpls($2); }
|
|
||||||
| MPLS { $$ = gen_mpls(-1); }
|
|
||||||
| pfvar { $$ = $1; }
|
|
||||||
;
|
|
||||||
|
|
||||||
pfvar: PF_IFNAME ID { $$ = gen_pf_ifname($2); }
|
|
||||||
| PF_RSET ID { $$ = gen_pf_ruleset($2); }
|
|
||||||
| PF_RNR NUM { $$ = gen_pf_rnr($2); }
|
|
||||||
| PF_SRNR NUM { $$ = gen_pf_srnr($2); }
|
|
||||||
| PF_REASON reason { $$ = gen_pf_reason($2); }
|
|
||||||
| PF_ACTION action { $$ = gen_pf_action($2); }
|
|
||||||
;
|
|
||||||
|
|
||||||
reason: NUM { $$ = $1; }
|
|
||||||
| ID { const char *reasons[] = PFRES_NAMES;
|
|
||||||
int i;
|
|
||||||
for (i = 0; reasons[i]; i++) {
|
|
||||||
if (pcap_strcasecmp($1, reasons[i]) == 0) {
|
|
||||||
$$ = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (reasons[i] == NULL)
|
|
||||||
bpf_error("unknown PF reason");
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
action: ID { if (pcap_strcasecmp($1, "pass") == 0 ||
|
|
||||||
pcap_strcasecmp($1, "accept") == 0)
|
|
||||||
$$ = PF_PASS;
|
|
||||||
else if (pcap_strcasecmp($1, "drop") == 0 ||
|
|
||||||
pcap_strcasecmp($1, "block") == 0)
|
|
||||||
$$ = PF_DROP;
|
|
||||||
else
|
|
||||||
bpf_error("unknown PF action");
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
relop: '>' { $$ = BPF_JGT; }
|
|
||||||
| GEQ { $$ = BPF_JGE; }
|
|
||||||
| '=' { $$ = BPF_JEQ; }
|
|
||||||
;
|
|
||||||
irelop: LEQ { $$ = BPF_JGT; }
|
|
||||||
| '<' { $$ = BPF_JGE; }
|
|
||||||
| NEQ { $$ = BPF_JEQ; }
|
|
||||||
;
|
|
||||||
arth: pnum { $$ = gen_loadi($1); }
|
|
||||||
| narth
|
|
||||||
;
|
|
||||||
narth: pname '[' arth ']' { $$ = gen_load($1, $3, 1); }
|
|
||||||
| pname '[' arth ':' NUM ']' { $$ = gen_load($1, $3, $5); }
|
|
||||||
| arth '+' arth { $$ = gen_arth(BPF_ADD, $1, $3); }
|
|
||||||
| arth '-' arth { $$ = gen_arth(BPF_SUB, $1, $3); }
|
|
||||||
| arth '*' arth { $$ = gen_arth(BPF_MUL, $1, $3); }
|
|
||||||
| arth '/' arth { $$ = gen_arth(BPF_DIV, $1, $3); }
|
|
||||||
| arth '&' arth { $$ = gen_arth(BPF_AND, $1, $3); }
|
|
||||||
| arth '|' arth { $$ = gen_arth(BPF_OR, $1, $3); }
|
|
||||||
| arth LSH arth { $$ = gen_arth(BPF_LSH, $1, $3); }
|
|
||||||
| arth RSH arth { $$ = gen_arth(BPF_RSH, $1, $3); }
|
|
||||||
| '-' arth %prec UMINUS { $$ = gen_neg($2); }
|
|
||||||
| paren narth ')' { $$ = $2; }
|
|
||||||
| LEN { $$ = gen_loadlen(); }
|
|
||||||
;
|
|
||||||
byteop: '&' { $$ = '&'; }
|
|
||||||
| '|' { $$ = '|'; }
|
|
||||||
| '<' { $$ = '<'; }
|
|
||||||
| '>' { $$ = '>'; }
|
|
||||||
| '=' { $$ = '='; }
|
|
||||||
;
|
|
||||||
pnum: NUM
|
|
||||||
| paren pnum ')' { $$ = $2; }
|
|
||||||
;
|
|
||||||
atmtype: LANE { $$ = A_LANE; }
|
|
||||||
| LLC { $$ = A_LLC; }
|
|
||||||
| 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($<blk>0.atmfieldtype, (bpf_int32)$2, (bpf_u_int32)$1, 0); }
|
|
||||||
| irelop NUM { $$.b = gen_atmfield_code($<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($$.atmfieldtype, (bpf_int32) $1, BPF_JEQ, 0);
|
|
||||||
}
|
|
||||||
;
|
|
||||||
atmlistvalue: atmfieldvalue
|
|
||||||
| atmlistvalue or atmfieldvalue { gen_or($1.b, $3.b); $$ = $3; }
|
|
||||||
;
|
|
||||||
/* MTP3 field types quantifier */
|
|
||||||
mtp3field: SIO { $$.mtp3fieldtype = M_SIO; }
|
|
||||||
| OPC { $$.mtp3fieldtype = M_OPC; }
|
|
||||||
| DPC { $$.mtp3fieldtype = M_DPC; }
|
|
||||||
| SLS { $$.mtp3fieldtype = M_SLS; }
|
|
||||||
;
|
|
||||||
mtp3value: mtp3fieldvalue
|
|
||||||
| relop NUM { $$.b = gen_mtp3field_code($<blk>0.mtp3fieldtype, (u_int)$2, (u_int)$1, 0); }
|
|
||||||
| irelop NUM { $$.b = gen_mtp3field_code($<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 )
|
|
||||||
$$.b = gen_mtp3field_code($$.mtp3fieldtype, (u_int) $1, BPF_JEQ, 0);
|
|
||||||
}
|
|
||||||
;
|
|
||||||
mtp3listvalue: mtp3fieldvalue
|
|
||||||
| mtp3listvalue or mtp3fieldvalue { gen_or($1.b, $3.b); $$ = $3; }
|
|
||||||
;
|
|
||||||
%%
|
|
||||||
727
libpcap/inet.c
727
libpcap/inet.c
@@ -1,727 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef lint
|
|
||||||
static const char rcsid[] _U_ =
|
|
||||||
"@(#) $Header$ (LBL)";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
||||||
/* 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
|
|
||||||
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
get_instance(const char *name)
|
|
||||||
{
|
|
||||||
const char *cp, *endcp;
|
|
||||||
int n;
|
|
||||||
|
|
||||||
if (strcmp(name, "any") == 0) {
|
|
||||||
/*
|
|
||||||
* Give the "any" device an artificially high instance
|
|
||||||
* number, so it shows up after all other non-loopback
|
|
||||||
* interfaces.
|
|
||||||
*/
|
|
||||||
return INT_MAX;
|
|
||||||
}
|
|
||||||
|
|
||||||
endcp = name + strlen(name);
|
|
||||||
for (cp = name; cp < endcp && !isdigit((unsigned char)*cp); ++cp)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (isdigit((unsigned char)*cp))
|
|
||||||
n = atoi(cp);
|
|
||||||
else
|
|
||||||
n = 0;
|
|
||||||
return (n);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
add_or_find_if(pcap_if_t **curdev_ret, pcap_if_t **alldevs, const char *name,
|
|
||||||
u_int flags, const char *description, char *errbuf)
|
|
||||||
{
|
|
||||||
pcap_t *p;
|
|
||||||
pcap_if_t *curdev, *prevdev, *nextdev;
|
|
||||||
int this_instance;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Can we open this interface for live capture?
|
|
||||||
*
|
|
||||||
* We do this check so that interfaces that ae supplied
|
|
||||||
* by the interface enumeration mechanism we're using
|
|
||||||
* but that don't support packet capture aren't included
|
|
||||||
* in the list. An example of this is loopback interfaces
|
|
||||||
* on Solaris; we don't just omit loopback interfaces
|
|
||||||
* becaue you *can* capture on loopback interfaces on some
|
|
||||||
* OSes.
|
|
||||||
*/
|
|
||||||
p = pcap_open_live(name, 68, 0, 0, errbuf);
|
|
||||||
if (p == NULL) {
|
|
||||||
/*
|
|
||||||
* No. Don't bother including it.
|
|
||||||
* Don't treat this as an error, though.
|
|
||||||
*/
|
|
||||||
*curdev_ret = NULL;
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
pcap_close(p);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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.
|
|
||||||
* Allocate a new entry.
|
|
||||||
*/
|
|
||||||
curdev = malloc(sizeof(pcap_if_t));
|
|
||||||
if (curdev == NULL) {
|
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
|
||||||
"malloc: %s", pcap_strerror(errno));
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Fill in the entry.
|
|
||||||
*/
|
|
||||||
curdev->next = NULL;
|
|
||||||
curdev->name = malloc(strlen(name) + 1);
|
|
||||||
strcpy(curdev->name, name);
|
|
||||||
if (description != NULL) {
|
|
||||||
/*
|
|
||||||
* We have a description for this interface.
|
|
||||||
*/
|
|
||||||
curdev->description = malloc(strlen(description) + 1);
|
|
||||||
strcpy(curdev->description, description);
|
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* We don't.
|
|
||||||
*/
|
|
||||||
curdev->description = NULL;
|
|
||||||
}
|
|
||||||
curdev->addresses = NULL; /* list starts out as empty */
|
|
||||||
curdev->flags = 0;
|
|
||||||
if (ISLOOPBACK(name, flags))
|
|
||||||
curdev->flags |= PCAP_IF_LOOPBACK;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Add it to the list, in the appropriate location.
|
|
||||||
* First, get the instance number of this interface.
|
|
||||||
*/
|
|
||||||
this_instance = get_instance(name);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Now look for the last interface with an instance number
|
|
||||||
* less than or equal to the new interface's instance
|
|
||||||
* number - except that non-loopback interfaces are
|
|
||||||
* arbitrarily treated as having interface numbers less
|
|
||||||
* than those of loopback interfaces, so the loopback
|
|
||||||
* interfaces are put at the end of the list.
|
|
||||||
*
|
|
||||||
* 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 a non-loopback interface
|
|
||||||
* and the next interface a loopback interface?
|
|
||||||
*/
|
|
||||||
if (!(curdev->flags & PCAP_IF_LOOPBACK) &&
|
|
||||||
(nextdev->flags & PCAP_IF_LOOPBACK)) {
|
|
||||||
/*
|
|
||||||
* Yes, we should put the new entry
|
|
||||||
* before "nextdev", i.e. after "prevdev".
|
|
||||||
*/
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Is the new interface's instance number less
|
|
||||||
* than the next interface's instance number,
|
|
||||||
* and is it the case that the new interface is a
|
|
||||||
* non-loopback interface or the next interface is
|
|
||||||
* a loopback interface?
|
|
||||||
*
|
|
||||||
* (The goal of both loopback tests is to make
|
|
||||||
* sure that we never put a loopback interface
|
|
||||||
* before any non-loopback interface and that we
|
|
||||||
* always put a non-loopback interface before all
|
|
||||||
* loopback interfaces.)
|
|
||||||
*/
|
|
||||||
if (this_instance < get_instance(nextdev->name) &&
|
|
||||||
(!(curdev->flags & PCAP_IF_LOOPBACK) ||
|
|
||||||
(nextdev->flags & PCAP_IF_LOOPBACK))) {
|
|
||||||
/*
|
|
||||||
* 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
add_addr_to_iflist(pcap_if_t **alldevs, const char *name, u_int 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;
|
|
||||||
pcap_addr_t *curaddr, *prevaddr, *nextaddr;
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* "curdev" is an entry for this interface; add an entry for this
|
|
||||||
* address to its list of addresses.
|
|
||||||
*
|
|
||||||
* Allocate the new entry and fill it in.
|
|
||||||
*/
|
|
||||||
curaddr = malloc(sizeof(pcap_addr_t));
|
|
||||||
if (curaddr == NULL) {
|
|
||||||
(void)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)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)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
|
||||||
"malloc: %s", pcap_strerror(errno));
|
|
||||||
free(curaddr);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
curaddr->netmask = NULL;
|
|
||||||
|
|
||||||
if (broadaddr != NULL) {
|
|
||||||
curaddr->broadaddr = dup_sockaddr(broadaddr, broadaddr_size);
|
|
||||||
if (curaddr->broadaddr == NULL) {
|
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
|
||||||
"malloc: %s", pcap_strerror(errno));
|
|
||||||
free(curaddr);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
curaddr->broadaddr = NULL;
|
|
||||||
|
|
||||||
if (dstaddr != NULL) {
|
|
||||||
curaddr->dstaddr = dup_sockaddr(dstaddr, dstaddr_size);
|
|
||||||
if (curaddr->dstaddr == NULL) {
|
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
|
||||||
"malloc: %s", pcap_strerror(errno));
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#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 *sin;
|
|
||||||
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
|
|
||||||
) {
|
|
||||||
*netp = *maskp = 0;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
fd = socket(AF_INET, SOCK_DGRAM, 0);
|
|
||||||
if (fd < 0) {
|
|
||||||
(void)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)strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
|
|
||||||
if (ioctl(fd, SIOCGIFADDR, (char *)&ifr) < 0) {
|
|
||||||
if (errno == EADDRNOTAVAIL) {
|
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
|
||||||
"%s: no IPv4 address assigned", device);
|
|
||||||
} else {
|
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
|
||||||
"SIOCGIFADDR: %s: %s",
|
|
||||||
device, pcap_strerror(errno));
|
|
||||||
}
|
|
||||||
(void)close(fd);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
sin = (struct sockaddr_in *)&ifr.ifr_addr;
|
|
||||||
*netp = sin->sin_addr.s_addr;
|
|
||||||
if (ioctl(fd, SIOCGIFNETMASK, (char *)&ifr) < 0) {
|
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
|
||||||
"SIOCGIFNETMASK: %s: %s", device, pcap_strerror(errno));
|
|
||||||
(void)close(fd);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
(void)close(fd);
|
|
||||||
*maskp = sin->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)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.
|
|
||||||
*/
|
|
||||||
char *
|
|
||||||
pcap_lookupdev(errbuf)
|
|
||||||
register char *errbuf;
|
|
||||||
{
|
|
||||||
DWORD dwVersion;
|
|
||||||
DWORD dwWindowsMajorVersion;
|
|
||||||
dwVersion = GetVersion(); /* get the OS version */
|
|
||||||
dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
|
|
||||||
|
|
||||||
if (dwVersion >= 0x80000000 && dwWindowsMajorVersion >= 4) {
|
|
||||||
/*
|
|
||||||
* Windows 95, 98, ME.
|
|
||||||
*/
|
|
||||||
ULONG NameLength = 8192;
|
|
||||||
static char AdaptersName[8192];
|
|
||||||
|
|
||||||
if (PacketGetAdapterNames(AdaptersName,&NameLength) )
|
|
||||||
return (AdaptersName);
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* Windows NT (NT 4.0, W2K, WXP). Convert the names to UNICODE for backward compatibility
|
|
||||||
*/
|
|
||||||
ULONG NameLength = 8192;
|
|
||||||
static WCHAR AdaptersName[8192];
|
|
||||||
char *tAstr;
|
|
||||||
WCHAR *tUstr;
|
|
||||||
WCHAR *TAdaptersName = (WCHAR*)malloc(8192 * sizeof(WCHAR));
|
|
||||||
int NAdapts = 0;
|
|
||||||
|
|
||||||
if(TAdaptersName == NULL)
|
|
||||||
{
|
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE, "memory allocation failure");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !PacketGetAdapterNames((PTSTR)TAdaptersName,&NameLength) )
|
|
||||||
{
|
|
||||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
|
||||||
"PacketGetAdapterNames: %s",
|
|
||||||
pcap_win32strerror());
|
|
||||||
free(TAdaptersName);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
tAstr = (char*)TAdaptersName;
|
|
||||||
tUstr = (WCHAR*)AdaptersName;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Convert and copy the device names
|
|
||||||
*/
|
|
||||||
while(sscanf(tAstr, "%S", tUstr) > 0)
|
|
||||||
{
|
|
||||||
tAstr += strlen(tAstr) + 1;
|
|
||||||
tUstr += wcslen(tUstr) + 1;
|
|
||||||
NAdapts ++;
|
|
||||||
}
|
|
||||||
|
|
||||||
tAstr++;
|
|
||||||
*tUstr = 0;
|
|
||||||
tUstr++;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copy the descriptions
|
|
||||||
*/
|
|
||||||
while(NAdapts--)
|
|
||||||
{
|
|
||||||
strcpy((char*)tUstr, tAstr);
|
|
||||||
(char*)tUstr += strlen(tAstr) + 1;;
|
|
||||||
tAstr += strlen(tAstr) + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
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 */
|
|
||||||
@@ -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,25 +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.
|
|
||||||
*
|
|
||||||
* @(#) $Header$
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Prototypes missing in AIX 4.x */
|
|
||||||
int ffs(int i);
|
|
||||||
@@ -1,25 +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.
|
|
||||||
*
|
|
||||||
* @(#) $Header$
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Prototypes missing in HP-UX 11.x */
|
|
||||||
int ffs(int i);
|
|
||||||
@@ -1,28 +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.
|
|
||||||
*
|
|
||||||
* @(#) $Header$ (LBL)
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Prototypes missing in Digital UNIX 4.x */
|
|
||||||
int snprintf(char *, size_t, const char *, ...);
|
|
||||||
int vsnprintf(char *, size_t, const char *, va_list);
|
|
||||||
int pfopen(char *, int);
|
|
||||||
|
|
||||||
@@ -1,32 +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.
|
|
||||||
*
|
|
||||||
* @(#) $Header$ (LBL)
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Prototypes missing in Tru64 UNIX 5.x
|
|
||||||
* XXX - "snprintf()" and "vsnprintf()" aren't missing, but you have to
|
|
||||||
* #define the right value to get them defined by <stdio.h>.
|
|
||||||
*/
|
|
||||||
int snprintf(char *, size_t, const char *, ...);
|
|
||||||
int vsnprintf(char *, size_t, const char *, va_list);
|
|
||||||
int pfopen(char *, int);
|
|
||||||
|
|
||||||
@@ -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.
|
|
||||||
*
|
|
||||||
* @(#) $Header$ (LBL)
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Prototypes missing in SunOS 5 */
|
|
||||||
char *strerror(int);
|
|
||||||
int snprintf(char *, size_t, const char *, ...);
|
|
||||||
@@ -1,215 +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.
|
|
||||||
*
|
|
||||||
* @(#) $Header$ (LBL)
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* 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);
|
|
||||||
void endservent(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 *);
|
|
||||||
void setservent(int);
|
|
||||||
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 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,39 +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.
|
|
||||||
*
|
|
||||||
* @(#) $Header$ (LBL)
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* 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);
|
|
||||||
void endservent(void);
|
|
||||||
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 *);
|
|
||||||
@@ -1,69 +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.
|
|
||||||
*
|
|
||||||
* @(#) $Header$ (LBL)
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 802.2 LLC SAP values.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef LLCSAP_NULL
|
|
||||||
#define LLCSAP_NULL 0x00
|
|
||||||
#endif
|
|
||||||
#ifndef LLCSAP_GLOBAL
|
|
||||||
#define LLCSAP_GLOBAL 0xff
|
|
||||||
#endif
|
|
||||||
#ifndef LLCSAP_8021B
|
|
||||||
#define LLCSAP_8021B_I 0x02
|
|
||||||
#endif
|
|
||||||
#ifndef LLCSAP_8021B
|
|
||||||
#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,632 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* $Id: snprintf.c,v 1.1 2004/04/05 22:43:51 guy Exp $ */
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include <config.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef lint
|
|
||||||
static const char rcsid[] _U_ =
|
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/missing/snprintf.c,v 1.1 2004/04/05 22:43:51 guy Exp $";
|
|
||||||
#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
|
|
||||||
snprintf (char *str, size_t sz, const char *format, ...)
|
|
||||||
{
|
|
||||||
va_list args;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
va_start(args, format);
|
|
||||||
ret = vsnprintf (str, sz, format, args);
|
|
||||||
|
|
||||||
#ifdef PARANOIA
|
|
||||||
{
|
|
||||||
int ret2;
|
|
||||||
char *tmp;
|
|
||||||
|
|
||||||
tmp = malloc (sz);
|
|
||||||
if (tmp == NULL)
|
|
||||||
abort ();
|
|
||||||
|
|
||||||
ret2 = 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
|
|
||||||
asnprintf (char **ret, size_t max_sz, const char *format, ...)
|
|
||||||
{
|
|
||||||
va_list args;
|
|
||||||
int val;
|
|
||||||
|
|
||||||
va_start(args, format);
|
|
||||||
val = vasnprintf (ret, max_sz, 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_VASPRINTF
|
|
||||||
int
|
|
||||||
vasprintf (char **ret, const char *format, va_list args)
|
|
||||||
{
|
|
||||||
return vasnprintf (ret, 0, format, args);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef HAVE_VASNPRINTF
|
|
||||||
int
|
|
||||||
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
|
|
||||||
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
|
|
||||||
|
|
||||||
109
libpcap/mkdep
109
libpcap/mkdep
@@ -1,109 +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
|
|
||||||
#
|
|
||||||
|
|
||||||
PATH=/bin:/usr/bin:/usr/ucb:/usr/local:/usr/local/bin
|
|
||||||
export PATH
|
|
||||||
|
|
||||||
MAKE=Makefile # default makefile name is "Makefile"
|
|
||||||
CC=cc # default C compiler is "cc"
|
|
||||||
|
|
||||||
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 ;;
|
|
||||||
|
|
||||||
# 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] [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 -M $* |
|
|
||||||
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 (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,80 +0,0 @@
|
|||||||
#
|
|
||||||
# Common defines for libpcap and 16/32-bit network drivers (djgpp)
|
|
||||||
#
|
|
||||||
# @(#) $Header: /tcpdump/master/libpcap/msdos/common.dj,v 1.2 2004/12/19 19:36:33 guy Exp $ (LBL)
|
|
||||||
|
|
||||||
.SUFFIXES: .exe .wlm .dxe .l .y
|
|
||||||
.PHONY: check_gcclib
|
|
||||||
|
|
||||||
default: check_gcclib all
|
|
||||||
|
|
||||||
GCCLIB = /djgpp/lib/gcc-lib/djgpp/3.31
|
|
||||||
MAKEFILE = Makefile.dj
|
|
||||||
|
|
||||||
#
|
|
||||||
# DLX 2.91+ lib. Change path to suite.
|
|
||||||
# Not used anymore. Uses DXE3 now.
|
|
||||||
#
|
|
||||||
# DLX_LIB = $(DJDIR)/contrib/dlx.291/libdlx.a
|
|
||||||
# DLX_LINK = $(DJDIR)/bin/dlxgen.exe
|
|
||||||
|
|
||||||
WATT32_ROOT = $(subst \,/,$(WATT_ROOT))
|
|
||||||
|
|
||||||
|
|
||||||
ifeq ($(wildcard $(GCCLIB)/libgcc.a),)
|
|
||||||
check_gcclib:
|
|
||||||
@echo libgcc.a not found. Set \"$(GCCLIB)\" to \"/djgpp/lib/gcc-lib/djgpp/3.X\"
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Include 32-bit driver support
|
|
||||||
#
|
|
||||||
USE_32BIT_DRIVERS = 0
|
|
||||||
|
|
||||||
#
|
|
||||||
# Use loadable driver modules instead of statically linking
|
|
||||||
# all drivers.
|
|
||||||
#
|
|
||||||
USE_32BIT_MODULES = 0
|
|
||||||
|
|
||||||
#
|
|
||||||
# Put interrupt sensitive code/data in locked sections
|
|
||||||
# Do `make clean' in all affected directories after changing this.
|
|
||||||
#
|
|
||||||
USE_SECTION_LOCKING = 0
|
|
||||||
|
|
||||||
#
|
|
||||||
# Set to 1 to use exception handler lib (only for me)
|
|
||||||
#
|
|
||||||
USE_EXCEPT = 0
|
|
||||||
|
|
||||||
CC = gcc.exe
|
|
||||||
LD = ld.exe
|
|
||||||
ASM = nasm.exe -fbin -dDEBUG
|
|
||||||
YACC = bison.exe
|
|
||||||
LEX = flex.exe
|
|
||||||
|
|
||||||
CFLAGS = -g -gcoff -O2 -Wall -I. -I$(WATT32_ROOT)/inc
|
|
||||||
|
|
||||||
ifeq ($(USE_EXCEPT),1)
|
|
||||||
CFLAGS += -DUSE_EXCEPT
|
|
||||||
EXC_LIB = d:/prog/mw/except/lib/libexc.a
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(USE_SECTION_LOCKING),1)
|
|
||||||
CFLAGS += -DUSE_SECTION_LOCKING
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(USE_32BIT_DRIVERS),1)
|
|
||||||
CFLAGS += -DUSE_32BIT_DRIVERS
|
|
||||||
endif
|
|
||||||
|
|
||||||
%.o: %.c
|
|
||||||
$(CC) -c $(CFLAGS) $<
|
|
||||||
@echo
|
|
||||||
|
|
||||||
%.o: %.s
|
|
||||||
$(CC) -c $(CFLAGS) -x assembler-with-cpp -o $@ $<
|
|
||||||
@echo
|
|
||||||
|
|
||||||
@@ -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,152 +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
|
|
||||||
#
|
|
||||||
# @(#) $Header: /tcpdump/master/libpcap/msdos/makefile.dj,v 1.2 2004/12/19 19:41:06 guy Exp $ (LBL)
|
|
||||||
|
|
||||||
VPATH = missing msdos
|
|
||||||
|
|
||||||
PREREQUISITES = scanner.c grammar.c tokdefs.h version.h msdos/pkt_stub.inc
|
|
||||||
|
|
||||||
include msdos/common.dj
|
|
||||||
|
|
||||||
DRIVER_DIR = ./msdos/pm_drvr
|
|
||||||
|
|
||||||
CFLAGS += -DDEBUG -DNDIS_DEBUG -DHAVE_LIMITS_H -DHAVE_STRERROR \
|
|
||||||
-D_U_='__attribute__((unused))' -DHAVE_VERSION_H
|
|
||||||
|
|
||||||
# CFLAGS += -Dyylval=pcap_lval -DBDEBUG -DNDEBUG
|
|
||||||
|
|
||||||
SOURCES = grammar.c scanner.c bpf_filt.c bpf_imag.c bpf_dump.c \
|
|
||||||
etherent.c gencode.c nametoad.c pcap-dos.c optimize.c \
|
|
||||||
savefile.c pcap.c inet.c msdos\pktdrvr.c msdos/ndis2.c \
|
|
||||||
missing/snprintf.c
|
|
||||||
|
|
||||||
OBJECTS = $(notdir $(SOURCES:.c=.o))
|
|
||||||
TEMPBIN = tmp.bin
|
|
||||||
|
|
||||||
ifeq ($(USE_32BIT_DRIVERS),1)
|
|
||||||
PM_OBJECTS = $(addprefix $(DRIVER_DIR)/, \
|
|
||||||
printk.o pci.o pci-scan.o bios32.o dma.o irq.o intwrap.o \
|
|
||||||
lock.o kmalloc.o quirks.o timer.o net_init.o)
|
|
||||||
#
|
|
||||||
# Static link of drivers
|
|
||||||
#
|
|
||||||
ifeq ($(USE_32BIT_MODULES),0)
|
|
||||||
PM_OBJECTS += $(addprefix $(DRIVER_DIR)/, \
|
|
||||||
accton.o 8390.o 3c503.o 3c509.o 3c59x.o 3c515.o \
|
|
||||||
3c575_cb.o 3c90x.o ne.o wd.o cs89x0.o rtl8139.o)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
all: libpcap.a
|
|
||||||
|
|
||||||
ifeq ($(USE_32BIT_DRIVERS),1)
|
|
||||||
$(PM_OBJECTS):
|
|
||||||
$(MAKE) -f Makefile.dj -C $(DRIVER_DIR) $(notdir $@)
|
|
||||||
endif
|
|
||||||
|
|
||||||
libpcap.a: version.h $(OBJECTS) $(PM_OBJECTS)
|
|
||||||
rm -f $@
|
|
||||||
ar rs $@ $^
|
|
||||||
|
|
||||||
msdos/pkt_stub.inc: msdos/bin2c.exe msdos/pkt_rx1.S
|
|
||||||
$(ASM) -o $(TEMPBIN) -lmsdos/pkt_rx1.lst msdos/pkt_rx1.S
|
|
||||||
./msdos/bin2c $(TEMPBIN) > $@
|
|
||||||
rm -f $(TEMPBIN)
|
|
||||||
|
|
||||||
grammar.c tokdefs.h: grammar.y
|
|
||||||
rm -f grammar.c tokdefs.h
|
|
||||||
$(YACC) --name-prefix=pcap_ --yacc --defines grammar.y
|
|
||||||
mv -f y_tab.c grammar.c
|
|
||||||
mv -f y_tab.h tokdefs.h
|
|
||||||
|
|
||||||
version.h: ./VERSION
|
|
||||||
@echo '/* Generated from VERSION. Do not edit */' > $@
|
|
||||||
sed -e 's/.*/static char pcap_version_string[] = "libpcap (&)";/' ./VERSION >> $@
|
|
||||||
|
|
||||||
scanner.c: scanner.l
|
|
||||||
$(LEX) -Ppcap_ -7 -t $^ > $@
|
|
||||||
@echo
|
|
||||||
|
|
||||||
msdos/bin2c.exe: msdos/bin2c.c
|
|
||||||
$(CC) $*.c -o $*.exe
|
|
||||||
|
|
||||||
clean:
|
|
||||||
$(MAKE) -f Makefile.dj -C $(DRIVER_DIR) clean
|
|
||||||
$(MAKE) -f Makefile.dj -C libcpcap clean
|
|
||||||
rm -f $(OBJECTS) msdos/pkt_rx1.lst Makefile.bak $(PREREQUISITES)
|
|
||||||
|
|
||||||
vclean: clean
|
|
||||||
rm -f libpcap.a msdos/bin2c.exe
|
|
||||||
|
|
||||||
#
|
|
||||||
# Generated dependencies; Due to some hacks in gcc 2.95 and djgpp 2.03
|
|
||||||
# we must prevent "$(DJDIR)/bin/../include/sys/version.h" from beeing
|
|
||||||
# included in dependency output (or else this makefile cannot be used on
|
|
||||||
# another machine). We therefore use a special 'specs' file during
|
|
||||||
# pre-processing.
|
|
||||||
#
|
|
||||||
MM_SPECS = specs.tmp
|
|
||||||
MAKEFILE = msdos/Makefile.dj
|
|
||||||
|
|
||||||
depend: $(PREREQUISITES)
|
|
||||||
@echo Generating dependencies..
|
|
||||||
@cp $(MAKEFILE) Makefile.bak
|
|
||||||
@echo "*cpp: %(cpp_cpu) %{posix:-D_POSIX_SOURCE} -remap" > $(MM_SPECS)
|
|
||||||
sed -e "/^# DO NOT DELETE THIS LINE/,$$d" < Makefile.bak > $(MAKEFILE)
|
|
||||||
echo "# DO NOT DELETE THIS LINE" >> $(MAKEFILE)
|
|
||||||
$(CC) -MM -specs=$(MM_SPECS) $(CFLAGS) $(SOURCES) >> $(MAKEFILE)
|
|
||||||
rm -f $(MM_SPECS)
|
|
||||||
|
|
||||||
#
|
|
||||||
# Manually generated dependencies
|
|
||||||
#
|
|
||||||
msdos/pktdrvr.c: msdos/pkt_stub.inc
|
|
||||||
scanner.c: scanner.l
|
|
||||||
grammar.c tokdefs.h: grammar.y
|
|
||||||
grammar.h: grammar.y
|
|
||||||
scanner.l: pcap-int.h pcap-namedb.h gencode.h grammar.h gnuc.h
|
|
||||||
grammar.y: pcap-int.h gencode.h pcap-namedb.h gnuc.h
|
|
||||||
|
|
||||||
#
|
|
||||||
# Automatically generated dependencies
|
|
||||||
#
|
|
||||||
# DO NOT DELETE THIS LINE
|
|
||||||
grammar.o: grammar.c pcap-int.h pcap.h pcap-bpf.h gencode.h pf.h \
|
|
||||||
pcap-namedb.h
|
|
||||||
scanner.o: scanner.c pcap-int.h pcap.h pcap-bpf.h gencode.h pcap-namedb.h \
|
|
||||||
tokdefs.h
|
|
||||||
bpf_filt.o: bpf_filt.c pcap-int.h pcap.h pcap-bpf.h gnuc.h
|
|
||||||
bpf_imag.o: bpf_imag.c pcap-int.h pcap.h pcap-bpf.h
|
|
||||||
bpf_dump.o: bpf_dump.c pcap.h pcap-bpf.h
|
|
||||||
etherent.o: etherent.c pcap-int.h pcap.h pcap-bpf.h pcap-namedb.h
|
|
||||||
gencode.o: gencode.c pcap-dos.h msdos/pm_drvr/lock.h pcap-int.h pcap.h \
|
|
||||||
pcap-bpf.h ethertype.h nlpid.h llc.h gencode.h atmuni31.h sunatmpos.h \
|
|
||||||
ppp.h sll.h arcnet.h pf.h pcap-namedb.h
|
|
||||||
nametoad.o: nametoad.c pcap-int.h pcap.h pcap-bpf.h gencode.h \
|
|
||||||
pcap-namedb.h ethertype.h
|
|
||||||
pcap-dos.o: pcap-dos.c msdos/pm_drvr/pmdrvr.h msdos/pm_drvr/iface.h \
|
|
||||||
msdos/pm_drvr/lock.h msdos/pm_drvr/ioport.h pcap-dos.h pcap-int.h \
|
|
||||||
pcap.h pcap-bpf.h msdos/pm_drvr/kmalloc.h msdos/pm_drvr/bitops.h \
|
|
||||||
msdos/pm_drvr/timer.h msdos/pm_drvr/dma.h msdos/pm_drvr/irq.h \
|
|
||||||
msdos/pm_drvr/printk.h msdos/pm_drvr/pci.h msdos/pm_drvr/bios32.h \
|
|
||||||
msdos/pm_drvr/module.h msdos/pm_drvr/3c501.h msdos/pm_drvr/3c503.h \
|
|
||||||
msdos/pm_drvr/3c509.h msdos/pm_drvr/3c59x.h msdos/pm_drvr/3c515.h \
|
|
||||||
msdos/pm_drvr/3c90x.h msdos/pm_drvr/3c575_cb.h msdos/pm_drvr/ne.h \
|
|
||||||
msdos/pm_drvr/wd.h msdos/pm_drvr/accton.h msdos/pm_drvr/cs89x0.h \
|
|
||||||
msdos/pm_drvr/rtl8139.h msdos/pm_drvr/ne2k-pci.h msdos/pktdrvr.h
|
|
||||||
optimize.o: optimize.c pcap-int.h pcap.h pcap-bpf.h gencode.h
|
|
||||||
savefile.o: savefile.c pcap-int.h pcap.h pcap-bpf.h
|
|
||||||
pcap.o: pcap.c pcap-dos.h msdos/pm_drvr/lock.h pcap-int.h pcap.h \
|
|
||||||
pcap-bpf.h
|
|
||||||
inet.o: inet.c pcap-int.h pcap.h pcap-bpf.h
|
|
||||||
pktdrvr.o: msdos/pktdrvr.c gnuc.h pcap-dos.h msdos/pm_drvr/lock.h \
|
|
||||||
pcap-int.h pcap.h pcap-bpf.h msdos/pktdrvr.h msdos/pkt_stub.inc
|
|
||||||
ndis2.o: msdos/ndis2.c pcap-dos.h msdos/pm_drvr/lock.h pcap-int.h pcap.h \
|
|
||||||
pcap-bpf.h msdos/ndis2.h
|
|
||||||
snprintf.o: missing/snprintf.c pcap-int.h pcap.h pcap-bpf.h
|
|
||||||
@@ -1,131 +0,0 @@
|
|||||||
#
|
|
||||||
# Watcom Makefile for dos-libpcap.
|
|
||||||
#
|
|
||||||
# Specify MODEL = `3r' or `3s'
|
|
||||||
# Specify TARGET = `pharlap' or `dos4g'
|
|
||||||
#
|
|
||||||
# Use this makefile from the libpcap root directory.
|
|
||||||
# E.g. like this:
|
|
||||||
#
|
|
||||||
# c:\net\pcap> wmake -f msdos\makefile.wc
|
|
||||||
#
|
|
||||||
|
|
||||||
MODEL = 3s
|
|
||||||
TARGET = dos4g
|
|
||||||
|
|
||||||
OBJDIR = msdos\$(TARGET).w$(MODEL)
|
|
||||||
LIB = $(OBJDIR)\pcap.lib
|
|
||||||
|
|
||||||
.EXTENSIONS: .l .y
|
|
||||||
|
|
||||||
DEFS = -dDEBUG -dNDIS_DEBUG -d_U_= -dHAVE_LIMITS_H -dHAVE_STRERROR &
|
|
||||||
-dHAVE_SNPRINTF -dHAVE_VSNPRINTF
|
|
||||||
|
|
||||||
CC = wcc386.exe
|
|
||||||
ASM = wasm.exe -$(MODEL) $(DEFS) -dDOSX -dDOS4GW -zq -bt=dos -fr=nul -d3 -s
|
|
||||||
|
|
||||||
OBJS = $(OBJDIR)\grammar.obj $(OBJDIR)\scanner.obj $(OBJDIR)\pcap.obj &
|
|
||||||
$(OBJDIR)\bpf_filt.obj $(OBJDIR)\bpf_imag.obj $(OBJDIR)\bpf_dump.obj &
|
|
||||||
$(OBJDIR)\etherent.obj $(OBJDIR)\gencode.obj $(OBJDIR)\nametoad.obj &
|
|
||||||
$(OBJDIR)\pcap-dos.obj $(OBJDIR)\pktdrvr.obj $(OBJDIR)\optimize.obj &
|
|
||||||
$(OBJDIR)\savefile.obj $(OBJDIR)\inet.obj $(OBJDIR)\ndis2.obj
|
|
||||||
|
|
||||||
CFLAGS = $(DEFS) $(YYDEFS) -I. -I$(%watt_root)\inc -I.\msdos\pm_drvr &
|
|
||||||
-$(MODEL) -mf -zff -zgf -zq -bt=dos -fr=nul -w6 -fpi &
|
|
||||||
-oilrtf -zm
|
|
||||||
|
|
||||||
TEMPBIN = tmp.bin
|
|
||||||
|
|
||||||
all: $(OBJDIR) $(OBJDIR)\pcap.lib
|
|
||||||
|
|
||||||
$(OBJDIR):
|
|
||||||
- mkdir $(OBJDIR)
|
|
||||||
|
|
||||||
$(OBJDIR)\pcap.lib: $(OBJS) wlib.arg
|
|
||||||
wlib -q -b -c $(OBJDIR)\pcap.lib @wlib.arg
|
|
||||||
|
|
||||||
wlib.arg: msdos\makefile.wc
|
|
||||||
%create $^@
|
|
||||||
for %f in ($(OBJS)) do %append $^@ +- %f
|
|
||||||
|
|
||||||
$(OBJDIR)\pktdrvr.obj: msdos\pkt_stub.inc msdos\pktdrvr.c gnuc.h &
|
|
||||||
pcap-dos.h pcap-int.h pcap.h msdos\pktdrvr.h
|
|
||||||
*$(CC) $(CFLAGS) msdos\pktdrvr.c -fo=$@
|
|
||||||
|
|
||||||
$(OBJDIR)\ndis2.obj: msdos\ndis2.c
|
|
||||||
*$(CC) $(CFLAGS) msdos\ndis2.c -fo=$@
|
|
||||||
|
|
||||||
.ERASE
|
|
||||||
.c{$(OBJDIR)}.obj:
|
|
||||||
*$(CC) $(CFLAGS) $[@ -fo=$@
|
|
||||||
|
|
||||||
grammar.c tokdefs.h: grammar.y
|
|
||||||
bison --name-prefix=pcap_ --yacc --defines $[@
|
|
||||||
- @del grammar.c
|
|
||||||
- @del tokdefs.h
|
|
||||||
ren y_tab.c grammar.c
|
|
||||||
ren y_tab.h tokdefs.h
|
|
||||||
|
|
||||||
scanner.c: scanner.l
|
|
||||||
flex -Ppcap_ -7 -o$@ $[@
|
|
||||||
|
|
||||||
msdos\pkt_stub.inc: bin2c.exe msdos\pkt_rx1.S
|
|
||||||
nasm -fbin -dDEBUG -o $(TEMPBIN) -lmsdos\pkt_rx1.lst msdos\pkt_rx1.S
|
|
||||||
bin2c.exe $(TEMPBIN) > $@
|
|
||||||
@del $(TEMPBIN)
|
|
||||||
|
|
||||||
bin2c.exe: msdos\bin2c.c
|
|
||||||
wcl $[@
|
|
||||||
|
|
||||||
clean realclean vclean: .SYMBOLIC
|
|
||||||
for %f in (dos4g.w3r dos4g.w3s pharlap.w3r pharlap.w3s) do &
|
|
||||||
@del %f\*.obj
|
|
||||||
@del grammar.c
|
|
||||||
@del tokdefs.h
|
|
||||||
@del scanner.c
|
|
||||||
@del bin2c.exe
|
|
||||||
@del bin2c.obj
|
|
||||||
@del msdos\pkt_stub.inc
|
|
||||||
@echo Cleaned
|
|
||||||
|
|
||||||
#
|
|
||||||
# dependencies
|
|
||||||
#
|
|
||||||
$(OBJDIR)\bpf_filt.obj: bpf_filt.c pcap-int.h pcap.h pcap-bpf.h gnuc.h
|
|
||||||
|
|
||||||
$(OBJDIR)\bpf_imag.obj: bpf_imag.c pcap-int.h pcap.h pcap-bpf.h
|
|
||||||
|
|
||||||
$(OBJDIR)\bpf_dump.obj: bpf_dump.c pcap.h pcap-bpf.h
|
|
||||||
|
|
||||||
$(OBJDIR)\etherent.obj: etherent.c pcap-int.h pcap.h pcap-bpf.h pcap-nam.h
|
|
||||||
|
|
||||||
$(OBJDIR)\optimize.obj: optimize.c pcap-int.h pcap.h pcap-bpf.h gencode.h
|
|
||||||
|
|
||||||
$(OBJDIR)\savefile.obj: savefile.c pcap-int.h pcap.h pcap-bpf.h
|
|
||||||
|
|
||||||
$(OBJDIR)\pcap.obj: pcap.c pcap-dos.h pcap-int.h pcap.h pcap-bpf.h
|
|
||||||
|
|
||||||
$(OBJDIR)\inet.obj: inet.c pcap-int.h pcap.h pcap-bpf.h
|
|
||||||
|
|
||||||
$(OBJDIR)\grammar.obj: grammar.c pcap-int.h pcap.h pcap-bpf.h gencode.h &
|
|
||||||
pf.h pcap-nam.h
|
|
||||||
|
|
||||||
$(OBJDIR)\scanner.obj: scanner.c pcap-int.h pcap.h pcap-bpf.h gencode.h &
|
|
||||||
pcap-nam.h tokdefs.h
|
|
||||||
|
|
||||||
$(OBJDIR)\gencode.obj: gencode.c pcap-dos.h pcap-int.h pcap.h pcap-bpf.h &
|
|
||||||
ethertyp.h nlpid.h llc.h gencode.h atmuni31.h sunatmpo.h ppp.h sll.h &
|
|
||||||
arcnet.h pf.h pcap-nam.h
|
|
||||||
|
|
||||||
$(OBJDIR)\nametoad.obj: nametoad.c pcap-int.h pcap.h pcap-bpf.h gencode.h &
|
|
||||||
pcap-nam.h ethertyp.h
|
|
||||||
|
|
||||||
$(OBJDIR)\pcap-dos.obj: pcap-dos.c pcap.h pcap-bpf.h pcap-dos.h pcap-int.h &
|
|
||||||
msdos\pktdrvr.h
|
|
||||||
|
|
||||||
$(OBJDIR)\pktdrvr.obj: msdos\pktdrvr.c gnuc.h pcap-dos.h pcap-int.h &
|
|
||||||
pcap.h pcap-bpf.h msdos\pktdrvr.h msdos\pkt_stub.inc
|
|
||||||
|
|
||||||
$(OBJDIR)\ndis2.obj: msdos\ndis2.c pcap-dos.h pcap-int.h pcap.h pcap-bpf.h &
|
|
||||||
msdos\ndis2.h
|
|
||||||
|
|
||||||
@@ -1,860 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1993,1994
|
|
||||||
* Texas A&M University. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by Texas A&M University
|
|
||||||
* and its contributors.
|
|
||||||
* 4. Neither the name of the University nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* Developers:
|
|
||||||
* David K. Hess, Douglas Lee Schales, David R. Safford
|
|
||||||
*
|
|
||||||
* Heavily modified for Metaware HighC + GNU C 2.8+
|
|
||||||
* Gisle Vanem 1998
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <dos.h>
|
|
||||||
#include <io.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "pcap-dos.h"
|
|
||||||
#include "pcap-int.h"
|
|
||||||
#include "msdos/ndis2.h"
|
|
||||||
|
|
||||||
#if defined(USE_NDIS2)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Packet buffer handling
|
|
||||||
*/
|
|
||||||
extern int FreePktBuf (PktBuf *buf);
|
|
||||||
extern int EnquePktBuf (PktBuf *buf);
|
|
||||||
extern PktBuf* AllocPktBuf (void);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Various defines
|
|
||||||
*/
|
|
||||||
#define MAX_NUM_DEBUG_STRINGS 90
|
|
||||||
#define DEBUG_STRING_LENGTH 80
|
|
||||||
#define STACK_POOL_SIZE 6
|
|
||||||
#define STACK_SIZE 256
|
|
||||||
|
|
||||||
#define MEDIA_FDDI 1
|
|
||||||
#define MEDIA_ETHERNET 2
|
|
||||||
#define MEDIA_TOKEN 3
|
|
||||||
|
|
||||||
static int startDebug = 0;
|
|
||||||
static int stopDebug = 0;
|
|
||||||
|
|
||||||
static DWORD droppedPackets = 0L;
|
|
||||||
static WORD frameSize = 0;
|
|
||||||
static WORD headerSize = 0;
|
|
||||||
static int mediaType = 0;
|
|
||||||
static char *lastErr = NULL;
|
|
||||||
|
|
||||||
static BYTE debugStrings [MAX_NUM_DEBUG_STRINGS][DEBUG_STRING_LENGTH];
|
|
||||||
static BYTE *freeStacks [STACK_POOL_SIZE];
|
|
||||||
static int freeStackPtr = STACK_POOL_SIZE - 1;
|
|
||||||
|
|
||||||
static ProtMan protManEntry = NULL;
|
|
||||||
static WORD protManDS = 0;
|
|
||||||
static volatile int xmitPending;
|
|
||||||
|
|
||||||
static struct _PktBuf *txBufPending;
|
|
||||||
static struct _CardHandle *handle;
|
|
||||||
static struct _CommonChars common;
|
|
||||||
static struct _ProtocolChars protChars;
|
|
||||||
static struct _ProtDispatch lowerTable;
|
|
||||||
|
|
||||||
static struct _FailingModules failingModules;
|
|
||||||
static struct _BindingsList bindings;
|
|
||||||
|
|
||||||
static struct {
|
|
||||||
WORD err_num;
|
|
||||||
char *err_text;
|
|
||||||
} ndis_errlist[] = {
|
|
||||||
|
|
||||||
{ ERR_SUCCESS,
|
|
||||||
"The function completed successfully.\n" },
|
|
||||||
|
|
||||||
{ ERR_WAIT_FOR_RELEASE,
|
|
||||||
"The ReceiveChain completed successfully but the protocol has\n"
|
|
||||||
"retained control of the buffer.\n" },
|
|
||||||
|
|
||||||
{ ERR_REQUEST_QUEUED,
|
|
||||||
"The current request has been queued.\n" },
|
|
||||||
|
|
||||||
{ ERR_FRAME_NOT_RECOGNIZED,
|
|
||||||
"Frame not recognized.\n" },
|
|
||||||
|
|
||||||
{ ERR_FRAME_REJECTED,
|
|
||||||
"Frame was discarded.\n" },
|
|
||||||
|
|
||||||
{ ERR_FORWARD_FRAME,
|
|
||||||
"Protocol wishes to forward frame to another protocol.\n" },
|
|
||||||
|
|
||||||
{ ERR_OUT_OF_RESOURCE,
|
|
||||||
"Out of resource.\n" },
|
|
||||||
|
|
||||||
{ ERR_INVALID_PARAMETER,
|
|
||||||
"Invalid parameter.\n" },
|
|
||||||
|
|
||||||
{ ERR_INVALID_FUNCTION,
|
|
||||||
"Invalid function.\n" },
|
|
||||||
|
|
||||||
{ ERR_NOT_SUPPORTED,
|
|
||||||
"Not supported.\n" },
|
|
||||||
|
|
||||||
{ ERR_HARDWARE_ERROR,
|
|
||||||
"Hardware error.\n" },
|
|
||||||
|
|
||||||
{ ERR_TRANSMIT_ERROR,
|
|
||||||
"The packet was not transmitted due to an error.\n" },
|
|
||||||
|
|
||||||
{ ERR_NO_SUCH_DESTINATION,
|
|
||||||
"Token ring packet was not recognized when transmitted.\n" },
|
|
||||||
|
|
||||||
{ ERR_BUFFER_TOO_SMALL,
|
|
||||||
"Provided buffer was too small.\n" },
|
|
||||||
|
|
||||||
{ ERR_ALREADY_STARTED,
|
|
||||||
"Network drivers already started.\n" },
|
|
||||||
|
|
||||||
{ ERR_INCOMPLETE_BINDING,
|
|
||||||
"Protocol driver could not complete its bindings.\n" },
|
|
||||||
|
|
||||||
{ ERR_DRIVER_NOT_INITIALIZED,
|
|
||||||
"MAC did not initialize properly.\n" },
|
|
||||||
|
|
||||||
{ ERR_HARDWARE_NOT_FOUND,
|
|
||||||
"Hardware not found.\n" },
|
|
||||||
|
|
||||||
{ ERR_HARDWARE_FAILURE,
|
|
||||||
"Hardware failure.\n" },
|
|
||||||
|
|
||||||
{ ERR_CONFIGURATION_FAILURE,
|
|
||||||
"Configuration failure.\n" },
|
|
||||||
|
|
||||||
{ ERR_INTERRUPT_CONFLICT,
|
|
||||||
"Interrupt conflict.\n" },
|
|
||||||
|
|
||||||
{ ERR_INCOMPATIBLE_MAC,
|
|
||||||
"The MAC is not compatible with the protocol.\n" },
|
|
||||||
|
|
||||||
{ ERR_INITIALIZATION_FAILED,
|
|
||||||
"Initialization failed.\n" },
|
|
||||||
|
|
||||||
{ ERR_NO_BINDING,
|
|
||||||
"Binding did not occur.\n" },
|
|
||||||
|
|
||||||
{ ERR_NETWORK_MAY_NOT_BE_CONNECTED,
|
|
||||||
"The network may not be connected to the adapter.\n" },
|
|
||||||
|
|
||||||
{ ERR_INCOMPATIBLE_OS_VERSION,
|
|
||||||
"The version of the operating system is incompatible with the protocol.\n" },
|
|
||||||
|
|
||||||
{ ERR_ALREADY_REGISTERED,
|
|
||||||
"The protocol is already registered.\n" },
|
|
||||||
|
|
||||||
{ ERR_PATH_NOT_FOUND,
|
|
||||||
"PROTMAN.EXE could not be found.\n" },
|
|
||||||
|
|
||||||
{ ERR_INSUFFICIENT_MEMORY,
|
|
||||||
"Insufficient memory.\n" },
|
|
||||||
|
|
||||||
{ ERR_INFO_NOT_FOUND,
|
|
||||||
"Protocol Mananger info structure is lost or corrupted.\n" },
|
|
||||||
|
|
||||||
{ ERR_GENERAL_FAILURE,
|
|
||||||
"General failure.\n" }
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Some handy macros
|
|
||||||
*/
|
|
||||||
#define PERROR(str) printf("%s (%d): %s\n", __FILE__,__LINE__,str)
|
|
||||||
#define DEBUG_RING() (debugStrings[stopDebug+1 == MAX_NUM_DEBUG_STRINGS ? \
|
|
||||||
stopDebug = 0 : ++stopDebug])
|
|
||||||
|
|
||||||
/*
|
|
||||||
* needs rewrite for DOSX
|
|
||||||
*/
|
|
||||||
#define MAC_DISPATCH(hnd) ((struct _MacUpperDispatch*)(hnd)->common->upperDispatchTable)
|
|
||||||
#define MAC_STATUS(hnd) ((struct _MacStatusTable*) (hnd)->common->serviceStatus)
|
|
||||||
#define MAC_CHAR(hnd) ((struct _MacChars*) (hnd)->common->serviceChars)
|
|
||||||
|
|
||||||
#ifdef NDIS_DEBUG
|
|
||||||
#define DEBUG0(str) printf (str)
|
|
||||||
#define DEBUG1(fmt,a) printf (fmt,a)
|
|
||||||
#define DEBUG2(fmt,a,b) printf (fmt,a,b)
|
|
||||||
#define TRACE0(str) sprintf (DEBUG_RING(),str)
|
|
||||||
#define TRACE1(fmt,a) sprintf (DEBUG_RING(),fmt,a)
|
|
||||||
#else
|
|
||||||
#define DEBUG0(str) ((void)0)
|
|
||||||
#define DEBUG1(fmt,a) ((void)0)
|
|
||||||
#define DEBUG2(fmt,a,b) ((void)0)
|
|
||||||
#define TRACE0(str) ((void)0)
|
|
||||||
#define TRACE1(fmt,a) ((void)0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This routine is called from both threads
|
|
||||||
*/
|
|
||||||
void NdisFreeStack (BYTE *aStack)
|
|
||||||
{
|
|
||||||
GUARD();
|
|
||||||
|
|
||||||
if (freeStackPtr == STACK_POOL_SIZE - 1)
|
|
||||||
PERROR ("tried to free too many stacks");
|
|
||||||
|
|
||||||
freeStacks[++freeStackPtr] = aStack;
|
|
||||||
|
|
||||||
if (freeStackPtr == 0)
|
|
||||||
TRACE0 ("freeStackPtr went positive\n");
|
|
||||||
|
|
||||||
UNGUARD();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This routine is called from callbacks to allocate local data
|
|
||||||
*/
|
|
||||||
BYTE *NdisAllocStack (void)
|
|
||||||
{
|
|
||||||
BYTE *stack;
|
|
||||||
|
|
||||||
GUARD();
|
|
||||||
|
|
||||||
if (freeStackPtr < 0)
|
|
||||||
{
|
|
||||||
/* Ran out of stack buffers. Return NULL which will start
|
|
||||||
* dropping packets
|
|
||||||
*/
|
|
||||||
TRACE0 ("freeStackPtr went negative\n");
|
|
||||||
stack = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
stack = freeStacks[freeStackPtr--];
|
|
||||||
|
|
||||||
UNGUARD();
|
|
||||||
return (stack);
|
|
||||||
}
|
|
||||||
|
|
||||||
CALLBACK (NdisSystemRequest (DWORD param1, DWORD param2, WORD param3,
|
|
||||||
WORD opcode, WORD targetDS))
|
|
||||||
{
|
|
||||||
static int bindEntry = 0;
|
|
||||||
struct _CommonChars *macCommon;
|
|
||||||
volatile WORD result;
|
|
||||||
|
|
||||||
switch (opcode)
|
|
||||||
{
|
|
||||||
case REQ_INITIATE_BIND:
|
|
||||||
macCommon = (struct _CommonChars*) param2;
|
|
||||||
if (macCommon == NULL)
|
|
||||||
{
|
|
||||||
printf ("There is an NDIS misconfiguration.\n");
|
|
||||||
result = ERR_GENERAL_FAILURE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
DEBUG2 ("module name %s\n"
|
|
||||||
"module type %s\n",
|
|
||||||
macCommon->moduleName,
|
|
||||||
((MacChars*) macCommon->serviceChars)->macName);
|
|
||||||
|
|
||||||
/* Binding to the MAC */
|
|
||||||
result = macCommon->systemRequest ((DWORD)&common, (DWORD)&macCommon,
|
|
||||||
0, REQ_BIND,
|
|
||||||
macCommon->moduleDS);
|
|
||||||
|
|
||||||
if (!strcmp(bindings.moduleName[bindEntry], handle->moduleName))
|
|
||||||
handle->common = macCommon;
|
|
||||||
else PERROR ("unknown module");
|
|
||||||
++bindEntry;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case REQ_INITIATE_UNBIND:
|
|
||||||
macCommon = (struct _CommonChars*) param2;
|
|
||||||
result = macCommon->systemRequest ((DWORD)&common, 0,
|
|
||||||
0, REQ_UNBIND,
|
|
||||||
macCommon->moduleDS);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
result = ERR_GENERAL_FAILURE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ARGSUSED (param1);
|
|
||||||
ARGSUSED (param3);
|
|
||||||
ARGSUSED (targetDS);
|
|
||||||
return (result);
|
|
||||||
}
|
|
||||||
|
|
||||||
CALLBACK (NdisRequestConfirm (WORD protId, WORD macId, WORD reqHandle,
|
|
||||||
WORD status, WORD request, WORD protDS))
|
|
||||||
{
|
|
||||||
ARGSUSED (protId); ARGSUSED (macId);
|
|
||||||
ARGSUSED (reqHandle); ARGSUSED (status);
|
|
||||||
ARGSUSED (request); ARGSUSED (protDS);
|
|
||||||
return (ERR_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
CALLBACK (NdisTransmitConfirm (WORD protId, WORD macId, WORD reqHandle,
|
|
||||||
WORD status, WORD protDS))
|
|
||||||
{
|
|
||||||
xmitPending--;
|
|
||||||
FreePktBuf (txBufPending); /* Add passed ECB back to the free list */
|
|
||||||
|
|
||||||
ARGSUSED (reqHandle);
|
|
||||||
ARGSUSED (status);
|
|
||||||
ARGSUSED (protDS);
|
|
||||||
return (ERR_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The primary function for receiving packets
|
|
||||||
*/
|
|
||||||
CALLBACK (NdisReceiveLookahead (WORD macId, WORD frameSize,
|
|
||||||
WORD bytesAvail, BYTE *buffer,
|
|
||||||
BYTE *indicate, WORD protDS))
|
|
||||||
{
|
|
||||||
int result;
|
|
||||||
PktBuf *pktBuf;
|
|
||||||
WORD bytesCopied;
|
|
||||||
struct _TDBufDescr tDBufDescr;
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
TRACE1 ("lookahead length = %d, ", bytesAvail);
|
|
||||||
TRACE1 ("ecb = %08lX, ", *ecb);
|
|
||||||
TRACE1 ("count = %08lX\n", count);
|
|
||||||
TRACE1 ("offset = %08lX, ", offset);
|
|
||||||
TRACE1 ("timesAllowed = %d, ", timesAllowed);
|
|
||||||
TRACE1 ("packet size = %d\n", look->dataLookAheadLen);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Allocate a buffer for the packet
|
|
||||||
*/
|
|
||||||
if ((pktBuf = AllocPktBuf()) == NULL)
|
|
||||||
{
|
|
||||||
droppedPackets++;
|
|
||||||
return (ERR_FRAME_REJECTED);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Now kludge things. Note we will have to undo this later. This will
|
|
||||||
* make the packet contiguous after the MLID has done the requested copy.
|
|
||||||
*/
|
|
||||||
|
|
||||||
tDBufDescr.tDDataCount = 1;
|
|
||||||
tDBufDescr.tDBufDescrRec[0].tDPtrType = NDIS_PTR_PHYSICAL;
|
|
||||||
tDBufDescr.tDBufDescrRec[0].tDDataPtr = pktBuf->buffer;
|
|
||||||
tDBufDescr.tDBufDescrRec[0].tDDataLen = pktBuf->length;
|
|
||||||
tDBufDescr.tDBufDescrRec[0].dummy = 0;
|
|
||||||
|
|
||||||
result = MAC_DISPATCH(handle)->transferData (&bytesCopied, 0, &tDBufDescr,
|
|
||||||
handle->common->moduleDS);
|
|
||||||
pktBuf->packetLength = bytesCopied;
|
|
||||||
|
|
||||||
if (result == ERR_SUCCESS)
|
|
||||||
EnquePktBuf(pktBuf);
|
|
||||||
else FreePktBuf (pktBuf);
|
|
||||||
|
|
||||||
ARGSUSED (frameSize);
|
|
||||||
ARGSUSED (bytesAvail);
|
|
||||||
ARGSUSED (indicate);
|
|
||||||
ARGSUSED (protDS);
|
|
||||||
|
|
||||||
return (ERR_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
CALLBACK (NdisIndicationComplete (WORD macId, WORD protDS))
|
|
||||||
{
|
|
||||||
ARGSUSED (macId);
|
|
||||||
ARGSUSED (protDS);
|
|
||||||
|
|
||||||
/* We don't give a hoot about these. Just return
|
|
||||||
*/
|
|
||||||
return (ERR_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This is the OTHER way we may receive packets
|
|
||||||
*/
|
|
||||||
CALLBACK (NdisReceiveChain (WORD macId, WORD frameSize, WORD reqHandle,
|
|
||||||
struct _RxBufDescr *rxBufDescr,
|
|
||||||
BYTE *indicate, WORD protDS))
|
|
||||||
{
|
|
||||||
struct _PktBuf *pktBuf;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* For now we copy the entire packet over to a PktBuf structure. This may be
|
|
||||||
* a performance hit but this routine probably isn't called very much, and
|
|
||||||
* it is a lot of work to do it otherwise. Also if it is a filter protocol
|
|
||||||
* packet we could end up sucking up MAC buffes.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ((pktBuf = AllocPktBuf()) == NULL)
|
|
||||||
{
|
|
||||||
droppedPackets++;
|
|
||||||
return (ERR_FRAME_REJECTED);
|
|
||||||
}
|
|
||||||
pktBuf->packetLength = 0;
|
|
||||||
|
|
||||||
/* Copy the packet to the buffer
|
|
||||||
*/
|
|
||||||
for (i = 0; i < rxBufDescr->rxDataCount; ++i)
|
|
||||||
{
|
|
||||||
struct _RxBufDescrRec *rxDescr = &rxBufDescr->rxBufDescrRec[i];
|
|
||||||
|
|
||||||
memcpy (pktBuf->buffer + pktBuf->packetLength,
|
|
||||||
rxDescr->rxDataPtr, rxDescr->rxDataLen);
|
|
||||||
pktBuf->packetLength += rxDescr->rxDataLen;
|
|
||||||
}
|
|
||||||
|
|
||||||
EnquePktBuf (pktBuf);
|
|
||||||
|
|
||||||
ARGSUSED (frameSize);
|
|
||||||
ARGSUSED (reqHandle);
|
|
||||||
ARGSUSED (indicate);
|
|
||||||
ARGSUSED (protDS);
|
|
||||||
|
|
||||||
/* This frees up the buffer for the MAC to use
|
|
||||||
*/
|
|
||||||
return (ERR_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
CALLBACK (NdisStatusProc (WORD macId, WORD param1, BYTE *indicate,
|
|
||||||
WORD opcode, WORD protDS))
|
|
||||||
{
|
|
||||||
switch (opcode)
|
|
||||||
{
|
|
||||||
case STATUS_RING_STATUS:
|
|
||||||
break;
|
|
||||||
case STATUS_ADAPTER_CHECK:
|
|
||||||
break;
|
|
||||||
case STATUS_START_RESET:
|
|
||||||
break;
|
|
||||||
case STATUS_INTERRUPT:
|
|
||||||
break;
|
|
||||||
case STATUS_END_RESET:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ARGSUSED (macId);
|
|
||||||
ARGSUSED (param1);
|
|
||||||
ARGSUSED (indicate);
|
|
||||||
ARGSUSED (opcode);
|
|
||||||
ARGSUSED (protDS);
|
|
||||||
|
|
||||||
/* We don't need to do anything about this stuff yet
|
|
||||||
*/
|
|
||||||
return (ERR_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Tell the NDIS driver to start the delivery of the packet
|
|
||||||
*/
|
|
||||||
int NdisSendPacket (struct _PktBuf *pktBuf, int macId)
|
|
||||||
{
|
|
||||||
struct _TxBufDescr txBufDescr;
|
|
||||||
int result;
|
|
||||||
|
|
||||||
xmitPending++;
|
|
||||||
txBufPending = pktBuf; /* we only have 1 pending Tx at a time */
|
|
||||||
|
|
||||||
txBufDescr.txImmedLen = 0;
|
|
||||||
txBufDescr.txImmedPtr = NULL;
|
|
||||||
txBufDescr.txDataCount = 1;
|
|
||||||
txBufDescr.txBufDescrRec[0].txPtrType = NDIS_PTR_PHYSICAL;
|
|
||||||
txBufDescr.txBufDescrRec[0].dummy = 0;
|
|
||||||
txBufDescr.txBufDescrRec[0].txDataLen = pktBuf->packetLength;
|
|
||||||
txBufDescr.txBufDescrRec[0].txDataPtr = pktBuf->buffer;
|
|
||||||
|
|
||||||
result = MAC_DISPATCH(handle)->transmitChain (common.moduleId,
|
|
||||||
pktBuf->handle,
|
|
||||||
&txBufDescr,
|
|
||||||
handle->common->moduleDS);
|
|
||||||
switch (result)
|
|
||||||
{
|
|
||||||
case ERR_OUT_OF_RESOURCE:
|
|
||||||
/* Note that this should not happen but if it does there is not
|
|
||||||
* much we can do about it
|
|
||||||
*/
|
|
||||||
printf ("ERROR: transmit queue overflowed\n");
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
case ERR_SUCCESS:
|
|
||||||
/* Everything was hunky dory and synchronous. Free up the
|
|
||||||
* packet buffer
|
|
||||||
*/
|
|
||||||
xmitPending--;
|
|
||||||
FreePktBuf (pktBuf);
|
|
||||||
return (1);
|
|
||||||
|
|
||||||
case ERR_REQUEST_QUEUED:
|
|
||||||
/* Everything was hunky dory and asynchronous. Do nothing
|
|
||||||
*/
|
|
||||||
return (1);
|
|
||||||
|
|
||||||
default:
|
|
||||||
printf ("Tx fail, code = %04X\n", result);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int ndis_nerr = sizeof(ndis_errlist) / sizeof(ndis_errlist[0]);
|
|
||||||
|
|
||||||
static char *Ndis_strerror (WORD errorCode)
|
|
||||||
{
|
|
||||||
static char buf[30];
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < ndis_nerr; i++)
|
|
||||||
if (errorCode == ndis_errlist[i].err_num)
|
|
||||||
return (ndis_errlist[i].err_text);
|
|
||||||
|
|
||||||
sprintf (buf,"unknown error %d",errorCode);
|
|
||||||
return (buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
char *NdisLastError (void)
|
|
||||||
{
|
|
||||||
char *errStr = lastErr;
|
|
||||||
lastErr = NULL;
|
|
||||||
return (errStr);
|
|
||||||
}
|
|
||||||
|
|
||||||
int NdisOpen (void)
|
|
||||||
{
|
|
||||||
struct _ReqBlock reqBlock;
|
|
||||||
int result;
|
|
||||||
int ndisFd = open (NDIS_PATH, O_RDONLY);
|
|
||||||
|
|
||||||
if (ndisFd < 0)
|
|
||||||
{
|
|
||||||
printf ("Could not open NDIS Protocol Manager device.\n");
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
memset (&reqBlock, 0, sizeof(ReqBlock));
|
|
||||||
|
|
||||||
reqBlock.opcode = PM_GET_PROTOCOL_MANAGER_LINKAGE;
|
|
||||||
|
|
||||||
result = NdisGetLinkage (ndisFd, (char*)&reqBlock, sizeof(ReqBlock));
|
|
||||||
if (result != 0)
|
|
||||||
{
|
|
||||||
printf ("Could not get Protocol Manager linkage.\n");
|
|
||||||
close (ndisFd);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
close (ndisFd);
|
|
||||||
protManEntry = (ProtMan) reqBlock.pointer1;
|
|
||||||
protManDS = reqBlock.word1;
|
|
||||||
|
|
||||||
DEBUG2 ("Entry Point = %04X:%04X\n", FP_SEG(protManEntry),FP_OFF(protManEntry));
|
|
||||||
DEBUG1 ("ProtMan DS = %04X\n", protManDS);
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int NdisRegisterAndBind (int promis)
|
|
||||||
{
|
|
||||||
struct _ReqBlock reqBlock;
|
|
||||||
WORD result;
|
|
||||||
|
|
||||||
memset (&common,0,sizeof(common));
|
|
||||||
|
|
||||||
common.tableSize = sizeof (common);
|
|
||||||
|
|
||||||
common.majorNdisVersion = 2;
|
|
||||||
common.minorNdisVersion = 0;
|
|
||||||
common.majorModuleVersion = 2;
|
|
||||||
common.minorModuleVersion = 0;
|
|
||||||
|
|
||||||
/* Indicates binding from below and dynamically loaded
|
|
||||||
*/
|
|
||||||
common.moduleFlags = 0x00000006L;
|
|
||||||
|
|
||||||
strcpy (common.moduleName, "PCAP");
|
|
||||||
|
|
||||||
common.protocolLevelUpper = 0xFF;
|
|
||||||
common.protocolLevelLower = 1;
|
|
||||||
common.interfaceLower = 1;
|
|
||||||
#ifdef __DJGPP__
|
|
||||||
common.moduleDS = _dos_ds; /* the callback data segment */
|
|
||||||
#else
|
|
||||||
common.moduleDS = _DS;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
common.systemRequest = (SystemRequest) systemRequestGlue;
|
|
||||||
common.serviceChars = (BYTE*) &protChars;
|
|
||||||
common.serviceStatus = NULL;
|
|
||||||
common.upperDispatchTable = NULL;
|
|
||||||
common.lowerDispatchTable = (BYTE*) &lowerTable;
|
|
||||||
|
|
||||||
protChars.length = sizeof (protChars);
|
|
||||||
protChars.name[0] = 0;
|
|
||||||
protChars.type = 0;
|
|
||||||
|
|
||||||
lowerTable.backPointer = &common;
|
|
||||||
lowerTable.requestConfirm = requestConfirmGlue;
|
|
||||||
lowerTable.transmitConfirm = transmitConfirmGlue;
|
|
||||||
lowerTable.receiveLookahead = receiveLookaheadGlue;
|
|
||||||
lowerTable.indicationComplete = indicationCompleteGlue;
|
|
||||||
lowerTable.receiveChain = receiveChainGlue;
|
|
||||||
lowerTable.status = statusGlue;
|
|
||||||
lowerTable.flags = 3;
|
|
||||||
if (promis)
|
|
||||||
lowerTable.flags |= 4; /* promiscous mode (receive everything) */
|
|
||||||
|
|
||||||
bindings.numBindings = 1;
|
|
||||||
strcpy (bindings.moduleName[0], handle->moduleName);
|
|
||||||
|
|
||||||
/* Register ourselves with NDIS
|
|
||||||
*/
|
|
||||||
reqBlock.opcode = PM_REGISTER_MODULE;
|
|
||||||
reqBlock.pointer1 = (BYTE FAR*) &common;
|
|
||||||
reqBlock.pointer2 = (BYTE FAR*) &bindings;
|
|
||||||
|
|
||||||
result = (*protManEntry) (&reqBlock, protManDS);
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
printf ("Protman registering failed: %s\n", Ndis_strerror(result));
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Start the binding process
|
|
||||||
*/
|
|
||||||
reqBlock.opcode = PM_BIND_AND_START;
|
|
||||||
reqBlock.pointer1 = (BYTE FAR*) &failingModules;
|
|
||||||
|
|
||||||
result = (*protManEntry) (&reqBlock, protManDS);
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
printf ("Start binding failed: %s\n", Ndis_strerror(result));
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int CheckMacFeatures (CardHandle *card)
|
|
||||||
{
|
|
||||||
DWORD serviceFlags;
|
|
||||||
BYTE _far *mediaString;
|
|
||||||
BYTE _far *mac_addr;
|
|
||||||
|
|
||||||
DEBUG2 ("checking card features\n"
|
|
||||||
"common table address = %08lX, macId = %d\n",
|
|
||||||
card->common, card->common->moduleId);
|
|
||||||
|
|
||||||
serviceFlags = MAC_CHAR (handle)->serviceFlags;
|
|
||||||
|
|
||||||
if ((serviceFlags & SF_PROMISCUOUS) == 0)
|
|
||||||
{
|
|
||||||
printf ("The MAC %s does not support promiscuous mode.\n",
|
|
||||||
card->moduleName);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
mediaString = MAC_CHAR (handle)->macName;
|
|
||||||
|
|
||||||
DEBUG1 ("media type = %s\n",mediaString);
|
|
||||||
|
|
||||||
/* Get the media type. And set the header size
|
|
||||||
*/
|
|
||||||
if (!strncmp(mediaString,"802.3",5) ||
|
|
||||||
!strncmp(mediaString,"DIX",3) ||
|
|
||||||
!strncmp(mediaString,"DIX+802.3",9))
|
|
||||||
headerSize = sizeof (EthernetIIHeader);
|
|
||||||
|
|
||||||
else if (!strncmp(mediaString,"FDDI",4))
|
|
||||||
headerSize = sizeof (FddiHeader) +
|
|
||||||
sizeof (Ieee802Dot2SnapHeader);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf ("Unsupported MAC type: `%s'\n", mediaString);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
frameSize = MAC_CHAR (handle)->maxFrameSize;
|
|
||||||
mac_addr = MAC_CHAR (handle)->currentAddress;
|
|
||||||
|
|
||||||
printf ("Hardware address: %02X:%02X:%02X:%02X:%02X:%02X\n",
|
|
||||||
mac_addr[0], mac_addr[1], mac_addr[2],
|
|
||||||
mac_addr[3], mac_addr[4], mac_addr[5]);
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int NdisStartMac (CardHandle *card)
|
|
||||||
{
|
|
||||||
WORD result;
|
|
||||||
|
|
||||||
/* Set the lookahead length
|
|
||||||
*/
|
|
||||||
result = MAC_DISPATCH(handle)->request (common.moduleId, 0,
|
|
||||||
headerSize, 0,
|
|
||||||
REQ_SET_LOOKAHEAD,
|
|
||||||
card->common->moduleDS);
|
|
||||||
|
|
||||||
/* We assume that if we got INVALID PARAMETER then either this
|
|
||||||
* is not supported or will work anyway. NE2000 does this.
|
|
||||||
*/
|
|
||||||
if (result != ERR_SUCCESS && result != ERR_INVALID_PARAMETER)
|
|
||||||
{
|
|
||||||
DEBUG1 ("Set lookahead failed: %s\n", Ndis_strerror(result));
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set the packet filter. Note that for some medias and drivers we
|
|
||||||
* must specify all three flags or the card(s) will not operate correctly.
|
|
||||||
*/
|
|
||||||
result = MAC_DISPATCH(handle)->request (common.moduleId, 0,
|
|
||||||
/* all packets */ FILTER_PROMISCUOUS |
|
|
||||||
/* packets to us */ FILTER_DIRECTED |
|
|
||||||
/* broadcasts */ FILTER_BROADCAST,
|
|
||||||
0, REQ_SET_PACKET_FILTER,
|
|
||||||
card->common->moduleDS);
|
|
||||||
if (result != ERR_SUCCESS)
|
|
||||||
{
|
|
||||||
DEBUG1 ("Set packet filter failed: %s\n", Ndis_strerror(result));
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If OPEN/CLOSE supported then open the adapter
|
|
||||||
*/
|
|
||||||
if (MAC_CHAR(handle)->serviceFlags & SF_OPEN_CLOSE)
|
|
||||||
{
|
|
||||||
result = MAC_DISPATCH(handle)->request (common.moduleId, 0, 0, NULL,
|
|
||||||
REQ_OPEN_ADAPTER,
|
|
||||||
card->common->moduleDS);
|
|
||||||
if (result != ERR_SUCCESS)
|
|
||||||
{
|
|
||||||
DEBUG1 ("Opening the MAC failed: %s\n", Ndis_strerror(result));
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void NdisShutdown (void)
|
|
||||||
{
|
|
||||||
struct _ReqBlock reqBlock;
|
|
||||||
int result, i;
|
|
||||||
|
|
||||||
if (!handle)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* If the adapters support open and are open then close them
|
|
||||||
*/
|
|
||||||
if ((MAC_CHAR(handle)->serviceFlags & SF_OPEN_CLOSE) &&
|
|
||||||
(MAC_STATUS(handle)->macStatus & MAC_OPEN))
|
|
||||||
{
|
|
||||||
result = MAC_DISPATCH(handle)->request (common.moduleId, 0, 0, 0,
|
|
||||||
REQ_CLOSE_ADAPTER,
|
|
||||||
handle->common->moduleDS);
|
|
||||||
if (result != ERR_SUCCESS)
|
|
||||||
{
|
|
||||||
printf ("Closing the MAC failed: %s\n", Ndis_strerror(result));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Tell the Protocol Manager to unbind and stop
|
|
||||||
*/
|
|
||||||
reqBlock.opcode = PM_UNBIND_AND_STOP;
|
|
||||||
reqBlock.pointer1 = (BYTE FAR*) &failingModules;
|
|
||||||
reqBlock.pointer2 = NULL;
|
|
||||||
|
|
||||||
result = (*protManEntry) (&reqBlock, protManDS);
|
|
||||||
if (result)
|
|
||||||
printf ("Unbind failed: %s\n", Ndis_strerror(result));
|
|
||||||
|
|
||||||
for (i = 0; i < STACK_POOL_SIZE; ++i)
|
|
||||||
free (freeStacks[i] - STACK_SIZE);
|
|
||||||
|
|
||||||
handle = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int NdisInit (int promis)
|
|
||||||
{
|
|
||||||
int i, result;
|
|
||||||
|
|
||||||
/* Allocate the real mode stacks used for NDIS callbacks
|
|
||||||
*/
|
|
||||||
for (i = 0; i < STACK_POOL_SIZE; ++i)
|
|
||||||
{
|
|
||||||
freeStacks[i] = malloc (STACK_SIZE);
|
|
||||||
if (!freeStacks[i])
|
|
||||||
return (0);
|
|
||||||
freeStacks[i] += STACK_SIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!NdisOpen())
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
if (!NdisRegisterAndBind(promis))
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
DEBUG1 ("My module id: %d\n", common.moduleId);
|
|
||||||
DEBUG1 ("Handle id; %d\n", handle->common->moduleId);
|
|
||||||
DEBUG1 ("MAC card: %-16s - ", handle->moduleName);
|
|
||||||
|
|
||||||
atexit (NdisShutdown);
|
|
||||||
|
|
||||||
if (!CheckMacFeatures(&handle))
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
switch (mediaType)
|
|
||||||
{
|
|
||||||
case MEDIA_FDDI:
|
|
||||||
DEBUG0 ("Media type: FDDI");
|
|
||||||
break;
|
|
||||||
case MEDIA_ETHERNET:
|
|
||||||
DEBUG0 ("Media type: ETHERNET");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
DEBUG0 ("Unsupported media.\n");
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
DEBUG1 (" - Frame size: %d\n", frameSize);
|
|
||||||
|
|
||||||
if (!NdisStartMac(&handle))
|
|
||||||
return (0);
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
#endif /* USE_NDIS2 */
|
|
||||||
|
|
||||||
@@ -1,559 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1993,1994
|
|
||||||
* Texas A&M University. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by Texas A&M University
|
|
||||||
* and its contributors.
|
|
||||||
* 4. Neither the name of the University nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* Developers:
|
|
||||||
* David K. Hess, Douglas Lee Schales, David R. Safford
|
|
||||||
*
|
|
||||||
* Heavily modified for Metaware HighC + GNU C 2.8+
|
|
||||||
* Gisle Vanem 1998
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __PCAP_NDIS_H
|
|
||||||
#define __PCAP_NDIS_H
|
|
||||||
|
|
||||||
#if defined (__HIGHC__)
|
|
||||||
#define pascal _CC(_CALLEE_POPS_STACK & ~_REVERSE_PARMS) /* calling convention */
|
|
||||||
#define CALLBACK(foo) pascal WORD foo
|
|
||||||
#define PAS_PTR(x,arg) typedef FAR WORD pascal (*x) arg
|
|
||||||
#define GUARD() _inline (0x9C,0xFA) /* pushfd, cli */
|
|
||||||
#define UNGUARD() _inline (0x9D) /* popfd */
|
|
||||||
#define FAR _far
|
|
||||||
|
|
||||||
#elif defined(__GNUC__)
|
|
||||||
#define CALLBACK(foo) WORD foo __attribute__((stdcall))
|
|
||||||
#define PAS_PTR(x,arg) typedef WORD (*x) arg __attribute__((stdcall))
|
|
||||||
#define GUARD() __asm__ __volatile__ ("pushfd; cli")
|
|
||||||
#define UNGUARD() __asm__ __volatile__ ("popfd")
|
|
||||||
#define FAR
|
|
||||||
|
|
||||||
#elif defined (__TURBOC__)
|
|
||||||
#define CALLBACK(foo) WORD pascal foo
|
|
||||||
#define PAS_PTR(x,arg) typedef WORD pascal (_far *x) arg
|
|
||||||
#define GUARD() _asm { pushf; cli }
|
|
||||||
#define UNGUARD() _asm { popf }
|
|
||||||
#define FAR _far
|
|
||||||
|
|
||||||
#elif defined (__WATCOMC__)
|
|
||||||
#define CALLBACK(foo) WORD pascal foo
|
|
||||||
#define PAS_PTR(x,arg) typedef WORD pascal (_far *x) arg
|
|
||||||
#define GUARD() _disable()
|
|
||||||
#define UNGUARD() _enable()
|
|
||||||
#define FAR _far
|
|
||||||
|
|
||||||
#else
|
|
||||||
#error Unsupported compiler
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Forwards
|
|
||||||
*/
|
|
||||||
struct _ReqBlock;
|
|
||||||
struct _TxBufDescr;
|
|
||||||
struct _TDBufDescr;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Protocol Manager API
|
|
||||||
*/
|
|
||||||
PAS_PTR (ProtMan, (struct _ReqBlock FAR*, WORD));
|
|
||||||
|
|
||||||
/*
|
|
||||||
* System request
|
|
||||||
*/
|
|
||||||
PAS_PTR (SystemRequest, (DWORD, DWORD, WORD, WORD, WORD));
|
|
||||||
|
|
||||||
/*
|
|
||||||
* MAC API
|
|
||||||
*/
|
|
||||||
PAS_PTR (TransmitChain, (WORD, WORD, struct _TxBufDescr FAR*, WORD));
|
|
||||||
PAS_PTR (TransferData, (WORD*,WORD, struct _TDBufDescr FAR*, WORD));
|
|
||||||
PAS_PTR (Request, (WORD, WORD, WORD, DWORD, WORD, WORD));
|
|
||||||
PAS_PTR (ReceiveRelease,(WORD, WORD));
|
|
||||||
PAS_PTR (IndicationOn, (WORD));
|
|
||||||
PAS_PTR (IndicationOff, (WORD));
|
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
HARDWARE_NOT_INSTALLED = 0,
|
|
||||||
HARDWARE_FAILED_DIAG = 1,
|
|
||||||
HARDWARE_FAILED_CONFIG = 2,
|
|
||||||
HARDWARE_HARD_FAULT = 3,
|
|
||||||
HARDWARE_SOFT_FAULT = 4,
|
|
||||||
HARDWARE_OK = 7,
|
|
||||||
HARDWARE_MASK = 0x0007,
|
|
||||||
MAC_BOUND = 0x0008,
|
|
||||||
MAC_OPEN = 0x0010,
|
|
||||||
DIAG_IN_PROGRESS = 0x0020
|
|
||||||
} NdisMacStatus;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
STATUS_RING_STATUS = 1,
|
|
||||||
STATUS_ADAPTER_CHECK = 2,
|
|
||||||
STATUS_START_RESET = 3,
|
|
||||||
STATUS_INTERRUPT = 4,
|
|
||||||
STATUS_END_RESET = 5
|
|
||||||
} NdisStatus;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
FILTER_DIRECTED = 1,
|
|
||||||
FILTER_BROADCAST = 2,
|
|
||||||
FILTER_PROMISCUOUS = 4,
|
|
||||||
FILTER_SOURCE_ROUTE = 8
|
|
||||||
} NdisPacketFilter;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
REQ_INITIATE_DIAGNOSTICS = 1,
|
|
||||||
REQ_READ_ERROR_LOG = 2,
|
|
||||||
REQ_SET_STATION_ADDRESS = 3,
|
|
||||||
REQ_OPEN_ADAPTER = 4,
|
|
||||||
REQ_CLOSE_ADAPTER = 5,
|
|
||||||
REQ_RESET_MAC = 6,
|
|
||||||
REQ_SET_PACKET_FILTER = 7,
|
|
||||||
REQ_ADD_MULTICAST_ADDRESS = 8,
|
|
||||||
REQ_DELETE_MULTICAST_ADDRESS = 9,
|
|
||||||
REQ_UPDATE_STATISTICS = 10,
|
|
||||||
REQ_CLEAR_STATISTICS = 11,
|
|
||||||
REQ_INTERRUPT_REQUEST = 12,
|
|
||||||
REQ_SET_FUNCTIONAL_ADDRESS = 13,
|
|
||||||
REQ_SET_LOOKAHEAD = 14
|
|
||||||
} NdisGeneralRequest;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
SF_BROADCAST = 0x00000001L,
|
|
||||||
SF_MULTICAST = 0x00000002L,
|
|
||||||
SF_FUNCTIONAL = 0x00000004L,
|
|
||||||
SF_PROMISCUOUS = 0x00000008L,
|
|
||||||
SF_SOFT_ADDRESS = 0x00000010L,
|
|
||||||
SF_STATS_CURRENT = 0x00000020L,
|
|
||||||
SF_INITIATE_DIAGS = 0x00000040L,
|
|
||||||
SF_LOOPBACK = 0x00000080L,
|
|
||||||
SF_RECEIVE_CHAIN = 0x00000100L,
|
|
||||||
SF_SOURCE_ROUTING = 0x00000200L,
|
|
||||||
SF_RESET_MAC = 0x00000400L,
|
|
||||||
SF_OPEN_CLOSE = 0x00000800L,
|
|
||||||
SF_INTERRUPT_REQUEST = 0x00001000L,
|
|
||||||
SF_SOURCE_ROUTING_BRIDGE = 0x00002000L,
|
|
||||||
SF_VIRTUAL_ADDRESSES = 0x00004000L
|
|
||||||
} NdisMacServiceFlags;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
REQ_INITIATE_BIND = 1,
|
|
||||||
REQ_BIND = 2,
|
|
||||||
REQ_INITIATE_PREBIND = 3,
|
|
||||||
REQ_INITIATE_UNBIND = 4,
|
|
||||||
REQ_UNBIND = 5
|
|
||||||
} NdisSysRequest;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
PM_GET_PROTOCOL_MANAGER_INFO = 1,
|
|
||||||
PM_REGISTER_MODULE = 2,
|
|
||||||
PM_BIND_AND_START = 3,
|
|
||||||
PM_GET_PROTOCOL_MANAGER_LINKAGE = 4,
|
|
||||||
PM_GET_PROTOCOL_INI_PATH = 5,
|
|
||||||
PM_REGISTER_PROTOCOL_MANAGER_INFO = 6,
|
|
||||||
PM_INIT_AND_REGISTER = 7,
|
|
||||||
PM_UNBIND_AND_STOP = 8,
|
|
||||||
PM_BIND_STATUS = 9,
|
|
||||||
PM_REGISTER_STATUS = 10
|
|
||||||
} NdisProtManager;
|
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
ERR_SUCCESS = 0x00,
|
|
||||||
ERR_WAIT_FOR_RELEASE = 0x01,
|
|
||||||
ERR_REQUEST_QUEUED = 0x02,
|
|
||||||
ERR_FRAME_NOT_RECOGNIZED = 0x03,
|
|
||||||
ERR_FRAME_REJECTED = 0x04,
|
|
||||||
ERR_FORWARD_FRAME = 0x05,
|
|
||||||
ERR_OUT_OF_RESOURCE = 0x06,
|
|
||||||
ERR_INVALID_PARAMETER = 0x07,
|
|
||||||
ERR_INVALID_FUNCTION = 0x08,
|
|
||||||
ERR_NOT_SUPPORTED = 0x09,
|
|
||||||
ERR_HARDWARE_ERROR = 0x0A,
|
|
||||||
ERR_TRANSMIT_ERROR = 0x0B,
|
|
||||||
ERR_NO_SUCH_DESTINATION = 0x0C,
|
|
||||||
ERR_BUFFER_TOO_SMALL = 0x0D,
|
|
||||||
ERR_ALREADY_STARTED = 0x20,
|
|
||||||
ERR_INCOMPLETE_BINDING = 0x21,
|
|
||||||
ERR_DRIVER_NOT_INITIALIZED = 0x22,
|
|
||||||
ERR_HARDWARE_NOT_FOUND = 0x23,
|
|
||||||
ERR_HARDWARE_FAILURE = 0x24,
|
|
||||||
ERR_CONFIGURATION_FAILURE = 0x25,
|
|
||||||
ERR_INTERRUPT_CONFLICT = 0x26,
|
|
||||||
ERR_INCOMPATIBLE_MAC = 0x27,
|
|
||||||
ERR_INITIALIZATION_FAILED = 0x28,
|
|
||||||
ERR_NO_BINDING = 0x29,
|
|
||||||
ERR_NETWORK_MAY_NOT_BE_CONNECTED = 0x2A,
|
|
||||||
ERR_INCOMPATIBLE_OS_VERSION = 0x2B,
|
|
||||||
ERR_ALREADY_REGISTERED = 0x2C,
|
|
||||||
ERR_PATH_NOT_FOUND = 0x2D,
|
|
||||||
ERR_INSUFFICIENT_MEMORY = 0x2E,
|
|
||||||
ERR_INFO_NOT_FOUND = 0x2F,
|
|
||||||
ERR_GENERAL_FAILURE = 0xFF
|
|
||||||
} NdisError;
|
|
||||||
|
|
||||||
#define NDIS_PARAM_INTEGER 0
|
|
||||||
#define NDIS_PARAM_STRING 1
|
|
||||||
|
|
||||||
#define NDIS_TX_BUF_LENGTH 8
|
|
||||||
#define NDIS_TD_BUF_LENGTH 1
|
|
||||||
#define NDIS_RX_BUF_LENGTH 8
|
|
||||||
|
|
||||||
#define NDIS_PTR_PHYSICAL 0
|
|
||||||
#define NDIS_PTR_VIRTUAL 2
|
|
||||||
|
|
||||||
#define NDIS_PATH "PROTMAN$"
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _CommonChars {
|
|
||||||
WORD tableSize;
|
|
||||||
BYTE majorNdisVersion; /* 2 - Latest version */
|
|
||||||
BYTE minorNdisVersion; /* 0 */
|
|
||||||
WORD reserved1;
|
|
||||||
BYTE majorModuleVersion;
|
|
||||||
BYTE minorModuleVersion;
|
|
||||||
DWORD moduleFlags;
|
|
||||||
/* 0 - Binding at upper boundary supported
|
|
||||||
* 1 - Binding at lower boundary supported
|
|
||||||
* 2 - Dynamically bound.
|
|
||||||
* 3-31 - Reserved, must be zero.
|
|
||||||
*/
|
|
||||||
BYTE moduleName[16];
|
|
||||||
BYTE protocolLevelUpper;
|
|
||||||
/* 1 - MAC
|
|
||||||
* 2 - Data Link
|
|
||||||
* 3 - Network
|
|
||||||
* 4 - Transport
|
|
||||||
* 5 - Session
|
|
||||||
* -1 - Not specified
|
|
||||||
*/
|
|
||||||
BYTE interfaceUpper;
|
|
||||||
BYTE protocolLevelLower;
|
|
||||||
/* 0 - Physical
|
|
||||||
* 1 - MAC
|
|
||||||
* 2 - Data Link
|
|
||||||
* 3 - Network
|
|
||||||
* 4 - Transport
|
|
||||||
* 5 - Session
|
|
||||||
* -1 - Not specified
|
|
||||||
*/
|
|
||||||
BYTE interfaceLower;
|
|
||||||
WORD moduleId;
|
|
||||||
WORD moduleDS;
|
|
||||||
SystemRequest systemRequest;
|
|
||||||
BYTE *serviceChars;
|
|
||||||
BYTE *serviceStatus;
|
|
||||||
BYTE *upperDispatchTable;
|
|
||||||
BYTE *lowerDispatchTable;
|
|
||||||
BYTE *reserved2; /* Must be NULL */
|
|
||||||
BYTE *reserved3; /* Must be NULL */
|
|
||||||
} CommonChars;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _MulticastList {
|
|
||||||
WORD maxMulticastAddresses;
|
|
||||||
WORD numberMulticastAddresses;
|
|
||||||
BYTE multicastAddress[16][16];
|
|
||||||
} MulticastList;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _MacChars {
|
|
||||||
WORD tableSize;
|
|
||||||
BYTE macName[16];
|
|
||||||
WORD addressLength;
|
|
||||||
BYTE permanentAddress[16];
|
|
||||||
BYTE currentAddress[16];
|
|
||||||
DWORD currentFunctionalAddress;
|
|
||||||
MulticastList *multicastList;
|
|
||||||
DWORD linkSpeed;
|
|
||||||
DWORD serviceFlags;
|
|
||||||
WORD maxFrameSize;
|
|
||||||
DWORD txBufferSize;
|
|
||||||
WORD txBufferAllocSize;
|
|
||||||
DWORD rxBufferSize;
|
|
||||||
WORD rxBufferAllocSize;
|
|
||||||
BYTE ieeeVendor[3];
|
|
||||||
BYTE vendorAdapter;
|
|
||||||
BYTE *vendorAdapterDescription;
|
|
||||||
WORD interruptLevel;
|
|
||||||
WORD txQueueDepth;
|
|
||||||
WORD maxDataBlocks;
|
|
||||||
} MacChars;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _ProtocolChars {
|
|
||||||
WORD length;
|
|
||||||
BYTE name[16];
|
|
||||||
WORD type;
|
|
||||||
} ProtocolChars;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _MacUpperDispatch {
|
|
||||||
CommonChars *backPointer;
|
|
||||||
Request request;
|
|
||||||
TransmitChain transmitChain;
|
|
||||||
TransferData transferData;
|
|
||||||
ReceiveRelease receiveRelease;
|
|
||||||
IndicationOn indicationOn;
|
|
||||||
IndicationOff indicationOff;
|
|
||||||
} MacUpperDispatch;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _MacStatusTable {
|
|
||||||
WORD tableSize;
|
|
||||||
DWORD lastDiag;
|
|
||||||
DWORD macStatus;
|
|
||||||
WORD packetFilter;
|
|
||||||
BYTE *mediaSpecificStats;
|
|
||||||
DWORD lastClear;
|
|
||||||
DWORD totalFramesRx;
|
|
||||||
DWORD totalFramesCrc;
|
|
||||||
DWORD totalBytesRx;
|
|
||||||
DWORD totalDiscardBufSpaceRx;
|
|
||||||
DWORD totalMulticastRx;
|
|
||||||
DWORD totalBroadcastRx;
|
|
||||||
DWORD obsolete1[5];
|
|
||||||
DWORD totalDiscardHwErrorRx;
|
|
||||||
DWORD totalFramesTx;
|
|
||||||
DWORD totalBytesTx;
|
|
||||||
DWORD totalMulticastTx;
|
|
||||||
DWORD totalBroadcastTx;
|
|
||||||
DWORD obsolete2[2];
|
|
||||||
DWORD totalDiscardTimeoutTx;
|
|
||||||
DWORD totalDiscardHwErrorTx;
|
|
||||||
} MacStatusTable;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _ProtDispatch {
|
|
||||||
CommonChars *backPointer;
|
|
||||||
DWORD flags;
|
|
||||||
/* 0 - handles non-LLC frames
|
|
||||||
* 1 - handles specific-LSAP LLC frames
|
|
||||||
* 2 - handles specific-LSAP LLC frames
|
|
||||||
* 3-31 - reserved must be 0
|
|
||||||
*/
|
|
||||||
void (*requestConfirm) (void);
|
|
||||||
void (*transmitConfirm) (void);
|
|
||||||
void (*receiveLookahead) (void);
|
|
||||||
void (*indicationComplete) (void);
|
|
||||||
void (*receiveChain) (void);
|
|
||||||
void (*status) (void);
|
|
||||||
} ProtDispatch;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _ReqBlock {
|
|
||||||
WORD opcode;
|
|
||||||
WORD status;
|
|
||||||
BYTE FAR *pointer1;
|
|
||||||
BYTE FAR *pointer2;
|
|
||||||
WORD word1;
|
|
||||||
} ReqBlock;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _TxBufDescrRec {
|
|
||||||
BYTE txPtrType;
|
|
||||||
BYTE dummy;
|
|
||||||
WORD txDataLen;
|
|
||||||
BYTE *txDataPtr;
|
|
||||||
} TxBufDescrRec;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _TxBufDescr {
|
|
||||||
WORD txImmedLen;
|
|
||||||
BYTE *txImmedPtr;
|
|
||||||
WORD txDataCount;
|
|
||||||
TxBufDescrRec txBufDescrRec[NDIS_TX_BUF_LENGTH];
|
|
||||||
} TxBufDescr;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _TDBufDescrRec {
|
|
||||||
BYTE tDPtrType;
|
|
||||||
BYTE dummy;
|
|
||||||
WORD tDDataLen;
|
|
||||||
BYTE *tDDataPtr;
|
|
||||||
} TDBufDescrRec;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _TDBufDescr {
|
|
||||||
WORD tDDataCount;
|
|
||||||
TDBufDescrRec tDBufDescrRec[NDIS_TD_BUF_LENGTH];
|
|
||||||
} TDBufDescr;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _RxBufDescrRec {
|
|
||||||
WORD rxDataLen;
|
|
||||||
BYTE *rxDataPtr;
|
|
||||||
} RxBufDescrRec;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _RxBufDescr {
|
|
||||||
WORD rxDataCount;
|
|
||||||
RxBufDescrRec rxBufDescrRec[NDIS_RX_BUF_LENGTH];
|
|
||||||
} RxBufDescr;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _PktBuf {
|
|
||||||
struct _PktBuf *nextLink;
|
|
||||||
struct _PktBuf *prevLink;
|
|
||||||
int handle;
|
|
||||||
int length;
|
|
||||||
int packetLength;
|
|
||||||
DWORD sequence;
|
|
||||||
BYTE *buffer;
|
|
||||||
} PktBuf;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _CardHandle {
|
|
||||||
BYTE moduleName[16];
|
|
||||||
CommonChars *common;
|
|
||||||
} CardHandle;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _BindingsList {
|
|
||||||
WORD numBindings;
|
|
||||||
BYTE moduleName[2][16];
|
|
||||||
} BindingsList;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _FailingModules {
|
|
||||||
BYTE upperModuleName[16];
|
|
||||||
BYTE lowerModuleName[16];
|
|
||||||
} FailingModules;
|
|
||||||
|
|
||||||
|
|
||||||
typedef union _HardwareAddress {
|
|
||||||
BYTE bytes[6];
|
|
||||||
WORD words[3];
|
|
||||||
struct {
|
|
||||||
BYTE bytes[6];
|
|
||||||
} addr;
|
|
||||||
} HardwareAddress;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _FddiHeader {
|
|
||||||
BYTE frameControl;
|
|
||||||
HardwareAddress etherDestHost;
|
|
||||||
HardwareAddress etherSrcHost;
|
|
||||||
} FddiHeader;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _EthernetIIHeader {
|
|
||||||
HardwareAddress etherDestHost;
|
|
||||||
HardwareAddress etherSrcHost;
|
|
||||||
WORD etherType;
|
|
||||||
} EthernetIIHeader;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _Ieee802Dot5Header {
|
|
||||||
HardwareAddress etherDestHost;
|
|
||||||
HardwareAddress etherSrcHost;
|
|
||||||
BYTE routeInfo[30];
|
|
||||||
} Ieee802Dot5Header;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _Ieee802Dot2SnapHeader {
|
|
||||||
BYTE dsap; /* 0xAA */
|
|
||||||
BYTE ssap; /* 0xAA */
|
|
||||||
BYTE control; /* 3 */
|
|
||||||
BYTE protocolId[5];
|
|
||||||
} Ieee802Dot2SnapHeader;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Prototypes
|
|
||||||
*/
|
|
||||||
extern char *NdisLastError (void);
|
|
||||||
extern int NdisOpen (void);
|
|
||||||
extern int NdisInit (int promis);
|
|
||||||
extern int NdisRegisterAndBind (int promis);
|
|
||||||
extern void NdisShutdown (void);
|
|
||||||
extern void NdisCheckMacFeatures (struct _CardHandle *card);
|
|
||||||
extern int NdisSendPacket (struct _PktBuf *pktBuf, int macId);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Assembly "glue" functions
|
|
||||||
*/
|
|
||||||
extern int systemRequestGlue();
|
|
||||||
extern int requestConfirmGlue();
|
|
||||||
extern int transmitConfirmGlue();
|
|
||||||
extern int receiveLookaheadGlue();
|
|
||||||
extern int indicationCompleteGlue();
|
|
||||||
extern int receiveChainGlue();
|
|
||||||
extern int statusGlue();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* IOCTL function
|
|
||||||
*/
|
|
||||||
#ifdef __SMALL__
|
|
||||||
extern int _far NdisGetLinkage (int handle, char *data, int size);
|
|
||||||
#else
|
|
||||||
extern int NdisGetLinkage (int handle, char *data, int size);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* NDIS callback handlers
|
|
||||||
*/
|
|
||||||
CALLBACK (NdisSystemRequest (DWORD,DWORD, WORD, WORD, WORD));
|
|
||||||
CALLBACK (NdisRequestConfirm ( WORD, WORD, WORD, WORD, WORD,WORD));
|
|
||||||
CALLBACK (NdisTransmitConfirm ( WORD, WORD, WORD, WORD, WORD));
|
|
||||||
CALLBACK (NdisReceiveLookahead ( WORD, WORD, WORD, BYTE*, BYTE*, WORD));
|
|
||||||
CALLBACK (NdisReceiveChain ( WORD, WORD, WORD, struct _RxBufDescr*, BYTE*, WORD));
|
|
||||||
CALLBACK (NdisStatusProc ( WORD, WORD, BYTE*, WORD,WORD));
|
|
||||||
CALLBACK (NdisIndicationComplete( WORD, WORD));
|
|
||||||
|
|
||||||
BYTE *NdisAllocStack (void);
|
|
||||||
void NdisFreeStack (BYTE*);
|
|
||||||
|
|
||||||
#ifdef __HIGHC__
|
|
||||||
#define RENAME_ASM_SYM(x) pragma Alias(x,"@" #x "") /* prepend `@' */
|
|
||||||
#define RENAME_C_SYM(x) pragma Alias(x,"_" #x "") /* prepend `_' */
|
|
||||||
|
|
||||||
RENAME_ASM_SYM (systemRequestGlue);
|
|
||||||
RENAME_ASM_SYM (requestConfirmGlue);
|
|
||||||
RENAME_ASM_SYM (transmitConfirmGlue);
|
|
||||||
RENAME_ASM_SYM (receiveLookaheadGlue);
|
|
||||||
RENAME_ASM_SYM (indicationCompleteGlue);
|
|
||||||
RENAME_ASM_SYM (receiveChainGlue);
|
|
||||||
RENAME_ASM_SYM (statusGlue);
|
|
||||||
RENAME_ASM_SYM (NdisGetLinkage);
|
|
||||||
RENAME_C_SYM (NdisSystemRequest);
|
|
||||||
RENAME_C_SYM (NdisRequestConfirm);
|
|
||||||
RENAME_C_SYM (NdisTransmitConfirm);
|
|
||||||
RENAME_C_SYM (NdisReceiveLookahead);
|
|
||||||
RENAME_C_SYM (NdisIndicationComplete);
|
|
||||||
RENAME_C_SYM (NdisReceiveChain);
|
|
||||||
RENAME_C_SYM (NdisStatusProc);
|
|
||||||
RENAME_C_SYM (NdisAllocStack);
|
|
||||||
RENAME_C_SYM (NdisFreeStack);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,188 +0,0 @@
|
|||||||
PAGE 60,132
|
|
||||||
NAME NDIS_0
|
|
||||||
|
|
||||||
ifdef DOSX
|
|
||||||
.386
|
|
||||||
_TEXT SEGMENT PUBLIC DWORD USE16 'CODE'
|
|
||||||
_TEXT ENDS
|
|
||||||
_DATA SEGMENT PUBLIC DWORD USE16 'CODE'
|
|
||||||
_DATA ENDS
|
|
||||||
_TEXT32 SEGMENT PUBLIC BYTE USE32 'CODE'
|
|
||||||
_TEXT32 ENDS
|
|
||||||
CB_DSEG EQU <CS> ; DOSX is tiny-model
|
|
||||||
D_SEG EQU <_TEXT SEGMENT>
|
|
||||||
D_END EQU <_TEXT ENDS>
|
|
||||||
ASSUME CS:_TEXT,DS:_TEXT
|
|
||||||
|
|
||||||
PUSHREGS equ <pushad>
|
|
||||||
POPREGS equ <popad>
|
|
||||||
|
|
||||||
PUBPROC macro name
|
|
||||||
align 4
|
|
||||||
public @&name
|
|
||||||
@&name label near
|
|
||||||
endm
|
|
||||||
else
|
|
||||||
.286
|
|
||||||
_TEXT SEGMENT PUBLIC DWORD 'CODE'
|
|
||||||
_TEXT ENDS
|
|
||||||
_DATA SEGMENT PUBLIC DWORD 'DATA'
|
|
||||||
_DATA ENDS
|
|
||||||
CB_DSEG EQU <SEG _DATA> ; 16bit is small/large model
|
|
||||||
D_SEG EQU <_DATA SEGMENT>
|
|
||||||
D_END EQU <_DATA ENDS>
|
|
||||||
ASSUME CS:_TEXT,DS:_DATA
|
|
||||||
|
|
||||||
PUSHREGS equ <pusha>
|
|
||||||
POPREGS equ <popa>
|
|
||||||
|
|
||||||
PUBPROC macro name
|
|
||||||
public _&name
|
|
||||||
_&name label far
|
|
||||||
endm
|
|
||||||
endif
|
|
||||||
|
|
||||||
;-------------------------------------------
|
|
||||||
|
|
||||||
D_SEG
|
|
||||||
|
|
||||||
D_END
|
|
||||||
|
|
||||||
|
|
||||||
_TEXT SEGMENT
|
|
||||||
|
|
||||||
EXTRN _NdisSystemRequest : near
|
|
||||||
EXTRN _NdisRequestConfirm : near
|
|
||||||
EXTRN _NdisTransmitConfirm : near
|
|
||||||
EXTRN _NdisReceiveLookahead : near
|
|
||||||
EXTRN _NdisIndicationComplete : near
|
|
||||||
EXTRN _NdisReceiveChain : near
|
|
||||||
EXTRN _NdisStatusProc : near
|
|
||||||
EXTRN _NdisAllocStack : near
|
|
||||||
EXTRN _NdisFreeStack : near
|
|
||||||
|
|
||||||
;
|
|
||||||
; *ALL* interrupt threads come through this macro.
|
|
||||||
;
|
|
||||||
CALLBACK macro callbackProc, argsSize
|
|
||||||
|
|
||||||
pushf
|
|
||||||
PUSHREGS ;; Save the registers
|
|
||||||
|
|
||||||
push es
|
|
||||||
push ds
|
|
||||||
mov ax,CB_DSEG ;; Load DS
|
|
||||||
mov ds,ax
|
|
||||||
call _NdisAllocStack ;; Get and install a stack.
|
|
||||||
|
|
||||||
mov bx,ss ;; Save off the old stack in other regs
|
|
||||||
mov cx,sp
|
|
||||||
mov ss,dx ;; Install the new one
|
|
||||||
mov sp,ax
|
|
||||||
push bx ;; Save the old one on to the new stack
|
|
||||||
push cx
|
|
||||||
sub sp,&argsSize ;; Allocate space for arguments on the stack
|
|
||||||
|
|
||||||
mov ax,ss ;; Set up the destination for the move
|
|
||||||
mov es,ax
|
|
||||||
mov di,sp
|
|
||||||
mov ds,bx ;; Set up the source for the move.
|
|
||||||
mov si,cx
|
|
||||||
add si,4+6+32
|
|
||||||
|
|
||||||
mov cx,&argsSize ;; Move the arguments to the stack.
|
|
||||||
shr cx,1
|
|
||||||
cld
|
|
||||||
rep movsw
|
|
||||||
|
|
||||||
mov ax,CB_DSEG ;; Set my data segment again.
|
|
||||||
mov ds,ax
|
|
||||||
|
|
||||||
call &callbackProc ;; Call the real callback.
|
|
||||||
pop di ;; Pop off the old stack
|
|
||||||
pop si
|
|
||||||
mov bx,ss ;; Save off the current allocated stack.
|
|
||||||
mov cx,sp
|
|
||||||
mov ss,si ;; Restore the old stack
|
|
||||||
mov sp,di
|
|
||||||
push ax ;; Save the return code
|
|
||||||
push bx ;; Free the stack. Push the pointer to it
|
|
||||||
push cx
|
|
||||||
call _NdisFreeStack
|
|
||||||
add sp,4
|
|
||||||
pop ax ;; Get the return code back
|
|
||||||
add di,32 ;; Get a pointer to ax on the stack
|
|
||||||
mov word ptr ss:[di],ax
|
|
||||||
pop ds
|
|
||||||
pop es
|
|
||||||
|
|
||||||
POPREGS
|
|
||||||
popf
|
|
||||||
endm
|
|
||||||
|
|
||||||
;
|
|
||||||
; Define all of the callbacks for the NDIS procs.
|
|
||||||
;
|
|
||||||
|
|
||||||
PUBPROC systemRequestGlue
|
|
||||||
CALLBACK _NdisSystemRequest,14
|
|
||||||
RETF
|
|
||||||
|
|
||||||
PUBPROC requestConfirmGlue
|
|
||||||
CALLBACK _NdisRequestConfirm,12
|
|
||||||
RETF
|
|
||||||
|
|
||||||
PUBPROC transmitConfirmGlue
|
|
||||||
CALLBACK _NdisTransmitConfirm,10
|
|
||||||
RETF
|
|
||||||
|
|
||||||
PUBPROC receiveLookaheadGlue
|
|
||||||
CALLBACK _NdisReceiveLookahead,16
|
|
||||||
RETF
|
|
||||||
|
|
||||||
PUBPROC indicationCompleteGlue
|
|
||||||
CALLBACK _NdisIndicationComplete,4
|
|
||||||
RETF
|
|
||||||
|
|
||||||
PUBPROC receiveChainGlue
|
|
||||||
CALLBACK _NdisReceiveChain,16
|
|
||||||
RETF
|
|
||||||
|
|
||||||
PUBPROC statusGlue
|
|
||||||
CALLBACK _NdisStatusProc,12
|
|
||||||
RETF
|
|
||||||
|
|
||||||
;
|
|
||||||
; int FAR NdisGetLinkage (int handle, char *data, int size);
|
|
||||||
;
|
|
||||||
|
|
||||||
ifdef DOSX
|
|
||||||
PUBPROC NdisGetLinkage
|
|
||||||
push ebx
|
|
||||||
mov ebx, [esp+8] ; device handle
|
|
||||||
mov eax, 4402h ; IOCTRL read function
|
|
||||||
mov edx, [esp+12] ; DS:EDX -> result data
|
|
||||||
mov ecx, [esp+16] ; ECX = length
|
|
||||||
int 21h
|
|
||||||
pop ebx
|
|
||||||
jc @fail
|
|
||||||
xor eax, eax
|
|
||||||
@fail: ret
|
|
||||||
|
|
||||||
else
|
|
||||||
PUBPROC NdisGetLinkage
|
|
||||||
enter 0, 0
|
|
||||||
mov bx, [bp+6]
|
|
||||||
mov ax, 4402h
|
|
||||||
mov dx, [bp+8]
|
|
||||||
mov cx, [bp+12]
|
|
||||||
int 21h
|
|
||||||
jc @fail
|
|
||||||
xor ax, ax
|
|
||||||
@fail: leave
|
|
||||||
retf
|
|
||||||
endif
|
|
||||||
|
|
||||||
ENDS
|
|
||||||
|
|
||||||
END
|
|
||||||
@@ -1,197 +0,0 @@
|
|||||||
PAGE 60,132
|
|
||||||
NAME PKT_RX
|
|
||||||
|
|
||||||
ifdef ??version ; using TASM
|
|
||||||
masm
|
|
||||||
jumps
|
|
||||||
endif
|
|
||||||
|
|
||||||
PUBLIC _pktDrop, _pktRxBuf, _pktTxBuf, _pktTemp
|
|
||||||
PUBLIC _rxOutOfs, _rxInOfs, _PktReceiver, _pktRxEnd
|
|
||||||
|
|
||||||
;
|
|
||||||
; these sizes MUST be equal to the sizes in PKTDRVR.H
|
|
||||||
;
|
|
||||||
|
|
||||||
RX_BUF_SIZE = 1500 ; max message size on Ethernet
|
|
||||||
TX_BUF_SIZE = 1500
|
|
||||||
|
|
||||||
ifdef DOSX
|
|
||||||
.386
|
|
||||||
NUM_RX_BUF = 32 ; # of RX element buffers
|
|
||||||
_TEXT SEGMENT PUBLIC DWORD USE16 'CODE'
|
|
||||||
_TEXT ENDS
|
|
||||||
_DATA SEGMENT PUBLIC DWORD USE16 'CODE'
|
|
||||||
_DATA ENDS
|
|
||||||
D_SEG EQU <_TEXT SEGMENT>
|
|
||||||
D_END EQU <_TEXT ENDS>
|
|
||||||
ASSUME CS:_TEXT,DS:_TEXT
|
|
||||||
else
|
|
||||||
.286
|
|
||||||
NUM_RX_BUF = 10
|
|
||||||
_TEXT SEGMENT PUBLIC DWORD 'CODE'
|
|
||||||
_TEXT ENDS
|
|
||||||
_DATA SEGMENT PUBLIC DWORD 'DATA'
|
|
||||||
_DATA ENDS
|
|
||||||
D_SEG EQU <_DATA SEGMENT>
|
|
||||||
D_END EQU <_DATA ENDS>
|
|
||||||
ASSUME CS:_TEXT,DS:_DATA
|
|
||||||
endif
|
|
||||||
|
|
||||||
;-------------------------------------------
|
|
||||||
|
|
||||||
D_SEG
|
|
||||||
|
|
||||||
RX_ELEMENT STRUC
|
|
||||||
firstCount dw 0 ; # of bytes on 1st call
|
|
||||||
secondCount dw 0 ; # of bytes on 2nd call
|
|
||||||
handle dw 0 ; handle for upcall
|
|
||||||
destinAdr db 6 dup (0) ; packet destination address
|
|
||||||
sourceAdr db 6 dup (0) ; packet source address
|
|
||||||
protocol dw 0 ; packet protocol number
|
|
||||||
rxBuffer db RX_BUF_SIZE dup (0) ; RX buffer
|
|
||||||
ENDS
|
|
||||||
align 4
|
|
||||||
_rxOutOfs dw offset _pktRxBuf ; ring buffer offsets
|
|
||||||
_rxInOfs dw offset _pktRxBuf ; into _pktRxBuf
|
|
||||||
_pktDrop dw 0,0 ; packet drop counter
|
|
||||||
_pktTemp db 20 dup (0) ; temp work area
|
|
||||||
_pktTxBuf db (TX_BUF_SIZE+14) dup (0) ; TX buffer
|
|
||||||
_pktRxBuf RX_ELEMENT NUM_RX_BUF dup (<>) ; RX structures
|
|
||||||
LAST_OFS = offset $
|
|
||||||
|
|
||||||
screenSeg dw 0B800h
|
|
||||||
newInOffset dw 0
|
|
||||||
|
|
||||||
fanChars db '-\|/'
|
|
||||||
fanIndex dw 0
|
|
||||||
|
|
||||||
D_END
|
|
||||||
|
|
||||||
_TEXT SEGMENT
|
|
||||||
|
|
||||||
|
|
||||||
SHOW_RX MACRO
|
|
||||||
push es
|
|
||||||
push bx
|
|
||||||
mov bx, screenSeg
|
|
||||||
mov es, bx ;; r-mode segment of colour screen
|
|
||||||
mov di, 158 ;; upper right corner - 1
|
|
||||||
mov bx, fanIndex
|
|
||||||
mov al, fanChars[bx] ;; get write char
|
|
||||||
mov ah, 15 ;; and white colour
|
|
||||||
stosw ;; write to screen at ES:EDI
|
|
||||||
inc fanIndex ;; update next index
|
|
||||||
and fanIndex, 3
|
|
||||||
pop bx
|
|
||||||
pop es
|
|
||||||
ENDM
|
|
||||||
|
|
||||||
;------------------------------------------------------------------------
|
|
||||||
;
|
|
||||||
; This macro return ES:DI to tail of Rx queue
|
|
||||||
|
|
||||||
ENQUEUE MACRO
|
|
||||||
LOCAL @noWrap
|
|
||||||
mov ax, _rxInOfs ;; DI = current in-offset
|
|
||||||
add ax, SIZE RX_ELEMENT ;; point to next _pktRxBuf buffer
|
|
||||||
cmp ax, LAST_OFS ;; pointing past last ?
|
|
||||||
jb @noWrap ;; no - jump
|
|
||||||
lea ax, _pktRxBuf ;; yes, point to 1st buffer
|
|
||||||
align 4
|
|
||||||
@noWrap: cmp ax, _rxOutOfs ;; in-ofs = out-ofs ?
|
|
||||||
je @dump ;; yes, queue is full
|
|
||||||
mov di, _rxInOfs ;; ES:DI -> buffer at queue input
|
|
||||||
mov newInOffset, ax ;; remember new input offset
|
|
||||||
|
|
||||||
;; NOTE. rxInOfs is updated after the packet has been copied
|
|
||||||
;; to ES:DI (= DS:SI on 2nd call) by the packet driver
|
|
||||||
|
|
||||||
ENDM
|
|
||||||
|
|
||||||
;------------------------------------------------------------------------
|
|
||||||
;
|
|
||||||
; This routine gets called by the packet driver twice:
|
|
||||||
; 1st time (AX=0) it requests an address where to put the packet
|
|
||||||
;
|
|
||||||
; 2nd time (AX=1) the packet has been copied to this location (DS:SI)
|
|
||||||
; BX has client handle (stored in RX_ELEMENT.handle).
|
|
||||||
; CX has # of bytes in packet on both call. They should be equal.
|
|
||||||
;
|
|
||||||
; A test for equality is done by putting CX in _pktRxBuf [n].firstCount
|
|
||||||
; and _pktRxBuf[n].secondCount, and CL on first call in
|
|
||||||
; _pktRxBuf[n].rxBuffer[CX]. These values are checked in "PktReceive"
|
|
||||||
; (PKTDRVR.C)
|
|
||||||
;
|
|
||||||
;---------------------------------------------------------------------
|
|
||||||
|
|
||||||
_PktReceiver:
|
|
||||||
pushf
|
|
||||||
cli ; no distraction wanted !
|
|
||||||
push ds
|
|
||||||
push bx
|
|
||||||
ifdef DOSX
|
|
||||||
mov bx, cs
|
|
||||||
else
|
|
||||||
mov bx, SEG _DATA
|
|
||||||
endif
|
|
||||||
mov ds, bx
|
|
||||||
mov es, bx ; ES = DS = CS or seg _DATA
|
|
||||||
pop bx ; restore handle
|
|
||||||
|
|
||||||
cmp ax, 0 ; first call? (AX=0)
|
|
||||||
jne @post ; AX=1: second call, do post process
|
|
||||||
|
|
||||||
ifdef DEBUG
|
|
||||||
SHOW_RX ; show that a packet is received
|
|
||||||
endif
|
|
||||||
cmp cx, RX_BUF_SIZE+14 ; size OK ?
|
|
||||||
ja @skip ; no, packet to large for us
|
|
||||||
|
|
||||||
ENQUEUE ; ES:DI -> _pktRxBuf[n]
|
|
||||||
|
|
||||||
mov [di].firstCount, cx ; remember the first count.
|
|
||||||
mov [di].handle, bx ; remember the handle.
|
|
||||||
add di, 6 ; ES:DI -> _pktRxBuf[n].destinAdr
|
|
||||||
pop ds
|
|
||||||
popf
|
|
||||||
retf ; far return to driver with ES:DI
|
|
||||||
|
|
||||||
align 4
|
|
||||||
@dump: inc _pktDrop[0] ; discard the packet on 1st call
|
|
||||||
adc _pktDrop[2], 0 ; increment packets lost
|
|
||||||
|
|
||||||
@skip: xor di, di ; return ES:DI = NIL pointer
|
|
||||||
xor ax, ax
|
|
||||||
mov es, ax
|
|
||||||
pop ds
|
|
||||||
popf
|
|
||||||
retf
|
|
||||||
|
|
||||||
align 4
|
|
||||||
@post: or si, si ; DS:SI->_pktRxBuf[n][n].destinAdr
|
|
||||||
jz @discard ; make sure we don't use NULL-pointer
|
|
||||||
|
|
||||||
sub si, 6 ; DS:SI -> _pktRxBuf[n].destinAdr
|
|
||||||
;
|
|
||||||
; push si
|
|
||||||
; push [si].firstCount
|
|
||||||
; call bpf_filter_match ; run the filter here some day?
|
|
||||||
; add sp, 4
|
|
||||||
; cmp ax, 0
|
|
||||||
; je @discard
|
|
||||||
|
|
||||||
mov [si].secondCount, cx
|
|
||||||
mov ax, newInOffset
|
|
||||||
mov _rxInOfs, ax ; update _pktRxBuf input offset
|
|
||||||
|
|
||||||
align 4
|
|
||||||
@discard:pop ds
|
|
||||||
popf
|
|
||||||
retf
|
|
||||||
|
|
||||||
_pktRxEnd db 0 ; marker for end of r-mode code/data
|
|
||||||
|
|
||||||
_TEXT ENDS
|
|
||||||
|
|
||||||
END
|
|
||||||
@@ -1,155 +0,0 @@
|
|||||||
;
|
|
||||||
; This file requires NASM 0.97+ to assemble
|
|
||||||
;
|
|
||||||
; Currently used only for djgpp + DOS4GW targets
|
|
||||||
;
|
|
||||||
; these sizes MUST be equal to the sizes in PKTDRVR.H
|
|
||||||
;
|
|
||||||
%define ETH_MTU 1500 ; max data size on Ethernet
|
|
||||||
%define ETH_MIN 60 ; min/max total frame size
|
|
||||||
%define ETH_MAX (ETH_MTU+2*6+2)
|
|
||||||
%define NUM_RX_BUF 32 ; # of RX element buffers
|
|
||||||
%define RX_SIZE (ETH_MAX+6) ; sizeof(RX_ELEMENT) = 1514+6
|
|
||||||
%idefine offset
|
|
||||||
|
|
||||||
struc RX_ELEMENT
|
|
||||||
.firstCount resw 1 ; # of bytes on 1st call
|
|
||||||
.secondCount resw 1 ; # of bytes on 2nd call
|
|
||||||
.handle resw 1 ; handle for upcall
|
|
||||||
; .timeStamp resw 4 ; 64-bit RDTSC value
|
|
||||||
.destinAdr resb 6 ; packet destination address
|
|
||||||
.sourceAdr resb 6 ; packet source address
|
|
||||||
.protocol resw 1 ; packet protocol number
|
|
||||||
.rxBuffer resb ETH_MTU ; RX buffer
|
|
||||||
endstruc
|
|
||||||
|
|
||||||
;-------------------------------------------
|
|
||||||
|
|
||||||
[org 0] ; assemble to .bin file
|
|
||||||
|
|
||||||
_rxOutOfs dw offset _pktRxBuf ; ring buffer offsets
|
|
||||||
_rxInOfs dw offset _pktRxBuf ; into _pktRxBuf
|
|
||||||
_pktDrop dw 0,0 ; packet drop counter
|
|
||||||
_pktTemp resb 20 ; temp work area
|
|
||||||
_pktTxBuf resb (ETH_MAX) ; TX buffer
|
|
||||||
_pktRxBuf resb (RX_SIZE*NUM_RX_BUF) ; RX structures
|
|
||||||
LAST_OFS equ $
|
|
||||||
|
|
||||||
screenSeg dw 0B800h
|
|
||||||
newInOffset dw 0
|
|
||||||
|
|
||||||
fanChars db '-\|/'
|
|
||||||
fanIndex dw 0
|
|
||||||
|
|
||||||
%macro SHOW_RX 0
|
|
||||||
push es
|
|
||||||
push bx
|
|
||||||
mov bx, [screenSeg]
|
|
||||||
mov es, bx ;; r-mode segment of colour screen
|
|
||||||
mov di, 158 ;; upper right corner - 1
|
|
||||||
mov bx, [fanIndex]
|
|
||||||
mov al, [fanChars+bx] ;; get write char
|
|
||||||
mov ah, 15 ;; and white colour
|
|
||||||
cld ;; Needed?
|
|
||||||
stosw ;; write to screen at ES:EDI
|
|
||||||
inc word [fanIndex] ;; update next index
|
|
||||||
and word [fanIndex], 3
|
|
||||||
pop bx
|
|
||||||
pop es
|
|
||||||
%endmacro
|
|
||||||
|
|
||||||
;PutTimeStamp
|
|
||||||
; rdtsc
|
|
||||||
; mov [si].timeStamp, eax
|
|
||||||
; mov [si+4].timeStamp, edx
|
|
||||||
; ret
|
|
||||||
|
|
||||||
|
|
||||||
;------------------------------------------------------------------------
|
|
||||||
;
|
|
||||||
; This routine gets called by the packet driver twice:
|
|
||||||
; 1st time (AX=0) it requests an address where to put the packet
|
|
||||||
;
|
|
||||||
; 2nd time (AX=1) the packet has been copied to this location (DS:SI)
|
|
||||||
; BX has client handle (stored in RX_ELEMENT.handle).
|
|
||||||
; CX has # of bytes in packet on both call. They should be equal.
|
|
||||||
; A test for equality is done by putting CX in _pktRxBuf [n].firstCount
|
|
||||||
; and _pktRxBuf[n].secondCount, and CL on first call in
|
|
||||||
; _pktRxBuf[n].rxBuffer[CX]. These values are checked in "PktReceive"
|
|
||||||
; (PKTDRVR.C)
|
|
||||||
;
|
|
||||||
;---------------------------------------------------------------------
|
|
||||||
|
|
||||||
_PktReceiver:
|
|
||||||
pushf
|
|
||||||
cli ; no distraction wanted !
|
|
||||||
push ds
|
|
||||||
push bx
|
|
||||||
mov bx, cs
|
|
||||||
mov ds, bx
|
|
||||||
mov es, bx ; ES = DS = CS or seg _DATA
|
|
||||||
pop bx ; restore handle
|
|
||||||
|
|
||||||
cmp ax, 0 ; first call? (AX=0)
|
|
||||||
jne @post ; AX=1: second call, do post process
|
|
||||||
|
|
||||||
%ifdef DEBUG
|
|
||||||
SHOW_RX ; show that a packet is received
|
|
||||||
%endif
|
|
||||||
|
|
||||||
cmp cx, ETH_MAX ; size OK ?
|
|
||||||
ja @skip ; no, too big
|
|
||||||
|
|
||||||
mov ax, [_rxInOfs]
|
|
||||||
add ax, RX_SIZE
|
|
||||||
cmp ax, LAST_OFS
|
|
||||||
jb @noWrap
|
|
||||||
mov ax, offset _pktRxBuf
|
|
||||||
@noWrap:
|
|
||||||
cmp ax, [_rxOutOfs]
|
|
||||||
je @dump
|
|
||||||
mov di, [_rxInOfs] ; ES:DI -> _pktRxBuf[n]
|
|
||||||
mov [newInOffset], ax
|
|
||||||
|
|
||||||
mov [di], cx ; remember firstCount.
|
|
||||||
mov [di+4], bx ; remember handle.
|
|
||||||
add di, 6 ; ES:DI -> _pktRxBuf[n].destinAdr
|
|
||||||
pop ds
|
|
||||||
popf
|
|
||||||
retf ; far return to driver with ES:DI
|
|
||||||
|
|
||||||
@dump: add word [_pktDrop+0], 1 ; discard the packet on 1st call
|
|
||||||
adc word [_pktDrop+2], 0 ; increment packets lost
|
|
||||||
|
|
||||||
@skip: xor di, di ; return ES:DI = NIL pointer
|
|
||||||
xor ax, ax
|
|
||||||
mov es, ax
|
|
||||||
pop ds
|
|
||||||
popf
|
|
||||||
retf
|
|
||||||
|
|
||||||
@post: or si, si ; DS:SI->_pktRxBuf[n][n].destinAdr
|
|
||||||
jz @discard ; make sure we don't use NULL-pointer
|
|
||||||
|
|
||||||
;
|
|
||||||
; push si
|
|
||||||
; call bpf_filter_match ; run the filter here some day
|
|
||||||
; pop si
|
|
||||||
; cmp ax, 0
|
|
||||||
; je @discard
|
|
||||||
|
|
||||||
mov [si-6+2], cx ; store _pktRxBuf[n].secondCount
|
|
||||||
mov ax, [newInOffset]
|
|
||||||
mov [_rxInOfs], ax ; update _pktRxBuf input offset
|
|
||||||
|
|
||||||
; call PutTimeStamp
|
|
||||||
|
|
||||||
@discard:
|
|
||||||
pop ds
|
|
||||||
popf
|
|
||||||
retf
|
|
||||||
|
|
||||||
_pktRxEnd db 0 ; marker for end of r-mode code/data
|
|
||||||
|
|
||||||
END
|
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,153 +0,0 @@
|
|||||||
#ifndef __PKTDRVR_H
|
|
||||||
#define __PKTDRVR_H
|
|
||||||
|
|
||||||
#define PUBLIC
|
|
||||||
#define LOCAL static
|
|
||||||
|
|
||||||
#define RX_BUF_SIZE ETH_MTU /* buffer size variables. NB !! */
|
|
||||||
#define TX_BUF_SIZE ETH_MTU /* must be same as in pkt_rx*.* */
|
|
||||||
|
|
||||||
#ifdef __HIGHC__
|
|
||||||
#pragma Off(Align_members)
|
|
||||||
#else
|
|
||||||
#pragma pack(1)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef enum { /* Packet-driver classes */
|
|
||||||
PD_ETHER = 1,
|
|
||||||
PD_PRONET10 = 2,
|
|
||||||
PD_IEEE8025 = 3,
|
|
||||||
PD_OMNINET = 4,
|
|
||||||
PD_APPLETALK = 5,
|
|
||||||
PD_SLIP = 6,
|
|
||||||
PD_STARTLAN = 7,
|
|
||||||
PD_ARCNET = 8,
|
|
||||||
PD_AX25 = 9,
|
|
||||||
PD_KISS = 10,
|
|
||||||
PD_IEEE8023_2 = 11,
|
|
||||||
PD_FDDI8022 = 12,
|
|
||||||
PD_X25 = 13,
|
|
||||||
PD_LANstar = 14,
|
|
||||||
PD_PPP = 18
|
|
||||||
} PKT_CLASS;
|
|
||||||
|
|
||||||
typedef enum { /* Packet-driver receive modes */
|
|
||||||
PDRX_OFF = 1, /* turn off receiver */
|
|
||||||
PDRX_DIRECT, /* receive only to this interface */
|
|
||||||
PDRX_BROADCAST, /* DIRECT + broadcast packets */
|
|
||||||
PDRX_MULTICAST1, /* BROADCAST + limited multicast */
|
|
||||||
PDRX_MULTICAST2, /* BROADCAST + all multicast */
|
|
||||||
PDRX_ALL_PACKETS, /* receive all packets on network */
|
|
||||||
} PKT_RX_MODE;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
char type[8];
|
|
||||||
char len;
|
|
||||||
} PKT_FRAME;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
BYTE class; /* = 1 for DEC/Interl/Xerox Ethernet */
|
|
||||||
BYTE number; /* = 0 for single LAN adapter */
|
|
||||||
WORD type; /* = 13 for 3C523 */
|
|
||||||
BYTE funcs; /* Basic/Extended/HiPerf functions */
|
|
||||||
WORD intr; /* user interrupt vector number */
|
|
||||||
WORD handle; /* Handle associated with session */
|
|
||||||
BYTE name [15]; /* Name of adapter interface,ie.3C523*/
|
|
||||||
BOOL quiet; /* (don't) print errors to stdout */
|
|
||||||
const char *error; /* address of error string */
|
|
||||||
BYTE majVer; /* Major driver implementation ver. */
|
|
||||||
BYTE minVer; /* Minor driver implementation ver. */
|
|
||||||
BYTE dummyLen; /* length of following data */
|
|
||||||
WORD MAClength; /* HiPerformance data, N/A */
|
|
||||||
WORD MTU; /* HiPerformance data, N/A */
|
|
||||||
WORD multicast; /* HiPerformance data, N/A */
|
|
||||||
WORD rcvrBuffers; /* valid for */
|
|
||||||
WORD UMTbufs; /* High Performance drivers only */
|
|
||||||
WORD postEOIintr; /* Usage ?? */
|
|
||||||
} PKT_INFO;
|
|
||||||
|
|
||||||
#define PKT_PARAM_SIZE 14 /* members majVer - postEOIintr */
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
DWORD inPackets; /* # of packets received */
|
|
||||||
DWORD outPackets; /* # of packets transmitted */
|
|
||||||
DWORD inBytes; /* # of bytes received */
|
|
||||||
DWORD outBytes; /* # of bytes transmitted */
|
|
||||||
DWORD inErrors; /* # of reception errors */
|
|
||||||
DWORD outErrors; /* # of transmission errors */
|
|
||||||
DWORD lost; /* # of packets lost (RX) */
|
|
||||||
} PKT_STAT;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
ETHER destin;
|
|
||||||
ETHER source;
|
|
||||||
WORD proto;
|
|
||||||
BYTE data [TX_BUF_SIZE];
|
|
||||||
} TX_ELEMENT;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
WORD firstCount; /* # of bytes on 1st */
|
|
||||||
WORD secondCount; /* and 2nd upcall */
|
|
||||||
WORD handle; /* instance that upcalled */
|
|
||||||
ETHER destin; /* E-net destination address */
|
|
||||||
ETHER source; /* E-net source address */
|
|
||||||
WORD proto; /* protocol number */
|
|
||||||
BYTE data [RX_BUF_SIZE];
|
|
||||||
} RX_ELEMENT;
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __HIGHC__
|
|
||||||
#pragma pop(Align_members)
|
|
||||||
#else
|
|
||||||
#pragma pack()
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Prototypes for publics
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern PKT_STAT pktStat; /* statistics for packets */
|
|
||||||
extern PKT_INFO pktInfo; /* packet-driver information */
|
|
||||||
|
|
||||||
extern PKT_RX_MODE receiveMode;
|
|
||||||
extern ETHER myAddress, ethBroadcast;
|
|
||||||
|
|
||||||
extern BOOL PktInitDriver (PKT_RX_MODE mode);
|
|
||||||
extern BOOL PktExitDriver (void);
|
|
||||||
|
|
||||||
extern const char *PktGetErrorStr (int errNum);
|
|
||||||
extern const char *PktGetClassName (WORD class);
|
|
||||||
extern const char *PktRXmodeStr (PKT_RX_MODE mode);
|
|
||||||
extern BOOL PktSearchDriver (void);
|
|
||||||
extern int PktReceive (BYTE *buf, int max);
|
|
||||||
extern BOOL PktTransmit (const void *eth, int len);
|
|
||||||
extern DWORD PktRxDropped (void);
|
|
||||||
extern BOOL PktReleaseHandle (WORD handle);
|
|
||||||
extern BOOL PktTerminHandle (WORD handle);
|
|
||||||
extern BOOL PktResetInterface (WORD handle);
|
|
||||||
extern BOOL PktSetReceiverMode(PKT_RX_MODE mode);
|
|
||||||
extern BOOL PktGetReceiverMode(PKT_RX_MODE *mode);
|
|
||||||
extern BOOL PktGetStatistics (WORD handle);
|
|
||||||
extern BOOL PktSessStatistics (WORD handle);
|
|
||||||
extern BOOL PktResetStatistics(WORD handle);
|
|
||||||
extern BOOL PktGetAddress (ETHER *addr);
|
|
||||||
extern BOOL PktSetAddress (const ETHER *addr);
|
|
||||||
extern BOOL PktGetDriverInfo (void);
|
|
||||||
extern BOOL PktGetDriverParam (void);
|
|
||||||
extern void PktQueueBusy (BOOL busy);
|
|
||||||
extern WORD PktBuffersUsed (void);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __PKTDRVR_H */
|
|
||||||
|
|
||||||
@@ -1,162 +0,0 @@
|
|||||||
@(#) $Header: /tcpdump/master/libpcap/msdos/readme.dos,v 1.3 2004/12/19 19:47:01 guy Exp $ (LBL)
|
|
||||||
|
|
||||||
libpcap for DOS
|
|
||||||
---------------
|
|
||||||
|
|
||||||
This file contains some notes on building and using libpcap for MS-DOS.
|
|
||||||
Look in `README' and `pcap.man' for usage and details. These targets are
|
|
||||||
supported:
|
|
||||||
|
|
||||||
- Borland C 4.0+ small or large model.
|
|
||||||
- Metaware HighC 3.1+ with PharLap DOS-extender
|
|
||||||
- GNU C 2.7+ with djgpp 2.01+ DOS extender
|
|
||||||
- Watcom C 11.x with DOS4GW extender
|
|
||||||
|
|
||||||
Note: the files in the libpcap.zip contains short trucated filenames.
|
|
||||||
So for djgpp to work with these, disable the use of long file names by
|
|
||||||
setting "LFN=n" in the environment.
|
|
||||||
|
|
||||||
Files specific to DOS are pcap-dos.[ch] and the assembly and C files in
|
|
||||||
the MSDOS sub-directory. Remember to built lipcap libraries from the top
|
|
||||||
install directory. And not from the MSDOS sub-directory.
|
|
||||||
|
|
||||||
Note for djgpp users:
|
|
||||||
If you got the libpcap from the official site www.tcpdump, then that
|
|
||||||
distribution does NOT contain any sources for building 32-bit drivers.
|
|
||||||
Instead get the full version at
|
|
||||||
http://www.bgnett.no/~giva/pcap/libpcap.zip
|
|
||||||
|
|
||||||
and set "USE_32BIT_DRIVERS = 1" in msdos\common.dj.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Requirements
|
|
||||||
------------
|
|
||||||
|
|
||||||
DOS-libpcap currently only works reliably with a real-mode Ethernet packet-
|
|
||||||
driver. This driver must be installed prior to using any program (e.g.
|
|
||||||
tcpdump) compiled with libpcap. Work is underway to implement protected-
|
|
||||||
mode drivers for 32-bit targets (djgpp only). The 3Com 3c509 driver is
|
|
||||||
working almost perfectly. Due to lack of LAN-cards, I've not had the
|
|
||||||
opportunity to test other drivers. These 32-bit drivers are modified
|
|
||||||
Linux drivers.
|
|
||||||
|
|
||||||
|
|
||||||
Required packages
|
|
||||||
-----------------
|
|
||||||
|
|
||||||
The following packages and tools must be present for all targets.
|
|
||||||
|
|
||||||
1. Watt-32 tcp/ip library. This library is *not* used to send or
|
|
||||||
receive network data. It's mostly used to access the 'hosts'
|
|
||||||
file and other <netdb.h> features. Get 'watt32s*.zip' at:
|
|
||||||
|
|
||||||
http://www.bgnett.no/~giva/
|
|
||||||
|
|
||||||
2. Exception handler and disassember library (libexc.a) is needed if
|
|
||||||
"USE_EXCEPT = 1" in common.dj. Available at:
|
|
||||||
|
|
||||||
http://www.bgnett.no/~giva/misc/exc_dx07.zip
|
|
||||||
|
|
||||||
3. Flex & Bison is used to generate parser for the filter handler
|
|
||||||
pcap_compile:
|
|
||||||
|
|
||||||
ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/flx254b.zip
|
|
||||||
ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bsn128b.zip
|
|
||||||
|
|
||||||
4. NASM assembler v 0.98 or later is required when building djgpp and
|
|
||||||
Watcom targets:
|
|
||||||
|
|
||||||
ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2tk/nasm098p.zip
|
|
||||||
|
|
||||||
5. sed (Stream Editor) is required for doing `make depend'.
|
|
||||||
It's available at
|
|
||||||
ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/sed*.zip
|
|
||||||
|
|
||||||
A touch tool to update the time-stamp of a file. E.g.
|
|
||||||
ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/grep*.zip
|
|
||||||
|
|
||||||
6. For djgpp rm.exe and cp.exe are required. These should already be
|
|
||||||
part of your djgpp installation. Also required (experimental at the
|
|
||||||
time) for djgpp is DLX 2.91 or later. This tool is for the generation
|
|
||||||
of dynamically loadable modules.
|
|
||||||
|
|
||||||
|
|
||||||
Compiling libpcap
|
|
||||||
-----------------
|
|
||||||
|
|
||||||
Follow these steps in building libpcap:
|
|
||||||
|
|
||||||
1. Make sure you've installed Watt-32 properly (see it's `INSTALL' file).
|
|
||||||
During that installation a environment variable `WATT_ROOT' is set.
|
|
||||||
This variable is used for building libpcap also (`WATT_INC' is
|
|
||||||
deducted from `WATT_ROOT'). djgpp users should also define environment
|
|
||||||
variables `C_INCLUDE_PATH' and `LIBRARY_PATH' to point to the include
|
|
||||||
directory and library directory respectively. E.g. put this in your
|
|
||||||
AUTOEXEC.BAT:
|
|
||||||
set C_INCLUDE_PATH=c:/net/watt/inc
|
|
||||||
set LIBRARY_PATH=c:/net/watt/lib
|
|
||||||
|
|
||||||
2. Revise the msdos/common.dj file for your djgpp/gcc installation;
|
|
||||||
- change the value of `GCCLIB' to match location of libgcc.a.
|
|
||||||
- set `USE_32BIT_DRIVERS = 1' to build 32-bit driver objects.
|
|
||||||
|
|
||||||
|
|
||||||
3. Build pcap by using appropriate makefile. For djgpp, use:
|
|
||||||
`make -f msdos/makefile.dj' (i.e. GNU `make')
|
|
||||||
|
|
||||||
For a Watcom target say:
|
|
||||||
`wmake -f msdos\makefile.wc'
|
|
||||||
|
|
||||||
For a Borland target say:
|
|
||||||
`maker -f msdos\Makefile pcap_bc.lib' (Borland's `maker.exe')
|
|
||||||
|
|
||||||
And for a HighC/Pharlap target say:
|
|
||||||
`maker -f msdos\Makefile pcap_hc.lib' (Borland's `maker.exe')
|
|
||||||
|
|
||||||
You might like to change some `CFLAGS' -- only `DEBUG' define currently
|
|
||||||
have any effect. It shows a rotating "fan" in upper right corner of
|
|
||||||
screen. Remove `DEBUG' if you don't like it. You could add
|
|
||||||
`-fomit-frame-pointer' to `CFLAGS' to speed up the generated code.
|
|
||||||
But note, this makes debugging and crash-traceback difficult. Only
|
|
||||||
add it if you're fully confident your application is 100% stable.
|
|
||||||
|
|
||||||
Note: Code in `USE_NDIS2' does not work at the moment.
|
|
||||||
|
|
||||||
4. The resulting libraries are put in current directory. There's no
|
|
||||||
test-program for `libpcap'. Linking the library with `tcpdump' is
|
|
||||||
the ultimate test anyway.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Extensions to libpcap
|
|
||||||
---------------------
|
|
||||||
|
|
||||||
I've included some extra functions to DOS-libpcap:
|
|
||||||
|
|
||||||
`pcap_config_hook (const char *name, const char *value)'
|
|
||||||
|
|
||||||
Allows an application to set values of internal libpcap variables.
|
|
||||||
`name' is typically a left-side keyword with an associated `value'
|
|
||||||
that is called from application's configure process (see tcpdump's
|
|
||||||
config.c file). libpcap keeps a set of tables that are searched for
|
|
||||||
a name/value match. Currently only used to set debug-levels and
|
|
||||||
parameters for the 32-bit network drivers.
|
|
||||||
|
|
||||||
`pcap_set_wait (pcap_t *, void (*)(void), int)' :
|
|
||||||
|
|
||||||
Only effective when reading offline traffic from dump-files.
|
|
||||||
Function `pcap_offline_read()' will wait (and optionally yield)
|
|
||||||
before printing next packet. This will simulate the pace the packets
|
|
||||||
where actually recorded.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Happy sniffing !
|
|
||||||
|
|
||||||
|
|
||||||
Gisle Vanem <giva@bgnett.no>
|
|
||||||
<gvanem@broadpark.no>
|
|
||||||
|
|
||||||
October 1999, 2004
|
|
||||||
|
|
||||||
@@ -1,505 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1990, 1991, 1992, 1993, 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: (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.
|
|
||||||
*
|
|
||||||
* Name to id translation routines used by the scanner.
|
|
||||||
* These functions are not time critical.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef lint
|
|
||||||
static const char rcsid[] _U_ =
|
|
||||||
"@(#) $Header$ (LBL)";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
#include <pcap-stdinc.h>
|
|
||||||
|
|
||||||
#else /* WIN32 */
|
|
||||||
|
|
||||||
#include <sys/param.h>
|
|
||||||
#include <sys/types.h> /* concession to AIX */
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#endif /* WIN32 */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* XXX - why was this included even on UNIX?
|
|
||||||
*/
|
|
||||||
#ifdef __MINGW32__
|
|
||||||
#include "IP6_misc.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef WIN32
|
|
||||||
#ifdef HAVE_ETHER_HOSTTON
|
|
||||||
/*
|
|
||||||
* XXX - do we need any of this if <netinet/if_ether.h> doesn't declare
|
|
||||||
* ether_hostton()?
|
|
||||||
*/
|
|
||||||
#ifdef HAVE_NETINET_IF_ETHER_H
|
|
||||||
struct mbuf; /* Squelch compiler warnings on some platforms for */
|
|
||||||
struct rtentry; /* declarations in <net/if.h> */
|
|
||||||
#include <net/if.h> /* for "struct ifnet" in "struct arpcom" on Solaris */
|
|
||||||
#include <netinet/if_ether.h>
|
|
||||||
#endif /* HAVE_NETINET_IF_ETHER_H */
|
|
||||||
#ifdef NETINET_ETHER_H_DECLARES_ETHER_HOSTTON
|
|
||||||
#include <netinet/ether.h>
|
|
||||||
#endif /* NETINET_ETHER_H_DECLARES_ETHER_HOSTTON */
|
|
||||||
#endif /* HAVE_ETHER_HOSTTON */
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include <netdb.h>
|
|
||||||
#endif /* WIN32 */
|
|
||||||
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "pcap-int.h"
|
|
||||||
|
|
||||||
#include "gencode.h"
|
|
||||||
#include <pcap-namedb.h>
|
|
||||||
|
|
||||||
#ifdef HAVE_OS_PROTO_H
|
|
||||||
#include "os-proto.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef NTOHL
|
|
||||||
#define NTOHL(x) (x) = ntohl(x)
|
|
||||||
#define NTOHS(x) (x) = ntohs(x)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline int xdtoi(int);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Convert host name to internet address.
|
|
||||||
* Return 0 upon failure.
|
|
||||||
*/
|
|
||||||
bpf_u_int32 **
|
|
||||||
pcap_nametoaddr(const char *name)
|
|
||||||
{
|
|
||||||
#ifndef h_addr
|
|
||||||
static bpf_u_int32 *hlist[2];
|
|
||||||
#endif
|
|
||||||
bpf_u_int32 **p;
|
|
||||||
struct hostent *hp;
|
|
||||||
|
|
||||||
if ((hp = gethostbyname(name)) != NULL) {
|
|
||||||
#ifndef h_addr
|
|
||||||
hlist[0] = (bpf_u_int32 *)hp->h_addr;
|
|
||||||
NTOHL(hp->h_addr);
|
|
||||||
return hlist;
|
|
||||||
#else
|
|
||||||
for (p = (bpf_u_int32 **)hp->h_addr_list; *p; ++p)
|
|
||||||
NTOHL(**p);
|
|
||||||
return (bpf_u_int32 **)hp->h_addr_list;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef INET6
|
|
||||||
struct addrinfo *
|
|
||||||
pcap_nametoaddrinfo(const char *name)
|
|
||||||
{
|
|
||||||
struct addrinfo hints, *res;
|
|
||||||
int error;
|
|
||||||
|
|
||||||
memset(&hints, 0, sizeof(hints));
|
|
||||||
hints.ai_family = PF_UNSPEC;
|
|
||||||
hints.ai_socktype = SOCK_STREAM; /*not really*/
|
|
||||||
hints.ai_protocol = IPPROTO_TCP; /*not really*/
|
|
||||||
error = getaddrinfo(name, NULL, &hints, &res);
|
|
||||||
if (error)
|
|
||||||
return NULL;
|
|
||||||
else
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
#endif /*INET6*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Convert net name to internet address.
|
|
||||||
* Return 0 upon failure.
|
|
||||||
*/
|
|
||||||
bpf_u_int32
|
|
||||||
pcap_nametonetaddr(const char *name)
|
|
||||||
{
|
|
||||||
#ifndef WIN32
|
|
||||||
struct netent *np;
|
|
||||||
|
|
||||||
if ((np = getnetbyname(name)) != NULL)
|
|
||||||
return np->n_net;
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
#else
|
|
||||||
/*
|
|
||||||
* There's no "getnetbyname()" on Windows.
|
|
||||||
*/
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Convert a port name to its port and protocol numbers.
|
|
||||||
* We assume only TCP or UDP.
|
|
||||||
* Return 0 upon failure.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
pcap_nametoport(const char *name, int *port, int *proto)
|
|
||||||
{
|
|
||||||
struct servent *sp;
|
|
||||||
int tcp_port = -1;
|
|
||||||
int udp_port = -1;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We need to check /etc/services for ambiguous entries.
|
|
||||||
* If we find the ambiguous entry, and it has the
|
|
||||||
* same port number, change the proto to PROTO_UNDEF
|
|
||||||
* so both TCP and UDP will be checked.
|
|
||||||
*/
|
|
||||||
sp = getservbyname(name, "tcp");
|
|
||||||
if (sp != NULL) tcp_port = ntohs(sp->s_port);
|
|
||||||
sp = getservbyname(name, "udp");
|
|
||||||
if (sp != NULL) udp_port = ntohs(sp->s_port);
|
|
||||||
if (tcp_port >= 0) {
|
|
||||||
*port = tcp_port;
|
|
||||||
*proto = IPPROTO_TCP;
|
|
||||||
if (udp_port >= 0) {
|
|
||||||
if (udp_port == tcp_port)
|
|
||||||
*proto = PROTO_UNDEF;
|
|
||||||
#ifdef notdef
|
|
||||||
else
|
|
||||||
/* Can't handle ambiguous names that refer
|
|
||||||
to different port numbers. */
|
|
||||||
warning("ambiguous port %s in /etc/services",
|
|
||||||
name);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (udp_port >= 0) {
|
|
||||||
*port = udp_port;
|
|
||||||
*proto = IPPROTO_UDP;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#if defined(ultrix) || defined(__osf__)
|
|
||||||
/* Special hack in case NFS isn't in /etc/services */
|
|
||||||
if (strcmp(name, "nfs") == 0) {
|
|
||||||
*port = 2049;
|
|
||||||
*proto = PROTO_UNDEF;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Convert a string in the form PPP-PPP, where correspond to ports, to
|
|
||||||
* a starting and ending port in a port range.
|
|
||||||
* Return 0 on failure.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
pcap_nametoportrange(const char *name, int *port1, int *port2, int *proto)
|
|
||||||
{
|
|
||||||
u_int p1, p2;
|
|
||||||
char *off, *cpy;
|
|
||||||
int save_proto;
|
|
||||||
|
|
||||||
if (sscanf(name, "%d-%d", &p1, &p2) != 2) {
|
|
||||||
if ((cpy = strdup(name)) == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if ((off = strchr(cpy, '-')) == NULL) {
|
|
||||||
free(cpy);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
*off = '\0';
|
|
||||||
|
|
||||||
if (pcap_nametoport(cpy, port1, proto) == 0) {
|
|
||||||
free(cpy);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
save_proto = *proto;
|
|
||||||
|
|
||||||
if (pcap_nametoport(off + 1, port2, proto) == 0) {
|
|
||||||
free(cpy);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*proto != save_proto)
|
|
||||||
*proto = PROTO_UNDEF;
|
|
||||||
} else {
|
|
||||||
*port1 = p1;
|
|
||||||
*port2 = p2;
|
|
||||||
*proto = PROTO_UNDEF;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
pcap_nametoproto(const char *str)
|
|
||||||
{
|
|
||||||
struct protoent *p;
|
|
||||||
|
|
||||||
p = getprotobyname(str);
|
|
||||||
if (p != 0)
|
|
||||||
return p->p_proto;
|
|
||||||
else
|
|
||||||
return PROTO_UNDEF;
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "ethertype.h"
|
|
||||||
|
|
||||||
struct eproto {
|
|
||||||
char *s;
|
|
||||||
u_short p;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Static data base of ether protocol types. */
|
|
||||||
struct eproto eproto_db[] = {
|
|
||||||
{ "pup", ETHERTYPE_PUP },
|
|
||||||
{ "xns", ETHERTYPE_NS },
|
|
||||||
{ "ip", ETHERTYPE_IP },
|
|
||||||
#ifdef INET6
|
|
||||||
{ "ip6", ETHERTYPE_IPV6 },
|
|
||||||
#endif
|
|
||||||
{ "arp", ETHERTYPE_ARP },
|
|
||||||
{ "rarp", ETHERTYPE_REVARP },
|
|
||||||
{ "sprite", ETHERTYPE_SPRITE },
|
|
||||||
{ "mopdl", ETHERTYPE_MOPDL },
|
|
||||||
{ "moprc", ETHERTYPE_MOPRC },
|
|
||||||
{ "decnet", ETHERTYPE_DN },
|
|
||||||
{ "lat", ETHERTYPE_LAT },
|
|
||||||
{ "sca", ETHERTYPE_SCA },
|
|
||||||
{ "lanbridge", ETHERTYPE_LANBRIDGE },
|
|
||||||
{ "vexp", ETHERTYPE_VEXP },
|
|
||||||
{ "vprod", ETHERTYPE_VPROD },
|
|
||||||
{ "atalk", ETHERTYPE_ATALK },
|
|
||||||
{ "atalkarp", ETHERTYPE_AARP },
|
|
||||||
{ "loopback", ETHERTYPE_LOOPBACK },
|
|
||||||
{ "decdts", ETHERTYPE_DECDTS },
|
|
||||||
{ "decdns", ETHERTYPE_DECDNS },
|
|
||||||
{ (char *)0, 0 }
|
|
||||||
};
|
|
||||||
|
|
||||||
int
|
|
||||||
pcap_nametoeproto(const char *s)
|
|
||||||
{
|
|
||||||
struct eproto *p = eproto_db;
|
|
||||||
|
|
||||||
while (p->s != 0) {
|
|
||||||
if (strcmp(p->s, s) == 0)
|
|
||||||
return p->p;
|
|
||||||
p += 1;
|
|
||||||
}
|
|
||||||
return PROTO_UNDEF;
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "llc.h"
|
|
||||||
|
|
||||||
/* Static data base of LLC values. */
|
|
||||||
static struct eproto llc_db[] = {
|
|
||||||
{ "iso", LLCSAP_ISONS },
|
|
||||||
{ "stp", LLCSAP_8021D },
|
|
||||||
{ "ipx", LLCSAP_IPX },
|
|
||||||
{ "netbeui", LLCSAP_NETBEUI },
|
|
||||||
{ (char *)0, 0 }
|
|
||||||
};
|
|
||||||
|
|
||||||
int
|
|
||||||
pcap_nametollc(const char *s)
|
|
||||||
{
|
|
||||||
struct eproto *p = llc_db;
|
|
||||||
|
|
||||||
while (p->s != 0) {
|
|
||||||
if (strcmp(p->s, s) == 0)
|
|
||||||
return p->p;
|
|
||||||
p += 1;
|
|
||||||
}
|
|
||||||
return PROTO_UNDEF;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
__pcap_atoin(const char *s, bpf_u_int32 *addr)
|
|
||||||
{
|
|
||||||
u_int n;
|
|
||||||
int len;
|
|
||||||
|
|
||||||
*addr = 0;
|
|
||||||
len = 0;
|
|
||||||
while (1) {
|
|
||||||
n = 0;
|
|
||||||
while (*s && *s != '.')
|
|
||||||
n = n * 10 + *s++ - '0';
|
|
||||||
*addr <<= 8;
|
|
||||||
*addr |= n & 0xff;
|
|
||||||
len += 8;
|
|
||||||
if (*s == '\0')
|
|
||||||
return len;
|
|
||||||
++s;
|
|
||||||
}
|
|
||||||
/* NOTREACHED */
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
__pcap_atodn(const char *s, bpf_u_int32 *addr)
|
|
||||||
{
|
|
||||||
#define AREASHIFT 10
|
|
||||||
#define AREAMASK 0176000
|
|
||||||
#define NODEMASK 01777
|
|
||||||
|
|
||||||
u_int node, area;
|
|
||||||
|
|
||||||
if (sscanf((char *)s, "%d.%d", &area, &node) != 2)
|
|
||||||
bpf_error("malformed decnet address '%s'", s);
|
|
||||||
|
|
||||||
*addr = (area << AREASHIFT) & AREAMASK;
|
|
||||||
*addr |= (node & NODEMASK);
|
|
||||||
|
|
||||||
return(32);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Convert 's' which has the form "xx:xx:xx:xx:xx:xx" into a new
|
|
||||||
* ethernet address. Assumes 's' is well formed.
|
|
||||||
*/
|
|
||||||
u_char *
|
|
||||||
pcap_ether_aton(const char *s)
|
|
||||||
{
|
|
||||||
register u_char *ep, *e;
|
|
||||||
register u_int d;
|
|
||||||
|
|
||||||
e = ep = (u_char *)malloc(6);
|
|
||||||
|
|
||||||
while (*s) {
|
|
||||||
if (*s == ':')
|
|
||||||
s += 1;
|
|
||||||
d = xdtoi(*s++);
|
|
||||||
if (isxdigit((unsigned char)*s)) {
|
|
||||||
d <<= 4;
|
|
||||||
d |= xdtoi(*s++);
|
|
||||||
}
|
|
||||||
*ep++ = d;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (e);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef HAVE_ETHER_HOSTTON
|
|
||||||
/* Roll our own */
|
|
||||||
u_char *
|
|
||||||
pcap_ether_hostton(const char *name)
|
|
||||||
{
|
|
||||||
register struct pcap_etherent *ep;
|
|
||||||
register u_char *ap;
|
|
||||||
static FILE *fp = NULL;
|
|
||||||
static int init = 0;
|
|
||||||
|
|
||||||
if (!init) {
|
|
||||||
fp = fopen(PCAP_ETHERS_FILE, "r");
|
|
||||||
++init;
|
|
||||||
if (fp == NULL)
|
|
||||||
return (NULL);
|
|
||||||
} else if (fp == NULL)
|
|
||||||
return (NULL);
|
|
||||||
else
|
|
||||||
rewind(fp);
|
|
||||||
|
|
||||||
while ((ep = pcap_next_etherent(fp)) != NULL) {
|
|
||||||
if (strcmp(ep->name, name) == 0) {
|
|
||||||
ap = (u_char *)malloc(6);
|
|
||||||
if (ap != NULL) {
|
|
||||||
memcpy(ap, ep->addr, 6);
|
|
||||||
return (ap);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
|
|
||||||
#if !defined(HAVE_DECL_ETHER_HOSTTON) || !HAVE_DECL_ETHER_HOSTTON
|
|
||||||
#ifndef HAVE_STRUCT_ETHER_ADDR
|
|
||||||
struct ether_addr {
|
|
||||||
unsigned char ether_addr_octet[6];
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
extern int ether_hostton(const char *, struct ether_addr *);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Use the os supplied routines */
|
|
||||||
u_char *
|
|
||||||
pcap_ether_hostton(const char *name)
|
|
||||||
{
|
|
||||||
register u_char *ap;
|
|
||||||
u_char a[6];
|
|
||||||
|
|
||||||
ap = NULL;
|
|
||||||
if (ether_hostton((char *)name, (struct ether_addr *)a) == 0) {
|
|
||||||
ap = (u_char *)malloc(6);
|
|
||||||
if (ap != NULL)
|
|
||||||
memcpy((char *)ap, (char *)a, 6);
|
|
||||||
}
|
|
||||||
return (ap);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
u_short
|
|
||||||
__pcap_nametodnaddr(const char *name)
|
|
||||||
{
|
|
||||||
#ifdef DECNETLIB
|
|
||||||
struct nodeent *getnodebyname();
|
|
||||||
struct nodeent *nep;
|
|
||||||
unsigned short res;
|
|
||||||
|
|
||||||
nep = getnodebyname(name);
|
|
||||||
if (nep == ((struct nodeent *)0))
|
|
||||||
bpf_error("unknown decnet host name '%s'\n", name);
|
|
||||||
|
|
||||||
memcpy((char *)&res, (char *)nep->n_addr, sizeof(unsigned short));
|
|
||||||
return(res);
|
|
||||||
#else
|
|
||||||
bpf_error("decnet name support not included, '%s' cannot be translated\n",
|
|
||||||
name);
|
|
||||||
return(0);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user