create project
This commit is contained in:
234
CREDITS
Normal file
234
CREDITS
Normal file
@@ -0,0 +1,234 @@
|
||||
This file lists people who have contributed to tcpdump:
|
||||
|
||||
The current maintainers:
|
||||
Bill Fenner <fenner at research dot att dot com>
|
||||
Denis Ovsienko <denis at ovsienko dot info>
|
||||
Fulvio Risso <risso at polito dot it>
|
||||
Guy Harris <guy at alum dot mit dot edu>
|
||||
Hannes Gredler <hannes at juniper dot net>
|
||||
Michael Richardson <mcr at sandelman dot ottawa dot on dot ca>
|
||||
Francois-Xavier Le Bail <fx dot lebail at yahoo dot com>
|
||||
|
||||
Additional people who have contributed patches:
|
||||
|
||||
Aaron Campbell <aaron at arbor dot net>
|
||||
A Costa <agcosta at gis dot net>
|
||||
Albert Chin <china at thewrittenword dot com>
|
||||
Alexandra Kossovsky <alexandra1975 at sourceforge dot net>
|
||||
Alfredo Andres <aandres at s21sec dot com>
|
||||
Ananth Suryanarayana <anantha at juniper dot net>
|
||||
Andrea Bittau <a dot bittau at cs dot ucl dot ac dot uk>
|
||||
Andrew Brown <atatat at atatdot dot net>
|
||||
Andrew Church <andrew at users dot sourceforge dot net>
|
||||
Andrew Darqui <andrew dot darqui at gmail dot com>
|
||||
Andrew Hintz <adhintz at users dot sourceforge dot net>
|
||||
Andrew Nording <andrew at nording dot ru>
|
||||
Andrew Tridgell <tridge at linuxcare dot com>
|
||||
Andy Heffernan <ahh at juniper dot net>
|
||||
Anton Bernal <anton at juniper dot net>
|
||||
Antonin Décimo <antonin dot decimo at gmail dot com>
|
||||
Arkadiusz Miskiewicz <misiek at pld dot org dot pl>
|
||||
Armando L. Caro Jr. <acaro at mail dot eecis dot udel dot edu>
|
||||
Arnaldo Carvalho de Melo <acme at ghostprotocols dot net>
|
||||
Atsushi Onoe <onoe at netbsd dot org>
|
||||
Baptiste Jonglez <baptiste dot jonglez at ens-lyon dot org>
|
||||
Ben Byer <bushing at sourceforge dot net>
|
||||
Ben Smithurst <ben at scientia dot demon dot co dot uk>
|
||||
Bert Vermeulen <bert at biot dot com>
|
||||
Bill Parker <wp02855 at gmail dot com>
|
||||
Bjoern A. Zeeb <bzeeb at Zabbadoz dot NeT>
|
||||
Bram <tcpdump at mail dot wizbit dot be>
|
||||
Brent L. Bates <blbates at vigyan dot com>
|
||||
Brian Ginsbach <ginsbach at cray dot com>
|
||||
Bruce M. Simpson <bms at spc dot org>
|
||||
Carles Kishimoto Bisbe <ckishimo at ac dot upc dot es>
|
||||
Charles M. Hannum <mycroft at netbsd dot org>
|
||||
Charlie Lenahan <clenahan at fortresstech dot com>
|
||||
Chris Cogdon <chris at cogdon dot org>
|
||||
Chris G. Demetriou <cgd at netbsd dot org>
|
||||
Chris Jepeway <jepeway at blasted-heath dot com>
|
||||
Chris Larson <clarson at kergoth dot com>
|
||||
Christian Sievers <c_s at users dot sourceforge dot net>
|
||||
Christophe Rhodes <csr21 at cantab dot net>
|
||||
Cliff Frey <cliff at meraki dot com>
|
||||
Craig Rodrigues <rodrigc at mediaone dot net>
|
||||
Crist J. Clark <cjclark at alum dot mit dot edu>
|
||||
Daniel Hagerty <hag at ai dot mit dot edu>
|
||||
Darren Reed <darrenr at reed dot wattle dot id dot au>
|
||||
David Binderman <d dot binderman at virgin dot net>
|
||||
David Horn <dhorn2000 at gmail dot com>
|
||||
David Smith <dsmith at redhat dot com>
|
||||
David Young <dyoung at ojctech dot com>
|
||||
Dmitrij Tejblum <tejblum at yandex-team dot ru>
|
||||
Dmitry Eremin-Solenikov <dbaryshkov at gmail dot com>
|
||||
Don Ebright <Don dot Ebright at compuware dot com>
|
||||
Eddie Kohler <xexd at sourceforge dot net>
|
||||
Elmar Kirchner <elmar at juniper dot net>
|
||||
Fang Wang <fangwang at sourceforge dot net>
|
||||
Florent Drouin <Florent dot Drouin at alcatel-lucent dot fr>
|
||||
Florian Forster <octo at verplant dot org>
|
||||
fra <foo at bar dot baz>
|
||||
Francesco Fondelli <francesco dot fondelli at gmail dot com>
|
||||
Francisco Matias Cuenca-Acuna <mcuenca at george dot rutgers dot edu>
|
||||
Francis Dupont <Francis dot Dupont at enst-bretagne dot fr>
|
||||
Frank Volf <volf at oasis dot IAEhv dot nl>
|
||||
Fulvio Risso <risso at polito dot it>
|
||||
George Bakos <gbakos at ists dot dartmouth dot edu>
|
||||
Gerald Combs <gerald at ethereal dot com>
|
||||
Gerrit Renker <gerrit at erg dot abdn dot ac dot uk>
|
||||
Gert Doering <gert at greenie dot muc dot de>
|
||||
Gilbert Ramirez Jr. <gram at xiexie dot org>
|
||||
Gisle Vanem <gvanem at yahoo dot no>
|
||||
Greg Minshall <minshall at acm dot org>
|
||||
Grégoire Henry <henry at pps dot jussieu dot fr>
|
||||
Gregory Detal <gregory dot detal at uclouvain dot be>
|
||||
Greg Stark <gsstark at mit dot edu>
|
||||
Hank Leininger <tcpdump-workers at progressive-comp dot com>
|
||||
Hannes Viertel <hviertel at juniper dot net>
|
||||
Harry Raaymakers <harryr at connect dot com dot au>
|
||||
Heinz-Ado Arnolds <Ado dot Arnolds at dhm-systems dot de>
|
||||
Hendrik Scholz <hendrik at scholz dot net>
|
||||
Herwin Weststrate <herwin at quarantainenet dot nl>
|
||||
Ian McDonald <imcdnzl at gmail dot com>
|
||||
Ilpo Järvinen <ilpo dot jarvinen at helsinki dot fi>
|
||||
Jacek Tobiasz <Jacek dot Tobiasz at atm dot com dot pl>
|
||||
Jakob Schlyter <jakob at openbsd dot org>
|
||||
Jamal Hadi Salim <hadi at cyberus dot ca>
|
||||
Jan Oravec <wsx at wsx6 dot net>
|
||||
Jason R. Thorpe <thorpej at netbsd dot org>
|
||||
Jefferson Ogata <jogata at nodc dot noaa dot gov>
|
||||
Jeffrey Hutzelman <jhutz at cmu dot edu>
|
||||
Jean-Raphaël Gaglione <jr dot gaglione at yahoo dot fr>
|
||||
Jesper Peterson <jesper at endace dot com>
|
||||
Jesse Gross <jesse at nicira dot com>
|
||||
Jim Hutchins <jim at ca dot sandia dot gov>
|
||||
João Medeiros <ignotus21 at sourceforge dot net>
|
||||
Joerg Mayer <jmayer at loplof dot de>
|
||||
Jonathan Heusser <jonny at drugphish dot ch>
|
||||
Jorge Boncompte [DTI2] <jorge at dti2 dot net>
|
||||
Jørgen Thomsen <jth at jth dot net>
|
||||
Julian Cowley <julian at lava dot net>
|
||||
Juliusz Chroboczek <jch at pps dot jussieu dot fr>
|
||||
Kaarthik Sivakumar <kaarthik at torrentnet dot com>
|
||||
Kaladhar Musunuru <kaladharm at sourceforge dot net>
|
||||
Karl Norby <karl-norby at sourceforge dot net>
|
||||
Kazushi Sugyo <sugyo at pb dot jp dot nec dot com>
|
||||
Kelly Carmichael <kcarmich at ipapp dot com>
|
||||
Ken Hornstein <kenh at cmf dot nrl dot navy dot mil>
|
||||
Kenichi Maehashi <webmaster at kenichimaehashi dot com>
|
||||
Kevin Steves <stevesk at pobox dot com>
|
||||
Klaus Klein <kleink at reziprozitaet dot de>
|
||||
Kris Kennaway <kris at freebsd dot org>
|
||||
Krzysztof Halasa <khc at pm dot waw dot pl>
|
||||
Larry Lile <lile at stdio dot com>
|
||||
Lennert Buytenhek <buytenh at gnu dot org>
|
||||
Loganaden Velvindron <logan at elandsys dot com>
|
||||
Longinus00 <Longinus00 at gmail dot com>
|
||||
Loris Degioanni <loris at netgroup-serv dot polito dot it>
|
||||
Love Hörnquist-Åstrand <lha at stacken dot kth dot se>
|
||||
Lucas C. Villa Real <lucasvr at us dot ibm dot com>
|
||||
Luis MartinGarcia <luis dot mgarc at gmail dot com>
|
||||
Maciej W. Rozycki <macro at ds2 dot pg dot gda dot pl>
|
||||
Manu Pathak <mapathak at cisco dot com>
|
||||
Marc Abramowitz <marc at marc-abramowitz dot com>
|
||||
Marc A. Lehmann <pcg at goof dot com>
|
||||
Marc Binderberger <mbind at sourceforge dot net>
|
||||
Mark Ellzey Thomas <mark at ackers dot net>
|
||||
Marko Kiiskila <carnil at cs dot tut dot fi>
|
||||
Markus Schöpflin <schoepflin at sourceforge dot net>
|
||||
Marshall Rose <mrose at dbc dot mtview dot ca dot us>
|
||||
Martin Husemann <martin at netbsd dot org>
|
||||
Matthieu Boutier <boutier at pps dot univ-paris-diderot dot fr>
|
||||
Max Laier <max at love2party dot net>
|
||||
Michael A. Meffie III <meffie at sourceforge dot net>
|
||||
Michael Madore <mmadore at turbolinux dot com>
|
||||
Michael Riepe <too-tired at sourceforge dot net>
|
||||
Michael Shalayeff <mickey at openbsd dot org>
|
||||
Michael Shields <shields at msrl dot com>
|
||||
Michael T. Stolarchuk <mts at off dot to>
|
||||
Michal Sekletar <msekleta at redhat dot com>
|
||||
Michele "mydecay" Marchetto <smarchetto1 at tin dot it>
|
||||
Mike Frysinger <vapier at gmail dot com>
|
||||
Minto Jeyananth <minto at juniper dot net>
|
||||
Monroe Williams <monroe at pobox dot com>
|
||||
Motonori Shindo <mshindo at mshindo dot net>
|
||||
Nathaniel Couper-Noles <Nathaniel at isi1 dot tccisi dot com>
|
||||
Nathan J. Williams <nathanw at MIT dot EDU>
|
||||
Neil T. Spring <bluehal at users dot sourceforge dot net>
|
||||
Nickolai Zeldovich <kolya at MIT dot EDU>
|
||||
Nicolas Ferrero <toorop at babylo dot net>
|
||||
Niels Provos <provos at openbsd dot org>
|
||||
Noritoshi Demizu <demizu at users dot sourceforge dot net>
|
||||
Olaf Kirch <okir at caldera dot de>
|
||||
Ola Martin Lykkja <ola dot lykkja at q-free dot com>
|
||||
Oleksij Rempel <linux at rempel-privat dot de>
|
||||
Onno van der Linden <onno at simplex dot nl>
|
||||
Paolo Abeni <paolo dot abeni at email dot it>
|
||||
Pascal Hennequin <pascal dot hennequin at int-evry dot fr>
|
||||
Pasvorn Boonmark <boonmark at juniper dot net>
|
||||
Paul Ferrell <pflarr at sourceforge dot net>
|
||||
Paul Mundt <lethal at linux-sh dot org>
|
||||
Paul S. Traina <pst at freebsd dot org>
|
||||
Pavlin Radoslavov <pavlin at icir dot org>
|
||||
Pawel Worach <pawel dot worach at gmail dot com>
|
||||
Pekka Savola <pekkas at netcore dot fi>
|
||||
Petar Alilovic <petar dot alilovic at gmail dot com>
|
||||
Peter Fales <peter at fales-lorenz dot net>
|
||||
Peter Jeremy <peter dot jeremy at alcatel dot com dot au>
|
||||
Peter Volkov <pva at gentoo dot org>
|
||||
<pfhunt at users dot sourceforge dot net>
|
||||
Phil Wood <cpw at lanl dot gov>
|
||||
Rafal Maszkowski <rzm at icm dot edu dot pl>
|
||||
Randy Sofia <rsofia at users dot sourceforge dot net>
|
||||
Raphael Raimbault <raphael dot raimbault at netasq dot com>
|
||||
Rick Cheng <rcheng at juniper dot net>
|
||||
Rick Jones <rick dot jones2 at hp dot com>
|
||||
Rick Watson <watsonrick at users dot sourceforge dot net>
|
||||
Rob Braun <bbraun at synack dot net>
|
||||
Robert Edmonds <stu-42 at sourceforge dot net>
|
||||
Roderick Schertler <roderick at argon dot org>
|
||||
Romain Francoise <rfrancoise at debian dot org>
|
||||
Ruben Kerkhof <ruben at rubenkerkhof dot com>
|
||||
Sagun Shakya <sagun dot shakya at sun dot com>
|
||||
Sami Farin <safari at iki dot fi>
|
||||
Scott Mcmillan <scott dot a dot mcmillan at intel dot com>
|
||||
Scott Rose <syberpunk at users dot sourceforge dot net>
|
||||
Sebastian Krahmer <krahmer at cs dot uni-potsdam dot de>
|
||||
Sebastien Raveau <sebastien dot raveau at epita dot fr>
|
||||
Sebastien Vincent <svincent at idems dot fr>
|
||||
Sepherosa Ziehau <sepherosa at gmail dot com>
|
||||
Seth Webster <swebster at sst dot ll dot mit dot edu>
|
||||
Shinsuke Suzuki <suz at kame dot net>
|
||||
Simon Ruderich <simon at ruderich dot org>
|
||||
Steinar Haug <sthaug at nethelp dot no>
|
||||
Stephane Bortzmeyer <stephane+github at bortzmeyer dot org>
|
||||
Swaminathan Chandrasekaran <chander at juniper dot net>
|
||||
Swaathi Vetrivel <swaathiv at juniper dot net>
|
||||
Takashi Yamamoto <yamt at mwd dot biglobe dot ne dot jp>
|
||||
Tatuya Jinmei <jinmei at kame dot net>
|
||||
Terry Kennedy <terry at tmk dot com>
|
||||
Thomas Jacob <jacob at internet24 dot de>
|
||||
Timo Koskiahde
|
||||
Tony Li <tli at procket dot com>
|
||||
Toshihiro Kanda <candy at fct dot kgc dot co dot jp>
|
||||
Udayakumar <udaya011 at gmail dot com>
|
||||
Uns Lider <unslider at miranda dot org>
|
||||
Victor Oppleman <oppleman at users dot sourceforge dot net>
|
||||
Vyacheslav Trushkin <dogonthesun at gmail dot com>
|
||||
Weesan Lee <weesan at juniper dot net>
|
||||
Wesley Griffin <wgriffin at users dot sourceforge dot net>
|
||||
Wesley Shields <wxs at FreeBSD dot org>
|
||||
Wilbert de Graaf <wilbertdg at hetnet dot nl>
|
||||
Will Drewry <will at alum dot bu dot edu>
|
||||
William J. Hulley <bill dot hulley at gmail dot com>
|
||||
Wim Torfs <wtorfs at gmail dot com>
|
||||
Yen Yen Lim
|
||||
Yoshifumi Nishida
|
||||
|
||||
The original LBL crew:
|
||||
Steve McCanne
|
||||
Craig Leres
|
||||
Van Jacobson
|
||||
|
||||
Past maintainers:
|
||||
Jun-ichiro itojun Hagino <itojun at iijlab dot net> Also see: http://www.wide.ad.jp/itojun-award/
|
||||
214
INSTALL.txt
Normal file
214
INSTALL.txt
Normal file
@@ -0,0 +1,214 @@
|
||||
If you have not built libpcap, and your system does not have libpcap
|
||||
installed, install libpcap first. Your system might provide a version
|
||||
of libpcap that can be installed; if so, to compile tcpdump you might
|
||||
need to install a "developer" version of libpcap as well as the
|
||||
"run-time" version. You can also install tcpdump.org's version of
|
||||
libpcap; see the README file in this directory for the ftp location.
|
||||
|
||||
You will need an ANSI C compiler to build tcpdump. The configure script
|
||||
will abort if your compiler is not ANSI compliant. If this happens, use
|
||||
the generally available GNU C compiler (GCC).
|
||||
|
||||
After libpcap has been built (either install it with "make install" or
|
||||
make sure both the libpcap and tcpdump source trees are in the same
|
||||
directory), run ./configure (a shell script). "configure" will
|
||||
determine your system attributes and generate an appropriate Makefile
|
||||
from Makefile.in. Now build tcpdump by running "make".
|
||||
|
||||
If everything builds ok, su and type "make install". This will install
|
||||
tcpdump and the manual entry. Any user will be able to use tcpdump to
|
||||
read saved captures. Whether a user will be able to capture traffic
|
||||
depends on the OS and the configuration of the system; see the tcpdump
|
||||
man page for details. DO NOT give untrusted users the ability to
|
||||
capture traffic. If a user can capture traffic, he or she could use
|
||||
utilities such as tcpdump to capture any traffic on your net, including
|
||||
passwords.
|
||||
|
||||
Note that most systems ship tcpdump, but usually an older version.
|
||||
Remember to remove or rename the installed binary when upgrading.
|
||||
|
||||
If your system is not one which we have tested tcpdump on, you may have
|
||||
to modify the configure script and Makefile.in. Please send us patches
|
||||
for any modifications you need to make.
|
||||
|
||||
Please see "PLATFORMS" for notes about tested platforms.
|
||||
|
||||
|
||||
FILES
|
||||
-----
|
||||
CHANGES - description of differences between releases
|
||||
CREDITS - people that have helped tcpdump along
|
||||
INSTALL.txt - this file
|
||||
LICENSE - the license under which tcpdump is distributed
|
||||
Makefile.in - compilation rules (input to the configure script)
|
||||
README - description of distribution
|
||||
Readme.Win32 - notes on building tcpdump on Win32 systems (with WinPcap)
|
||||
VERSION - version of this release
|
||||
aclocal.m4 - autoconf macros
|
||||
addrtoname.c - address to hostname routines
|
||||
addrtoname.h - address to hostname definitions
|
||||
ah.h - IPSEC Authentication Header definitions
|
||||
appletalk.h - AppleTalk definitions
|
||||
ascii_strcasecmp.c - locale-independent case-independent string comparison
|
||||
routines
|
||||
atime.awk - TCP ack awk script
|
||||
atm.h - ATM traffic type definitions
|
||||
bpf_dump.c - BPF program printing routines, in case libpcap doesn't
|
||||
have them
|
||||
chdlc.h - Cisco HDLC definitions
|
||||
cpack.c - functions to extract packed data
|
||||
cpack.h - declarations of functions to extract packed data
|
||||
config.guess - autoconf support
|
||||
config.h.in - autoconf input
|
||||
config.sub - autoconf support
|
||||
configure - configure script (run this first)
|
||||
configure.in - configure script source
|
||||
ether.h - Ethernet definitions
|
||||
ethertype.h - Ethernet type value definitions
|
||||
extract.h - alignment definitions
|
||||
gmpls.c - GMPLS definitions
|
||||
gmpls.h - GMPLS declarations
|
||||
gmt2local.c - time conversion routines
|
||||
gmt2local.h - time conversion prototypes
|
||||
install-sh - BSD style install script
|
||||
interface.h - globals, prototypes and definitions
|
||||
ip.h - IP definitions
|
||||
ip6.h - IPv6 definitions
|
||||
ipproto.c - IP protocol type value-to-name table
|
||||
ipproto.h - IP protocol type value definitions
|
||||
l2vpn.c - L2VPN encapsulation value-to-name table
|
||||
l2vpn.h - L2VPN encapsulation definitions
|
||||
lbl/os-*.h - OS-dependent defines and prototypes
|
||||
llc.h - LLC definitions
|
||||
machdep.c - machine dependent routines
|
||||
machdep.h - machine dependent definitions
|
||||
makemib - mib to header script
|
||||
mib.h - mib definitions
|
||||
missing/* - replacements for missing library functions
|
||||
mkdep - construct Makefile dependency list
|
||||
mpls.h - MPLS definitions
|
||||
nameser.h - DNS definitions
|
||||
netdissect.h - definitions and declarations for tcpdump-as-library
|
||||
(under development)
|
||||
nfs.h - Network File System V2 definitions
|
||||
nfsfh.h - Network File System file handle definitions
|
||||
nlpid.c - OSI NLPID value-to-name table
|
||||
nlpid.h - OSI NLPID definitions
|
||||
ospf.h - Open Shortest Path First definitions
|
||||
packetdat.awk - TCP chunk summary awk script
|
||||
parsenfsfh.c - Network File System file parser routines
|
||||
pcap_dump_ftell.c - pcap_dump_ftell() implementation, in case libpcap
|
||||
doesn't have it
|
||||
pcap-missing.h - declarations of functions possibly missing from libpcap
|
||||
ppp.h - Point to Point Protocol definitions
|
||||
print-802_11.c - IEEE 802.11 printer routines
|
||||
print-ap1394.c - Apple IP-over-IEEE 1394 printer routines
|
||||
print-ah.c - IPSEC Authentication Header printer routines
|
||||
print-aodv.c - AODV printer routines
|
||||
print-arcnet.c - ARCNET printer routines
|
||||
print-arp.c - Address Resolution Protocol printer routines
|
||||
print-ascii.c - ASCII packet dump routines
|
||||
print-atalk.c - AppleTalk printer routines
|
||||
print-atm.c - ATM printer routines
|
||||
print-beep.c - BEEP printer routines
|
||||
print-bgp.c - Border Gateway Protocol printer routines
|
||||
print-bootp.c - BOOTP and IPv4 DHCP printer routines
|
||||
print-bt.c - Bluetooth printer routines
|
||||
print-cdp.c - Cisco Discovery Protocol printer routines
|
||||
print-chdlc.c - Cisco HDLC printer routines
|
||||
print-cip.c - Classical-IP over ATM routines
|
||||
print-cnfp.c - Cisco NetFlow printer routines
|
||||
print-dccp.c - DCCP printer routines
|
||||
print-decnet.c - DECnet printer routines
|
||||
print-dhcp6.c - IPv6 DHCP printer routines
|
||||
print-domain.c - Domain Name System printer routines
|
||||
print-dvmrp.c - Distance Vector Multicast Routing Protocol printer routines
|
||||
print-eap.c - EAP printer routines
|
||||
print-enc.c - OpenBSD IPsec encapsulation BPF layer printer routines
|
||||
print-egp.c - External Gateway Protocol printer routines
|
||||
print-esp.c - IPSEC Encapsulating Security Payload printer routines
|
||||
print-ether.c - Ethernet printer routines
|
||||
print-fddi.c - Fiber Distributed Data Interface printer routines
|
||||
print-fr.c - Frame Relay printer routines
|
||||
print-frag6.c - IPv6 fragmentation header printer routines
|
||||
print-gre.c - Generic Routing Encapsulation printer routines
|
||||
print-hsrp.c - Cisco Hot Standby Router Protocol printer routines
|
||||
print-icmp.c - Internet Control Message Protocol printer routines
|
||||
print-icmp6.c - IPv6 Internet Control Message Protocol printer routines
|
||||
print-igmp.c - Internet Group Management Protocol printer routines
|
||||
print-igrp.c - Interior Gateway Routing Protocol printer routines
|
||||
print-ip.c - IP printer routines
|
||||
print-ip6.c - IPv6 printer routines
|
||||
print-ip6opts.c - IPv6 header option printer routines
|
||||
print-ipcomp.c - IP Payload Compression Protocol printer routines
|
||||
print-ipx.c - IPX printer routines
|
||||
print-isakmp.c - Internet Security Association and Key Management Protocol
|
||||
print-isoclns.c - ISO CLNS, ESIS, and ISIS printer routines
|
||||
print-krb.c - Kerberos printer routines
|
||||
print-l2tp.c - Layer Two Tunneling Protocol printer routines
|
||||
print-lane.c - ATM LANE printer routines
|
||||
print-llc.c - IEEE 802.2 LLC printer routines
|
||||
print-lspping.c - LSPPING printer routines
|
||||
print-lwres.c - Lightweight Resolver protocol printer routines
|
||||
print-mobile.c - IPv4 mobility printer routines
|
||||
print-mobility.c - IPv6 mobility printer routines
|
||||
print-mpls.c - Multi-Protocol Label Switching printer routines
|
||||
print-msdp.c - Multicast Source Discovery Protocol printer routines
|
||||
print-nfs.c - Network File System printer routines
|
||||
print-ntp.c - Network Time Protocol printer routines
|
||||
print-null.c - BSD loopback device printer routines
|
||||
print-ospf.c - Open Shortest Path First printer routines
|
||||
print-ospf6.c - IPv6 Open Shortest Path First printer routines
|
||||
print-pflog.c - OpenBSD packet filter log file printer routines
|
||||
print-pgm.c - Pragmatic General Multicast printer routines
|
||||
print-pim.c - Protocol Independent Multicast printer routines
|
||||
print-ppp.c - Point to Point Protocol printer routines
|
||||
print-pppoe.c - PPP-over-Ethernet printer routines
|
||||
print-pptp.c - Point-to-Point Tunnelling Protocol printer routines
|
||||
print-radius.c - Radius protocol printer routines
|
||||
print-raw.c - Raw IP printer routines
|
||||
print-rip.c - Routing Information Protocol printer routines
|
||||
print-ripng.c - IPv6 Routing Information Protocol printer routines
|
||||
print-rrcp.c - Realtek Remote Control Protocol routines
|
||||
print-rsvp.c - Resource reSerVation Protocol (RSVP) printer routines
|
||||
print-rt6.c - IPv6 routing header printer routines
|
||||
print-rx.c - AFS RX printer routines
|
||||
print-sctp.c - Stream Control Transmission Protocol printer routines
|
||||
print-sip.c - SIP printer routines
|
||||
print-sl.c - Compressed Serial Line Internet Protocol printer routines
|
||||
print-sll.c - Linux "cooked" capture printer routines
|
||||
print-slow.c - IEEE "slow protocol" (802.3ad) printer routines
|
||||
print-smb.c - SMB/CIFS printer routines
|
||||
print-snmp.c - Simple Network Management Protocol printer routines
|
||||
print-stp.c - IEEE 802.1d spanning tree protocol printer routines
|
||||
print-sunatm.c - SunATM DLPI capture printer routines
|
||||
print-sunrpc.c - Sun Remote Procedure Call printer routines
|
||||
print-symantec.c - Symantec Enterprise Firewall printer routines
|
||||
print-tcp.c - TCP printer routines
|
||||
print-telnet.c - Telnet option printer routines
|
||||
print-tftp.c - Trivial File Transfer Protocol printer routines
|
||||
print-timed.c - BSD time daemon protocol printer routines
|
||||
print-token.c - Token Ring printer routines
|
||||
print-udp.c - UDP printer routines
|
||||
print-usb.c - USB printer routines
|
||||
print-vjc.c - PPP Van Jacobson compression (RFC1144) printer routines
|
||||
print-vrrp.c - Virtual Router Redundancy Protocol
|
||||
print-wb.c - White Board printer routines
|
||||
print-zephyr.c - Zephyr printer routines
|
||||
rpc_auth.h - definitions for ONC RPC authentication
|
||||
rpc_msg.h - definitions for ONC RPC messages
|
||||
send-ack.awk - unidirectional tcp send/ack awk script
|
||||
setsignal.c - OS-independent signal routines
|
||||
setsignal.h - OS-independent signal prototypes
|
||||
slcompress.h - SLIP/PPP Van Jacobson compression (RFC1144) definitions
|
||||
smb.h - SMB/CIFS definitions
|
||||
smbutil.c - SMB/CIFS utility routines
|
||||
stime.awk - TCP send awk script
|
||||
tcp.h - TCP definitions
|
||||
tcpdump.1 - manual entry
|
||||
tcpdump.c - main program
|
||||
timeval-operations.h - timeval operations macros
|
||||
udp.h - UDP definitions
|
||||
util.c - utility routines
|
||||
vfprintf.c - emulation routine
|
||||
win32 - headers and routines for building on Win32 systems
|
||||
19
LICENSE
Normal file
19
LICENSE
Normal file
@@ -0,0 +1,19 @@
|
||||
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.
|
||||
22
Makefile-devel-adds
Normal file
22
Makefile-devel-adds
Normal file
@@ -0,0 +1,22 @@
|
||||
#
|
||||
# Auto-regenerate configure script or Makefile when things change.
|
||||
# From autoconf.info . Works best with GNU Make.
|
||||
#
|
||||
${srcdir}/configure: configure.in aclocal.m4
|
||||
cd ${srcdir} && autoconf
|
||||
|
||||
# autoheader might not change config.h.in, so touch a stamp file.
|
||||
${srcdir}/config.h.in: ${srcdir}/stamp-h.in
|
||||
${srcdir}/stamp-h.in: configure.in aclocal.m4
|
||||
cd ${srcdir} && autoheader
|
||||
echo timestamp > ${srcdir}/stamp-h.in
|
||||
|
||||
config.h: stamp-h
|
||||
stamp-h: ${srcdir}/config.h.in config.status
|
||||
./config.status
|
||||
|
||||
Makefile: Makefile.in config.status
|
||||
./config.status
|
||||
|
||||
config.status: ${srcdir}/configure
|
||||
./config.status --recheck
|
||||
453
Makefile.in
Normal file
453
Makefile.in
Normal file
@@ -0,0 +1,453 @@
|
||||
# Copyright (c) 1988, 1989, 1990, 1991, 1992, 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.
|
||||
|
||||
#
|
||||
# Various configurable paths (remember to edit Makefile.in, not Makefile)
|
||||
#
|
||||
|
||||
# Top level hierarchy
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
datarootdir = @datarootdir@
|
||||
# Pathname of directory to install the binary
|
||||
sbindir = @sbindir@
|
||||
# Pathname of directory to install the man page
|
||||
mandir = @mandir@
|
||||
|
||||
# VPATH
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
#
|
||||
# You shouldn't need to edit anything below here.
|
||||
#
|
||||
|
||||
CC = @CC@
|
||||
AR = @AR@
|
||||
MKDEP = @MKDEP@
|
||||
PROG = tcpdump
|
||||
CCOPT = @V_CCOPT@
|
||||
INCLS = -I. @V_INCLS@
|
||||
DEFS = @DEFS@ @CPPFLAGS@ @V_DEFS@
|
||||
|
||||
# Standard CFLAGS
|
||||
CFLAGS = @CFLAGS@
|
||||
FULL_CFLAGS = $(CCOPT) $(DEFS) $(INCLS) $(CFLAGS)
|
||||
|
||||
# Standard LDFLAGS
|
||||
LDFLAGS = @LDFLAGS@
|
||||
|
||||
# Standard LIBS
|
||||
LIBS = @LIBS@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
RANLIB = @RANLIB@
|
||||
|
||||
DEPENDENCY_CFLAG = @DEPENDENCY_CFLAG@
|
||||
|
||||
# Explicitly define compilation rule since SunOS 4's make doesn't like gcc.
|
||||
# Also, gcc does not remove the .o before forking 'as', which can be a
|
||||
# problem if you don't own the file but can write to the directory.
|
||||
.c.o:
|
||||
@rm -f $@
|
||||
$(CC) $(FULL_CFLAGS) -c $(srcdir)/$*.c
|
||||
|
||||
CSRC = setsignal.c tcpdump.c util.c
|
||||
|
||||
LIBNETDISSECT_SRC=\
|
||||
addrtoname.c \
|
||||
addrtostr.c \
|
||||
af.c \
|
||||
ascii_strcasecmp.c \
|
||||
checksum.c \
|
||||
cpack.c \
|
||||
gmpls.c \
|
||||
gmt2local.c \
|
||||
in_cksum.c \
|
||||
ipproto.c \
|
||||
l2vpn.c \
|
||||
machdep.c \
|
||||
nlpid.c \
|
||||
oui.c \
|
||||
parsenfsfh.c \
|
||||
print.c \
|
||||
print-802_11.c \
|
||||
print-802_15_4.c \
|
||||
print-ah.c \
|
||||
print-ahcp.c \
|
||||
print-aodv.c \
|
||||
print-aoe.c \
|
||||
print-ap1394.c \
|
||||
print-arcnet.c \
|
||||
print-arp.c \
|
||||
print-ascii.c \
|
||||
print-atalk.c \
|
||||
print-atm.c \
|
||||
print-babel.c \
|
||||
print-beep.c \
|
||||
print-bfd.c \
|
||||
print-bgp.c \
|
||||
print-bootp.c \
|
||||
print-bt.c \
|
||||
print-calm-fast.c \
|
||||
print-carp.c \
|
||||
print-cdp.c \
|
||||
print-cfm.c \
|
||||
print-chdlc.c \
|
||||
print-cip.c \
|
||||
print-cnfp.c \
|
||||
print-dccp.c \
|
||||
print-decnet.c \
|
||||
print-dhcp6.c \
|
||||
print-domain.c \
|
||||
print-dtp.c \
|
||||
print-dvmrp.c \
|
||||
print-eap.c \
|
||||
print-egp.c \
|
||||
print-eigrp.c \
|
||||
print-enc.c \
|
||||
print-esp.c \
|
||||
print-ether.c \
|
||||
print-fddi.c \
|
||||
print-forces.c \
|
||||
print-fr.c \
|
||||
print-frag6.c \
|
||||
print-ftp.c \
|
||||
print-geneve.c \
|
||||
print-geonet.c \
|
||||
print-gre.c \
|
||||
print-hncp.c \
|
||||
print-hsrp.c \
|
||||
print-http.c \
|
||||
print-icmp.c \
|
||||
print-icmp6.c \
|
||||
print-igmp.c \
|
||||
print-igrp.c \
|
||||
print-ip.c \
|
||||
print-ip6.c \
|
||||
print-ip6opts.c \
|
||||
print-ipcomp.c \
|
||||
print-ipfc.c \
|
||||
print-ipnet.c \
|
||||
print-ipx.c \
|
||||
print-isakmp.c \
|
||||
print-isoclns.c \
|
||||
print-juniper.c \
|
||||
print-krb.c \
|
||||
print-l2tp.c \
|
||||
print-lane.c \
|
||||
print-ldp.c \
|
||||
print-lisp.c \
|
||||
print-llc.c \
|
||||
print-lldp.c \
|
||||
print-lmp.c \
|
||||
print-loopback.c \
|
||||
print-lspping.c \
|
||||
print-lwapp.c \
|
||||
print-lwres.c \
|
||||
print-m3ua.c \
|
||||
print-medsa.c \
|
||||
print-mobile.c \
|
||||
print-mobility.c \
|
||||
print-mpcp.c \
|
||||
print-mpls.c \
|
||||
print-mptcp.c \
|
||||
print-msdp.c \
|
||||
print-msnlb.c \
|
||||
print-nflog.c \
|
||||
print-nfs.c \
|
||||
print-nsh.c \
|
||||
print-ntp.c \
|
||||
print-null.c \
|
||||
print-olsr.c \
|
||||
print-openflow-1.0.c \
|
||||
print-openflow.c \
|
||||
print-ospf.c \
|
||||
print-ospf6.c \
|
||||
print-otv.c \
|
||||
print-pgm.c \
|
||||
print-pim.c \
|
||||
print-pktap.c \
|
||||
print-ppi.c \
|
||||
print-ppp.c \
|
||||
print-pppoe.c \
|
||||
print-pptp.c \
|
||||
print-radius.c \
|
||||
print-raw.c \
|
||||
print-resp.c \
|
||||
print-rip.c \
|
||||
print-ripng.c \
|
||||
print-rpki-rtr.c \
|
||||
print-rrcp.c \
|
||||
print-rsvp.c \
|
||||
print-rt6.c \
|
||||
print-rtsp.c \
|
||||
print-rx.c \
|
||||
print-sctp.c \
|
||||
print-sflow.c \
|
||||
print-sip.c \
|
||||
print-sl.c \
|
||||
print-sll.c \
|
||||
print-slow.c \
|
||||
print-smtp.c \
|
||||
print-snmp.c \
|
||||
print-stp.c \
|
||||
print-sunatm.c \
|
||||
print-sunrpc.c \
|
||||
print-symantec.c \
|
||||
print-syslog.c \
|
||||
print-tcp.c \
|
||||
print-telnet.c \
|
||||
print-tftp.c \
|
||||
print-timed.c \
|
||||
print-tipc.c \
|
||||
print-token.c \
|
||||
print-udld.c \
|
||||
print-udp.c \
|
||||
print-usb.c \
|
||||
print-vjc.c \
|
||||
print-vqp.c \
|
||||
print-vrrp.c \
|
||||
print-vtp.c \
|
||||
print-vxlan.c \
|
||||
print-vxlan-gpe.c \
|
||||
print-wb.c \
|
||||
print-zephyr.c \
|
||||
print-zeromq.c \
|
||||
signature.c \
|
||||
strtoaddr.c \
|
||||
util-print.c
|
||||
|
||||
LOCALSRC = @LOCALSRC@
|
||||
GENSRC = version.c
|
||||
LIBOBJS = @LIBOBJS@
|
||||
|
||||
LIBNETDISSECT_OBJ=$(LIBNETDISSECT_SRC:.c=.o) ${LOCALSRC:.c=.o} ${LIBOBJS}
|
||||
LIBNETDISSECT=libnetdissect.a
|
||||
|
||||
|
||||
SRC = $(CSRC) $(GENSRC) $(LOCALSRC) $(LIBNETDISSECT_SRC)
|
||||
|
||||
# We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot
|
||||
# hack the extra indirection
|
||||
OBJ = $(CSRC:.c=.o) $(GENSRC:.c=.o) $(LIBNETDISSECT_OBJ)
|
||||
HDR = \
|
||||
addrtoname.h \
|
||||
addrtostr.h \
|
||||
af.h \
|
||||
ah.h \
|
||||
appletalk.h \
|
||||
ascii_strcasecmp.h \
|
||||
atm.h \
|
||||
chdlc.h \
|
||||
cpack.h \
|
||||
ether.h \
|
||||
ethertype.h \
|
||||
extract.h \
|
||||
getopt_long.h \
|
||||
gmpls.h \
|
||||
gmt2local.h \
|
||||
interface.h \
|
||||
ip.h \
|
||||
ip6.h \
|
||||
ipproto.h \
|
||||
l2vpn.h \
|
||||
llc.h \
|
||||
machdep.h \
|
||||
mib.h \
|
||||
mpls.h \
|
||||
nameser.h \
|
||||
netdissect.h \
|
||||
nfs.h \
|
||||
nfsfh.h \
|
||||
nlpid.h \
|
||||
openflow.h \
|
||||
ospf.h \
|
||||
oui.h \
|
||||
pcap-missing.h \
|
||||
ppp.h \
|
||||
print.h \
|
||||
rpc_auth.h \
|
||||
rpc_msg.h \
|
||||
rpl.h \
|
||||
setsignal.h \
|
||||
signature.h \
|
||||
slcompress.h \
|
||||
smb.h \
|
||||
strtoaddr.h \
|
||||
tcp.h \
|
||||
netdissect-stdinc.h \
|
||||
timeval-operations.h \
|
||||
udp.h
|
||||
|
||||
TAGHDR = \
|
||||
/usr/include/arpa/tftp.h \
|
||||
/usr/include/net/if_arp.h \
|
||||
/usr/include/net/slip.h \
|
||||
/usr/include/netinet/if_ether.h \
|
||||
/usr/include/netinet/in.h \
|
||||
/usr/include/netinet/ip_icmp.h \
|
||||
/usr/include/netinet/tcp.h \
|
||||
/usr/include/netinet/udp.h \
|
||||
/usr/include/protocols/routed.h
|
||||
|
||||
TAGFILES = $(SRC) $(HDR) $(TAGHDR)
|
||||
|
||||
CLEANFILES = $(PROG) $(OBJ) $(GENSRC)
|
||||
|
||||
EXTRA_DIST = \
|
||||
CHANGES \
|
||||
CREDITS \
|
||||
INSTALL.txt \
|
||||
LICENSE \
|
||||
Makefile.in \
|
||||
Makefile-devel-adds \
|
||||
README.md \
|
||||
Readme.Win32 \
|
||||
VERSION \
|
||||
aclocal.m4 \
|
||||
atime.awk \
|
||||
bpf_dump.c \
|
||||
config.guess \
|
||||
config.h.in \
|
||||
config.sub \
|
||||
configure \
|
||||
configure.in \
|
||||
install-sh \
|
||||
lbl/os-osf4.h \
|
||||
lbl/os-solaris2.h \
|
||||
lbl/os-sunos4.h \
|
||||
lbl/os-ultrix4.h \
|
||||
makemib \
|
||||
missing/dlnames.c \
|
||||
missing/datalinks.c \
|
||||
missing/getopt_long.c \
|
||||
missing/snprintf.c \
|
||||
missing/strdup.c \
|
||||
missing/strlcat.c \
|
||||
missing/strlcpy.c \
|
||||
missing/strsep.c \
|
||||
mkdep \
|
||||
packetdat.awk \
|
||||
pcap_dump_ftell.c \
|
||||
print-pflog.c \
|
||||
print-smb.c \
|
||||
send-ack.awk \
|
||||
smbutil.c \
|
||||
stime.awk \
|
||||
tcpdump.1.in \
|
||||
vfprintf.c \
|
||||
win32/prj/GNUmakefile \
|
||||
win32/prj/WinDump.dsp \
|
||||
win32/prj/WinDump.dsw
|
||||
|
||||
TEST_DIST= `find tests \( -name 'DIFF' -prune \) -o \( -name NEW -prune \) -o -type f \! -name '.*' \! -name '*~' -print`
|
||||
|
||||
all: $(PROG) $(LIBNETDISSECT)
|
||||
|
||||
$(PROG): $(OBJ) @V_PCAPDEP@
|
||||
@rm -f $@
|
||||
$(CC) $(FULL_CFLAGS) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
|
||||
|
||||
$(LIBNETDISSECT): $(LIBNETDISSECT_OBJ)
|
||||
@rm -f $@
|
||||
$(AR) cr $@ $(LIBNETDISSECT_OBJ)
|
||||
$(RANLIB) $@
|
||||
|
||||
datalinks.o: $(srcdir)/missing/datalinks.c
|
||||
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/datalinks.c
|
||||
dlnames.o: $(srcdir)/missing/dlnames.c
|
||||
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/dlnames.c
|
||||
getopt_long.o: $(srcdir)/missing/getopt_long.c
|
||||
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/getopt_long.c
|
||||
snprintf.o: $(srcdir)/missing/snprintf.c
|
||||
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c
|
||||
strdup.o: $(srcdir)/missing/strdup.c
|
||||
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strdup.c
|
||||
strlcat.o: $(srcdir)/missing/strlcat.c
|
||||
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strlcat.c
|
||||
strlcpy.o: $(srcdir)/missing/strlcpy.c
|
||||
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strlcpy.c
|
||||
strsep.o: $(srcdir)/missing/strsep.c
|
||||
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strsep.c
|
||||
|
||||
version.o: version.c
|
||||
$(CC) $(FULL_CFLAGS) -c version.c
|
||||
|
||||
version.c: $(srcdir)/VERSION
|
||||
@rm -f $@
|
||||
if grep GIT ${srcdir}/VERSION >/dev/null; then \
|
||||
read ver <${srcdir}/VERSION; \
|
||||
echo $$ver | tr -d '\012'; \
|
||||
date +_%Y_%m_%d; \
|
||||
else \
|
||||
cat ${srcdir}/VERSION; \
|
||||
fi | sed -e 's/.*/const char version[] = "&";/' > $@
|
||||
|
||||
install: all
|
||||
[ -d $(DESTDIR)$(sbindir) ] || \
|
||||
(mkdir -p $(DESTDIR)$(sbindir); chmod 755 $(DESTDIR)$(sbindir))
|
||||
$(INSTALL_PROGRAM) $(PROG) $(DESTDIR)$(sbindir)/$(PROG)
|
||||
$(INSTALL_PROGRAM) $(PROG) $(DESTDIR)$(sbindir)/$(PROG).`cat ${srcdir}/VERSION`
|
||||
[ -d $(DESTDIR)$(mandir)/man1 ] || \
|
||||
(mkdir -p $(DESTDIR)$(mandir)/man1; chmod 755 $(DESTDIR)$(mandir)/man1)
|
||||
$(INSTALL_DATA) $(PROG).1 $(DESTDIR)$(mandir)/man1/$(PROG).1
|
||||
|
||||
uninstall:
|
||||
rm -f $(DESTDIR)$(sbindir)/$(PROG)
|
||||
rm -f $(DESTDIR)$(mandir)/man1/$(PROG).1
|
||||
|
||||
lint: $(GENSRC)
|
||||
lint -hbxn $(SRC) | \
|
||||
grep -v 'struct/union .* never defined' | \
|
||||
grep -v 'possible pointer alignment problem'
|
||||
|
||||
clean:
|
||||
rm -f $(CLEANFILES) $(PROG)-`cat VERSION`.tar.gz
|
||||
|
||||
distclean:
|
||||
rm -f $(CLEANFILES) Makefile config.cache config.log config.status \
|
||||
config.h gnuc.h os-proto.h stamp-h stamp-h.in $(PROG).1 \
|
||||
libnetdissect.a tests/.failed tests/.passed \
|
||||
tests/failure-outputs.txt
|
||||
rm -rf autom4te.cache tests/DIFF tests/NEW
|
||||
|
||||
check: tcpdump
|
||||
(cd tests && ./TESTrun.sh)
|
||||
|
||||
tags: $(TAGFILES)
|
||||
ctags -wtd $(TAGFILES)
|
||||
|
||||
TAGS: $(TAGFILES)
|
||||
etags $(TAGFILES)
|
||||
|
||||
releasetar:
|
||||
@cwd=`pwd` ; dir=`basename $$cwd` ; name=$(PROG)-`cat VERSION` ; \
|
||||
mkdir $$name; \
|
||||
tar cf - $(CSRC) $(HDR) $(LIBNETDISSECT_SRC) $(EXTRA_DIST) $(TEST_DIST) | (cd $$name; tar xf -); \
|
||||
tar -c -z -f $$name.tar.gz $$name; \
|
||||
rm -rf $$name
|
||||
|
||||
testlist:
|
||||
echo $(TEST_DIST)
|
||||
|
||||
depend: $(GENSRC)
|
||||
$(MKDEP) -c $(CC) -m $(DEPENDENCY_CFLAG) $(DEFS) $(INCLS) $(SRC)
|
||||
243
README.md
Normal file
243
README.md
Normal file
@@ -0,0 +1,243 @@
|
||||
# tcpdump
|
||||
|
||||
[](https://travis-ci.org/the-tcpdump-group/tcpdump)
|
||||
|
||||
TCPDUMP 4.x.y
|
||||
Now maintained by "The Tcpdump Group"
|
||||
See www.tcpdump.org
|
||||
|
||||
Please send inquiries/comments/reports to:
|
||||
|
||||
* tcpdump-workers@lists.tcpdump.org
|
||||
|
||||
Anonymous Git is available via:
|
||||
|
||||
git clone git://bpf.tcpdump.org/tcpdump
|
||||
|
||||
Please submit patches by forking the branch on GitHub at:
|
||||
|
||||
* http://github.com/the-tcpdump-group/tcpdump/tree/master
|
||||
|
||||
and issuing a pull request.
|
||||
|
||||
formerly from Lawrence Berkeley National Laboratory
|
||||
Network Research Group <tcpdump@ee.lbl.gov>
|
||||
ftp://ftp.ee.lbl.gov/old/tcpdump.tar.Z (3.4)
|
||||
|
||||
This directory contains source code for tcpdump, a tool for network
|
||||
monitoring and data acquisition. This software was originally
|
||||
developed by the Network Research Group at the Lawrence Berkeley
|
||||
National Laboratory. The original distribution is available via
|
||||
anonymous ftp to `ftp.ee.lbl.gov`, in `tcpdump.tar.Z`. More recent
|
||||
development is performed at tcpdump.org, http://www.tcpdump.org/
|
||||
|
||||
Tcpdump uses libpcap, a system-independent interface for user-level
|
||||
packet capture. Before building tcpdump, you must first retrieve and
|
||||
build libpcap, also originally from LBL and now being maintained by
|
||||
tcpdump.org; see http://www.tcpdump.org/ .
|
||||
|
||||
Once libpcap is built (either install it or make sure it's in
|
||||
`../libpcap`), you can build tcpdump using the procedure in the `INSTALL.txt`
|
||||
file.
|
||||
|
||||
The program is loosely based on SMI's "etherfind" although none of the
|
||||
etherfind code remains. It was originally written by Van Jacobson as
|
||||
part of an ongoing research project to investigate and improve tcp and
|
||||
internet gateway performance. The parts of the program originally
|
||||
taken from Sun's etherfind were later re-written by Steven McCanne of
|
||||
LBL. To insure that there would be no vestige of proprietary code in
|
||||
tcpdump, Steve wrote these pieces from the specification given by the
|
||||
manual entry, with no access to the source of tcpdump or etherfind.
|
||||
|
||||
Over the past few years, tcpdump has been steadily improved by the
|
||||
excellent contributions from the Internet community (just browse
|
||||
through the `CHANGES` file). We are grateful for all the input.
|
||||
|
||||
Richard Stevens gives an excellent treatment of the Internet protocols
|
||||
in his book *"TCP/IP Illustrated, Volume 1"*. If you want to learn more
|
||||
about tcpdump and how to interpret its output, pick up this book.
|
||||
|
||||
Some tools for viewing and analyzing tcpdump trace files are available
|
||||
from the Internet Traffic Archive:
|
||||
|
||||
* http://www.sigcomm.org/ITA/
|
||||
|
||||
Another tool that tcpdump users might find useful is tcpslice:
|
||||
|
||||
* https://github.com/the-tcpdump-group/tcpslice
|
||||
|
||||
It is a program that can be used to extract portions of tcpdump binary
|
||||
trace files. See the above distribution for further details and
|
||||
documentation.
|
||||
|
||||
Problems, bugs, questions, desirable enhancements, etc. should be sent
|
||||
to the address "tcpdump-workers@lists.tcpdump.org". Bugs, support
|
||||
requests, and feature requests may also be submitted on the GitHub issue
|
||||
tracker for tcpdump at:
|
||||
|
||||
* https://github.com/the-tcpdump-group/tcpdump/issues
|
||||
|
||||
Source code contributions, etc. should be sent to the email address
|
||||
above or submitted by forking the branch on GitHub at:
|
||||
|
||||
* http://github.com/the-tcpdump-group/tcpdump/tree/master
|
||||
|
||||
and issuing a pull request.
|
||||
|
||||
Current versions can be found at www.tcpdump.org.
|
||||
|
||||
- The TCPdump team
|
||||
|
||||
original text by: Steve McCanne, Craig Leres, Van Jacobson
|
||||
|
||||
-------------------------------------
|
||||
```
|
||||
This directory also contains some short awk programs intended as
|
||||
examples of ways to reduce tcpdump data when you're tracking
|
||||
particular network problems:
|
||||
|
||||
send-ack.awk
|
||||
Simplifies the tcpdump trace for an ftp (or other unidirectional
|
||||
tcp transfer). Since we assume that one host only sends and
|
||||
the other only acks, all address information is left off and
|
||||
we just note if the packet is a "send" or an "ack".
|
||||
|
||||
There is one output line per line of the original trace.
|
||||
Field 1 is the packet time in decimal seconds, relative
|
||||
to the start of the conversation. Field 2 is delta-time
|
||||
from last packet. Field 3 is packet type/direction.
|
||||
"Send" means data going from sender to receiver, "ack"
|
||||
means an ack going from the receiver to the sender. A
|
||||
preceding "*" indicates that the data is a retransmission.
|
||||
A preceding "-" indicates a hole in the sequence space
|
||||
(i.e., missing packet(s)), a "#" means an odd-size (not max
|
||||
seg size) packet. Field 4 has the packet flags
|
||||
(same format as raw trace). Field 5 is the sequence
|
||||
number (start seq. num for sender, next expected seq number
|
||||
for acks). The number in parens following an ack is
|
||||
the delta-time from the first send of the packet to the
|
||||
ack. A number in parens following a send is the
|
||||
delta-time from the first send of the packet to the
|
||||
current send (on duplicate packets only). Duplicate
|
||||
sends or acks have a number in square brackets showing
|
||||
the number of duplicates so far.
|
||||
|
||||
Here is a short sample from near the start of an ftp:
|
||||
3.00 0.20 send . 512
|
||||
3.20 0.20 ack . 1024 (0.20)
|
||||
3.20 0.00 send P 1024
|
||||
3.40 0.20 ack . 1536 (0.20)
|
||||
3.80 0.40 * send . 0 (3.80) [2]
|
||||
3.82 0.02 * ack . 1536 (0.62) [2]
|
||||
Three seconds into the conversation, bytes 512 through 1023
|
||||
were sent. 200ms later they were acked. Shortly thereafter
|
||||
bytes 1024-1535 were sent and again acked after 200ms.
|
||||
Then, for no apparent reason, 0-511 is retransmitted, 3.8
|
||||
seconds after its initial send (the round trip time for this
|
||||
ftp was 1sec, +-500ms). Since the receiver is expecting
|
||||
1536, 1536 is re-acked when 0 arrives.
|
||||
|
||||
packetdat.awk
|
||||
Computes chunk summary data for an ftp (or similar
|
||||
unidirectional tcp transfer). [A "chunk" refers to
|
||||
a chunk of the sequence space -- essentially the packet
|
||||
sequence number divided by the max segment size.]
|
||||
|
||||
A summary line is printed showing the number of chunks,
|
||||
the number of packets it took to send that many chunks
|
||||
(if there are no lost or duplicated packets, the number
|
||||
of packets should equal the number of chunks) and the
|
||||
number of acks.
|
||||
|
||||
Following the summary line is one line of information
|
||||
per chunk. The line contains eight fields:
|
||||
1 - the chunk number
|
||||
2 - the start sequence number for this chunk
|
||||
3 - time of first send
|
||||
4 - time of last send
|
||||
5 - time of first ack
|
||||
6 - time of last ack
|
||||
7 - number of times chunk was sent
|
||||
8 - number of times chunk was acked
|
||||
(all times are in decimal seconds, relative to the start
|
||||
of the conversation.)
|
||||
|
||||
As an example, here is the first part of the output for
|
||||
an ftp trace:
|
||||
|
||||
# 134 chunks. 536 packets sent. 508 acks.
|
||||
1 1 0.00 5.80 0.20 0.20 4 1
|
||||
2 513 0.28 6.20 0.40 0.40 4 1
|
||||
3 1025 1.16 6.32 1.20 1.20 4 1
|
||||
4 1561 1.86 15.00 2.00 2.00 6 1
|
||||
5 2049 2.16 15.44 2.20 2.20 5 1
|
||||
6 2585 2.64 16.44 2.80 2.80 5 1
|
||||
7 3073 3.00 16.66 3.20 3.20 4 1
|
||||
8 3609 3.20 17.24 3.40 5.82 4 11
|
||||
9 4097 6.02 6.58 6.20 6.80 2 5
|
||||
|
||||
This says that 134 chunks were transferred (about 70K
|
||||
since the average packet size was 512 bytes). It took
|
||||
536 packets to transfer the data (i.e., on the average
|
||||
each chunk was transmitted four times). Looking at,
|
||||
say, chunk 4, we see it represents the 512 bytes of
|
||||
sequence space from 1561 to 2048. It was first sent
|
||||
1.86 seconds into the conversation. It was last
|
||||
sent 15 seconds into the conversation and was sent
|
||||
a total of 6 times (i.e., it was retransmitted every
|
||||
2 seconds on the average). It was acked once, 140ms
|
||||
after it first arrived.
|
||||
|
||||
stime.awk
|
||||
atime.awk
|
||||
Output one line per send or ack, respectively, in the form
|
||||
<time> <seq. number>
|
||||
where <time> is the time in seconds since the start of the
|
||||
transfer and <seq. number> is the sequence number being sent
|
||||
or acked. I typically plot this data looking for suspicious
|
||||
patterns.
|
||||
|
||||
|
||||
The problem I was looking at was the bulk-data-transfer
|
||||
throughput of medium delay network paths (1-6 sec. round trip
|
||||
time) under typical DARPA Internet conditions. The trace of the
|
||||
ftp transfer of a large file was used as the raw data source.
|
||||
The method was:
|
||||
|
||||
- On a local host (but not the Sun running tcpdump), connect to
|
||||
the remote ftp.
|
||||
|
||||
- On the monitor Sun, start the trace going. E.g.,
|
||||
tcpdump host local-host and remote-host and port ftp-data >tracefile
|
||||
|
||||
- On local, do either a get or put of a large file (~500KB),
|
||||
preferably to the null device (to minimize effects like
|
||||
closing the receive window while waiting for a disk write).
|
||||
|
||||
- When transfer is finished, stop tcpdump. Use awk to make up
|
||||
two files of summary data (maxsize is the maximum packet size,
|
||||
tracedata is the file of tcpdump tracedata):
|
||||
awk -f send-ack.awk packetsize=avgsize tracedata >sa
|
||||
awk -f packetdat.awk packetsize=avgsize tracedata >pd
|
||||
|
||||
- While the summary data files are printing, take a look at
|
||||
how the transfer behaved:
|
||||
awk -f stime.awk tracedata | xgraph
|
||||
(90% of what you learn seems to happen in this step).
|
||||
|
||||
- Do all of the above steps several times, both directions,
|
||||
at different times of day, with different protocol
|
||||
implementations on the other end.
|
||||
|
||||
- Using one of the Unix data analysis packages (in my case,
|
||||
S and Gary Perlman's Unix|Stat), spend a few months staring
|
||||
at the data.
|
||||
|
||||
- Change something in the local protocol implementation and
|
||||
redo the steps above.
|
||||
|
||||
- Once a week, tell your funding agent that you're discovering
|
||||
wonderful things and you'll write up that research report
|
||||
"real soon now".
|
||||
```
|
||||
24
Readme.Win32
Normal file
24
Readme.Win32
Normal file
@@ -0,0 +1,24 @@
|
||||
To build tcpdump under Windows, you need:
|
||||
|
||||
- version 6 (or higher) of Microsoft Visual Studio or the Cygnus gnu
|
||||
C compiler.
|
||||
- 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 WinPcap source code, that includes libpcap for win32. Download it
|
||||
from http://winpcap.polito.it or download libpcap sources from
|
||||
http://www.tcpdump.org and follow the instructions in the README.Win32
|
||||
file.
|
||||
|
||||
First, extract tcpdump and WinPcap in the same folder, and build WinPcap.
|
||||
|
||||
The Visual Studio project and the cygwin makefile are in the Win32\prj
|
||||
folder.
|
||||
|
||||
From Visual Studio, open windump.dsw and build the program. The release
|
||||
version of the WinDump.exe executable file will be created in the
|
||||
windump\win32\prj\release directory . The debug version will be generated
|
||||
in windump\win32\prj\debug.
|
||||
|
||||
From cygnus, go to windump\win32\prj\ and type "make". WinDump.exe will be
|
||||
created in the same directory.
|
||||
1360
aclocal.m4
vendored
Normal file
1360
aclocal.m4
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1271
addrtoname.c
Normal file
1271
addrtoname.c
Normal file
File diff suppressed because it is too large
Load Diff
61
addrtoname.h
Normal file
61
addrtoname.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 1990, 1992, 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Definitions to let us compile most of the IPv6 code even on systems
|
||||
* without IPv6 support.
|
||||
*/
|
||||
#ifndef INET6_ADDRSTRLEN
|
||||
#define INET6_ADDRSTRLEN 46
|
||||
#endif
|
||||
|
||||
/* Name to address translation routines. */
|
||||
|
||||
enum {
|
||||
LINKADDR_ETHER,
|
||||
LINKADDR_FRELAY,
|
||||
LINKADDR_IEEE1394,
|
||||
LINKADDR_ATM
|
||||
};
|
||||
|
||||
#define BUFSIZE 128
|
||||
|
||||
extern const char *linkaddr_string(netdissect_options *, const u_char *, const unsigned int, const unsigned int);
|
||||
extern const char *etheraddr_string(netdissect_options *, const u_char *);
|
||||
extern const char *le64addr_string(netdissect_options *, const u_char *);
|
||||
extern const char *etherproto_string(netdissect_options *, u_short);
|
||||
extern const char *tcpport_string(netdissect_options *, u_short);
|
||||
extern const char *udpport_string(netdissect_options *, u_short);
|
||||
extern const char *isonsap_string(netdissect_options *, const u_char *, register u_int);
|
||||
extern const char *dnaddr_string(netdissect_options *, u_short);
|
||||
extern const char *protoid_string(netdissect_options *, const u_char *);
|
||||
extern const char *ipxsap_string(netdissect_options *, u_short);
|
||||
extern const char *getname(netdissect_options *, const u_char *);
|
||||
extern const char *getname6(netdissect_options *, const u_char *);
|
||||
extern const char *intoa(uint32_t);
|
||||
|
||||
extern void init_addrtoname(netdissect_options *, uint32_t, uint32_t);
|
||||
extern struct hnamemem *newhnamemem(netdissect_options *);
|
||||
extern struct h6namemem *newh6namemem(netdissect_options *);
|
||||
extern const char * ieee8021q_tci_string(const uint16_t);
|
||||
|
||||
#define ipaddr_string(ndo, p) getname(ndo, (const u_char *)(p))
|
||||
#define ip6addr_string(ndo, p) getname6(ndo, (const u_char *)(p))
|
||||
199
addrtostr.c
Normal file
199
addrtostr.c
Normal file
@@ -0,0 +1,199 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <netdissect-stdinc.h>
|
||||
#include "addrtostr.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef IN6ADDRSZ
|
||||
#define IN6ADDRSZ 16 /* IPv6 T_AAAA */
|
||||
#endif
|
||||
|
||||
#ifndef INT16SZ
|
||||
#define INT16SZ 2 /* word size */
|
||||
#endif
|
||||
|
||||
const char *
|
||||
addrtostr (const void *src, char *dst, size_t size)
|
||||
{
|
||||
const u_char *srcaddr = (const u_char *)src;
|
||||
const char digits[] = "0123456789";
|
||||
int i;
|
||||
const char *orig_dst = dst;
|
||||
|
||||
if (size < INET_ADDRSTRLEN) {
|
||||
errno = ENOSPC;
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < 4; ++i) {
|
||||
int n = *srcaddr++;
|
||||
int non_zerop = 0;
|
||||
|
||||
if (non_zerop || n / 100 > 0) {
|
||||
*dst++ = digits[n / 100];
|
||||
n %= 100;
|
||||
non_zerop = 1;
|
||||
}
|
||||
if (non_zerop || n / 10 > 0) {
|
||||
*dst++ = digits[n / 10];
|
||||
n %= 10;
|
||||
non_zerop = 1;
|
||||
}
|
||||
*dst++ = digits[n];
|
||||
if (i != 3)
|
||||
*dst++ = '.';
|
||||
}
|
||||
*dst++ = '\0';
|
||||
return orig_dst;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert IPv6 binary address into presentation (printable) format.
|
||||
*/
|
||||
const char *
|
||||
addrtostr6 (const void *src, char *dst, size_t size)
|
||||
{
|
||||
/*
|
||||
* Note that int32_t and int16_t need only be "at least" large enough
|
||||
* to contain a value of the specified size. On some systems, like
|
||||
* Crays, there is no such thing as an integer variable with 16 bits.
|
||||
* Keep this in mind if you think this function should have been coded
|
||||
* to use pointer overlays. All the world's not a VAX.
|
||||
*/
|
||||
const u_char *srcaddr = (const u_char *)src;
|
||||
char tmp [INET6_ADDRSTRLEN+1];
|
||||
char *tp;
|
||||
struct {
|
||||
long base;
|
||||
long len;
|
||||
} best, cur;
|
||||
u_long words [IN6ADDRSZ / INT16SZ];
|
||||
u_int i;
|
||||
|
||||
/* Preprocess:
|
||||
* Copy the input (bytewise) array into a wordwise array.
|
||||
* Find the longest run of 0x00's in src[] for :: shorthanding.
|
||||
*/
|
||||
memset (words, 0, sizeof(words));
|
||||
for (i = 0; i < IN6ADDRSZ; i++)
|
||||
words[i/2] |= (srcaddr[i] << ((1 - (i % 2)) << 3));
|
||||
|
||||
best.len = 0;
|
||||
best.base = -1;
|
||||
cur.len = 0;
|
||||
cur.base = -1;
|
||||
for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++)
|
||||
{
|
||||
if (words[i] == 0)
|
||||
{
|
||||
if (cur.base == -1)
|
||||
cur.base = i, cur.len = 1;
|
||||
else cur.len++;
|
||||
}
|
||||
else if (cur.base != -1)
|
||||
{
|
||||
if (best.base == -1 || cur.len > best.len)
|
||||
best = cur;
|
||||
cur.base = -1;
|
||||
}
|
||||
}
|
||||
if ((cur.base != -1) && (best.base == -1 || cur.len > best.len))
|
||||
best = cur;
|
||||
if (best.base != -1 && best.len < 2)
|
||||
best.base = -1;
|
||||
|
||||
/* Format the result.
|
||||
*/
|
||||
tp = tmp;
|
||||
for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++)
|
||||
{
|
||||
/* Are we inside the best run of 0x00's?
|
||||
*/
|
||||
if (best.base != -1 && i >= best.base && i < (best.base + best.len))
|
||||
{
|
||||
if (i == best.base)
|
||||
*tp++ = ':';
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Are we following an initial run of 0x00s or any real hex?
|
||||
*/
|
||||
if (i != 0)
|
||||
*tp++ = ':';
|
||||
|
||||
/* Is this address an encapsulated IPv4?
|
||||
*/
|
||||
if (i == 6 && best.base == 0 &&
|
||||
(best.len == 6 || (best.len == 5 && words[5] == 0xffff)))
|
||||
{
|
||||
if (!addrtostr(srcaddr+12, tp, sizeof(tmp) - (tp - tmp)))
|
||||
{
|
||||
errno = ENOSPC;
|
||||
return (NULL);
|
||||
}
|
||||
tp += strlen(tp);
|
||||
break;
|
||||
}
|
||||
tp += sprintf (tp, "%lx", words[i]);
|
||||
}
|
||||
|
||||
/* Was it a trailing run of 0x00's?
|
||||
*/
|
||||
if (best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ))
|
||||
*tp++ = ':';
|
||||
*tp++ = '\0';
|
||||
|
||||
/* Check for overflow, copy, and we're done.
|
||||
*/
|
||||
if ((size_t)(tp - tmp) > size)
|
||||
{
|
||||
errno = ENOSPC;
|
||||
return (NULL);
|
||||
}
|
||||
return strcpy (dst, tmp);
|
||||
}
|
||||
42
addrtostr.h
Normal file
42
addrtostr.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* Address to printable string translation routines. */
|
||||
|
||||
extern const char *addrtostr(const void *src, char *dst, size_t size);
|
||||
extern const char *addrtostr6(const void *src, char *dst, size_t size);
|
||||
58
af.c
Normal file
58
af.c
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2006 The TCPDUMP project
|
||||
*
|
||||
* 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, and (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.
|
||||
* 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.
|
||||
*
|
||||
* Original code by Hannes Gredler (hannes@juniper.net)
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <netdissect-stdinc.h>
|
||||
#include "netdissect.h"
|
||||
#include "af.h"
|
||||
|
||||
const struct tok af_values[] = {
|
||||
{ 0, "Reserved"},
|
||||
{ AFNUM_INET, "IPv4"},
|
||||
{ AFNUM_INET6, "IPv6"},
|
||||
{ AFNUM_NSAP, "NSAP"},
|
||||
{ AFNUM_HDLC, "HDLC"},
|
||||
{ AFNUM_BBN1822, "BBN 1822"},
|
||||
{ AFNUM_802, "802"},
|
||||
{ AFNUM_E163, "E.163"},
|
||||
{ AFNUM_E164, "E.164"},
|
||||
{ AFNUM_F69, "F.69"},
|
||||
{ AFNUM_X121, "X.121"},
|
||||
{ AFNUM_IPX, "Novell IPX"},
|
||||
{ AFNUM_ATALK, "Appletalk"},
|
||||
{ AFNUM_DECNET, "Decnet IV"},
|
||||
{ AFNUM_BANYAN, "Banyan Vines"},
|
||||
{ AFNUM_E164NSAP, "E.164 with NSAP subaddress"},
|
||||
{ AFNUM_L2VPN, "Layer-2 VPN"},
|
||||
{ AFNUM_VPLS, "VPLS"},
|
||||
{ 0, NULL},
|
||||
};
|
||||
|
||||
const struct tok bsd_af_values[] = {
|
||||
{ BSD_AFNUM_INET, "IPv4" },
|
||||
{ BSD_AFNUM_NS, "NS" },
|
||||
{ BSD_AFNUM_ISO, "ISO" },
|
||||
{ BSD_AFNUM_APPLETALK, "Appletalk" },
|
||||
{ BSD_AFNUM_IPX, "IPX" },
|
||||
{ BSD_AFNUM_INET6_BSD, "IPv6" },
|
||||
{ BSD_AFNUM_INET6_FREEBSD, "IPv6" },
|
||||
{ BSD_AFNUM_INET6_DARWIN, "IPv6" },
|
||||
{ 0, NULL}
|
||||
};
|
||||
55
af.h
Normal file
55
af.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2006 The TCPDUMP project
|
||||
*
|
||||
* 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, and (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.
|
||||
* 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.
|
||||
*
|
||||
* Original code by Hannes Gredler (hannes@juniper.net)
|
||||
*/
|
||||
|
||||
extern const struct tok af_values[];
|
||||
extern const struct tok bsd_af_values[];
|
||||
|
||||
/* RFC1700 address family numbers */
|
||||
#define AFNUM_INET 1
|
||||
#define AFNUM_INET6 2
|
||||
#define AFNUM_NSAP 3
|
||||
#define AFNUM_HDLC 4
|
||||
#define AFNUM_BBN1822 5
|
||||
#define AFNUM_802 6
|
||||
#define AFNUM_E163 7
|
||||
#define AFNUM_E164 8
|
||||
#define AFNUM_F69 9
|
||||
#define AFNUM_X121 10
|
||||
#define AFNUM_IPX 11
|
||||
#define AFNUM_ATALK 12
|
||||
#define AFNUM_DECNET 13
|
||||
#define AFNUM_BANYAN 14
|
||||
#define AFNUM_E164NSAP 15
|
||||
#define AFNUM_VPLS 25
|
||||
/* draft-kompella-ppvpn-l2vpn */
|
||||
#define AFNUM_L2VPN 196 /* still to be approved by IANA */
|
||||
|
||||
/*
|
||||
* BSD AF_ values.
|
||||
*
|
||||
* Unfortunately, the BSDs don't all use the same value for AF_INET6,
|
||||
* so, because we want to be able to read captures from all of the BSDs,
|
||||
* we check for all of them.
|
||||
*/
|
||||
#define BSD_AFNUM_INET 2
|
||||
#define BSD_AFNUM_NS 6 /* XEROX NS protocols */
|
||||
#define BSD_AFNUM_ISO 7
|
||||
#define BSD_AFNUM_APPLETALK 16
|
||||
#define BSD_AFNUM_IPX 23
|
||||
#define BSD_AFNUM_INET6_BSD 24 /* OpenBSD (and probably NetBSD), BSD/OS */
|
||||
#define BSD_AFNUM_INET6_FREEBSD 28
|
||||
#define BSD_AFNUM_INET6_DARWIN 30
|
||||
57
ah.h
Normal file
57
ah.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/* $NetBSD: ah.h,v 1.12 2000/07/23 05:23:04 itojun Exp $ */
|
||||
/* $KAME: ah.h,v 1.12 2000/07/20 17:41:01 itojun Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the project nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* RFC1826/2402 authentication header.
|
||||
*/
|
||||
|
||||
#ifndef _NETINET6_AH_H_
|
||||
#define _NETINET6_AH_H_
|
||||
|
||||
struct ah {
|
||||
uint8_t ah_nxt; /* Next Header */
|
||||
uint8_t ah_len; /* Length of data, in 32bit */
|
||||
uint16_t ah_reserve; /* Reserved for future use */
|
||||
uint32_t ah_spi; /* Security parameter index */
|
||||
/* variable size, 32bit bound*/ /* Authentication data */
|
||||
};
|
||||
|
||||
struct newah {
|
||||
uint8_t ah_nxt; /* Next Header */
|
||||
uint8_t ah_len; /* Length of data + 1, in 32bit */
|
||||
uint16_t ah_reserve; /* Reserved for future use */
|
||||
uint32_t ah_spi; /* Security parameter index */
|
||||
uint32_t ah_seq; /* Sequence number field */
|
||||
/* variable size, 32bit bound*/ /* Authentication data */
|
||||
};
|
||||
|
||||
#endif /*_NETINET6_AH_H_*/
|
||||
166
appletalk.h
Normal file
166
appletalk.h
Normal file
@@ -0,0 +1,166 @@
|
||||
/*
|
||||
* Copyright (c) 1988, 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.
|
||||
*
|
||||
* AppleTalk protocol formats (courtesy Bill Croft of Stanford/SUMEX).
|
||||
*/
|
||||
|
||||
struct LAP {
|
||||
uint8_t dst;
|
||||
uint8_t src;
|
||||
uint8_t type;
|
||||
};
|
||||
#define lapShortDDP 1 /* short DDP type */
|
||||
#define lapDDP 2 /* DDP type */
|
||||
#define lapKLAP 'K' /* Kinetics KLAP type */
|
||||
|
||||
/* Datagram Delivery Protocol */
|
||||
|
||||
struct atDDP {
|
||||
uint16_t length;
|
||||
uint16_t checksum;
|
||||
uint16_t dstNet;
|
||||
uint16_t srcNet;
|
||||
uint8_t dstNode;
|
||||
uint8_t srcNode;
|
||||
uint8_t dstSkt;
|
||||
uint8_t srcSkt;
|
||||
uint8_t type;
|
||||
};
|
||||
|
||||
struct atShortDDP {
|
||||
uint16_t length;
|
||||
uint8_t dstSkt;
|
||||
uint8_t srcSkt;
|
||||
uint8_t type;
|
||||
};
|
||||
|
||||
#define ddpMaxWKS 0x7F
|
||||
#define ddpMaxData 586
|
||||
#define ddpLengthMask 0x3FF
|
||||
#define ddpHopShift 10
|
||||
#define ddpSize 13 /* size of DDP header (avoid struct padding) */
|
||||
#define ddpSSize 5
|
||||
#define ddpWKS 128 /* boundary of DDP well known sockets */
|
||||
#define ddpRTMP 1 /* RTMP type */
|
||||
#define ddpRTMPrequest 5 /* RTMP request type */
|
||||
#define ddpNBP 2 /* NBP type */
|
||||
#define ddpATP 3 /* ATP type */
|
||||
#define ddpECHO 4 /* ECHO type */
|
||||
#define ddpIP 22 /* IP type */
|
||||
#define ddpARP 23 /* ARP type */
|
||||
#define ddpEIGRP 88 /* EIGRP over Appletalk */
|
||||
#define ddpKLAP 0x4b /* Kinetics KLAP type */
|
||||
|
||||
|
||||
/* AppleTalk Transaction Protocol */
|
||||
|
||||
struct atATP {
|
||||
uint8_t control;
|
||||
uint8_t bitmap;
|
||||
uint16_t transID;
|
||||
int32_t userData;
|
||||
};
|
||||
|
||||
#define atpReqCode 0x40
|
||||
#define atpRspCode 0x80
|
||||
#define atpRelCode 0xC0
|
||||
#define atpXO 0x20
|
||||
#define atpEOM 0x10
|
||||
#define atpSTS 0x08
|
||||
#define atpFlagMask 0x3F
|
||||
#define atpControlMask 0xF8
|
||||
#define atpMaxNum 8
|
||||
#define atpMaxData 578
|
||||
|
||||
|
||||
/* AppleTalk Echo Protocol */
|
||||
|
||||
struct atEcho {
|
||||
uint8_t echoFunction;
|
||||
uint8_t *echoData;
|
||||
};
|
||||
|
||||
#define echoSkt 4 /* the echoer socket */
|
||||
#define echoSize 1 /* size of echo header */
|
||||
#define echoRequest 1 /* echo request */
|
||||
#define echoReply 2 /* echo request */
|
||||
|
||||
|
||||
/* Name Binding Protocol */
|
||||
|
||||
struct atNBP {
|
||||
uint8_t control;
|
||||
uint8_t id;
|
||||
};
|
||||
|
||||
struct atNBPtuple {
|
||||
uint16_t net;
|
||||
uint8_t node;
|
||||
uint8_t skt;
|
||||
uint8_t enumerator;
|
||||
};
|
||||
|
||||
#define nbpBrRq 0x10
|
||||
#define nbpLkUp 0x20
|
||||
#define nbpLkUpReply 0x30
|
||||
|
||||
#define nbpNIS 2
|
||||
#define nbpTupleMax 15
|
||||
|
||||
#define nbpHeaderSize 2
|
||||
#define nbpTupleSize 5
|
||||
|
||||
#define nbpSkt 2 /* NIS */
|
||||
|
||||
|
||||
/* Routing Table Maint. Protocol */
|
||||
|
||||
#define rtmpSkt 1 /* number of RTMP socket */
|
||||
#define rtmpSize 4 /* minimum size */
|
||||
#define rtmpTupleSize 3
|
||||
|
||||
|
||||
/* Zone Information Protocol */
|
||||
|
||||
struct zipHeader {
|
||||
uint8_t command;
|
||||
uint8_t netcount;
|
||||
};
|
||||
|
||||
#define zipHeaderSize 2
|
||||
#define zipQuery 1
|
||||
#define zipReply 2
|
||||
#define zipTakedown 3
|
||||
#define zipBringup 4
|
||||
#define ddpZIP 6
|
||||
#define zipSkt 6
|
||||
#define GetMyZone 7
|
||||
#define GetZoneList 8
|
||||
|
||||
/*
|
||||
* UDP port range used for ddp-in-udp encapsulation is 16512-16639
|
||||
* for client sockets (128-255) and 200-327 for server sockets
|
||||
* (0-127). We also try to recognize the pre-April 88 server
|
||||
* socket range of 768-895.
|
||||
*/
|
||||
#define atalk_port(p) \
|
||||
(((unsigned)((p) - 16512) < 128) || \
|
||||
((unsigned)((p) - 200) < 128) || \
|
||||
((unsigned)((p) - 768) < 128))
|
||||
105
ascii_strcasecmp.c
Normal file
105
ascii_strcasecmp.c
Normal file
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright (c) 1987 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 written prior permission. This software
|
||||
* is provided ``as is'' without express or implied warranty.
|
||||
*/
|
||||
|
||||
#include "ascii_strcasecmp.h"
|
||||
|
||||
/*
|
||||
* This array maps upper-case ASCII letters to their lower-case
|
||||
* equivalents; all other byte values are mapped to themselves,
|
||||
* so this is locale-independent and intended to be locale-independent,
|
||||
* to avoid issues with, for example, "i" and "I" not being lower-case
|
||||
* and upper-case versions of the same letter in Turkish, where
|
||||
* there are separate "i with dot" and "i without dot" letters.
|
||||
*/
|
||||
static const unsigned char charmap[] = {
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
||||
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
|
||||
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
|
||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
|
||||
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
|
||||
0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
|
||||
0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
|
||||
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
|
||||
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
|
||||
0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
|
||||
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
|
||||
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
|
||||
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
|
||||
0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
|
||||
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
|
||||
0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
|
||||
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
|
||||
0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
|
||||
0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
|
||||
0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
|
||||
0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
|
||||
0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
|
||||
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
|
||||
0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
|
||||
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
|
||||
0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
|
||||
0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
|
||||
0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
|
||||
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
|
||||
0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
|
||||
};
|
||||
|
||||
int
|
||||
ascii_strcasecmp(const char *s1, const char *s2)
|
||||
{
|
||||
register const unsigned char *cm = charmap,
|
||||
*us1 = (const unsigned char *)s1,
|
||||
*us2 = (const unsigned char *)s2;
|
||||
|
||||
while (cm[*us1] == cm[*us2++])
|
||||
if (*us1++ == '\0')
|
||||
return(0);
|
||||
return(cm[*us1] - cm[*--us2]);
|
||||
}
|
||||
|
||||
int
|
||||
ascii_strncasecmp(const char *s1, const char *s2, register size_t n)
|
||||
{
|
||||
register const unsigned char *cm = charmap,
|
||||
*us1 = (const unsigned char *)s1,
|
||||
*us2 = (const unsigned char *)s2;
|
||||
|
||||
for (;;) {
|
||||
if (n == 0) {
|
||||
/*
|
||||
* We've run out of characters that we should
|
||||
* compare, and they've all been equal; return
|
||||
* 0, to indicate that the prefixes are the
|
||||
* same.
|
||||
*/
|
||||
return(0);
|
||||
}
|
||||
if (cm[*us1] != cm[*us2++]) {
|
||||
/*
|
||||
* We've found a mismatch.
|
||||
*/
|
||||
break;
|
||||
}
|
||||
if (*us1++ == '\0') {
|
||||
/*
|
||||
* We've run out of characters *to* compare,
|
||||
* and they've all been equal; return 0, to
|
||||
* indicate that the strings are the same.
|
||||
*/
|
||||
return(0);
|
||||
}
|
||||
n--;
|
||||
}
|
||||
return(cm[*us1] - cm[*--us2]);
|
||||
}
|
||||
33
ascii_strcasecmp.h
Normal file
33
ascii_strcasecmp.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 1988-1997
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Copyright (c) 1998-2012 Michael Richardson <mcr@tcpdump.org>
|
||||
* The TCPDUMP project
|
||||
*
|
||||
* 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 netdissect_ascii_strcasecmp_h
|
||||
#define netdissect_ascii_strcasecmp_h
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
extern int ascii_strcasecmp(const char *, const char *);
|
||||
extern int ascii_strncasecmp(const char *, const char *, size_t);
|
||||
|
||||
#endif /* netdissect_ascii_strcasecmp_h */
|
||||
18
atime.awk
Normal file
18
atime.awk
Normal file
@@ -0,0 +1,18 @@
|
||||
$6 ~ /^ack/ && $5 !~ /[SFR]/ {
|
||||
# given a tcpdump ftp trace, output one line for each ack
|
||||
# in the form
|
||||
# <ack time> <seq no>
|
||||
# where <ack time> is the time packet was acked (in seconds with
|
||||
# zero at time of first packet) and <seq no> is the tcp sequence
|
||||
# number of the ack divided by 1024 (i.e., Kbytes acked).
|
||||
#
|
||||
# convert time to seconds
|
||||
n = split ($1,t,":")
|
||||
tim = t[1]*3600 + t[2]*60 + t[3]
|
||||
if (! tzero) {
|
||||
tzero = tim
|
||||
OFS = "\t"
|
||||
}
|
||||
# get packet sequence number
|
||||
printf "%7.2f\t%g\n", tim-tzero, $7/1024
|
||||
}
|
||||
31
atm.h
Normal file
31
atm.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2002 Guy Harris.
|
||||
* 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, and (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.
|
||||
* The name of Guy Harris 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Traffic types for ATM.
|
||||
*/
|
||||
#define ATM_UNKNOWN 0 /* Unknown */
|
||||
#define ATM_LANE 1 /* LANE */
|
||||
#define ATM_LLC 2 /* LLC encapsulation */
|
||||
|
||||
/*
|
||||
* some OAM cell captures (most notably Juniper's)
|
||||
* do not deliver a heading HEC byte
|
||||
*/
|
||||
#define ATM_OAM_NOHEC 0
|
||||
#define ATM_OAM_HEC 1
|
||||
#define ATM_HDR_LEN_NOHEC 4
|
||||
61
bpf_dump.c
Normal file
61
bpf_dump.c
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 1992, 1993, 1994, 1995, 1996
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that: (1) source code distributions
|
||||
* retain the above copyright notice and this paragraph in its entirety, (2)
|
||||
* distributions including binary code include the above copyright notice and
|
||||
* this paragraph in its entirety in the documentation or other materials
|
||||
* provided with the distribution, and (3) all advertising materials mentioning
|
||||
* features or use of this software display the following acknowledgement:
|
||||
* ``This product includes software developed by the University of California,
|
||||
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
|
||||
* the University nor the names of its contributors may be used to endorse
|
||||
* or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <netdissect-stdinc.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "netdissect.h"
|
||||
|
||||
void
|
||||
bpf_dump(const 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));
|
||||
}
|
||||
}
|
||||
26
chdlc.h
Normal file
26
chdlc.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) 1990, 1991, 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.
|
||||
*/
|
||||
|
||||
#define CHDLC_HDRLEN 4
|
||||
#define CHDLC_UNICAST 0x0f
|
||||
#define CHDLC_BCAST 0x8f
|
||||
#define CHDLC_TYPE_SLARP 0x8035
|
||||
#define CHDLC_TYPE_CDP 0x2000
|
||||
189
checksum.c
Normal file
189
checksum.c
Normal file
@@ -0,0 +1,189 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2006 The TCPDUMP project
|
||||
*
|
||||
* 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, and (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.
|
||||
* 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.
|
||||
*
|
||||
* miscellaneous checksumming routines
|
||||
*
|
||||
* Original code by Hannes Gredler (hannes@juniper.net)
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <netdissect-stdinc.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "netdissect.h"
|
||||
|
||||
/*
|
||||
* CRC-10 table generated using the following Python snippet:
|
||||
|
||||
import sys
|
||||
|
||||
crc_table = []
|
||||
for i in range(256):
|
||||
accum = i << 2
|
||||
for j in range(8):
|
||||
accum <<= 1
|
||||
if accum & 0x400:
|
||||
accum ^= 0x633
|
||||
crc_table.append(accum)
|
||||
|
||||
for i in range(len(crc_table)/8):
|
||||
for j in range(8):
|
||||
sys.stdout.write("0x%04x, " % crc_table[i*8+j])
|
||||
sys.stdout.write("\n")
|
||||
|
||||
*/
|
||||
static const uint16_t crc10_table[256] =
|
||||
{
|
||||
0x0000, 0x0233, 0x0255, 0x0066, 0x0299, 0x00aa, 0x00cc, 0x02ff,
|
||||
0x0301, 0x0132, 0x0154, 0x0367, 0x0198, 0x03ab, 0x03cd, 0x01fe,
|
||||
0x0031, 0x0202, 0x0264, 0x0057, 0x02a8, 0x009b, 0x00fd, 0x02ce,
|
||||
0x0330, 0x0103, 0x0165, 0x0356, 0x01a9, 0x039a, 0x03fc, 0x01cf,
|
||||
0x0062, 0x0251, 0x0237, 0x0004, 0x02fb, 0x00c8, 0x00ae, 0x029d,
|
||||
0x0363, 0x0150, 0x0136, 0x0305, 0x01fa, 0x03c9, 0x03af, 0x019c,
|
||||
0x0053, 0x0260, 0x0206, 0x0035, 0x02ca, 0x00f9, 0x009f, 0x02ac,
|
||||
0x0352, 0x0161, 0x0107, 0x0334, 0x01cb, 0x03f8, 0x039e, 0x01ad,
|
||||
0x00c4, 0x02f7, 0x0291, 0x00a2, 0x025d, 0x006e, 0x0008, 0x023b,
|
||||
0x03c5, 0x01f6, 0x0190, 0x03a3, 0x015c, 0x036f, 0x0309, 0x013a,
|
||||
0x00f5, 0x02c6, 0x02a0, 0x0093, 0x026c, 0x005f, 0x0039, 0x020a,
|
||||
0x03f4, 0x01c7, 0x01a1, 0x0392, 0x016d, 0x035e, 0x0338, 0x010b,
|
||||
0x00a6, 0x0295, 0x02f3, 0x00c0, 0x023f, 0x000c, 0x006a, 0x0259,
|
||||
0x03a7, 0x0194, 0x01f2, 0x03c1, 0x013e, 0x030d, 0x036b, 0x0158,
|
||||
0x0097, 0x02a4, 0x02c2, 0x00f1, 0x020e, 0x003d, 0x005b, 0x0268,
|
||||
0x0396, 0x01a5, 0x01c3, 0x03f0, 0x010f, 0x033c, 0x035a, 0x0169,
|
||||
0x0188, 0x03bb, 0x03dd, 0x01ee, 0x0311, 0x0122, 0x0144, 0x0377,
|
||||
0x0289, 0x00ba, 0x00dc, 0x02ef, 0x0010, 0x0223, 0x0245, 0x0076,
|
||||
0x01b9, 0x038a, 0x03ec, 0x01df, 0x0320, 0x0113, 0x0175, 0x0346,
|
||||
0x02b8, 0x008b, 0x00ed, 0x02de, 0x0021, 0x0212, 0x0274, 0x0047,
|
||||
0x01ea, 0x03d9, 0x03bf, 0x018c, 0x0373, 0x0140, 0x0126, 0x0315,
|
||||
0x02eb, 0x00d8, 0x00be, 0x028d, 0x0072, 0x0241, 0x0227, 0x0014,
|
||||
0x01db, 0x03e8, 0x038e, 0x01bd, 0x0342, 0x0171, 0x0117, 0x0324,
|
||||
0x02da, 0x00e9, 0x008f, 0x02bc, 0x0043, 0x0270, 0x0216, 0x0025,
|
||||
0x014c, 0x037f, 0x0319, 0x012a, 0x03d5, 0x01e6, 0x0180, 0x03b3,
|
||||
0x024d, 0x007e, 0x0018, 0x022b, 0x00d4, 0x02e7, 0x0281, 0x00b2,
|
||||
0x017d, 0x034e, 0x0328, 0x011b, 0x03e4, 0x01d7, 0x01b1, 0x0382,
|
||||
0x027c, 0x004f, 0x0029, 0x021a, 0x00e5, 0x02d6, 0x02b0, 0x0083,
|
||||
0x012e, 0x031d, 0x037b, 0x0148, 0x03b7, 0x0184, 0x01e2, 0x03d1,
|
||||
0x022f, 0x001c, 0x007a, 0x0249, 0x00b6, 0x0285, 0x02e3, 0x00d0,
|
||||
0x011f, 0x032c, 0x034a, 0x0179, 0x0386, 0x01b5, 0x01d3, 0x03e0,
|
||||
0x021e, 0x002d, 0x004b, 0x0278, 0x0087, 0x02b4, 0x02d2, 0x00e1
|
||||
};
|
||||
|
||||
static void
|
||||
init_crc10_table(void)
|
||||
{
|
||||
#define CRC10_POLYNOMIAL 0x633
|
||||
register int i, j;
|
||||
register uint16_t accum;
|
||||
uint16_t verify_crc10_table[256];
|
||||
|
||||
for ( i = 0; i < 256; i++ )
|
||||
{
|
||||
accum = ((unsigned short) i << 2);
|
||||
for ( j = 0; j < 8; j++ )
|
||||
{
|
||||
if ((accum <<= 1) & 0x400) accum ^= CRC10_POLYNOMIAL;
|
||||
}
|
||||
verify_crc10_table[i] = accum;
|
||||
}
|
||||
assert(memcmp(verify_crc10_table,
|
||||
crc10_table,
|
||||
sizeof(verify_crc10_table)) == 0);
|
||||
#undef CRC10_POLYNOMIAL
|
||||
}
|
||||
|
||||
uint16_t
|
||||
verify_crc10_cksum(uint16_t accum, const u_char *p, int length)
|
||||
{
|
||||
register int i;
|
||||
|
||||
for ( i = 0; i < length; i++ )
|
||||
{
|
||||
accum = ((accum << 8) & 0x3ff)
|
||||
^ crc10_table[( accum >> 2) & 0xff]
|
||||
^ *p++;
|
||||
}
|
||||
return accum;
|
||||
}
|
||||
|
||||
/* precompute checksum tables */
|
||||
void
|
||||
init_checksum(void) {
|
||||
|
||||
init_crc10_table();
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates the OSI Fletcher checksum. See 8473-1, Appendix C, section C.3.
|
||||
* The checksum field of the passed PDU does not need to be reset to zero.
|
||||
*/
|
||||
uint16_t
|
||||
create_osi_cksum (const uint8_t *pptr, int checksum_offset, int length)
|
||||
{
|
||||
|
||||
int x;
|
||||
int y;
|
||||
uint32_t mul;
|
||||
uint32_t c0;
|
||||
uint32_t c1;
|
||||
uint16_t checksum;
|
||||
int idx;
|
||||
|
||||
c0 = 0;
|
||||
c1 = 0;
|
||||
|
||||
for (idx = 0; idx < length; idx++) {
|
||||
/*
|
||||
* Ignore the contents of the checksum field.
|
||||
*/
|
||||
if (idx == checksum_offset ||
|
||||
idx == checksum_offset+1) {
|
||||
c1 += c0;
|
||||
pptr++;
|
||||
} else {
|
||||
c0 = c0 + *(pptr++);
|
||||
c1 += c0;
|
||||
}
|
||||
}
|
||||
|
||||
c0 = c0 % 255;
|
||||
c1 = c1 % 255;
|
||||
|
||||
mul = (length - checksum_offset)*(c0);
|
||||
|
||||
x = mul - c0 - c1;
|
||||
y = c1 - mul - 1;
|
||||
|
||||
if ( y >= 0 ) y++;
|
||||
if ( x < 0 ) x--;
|
||||
|
||||
x %= 255;
|
||||
y %= 255;
|
||||
|
||||
|
||||
if (x == 0) x = 255;
|
||||
if (y == 0) y = 255;
|
||||
|
||||
y &= 0x00FF;
|
||||
checksum = ((x << 8) | y);
|
||||
|
||||
return checksum;
|
||||
}
|
||||
1435
config.guess
vendored
Normal file
1435
config.guess
vendored
Normal file
File diff suppressed because it is too large
Load Diff
394
config.h.in
Normal file
394
config.h.in
Normal file
@@ -0,0 +1,394 @@
|
||||
/* config.h.in. Generated from configure.in by autoheader. */
|
||||
|
||||
/* define if you want to build the possibly-buggy SMB printer */
|
||||
#undef ENABLE_SMB
|
||||
|
||||
/* Define to 1 if you have the `alarm' function. */
|
||||
#undef HAVE_ALARM
|
||||
|
||||
/* Define to 1 if you have the `bpf_dump' function. */
|
||||
#undef HAVE_BPF_DUMP
|
||||
|
||||
/* capsicum support available */
|
||||
#undef HAVE_CAPSICUM
|
||||
|
||||
/* Define to 1 if you have the `cap_enter' function. */
|
||||
#undef HAVE_CAP_ENTER
|
||||
|
||||
/* Define to 1 if you have the `cap_ioctls_limit' function. */
|
||||
#undef HAVE_CAP_IOCTLS_LIMIT
|
||||
|
||||
/* Define to 1 if you have the <cap-ng.h> header file. */
|
||||
#undef HAVE_CAP_NG_H
|
||||
|
||||
/* Define to 1 if you have the `cap_rights_limit' function. */
|
||||
#undef HAVE_CAP_RIGHTS_LIMIT
|
||||
|
||||
/* Define to 1 if you have the declaration of `ether_ntohost', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_ETHER_NTOHOST
|
||||
|
||||
/* define if you have the dnet_htoa function */
|
||||
#undef HAVE_DNET_HTOA
|
||||
|
||||
/* Define to 1 if you have the `ether_ntohost' function. */
|
||||
#undef HAVE_ETHER_NTOHOST
|
||||
|
||||
/* Define to 1 if you have the `EVP_CIPHER_CTX_new' function. */
|
||||
#undef HAVE_EVP_CIPHER_CTX_NEW
|
||||
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#undef HAVE_FCNTL_H
|
||||
|
||||
/* Define to 1 if you have the `fork' function. */
|
||||
#undef HAVE_FORK
|
||||
|
||||
/* Define to 1 if you have the `getopt_long' function. */
|
||||
#undef HAVE_GETOPT_LONG
|
||||
|
||||
/* define if you have getrpcbynumber() */
|
||||
#undef HAVE_GETRPCBYNUMBER
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the `cap-ng' library (-lcap-ng). */
|
||||
#undef HAVE_LIBCAP_NG
|
||||
|
||||
/* Define to 1 if you have the `crypto' library (-lcrypto). */
|
||||
#undef HAVE_LIBCRYPTO
|
||||
|
||||
/* Define to 1 if you have the `rpc' library (-lrpc). */
|
||||
#undef HAVE_LIBRPC
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if you have the <netdnet/dnetdb.h> header file. */
|
||||
#undef HAVE_NETDNET_DNETDB_H
|
||||
|
||||
/* define if you have a dnet_htoa declaration in <netdnet/dnetdb.h> */
|
||||
#undef HAVE_NETDNET_DNETDB_H_DNET_HTOA
|
||||
|
||||
/* Define to 1 if you have the <netinet/ether.h> header file. */
|
||||
#undef HAVE_NETINET_ETHER_H
|
||||
|
||||
/* Define to 1 if you have the <netinet/if_ether.h> header file. */
|
||||
#undef HAVE_NETINET_IF_ETHER_H
|
||||
|
||||
/* Define to 1 if you have the <net/if_pflog.h> header file. */
|
||||
#undef HAVE_NET_IF_PFLOG_H
|
||||
|
||||
/* Define to 1 if you have the <net/pfvar.h> header file. */
|
||||
#undef HAVE_NET_PFVAR_H
|
||||
|
||||
/* Define to 1 if you have the `openat' function. */
|
||||
#undef HAVE_OPENAT
|
||||
|
||||
/* Define to 1 if you have the <openssl/evp.h> header file. */
|
||||
#undef HAVE_OPENSSL_EVP_H
|
||||
|
||||
/* define if the OS provides AF_INET6 and struct in6_addr */
|
||||
#undef HAVE_OS_IPV6_SUPPORT
|
||||
|
||||
/* if there's an os_proto.h for this platform, to use additional prototypes */
|
||||
#undef HAVE_OS_PROTO_H
|
||||
|
||||
/* Define to 1 if you have the <pcap/bluetooth.h> header file. */
|
||||
#undef HAVE_PCAP_BLUETOOTH_H
|
||||
|
||||
/* Define to 1 if you have the `pcap_breakloop' function. */
|
||||
#undef HAVE_PCAP_BREAKLOOP
|
||||
|
||||
/* Define to 1 if you have the `pcap_create' function. */
|
||||
#undef HAVE_PCAP_CREATE
|
||||
|
||||
/* define if libpcap has pcap_datalink_name_to_val() */
|
||||
#undef HAVE_PCAP_DATALINK_NAME_TO_VAL
|
||||
|
||||
/* define if libpcap has pcap_datalink_val_to_description() */
|
||||
#undef HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION
|
||||
|
||||
/* define if libpcap has pcap_debug */
|
||||
#undef HAVE_PCAP_DEBUG
|
||||
|
||||
/* Define to 1 if you have the `pcap_dump_flush' function. */
|
||||
#undef HAVE_PCAP_DUMP_FLUSH
|
||||
|
||||
/* define if libpcap has pcap_dump_ftell() */
|
||||
#undef HAVE_PCAP_DUMP_FTELL
|
||||
|
||||
/* Define to 1 if you have the `pcap_findalldevs' function. */
|
||||
#undef HAVE_PCAP_FINDALLDEVS
|
||||
|
||||
/* Define to 1 if you have the `pcap_free_datalinks' function. */
|
||||
#undef HAVE_PCAP_FREE_DATALINKS
|
||||
|
||||
/* Define to 1 if the system has the type `pcap_if_t'. */
|
||||
#undef HAVE_PCAP_IF_T
|
||||
|
||||
/* Define to 1 if you have the `pcap_lib_version' function. */
|
||||
#undef HAVE_PCAP_LIB_VERSION
|
||||
|
||||
/* define if libpcap has pcap_list_datalinks() */
|
||||
#undef HAVE_PCAP_LIST_DATALINKS
|
||||
|
||||
/* Define to 1 if you have the <pcap/nflog.h> header file. */
|
||||
#undef HAVE_PCAP_NFLOG_H
|
||||
|
||||
/* Define to 1 if you have the `pcap_setdirection' function. */
|
||||
#undef HAVE_PCAP_SETDIRECTION
|
||||
|
||||
/* Define to 1 if you have the `pcap_set_datalink' function. */
|
||||
#undef HAVE_PCAP_SET_DATALINK
|
||||
|
||||
/* Define to 1 if you have the `pcap_set_immediate_mode' function. */
|
||||
#undef HAVE_PCAP_SET_IMMEDIATE_MODE
|
||||
|
||||
/* Define to 1 if you have the `pcap_set_optimizer_debug' function. */
|
||||
#undef HAVE_PCAP_SET_OPTIMIZER_DEBUG
|
||||
|
||||
/* Define to 1 if you have the `pcap_set_parser_debug' function. */
|
||||
#undef HAVE_PCAP_SET_PARSER_DEBUG
|
||||
|
||||
/* Define to 1 if you have the `pcap_set_tstamp_precision' function. */
|
||||
#undef HAVE_PCAP_SET_TSTAMP_PRECISION
|
||||
|
||||
/* Define to 1 if you have the `pcap_set_tstamp_type' function. */
|
||||
#undef HAVE_PCAP_SET_TSTAMP_TYPE
|
||||
|
||||
/* Define to 1 if you have the <pcap/usb.h> header file. */
|
||||
#undef HAVE_PCAP_USB_H
|
||||
|
||||
/* define if libpcap has pcap_version */
|
||||
#undef HAVE_PCAP_VERSION
|
||||
|
||||
/* Define to 1 if you have the `pfopen' function. */
|
||||
#undef HAVE_PFOPEN
|
||||
|
||||
/* Define to 1 if you have the <rpc/rpcent.h> header file. */
|
||||
#undef HAVE_RPC_RPCENT_H
|
||||
|
||||
/* Define to 1 if you have the <rpc/rpc.h> header file. */
|
||||
#undef HAVE_RPC_RPC_H
|
||||
|
||||
/* Define to 1 if you have the `setlinebuf' function. */
|
||||
#undef HAVE_SETLINEBUF
|
||||
|
||||
/* Define to 1 if you have the `sigaction' function. */
|
||||
#undef HAVE_SIGACTION
|
||||
|
||||
/* Define to 1 if you have the `sigset' function. */
|
||||
#undef HAVE_SIGSET
|
||||
|
||||
/* Define to 1 if you have the `snprintf' function. */
|
||||
#undef HAVE_SNPRINTF
|
||||
|
||||
/* if struct sockaddr has the sa_len member */
|
||||
#undef HAVE_SOCKADDR_SA_LEN
|
||||
|
||||
/* 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 `strdup' function. */
|
||||
#undef HAVE_STRDUP
|
||||
|
||||
/* Define to 1 if you have the `strftime' function. */
|
||||
#undef HAVE_STRFTIME
|
||||
|
||||
/* 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 `strlcat' function. */
|
||||
#undef HAVE_STRLCAT
|
||||
|
||||
/* Define to 1 if you have the `strlcpy' function. */
|
||||
#undef HAVE_STRLCPY
|
||||
|
||||
/* Define to 1 if you have the `strsep' function. */
|
||||
#undef HAVE_STRSEP
|
||||
|
||||
/* 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/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
/* Define to 1 if the system has the type `uintptr_t'. */
|
||||
#undef HAVE_UINTPTR_T
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define to 1 if you have the `vfork' function. */
|
||||
#undef HAVE_VFORK
|
||||
|
||||
/* Define to 1 if you have the `vfprintf' function. */
|
||||
#undef HAVE_VFPRINTF
|
||||
|
||||
/* Define to 1 if you have the `vsnprintf' function. */
|
||||
#undef HAVE_VSNPRINTF
|
||||
|
||||
/* define if libpcap has yydebug */
|
||||
#undef HAVE_YYDEBUG
|
||||
|
||||
/* define if your compiler has __attribute__ */
|
||||
#undef HAVE___ATTRIBUTE__
|
||||
|
||||
/* if unaligned access fails */
|
||||
#undef LBL_ALIGN
|
||||
|
||||
/* Define to 1 if netinet/ether.h declares `ether_ntohost' */
|
||||
#undef NETINET_ETHER_H_DECLARES_ETHER_NTOHOST
|
||||
|
||||
/* Define to 1 if netinet/if_ether.h declares `ether_ntohost' */
|
||||
#undef NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#undef PACKAGE_NAME
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#undef PACKAGE_STRING
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#undef PACKAGE_URL
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* define if the platform doesn't define PRId64 */
|
||||
#undef PRId64
|
||||
|
||||
/* define if the platform doesn't define PRIo64 */
|
||||
#undef PRIo64
|
||||
|
||||
/* define if the platform doesn't define PRIx64 */
|
||||
#undef PRIu64
|
||||
|
||||
/* define if the platform doesn't define PRIu64 */
|
||||
#undef PRIx64
|
||||
|
||||
/* Define as the return type of signal handlers (`int' or `void'). */
|
||||
#undef RETSIGTYPE
|
||||
|
||||
/* return value of signal handlers */
|
||||
#undef RETSIGVAL
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
|
||||
#undef TIME_WITH_SYS_TIME
|
||||
|
||||
/* define if you have ether_ntohost() and it works */
|
||||
#undef USE_ETHER_NTOHOST
|
||||
|
||||
/* Define if you enable support for libsmi */
|
||||
#undef USE_LIBSMI
|
||||
|
||||
/* define if should chroot when dropping privileges */
|
||||
#undef WITH_CHROOT
|
||||
|
||||
/* define if should drop privileges by default */
|
||||
#undef WITH_USER
|
||||
|
||||
/* get BSD semantics on Irix */
|
||||
#undef _BSD_SIGNALS
|
||||
|
||||
/* define on AIX to get certain functions */
|
||||
#undef _SUN
|
||||
|
||||
/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
|
||||
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
|
||||
#define below would cause a syntax error. */
|
||||
#undef _UINT32_T
|
||||
|
||||
/* Define for Solaris 2.5.1 so the uint64_t typedef from <sys/synch.h>,
|
||||
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
|
||||
#define below would cause a syntax error. */
|
||||
#undef _UINT64_T
|
||||
|
||||
/* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
|
||||
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
|
||||
#define below would cause a syntax error. */
|
||||
#undef _UINT8_T
|
||||
|
||||
/* define if your compiler allows __attribute__((format)) without a warning */
|
||||
#undef __ATTRIBUTE___FORMAT_OK
|
||||
|
||||
/* define if your compiler allows __attribute__((format)) to be applied to
|
||||
function pointers */
|
||||
#undef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS
|
||||
|
||||
/* define if your compiler allows __attribute__((noreturn)) to be applied to
|
||||
function pointers */
|
||||
#undef __ATTRIBUTE___NORETURN_OK_FOR_FUNCTION_POINTERS
|
||||
|
||||
/* to handle Ultrix compilers that don't support const in prototypes */
|
||||
#undef const
|
||||
|
||||
/* Define as token for inline if inlining supported */
|
||||
#undef inline
|
||||
|
||||
/* Define to the type of a signed integer type of width exactly 16 bits if
|
||||
such a type exists and the standard includes do not define it. */
|
||||
#undef int16_t
|
||||
|
||||
/* Define to the type of a signed integer type of width exactly 32 bits if
|
||||
such a type exists and the standard includes do not define it. */
|
||||
#undef int32_t
|
||||
|
||||
/* Define to the type of a signed integer type of width exactly 64 bits if
|
||||
such a type exists and the standard includes do not define it. */
|
||||
#undef int64_t
|
||||
|
||||
/* Define to the type of a signed integer type of width exactly 8 bits if such
|
||||
a type exists and the standard includes do not define it. */
|
||||
#undef int8_t
|
||||
|
||||
/* Define to `uint16_t' if u_int16_t not defined. */
|
||||
#undef u_int16_t
|
||||
|
||||
/* Define to `uint32_t' if u_int32_t not defined. */
|
||||
#undef u_int32_t
|
||||
|
||||
/* Define to `uint64_t' if u_int64_t not defined. */
|
||||
#undef u_int64_t
|
||||
|
||||
/* Define to `uint8_t' if u_int8_t not defined. */
|
||||
#undef u_int8_t
|
||||
|
||||
/* Define to the type of an unsigned integer type of width exactly 16 bits if
|
||||
such a type exists and the standard includes do not define it. */
|
||||
#undef uint16_t
|
||||
|
||||
/* Define to the type of an unsigned integer type of width exactly 32 bits if
|
||||
such a type exists and the standard includes do not define it. */
|
||||
#undef uint32_t
|
||||
|
||||
/* Define to the type of an unsigned integer type of width exactly 64 bits if
|
||||
such a type exists and the standard includes do not define it. */
|
||||
#undef uint64_t
|
||||
|
||||
/* Define to the type of an unsigned integer type of width exactly 8 bits if
|
||||
such a type exists and the standard includes do not define it. */
|
||||
#undef uint8_t
|
||||
|
||||
/* Define to the type of an unsigned integer type wide enough to hold a
|
||||
pointer, if such a type exists, and if the system does not define it. */
|
||||
#undef uintptr_t
|
||||
1807
config.sub
vendored
Normal file
1807
config.sub
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1006
configure.in
Normal file
1006
configure.in
Normal file
File diff suppressed because it is too large
Load Diff
155
cpack.c
Normal file
155
cpack.c
Normal file
@@ -0,0 +1,155 @@
|
||||
/*-
|
||||
* Copyright (c) 2003, 2004 David Young. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of David Young may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``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 DAVID
|
||||
* YOUNG BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <netdissect-stdinc.h>
|
||||
|
||||
#include "cpack.h"
|
||||
#include "extract.h"
|
||||
|
||||
const uint8_t *
|
||||
cpack_next_boundary(const uint8_t *buf, const uint8_t *p, size_t alignment)
|
||||
{
|
||||
size_t misalignment = (size_t)(p - buf) % alignment;
|
||||
|
||||
if (misalignment == 0)
|
||||
return p;
|
||||
|
||||
return p + (alignment - misalignment);
|
||||
}
|
||||
|
||||
/* Advance to the next wordsize boundary. Return NULL if fewer than
|
||||
* wordsize bytes remain in the buffer after the boundary. Otherwise,
|
||||
* return a pointer to the boundary.
|
||||
*/
|
||||
const uint8_t *
|
||||
cpack_align_and_reserve(struct cpack_state *cs, size_t wordsize)
|
||||
{
|
||||
const uint8_t *next;
|
||||
|
||||
/* Ensure alignment. */
|
||||
next = cpack_next_boundary(cs->c_buf, cs->c_next, wordsize);
|
||||
|
||||
/* Too little space for wordsize bytes? */
|
||||
if (next - cs->c_buf + wordsize > cs->c_len)
|
||||
return NULL;
|
||||
|
||||
return next;
|
||||
}
|
||||
|
||||
/* Advance by N bytes without returning them. */
|
||||
int
|
||||
cpack_advance(struct cpack_state *cs, const size_t toskip)
|
||||
{
|
||||
/* No space left? */
|
||||
if (cs->c_next - cs->c_buf + toskip > cs->c_len)
|
||||
return -1;
|
||||
cs->c_next += toskip;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
cpack_init(struct cpack_state *cs, const uint8_t *buf, size_t buflen)
|
||||
{
|
||||
memset(cs, 0, sizeof(*cs));
|
||||
|
||||
cs->c_buf = buf;
|
||||
cs->c_len = buflen;
|
||||
cs->c_next = cs->c_buf;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Unpack a 64-bit unsigned integer. */
|
||||
int
|
||||
cpack_uint64(struct cpack_state *cs, uint64_t *u)
|
||||
{
|
||||
const uint8_t *next;
|
||||
|
||||
if ((next = cpack_align_and_reserve(cs, sizeof(*u))) == NULL)
|
||||
return -1;
|
||||
|
||||
*u = EXTRACT_LE_64BITS(next);
|
||||
|
||||
/* Move pointer past the uint64_t. */
|
||||
cs->c_next = next + sizeof(*u);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Unpack a 32-bit unsigned integer. */
|
||||
int
|
||||
cpack_uint32(struct cpack_state *cs, uint32_t *u)
|
||||
{
|
||||
const uint8_t *next;
|
||||
|
||||
if ((next = cpack_align_and_reserve(cs, sizeof(*u))) == NULL)
|
||||
return -1;
|
||||
|
||||
*u = EXTRACT_LE_32BITS(next);
|
||||
|
||||
/* Move pointer past the uint32_t. */
|
||||
cs->c_next = next + sizeof(*u);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Unpack a 16-bit unsigned integer. */
|
||||
int
|
||||
cpack_uint16(struct cpack_state *cs, uint16_t *u)
|
||||
{
|
||||
const uint8_t *next;
|
||||
|
||||
if ((next = cpack_align_and_reserve(cs, sizeof(*u))) == NULL)
|
||||
return -1;
|
||||
|
||||
*u = EXTRACT_LE_16BITS(next);
|
||||
|
||||
/* Move pointer past the uint16_t. */
|
||||
cs->c_next = next + sizeof(*u);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Unpack an 8-bit unsigned integer. */
|
||||
int
|
||||
cpack_uint8(struct cpack_state *cs, uint8_t *u)
|
||||
{
|
||||
/* No space left? */
|
||||
if ((size_t)(cs->c_next - cs->c_buf) >= cs->c_len)
|
||||
return -1;
|
||||
|
||||
*u = *cs->c_next;
|
||||
|
||||
/* Move pointer past the uint8_t. */
|
||||
cs->c_next++;
|
||||
return 0;
|
||||
}
|
||||
56
cpack.h
Normal file
56
cpack.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/*-
|
||||
* Copyright (c) 2003, 2004 David Young. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of David Young may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``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 DAVID
|
||||
* YOUNG 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 _CPACK_H
|
||||
#define _CPACK_H
|
||||
|
||||
struct cpack_state {
|
||||
const uint8_t *c_buf;
|
||||
const uint8_t *c_next;
|
||||
size_t c_len;
|
||||
};
|
||||
|
||||
int cpack_init(struct cpack_state *, const uint8_t *, size_t);
|
||||
|
||||
int cpack_uint8(struct cpack_state *, uint8_t *);
|
||||
int cpack_uint16(struct cpack_state *, uint16_t *);
|
||||
int cpack_uint32(struct cpack_state *, uint32_t *);
|
||||
int cpack_uint64(struct cpack_state *, uint64_t *);
|
||||
|
||||
const uint8_t *cpack_next_boundary(const uint8_t *buf, const uint8_t *p, size_t alignment);
|
||||
const uint8_t *cpack_align_and_reserve(struct cpack_state *cs, size_t wordsize);
|
||||
|
||||
#define cpack_int8(__s, __p) cpack_uint8((__s), (uint8_t*)(__p))
|
||||
#define cpack_int16(__s, __p) cpack_uint16((__s), (uint16_t*)(__p))
|
||||
#define cpack_int32(__s, __p) cpack_uint32((__s), (uint32_t*)(__p))
|
||||
#define cpack_int64(__s, __p) cpack_uint64((__s), (uint64_t*)(__p))
|
||||
|
||||
extern int cpack_advance(struct cpack_state *, const size_t);
|
||||
|
||||
#endif /* _CPACK_H */
|
||||
57
ether.h
Normal file
57
ether.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* @(#)if_ether.h 8.3 (Berkeley) 5/2/95
|
||||
*/
|
||||
|
||||
#define ETHERMTU 1500
|
||||
|
||||
/*
|
||||
* The number of bytes in an ethernet (MAC) address.
|
||||
*/
|
||||
#define ETHER_ADDR_LEN 6
|
||||
|
||||
/*
|
||||
* Structure of an Ethernet header.
|
||||
*/
|
||||
struct ether_header {
|
||||
uint8_t ether_dhost[ETHER_ADDR_LEN];
|
||||
uint8_t ether_shost[ETHER_ADDR_LEN];
|
||||
uint16_t ether_length_type;
|
||||
};
|
||||
|
||||
/*
|
||||
* Length of an Ethernet header; note that some compilers may pad
|
||||
* "struct ether_header" to a multiple of 4 bytes, for example, so
|
||||
* "sizeof (struct ether_header)" may not give the right answer.
|
||||
*/
|
||||
#define ETHER_HDRLEN 14
|
||||
203
ethertype.h
Normal file
203
ethertype.h
Normal file
@@ -0,0 +1,203 @@
|
||||
/*
|
||||
* Copyright (c) 1993, 1994, 1996
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that: (1) source code distributions
|
||||
* retain the above copyright notice and this paragraph in its entirety, (2)
|
||||
* distributions including binary code include the above copyright notice and
|
||||
* this paragraph in its entirety in the documentation or other materials
|
||||
* provided with the distribution, and (3) all advertising materials mentioning
|
||||
* features or use of this software display the following acknowledgement:
|
||||
* ``This product includes software developed by the University of California,
|
||||
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
|
||||
* the University nor the names of its contributors may be used to endorse
|
||||
* or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Ethernet types.
|
||||
*
|
||||
* We wrap the declarations with #ifdef, so that if a file includes
|
||||
* <netinet/if_ether.h>, which may declare some of these, we don't
|
||||
* get a bunch of complaints from the C compiler about redefinitions
|
||||
* of these values.
|
||||
*
|
||||
* We declare all of them here so that no file has to include
|
||||
* <netinet/if_ether.h> if all it needs are ETHERTYPE_ values.
|
||||
*/
|
||||
|
||||
#ifndef ETHERTYPE_LEN
|
||||
#define ETHERTYPE_LEN 2
|
||||
#endif
|
||||
|
||||
#ifndef ETHERTYPE_GRE_ISO
|
||||
#define ETHERTYPE_GRE_ISO 0x00FE /* not really an ethertype only used in GRE */
|
||||
#endif
|
||||
#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_TEB
|
||||
#define ETHERTYPE_TEB 0x6558
|
||||
#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_TIPC
|
||||
#define ETHERTYPE_TIPC 0x88ca
|
||||
#endif
|
||||
#ifndef ETHERTYPE_8021Q
|
||||
#define ETHERTYPE_8021Q 0x8100
|
||||
#endif
|
||||
|
||||
/* see:
|
||||
http://en.wikipedia.org/wiki/IEEE_802.1Q
|
||||
and http://en.wikipedia.org/wiki/QinQ
|
||||
*/
|
||||
#ifndef ETHERTYPE_8021Q9100
|
||||
#define ETHERTYPE_8021Q9100 0x9100
|
||||
#endif
|
||||
#ifndef ETHERTYPE_8021Q9200
|
||||
#define ETHERTYPE_8021Q9200 0x9200
|
||||
#endif
|
||||
#ifndef ETHERTYPE_8021QinQ
|
||||
#define ETHERTYPE_8021QinQ 0x88a8
|
||||
#endif
|
||||
#ifndef ETHERTYPE_IPX
|
||||
#define ETHERTYPE_IPX 0x8137
|
||||
#endif
|
||||
#ifndef ETHERTYPE_IPV6
|
||||
#define ETHERTYPE_IPV6 0x86dd
|
||||
#endif
|
||||
#ifndef ETHERTYPE_PPP
|
||||
#define ETHERTYPE_PPP 0x880b
|
||||
#endif
|
||||
#ifndef ETHERTYPE_MPCP
|
||||
#define ETHERTYPE_MPCP 0x8808
|
||||
#endif
|
||||
#ifndef ETHERTYPE_SLOW
|
||||
#define ETHERTYPE_SLOW 0x8809
|
||||
#endif
|
||||
#ifndef ETHERTYPE_MPLS
|
||||
#define ETHERTYPE_MPLS 0x8847
|
||||
#endif
|
||||
#ifndef ETHERTYPE_MPLS_MULTI
|
||||
#define ETHERTYPE_MPLS_MULTI 0x8848
|
||||
#endif
|
||||
#ifndef ETHERTYPE_PPPOED
|
||||
#define ETHERTYPE_PPPOED 0x8863
|
||||
#endif
|
||||
#ifndef ETHERTYPE_PPPOES
|
||||
#define ETHERTYPE_PPPOES 0x8864
|
||||
#endif
|
||||
#ifndef ETHERTYPE_PPPOED2
|
||||
#define ETHERTYPE_PPPOED2 0x3c12
|
||||
#endif
|
||||
#ifndef ETHERTYPE_PPPOES2
|
||||
#define ETHERTYPE_PPPOES2 0x3c13
|
||||
#endif
|
||||
#ifndef ETHERTYPE_MS_NLB_HB
|
||||
#define ETHERTYPE_MS_NLB_HB 0x886f /* MS Network Load Balancing Heartbeat */
|
||||
#endif
|
||||
#ifndef ETHERTYPE_JUMBO
|
||||
#define ETHERTYPE_JUMBO 0x8870
|
||||
#endif
|
||||
#ifndef ETHERTYPE_LLDP
|
||||
#define ETHERTYPE_LLDP 0x88cc
|
||||
#endif
|
||||
#ifndef ETHERTYPE_EAPOL
|
||||
#define ETHERTYPE_EAPOL 0x888e
|
||||
#endif
|
||||
#ifndef ETHERTYPE_RRCP
|
||||
#define ETHERTYPE_RRCP 0x8899
|
||||
#endif
|
||||
#ifndef ETHERTYPE_AOE
|
||||
#define ETHERTYPE_AOE 0x88a2
|
||||
#endif
|
||||
#ifndef ETHERTYPE_LOOPBACK
|
||||
#define ETHERTYPE_LOOPBACK 0x9000
|
||||
#endif
|
||||
#ifndef ETHERTYPE_VMAN
|
||||
#define ETHERTYPE_VMAN 0x9100 /* Extreme VMAN Protocol */
|
||||
#endif
|
||||
#ifndef ETHERTYPE_CFM_OLD
|
||||
#define ETHERTYPE_CFM_OLD 0xabcd /* 802.1ag depreciated */
|
||||
#endif
|
||||
#ifndef ETHERTYPE_CFM
|
||||
#define ETHERTYPE_CFM 0x8902 /* 802.1ag */
|
||||
#endif
|
||||
#ifndef ETHERTYPE_IEEE1905_1
|
||||
#define ETHERTYPE_IEEE1905_1 0x893a /* IEEE 1905.1 */
|
||||
#endif
|
||||
#ifndef ETHERTYPE_ISO
|
||||
#define ETHERTYPE_ISO 0xfefe /* nonstandard - used in Cisco HDLC encapsulation */
|
||||
#endif
|
||||
#ifndef ETHERTYPE_CALM_FAST
|
||||
#define ETHERTYPE_CALM_FAST 0x1111 /* ISO CALM FAST */
|
||||
#endif
|
||||
#ifndef ETHERTYPE_GEONET_OLD
|
||||
#define ETHERTYPE_GEONET_OLD 0x0707 /* ETSI GeoNetworking (before Jan 2013) */
|
||||
#endif
|
||||
#ifndef ETHERTYPE_GEONET
|
||||
#define ETHERTYPE_GEONET 0x8947 /* ETSI GeoNetworking (Official IEEE registration from Jan 2013) */
|
||||
#endif
|
||||
#ifndef ETHERTYPE_MEDSA
|
||||
#define ETHERTYPE_MEDSA 0xdada /* Marvel Distributed Switch Architecture */
|
||||
#endif
|
||||
|
||||
extern const struct tok ethertype_values[];
|
||||
217
extract.h
Normal file
217
extract.h
Normal file
@@ -0,0 +1,217 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Macros to extract possibly-unaligned big-endian integral values.
|
||||
*/
|
||||
#ifdef LBL_ALIGN
|
||||
/*
|
||||
* The processor doesn't natively handle unaligned loads.
|
||||
*/
|
||||
#if defined(__GNUC__) && defined(HAVE___ATTRIBUTE__) && \
|
||||
(defined(__alpha) || defined(__alpha__) || \
|
||||
defined(__mips) || defined(__mips__))
|
||||
|
||||
/*
|
||||
* This is a GCC-compatible compiler and we have __attribute__, which
|
||||
* we assume that mean we have __attribute__((packed)), and this is
|
||||
* MIPS or Alpha, which has instructions that can help when doing
|
||||
* unaligned loads.
|
||||
*
|
||||
* Declare packed structures containing a uint16_t and a uint32_t,
|
||||
* cast the pointer to point to one of those, and fetch through it;
|
||||
* the GCC manual doesn't appear to explicitly say that
|
||||
* __attribute__((packed)) causes the compiler to generate unaligned-safe
|
||||
* code, but it apppears to do so.
|
||||
*
|
||||
* We do this in case the compiler can generate code using those
|
||||
* instructions to do an unaligned load and pass stuff to "ntohs()" or
|
||||
* "ntohl()", which might be better than than the code to fetch the
|
||||
* bytes one at a time and assemble them. (That might not be the
|
||||
* case on a little-endian platform, such as DEC's MIPS machines and
|
||||
* Alpha machines, where "ntohs()" and "ntohl()" might not be done
|
||||
* inline.)
|
||||
*
|
||||
* We do this only for specific architectures because, for example,
|
||||
* at least some versions of GCC, when compiling for 64-bit SPARC,
|
||||
* generate code that assumes alignment if we do this.
|
||||
*
|
||||
* XXX - add other architectures and compilers as possible and
|
||||
* appropriate.
|
||||
*
|
||||
* HP's C compiler, indicated by __HP_cc being defined, supports
|
||||
* "#pragma unaligned N" in version A.05.50 and later, where "N"
|
||||
* specifies a number of bytes at which the typedef on the next
|
||||
* line is aligned, e.g.
|
||||
*
|
||||
* #pragma unalign 1
|
||||
* typedef uint16_t unaligned_uint16_t;
|
||||
*
|
||||
* to define unaligned_uint16_t as a 16-bit unaligned data type.
|
||||
* This could be presumably used, in sufficiently recent versions of
|
||||
* the compiler, with macros similar to those below. This would be
|
||||
* useful only if that compiler could generate better code for PA-RISC
|
||||
* or Itanium than would be generated by a bunch of shifts-and-ORs.
|
||||
*
|
||||
* DEC C, indicated by __DECC being defined, has, at least on Alpha,
|
||||
* an __unaligned qualifier that can be applied to pointers to get the
|
||||
* compiler to generate code that does unaligned loads and stores when
|
||||
* dereferencing the pointer in question.
|
||||
*
|
||||
* XXX - what if the native C compiler doesn't support
|
||||
* __attribute__((packed))? How can we get it to generate unaligned
|
||||
* accesses for *specific* items?
|
||||
*/
|
||||
typedef struct {
|
||||
uint16_t val;
|
||||
} __attribute__((packed)) unaligned_uint16_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t val;
|
||||
} __attribute__((packed)) unaligned_uint32_t;
|
||||
|
||||
static inline uint16_t
|
||||
EXTRACT_16BITS(const void *p)
|
||||
{
|
||||
return ((uint16_t)ntohs(((const unaligned_uint16_t *)(p))->val));
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
EXTRACT_32BITS(const void *p)
|
||||
{
|
||||
return ((uint32_t)ntohl(((const unaligned_uint32_t *)(p))->val));
|
||||
}
|
||||
|
||||
static inline uint64_t
|
||||
EXTRACT_64BITS(const void *p)
|
||||
{
|
||||
return ((uint64_t)(((uint64_t)ntohl(((const unaligned_uint32_t *)(p) + 0)->val)) << 32 | \
|
||||
((uint64_t)ntohl(((const unaligned_uint32_t *)(p) + 1)->val)) << 0));
|
||||
}
|
||||
|
||||
#else /* have to do it a byte at a time */
|
||||
/*
|
||||
* This isn't a GCC-compatible compiler, we don't have __attribute__,
|
||||
* or we do but we don't know of any better way with this instruction
|
||||
* set to do unaligned loads, so do unaligned loads of big-endian
|
||||
* quantities the hard way - fetch the bytes one at a time and
|
||||
* assemble them.
|
||||
*/
|
||||
#define EXTRACT_16BITS(p) \
|
||||
((uint16_t)(((uint16_t)(*((const uint8_t *)(p) + 0)) << 8) | \
|
||||
((uint16_t)(*((const uint8_t *)(p) + 1)) << 0)))
|
||||
#define EXTRACT_32BITS(p) \
|
||||
((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 0)) << 24) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 1)) << 16) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 2)) << 8) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 3)) << 0)))
|
||||
#define EXTRACT_64BITS(p) \
|
||||
((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 56) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 1)) << 48) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 2)) << 40) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 3)) << 32) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 4)) << 24) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 5)) << 16) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 6)) << 8) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 7)) << 0)))
|
||||
#endif /* must special-case unaligned accesses */
|
||||
#else /* LBL_ALIGN */
|
||||
/*
|
||||
* The processor natively handles unaligned loads, so we can just
|
||||
* cast the pointer and fetch through it.
|
||||
*/
|
||||
static inline uint16_t
|
||||
EXTRACT_16BITS(const void *p)
|
||||
{
|
||||
return ((uint16_t)ntohs(*(const uint16_t *)(p)));
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
EXTRACT_32BITS(const void *p)
|
||||
{
|
||||
return ((uint32_t)ntohl(*(const uint32_t *)(p)));
|
||||
}
|
||||
|
||||
static inline uint64_t
|
||||
EXTRACT_64BITS(const void *p)
|
||||
{
|
||||
return ((uint64_t)(((uint64_t)ntohl(*((const uint32_t *)(p) + 0))) << 32 | \
|
||||
((uint64_t)ntohl(*((const uint32_t *)(p) + 1))) << 0));
|
||||
|
||||
}
|
||||
|
||||
#endif /* LBL_ALIGN */
|
||||
|
||||
#define EXTRACT_24BITS(p) \
|
||||
((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 0)) << 16) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 1)) << 8) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 2)) << 0)))
|
||||
|
||||
#define EXTRACT_40BITS(p) \
|
||||
((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 32) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 1)) << 24) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 2)) << 16) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 3)) << 8) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 4)) << 0)))
|
||||
|
||||
#define EXTRACT_48BITS(p) \
|
||||
((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 40) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 1)) << 32) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 2)) << 24) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 3)) << 16) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 4)) << 8) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 5)) << 0)))
|
||||
|
||||
#define EXTRACT_56BITS(p) \
|
||||
((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 48) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 1)) << 40) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 2)) << 32) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 3)) << 24) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 4)) << 16) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 5)) << 8) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 6)) << 0)))
|
||||
|
||||
/*
|
||||
* Macros to extract possibly-unaligned little-endian integral values.
|
||||
* XXX - do loads on little-endian machines that support unaligned loads?
|
||||
*/
|
||||
#define EXTRACT_LE_8BITS(p) (*(p))
|
||||
#define EXTRACT_LE_16BITS(p) \
|
||||
((uint16_t)(((uint16_t)(*((const uint8_t *)(p) + 1)) << 8) | \
|
||||
((uint16_t)(*((const uint8_t *)(p) + 0)) << 0)))
|
||||
#define EXTRACT_LE_32BITS(p) \
|
||||
((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 3)) << 24) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 2)) << 16) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 1)) << 8) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 0)) << 0)))
|
||||
#define EXTRACT_LE_24BITS(p) \
|
||||
((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 2)) << 16) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 1)) << 8) | \
|
||||
((uint32_t)(*((const uint8_t *)(p) + 0)) << 0)))
|
||||
#define EXTRACT_LE_64BITS(p) \
|
||||
((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 7)) << 56) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 6)) << 48) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 5)) << 40) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 4)) << 32) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 3)) << 24) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 2)) << 16) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 1)) << 8) | \
|
||||
((uint64_t)(*((const uint8_t *)(p) + 0)) << 0)))
|
||||
66
getopt_long.h
Normal file
66
getopt_long.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/* $NetBSD: getopt.h,v 1.4 2000/07/07 10:43:54 ad Exp $ */
|
||||
/* $FreeBSD$ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Dieter Baron and Thomas Klausner.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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 _GETOPT_LONG_H_
|
||||
#define _GETOPT_LONG_H_
|
||||
|
||||
/*
|
||||
* GNU-like getopt_long()/getopt_long_only() with 4.4BSD optreset extension.
|
||||
* getopt() is declared here too for GNU programs.
|
||||
*/
|
||||
#define no_argument 0
|
||||
#define required_argument 1
|
||||
#define optional_argument 2
|
||||
|
||||
struct option {
|
||||
/* name of long option */
|
||||
const char *name;
|
||||
/*
|
||||
* one of no_argument, required_argument, and optional_argument:
|
||||
* whether option takes an argument
|
||||
*/
|
||||
int has_arg;
|
||||
/* if not NULL, set *flag to val when option found */
|
||||
int *flag;
|
||||
/* if flag not NULL, value to set *flag to; else return value */
|
||||
int val;
|
||||
};
|
||||
|
||||
int getopt_long(int, char * const *, const char *,
|
||||
const struct option *, int *);
|
||||
int getopt_long_only(int, char * const *, const char *,
|
||||
const struct option *, int *);
|
||||
|
||||
extern char *optarg; /* getopt(3) external variables */
|
||||
extern int optind, opterr, optopt;
|
||||
|
||||
#endif /* !_GETOPT_LONG_H_ */
|
||||
192
gmpls.c
Normal file
192
gmpls.c
Normal file
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
* 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, and (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.
|
||||
* 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.
|
||||
*
|
||||
* Original code by Hannes Gredler (hannes@juniper.net)
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <netdissect-stdinc.h>
|
||||
|
||||
#include "netdissect.h"
|
||||
#include "gmpls.h"
|
||||
|
||||
/* rfc3471 */
|
||||
const struct tok gmpls_link_prot_values[] = {
|
||||
{ 0x01, "Extra Traffic"},
|
||||
{ 0x02, "Unprotected"},
|
||||
{ 0x04, "Shared"},
|
||||
{ 0x08, "Dedicated 1:1"},
|
||||
{ 0x10, "Dedicated 1+1"},
|
||||
{ 0x20, "Enhanced"},
|
||||
{ 0x40, "Reserved"},
|
||||
{ 0x80, "Reserved"},
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
/* rfc3471 */
|
||||
const struct tok gmpls_switch_cap_values[] = {
|
||||
{ GMPLS_PSC1, "Packet-Switch Capable-1"},
|
||||
{ GMPLS_PSC2, "Packet-Switch Capable-2"},
|
||||
{ GMPLS_PSC3, "Packet-Switch Capable-3"},
|
||||
{ GMPLS_PSC4, "Packet-Switch Capable-4"},
|
||||
{ GMPLS_L2SC, "Layer-2 Switch Capable"},
|
||||
{ GMPLS_TSC, "Time-Division-Multiplex"},
|
||||
{ GMPLS_LSC, "Lambda-Switch Capable"},
|
||||
{ GMPLS_FSC, "Fiber-Switch Capable"},
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
/* rfc4205 */
|
||||
const struct tok gmpls_switch_cap_tsc_indication_values[] = {
|
||||
{ 0, "Standard SONET/SDH" },
|
||||
{ 1, "Arbitrary SONET/SDH" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
/* rfc3471 */
|
||||
const struct tok gmpls_encoding_values[] = {
|
||||
{ 1, "Packet"},
|
||||
{ 2, "Ethernet V2/DIX"},
|
||||
{ 3, "ANSI/ETSI PDH"},
|
||||
{ 4, "Reserved"},
|
||||
{ 5, "SDH ITU-T G.707/SONET ANSI T1.105"},
|
||||
{ 6, "Reserved"},
|
||||
{ 7, "Digital Wrapper"},
|
||||
{ 8, "Lambda (photonic)"},
|
||||
{ 9, "Fiber"},
|
||||
{ 10, "Reserved"},
|
||||
{ 11, "FiberChannel"},
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
/* rfc3471 */
|
||||
const struct tok gmpls_payload_values[] = {
|
||||
{ 0, "Unknown"},
|
||||
{ 1, "Reserved"},
|
||||
{ 2, "Reserved"},
|
||||
{ 3, "Reserved"},
|
||||
{ 4, "Reserved"},
|
||||
{ 5, "Asynchronous mapping of E4"},
|
||||
{ 6, "Asynchronous mapping of DS3/T3"},
|
||||
{ 7, "Asynchronous mapping of E3"},
|
||||
{ 8, "Bit synchronous mapping of E3"},
|
||||
{ 9, "Byte synchronous mapping of E3"},
|
||||
{ 10, "Asynchronous mapping of DS2/T2"},
|
||||
{ 11, "Bit synchronous mapping of DS2/T2"},
|
||||
{ 12, "Reserved"},
|
||||
{ 13, "Asynchronous mapping of E1"},
|
||||
{ 14, "Byte synchronous mapping of E1"},
|
||||
{ 15, "Byte synchronous mapping of 31 * DS0"},
|
||||
{ 16, "Asynchronous mapping of DS1/T1"},
|
||||
{ 17, "Bit synchronous mapping of DS1/T1"},
|
||||
{ 18, "Byte synchronous mapping of DS1/T1"},
|
||||
{ 19, "VC-11 in VC-12"},
|
||||
{ 20, "Reserved"},
|
||||
{ 21, "Reserved"},
|
||||
{ 22, "DS1 SF Asynchronous"},
|
||||
{ 23, "DS1 ESF Asynchronous"},
|
||||
{ 24, "DS3 M23 Asynchronous"},
|
||||
{ 25, "DS3 C-Bit Parity Asynchronous"},
|
||||
{ 26, "VT/LOVC"},
|
||||
{ 27, "STS SPE/HOVC"},
|
||||
{ 28, "POS - No Scrambling, 16 bit CRC"},
|
||||
{ 29, "POS - No Scrambling, 32 bit CRC"},
|
||||
{ 30, "POS - Scrambling, 16 bit CRC"},
|
||||
{ 31, "POS - Scrambling, 32 bit CRC"},
|
||||
{ 32, "ATM mapping"},
|
||||
{ 33, "Ethernet PHY"},
|
||||
{ 34, "SONET/SDH"},
|
||||
{ 35, "Reserved (SONET deprecated)"},
|
||||
{ 36, "Digital Wrapper"},
|
||||
{ 37, "Lambda"},
|
||||
{ 38, "ANSI/ETSI PDH"},
|
||||
{ 39, "Reserved"},
|
||||
{ 40, "Link Access Protocol SDH (X.85 and X.86)"},
|
||||
{ 41, "FDDI"},
|
||||
{ 42, "DQDB (ETSI ETS 300 216)"},
|
||||
{ 43, "FiberChannel-3 (Services)"},
|
||||
{ 44, "HDLC"},
|
||||
{ 45, "Ethernet V2/DIX (only)"},
|
||||
{ 46, "Ethernet 802.3 (only)"},
|
||||
/* draft-ietf-ccamp-gmpls-g709-04.txt */
|
||||
{ 47, "G.709 ODUj"},
|
||||
{ 48, "G.709 OTUk(v)"},
|
||||
{ 49, "CBR/CBRa"},
|
||||
{ 50, "CBRb"},
|
||||
{ 51, "BSOT"},
|
||||
{ 52, "BSNT"},
|
||||
{ 53, "IP/PPP (GFP)"},
|
||||
{ 54, "Ethernet MAC (framed GFP)"},
|
||||
{ 55, "Ethernet PHY (transparent GFP)"},
|
||||
{ 56, "ESCON"},
|
||||
{ 57, "FICON"},
|
||||
{ 58, "Fiber Channel"},
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
/*
|
||||
* Link Type values used by LMP Service Discovery (specifically, the Client
|
||||
* Port Service Attributes Object). See UNI 1.0 section 9.4.2 for details.
|
||||
*/
|
||||
const struct tok lmp_sd_service_config_cpsa_link_type_values[] = {
|
||||
{ 5, "SDH ITU-T G.707"},
|
||||
{ 6, "SONET ANSI T1.105"},
|
||||
{ 0, NULL}
|
||||
};
|
||||
|
||||
/*
|
||||
* Signal Type values for SDH links used by LMP Service Discovery (specifically,
|
||||
* the Client Port Service Attributes Object). See UNI 1.0 section 9.4.2 for
|
||||
* details.
|
||||
*/
|
||||
const struct tok lmp_sd_service_config_cpsa_signal_type_sdh_values[] = {
|
||||
{ 5, "VC-3"},
|
||||
{ 6, "VC-4"},
|
||||
{ 7, "STM-0"},
|
||||
{ 8, "STM-1"},
|
||||
{ 9, "STM-4"},
|
||||
{ 10, "STM-16"},
|
||||
{ 11, "STM-64"},
|
||||
{ 12, "STM-256"},
|
||||
{ 0, NULL}
|
||||
};
|
||||
|
||||
/*
|
||||
* Signal Type values for SONET links used by LMP Service Discovery (specifically,
|
||||
* the Client Port Service Attributes Object). See UNI 1.0 section 9.4.2 for
|
||||
* details.
|
||||
*/
|
||||
const struct tok lmp_sd_service_config_cpsa_signal_type_sonet_values[] = {
|
||||
{ 5, "STS-1 SPE"},
|
||||
{ 6, "STS-3c SPE"},
|
||||
{ 7, "STS-1"},
|
||||
{ 8, "STM-3"},
|
||||
{ 9, "STM-12"},
|
||||
{ 10, "STM-48"},
|
||||
{ 11, "STM-192"},
|
||||
{ 12, "STM-768"},
|
||||
{ 0, NULL}
|
||||
};
|
||||
|
||||
#define DIFFSERV_BC_MODEL_RDM 0 /* draft-ietf-tewg-diff-te-proto-07 */
|
||||
#define DIFFSERV_BC_MODEL_MAM 1 /* draft-ietf-tewg-diff-te-proto-07 */
|
||||
#define DIFFSERV_BC_MODEL_EXTD_MAM 254 /* experimental */
|
||||
|
||||
const struct tok diffserv_te_bc_values[] = {
|
||||
{ DIFFSERV_BC_MODEL_RDM, "Russian dolls"},
|
||||
{ DIFFSERV_BC_MODEL_MAM, "Maximum allocation"},
|
||||
{ DIFFSERV_BC_MODEL_EXTD_MAM, "Maximum allocation with E-LSP support"},
|
||||
{ 0, NULL }
|
||||
};
|
||||
33
gmpls.h
Normal file
33
gmpls.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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, and (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.
|
||||
* 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.
|
||||
*
|
||||
* Original code by Hannes Gredler (hannes@juniper.net)
|
||||
*/
|
||||
|
||||
#define GMPLS_PSC1 1
|
||||
#define GMPLS_PSC2 2
|
||||
#define GMPLS_PSC3 3
|
||||
#define GMPLS_PSC4 4
|
||||
#define GMPLS_L2SC 51
|
||||
#define GMPLS_TSC 100
|
||||
#define GMPLS_LSC 150
|
||||
#define GMPLS_FSC 200
|
||||
|
||||
extern const struct tok gmpls_link_prot_values[];
|
||||
extern const struct tok gmpls_switch_cap_values[];
|
||||
extern const struct tok gmpls_switch_cap_tsc_indication_values[];
|
||||
extern const struct tok gmpls_encoding_values[];
|
||||
extern const struct tok gmpls_payload_values[];
|
||||
extern const struct tok diffserv_te_bc_values[];
|
||||
extern const struct tok lmp_sd_service_config_cpsa_link_type_values[];
|
||||
extern const struct tok lmp_sd_service_config_cpsa_signal_type_sdh_values[];
|
||||
extern const struct tok lmp_sd_service_config_cpsa_signal_type_sonet_values[];
|
||||
66
gmt2local.c
Normal file
66
gmt2local.c
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <netdissect-stdinc.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef HAVE_OS_PROTO_H
|
||||
#include "os-proto.h"
|
||||
#endif
|
||||
|
||||
#include "gmt2local.h"
|
||||
|
||||
/*
|
||||
* Returns the difference between gmt and local time in seconds.
|
||||
* Use gmtime() and localtime() to keep things simple.
|
||||
*/
|
||||
int32_t
|
||||
gmt2local(time_t t)
|
||||
{
|
||||
register int dt, dir;
|
||||
register struct tm *gmt, *loc;
|
||||
struct tm sgmt;
|
||||
|
||||
if (t == 0)
|
||||
t = time(NULL);
|
||||
gmt = &sgmt;
|
||||
*gmt = *gmtime(&t);
|
||||
loc = localtime(&t);
|
||||
dt = (loc->tm_hour - gmt->tm_hour) * 60 * 60 +
|
||||
(loc->tm_min - gmt->tm_min) * 60;
|
||||
|
||||
/*
|
||||
* If the year or julian day is different, we span 00:00 GMT
|
||||
* and must add or subtract a day. Check the year first to
|
||||
* avoid problems when the julian day wraps.
|
||||
*/
|
||||
dir = loc->tm_year - gmt->tm_year;
|
||||
if (dir == 0)
|
||||
dir = loc->tm_yday - gmt->tm_yday;
|
||||
dt += dir * 24 * 60 * 60;
|
||||
|
||||
return (dt);
|
||||
}
|
||||
25
gmt2local.h
Normal file
25
gmt2local.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
#ifndef gmt2local_h
|
||||
#define gmt2local_h
|
||||
|
||||
int32_t gmt2local(time_t);
|
||||
#endif
|
||||
200
in_cksum.c
Normal file
200
in_cksum.c
Normal file
@@ -0,0 +1,200 @@
|
||||
/* in_cksum.c
|
||||
* 4.4-Lite-2 Internet checksum routine, modified to take a vector of
|
||||
* pointers/lengths giving the pieces to be checksummed. Also using
|
||||
* Tahoe/CGI version of ADDCARRY(x) macro instead of from portable version.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1992, 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. 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.
|
||||
*
|
||||
* @(#)in_cksum.c 8.1 (Berkeley) 6/10/93
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <netdissect-stdinc.h>
|
||||
|
||||
#include "netdissect.h"
|
||||
|
||||
/*
|
||||
* Checksum routine for Internet Protocol family headers (Portable Version).
|
||||
*
|
||||
* This routine is very heavily used in the network
|
||||
* code and should be modified for each CPU to be as fast as possible.
|
||||
*/
|
||||
|
||||
#define ADDCARRY(x) {if ((x) > 65535) (x) -= 65535;}
|
||||
#define REDUCE {l_util.l = sum; sum = l_util.s[0] + l_util.s[1]; ADDCARRY(sum);}
|
||||
|
||||
uint16_t
|
||||
in_cksum(const struct cksum_vec *vec, int veclen)
|
||||
{
|
||||
register const uint16_t *w;
|
||||
register int sum = 0;
|
||||
register int mlen = 0;
|
||||
int byte_swapped = 0;
|
||||
|
||||
union {
|
||||
uint8_t c[2];
|
||||
uint16_t s;
|
||||
} s_util;
|
||||
union {
|
||||
uint16_t s[2];
|
||||
uint32_t l;
|
||||
} l_util;
|
||||
|
||||
for (; veclen != 0; vec++, veclen--) {
|
||||
if (vec->len == 0)
|
||||
continue;
|
||||
w = (const uint16_t *)(const void *)vec->ptr;
|
||||
if (mlen == -1) {
|
||||
/*
|
||||
* The first byte of this chunk is the continuation
|
||||
* of a word spanning between this chunk and the
|
||||
* last chunk.
|
||||
*
|
||||
* s_util.c[0] is already saved when scanning previous
|
||||
* chunk.
|
||||
*/
|
||||
s_util.c[1] = *(const uint8_t *)w;
|
||||
sum += s_util.s;
|
||||
w = (const uint16_t *)(const void *)((const uint8_t *)w + 1);
|
||||
mlen = vec->len - 1;
|
||||
} else
|
||||
mlen = vec->len;
|
||||
/*
|
||||
* Force to even boundary.
|
||||
*/
|
||||
if ((1 & (uintptr_t) w) && (mlen > 0)) {
|
||||
REDUCE;
|
||||
sum <<= 8;
|
||||
s_util.c[0] = *(const uint8_t *)w;
|
||||
w = (const uint16_t *)(const void *)((const uint8_t *)w + 1);
|
||||
mlen--;
|
||||
byte_swapped = 1;
|
||||
}
|
||||
/*
|
||||
* Unroll the loop to make overhead from
|
||||
* branches &c small.
|
||||
*/
|
||||
while ((mlen -= 32) >= 0) {
|
||||
sum += w[0]; sum += w[1]; sum += w[2]; sum += w[3];
|
||||
sum += w[4]; sum += w[5]; sum += w[6]; sum += w[7];
|
||||
sum += w[8]; sum += w[9]; sum += w[10]; sum += w[11];
|
||||
sum += w[12]; sum += w[13]; sum += w[14]; sum += w[15];
|
||||
w += 16;
|
||||
}
|
||||
mlen += 32;
|
||||
while ((mlen -= 8) >= 0) {
|
||||
sum += w[0]; sum += w[1]; sum += w[2]; sum += w[3];
|
||||
w += 4;
|
||||
}
|
||||
mlen += 8;
|
||||
if (mlen == 0 && byte_swapped == 0)
|
||||
continue;
|
||||
REDUCE;
|
||||
while ((mlen -= 2) >= 0) {
|
||||
sum += *w++;
|
||||
}
|
||||
if (byte_swapped) {
|
||||
REDUCE;
|
||||
sum <<= 8;
|
||||
byte_swapped = 0;
|
||||
if (mlen == -1) {
|
||||
s_util.c[1] = *(const uint8_t *)w;
|
||||
sum += s_util.s;
|
||||
mlen = 0;
|
||||
} else
|
||||
mlen = -1;
|
||||
} else if (mlen == -1)
|
||||
s_util.c[0] = *(const uint8_t *)w;
|
||||
}
|
||||
if (mlen == -1) {
|
||||
/* The last mbuf has odd # of bytes. Follow the
|
||||
standard (the odd byte may be shifted left by 8 bits
|
||||
or not as determined by endian-ness of the machine) */
|
||||
s_util.c[1] = 0;
|
||||
sum += s_util.s;
|
||||
}
|
||||
REDUCE;
|
||||
return (~sum & 0xffff);
|
||||
}
|
||||
|
||||
/*
|
||||
* Given the host-byte-order value of the checksum field in a packet
|
||||
* header, and the network-byte-order computed checksum of the data
|
||||
* that the checksum covers (including the checksum itself), compute
|
||||
* what the checksum field *should* have been.
|
||||
*/
|
||||
uint16_t
|
||||
in_cksum_shouldbe(uint16_t sum, uint16_t computed_sum)
|
||||
{
|
||||
uint32_t shouldbe;
|
||||
|
||||
/*
|
||||
* The value that should have gone into the checksum field
|
||||
* is the negative of the value gotten by summing up everything
|
||||
* *but* the checksum field.
|
||||
*
|
||||
* We can compute that by subtracting the value of the checksum
|
||||
* field from the sum of all the data in the packet, and then
|
||||
* computing the negative of that value.
|
||||
*
|
||||
* "sum" is the value of the checksum field, and "computed_sum"
|
||||
* is the negative of the sum of all the data in the packets,
|
||||
* so that's -(-computed_sum - sum), or (sum + computed_sum).
|
||||
*
|
||||
* All the arithmetic in question is one's complement, so the
|
||||
* addition must include an end-around carry; we do this by
|
||||
* doing the arithmetic in 32 bits (with no sign-extension),
|
||||
* and then adding the upper 16 bits of the sum, which contain
|
||||
* the carry, to the lower 16 bits of the sum, and then do it
|
||||
* again in case *that* sum produced a carry.
|
||||
*
|
||||
* As RFC 1071 notes, the checksum can be computed without
|
||||
* byte-swapping the 16-bit words; summing 16-bit words
|
||||
* on a big-endian machine gives a big-endian checksum, which
|
||||
* can be directly stuffed into the big-endian checksum fields
|
||||
* in protocol headers, and summing words on a little-endian
|
||||
* machine gives a little-endian checksum, which must be
|
||||
* byte-swapped before being stuffed into a big-endian checksum
|
||||
* field.
|
||||
*
|
||||
* "computed_sum" is a network-byte-order value, so we must put
|
||||
* it in host byte order before subtracting it from the
|
||||
* host-byte-order value from the header; the adjusted checksum
|
||||
* will be in host byte order, which is what we'll return.
|
||||
*/
|
||||
shouldbe = sum;
|
||||
shouldbe += ntohs(computed_sum);
|
||||
shouldbe = (shouldbe & 0xFFFF) + (shouldbe >> 16);
|
||||
shouldbe = (shouldbe & 0xFFFF) + (shouldbe >> 16);
|
||||
return shouldbe;
|
||||
}
|
||||
250
install-sh
Normal file
250
install-sh
Normal file
@@ -0,0 +1,250 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
# install - install a program, script, or datafile
|
||||
# This comes from X11R5 (mit/util/scripts/install.sh).
|
||||
#
|
||||
# Copyright 1991 by the Massachusetts Institute of Technology
|
||||
#
|
||||
# Permission to use, copy, modify, distribute, and sell this software and its
|
||||
# documentation for any purpose is hereby granted without fee, provided that
|
||||
# the above copyright notice appear in all copies and that both that
|
||||
# copyright notice and this permission notice appear in supporting
|
||||
# documentation, and that the name of M.I.T. not be used in advertising or
|
||||
# publicity pertaining to distribution of the software without specific,
|
||||
# written prior permission. M.I.T. makes no representations about the
|
||||
# suitability of this software for any purpose. It is provided "as is"
|
||||
# without express or implied warranty.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# `make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch. It can only install one file at a time, a restriction
|
||||
# shared with many OS's install programs.
|
||||
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit="${DOITPROG-}"
|
||||
|
||||
|
||||
# put in absolute paths if you don't have them in your path; or use env. vars.
|
||||
|
||||
mvprog="${MVPROG-mv}"
|
||||
cpprog="${CPPROG-cp}"
|
||||
chmodprog="${CHMODPROG-chmod}"
|
||||
chownprog="${CHOWNPROG-chown}"
|
||||
chgrpprog="${CHGRPPROG-chgrp}"
|
||||
stripprog="${STRIPPROG-strip}"
|
||||
rmprog="${RMPROG-rm}"
|
||||
mkdirprog="${MKDIRPROG-mkdir}"
|
||||
|
||||
transformbasename=""
|
||||
transform_arg=""
|
||||
instcmd="$mvprog"
|
||||
chmodcmd="$chmodprog 0755"
|
||||
chowncmd=""
|
||||
chgrpcmd=""
|
||||
stripcmd=""
|
||||
rmcmd="$rmprog -f"
|
||||
mvcmd="$mvprog"
|
||||
src=""
|
||||
dst=""
|
||||
dir_arg=""
|
||||
|
||||
while [ x"$1" != x ]; do
|
||||
case $1 in
|
||||
-c) instcmd="$cpprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-d) dir_arg=true
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-m) chmodcmd="$chmodprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-s) stripcmd="$stripprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
*) if [ x"$src" = x ]
|
||||
then
|
||||
src=$1
|
||||
else
|
||||
# this colon is to work around a 386BSD /bin/sh bug
|
||||
:
|
||||
dst=$1
|
||||
fi
|
||||
shift
|
||||
continue;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ x"$src" = x ]
|
||||
then
|
||||
echo "install: no input file specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]; then
|
||||
dst=$src
|
||||
src=""
|
||||
|
||||
if [ -d $dst ]; then
|
||||
instcmd=:
|
||||
else
|
||||
instcmd=mkdir
|
||||
fi
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
|
||||
if [ -f $src -o -d $src ]
|
||||
then
|
||||
true
|
||||
else
|
||||
echo "install: $src does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ x"$dst" = x ]
|
||||
then
|
||||
echo "install: no destination specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# If destination is a directory, append the input filename; if your system
|
||||
# does not like double slashes in filenames, you may need to add some logic
|
||||
|
||||
if [ -d $dst ]
|
||||
then
|
||||
dst="$dst"/`basename $src`
|
||||
else
|
||||
true
|
||||
fi
|
||||
fi
|
||||
|
||||
## this sed command emulates the dirname command
|
||||
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
||||
|
||||
# Make sure that the destination directory exists.
|
||||
# this part is taken from Noah Friedman's mkinstalldirs script
|
||||
|
||||
# Skip lots of stat calls in the usual case.
|
||||
if [ ! -d "$dstdir" ]; then
|
||||
defaultIFS='
|
||||
'
|
||||
IFS="${IFS-${defaultIFS}}"
|
||||
|
||||
oIFS="${IFS}"
|
||||
# Some sh's can't handle IFS=/ for some reason.
|
||||
IFS='%'
|
||||
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
|
||||
IFS="${oIFS}"
|
||||
|
||||
pathcomp=''
|
||||
|
||||
while [ $# -ne 0 ] ; do
|
||||
pathcomp="${pathcomp}${1}"
|
||||
shift
|
||||
|
||||
if [ ! -d "${pathcomp}" ] ;
|
||||
then
|
||||
$mkdirprog "${pathcomp}"
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
pathcomp="${pathcomp}/"
|
||||
done
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]
|
||||
then
|
||||
$doit $instcmd $dst &&
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
|
||||
else
|
||||
|
||||
# If we're going to rename the final executable, determine the name now.
|
||||
|
||||
if [ x"$transformarg" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
dstfile=`basename $dst $transformbasename |
|
||||
sed $transformarg`$transformbasename
|
||||
fi
|
||||
|
||||
# don't allow the sed command to completely eliminate the filename
|
||||
|
||||
if [ x"$dstfile" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# Make a temp file name in the proper directory.
|
||||
|
||||
dsttmp=$dstdir/#inst.$$#
|
||||
|
||||
# Move or copy the file name to the temp name
|
||||
|
||||
$doit $instcmd $src $dsttmp &&
|
||||
|
||||
trap "rm -f ${dsttmp}" 0 &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits
|
||||
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $instcmd $src $dsttmp" command.
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
|
||||
$doit $rmcmd -f $dstdir/$dstfile &&
|
||||
$doit $mvcmd $dsttmp $dstdir/$dstfile
|
||||
|
||||
fi &&
|
||||
|
||||
|
||||
exit 0
|
||||
94
interface.h
Normal file
94
interface.h
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (c) 1988-2002
|
||||
* 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 tcpdump_interface_h
|
||||
#define tcpdump_interface_h
|
||||
|
||||
#ifdef HAVE_OS_PROTO_H
|
||||
#include "os-proto.h"
|
||||
#endif
|
||||
|
||||
/* snprintf et al */
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#if HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_SNPRINTF)
|
||||
int snprintf(char *, size_t, const char *, ...)
|
||||
#ifdef __ATTRIBUTE___FORMAT_OK
|
||||
__attribute__((format(printf, 3, 4)))
|
||||
#endif /* __ATTRIBUTE___FORMAT_OK */
|
||||
;
|
||||
#endif /* !defined(HAVE_SNPRINTF) */
|
||||
|
||||
#if !defined(HAVE_VSNPRINTF)
|
||||
int vsnprintf(char *, size_t, const char *, va_list)
|
||||
#ifdef __ATTRIBUTE___FORMAT_OK
|
||||
__attribute__((format(printf, 3, 0)))
|
||||
#endif /* __ATTRIBUTE___FORMAT_OK */
|
||||
;
|
||||
#endif /* !defined(HAVE_VSNPRINTF) */
|
||||
|
||||
#ifndef HAVE_STRLCAT
|
||||
extern size_t strlcat(char *, const char *, size_t);
|
||||
#endif
|
||||
#ifndef HAVE_STRLCPY
|
||||
extern size_t strlcpy(char *, const char *, size_t);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRDUP
|
||||
extern char *strdup(const char *);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRSEP
|
||||
extern char *strsep(char **, const char *);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
extern char *program_name; /* used to generate self-identifying messages */
|
||||
|
||||
extern void error(const char *, ...)
|
||||
__attribute__((noreturn))
|
||||
#ifdef __ATTRIBUTE___FORMAT_OK
|
||||
__attribute__((format (printf, 1, 2)))
|
||||
#endif /* __ATTRIBUTE___FORMAT_OK */
|
||||
;
|
||||
extern void warning(const char *, ...)
|
||||
#ifdef __ATTRIBUTE___FORMAT_OK
|
||||
__attribute__((format (printf, 1, 2)))
|
||||
#endif /* __ATTRIBUTE___FORMAT_OK */
|
||||
;
|
||||
|
||||
extern char *read_infile(char *);
|
||||
extern char *copy_argv(char **);
|
||||
|
||||
#include <pcap.h>
|
||||
|
||||
#ifndef HAVE_BPF_DUMP
|
||||
struct bpf_program;
|
||||
|
||||
extern void bpf_dump(const struct bpf_program *, int);
|
||||
|
||||
#endif
|
||||
164
ip.h
Normal file
164
ip.h
Normal file
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* @(#)ip.h 8.2 (Berkeley) 6/1/94
|
||||
*/
|
||||
|
||||
#ifndef netdissect_ip_h
|
||||
#define netdissect_ip_h
|
||||
|
||||
/*
|
||||
* Definitions for internet protocol version 4.
|
||||
* Per RFC 791, September 1981.
|
||||
*/
|
||||
#define IPVERSION 4
|
||||
|
||||
/*
|
||||
* Structure of an internet header, naked of options.
|
||||
*
|
||||
* We declare ip_len and ip_off to be short, rather than u_short
|
||||
* pragmatically since otherwise unsigned comparisons can result
|
||||
* against negative integers quite easily, and fail in subtle ways.
|
||||
*/
|
||||
struct ip {
|
||||
nd_uint8_t ip_vhl; /* header length, version */
|
||||
#define IP_V(ip) (((ip)->ip_vhl & 0xf0) >> 4)
|
||||
#define IP_HL(ip) ((ip)->ip_vhl & 0x0f)
|
||||
nd_uint8_t ip_tos; /* type of service */
|
||||
nd_uint16_t ip_len; /* total length */
|
||||
nd_uint16_t ip_id; /* identification */
|
||||
nd_uint16_t ip_off; /* fragment offset field */
|
||||
#define IP_DF 0x4000 /* dont fragment flag */
|
||||
#define IP_MF 0x2000 /* more fragments flag */
|
||||
#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
|
||||
nd_uint8_t ip_ttl; /* time to live */
|
||||
nd_uint8_t ip_p; /* protocol */
|
||||
nd_uint16_t ip_sum; /* checksum */
|
||||
nd_ipv4 ip_src,ip_dst; /* source and dest address */
|
||||
};
|
||||
|
||||
#define IP_MAXPACKET 65535 /* maximum packet size */
|
||||
|
||||
/*
|
||||
* Definitions for IP type of service (ip_tos)
|
||||
*/
|
||||
#define IPTOS_LOWDELAY 0x10
|
||||
#define IPTOS_THROUGHPUT 0x08
|
||||
#define IPTOS_RELIABILITY 0x04
|
||||
|
||||
/*
|
||||
* Definitions for IP precedence (also in ip_tos) (hopefully unused)
|
||||
*/
|
||||
#define IPTOS_PREC_NETCONTROL 0xe0
|
||||
#define IPTOS_PREC_INTERNETCONTROL 0xc0
|
||||
#define IPTOS_PREC_CRITIC_ECP 0xa0
|
||||
#define IPTOS_PREC_FLASHOVERRIDE 0x80
|
||||
#define IPTOS_PREC_FLASH 0x60
|
||||
#define IPTOS_PREC_IMMEDIATE 0x40
|
||||
#define IPTOS_PREC_PRIORITY 0x20
|
||||
#define IPTOS_PREC_ROUTINE 0x00
|
||||
|
||||
/*
|
||||
* Definitions for options.
|
||||
*/
|
||||
#define IPOPT_COPIED(o) ((o)&0x80)
|
||||
#define IPOPT_CLASS(o) ((o)&0x60)
|
||||
#define IPOPT_NUMBER(o) ((o)&0x1f)
|
||||
|
||||
#define IPOPT_CONTROL 0x00
|
||||
#define IPOPT_RESERVED1 0x20
|
||||
#define IPOPT_DEBMEAS 0x40
|
||||
#define IPOPT_RESERVED2 0x60
|
||||
|
||||
#define IPOPT_EOL 0 /* end of option list */
|
||||
#define IPOPT_NOP 1 /* no operation */
|
||||
|
||||
#define IPOPT_RR 7 /* record packet route */
|
||||
#define IPOPT_TS 68 /* timestamp */
|
||||
#define IPOPT_RFC1393 82 /* traceroute RFC 1393 */
|
||||
#define IPOPT_SECURITY 130 /* provide s,c,h,tcc */
|
||||
#define IPOPT_LSRR 131 /* loose source route */
|
||||
#define IPOPT_SATID 136 /* satnet id */
|
||||
#define IPOPT_SSRR 137 /* strict source route */
|
||||
#define IPOPT_RA 148 /* router-alert, rfc2113 */
|
||||
|
||||
/*
|
||||
* Offsets to fields in options other than EOL and NOP.
|
||||
*/
|
||||
#define IPOPT_OPTVAL 0 /* option ID */
|
||||
#define IPOPT_OLEN 1 /* option length */
|
||||
#define IPOPT_OFFSET 2 /* offset within option */
|
||||
#define IPOPT_MINOFF 4 /* min value of above */
|
||||
|
||||
/*
|
||||
* Time stamp option structure.
|
||||
*/
|
||||
struct ip_timestamp {
|
||||
nd_uint8_t ipt_code; /* IPOPT_TS */
|
||||
nd_uint8_t ipt_len; /* size of structure (variable) */
|
||||
nd_uint8_t ipt_ptr; /* index of current entry */
|
||||
nd_uint8_t ipt_oflwflg; /* flags, overflow counter */
|
||||
#define IPTS_OFLW(ip) (((ipt)->ipt_oflwflg & 0xf0) >> 4)
|
||||
#define IPTS_FLG(ip) ((ipt)->ipt_oflwflg & 0x0f)
|
||||
union ipt_timestamp {
|
||||
nd_uint32_t ipt_time[1];
|
||||
struct ipt_ta {
|
||||
nd_ipv4 ipt_addr;
|
||||
nd_uint32_t ipt_time;
|
||||
} ipt_ta[1];
|
||||
} ipt_timestamp;
|
||||
};
|
||||
|
||||
/* flag bits for ipt_flg */
|
||||
#define IPOPT_TS_TSONLY 0 /* timestamps only */
|
||||
#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */
|
||||
#define IPOPT_TS_PRESPEC 3 /* specified modules only */
|
||||
|
||||
/* bits for security (not byte swapped) */
|
||||
#define IPOPT_SECUR_UNCLASS 0x0000
|
||||
#define IPOPT_SECUR_CONFID 0xf135
|
||||
#define IPOPT_SECUR_EFTO 0x789a
|
||||
#define IPOPT_SECUR_MMMM 0xbc4d
|
||||
#define IPOPT_SECUR_RESTR 0xaf13
|
||||
#define IPOPT_SECUR_SECRET 0xd788
|
||||
#define IPOPT_SECUR_TOPSECRET 0x6bc5
|
||||
|
||||
/*
|
||||
* Internet implementation parameters.
|
||||
*/
|
||||
#define MAXTTL 255 /* maximum time to live (seconds) */
|
||||
#define IPDEFTTL 64 /* default ttl, from RFC 1340 */
|
||||
#define IPFRAGTTL 60 /* time to live for frags, slowhz */
|
||||
#define IPTTLDEC 1 /* subtracted when forwarding */
|
||||
|
||||
#define IP_MSS 576 /* default maximum segment size */
|
||||
#endif /* netdissect_ip_h */
|
||||
202
ip6.h
Normal file
202
ip6.h
Normal file
@@ -0,0 +1,202 @@
|
||||
/* NetBSD: ip6.h,v 1.9 2000/07/13 05:34:21 itojun Exp */
|
||||
/* $KAME: ip6.h,v 1.9 2000/07/02 21:01:32 itojun Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the project nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* @(#)ip.h 8.1 (Berkeley) 6/10/93
|
||||
*/
|
||||
|
||||
#ifndef _NETINET_IP6_H_
|
||||
#define _NETINET_IP6_H_
|
||||
|
||||
/*
|
||||
* Definition for internet protocol version 6.
|
||||
* RFC 2460
|
||||
*/
|
||||
|
||||
struct ip6_hdr {
|
||||
union {
|
||||
struct ip6_hdrctl {
|
||||
uint32_t ip6_un1_flow; /* 20 bits of flow-ID */
|
||||
uint16_t ip6_un1_plen; /* payload length */
|
||||
uint8_t ip6_un1_nxt; /* next header */
|
||||
uint8_t ip6_un1_hlim; /* hop limit */
|
||||
} ip6_un1;
|
||||
uint8_t ip6_un2_vfc; /* 4 bits version, top 4 bits class */
|
||||
} ip6_ctlun;
|
||||
struct in6_addr ip6_src; /* source address */
|
||||
struct in6_addr ip6_dst; /* destination address */
|
||||
} UNALIGNED;
|
||||
|
||||
#define ip6_vfc ip6_ctlun.ip6_un2_vfc
|
||||
#define IP6_VERSION(ip6_hdr) (((ip6_hdr)->ip6_vfc & 0xf0) >> 4)
|
||||
#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
|
||||
|
||||
/* in network endian */
|
||||
#define IPV6_FLOWINFO_MASK ((uint32_t)htonl(0x0fffffff)) /* flow info (28 bits) */
|
||||
#define IPV6_FLOWLABEL_MASK ((uint32_t)htonl(0x000fffff)) /* flow label (20 bits) */
|
||||
#if 1
|
||||
/* ECN bits proposed by Sally Floyd */
|
||||
#define IP6TOS_CE 0x01 /* congestion experienced */
|
||||
#define IP6TOS_ECT 0x02 /* ECN-capable transport */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Extension Headers
|
||||
*/
|
||||
|
||||
struct ip6_ext {
|
||||
uint8_t ip6e_nxt;
|
||||
uint8_t ip6e_len;
|
||||
} UNALIGNED;
|
||||
|
||||
/* Hop-by-Hop options header */
|
||||
struct ip6_hbh {
|
||||
uint8_t ip6h_nxt; /* next header */
|
||||
uint8_t ip6h_len; /* length in units of 8 octets */
|
||||
/* followed by options */
|
||||
} UNALIGNED;
|
||||
|
||||
/* Destination options header */
|
||||
struct ip6_dest {
|
||||
uint8_t ip6d_nxt; /* next header */
|
||||
uint8_t ip6d_len; /* length in units of 8 octets */
|
||||
/* followed by options */
|
||||
} UNALIGNED;
|
||||
|
||||
/* http://www.iana.org/assignments/ipv6-parameters/ipv6-parameters.xhtml */
|
||||
|
||||
/* 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_RPL 0x63 /* 01 1 00011 */
|
||||
#define IP6OPT_TUN_ENC_LIMIT 0x04 /* 00 0 00100 */
|
||||
#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_QUICK_START 0x26 /* 00 1 00110 */
|
||||
#define IP6OPT_CALIPSO 0x07 /* 00 0 00111 */
|
||||
#define IP6OPT_SMF_DPD 0x08 /* 00 0 01000 */
|
||||
#define IP6OPT_HOME_ADDRESS 0xc9 /* 11 0 01001 */
|
||||
#define IP6OPT_HOMEADDR_MINLEN 18
|
||||
#define IP6OPT_EID 0x8a /* 10 0 01010 */
|
||||
#define IP6OPT_ILNP_NOTICE 0x8b /* 10 0 01011 */
|
||||
#define IP6OPT_LINE_ID 0x8c /* 10 0 01100 */
|
||||
#define IP6OPT_MPL 0x6d /* 01 1 01101 */
|
||||
#define IP6OPT_IP_DFF 0xee /* 11 1 01110 */
|
||||
|
||||
#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
|
||||
|
||||
/* Routing header */
|
||||
struct ip6_rthdr {
|
||||
uint8_t ip6r_nxt; /* next header */
|
||||
uint8_t ip6r_len; /* length in units of 8 octets */
|
||||
uint8_t ip6r_type; /* routing type */
|
||||
uint8_t ip6r_segleft; /* segments left */
|
||||
/* followed by routing type specific data */
|
||||
} UNALIGNED;
|
||||
|
||||
#define IPV6_RTHDR_TYPE_0 0
|
||||
#define IPV6_RTHDR_TYPE_2 2
|
||||
|
||||
/* Type 0 Routing header */
|
||||
/* Also used for Type 2 */
|
||||
struct ip6_rthdr0 {
|
||||
uint8_t ip6r0_nxt; /* next header */
|
||||
uint8_t ip6r0_len; /* length in units of 8 octets */
|
||||
uint8_t ip6r0_type; /* always zero */
|
||||
uint8_t ip6r0_segleft; /* segments left */
|
||||
uint8_t ip6r0_reserved; /* reserved field */
|
||||
uint8_t ip6r0_slmap[3]; /* strict/loose bit map */
|
||||
struct in6_addr ip6r0_addr[1]; /* up to 23 addresses */
|
||||
} UNALIGNED;
|
||||
|
||||
/* Fragment header */
|
||||
struct ip6_frag {
|
||||
uint8_t ip6f_nxt; /* next header */
|
||||
uint8_t ip6f_reserved; /* reserved field */
|
||||
uint16_t ip6f_offlg; /* offset, reserved, and flag */
|
||||
uint32_t ip6f_ident; /* identification */
|
||||
} UNALIGNED;
|
||||
|
||||
#define IP6F_OFF_MASK 0xfff8 /* mask out offset from ip6f_offlg */
|
||||
#define IP6F_RESERVED_MASK 0x0006 /* reserved bits in ip6f_offlg */
|
||||
#define IP6F_MORE_FRAG 0x0001 /* more-fragments flag */
|
||||
|
||||
#endif /* not _NETINET_IP6_H_ */
|
||||
56
ipproto.c
Normal file
56
ipproto.c
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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, and (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.
|
||||
* 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.
|
||||
*
|
||||
* Original code by Hannes Gredler (hannes@juniper.net)
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <netdissect-stdinc.h>
|
||||
|
||||
#include "netdissect.h"
|
||||
#include "ipproto.h"
|
||||
|
||||
const struct tok ipproto_values[] = {
|
||||
{ IPPROTO_HOPOPTS, "Options" },
|
||||
{ IPPROTO_ICMP, "ICMP" },
|
||||
{ IPPROTO_IGMP, "IGMP" },
|
||||
{ IPPROTO_IPV4, "IPIP" },
|
||||
{ IPPROTO_TCP, "TCP" },
|
||||
{ IPPROTO_EGP, "EGP" },
|
||||
{ IPPROTO_PIGP, "IGRP" },
|
||||
{ IPPROTO_UDP, "UDP" },
|
||||
{ IPPROTO_DCCP, "DCCP" },
|
||||
{ IPPROTO_IPV6, "IPv6" },
|
||||
{ IPPROTO_ROUTING, "Routing" },
|
||||
{ IPPROTO_FRAGMENT, "Fragment" },
|
||||
{ IPPROTO_RSVP, "RSVP" },
|
||||
{ IPPROTO_GRE, "GRE" },
|
||||
{ IPPROTO_ESP, "ESP" },
|
||||
{ IPPROTO_AH, "AH" },
|
||||
{ IPPROTO_MOBILE, "Mobile IP" },
|
||||
{ IPPROTO_ICMPV6, "ICMPv6" },
|
||||
{ IPPROTO_MOBILITY_OLD, "Mobile IP (old)" },
|
||||
{ IPPROTO_EIGRP, "EIGRP" },
|
||||
{ IPPROTO_OSPF, "OSPF" },
|
||||
{ IPPROTO_PIM, "PIM" },
|
||||
{ IPPROTO_IPCOMP, "Compressed IP" },
|
||||
{ IPPROTO_VRRP, "VRRP" },
|
||||
{ IPPROTO_PGM, "PGM" },
|
||||
{ IPPROTO_SCTP, "SCTP" },
|
||||
{ IPPROTO_MOBILITY, "Mobility" },
|
||||
{ IPPROTO_CARP, "CARP" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
145
ipproto.h
Normal file
145
ipproto.h
Normal file
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 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.
|
||||
*
|
||||
* From:
|
||||
* @(#)in.h 8.3 (Berkeley) 1/3/94
|
||||
* $FreeBSD: src/sys/netinet/in.h,v 1.38.2.3 1999/08/29 16:29:34 peter Exp $
|
||||
*/
|
||||
|
||||
extern const struct tok ipproto_values[];
|
||||
|
||||
#ifndef IPPROTO_IP
|
||||
#define IPPROTO_IP 0 /* dummy for IP */
|
||||
#endif
|
||||
#ifndef IPPROTO_HOPOPTS
|
||||
#define IPPROTO_HOPOPTS 0 /* IPv6 hop-by-hop options */
|
||||
#endif
|
||||
#ifndef IPPROTO_ICMP
|
||||
#define IPPROTO_ICMP 1 /* control message protocol */
|
||||
#endif
|
||||
#ifndef IPPROTO_IGMP
|
||||
#define IPPROTO_IGMP 2 /* group mgmt protocol */
|
||||
#endif
|
||||
#ifndef IPPROTO_IPV4
|
||||
#define IPPROTO_IPV4 4
|
||||
#endif
|
||||
#ifndef IPPROTO_TCP
|
||||
#define IPPROTO_TCP 6 /* tcp */
|
||||
#endif
|
||||
#ifndef IPPROTO_EGP
|
||||
#define IPPROTO_EGP 8 /* exterior gateway protocol */
|
||||
#endif
|
||||
#ifndef IPPROTO_PIGP
|
||||
#define IPPROTO_PIGP 9
|
||||
#endif
|
||||
#ifndef IPPROTO_UDP
|
||||
#define IPPROTO_UDP 17 /* user datagram protocol */
|
||||
#endif
|
||||
#ifndef IPPROTO_DCCP
|
||||
#define IPPROTO_DCCP 33 /* datagram congestion control protocol */
|
||||
#endif
|
||||
#ifndef IPPROTO_IPV6
|
||||
#define IPPROTO_IPV6 41
|
||||
#endif
|
||||
#ifndef IPPROTO_ROUTING
|
||||
#define IPPROTO_ROUTING 43 /* IPv6 routing header */
|
||||
#endif
|
||||
#ifndef IPPROTO_FRAGMENT
|
||||
#define IPPROTO_FRAGMENT 44 /* IPv6 fragmentation header */
|
||||
#endif
|
||||
#ifndef IPPROTO_RSVP
|
||||
#define IPPROTO_RSVP 46 /* resource reservation */
|
||||
#endif
|
||||
#ifndef IPPROTO_GRE
|
||||
#define IPPROTO_GRE 47 /* General Routing Encap. */
|
||||
#endif
|
||||
#ifndef IPPROTO_ESP
|
||||
#define IPPROTO_ESP 50 /* SIPP Encap Sec. Payload */
|
||||
#endif
|
||||
#ifndef IPPROTO_AH
|
||||
#define IPPROTO_AH 51 /* SIPP Auth Header */
|
||||
#endif
|
||||
#ifndef IPPROTO_MOBILE
|
||||
#define IPPROTO_MOBILE 55
|
||||
#endif
|
||||
#ifndef IPPROTO_ICMPV6
|
||||
#define IPPROTO_ICMPV6 58 /* ICMPv6 */
|
||||
#endif
|
||||
#ifndef IPPROTO_NONE
|
||||
#define IPPROTO_NONE 59 /* IPv6 no next header */
|
||||
#endif
|
||||
#ifndef IPPROTO_DSTOPTS
|
||||
#define IPPROTO_DSTOPTS 60 /* IPv6 destination options */
|
||||
#endif
|
||||
#ifndef IPPROTO_MOBILITY_OLD
|
||||
/*
|
||||
* The current Protocol Numbers list says that the IP protocol number for
|
||||
* mobility headers is 135; it cites draft-ietf-mobileip-ipv6-24, but
|
||||
* that draft doesn't actually give a number.
|
||||
*
|
||||
* It appears that 62 used to be used, even though that's assigned to
|
||||
* a protocol called CFTP; however, the only reference for CFTP is a
|
||||
* Network Message from BBN back in 1982, so, for now, we support 62,
|
||||
* aas well as 135, as a protocol number for mobility headers.
|
||||
*/
|
||||
#define IPPROTO_MOBILITY_OLD 62
|
||||
#endif
|
||||
#ifndef IPPROTO_ND
|
||||
#define IPPROTO_ND 77 /* Sun net disk proto (temp.) */
|
||||
#endif
|
||||
#ifndef IPPROTO_EIGRP
|
||||
#define IPPROTO_EIGRP 88 /* Cisco/GXS IGRP */
|
||||
#endif
|
||||
#ifndef IPPROTO_OSPF
|
||||
#define IPPROTO_OSPF 89
|
||||
#endif
|
||||
#ifndef IPPROTO_PIM
|
||||
#define IPPROTO_PIM 103
|
||||
#endif
|
||||
#ifndef IPPROTO_IPCOMP
|
||||
#define IPPROTO_IPCOMP 108
|
||||
#endif
|
||||
#ifndef IPPROTO_VRRP
|
||||
#define IPPROTO_VRRP 112
|
||||
#endif
|
||||
#ifndef IPPROTO_CARP
|
||||
#define IPPROTO_CARP 112
|
||||
#endif
|
||||
#ifndef IPPROTO_PGM
|
||||
#define IPPROTO_PGM 113
|
||||
#endif
|
||||
#ifndef IPPROTO_SCTP
|
||||
#define IPPROTO_SCTP 132
|
||||
#endif
|
||||
#ifndef IPPROTO_MOBILITY
|
||||
#define IPPROTO_MOBILITY 135
|
||||
#endif
|
||||
53
l2vpn.c
Normal file
53
l2vpn.c
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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, and (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.
|
||||
* 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.
|
||||
*
|
||||
* Original code by Hannes Gredler (hannes@juniper.net)
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <netdissect-stdinc.h>
|
||||
#include "netdissect.h"
|
||||
#include "l2vpn.h"
|
||||
|
||||
/* draft-ietf-pwe3-iana-allocation-04 */
|
||||
const struct tok l2vpn_encaps_values[] = {
|
||||
{ 0x00, "Reserved"},
|
||||
{ 0x01, "Frame Relay"},
|
||||
{ 0x02, "ATM AAL5 VCC transport"},
|
||||
{ 0x03, "ATM transparent cell transport"},
|
||||
{ 0x04, "Ethernet VLAN"},
|
||||
{ 0x05, "Ethernet"},
|
||||
{ 0x06, "Cisco-HDLC"},
|
||||
{ 0x07, "PPP"},
|
||||
{ 0x08, "SONET/SDH Circuit Emulation Service over MPLS"},
|
||||
{ 0x09, "ATM n-to-one VCC cell transport"},
|
||||
{ 0x0a, "ATM n-to-one VPC cell transport"},
|
||||
{ 0x0b, "IP Layer2 Transport"},
|
||||
{ 0x0c, "ATM one-to-one VCC Cell Mode"},
|
||||
{ 0x0d, "ATM one-to-one VPC Cell Mode"},
|
||||
{ 0x0e, "ATM AAL5 PDU VCC transport"},
|
||||
{ 0x0f, "Frame-Relay Port mode"},
|
||||
{ 0x10, "SONET/SDH Circuit Emulation over Packet"},
|
||||
{ 0x11, "Structure-agnostic E1 over Packet"},
|
||||
{ 0x12, "Structure-agnostic T1 (DS1) over Packet"},
|
||||
{ 0x13, "Structure-agnostic E3 over Packet"},
|
||||
{ 0x14, "Structure-agnostic T3 (DS3) over Packet"},
|
||||
{ 0x15, "CESoPSN basic mode"},
|
||||
{ 0x16, "TDMoIP basic mode"},
|
||||
{ 0x17, "CESoPSN TDM with CAS"},
|
||||
{ 0x18, "TDMoIP TDM with CAS"},
|
||||
{ 0x40, "IP-interworking"},
|
||||
{ 0, NULL}
|
||||
};
|
||||
16
l2vpn.h
Normal file
16
l2vpn.h
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* 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, and (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.
|
||||
* 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.
|
||||
*
|
||||
* Original code by Hannes Gredler (hannes@juniper.net)
|
||||
*/
|
||||
|
||||
extern const struct tok l2vpn_encaps_values[];
|
||||
24
lbl/os-osf4.h
Normal file
24
lbl/os-osf4.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (c) 1993, 1994, 1995, 1996, 1997
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that: (1) source code distributions
|
||||
* retain the above copyright notice and this paragraph in its entirety, (2)
|
||||
* distributions including binary code include the above copyright notice and
|
||||
* this paragraph in its entirety in the documentation or other materials
|
||||
* provided with the distribution, and (3) all advertising materials mentioning
|
||||
* features or use of this software display the following acknowledgement:
|
||||
* ``This product includes software developed by the University of California,
|
||||
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
|
||||
* the University nor the names of its contributors may be used to endorse
|
||||
* or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
/* Prototypes missing in Digital UNIX 4.x */
|
||||
int snprintf(char *, size_t, const char *, ...);
|
||||
int vsnprintf(char *, size_t, const char *, va_list);
|
||||
27
lbl/os-solaris2.h
Normal file
27
lbl/os-solaris2.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 1993, 1994, 1995, 1996, 1997
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that: (1) source code distributions
|
||||
* retain the above copyright notice and this paragraph in its entirety, (2)
|
||||
* distributions including binary code include the above copyright notice and
|
||||
* this paragraph in its entirety in the documentation or other materials
|
||||
* provided with the distribution, and (3) all advertising materials mentioning
|
||||
* features or use of this software display the following acknowledgement:
|
||||
* ``This product includes software developed by the University of California,
|
||||
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
|
||||
* the University nor the names of its contributors may be used to endorse
|
||||
* or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
/* Prototypes missing in SunOS 5 */
|
||||
#if defined(_STDIO_H) && defined(HAVE_SETLINEBUF)
|
||||
int setlinebuf(FILE *);
|
||||
#endif
|
||||
char *strerror(int);
|
||||
int snprintf(char *, size_t, const char *, ...);
|
||||
211
lbl/os-sunos4.h
Normal file
211
lbl/os-sunos4.h
Normal file
@@ -0,0 +1,211 @@
|
||||
/*
|
||||
* Copyright (c) 1989, 1990, 1993, 1994, 1995, 1996
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that: (1) source code distributions
|
||||
* retain the above copyright notice and this paragraph in its entirety, (2)
|
||||
* distributions including binary code include the above copyright notice and
|
||||
* this paragraph in its entirety in the documentation or other materials
|
||||
* provided with the distribution, and (3) all advertising materials mentioning
|
||||
* features or use of this software display the following acknowledgement:
|
||||
* ``This product includes software developed by the University of California,
|
||||
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
|
||||
* the University nor the names of its contributors may be used to endorse
|
||||
* or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
/* Prototypes missing in SunOS 4 */
|
||||
#ifdef FILE
|
||||
int _filbuf(FILE *);
|
||||
int _flsbuf(u_char, FILE *);
|
||||
int fclose(FILE *);
|
||||
int fflush(FILE *);
|
||||
int fgetc(FILE *);
|
||||
int fprintf(FILE *, const char *, ...);
|
||||
int fputc(int, FILE *);
|
||||
int fputs(const char *, FILE *);
|
||||
u_int fread(void *, u_int, u_int, FILE *);
|
||||
int fseek(FILE *, long, int);
|
||||
u_int fwrite(const void *, u_int, u_int, FILE *);
|
||||
int pclose(FILE *);
|
||||
void rewind(FILE *);
|
||||
void setbuf(FILE *, char *);
|
||||
int setlinebuf(FILE *);
|
||||
int ungetc(int, FILE *);
|
||||
int vfprintf(FILE *, const char *, ...);
|
||||
int vprintf(const char *, ...);
|
||||
#endif
|
||||
|
||||
#if __GNUC__ <= 1
|
||||
int read(int, char *, u_int);
|
||||
int write(int, char *, u_int);
|
||||
#endif
|
||||
|
||||
long a64l(const char *);
|
||||
#ifdef __STDC__
|
||||
struct sockaddr;
|
||||
#endif
|
||||
int accept(int, struct sockaddr *, int *);
|
||||
int bind(int, struct sockaddr *, int);
|
||||
int bcmp(const void *, const void *, u_int);
|
||||
void bcopy(const void *, void *, u_int);
|
||||
void bzero(void *, int);
|
||||
int chroot(const char *);
|
||||
int close(int);
|
||||
void closelog(void);
|
||||
int connect(int, struct sockaddr *, int);
|
||||
char *crypt(const char *, const char *);
|
||||
int daemon(int, int);
|
||||
int fchmod(int, int);
|
||||
int fchown(int, int, int);
|
||||
void endgrent(void);
|
||||
void endpwent(void);
|
||||
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);
|
||||
#ifdef __STDC__
|
||||
struct tm;
|
||||
#endif
|
||||
int strftime(char *, int, char *, struct tm *);
|
||||
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
|
||||
36
lbl/os-ultrix4.h
Normal file
36
lbl/os-ultrix4.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 1990, 1993, 1994, 1995, 1996
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that: (1) source code distributions
|
||||
* retain the above copyright notice and this paragraph in its entirety, (2)
|
||||
* distributions including binary code include the above copyright notice and
|
||||
* this paragraph in its entirety in the documentation or other materials
|
||||
* provided with the distribution, and (3) all advertising materials mentioning
|
||||
* features or use of this software display the following acknowledgement:
|
||||
* ``This product includes software developed by the University of California,
|
||||
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
|
||||
* the University nor the names of its contributors may be used to endorse
|
||||
* or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
/* Prototypes missing in Ultrix 4 */
|
||||
int bcmp(const char *, const char *, u_int);
|
||||
void bcopy(const void *, void *, u_int);
|
||||
void bzero(void *, u_int);
|
||||
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);
|
||||
122
llc.h
Normal file
122
llc.h
Normal file
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Copyright (c) 1993, 1994, 1997
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that: (1) source code distributions
|
||||
* retain the above copyright notice and this paragraph in its entirety, (2)
|
||||
* distributions including binary code include the above copyright notice and
|
||||
* this paragraph in its entirety in the documentation or other materials
|
||||
* provided with the distribution, and (3) all advertising materials mentioning
|
||||
* features or use of this software display the following acknowledgement:
|
||||
* ``This product includes software developed by the University of California,
|
||||
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
|
||||
* the University nor the names of its contributors may be used to endorse
|
||||
* or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Definitions for information in the LLC header.
|
||||
*/
|
||||
|
||||
#define LLC_U_FMT 3
|
||||
#define LLC_GSAP 1
|
||||
#define LLC_IG 1 /* Individual / Group */
|
||||
#define LLC_S_FMT 1
|
||||
|
||||
#define LLC_U_POLL 0x10
|
||||
#define LLC_IS_POLL 0x0100
|
||||
#define LLC_XID_FI 0x81
|
||||
|
||||
#define LLC_U_CMD(u) ((u) & 0xef)
|
||||
#define LLC_UI 0x03
|
||||
#define LLC_UA 0x63
|
||||
#define LLC_DISC 0x43
|
||||
#define LLC_DM 0x0f
|
||||
#define LLC_SABME 0x6f
|
||||
#define LLC_TEST 0xe3
|
||||
#define LLC_XID 0xaf
|
||||
#define LLC_FRMR 0x87
|
||||
|
||||
#define LLC_S_CMD(is) (((is) >> 2) & 0x03)
|
||||
#define LLC_RR 0x0001
|
||||
#define LLC_RNR 0x0005
|
||||
#define LLC_REJ 0x0009
|
||||
|
||||
#define LLC_IS_NR(is) (((is) >> 9) & 0x7f)
|
||||
#define LLC_I_NS(is) (((is) >> 1) & 0x7f)
|
||||
|
||||
#ifndef LLCSAP_NULL
|
||||
#define LLCSAP_NULL 0x00
|
||||
#endif
|
||||
#ifndef LLCSAP_GLOBAL
|
||||
#define LLCSAP_GLOBAL 0xff
|
||||
#endif
|
||||
#ifndef LLCSAP_8021B_I
|
||||
#define LLCSAP_8021B_I 0x02
|
||||
#endif
|
||||
#ifndef LLCSAP_8021B_G
|
||||
#define LLCSAP_8021B_G 0x03
|
||||
#endif
|
||||
#ifndef LLCSAP_SNA
|
||||
#define LLCSAP_SNA 0x04
|
||||
#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
|
||||
|
||||
/*
|
||||
* PIDs for use with OUI_CISCO.
|
||||
*/
|
||||
#define PID_CISCO_CDP 0x2000 /* Cisco Discovery Protocol */
|
||||
#define PID_CISCO_VTP 0x2003 /* Cisco VLAN Trunk Protocol */
|
||||
#define PID_CISCO_DTP 0x2004 /* Cisco Dynamic Trunk Protocol */
|
||||
#define PID_CISCO_UDLD 0x0111 /* Unidirectional Link Detection */
|
||||
#define PID_CISCO_PVST 0x010b /* Per VLAN Spanning Tree+ and RPVST+ */
|
||||
#define PID_CISCO_VLANBRIDGE 0x010c /* "VLAN Bridge", according to Wireshark */
|
||||
|
||||
/*
|
||||
* PIDs for use with OUI_RFC2684.
|
||||
*/
|
||||
#define PID_RFC2684_ETH_FCS 0x0001 /* Ethernet, with FCS */
|
||||
#define PID_RFC2684_ETH_NOFCS 0x0007 /* Ethernet, without FCS */
|
||||
#define PID_RFC2684_802_4_FCS 0x0002 /* 802.4, with FCS */
|
||||
#define PID_RFC2684_802_4_NOFCS 0x0008 /* 802.4, without FCS */
|
||||
#define PID_RFC2684_802_5_FCS 0x0003 /* 802.5, with FCS */
|
||||
#define PID_RFC2684_802_5_NOFCS 0x0009 /* 802.5, without FCS */
|
||||
#define PID_RFC2684_FDDI_FCS 0x0004 /* FDDI, with FCS */
|
||||
#define PID_RFC2684_FDDI_NOFCS 0x000a /* FDDI, without FCS */
|
||||
#define PID_RFC2684_802_6_FCS 0x0005 /* 802.6, with FCS */
|
||||
#define PID_RFC2684_802_6_NOFCS 0x000b /* 802.6, without FCS */
|
||||
#define PID_RFC2684_BPDU 0x000e /* BPDUs */
|
||||
74
machdep.c
Normal file
74
machdep.c
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* XXX - all we need, on platforms other than DEC OSF/1 (a/k/a Digital UNIX,
|
||||
* a/k/a Tru64 UNIX), is "size_t", which is a standard C type; what do we
|
||||
* need to do to get it defined? This is clearly wrong, as we shouldn't
|
||||
* have to include UNIX or Windows system header files to get it.
|
||||
*/
|
||||
#include <netdissect-stdinc.h>
|
||||
|
||||
#ifndef HAVE___ATTRIBUTE__
|
||||
#define __attribute__(x)
|
||||
#endif /* HAVE___ATTRIBUTE__ */
|
||||
|
||||
#ifdef __osf__
|
||||
#include <sys/sysinfo.h>
|
||||
#include <sys/proc.h>
|
||||
|
||||
#if !defined(HAVE_SNPRINTF)
|
||||
int snprintf(char *, size_t, const char *, ...)
|
||||
#ifdef __ATTRIBUTE___FORMAT_OK
|
||||
__attribute__((format(printf, 3, 4)))
|
||||
#endif /* __ATTRIBUTE___FORMAT_OK */
|
||||
;
|
||||
#endif /* !defined(HAVE_SNPRINTF) */
|
||||
#endif /* __osf__ */
|
||||
|
||||
#include "machdep.h"
|
||||
|
||||
/*
|
||||
* On platforms where the CPU doesn't support unaligned loads, force
|
||||
* unaligned accesses to abort with SIGBUS, rather than being fixed
|
||||
* up (slowly) by the OS kernel; on those platforms, misaligned accesses
|
||||
* are bugs, and we want tcpdump to crash so that the bugs are reported.
|
||||
*
|
||||
* The only OS on which this is necessary is DEC OSF/1^W^WDigital
|
||||
* UNIX^W^WTru64 UNIX.
|
||||
*/
|
||||
int
|
||||
abort_on_misalignment(char *ebuf _U_, size_t ebufsiz _U_)
|
||||
{
|
||||
#ifdef __osf__
|
||||
static int buf[2] = { SSIN_UACPROC, UAC_SIGBUS };
|
||||
|
||||
if (setsysinfo(SSI_NVPAIRS, (caddr_t)buf, 1, 0, 0) < 0) {
|
||||
(void)snprintf(ebuf, ebufsiz, "setsysinfo: errno %d", errno);
|
||||
return (-1);
|
||||
}
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
25
machdep.h
Normal file
25
machdep.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (c) 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 netdissect_machdep_h
|
||||
#define netdissect_machdep_h
|
||||
|
||||
int abort_on_misalignment(char *, size_t);
|
||||
#endif
|
||||
247
makemib
Normal file
247
makemib
Normal file
@@ -0,0 +1,247 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) 1990, 1996
|
||||
# John Robert LoVerso. All rights reserved.
|
||||
# SMIv2 parsing copyright (c) 1999
|
||||
# William C. Fenner.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notices, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notices, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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.
|
||||
|
||||
#
|
||||
# This script will read either ASN.1-style MIB files or the ".defs" files
|
||||
# created by the ISODE "mosy" program on such files.
|
||||
#
|
||||
# The output of this script is the "mib.h" file used by tcpdumps' ASN.1/SNMP
|
||||
# decoding code.
|
||||
#
|
||||
# This script needs to be run by "gawk" (GNU awk). "nawk" will work, but
|
||||
# dump will get a recursion error if you process LARGE mibs. While it would
|
||||
# by farily easy to rewrite this not to use recursion (and also easy to
|
||||
# eliminate use of gsub and functions to use classic "awk"), you have to
|
||||
# order the structure declarations in defined-first order for the compiler
|
||||
# not to barf; too bad tsort doesn't take arguments.
|
||||
#
|
||||
|
||||
cat << EOF
|
||||
/*
|
||||
* This file was generated by tcpdump/makemib on `date`
|
||||
* You probably don't want to edit this by hand!
|
||||
*
|
||||
* struct mib somename = { desc, oid-octet, type, child-pointer, next-pointer
|
||||
};
|
||||
*/
|
||||
|
||||
EOF
|
||||
|
||||
awk '
|
||||
BEGIN {
|
||||
debug=0;
|
||||
# for sanity, we prep the namespace with objects from RFC-1155
|
||||
# (we manually establish the root)
|
||||
oid["iso"]=1
|
||||
oidadd("org", "iso", 3)
|
||||
oidadd("dod", "org", 6)
|
||||
oidadd("internet", "dod", 1)
|
||||
oidadd("directory", "internet", 1)
|
||||
oidadd("mgmt", "internet", 2)
|
||||
#XXX oidadd("mib", "mgmt", 1)
|
||||
oidadd("mib-2", "mgmt", 1)
|
||||
oidadd("experimental", "internet", 3)
|
||||
oidadd("private", "internet", 4)
|
||||
oidadd("enterprises", "private", 1)
|
||||
oidadd("ip", "mib-2", 4)
|
||||
oidadd("transmission", "mib-2", 10)
|
||||
|
||||
holddesc="none"
|
||||
}
|
||||
|
||||
#
|
||||
# Read mosy "*.defs" file. mosy does all the parsing work; we just read
|
||||
# its simple and straightforward output. It would not be too hard to make
|
||||
# tcpdump directly read mosy output, but...
|
||||
#
|
||||
# Ignore these unless the current file is called something.defs; false
|
||||
# positives are too common in DESCRIPTIONs.
|
||||
|
||||
NF > 1 && index($2,".")>0 && FILENAME ~ /\.defs/ {
|
||||
# currently ignore items of the form "{ iso.3.6.1 }"
|
||||
if (split($2, p, ".") == 2) {
|
||||
oidadd($1, p[1], p[2])
|
||||
}
|
||||
next
|
||||
}
|
||||
|
||||
#
|
||||
# Must be a MIB file
|
||||
# Make it easier to parse - used to be done by sed
|
||||
{ sub(/--\*.*\*--/, ""); sub(/--.*/, ""); gsub(/[{}]/, " & "); }
|
||||
|
||||
#
|
||||
# this next section is simple and naive, but does the job ok
|
||||
#
|
||||
|
||||
# foo OBJECT IDENTIFIER ::= { baz 17 }
|
||||
# or
|
||||
# foo OBJECT IDENTIFIER ::=
|
||||
# { baz 17 }
|
||||
$2$3$4 == "OBJECTIDENTIFIER::=" {
|
||||
holddesc="none"
|
||||
if (NF == 8)
|
||||
oidadd($1, $6, $7)
|
||||
if (NF == 4)
|
||||
holddesc=$1
|
||||
next
|
||||
}
|
||||
$1 == "{" && holddesc != "none" && NF == 4 {
|
||||
oidadd(holddesc, $2, $3)
|
||||
holddesc="none"
|
||||
}
|
||||
#
|
||||
# foo OBJECT IDENTIFIER
|
||||
# ::= { bar 1 }
|
||||
$2$3 == "OBJECTIDENTIFIER" && $1 != "SYNTAX" && NF == 3 {
|
||||
holddesc=$1
|
||||
}
|
||||
#
|
||||
# foo
|
||||
# OBJECT IDENTIFIER ::= { bar 1 }
|
||||
# a couple of heuristics to exclude single words in e.g. long
|
||||
# DESCRIPTION clauses
|
||||
NF == 1 && $1 ~ "[a-z][a-z]*[A-Z]" && $1 !~ /[(){}.,]/ && holddesc == "none" {
|
||||
holddesc=$1
|
||||
}
|
||||
$1$2$3 == "OBJECTIDENTIFIER::=" && holddesc != "none" {
|
||||
oidadd(holddesc, $5, $6)
|
||||
holddesc="none"
|
||||
}
|
||||
#
|
||||
# "normal" style
|
||||
# foo OBJECT-TYPE ...
|
||||
# ...
|
||||
# ::= { baz 5 }
|
||||
$2 == "MODULE-IDENTITY" || $2 == "MODULE-COMPLIANCE" ||
|
||||
$2 == "OBJECT-IDENTITY" || $2 == "OBJECT-TYPE" ||
|
||||
$2 == "OBJECT-GROUP" ||
|
||||
$2 == "NOTIFICATION-TYPE" || $2 == "NOTIFICATION-GROUP" {
|
||||
holddesc=$1
|
||||
}
|
||||
$1 == "::=" && holddesc != "none" && NF == 5 {
|
||||
oidadd(holddesc, $3, $4)
|
||||
holddesc="none"
|
||||
}
|
||||
#
|
||||
# foo ::= { baz 17 }
|
||||
$2$3 == "::={" {
|
||||
oidadd($1,$4,$5)
|
||||
holddesc="none"
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# End of the road - output the data.
|
||||
#
|
||||
|
||||
END {
|
||||
print "struct obj"
|
||||
dump("iso")
|
||||
print "*mibroot = &_iso_obj;"
|
||||
}
|
||||
|
||||
function inn(file) {
|
||||
if (file == "" || file == "-")
|
||||
return ""
|
||||
return " in " file
|
||||
}
|
||||
|
||||
#
|
||||
# add a new object to the tree
|
||||
#
|
||||
# new OBJECT IDENTIFIER ::= { parent value }
|
||||
#
|
||||
|
||||
function oidadd(new, parent, value) {
|
||||
# Ignore 0.0
|
||||
if (parent == "0" && value == 0)
|
||||
return
|
||||
if (debug)
|
||||
print "/* oidadd" inn(FILENAME) ":", new, "in", parent, "as", value, "line", $0, "*/"
|
||||
# use safe C identifiers
|
||||
gsub(/[-&\/]/,"",new)
|
||||
gsub(/[-&\/]/,"",parent)
|
||||
# check if parent missing
|
||||
if (oid[parent] == "") {
|
||||
printf "/* parse problem%s: no parent for %s.%s(%d) */\n", \
|
||||
inn(FILENAME), parent, new, value
|
||||
return
|
||||
}
|
||||
# check if parent.value already exists
|
||||
if (oid[new] > 0 && oid[new] != value) {
|
||||
printf "/* parse problem%s: dup %s.%s(%d) != old (%d) */\n", \
|
||||
inn(FILENAME), parent, new, value, oid[new]
|
||||
return
|
||||
}
|
||||
# check for new name for parent.value
|
||||
if (child[parent] != "") {
|
||||
for (sib = child[parent]; sib != ""; sib = sibling[sib])
|
||||
if (oid[sib] == value) {
|
||||
if (new != sib)
|
||||
printf "/* parse problem%s: new name" \
|
||||
" \"%s\"" \
|
||||
" for %s.%s(%d) ignored */\n", \
|
||||
inn(FILENAME), new, parent, \
|
||||
sib, value
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
oid[new]=value
|
||||
if (child[parent] == "") {
|
||||
child[parent] = new
|
||||
} else {
|
||||
sibling[new] = child[parent]
|
||||
child[parent] = new
|
||||
}
|
||||
}
|
||||
|
||||
#
|
||||
# old(?) routine to recurse down the tree (in postfix order for convenience)
|
||||
#
|
||||
|
||||
function dump(item, c, s) {
|
||||
# newitem=sofar"."item"("oid[item]")"
|
||||
# printf "/* %s c=%s s=%s */\n", newitem, child[item], sibling[item]
|
||||
c="NULL"
|
||||
if (child[item] != "") {
|
||||
dump(child[item])
|
||||
c = "&_"child[item]"_obj"
|
||||
}
|
||||
s="NULL"
|
||||
if (sibling[item] != "") {
|
||||
dump(sibling[item])
|
||||
s = "&_"sibling[item]"_obj"
|
||||
}
|
||||
printf "_%s_obj = {\n\t\"%s\", %d, 0,\n\t%s, %s\n},\n", \
|
||||
item, item, oid[item], c, s
|
||||
}
|
||||
' $@
|
||||
exit 0
|
||||
42
mesa_pkt_dump.h
Normal file
42
mesa_pkt_dump.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#ifndef _MESA_PKT_DUMP_H_
|
||||
#define _MESA_PKT_DUMP_H_ 1
|
||||
|
||||
/*
|
||||
<09><><EFBFBD><EFBFBD>DPDK-3.0, PFRINGģʽ<C4A3><CABD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>ʱ, ͨ<><CDA8>ƽ̨ʵʱ<CAB5><CAB1><EFBFBD><EFBFBD>.
|
||||
*/
|
||||
|
||||
#define PKT_DUMP_HDR_MAGIC (0x44554D50) /* 'MESA' */
|
||||
|
||||
enum pkt_dump_opt_t{
|
||||
PKT_DUMP_OPT_RCV_PORT,
|
||||
PKT_DUMP_OPT_BPF_FILTER,
|
||||
PKT_DUMP_OPT_DATA_OFFSET,
|
||||
PKT_DUMP_OPT_THREAD_INDEX,
|
||||
PKT_DUMP_OPT_ACK, /* sapp<70><70><EFBFBD>ظ<EFBFBD>tcpdump_mesa<73><61>ack<63><6B> */
|
||||
PKT_DUMP_OPT_PERCEPTIVE, /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ, <20><><EFBFBD>Է<EFBFBD><D4B7>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
};
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD>Ժ<EFBFBD><D4BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3>ARM, PowerPC, MIPS<50><53><EFBFBD><EFBFBD>ֲ */
|
||||
struct pkt_dump_opt{
|
||||
unsigned short opt_type;
|
||||
unsigned short opt_len;
|
||||
/* actual opt value */
|
||||
}__attribute__((packed, aligned(1)));
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD>Ժ<EFBFBD><D4BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3>ARM, PowerPC, MIPS<50><53><EFBFBD><EFBFBD>ֲ */
|
||||
struct pkt_dump_handshake{
|
||||
unsigned int magic; /* <20>̶<EFBFBD>Ϊ0x44554D50, 'DUMP' */
|
||||
unsigned int version; /* <20><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>˫<EFBFBD><CBAB><EFBFBD>İ汾<C4B0><E6B1BE>, һ<><D2BB>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>20170106<30><36> */
|
||||
unsigned int opt_num; /* <20><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20>籾<EFBFBD>˽<EFBFBD><CBBD>ն˿ں<CBBF>, BPF<50><46><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD>offsetֵ<74>ȵ<EFBFBD> */
|
||||
}__attribute__((packed, aligned(1)));
|
||||
|
||||
|
||||
struct perceptive_info{
|
||||
unsigned char thread_id;
|
||||
unsigned char pad;
|
||||
unsigned int pkt_seq; /* <20><>0<EFBFBD><30>ʼ<EFBFBD>ۼ<EFBFBD>, <20><><EFBFBD><EFBFBD>seq<65>пն<D0BF>, ˵<><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6>˶<EFBFBD><CBB6>ٰ<EFBFBD> */
|
||||
}__attribute__((packed, aligned(1)));
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
62
missing/datalinks.c
Normal file
62
missing/datalinks.c
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) 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 the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the Computer Systems
|
||||
* Engineering Group at Lawrence Berkeley Laboratory.
|
||||
* 4. Neither the name of the University nor of the Laboratory may be used
|
||||
* to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <netdissect-stdinc.h>
|
||||
|
||||
#include <pcap.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "pcap-missing.h"
|
||||
|
||||
/*
|
||||
* Stub versions for platforms that don't support them.
|
||||
*/
|
||||
int
|
||||
pcap_list_datalinks(pcap_t *p, int **dlt_buffer)
|
||||
{
|
||||
/*
|
||||
* This platform doesn't support changing the DLT for an
|
||||
* interface. Return a list of DLTs containing only the
|
||||
* DLT this device supports.
|
||||
*/
|
||||
*dlt_buffer = (int*)malloc(sizeof(**dlt_buffer));
|
||||
if (*dlt_buffer == NULL)
|
||||
return (-1);
|
||||
**dlt_buffer = pcap_datalink(p);
|
||||
return (1);
|
||||
}
|
||||
171
missing/dlnames.c
Normal file
171
missing/dlnames.c
Normal file
@@ -0,0 +1,171 @@
|
||||
/*
|
||||
* Copyright (c) 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 the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the Computer Systems
|
||||
* Engineering Group at Lawrence Berkeley Laboratory.
|
||||
* 4. Neither the name of the University nor of the Laboratory may be used
|
||||
* to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <netdissect-stdinc.h>
|
||||
|
||||
#include <pcap.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "pcap-missing.h"
|
||||
#include "ascii_strcasecmp.h"
|
||||
|
||||
struct dlt_choice {
|
||||
const char *name;
|
||||
const char *description;
|
||||
int dlt;
|
||||
};
|
||||
|
||||
#define DLT_CHOICE(code, description) { #code, description, code }
|
||||
#define DLT_CHOICE_SENTINEL { NULL, NULL, 0 }
|
||||
|
||||
static struct dlt_choice dlt_choices[] = {
|
||||
DLT_CHOICE(DLT_NULL, "BSD loopback"),
|
||||
DLT_CHOICE(DLT_EN10MB, "Ethernet"),
|
||||
DLT_CHOICE(DLT_IEEE802, "Token ring"),
|
||||
DLT_CHOICE(DLT_ARCNET, "ARCNET"),
|
||||
DLT_CHOICE(DLT_SLIP, "SLIP"),
|
||||
DLT_CHOICE(DLT_PPP, "PPP"),
|
||||
DLT_CHOICE(DLT_FDDI, "FDDI"),
|
||||
DLT_CHOICE(DLT_ATM_RFC1483, "RFC 1483 IP-over-ATM"),
|
||||
DLT_CHOICE(DLT_RAW, "Raw IP"),
|
||||
#ifdef DLT_SLIP_BSDOS
|
||||
DLT_CHOICE(DLT_SLIP_BSDOS, "BSD/OS SLIP"),
|
||||
#endif
|
||||
#ifdef DLT_PPP_BSDOS
|
||||
DLT_CHOICE(DLT_PPP_BSDOS, "BSD/OS PPP"),
|
||||
#endif
|
||||
#ifdef DLT_ATM_CLIP
|
||||
DLT_CHOICE(DLT_ATM_CLIP, "Linux Classical IP-over-ATM"),
|
||||
#endif
|
||||
#ifdef DLT_PPP_SERIAL
|
||||
DLT_CHOICE(DLT_PPP_SERIAL, "PPP over serial"),
|
||||
#endif
|
||||
#ifdef DLT_PPP_ETHER
|
||||
DLT_CHOICE(DLT_PPP_ETHER, "PPPoE"),
|
||||
#endif
|
||||
#ifdef DLT_C_HDLC
|
||||
DLT_CHOICE(DLT_C_HDLC, "Cisco HDLC"),
|
||||
#endif
|
||||
#ifdef DLT_IEEE802_11
|
||||
DLT_CHOICE(DLT_IEEE802_11, "802.11"),
|
||||
#endif
|
||||
#ifdef DLT_FRELAY
|
||||
DLT_CHOICE(DLT_FRELAY, "Frame Relay"),
|
||||
#endif
|
||||
#ifdef DLT_LOOP
|
||||
DLT_CHOICE(DLT_LOOP, "OpenBSD loopback"),
|
||||
#endif
|
||||
#ifdef DLT_ENC
|
||||
DLT_CHOICE(DLT_ENC, "OpenBSD encapsulated IP"),
|
||||
#endif
|
||||
#ifdef DLT_LINUX_SLL
|
||||
DLT_CHOICE(DLT_LINUX_SLL, "Linux cooked"),
|
||||
#endif
|
||||
#ifdef DLT_LTALK
|
||||
DLT_CHOICE(DLT_LTALK, "Localtalk"),
|
||||
#endif
|
||||
#ifdef DLT_PFLOG
|
||||
DLT_CHOICE(DLT_PFLOG, "OpenBSD pflog file"),
|
||||
#endif
|
||||
#ifdef DLT_PRISM_HEADER
|
||||
DLT_CHOICE(DLT_PRISM_HEADER, "802.11 plus Prism header"),
|
||||
#endif
|
||||
#ifdef DLT_IP_OVER_FC
|
||||
DLT_CHOICE(DLT_IP_OVER_FC, "RFC 2625 IP-over-Fibre Channel"),
|
||||
#endif
|
||||
#ifdef DLT_SUNATM
|
||||
DLT_CHOICE(DLT_SUNATM, "Sun raw ATM"),
|
||||
#endif
|
||||
#ifdef DLT_IEEE802_11_RADIO
|
||||
DLT_CHOICE(DLT_IEEE802_11_RADIO, "802.11 plus radio information header"),
|
||||
#endif
|
||||
#ifdef DLT_ARCNET_LINUX
|
||||
DLT_CHOICE(DLT_ARCNET_LINUX, "Linux ARCNET"),
|
||||
#endif
|
||||
#ifdef DLT_LINUX_IRDA
|
||||
DLT_CHOICE(DLT_LINUX_IRDA, "Linux IrDA"),
|
||||
#endif
|
||||
#ifdef DLT_LANE8023
|
||||
DLT_CHOICE(DLT_LANE8023, "Linux 802.3 LANE"),
|
||||
#endif
|
||||
#ifdef DLT_CIP
|
||||
DLT_CHOICE(DLT_CIP, "Linux Classical IP-over-ATM"),
|
||||
#endif
|
||||
#ifdef DLT_HDLC
|
||||
DLT_CHOICE(DLT_HDLC, "Cisco HDLC"),
|
||||
#endif
|
||||
DLT_CHOICE_SENTINEL
|
||||
};
|
||||
|
||||
#ifndef HAVE_PCAP_DATALINK_NAME_TO_VAL
|
||||
int
|
||||
pcap_datalink_name_to_val(const char *name)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; dlt_choices[i].name != NULL; i++) {
|
||||
if (ascii_strcasecmp(dlt_choices[i].name + sizeof("DLT_") - 1,
|
||||
name) == 0)
|
||||
return (dlt_choices[i].dlt);
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
|
||||
const char *
|
||||
pcap_datalink_val_to_name(int dlt)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; dlt_choices[i].name != NULL; i++) {
|
||||
if (dlt_choices[i].dlt == dlt)
|
||||
return (dlt_choices[i].name + sizeof("DLT_") - 1);
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
const char *
|
||||
pcap_datalink_val_to_description(int dlt)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; dlt_choices[i].name != NULL; i++) {
|
||||
if (dlt_choices[i].dlt == dlt)
|
||||
return (dlt_choices[i].description);
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
612
missing/getopt_long.c
Normal file
612
missing/getopt_long.c
Normal file
@@ -0,0 +1,612 @@
|
||||
/* $OpenBSD: getopt_long.c,v 1.22 2006/10/04 21:29:04 jmc Exp $ */
|
||||
/* $NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2002 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 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.
|
||||
*
|
||||
* Sponsored in part by the Defense Advanced Research Projects
|
||||
* Agency (DARPA) and Air Force Research Laboratory, Air Force
|
||||
* Materiel Command, USAF, under agreement number F39502-99-1-0512.
|
||||
*/
|
||||
/*-
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Dieter Baron and Thomas Klausner.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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 <errno.h>
|
||||
#include "getopt_long.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#define GNU_COMPATIBLE /* Be more compatible, configure's use us! */
|
||||
|
||||
#define PRINT_ERROR ((opterr) && (*options != ':'))
|
||||
|
||||
#define FLAG_PERMUTE 0x01 /* permute non-options to the end of argv */
|
||||
#define FLAG_ALLARGS 0x02 /* treat non-options as args to option "-1" */
|
||||
#define FLAG_LONGONLY 0x04 /* operate as getopt_long_only */
|
||||
|
||||
/* return values */
|
||||
#define BADCH (int)'?'
|
||||
#define BADARG ((*options == ':') ? (int)':' : (int)'?')
|
||||
#define INORDER (int)1
|
||||
|
||||
#define EMSG ""
|
||||
|
||||
#ifdef GNU_COMPATIBLE
|
||||
#define NO_PREFIX (-1)
|
||||
#define D_PREFIX 0
|
||||
#define DD_PREFIX 1
|
||||
#define W_PREFIX 2
|
||||
#endif
|
||||
|
||||
char *optarg;
|
||||
int optind, opterr = 1, optopt;
|
||||
|
||||
static int getopt_internal(int, char * const *, const char *,
|
||||
const struct option *, int *, int);
|
||||
static int parse_long_options(char * const *, const char *,
|
||||
const struct option *, int *, int, int);
|
||||
static int gcd(int, int);
|
||||
static void permute_args(int, int, int, char * const *);
|
||||
|
||||
static const char *place = EMSG; /* option letter processing */
|
||||
|
||||
static int nonopt_start = -1; /* first non option argument (for permute) */
|
||||
static int nonopt_end = -1; /* first option after non options (for permute) */
|
||||
|
||||
/* Error messages */
|
||||
static const char recargchar[] = "option requires an argument -- %c";
|
||||
static const char illoptchar[] = "illegal option -- %c"; /* From P1003.2 */
|
||||
#ifdef GNU_COMPATIBLE
|
||||
static int dash_prefix = NO_PREFIX;
|
||||
static const char gnuoptchar[] = "invalid option -- %c";
|
||||
|
||||
static const char recargstring[] = "option `%s%s' requires an argument";
|
||||
static const char ambig[] = "option `%s%.*s' is ambiguous";
|
||||
static const char noarg[] = "option `%s%.*s' doesn't allow an argument";
|
||||
static const char illoptstring[] = "unrecognized option `%s%s'";
|
||||
#else
|
||||
static const char recargstring[] = "option requires an argument -- %s";
|
||||
static const char ambig[] = "ambiguous option -- %.*s";
|
||||
static const char noarg[] = "option doesn't take an argument -- %.*s";
|
||||
static const char illoptstring[] = "unknown option -- %s";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Compute the greatest common divisor of a and b.
|
||||
*/
|
||||
static int
|
||||
gcd(int a, int b)
|
||||
{
|
||||
int c;
|
||||
|
||||
c = a % b;
|
||||
while (c != 0) {
|
||||
a = b;
|
||||
b = c;
|
||||
c = a % b;
|
||||
}
|
||||
|
||||
return (b);
|
||||
}
|
||||
|
||||
/*
|
||||
* Exchange the block from nonopt_start to nonopt_end with the block
|
||||
* from nonopt_end to opt_end (keeping the same order of arguments
|
||||
* in each block).
|
||||
*/
|
||||
static void
|
||||
permute_args(int panonopt_start, int panonopt_end, int opt_end,
|
||||
char * const *nargv)
|
||||
{
|
||||
int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos;
|
||||
char *swap;
|
||||
|
||||
/*
|
||||
* compute lengths of blocks and number and size of cycles
|
||||
*/
|
||||
nnonopts = panonopt_end - panonopt_start;
|
||||
nopts = opt_end - panonopt_end;
|
||||
ncycle = gcd(nnonopts, nopts);
|
||||
cyclelen = (opt_end - panonopt_start) / ncycle;
|
||||
|
||||
for (i = 0; i < ncycle; i++) {
|
||||
cstart = panonopt_end+i;
|
||||
pos = cstart;
|
||||
for (j = 0; j < cyclelen; j++) {
|
||||
if (pos >= panonopt_end)
|
||||
pos -= nnonopts;
|
||||
else
|
||||
pos += nopts;
|
||||
swap = nargv[pos];
|
||||
/* LINTED const cast */
|
||||
((char **) nargv)[pos] = nargv[cstart];
|
||||
/* LINTED const cast */
|
||||
((char **)nargv)[cstart] = swap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
warnx(const char *fmt, ...)
|
||||
{
|
||||
extern char *program_name;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
fprintf(stderr, "%s: ", program_name);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
fprintf(stderr, "\n");
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
/*
|
||||
* parse_long_options --
|
||||
* Parse long options in argc/argv argument vector.
|
||||
* Returns -1 if short_too is set and the option does not match long_options.
|
||||
*/
|
||||
static int
|
||||
parse_long_options(char * const *nargv, const char *options,
|
||||
const struct option *long_options, int *idx, int short_too, int flags)
|
||||
{
|
||||
const char *current_argv, *has_equal;
|
||||
#ifdef GNU_COMPATIBLE
|
||||
const char *current_dash;
|
||||
#endif
|
||||
size_t current_argv_len;
|
||||
int i, match, exact_match, second_partial_match;
|
||||
|
||||
current_argv = place;
|
||||
#ifdef GNU_COMPATIBLE
|
||||
switch (dash_prefix) {
|
||||
case D_PREFIX:
|
||||
current_dash = "-";
|
||||
break;
|
||||
case DD_PREFIX:
|
||||
current_dash = "--";
|
||||
break;
|
||||
case W_PREFIX:
|
||||
current_dash = "-W ";
|
||||
break;
|
||||
default:
|
||||
current_dash = "";
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
match = -1;
|
||||
exact_match = 0;
|
||||
second_partial_match = 0;
|
||||
|
||||
optind++;
|
||||
|
||||
if ((has_equal = strchr(current_argv, '=')) != NULL) {
|
||||
/* argument found (--option=arg) */
|
||||
current_argv_len = has_equal - current_argv;
|
||||
has_equal++;
|
||||
} else
|
||||
current_argv_len = strlen(current_argv);
|
||||
|
||||
for (i = 0; long_options[i].name; i++) {
|
||||
/* find matching long option */
|
||||
if (strncmp(current_argv, long_options[i].name,
|
||||
current_argv_len))
|
||||
continue;
|
||||
|
||||
if (strlen(long_options[i].name) == current_argv_len) {
|
||||
/* exact match */
|
||||
match = i;
|
||||
exact_match = 1;
|
||||
break;
|
||||
}
|
||||
/*
|
||||
* If this is a known short option, don't allow
|
||||
* a partial match of a single character.
|
||||
*/
|
||||
if (short_too && current_argv_len == 1)
|
||||
continue;
|
||||
|
||||
if (match == -1) /* first partial match */
|
||||
match = i;
|
||||
else if ((flags & FLAG_LONGONLY) ||
|
||||
long_options[i].has_arg !=
|
||||
long_options[match].has_arg ||
|
||||
long_options[i].flag != long_options[match].flag ||
|
||||
long_options[i].val != long_options[match].val)
|
||||
second_partial_match = 1;
|
||||
}
|
||||
if (!exact_match && second_partial_match) {
|
||||
/* ambiguous abbreviation */
|
||||
if (PRINT_ERROR)
|
||||
warnx(ambig,
|
||||
#ifdef GNU_COMPATIBLE
|
||||
current_dash,
|
||||
#endif
|
||||
(int)current_argv_len,
|
||||
current_argv);
|
||||
optopt = 0;
|
||||
return (BADCH);
|
||||
}
|
||||
if (match != -1) { /* option found */
|
||||
if (long_options[match].has_arg == no_argument
|
||||
&& has_equal) {
|
||||
if (PRINT_ERROR)
|
||||
warnx(noarg,
|
||||
#ifdef GNU_COMPATIBLE
|
||||
current_dash,
|
||||
#endif
|
||||
(int)current_argv_len,
|
||||
current_argv);
|
||||
/*
|
||||
* XXX: GNU sets optopt to val regardless of flag
|
||||
*/
|
||||
if (long_options[match].flag == NULL)
|
||||
optopt = long_options[match].val;
|
||||
else
|
||||
optopt = 0;
|
||||
#ifdef GNU_COMPATIBLE
|
||||
return (BADCH);
|
||||
#else
|
||||
return (BADARG);
|
||||
#endif
|
||||
}
|
||||
if (long_options[match].has_arg == required_argument ||
|
||||
long_options[match].has_arg == optional_argument) {
|
||||
if (has_equal)
|
||||
optarg = (char *)has_equal;
|
||||
else if (long_options[match].has_arg ==
|
||||
required_argument) {
|
||||
/*
|
||||
* optional argument doesn't use next nargv
|
||||
*/
|
||||
optarg = nargv[optind++];
|
||||
}
|
||||
}
|
||||
if ((long_options[match].has_arg == required_argument)
|
||||
&& (optarg == NULL)) {
|
||||
/*
|
||||
* Missing argument; leading ':' indicates no error
|
||||
* should be generated.
|
||||
*/
|
||||
if (PRINT_ERROR)
|
||||
warnx(recargstring,
|
||||
#ifdef GNU_COMPATIBLE
|
||||
current_dash,
|
||||
#endif
|
||||
current_argv);
|
||||
/*
|
||||
* XXX: GNU sets optopt to val regardless of flag
|
||||
*/
|
||||
if (long_options[match].flag == NULL)
|
||||
optopt = long_options[match].val;
|
||||
else
|
||||
optopt = 0;
|
||||
--optind;
|
||||
return (BADARG);
|
||||
}
|
||||
} else { /* unknown option */
|
||||
if (short_too) {
|
||||
--optind;
|
||||
return (-1);
|
||||
}
|
||||
if (PRINT_ERROR)
|
||||
warnx(illoptstring,
|
||||
#ifdef GNU_COMPATIBLE
|
||||
current_dash,
|
||||
#endif
|
||||
current_argv);
|
||||
optopt = 0;
|
||||
return (BADCH);
|
||||
}
|
||||
if (idx)
|
||||
*idx = match;
|
||||
if (long_options[match].flag) {
|
||||
*long_options[match].flag = long_options[match].val;
|
||||
return (0);
|
||||
} else
|
||||
return (long_options[match].val);
|
||||
}
|
||||
|
||||
/*
|
||||
* getopt_internal --
|
||||
* Parse argc/argv argument vector. Called by user level routines.
|
||||
*/
|
||||
static int
|
||||
getopt_internal(int nargc, char * const *nargv, const char *options,
|
||||
const struct option *long_options, int *idx, int flags)
|
||||
{
|
||||
char *oli; /* option letter list index */
|
||||
int optchar, short_too;
|
||||
int posixly_correct; /* no static, can be changed on the fly */
|
||||
|
||||
if (options == NULL)
|
||||
return (-1);
|
||||
|
||||
/*
|
||||
* Disable GNU extensions if POSIXLY_CORRECT is set or options
|
||||
* string begins with a '+'.
|
||||
*/
|
||||
posixly_correct = (getenv("POSIXLY_CORRECT") != NULL);
|
||||
#ifdef GNU_COMPATIBLE
|
||||
if (*options == '-')
|
||||
flags |= FLAG_ALLARGS;
|
||||
else if (posixly_correct || *options == '+')
|
||||
flags &= ~FLAG_PERMUTE;
|
||||
#else
|
||||
if (posixly_correct || *options == '+')
|
||||
flags &= ~FLAG_PERMUTE;
|
||||
else if (*options == '-')
|
||||
flags |= FLAG_ALLARGS;
|
||||
#endif
|
||||
if (*options == '+' || *options == '-')
|
||||
options++;
|
||||
|
||||
/*
|
||||
* XXX Some GNU programs (like cvs) set optind to 0 instead of
|
||||
* XXX using optreset. Work around this braindamage.
|
||||
*/
|
||||
if (optind == 0)
|
||||
optind = 1;
|
||||
|
||||
optarg = NULL;
|
||||
start:
|
||||
if (!*place) { /* update scanning pointer */
|
||||
if (optind >= nargc) { /* end of argument vector */
|
||||
place = EMSG;
|
||||
if (nonopt_end != -1) {
|
||||
/* do permutation, if we have to */
|
||||
permute_args(nonopt_start, nonopt_end,
|
||||
optind, nargv);
|
||||
optind -= nonopt_end - nonopt_start;
|
||||
}
|
||||
else if (nonopt_start != -1) {
|
||||
/*
|
||||
* If we skipped non-options, set optind
|
||||
* to the first of them.
|
||||
*/
|
||||
optind = nonopt_start;
|
||||
}
|
||||
nonopt_start = nonopt_end = -1;
|
||||
return (-1);
|
||||
}
|
||||
if (*(place = nargv[optind]) != '-' ||
|
||||
#ifdef GNU_COMPATIBLE
|
||||
place[1] == '\0') {
|
||||
#else
|
||||
(place[1] == '\0' && strchr(options, '-') == NULL)) {
|
||||
#endif
|
||||
place = EMSG; /* found non-option */
|
||||
if (flags & FLAG_ALLARGS) {
|
||||
/*
|
||||
* GNU extension:
|
||||
* return non-option as argument to option 1
|
||||
*/
|
||||
optarg = nargv[optind++];
|
||||
return (INORDER);
|
||||
}
|
||||
if (!(flags & FLAG_PERMUTE)) {
|
||||
/*
|
||||
* If no permutation wanted, stop parsing
|
||||
* at first non-option.
|
||||
*/
|
||||
return (-1);
|
||||
}
|
||||
/* do permutation */
|
||||
if (nonopt_start == -1)
|
||||
nonopt_start = optind;
|
||||
else if (nonopt_end != -1) {
|
||||
permute_args(nonopt_start, nonopt_end,
|
||||
optind, nargv);
|
||||
nonopt_start = optind -
|
||||
(nonopt_end - nonopt_start);
|
||||
nonopt_end = -1;
|
||||
}
|
||||
optind++;
|
||||
/* process next argument */
|
||||
goto start;
|
||||
}
|
||||
if (nonopt_start != -1 && nonopt_end == -1)
|
||||
nonopt_end = optind;
|
||||
|
||||
/*
|
||||
* If we have "-" do nothing, if "--" we are done.
|
||||
*/
|
||||
if (place[1] != '\0' && *++place == '-' && place[1] == '\0') {
|
||||
optind++;
|
||||
place = EMSG;
|
||||
/*
|
||||
* We found an option (--), so if we skipped
|
||||
* non-options, we have to permute.
|
||||
*/
|
||||
if (nonopt_end != -1) {
|
||||
permute_args(nonopt_start, nonopt_end,
|
||||
optind, nargv);
|
||||
optind -= nonopt_end - nonopt_start;
|
||||
}
|
||||
nonopt_start = nonopt_end = -1;
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check long options if:
|
||||
* 1) we were passed some
|
||||
* 2) the arg is not just "-"
|
||||
* 3) either the arg starts with -- we are getopt_long_only()
|
||||
*/
|
||||
if (long_options != NULL && place != nargv[optind] &&
|
||||
(*place == '-' || (flags & FLAG_LONGONLY))) {
|
||||
short_too = 0;
|
||||
#ifdef GNU_COMPATIBLE
|
||||
dash_prefix = D_PREFIX;
|
||||
#endif
|
||||
if (*place == '-') {
|
||||
place++; /* --foo long option */
|
||||
#ifdef GNU_COMPATIBLE
|
||||
dash_prefix = DD_PREFIX;
|
||||
#endif
|
||||
} else if (*place != ':' && strchr(options, *place) != NULL)
|
||||
short_too = 1; /* could be short option too */
|
||||
|
||||
optchar = parse_long_options(nargv, options, long_options,
|
||||
idx, short_too, flags);
|
||||
if (optchar != -1) {
|
||||
place = EMSG;
|
||||
return (optchar);
|
||||
}
|
||||
}
|
||||
|
||||
if ((optchar = (int)*place++) == (int)':' ||
|
||||
(optchar == (int)'-' && *place != '\0') ||
|
||||
(oli = strchr(options, optchar)) == NULL) {
|
||||
/*
|
||||
* If the user specified "-" and '-' isn't listed in
|
||||
* options, return -1 (non-option) as per POSIX.
|
||||
* Otherwise, it is an unknown option character (or ':').
|
||||
*/
|
||||
if (optchar == (int)'-' && *place == '\0')
|
||||
return (-1);
|
||||
if (!*place)
|
||||
++optind;
|
||||
#ifdef GNU_COMPATIBLE
|
||||
if (PRINT_ERROR)
|
||||
warnx(posixly_correct ? illoptchar : gnuoptchar,
|
||||
optchar);
|
||||
#else
|
||||
if (PRINT_ERROR)
|
||||
warnx(illoptchar, optchar);
|
||||
#endif
|
||||
optopt = optchar;
|
||||
return (BADCH);
|
||||
}
|
||||
if (long_options != NULL && optchar == 'W' && oli[1] == ';') {
|
||||
/* -W long-option */
|
||||
if (*place) /* no space */
|
||||
/* NOTHING */;
|
||||
else if (++optind >= nargc) { /* no arg */
|
||||
place = EMSG;
|
||||
if (PRINT_ERROR)
|
||||
warnx(recargchar, optchar);
|
||||
optopt = optchar;
|
||||
return (BADARG);
|
||||
} else /* white space */
|
||||
place = nargv[optind];
|
||||
#ifdef GNU_COMPATIBLE
|
||||
dash_prefix = W_PREFIX;
|
||||
#endif
|
||||
optchar = parse_long_options(nargv, options, long_options,
|
||||
idx, 0, flags);
|
||||
place = EMSG;
|
||||
return (optchar);
|
||||
}
|
||||
if (*++oli != ':') { /* doesn't take argument */
|
||||
if (!*place)
|
||||
++optind;
|
||||
} else { /* takes (optional) argument */
|
||||
optarg = NULL;
|
||||
if (*place) /* no white space */
|
||||
optarg = (char *)place;
|
||||
else if (oli[1] != ':') { /* arg not optional */
|
||||
if (++optind >= nargc) { /* no arg */
|
||||
place = EMSG;
|
||||
if (PRINT_ERROR)
|
||||
warnx(recargchar, optchar);
|
||||
optopt = optchar;
|
||||
return (BADARG);
|
||||
} else
|
||||
optarg = nargv[optind];
|
||||
}
|
||||
place = EMSG;
|
||||
++optind;
|
||||
}
|
||||
/* dump back option letter */
|
||||
return (optchar);
|
||||
}
|
||||
|
||||
#ifdef REPLACE_GETOPT
|
||||
/*
|
||||
* getopt --
|
||||
* Parse argc/argv argument vector.
|
||||
*
|
||||
* [eventually this will replace the BSD getopt]
|
||||
*/
|
||||
int
|
||||
getopt(int nargc, char * const *nargv, const char *options)
|
||||
{
|
||||
|
||||
/*
|
||||
* We don't pass FLAG_PERMUTE to getopt_internal() since
|
||||
* the BSD getopt(3) (unlike GNU) has never done this.
|
||||
*
|
||||
* Furthermore, since many privileged programs call getopt()
|
||||
* before dropping privileges it makes sense to keep things
|
||||
* as simple (and bug-free) as possible.
|
||||
*/
|
||||
return (getopt_internal(nargc, nargv, options, NULL, NULL, 0));
|
||||
}
|
||||
#endif /* REPLACE_GETOPT */
|
||||
|
||||
/*
|
||||
* getopt_long --
|
||||
* Parse argc/argv argument vector.
|
||||
*/
|
||||
int
|
||||
getopt_long(int nargc, char * const *nargv, const char *options,
|
||||
const struct option *long_options, int *idx)
|
||||
{
|
||||
|
||||
return (getopt_internal(nargc, nargv, options, long_options, idx,
|
||||
FLAG_PERMUTE));
|
||||
}
|
||||
|
||||
/*
|
||||
* getopt_long_only --
|
||||
* Parse argc/argv argument vector.
|
||||
*/
|
||||
int
|
||||
getopt_long_only(int nargc, char * const *nargv, const char *options,
|
||||
const struct option *long_options, int *idx)
|
||||
{
|
||||
|
||||
return (getopt_internal(nargc, nargv, options, long_options, idx,
|
||||
FLAG_PERMUTE|FLAG_LONGONLY));
|
||||
}
|
||||
625
missing/snprintf.c
Normal file
625
missing/snprintf.c
Normal file
@@ -0,0 +1,625 @@
|
||||
/*
|
||||
* Copyright (c) 1995-1999 Kungliga Tekniska H<>gskolan
|
||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "netdissect.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
|
||||
|
||||
52
missing/strdup.c
Normal file
52
missing/strdup.c
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 1988, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "netdissect.h"
|
||||
|
||||
char *
|
||||
strdup(str)
|
||||
const char *str;
|
||||
{
|
||||
size_t len;
|
||||
char *copy;
|
||||
|
||||
len = strlen(str) + 1;
|
||||
if ((copy = malloc(len)) == NULL)
|
||||
return (NULL);
|
||||
memcpy(copy, str, len);
|
||||
return (copy);
|
||||
}
|
||||
73
missing/strlcat.c
Normal file
73
missing/strlcat.c
Normal file
@@ -0,0 +1,73 @@
|
||||
/* $NetBSD: strlcat.c,v 1.5 1999/09/20 04:39:47 lukem Exp $ */
|
||||
/* from OpenBSD: strlcat.c,v 1.2 1999/06/17 16:28:58 millert Exp */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <netdissect-stdinc.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "netdissect.h"
|
||||
|
||||
/*
|
||||
* Appends src to string dst of size siz (unlike strncat, siz is the
|
||||
* full size of dst, not space left). At most siz-1 characters
|
||||
* will be copied. Always NUL terminates (unless siz == 0).
|
||||
* Returns strlen(src); if retval >= siz, truncation occurred.
|
||||
*/
|
||||
size_t
|
||||
strlcat(char *dst, const char *src, size_t siz)
|
||||
{
|
||||
register char *d = dst;
|
||||
register const char *s = src;
|
||||
register size_t n = siz;
|
||||
size_t dlen;
|
||||
|
||||
/* Find the end of dst and adjust bytes left but don't go past end */
|
||||
while (*d != '\0' && n-- != 0)
|
||||
d++;
|
||||
dlen = d - dst;
|
||||
n = siz - dlen;
|
||||
|
||||
if (n == 0)
|
||||
return(dlen + strlen(s));
|
||||
while (*s != '\0') {
|
||||
if (n != 1) {
|
||||
*d++ = *s;
|
||||
n--;
|
||||
}
|
||||
s++;
|
||||
}
|
||||
*d = '\0';
|
||||
|
||||
return(dlen + (s - src)); /* count does not include NUL */
|
||||
}
|
||||
70
missing/strlcpy.c
Normal file
70
missing/strlcpy.c
Normal file
@@ -0,0 +1,70 @@
|
||||
/* $NetBSD: strlcpy.c,v 1.5 1999/09/20 04:39:47 lukem Exp $ */
|
||||
/* from OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <netdissect-stdinc.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "netdissect.h"
|
||||
|
||||
/*
|
||||
* Copy src to string dst of size siz. At most siz-1 characters
|
||||
* will be copied. Always NUL terminates (unless siz == 0).
|
||||
* Returns strlen(src); if retval >= siz, truncation occurred.
|
||||
*/
|
||||
size_t
|
||||
strlcpy(char *dst, const char *src, size_t siz)
|
||||
{
|
||||
register char *d = dst;
|
||||
register const char *s = src;
|
||||
register size_t n = siz;
|
||||
|
||||
/* Copy as many bytes as will fit */
|
||||
if (n != 0 && --n != 0) {
|
||||
do {
|
||||
if ((*d++ = *s++) == 0)
|
||||
break;
|
||||
} while (--n != 0);
|
||||
}
|
||||
|
||||
/* Not enough room in dst, add NUL and traverse rest of src */
|
||||
if (n == 0) {
|
||||
if (siz != 0)
|
||||
*d = '\0'; /* NUL-terminate dst */
|
||||
while (*s++)
|
||||
;
|
||||
}
|
||||
|
||||
return(s - src - 1); /* count does not include NUL */
|
||||
}
|
||||
80
missing/strsep.c
Normal file
80
missing/strsep.c
Normal file
@@ -0,0 +1,80 @@
|
||||
/*-
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <netdissect-stdinc.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "netdissect.h"
|
||||
|
||||
/*
|
||||
* Get next token from string *stringp, where tokens are possibly-empty
|
||||
* strings separated by characters from delim.
|
||||
*
|
||||
* Writes NULs into the string at *stringp to end tokens.
|
||||
* delim need not remain constant from call to call.
|
||||
* On return, *stringp points past the last NUL written (if there might
|
||||
* be further tokens), or is NULL (if there are definitely no more tokens).
|
||||
*
|
||||
* If *stringp is NULL, strsep returns NULL.
|
||||
*/
|
||||
char *
|
||||
strsep(char **stringp, const char *delim)
|
||||
{
|
||||
register char *s;
|
||||
register const char *spanp;
|
||||
register int c, sc;
|
||||
char *tok;
|
||||
|
||||
if ((s = *stringp) == NULL)
|
||||
return (NULL);
|
||||
for (tok = s;;) {
|
||||
c = *s++;
|
||||
spanp = delim;
|
||||
do {
|
||||
if ((sc = *spanp++) == c) {
|
||||
if (c == 0)
|
||||
s = NULL;
|
||||
else
|
||||
s[-1] = 0;
|
||||
*stringp = s;
|
||||
return (tok);
|
||||
}
|
||||
} while (sc != 0);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
112
mkdep
Normal file
112
mkdep
Normal file
@@ -0,0 +1,112 @@
|
||||
#!/bin/sh -
|
||||
#
|
||||
# Copyright (c) 1994, 1996
|
||||
# The Regents of the University of California. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms are permitted
|
||||
# provided that this notice is preserved and that due credit is given
|
||||
# to the University of California at Berkeley. The name of the University
|
||||
# may not be used to endorse or promote products derived from this
|
||||
# software without specific prior written permission. This software
|
||||
# is provided ``as is'' without express or implied warranty.
|
||||
#
|
||||
# @(#)mkdep.sh 5.11 (Berkeley) 5/5/88
|
||||
#
|
||||
|
||||
MAKE=Makefile # default makefile name is "Makefile"
|
||||
CC=cc # default C compiler is "cc"
|
||||
DEPENDENCY_CFLAG=-M # default dependency-generation flag is -M
|
||||
|
||||
while :
|
||||
do case "$1" in
|
||||
# -c allows you to specify the C compiler
|
||||
-c)
|
||||
CC=$2
|
||||
shift; shift ;;
|
||||
|
||||
# -f allows you to select a makefile name
|
||||
-f)
|
||||
MAKE=$2
|
||||
shift; shift ;;
|
||||
|
||||
# -m allows you to specify the dependency-generation flag
|
||||
-m)
|
||||
DEPENDENCY_CFLAG=$2
|
||||
shift; shift ;;
|
||||
|
||||
# the -p flag produces "program: program.c" style dependencies
|
||||
# so .o's don't get produced
|
||||
-p)
|
||||
SED='s;\.o;;'
|
||||
shift ;;
|
||||
*)
|
||||
break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ $# = 0 ] ; then
|
||||
echo 'usage: mkdep [-p] [-c cc] [-f makefile] [-m dependency-cflag] [flags] file ...'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -w $MAKE ]; then
|
||||
echo "mkdep: no writeable file \"$MAKE\""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TMP=/tmp/mkdep$$
|
||||
|
||||
trap 'rm -f $TMP ; exit 1' 1 2 3 13 15
|
||||
|
||||
cp $MAKE ${MAKE}.bak
|
||||
|
||||
sed -e '/DO NOT DELETE THIS LINE/,$d' < $MAKE > $TMP
|
||||
|
||||
cat << _EOF_ >> $TMP
|
||||
# DO NOT DELETE THIS LINE -- mkdep uses it.
|
||||
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
|
||||
|
||||
_EOF_
|
||||
|
||||
# If your compiler doesn't have -M, add it. If you can't, the next two
|
||||
# lines will try and replace the "cc -M". The real problem is that this
|
||||
# hack can't deal with anything that requires a search path, and doesn't
|
||||
# even try for anything using bracket (<>) syntax.
|
||||
#
|
||||
# egrep '^#include[ ]*".*"' /dev/null $* |
|
||||
# sed -e 's/:[^"]*"\([^"]*\)".*/: \1/' -e 's/\.c/.o/' |
|
||||
|
||||
# XXX this doesn't work with things like "-DDECLWAITSTATUS=union\ wait"
|
||||
$CC $DEPENDENCY_CFLAG $* |
|
||||
sed "
|
||||
s; \./; ;g
|
||||
$SED" |
|
||||
awk '{
|
||||
if ($1 != prev) {
|
||||
if (rec != "")
|
||||
print rec;
|
||||
rec = $0;
|
||||
prev = $1;
|
||||
}
|
||||
else {
|
||||
if (length(rec $2) > 78) {
|
||||
print rec;
|
||||
rec = $0;
|
||||
}
|
||||
else
|
||||
rec = rec " " $2
|
||||
}
|
||||
}
|
||||
END {
|
||||
print rec
|
||||
}' >> $TMP
|
||||
|
||||
cat << _EOF_ >> $TMP
|
||||
|
||||
# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
|
||||
_EOF_
|
||||
|
||||
# copy to preserve permissions
|
||||
cp $TMP $MAKE
|
||||
rm -f ${MAKE}.bak $TMP
|
||||
exit 0
|
||||
41
mpls.h
Normal file
41
mpls.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2001 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.
|
||||
*/
|
||||
|
||||
#define LABEL_MASK 0xfffff000
|
||||
#define LABEL_SHIFT 12
|
||||
#define EXP_MASK 0x00000e00
|
||||
#define EXP_SHIFT 9
|
||||
#define STACK_MASK 0x00000100
|
||||
#define STACK_SHIFT 8
|
||||
#define TTL_MASK 0x000000ff
|
||||
#define TTL_SHIFT 0
|
||||
|
||||
#define MPLS_LABEL(x) (((x) & LABEL_MASK) >> LABEL_SHIFT)
|
||||
#define MPLS_EXP(x) (((x) & EXP_MASK) >> EXP_SHIFT)
|
||||
#define MPLS_STACK(x) (((x) & STACK_MASK) >> STACK_SHIFT)
|
||||
#define MPLS_TTL(x) (((x) & TTL_MASK) >> TTL_SHIFT)
|
||||
300
nameser.h
Normal file
300
nameser.h
Normal file
@@ -0,0 +1,300 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* @(#)nameser.h 8.2 (Berkeley) 2/16/94
|
||||
* -
|
||||
* 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 _NAMESER_H_
|
||||
#define _NAMESER_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
/*
|
||||
* 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 */
|
||||
/* Number of bytes of fixed size data in query structure */
|
||||
#define QFIXEDSZ 4
|
||||
/* number of bytes of fixed size data in resource record */
|
||||
#define RRFIXEDSZ 10
|
||||
|
||||
/*
|
||||
* Currently defined opcodes
|
||||
*/
|
||||
#define QUERY 0x0 /* standard query */
|
||||
#define IQUERY 0x1 /* inverse query */
|
||||
#define STATUS 0x2 /* nameserver status query */
|
||||
#if 0
|
||||
#define xxx 0x3 /* 0x3 reserved */
|
||||
#endif
|
||||
/* 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 */
|
||||
|
||||
/*
|
||||
* Undefine various #defines from various System V-flavored OSes (Solaris,
|
||||
* SINIX, HP-UX) so the compiler doesn't whine that we redefine them.
|
||||
*/
|
||||
#ifdef T_NULL
|
||||
#undef T_NULL
|
||||
#endif
|
||||
#ifdef T_OPT
|
||||
#undef T_OPT
|
||||
#endif
|
||||
#ifdef T_UNSPEC
|
||||
#undef T_UNSPEC
|
||||
#endif
|
||||
#ifdef NOERROR
|
||||
#undef NOERROR
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Currently defined response codes
|
||||
*/
|
||||
#define NOERROR 0 /* no error */
|
||||
#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 */
|
||||
/* non standard */
|
||||
#define NOCHANGE 0xf /* update failed to change db */
|
||||
|
||||
/*
|
||||
* 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 /* connonical 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 lookup for NSAP */
|
||||
#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 */
|
||||
#define T_NXT 30 /* Next Valid Name in Zone */
|
||||
#define T_EID 31 /* Endpoint identifier */
|
||||
#define T_NIMLOC 32 /* Nimrod locator */
|
||||
#define T_SRV 33 /* Server selection */
|
||||
#define T_ATMA 34 /* ATM Address */
|
||||
#define T_NAPTR 35 /* Naming Authority PoinTeR */
|
||||
#define T_KX 36 /* Key Exchanger */
|
||||
#define T_CERT 37 /* Certificates in the DNS */
|
||||
#define T_A6 38 /* IP6 address */
|
||||
#define T_DNAME 39 /* non-terminal redirection */
|
||||
#define T_SINK 40 /* unknown */
|
||||
#define T_OPT 41 /* EDNS0 option (meta-RR) */
|
||||
#define T_APL 42 /* lists of address prefixes */
|
||||
#define T_DS 43 /* Delegation Signer */
|
||||
#define T_SSHFP 44 /* SSH Fingerprint */
|
||||
#define T_IPSECKEY 45 /* IPsec keying material */
|
||||
#define T_RRSIG 46 /* new security signature */
|
||||
#define T_NSEC 47 /* provable insecure information */
|
||||
#define T_DNSKEY 48 /* new security key */
|
||||
/* non standard */
|
||||
#define T_SPF 99 /* sender policy framework */
|
||||
#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) */
|
||||
#define T_UNSPECA 104 /* "unspecified ascii". Ugly MIT hack */
|
||||
/* Query type values which do not appear in resource records */
|
||||
#define T_TKEY 249 /* Transaction Key [RFC2930] */
|
||||
#define T_TSIG 250 /* Transaction Signature [RFC2845] */
|
||||
#define T_IXFR 251 /* incremental transfer [RFC1995] */
|
||||
#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 */
|
||||
#define C_QU 0x8000 /* mDNS QU flag in queries */
|
||||
#define C_CACHE_FLUSH 0x8000 /* mDNS cache flush flag in replies */
|
||||
|
||||
/*
|
||||
* 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
|
||||
|
||||
/*
|
||||
* Structure for query header.
|
||||
*/
|
||||
typedef struct {
|
||||
uint16_t id; /* query identification number */
|
||||
uint8_t flags1; /* first byte of flags */
|
||||
uint8_t flags2; /* second byte of flags */
|
||||
uint16_t qdcount; /* number of question entries */
|
||||
uint16_t ancount; /* number of answer entries */
|
||||
uint16_t nscount; /* number of authority entries */
|
||||
uint16_t arcount; /* number of resource entries */
|
||||
} HEADER;
|
||||
|
||||
/*
|
||||
* Macros for subfields of flag fields.
|
||||
*/
|
||||
#define DNS_QR(np) ((np)->flags1 & 0x80) /* response flag */
|
||||
#define DNS_OPCODE(np) ((((np)->flags1) >> 3) & 0xF) /* purpose of message */
|
||||
#define DNS_AA(np) ((np)->flags1 & 0x04) /* authoritative answer */
|
||||
#define DNS_TC(np) ((np)->flags1 & 0x02) /* truncated message */
|
||||
#define DNS_RD(np) ((np)->flags1 & 0x01) /* recursion desired */
|
||||
|
||||
#define DNS_RA(np) ((np)->flags2 & 0x80) /* recursion available */
|
||||
#define DNS_AD(np) ((np)->flags2 & 0x20) /* authentic data from named */
|
||||
#define DNS_CD(np) ((np)->flags2 & 0x10) /* checking disabled by resolver */
|
||||
#define DNS_RCODE(np) ((np)->flags2 & 0xF) /* response code */
|
||||
|
||||
/*
|
||||
* Defines for handling compressed domain names, EDNS0 labels, etc.
|
||||
*/
|
||||
#define INDIR_MASK 0xc0 /* 11.... */
|
||||
#define EDNS0_MASK 0x40 /* 01.... */
|
||||
# define EDNS0_ELT_BITLABEL 0x01
|
||||
|
||||
/*
|
||||
* 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 */
|
||||
uint32_t r_ttl; /* time to live */
|
||||
int r_size; /* size of data area */
|
||||
char *r_data; /* pointer to data */
|
||||
};
|
||||
|
||||
/*
|
||||
* Inline versions of get/put short/long. Pointer is advanced.
|
||||
* We also assume that a "uint16_t" holds 2 "chars"
|
||||
* and that a "uint32_t" holds 4 "chars".
|
||||
*
|
||||
* These macros demonstrate the property of C whereby it can be
|
||||
* portable or it can be elegant but never both.
|
||||
*/
|
||||
#define GETSHORT(s, cp) { \
|
||||
register u_char *t_cp = (u_char *)(cp); \
|
||||
(s) = ((uint16_t)t_cp[0] << 8) | (uint16_t)t_cp[1]; \
|
||||
(cp) += 2; \
|
||||
}
|
||||
|
||||
#define GETLONG(l, cp) { \
|
||||
register u_char *t_cp = (u_char *)(cp); \
|
||||
(l) = (((uint32_t)t_cp[0]) << 24) \
|
||||
| (((uint32_t)t_cp[1]) << 16) \
|
||||
| (((uint32_t)t_cp[2]) << 8) \
|
||||
| (((uint32_t)t_cp[3])); \
|
||||
(cp) += 4; \
|
||||
}
|
||||
|
||||
#define PUTSHORT(s, cp) { \
|
||||
register uint16_t t_s = (uint16_t)(s); \
|
||||
register u_char *t_cp = (u_char *)(cp); \
|
||||
*t_cp++ = t_s >> 8; \
|
||||
*t_cp = t_s; \
|
||||
(cp) += 2; \
|
||||
}
|
||||
|
||||
/*
|
||||
* Warning: PUTLONG --no-longer-- destroys its first argument. if you
|
||||
* were depending on this "feature", you will lose.
|
||||
*/
|
||||
#define PUTLONG(l, cp) { \
|
||||
register uint32_t t_l = (uint32_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) += 4; \
|
||||
}
|
||||
|
||||
#endif /* !_NAMESER_H_ */
|
||||
404
netdissect-stdinc.h
Normal file
404
netdissect-stdinc.h
Normal file
@@ -0,0 +1,404 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Include the appropriate OS header files on Windows and various flavors
|
||||
* of UNIX, include various non-OS header files on Windows, and define
|
||||
* various items as needed, to isolate most of netdissect's platform
|
||||
* differences to this one file.
|
||||
*/
|
||||
|
||||
#ifndef netdissect_stdinc_h
|
||||
#define netdissect_stdinc_h
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
/*
|
||||
* Includes and definitions for Windows.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifndef uint8_t
|
||||
#define uint8_t unsigned char
|
||||
#endif
|
||||
|
||||
#ifndef int8_t
|
||||
#define int8_t signed char
|
||||
#endif
|
||||
|
||||
#ifndef uint16_t
|
||||
#define uint16_t unsigned short
|
||||
#endif
|
||||
|
||||
#ifndef int16_t
|
||||
#define int16_t signed short
|
||||
#endif
|
||||
|
||||
#ifndef uint32_t
|
||||
#define uint32_t unsigned int
|
||||
#endif
|
||||
|
||||
#ifndef int32_t
|
||||
#define int32_t signed int
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_EXTENSIONS
|
||||
|
||||
#ifndef uint64_t
|
||||
#define uint64_t unsigned _int64
|
||||
#endif
|
||||
|
||||
#ifndef int64_t
|
||||
#define int64_t _int64
|
||||
#endif
|
||||
|
||||
#ifndef PRId64
|
||||
#define PRId64 "I64d"
|
||||
#endif
|
||||
|
||||
#ifndef PRIo64
|
||||
#define PRIo64 "I64o"
|
||||
#endif
|
||||
|
||||
#ifndef PRIu64
|
||||
#define PRIu64 "I64u"
|
||||
#endif
|
||||
|
||||
#ifndef PRIx64
|
||||
#define PRIx64 "I64x"
|
||||
#endif
|
||||
|
||||
#else /* _MSC_EXTENSIONS */
|
||||
|
||||
#ifndef uint64_t
|
||||
#define uint64_t unsigned long long
|
||||
#endif
|
||||
|
||||
#ifndef int64_t
|
||||
#define int64_t long long
|
||||
#endif
|
||||
|
||||
#ifndef PRId64
|
||||
#define PRId64 "lld"
|
||||
#endif
|
||||
|
||||
#ifndef PRIo64
|
||||
#define PRIo64 "llo"
|
||||
#endif
|
||||
|
||||
#ifndef PRIu64
|
||||
#define PRIu64 "llu"
|
||||
#endif
|
||||
|
||||
#ifndef PRIx64
|
||||
#define PRIx64 "llx"
|
||||
#endif
|
||||
|
||||
#endif /* _MSC_EXTENSIONS */
|
||||
|
||||
/*
|
||||
* Suppress definition of intN_t in bittypes.h, as included by <pcap/pcap.h>
|
||||
* on Windows.
|
||||
* (Yes, HAVE_U_INTn_T, as the definition guards are UN*X-oriented, and
|
||||
* we check for u_intN_t in the UN*X configure script.)
|
||||
*/
|
||||
#define HAVE_U_INT8_T
|
||||
#define HAVE_U_INT16_T
|
||||
#define HAVE_U_INT32_T
|
||||
#define HAVE_U_INT64_T
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define stat _stat
|
||||
#define open _open
|
||||
#define fstat _fstat
|
||||
#define read _read
|
||||
#define close _close
|
||||
#define O_RDONLY _O_RDONLY
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
/*
|
||||
* With MSVC, for C, __inline is used to make a function an inline.
|
||||
*/
|
||||
#ifdef _MSC_VER
|
||||
#define inline __inline
|
||||
#endif
|
||||
|
||||
#ifdef AF_INET6
|
||||
#define HAVE_OS_IPV6_SUPPORT
|
||||
#endif
|
||||
|
||||
#ifndef INET6_ADDRSTRLEN
|
||||
#define INET6_ADDRSTRLEN 46
|
||||
#endif
|
||||
|
||||
/* It is in MSVC's <errno.h>, but not defined in MingW+Watcom.
|
||||
*/
|
||||
#ifndef EAFNOSUPPORT
|
||||
#define EAFNOSUPPORT WSAEAFNOSUPPORT
|
||||
#endif
|
||||
|
||||
#ifndef caddr_t
|
||||
typedef char* caddr_t;
|
||||
#endif /* caddr_t */
|
||||
|
||||
#define MAXHOSTNAMELEN 64
|
||||
#define snprintf _snprintf
|
||||
#define vsnprintf _vsnprintf
|
||||
#define RETSIGTYPE void
|
||||
|
||||
#else /* _WIN32 */
|
||||
|
||||
/*
|
||||
* Includes and definitions for various flavors of UN*X.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
#include <netdb.h>
|
||||
#if HAVE_INTTYPES_H
|
||||
#include <inttypes.h>
|
||||
#elif HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h> /* concession to AIX */
|
||||
#include <sys/time.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#ifdef TIME_WITH_SYS_TIME
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#ifndef HAVE___ATTRIBUTE__
|
||||
#define __attribute__(x)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Used to declare a structure unaligned, so that the C compiler,
|
||||
* if necessary, generates code that doesn't assume alignment.
|
||||
* This is required because there is no guarantee that the packet
|
||||
* data we get from libpcap/WinPcap is properly aligned.
|
||||
*
|
||||
* This assumes that, for all compilers that support __attribute__:
|
||||
*
|
||||
* 1) they support __attribute__((packed));
|
||||
*
|
||||
* 2) for all instruction set architectures requiring strict
|
||||
* alignment, declaring a structure with that attribute
|
||||
* causes the compiler to generate code that handles
|
||||
* misaligned 2-byte, 4-byte, and 8-byte integral
|
||||
* quantities.
|
||||
*
|
||||
* It does not (yet) handle compilers where you can get the compiler
|
||||
* to generate code of that sort by some other means.
|
||||
*
|
||||
* This is required in order to, for example, keep the compiler from
|
||||
* generating, for
|
||||
*
|
||||
* if (bp->bp_htype == 1 && bp->bp_hlen == 6 && bp->bp_op == BOOTPREQUEST) {
|
||||
*
|
||||
* in print-bootp.c, code that loads the first 4-byte word of a
|
||||
* "struct bootp", masking out the bp_hops field, and comparing the result
|
||||
* against 0x01010600.
|
||||
*
|
||||
* Note: this also requires that padding be put into the structure,
|
||||
* at least for compilers where it's implemented as __attribute__((packed)).
|
||||
*/
|
||||
#if !(defined(_MSC_VER) && defined(UNALIGNED))
|
||||
/* MSVC may have its own macro defined with the same name and purpose. */
|
||||
#undef UNALIGNED
|
||||
#define UNALIGNED __attribute__((packed))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* fopen() read and write modes for text files and binary files.
|
||||
*/
|
||||
#if defined(_WIN32) || defined(MSDOS)
|
||||
#define FOPEN_READ_TXT "rt"
|
||||
#define FOPEN_READ_BIN "rb"
|
||||
#define FOPEN_WRITE_TXT "wt"
|
||||
#define FOPEN_WRITE_BIN "wb"
|
||||
#else
|
||||
#define FOPEN_READ_TXT "r"
|
||||
#define FOPEN_READ_BIN FOPEN_READ_TXT
|
||||
#define FOPEN_WRITE_TXT "w"
|
||||
#define FOPEN_WRITE_BIN FOPEN_WRITE_TXT
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Inline x86 assembler-language versions of ntoh[ls]() and hton[ls](),
|
||||
* defined if the OS doesn't provide them. These assume no more than
|
||||
* an 80386, so, for example, it avoids the bswap instruction added in
|
||||
* the 80486.
|
||||
*
|
||||
* (We don't use them on OS X; Apple provides their own, which *doesn't*
|
||||
* avoid the bswap instruction, as OS X only supports machines that
|
||||
* have it.)
|
||||
*/
|
||||
#if defined(__GNUC__) && defined(__i386__) && !defined(__APPLE__) && !defined(__ntohl)
|
||||
#undef ntohl
|
||||
#undef ntohs
|
||||
#undef htonl
|
||||
#undef htons
|
||||
|
||||
static __inline__ unsigned long __ntohl (unsigned long x);
|
||||
static __inline__ unsigned short __ntohs (unsigned short x);
|
||||
|
||||
#define ntohl(x) __ntohl(x)
|
||||
#define ntohs(x) __ntohs(x)
|
||||
#define htonl(x) __ntohl(x)
|
||||
#define htons(x) __ntohs(x)
|
||||
|
||||
static __inline__ unsigned long __ntohl (unsigned long x)
|
||||
{
|
||||
__asm__ ("xchgb %b0, %h0\n\t" /* swap lower bytes */
|
||||
"rorl $16, %0\n\t" /* swap words */
|
||||
"xchgb %b0, %h0" /* swap higher bytes */
|
||||
: "=q" (x) : "0" (x));
|
||||
return (x);
|
||||
}
|
||||
|
||||
static __inline__ unsigned short __ntohs (unsigned short x)
|
||||
{
|
||||
__asm__ ("xchgb %b0, %h0" /* swap bytes */
|
||||
: "=q" (x) : "0" (x));
|
||||
return (x);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If the OS doesn't define AF_INET6 and struct in6_addr:
|
||||
*
|
||||
* define AF_INET6, so we can use it internally as a "this is an
|
||||
* IPv6 address" indication;
|
||||
*
|
||||
* define struct in6_addr so that we can use it for IPv6 addresses.
|
||||
*/
|
||||
#ifndef HAVE_OS_IPV6_SUPPORT
|
||||
#ifndef AF_INET6
|
||||
#define AF_INET6 24
|
||||
|
||||
struct in6_addr {
|
||||
union {
|
||||
__uint8_t __u6_addr8[16];
|
||||
__uint16_t __u6_addr16[8];
|
||||
__uint32_t __u6_addr32[4];
|
||||
} __u6_addr; /* 128-bit IP6 address */
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef NI_MAXHOST
|
||||
#define NI_MAXHOST 1025
|
||||
#endif
|
||||
|
||||
#ifndef INET_ADDRSTRLEN
|
||||
#define INET_ADDRSTRLEN 16
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The Apple deprecation workaround macros below were adopted from the
|
||||
* FreeRADIUS server code under permission of Alan DeKok and Arran Cudbard-Bell.
|
||||
*/
|
||||
|
||||
#define XSTRINGIFY(x) #x
|
||||
|
||||
/*
|
||||
* Macros for controlling warnings in GCC >= 4.2 and clang >= 2.8
|
||||
*/
|
||||
#define DIAG_JOINSTR(x,y) XSTRINGIFY(x ## y)
|
||||
#define DIAG_DO_PRAGMA(x) _Pragma (#x)
|
||||
|
||||
#if defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 402
|
||||
# define DIAG_PRAGMA(x) DIAG_DO_PRAGMA(GCC diagnostic x)
|
||||
# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406
|
||||
# define DIAG_OFF(x) DIAG_PRAGMA(push) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,x))
|
||||
# define DIAG_ON(x) DIAG_PRAGMA(pop)
|
||||
# else
|
||||
# define DIAG_OFF(x) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,x))
|
||||
# define DIAG_ON(x) DIAG_PRAGMA(warning DIAG_JOINSTR(-W,x))
|
||||
# endif
|
||||
#elif defined(__clang__) && ((__clang_major__ * 100) + __clang_minor__ >= 208)
|
||||
# define DIAG_PRAGMA(x) DIAG_DO_PRAGMA(clang diagnostic x)
|
||||
# define DIAG_OFF(x) DIAG_PRAGMA(push) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,x))
|
||||
# define DIAG_ON(x) DIAG_PRAGMA(pop)
|
||||
#else
|
||||
# define DIAG_OFF(x)
|
||||
# define DIAG_ON(x)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* For dealing with APIs which are only deprecated in OSX (like the OpenSSL API)
|
||||
*/
|
||||
#ifdef __APPLE__
|
||||
# define USES_APPLE_DEPRECATED_API DIAG_OFF(deprecated-declarations)
|
||||
# define USES_APPLE_RST DIAG_ON(deprecated-declarations)
|
||||
#else
|
||||
# define USES_APPLE_DEPRECATED_API
|
||||
# define USES_APPLE_RST
|
||||
#endif
|
||||
|
||||
/*
|
||||
* end of Apple deprecation workaround macros
|
||||
*/
|
||||
|
||||
#ifndef min
|
||||
#define min(a,b) ((a)>(b)?(b):(a))
|
||||
#endif
|
||||
#ifndef max
|
||||
#define max(a,b) ((b)>(a)?(b):(a))
|
||||
#endif
|
||||
|
||||
#endif /* netdissect_stdinc_h */
|
||||
633
netdissect.h
Normal file
633
netdissect.h
Normal file
@@ -0,0 +1,633 @@
|
||||
/*
|
||||
* Copyright (c) 1988-1997
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Copyright (c) 1998-2012 Michael Richardson <mcr@tcpdump.org>
|
||||
* The TCPDUMP project
|
||||
*
|
||||
* 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 netdissect_h
|
||||
#define netdissect_h
|
||||
|
||||
#ifdef HAVE_OS_PROTO_H
|
||||
#include "os-proto.h"
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifndef HAVE___ATTRIBUTE__
|
||||
#define __attribute__(x)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Data types corresponding to multi-byte integral values within data
|
||||
* structures. These are defined as arrays of octets, so that they're
|
||||
* not aligned on their "natural" boundaries, and so that you *must*
|
||||
* use the EXTRACT_ macros to extract them (which you should be doing
|
||||
* *anyway*, so as not to assume a particular byte order or alignment
|
||||
* in your code).
|
||||
*/
|
||||
typedef unsigned char nd_uint16_t[2];
|
||||
typedef unsigned char nd_uint24_t[3];
|
||||
typedef unsigned char nd_uint32_t[4];
|
||||
typedef unsigned char nd_uint40_t[5];
|
||||
typedef unsigned char nd_uint48_t[6];
|
||||
typedef unsigned char nd_uint56_t[7];
|
||||
typedef unsigned char nd_uint64_t[8];
|
||||
|
||||
/*
|
||||
* Use this for IPv4 addresses. It's defined as an array of octets, so
|
||||
* that it's not aligned on its "natural" boundary, and it's defined as
|
||||
* a structure in the hopes that this makes it harder to naively use
|
||||
* EXTRACT_32BITS() to extract the value - in many cases you just want
|
||||
* to use UNALIGNED_MEMCPY() to copy its value, so that it remains in
|
||||
* network byte order.
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned char bytes[4];
|
||||
} nd_ipv4;
|
||||
|
||||
/*
|
||||
* Data types corresponding to single-byte integral values, for
|
||||
* completeness.
|
||||
*/
|
||||
typedef unsigned char nd_uint8_t;
|
||||
typedef signed char nd_int8_t;
|
||||
|
||||
/* snprintf et al */
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <pcap.h>
|
||||
|
||||
#include "ip.h" /* struct ip for nextproto4_cksum() */
|
||||
#include "ip6.h" /* struct ip6 for nextproto6_cksum() */
|
||||
|
||||
extern int32_t thiszone; /* seconds offset from gmt to local time */
|
||||
/* invalid string to print '(invalid)' for malformed or corrupted packets */
|
||||
extern const char istr[];
|
||||
|
||||
#if !defined(HAVE_SNPRINTF)
|
||||
int snprintf (char *str, size_t sz, const char *format, ...)
|
||||
#ifdef __ATTRIBUTE___FORMAT_OK
|
||||
__attribute__((format (printf, 3, 4)))
|
||||
#endif /* __ATTRIBUTE___FORMAT_OK */
|
||||
;
|
||||
#endif /* !defined(HAVE_SNPRINTF) */
|
||||
|
||||
#if !defined(HAVE_VSNPRINTF)
|
||||
int vsnprintf (char *str, size_t sz, const char *format, va_list ap)
|
||||
#ifdef __ATTRIBUTE___FORMAT_OK
|
||||
__attribute__((format (printf, 3, 0)))
|
||||
#endif /* __ATTRIBUTE___FORMAT_OK */
|
||||
;
|
||||
#endif /* !defined(HAVE_VSNPRINTF) */
|
||||
|
||||
#ifndef HAVE_STRLCAT
|
||||
extern size_t strlcat (char *, const char *, size_t);
|
||||
#endif
|
||||
#ifndef HAVE_STRLCPY
|
||||
extern size_t strlcpy (char *, const char *, size_t);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRDUP
|
||||
extern char *strdup (const char *str);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRSEP
|
||||
extern char *strsep(char **, const char *);
|
||||
#endif
|
||||
|
||||
struct tok {
|
||||
u_int v; /* value */
|
||||
const char *s; /* string */
|
||||
};
|
||||
|
||||
extern const char *tok2strbuf(const struct tok *, const char *, u_int,
|
||||
char *buf, size_t bufsize);
|
||||
|
||||
/* tok2str is deprecated */
|
||||
extern const char *tok2str(const struct tok *, const char *, u_int);
|
||||
extern char *bittok2str(const struct tok *, const char *, u_int);
|
||||
extern char *bittok2str_nosep(const struct tok *, const char *, u_int);
|
||||
|
||||
typedef struct netdissect_options netdissect_options;
|
||||
|
||||
#define IF_PRINTER_ARGS (netdissect_options *, const struct pcap_pkthdr *, const u_char *)
|
||||
|
||||
typedef u_int (*if_printer) IF_PRINTER_ARGS;
|
||||
|
||||
struct netdissect_options {
|
||||
int ndo_bflag; /* print 4 byte ASes in ASDOT notation */
|
||||
int ndo_eflag; /* print ethernet header */
|
||||
int ndo_fflag; /* don't translate "foreign" IP address */
|
||||
int ndo_Kflag; /* don't check TCP checksums */
|
||||
int ndo_nflag; /* leave addresses as numbers */
|
||||
int ndo_Nflag; /* remove domains from printed host names */
|
||||
int ndo_qflag; /* quick (shorter) output */
|
||||
int ndo_mflag; /* use the libsmi to translate OIDs */
|
||||
int ndo_Sflag; /* print raw TCP sequence numbers */
|
||||
int ndo_tflag; /* print packet arrival time */
|
||||
int ndo_uflag; /* Print undecoded NFS handles */
|
||||
int ndo_vflag; /* verbosity level */
|
||||
int ndo_xflag; /* print packet in hex */
|
||||
int ndo_Xflag; /* print packet in hex/ascii */
|
||||
int ndo_Aflag; /* print packet only in ascii observing TAB,
|
||||
* LF, CR and SPACE as graphical chars
|
||||
*/
|
||||
int ndo_Hflag; /* dissect 802.11s draft mesh standard */
|
||||
int ndo_packet_number; /* print a packet number in the beginning of line */
|
||||
int ndo_suppress_default_print; /* don't use default_print() for unknown packet types */
|
||||
int ndo_tstamp_precision; /* requested time stamp precision */
|
||||
const char *program_name; /* Name of the program using the library */
|
||||
|
||||
char *ndo_espsecret;
|
||||
struct sa_list *ndo_sa_list_head; /* used by print-esp.c */
|
||||
struct sa_list *ndo_sa_default;
|
||||
|
||||
char *ndo_sigsecret; /* Signature verification secret key */
|
||||
|
||||
int ndo_packettype; /* as specified by -T */
|
||||
|
||||
int ndo_snaplen;
|
||||
|
||||
/*global pointers to beginning and end of current packet (during printing) */
|
||||
const u_char *ndo_packetp;
|
||||
const u_char *ndo_snapend;
|
||||
|
||||
/* pointer to the if_printer function */
|
||||
if_printer ndo_if_printer;
|
||||
|
||||
/* pointer to void function to output stuff */
|
||||
void (*ndo_default_print)(netdissect_options *,
|
||||
register const u_char *bp, register u_int length);
|
||||
|
||||
/* pointer to function to do regular output */
|
||||
int (*ndo_printf)(netdissect_options *,
|
||||
const char *fmt, ...)
|
||||
#ifdef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS
|
||||
__attribute__ ((format (printf, 2, 3)))
|
||||
#endif
|
||||
;
|
||||
/* pointer to function to output errors */
|
||||
void (*ndo_error)(netdissect_options *,
|
||||
const char *fmt, ...)
|
||||
#ifdef __ATTRIBUTE___NORETURN_OK_FOR_FUNCTION_POINTERS
|
||||
__attribute__ ((noreturn))
|
||||
#endif /* __ATTRIBUTE___NORETURN_OK_FOR_FUNCTION_POINTERS */
|
||||
#ifdef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS
|
||||
__attribute__ ((format (printf, 2, 3)))
|
||||
#endif /* __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS */
|
||||
;
|
||||
/* pointer to function to output warnings */
|
||||
void (*ndo_warning)(netdissect_options *,
|
||||
const char *fmt, ...)
|
||||
#ifdef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS
|
||||
__attribute__ ((format (printf, 2, 3)))
|
||||
#endif
|
||||
;
|
||||
};
|
||||
|
||||
#define PT_VAT 1 /* Visual Audio Tool */
|
||||
#define PT_WB 2 /* distributed White Board */
|
||||
#define PT_RPC 3 /* Remote Procedure Call */
|
||||
#define PT_RTP 4 /* Real-Time Applications protocol */
|
||||
#define PT_RTCP 5 /* Real-Time Applications control protocol */
|
||||
#define PT_SNMP 6 /* Simple Network Management Protocol */
|
||||
#define PT_CNFP 7 /* Cisco NetFlow protocol */
|
||||
#define PT_TFTP 8 /* trivial file transfer protocol */
|
||||
#define PT_AODV 9 /* Ad-hoc On-demand Distance Vector Protocol */
|
||||
#define PT_CARP 10 /* Common Address Redundancy Protocol */
|
||||
#define PT_RADIUS 11 /* RADIUS authentication Protocol */
|
||||
#define PT_ZMTP1 12 /* ZeroMQ Message Transport Protocol 1.0 */
|
||||
#define PT_VXLAN 13 /* Virtual eXtensible Local Area Network */
|
||||
#define PT_PGM 14 /* [UDP-encapsulated] Pragmatic General Multicast */
|
||||
#define PT_PGM_ZMTP1 15 /* ZMTP/1.0 inside PGM (native or UDP-encapsulated) */
|
||||
#define PT_LMP 16 /* Link Management Protocol */
|
||||
#define PT_RESP 17 /* RESP */
|
||||
|
||||
#ifndef min
|
||||
#define min(a,b) ((a)>(b)?(b):(a))
|
||||
#endif
|
||||
#ifndef max
|
||||
#define max(a,b) ((b)>(a)?(b):(a))
|
||||
#endif
|
||||
|
||||
/* For source or destination ports tests (UDP, TCP, ...) */
|
||||
#define IS_SRC_OR_DST_PORT(p) (sport == (p) || dport == (p))
|
||||
|
||||
/*
|
||||
* Maximum snapshot length. This should be enough to capture the full
|
||||
* packet on most network interfaces.
|
||||
*
|
||||
*
|
||||
* Somewhat arbitrary, but chosen to be:
|
||||
*
|
||||
* 1) big enough for maximum-size Linux loopback packets (65549)
|
||||
* and some USB packets captured with USBPcap:
|
||||
*
|
||||
* http://desowin.org/usbpcap/
|
||||
*
|
||||
* (> 131072, < 262144)
|
||||
*
|
||||
* and
|
||||
*
|
||||
* 2) small enough not to cause attempts to allocate huge amounts of
|
||||
* memory; some applications might use the snapshot length in a
|
||||
* savefile header to control the size of the buffer they allocate,
|
||||
* so a size of, say, 2^31-1 might not work well.
|
||||
*
|
||||
* XXX - does it need to be bigger still?
|
||||
*/
|
||||
#define MAXIMUM_SNAPLEN 262144
|
||||
|
||||
/*
|
||||
* The default snapshot length is the maximum.
|
||||
*/
|
||||
#define DEFAULT_SNAPLEN MAXIMUM_SNAPLEN
|
||||
|
||||
#define ESRC(ep) ((ep)->ether_shost)
|
||||
#define EDST(ep) ((ep)->ether_dhost)
|
||||
|
||||
#ifndef NTOHL
|
||||
#define NTOHL(x) (x) = ntohl(x)
|
||||
#define NTOHS(x) (x) = ntohs(x)
|
||||
#define HTONL(x) (x) = htonl(x)
|
||||
#define HTONS(x) (x) = htons(x)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* True if "l" bytes of "var" were captured.
|
||||
*
|
||||
* The "ndo->ndo_snapend - (l) <= ndo->ndo_snapend" checks to make sure
|
||||
* "l" isn't so large that "ndo->ndo_snapend - (l)" underflows.
|
||||
*
|
||||
* The check is for <= rather than < because "l" might be 0.
|
||||
*
|
||||
* We cast the pointers to uintptr_t to make sure that the compiler
|
||||
* doesn't optimize away any of these tests (which it is allowed to
|
||||
* do, as adding an integer to, or subtracting an integer from, a
|
||||
* pointer assumes that the pointer is a pointer to an element of an
|
||||
* array and that the result of the addition or subtraction yields a
|
||||
* pointer to another member of the array, so that, for example, if
|
||||
* you subtract a positive integer from a pointer, the result is
|
||||
* guaranteed to be less than the original pointer value). See
|
||||
*
|
||||
* http://www.kb.cert.org/vuls/id/162289
|
||||
*/
|
||||
|
||||
/*
|
||||
* Test in two parts to avoid these warnings:
|
||||
* comparison of unsigned expression >= 0 is always true [-Wtype-limits],
|
||||
* comparison is always true due to limited range of data type [-Wtype-limits].
|
||||
*/
|
||||
#define IS_NOT_NEGATIVE(x) (((x) > 0) || ((x) == 0))
|
||||
|
||||
#define ND_TTEST2(var, l) \
|
||||
(IS_NOT_NEGATIVE(l) && \
|
||||
((uintptr_t)ndo->ndo_snapend - (l) <= (uintptr_t)ndo->ndo_snapend && \
|
||||
(uintptr_t)&(var) <= (uintptr_t)ndo->ndo_snapend - (l)))
|
||||
|
||||
/* True if "var" was captured */
|
||||
#define ND_TTEST(var) ND_TTEST2(var, sizeof(var))
|
||||
|
||||
/* Bail if "l" bytes of "var" were not captured */
|
||||
#define ND_TCHECK2(var, l) if (!ND_TTEST2(var, l)) goto trunc
|
||||
|
||||
/* Bail if "var" was not captured */
|
||||
#define ND_TCHECK(var) ND_TCHECK2(var, sizeof(var))
|
||||
|
||||
#define ND_PRINT(STUFF) (*ndo->ndo_printf)STUFF
|
||||
#define ND_DEFAULTPRINT(ap, length) (*ndo->ndo_default_print)(ndo, ap, length)
|
||||
|
||||
extern void ts_print(netdissect_options *, const struct timeval *);
|
||||
extern void relts_print(netdissect_options *, int);
|
||||
|
||||
extern void fn_print_char(netdissect_options *, u_char);
|
||||
extern int fn_print(netdissect_options *, const u_char *, const u_char *);
|
||||
extern int fn_printn(netdissect_options *, const u_char *, u_int, const u_char *);
|
||||
extern int fn_printzp(netdissect_options *, const u_char *, u_int, const u_char *);
|
||||
|
||||
/*
|
||||
* Flags for txtproto_print().
|
||||
*/
|
||||
#define RESP_CODE_SECOND_TOKEN 0x00000001 /* response code is second token in response line */
|
||||
|
||||
extern void txtproto_print(netdissect_options *, const u_char *, u_int,
|
||||
const char *, const char **, u_int);
|
||||
|
||||
/*
|
||||
* Locale-independent macros for testing character properties and
|
||||
* stripping the 8th bit from characters. Assumed to be handed
|
||||
* a value between 0 and 255, i.e. don't hand them a char, as
|
||||
* those might be in the range -128 to 127.
|
||||
*/
|
||||
#define ND_ISASCII(c) (!((c) & 0x80)) /* value is an ASCII code point */
|
||||
#define ND_ISPRINT(c) ((c) >= 0x20 && (c) <= 0x7E)
|
||||
#define ND_ISGRAPH(c) ((c) > 0x20 && (c) <= 0x7E)
|
||||
#define ND_TOASCII(c) ((c) & 0x7F)
|
||||
|
||||
extern void safeputchar(netdissect_options *, const u_char);
|
||||
extern void safeputs(netdissect_options *, const u_char *, const u_int);
|
||||
|
||||
#ifdef LBL_ALIGN
|
||||
/*
|
||||
* The processor doesn't natively handle unaligned loads,
|
||||
* and the compiler might "helpfully" optimize memcpy()
|
||||
* and memcmp(), when handed pointers that would normally
|
||||
* be properly aligned, into sequences that assume proper
|
||||
* alignment.
|
||||
*
|
||||
* Do copies and compares of possibly-unaligned data by
|
||||
* calling routines that wrap memcpy() and memcmp(), to
|
||||
* prevent that optimization.
|
||||
*/
|
||||
extern void unaligned_memcpy(void *, const void *, size_t);
|
||||
extern int unaligned_memcmp(const void *, const void *, size_t);
|
||||
#define UNALIGNED_MEMCPY(p, q, l) unaligned_memcpy((p), (q), (l))
|
||||
#define UNALIGNED_MEMCMP(p, q, l) unaligned_memcmp((p), (q), (l))
|
||||
#else
|
||||
/*
|
||||
* The procesor natively handles unaligned loads, so just use memcpy()
|
||||
* and memcmp(), to enable those optimizations.
|
||||
*/
|
||||
#define UNALIGNED_MEMCPY(p, q, l) memcpy((p), (q), (l))
|
||||
#define UNALIGNED_MEMCMP(p, q, l) memcmp((p), (q), (l))
|
||||
#endif
|
||||
|
||||
#define PLURAL_SUFFIX(n) \
|
||||
(((n) != 1) ? "s" : "")
|
||||
|
||||
extern const char *tok2strary_internal(const char **, int, const char *, int);
|
||||
#define tok2strary(a,f,i) tok2strary_internal(a, sizeof(a)/sizeof(a[0]),f,i)
|
||||
|
||||
extern if_printer lookup_printer(int);
|
||||
|
||||
/* The DLT printer routines */
|
||||
|
||||
extern u_int ap1394_if_print IF_PRINTER_ARGS;
|
||||
extern u_int arcnet_if_print IF_PRINTER_ARGS;
|
||||
extern u_int arcnet_linux_if_print IF_PRINTER_ARGS;
|
||||
extern u_int atm_if_print IF_PRINTER_ARGS;
|
||||
extern u_int bt_if_print IF_PRINTER_ARGS;
|
||||
extern u_int chdlc_if_print IF_PRINTER_ARGS;
|
||||
extern u_int cip_if_print IF_PRINTER_ARGS;
|
||||
extern u_int enc_if_print IF_PRINTER_ARGS;
|
||||
extern u_int ether_if_print IF_PRINTER_ARGS;
|
||||
extern u_int fddi_if_print IF_PRINTER_ARGS;
|
||||
extern u_int fr_if_print IF_PRINTER_ARGS;
|
||||
extern u_int ieee802_11_if_print IF_PRINTER_ARGS;
|
||||
extern u_int ieee802_11_radio_avs_if_print IF_PRINTER_ARGS;
|
||||
extern u_int ieee802_11_radio_if_print IF_PRINTER_ARGS;
|
||||
extern u_int ieee802_15_4_if_print IF_PRINTER_ARGS;
|
||||
extern u_int ipfc_if_print IF_PRINTER_ARGS;
|
||||
extern u_int ipnet_if_print IF_PRINTER_ARGS;
|
||||
extern u_int juniper_atm1_print IF_PRINTER_ARGS;
|
||||
extern u_int juniper_atm2_print IF_PRINTER_ARGS;
|
||||
extern u_int juniper_chdlc_print IF_PRINTER_ARGS;
|
||||
extern u_int juniper_es_print IF_PRINTER_ARGS;
|
||||
extern u_int juniper_ether_print IF_PRINTER_ARGS;
|
||||
extern u_int juniper_frelay_print IF_PRINTER_ARGS;
|
||||
extern u_int juniper_ggsn_print IF_PRINTER_ARGS;
|
||||
extern u_int juniper_mfr_print IF_PRINTER_ARGS;
|
||||
extern u_int juniper_mlfr_print IF_PRINTER_ARGS;
|
||||
extern u_int juniper_mlppp_print IF_PRINTER_ARGS;
|
||||
extern u_int juniper_monitor_print IF_PRINTER_ARGS;
|
||||
extern u_int juniper_ppp_print IF_PRINTER_ARGS;
|
||||
extern u_int juniper_pppoe_atm_print IF_PRINTER_ARGS;
|
||||
extern u_int juniper_pppoe_print IF_PRINTER_ARGS;
|
||||
extern u_int juniper_services_print IF_PRINTER_ARGS;
|
||||
extern u_int lane_if_print IF_PRINTER_ARGS;
|
||||
extern u_int ltalk_if_print IF_PRINTER_ARGS;
|
||||
extern u_int mfr_if_print IF_PRINTER_ARGS;
|
||||
extern u_int netanalyzer_if_print IF_PRINTER_ARGS;
|
||||
extern u_int netanalyzer_transparent_if_print IF_PRINTER_ARGS;
|
||||
extern u_int nflog_if_print IF_PRINTER_ARGS;
|
||||
extern u_int null_if_print IF_PRINTER_ARGS;
|
||||
extern u_int pflog_if_print IF_PRINTER_ARGS;
|
||||
extern u_int pktap_if_print IF_PRINTER_ARGS;
|
||||
extern u_int ppi_if_print IF_PRINTER_ARGS;
|
||||
extern u_int ppp_bsdos_if_print IF_PRINTER_ARGS;
|
||||
extern u_int ppp_hdlc_if_print IF_PRINTER_ARGS;
|
||||
extern u_int ppp_if_print IF_PRINTER_ARGS;
|
||||
extern u_int pppoe_if_print IF_PRINTER_ARGS;
|
||||
extern u_int prism_if_print IF_PRINTER_ARGS;
|
||||
extern u_int raw_if_print IF_PRINTER_ARGS;
|
||||
extern u_int sl_bsdos_if_print IF_PRINTER_ARGS;
|
||||
extern u_int sl_if_print IF_PRINTER_ARGS;
|
||||
extern u_int sll_if_print IF_PRINTER_ARGS;
|
||||
extern u_int sunatm_if_print IF_PRINTER_ARGS;
|
||||
extern u_int symantec_if_print IF_PRINTER_ARGS;
|
||||
extern u_int token_if_print IF_PRINTER_ARGS;
|
||||
extern u_int usb_linux_48_byte_print IF_PRINTER_ARGS;
|
||||
extern u_int usb_linux_64_byte_print IF_PRINTER_ARGS;
|
||||
|
||||
/* The printer routines. */
|
||||
|
||||
extern void aarp_print(netdissect_options *, const u_char *, u_int);
|
||||
extern int ah_print(netdissect_options *, register const u_char *);
|
||||
extern void ahcp_print(netdissect_options *, const u_char *, const u_int);
|
||||
extern void aodv_print(netdissect_options *, const u_char *, u_int, int);
|
||||
extern void aoe_print(netdissect_options *, const u_char *, const u_int);
|
||||
extern void arp_print(netdissect_options *, const u_char *, u_int, u_int);
|
||||
extern void ascii_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void atalk_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void atm_print(netdissect_options *, u_int, u_int, u_int, const u_char *, u_int, u_int);
|
||||
extern void babel_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void beep_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void bfd_print(netdissect_options *, const u_char *, u_int, u_int);
|
||||
extern void bgp_print(netdissect_options *, const u_char *, int);
|
||||
extern char *bgp_vpn_rd_print (netdissect_options *, const u_char *);
|
||||
extern void bootp_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void calm_fast_print(netdissect_options *, const u_char *, const u_char *, u_int);
|
||||
extern void carp_print(netdissect_options *, const u_char *, u_int, int);
|
||||
extern void cdp_print(netdissect_options *, const u_char *, u_int, u_int);
|
||||
extern void cfm_print(netdissect_options *, const u_char *, u_int);
|
||||
extern u_int chdlc_print(netdissect_options *, register const u_char *, u_int);
|
||||
extern void cisco_autorp_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void cnfp_print(netdissect_options *, const u_char *);
|
||||
extern void dccp_print(netdissect_options *, const u_char *, const u_char *, u_int);
|
||||
extern void decnet_print(netdissect_options *, const u_char *, u_int, u_int);
|
||||
extern void dhcp6_print(netdissect_options *, const u_char *, u_int);
|
||||
extern int dstopt_print(netdissect_options *, const u_char *);
|
||||
extern void dtp_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void dvmrp_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void eap_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void egp_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void eigrp_print(netdissect_options *, const u_char *, u_int);
|
||||
extern int esp_print(netdissect_options *, const u_char *, const int, const u_char *, int *, int *);
|
||||
extern u_int ether_print(netdissect_options *, const u_char *, u_int, u_int, void (*)(netdissect_options *, const u_char *), const u_char *);
|
||||
extern int ethertype_print(netdissect_options *, u_short, const u_char *, u_int, u_int);
|
||||
extern u_int fddi_print(netdissect_options *, const u_char *, u_int, u_int);
|
||||
extern void forces_print(netdissect_options *, const u_char *, u_int);
|
||||
extern u_int fr_print(netdissect_options *, register const u_char *, u_int);
|
||||
extern int frag6_print(netdissect_options *, const u_char *, const u_char *);
|
||||
extern void ftp_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void geneve_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void geonet_print(netdissect_options *, const u_char *, const u_char *, u_int);
|
||||
extern void gre_print(netdissect_options *, const u_char *, u_int);
|
||||
extern int hbhopt_print(netdissect_options *, const u_char *);
|
||||
extern void hex_and_ascii_print(netdissect_options *, const char *, const u_char *, u_int);
|
||||
extern void hex_and_ascii_print_with_offset(netdissect_options *, const char *, const u_char *, u_int, u_int);
|
||||
extern void hex_print(netdissect_options *, const char *ident, const u_char *cp, u_int);
|
||||
extern void hex_print_with_offset(netdissect_options *, const char *ident, const u_char *cp, u_int, u_int);
|
||||
extern void hncp_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void hsrp_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void http_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void icmp6_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
|
||||
extern void icmp_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
|
||||
extern void igmp_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void igrp_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void ip6_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void ipN_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void ip_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void ip_print_inner(netdissect_options *, const u_char *, u_int, u_int nh, const u_char *);
|
||||
extern int ipcomp_print(netdissect_options *, register const u_char *, int *);
|
||||
extern void ipx_netbios_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void ipx_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void isakmp_print(netdissect_options *, const u_char *, u_int, const u_char *);
|
||||
extern void isakmp_rfc3948_print(netdissect_options *, const u_char *, u_int, const u_char *);
|
||||
extern void isoclns_print(netdissect_options *, const u_char *, u_int, u_int);
|
||||
extern void krb_print(netdissect_options *, const u_char *);
|
||||
extern void l2tp_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void lane_print(netdissect_options *, const u_char *, u_int, u_int);
|
||||
extern void ldp_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void lisp_print(netdissect_options *, const u_char *, u_int);
|
||||
extern u_int llap_print(netdissect_options *, const u_char *, u_int);
|
||||
extern int llc_print(netdissect_options *, const u_char *, u_int, u_int, const u_char *, const u_char *);
|
||||
extern void lldp_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void lmp_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void loopback_print(netdissect_options *, const u_char *, const u_int);
|
||||
extern void lspping_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void lwapp_control_print(netdissect_options *, const u_char *, u_int, int);
|
||||
extern void lwapp_data_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void lwres_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void m3ua_print(netdissect_options *, const u_char *, const u_int);
|
||||
extern void medsa_print(netdissect_options *, const u_char *, u_int, u_int);
|
||||
extern u_int mfr_print(netdissect_options *, register const u_char *, u_int);
|
||||
extern void mobile_print(netdissect_options *, const u_char *, u_int);
|
||||
extern int mobility_print(netdissect_options *, const u_char *, const u_char *);
|
||||
extern void mpcp_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void mpls_print(netdissect_options *, const u_char *, u_int);
|
||||
extern int mptcp_print(netdissect_options *, const u_char *, u_int, u_char);
|
||||
extern void msdp_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void msnlb_print(netdissect_options *, const u_char *);
|
||||
extern void nbt_tcp_print(netdissect_options *, const u_char *, int);
|
||||
extern void nbt_udp137_print(netdissect_options *, const u_char *, int);
|
||||
extern void nbt_udp138_print(netdissect_options *, const u_char *, int);
|
||||
extern void netbeui_print(netdissect_options *, u_short, const u_char *, int);
|
||||
extern void nfsreply_print(netdissect_options *, const u_char *, u_int, const u_char *);
|
||||
extern void nfsreply_print_noaddr(netdissect_options *, const u_char *, u_int, const u_char *);
|
||||
extern void nfsreq_print_noaddr(netdissect_options *, const u_char *, u_int, const u_char *);
|
||||
extern const u_char * ns_nprint (netdissect_options *, register const u_char *, register const u_char *);
|
||||
extern void ns_print(netdissect_options *, const u_char *, u_int, int);
|
||||
extern void nsh_print(netdissect_options *ndo, const u_char *bp, u_int len);
|
||||
extern void ntp_print(netdissect_options *, const u_char *, u_int);
|
||||
extern int oam_print(netdissect_options *, const u_char *, u_int, u_int);
|
||||
extern void olsr_print(netdissect_options *, const u_char *, u_int, int);
|
||||
extern void openflow_print(netdissect_options *, const u_char *, const u_int);
|
||||
extern void ospf6_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void ospf_print(netdissect_options *, const u_char *, u_int, const u_char *);
|
||||
extern int ospf_print_grace_lsa(netdissect_options *, const uint8_t *, u_int);
|
||||
extern int ospf_print_te_lsa(netdissect_options *, const uint8_t *, u_int);
|
||||
extern void otv_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void pgm_print(netdissect_options *, const u_char *, u_int, const u_char *);
|
||||
extern void pim_print(netdissect_options *, const u_char *, u_int, const u_char *);
|
||||
extern void pimv1_print(netdissect_options *, const u_char *, u_int);
|
||||
extern u_int ppp_print(netdissect_options *, register const u_char *, u_int);
|
||||
extern u_int pppoe_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void pptp_print(netdissect_options *, const u_char *);
|
||||
extern int print_unknown_data(netdissect_options *, const u_char *, const char *, int);
|
||||
extern char *q922_string(netdissect_options *, const u_char *, u_int);
|
||||
extern void q933_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void radius_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void resp_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void rip_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void ripng_print(netdissect_options *, const u_char *, unsigned int);
|
||||
extern void rpki_rtr_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void rrcp_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void rsvp_print(netdissect_options *, const u_char *, u_int);
|
||||
extern int rt6_print(netdissect_options *, const u_char *, const u_char *);
|
||||
extern void rtsp_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void rx_print(netdissect_options *, register const u_char *, int, int, int, const u_char *);
|
||||
extern void sctp_print(netdissect_options *, const u_char *, const u_char *, u_int);
|
||||
extern void sflow_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void sip_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void slow_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void smb_print_data(netdissect_options *, const unsigned char *, int);
|
||||
extern void smb_tcp_print(netdissect_options *, const u_char *, int);
|
||||
extern void smtp_print(netdissect_options *, const u_char *, u_int);
|
||||
extern int snap_print(netdissect_options *, const u_char *, u_int, u_int, const u_char *, const u_char *, u_int);
|
||||
extern void snmp_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void stp_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void sunrpcrequest_print(netdissect_options *, const u_char *, u_int, const u_char *);
|
||||
extern void syslog_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void tcp_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
|
||||
extern void telnet_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void tftp_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void timed_print(netdissect_options *, const u_char *);
|
||||
extern void tipc_print(netdissect_options *, const u_char *, u_int, u_int);
|
||||
extern u_int token_print(netdissect_options *, const u_char *, u_int, u_int);
|
||||
extern void udld_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void udp_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
|
||||
extern int vjc_print(netdissect_options *, register const char *, u_short);
|
||||
extern void vqp_print(netdissect_options *, register const u_char *, register u_int);
|
||||
extern void vrrp_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
|
||||
extern void vtp_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void vxlan_gpe_print(netdissect_options *ndo, const u_char *bp, u_int len);
|
||||
extern void vxlan_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void wb_print(netdissect_options *, const void *, u_int);
|
||||
extern void zephyr_print(netdissect_options *, const u_char *, int);
|
||||
extern void zmtp1_print(netdissect_options *, const u_char *, u_int);
|
||||
extern void zmtp1_print_datagram(netdissect_options *, const u_char *, const u_int);
|
||||
|
||||
/* checksum routines */
|
||||
extern void init_checksum(void);
|
||||
extern uint16_t verify_crc10_cksum(uint16_t, const u_char *, int);
|
||||
extern uint16_t create_osi_cksum(const uint8_t *, int, int);
|
||||
|
||||
struct cksum_vec {
|
||||
const uint8_t *ptr;
|
||||
int len;
|
||||
};
|
||||
extern uint16_t in_cksum(const struct cksum_vec *, int);
|
||||
extern uint16_t in_cksum_shouldbe(uint16_t, uint16_t);
|
||||
|
||||
extern int nextproto4_cksum(netdissect_options *, const struct ip *, const uint8_t *, u_int, u_int, u_int);
|
||||
|
||||
/* in print-ip6.c */
|
||||
extern int nextproto6_cksum(netdissect_options *, const struct ip6_hdr *, const uint8_t *, u_int, u_int, u_int);
|
||||
|
||||
/* Utilities */
|
||||
extern int mask2plen(uint32_t);
|
||||
extern int mask62plen(const u_char *);
|
||||
|
||||
extern const char *dnname_string(netdissect_options *, u_short);
|
||||
extern const char *dnnum_string(netdissect_options *, u_short);
|
||||
|
||||
extern char *smb_errstr(int, int);
|
||||
extern const char *nt_errstr(uint32_t);
|
||||
|
||||
extern int decode_prefix4(netdissect_options *, const u_char *, u_int, char *, u_int);
|
||||
extern int decode_prefix6(netdissect_options *, const u_char *, u_int, char *, u_int);
|
||||
|
||||
extern void esp_print_decodesecret(netdissect_options *);
|
||||
extern int esp_print_decrypt_buffer_by_ikev2(netdissect_options *, int,
|
||||
u_char spii[8], u_char spir[8],
|
||||
const u_char *, const u_char *);
|
||||
|
||||
#endif /* netdissect_h */
|
||||
438
nfs.h
Normal file
438
nfs.h
Normal file
@@ -0,0 +1,438 @@
|
||||
/* NetBSD: nfs.h,v 1.1 1996/05/23 22:49:53 fvdl Exp */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Rick Macklem at The University of Guelph.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @(#)nfsproto.h 8.2 (Berkeley) 3/30/95
|
||||
*/
|
||||
|
||||
/*
|
||||
* nfs definitions as per the Version 2 and 3 specs
|
||||
*/
|
||||
|
||||
/*
|
||||
* Constants as defined in the Sun NFS Version 2 and 3 specs.
|
||||
* "NFS: Network File System Protocol Specification" RFC1094
|
||||
* and in the "NFS: Network File System Version 3 Protocol
|
||||
* Specification"
|
||||
*/
|
||||
|
||||
#define NFS_PORT 2049
|
||||
#define NFS_PROG 100003
|
||||
#define NFS_VER2 2
|
||||
#define NFS_VER3 3
|
||||
#define NFS_V2MAXDATA 8192
|
||||
#define NFS_MAXDGRAMDATA 16384
|
||||
#define NFS_MAXDATA 32768
|
||||
#define NFS_MAXPATHLEN 1024
|
||||
#define NFS_MAXNAMLEN 255
|
||||
#define NFS_MAXPKTHDR 404
|
||||
#define NFS_MAXPACKET (NFS_MAXPKTHDR + NFS_MAXDATA)
|
||||
#define NFS_MINPACKET 20
|
||||
#define NFS_FABLKSIZE 512 /* Size in bytes of a block wrt fa_blocks */
|
||||
|
||||
/* Stat numbers for rpc returns (version 2 and 3) */
|
||||
#define NFS_OK 0
|
||||
#define NFSERR_PERM 1
|
||||
#define NFSERR_NOENT 2
|
||||
#define NFSERR_IO 5
|
||||
#define NFSERR_NXIO 6
|
||||
#define NFSERR_ACCES 13
|
||||
#define NFSERR_EXIST 17
|
||||
#define NFSERR_XDEV 18 /* Version 3 only */
|
||||
#define NFSERR_NODEV 19
|
||||
#define NFSERR_NOTDIR 20
|
||||
#define NFSERR_ISDIR 21
|
||||
#define NFSERR_INVAL 22 /* Version 3 only */
|
||||
#define NFSERR_FBIG 27
|
||||
#define NFSERR_NOSPC 28
|
||||
#define NFSERR_ROFS 30
|
||||
#define NFSERR_MLINK 31 /* Version 3 only */
|
||||
#define NFSERR_NAMETOL 63
|
||||
#define NFSERR_NOTEMPTY 66
|
||||
#define NFSERR_DQUOT 69
|
||||
#define NFSERR_STALE 70
|
||||
#define NFSERR_REMOTE 71 /* Version 3 only */
|
||||
#define NFSERR_WFLUSH 99 /* Version 2 only */
|
||||
#define NFSERR_BADHANDLE 10001 /* The rest Version 3 only */
|
||||
#define NFSERR_NOT_SYNC 10002
|
||||
#define NFSERR_BAD_COOKIE 10003
|
||||
#define NFSERR_NOTSUPP 10004
|
||||
#define NFSERR_TOOSMALL 10005
|
||||
#define NFSERR_SERVERFAULT 10006
|
||||
#define NFSERR_BADTYPE 10007
|
||||
#define NFSERR_JUKEBOX 10008
|
||||
#define NFSERR_TRYLATER NFSERR_JUKEBOX
|
||||
#define NFSERR_STALEWRITEVERF 30001 /* Fake return for nfs_commit() */
|
||||
|
||||
#define NFSERR_RETVOID 0x20000000 /* Return void, not error */
|
||||
#define NFSERR_AUTHERR 0x40000000 /* Mark an authentication error */
|
||||
#define NFSERR_RETERR 0x80000000 /* Mark an error return for V3 */
|
||||
|
||||
/* Sizes in bytes of various nfs rpc components */
|
||||
#define NFSX_UNSIGNED 4
|
||||
|
||||
/* specific to NFS Version 2 */
|
||||
#define NFSX_V2FH 32
|
||||
#define NFSX_V2FATTR 68
|
||||
#define NFSX_V2SATTR 32
|
||||
#define NFSX_V2COOKIE 4
|
||||
#define NFSX_V2STATFS 20
|
||||
|
||||
/* specific to NFS Version 3 */
|
||||
#if 0
|
||||
#define NFSX_V3FH (sizeof (fhandle_t)) /* size this server uses */
|
||||
#endif
|
||||
#define NFSX_V3FHMAX 64 /* max. allowed by protocol */
|
||||
#define NFSX_V3FATTR 84
|
||||
#define NFSX_V3SATTR 60 /* max. all fields filled in */
|
||||
#define NFSX_V3SRVSATTR (sizeof (struct nfsv3_sattr))
|
||||
#define NFSX_V3POSTOPATTR (NFSX_V3FATTR + NFSX_UNSIGNED)
|
||||
#define NFSX_V3WCCDATA (NFSX_V3POSTOPATTR + 8 * NFSX_UNSIGNED)
|
||||
#define NFSX_V3COOKIEVERF 8
|
||||
#define NFSX_V3WRITEVERF 8
|
||||
#define NFSX_V3CREATEVERF 8
|
||||
#define NFSX_V3STATFS 52
|
||||
#define NFSX_V3FSINFO 48
|
||||
#define NFSX_V3PATHCONF 24
|
||||
|
||||
/* variants for both versions */
|
||||
#define NFSX_FH(v3) ((v3) ? (NFSX_V3FHMAX + NFSX_UNSIGNED) : \
|
||||
NFSX_V2FH)
|
||||
#define NFSX_SRVFH(v3) ((v3) ? NFSX_V3FH : NFSX_V2FH)
|
||||
#define NFSX_FATTR(v3) ((v3) ? NFSX_V3FATTR : NFSX_V2FATTR)
|
||||
#define NFSX_PREOPATTR(v3) ((v3) ? (7 * NFSX_UNSIGNED) : 0)
|
||||
#define NFSX_POSTOPATTR(v3) ((v3) ? (NFSX_V3FATTR + NFSX_UNSIGNED) : 0)
|
||||
#define NFSX_POSTOPORFATTR(v3) ((v3) ? (NFSX_V3FATTR + NFSX_UNSIGNED) : \
|
||||
NFSX_V2FATTR)
|
||||
#define NFSX_WCCDATA(v3) ((v3) ? NFSX_V3WCCDATA : 0)
|
||||
#define NFSX_WCCORFATTR(v3) ((v3) ? NFSX_V3WCCDATA : NFSX_V2FATTR)
|
||||
#define NFSX_SATTR(v3) ((v3) ? NFSX_V3SATTR : NFSX_V2SATTR)
|
||||
#define NFSX_COOKIEVERF(v3) ((v3) ? NFSX_V3COOKIEVERF : 0)
|
||||
#define NFSX_WRITEVERF(v3) ((v3) ? NFSX_V3WRITEVERF : 0)
|
||||
#define NFSX_READDIR(v3) ((v3) ? (5 * NFSX_UNSIGNED) : \
|
||||
(2 * NFSX_UNSIGNED))
|
||||
#define NFSX_STATFS(v3) ((v3) ? NFSX_V3STATFS : NFSX_V2STATFS)
|
||||
|
||||
/* nfs rpc procedure numbers (before version mapping) */
|
||||
#define NFSPROC_NULL 0
|
||||
#define NFSPROC_GETATTR 1
|
||||
#define NFSPROC_SETATTR 2
|
||||
#define NFSPROC_LOOKUP 3
|
||||
#define NFSPROC_ACCESS 4
|
||||
#define NFSPROC_READLINK 5
|
||||
#define NFSPROC_READ 6
|
||||
#define NFSPROC_WRITE 7
|
||||
#define NFSPROC_CREATE 8
|
||||
#define NFSPROC_MKDIR 9
|
||||
#define NFSPROC_SYMLINK 10
|
||||
#define NFSPROC_MKNOD 11
|
||||
#define NFSPROC_REMOVE 12
|
||||
#define NFSPROC_RMDIR 13
|
||||
#define NFSPROC_RENAME 14
|
||||
#define NFSPROC_LINK 15
|
||||
#define NFSPROC_READDIR 16
|
||||
#define NFSPROC_READDIRPLUS 17
|
||||
#define NFSPROC_FSSTAT 18
|
||||
#define NFSPROC_FSINFO 19
|
||||
#define NFSPROC_PATHCONF 20
|
||||
#define NFSPROC_COMMIT 21
|
||||
|
||||
/* And leasing (nqnfs) procedure numbers (must be last) */
|
||||
#define NQNFSPROC_GETLEASE 22
|
||||
#define NQNFSPROC_VACATED 23
|
||||
#define NQNFSPROC_EVICTED 24
|
||||
|
||||
#define NFSPROC_NOOP 25
|
||||
#define NFS_NPROCS 26
|
||||
|
||||
/* Actual Version 2 procedure numbers */
|
||||
#define NFSV2PROC_NULL 0
|
||||
#define NFSV2PROC_GETATTR 1
|
||||
#define NFSV2PROC_SETATTR 2
|
||||
#define NFSV2PROC_NOOP 3
|
||||
#define NFSV2PROC_ROOT NFSV2PROC_NOOP /* Obsolete */
|
||||
#define NFSV2PROC_LOOKUP 4
|
||||
#define NFSV2PROC_READLINK 5
|
||||
#define NFSV2PROC_READ 6
|
||||
#define NFSV2PROC_WRITECACHE NFSV2PROC_NOOP /* Obsolete */
|
||||
#define NFSV2PROC_WRITE 8
|
||||
#define NFSV2PROC_CREATE 9
|
||||
#define NFSV2PROC_REMOVE 10
|
||||
#define NFSV2PROC_RENAME 11
|
||||
#define NFSV2PROC_LINK 12
|
||||
#define NFSV2PROC_SYMLINK 13
|
||||
#define NFSV2PROC_MKDIR 14
|
||||
#define NFSV2PROC_RMDIR 15
|
||||
#define NFSV2PROC_READDIR 16
|
||||
#define NFSV2PROC_STATFS 17
|
||||
|
||||
/*
|
||||
* Constants used by the Version 3 protocol for various RPCs
|
||||
*/
|
||||
#define NFSV3SATTRTIME_DONTCHANGE 0
|
||||
#define NFSV3SATTRTIME_TOSERVER 1
|
||||
#define NFSV3SATTRTIME_TOCLIENT 2
|
||||
|
||||
#define NFSV3ATTRTIME_NMODES 3
|
||||
|
||||
#define NFSV3ACCESS_READ 0x01
|
||||
#define NFSV3ACCESS_LOOKUP 0x02
|
||||
#define NFSV3ACCESS_MODIFY 0x04
|
||||
#define NFSV3ACCESS_EXTEND 0x08
|
||||
#define NFSV3ACCESS_DELETE 0x10
|
||||
#define NFSV3ACCESS_EXECUTE 0x20
|
||||
#define NFSV3ACCESS_FULL 0x3f
|
||||
|
||||
#define NFSV3WRITE_UNSTABLE 0
|
||||
#define NFSV3WRITE_DATASYNC 1
|
||||
#define NFSV3WRITE_FILESYNC 2
|
||||
|
||||
#define NFSV3WRITE_NMODES 3
|
||||
|
||||
#define NFSV3CREATE_UNCHECKED 0
|
||||
#define NFSV3CREATE_GUARDED 1
|
||||
#define NFSV3CREATE_EXCLUSIVE 2
|
||||
|
||||
#define NFSV3CREATE_NMODES 3
|
||||
|
||||
#define NFSV3FSINFO_LINK 0x01
|
||||
#define NFSV3FSINFO_SYMLINK 0x02
|
||||
#define NFSV3FSINFO_HOMOGENEOUS 0x08
|
||||
#define NFSV3FSINFO_CANSETTIME 0x10
|
||||
|
||||
/* Conversion macros */
|
||||
#define vtonfsv2_mode(t,m) \
|
||||
txdr_unsigned(((t) == VFIFO) ? MAKEIMODE(VCHR, (m)) : \
|
||||
MAKEIMODE((t), (m)))
|
||||
#define vtonfsv3_mode(m) txdr_unsigned((m) & 07777)
|
||||
#define nfstov_mode(a) (fxdr_unsigned(uint16_t, (a))&07777)
|
||||
#define vtonfsv2_type(a) txdr_unsigned(nfsv2_type[((int32_t)(a))])
|
||||
#define vtonfsv3_type(a) txdr_unsigned(nfsv3_type[((int32_t)(a))])
|
||||
#define nfsv2tov_type(a) nv2tov_type[fxdr_unsigned(uint32_t,(a))&0x7]
|
||||
#define nfsv3tov_type(a) nv3tov_type[fxdr_unsigned(uint32_t,(a))&0x7]
|
||||
|
||||
/* File types */
|
||||
typedef enum { NFNON=0, NFREG=1, NFDIR=2, NFBLK=3, NFCHR=4, NFLNK=5,
|
||||
NFSOCK=6, NFFIFO=7 } nfs_type;
|
||||
|
||||
/* Structs for common parts of the rpc's */
|
||||
/*
|
||||
* File Handle (32 bytes for version 2), variable up to 64 for version 3.
|
||||
* File Handles of up to NFS_SMALLFH in size are stored directly in the
|
||||
* nfs node, whereas larger ones are malloc'd. (This never happens when
|
||||
* NFS_SMALLFH is set to 64.)
|
||||
* NFS_SMALLFH should be in the range of 32 to 64 and be divisible by 4.
|
||||
*/
|
||||
#ifndef NFS_SMALLFH
|
||||
#define NFS_SMALLFH 64
|
||||
#endif
|
||||
union nfsfh {
|
||||
/* fhandle_t fh_generic; */
|
||||
u_char fh_bytes[NFS_SMALLFH];
|
||||
};
|
||||
typedef union nfsfh nfsfh_t;
|
||||
|
||||
struct nfsv2_time {
|
||||
uint32_t nfsv2_sec;
|
||||
uint32_t nfsv2_usec;
|
||||
};
|
||||
typedef struct nfsv2_time nfstime2;
|
||||
|
||||
struct nfsv3_time {
|
||||
uint32_t nfsv3_sec;
|
||||
uint32_t nfsv3_nsec;
|
||||
};
|
||||
typedef struct nfsv3_time nfstime3;
|
||||
|
||||
/*
|
||||
* Quads are defined as arrays of 2 longs to ensure dense packing for the
|
||||
* protocol and to facilitate xdr conversion.
|
||||
*/
|
||||
struct nfs_uquad {
|
||||
uint32_t nfsuquad[2];
|
||||
};
|
||||
typedef struct nfs_uquad nfsuint64;
|
||||
|
||||
/*
|
||||
* NFS Version 3 special file number.
|
||||
*/
|
||||
struct nfsv3_spec {
|
||||
uint32_t specdata1;
|
||||
uint32_t specdata2;
|
||||
};
|
||||
typedef struct nfsv3_spec nfsv3spec;
|
||||
|
||||
/*
|
||||
* File attributes and setable attributes. These structures cover both
|
||||
* NFS version 2 and the version 3 protocol. Note that the union is only
|
||||
* used so that one pointer can refer to both variants. These structures
|
||||
* go out on the wire and must be densely packed, so no quad data types
|
||||
* are used. (all fields are longs or u_longs or structures of same)
|
||||
* NB: You can't do sizeof(struct nfs_fattr), you must use the
|
||||
* NFSX_FATTR(v3) macro.
|
||||
*/
|
||||
struct nfs_fattr {
|
||||
uint32_t fa_type;
|
||||
uint32_t fa_mode;
|
||||
uint32_t fa_nlink;
|
||||
uint32_t fa_uid;
|
||||
uint32_t fa_gid;
|
||||
union {
|
||||
struct {
|
||||
uint32_t nfsv2fa_size;
|
||||
uint32_t nfsv2fa_blocksize;
|
||||
uint32_t nfsv2fa_rdev;
|
||||
uint32_t nfsv2fa_blocks;
|
||||
uint32_t nfsv2fa_fsid;
|
||||
uint32_t nfsv2fa_fileid;
|
||||
nfstime2 nfsv2fa_atime;
|
||||
nfstime2 nfsv2fa_mtime;
|
||||
nfstime2 nfsv2fa_ctime;
|
||||
} fa_nfsv2;
|
||||
struct {
|
||||
nfsuint64 nfsv3fa_size;
|
||||
nfsuint64 nfsv3fa_used;
|
||||
nfsv3spec nfsv3fa_rdev;
|
||||
nfsuint64 nfsv3fa_fsid;
|
||||
nfsuint64 nfsv3fa_fileid;
|
||||
nfstime3 nfsv3fa_atime;
|
||||
nfstime3 nfsv3fa_mtime;
|
||||
nfstime3 nfsv3fa_ctime;
|
||||
} fa_nfsv3;
|
||||
} fa_un;
|
||||
};
|
||||
|
||||
/* and some ugly defines for accessing union components */
|
||||
#define fa2_size fa_un.fa_nfsv2.nfsv2fa_size
|
||||
#define fa2_blocksize fa_un.fa_nfsv2.nfsv2fa_blocksize
|
||||
#define fa2_rdev fa_un.fa_nfsv2.nfsv2fa_rdev
|
||||
#define fa2_blocks fa_un.fa_nfsv2.nfsv2fa_blocks
|
||||
#define fa2_fsid fa_un.fa_nfsv2.nfsv2fa_fsid
|
||||
#define fa2_fileid fa_un.fa_nfsv2.nfsv2fa_fileid
|
||||
#define fa2_atime fa_un.fa_nfsv2.nfsv2fa_atime
|
||||
#define fa2_mtime fa_un.fa_nfsv2.nfsv2fa_mtime
|
||||
#define fa2_ctime fa_un.fa_nfsv2.nfsv2fa_ctime
|
||||
#define fa3_size fa_un.fa_nfsv3.nfsv3fa_size
|
||||
#define fa3_used fa_un.fa_nfsv3.nfsv3fa_used
|
||||
#define fa3_rdev fa_un.fa_nfsv3.nfsv3fa_rdev
|
||||
#define fa3_fsid fa_un.fa_nfsv3.nfsv3fa_fsid
|
||||
#define fa3_fileid fa_un.fa_nfsv3.nfsv3fa_fileid
|
||||
#define fa3_atime fa_un.fa_nfsv3.nfsv3fa_atime
|
||||
#define fa3_mtime fa_un.fa_nfsv3.nfsv3fa_mtime
|
||||
#define fa3_ctime fa_un.fa_nfsv3.nfsv3fa_ctime
|
||||
|
||||
struct nfsv2_sattr {
|
||||
uint32_t sa_mode;
|
||||
uint32_t sa_uid;
|
||||
uint32_t sa_gid;
|
||||
uint32_t sa_size;
|
||||
nfstime2 sa_atime;
|
||||
nfstime2 sa_mtime;
|
||||
};
|
||||
|
||||
/*
|
||||
* NFS Version 3 sattr structure for the new node creation case.
|
||||
*/
|
||||
struct nfsv3_sattr {
|
||||
uint32_t sa_modeset;
|
||||
uint32_t sa_mode;
|
||||
uint32_t sa_uidset;
|
||||
uint32_t sa_uid;
|
||||
uint32_t sa_gidset;
|
||||
uint32_t sa_gid;
|
||||
uint32_t sa_sizeset;
|
||||
uint32_t sa_size;
|
||||
uint32_t sa_atimetype;
|
||||
nfstime3 sa_atime;
|
||||
uint32_t sa_mtimetype;
|
||||
nfstime3 sa_mtime;
|
||||
};
|
||||
|
||||
struct nfs_statfs {
|
||||
union {
|
||||
struct {
|
||||
uint32_t nfsv2sf_tsize;
|
||||
uint32_t nfsv2sf_bsize;
|
||||
uint32_t nfsv2sf_blocks;
|
||||
uint32_t nfsv2sf_bfree;
|
||||
uint32_t nfsv2sf_bavail;
|
||||
} sf_nfsv2;
|
||||
struct {
|
||||
nfsuint64 nfsv3sf_tbytes;
|
||||
nfsuint64 nfsv3sf_fbytes;
|
||||
nfsuint64 nfsv3sf_abytes;
|
||||
nfsuint64 nfsv3sf_tfiles;
|
||||
nfsuint64 nfsv3sf_ffiles;
|
||||
nfsuint64 nfsv3sf_afiles;
|
||||
uint32_t nfsv3sf_invarsec;
|
||||
} sf_nfsv3;
|
||||
} sf_un;
|
||||
};
|
||||
|
||||
#define sf_tsize sf_un.sf_nfsv2.nfsv2sf_tsize
|
||||
#define sf_bsize sf_un.sf_nfsv2.nfsv2sf_bsize
|
||||
#define sf_blocks sf_un.sf_nfsv2.nfsv2sf_blocks
|
||||
#define sf_bfree sf_un.sf_nfsv2.nfsv2sf_bfree
|
||||
#define sf_bavail sf_un.sf_nfsv2.nfsv2sf_bavail
|
||||
#define sf_tbytes sf_un.sf_nfsv3.nfsv3sf_tbytes
|
||||
#define sf_fbytes sf_un.sf_nfsv3.nfsv3sf_fbytes
|
||||
#define sf_abytes sf_un.sf_nfsv3.nfsv3sf_abytes
|
||||
#define sf_tfiles sf_un.sf_nfsv3.nfsv3sf_tfiles
|
||||
#define sf_ffiles sf_un.sf_nfsv3.nfsv3sf_ffiles
|
||||
#define sf_afiles sf_un.sf_nfsv3.nfsv3sf_afiles
|
||||
#define sf_invarsec sf_un.sf_nfsv3.nfsv3sf_invarsec
|
||||
|
||||
struct nfsv3_fsinfo {
|
||||
uint32_t fs_rtmax;
|
||||
uint32_t fs_rtpref;
|
||||
uint32_t fs_rtmult;
|
||||
uint32_t fs_wtmax;
|
||||
uint32_t fs_wtpref;
|
||||
uint32_t fs_wtmult;
|
||||
uint32_t fs_dtpref;
|
||||
nfsuint64 fs_maxfilesize;
|
||||
nfstime3 fs_timedelta;
|
||||
uint32_t fs_properties;
|
||||
};
|
||||
|
||||
struct nfsv3_pathconf {
|
||||
uint32_t pc_linkmax;
|
||||
uint32_t pc_namemax;
|
||||
uint32_t pc_notrunc;
|
||||
uint32_t pc_chownrestricted;
|
||||
uint32_t pc_caseinsensitive;
|
||||
uint32_t pc_casepreserving;
|
||||
};
|
||||
66
nfsfh.h
Normal file
66
nfsfh.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 1993, 1994 Jeffrey C. Mogul, Digital Equipment Corporation,
|
||||
* Western Research Laboratory. All rights reserved.
|
||||
* Copyright (c) 2001 Compaq Computer Corporation. All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, and modify this software and its
|
||||
* documentation is hereby granted only under the following terms and
|
||||
* conditions. Both the above copyright notice and this permission
|
||||
* notice must appear in all copies of the software, derivative works
|
||||
* or modified versions, and any portions thereof, and both notices
|
||||
* must appear in supporting documentation.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND COMPAQ COMPUTER CORPORATION
|
||||
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
||||
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
|
||||
* EVENT SHALL COMPAQ COMPUTER 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* nfsfh.h - NFS file handle definitions (for portable use)
|
||||
*
|
||||
* Jeffrey C. Mogul
|
||||
* Digital Equipment Corporation
|
||||
* Western Research Laboratory
|
||||
*/
|
||||
|
||||
/*
|
||||
* Internal representation of dev_t, because different NFS servers
|
||||
* that we might be spying upon use different external representations.
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t Minor; /* upper case to avoid clashing with macro names */
|
||||
uint32_t Major;
|
||||
} my_devt;
|
||||
|
||||
#define dev_eq(a,b) ((a.Minor == b.Minor) && (a.Major == b.Major))
|
||||
|
||||
/*
|
||||
* Many file servers now use a large file system ID. This is
|
||||
* our internal representation of that.
|
||||
*/
|
||||
typedef struct {
|
||||
my_devt Fsid_dev; /* XXX avoid name conflict with AIX */
|
||||
char Opaque_Handle[2 * 32 + 1];
|
||||
uint32_t fsid_code;
|
||||
} my_fsid;
|
||||
|
||||
#define fsid_eq(a,b) ((a.fsid_code == b.fsid_code) &&\
|
||||
dev_eq(a.Fsid_dev, b.Fsid_dev))
|
||||
|
||||
extern void Parse_fh(const unsigned char *, int, my_fsid *, uint32_t *, const char **, const char **, int);
|
||||
41
nlpid.c
Normal file
41
nlpid.c
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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, and (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.
|
||||
* 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.
|
||||
*
|
||||
* Original code by Hannes Gredler (hannes@juniper.net)
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <netdissect-stdinc.h>
|
||||
#include "netdissect.h"
|
||||
#include "nlpid.h"
|
||||
|
||||
const struct tok nlpid_values[] = {
|
||||
{ NLPID_NULLNS, "NULL" },
|
||||
{ NLPID_Q933, "Q.933" },
|
||||
{ NLPID_LMI, "LMI" },
|
||||
{ NLPID_SNAP, "SNAP" },
|
||||
{ NLPID_CLNP, "CLNP" },
|
||||
{ NLPID_ESIS, "ES-IS" },
|
||||
{ NLPID_ISIS, "IS-IS" },
|
||||
{ NLPID_CONS, "CONS" },
|
||||
{ NLPID_IDRP, "IDRP" },
|
||||
{ NLPID_SPB, "ISIS_SPB" },
|
||||
{ NLPID_MFR, "FRF.15" },
|
||||
{ NLPID_IP, "IPv4" },
|
||||
{ NLPID_PPP, "PPP" },
|
||||
{ NLPID_X25_ESIS, "X25 ES-IS" },
|
||||
{ NLPID_IP6, "IPv6" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
32
nlpid.h
Normal file
32
nlpid.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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, and (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.
|
||||
* 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.
|
||||
*
|
||||
* Original code by Hannes Gredler (hannes@juniper.net)
|
||||
*/
|
||||
|
||||
extern const struct tok nlpid_values[];
|
||||
|
||||
#define NLPID_NULLNS 0x00
|
||||
#define NLPID_Q933 0x08 /* ANSI T1.617 Annex D or ITU-T Q.933 Annex A */
|
||||
#define NLPID_LMI 0x09 /* The original, aka Cisco, aka Gang of Four */
|
||||
#define NLPID_SNAP 0x80
|
||||
#define NLPID_CLNP 0x81 /* iso9577 */
|
||||
#define NLPID_ESIS 0x82 /* iso9577 */
|
||||
#define NLPID_ISIS 0x83 /* iso9577 */
|
||||
#define NLPID_CONS 0x84
|
||||
#define NLPID_IDRP 0x85
|
||||
#define NLPID_MFR 0xb1 /* FRF.15 */
|
||||
#define NLPID_SPB 0xc1 /* IEEE 802.1aq/D4.5 */
|
||||
#define NLPID_IP 0xcc
|
||||
#define NLPID_PPP 0xcf
|
||||
#define NLPID_X25_ESIS 0x8a
|
||||
#define NLPID_IP6 0x8e
|
||||
51
openflow.h
Normal file
51
openflow.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2013 The TCPDUMP 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.
|
||||
*
|
||||
* 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 HOLDER 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.
|
||||
*/
|
||||
|
||||
/* OpenFlow: protocol between controller and datapath. */
|
||||
|
||||
/* for netdissect_options */
|
||||
#include "netdissect.h"
|
||||
|
||||
#define OF_HEADER_LEN 8
|
||||
|
||||
#define ONF_EXP_ONF 0x4f4e4600
|
||||
#define ONF_EXP_BUTE 0xff000001
|
||||
#define ONF_EXP_NOVIFLOW 0xff000002
|
||||
#define ONF_EXP_L3 0xff000003
|
||||
#define ONF_EXP_L4L7 0xff000004
|
||||
#define ONF_EXP_WMOB 0xff000005
|
||||
#define ONF_EXP_FABS 0xff000006
|
||||
#define ONF_EXP_OTRANS 0xff000007
|
||||
extern const struct tok onf_exp_str[];
|
||||
|
||||
/*
|
||||
* Routines to print packets for various versions of OpenFlow.
|
||||
*/
|
||||
extern const u_char *of10_header_body_print(netdissect_options *ndo,
|
||||
const u_char *, const u_char *,
|
||||
const uint8_t, const uint16_t, const uint32_t);
|
||||
extern const char * of_vendor_name(const uint32_t);
|
||||
325
ospf.h
Normal file
325
ospf.h
Normal file
@@ -0,0 +1,325 @@
|
||||
/*
|
||||
* Copyright (c) 1991, 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.
|
||||
*
|
||||
* OSPF support contributed by Jeffrey Honig (jch@mitchell.cit.cornell.edu)
|
||||
*/
|
||||
#define OSPF_TYPE_UMD 0 /* UMd's special monitoring packets */
|
||||
#define OSPF_TYPE_HELLO 1 /* Hello */
|
||||
#define OSPF_TYPE_DD 2 /* Database Description */
|
||||
#define OSPF_TYPE_LS_REQ 3 /* Link State Request */
|
||||
#define OSPF_TYPE_LS_UPDATE 4 /* Link State Update */
|
||||
#define OSPF_TYPE_LS_ACK 5 /* Link State Ack */
|
||||
|
||||
/* Options field
|
||||
*
|
||||
* +------------------------------------+
|
||||
* | DN | O | DC | L | N/P | MC | E | T |
|
||||
* +------------------------------------+
|
||||
*
|
||||
*/
|
||||
|
||||
#define OSPF_OPTION_T 0x01 /* T bit: TOS support */
|
||||
#define OSPF_OPTION_E 0x02 /* E bit: External routes advertised */
|
||||
#define OSPF_OPTION_MC 0x04 /* MC bit: Multicast capable */
|
||||
#define OSPF_OPTION_NP 0x08 /* N/P bit: NSSA capable */
|
||||
#define OSPF_OPTION_EA 0x10 /* EA bit: External Attribute capable */
|
||||
#define OSPF_OPTION_L 0x10 /* L bit: Packet contains LLS data block */
|
||||
#define OSPF_OPTION_DC 0x20 /* DC bit: Demand circuit capable */
|
||||
#define OSPF_OPTION_O 0x40 /* O bit: Opaque LSA capable */
|
||||
#define OSPF_OPTION_DN 0x80 /* DN bit: Up/Down Bit capable - draft-ietf-ospf-2547-dnbit-04 */
|
||||
|
||||
/* ospf_authtype */
|
||||
#define OSPF_AUTH_NONE 0 /* No auth-data */
|
||||
#define OSPF_AUTH_SIMPLE 1 /* Simple password */
|
||||
#define OSPF_AUTH_SIMPLE_LEN 8 /* max length of simple authentication */
|
||||
#define OSPF_AUTH_MD5 2 /* MD5 authentication */
|
||||
#define OSPF_AUTH_MD5_LEN 16 /* length of MD5 authentication */
|
||||
|
||||
/* db_flags */
|
||||
#define OSPF_DB_INIT 0x04
|
||||
#define OSPF_DB_MORE 0x02
|
||||
#define OSPF_DB_MASTER 0x01
|
||||
#define OSPF_DB_RESYNC 0x08 /* RFC4811 */
|
||||
|
||||
/* ls_type */
|
||||
#define LS_TYPE_ROUTER 1 /* router link */
|
||||
#define LS_TYPE_NETWORK 2 /* network link */
|
||||
#define LS_TYPE_SUM_IP 3 /* summary link */
|
||||
#define LS_TYPE_SUM_ABR 4 /* summary area link */
|
||||
#define LS_TYPE_ASE 5 /* ASE */
|
||||
#define LS_TYPE_GROUP 6 /* Group membership (multicast */
|
||||
/* extensions 23 July 1991) */
|
||||
#define LS_TYPE_NSSA 7 /* rfc3101 - Not so Stubby Areas */
|
||||
#define LS_TYPE_OPAQUE_LL 9 /* rfc2370 - Opaque Link Local */
|
||||
#define LS_TYPE_OPAQUE_AL 10 /* rfc2370 - Opaque Link Local */
|
||||
#define LS_TYPE_OPAQUE_DW 11 /* rfc2370 - Opaque Domain Wide */
|
||||
|
||||
#define LS_OPAQUE_TYPE_TE 1 /* rfc3630 */
|
||||
#define LS_OPAQUE_TYPE_GRACE 3 /* rfc3623 */
|
||||
#define LS_OPAQUE_TYPE_RI 4 /* draft-ietf-ospf-cap-03 */
|
||||
|
||||
#define LS_OPAQUE_TE_TLV_ROUTER 1 /* rfc3630 */
|
||||
#define LS_OPAQUE_TE_TLV_LINK 2 /* rfc3630 */
|
||||
|
||||
#define LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE 1 /* rfc3630 */
|
||||
#define LS_OPAQUE_TE_LINK_SUBTLV_LINK_ID 2 /* rfc3630 */
|
||||
#define LS_OPAQUE_TE_LINK_SUBTLV_LOCAL_IP 3 /* rfc3630 */
|
||||
#define LS_OPAQUE_TE_LINK_SUBTLV_REMOTE_IP 4 /* rfc3630 */
|
||||
#define LS_OPAQUE_TE_LINK_SUBTLV_TE_METRIC 5 /* rfc3630 */
|
||||
#define LS_OPAQUE_TE_LINK_SUBTLV_MAX_BW 6 /* rfc3630 */
|
||||
#define LS_OPAQUE_TE_LINK_SUBTLV_MAX_RES_BW 7 /* rfc3630 */
|
||||
#define LS_OPAQUE_TE_LINK_SUBTLV_UNRES_BW 8 /* rfc3630 */
|
||||
#define LS_OPAQUE_TE_LINK_SUBTLV_ADMIN_GROUP 9 /* rfc3630 */
|
||||
#define LS_OPAQUE_TE_LINK_SUBTLV_LINK_LOCAL_REMOTE_ID 11 /* rfc4203 */
|
||||
#define LS_OPAQUE_TE_LINK_SUBTLV_LINK_PROTECTION_TYPE 14 /* rfc4203 */
|
||||
#define LS_OPAQUE_TE_LINK_SUBTLV_INTF_SW_CAP_DESCR 15 /* rfc4203 */
|
||||
#define LS_OPAQUE_TE_LINK_SUBTLV_SHARED_RISK_GROUP 16 /* rfc4203 */
|
||||
#define LS_OPAQUE_TE_LINK_SUBTLV_BW_CONSTRAINTS 17 /* rfc4124 */
|
||||
|
||||
#define LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE_PTP 1 /* rfc3630 */
|
||||
#define LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE_MA 2 /* rfc3630 */
|
||||
|
||||
#define LS_OPAQUE_GRACE_TLV_PERIOD 1 /* rfc3623 */
|
||||
#define LS_OPAQUE_GRACE_TLV_REASON 2 /* rfc3623 */
|
||||
#define LS_OPAQUE_GRACE_TLV_INT_ADDRESS 3 /* rfc3623 */
|
||||
|
||||
#define LS_OPAQUE_GRACE_TLV_REASON_UNKNOWN 0 /* rfc3623 */
|
||||
#define LS_OPAQUE_GRACE_TLV_REASON_SW_RESTART 1 /* rfc3623 */
|
||||
#define LS_OPAQUE_GRACE_TLV_REASON_SW_UPGRADE 2 /* rfc3623 */
|
||||
#define LS_OPAQUE_GRACE_TLV_REASON_CP_SWITCH 3 /* rfc3623 */
|
||||
|
||||
#define LS_OPAQUE_RI_TLV_CAP 1 /* draft-ietf-ospf-cap-03 */
|
||||
|
||||
|
||||
/* rla_link.link_type */
|
||||
#define RLA_TYPE_ROUTER 1 /* point-to-point to another router */
|
||||
#define RLA_TYPE_TRANSIT 2 /* connection to transit network */
|
||||
#define RLA_TYPE_STUB 3 /* connection to stub network */
|
||||
#define RLA_TYPE_VIRTUAL 4 /* virtual link */
|
||||
|
||||
/* rla_flags */
|
||||
#define RLA_FLAG_B 0x01
|
||||
#define RLA_FLAG_E 0x02
|
||||
#define RLA_FLAG_W1 0x04
|
||||
#define RLA_FLAG_W2 0x08
|
||||
|
||||
/* sla_tosmetric breakdown */
|
||||
#define SLA_MASK_TOS 0x7f000000
|
||||
#define SLA_MASK_METRIC 0x00ffffff
|
||||
#define SLA_SHIFT_TOS 24
|
||||
|
||||
/* asla_tosmetric breakdown */
|
||||
#define ASLA_FLAG_EXTERNAL 0x80000000
|
||||
#define ASLA_MASK_TOS 0x7f000000
|
||||
#define ASLA_SHIFT_TOS 24
|
||||
#define ASLA_MASK_METRIC 0x00ffffff
|
||||
|
||||
/* multicast vertex type */
|
||||
#define MCLA_VERTEX_ROUTER 1
|
||||
#define MCLA_VERTEX_NETWORK 2
|
||||
|
||||
/* Link-Local-Signaling */
|
||||
#define OSPF_LLS_HDRLEN 4U /* RFC5613 Section 2.2 */
|
||||
|
||||
#define OSPF_LLS_EO 1 /* RFC4811, RFC4812 */
|
||||
#define OSPF_LLS_MD5 2 /* RFC4813 */
|
||||
|
||||
#define OSPF_LLS_EO_LR 0x00000001 /* RFC4811 */
|
||||
#define OSPF_LLS_EO_RS 0x00000002 /* RFC4812 */
|
||||
|
||||
/*
|
||||
* TOS metric struct (will be 0 or more in router links update)
|
||||
*/
|
||||
struct tos_metric {
|
||||
uint8_t tos_type;
|
||||
uint8_t reserved;
|
||||
uint8_t tos_metric[2];
|
||||
};
|
||||
struct tos_link {
|
||||
uint8_t link_type;
|
||||
uint8_t link_tos_count;
|
||||
uint8_t tos_metric[2];
|
||||
};
|
||||
union un_tos {
|
||||
struct tos_link link;
|
||||
struct tos_metric metrics;
|
||||
};
|
||||
|
||||
/* link state advertisement header */
|
||||
struct lsa_hdr {
|
||||
uint16_t ls_age;
|
||||
uint8_t ls_options;
|
||||
uint8_t ls_type;
|
||||
union {
|
||||
struct in_addr lsa_id;
|
||||
struct { /* opaque LSAs change the LSA-ID field */
|
||||
uint8_t opaque_type;
|
||||
uint8_t opaque_id[3];
|
||||
} opaque_field;
|
||||
} un_lsa_id;
|
||||
struct in_addr ls_router;
|
||||
uint32_t ls_seq;
|
||||
uint16_t ls_chksum;
|
||||
uint16_t ls_length;
|
||||
};
|
||||
|
||||
/* link state advertisement */
|
||||
struct lsa {
|
||||
struct lsa_hdr ls_hdr;
|
||||
|
||||
/* Link state types */
|
||||
union {
|
||||
/* Router links advertisements */
|
||||
struct {
|
||||
uint8_t rla_flags;
|
||||
uint8_t rla_zero[1];
|
||||
uint16_t rla_count;
|
||||
struct rlalink {
|
||||
struct in_addr link_id;
|
||||
struct in_addr link_data;
|
||||
union un_tos un_tos;
|
||||
} rla_link[1]; /* may repeat */
|
||||
} un_rla;
|
||||
|
||||
/* Network links advertisements */
|
||||
struct {
|
||||
struct in_addr nla_mask;
|
||||
struct in_addr nla_router[1]; /* may repeat */
|
||||
} un_nla;
|
||||
|
||||
/* Summary links advertisements */
|
||||
struct {
|
||||
struct in_addr sla_mask;
|
||||
uint32_t sla_tosmetric[1]; /* may repeat */
|
||||
} un_sla;
|
||||
|
||||
/* AS external links advertisements */
|
||||
struct {
|
||||
struct in_addr asla_mask;
|
||||
struct aslametric {
|
||||
uint32_t asla_tosmetric;
|
||||
struct in_addr asla_forward;
|
||||
struct in_addr asla_tag;
|
||||
} asla_metric[1]; /* may repeat */
|
||||
} un_asla;
|
||||
|
||||
/* Multicast group membership */
|
||||
struct mcla {
|
||||
uint32_t mcla_vtype;
|
||||
struct in_addr mcla_vid;
|
||||
} un_mcla[1];
|
||||
|
||||
/* Opaque TE LSA */
|
||||
struct {
|
||||
uint16_t type;
|
||||
uint16_t length;
|
||||
uint8_t data[1]; /* may repeat */
|
||||
} un_te_lsa_tlv;
|
||||
|
||||
/* Opaque Grace LSA */
|
||||
struct {
|
||||
uint16_t type;
|
||||
uint16_t length;
|
||||
uint8_t data[1]; /* may repeat */
|
||||
} un_grace_tlv;
|
||||
|
||||
/* Opaque Router information LSA */
|
||||
struct {
|
||||
uint16_t type;
|
||||
uint16_t length;
|
||||
uint8_t data[1]; /* may repeat */
|
||||
} un_ri_tlv;
|
||||
|
||||
/* Unknown LSA */
|
||||
struct unknown {
|
||||
uint8_t data[1]; /* may repeat */
|
||||
} un_unknown[1];
|
||||
|
||||
} lsa_un;
|
||||
};
|
||||
|
||||
#define OSPF_AUTH_SIZE 8
|
||||
|
||||
/*
|
||||
* the main header
|
||||
*/
|
||||
struct ospfhdr {
|
||||
uint8_t ospf_version;
|
||||
uint8_t ospf_type;
|
||||
uint16_t ospf_len;
|
||||
struct in_addr ospf_routerid;
|
||||
struct in_addr ospf_areaid;
|
||||
uint16_t ospf_chksum;
|
||||
uint16_t ospf_authtype;
|
||||
uint8_t ospf_authdata[OSPF_AUTH_SIZE];
|
||||
union {
|
||||
|
||||
/* Hello packet */
|
||||
struct {
|
||||
struct in_addr hello_mask;
|
||||
uint16_t hello_helloint;
|
||||
uint8_t hello_options;
|
||||
uint8_t hello_priority;
|
||||
uint32_t hello_deadint;
|
||||
struct in_addr hello_dr;
|
||||
struct in_addr hello_bdr;
|
||||
struct in_addr hello_neighbor[1]; /* may repeat */
|
||||
} un_hello;
|
||||
|
||||
/* Database Description packet */
|
||||
struct {
|
||||
uint16_t db_ifmtu;
|
||||
uint8_t db_options;
|
||||
uint8_t db_flags;
|
||||
uint32_t db_seq;
|
||||
struct lsa_hdr db_lshdr[1]; /* may repeat */
|
||||
} un_db;
|
||||
|
||||
/* Link State Request */
|
||||
struct lsr {
|
||||
uint8_t ls_type[4];
|
||||
union {
|
||||
struct in_addr ls_stateid;
|
||||
struct { /* opaque LSAs change the LSA-ID field */
|
||||
uint8_t opaque_type;
|
||||
uint8_t opaque_id[3];
|
||||
} opaque_field;
|
||||
} un_ls_stateid;
|
||||
struct in_addr ls_router;
|
||||
} un_lsr[1]; /* may repeat */
|
||||
|
||||
/* Link State Update */
|
||||
struct {
|
||||
uint32_t lsu_count;
|
||||
struct lsa lsu_lsa[1]; /* may repeat */
|
||||
} un_lsu;
|
||||
|
||||
/* Link State Acknowledgement */
|
||||
struct {
|
||||
struct lsa_hdr lsa_lshdr[1]; /* may repeat */
|
||||
} un_lsa ;
|
||||
} ospf_un ;
|
||||
};
|
||||
|
||||
#define ospf_hello ospf_un.un_hello
|
||||
#define ospf_db ospf_un.un_db
|
||||
#define ospf_lsr ospf_un.un_lsr
|
||||
#define ospf_lsu ospf_un.un_lsu
|
||||
#define ospf_lsa ospf_un.un_lsa
|
||||
103
oui.c
Normal file
103
oui.c
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* 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, and (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.
|
||||
* 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.
|
||||
*
|
||||
* Original code by Hannes Gredler (hannes@juniper.net)
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <netdissect-stdinc.h>
|
||||
#include "netdissect.h"
|
||||
#include "oui.h"
|
||||
|
||||
/* FIXME complete OUI list using a script */
|
||||
|
||||
const struct tok oui_values[] = {
|
||||
{ OUI_ENCAP_ETHER, "Ethernet" },
|
||||
{ OUI_CISCO, "Cisco" },
|
||||
{ OUI_NORTEL, "Nortel Networks SONMP" },
|
||||
{ OUI_CISCO_90, "Cisco bridged" },
|
||||
{ OUI_RFC2684, "Ethernet bridged" },
|
||||
{ OUI_ATM_FORUM, "ATM Forum" },
|
||||
{ OUI_CABLE_BPDU, "DOCSIS Spanning Tree" },
|
||||
{ OUI_APPLETALK, "Appletalk" },
|
||||
{ OUI_JUNIPER, "Juniper" },
|
||||
{ OUI_HP, "Hewlett-Packard" },
|
||||
{ OUI_IEEE_8021_PRIVATE, "IEEE 802.1 Private"},
|
||||
{ OUI_IEEE_8023_PRIVATE, "IEEE 802.3 Private"},
|
||||
{ OUI_TIA, "ANSI/TIA"},
|
||||
{ OUI_DCBX, "DCBX"},
|
||||
{ OUI_NICIRA, "Nicira Networks" },
|
||||
{ OUI_BSN, "Big Switch Networks" },
|
||||
{ OUI_VELLO, "Vello Systems" },
|
||||
{ OUI_HP2, "HP" },
|
||||
{ OUI_HPLABS, "HP-Labs" },
|
||||
{ OUI_INFOBLOX, "Infoblox Inc" },
|
||||
{ OUI_ONLAB, "Open Networking Lab" },
|
||||
{ OUI_FREESCALE, "Freescale" },
|
||||
{ OUI_NETRONOME, "Netronome" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
/*
|
||||
* SMI Network Management Private Enterprise Codes for organizations.
|
||||
*
|
||||
* XXX - these also appear in FreeRadius dictionary files, with items such
|
||||
* as
|
||||
*
|
||||
* VENDOR Cisco 9
|
||||
*
|
||||
* List taken from Ethereal's epan/sminmpec.c.
|
||||
*/
|
||||
const struct tok smi_values[] = {
|
||||
{ SMI_IETF, "IETF (reserved)"},
|
||||
{ SMI_ACC, "ACC"},
|
||||
{ SMI_CISCO, "Cisco"},
|
||||
{ SMI_HEWLETT_PACKARD, "Hewlett Packard"},
|
||||
{ SMI_SUN_MICROSYSTEMS, "Sun Microsystems"},
|
||||
{ SMI_MERIT, "Merit"},
|
||||
{ SMI_SHIVA, "Shiva"},
|
||||
{ SMI_ERICSSON, "Ericsson AB"},
|
||||
{ SMI_CISCO_VPN5000, "Cisco VPN 5000"},
|
||||
{ SMI_LIVINGSTON, "Livingston"},
|
||||
{ SMI_MICROSOFT, "Microsoft"},
|
||||
{ SMI_3COM, "3Com"},
|
||||
{ SMI_ASCEND, "Ascend"},
|
||||
{ SMI_BAY, "Bay Networks"},
|
||||
{ SMI_FOUNDRY, "Foundry"},
|
||||
{ SMI_VERSANET, "Versanet"},
|
||||
{ SMI_REDBACK, "Redback"},
|
||||
{ SMI_JUNIPER, "Juniper Networks"},
|
||||
{ SMI_APTIS, "Aptis"},
|
||||
{ SMI_CISCO_VPN3000, "Cisco VPN 3000"},
|
||||
{ SMI_COSINE, "CoSine Communications"},
|
||||
{ SMI_NETSCREEN, "Netscreen"},
|
||||
{ SMI_SHASTA, "Shasta"},
|
||||
{ SMI_NOMADIX, "Nomadix"},
|
||||
{ SMI_SIEMENS, "Siemens"},
|
||||
{ SMI_CABLELABS, "CableLabs"},
|
||||
{ SMI_UNISPHERE, "Unisphere Networks"},
|
||||
{ SMI_CISCO_BBSM, "Cisco BBSM"},
|
||||
{ SMI_THE3GPP2, "3rd Generation Partnership Project 2 (3GPP2)"},
|
||||
{ SMI_IP_UNPLUGGED, "ipUnplugged"},
|
||||
{ SMI_ISSANNI, "Issanni Communications"},
|
||||
{ SMI_QUINTUM, "Quintum"},
|
||||
{ SMI_INTERLINK, "Interlink"},
|
||||
{ SMI_COLUBRIS, "Colubris"},
|
||||
{ SMI_COLUMBIA_UNIVERSITY, "Columbia University"},
|
||||
{ SMI_THE3GPP, "3GPP"},
|
||||
{ SMI_GEMTEK_SYSTEMS, "Gemtek-Systems"},
|
||||
{ SMI_WIFI_ALLIANCE, "Wi-Fi Alliance"},
|
||||
{ 0, NULL}
|
||||
};
|
||||
90
oui.h
Normal file
90
oui.h
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* 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, and (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.
|
||||
* 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.
|
||||
*
|
||||
* Original code by Hannes Gredler (hannes@juniper.net)
|
||||
*/
|
||||
|
||||
extern const struct tok oui_values[];
|
||||
extern const struct tok smi_values[];
|
||||
|
||||
#define OUI_ENCAP_ETHER 0x000000 /* encapsulated Ethernet */
|
||||
#define OUI_CISCO 0x00000c /* Cisco protocols */
|
||||
#define OUI_NORTEL 0x000081 /* Nortel SONMP */
|
||||
#define OUI_CISCO_90 0x0000f8 /* Cisco bridging */
|
||||
#define OUI_RFC2684 0x0080c2 /* RFC 2427/2684 bridged Ethernet */
|
||||
#define OUI_ATM_FORUM 0x00A03E /* ATM Forum */
|
||||
#define OUI_CABLE_BPDU 0x00E02F /* DOCSIS spanning tree BPDU */
|
||||
#define OUI_APPLETALK 0x080007 /* Appletalk */
|
||||
#define OUI_JUNIPER 0x009069 /* Juniper */
|
||||
#define OUI_HP 0x080009 /* Hewlett-Packard */
|
||||
#define OUI_IEEE_8021_PRIVATE 0x0080c2 /* IEEE 802.1 Organisation Specific - Annex F */
|
||||
#define OUI_IEEE_8023_PRIVATE 0x00120f /* IEEE 802.3 Organisation Specific - Annex G */
|
||||
#define OUI_TIA 0x0012bb /* TIA - Telecommunications Industry Association - ANSI/TIA-1057- 2006 */
|
||||
#define OUI_DCBX 0x001B21 /* DCBX */
|
||||
#define OUI_NICIRA 0x002320 /* Nicira Networks */
|
||||
#define OUI_BSN 0x5c16c7 /* Big Switch Networks */
|
||||
#define OUI_VELLO 0xb0d2f5 /* Vello Systems */
|
||||
#define OUI_HP2 0x002481 /* HP too */
|
||||
#define OUI_HPLABS 0x0004ea /* HP-Labs */
|
||||
#define OUI_INFOBLOX 0x748771 /* Infoblox Inc */
|
||||
#define OUI_ONLAB 0xa42305 /* Open Networking Lab */
|
||||
#define OUI_FREESCALE 0x00049f /* Freescale */
|
||||
#define OUI_NETRONOME 0x0015ad /* Netronome */
|
||||
|
||||
/*
|
||||
* These are SMI Network Management Private Enterprise Codes for
|
||||
* organizations; see
|
||||
*
|
||||
* http://www.iana.org/assignments/enterprise-numbers
|
||||
*
|
||||
* for a list.
|
||||
*
|
||||
* List taken from Ethereal's epan/sminmpec.h.
|
||||
*/
|
||||
#define SMI_IETF 0 /* reserved - used by the IETF in L2TP? */
|
||||
#define SMI_ACC 5
|
||||
#define SMI_CISCO 9
|
||||
#define SMI_HEWLETT_PACKARD 11
|
||||
#define SMI_SUN_MICROSYSTEMS 42
|
||||
#define SMI_MERIT 61
|
||||
#define SMI_SHIVA 166
|
||||
#define SMI_ERICSSON 193
|
||||
#define SMI_CISCO_VPN5000 255
|
||||
#define SMI_LIVINGSTON 307
|
||||
#define SMI_MICROSOFT 311
|
||||
#define SMI_3COM 429
|
||||
#define SMI_ASCEND 529
|
||||
#define SMI_BAY 1584
|
||||
#define SMI_FOUNDRY 1991
|
||||
#define SMI_VERSANET 2180
|
||||
#define SMI_REDBACK 2352
|
||||
#define SMI_JUNIPER 2636
|
||||
#define SMI_APTIS 2637
|
||||
#define SMI_CISCO_VPN3000 3076
|
||||
#define SMI_COSINE 3085
|
||||
#define SMI_SHASTA 3199
|
||||
#define SMI_NETSCREEN 3224
|
||||
#define SMI_NOMADIX 3309
|
||||
#define SMI_SIEMENS 4329
|
||||
#define SMI_CABLELABS 4491
|
||||
#define SMI_UNISPHERE 4874
|
||||
#define SMI_CISCO_BBSM 5263
|
||||
#define SMI_THE3GPP2 5535
|
||||
#define SMI_IP_UNPLUGGED 5925
|
||||
#define SMI_ISSANNI 5948
|
||||
#define SMI_QUINTUM 6618
|
||||
#define SMI_INTERLINK 6728
|
||||
#define SMI_COLUBRIS 8744
|
||||
#define SMI_COLUMBIA_UNIVERSITY 11862
|
||||
#define SMI_THE3GPP 10415
|
||||
#define SMI_GEMTEK_SYSTEMS 10529
|
||||
#define SMI_WIFI_ALLIANCE 14122
|
||||
61
packetdat.awk
Normal file
61
packetdat.awk
Normal file
@@ -0,0 +1,61 @@
|
||||
BEGIN {
|
||||
# we need to know (usual) packet size to convert byte numbers
|
||||
# to packet numbers
|
||||
if (packetsize <= 0)
|
||||
packetsize = 512
|
||||
}
|
||||
$5 !~ /[SR]/ {
|
||||
# print out per-packet data in the form:
|
||||
# <packet #>
|
||||
# <start sequence #>
|
||||
# <1st send time>
|
||||
# <last send time>
|
||||
# <1st ack time>
|
||||
# <last ack time>
|
||||
# <# sends>
|
||||
# <# acks>
|
||||
|
||||
n = split ($1,t,":")
|
||||
tim = t[1]*3600 + t[2]*60 + t[3]
|
||||
if ($6 != "ack") {
|
||||
i = index($6,":")
|
||||
strtSeq = substr($6,1,i-1)
|
||||
id = 1.5 + (strtSeq - 1) / packetsize
|
||||
id -= id % 1
|
||||
if (maxId < id)
|
||||
maxId = id
|
||||
if (firstSend[id] == 0) {
|
||||
firstSend[id] = tim
|
||||
seqNo[id] = strtSeq
|
||||
}
|
||||
lastSend[id] = tim
|
||||
timesSent[id]++
|
||||
totalPackets++
|
||||
} else {
|
||||
id = 1 + ($7 - 2) / packetsize
|
||||
id -= id % 1
|
||||
timesAcked[id]++
|
||||
if (firstAck[id] == 0)
|
||||
firstAck[id] = tim
|
||||
lastAck[id] = tim
|
||||
totalAcks++
|
||||
}
|
||||
}
|
||||
END {
|
||||
print "# " maxId " chunks. " totalPackets " packets sent. " \
|
||||
totalAcks " acks."
|
||||
# for packets that were implicitly acked, make the ack time
|
||||
# be the ack time of next explicitly acked packet.
|
||||
for (i = maxId-1; i > 0; --i)
|
||||
while (i > 0 && firstAck[i] == 0) {
|
||||
lastAck[i] = firstAck[i] = firstAck[i+1]
|
||||
--i
|
||||
}
|
||||
tzero = firstSend[1]
|
||||
for (i = 1; i <= maxId; i++)
|
||||
printf "%d\t%d\t%.2f\t%.2f\t%.2f\t%.2f\t%d\t%d\n",\
|
||||
i, seqNo[i], \
|
||||
firstSend[i] - tzero, lastSend[i] - tzero,\
|
||||
firstAck[i] - tzero, lastAck[i] - tzero,\
|
||||
timesSent[i], timesAcked[i]
|
||||
}
|
||||
466
parsenfsfh.c
Normal file
466
parsenfsfh.c
Normal file
@@ -0,0 +1,466 @@
|
||||
/*
|
||||
* Copyright (c) 1993, 1994 Jeffrey C. Mogul, Digital Equipment Corporation,
|
||||
* Western Research Laboratory. All rights reserved.
|
||||
* Copyright (c) 2001 Compaq Computer Corporation. All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, and modify this software and its
|
||||
* documentation is hereby granted only under the following terms and
|
||||
* conditions. Both the above copyright notice and this permission
|
||||
* notice must appear in all copies of the software, derivative works
|
||||
* or modified versions, and any portions thereof, and both notices
|
||||
* must appear in supporting documentation.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND COMPAQ COMPUTER CORPORATION
|
||||
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
||||
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
|
||||
* EVENT SHALL COMPAQ COMPUTER 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* parsenfsfh.c - portable parser for NFS file handles
|
||||
* uses all sorts of heuristics
|
||||
*
|
||||
* Jeffrey C. Mogul
|
||||
* Digital Equipment Corporation
|
||||
* Western Research Laboratory
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <netdissect-stdinc.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "netdissect.h"
|
||||
#include "nfsfh.h"
|
||||
|
||||
/*
|
||||
* This routine attempts to parse a file handle (in network byte order),
|
||||
* using heuristics to guess what kind of format it is in. See the
|
||||
* file "fhandle_layouts" for a detailed description of the various
|
||||
* patterns we know about.
|
||||
*
|
||||
* The file handle is parsed into our internal representation of a
|
||||
* file-system id, and an internal representation of an inode-number.
|
||||
*/
|
||||
|
||||
#define FHT_UNKNOWN 0
|
||||
#define FHT_AUSPEX 1
|
||||
#define FHT_DECOSF 2
|
||||
#define FHT_IRIX4 3
|
||||
#define FHT_IRIX5 4
|
||||
#define FHT_SUNOS3 5
|
||||
#define FHT_SUNOS4 6
|
||||
#define FHT_ULTRIX 7
|
||||
#define FHT_VMSUCX 8
|
||||
#define FHT_SUNOS5 9
|
||||
#define FHT_AIX32 10
|
||||
#define FHT_HPUX9 11
|
||||
#define FHT_BSD44 12
|
||||
|
||||
#ifdef ultrix
|
||||
/* Nasty hack to keep the Ultrix C compiler from emitting bogus warnings */
|
||||
#define XFF(x) ((uint32_t)(x))
|
||||
#else
|
||||
#define XFF(x) (x)
|
||||
#endif
|
||||
|
||||
#define make_uint32(msb,b,c,lsb)\
|
||||
(XFF(lsb) + (XFF(c)<<8) + (XFF(b)<<16) + (XFF(msb)<<24))
|
||||
|
||||
#define make_uint24(msb,b, lsb)\
|
||||
(XFF(lsb) + (XFF(b)<<8) + (XFF(msb)<<16))
|
||||
|
||||
#define make_uint16(msb,lsb)\
|
||||
(XFF(lsb) + (XFF(msb)<<8))
|
||||
|
||||
#ifdef __alpha
|
||||
/* or other 64-bit systems */
|
||||
#define make_uint48(msb,b,c,d,e,lsb)\
|
||||
((lsb) + ((e)<<8) + ((d)<<16) + ((c)<<24) + ((b)<<32) + ((msb)<<40))
|
||||
#else
|
||||
/* on 32-bit systems ignore high-order bits */
|
||||
#define make_uint48(msb,b,c,d,e,lsb)\
|
||||
((lsb) + ((e)<<8) + ((d)<<16) + ((c)<<24))
|
||||
#endif
|
||||
|
||||
static int is_UCX(const unsigned char *);
|
||||
|
||||
void
|
||||
Parse_fh(register const unsigned char *fh, int len _U_, my_fsid *fsidp,
|
||||
uint32_t *inop,
|
||||
const char **osnamep, /* if non-NULL, return OS name here */
|
||||
const char **fsnamep, /* if non-NULL, return server fs name here (for VMS) */
|
||||
int ourself) /* true if file handle was generated on this host */
|
||||
{
|
||||
register const unsigned char *fhp = fh;
|
||||
uint32_t temp;
|
||||
int fhtype = FHT_UNKNOWN;
|
||||
int i;
|
||||
|
||||
if (ourself) {
|
||||
/* File handle generated on this host, no need for guessing */
|
||||
#if defined(IRIX40)
|
||||
fhtype = FHT_IRIX4;
|
||||
#endif
|
||||
#if defined(IRIX50)
|
||||
fhtype = FHT_IRIX5;
|
||||
#endif
|
||||
#if defined(IRIX51)
|
||||
fhtype = FHT_IRIX5;
|
||||
#endif
|
||||
#if defined(SUNOS4)
|
||||
fhtype = FHT_SUNOS4;
|
||||
#endif
|
||||
#if defined(SUNOS5)
|
||||
fhtype = FHT_SUNOS5;
|
||||
#endif
|
||||
#if defined(ultrix)
|
||||
fhtype = FHT_ULTRIX;
|
||||
#endif
|
||||
#if defined(__osf__)
|
||||
fhtype = FHT_DECOSF;
|
||||
#endif
|
||||
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) \
|
||||
|| defined(__OpenBSD__)
|
||||
fhtype = FHT_BSD44;
|
||||
#endif
|
||||
}
|
||||
/*
|
||||
* This is basically a big decision tree
|
||||
*/
|
||||
else if ((fhp[0] == 0) && (fhp[1] == 0)) {
|
||||
/* bytes[0,1] == (0,0); rules out Ultrix, IRIX5, SUNOS5 */
|
||||
/* probably rules out HP-UX, AIX unless they allow major=0 */
|
||||
if ((fhp[2] == 0) && (fhp[3] == 0)) {
|
||||
/* bytes[2,3] == (0,0); must be Auspex */
|
||||
/* XXX or could be Ultrix+MASSBUS "hp" disk? */
|
||||
fhtype = FHT_AUSPEX;
|
||||
}
|
||||
else {
|
||||
/*
|
||||
* bytes[2,3] != (0,0); rules out Auspex, could be
|
||||
* DECOSF, SUNOS4, or IRIX4
|
||||
*/
|
||||
if ((fhp[4] != 0) && (fhp[5] == 0) &&
|
||||
(fhp[8] == 12) && (fhp[9] == 0)) {
|
||||
/* seems to be DECOSF, with minor == 0 */
|
||||
fhtype = FHT_DECOSF;
|
||||
}
|
||||
else {
|
||||
/* could be SUNOS4 or IRIX4 */
|
||||
/* XXX the test of fhp[5] == 8 could be wrong */
|
||||
if ((fhp[4] == 0) && (fhp[5] == 8) && (fhp[6] == 0) &&
|
||||
(fhp[7] == 0)) {
|
||||
/* looks like a length, not a file system typecode */
|
||||
fhtype = FHT_IRIX4;
|
||||
}
|
||||
else {
|
||||
/* by elimination */
|
||||
fhtype = FHT_SUNOS4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
/*
|
||||
* bytes[0,1] != (0,0); rules out Auspex, IRIX4, SUNOS4
|
||||
* could be IRIX5, DECOSF, UCX, Ultrix, SUNOS5
|
||||
* could be AIX, HP-UX
|
||||
*/
|
||||
if ((fhp[2] == 0) && (fhp[3] == 0)) {
|
||||
/*
|
||||
* bytes[2,3] == (0,0); rules out OSF, probably not UCX
|
||||
* (unless the exported device name is just one letter!),
|
||||
* could be Ultrix, IRIX5, AIX, or SUNOS5
|
||||
* might be HP-UX (depends on their values for minor devs)
|
||||
*/
|
||||
if ((fhp[6] == 0) && (fhp[7] == 0)) {
|
||||
fhtype = FHT_BSD44;
|
||||
}
|
||||
/*XXX we probably only need to test of these two bytes */
|
||||
else if ((fhp[21] == 0) && (fhp[23] == 0)) {
|
||||
fhtype = FHT_ULTRIX;
|
||||
}
|
||||
else {
|
||||
/* Could be SUNOS5/IRIX5, maybe AIX */
|
||||
/* XXX no obvious difference between SUNOS5 and IRIX5 */
|
||||
if (fhp[9] == 10)
|
||||
fhtype = FHT_SUNOS5;
|
||||
/* XXX what about AIX? */
|
||||
}
|
||||
}
|
||||
else {
|
||||
/*
|
||||
* bytes[2,3] != (0,0); rules out Ultrix, could be
|
||||
* DECOSF, SUNOS5, IRIX5, AIX, HP-UX, or UCX
|
||||
*/
|
||||
if ((fhp[8] == 12) && (fhp[9] == 0)) {
|
||||
fhtype = FHT_DECOSF;
|
||||
}
|
||||
else if ((fhp[8] == 0) && (fhp[9] == 10)) {
|
||||
/* could be SUNOS5/IRIX5, AIX, HP-UX */
|
||||
if ((fhp[7] == 0) && (fhp[6] == 0) &&
|
||||
(fhp[5] == 0) && (fhp[4] == 0)) {
|
||||
/* XXX is this always true of HP-UX? */
|
||||
fhtype = FHT_HPUX9;
|
||||
}
|
||||
else if (fhp[7] == 2) {
|
||||
/* This would be MNT_NFS on AIX, which is impossible */
|
||||
fhtype = FHT_SUNOS5; /* or maybe IRIX5 */
|
||||
}
|
||||
else {
|
||||
/*
|
||||
* XXX Could be SUNOS5/IRIX5 or AIX. I don't
|
||||
* XXX see any way to disambiguate these, so
|
||||
* XXX I'm going with the more likely guess.
|
||||
* XXX Sorry, Big Blue.
|
||||
*/
|
||||
fhtype = FHT_SUNOS5; /* or maybe IRIX5 */
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (is_UCX(fhp)) {
|
||||
fhtype = FHT_VMSUCX;
|
||||
}
|
||||
else {
|
||||
fhtype = FHT_UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* XXX still needs to handle SUNOS3 */
|
||||
|
||||
switch (fhtype) {
|
||||
case FHT_AUSPEX:
|
||||
fsidp->Fsid_dev.Minor = fhp[7];
|
||||
fsidp->Fsid_dev.Major = fhp[6];
|
||||
fsidp->fsid_code = 0;
|
||||
|
||||
*inop = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
|
||||
|
||||
if (osnamep)
|
||||
*osnamep = "Auspex";
|
||||
break;
|
||||
|
||||
case FHT_BSD44:
|
||||
fsidp->Fsid_dev.Minor = fhp[0];
|
||||
fsidp->Fsid_dev.Major = fhp[1];
|
||||
fsidp->fsid_code = 0;
|
||||
|
||||
*inop = make_uint32(fhp[15], fhp[14], fhp[13], fhp[12]);
|
||||
|
||||
if (osnamep)
|
||||
*osnamep = "BSD 4.4";
|
||||
break;
|
||||
|
||||
case FHT_DECOSF:
|
||||
fsidp->fsid_code = make_uint32(fhp[7], fhp[6], fhp[5], fhp[4]);
|
||||
/* XXX could ignore 3 high-order bytes */
|
||||
|
||||
temp = make_uint32(fhp[3], fhp[2], fhp[1], fhp[0]);
|
||||
fsidp->Fsid_dev.Minor = temp & 0xFFFFF;
|
||||
fsidp->Fsid_dev.Major = (temp>>20) & 0xFFF;
|
||||
|
||||
*inop = make_uint32(fhp[15], fhp[14], fhp[13], fhp[12]);
|
||||
if (osnamep)
|
||||
*osnamep = "OSF";
|
||||
break;
|
||||
|
||||
case FHT_IRIX4:
|
||||
fsidp->Fsid_dev.Minor = fhp[3];
|
||||
fsidp->Fsid_dev.Major = fhp[2];
|
||||
fsidp->fsid_code = 0;
|
||||
|
||||
*inop = make_uint32(fhp[8], fhp[9], fhp[10], fhp[11]);
|
||||
|
||||
if (osnamep)
|
||||
*osnamep = "IRIX4";
|
||||
break;
|
||||
|
||||
case FHT_IRIX5:
|
||||
fsidp->Fsid_dev.Minor = make_uint16(fhp[2], fhp[3]);
|
||||
fsidp->Fsid_dev.Major = make_uint16(fhp[0], fhp[1]);
|
||||
fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]);
|
||||
|
||||
*inop = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
|
||||
|
||||
if (osnamep)
|
||||
*osnamep = "IRIX5";
|
||||
break;
|
||||
|
||||
#ifdef notdef
|
||||
case FHT_SUNOS3:
|
||||
/*
|
||||
* XXX - none of the heuristics above return this.
|
||||
* Are there any SunOS 3.x systems around to care about?
|
||||
*/
|
||||
if (osnamep)
|
||||
*osnamep = "SUNOS3";
|
||||
break;
|
||||
#endif
|
||||
|
||||
case FHT_SUNOS4:
|
||||
fsidp->Fsid_dev.Minor = fhp[3];
|
||||
fsidp->Fsid_dev.Major = fhp[2];
|
||||
fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]);
|
||||
|
||||
*inop = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
|
||||
|
||||
if (osnamep)
|
||||
*osnamep = "SUNOS4";
|
||||
break;
|
||||
|
||||
case FHT_SUNOS5:
|
||||
temp = make_uint16(fhp[0], fhp[1]);
|
||||
fsidp->Fsid_dev.Major = (temp>>2) & 0x3FFF;
|
||||
temp = make_uint24(fhp[1], fhp[2], fhp[3]);
|
||||
fsidp->Fsid_dev.Minor = temp & 0x3FFFF;
|
||||
fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]);
|
||||
|
||||
*inop = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
|
||||
|
||||
if (osnamep)
|
||||
*osnamep = "SUNOS5";
|
||||
break;
|
||||
|
||||
case FHT_ULTRIX:
|
||||
fsidp->fsid_code = 0;
|
||||
fsidp->Fsid_dev.Minor = fhp[0];
|
||||
fsidp->Fsid_dev.Major = fhp[1];
|
||||
|
||||
temp = make_uint32(fhp[7], fhp[6], fhp[5], fhp[4]);
|
||||
*inop = temp;
|
||||
if (osnamep)
|
||||
*osnamep = "Ultrix";
|
||||
break;
|
||||
|
||||
case FHT_VMSUCX:
|
||||
/* No numeric file system ID, so hash on the device-name */
|
||||
if (sizeof(*fsidp) >= 14) {
|
||||
if (sizeof(*fsidp) > 14)
|
||||
memset((char *)fsidp, 0, sizeof(*fsidp));
|
||||
/* just use the whole thing */
|
||||
memcpy((char *)fsidp, (const char *)fh, 14);
|
||||
}
|
||||
else {
|
||||
uint32_t tempa[4]; /* at least 16 bytes, maybe more */
|
||||
|
||||
memset((char *)tempa, 0, sizeof(tempa));
|
||||
memcpy((char *)tempa, (const char *)fh, 14); /* ensure alignment */
|
||||
fsidp->Fsid_dev.Minor = tempa[0] + (tempa[1]<<1);
|
||||
fsidp->Fsid_dev.Major = tempa[2] + (tempa[3]<<1);
|
||||
fsidp->fsid_code = 0;
|
||||
}
|
||||
|
||||
/* VMS file ID is: (RVN, FidHi, FidLo) */
|
||||
*inop = make_uint32(fhp[26], fhp[27], fhp[23], fhp[22]);
|
||||
|
||||
/* Caller must save (and null-terminate?) this value */
|
||||
if (fsnamep)
|
||||
*fsnamep = (const char *)&(fhp[1]);
|
||||
|
||||
if (osnamep)
|
||||
*osnamep = "VMS";
|
||||
break;
|
||||
|
||||
case FHT_AIX32:
|
||||
fsidp->Fsid_dev.Minor = make_uint16(fhp[2], fhp[3]);
|
||||
fsidp->Fsid_dev.Major = make_uint16(fhp[0], fhp[1]);
|
||||
fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]);
|
||||
|
||||
*inop = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
|
||||
|
||||
if (osnamep)
|
||||
*osnamep = "AIX32";
|
||||
break;
|
||||
|
||||
case FHT_HPUX9:
|
||||
fsidp->Fsid_dev.Major = fhp[0];
|
||||
temp = make_uint24(fhp[1], fhp[2], fhp[3]);
|
||||
fsidp->Fsid_dev.Minor = temp;
|
||||
fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]);
|
||||
|
||||
*inop = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
|
||||
|
||||
if (osnamep)
|
||||
*osnamep = "HPUX9";
|
||||
break;
|
||||
|
||||
case FHT_UNKNOWN:
|
||||
#ifdef DEBUG
|
||||
/* XXX debugging */
|
||||
for (i = 0; i < 32; i++)
|
||||
(void)fprintf(stderr, "%x.", fhp[i]);
|
||||
(void)fprintf(stderr, "\n");
|
||||
#endif
|
||||
/* Save the actual handle, so it can be display with -u */
|
||||
for (i = 0; i < 32; i++)
|
||||
(void)snprintf(&(fsidp->Opaque_Handle[i*2]), 3, "%.2X", fhp[i]);
|
||||
|
||||
/* XXX for now, give "bogus" values to aid debugging */
|
||||
fsidp->fsid_code = 0;
|
||||
fsidp->Fsid_dev.Minor = 257;
|
||||
fsidp->Fsid_dev.Major = 257;
|
||||
*inop = 1;
|
||||
|
||||
/* display will show this string instead of (257,257) */
|
||||
if (fsnamep)
|
||||
*fsnamep = "Unknown";
|
||||
|
||||
if (osnamep)
|
||||
*osnamep = "Unknown";
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Is this a VMS UCX file handle?
|
||||
* Check for:
|
||||
* (1) leading code byte [XXX not yet]
|
||||
* (2) followed by string of printing chars & spaces
|
||||
* (3) followed by string of nulls
|
||||
*/
|
||||
static int
|
||||
is_UCX(const unsigned char *fhp)
|
||||
{
|
||||
register int i;
|
||||
int seen_null = 0;
|
||||
|
||||
for (i = 1; i < 14; i++) {
|
||||
if (ND_ISPRINT(fhp[i])) {
|
||||
if (seen_null)
|
||||
return(0);
|
||||
else
|
||||
continue;
|
||||
}
|
||||
else if (fhp[i] == 0) {
|
||||
seen_null = 1;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
return(0);
|
||||
}
|
||||
|
||||
return(1);
|
||||
}
|
||||
49
pcap-missing.h
Normal file
49
pcap-missing.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 1988-2002
|
||||
* 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 netdissect_pcap_missing_h
|
||||
#define netdissect_pcap_missing_h
|
||||
|
||||
/*
|
||||
* Declarations of functions that might be missing from libpcap.
|
||||
*/
|
||||
|
||||
#ifndef HAVE_PCAP_LIST_DATALINKS
|
||||
extern int pcap_list_datalinks(pcap_t *, int **);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_PCAP_DATALINK_NAME_TO_VAL
|
||||
/*
|
||||
* We assume no platform has one but not the other.
|
||||
*/
|
||||
extern int pcap_datalink_name_to_val(const char *);
|
||||
extern const char *pcap_datalink_val_to_name(int);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION
|
||||
extern const char *pcap_datalink_val_to_description(int);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_PCAP_DUMP_FTELL
|
||||
extern long pcap_dump_ftell(pcap_dumper_t *);
|
||||
#endif
|
||||
|
||||
#endif /* netdissect_pcap_missing_h */
|
||||
31
pcap_dump_ftell.c
Normal file
31
pcap_dump_ftell.c
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <pcap.h>
|
||||
|
||||
#include "pcap-missing.h"
|
||||
|
||||
long
|
||||
pcap_dump_ftell(pcap_dumper_t *p)
|
||||
{
|
||||
return (ftell((FILE *)p));
|
||||
}
|
||||
68
ppp.h
Normal file
68
ppp.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Point to Point Protocol (PPP) RFC1331
|
||||
*
|
||||
* Copyright 1989 by Carnegie Mellon.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this program for any
|
||||
* purpose and without fee is hereby granted, provided that this copyright
|
||||
* and permission notice appear on all copies and supporting documentation,
|
||||
* the name of Carnegie Mellon not be used in advertising or publicity
|
||||
* pertaining to distribution of the program without specific prior
|
||||
* permission, and notice be given in supporting documentation that copying
|
||||
* and distribution is by permission of Carnegie Mellon and Stanford
|
||||
* University. Carnegie Mellon makes no representations about the
|
||||
* suitability of this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*/
|
||||
#define PPP_HDRLEN 4 /* length of PPP header */
|
||||
|
||||
#define PPP_ADDRESS 0xff /* The address byte value */
|
||||
#define PPP_CONTROL 0x03 /* The control byte value */
|
||||
|
||||
#define PPP_WITHDIRECTION_IN 0x00 /* non-standard for DLT_PPP_WITHDIRECTION */
|
||||
#define PPP_WITHDIRECTION_OUT 0x01 /* non-standard for DLT_PPP_WITHDIRECTION */
|
||||
|
||||
/* Protocol numbers */
|
||||
#define PPP_IP 0x0021 /* Raw IP */
|
||||
#define PPP_OSI 0x0023 /* OSI Network Layer */
|
||||
#define PPP_NS 0x0025 /* Xerox NS IDP */
|
||||
#define PPP_DECNET 0x0027 /* DECnet Phase IV */
|
||||
#define PPP_APPLE 0x0029 /* Appletalk */
|
||||
#define PPP_IPX 0x002b /* Novell IPX */
|
||||
#define PPP_VJC 0x002d /* Van Jacobson Compressed TCP/IP */
|
||||
#define PPP_VJNC 0x002f /* Van Jacobson Uncompressed TCP/IP */
|
||||
#define PPP_BRPDU 0x0031 /* Bridging PDU */
|
||||
#define PPP_STII 0x0033 /* Stream Protocol (ST-II) */
|
||||
#define PPP_VINES 0x0035 /* Banyan Vines */
|
||||
#define PPP_ML 0x003d /* Multi-Link PPP */
|
||||
#define PPP_IPV6 0x0057 /* IPv6 */
|
||||
#define PPP_COMP 0x00fd /* Compressed Datagram */
|
||||
|
||||
#define PPP_HELLO 0x0201 /* 802.1d Hello Packets */
|
||||
#define PPP_LUXCOM 0x0231 /* Luxcom */
|
||||
#define PPP_SNS 0x0233 /* Sigma Network Systems */
|
||||
#define PPP_MPLS_UCAST 0x0281 /* rfc 3032 */
|
||||
#define PPP_MPLS_MCAST 0x0283 /* rfc 3022 */
|
||||
|
||||
#define PPP_IPCP 0x8021 /* IP Control Protocol */
|
||||
#define PPP_OSICP 0x8023 /* OSI Network Layer Control Protocol */
|
||||
#define PPP_NSCP 0x8025 /* Xerox NS IDP Control Protocol */
|
||||
#define PPP_DECNETCP 0x8027 /* DECnet Control Protocol */
|
||||
#define PPP_APPLECP 0x8029 /* Appletalk Control Protocol */
|
||||
#define PPP_IPXCP 0x802b /* Novell IPX Control Protocol */
|
||||
#define PPP_STIICP 0x8033 /* Strean Protocol Control Protocol */
|
||||
#define PPP_VINESCP 0x8035 /* Banyan Vines Control Protocol */
|
||||
#define PPP_IPV6CP 0x8057 /* IPv6 Control Protocol */
|
||||
#define PPP_CCP 0x80fd /* Compress Control Protocol */
|
||||
#define PPP_MPLSCP 0x8281 /* rfc 3022 */
|
||||
|
||||
#define PPP_LCP 0xc021 /* Link Control Protocol */
|
||||
#define PPP_PAP 0xc023 /* Password Authentication Protocol */
|
||||
#define PPP_LQM 0xc025 /* Link Quality Monitoring */
|
||||
#define PPP_SPAP 0xc027
|
||||
#define PPP_CHAP 0xc223 /* Challenge Handshake Authentication Protocol */
|
||||
#define PPP_BACP 0xc02b /* Bandwidth Allocation Control Protocol */
|
||||
#define PPP_BAP 0xc02d /* BAP */
|
||||
#define PPP_MPCP 0xc03d /* Multi-Link */
|
||||
#define PPP_SPAP_OLD 0xc123
|
||||
#define PPP_EAP 0xc227
|
||||
3371
print-802_11.c
Normal file
3371
print-802_11.c
Normal file
File diff suppressed because it is too large
Load Diff
179
print-802_15_4.c
Normal file
179
print-802_15_4.c
Normal file
@@ -0,0 +1,179 @@
|
||||
/*
|
||||
* Copyright (c) 2009
|
||||
* Siemens AG, All rights reserved.
|
||||
* Dmitry Eremin-Solenikov (dbaryshkov@gmail.com)
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that: (1) source code distributions
|
||||
* retain the above copyright notice and this paragraph in its entirety, (2)
|
||||
* distributions including binary code include the above copyright notice and
|
||||
* this paragraph in its entirety in the documentation or other materials
|
||||
* provided with the distribution, and (3) all advertising materials mentioning
|
||||
* features or use of this software display the following acknowledgement:
|
||||
* ``This product includes software developed by the University of California,
|
||||
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
|
||||
* the University nor the names of its contributors may be used to endorse
|
||||
* or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <netdissect-stdinc.h>
|
||||
|
||||
#include "netdissect.h"
|
||||
#include "addrtoname.h"
|
||||
|
||||
#include "extract.h"
|
||||
|
||||
static const char *ftypes[] = {
|
||||
"Beacon", /* 0 */
|
||||
"Data", /* 1 */
|
||||
"ACK", /* 2 */
|
||||
"Command", /* 3 */
|
||||
"Reserved", /* 4 */
|
||||
"Reserved", /* 5 */
|
||||
"Reserved", /* 6 */
|
||||
"Reserved", /* 7 */
|
||||
};
|
||||
|
||||
static int
|
||||
extract_header_length(uint16_t fc)
|
||||
{
|
||||
int len = 0;
|
||||
|
||||
switch ((fc >> 10) & 0x3) {
|
||||
case 0x00:
|
||||
if (fc & (1 << 6)) /* intra-PAN with none dest addr */
|
||||
return -1;
|
||||
break;
|
||||
case 0x01:
|
||||
return -1;
|
||||
case 0x02:
|
||||
len += 4;
|
||||
break;
|
||||
case 0x03:
|
||||
len += 10;
|
||||
break;
|
||||
}
|
||||
|
||||
switch ((fc >> 14) & 0x3) {
|
||||
case 0x00:
|
||||
break;
|
||||
case 0x01:
|
||||
return -1;
|
||||
case 0x02:
|
||||
len += 4;
|
||||
break;
|
||||
case 0x03:
|
||||
len += 10;
|
||||
break;
|
||||
}
|
||||
|
||||
if (fc & (1 << 6)) {
|
||||
if (len < 2)
|
||||
return -1;
|
||||
len -= 2;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
u_int
|
||||
ieee802_15_4_if_print(netdissect_options *ndo,
|
||||
const struct pcap_pkthdr *h, const u_char *p)
|
||||
{
|
||||
u_int caplen = h->caplen;
|
||||
int hdrlen;
|
||||
uint16_t fc;
|
||||
uint8_t seq;
|
||||
|
||||
if (caplen < 3) {
|
||||
ND_PRINT((ndo, "[|802.15.4] %x", caplen));
|
||||
return caplen;
|
||||
}
|
||||
|
||||
fc = EXTRACT_LE_16BITS(p);
|
||||
hdrlen = extract_header_length(fc);
|
||||
|
||||
seq = EXTRACT_LE_8BITS(p + 2);
|
||||
|
||||
p += 3;
|
||||
caplen -= 3;
|
||||
|
||||
ND_PRINT((ndo,"IEEE 802.15.4 %s packet ", ftypes[fc & 0x7]));
|
||||
if (ndo->ndo_vflag)
|
||||
ND_PRINT((ndo,"seq %02x ", seq));
|
||||
if (hdrlen == -1) {
|
||||
ND_PRINT((ndo,"invalid! "));
|
||||
return caplen;
|
||||
}
|
||||
|
||||
|
||||
if (!ndo->ndo_vflag) {
|
||||
p+= hdrlen;
|
||||
caplen -= hdrlen;
|
||||
} else {
|
||||
uint16_t panid = 0;
|
||||
|
||||
switch ((fc >> 10) & 0x3) {
|
||||
case 0x00:
|
||||
ND_PRINT((ndo,"none "));
|
||||
break;
|
||||
case 0x01:
|
||||
ND_PRINT((ndo,"reserved destination addressing mode"));
|
||||
return 0;
|
||||
case 0x02:
|
||||
panid = EXTRACT_LE_16BITS(p);
|
||||
p += 2;
|
||||
ND_PRINT((ndo,"%04x:%04x ", panid, EXTRACT_LE_16BITS(p)));
|
||||
p += 2;
|
||||
break;
|
||||
case 0x03:
|
||||
panid = EXTRACT_LE_16BITS(p);
|
||||
p += 2;
|
||||
ND_PRINT((ndo,"%04x:%s ", panid, le64addr_string(ndo, p)));
|
||||
p += 8;
|
||||
break;
|
||||
}
|
||||
ND_PRINT((ndo,"< "));
|
||||
|
||||
switch ((fc >> 14) & 0x3) {
|
||||
case 0x00:
|
||||
ND_PRINT((ndo,"none "));
|
||||
break;
|
||||
case 0x01:
|
||||
ND_PRINT((ndo,"reserved source addressing mode"));
|
||||
return 0;
|
||||
case 0x02:
|
||||
if (!(fc & (1 << 6))) {
|
||||
panid = EXTRACT_LE_16BITS(p);
|
||||
p += 2;
|
||||
}
|
||||
ND_PRINT((ndo,"%04x:%04x ", panid, EXTRACT_LE_16BITS(p)));
|
||||
p += 2;
|
||||
break;
|
||||
case 0x03:
|
||||
if (!(fc & (1 << 6))) {
|
||||
panid = EXTRACT_LE_16BITS(p);
|
||||
p += 2;
|
||||
}
|
||||
ND_PRINT((ndo,"%04x:%s ", panid, le64addr_string(ndo, p)));
|
||||
p += 8;
|
||||
break;
|
||||
}
|
||||
|
||||
caplen -= hdrlen;
|
||||
}
|
||||
|
||||
if (!ndo->ndo_suppress_default_print)
|
||||
ND_DEFAULTPRINT(p, caplen);
|
||||
|
||||
return 0;
|
||||
}
|
||||
63
print-ah.c
Normal file
63
print-ah.c
Normal file
@@ -0,0 +1,63 @@
|
||||
/* $NetBSD: print-ah.c,v 1.4 1996/05/20 00:41:16 fvdl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 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: (1) source code distributions
|
||||
* retain the above copyright notice and this paragraph in its entirety, (2)
|
||||
* distributions including binary code include the above copyright notice and
|
||||
* this paragraph in its entirety in the documentation or other materials
|
||||
* provided with the distribution, and (3) all advertising materials mentioning
|
||||
* features or use of this software display the following acknowledgement:
|
||||
* ``This product includes software developed by the University of California,
|
||||
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
|
||||
* the University nor the names of its contributors may be used to endorse
|
||||
* or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <netdissect-stdinc.h>
|
||||
|
||||
#include "ah.h"
|
||||
|
||||
#include "netdissect.h"
|
||||
#include "extract.h"
|
||||
|
||||
int
|
||||
ah_print(netdissect_options *ndo, register const u_char *bp)
|
||||
{
|
||||
register const struct ah *ah;
|
||||
register const u_char *ep;
|
||||
int sumlen;
|
||||
uint32_t spi;
|
||||
|
||||
ah = (const struct ah *)bp;
|
||||
ep = ndo->ndo_snapend; /* 'ep' points to the end of available data. */
|
||||
|
||||
ND_TCHECK(*ah);
|
||||
|
||||
sumlen = ah->ah_len << 2;
|
||||
spi = EXTRACT_32BITS(&ah->ah_spi);
|
||||
|
||||
ND_PRINT((ndo, "AH(spi=0x%08x", spi));
|
||||
if (ndo->ndo_vflag)
|
||||
ND_PRINT((ndo, ",sumlen=%d", sumlen));
|
||||
ND_PRINT((ndo, ",seq=0x%x", EXTRACT_32BITS(ah + 1)));
|
||||
if (bp + sizeof(struct ah) + sumlen > ep)
|
||||
ND_PRINT((ndo, "[truncated]"));
|
||||
ND_PRINT((ndo, "): "));
|
||||
|
||||
return sizeof(struct ah) + sumlen;
|
||||
trunc:
|
||||
ND_PRINT((ndo, "[|AH]"));
|
||||
return -1;
|
||||
}
|
||||
411
print-ahcp.c
Normal file
411
print-ahcp.c
Normal file
@@ -0,0 +1,411 @@
|
||||
/*
|
||||
* This module implements decoding of AHCP (Ad Hoc Configuration Protocol) based
|
||||
* on draft-chroboczek-ahcp-00 and source code of ahcpd-0.53.
|
||||
*
|
||||
*
|
||||
* Copyright (c) 2013 The TCPDUMP 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.
|
||||
*
|
||||
* 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 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <netdissect-stdinc.h>
|
||||
|
||||
#include "netdissect.h"
|
||||
#include "extract.h"
|
||||
#include "addrtoname.h"
|
||||
|
||||
static const char tstr[] = " [|ahcp]";
|
||||
|
||||
#define AHCP_MAGIC_NUMBER 43
|
||||
#define AHCP_VERSION_1 1
|
||||
#define AHCP1_HEADER_FIX_LEN 24
|
||||
#define AHCP1_BODY_MIN_LEN 4
|
||||
|
||||
#define AHCP1_MSG_DISCOVER 0
|
||||
#define AHCP1_MSG_OFFER 1
|
||||
#define AHCP1_MSG_REQUEST 2
|
||||
#define AHCP1_MSG_ACK 3
|
||||
#define AHCP1_MSG_NACK 4
|
||||
#define AHCP1_MSG_RELEASE 5
|
||||
|
||||
static const struct tok ahcp1_msg_str[] = {
|
||||
{ AHCP1_MSG_DISCOVER, "Discover" },
|
||||
{ AHCP1_MSG_OFFER, "Offer" },
|
||||
{ AHCP1_MSG_REQUEST, "Request" },
|
||||
{ AHCP1_MSG_ACK, "Ack" },
|
||||
{ AHCP1_MSG_NACK, "Nack" },
|
||||
{ AHCP1_MSG_RELEASE, "Release" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
#define AHCP1_OPT_PAD 0
|
||||
#define AHCP1_OPT_MANDATORY 1
|
||||
#define AHCP1_OPT_ORIGIN_TIME 2
|
||||
#define AHCP1_OPT_EXPIRES 3
|
||||
#define AHCP1_OPT_MY_IPV6_ADDRESS 4
|
||||
#define AHCP1_OPT_MY_IPV4_ADDRESS 5
|
||||
#define AHCP1_OPT_IPV6_PREFIX 6
|
||||
#define AHCP1_OPT_IPV4_PREFIX 7
|
||||
#define AHCP1_OPT_IPV6_ADDRESS 8
|
||||
#define AHCP1_OPT_IPV4_ADDRESS 9
|
||||
#define AHCP1_OPT_IPV6_PREFIX_DELEGATION 10
|
||||
#define AHCP1_OPT_IPV4_PREFIX_DELEGATION 11
|
||||
#define AHCP1_OPT_NAME_SERVER 12
|
||||
#define AHCP1_OPT_NTP_SERVER 13
|
||||
#define AHCP1_OPT_MAX 13
|
||||
|
||||
static const struct tok ahcp1_opt_str[] = {
|
||||
{ AHCP1_OPT_PAD, "Pad" },
|
||||
{ AHCP1_OPT_MANDATORY, "Mandatory" },
|
||||
{ AHCP1_OPT_ORIGIN_TIME, "Origin Time" },
|
||||
{ AHCP1_OPT_EXPIRES, "Expires" },
|
||||
{ AHCP1_OPT_MY_IPV6_ADDRESS, "My-IPv6-Address" },
|
||||
{ AHCP1_OPT_MY_IPV4_ADDRESS, "My-IPv4-Address" },
|
||||
{ AHCP1_OPT_IPV6_PREFIX, "IPv6 Prefix" },
|
||||
{ AHCP1_OPT_IPV4_PREFIX, "IPv4 Prefix" },
|
||||
{ AHCP1_OPT_IPV6_ADDRESS, "IPv6 Address" },
|
||||
{ AHCP1_OPT_IPV4_ADDRESS, "IPv4 Address" },
|
||||
{ AHCP1_OPT_IPV6_PREFIX_DELEGATION, "IPv6 Prefix Delegation" },
|
||||
{ AHCP1_OPT_IPV4_PREFIX_DELEGATION, "IPv4 Prefix Delegation" },
|
||||
{ AHCP1_OPT_NAME_SERVER, "Name Server" },
|
||||
{ AHCP1_OPT_NTP_SERVER, "NTP Server" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static int
|
||||
ahcp_time_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
|
||||
{
|
||||
time_t t;
|
||||
struct tm *tm;
|
||||
char buf[BUFSIZE];
|
||||
|
||||
if (cp + 4 != ep)
|
||||
goto invalid;
|
||||
ND_TCHECK2(*cp, 4);
|
||||
t = EXTRACT_32BITS(cp);
|
||||
if (NULL == (tm = gmtime(&t)))
|
||||
ND_PRINT((ndo, ": gmtime() error"));
|
||||
else if (0 == strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", tm))
|
||||
ND_PRINT((ndo, ": strftime() error"));
|
||||
else
|
||||
ND_PRINT((ndo, ": %s UTC", buf));
|
||||
return 0;
|
||||
|
||||
invalid:
|
||||
ND_PRINT((ndo, "%s", istr));
|
||||
ND_TCHECK2(*cp, ep - cp);
|
||||
return 0;
|
||||
trunc:
|
||||
ND_PRINT((ndo, "%s", tstr));
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
ahcp_seconds_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
|
||||
{
|
||||
if (cp + 4 != ep)
|
||||
goto invalid;
|
||||
ND_TCHECK2(*cp, 4);
|
||||
ND_PRINT((ndo, ": %us", EXTRACT_32BITS(cp)));
|
||||
return 0;
|
||||
|
||||
invalid:
|
||||
ND_PRINT((ndo, "%s", istr));
|
||||
ND_TCHECK2(*cp, ep - cp);
|
||||
return 0;
|
||||
trunc:
|
||||
ND_PRINT((ndo, "%s", tstr));
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
ahcp_ipv6_addresses_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
|
||||
{
|
||||
const char *sep = ": ";
|
||||
|
||||
while (cp < ep) {
|
||||
if (cp + 16 > ep)
|
||||
goto invalid;
|
||||
ND_TCHECK2(*cp, 16);
|
||||
ND_PRINT((ndo, "%s%s", sep, ip6addr_string(ndo, cp)));
|
||||
cp += 16;
|
||||
sep = ", ";
|
||||
}
|
||||
return 0;
|
||||
|
||||
invalid:
|
||||
ND_PRINT((ndo, "%s", istr));
|
||||
ND_TCHECK2(*cp, ep - cp);
|
||||
return 0;
|
||||
trunc:
|
||||
ND_PRINT((ndo, "%s", tstr));
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
ahcp_ipv4_addresses_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
|
||||
{
|
||||
const char *sep = ": ";
|
||||
|
||||
while (cp < ep) {
|
||||
if (cp + 4 > ep)
|
||||
goto invalid;
|
||||
ND_TCHECK2(*cp, 4);
|
||||
ND_PRINT((ndo, "%s%s", sep, ipaddr_string(ndo, cp)));
|
||||
cp += 4;
|
||||
sep = ", ";
|
||||
}
|
||||
return 0;
|
||||
|
||||
invalid:
|
||||
ND_PRINT((ndo, "%s", istr));
|
||||
ND_TCHECK2(*cp, ep - cp);
|
||||
return 0;
|
||||
trunc:
|
||||
ND_PRINT((ndo, "%s", tstr));
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
ahcp_ipv6_prefixes_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
|
||||
{
|
||||
const char *sep = ": ";
|
||||
|
||||
while (cp < ep) {
|
||||
if (cp + 17 > ep)
|
||||
goto invalid;
|
||||
ND_TCHECK2(*cp, 17);
|
||||
ND_PRINT((ndo, "%s%s/%u", sep, ip6addr_string(ndo, cp), *(cp + 16)));
|
||||
cp += 17;
|
||||
sep = ", ";
|
||||
}
|
||||
return 0;
|
||||
|
||||
invalid:
|
||||
ND_PRINT((ndo, "%s", istr));
|
||||
ND_TCHECK2(*cp, ep - cp);
|
||||
return 0;
|
||||
trunc:
|
||||
ND_PRINT((ndo, "%s", tstr));
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
ahcp_ipv4_prefixes_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
|
||||
{
|
||||
const char *sep = ": ";
|
||||
|
||||
while (cp < ep) {
|
||||
if (cp + 5 > ep)
|
||||
goto invalid;
|
||||
ND_TCHECK2(*cp, 5);
|
||||
ND_PRINT((ndo, "%s%s/%u", sep, ipaddr_string(ndo, cp), *(cp + 4)));
|
||||
cp += 5;
|
||||
sep = ", ";
|
||||
}
|
||||
return 0;
|
||||
|
||||
invalid:
|
||||
ND_PRINT((ndo, "%s", istr));
|
||||
ND_TCHECK2(*cp, ep - cp);
|
||||
return 0;
|
||||
trunc:
|
||||
ND_PRINT((ndo, "%s", tstr));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Data decoders signal truncated data with -1. */
|
||||
static int
|
||||
(* const data_decoders[AHCP1_OPT_MAX + 1])(netdissect_options *, const u_char *, const u_char *) = {
|
||||
/* [AHCP1_OPT_PAD] = */ NULL,
|
||||
/* [AHCP1_OPT_MANDATORY] = */ NULL,
|
||||
/* [AHCP1_OPT_ORIGIN_TIME] = */ ahcp_time_print,
|
||||
/* [AHCP1_OPT_EXPIRES] = */ ahcp_seconds_print,
|
||||
/* [AHCP1_OPT_MY_IPV6_ADDRESS] = */ ahcp_ipv6_addresses_print,
|
||||
/* [AHCP1_OPT_MY_IPV4_ADDRESS] = */ ahcp_ipv4_addresses_print,
|
||||
/* [AHCP1_OPT_IPV6_PREFIX] = */ ahcp_ipv6_prefixes_print,
|
||||
/* [AHCP1_OPT_IPV4_PREFIX] = */ NULL,
|
||||
/* [AHCP1_OPT_IPV6_ADDRESS] = */ ahcp_ipv6_addresses_print,
|
||||
/* [AHCP1_OPT_IPV4_ADDRESS] = */ ahcp_ipv4_addresses_print,
|
||||
/* [AHCP1_OPT_IPV6_PREFIX_DELEGATION] = */ ahcp_ipv6_prefixes_print,
|
||||
/* [AHCP1_OPT_IPV4_PREFIX_DELEGATION] = */ ahcp_ipv4_prefixes_print,
|
||||
/* [AHCP1_OPT_NAME_SERVER] = */ ahcp_ipv6_addresses_print,
|
||||
/* [AHCP1_OPT_NTP_SERVER] = */ ahcp_ipv6_addresses_print,
|
||||
};
|
||||
|
||||
static void
|
||||
ahcp1_options_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
|
||||
{
|
||||
uint8_t option_no, option_len;
|
||||
|
||||
while (cp < ep) {
|
||||
/* Option no */
|
||||
ND_TCHECK2(*cp, 1);
|
||||
option_no = *cp;
|
||||
cp += 1;
|
||||
ND_PRINT((ndo, "\n\t %s", tok2str(ahcp1_opt_str, "Unknown-%u", option_no)));
|
||||
if (option_no == AHCP1_OPT_PAD || option_no == AHCP1_OPT_MANDATORY)
|
||||
continue;
|
||||
/* Length */
|
||||
if (cp + 1 > ep)
|
||||
goto invalid;
|
||||
ND_TCHECK2(*cp, 1);
|
||||
option_len = *cp;
|
||||
cp += 1;
|
||||
if (cp + option_len > ep)
|
||||
goto invalid;
|
||||
/* Value */
|
||||
if (option_no <= AHCP1_OPT_MAX && data_decoders[option_no] != NULL) {
|
||||
if (data_decoders[option_no](ndo, cp, cp + option_len) < 0)
|
||||
break; /* truncated and already marked up */
|
||||
} else {
|
||||
ND_PRINT((ndo, " (Length %u)", option_len));
|
||||
ND_TCHECK2(*cp, option_len);
|
||||
}
|
||||
cp += option_len;
|
||||
}
|
||||
return;
|
||||
|
||||
invalid:
|
||||
ND_PRINT((ndo, "%s", istr));
|
||||
ND_TCHECK2(*cp, ep - cp);
|
||||
return;
|
||||
trunc:
|
||||
ND_PRINT((ndo, "%s", tstr));
|
||||
}
|
||||
|
||||
static void
|
||||
ahcp1_body_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
|
||||
{
|
||||
uint8_t type, mbz;
|
||||
uint16_t body_len;
|
||||
|
||||
if (cp + AHCP1_BODY_MIN_LEN > ep)
|
||||
goto invalid;
|
||||
/* Type */
|
||||
ND_TCHECK2(*cp, 1);
|
||||
type = *cp;
|
||||
cp += 1;
|
||||
/* MBZ */
|
||||
ND_TCHECK2(*cp, 1);
|
||||
mbz = *cp;
|
||||
cp += 1;
|
||||
/* Length */
|
||||
ND_TCHECK2(*cp, 2);
|
||||
body_len = EXTRACT_16BITS(cp);
|
||||
cp += 2;
|
||||
|
||||
if (ndo->ndo_vflag) {
|
||||
ND_PRINT((ndo, "\n\t%s", tok2str(ahcp1_msg_str, "Unknown-%u", type)));
|
||||
if (mbz != 0)
|
||||
ND_PRINT((ndo, ", MBZ %u", mbz));
|
||||
ND_PRINT((ndo, ", Length %u", body_len));
|
||||
}
|
||||
if (cp + body_len > ep)
|
||||
goto invalid;
|
||||
|
||||
/* Options */
|
||||
if (ndo->ndo_vflag >= 2)
|
||||
ahcp1_options_print(ndo, cp, cp + body_len); /* not ep (ignore extra data) */
|
||||
else
|
||||
ND_TCHECK2(*cp, body_len);
|
||||
return;
|
||||
|
||||
invalid:
|
||||
ND_PRINT((ndo, "%s", istr));
|
||||
ND_TCHECK2(*cp, ep - cp);
|
||||
return;
|
||||
trunc:
|
||||
ND_PRINT((ndo, "%s", tstr));
|
||||
}
|
||||
|
||||
void
|
||||
ahcp_print(netdissect_options *ndo, const u_char *cp, const u_int len)
|
||||
{
|
||||
const u_char *ep = cp + len;
|
||||
uint8_t version;
|
||||
|
||||
ND_PRINT((ndo, "AHCP"));
|
||||
if (len < 2)
|
||||
goto invalid;
|
||||
/* Magic */
|
||||
ND_TCHECK2(*cp, 1);
|
||||
if (*cp != AHCP_MAGIC_NUMBER)
|
||||
goto invalid;
|
||||
cp += 1;
|
||||
/* Version */
|
||||
ND_TCHECK2(*cp, 1);
|
||||
version = *cp;
|
||||
cp += 1;
|
||||
switch (version) {
|
||||
case AHCP_VERSION_1: {
|
||||
ND_PRINT((ndo, " Version 1"));
|
||||
if (len < AHCP1_HEADER_FIX_LEN)
|
||||
goto invalid;
|
||||
if (!ndo->ndo_vflag) {
|
||||
ND_TCHECK2(*cp, AHCP1_HEADER_FIX_LEN - 2);
|
||||
cp += AHCP1_HEADER_FIX_LEN - 2;
|
||||
} else {
|
||||
/* Hopcount */
|
||||
ND_TCHECK2(*cp, 1);
|
||||
ND_PRINT((ndo, "\n\tHopcount %u", *cp));
|
||||
cp += 1;
|
||||
/* Original Hopcount */
|
||||
ND_TCHECK2(*cp, 1);
|
||||
ND_PRINT((ndo, ", Original Hopcount %u", *cp));
|
||||
cp += 1;
|
||||
/* Nonce */
|
||||
ND_TCHECK2(*cp, 4);
|
||||
ND_PRINT((ndo, ", Nonce 0x%08x", EXTRACT_32BITS(cp)));
|
||||
cp += 4;
|
||||
/* Source Id */
|
||||
ND_TCHECK2(*cp, 8);
|
||||
ND_PRINT((ndo, ", Source Id %s", linkaddr_string(ndo, cp, 0, 8)));
|
||||
cp += 8;
|
||||
/* Destination Id */
|
||||
ND_TCHECK2(*cp, 8);
|
||||
ND_PRINT((ndo, ", Destination Id %s", linkaddr_string(ndo, cp, 0, 8)));
|
||||
cp += 8;
|
||||
}
|
||||
/* Body */
|
||||
ahcp1_body_print(ndo, cp, ep);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ND_PRINT((ndo, " Version %u (unknown)", version));
|
||||
break;
|
||||
}
|
||||
return;
|
||||
|
||||
invalid:
|
||||
ND_PRINT((ndo, "%s", istr));
|
||||
ND_TCHECK2(*cp, ep - cp);
|
||||
return;
|
||||
trunc:
|
||||
ND_PRINT((ndo, "%s", tstr));
|
||||
}
|
||||
530
print-aodv.c
Normal file
530
print-aodv.c
Normal file
@@ -0,0 +1,530 @@
|
||||
/*
|
||||
* Copyright (c) 2003 Bruce M. Simpson <bms@spc.org>
|
||||
* 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 Bruce M. Simpson.
|
||||
* 4. Neither the name of Bruce M. Simpson nor the names of co-
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Bruce M. Simpson 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 Bruce M. Simpson OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <netdissect-stdinc.h>
|
||||
|
||||
#include "netdissect.h"
|
||||
#include "addrtoname.h"
|
||||
#include "extract.h"
|
||||
|
||||
|
||||
struct aodv_rreq {
|
||||
uint8_t rreq_type; /* AODV message type (1) */
|
||||
uint8_t rreq_flags; /* various flags */
|
||||
uint8_t rreq_zero0; /* reserved, set to zero */
|
||||
uint8_t rreq_hops; /* number of hops from originator */
|
||||
uint32_t rreq_id; /* request ID */
|
||||
uint32_t rreq_da; /* destination IPv4 address */
|
||||
uint32_t rreq_ds; /* destination sequence number */
|
||||
uint32_t rreq_oa; /* originator IPv4 address */
|
||||
uint32_t rreq_os; /* originator sequence number */
|
||||
};
|
||||
struct aodv_rreq6 {
|
||||
uint8_t rreq_type; /* AODV message type (1) */
|
||||
uint8_t rreq_flags; /* various flags */
|
||||
uint8_t rreq_zero0; /* reserved, set to zero */
|
||||
uint8_t rreq_hops; /* number of hops from originator */
|
||||
uint32_t rreq_id; /* request ID */
|
||||
struct in6_addr rreq_da; /* destination IPv6 address */
|
||||
uint32_t rreq_ds; /* destination sequence number */
|
||||
struct in6_addr rreq_oa; /* originator IPv6 address */
|
||||
uint32_t rreq_os; /* originator sequence number */
|
||||
};
|
||||
struct aodv_rreq6_draft_01 {
|
||||
uint8_t rreq_type; /* AODV message type (16) */
|
||||
uint8_t rreq_flags; /* various flags */
|
||||
uint8_t rreq_zero0; /* reserved, set to zero */
|
||||
uint8_t rreq_hops; /* number of hops from originator */
|
||||
uint32_t rreq_id; /* request ID */
|
||||
uint32_t rreq_ds; /* destination sequence number */
|
||||
uint32_t rreq_os; /* originator sequence number */
|
||||
struct in6_addr rreq_da; /* destination IPv6 address */
|
||||
struct in6_addr rreq_oa; /* originator IPv6 address */
|
||||
};
|
||||
|
||||
#define RREQ_JOIN 0x80 /* join (reserved for multicast */
|
||||
#define RREQ_REPAIR 0x40 /* repair (reserved for multicast */
|
||||
#define RREQ_GRAT 0x20 /* gratuitous RREP */
|
||||
#define RREQ_DEST 0x10 /* destination only */
|
||||
#define RREQ_UNKNOWN 0x08 /* unknown destination sequence num */
|
||||
#define RREQ_FLAGS_MASK 0xF8 /* mask for rreq_flags */
|
||||
|
||||
struct aodv_rrep {
|
||||
uint8_t rrep_type; /* AODV message type (2) */
|
||||
uint8_t rrep_flags; /* various flags */
|
||||
uint8_t rrep_ps; /* prefix size */
|
||||
uint8_t rrep_hops; /* number of hops from o to d */
|
||||
uint32_t rrep_da; /* destination IPv4 address */
|
||||
uint32_t rrep_ds; /* destination sequence number */
|
||||
uint32_t rrep_oa; /* originator IPv4 address */
|
||||
uint32_t rrep_life; /* lifetime of this route */
|
||||
};
|
||||
struct aodv_rrep6 {
|
||||
uint8_t rrep_type; /* AODV message type (2) */
|
||||
uint8_t rrep_flags; /* various flags */
|
||||
uint8_t rrep_ps; /* prefix size */
|
||||
uint8_t rrep_hops; /* number of hops from o to d */
|
||||
struct in6_addr rrep_da; /* destination IPv6 address */
|
||||
uint32_t rrep_ds; /* destination sequence number */
|
||||
struct in6_addr rrep_oa; /* originator IPv6 address */
|
||||
uint32_t rrep_life; /* lifetime of this route */
|
||||
};
|
||||
struct aodv_rrep6_draft_01 {
|
||||
uint8_t rrep_type; /* AODV message type (17) */
|
||||
uint8_t rrep_flags; /* various flags */
|
||||
uint8_t rrep_ps; /* prefix size */
|
||||
uint8_t rrep_hops; /* number of hops from o to d */
|
||||
uint32_t rrep_ds; /* destination sequence number */
|
||||
struct in6_addr rrep_da; /* destination IPv6 address */
|
||||
struct in6_addr rrep_oa; /* originator IPv6 address */
|
||||
uint32_t rrep_life; /* lifetime of this route */
|
||||
};
|
||||
|
||||
#define RREP_REPAIR 0x80 /* repair (reserved for multicast */
|
||||
#define RREP_ACK 0x40 /* acknowledgement required */
|
||||
#define RREP_FLAGS_MASK 0xC0 /* mask for rrep_flags */
|
||||
#define RREP_PREFIX_MASK 0x1F /* mask for prefix size */
|
||||
|
||||
struct rerr_unreach {
|
||||
uint32_t u_da; /* IPv4 address */
|
||||
uint32_t u_ds; /* sequence number */
|
||||
};
|
||||
struct rerr_unreach6 {
|
||||
struct in6_addr u_da; /* IPv6 address */
|
||||
uint32_t u_ds; /* sequence number */
|
||||
};
|
||||
struct rerr_unreach6_draft_01 {
|
||||
struct in6_addr u_da; /* IPv6 address */
|
||||
uint32_t u_ds; /* sequence number */
|
||||
};
|
||||
|
||||
struct aodv_rerr {
|
||||
uint8_t rerr_type; /* AODV message type (3 or 18) */
|
||||
uint8_t rerr_flags; /* various flags */
|
||||
uint8_t rerr_zero0; /* reserved, set to zero */
|
||||
uint8_t rerr_dc; /* destination count */
|
||||
};
|
||||
|
||||
#define RERR_NODELETE 0x80 /* don't delete the link */
|
||||
#define RERR_FLAGS_MASK 0x80 /* mask for rerr_flags */
|
||||
|
||||
struct aodv_rrep_ack {
|
||||
uint8_t ra_type;
|
||||
uint8_t ra_zero0;
|
||||
};
|
||||
|
||||
#define AODV_RREQ 1 /* route request */
|
||||
#define AODV_RREP 2 /* route response */
|
||||
#define AODV_RERR 3 /* error report */
|
||||
#define AODV_RREP_ACK 4 /* route response acknowledgement */
|
||||
|
||||
#define AODV_V6_DRAFT_01_RREQ 16 /* IPv6 route request */
|
||||
#define AODV_V6_DRAFT_01_RREP 17 /* IPv6 route response */
|
||||
#define AODV_V6_DRAFT_01_RERR 18 /* IPv6 error report */
|
||||
#define AODV_V6_DRAFT_01_RREP_ACK 19 /* IPV6 route response acknowledgment */
|
||||
|
||||
struct aodv_ext {
|
||||
uint8_t type; /* extension type */
|
||||
uint8_t length; /* extension length */
|
||||
};
|
||||
|
||||
struct aodv_hello {
|
||||
struct aodv_ext eh; /* extension header */
|
||||
uint8_t interval[4]; /* expect my next hello in
|
||||
* (n) ms
|
||||
* NOTE: this is not aligned */
|
||||
};
|
||||
|
||||
#define AODV_EXT_HELLO 1
|
||||
|
||||
static void
|
||||
aodv_extension(netdissect_options *ndo,
|
||||
const struct aodv_ext *ep, u_int length)
|
||||
{
|
||||
const struct aodv_hello *ah;
|
||||
|
||||
switch (ep->type) {
|
||||
case AODV_EXT_HELLO:
|
||||
ah = (const struct aodv_hello *)(const void *)ep;
|
||||
ND_TCHECK(*ah);
|
||||
if (length < sizeof(struct aodv_hello))
|
||||
goto trunc;
|
||||
ND_PRINT((ndo, "\n\text HELLO %ld ms",
|
||||
(unsigned long)EXTRACT_32BITS(&ah->interval)));
|
||||
break;
|
||||
|
||||
default:
|
||||
ND_PRINT((ndo, "\n\text %u %u", ep->type, ep->length));
|
||||
break;
|
||||
}
|
||||
return;
|
||||
|
||||
trunc:
|
||||
ND_PRINT((ndo, " [|hello]"));
|
||||
}
|
||||
|
||||
static void
|
||||
aodv_rreq(netdissect_options *ndo, const u_char *dat, u_int length)
|
||||
{
|
||||
u_int i;
|
||||
const struct aodv_rreq *ap = (const struct aodv_rreq *)dat;
|
||||
|
||||
ND_TCHECK(*ap);
|
||||
if (length < sizeof(*ap))
|
||||
goto trunc;
|
||||
ND_PRINT((ndo, " rreq %u %s%s%s%s%shops %u id 0x%08lx\n"
|
||||
"\tdst %s seq %lu src %s seq %lu", length,
|
||||
ap->rreq_type & RREQ_JOIN ? "[J]" : "",
|
||||
ap->rreq_type & RREQ_REPAIR ? "[R]" : "",
|
||||
ap->rreq_type & RREQ_GRAT ? "[G]" : "",
|
||||
ap->rreq_type & RREQ_DEST ? "[D]" : "",
|
||||
ap->rreq_type & RREQ_UNKNOWN ? "[U] " : " ",
|
||||
ap->rreq_hops,
|
||||
(unsigned long)EXTRACT_32BITS(&ap->rreq_id),
|
||||
ipaddr_string(ndo, &ap->rreq_da),
|
||||
(unsigned long)EXTRACT_32BITS(&ap->rreq_ds),
|
||||
ipaddr_string(ndo, &ap->rreq_oa),
|
||||
(unsigned long)EXTRACT_32BITS(&ap->rreq_os)));
|
||||
i = length - sizeof(*ap);
|
||||
if (i >= sizeof(struct aodv_ext))
|
||||
aodv_extension(ndo, (const struct aodv_ext *)(dat + sizeof(*ap)), i);
|
||||
return;
|
||||
|
||||
trunc:
|
||||
ND_PRINT((ndo, " [|rreq"));
|
||||
}
|
||||
|
||||
static void
|
||||
aodv_rrep(netdissect_options *ndo, const u_char *dat, u_int length)
|
||||
{
|
||||
u_int i;
|
||||
const struct aodv_rrep *ap = (const struct aodv_rrep *)dat;
|
||||
|
||||
ND_TCHECK(*ap);
|
||||
if (length < sizeof(*ap))
|
||||
goto trunc;
|
||||
ND_PRINT((ndo, " rrep %u %s%sprefix %u hops %u\n"
|
||||
"\tdst %s dseq %lu src %s %lu ms", length,
|
||||
ap->rrep_type & RREP_REPAIR ? "[R]" : "",
|
||||
ap->rrep_type & RREP_ACK ? "[A] " : " ",
|
||||
ap->rrep_ps & RREP_PREFIX_MASK,
|
||||
ap->rrep_hops,
|
||||
ipaddr_string(ndo, &ap->rrep_da),
|
||||
(unsigned long)EXTRACT_32BITS(&ap->rrep_ds),
|
||||
ipaddr_string(ndo, &ap->rrep_oa),
|
||||
(unsigned long)EXTRACT_32BITS(&ap->rrep_life)));
|
||||
i = length - sizeof(*ap);
|
||||
if (i >= sizeof(struct aodv_ext))
|
||||
aodv_extension(ndo, (const struct aodv_ext *)(dat + sizeof(*ap)), i);
|
||||
return;
|
||||
|
||||
trunc:
|
||||
ND_PRINT((ndo, " [|rreq"));
|
||||
}
|
||||
|
||||
static void
|
||||
aodv_rerr(netdissect_options *ndo, const u_char *dat, u_int length)
|
||||
{
|
||||
u_int i, dc;
|
||||
const struct aodv_rerr *ap = (const struct aodv_rerr *)dat;
|
||||
const struct rerr_unreach *dp;
|
||||
|
||||
ND_TCHECK(*ap);
|
||||
if (length < sizeof(*ap))
|
||||
goto trunc;
|
||||
ND_PRINT((ndo, " rerr %s [items %u] [%u]:",
|
||||
ap->rerr_flags & RERR_NODELETE ? "[D]" : "",
|
||||
ap->rerr_dc, length));
|
||||
dp = (const struct rerr_unreach *)(dat + sizeof(*ap));
|
||||
i = length - sizeof(*ap);
|
||||
for (dc = ap->rerr_dc; dc != 0; dc--) {
|
||||
ND_TCHECK(*dp);
|
||||
if (i < sizeof(*dp))
|
||||
goto trunc;
|
||||
ND_PRINT((ndo, " {%s}(%ld)", ipaddr_string(ndo, &dp->u_da),
|
||||
(unsigned long)EXTRACT_32BITS(&dp->u_ds)));
|
||||
dp++;
|
||||
i -= sizeof(*dp);
|
||||
}
|
||||
return;
|
||||
|
||||
trunc:
|
||||
ND_PRINT((ndo, "[|rerr]"));
|
||||
}
|
||||
|
||||
static void
|
||||
aodv_v6_rreq(netdissect_options *ndo, const u_char *dat, u_int length)
|
||||
{
|
||||
u_int i;
|
||||
const struct aodv_rreq6 *ap = (const struct aodv_rreq6 *)dat;
|
||||
|
||||
ND_TCHECK(*ap);
|
||||
if (length < sizeof(*ap))
|
||||
goto trunc;
|
||||
ND_PRINT((ndo, " v6 rreq %u %s%s%s%s%shops %u id 0x%08lx\n"
|
||||
"\tdst %s seq %lu src %s seq %lu", length,
|
||||
ap->rreq_type & RREQ_JOIN ? "[J]" : "",
|
||||
ap->rreq_type & RREQ_REPAIR ? "[R]" : "",
|
||||
ap->rreq_type & RREQ_GRAT ? "[G]" : "",
|
||||
ap->rreq_type & RREQ_DEST ? "[D]" : "",
|
||||
ap->rreq_type & RREQ_UNKNOWN ? "[U] " : " ",
|
||||
ap->rreq_hops,
|
||||
(unsigned long)EXTRACT_32BITS(&ap->rreq_id),
|
||||
ip6addr_string(ndo, &ap->rreq_da),
|
||||
(unsigned long)EXTRACT_32BITS(&ap->rreq_ds),
|
||||
ip6addr_string(ndo, &ap->rreq_oa),
|
||||
(unsigned long)EXTRACT_32BITS(&ap->rreq_os)));
|
||||
i = length - sizeof(*ap);
|
||||
if (i >= sizeof(struct aodv_ext))
|
||||
aodv_extension(ndo, (const struct aodv_ext *)(dat + sizeof(*ap)), i);
|
||||
return;
|
||||
|
||||
trunc:
|
||||
ND_PRINT((ndo, " [|rreq"));
|
||||
}
|
||||
|
||||
static void
|
||||
aodv_v6_rrep(netdissect_options *ndo, const u_char *dat, u_int length)
|
||||
{
|
||||
u_int i;
|
||||
const struct aodv_rrep6 *ap = (const struct aodv_rrep6 *)dat;
|
||||
|
||||
ND_TCHECK(*ap);
|
||||
if (length < sizeof(*ap))
|
||||
goto trunc;
|
||||
ND_PRINT((ndo, " rrep %u %s%sprefix %u hops %u\n"
|
||||
"\tdst %s dseq %lu src %s %lu ms", length,
|
||||
ap->rrep_type & RREP_REPAIR ? "[R]" : "",
|
||||
ap->rrep_type & RREP_ACK ? "[A] " : " ",
|
||||
ap->rrep_ps & RREP_PREFIX_MASK,
|
||||
ap->rrep_hops,
|
||||
ip6addr_string(ndo, &ap->rrep_da),
|
||||
(unsigned long)EXTRACT_32BITS(&ap->rrep_ds),
|
||||
ip6addr_string(ndo, &ap->rrep_oa),
|
||||
(unsigned long)EXTRACT_32BITS(&ap->rrep_life)));
|
||||
i = length - sizeof(*ap);
|
||||
if (i >= sizeof(struct aodv_ext))
|
||||
aodv_extension(ndo, (const struct aodv_ext *)(dat + sizeof(*ap)), i);
|
||||
return;
|
||||
|
||||
trunc:
|
||||
ND_PRINT((ndo, " [|rreq"));
|
||||
}
|
||||
|
||||
static void
|
||||
aodv_v6_rerr(netdissect_options *ndo, const u_char *dat, u_int length)
|
||||
{
|
||||
u_int i, dc;
|
||||
const struct aodv_rerr *ap = (const struct aodv_rerr *)dat;
|
||||
const struct rerr_unreach6 *dp6;
|
||||
|
||||
ND_TCHECK(*ap);
|
||||
if (length < sizeof(*ap))
|
||||
goto trunc;
|
||||
ND_PRINT((ndo, " rerr %s [items %u] [%u]:",
|
||||
ap->rerr_flags & RERR_NODELETE ? "[D]" : "",
|
||||
ap->rerr_dc, length));
|
||||
dp6 = (const struct rerr_unreach6 *)(const void *)(ap + 1);
|
||||
i = length - sizeof(*ap);
|
||||
for (dc = ap->rerr_dc; dc != 0; dc--) {
|
||||
ND_TCHECK(*dp6);
|
||||
if (i < sizeof(*dp6))
|
||||
goto trunc;
|
||||
ND_PRINT((ndo, " {%s}(%ld)", ip6addr_string(ndo, &dp6->u_da),
|
||||
(unsigned long)EXTRACT_32BITS(&dp6->u_ds)));
|
||||
dp6++;
|
||||
i -= sizeof(*dp6);
|
||||
}
|
||||
return;
|
||||
|
||||
trunc:
|
||||
ND_PRINT((ndo, "[|rerr]"));
|
||||
}
|
||||
|
||||
static void
|
||||
aodv_v6_draft_01_rreq(netdissect_options *ndo, const u_char *dat, u_int length)
|
||||
{
|
||||
u_int i;
|
||||
const struct aodv_rreq6_draft_01 *ap = (const struct aodv_rreq6_draft_01 *)dat;
|
||||
|
||||
ND_TCHECK(*ap);
|
||||
if (length < sizeof(*ap))
|
||||
goto trunc;
|
||||
ND_PRINT((ndo, " rreq %u %s%s%s%s%shops %u id 0x%08lx\n"
|
||||
"\tdst %s seq %lu src %s seq %lu", length,
|
||||
ap->rreq_type & RREQ_JOIN ? "[J]" : "",
|
||||
ap->rreq_type & RREQ_REPAIR ? "[R]" : "",
|
||||
ap->rreq_type & RREQ_GRAT ? "[G]" : "",
|
||||
ap->rreq_type & RREQ_DEST ? "[D]" : "",
|
||||
ap->rreq_type & RREQ_UNKNOWN ? "[U] " : " ",
|
||||
ap->rreq_hops,
|
||||
(unsigned long)EXTRACT_32BITS(&ap->rreq_id),
|
||||
ip6addr_string(ndo, &ap->rreq_da),
|
||||
(unsigned long)EXTRACT_32BITS(&ap->rreq_ds),
|
||||
ip6addr_string(ndo, &ap->rreq_oa),
|
||||
(unsigned long)EXTRACT_32BITS(&ap->rreq_os)));
|
||||
i = length - sizeof(*ap);
|
||||
if (i >= sizeof(struct aodv_ext))
|
||||
aodv_extension(ndo, (const struct aodv_ext *)(dat + sizeof(*ap)), i);
|
||||
return;
|
||||
|
||||
trunc:
|
||||
ND_PRINT((ndo, " [|rreq"));
|
||||
}
|
||||
|
||||
static void
|
||||
aodv_v6_draft_01_rrep(netdissect_options *ndo, const u_char *dat, u_int length)
|
||||
{
|
||||
u_int i;
|
||||
const struct aodv_rrep6_draft_01 *ap = (const struct aodv_rrep6_draft_01 *)dat;
|
||||
|
||||
ND_TCHECK(*ap);
|
||||
if (length < sizeof(*ap))
|
||||
goto trunc;
|
||||
ND_PRINT((ndo, " rrep %u %s%sprefix %u hops %u\n"
|
||||
"\tdst %s dseq %lu src %s %lu ms", length,
|
||||
ap->rrep_type & RREP_REPAIR ? "[R]" : "",
|
||||
ap->rrep_type & RREP_ACK ? "[A] " : " ",
|
||||
ap->rrep_ps & RREP_PREFIX_MASK,
|
||||
ap->rrep_hops,
|
||||
ip6addr_string(ndo, &ap->rrep_da),
|
||||
(unsigned long)EXTRACT_32BITS(&ap->rrep_ds),
|
||||
ip6addr_string(ndo, &ap->rrep_oa),
|
||||
(unsigned long)EXTRACT_32BITS(&ap->rrep_life)));
|
||||
i = length - sizeof(*ap);
|
||||
if (i >= sizeof(struct aodv_ext))
|
||||
aodv_extension(ndo, (const struct aodv_ext *)(dat + sizeof(*ap)), i);
|
||||
return;
|
||||
|
||||
trunc:
|
||||
ND_PRINT((ndo, " [|rreq"));
|
||||
}
|
||||
|
||||
static void
|
||||
aodv_v6_draft_01_rerr(netdissect_options *ndo, const u_char *dat, u_int length)
|
||||
{
|
||||
u_int i, dc;
|
||||
const struct aodv_rerr *ap = (const struct aodv_rerr *)dat;
|
||||
const struct rerr_unreach6_draft_01 *dp6;
|
||||
|
||||
ND_TCHECK(*ap);
|
||||
if (length < sizeof(*ap))
|
||||
goto trunc;
|
||||
ND_PRINT((ndo, " rerr %s [items %u] [%u]:",
|
||||
ap->rerr_flags & RERR_NODELETE ? "[D]" : "",
|
||||
ap->rerr_dc, length));
|
||||
dp6 = (const struct rerr_unreach6_draft_01 *)(const void *)(ap + 1);
|
||||
i = length - sizeof(*ap);
|
||||
for (dc = ap->rerr_dc; dc != 0; dc--) {
|
||||
ND_TCHECK(*dp6);
|
||||
if (i < sizeof(*dp6))
|
||||
goto trunc;
|
||||
ND_PRINT((ndo, " {%s}(%ld)", ip6addr_string(ndo, &dp6->u_da),
|
||||
(unsigned long)EXTRACT_32BITS(&dp6->u_ds)));
|
||||
dp6++;
|
||||
i -= sizeof(*dp6);
|
||||
}
|
||||
return;
|
||||
|
||||
trunc:
|
||||
ND_PRINT((ndo, "[|rerr]"));
|
||||
}
|
||||
|
||||
void
|
||||
aodv_print(netdissect_options *ndo,
|
||||
const u_char *dat, u_int length, int is_ip6)
|
||||
{
|
||||
uint8_t msg_type;
|
||||
|
||||
/*
|
||||
* The message type is the first byte; make sure we have it
|
||||
* and then fetch it.
|
||||
*/
|
||||
ND_TCHECK(*dat);
|
||||
msg_type = *dat;
|
||||
ND_PRINT((ndo, " aodv"));
|
||||
|
||||
switch (msg_type) {
|
||||
|
||||
case AODV_RREQ:
|
||||
if (is_ip6)
|
||||
aodv_v6_rreq(ndo, dat, length);
|
||||
else
|
||||
aodv_rreq(ndo, dat, length);
|
||||
break;
|
||||
|
||||
case AODV_RREP:
|
||||
if (is_ip6)
|
||||
aodv_v6_rrep(ndo, dat, length);
|
||||
else
|
||||
aodv_rrep(ndo, dat, length);
|
||||
break;
|
||||
|
||||
case AODV_RERR:
|
||||
if (is_ip6)
|
||||
aodv_v6_rerr(ndo, dat, length);
|
||||
else
|
||||
aodv_rerr(ndo, dat, length);
|
||||
break;
|
||||
|
||||
case AODV_RREP_ACK:
|
||||
ND_PRINT((ndo, " rrep-ack %u", length));
|
||||
break;
|
||||
|
||||
case AODV_V6_DRAFT_01_RREQ:
|
||||
aodv_v6_draft_01_rreq(ndo, dat, length);
|
||||
break;
|
||||
|
||||
case AODV_V6_DRAFT_01_RREP:
|
||||
aodv_v6_draft_01_rrep(ndo, dat, length);
|
||||
break;
|
||||
|
||||
case AODV_V6_DRAFT_01_RERR:
|
||||
aodv_v6_draft_01_rerr(ndo, dat, length);
|
||||
break;
|
||||
|
||||
case AODV_V6_DRAFT_01_RREP_ACK:
|
||||
ND_PRINT((ndo, " rrep-ack %u", length));
|
||||
break;
|
||||
|
||||
default:
|
||||
ND_PRINT((ndo, " type %u %u", msg_type, length));
|
||||
}
|
||||
return;
|
||||
|
||||
trunc:
|
||||
ND_PRINT((ndo, " [|aodv]"));
|
||||
}
|
||||
430
print-aoe.c
Normal file
430
print-aoe.c
Normal file
@@ -0,0 +1,430 @@
|
||||
/*
|
||||
* This module implements decoding of the ATA over Ethernet (AoE) protocol
|
||||
* according to the following specification:
|
||||
* http://support.coraid.com/documents/AoEr11.txt
|
||||
*
|
||||
* Copyright (c) 2014 The TCPDUMP 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.
|
||||
*
|
||||
* 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 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <netdissect-stdinc.h>
|
||||
|
||||
#include "netdissect.h"
|
||||
#include "extract.h"
|
||||
#include "addrtoname.h"
|
||||
#include "ether.h"
|
||||
|
||||
static const char tstr[] = " [|aoe]";
|
||||
|
||||
#define AOE_V1 1
|
||||
#define ATA_SECTOR_SIZE 512
|
||||
|
||||
#define AOEV1_CMD_ISSUE_ATA_COMMAND 0
|
||||
#define AOEV1_CMD_QUERY_CONFIG_INFORMATION 1
|
||||
#define AOEV1_CMD_MAC_MASK_LIST 2
|
||||
#define AOEV1_CMD_RESERVE_RELEASE 3
|
||||
|
||||
static const struct tok cmdcode_str[] = {
|
||||
{ AOEV1_CMD_ISSUE_ATA_COMMAND, "Issue ATA Command" },
|
||||
{ AOEV1_CMD_QUERY_CONFIG_INFORMATION, "Query Config Information" },
|
||||
{ AOEV1_CMD_MAC_MASK_LIST, "MAC Mask List" },
|
||||
{ AOEV1_CMD_RESERVE_RELEASE, "Reserve/Release" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
#define AOEV1_COMMON_HDR_LEN 10U /* up to but w/o Arg */
|
||||
#define AOEV1_ISSUE_ARG_LEN 12U /* up to but w/o Data */
|
||||
#define AOEV1_QUERY_ARG_LEN 8U /* up to but w/o Config String */
|
||||
#define AOEV1_MAC_ARG_LEN 4U /* up to but w/o Directive 0 */
|
||||
#define AOEV1_RESERVE_ARG_LEN 2U /* up to but w/o Ethernet address 0 */
|
||||
#define AOEV1_MAX_CONFSTR_LEN 1024U
|
||||
|
||||
#define AOEV1_FLAG_R 0x08
|
||||
#define AOEV1_FLAG_E 0x04
|
||||
|
||||
static const struct tok aoev1_flag_str[] = {
|
||||
{ AOEV1_FLAG_R, "Response" },
|
||||
{ AOEV1_FLAG_E, "Error" },
|
||||
{ 0x02, "MBZ-0x02" },
|
||||
{ 0x01, "MBZ-0x01" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static const struct tok aoev1_errcode_str[] = {
|
||||
{ 1, "Unrecognized command code" },
|
||||
{ 2, "Bad argument parameter" },
|
||||
{ 3, "Device unavailable" },
|
||||
{ 4, "Config string present" },
|
||||
{ 5, "Unsupported version" },
|
||||
{ 6, "Target is reserved" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
#define AOEV1_AFLAG_E 0x40
|
||||
#define AOEV1_AFLAG_D 0x10
|
||||
#define AOEV1_AFLAG_A 0x02
|
||||
#define AOEV1_AFLAG_W 0x01
|
||||
|
||||
static const struct tok aoev1_aflag_str[] = {
|
||||
{ 0x08, "MBZ-0x08" },
|
||||
{ AOEV1_AFLAG_E, "Ext48" },
|
||||
{ 0x06, "MBZ-0x06" },
|
||||
{ AOEV1_AFLAG_D, "Device" },
|
||||
{ 0x04, "MBZ-0x04" },
|
||||
{ 0x03, "MBZ-0x03" },
|
||||
{ AOEV1_AFLAG_A, "Async" },
|
||||
{ AOEV1_AFLAG_W, "Write" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static const struct tok aoev1_ccmd_str[] = {
|
||||
{ 0, "read config string" },
|
||||
{ 1, "test config string" },
|
||||
{ 2, "test config string prefix" },
|
||||
{ 3, "set config string" },
|
||||
{ 4, "force set config string" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static const struct tok aoev1_mcmd_str[] = {
|
||||
{ 0, "Read Mac Mask List" },
|
||||
{ 1, "Edit Mac Mask List" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static const struct tok aoev1_merror_str[] = {
|
||||
{ 1, "Unspecified Error" },
|
||||
{ 2, "Bad DCmd directive" },
|
||||
{ 3, "Mask list full" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static const struct tok aoev1_dcmd_str[] = {
|
||||
{ 0, "No Directive" },
|
||||
{ 1, "Add mac address to mask list" },
|
||||
{ 2, "Delete mac address from mask list" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static const struct tok aoev1_rcmd_str[] = {
|
||||
{ 0, "Read reserve list" },
|
||||
{ 1, "Set reserve list" },
|
||||
{ 2, "Force set reserve list" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static void
|
||||
aoev1_issue_print(netdissect_options *ndo,
|
||||
const u_char *cp, const u_int len)
|
||||
{
|
||||
const u_char *ep = cp + len;
|
||||
|
||||
if (len < AOEV1_ISSUE_ARG_LEN)
|
||||
goto invalid;
|
||||
/* AFlags */
|
||||
ND_TCHECK2(*cp, 1);
|
||||
ND_PRINT((ndo, "\n\tAFlags: [%s]", bittok2str(aoev1_aflag_str, "none", *cp)));
|
||||
cp += 1;
|
||||
/* Err/Feature */
|
||||
ND_TCHECK2(*cp, 1);
|
||||
ND_PRINT((ndo, ", Err/Feature: %u", *cp));
|
||||
cp += 1;
|
||||
/* Sector Count (not correlated with the length) */
|
||||
ND_TCHECK2(*cp, 1);
|
||||
ND_PRINT((ndo, ", Sector Count: %u", *cp));
|
||||
cp += 1;
|
||||
/* Cmd/Status */
|
||||
ND_TCHECK2(*cp, 1);
|
||||
ND_PRINT((ndo, ", Cmd/Status: %u", *cp));
|
||||
cp += 1;
|
||||
/* lba0 */
|
||||
ND_TCHECK2(*cp, 1);
|
||||
ND_PRINT((ndo, "\n\tlba0: %u", *cp));
|
||||
cp += 1;
|
||||
/* lba1 */
|
||||
ND_TCHECK2(*cp, 1);
|
||||
ND_PRINT((ndo, ", lba1: %u", *cp));
|
||||
cp += 1;
|
||||
/* lba2 */
|
||||
ND_TCHECK2(*cp, 1);
|
||||
ND_PRINT((ndo, ", lba2: %u", *cp));
|
||||
cp += 1;
|
||||
/* lba3 */
|
||||
ND_TCHECK2(*cp, 1);
|
||||
ND_PRINT((ndo, ", lba3: %u", *cp));
|
||||
cp += 1;
|
||||
/* lba4 */
|
||||
ND_TCHECK2(*cp, 1);
|
||||
ND_PRINT((ndo, ", lba4: %u", *cp));
|
||||
cp += 1;
|
||||
/* lba5 */
|
||||
ND_TCHECK2(*cp, 1);
|
||||
ND_PRINT((ndo, ", lba5: %u", *cp));
|
||||
cp += 1;
|
||||
/* Reserved */
|
||||
ND_TCHECK2(*cp, 2);
|
||||
cp += 2;
|
||||
/* Data */
|
||||
if (len > AOEV1_ISSUE_ARG_LEN)
|
||||
ND_PRINT((ndo, "\n\tData: %u bytes", len - AOEV1_ISSUE_ARG_LEN));
|
||||
return;
|
||||
|
||||
invalid:
|
||||
ND_PRINT((ndo, "%s", istr));
|
||||
ND_TCHECK2(*cp, ep - cp);
|
||||
return;
|
||||
trunc:
|
||||
ND_PRINT((ndo, "%s", tstr));
|
||||
}
|
||||
|
||||
static void
|
||||
aoev1_query_print(netdissect_options *ndo,
|
||||
const u_char *cp, const u_int len)
|
||||
{
|
||||
const u_char *ep = cp + len;
|
||||
uint16_t cslen;
|
||||
|
||||
if (len < AOEV1_QUERY_ARG_LEN)
|
||||
goto invalid;
|
||||
/* Buffer Count */
|
||||
ND_TCHECK2(*cp, 2);
|
||||
ND_PRINT((ndo, "\n\tBuffer Count: %u", EXTRACT_16BITS(cp)));
|
||||
cp += 2;
|
||||
/* Firmware Version */
|
||||
ND_TCHECK2(*cp, 2);
|
||||
ND_PRINT((ndo, ", Firmware Version: %u", EXTRACT_16BITS(cp)));
|
||||
cp += 2;
|
||||
/* Sector Count */
|
||||
ND_TCHECK2(*cp, 1);
|
||||
ND_PRINT((ndo, ", Sector Count: %u", *cp));
|
||||
cp += 1;
|
||||
/* AoE/CCmd */
|
||||
ND_TCHECK2(*cp, 1);
|
||||
ND_PRINT((ndo, ", AoE: %u, CCmd: %s", (*cp & 0xF0) >> 4,
|
||||
tok2str(aoev1_ccmd_str, "Unknown (0x02x)", *cp & 0x0F)));
|
||||
cp += 1;
|
||||
/* Config String Length */
|
||||
ND_TCHECK2(*cp, 2);
|
||||
cslen = EXTRACT_16BITS(cp);
|
||||
cp += 2;
|
||||
if (cslen > AOEV1_MAX_CONFSTR_LEN || AOEV1_QUERY_ARG_LEN + cslen > len)
|
||||
goto invalid;
|
||||
/* Config String */
|
||||
ND_TCHECK2(*cp, cslen);
|
||||
if (cslen) {
|
||||
ND_PRINT((ndo, "\n\tConfig String (length %u): ", cslen));
|
||||
if (fn_printn(ndo, cp, cslen, ndo->ndo_snapend))
|
||||
goto trunc;
|
||||
}
|
||||
return;
|
||||
|
||||
invalid:
|
||||
ND_PRINT((ndo, "%s", istr));
|
||||
ND_TCHECK2(*cp, ep - cp);
|
||||
return;
|
||||
trunc:
|
||||
ND_PRINT((ndo, "%s", tstr));
|
||||
}
|
||||
|
||||
static void
|
||||
aoev1_mac_print(netdissect_options *ndo,
|
||||
const u_char *cp, const u_int len)
|
||||
{
|
||||
const u_char *ep = cp + len;
|
||||
uint8_t dircount, i;
|
||||
|
||||
if (len < AOEV1_MAC_ARG_LEN)
|
||||
goto invalid;
|
||||
/* Reserved */
|
||||
ND_TCHECK2(*cp, 1);
|
||||
cp += 1;
|
||||
/* MCmd */
|
||||
ND_TCHECK2(*cp, 1);
|
||||
ND_PRINT((ndo, "\n\tMCmd: %s", tok2str(aoev1_mcmd_str, "Unknown (0x%02x)", *cp)));
|
||||
cp += 1;
|
||||
/* MError */
|
||||
ND_TCHECK2(*cp, 1);
|
||||
ND_PRINT((ndo, ", MError: %s", tok2str(aoev1_merror_str, "Unknown (0x%02x)", *cp)));
|
||||
cp += 1;
|
||||
/* Dir Count */
|
||||
ND_TCHECK2(*cp, 1);
|
||||
dircount = *cp;
|
||||
cp += 1;
|
||||
ND_PRINT((ndo, ", Dir Count: %u", dircount));
|
||||
if (AOEV1_MAC_ARG_LEN + dircount * 8 > len)
|
||||
goto invalid;
|
||||
/* directives */
|
||||
for (i = 0; i < dircount; i++) {
|
||||
/* Reserved */
|
||||
ND_TCHECK2(*cp, 1);
|
||||
cp += 1;
|
||||
/* DCmd */
|
||||
ND_TCHECK2(*cp, 1);
|
||||
ND_PRINT((ndo, "\n\t DCmd: %s", tok2str(aoev1_dcmd_str, "Unknown (0x%02x)", *cp)));
|
||||
cp += 1;
|
||||
/* Ethernet Address */
|
||||
ND_TCHECK2(*cp, ETHER_ADDR_LEN);
|
||||
ND_PRINT((ndo, ", Ethernet Address: %s", etheraddr_string(ndo, cp)));
|
||||
cp += ETHER_ADDR_LEN;
|
||||
}
|
||||
return;
|
||||
|
||||
invalid:
|
||||
ND_PRINT((ndo, "%s", istr));
|
||||
ND_TCHECK2(*cp, ep - cp);
|
||||
return;
|
||||
trunc:
|
||||
ND_PRINT((ndo, "%s", tstr));
|
||||
}
|
||||
|
||||
static void
|
||||
aoev1_reserve_print(netdissect_options *ndo,
|
||||
const u_char *cp, const u_int len)
|
||||
{
|
||||
const u_char *ep = cp + len;
|
||||
uint8_t nmacs, i;
|
||||
|
||||
if (len < AOEV1_RESERVE_ARG_LEN || (len - AOEV1_RESERVE_ARG_LEN) % ETHER_ADDR_LEN)
|
||||
goto invalid;
|
||||
/* RCmd */
|
||||
ND_TCHECK2(*cp, 1);
|
||||
ND_PRINT((ndo, "\n\tRCmd: %s", tok2str(aoev1_rcmd_str, "Unknown (0x%02x)", *cp)));
|
||||
cp += 1;
|
||||
/* NMacs (correlated with the length) */
|
||||
ND_TCHECK2(*cp, 1);
|
||||
nmacs = *cp;
|
||||
cp += 1;
|
||||
ND_PRINT((ndo, ", NMacs: %u", nmacs));
|
||||
if (AOEV1_RESERVE_ARG_LEN + nmacs * ETHER_ADDR_LEN != len)
|
||||
goto invalid;
|
||||
/* addresses */
|
||||
for (i = 0; i < nmacs; i++) {
|
||||
ND_PRINT((ndo, "\n\tEthernet Address %u: %s", i, etheraddr_string(ndo, cp)));
|
||||
cp += ETHER_ADDR_LEN;
|
||||
}
|
||||
return;
|
||||
|
||||
invalid:
|
||||
ND_PRINT((ndo, "%s", istr));
|
||||
ND_TCHECK2(*cp, ep - cp);
|
||||
return;
|
||||
trunc:
|
||||
ND_PRINT((ndo, "%s", tstr));
|
||||
}
|
||||
|
||||
/* cp points to the Ver/Flags octet */
|
||||
static void
|
||||
aoev1_print(netdissect_options *ndo,
|
||||
const u_char *cp, const u_int len)
|
||||
{
|
||||
const u_char *ep = cp + len;
|
||||
uint8_t flags, command;
|
||||
void (*cmd_decoder)(netdissect_options *, const u_char *, const u_int);
|
||||
|
||||
if (len < AOEV1_COMMON_HDR_LEN)
|
||||
goto invalid;
|
||||
/* Flags */
|
||||
flags = *cp & 0x0F;
|
||||
ND_PRINT((ndo, ", Flags: [%s]", bittok2str(aoev1_flag_str, "none", flags)));
|
||||
cp += 1;
|
||||
if (! ndo->ndo_vflag)
|
||||
return;
|
||||
/* Error */
|
||||
ND_TCHECK2(*cp, 1);
|
||||
if (flags & AOEV1_FLAG_E)
|
||||
ND_PRINT((ndo, "\n\tError: %s", tok2str(aoev1_errcode_str, "Invalid (%u)", *cp)));
|
||||
cp += 1;
|
||||
/* Major */
|
||||
ND_TCHECK2(*cp, 2);
|
||||
ND_PRINT((ndo, "\n\tMajor: 0x%04x", EXTRACT_16BITS(cp)));
|
||||
cp += 2;
|
||||
/* Minor */
|
||||
ND_TCHECK2(*cp, 1);
|
||||
ND_PRINT((ndo, ", Minor: 0x%02x", *cp));
|
||||
cp += 1;
|
||||
/* Command */
|
||||
ND_TCHECK2(*cp, 1);
|
||||
command = *cp;
|
||||
cp += 1;
|
||||
ND_PRINT((ndo, ", Command: %s", tok2str(cmdcode_str, "Unknown (0x%02x)", command)));
|
||||
/* Tag */
|
||||
ND_TCHECK2(*cp, 4);
|
||||
ND_PRINT((ndo, ", Tag: 0x%08x", EXTRACT_32BITS(cp)));
|
||||
cp += 4;
|
||||
/* Arg */
|
||||
cmd_decoder =
|
||||
command == AOEV1_CMD_ISSUE_ATA_COMMAND ? aoev1_issue_print :
|
||||
command == AOEV1_CMD_QUERY_CONFIG_INFORMATION ? aoev1_query_print :
|
||||
command == AOEV1_CMD_MAC_MASK_LIST ? aoev1_mac_print :
|
||||
command == AOEV1_CMD_RESERVE_RELEASE ? aoev1_reserve_print :
|
||||
NULL;
|
||||
if (cmd_decoder != NULL)
|
||||
cmd_decoder(ndo, cp, len - AOEV1_COMMON_HDR_LEN);
|
||||
return;
|
||||
|
||||
invalid:
|
||||
ND_PRINT((ndo, "%s", istr));
|
||||
ND_TCHECK2(*cp, ep - cp);
|
||||
return;
|
||||
trunc:
|
||||
ND_PRINT((ndo, "%s", tstr));
|
||||
}
|
||||
|
||||
void
|
||||
aoe_print(netdissect_options *ndo,
|
||||
const u_char *cp, const u_int len)
|
||||
{
|
||||
const u_char *ep = cp + len;
|
||||
uint8_t ver;
|
||||
|
||||
ND_PRINT((ndo, "AoE length %u", len));
|
||||
|
||||
if (len < 1)
|
||||
goto invalid;
|
||||
/* Ver/Flags */
|
||||
ND_TCHECK2(*cp, 1);
|
||||
ver = (*cp & 0xF0) >> 4;
|
||||
/* Don't advance cp yet: low order 4 bits are version-specific. */
|
||||
ND_PRINT((ndo, ", Ver %u", ver));
|
||||
|
||||
switch (ver) {
|
||||
case AOE_V1:
|
||||
aoev1_print(ndo, cp, len);
|
||||
break;
|
||||
}
|
||||
return;
|
||||
|
||||
invalid:
|
||||
ND_PRINT((ndo, "%s", istr));
|
||||
ND_TCHECK2(*cp, ep - cp);
|
||||
return;
|
||||
trunc:
|
||||
ND_PRINT((ndo, "%s", tstr));
|
||||
}
|
||||
|
||||
112
print-ap1394.c
Normal file
112
print-ap1394.c
Normal file
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that: (1) source code distributions
|
||||
* retain the above copyright notice and this paragraph in its entirety, (2)
|
||||
* distributions including binary code include the above copyright notice and
|
||||
* this paragraph in its entirety in the documentation or other materials
|
||||
* provided with the distribution, and (3) all advertising materials mentioning
|
||||
* features or use of this software display the following acknowledgement:
|
||||
* ``This product includes software developed by the University of California,
|
||||
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
|
||||
* the University nor the names of its contributors may be used to endorse
|
||||
* or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <netdissect-stdinc.h>
|
||||
|
||||
#include "netdissect.h"
|
||||
#include "extract.h"
|
||||
#include "addrtoname.h"
|
||||
#include "ethertype.h"
|
||||
|
||||
/*
|
||||
* Structure of a header for Apple's IP-over-IEEE 1384 BPF header.
|
||||
*/
|
||||
#define FIREWIRE_EUI64_LEN 8
|
||||
struct firewire_header {
|
||||
u_char firewire_dhost[FIREWIRE_EUI64_LEN];
|
||||
u_char firewire_shost[FIREWIRE_EUI64_LEN];
|
||||
u_short firewire_type;
|
||||
};
|
||||
|
||||
/*
|
||||
* Length of that header; note that some compilers may pad
|
||||
* "struct firewire_header" to a multiple of 4 bytes, for example, so
|
||||
* "sizeof (struct firewire_header)" may not give the right answer.
|
||||
*/
|
||||
#define FIREWIRE_HDRLEN 18
|
||||
|
||||
static inline void
|
||||
ap1394_hdr_print(netdissect_options *ndo, register const u_char *bp, u_int length)
|
||||
{
|
||||
register const struct firewire_header *fp;
|
||||
uint16_t firewire_type;
|
||||
|
||||
fp = (const struct firewire_header *)bp;
|
||||
|
||||
ND_PRINT((ndo, "%s > %s",
|
||||
linkaddr_string(ndo, fp->firewire_shost, LINKADDR_IEEE1394, FIREWIRE_EUI64_LEN),
|
||||
linkaddr_string(ndo, fp->firewire_dhost, LINKADDR_IEEE1394, FIREWIRE_EUI64_LEN)));
|
||||
|
||||
firewire_type = EXTRACT_16BITS(&fp->firewire_type);
|
||||
if (!ndo->ndo_qflag) {
|
||||
ND_PRINT((ndo, ", ethertype %s (0x%04x)",
|
||||
tok2str(ethertype_values,"Unknown", firewire_type),
|
||||
firewire_type));
|
||||
} else {
|
||||
ND_PRINT((ndo, ", %s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", firewire_type)));
|
||||
}
|
||||
|
||||
ND_PRINT((ndo, ", length %u: ", length));
|
||||
}
|
||||
|
||||
/*
|
||||
* This is the top level routine of the printer. 'p' points
|
||||
* to the ether header of the packet, 'h->ts' is the timestamp,
|
||||
* 'h->len' is the length of the packet off the wire, and 'h->caplen'
|
||||
* is the number of bytes actually captured.
|
||||
*/
|
||||
u_int
|
||||
ap1394_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
|
||||
{
|
||||
u_int length = h->len;
|
||||
u_int caplen = h->caplen;
|
||||
const struct firewire_header *fp;
|
||||
u_short ether_type;
|
||||
|
||||
if (caplen < FIREWIRE_HDRLEN) {
|
||||
ND_PRINT((ndo, "[|ap1394]"));
|
||||
return FIREWIRE_HDRLEN;
|
||||
}
|
||||
|
||||
if (ndo->ndo_eflag)
|
||||
ap1394_hdr_print(ndo, p, length);
|
||||
|
||||
length -= FIREWIRE_HDRLEN;
|
||||
caplen -= FIREWIRE_HDRLEN;
|
||||
fp = (const struct firewire_header *)p;
|
||||
p += FIREWIRE_HDRLEN;
|
||||
|
||||
ether_type = EXTRACT_16BITS(&fp->firewire_type);
|
||||
if (ethertype_print(ndo, ether_type, p, length, caplen) == 0) {
|
||||
/* ether_type not known, print raw packet */
|
||||
if (!ndo->ndo_eflag)
|
||||
ap1394_hdr_print(ndo, (const u_char *)fp, length + FIREWIRE_HDRLEN);
|
||||
|
||||
if (!ndo->ndo_suppress_default_print)
|
||||
ND_DEFAULTPRINT(p, caplen);
|
||||
}
|
||||
|
||||
return FIREWIRE_HDRLEN;
|
||||
}
|
||||
358
print-arcnet.c
Normal file
358
print-arcnet.c
Normal file
@@ -0,0 +1,358 @@
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 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.
|
||||
*
|
||||
* From: NetBSD: print-arcnet.c,v 1.2 2000/04/24 13:02:28 itojun Exp
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <netdissect-stdinc.h>
|
||||
|
||||
#include "netdissect.h"
|
||||
#include "extract.h"
|
||||
|
||||
/*
|
||||
* from: NetBSD: if_arc.h,v 1.13 1999/11/19 20:41:19 thorpej Exp
|
||||
*/
|
||||
|
||||
/*
|
||||
* Structure of a 2.5MB/s Arcnet header on the BSDs,
|
||||
* as given to interface code.
|
||||
*/
|
||||
struct arc_header {
|
||||
uint8_t arc_shost;
|
||||
uint8_t arc_dhost;
|
||||
uint8_t arc_type;
|
||||
/*
|
||||
* only present for newstyle encoding with LL fragmentation.
|
||||
* Don't use sizeof(anything), use ARC_HDR{,NEW}LEN instead.
|
||||
*/
|
||||
uint8_t arc_flag;
|
||||
uint16_t arc_seqid;
|
||||
|
||||
/*
|
||||
* only present in exception packets (arc_flag == 0xff)
|
||||
*/
|
||||
uint8_t arc_type2; /* same as arc_type */
|
||||
uint8_t arc_flag2; /* real flag value */
|
||||
uint16_t arc_seqid2; /* real seqid value */
|
||||
};
|
||||
|
||||
#define ARC_HDRLEN 3
|
||||
#define ARC_HDRNEWLEN 6
|
||||
#define ARC_HDRNEWLEN_EXC 10
|
||||
|
||||
/* 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 */
|
||||
|
||||
/*
|
||||
* Structure of a 2.5MB/s Arcnet header on Linux. Linux has
|
||||
* an extra "offset" field when given to interface code, and
|
||||
* never presents packets that look like exception frames.
|
||||
*/
|
||||
struct arc_linux_header {
|
||||
uint8_t arc_shost;
|
||||
uint8_t arc_dhost;
|
||||
uint16_t arc_offset;
|
||||
uint8_t arc_type;
|
||||
/*
|
||||
* only present for newstyle encoding with LL fragmentation.
|
||||
* Don't use sizeof(anything), use ARC_LINUX_HDR{,NEW}LEN
|
||||
* instead.
|
||||
*/
|
||||
uint8_t arc_flag;
|
||||
uint16_t arc_seqid;
|
||||
};
|
||||
|
||||
#define ARC_LINUX_HDRLEN 5
|
||||
#define ARC_LINUX_HDRNEWLEN 8
|
||||
|
||||
static int arcnet_encap_print(netdissect_options *, u_char arctype, const u_char *p,
|
||||
u_int length, u_int caplen);
|
||||
|
||||
static const struct tok arctypemap[] = {
|
||||
{ ARCTYPE_IP_OLD, "oldip" },
|
||||
{ ARCTYPE_ARP_OLD, "oldarp" },
|
||||
{ ARCTYPE_IP, "ip" },
|
||||
{ ARCTYPE_ARP, "arp" },
|
||||
{ ARCTYPE_REVARP, "rarp" },
|
||||
{ ARCTYPE_ATALK, "atalk" },
|
||||
{ ARCTYPE_BANIAN, "banyan" },
|
||||
{ ARCTYPE_IPX, "ipx" },
|
||||
{ ARCTYPE_INET6, "ipv6" },
|
||||
{ ARCTYPE_DIAGNOSE, "diag" },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
static inline void
|
||||
arcnet_print(netdissect_options *ndo, const u_char *bp, u_int length, int phds,
|
||||
int flag, u_int seqid)
|
||||
{
|
||||
const struct arc_header *ap;
|
||||
const char *arctypename;
|
||||
|
||||
|
||||
ap = (const struct arc_header *)bp;
|
||||
|
||||
|
||||
if (ndo->ndo_qflag) {
|
||||
ND_PRINT((ndo, "%02x %02x %d: ",
|
||||
ap->arc_shost,
|
||||
ap->arc_dhost,
|
||||
length));
|
||||
return;
|
||||
}
|
||||
|
||||
arctypename = tok2str(arctypemap, "%02x", ap->arc_type);
|
||||
|
||||
if (!phds) {
|
||||
ND_PRINT((ndo, "%02x %02x %s %d: ",
|
||||
ap->arc_shost, ap->arc_dhost, arctypename,
|
||||
length));
|
||||
return;
|
||||
}
|
||||
|
||||
if (flag == 0) {
|
||||
ND_PRINT((ndo, "%02x %02x %s seqid %04x %d: ",
|
||||
ap->arc_shost, ap->arc_dhost, arctypename, seqid,
|
||||
length));
|
||||
return;
|
||||
}
|
||||
|
||||
if (flag & 1)
|
||||
ND_PRINT((ndo, "%02x %02x %s seqid %04x "
|
||||
"(first of %d fragments) %d: ",
|
||||
ap->arc_shost, ap->arc_dhost, arctypename, seqid,
|
||||
(flag + 3) / 2, length));
|
||||
else
|
||||
ND_PRINT((ndo, "%02x %02x %s seqid %04x "
|
||||
"(fragment %d) %d: ",
|
||||
ap->arc_shost, ap->arc_dhost, arctypename, seqid,
|
||||
flag/2 + 1, length));
|
||||
}
|
||||
|
||||
/*
|
||||
* This is the top level routine of the printer. 'p' points
|
||||
* to the ARCNET header of the packet, 'h->ts' is the timestamp,
|
||||
* 'h->len' is the length of the packet off the wire, and 'h->caplen'
|
||||
* is the number of bytes actually captured.
|
||||
*/
|
||||
u_int
|
||||
arcnet_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
|
||||
{
|
||||
u_int caplen = h->caplen;
|
||||
u_int length = h->len;
|
||||
const struct arc_header *ap;
|
||||
|
||||
int phds, flag = 0, archdrlen = 0;
|
||||
u_int seqid = 0;
|
||||
u_char arc_type;
|
||||
|
||||
if (caplen < ARC_HDRLEN || length < ARC_HDRLEN) {
|
||||
ND_PRINT((ndo, "[|arcnet]"));
|
||||
return (caplen);
|
||||
}
|
||||
|
||||
ap = (const struct arc_header *)p;
|
||||
arc_type = ap->arc_type;
|
||||
|
||||
switch (arc_type) {
|
||||
default:
|
||||
phds = 1;
|
||||
break;
|
||||
case ARCTYPE_IP_OLD:
|
||||
case ARCTYPE_ARP_OLD:
|
||||
case ARCTYPE_DIAGNOSE:
|
||||
phds = 0;
|
||||
archdrlen = ARC_HDRLEN;
|
||||
break;
|
||||
}
|
||||
|
||||
if (phds) {
|
||||
if (caplen < ARC_HDRNEWLEN || length < ARC_HDRNEWLEN) {
|
||||
arcnet_print(ndo, p, length, 0, 0, 0);
|
||||
ND_PRINT((ndo, "[|phds]"));
|
||||
return (caplen);
|
||||
}
|
||||
|
||||
if (ap->arc_flag == 0xff) {
|
||||
if (caplen < ARC_HDRNEWLEN_EXC || length < ARC_HDRNEWLEN_EXC) {
|
||||
arcnet_print(ndo, p, length, 0, 0, 0);
|
||||
ND_PRINT((ndo, "[|phds extended]"));
|
||||
return (caplen);
|
||||
}
|
||||
flag = ap->arc_flag2;
|
||||
seqid = EXTRACT_16BITS(&ap->arc_seqid2);
|
||||
archdrlen = ARC_HDRNEWLEN_EXC;
|
||||
} else {
|
||||
flag = ap->arc_flag;
|
||||
seqid = EXTRACT_16BITS(&ap->arc_seqid);
|
||||
archdrlen = ARC_HDRNEWLEN;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ndo->ndo_eflag)
|
||||
arcnet_print(ndo, p, length, phds, flag, seqid);
|
||||
|
||||
/*
|
||||
* Go past the ARCNET header.
|
||||
*/
|
||||
length -= archdrlen;
|
||||
caplen -= archdrlen;
|
||||
p += archdrlen;
|
||||
|
||||
if (phds && flag && (flag & 1) == 0) {
|
||||
/*
|
||||
* This is a middle fragment.
|
||||
*/
|
||||
return (archdrlen);
|
||||
}
|
||||
|
||||
if (!arcnet_encap_print(ndo, arc_type, p, length, caplen))
|
||||
ND_DEFAULTPRINT(p, caplen);
|
||||
|
||||
return (archdrlen);
|
||||
}
|
||||
|
||||
/*
|
||||
* This is the top level routine of the printer. 'p' points
|
||||
* to the ARCNET header of the packet, 'h->ts' is the timestamp,
|
||||
* 'h->len' is the length of the packet off the wire, and 'h->caplen'
|
||||
* is the number of bytes actually captured. It is quite similar
|
||||
* to the non-Linux style printer except that Linux doesn't ever
|
||||
* supply packets that look like exception frames, it always supplies
|
||||
* reassembled packets rather than raw frames, and headers have an
|
||||
* extra "offset" field between the src/dest and packet type.
|
||||
*/
|
||||
u_int
|
||||
arcnet_linux_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
|
||||
{
|
||||
u_int caplen = h->caplen;
|
||||
u_int length = h->len;
|
||||
const struct arc_linux_header *ap;
|
||||
|
||||
int archdrlen = 0;
|
||||
u_char arc_type;
|
||||
|
||||
if (caplen < ARC_LINUX_HDRLEN || length < ARC_LINUX_HDRLEN) {
|
||||
ND_PRINT((ndo, "[|arcnet]"));
|
||||
return (caplen);
|
||||
}
|
||||
|
||||
ap = (const struct arc_linux_header *)p;
|
||||
arc_type = ap->arc_type;
|
||||
|
||||
switch (arc_type) {
|
||||
default:
|
||||
archdrlen = ARC_LINUX_HDRNEWLEN;
|
||||
if (caplen < ARC_LINUX_HDRNEWLEN || length < ARC_LINUX_HDRNEWLEN) {
|
||||
ND_PRINT((ndo, "[|arcnet]"));
|
||||
return (caplen);
|
||||
}
|
||||
break;
|
||||
case ARCTYPE_IP_OLD:
|
||||
case ARCTYPE_ARP_OLD:
|
||||
case ARCTYPE_DIAGNOSE:
|
||||
archdrlen = ARC_LINUX_HDRLEN;
|
||||
break;
|
||||
}
|
||||
|
||||
if (ndo->ndo_eflag)
|
||||
arcnet_print(ndo, p, length, 0, 0, 0);
|
||||
|
||||
/*
|
||||
* Go past the ARCNET header.
|
||||
*/
|
||||
length -= archdrlen;
|
||||
caplen -= archdrlen;
|
||||
p += archdrlen;
|
||||
|
||||
if (!arcnet_encap_print(ndo, arc_type, p, length, caplen))
|
||||
ND_DEFAULTPRINT(p, caplen);
|
||||
|
||||
return (archdrlen);
|
||||
}
|
||||
|
||||
/*
|
||||
* Prints the packet encapsulated in an ARCnet data field,
|
||||
* given the ARCnet system code.
|
||||
*
|
||||
* Returns non-zero if it can do so, zero if the system code is unknown.
|
||||
*/
|
||||
|
||||
|
||||
static int
|
||||
arcnet_encap_print(netdissect_options *ndo, u_char arctype, const u_char *p,
|
||||
u_int length, u_int caplen)
|
||||
{
|
||||
switch (arctype) {
|
||||
|
||||
case ARCTYPE_IP_OLD:
|
||||
case ARCTYPE_IP:
|
||||
ip_print(ndo, p, length);
|
||||
return (1);
|
||||
|
||||
case ARCTYPE_INET6:
|
||||
ip6_print(ndo, p, length);
|
||||
return (1);
|
||||
|
||||
case ARCTYPE_ARP_OLD:
|
||||
case ARCTYPE_ARP:
|
||||
case ARCTYPE_REVARP:
|
||||
arp_print(ndo, p, length, caplen);
|
||||
return (1);
|
||||
|
||||
case ARCTYPE_ATALK: /* XXX was this ever used? */
|
||||
if (ndo->ndo_vflag)
|
||||
ND_PRINT((ndo, "et1 "));
|
||||
atalk_print(ndo, p, length);
|
||||
return (1);
|
||||
|
||||
case ARCTYPE_IPX:
|
||||
ipx_print(ndo, p, length);
|
||||
return (1);
|
||||
|
||||
default:
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* c-style: bsd
|
||||
* End:
|
||||
*/
|
||||
|
||||
413
print-arp.c
Normal file
413
print-arp.c
Normal file
@@ -0,0 +1,413 @@
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <netdissect-stdinc.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "netdissect.h"
|
||||
#include "addrtoname.h"
|
||||
#include "ether.h"
|
||||
#include "ethertype.h"
|
||||
#include "extract.h"
|
||||
|
||||
static const char tstr[] = "[|ARP]";
|
||||
|
||||
/*
|
||||
* Address Resolution Protocol.
|
||||
*
|
||||
* See RFC 826 for protocol description. ARP packets are variable
|
||||
* in size; the arphdr structure defines the fixed-length portion.
|
||||
* Protocol type values are the same as those for 10 Mb/s Ethernet.
|
||||
* It is followed by the variable-sized fields ar_sha, arp_spa,
|
||||
* arp_tha and arp_tpa in that order, according to the lengths
|
||||
* specified. Field names used correspond to RFC 826.
|
||||
*/
|
||||
struct arp_pkthdr {
|
||||
u_short ar_hrd; /* format of hardware address */
|
||||
#define ARPHRD_ETHER 1 /* ethernet hardware format */
|
||||
#define ARPHRD_IEEE802 6 /* token-ring hardware format */
|
||||
#define ARPHRD_ARCNET 7 /* arcnet hardware format */
|
||||
#define ARPHRD_FRELAY 15 /* frame relay hardware format */
|
||||
#define ARPHRD_ATM2225 19 /* ATM (RFC 2225) */
|
||||
#define ARPHRD_STRIP 23 /* Ricochet Starmode Radio hardware format */
|
||||
#define ARPHRD_IEEE1394 24 /* IEEE 1394 (FireWire) hardware format */
|
||||
u_short ar_pro; /* format of protocol address */
|
||||
u_char ar_hln; /* length of hardware address */
|
||||
u_char ar_pln; /* length of protocol address */
|
||||
u_short ar_op; /* one of: */
|
||||
#define ARPOP_REQUEST 1 /* request to resolve address */
|
||||
#define ARPOP_REPLY 2 /* response to previous request */
|
||||
#define ARPOP_REVREQUEST 3 /* request protocol address given hardware */
|
||||
#define ARPOP_REVREPLY 4 /* response giving protocol address */
|
||||
#define ARPOP_INVREQUEST 8 /* request to identify peer */
|
||||
#define ARPOP_INVREPLY 9 /* response identifying peer */
|
||||
#define ARPOP_NAK 10 /* NAK - only valif for ATM ARP */
|
||||
|
||||
/*
|
||||
* The remaining fields are variable in size,
|
||||
* according to the sizes above.
|
||||
*/
|
||||
#ifdef COMMENT_ONLY
|
||||
u_char ar_sha[]; /* sender hardware address */
|
||||
u_char ar_spa[]; /* sender protocol address */
|
||||
u_char ar_tha[]; /* target hardware address */
|
||||
u_char ar_tpa[]; /* target protocol address */
|
||||
#endif
|
||||
#define ar_sha(ap) (((const u_char *)((ap)+1))+0)
|
||||
#define ar_spa(ap) (((const u_char *)((ap)+1))+ (ap)->ar_hln)
|
||||
#define ar_tha(ap) (((const u_char *)((ap)+1))+ (ap)->ar_hln+(ap)->ar_pln)
|
||||
#define ar_tpa(ap) (((const u_char *)((ap)+1))+2*(ap)->ar_hln+(ap)->ar_pln)
|
||||
};
|
||||
|
||||
#define ARP_HDRLEN 8
|
||||
|
||||
#define HRD(ap) EXTRACT_16BITS(&(ap)->ar_hrd)
|
||||
#define HRD_LEN(ap) ((ap)->ar_hln)
|
||||
#define PROTO_LEN(ap) ((ap)->ar_pln)
|
||||
#define OP(ap) EXTRACT_16BITS(&(ap)->ar_op)
|
||||
#define PRO(ap) EXTRACT_16BITS(&(ap)->ar_pro)
|
||||
#define SHA(ap) (ar_sha(ap))
|
||||
#define SPA(ap) (ar_spa(ap))
|
||||
#define THA(ap) (ar_tha(ap))
|
||||
#define TPA(ap) (ar_tpa(ap))
|
||||
|
||||
|
||||
static const struct tok arpop_values[] = {
|
||||
{ ARPOP_REQUEST, "Request" },
|
||||
{ ARPOP_REPLY, "Reply" },
|
||||
{ ARPOP_REVREQUEST, "Reverse Request" },
|
||||
{ ARPOP_REVREPLY, "Reverse Reply" },
|
||||
{ ARPOP_INVREQUEST, "Inverse Request" },
|
||||
{ ARPOP_INVREPLY, "Inverse Reply" },
|
||||
{ ARPOP_NAK, "NACK Reply" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static const struct tok arphrd_values[] = {
|
||||
{ ARPHRD_ETHER, "Ethernet" },
|
||||
{ ARPHRD_IEEE802, "TokenRing" },
|
||||
{ ARPHRD_ARCNET, "ArcNet" },
|
||||
{ ARPHRD_FRELAY, "FrameRelay" },
|
||||
{ ARPHRD_STRIP, "Strip" },
|
||||
{ ARPHRD_IEEE1394, "IEEE 1394" },
|
||||
{ ARPHRD_ATM2225, "ATM" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
/*
|
||||
* ATM Address Resolution Protocol.
|
||||
*
|
||||
* See RFC 2225 for protocol description. ATMARP packets are similar
|
||||
* to ARP packets, except that there are no length fields for the
|
||||
* protocol address - instead, there are type/length fields for
|
||||
* the ATM number and subaddress - and the hardware addresses consist
|
||||
* of an ATM number and an ATM subaddress.
|
||||
*/
|
||||
struct atmarp_pkthdr {
|
||||
u_short aar_hrd; /* format of hardware address */
|
||||
u_short aar_pro; /* format of protocol address */
|
||||
u_char aar_shtl; /* length of source ATM number */
|
||||
u_char aar_sstl; /* length of source ATM subaddress */
|
||||
#define ATMARP_IS_E164 0x40 /* bit in type/length for E.164 format */
|
||||
#define ATMARP_LEN_MASK 0x3F /* length of {sub}address in type/length */
|
||||
u_short aar_op; /* same as regular ARP */
|
||||
u_char aar_spln; /* length of source protocol address */
|
||||
u_char aar_thtl; /* length of target ATM number */
|
||||
u_char aar_tstl; /* length of target ATM subaddress */
|
||||
u_char aar_tpln; /* length of target protocol address */
|
||||
/*
|
||||
* The remaining fields are variable in size,
|
||||
* according to the sizes above.
|
||||
*/
|
||||
#ifdef COMMENT_ONLY
|
||||
u_char aar_sha[]; /* source ATM number */
|
||||
u_char aar_ssa[]; /* source ATM subaddress */
|
||||
u_char aar_spa[]; /* sender protocol address */
|
||||
u_char aar_tha[]; /* target ATM number */
|
||||
u_char aar_tsa[]; /* target ATM subaddress */
|
||||
u_char aar_tpa[]; /* target protocol address */
|
||||
#endif
|
||||
|
||||
#define ATMHRD(ap) EXTRACT_16BITS(&(ap)->aar_hrd)
|
||||
#define ATMSHRD_LEN(ap) ((ap)->aar_shtl & ATMARP_LEN_MASK)
|
||||
#define ATMSSLN(ap) ((ap)->aar_sstl & ATMARP_LEN_MASK)
|
||||
#define ATMSPROTO_LEN(ap) ((ap)->aar_spln)
|
||||
#define ATMOP(ap) EXTRACT_16BITS(&(ap)->aar_op)
|
||||
#define ATMPRO(ap) EXTRACT_16BITS(&(ap)->aar_pro)
|
||||
#define ATMTHRD_LEN(ap) ((ap)->aar_thtl & ATMARP_LEN_MASK)
|
||||
#define ATMTSLN(ap) ((ap)->aar_tstl & ATMARP_LEN_MASK)
|
||||
#define ATMTPROTO_LEN(ap) ((ap)->aar_tpln)
|
||||
#define aar_sha(ap) ((const u_char *)((ap)+1))
|
||||
#define aar_ssa(ap) (aar_sha(ap) + ATMSHRD_LEN(ap))
|
||||
#define aar_spa(ap) (aar_ssa(ap) + ATMSSLN(ap))
|
||||
#define aar_tha(ap) (aar_spa(ap) + ATMSPROTO_LEN(ap))
|
||||
#define aar_tsa(ap) (aar_tha(ap) + ATMTHRD_LEN(ap))
|
||||
#define aar_tpa(ap) (aar_tsa(ap) + ATMTSLN(ap))
|
||||
};
|
||||
|
||||
#define ATMSHA(ap) (aar_sha(ap))
|
||||
#define ATMSSA(ap) (aar_ssa(ap))
|
||||
#define ATMSPA(ap) (aar_spa(ap))
|
||||
#define ATMTHA(ap) (aar_tha(ap))
|
||||
#define ATMTSA(ap) (aar_tsa(ap))
|
||||
#define ATMTPA(ap) (aar_tpa(ap))
|
||||
|
||||
static u_char ezero[6];
|
||||
|
||||
static void
|
||||
atmarp_addr_print(netdissect_options *ndo,
|
||||
const u_char *ha, u_int ha_len, const u_char *srca,
|
||||
u_int srca_len)
|
||||
{
|
||||
if (ha_len == 0)
|
||||
ND_PRINT((ndo, "<No address>"));
|
||||
else {
|
||||
ND_PRINT((ndo, "%s", linkaddr_string(ndo, ha, LINKADDR_ATM, ha_len)));
|
||||
if (srca_len != 0)
|
||||
ND_PRINT((ndo, ",%s",
|
||||
linkaddr_string(ndo, srca, LINKADDR_ATM, srca_len)));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
atmarp_print(netdissect_options *ndo,
|
||||
const u_char *bp, u_int length, u_int caplen)
|
||||
{
|
||||
const struct atmarp_pkthdr *ap;
|
||||
u_short pro, hrd, op;
|
||||
|
||||
ap = (const struct atmarp_pkthdr *)bp;
|
||||
ND_TCHECK(*ap);
|
||||
|
||||
hrd = ATMHRD(ap);
|
||||
pro = ATMPRO(ap);
|
||||
op = ATMOP(ap);
|
||||
|
||||
if (!ND_TTEST2(*aar_tpa(ap), ATMTPROTO_LEN(ap))) {
|
||||
ND_PRINT((ndo, "%s", tstr));
|
||||
ND_DEFAULTPRINT((const u_char *)ap, length);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ndo->ndo_eflag) {
|
||||
ND_PRINT((ndo, "ARP, "));
|
||||
}
|
||||
|
||||
if ((pro != ETHERTYPE_IP && pro != ETHERTYPE_TRAIL) ||
|
||||
ATMSPROTO_LEN(ap) != 4 ||
|
||||
ATMTPROTO_LEN(ap) != 4 ||
|
||||
ndo->ndo_vflag) {
|
||||
ND_PRINT((ndo, "%s, %s (len %u/%u)",
|
||||
tok2str(arphrd_values, "Unknown Hardware (%u)", hrd),
|
||||
tok2str(ethertype_values, "Unknown Protocol (0x%04x)", pro),
|
||||
ATMSPROTO_LEN(ap),
|
||||
ATMTPROTO_LEN(ap)));
|
||||
|
||||
/* don't know know about the address formats */
|
||||
if (!ndo->ndo_vflag) {
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
/* print operation */
|
||||
ND_PRINT((ndo, "%s%s ",
|
||||
ndo->ndo_vflag ? ", " : "",
|
||||
tok2str(arpop_values, "Unknown (%u)", op)));
|
||||
|
||||
switch (op) {
|
||||
|
||||
case ARPOP_REQUEST:
|
||||
ND_PRINT((ndo, "who-has %s", ipaddr_string(ndo, ATMTPA(ap))));
|
||||
if (ATMTHRD_LEN(ap) != 0) {
|
||||
ND_PRINT((ndo, " ("));
|
||||
atmarp_addr_print(ndo, ATMTHA(ap), ATMTHRD_LEN(ap),
|
||||
ATMTSA(ap), ATMTSLN(ap));
|
||||
ND_PRINT((ndo, ")"));
|
||||
}
|
||||
ND_PRINT((ndo, "tell %s", ipaddr_string(ndo, ATMSPA(ap))));
|
||||
break;
|
||||
|
||||
case ARPOP_REPLY:
|
||||
ND_PRINT((ndo, "%s is-at ", ipaddr_string(ndo, ATMSPA(ap))));
|
||||
atmarp_addr_print(ndo, ATMSHA(ap), ATMSHRD_LEN(ap), ATMSSA(ap),
|
||||
ATMSSLN(ap));
|
||||
break;
|
||||
|
||||
case ARPOP_INVREQUEST:
|
||||
ND_PRINT((ndo, "who-is "));
|
||||
atmarp_addr_print(ndo, ATMTHA(ap), ATMTHRD_LEN(ap), ATMTSA(ap),
|
||||
ATMTSLN(ap));
|
||||
ND_PRINT((ndo, " tell "));
|
||||
atmarp_addr_print(ndo, ATMSHA(ap), ATMSHRD_LEN(ap), ATMSSA(ap),
|
||||
ATMSSLN(ap));
|
||||
break;
|
||||
|
||||
case ARPOP_INVREPLY:
|
||||
atmarp_addr_print(ndo, ATMSHA(ap), ATMSHRD_LEN(ap), ATMSSA(ap),
|
||||
ATMSSLN(ap));
|
||||
ND_PRINT((ndo, "at %s", ipaddr_string(ndo, ATMSPA(ap))));
|
||||
break;
|
||||
|
||||
case ARPOP_NAK:
|
||||
ND_PRINT((ndo, "for %s", ipaddr_string(ndo, ATMSPA(ap))));
|
||||
break;
|
||||
|
||||
default:
|
||||
ND_DEFAULTPRINT((const u_char *)ap, caplen);
|
||||
return;
|
||||
}
|
||||
|
||||
out:
|
||||
ND_PRINT((ndo, ", length %u", length));
|
||||
return;
|
||||
|
||||
trunc:
|
||||
ND_PRINT((ndo, "%s", tstr));
|
||||
}
|
||||
|
||||
void
|
||||
arp_print(netdissect_options *ndo,
|
||||
const u_char *bp, u_int length, u_int caplen)
|
||||
{
|
||||
const struct arp_pkthdr *ap;
|
||||
u_short pro, hrd, op, linkaddr;
|
||||
|
||||
ap = (const struct arp_pkthdr *)bp;
|
||||
ND_TCHECK(*ap);
|
||||
|
||||
hrd = HRD(ap);
|
||||
pro = PRO(ap);
|
||||
op = OP(ap);
|
||||
|
||||
|
||||
/* if its ATM then call the ATM ARP printer
|
||||
for Frame-relay ARP most of the fields
|
||||
are similar to Ethernet so overload the Ethernet Printer
|
||||
and set the linkaddr type for linkaddr_string(ndo, ) accordingly */
|
||||
|
||||
switch(hrd) {
|
||||
case ARPHRD_ATM2225:
|
||||
atmarp_print(ndo, bp, length, caplen);
|
||||
return;
|
||||
case ARPHRD_FRELAY:
|
||||
linkaddr = LINKADDR_FRELAY;
|
||||
break;
|
||||
default:
|
||||
linkaddr = LINKADDR_ETHER;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!ND_TTEST2(*ar_tpa(ap), PROTO_LEN(ap))) {
|
||||
ND_PRINT((ndo, "%s", tstr));
|
||||
ND_DEFAULTPRINT((const u_char *)ap, length);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ndo->ndo_eflag) {
|
||||
ND_PRINT((ndo, "ARP, "));
|
||||
}
|
||||
|
||||
/* print hardware type/len and proto type/len */
|
||||
if ((pro != ETHERTYPE_IP && pro != ETHERTYPE_TRAIL) ||
|
||||
PROTO_LEN(ap) != 4 ||
|
||||
HRD_LEN(ap) == 0 ||
|
||||
ndo->ndo_vflag) {
|
||||
ND_PRINT((ndo, "%s (len %u), %s (len %u)",
|
||||
tok2str(arphrd_values, "Unknown Hardware (%u)", hrd),
|
||||
HRD_LEN(ap),
|
||||
tok2str(ethertype_values, "Unknown Protocol (0x%04x)", pro),
|
||||
PROTO_LEN(ap)));
|
||||
|
||||
/* don't know know about the address formats */
|
||||
if (!ndo->ndo_vflag) {
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
/* print operation */
|
||||
ND_PRINT((ndo, "%s%s ",
|
||||
ndo->ndo_vflag ? ", " : "",
|
||||
tok2str(arpop_values, "Unknown (%u)", op)));
|
||||
|
||||
switch (op) {
|
||||
|
||||
case ARPOP_REQUEST:
|
||||
ND_PRINT((ndo, "who-has %s", ipaddr_string(ndo, TPA(ap))));
|
||||
if (memcmp((const char *)ezero, (const char *)THA(ap), HRD_LEN(ap)) != 0)
|
||||
ND_PRINT((ndo, " (%s)",
|
||||
linkaddr_string(ndo, THA(ap), linkaddr, HRD_LEN(ap))));
|
||||
ND_PRINT((ndo, " tell %s", ipaddr_string(ndo, SPA(ap))));
|
||||
break;
|
||||
|
||||
case ARPOP_REPLY:
|
||||
ND_PRINT((ndo, "%s is-at %s",
|
||||
ipaddr_string(ndo, SPA(ap)),
|
||||
linkaddr_string(ndo, SHA(ap), linkaddr, HRD_LEN(ap))));
|
||||
break;
|
||||
|
||||
case ARPOP_REVREQUEST:
|
||||
ND_PRINT((ndo, "who-is %s tell %s",
|
||||
linkaddr_string(ndo, THA(ap), linkaddr, HRD_LEN(ap)),
|
||||
linkaddr_string(ndo, SHA(ap), linkaddr, HRD_LEN(ap))));
|
||||
break;
|
||||
|
||||
case ARPOP_REVREPLY:
|
||||
ND_PRINT((ndo, "%s at %s",
|
||||
linkaddr_string(ndo, THA(ap), linkaddr, HRD_LEN(ap)),
|
||||
ipaddr_string(ndo, TPA(ap))));
|
||||
break;
|
||||
|
||||
case ARPOP_INVREQUEST:
|
||||
ND_PRINT((ndo, "who-is %s tell %s",
|
||||
linkaddr_string(ndo, THA(ap), linkaddr, HRD_LEN(ap)),
|
||||
linkaddr_string(ndo, SHA(ap), linkaddr, HRD_LEN(ap))));
|
||||
break;
|
||||
|
||||
case ARPOP_INVREPLY:
|
||||
ND_PRINT((ndo,"%s at %s",
|
||||
linkaddr_string(ndo, SHA(ap), linkaddr, HRD_LEN(ap)),
|
||||
ipaddr_string(ndo, SPA(ap))));
|
||||
break;
|
||||
|
||||
default:
|
||||
ND_DEFAULTPRINT((const u_char *)ap, caplen);
|
||||
return;
|
||||
}
|
||||
|
||||
out:
|
||||
ND_PRINT((ndo, ", length %u", length));
|
||||
|
||||
return;
|
||||
trunc:
|
||||
ND_PRINT((ndo, "%s", tstr));
|
||||
}
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* c-style: bsd
|
||||
* End:
|
||||
*/
|
||||
|
||||
207
print-ascii.c
Normal file
207
print-ascii.c
Normal file
@@ -0,0 +1,207 @@
|
||||
/* $NetBSD: print-ascii.c,v 1.1 1999/09/30 14:49:12 sjg Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Alan Barrett and Simon J. Gerraty.
|
||||
*
|
||||
* 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 NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <netdissect-stdinc.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "netdissect.h"
|
||||
|
||||
#define ASCII_LINELENGTH 300
|
||||
#define HEXDUMP_BYTES_PER_LINE 16
|
||||
#define HEXDUMP_SHORTS_PER_LINE (HEXDUMP_BYTES_PER_LINE / 2)
|
||||
#define HEXDUMP_HEXSTUFF_PER_SHORT 5 /* 4 hex digits and a space */
|
||||
#define HEXDUMP_HEXSTUFF_PER_LINE \
|
||||
(HEXDUMP_HEXSTUFF_PER_SHORT * HEXDUMP_SHORTS_PER_LINE)
|
||||
|
||||
void
|
||||
ascii_print(netdissect_options *ndo,
|
||||
const u_char *cp, u_int length)
|
||||
{
|
||||
u_int caplength;
|
||||
register u_char s;
|
||||
|
||||
caplength = (ndo->ndo_snapend >= cp) ? ndo->ndo_snapend - cp : 0;
|
||||
if (length > caplength)
|
||||
length = caplength;
|
||||
ND_PRINT((ndo, "\n"));
|
||||
while (length > 0) {
|
||||
s = *cp++;
|
||||
length--;
|
||||
if (s == '\r') {
|
||||
/*
|
||||
* Don't print CRs at the end of the line; they
|
||||
* don't belong at the ends of lines on UN*X,
|
||||
* and the standard I/O library will give us one
|
||||
* on Windows so we don't need to print one
|
||||
* ourselves.
|
||||
*
|
||||
* In the middle of a line, just print a '.'.
|
||||
*/
|
||||
if (length > 1 && *cp != '\n')
|
||||
ND_PRINT((ndo, "."));
|
||||
} else {
|
||||
if (!ND_ISGRAPH(s) &&
|
||||
(s != '\t' && s != ' ' && s != '\n'))
|
||||
ND_PRINT((ndo, "."));
|
||||
else
|
||||
ND_PRINT((ndo, "%c", s));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
hex_and_ascii_print_with_offset(netdissect_options *ndo, register const char *ident,
|
||||
register const u_char *cp, register u_int length, register u_int oset)
|
||||
{
|
||||
u_int caplength;
|
||||
register u_int i;
|
||||
register int s1, s2;
|
||||
register int nshorts;
|
||||
char hexstuff[HEXDUMP_SHORTS_PER_LINE*HEXDUMP_HEXSTUFF_PER_SHORT+1], *hsp;
|
||||
char asciistuff[ASCII_LINELENGTH+1], *asp;
|
||||
|
||||
caplength = (ndo->ndo_snapend >= cp) ? ndo->ndo_snapend - cp : 0;
|
||||
if (length > caplength)
|
||||
length = caplength;
|
||||
nshorts = length / sizeof(u_short);
|
||||
i = 0;
|
||||
hsp = hexstuff; asp = asciistuff;
|
||||
while (--nshorts >= 0) {
|
||||
s1 = *cp++;
|
||||
s2 = *cp++;
|
||||
(void)snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff),
|
||||
" %02x%02x", s1, s2);
|
||||
hsp += HEXDUMP_HEXSTUFF_PER_SHORT;
|
||||
*(asp++) = (ND_ISGRAPH(s1) ? s1 : '.');
|
||||
*(asp++) = (ND_ISGRAPH(s2) ? s2 : '.');
|
||||
i++;
|
||||
if (i >= HEXDUMP_SHORTS_PER_LINE) {
|
||||
*hsp = *asp = '\0';
|
||||
ND_PRINT((ndo, "%s0x%04x: %-*s %s",
|
||||
ident, oset, HEXDUMP_HEXSTUFF_PER_LINE,
|
||||
hexstuff, asciistuff));
|
||||
i = 0; hsp = hexstuff; asp = asciistuff;
|
||||
oset += HEXDUMP_BYTES_PER_LINE;
|
||||
}
|
||||
}
|
||||
if (length & 1) {
|
||||
s1 = *cp++;
|
||||
(void)snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff),
|
||||
" %02x", s1);
|
||||
hsp += 3;
|
||||
*(asp++) = (ND_ISGRAPH(s1) ? s1 : '.');
|
||||
++i;
|
||||
}
|
||||
if (i > 0) {
|
||||
*hsp = *asp = '\0';
|
||||
ND_PRINT((ndo, "%s0x%04x: %-*s %s",
|
||||
ident, oset, HEXDUMP_HEXSTUFF_PER_LINE,
|
||||
hexstuff, asciistuff));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
hex_and_ascii_print(netdissect_options *ndo, register const char *ident,
|
||||
register const u_char *cp, register u_int length)
|
||||
{
|
||||
hex_and_ascii_print_with_offset(ndo, ident, cp, length, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* telnet_print() wants this. It is essentially default_print_unaligned()
|
||||
*/
|
||||
void
|
||||
hex_print_with_offset(netdissect_options *ndo,
|
||||
const char *ident, const u_char *cp, u_int length,
|
||||
u_int oset)
|
||||
{
|
||||
u_int caplength;
|
||||
register u_int i, s;
|
||||
register int nshorts;
|
||||
|
||||
caplength = (ndo->ndo_snapend >= cp) ? ndo->ndo_snapend - cp : 0;
|
||||
if (length > caplength)
|
||||
length = caplength;
|
||||
nshorts = (u_int) length / sizeof(u_short);
|
||||
i = 0;
|
||||
while (--nshorts >= 0) {
|
||||
if ((i++ % 8) == 0) {
|
||||
ND_PRINT((ndo,"%s0x%04x: ", ident, oset));
|
||||
oset += HEXDUMP_BYTES_PER_LINE;
|
||||
}
|
||||
s = *cp++;
|
||||
ND_PRINT((ndo," %02x%02x", s, *cp++));
|
||||
}
|
||||
if (length & 1) {
|
||||
if ((i % 8) == 0)
|
||||
ND_PRINT((ndo,"%s0x%04x: ", ident, oset));
|
||||
ND_PRINT((ndo," %02x", *cp));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* just for completeness
|
||||
*/
|
||||
void
|
||||
hex_print(netdissect_options *ndo,const char *ident, const u_char *cp, u_int length)
|
||||
{
|
||||
hex_print_with_offset(ndo, ident, cp, length, 0);
|
||||
}
|
||||
|
||||
#ifdef MAIN
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
hex_print("\n\t", "Hello, World!\n", 14);
|
||||
printf("\n");
|
||||
hex_and_ascii_print("\n\t", "Hello, World!\n", 14);
|
||||
printf("\n");
|
||||
ascii_print("Hello, World!\n", 14);
|
||||
printf("\n");
|
||||
#define TMSG "Now is the winter of our discontent...\n"
|
||||
hex_print_with_offset("\n\t", TMSG, sizeof(TMSG) - 1, 0x100);
|
||||
printf("\n");
|
||||
hex_and_ascii_print_with_offset("\n\t", TMSG, sizeof(TMSG) - 1, 0x100);
|
||||
printf("\n");
|
||||
exit(0);
|
||||
}
|
||||
#endif /* MAIN */
|
||||
629
print-atalk.c
Normal file
629
print-atalk.c
Normal file
@@ -0,0 +1,629 @@
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 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.
|
||||
*
|
||||
* Format and print AppleTalk packets.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <netdissect-stdinc.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "netdissect.h"
|
||||
#include "addrtoname.h"
|
||||
#include "ethertype.h"
|
||||
#include "extract.h"
|
||||
#include "appletalk.h"
|
||||
|
||||
static const char tstr[] = "[|atalk]";
|
||||
|
||||
static const struct tok type2str[] = {
|
||||
{ ddpRTMP, "rtmp" },
|
||||
{ ddpRTMPrequest, "rtmpReq" },
|
||||
{ ddpECHO, "echo" },
|
||||
{ ddpIP, "IP" },
|
||||
{ ddpARP, "ARP" },
|
||||
{ ddpKLAP, "KLAP" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
struct aarp {
|
||||
uint16_t htype, ptype;
|
||||
uint8_t halen, palen;
|
||||
uint16_t op;
|
||||
uint8_t hsaddr[6];
|
||||
uint8_t psaddr[4];
|
||||
uint8_t hdaddr[6];
|
||||
uint8_t pdaddr[4];
|
||||
};
|
||||
|
||||
static void atp_print(netdissect_options *, const struct atATP *, u_int);
|
||||
static void atp_bitmap_print(netdissect_options *, u_char);
|
||||
static void nbp_print(netdissect_options *, const struct atNBP *, u_int, u_short, u_char, u_char);
|
||||
static const struct atNBPtuple *nbp_tuple_print(netdissect_options *ndo, const struct atNBPtuple *,
|
||||
const u_char *,
|
||||
u_short, u_char, u_char);
|
||||
static const struct atNBPtuple *nbp_name_print(netdissect_options *, const struct atNBPtuple *,
|
||||
const u_char *);
|
||||
static const char *ataddr_string(netdissect_options *, u_short, u_char);
|
||||
static void ddp_print(netdissect_options *, const u_char *, u_int, int, u_short, u_char, u_char);
|
||||
static const char *ddpskt_string(netdissect_options *, int);
|
||||
|
||||
/*
|
||||
* Print LLAP packets received on a physical LocalTalk interface.
|
||||
*/
|
||||
u_int
|
||||
ltalk_if_print(netdissect_options *ndo,
|
||||
const struct pcap_pkthdr *h, const u_char *p)
|
||||
{
|
||||
return (llap_print(ndo, p, h->caplen));
|
||||
}
|
||||
|
||||
/*
|
||||
* Print AppleTalk LLAP packets.
|
||||
*/
|
||||
u_int
|
||||
llap_print(netdissect_options *ndo,
|
||||
register const u_char *bp, u_int length)
|
||||
{
|
||||
register const struct LAP *lp;
|
||||
register const struct atDDP *dp;
|
||||
register const struct atShortDDP *sdp;
|
||||
u_short snet;
|
||||
u_int hdrlen;
|
||||
|
||||
if (length < sizeof(*lp)) {
|
||||
ND_PRINT((ndo, " [|llap %u]", length));
|
||||
return (length);
|
||||
}
|
||||
lp = (const struct LAP *)bp;
|
||||
bp += sizeof(*lp);
|
||||
length -= sizeof(*lp);
|
||||
hdrlen = sizeof(*lp);
|
||||
switch (lp->type) {
|
||||
|
||||
case lapShortDDP:
|
||||
if (length < ddpSSize) {
|
||||
ND_PRINT((ndo, " [|sddp %u]", length));
|
||||
return (length);
|
||||
}
|
||||
sdp = (const struct atShortDDP *)bp;
|
||||
ND_PRINT((ndo, "%s.%s",
|
||||
ataddr_string(ndo, 0, lp->src), ddpskt_string(ndo, sdp->srcSkt)));
|
||||
ND_PRINT((ndo, " > %s.%s:",
|
||||
ataddr_string(ndo, 0, lp->dst), ddpskt_string(ndo, sdp->dstSkt)));
|
||||
bp += ddpSSize;
|
||||
length -= ddpSSize;
|
||||
hdrlen += ddpSSize;
|
||||
ddp_print(ndo, bp, length, sdp->type, 0, lp->src, sdp->srcSkt);
|
||||
break;
|
||||
|
||||
case lapDDP:
|
||||
if (length < ddpSize) {
|
||||
ND_PRINT((ndo, " [|ddp %u]", length));
|
||||
return (length);
|
||||
}
|
||||
dp = (const struct atDDP *)bp;
|
||||
snet = EXTRACT_16BITS(&dp->srcNet);
|
||||
ND_PRINT((ndo, "%s.%s", ataddr_string(ndo, snet, dp->srcNode),
|
||||
ddpskt_string(ndo, dp->srcSkt)));
|
||||
ND_PRINT((ndo, " > %s.%s:",
|
||||
ataddr_string(ndo, EXTRACT_16BITS(&dp->dstNet), dp->dstNode),
|
||||
ddpskt_string(ndo, dp->dstSkt)));
|
||||
bp += ddpSize;
|
||||
length -= ddpSize;
|
||||
hdrlen += ddpSize;
|
||||
ddp_print(ndo, bp, length, dp->type, snet, dp->srcNode, dp->srcSkt);
|
||||
break;
|
||||
|
||||
#ifdef notdef
|
||||
case lapKLAP:
|
||||
klap_print(bp, length);
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
ND_PRINT((ndo, "%d > %d at-lap#%d %u",
|
||||
lp->src, lp->dst, lp->type, length));
|
||||
break;
|
||||
}
|
||||
return (hdrlen);
|
||||
}
|
||||
|
||||
/*
|
||||
* Print EtherTalk/TokenTalk packets (or FDDITalk, or whatever it's called
|
||||
* when it runs over FDDI; yes, I've seen FDDI captures with AppleTalk
|
||||
* packets in them).
|
||||
*/
|
||||
void
|
||||
atalk_print(netdissect_options *ndo,
|
||||
register const u_char *bp, u_int length)
|
||||
{
|
||||
register const struct atDDP *dp;
|
||||
u_short snet;
|
||||
|
||||
if(!ndo->ndo_eflag)
|
||||
ND_PRINT((ndo, "AT "));
|
||||
|
||||
if (length < ddpSize) {
|
||||
ND_PRINT((ndo, " [|ddp %u]", length));
|
||||
return;
|
||||
}
|
||||
dp = (const struct atDDP *)bp;
|
||||
snet = EXTRACT_16BITS(&dp->srcNet);
|
||||
ND_PRINT((ndo, "%s.%s", ataddr_string(ndo, snet, dp->srcNode),
|
||||
ddpskt_string(ndo, dp->srcSkt)));
|
||||
ND_PRINT((ndo, " > %s.%s: ",
|
||||
ataddr_string(ndo, EXTRACT_16BITS(&dp->dstNet), dp->dstNode),
|
||||
ddpskt_string(ndo, dp->dstSkt)));
|
||||
bp += ddpSize;
|
||||
length -= ddpSize;
|
||||
ddp_print(ndo, bp, length, dp->type, snet, dp->srcNode, dp->srcSkt);
|
||||
}
|
||||
|
||||
/* XXX should probably pass in the snap header and do checks like arp_print() */
|
||||
void
|
||||
aarp_print(netdissect_options *ndo,
|
||||
register const u_char *bp, u_int length)
|
||||
{
|
||||
register const struct aarp *ap;
|
||||
|
||||
#define AT(member) ataddr_string(ndo, (ap->member[1]<<8)|ap->member[2],ap->member[3])
|
||||
|
||||
ND_PRINT((ndo, "aarp "));
|
||||
ap = (const struct aarp *)bp;
|
||||
if (EXTRACT_16BITS(&ap->htype) == 1 &&
|
||||
EXTRACT_16BITS(&ap->ptype) == ETHERTYPE_ATALK &&
|
||||
ap->halen == 6 && ap->palen == 4 )
|
||||
switch (EXTRACT_16BITS(&ap->op)) {
|
||||
|
||||
case 1: /* request */
|
||||
ND_PRINT((ndo, "who-has %s tell %s", AT(pdaddr), AT(psaddr)));
|
||||
return;
|
||||
|
||||
case 2: /* response */
|
||||
ND_PRINT((ndo, "reply %s is-at %s", AT(psaddr), etheraddr_string(ndo, ap->hsaddr)));
|
||||
return;
|
||||
|
||||
case 3: /* probe (oy!) */
|
||||
ND_PRINT((ndo, "probe %s tell %s", AT(pdaddr), AT(psaddr)));
|
||||
return;
|
||||
}
|
||||
ND_PRINT((ndo, "len %u op %u htype %u ptype %#x halen %u palen %u",
|
||||
length, EXTRACT_16BITS(&ap->op), EXTRACT_16BITS(&ap->htype),
|
||||
EXTRACT_16BITS(&ap->ptype), ap->halen, ap->palen));
|
||||
}
|
||||
|
||||
/*
|
||||
* Print AppleTalk Datagram Delivery Protocol packets.
|
||||
*/
|
||||
static void
|
||||
ddp_print(netdissect_options *ndo,
|
||||
register const u_char *bp, register u_int length, register int t,
|
||||
register u_short snet, register u_char snode, u_char skt)
|
||||
{
|
||||
|
||||
switch (t) {
|
||||
|
||||
case ddpNBP:
|
||||
nbp_print(ndo, (const struct atNBP *)bp, length, snet, snode, skt);
|
||||
break;
|
||||
|
||||
case ddpATP:
|
||||
atp_print(ndo, (const struct atATP *)bp, length);
|
||||
break;
|
||||
|
||||
case ddpEIGRP:
|
||||
eigrp_print(ndo, bp, length);
|
||||
break;
|
||||
|
||||
default:
|
||||
ND_PRINT((ndo, " at-%s %d", tok2str(type2str, NULL, t), length));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
atp_print(netdissect_options *ndo,
|
||||
register const struct atATP *ap, u_int length)
|
||||
{
|
||||
char c;
|
||||
uint32_t data;
|
||||
|
||||
if ((const u_char *)(ap + 1) > ndo->ndo_snapend) {
|
||||
/* Just bail if we don't have the whole chunk. */
|
||||
ND_PRINT((ndo, "%s", tstr));
|
||||
return;
|
||||
}
|
||||
if (length < sizeof(*ap)) {
|
||||
ND_PRINT((ndo, " [|atp %u]", length));
|
||||
return;
|
||||
}
|
||||
length -= sizeof(*ap);
|
||||
switch (ap->control & 0xc0) {
|
||||
|
||||
case atpReqCode:
|
||||
ND_PRINT((ndo, " atp-req%s %d",
|
||||
ap->control & atpXO? " " : "*",
|
||||
EXTRACT_16BITS(&ap->transID)));
|
||||
|
||||
atp_bitmap_print(ndo, ap->bitmap);
|
||||
|
||||
if (length != 0)
|
||||
ND_PRINT((ndo, " [len=%u]", length));
|
||||
|
||||
switch (ap->control & (atpEOM|atpSTS)) {
|
||||
case atpEOM:
|
||||
ND_PRINT((ndo, " [EOM]"));
|
||||
break;
|
||||
case atpSTS:
|
||||
ND_PRINT((ndo, " [STS]"));
|
||||
break;
|
||||
case atpEOM|atpSTS:
|
||||
ND_PRINT((ndo, " [EOM,STS]"));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case atpRspCode:
|
||||
ND_PRINT((ndo, " atp-resp%s%d:%d (%u)",
|
||||
ap->control & atpEOM? "*" : " ",
|
||||
EXTRACT_16BITS(&ap->transID), ap->bitmap, length));
|
||||
switch (ap->control & (atpXO|atpSTS)) {
|
||||
case atpXO:
|
||||
ND_PRINT((ndo, " [XO]"));
|
||||
break;
|
||||
case atpSTS:
|
||||
ND_PRINT((ndo, " [STS]"));
|
||||
break;
|
||||
case atpXO|atpSTS:
|
||||
ND_PRINT((ndo, " [XO,STS]"));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case atpRelCode:
|
||||
ND_PRINT((ndo, " atp-rel %d", EXTRACT_16BITS(&ap->transID)));
|
||||
|
||||
atp_bitmap_print(ndo, ap->bitmap);
|
||||
|
||||
/* length should be zero */
|
||||
if (length)
|
||||
ND_PRINT((ndo, " [len=%u]", length));
|
||||
|
||||
/* there shouldn't be any control flags */
|
||||
if (ap->control & (atpXO|atpEOM|atpSTS)) {
|
||||
c = '[';
|
||||
if (ap->control & atpXO) {
|
||||
ND_PRINT((ndo, "%cXO", c));
|
||||
c = ',';
|
||||
}
|
||||
if (ap->control & atpEOM) {
|
||||
ND_PRINT((ndo, "%cEOM", c));
|
||||
c = ',';
|
||||
}
|
||||
if (ap->control & atpSTS) {
|
||||
ND_PRINT((ndo, "%cSTS", c));
|
||||
c = ',';
|
||||
}
|
||||
ND_PRINT((ndo, "]"));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
ND_PRINT((ndo, " atp-0x%x %d (%u)", ap->control,
|
||||
EXTRACT_16BITS(&ap->transID), length));
|
||||
break;
|
||||
}
|
||||
data = EXTRACT_32BITS(&ap->userData);
|
||||
if (data != 0)
|
||||
ND_PRINT((ndo, " 0x%x", data));
|
||||
}
|
||||
|
||||
static void
|
||||
atp_bitmap_print(netdissect_options *ndo,
|
||||
register u_char bm)
|
||||
{
|
||||
register char c;
|
||||
register int i;
|
||||
|
||||
/*
|
||||
* The '& 0xff' below is needed for compilers that want to sign
|
||||
* extend a u_char, which is the case with the Ultrix compiler.
|
||||
* (gcc is smart enough to eliminate it, at least on the Sparc).
|
||||
*/
|
||||
if ((bm + 1) & (bm & 0xff)) {
|
||||
c = '<';
|
||||
for (i = 0; bm; ++i) {
|
||||
if (bm & 1) {
|
||||
ND_PRINT((ndo, "%c%d", c, i));
|
||||
c = ',';
|
||||
}
|
||||
bm >>= 1;
|
||||
}
|
||||
ND_PRINT((ndo, ">"));
|
||||
} else {
|
||||
for (i = 0; bm; ++i)
|
||||
bm >>= 1;
|
||||
if (i > 1)
|
||||
ND_PRINT((ndo, "<0-%d>", i - 1));
|
||||
else
|
||||
ND_PRINT((ndo, "<0>"));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
nbp_print(netdissect_options *ndo,
|
||||
register const struct atNBP *np, u_int length, register u_short snet,
|
||||
register u_char snode, register u_char skt)
|
||||
{
|
||||
register const struct atNBPtuple *tp =
|
||||
(const struct atNBPtuple *)((const u_char *)np + nbpHeaderSize);
|
||||
int i;
|
||||
const u_char *ep;
|
||||
|
||||
if (length < nbpHeaderSize) {
|
||||
ND_PRINT((ndo, " truncated-nbp %u", length));
|
||||
return;
|
||||
}
|
||||
|
||||
length -= nbpHeaderSize;
|
||||
if (length < 8) {
|
||||
/* must be room for at least one tuple */
|
||||
ND_PRINT((ndo, " truncated-nbp %u", length + nbpHeaderSize));
|
||||
return;
|
||||
}
|
||||
/* ep points to end of available data */
|
||||
ep = ndo->ndo_snapend;
|
||||
if ((const u_char *)tp > ep) {
|
||||
ND_PRINT((ndo, "%s", tstr));
|
||||
return;
|
||||
}
|
||||
switch (i = np->control & 0xf0) {
|
||||
|
||||
case nbpBrRq:
|
||||
case nbpLkUp:
|
||||
ND_PRINT((ndo, i == nbpLkUp? " nbp-lkup %d:":" nbp-brRq %d:", np->id));
|
||||
if ((const u_char *)(tp + 1) > ep) {
|
||||
ND_PRINT((ndo, "%s", tstr));
|
||||
return;
|
||||
}
|
||||
(void)nbp_name_print(ndo, tp, ep);
|
||||
/*
|
||||
* look for anomalies: the spec says there can only
|
||||
* be one tuple, the address must match the source
|
||||
* address and the enumerator should be zero.
|
||||
*/
|
||||
if ((np->control & 0xf) != 1)
|
||||
ND_PRINT((ndo, " [ntup=%d]", np->control & 0xf));
|
||||
if (tp->enumerator)
|
||||
ND_PRINT((ndo, " [enum=%d]", tp->enumerator));
|
||||
if (EXTRACT_16BITS(&tp->net) != snet ||
|
||||
tp->node != snode || tp->skt != skt)
|
||||
ND_PRINT((ndo, " [addr=%s.%d]",
|
||||
ataddr_string(ndo, EXTRACT_16BITS(&tp->net),
|
||||
tp->node), tp->skt));
|
||||
break;
|
||||
|
||||
case nbpLkUpReply:
|
||||
ND_PRINT((ndo, " nbp-reply %d:", np->id));
|
||||
|
||||
/* print each of the tuples in the reply */
|
||||
for (i = np->control & 0xf; --i >= 0 && tp; )
|
||||
tp = nbp_tuple_print(ndo, tp, ep, snet, snode, skt);
|
||||
break;
|
||||
|
||||
default:
|
||||
ND_PRINT((ndo, " nbp-0x%x %d (%u)", np->control, np->id, length));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* print a counted string */
|
||||
static const char *
|
||||
print_cstring(netdissect_options *ndo,
|
||||
register const char *cp, register const u_char *ep)
|
||||
{
|
||||
register u_int length;
|
||||
|
||||
if (cp >= (const char *)ep) {
|
||||
ND_PRINT((ndo, "%s", tstr));
|
||||
return (0);
|
||||
}
|
||||
length = *cp++;
|
||||
|
||||
/* Spec says string can be at most 32 bytes long */
|
||||
if (length > 32) {
|
||||
ND_PRINT((ndo, "[len=%u]", length));
|
||||
return (0);
|
||||
}
|
||||
while ((int)--length >= 0) {
|
||||
if (cp >= (const char *)ep) {
|
||||
ND_PRINT((ndo, "%s", tstr));
|
||||
return (0);
|
||||
}
|
||||
ND_PRINT((ndo, "%c", *cp++));
|
||||
}
|
||||
return (cp);
|
||||
}
|
||||
|
||||
static const struct atNBPtuple *
|
||||
nbp_tuple_print(netdissect_options *ndo,
|
||||
register const struct atNBPtuple *tp, register const u_char *ep,
|
||||
register u_short snet, register u_char snode, register u_char skt)
|
||||
{
|
||||
register const struct atNBPtuple *tpn;
|
||||
|
||||
if ((const u_char *)(tp + 1) > ep) {
|
||||
ND_PRINT((ndo, "%s", tstr));
|
||||
return 0;
|
||||
}
|
||||
tpn = nbp_name_print(ndo, tp, ep);
|
||||
|
||||
/* if the enumerator isn't 1, print it */
|
||||
if (tp->enumerator != 1)
|
||||
ND_PRINT((ndo, "(%d)", tp->enumerator));
|
||||
|
||||
/* if the socket doesn't match the src socket, print it */
|
||||
if (tp->skt != skt)
|
||||
ND_PRINT((ndo, " %d", tp->skt));
|
||||
|
||||
/* if the address doesn't match the src address, it's an anomaly */
|
||||
if (EXTRACT_16BITS(&tp->net) != snet || tp->node != snode)
|
||||
ND_PRINT((ndo, " [addr=%s]",
|
||||
ataddr_string(ndo, EXTRACT_16BITS(&tp->net), tp->node)));
|
||||
|
||||
return (tpn);
|
||||
}
|
||||
|
||||
static const struct atNBPtuple *
|
||||
nbp_name_print(netdissect_options *ndo,
|
||||
const struct atNBPtuple *tp, register const u_char *ep)
|
||||
{
|
||||
register const char *cp = (const char *)tp + nbpTupleSize;
|
||||
|
||||
ND_PRINT((ndo, " "));
|
||||
|
||||
/* Object */
|
||||
ND_PRINT((ndo, "\""));
|
||||
if ((cp = print_cstring(ndo, cp, ep)) != NULL) {
|
||||
/* Type */
|
||||
ND_PRINT((ndo, ":"));
|
||||
if ((cp = print_cstring(ndo, cp, ep)) != NULL) {
|
||||
/* Zone */
|
||||
ND_PRINT((ndo, "@"));
|
||||
if ((cp = print_cstring(ndo, cp, ep)) != NULL)
|
||||
ND_PRINT((ndo, "\""));
|
||||
}
|
||||
}
|
||||
return ((const struct atNBPtuple *)cp);
|
||||
}
|
||||
|
||||
|
||||
#define HASHNAMESIZE 4096
|
||||
|
||||
struct hnamemem {
|
||||
int addr;
|
||||
char *name;
|
||||
struct hnamemem *nxt;
|
||||
};
|
||||
|
||||
static struct hnamemem hnametable[HASHNAMESIZE];
|
||||
|
||||
static const char *
|
||||
ataddr_string(netdissect_options *ndo,
|
||||
u_short atnet, u_char athost)
|
||||
{
|
||||
register struct hnamemem *tp, *tp2;
|
||||
register int i = (atnet << 8) | athost;
|
||||
char nambuf[256+1];
|
||||
static int first = 1;
|
||||
FILE *fp;
|
||||
|
||||
/*
|
||||
* if this is the first call, see if there's an AppleTalk
|
||||
* number to name map file.
|
||||
*/
|
||||
if (first && (first = 0, !ndo->ndo_nflag)
|
||||
&& (fp = fopen("/etc/atalk.names", "r"))) {
|
||||
char line[256];
|
||||
int i1, i2;
|
||||
|
||||
while (fgets(line, sizeof(line), fp)) {
|
||||
if (line[0] == '\n' || line[0] == 0 || line[0] == '#')
|
||||
continue;
|
||||
if (sscanf(line, "%d.%d %256s", &i1, &i2, nambuf) == 3)
|
||||
/* got a hostname. */
|
||||
i2 |= (i1 << 8);
|
||||
else if (sscanf(line, "%d %256s", &i1, nambuf) == 2)
|
||||
/* got a net name */
|
||||
i2 = (i1 << 8) | 255;
|
||||
else
|
||||
continue;
|
||||
|
||||
for (tp = &hnametable[i2 & (HASHNAMESIZE-1)];
|
||||
tp->nxt; tp = tp->nxt)
|
||||
;
|
||||
tp->addr = i2;
|
||||
tp->nxt = newhnamemem(ndo);
|
||||
tp->name = strdup(nambuf);
|
||||
if (tp->name == NULL)
|
||||
(*ndo->ndo_error)(ndo,
|
||||
"ataddr_string: strdup(nambuf)");
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
for (tp = &hnametable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt)
|
||||
if (tp->addr == i)
|
||||
return (tp->name);
|
||||
|
||||
/* didn't have the node name -- see if we've got the net name */
|
||||
i |= 255;
|
||||
for (tp2 = &hnametable[i & (HASHNAMESIZE-1)]; tp2->nxt; tp2 = tp2->nxt)
|
||||
if (tp2->addr == i) {
|
||||
tp->addr = (atnet << 8) | athost;
|
||||
tp->nxt = newhnamemem(ndo);
|
||||
(void)snprintf(nambuf, sizeof(nambuf), "%s.%d",
|
||||
tp2->name, athost);
|
||||
tp->name = strdup(nambuf);
|
||||
if (tp->name == NULL)
|
||||
(*ndo->ndo_error)(ndo,
|
||||
"ataddr_string: strdup(nambuf)");
|
||||
return (tp->name);
|
||||
}
|
||||
|
||||
tp->addr = (atnet << 8) | athost;
|
||||
tp->nxt = newhnamemem(ndo);
|
||||
if (athost != 255)
|
||||
(void)snprintf(nambuf, sizeof(nambuf), "%d.%d", atnet, athost);
|
||||
else
|
||||
(void)snprintf(nambuf, sizeof(nambuf), "%d", atnet);
|
||||
tp->name = strdup(nambuf);
|
||||
if (tp->name == NULL)
|
||||
(*ndo->ndo_error)(ndo, "ataddr_string: strdup(nambuf)");
|
||||
|
||||
return (tp->name);
|
||||
}
|
||||
|
||||
static const struct tok skt2str[] = {
|
||||
{ rtmpSkt, "rtmp" }, /* routing table maintenance */
|
||||
{ nbpSkt, "nis" }, /* name info socket */
|
||||
{ echoSkt, "echo" }, /* AppleTalk echo protocol */
|
||||
{ zipSkt, "zip" }, /* zone info protocol */
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static const char *
|
||||
ddpskt_string(netdissect_options *ndo,
|
||||
register int skt)
|
||||
{
|
||||
static char buf[8];
|
||||
|
||||
if (ndo->ndo_nflag) {
|
||||
(void)snprintf(buf, sizeof(buf), "%d", skt);
|
||||
return (buf);
|
||||
}
|
||||
return (tok2str(skt2str, "%d", skt));
|
||||
}
|
||||
547
print-atm.c
Normal file
547
print-atm.c
Normal file
@@ -0,0 +1,547 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <netdissect-stdinc.h>
|
||||
|
||||
#include "netdissect.h"
|
||||
#include "extract.h"
|
||||
#include "addrtoname.h"
|
||||
#include "atm.h"
|
||||
#include "llc.h"
|
||||
|
||||
/* start of the original atmuni31.h */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 Yen Yen Lim and North Dakota State University
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Yen Yen Lim and
|
||||
North Dakota State University
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* Based on UNI3.1 standard by ATM Forum */
|
||||
|
||||
/* ATM traffic types based on VPI=0 and (the following VCI */
|
||||
#define VCI_PPC 0x05 /* Point-to-point signal msg */
|
||||
#define VCI_BCC 0x02 /* Broadcast signal msg */
|
||||
#define VCI_OAMF4SC 0x03 /* Segment OAM F4 flow cell */
|
||||
#define VCI_OAMF4EC 0x04 /* End-to-end OAM F4 flow cell */
|
||||
#define VCI_METAC 0x01 /* Meta signal msg */
|
||||
#define VCI_ILMIC 0x10 /* ILMI msg */
|
||||
|
||||
/* Q.2931 signalling messages */
|
||||
#define CALL_PROCEED 0x02 /* call proceeding */
|
||||
#define CONNECT 0x07 /* connect */
|
||||
#define CONNECT_ACK 0x0f /* connect_ack */
|
||||
#define SETUP 0x05 /* setup */
|
||||
#define RELEASE 0x4d /* release */
|
||||
#define RELEASE_DONE 0x5a /* release_done */
|
||||
#define RESTART 0x46 /* restart */
|
||||
#define RESTART_ACK 0x4e /* restart ack */
|
||||
#define STATUS 0x7d /* status */
|
||||
#define STATUS_ENQ 0x75 /* status ack */
|
||||
#define ADD_PARTY 0x80 /* add party */
|
||||
#define ADD_PARTY_ACK 0x81 /* add party ack */
|
||||
#define ADD_PARTY_REJ 0x82 /* add party rej */
|
||||
#define DROP_PARTY 0x83 /* drop party */
|
||||
#define DROP_PARTY_ACK 0x84 /* drop party ack */
|
||||
|
||||
/* Information Element Parameters in the signalling messages */
|
||||
#define CAUSE 0x08 /* cause */
|
||||
#define ENDPT_REF 0x54 /* endpoint reference */
|
||||
#define AAL_PARA 0x58 /* ATM adaptation layer parameters */
|
||||
#define TRAFF_DESCRIP 0x59 /* atm traffic descriptors */
|
||||
#define CONNECT_ID 0x5a /* connection identifier */
|
||||
#define QOS_PARA 0x5c /* quality of service parameters */
|
||||
#define B_HIGHER 0x5d /* broadband higher layer information */
|
||||
#define B_BEARER 0x5e /* broadband bearer capability */
|
||||
#define B_LOWER 0x5f /* broadband lower information */
|
||||
#define CALLING_PARTY 0x6c /* calling party number */
|
||||
#define CALLED_PARTY 0x70 /* called party nmber */
|
||||
|
||||
#define Q2931 0x09
|
||||
|
||||
/* Q.2931 signalling general messages format */
|
||||
#define PROTO_POS 0 /* offset of protocol discriminator */
|
||||
#define CALL_REF_POS 2 /* offset of call reference value */
|
||||
#define MSG_TYPE_POS 5 /* offset of message type */
|
||||
#define MSG_LEN_POS 7 /* offset of mesage length */
|
||||
#define IE_BEGIN_POS 9 /* offset of first information element */
|
||||
|
||||
/* format of signalling messages */
|
||||
#define TYPE_POS 0
|
||||
#define LEN_POS 2
|
||||
#define FIELD_BEGIN_POS 4
|
||||
|
||||
/* end of the original atmuni31.h */
|
||||
|
||||
static const char tstr[] = "[|atm]";
|
||||
|
||||
#define OAM_CRC10_MASK 0x3ff
|
||||
#define OAM_PAYLOAD_LEN 48
|
||||
#define OAM_FUNCTION_SPECIFIC_LEN 45 /* this excludes crc10 and cell-type/function-type */
|
||||
#define OAM_CELLTYPE_FUNCTYPE_LEN 1
|
||||
|
||||
static const struct tok oam_f_values[] = {
|
||||
{ VCI_OAMF4SC, "OAM F4 (segment)" },
|
||||
{ VCI_OAMF4EC, "OAM F4 (end)" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static const struct tok atm_pty_values[] = {
|
||||
{ 0x0, "user data, uncongested, SDU 0" },
|
||||
{ 0x1, "user data, uncongested, SDU 1" },
|
||||
{ 0x2, "user data, congested, SDU 0" },
|
||||
{ 0x3, "user data, congested, SDU 1" },
|
||||
{ 0x4, "VCC OAM F5 flow segment" },
|
||||
{ 0x5, "VCC OAM F5 flow end-to-end" },
|
||||
{ 0x6, "Traffic Control and resource Mgmt" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
#define OAM_CELLTYPE_FM 0x1
|
||||
#define OAM_CELLTYPE_PM 0x2
|
||||
#define OAM_CELLTYPE_AD 0x8
|
||||
#define OAM_CELLTYPE_SM 0xf
|
||||
|
||||
static const struct tok oam_celltype_values[] = {
|
||||
{ OAM_CELLTYPE_FM, "Fault Management" },
|
||||
{ OAM_CELLTYPE_PM, "Performance Management" },
|
||||
{ OAM_CELLTYPE_AD, "activate/deactivate" },
|
||||
{ OAM_CELLTYPE_SM, "System Management" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
#define OAM_FM_FUNCTYPE_AIS 0x0
|
||||
#define OAM_FM_FUNCTYPE_RDI 0x1
|
||||
#define OAM_FM_FUNCTYPE_CONTCHECK 0x4
|
||||
#define OAM_FM_FUNCTYPE_LOOPBACK 0x8
|
||||
|
||||
static const struct tok oam_fm_functype_values[] = {
|
||||
{ OAM_FM_FUNCTYPE_AIS, "AIS" },
|
||||
{ OAM_FM_FUNCTYPE_RDI, "RDI" },
|
||||
{ OAM_FM_FUNCTYPE_CONTCHECK, "Continuity Check" },
|
||||
{ OAM_FM_FUNCTYPE_LOOPBACK, "Loopback" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static const struct tok oam_pm_functype_values[] = {
|
||||
{ 0x0, "Forward Monitoring" },
|
||||
{ 0x1, "Backward Reporting" },
|
||||
{ 0x2, "Monitoring and Reporting" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static const struct tok oam_ad_functype_values[] = {
|
||||
{ 0x0, "Performance Monitoring" },
|
||||
{ 0x1, "Continuity Check" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
#define OAM_FM_LOOPBACK_INDICATOR_MASK 0x1
|
||||
|
||||
static const struct tok oam_fm_loopback_indicator_values[] = {
|
||||
{ 0x0, "Reply" },
|
||||
{ 0x1, "Request" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static const struct tok *oam_functype_values[16] = {
|
||||
NULL,
|
||||
oam_fm_functype_values, /* 1 */
|
||||
oam_pm_functype_values, /* 2 */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
oam_ad_functype_values, /* 8 */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
/*
|
||||
* Print an RFC 1483 LLC-encapsulated ATM frame.
|
||||
*/
|
||||
static u_int
|
||||
atm_llc_print(netdissect_options *ndo,
|
||||
const u_char *p, int length, int caplen)
|
||||
{
|
||||
int llc_hdrlen;
|
||||
|
||||
llc_hdrlen = llc_print(ndo, p, length, caplen, NULL, NULL);
|
||||
if (llc_hdrlen < 0) {
|
||||
/* packet not known, print raw packet */
|
||||
if (!ndo->ndo_suppress_default_print)
|
||||
ND_DEFAULTPRINT(p, caplen);
|
||||
llc_hdrlen = -llc_hdrlen;
|
||||
}
|
||||
return (llc_hdrlen);
|
||||
}
|
||||
|
||||
/*
|
||||
* Given a SAP value, generate the LLC header value for a UI packet
|
||||
* with that SAP as the source and destination SAP.
|
||||
*/
|
||||
#define LLC_UI_HDR(sap) ((sap)<<16 | (sap<<8) | 0x03)
|
||||
|
||||
/*
|
||||
* This is the top level routine of the printer. 'p' points
|
||||
* to the LLC/SNAP header of the packet, 'h->ts' is the timestamp,
|
||||
* 'h->len' is the length of the packet off the wire, and 'h->caplen'
|
||||
* is the number of bytes actually captured.
|
||||
*/
|
||||
u_int
|
||||
atm_if_print(netdissect_options *ndo,
|
||||
const struct pcap_pkthdr *h, const u_char *p)
|
||||
{
|
||||
u_int caplen = h->caplen;
|
||||
u_int length = h->len;
|
||||
uint32_t llchdr;
|
||||
u_int hdrlen = 0;
|
||||
|
||||
if (caplen < 1 || length < 1) {
|
||||
ND_PRINT((ndo, "%s", tstr));
|
||||
return (caplen);
|
||||
}
|
||||
|
||||
/* Cisco Style NLPID ? */
|
||||
if (*p == LLC_UI) {
|
||||
if (ndo->ndo_eflag)
|
||||
ND_PRINT((ndo, "CNLPID "));
|
||||
isoclns_print(ndo, p + 1, length - 1, caplen - 1);
|
||||
return hdrlen;
|
||||
}
|
||||
|
||||
/*
|
||||
* Must have at least a DSAP, an SSAP, and the first byte of the
|
||||
* control field.
|
||||
*/
|
||||
if (caplen < 3 || length < 3) {
|
||||
ND_PRINT((ndo, "%s", tstr));
|
||||
return (caplen);
|
||||
}
|
||||
|
||||
/*
|
||||
* Extract the presumed LLC header into a variable, for quick
|
||||
* testing.
|
||||
* Then check for a header that's neither a header for a SNAP
|
||||
* packet nor an RFC 2684 routed NLPID-formatted PDU nor
|
||||
* an 802.2-but-no-SNAP IP packet.
|
||||
*/
|
||||
llchdr = EXTRACT_24BITS(p);
|
||||
if (llchdr != LLC_UI_HDR(LLCSAP_SNAP) &&
|
||||
llchdr != LLC_UI_HDR(LLCSAP_ISONS) &&
|
||||
llchdr != LLC_UI_HDR(LLCSAP_IP)) {
|
||||
/*
|
||||
* XXX - assume 802.6 MAC header from Fore driver.
|
||||
*
|
||||
* Unfortunately, the above list doesn't check for
|
||||
* all known SAPs, doesn't check for headers where
|
||||
* the source and destination SAP aren't the same,
|
||||
* and doesn't check for non-UI frames. It also
|
||||
* runs the risk of an 802.6 MAC header that happens
|
||||
* to begin with one of those values being
|
||||
* incorrectly treated as an 802.2 header.
|
||||
*
|
||||
* So is that Fore driver still around? And, if so,
|
||||
* is it still putting 802.6 MAC headers on ATM
|
||||
* packets? If so, could it be changed to use a
|
||||
* new DLT_IEEE802_6 value if we added it?
|
||||
*/
|
||||
if (caplen < 20 || length < 20) {
|
||||
ND_PRINT((ndo, "%s", tstr));
|
||||
return (caplen);
|
||||
}
|
||||
if (ndo->ndo_eflag)
|
||||
ND_PRINT((ndo, "%08x%08x %08x%08x ",
|
||||
EXTRACT_32BITS(p),
|
||||
EXTRACT_32BITS(p+4),
|
||||
EXTRACT_32BITS(p+8),
|
||||
EXTRACT_32BITS(p+12)));
|
||||
p += 20;
|
||||
length -= 20;
|
||||
caplen -= 20;
|
||||
hdrlen += 20;
|
||||
}
|
||||
hdrlen += atm_llc_print(ndo, p, length, caplen);
|
||||
return (hdrlen);
|
||||
}
|
||||
|
||||
/*
|
||||
* ATM signalling.
|
||||
*/
|
||||
static const struct tok msgtype2str[] = {
|
||||
{ CALL_PROCEED, "Call_proceeding" },
|
||||
{ CONNECT, "Connect" },
|
||||
{ CONNECT_ACK, "Connect_ack" },
|
||||
{ SETUP, "Setup" },
|
||||
{ RELEASE, "Release" },
|
||||
{ RELEASE_DONE, "Release_complete" },
|
||||
{ RESTART, "Restart" },
|
||||
{ RESTART_ACK, "Restart_ack" },
|
||||
{ STATUS, "Status" },
|
||||
{ STATUS_ENQ, "Status_enquiry" },
|
||||
{ ADD_PARTY, "Add_party" },
|
||||
{ ADD_PARTY_ACK, "Add_party_ack" },
|
||||
{ ADD_PARTY_REJ, "Add_party_reject" },
|
||||
{ DROP_PARTY, "Drop_party" },
|
||||
{ DROP_PARTY_ACK, "Drop_party_ack" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static void
|
||||
sig_print(netdissect_options *ndo,
|
||||
const u_char *p, int caplen)
|
||||
{
|
||||
uint32_t call_ref;
|
||||
|
||||
if (caplen < PROTO_POS) {
|
||||
ND_PRINT((ndo, "%s", tstr));
|
||||
return;
|
||||
}
|
||||
if (p[PROTO_POS] == Q2931) {
|
||||
/*
|
||||
* protocol:Q.2931 for User to Network Interface
|
||||
* (UNI 3.1) signalling
|
||||
*/
|
||||
ND_PRINT((ndo, "Q.2931"));
|
||||
if (caplen < MSG_TYPE_POS) {
|
||||
ND_PRINT((ndo, " %s", tstr));
|
||||
return;
|
||||
}
|
||||
ND_PRINT((ndo, ":%s ",
|
||||
tok2str(msgtype2str, "msgtype#%d", p[MSG_TYPE_POS])));
|
||||
|
||||
/*
|
||||
* The call reference comes before the message type,
|
||||
* so if we know we have the message type, which we
|
||||
* do from the caplen test above, we also know we have
|
||||
* the call reference.
|
||||
*/
|
||||
call_ref = EXTRACT_24BITS(&p[CALL_REF_POS]);
|
||||
ND_PRINT((ndo, "CALL_REF:0x%06x", call_ref));
|
||||
} else {
|
||||
/* SCCOP with some unknown protocol atop it */
|
||||
ND_PRINT((ndo, "SSCOP, proto %d ", p[PROTO_POS]));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Print an ATM PDU (such as an AAL5 PDU).
|
||||
*/
|
||||
void
|
||||
atm_print(netdissect_options *ndo,
|
||||
u_int vpi, u_int vci, u_int traftype, const u_char *p, u_int length,
|
||||
u_int caplen)
|
||||
{
|
||||
if (ndo->ndo_eflag)
|
||||
ND_PRINT((ndo, "VPI:%u VCI:%u ", vpi, vci));
|
||||
|
||||
if (vpi == 0) {
|
||||
switch (vci) {
|
||||
|
||||
case VCI_PPC:
|
||||
sig_print(ndo, p, caplen);
|
||||
return;
|
||||
|
||||
case VCI_BCC:
|
||||
ND_PRINT((ndo, "broadcast sig: "));
|
||||
return;
|
||||
|
||||
case VCI_OAMF4SC: /* fall through */
|
||||
case VCI_OAMF4EC:
|
||||
oam_print(ndo, p, length, ATM_OAM_HEC);
|
||||
return;
|
||||
|
||||
case VCI_METAC:
|
||||
ND_PRINT((ndo, "meta: "));
|
||||
return;
|
||||
|
||||
case VCI_ILMIC:
|
||||
ND_PRINT((ndo, "ilmi: "));
|
||||
snmp_print(ndo, p, length);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
switch (traftype) {
|
||||
|
||||
case ATM_LLC:
|
||||
default:
|
||||
/*
|
||||
* Assumes traffic is LLC if unknown.
|
||||
*/
|
||||
atm_llc_print(ndo, p, length, caplen);
|
||||
break;
|
||||
|
||||
case ATM_LANE:
|
||||
lane_print(ndo, p, length, caplen);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
struct oam_fm_loopback_t {
|
||||
uint8_t loopback_indicator;
|
||||
uint8_t correlation_tag[4];
|
||||
uint8_t loopback_id[12];
|
||||
uint8_t source_id[12];
|
||||
uint8_t unused[16];
|
||||
};
|
||||
|
||||
struct oam_fm_ais_rdi_t {
|
||||
uint8_t failure_type;
|
||||
uint8_t failure_location[16];
|
||||
uint8_t unused[28];
|
||||
};
|
||||
|
||||
int
|
||||
oam_print (netdissect_options *ndo,
|
||||
const u_char *p, u_int length, u_int hec)
|
||||
{
|
||||
uint32_t cell_header;
|
||||
uint16_t vpi, vci, cksum, cksum_shouldbe, idx;
|
||||
uint8_t cell_type, func_type, payload, clp;
|
||||
|
||||
union {
|
||||
const struct oam_fm_loopback_t *oam_fm_loopback;
|
||||
const struct oam_fm_ais_rdi_t *oam_fm_ais_rdi;
|
||||
} oam_ptr;
|
||||
|
||||
|
||||
cell_header = EXTRACT_32BITS(p+hec);
|
||||
cell_type = ((*(p+ATM_HDR_LEN_NOHEC+hec))>>4) & 0x0f;
|
||||
func_type = (*(p+ATM_HDR_LEN_NOHEC+hec)) & 0x0f;
|
||||
|
||||
vpi = (cell_header>>20)&0xff;
|
||||
vci = (cell_header>>4)&0xffff;
|
||||
payload = (cell_header>>1)&0x7;
|
||||
clp = cell_header&0x1;
|
||||
|
||||
ND_PRINT((ndo, "%s, vpi %u, vci %u, payload [ %s ], clp %u, length %u",
|
||||
tok2str(oam_f_values, "OAM F5", vci),
|
||||
vpi, vci,
|
||||
tok2str(atm_pty_values, "Unknown", payload),
|
||||
clp, length));
|
||||
|
||||
if (!ndo->ndo_vflag) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
ND_PRINT((ndo, "\n\tcell-type %s (%u)",
|
||||
tok2str(oam_celltype_values, "unknown", cell_type),
|
||||
cell_type));
|
||||
|
||||
if (oam_functype_values[cell_type] == NULL)
|
||||
ND_PRINT((ndo, ", func-type unknown (%u)", func_type));
|
||||
else
|
||||
ND_PRINT((ndo, ", func-type %s (%u)",
|
||||
tok2str(oam_functype_values[cell_type],"none",func_type),
|
||||
func_type));
|
||||
|
||||
p += ATM_HDR_LEN_NOHEC + hec;
|
||||
|
||||
switch (cell_type << 4 | func_type) {
|
||||
case (OAM_CELLTYPE_FM << 4 | OAM_FM_FUNCTYPE_LOOPBACK):
|
||||
oam_ptr.oam_fm_loopback = (const struct oam_fm_loopback_t *)(p + OAM_CELLTYPE_FUNCTYPE_LEN);
|
||||
ND_PRINT((ndo, "\n\tLoopback-Indicator %s, Correlation-Tag 0x%08x",
|
||||
tok2str(oam_fm_loopback_indicator_values,
|
||||
"Unknown",
|
||||
oam_ptr.oam_fm_loopback->loopback_indicator & OAM_FM_LOOPBACK_INDICATOR_MASK),
|
||||
EXTRACT_32BITS(&oam_ptr.oam_fm_loopback->correlation_tag)));
|
||||
ND_PRINT((ndo, "\n\tLocation-ID "));
|
||||
for (idx = 0; idx < sizeof(oam_ptr.oam_fm_loopback->loopback_id); idx++) {
|
||||
if (idx % 2) {
|
||||
ND_PRINT((ndo, "%04x ", EXTRACT_16BITS(&oam_ptr.oam_fm_loopback->loopback_id[idx])));
|
||||
}
|
||||
}
|
||||
ND_PRINT((ndo, "\n\tSource-ID "));
|
||||
for (idx = 0; idx < sizeof(oam_ptr.oam_fm_loopback->source_id); idx++) {
|
||||
if (idx % 2) {
|
||||
ND_PRINT((ndo, "%04x ", EXTRACT_16BITS(&oam_ptr.oam_fm_loopback->source_id[idx])));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case (OAM_CELLTYPE_FM << 4 | OAM_FM_FUNCTYPE_AIS):
|
||||
case (OAM_CELLTYPE_FM << 4 | OAM_FM_FUNCTYPE_RDI):
|
||||
oam_ptr.oam_fm_ais_rdi = (const struct oam_fm_ais_rdi_t *)(p + OAM_CELLTYPE_FUNCTYPE_LEN);
|
||||
ND_PRINT((ndo, "\n\tFailure-type 0x%02x", oam_ptr.oam_fm_ais_rdi->failure_type));
|
||||
ND_PRINT((ndo, "\n\tLocation-ID "));
|
||||
for (idx = 0; idx < sizeof(oam_ptr.oam_fm_ais_rdi->failure_location); idx++) {
|
||||
if (idx % 2) {
|
||||
ND_PRINT((ndo, "%04x ", EXTRACT_16BITS(&oam_ptr.oam_fm_ais_rdi->failure_location[idx])));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case (OAM_CELLTYPE_FM << 4 | OAM_FM_FUNCTYPE_CONTCHECK):
|
||||
/* FIXME */
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* crc10 checksum verification */
|
||||
cksum = EXTRACT_16BITS(p + OAM_CELLTYPE_FUNCTYPE_LEN + OAM_FUNCTION_SPECIFIC_LEN)
|
||||
& OAM_CRC10_MASK;
|
||||
cksum_shouldbe = verify_crc10_cksum(0, p, OAM_PAYLOAD_LEN);
|
||||
|
||||
ND_PRINT((ndo, "\n\tcksum 0x%03x (%scorrect)",
|
||||
cksum,
|
||||
cksum_shouldbe == 0 ? "" : "in"));
|
||||
|
||||
return 1;
|
||||
}
|
||||
715
print-babel.c
Normal file
715
print-babel.c
Normal file
@@ -0,0 +1,715 @@
|
||||
/*
|
||||
* Copyright (c) 2007-2011 Grégoire Henry, Juliusz Chroboczek
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <netdissect-stdinc.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "netdissect.h"
|
||||
#include "addrtoname.h"
|
||||
#include "extract.h"
|
||||
|
||||
static const char tstr[] = "[|babel]";
|
||||
|
||||
static void babel_print_v2(netdissect_options *, const u_char *cp, u_int length);
|
||||
|
||||
void
|
||||
babel_print(netdissect_options *ndo,
|
||||
const u_char *cp, u_int length)
|
||||
{
|
||||
ND_PRINT((ndo, "babel"));
|
||||
|
||||
ND_TCHECK2(*cp, 4);
|
||||
|
||||
if(cp[0] != 42) {
|
||||
ND_PRINT((ndo, " invalid header"));
|
||||
return;
|
||||
} else {
|
||||
ND_PRINT((ndo, " %d", cp[1]));
|
||||
}
|
||||
|
||||
switch(cp[1]) {
|
||||
case 2:
|
||||
babel_print_v2(ndo, cp, length);
|
||||
break;
|
||||
default:
|
||||
ND_PRINT((ndo, " unknown version"));
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
trunc:
|
||||
ND_PRINT((ndo, " %s", tstr));
|
||||
return;
|
||||
}
|
||||
|
||||
/* TLVs */
|
||||
#define MESSAGE_PAD1 0
|
||||
#define MESSAGE_PADN 1
|
||||
#define MESSAGE_ACK_REQ 2
|
||||
#define MESSAGE_ACK 3
|
||||
#define MESSAGE_HELLO 4
|
||||
#define MESSAGE_IHU 5
|
||||
#define MESSAGE_ROUTER_ID 6
|
||||
#define MESSAGE_NH 7
|
||||
#define MESSAGE_UPDATE 8
|
||||
#define MESSAGE_REQUEST 9
|
||||
#define MESSAGE_MH_REQUEST 10
|
||||
#define MESSAGE_TSPC 11
|
||||
#define MESSAGE_HMAC 12
|
||||
#define MESSAGE_UPDATE_SRC_SPECIFIC 13
|
||||
#define MESSAGE_REQUEST_SRC_SPECIFIC 14
|
||||
#define MESSAGE_MH_REQUEST_SRC_SPECIFIC 15
|
||||
|
||||
/* sub-TLVs */
|
||||
#define MESSAGE_SUB_PAD1 0
|
||||
#define MESSAGE_SUB_PADN 1
|
||||
#define MESSAGE_SUB_DIVERSITY 2
|
||||
#define MESSAGE_SUB_TIMESTAMP 3
|
||||
|
||||
/* Diversity sub-TLV channel codes */
|
||||
static const struct tok diversity_str[] = {
|
||||
{ 0, "reserved" },
|
||||
{ 255, "all" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static const char *
|
||||
format_id(const u_char *id)
|
||||
{
|
||||
static char buf[25];
|
||||
snprintf(buf, 25, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
|
||||
id[0], id[1], id[2], id[3], id[4], id[5], id[6], id[7]);
|
||||
buf[24] = '\0';
|
||||
return buf;
|
||||
}
|
||||
|
||||
static const unsigned char v4prefix[16] =
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 0 };
|
||||
|
||||
static const char *
|
||||
format_prefix(netdissect_options *ndo, const u_char *prefix, unsigned char plen)
|
||||
{
|
||||
static char buf[50];
|
||||
if(plen >= 96 && memcmp(prefix, v4prefix, 12) == 0)
|
||||
snprintf(buf, 50, "%s/%u", ipaddr_string(ndo, prefix + 12), plen - 96);
|
||||
else
|
||||
snprintf(buf, 50, "%s/%u", ip6addr_string(ndo, prefix), plen);
|
||||
buf[49] = '\0';
|
||||
return buf;
|
||||
}
|
||||
|
||||
static const char *
|
||||
format_address(netdissect_options *ndo, const u_char *prefix)
|
||||
{
|
||||
if(memcmp(prefix, v4prefix, 12) == 0)
|
||||
return ipaddr_string(ndo, prefix + 12);
|
||||
else
|
||||
return ip6addr_string(ndo, prefix);
|
||||
}
|
||||
|
||||
static const char *
|
||||
format_interval(const uint16_t i)
|
||||
{
|
||||
static char buf[sizeof("000.00s")];
|
||||
|
||||
if (i == 0)
|
||||
return "0.0s (bogus)";
|
||||
snprintf(buf, sizeof(buf), "%u.%02us", i / 100, i % 100);
|
||||
return buf;
|
||||
}
|
||||
|
||||
static const char *
|
||||
format_interval_update(const uint16_t i)
|
||||
{
|
||||
return i == 0xFFFF ? "infinity" : format_interval(i);
|
||||
}
|
||||
|
||||
static const char *
|
||||
format_timestamp(const uint32_t i)
|
||||
{
|
||||
static char buf[sizeof("0000.000000s")];
|
||||
snprintf(buf, sizeof(buf), "%u.%06us", i / 1000000, i % 1000000);
|
||||
return buf;
|
||||
}
|
||||
|
||||
/* Return number of octets consumed from the input buffer (not the prefix length
|
||||
* in bytes), or -1 for encoding error. */
|
||||
static int
|
||||
network_prefix(int ae, int plen, unsigned int omitted,
|
||||
const unsigned char *p, const unsigned char *dp,
|
||||
unsigned int len, unsigned char *p_r)
|
||||
{
|
||||
unsigned pb;
|
||||
unsigned char prefix[16];
|
||||
int consumed = 0;
|
||||
|
||||
if(plen >= 0)
|
||||
pb = (plen + 7) / 8;
|
||||
else if(ae == 1)
|
||||
pb = 4;
|
||||
else
|
||||
pb = 16;
|
||||
|
||||
if(pb > 16)
|
||||
return -1;
|
||||
|
||||
memset(prefix, 0, 16);
|
||||
|
||||
switch(ae) {
|
||||
case 0: break;
|
||||
case 1:
|
||||
if(omitted > 4 || pb > 4 || (pb > omitted && len < pb - omitted))
|
||||
return -1;
|
||||
memcpy(prefix, v4prefix, 12);
|
||||
if(omitted) {
|
||||
if (dp == NULL) return -1;
|
||||
memcpy(prefix, dp, 12 + omitted);
|
||||
}
|
||||
if(pb > omitted) {
|
||||
memcpy(prefix + 12 + omitted, p, pb - omitted);
|
||||
consumed = pb - omitted;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if(omitted > 16 || (pb > omitted && len < pb - omitted))
|
||||
return -1;
|
||||
if(omitted) {
|
||||
if (dp == NULL) return -1;
|
||||
memcpy(prefix, dp, omitted);
|
||||
}
|
||||
if(pb > omitted) {
|
||||
memcpy(prefix + omitted, p, pb - omitted);
|
||||
consumed = pb - omitted;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if(pb > 8 && len < pb - 8) return -1;
|
||||
prefix[0] = 0xfe;
|
||||
prefix[1] = 0x80;
|
||||
if(pb > 8) {
|
||||
memcpy(prefix + 8, p, pb - 8);
|
||||
consumed = pb - 8;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy(p_r, prefix, 16);
|
||||
return consumed;
|
||||
}
|
||||
|
||||
static int
|
||||
network_address(int ae, const unsigned char *a, unsigned int len,
|
||||
unsigned char *a_r)
|
||||
{
|
||||
return network_prefix(ae, -1, 0, a, NULL, len, a_r);
|
||||
}
|
||||
|
||||
/*
|
||||
* Sub-TLVs consume the "extra data" of Babel TLVs (see Section 4.3 of RFC6126),
|
||||
* their encoding is similar to the encoding of TLVs, but the type namespace is
|
||||
* different:
|
||||
*
|
||||
* o Type 0 stands for Pad1 sub-TLV with the same encoding as the Pad1 TLV.
|
||||
* o Type 1 stands for PadN sub-TLV with the same encoding as the PadN TLV.
|
||||
* o Type 2 stands for Diversity sub-TLV, which propagates diversity routing
|
||||
* data. Its body is a variable-length sequence of 8-bit unsigned integers,
|
||||
* each representing per-hop number of interferring radio channel for the
|
||||
* prefix. Channel 0 is invalid and must not be used in the sub-TLV, channel
|
||||
* 255 interferes with any other channel.
|
||||
* o Type 3 stands for Timestamp sub-TLV, used to compute RTT between
|
||||
* neighbours. In the case of a Hello TLV, the body stores a 32-bits
|
||||
* timestamp, while in the case of a IHU TLV, two 32-bits timestamps are
|
||||
* stored.
|
||||
*
|
||||
* Sub-TLV types 0 and 1 are valid for any TLV type, whether sub-TLV type 2 is
|
||||
* only valid for TLV type 8 (Update). Note that within an Update TLV a missing
|
||||
* Diversity sub-TLV is not the same as a Diversity sub-TLV with an empty body.
|
||||
* The former would mean a lack of any claims about the interference, and the
|
||||
* latter would state that interference is definitely absent.
|
||||
* A type 3 sub-TLV is valid both for Hello and IHU TLVs, though the exact
|
||||
* semantic of the sub-TLV is different in each case.
|
||||
*/
|
||||
static void
|
||||
subtlvs_print(netdissect_options *ndo,
|
||||
const u_char *cp, const u_char *ep, const uint8_t tlv_type)
|
||||
{
|
||||
uint8_t subtype, sublen;
|
||||
const char *sep;
|
||||
uint32_t t1, t2;
|
||||
|
||||
while (cp < ep) {
|
||||
subtype = *cp++;
|
||||
if(subtype == MESSAGE_SUB_PAD1) {
|
||||
ND_PRINT((ndo, " sub-pad1"));
|
||||
continue;
|
||||
}
|
||||
if(cp == ep)
|
||||
goto invalid;
|
||||
sublen = *cp++;
|
||||
if(cp + sublen > ep)
|
||||
goto invalid;
|
||||
|
||||
switch(subtype) {
|
||||
case MESSAGE_SUB_PADN:
|
||||
ND_PRINT((ndo, " sub-padn"));
|
||||
cp += sublen;
|
||||
break;
|
||||
case MESSAGE_SUB_DIVERSITY:
|
||||
ND_PRINT((ndo, " sub-diversity"));
|
||||
if (sublen == 0) {
|
||||
ND_PRINT((ndo, " empty"));
|
||||
break;
|
||||
}
|
||||
sep = " ";
|
||||
while(sublen--) {
|
||||
ND_PRINT((ndo, "%s%s", sep, tok2str(diversity_str, "%u", *cp++)));
|
||||
sep = "-";
|
||||
}
|
||||
if(tlv_type != MESSAGE_UPDATE &&
|
||||
tlv_type != MESSAGE_UPDATE_SRC_SPECIFIC)
|
||||
ND_PRINT((ndo, " (bogus)"));
|
||||
break;
|
||||
case MESSAGE_SUB_TIMESTAMP:
|
||||
ND_PRINT((ndo, " sub-timestamp"));
|
||||
if(tlv_type == MESSAGE_HELLO) {
|
||||
if(sublen < 4)
|
||||
goto invalid;
|
||||
t1 = EXTRACT_32BITS(cp);
|
||||
ND_PRINT((ndo, " %s", format_timestamp(t1)));
|
||||
} else if(tlv_type == MESSAGE_IHU) {
|
||||
if(sublen < 8)
|
||||
goto invalid;
|
||||
t1 = EXTRACT_32BITS(cp);
|
||||
ND_PRINT((ndo, " %s", format_timestamp(t1)));
|
||||
t2 = EXTRACT_32BITS(cp + 4);
|
||||
ND_PRINT((ndo, "|%s", format_timestamp(t2)));
|
||||
} else
|
||||
ND_PRINT((ndo, " (bogus)"));
|
||||
cp += sublen;
|
||||
break;
|
||||
default:
|
||||
ND_PRINT((ndo, " sub-unknown-0x%02x", subtype));
|
||||
cp += sublen;
|
||||
} /* switch */
|
||||
} /* while */
|
||||
return;
|
||||
|
||||
invalid:
|
||||
ND_PRINT((ndo, "%s", istr));
|
||||
}
|
||||
|
||||
#define ICHECK(i, l) \
|
||||
if ((i) + (l) > bodylen || (i) + (l) > length) goto invalid;
|
||||
|
||||
static void
|
||||
babel_print_v2(netdissect_options *ndo,
|
||||
const u_char *cp, u_int length)
|
||||
{
|
||||
u_int i;
|
||||
u_short bodylen;
|
||||
u_char v4_prefix[16] =
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 0 };
|
||||
u_char v6_prefix[16] = {0};
|
||||
|
||||
ND_TCHECK2(*cp, 4);
|
||||
if (length < 4)
|
||||
goto invalid;
|
||||
bodylen = EXTRACT_16BITS(cp + 2);
|
||||
ND_PRINT((ndo, " (%u)", bodylen));
|
||||
|
||||
/* Process the TLVs in the body */
|
||||
i = 0;
|
||||
while(i < bodylen) {
|
||||
const u_char *message;
|
||||
u_int type, len;
|
||||
|
||||
message = cp + 4 + i;
|
||||
|
||||
ND_TCHECK2(*message, 1);
|
||||
if((type = message[0]) == MESSAGE_PAD1) {
|
||||
ND_PRINT((ndo, ndo->ndo_vflag ? "\n\tPad 1" : " pad1"));
|
||||
i += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
ND_TCHECK2(*message, 2);
|
||||
ICHECK(i, 2);
|
||||
len = message[1];
|
||||
|
||||
ND_TCHECK2(*message, 2 + len);
|
||||
ICHECK(i, 2 + len);
|
||||
|
||||
switch(type) {
|
||||
case MESSAGE_PADN: {
|
||||
if (!ndo->ndo_vflag)
|
||||
ND_PRINT((ndo, " padN"));
|
||||
else
|
||||
ND_PRINT((ndo, "\n\tPad %d", len + 2));
|
||||
}
|
||||
break;
|
||||
|
||||
case MESSAGE_ACK_REQ: {
|
||||
u_short nonce, interval;
|
||||
if (!ndo->ndo_vflag)
|
||||
ND_PRINT((ndo, " ack-req"));
|
||||
else {
|
||||
ND_PRINT((ndo, "\n\tAcknowledgment Request "));
|
||||
if(len < 6) goto invalid;
|
||||
nonce = EXTRACT_16BITS(message + 4);
|
||||
interval = EXTRACT_16BITS(message + 6);
|
||||
ND_PRINT((ndo, "%04x %s", nonce, format_interval(interval)));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MESSAGE_ACK: {
|
||||
u_short nonce;
|
||||
if (!ndo->ndo_vflag)
|
||||
ND_PRINT((ndo, " ack"));
|
||||
else {
|
||||
ND_PRINT((ndo, "\n\tAcknowledgment "));
|
||||
if(len < 2) goto invalid;
|
||||
nonce = EXTRACT_16BITS(message + 2);
|
||||
ND_PRINT((ndo, "%04x", nonce));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MESSAGE_HELLO: {
|
||||
u_short seqno, interval;
|
||||
if (!ndo->ndo_vflag)
|
||||
ND_PRINT((ndo, " hello"));
|
||||
else {
|
||||
ND_PRINT((ndo, "\n\tHello "));
|
||||
if(len < 6) goto invalid;
|
||||
seqno = EXTRACT_16BITS(message + 4);
|
||||
interval = EXTRACT_16BITS(message + 6);
|
||||
ND_PRINT((ndo, "seqno %u interval %s", seqno, format_interval(interval)));
|
||||
/* Extra data. */
|
||||
if(len > 6)
|
||||
subtlvs_print(ndo, message + 8, message + 2 + len, type);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MESSAGE_IHU: {
|
||||
unsigned short txcost, interval;
|
||||
if (!ndo->ndo_vflag)
|
||||
ND_PRINT((ndo, " ihu"));
|
||||
else {
|
||||
u_char address[16];
|
||||
int rc;
|
||||
ND_PRINT((ndo, "\n\tIHU "));
|
||||
if(len < 6) goto invalid;
|
||||
txcost = EXTRACT_16BITS(message + 4);
|
||||
interval = EXTRACT_16BITS(message + 6);
|
||||
rc = network_address(message[2], message + 8, len - 6, address);
|
||||
if(rc < 0) { ND_PRINT((ndo, "%s", tstr)); break; }
|
||||
ND_PRINT((ndo, "%s txcost %u interval %s",
|
||||
format_address(ndo, address), txcost, format_interval(interval)));
|
||||
/* Extra data. */
|
||||
if((u_int)rc < len - 6)
|
||||
subtlvs_print(ndo, message + 8 + rc, message + 2 + len,
|
||||
type);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MESSAGE_ROUTER_ID: {
|
||||
if (!ndo->ndo_vflag)
|
||||
ND_PRINT((ndo, " router-id"));
|
||||
else {
|
||||
ND_PRINT((ndo, "\n\tRouter Id"));
|
||||
if(len < 10) goto invalid;
|
||||
ND_PRINT((ndo, " %s", format_id(message + 4)));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MESSAGE_NH: {
|
||||
if (!ndo->ndo_vflag)
|
||||
ND_PRINT((ndo, " nh"));
|
||||
else {
|
||||
int rc;
|
||||
u_char nh[16];
|
||||
ND_PRINT((ndo, "\n\tNext Hop"));
|
||||
if(len < 2) goto invalid;
|
||||
rc = network_address(message[2], message + 4, len - 2, nh);
|
||||
if(rc < 0) goto invalid;
|
||||
ND_PRINT((ndo, " %s", format_address(ndo, nh)));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MESSAGE_UPDATE: {
|
||||
if (!ndo->ndo_vflag) {
|
||||
ND_PRINT((ndo, " update"));
|
||||
if(len < 1)
|
||||
ND_PRINT((ndo, "/truncated"));
|
||||
else
|
||||
ND_PRINT((ndo, "%s%s%s",
|
||||
(message[3] & 0x80) ? "/prefix": "",
|
||||
(message[3] & 0x40) ? "/id" : "",
|
||||
(message[3] & 0x3f) ? "/unknown" : ""));
|
||||
} else {
|
||||
u_short interval, seqno, metric;
|
||||
u_char plen;
|
||||
int rc;
|
||||
u_char prefix[16];
|
||||
ND_PRINT((ndo, "\n\tUpdate"));
|
||||
if(len < 10) goto invalid;
|
||||
plen = message[4] + (message[2] == 1 ? 96 : 0);
|
||||
rc = network_prefix(message[2], message[4], message[5],
|
||||
message + 12,
|
||||
message[2] == 1 ? v4_prefix : v6_prefix,
|
||||
len - 10, prefix);
|
||||
if(rc < 0) goto invalid;
|
||||
interval = EXTRACT_16BITS(message + 6);
|
||||
seqno = EXTRACT_16BITS(message + 8);
|
||||
metric = EXTRACT_16BITS(message + 10);
|
||||
ND_PRINT((ndo, "%s%s%s %s metric %u seqno %u interval %s",
|
||||
(message[3] & 0x80) ? "/prefix": "",
|
||||
(message[3] & 0x40) ? "/id" : "",
|
||||
(message[3] & 0x3f) ? "/unknown" : "",
|
||||
format_prefix(ndo, prefix, plen),
|
||||
metric, seqno, format_interval_update(interval)));
|
||||
if(message[3] & 0x80) {
|
||||
if(message[2] == 1)
|
||||
memcpy(v4_prefix, prefix, 16);
|
||||
else
|
||||
memcpy(v6_prefix, prefix, 16);
|
||||
}
|
||||
/* extra data? */
|
||||
if((u_int)rc < len - 10)
|
||||
subtlvs_print(ndo, message + 12 + rc, message + 2 + len, type);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MESSAGE_REQUEST: {
|
||||
if (!ndo->ndo_vflag)
|
||||
ND_PRINT((ndo, " request"));
|
||||
else {
|
||||
int rc;
|
||||
u_char prefix[16], plen;
|
||||
ND_PRINT((ndo, "\n\tRequest "));
|
||||
if(len < 2) goto invalid;
|
||||
plen = message[3] + (message[2] == 1 ? 96 : 0);
|
||||
rc = network_prefix(message[2], message[3], 0,
|
||||
message + 4, NULL, len - 2, prefix);
|
||||
if(rc < 0) goto invalid;
|
||||
ND_PRINT((ndo, "for %s",
|
||||
message[2] == 0 ? "any" : format_prefix(ndo, prefix, plen)));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MESSAGE_MH_REQUEST : {
|
||||
if (!ndo->ndo_vflag)
|
||||
ND_PRINT((ndo, " mh-request"));
|
||||
else {
|
||||
int rc;
|
||||
u_short seqno;
|
||||
u_char prefix[16], plen;
|
||||
ND_PRINT((ndo, "\n\tMH-Request "));
|
||||
if(len < 14) goto invalid;
|
||||
seqno = EXTRACT_16BITS(message + 4);
|
||||
rc = network_prefix(message[2], message[3], 0,
|
||||
message + 16, NULL, len - 14, prefix);
|
||||
if(rc < 0) goto invalid;
|
||||
plen = message[3] + (message[2] == 1 ? 96 : 0);
|
||||
ND_PRINT((ndo, "(%u hops) for %s seqno %u id %s",
|
||||
message[6], format_prefix(ndo, prefix, plen),
|
||||
seqno, format_id(message + 8)));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MESSAGE_TSPC :
|
||||
if (!ndo->ndo_vflag)
|
||||
ND_PRINT((ndo, " tspc"));
|
||||
else {
|
||||
ND_PRINT((ndo, "\n\tTS/PC "));
|
||||
if(len < 6) goto invalid;
|
||||
ND_PRINT((ndo, "timestamp %u packetcounter %u", EXTRACT_32BITS (message + 4),
|
||||
EXTRACT_16BITS(message + 2)));
|
||||
}
|
||||
break;
|
||||
case MESSAGE_HMAC : {
|
||||
if (!ndo->ndo_vflag)
|
||||
ND_PRINT((ndo, " hmac"));
|
||||
else {
|
||||
unsigned j;
|
||||
ND_PRINT((ndo, "\n\tHMAC "));
|
||||
if(len < 18) goto invalid;
|
||||
ND_PRINT((ndo, "key-id %u digest-%u ", EXTRACT_16BITS(message + 2), len - 2));
|
||||
for (j = 0; j < len - 2; j++)
|
||||
ND_PRINT((ndo, "%02X", message[4 + j]));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MESSAGE_UPDATE_SRC_SPECIFIC : {
|
||||
if(!ndo->ndo_vflag) {
|
||||
ND_PRINT((ndo, " ss-update"));
|
||||
} else {
|
||||
u_char prefix[16], src_prefix[16];
|
||||
u_short interval, seqno, metric;
|
||||
u_char ae, plen, src_plen, omitted;
|
||||
int rc;
|
||||
int parsed_len = 10;
|
||||
ND_PRINT((ndo, "\n\tSS-Update"));
|
||||
if(len < 10) goto invalid;
|
||||
ae = message[2];
|
||||
src_plen = message[3];
|
||||
plen = message[4];
|
||||
omitted = message[5];
|
||||
interval = EXTRACT_16BITS(message + 6);
|
||||
seqno = EXTRACT_16BITS(message + 8);
|
||||
metric = EXTRACT_16BITS(message + 10);
|
||||
rc = network_prefix(ae, plen, omitted, message + 2 + parsed_len,
|
||||
ae == 1 ? v4_prefix : v6_prefix,
|
||||
len - parsed_len, prefix);
|
||||
if(rc < 0) goto invalid;
|
||||
if(ae == 1)
|
||||
plen += 96;
|
||||
parsed_len += rc;
|
||||
rc = network_prefix(ae, src_plen, 0, message + 2 + parsed_len,
|
||||
NULL, len - parsed_len, src_prefix);
|
||||
if(rc < 0) goto invalid;
|
||||
if(ae == 1)
|
||||
src_plen += 96;
|
||||
parsed_len += rc;
|
||||
|
||||
ND_PRINT((ndo, " %s from", format_prefix(ndo, prefix, plen)));
|
||||
ND_PRINT((ndo, " %s metric %u seqno %u interval %s",
|
||||
format_prefix(ndo, src_prefix, src_plen),
|
||||
metric, seqno, format_interval_update(interval)));
|
||||
/* extra data? */
|
||||
if((u_int)parsed_len < len)
|
||||
subtlvs_print(ndo, message + 2 + parsed_len,
|
||||
message + 2 + len, type);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MESSAGE_REQUEST_SRC_SPECIFIC : {
|
||||
if(!ndo->ndo_vflag)
|
||||
ND_PRINT((ndo, " ss-request"));
|
||||
else {
|
||||
int rc, parsed_len = 3;
|
||||
u_char ae, plen, src_plen, prefix[16], src_prefix[16];
|
||||
ND_PRINT((ndo, "\n\tSS-Request "));
|
||||
if(len < 3) goto invalid;
|
||||
ae = message[2];
|
||||
plen = message[3];
|
||||
src_plen = message[4];
|
||||
rc = network_prefix(ae, plen, 0, message + 2 + parsed_len,
|
||||
NULL, len - parsed_len, prefix);
|
||||
if(rc < 0) goto invalid;
|
||||
if(ae == 1)
|
||||
plen += 96;
|
||||
parsed_len += rc;
|
||||
rc = network_prefix(ae, src_plen, 0, message + 2 + parsed_len,
|
||||
NULL, len - parsed_len, src_prefix);
|
||||
if(rc < 0) goto invalid;
|
||||
if(ae == 1)
|
||||
src_plen += 96;
|
||||
parsed_len += rc;
|
||||
if(ae == 0) {
|
||||
ND_PRINT((ndo, "for any"));
|
||||
} else {
|
||||
ND_PRINT((ndo, "for (%s, ", format_prefix(ndo, prefix, plen)));
|
||||
ND_PRINT((ndo, "%s)", format_prefix(ndo, src_prefix, src_plen)));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MESSAGE_MH_REQUEST_SRC_SPECIFIC : {
|
||||
if(!ndo->ndo_vflag)
|
||||
ND_PRINT((ndo, " ss-mh-request"));
|
||||
else {
|
||||
int rc, parsed_len = 14;
|
||||
u_short seqno;
|
||||
u_char ae, plen, src_plen, prefix[16], src_prefix[16], hopc;
|
||||
const u_char *router_id = NULL;
|
||||
ND_PRINT((ndo, "\n\tSS-MH-Request "));
|
||||
if(len < 14) goto invalid;
|
||||
ae = message[2];
|
||||
plen = message[3];
|
||||
seqno = EXTRACT_16BITS(message + 4);
|
||||
hopc = message[6];
|
||||
src_plen = message[7];
|
||||
router_id = message + 8;
|
||||
rc = network_prefix(ae, plen, 0, message + 2 + parsed_len,
|
||||
NULL, len - parsed_len, prefix);
|
||||
if(rc < 0) goto invalid;
|
||||
if(ae == 1)
|
||||
plen += 96;
|
||||
parsed_len += rc;
|
||||
rc = network_prefix(ae, src_plen, 0, message + 2 + parsed_len,
|
||||
NULL, len - parsed_len, src_prefix);
|
||||
if(rc < 0) goto invalid;
|
||||
if(ae == 1)
|
||||
src_plen += 96;
|
||||
ND_PRINT((ndo, "(%u hops) for (%s, ",
|
||||
hopc, format_prefix(ndo, prefix, plen)));
|
||||
ND_PRINT((ndo, "%s) seqno %u id %s",
|
||||
format_prefix(ndo, src_prefix, src_plen),
|
||||
seqno, format_id(router_id)));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (!ndo->ndo_vflag)
|
||||
ND_PRINT((ndo, " unknown"));
|
||||
else
|
||||
ND_PRINT((ndo, "\n\tUnknown message type %d", type));
|
||||
}
|
||||
i += len + 2;
|
||||
}
|
||||
return;
|
||||
|
||||
trunc:
|
||||
ND_PRINT((ndo, " %s", tstr));
|
||||
return;
|
||||
|
||||
invalid:
|
||||
ND_PRINT((ndo, "%s", istr));
|
||||
return;
|
||||
}
|
||||
58
print-beep.c
Normal file
58
print-beep.c
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2000, Richard Sharpe
|
||||
*
|
||||
* This software may be distributed either under the terms of the
|
||||
* BSD-style license that accompanies tcpdump or under the GNU GPL
|
||||
* version 2 or later.
|
||||
*
|
||||
* print-beep.c
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <netdissect-stdinc.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "netdissect.h"
|
||||
|
||||
/* Check for a string but not go beyond length
|
||||
* Return TRUE on match, FALSE otherwise
|
||||
*
|
||||
* Looks at the first few chars up to tl1 ...
|
||||
*/
|
||||
|
||||
static int
|
||||
l_strnstart(const char *tstr1, u_int tl1, const char *str2, u_int l2)
|
||||
{
|
||||
|
||||
if (tl1 > l2)
|
||||
return 0;
|
||||
|
||||
return (strncmp(tstr1, str2, tl1) == 0 ? 1 : 0);
|
||||
}
|
||||
|
||||
void
|
||||
beep_print(netdissect_options *ndo, const u_char *bp, u_int length)
|
||||
{
|
||||
|
||||
if (l_strnstart("MSG", 4, (const char *)bp, length)) /* A REQuest */
|
||||
ND_PRINT((ndo, " BEEP MSG"));
|
||||
else if (l_strnstart("RPY ", 4, (const char *)bp, length))
|
||||
ND_PRINT((ndo, " BEEP RPY"));
|
||||
else if (l_strnstart("ERR ", 4, (const char *)bp, length))
|
||||
ND_PRINT((ndo, " BEEP ERR"));
|
||||
else if (l_strnstart("ANS ", 4, (const char *)bp, length))
|
||||
ND_PRINT((ndo, " BEEP ANS"));
|
||||
else if (l_strnstart("NUL ", 4, (const char *)bp, length))
|
||||
ND_PRINT((ndo, " BEEP NUL"));
|
||||
else if (l_strnstart("SEQ ", 4, (const char *)bp, length))
|
||||
ND_PRINT((ndo, " BEEP SEQ"));
|
||||
else if (l_strnstart("END", 4, (const char *)bp, length))
|
||||
ND_PRINT((ndo, " BEEP END"));
|
||||
else
|
||||
ND_PRINT((ndo, " BEEP (payload or undecoded)"));
|
||||
}
|
||||
281
print-bfd.c
Normal file
281
print-bfd.c
Normal file
@@ -0,0 +1,281 @@
|
||||
/*
|
||||
* 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, and (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.
|
||||
* 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.
|
||||
*
|
||||
* Original code by Hannes Gredler (hannes@juniper.net)
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <netdissect-stdinc.h>
|
||||
|
||||
#include "netdissect.h"
|
||||
#include "extract.h"
|
||||
|
||||
#include "udp.h"
|
||||
|
||||
/*
|
||||
* Control packet, BFDv0, draft-katz-ward-bfd-01.txt
|
||||
*
|
||||
* 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
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* |Vers | Diag |H|D|P|F| Rsvd | Detect Mult | Length |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | My Discriminator |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Your Discriminator |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Desired Min TX Interval |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Required Min RX Interval |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Required Min Echo RX Interval |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
*/
|
||||
|
||||
/*
|
||||
* Control packet, BFDv1, draft-ietf-bfd-base-02.txt
|
||||
*
|
||||
* 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
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* |Vers | Diag |Sta|P|F|C|A|D|R| Detect Mult | Length |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | My Discriminator |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Your Discriminator |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Desired Min TX Interval |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Required Min RX Interval |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Required Min Echo RX Interval |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
*/
|
||||
|
||||
struct bfd_header_t {
|
||||
uint8_t version_diag;
|
||||
uint8_t flags;
|
||||
uint8_t detect_time_multiplier;
|
||||
uint8_t length;
|
||||
uint8_t my_discriminator[4];
|
||||
uint8_t your_discriminator[4];
|
||||
uint8_t desired_min_tx_interval[4];
|
||||
uint8_t required_min_rx_interval[4];
|
||||
uint8_t required_min_echo_interval[4];
|
||||
};
|
||||
|
||||
/*
|
||||
* An optional Authentication Header may be present
|
||||
*
|
||||
* 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
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Auth Type | Auth Len | Authentication Data... |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
*/
|
||||
|
||||
struct bfd_auth_header_t {
|
||||
uint8_t auth_type;
|
||||
uint8_t auth_len;
|
||||
uint8_t auth_data;
|
||||
};
|
||||
|
||||
static const struct tok bfd_v1_authentication_values[] = {
|
||||
{ 0, "Reserved" },
|
||||
{ 1, "Simple Password" },
|
||||
{ 2, "Keyed MD5" },
|
||||
{ 3, "Meticulous Keyed MD5" },
|
||||
{ 4, "Keyed SHA1" },
|
||||
{ 5, "Meticulous Keyed SHA1" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
#define BFD_EXTRACT_VERSION(x) (((x)&0xe0)>>5)
|
||||
#define BFD_EXTRACT_DIAG(x) ((x)&0x1f)
|
||||
|
||||
static const struct tok bfd_port_values[] = {
|
||||
{ BFD_CONTROL_PORT, "Control" },
|
||||
{ BFD_ECHO_PORT, "Echo" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
|
||||
static const struct tok bfd_diag_values[] = {
|
||||
{ 0, "No Diagnostic" },
|
||||
{ 1, "Control Detection Time Expired" },
|
||||
{ 2, "Echo Function Failed" },
|
||||
{ 3, "Neighbor Signaled Session Down" },
|
||||
{ 4, "Forwarding Plane Reset" },
|
||||
{ 5, "Path Down" },
|
||||
{ 6, "Concatenated Path Down" },
|
||||
{ 7, "Administratively Down" },
|
||||
{ 8, "Reverse Concatenated Path Down" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static const struct tok bfd_v0_flag_values[] = {
|
||||
{ 0x80, "I Hear You" },
|
||||
{ 0x40, "Demand" },
|
||||
{ 0x20, "Poll" },
|
||||
{ 0x10, "Final" },
|
||||
{ 0x08, "Reserved" },
|
||||
{ 0x04, "Reserved" },
|
||||
{ 0x02, "Reserved" },
|
||||
{ 0x01, "Reserved" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
#define BFD_FLAG_AUTH 0x04
|
||||
|
||||
static const struct tok bfd_v1_flag_values[] = {
|
||||
{ 0x20, "Poll" },
|
||||
{ 0x10, "Final" },
|
||||
{ 0x08, "Control Plane Independent" },
|
||||
{ BFD_FLAG_AUTH, "Authentication Present" },
|
||||
{ 0x02, "Demand" },
|
||||
{ 0x01, "Reserved" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static const struct tok bfd_v1_state_values[] = {
|
||||
{ 0, "AdminDown" },
|
||||
{ 1, "Down" },
|
||||
{ 2, "Init" },
|
||||
{ 3, "Up" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
void
|
||||
bfd_print(netdissect_options *ndo, register const u_char *pptr,
|
||||
register u_int len, register u_int port)
|
||||
{
|
||||
const struct bfd_header_t *bfd_header;
|
||||
const struct bfd_auth_header_t *bfd_auth_header;
|
||||
uint8_t version = 0;
|
||||
|
||||
bfd_header = (const struct bfd_header_t *)pptr;
|
||||
if (port == BFD_CONTROL_PORT) {
|
||||
ND_TCHECK(*bfd_header);
|
||||
version = BFD_EXTRACT_VERSION(bfd_header->version_diag);
|
||||
} else if (port == BFD_ECHO_PORT) {
|
||||
/* Echo is BFD v1 only */
|
||||
version = 1;
|
||||
}
|
||||
switch ((port << 8) | version) {
|
||||
|
||||
/* BFDv0 */
|
||||
case (BFD_CONTROL_PORT << 8):
|
||||
if (ndo->ndo_vflag < 1)
|
||||
{
|
||||
ND_PRINT((ndo, "BFDv%u, %s, Flags: [%s], length: %u",
|
||||
version,
|
||||
tok2str(bfd_port_values, "unknown (%u)", port),
|
||||
bittok2str(bfd_v0_flag_values, "none", bfd_header->flags),
|
||||
len));
|
||||
return;
|
||||
}
|
||||
|
||||
ND_PRINT((ndo, "BFDv%u, length: %u\n\t%s, Flags: [%s], Diagnostic: %s (0x%02x)",
|
||||
version,
|
||||
len,
|
||||
tok2str(bfd_port_values, "unknown (%u)", port),
|
||||
bittok2str(bfd_v0_flag_values, "none", bfd_header->flags),
|
||||
tok2str(bfd_diag_values,"unknown",BFD_EXTRACT_DIAG(bfd_header->version_diag)),
|
||||
BFD_EXTRACT_DIAG(bfd_header->version_diag)));
|
||||
|
||||
ND_PRINT((ndo, "\n\tDetection Timer Multiplier: %u (%u ms Detection time), BFD Length: %u",
|
||||
bfd_header->detect_time_multiplier,
|
||||
bfd_header->detect_time_multiplier * EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000,
|
||||
bfd_header->length));
|
||||
|
||||
|
||||
ND_PRINT((ndo, "\n\tMy Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->my_discriminator)));
|
||||
ND_PRINT((ndo, ", Your Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->your_discriminator)));
|
||||
ND_PRINT((ndo, "\n\t Desired min Tx Interval: %4u ms", EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000));
|
||||
ND_PRINT((ndo, "\n\t Required min Rx Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_rx_interval)/1000));
|
||||
ND_PRINT((ndo, "\n\t Required min Echo Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_echo_interval)/1000));
|
||||
break;
|
||||
|
||||
/* BFDv1 */
|
||||
case (BFD_CONTROL_PORT << 8 | 1):
|
||||
if (ndo->ndo_vflag < 1)
|
||||
{
|
||||
ND_PRINT((ndo, "BFDv%u, %s, State %s, Flags: [%s], length: %u",
|
||||
version,
|
||||
tok2str(bfd_port_values, "unknown (%u)", port),
|
||||
tok2str(bfd_v1_state_values, "unknown (%u)", (bfd_header->flags & 0xc0) >> 6),
|
||||
bittok2str(bfd_v1_flag_values, "none", bfd_header->flags & 0x3f),
|
||||
len));
|
||||
return;
|
||||
}
|
||||
|
||||
ND_PRINT((ndo, "BFDv%u, length: %u\n\t%s, State %s, Flags: [%s], Diagnostic: %s (0x%02x)",
|
||||
version,
|
||||
len,
|
||||
tok2str(bfd_port_values, "unknown (%u)", port),
|
||||
tok2str(bfd_v1_state_values, "unknown (%u)", (bfd_header->flags & 0xc0) >> 6),
|
||||
bittok2str(bfd_v1_flag_values, "none", bfd_header->flags & 0x3f),
|
||||
tok2str(bfd_diag_values,"unknown",BFD_EXTRACT_DIAG(bfd_header->version_diag)),
|
||||
BFD_EXTRACT_DIAG(bfd_header->version_diag)));
|
||||
|
||||
ND_PRINT((ndo, "\n\tDetection Timer Multiplier: %u (%u ms Detection time), BFD Length: %u",
|
||||
bfd_header->detect_time_multiplier,
|
||||
bfd_header->detect_time_multiplier * EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000,
|
||||
bfd_header->length));
|
||||
|
||||
|
||||
ND_PRINT((ndo, "\n\tMy Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->my_discriminator)));
|
||||
ND_PRINT((ndo, ", Your Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->your_discriminator)));
|
||||
ND_PRINT((ndo, "\n\t Desired min Tx Interval: %4u ms", EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000));
|
||||
ND_PRINT((ndo, "\n\t Required min Rx Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_rx_interval)/1000));
|
||||
ND_PRINT((ndo, "\n\t Required min Echo Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_echo_interval)/1000));
|
||||
|
||||
if (bfd_header->flags & BFD_FLAG_AUTH) {
|
||||
pptr += sizeof (const struct bfd_header_t);
|
||||
bfd_auth_header = (const struct bfd_auth_header_t *)pptr;
|
||||
ND_TCHECK2(*bfd_auth_header, sizeof(const struct bfd_auth_header_t));
|
||||
ND_PRINT((ndo, "\n\t%s (%u) Authentication, length %u present",
|
||||
tok2str(bfd_v1_authentication_values,"Unknown",bfd_auth_header->auth_type),
|
||||
bfd_auth_header->auth_type,
|
||||
bfd_auth_header->auth_len));
|
||||
}
|
||||
break;
|
||||
|
||||
/* BFDv0 */
|
||||
case (BFD_ECHO_PORT << 8): /* not yet supported - fall through */
|
||||
/* BFDv1 */
|
||||
case (BFD_ECHO_PORT << 8 | 1):
|
||||
|
||||
default:
|
||||
ND_PRINT((ndo, "BFD, %s, length: %u",
|
||||
tok2str(bfd_port_values, "unknown (%u)", port),
|
||||
len));
|
||||
if (ndo->ndo_vflag >= 1) {
|
||||
if(!print_unknown_data(ndo, pptr,"\n\t",len))
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return;
|
||||
|
||||
trunc:
|
||||
ND_PRINT((ndo, "[|BFD]"));
|
||||
}
|
||||
/*
|
||||
* Local Variables:
|
||||
* c-style: whitesmith
|
||||
* c-basic-offset: 8
|
||||
* End:
|
||||
*/
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user