Vendor import of tcpdump 4.2.1.
This commit is contained in:
parent
6d59e2f382
commit
60894fde29
61
CHANGES
61
CHANGES
@ -1,3 +1,64 @@
|
||||
Friday December 9, 2011. guy@alum.mit.edu.
|
||||
Summary for 4.2.1 tcpdump release
|
||||
Only build the Babel printer if IPv6 is enabled.
|
||||
Support Babel on port 6696 as well as 6697.
|
||||
Include ppi.h in release tarball.
|
||||
Include all the test files in the release tarball, and don't
|
||||
"include" test files that no longer exist.
|
||||
Don't assume we have <rpc/rpc.h> - check for it.
|
||||
Support "-T carp" as a way of dissecting IP protocol 112 as CARP
|
||||
rather than VRRP.
|
||||
Support Hilscher NetAnalyzer link-layer header format.
|
||||
Constify some pointers and fix compiler warnings.
|
||||
Get rid of never-true test.
|
||||
Fix an unintended fall-through in a case statement in the ARP
|
||||
printer.
|
||||
Fix several cases where sizeof(sizeof(XXX)) was used when just
|
||||
sizeof(XXX) was intended.
|
||||
Make stricter sanity checks in the ES-IS printer.
|
||||
Get rid of some GCCisms that caused builds to fai with compilers
|
||||
that don't support them.
|
||||
Fix typo in man page.
|
||||
Added length checks to Babel printer.
|
||||
|
||||
Sunday July 24, 2011. mcr@sandelman.ca.
|
||||
Summary for 4.2.+
|
||||
merged 802.15.4 decoder from Dmitry Eremin-Solenikov <dbaryshkov
|
||||
at gmail dot com>
|
||||
updates to forces for new port numbers
|
||||
Use "-H", not "-h", for the 802.11s option. (-h always help)
|
||||
Better ICMPv6 checksum handling.
|
||||
add support for the RPKI/Router Protocol, per -ietf-sidr-rpki-rtr-12
|
||||
get rid of uuencoded pcap test files, git can do binary.
|
||||
sFlow changes for 64-bit counters.
|
||||
fixes for PPI packet header handling and printing.
|
||||
Add DCB Exchange protocol (DCBX) version 1.01.
|
||||
Babel dissector, from Juliusz Chroboczek and Grégoire Henry.
|
||||
improvements to radiotap for rate values > 127.
|
||||
Many improvements to ForCES decode, including fix SCTP TML port
|
||||
updated RPL type code to RPL-17 draft
|
||||
Improve printout of DHCPv6 options.
|
||||
added support and test case for QinQ (802.1q VLAN) packets
|
||||
Handle DLT_IEEE802_15_4_NOFCS like DLT_IEEE802_15_4.
|
||||
Build fixes for Sparc and other machines with alignment restrictions.
|
||||
Merged changes from Debian package.
|
||||
PGM: Add ACK decoding and add PGMCC DATA and FEEDBACK options.
|
||||
Build fixes for OSX (Snow Leopard and others)
|
||||
Add support for IEEE 802.15.4 packets
|
||||
|
||||
Tue. July 20, 2010. guy@alum.mit.edu.
|
||||
Summary for 4.1.2 tcpdump release
|
||||
If -U is specified, flush the file after creating it, so it's
|
||||
not zero-length
|
||||
Fix TCP flags output description, and some typoes, in the man
|
||||
page
|
||||
Add a -h flag, and only attempt to recognize 802.11s mesh
|
||||
headers if it's set
|
||||
When printing the link-layer type list, send *all* output to
|
||||
stderr
|
||||
Include the CFLAGS setting when configure was run in the
|
||||
compiler flags
|
||||
|
||||
Thu. April 1, 2010. guy@alum.mit.edu.
|
||||
Summary for 4.1.1 tcpdump release
|
||||
Fix build on systems with PF, such as FreeBSD and OpenBSD.
|
||||
|
372
CREDITS
372
CREDITS
@ -1,189 +1,203 @@
|
||||
This file lists people who have contributed to tcpdump:
|
||||
|
||||
The current maintainers:
|
||||
Bill Fenner <fenner at research dot att dot com>
|
||||
David Young <dyoung at pobox dot com>
|
||||
Fulvio Risso <risso at polito dot it>
|
||||
Guy Harris <guy at alum dot mit dot edu>
|
||||
Hannes Gredler <hannes at juniper dot net>
|
||||
Michael Richardson <mcr at sandelman dot ottawa dot on dot ca>
|
||||
Bill Fenner <fenner at research dot att dot com>
|
||||
David Young <dyoung at pobox dot com>
|
||||
Fulvio Risso <risso at polito dot it>
|
||||
Guy Harris <guy at alum dot mit dot edu>
|
||||
Hannes Gredler <hannes at juniper dot net>
|
||||
Michael Richardson <mcr at sandelman dot ottawa dot on dot ca>
|
||||
|
||||
Additional people who have contributed patches:
|
||||
|
||||
Aaron Campbell <aaron at arbor dot net>
|
||||
Alfredo Andres <aandres at s21sec dot com>
|
||||
Albert Chin <china at thewrittenword 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 Hintz <adhintz at users dot sourceforge dot net>
|
||||
Andrew Silent <andrew at nording dot ru>
|
||||
Andrew Tridgell <tridge at linuxcare dot com>
|
||||
Andy Heffernan <ahh at juniper dot net>
|
||||
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>
|
||||
Ben Byer <bushing at sourceforge dot net>
|
||||
Atsushi Onoe <onoe at netbsd dot org>
|
||||
Ben Smithurst <ben at scientia dot demon dot co dot uk>
|
||||
Bert Vermeulen <bert at biot dot com>
|
||||
Bjoern A. Zeeb <bzeeb at Zabbadoz dot NeT>
|
||||
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>
|
||||
Charlie Lenahan <clenahan at fortresstech dot com>
|
||||
Charles M. Hannum <mycroft at netbsd dot org>
|
||||
Chris Cogdon <chris at cogdon dot org>
|
||||
Chris G. Demetriou <cgd at netbsd dot org>
|
||||
Christian Sievers <c_s at users dot sourceforge dot net>
|
||||
Chris Jepeway <jepeway at blasted-heath dot com>
|
||||
Chris Larson <clarson at kergoth 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>
|
||||
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>
|
||||
Francis Dupont <Francis dot Dupont at enst-bretagne dot fr>
|
||||
Francisco Matias Cuenca-Acuna <mcuenca at george dot rutgers dot edu>
|
||||
Francois-Xavier Le Bail <fx dot lebail at yahoo dot com>
|
||||
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>
|
||||
Greg Minshall <minshall at acm dot org>
|
||||
Greg Stark <gsstark at mit dot edu>
|
||||
Gilbert Ramirez Jr. <gram at xiexie dot org>
|
||||
Gisle Vanem <giva at bgnett dot no>
|
||||
Hannes Viertel <hviertel at juniper dot net>
|
||||
Hank Leininger <tcpdump-workers at progressive-comp dot com>
|
||||
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>
|
||||
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>
|
||||
Jesper Peterson <jesper at endace dot com>
|
||||
Jim Hutchins <jim at ca dot sandia dot gov>
|
||||
Jonathan Heusser <jonny at drugphish dot ch>
|
||||
Tatuya Jinmei <jinmei at kame dot net>
|
||||
João Medeiros <ignotus21 at sourceforge dot net>
|
||||
Joerg Mayer <jmayer@loplof.de>
|
||||
Jørgen Thomsen <jth at jth dot net>
|
||||
Julian Cowley <julian at lava dot net>
|
||||
Kaarthik Sivakumar <kaarthik at torrentnet dot com>
|
||||
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>
|
||||
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>
|
||||
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 Martin Garcia <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 Binderberger <mbind at sourceforge dot net>
|
||||
Marc A. Lehmann <pcg at goof dot com>
|
||||
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>
|
||||
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>
|
||||
Michele "mydecay" Marchetto <smarchetto1 at tin dot it>
|
||||
Mike Frysinger <vapier at gmail dot com>
|
||||
Monroe Williams <monroe at pobox dot com>
|
||||
Motonori Shindo <mshindo at mshindo dot net>
|
||||
Nathan J. Williams <nathanw at MIT dot EDU>
|
||||
Nathaniel Couper-Noles <Nathaniel at isi1 dot tccisi dot com>
|
||||
Neil T. Spring <bluehal at users dot sourceforge dot net>
|
||||
Niels Provos <provos at openbsd dot org>
|
||||
Nickolai Zeldovich <kolya at MIT dot EDU>
|
||||
Nicolas Ferrero <toorop at babylo dot net>
|
||||
Noritoshi Demizu <demizu at users dot sourceforge dot net>
|
||||
Olaf Kirch <okir at caldera 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 Mundt <lethal at linux-sh dot org>
|
||||
Paul S. Traina <pst at freebsd dot org>
|
||||
Pavlin Radoslavov <pavlin at icir dot org>
|
||||
Pekka Savola <pekkas at netcore dot fi>
|
||||
Peter Fales <peter at fales-lorenz dot net>
|
||||
Peter Jeremy <peter dot jeremy at alcatel dot com dot au>
|
||||
<pfhunt at users dot sourceforge dot net>
|
||||
Peter Volkov <pva at gentoo dot org>
|
||||
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>
|
||||
Sagun Shakya <sagun dot shakya at sun dot com>
|
||||
Sami Farin <safari at iki dot fi>
|
||||
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>
|
||||
Steinar Haug <sthaug at nethelp dot no>
|
||||
Swaminathan Chandrasekaran <chander at juniper dot net>
|
||||
Takashi Yamamoto <yamt at mwd dot biglobe dot ne dot jp>
|
||||
Terry Kennedy <terry at tmk dot com>
|
||||
Timo Koskiahde
|
||||
Tony Li <tli at procket dot com>
|
||||
Toshihiro Kanda <candy at fct dot kgc dot co dot jp>
|
||||
Uns Lider <unslider at miranda dot org>
|
||||
Victor Oppleman <oppleman at users dot sourceforge 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>
|
||||
Yen Yen Lim
|
||||
Yoshifumi Nishida
|
||||
A Costa <agcosta at gis dot net>
|
||||
Aaron Campbell <aaron at arbor dot net>
|
||||
Alfredo Andres <aandres at s21sec dot com>
|
||||
Albert Chin <china at thewrittenword 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 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>
|
||||
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>
|
||||
Ben Byer <bushing at sourceforge dot net>
|
||||
Atsushi Onoe <onoe at netbsd dot org>
|
||||
Ben Smithurst <ben at scientia dot demon dot co dot uk>
|
||||
Bert Vermeulen <bert at biot dot com>
|
||||
Bjoern A. Zeeb <bzeeb at Zabbadoz dot NeT>
|
||||
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>
|
||||
Charlie Lenahan <clenahan at fortresstech dot com>
|
||||
Charles M. Hannum <mycroft at netbsd dot org>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
Francis Dupont <Francis dot Dupont at enst-bretagne dot fr>
|
||||
Francisco Matias Cuenca-Acuna <mcuenca at george dot rutgers dot edu>
|
||||
Francois-Xavier Le Bail <fx dot lebail at yahoo dot com>
|
||||
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>
|
||||
Greg Minshall <minshall at acm dot org>
|
||||
Greg Stark <gsstark at mit dot edu>
|
||||
Grégoire Henry <henry@pps.jussieu.fr>
|
||||
Gilbert Ramirez Jr. <gram at xiexie dot org>
|
||||
Gisle Vanem <gvanem at broadpark dot no>
|
||||
Hannes Viertel <hviertel at juniper dot net>
|
||||
Hank Leininger <tcpdump-workers at progressive-comp dot com>
|
||||
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>
|
||||
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>
|
||||
Jesper Peterson <jesper at endace dot com>
|
||||
Jim Hutchins <jim at ca dot sandia dot gov>
|
||||
Jonathan Heusser <jonny at drugphish dot ch>
|
||||
Tatuya Jinmei <jinmei at kame dot net>
|
||||
João Medeiros <ignotus21 at sourceforge dot net>
|
||||
Joerg Mayer <jmayer@loplof.de>
|
||||
Jørgen Thomsen <jth at jth dot net>
|
||||
Julian Cowley <julian at lava dot net>
|
||||
Juliusz Chroboczek <jch@pps.jussieu.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>
|
||||
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>
|
||||
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 Binderberger <mbind at sourceforge dot net>
|
||||
Marc A. Lehmann <pcg at goof dot com>
|
||||
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>
|
||||
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>
|
||||
Nathan J. Williams <nathanw at MIT dot EDU>
|
||||
Nathaniel Couper-Noles <Nathaniel at isi1 dot tccisi dot com>
|
||||
Neil T. Spring <bluehal at users dot sourceforge dot net>
|
||||
Niels Provos <provos at openbsd dot org>
|
||||
Nickolai Zeldovich <kolya at MIT dot EDU>
|
||||
Nicolas Ferrero <toorop at babylo dot net>
|
||||
Noritoshi Demizu <demizu at users dot sourceforge dot net>
|
||||
Olaf Kirch <okir at caldera 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>
|
||||
Peter Fales <peter at fales-lorenz dot net>
|
||||
Peter Jeremy <peter dot jeremy at alcatel dot com dot au>
|
||||
<pfhunt at users dot sourceforge dot net>
|
||||
Peter Volkov <pva at gentoo dot org>
|
||||
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>
|
||||
Sagun Shakya <sagun dot shakya at sun dot com>
|
||||
Sami Farin <safari at iki dot fi>
|
||||
Scott Mcmillan <scott.a.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>
|
||||
Steinar Haug <sthaug at nethelp dot no>
|
||||
Swaminathan Chandrasekaran <chander at juniper dot net>
|
||||
Takashi Yamamoto <yamt at mwd dot biglobe dot ne dot jp>
|
||||
Terry Kennedy <terry at tmk dot com>
|
||||
Timo Koskiahde
|
||||
Tony Li <tli at procket dot com>
|
||||
Toshihiro Kanda <candy at fct dot kgc dot co dot jp>
|
||||
Uns Lider <unslider at miranda dot org>
|
||||
Victor Oppleman <oppleman at users dot sourceforge dot net>
|
||||
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>
|
||||
Yen Yen Lim
|
||||
Yoshifumi Nishida
|
||||
|
||||
The original LBL crew:
|
||||
Steve McCanne
|
||||
Craig Leres
|
||||
Van Jacobson
|
||||
Steve McCanne
|
||||
Craig Leres
|
||||
Van Jacobson
|
||||
|
||||
Past maintainers:
|
||||
Jun-ichiro itojun Hagino <itojun at iijlab dot net>
|
||||
Jun-ichiro itojun Hagino <itojun at iijlab dot net>
|
||||
|
105
Makefile.in
105
Makefile.in
@ -26,6 +26,7 @@
|
||||
# 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
|
||||
@ -46,7 +47,8 @@ INCLS = -I. @V_INCLS@
|
||||
DEFS = @DEFS@ @CPPFLAGS@ @V_DEFS@
|
||||
|
||||
# Standard CFLAGS
|
||||
CFLAGS = $(CCOPT) $(DEFS) $(INCLS)
|
||||
CFLAGS = @CFLAGS@
|
||||
FULL_CFLAGS = $(CCOPT) $(DEFS) $(INCLS) $(CFLAGS)
|
||||
|
||||
# Standard LDFLAGS
|
||||
LDFLAGS = @LDFLAGS@
|
||||
@ -64,15 +66,15 @@ RANLIB = @RANLIB@
|
||||
# problem if you don't own the file but can write to the directory.
|
||||
.c.o:
|
||||
@rm -f $@
|
||||
$(CC) $(CFLAGS) -c $(srcdir)/$*.c
|
||||
$(CC) $(FULL_CFLAGS) -c $(srcdir)/$*.c
|
||||
|
||||
CSRC = addrtoname.c af.c checksum.c cpack.c gmpls.c oui.c gmt2local.c ipproto.c \
|
||||
nlpid.c l2vpn.c machdep.c parsenfsfh.c \
|
||||
print-802_11.c print-ap1394.c print-ah.c print-arcnet.c \
|
||||
print-aodv.c print-arp.c print-ascii.c print-atalk.c print-atm.c \
|
||||
print-beep.c print-bfd.c print-bgp.c print-bootp.c print-bt.c \
|
||||
print-cdp.c print-cfm.c print-chdlc.c print-cip.c print-cnfp.c \
|
||||
print-dccp.c print-decnet.c \
|
||||
nlpid.c l2vpn.c machdep.c parsenfsfh.c in_cksum.c \
|
||||
print-802_11.c print-802_15_4.c print-ap1394.c print-ah.c \
|
||||
print-arcnet.c print-aodv.c print-arp.c print-ascii.c print-atalk.c \
|
||||
print-atm.c print-beep.c print-bfd.c print-bgp.c \
|
||||
print-bootp.c print-bt.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-domain.c print-dtp.c print-dvmrp.c print-enc.c print-egp.c \
|
||||
print-eap.c print-eigrp.c\
|
||||
print-esp.c print-ether.c print-fddi.c print-fr.c \
|
||||
@ -83,8 +85,9 @@ CSRC = addrtoname.c af.c checksum.c cpack.c gmpls.c oui.c gmt2local.c ipproto.c
|
||||
print-lmp.c print-lspping.c print-lwapp.c \
|
||||
print-lwres.c print-mobile.c print-mpcp.c print-mpls.c print-msdp.c \
|
||||
print-nfs.c print-ntp.c print-null.c print-olsr.c print-ospf.c \
|
||||
print-pgm.c print-pim.c print-ppp.c print-pppoe.c print-pptp.c \
|
||||
print-radius.c print-raw.c print-rip.c print-rrcp.c print-rsvp.c \
|
||||
print-pgm.c print-pim.c \
|
||||
print-ppi.c print-ppp.c print-pppoe.c print-pptp.c \
|
||||
print-radius.c print-raw.c print-rip.c print-rpki-rtr.c print-rrcp.c print-rsvp.c \
|
||||
print-rx.c print-sctp.c print-sflow.c print-sip.c print-sl.c print-sll.c \
|
||||
print-slow.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 \
|
||||
@ -165,6 +168,7 @@ HDR = \
|
||||
oui.h \
|
||||
pcap-missing.h \
|
||||
pmap_prot.h \
|
||||
ppi.h \
|
||||
ppp.h \
|
||||
route6d.h \
|
||||
rpc_auth.h \
|
||||
@ -226,16 +230,12 @@ EXTRA_DIST = \
|
||||
lbl/os-ultrix4.h \
|
||||
makemib \
|
||||
missing/addrinfo.h \
|
||||
missing/addrsize.h \
|
||||
missing/bittypes.h \
|
||||
missing/dlnames.c \
|
||||
missing/datalinks.c \
|
||||
missing/getnameinfo.c \
|
||||
missing/inet_aton.c \
|
||||
missing/inet_ntop.c \
|
||||
missing/inet_pton.c \
|
||||
missing/resolv6.h \
|
||||
missing/resolv_ext.h \
|
||||
missing/snprintf.c \
|
||||
missing/sockstorage.h \
|
||||
missing/strdup.c \
|
||||
@ -245,6 +245,7 @@ EXTRA_DIST = \
|
||||
mkdep \
|
||||
packetdat.awk \
|
||||
pcap_dump_ftell.c \
|
||||
print-babel.c \
|
||||
print-dhcp6.c \
|
||||
print-frag6.c \
|
||||
print-icmp6.c \
|
||||
@ -262,12 +263,18 @@ EXTRA_DIST = \
|
||||
stime.awk \
|
||||
strcasecmp.c \
|
||||
tcpdump.1.in \
|
||||
tests/02-sunrise-sunset-esp.puu \
|
||||
tests/08-sunrise-sunset-aes.puu \
|
||||
tests/08-sunrise-sunset-esp2.puu \
|
||||
tests/02-sunrise-sunset-esp.pcap \
|
||||
tests/08-sunrise-sunset-aes.pcap \
|
||||
tests/08-sunrise-sunset-esp2.pcap \
|
||||
tests/QinQpacket.out \
|
||||
tests/QinQpacket.pcap \
|
||||
tests/QinQpacketv.out \
|
||||
tests/TESTLIST \
|
||||
tests/TESTonce \
|
||||
tests/TESTrun.sh \
|
||||
tests/babel.pcap \
|
||||
tests/babel1.out \
|
||||
tests/babel1v.out \
|
||||
tests/bgp-infinite-loop.pcap \
|
||||
tests/bgp_vpn_attrset.out \
|
||||
tests/bgp_vpn_attrset.pcap \
|
||||
@ -279,8 +286,8 @@ EXTRA_DIST = \
|
||||
tests/e1000g.pcap \
|
||||
tests/eapon1.gdbinit \
|
||||
tests/eapon1.out \
|
||||
tests/eapon1.puu \
|
||||
tests/eapon2.puu \
|
||||
tests/eapon1.pcap \
|
||||
tests/empty.uu \
|
||||
tests/esp-secrets.txt \
|
||||
tests/esp0.out \
|
||||
tests/esp1.gdbinit \
|
||||
@ -292,61 +299,57 @@ EXTRA_DIST = \
|
||||
tests/esp5.gdbinit \
|
||||
tests/esp5.out \
|
||||
tests/espudp1.out \
|
||||
tests/espudp1.puu \
|
||||
tests/espudp1.pcap \
|
||||
tests/forces1.out \
|
||||
tests/forces1.pcap \
|
||||
tests/forces1vvv.out \
|
||||
tests/forces1vvvv.out \
|
||||
tests/forces2.out \
|
||||
tests/forces2.pcap \
|
||||
tests/forces2v.out \
|
||||
tests/forces2vv.out \
|
||||
tests/ikev2.puu \
|
||||
tests/forces3vvv.out \
|
||||
tests/ikev2four.out \
|
||||
tests/ikev2four.puu \
|
||||
tests/ikev2four.pcap \
|
||||
tests/ikev2fourv.out \
|
||||
tests/ikev2fourv4.out \
|
||||
tests/ikev2pI2-secrets.txt \
|
||||
tests/ikev2pI2.out \
|
||||
tests/ikev2pI2.puu \
|
||||
tests/isakmp-delete-segfault.puu \
|
||||
tests/isakmp-identification-segfault.puu \
|
||||
tests/isakmp-pointer-loop.puu \
|
||||
tests/ikev2pI2.pcap \
|
||||
tests/isakmp-delete-segfault.pcap \
|
||||
tests/isakmp-identification-segfault.pcap \
|
||||
tests/isakmp-pointer-loop.pcap \
|
||||
tests/isakmp1.out \
|
||||
tests/isakmp2.out \
|
||||
tests/isakmp3.out \
|
||||
tests/isakmp4.out \
|
||||
tests/isakmp4500.puu \
|
||||
tests/isakmp4500.pcap \
|
||||
tests/isis-infinite-loop.pcap \
|
||||
tests/ldp-infinite-loop.pcap \
|
||||
tests/lmp.out \
|
||||
tests/lmp.puu \
|
||||
tests/lmp.pcap \
|
||||
tests/lmp.sh \
|
||||
tests/lspping-fec-ldp.pcap \
|
||||
tests/lspping-fec-rsvp.pcap \
|
||||
tests/mpls-ldp-hello.out \
|
||||
tests/mpls-ldp-hello.puu \
|
||||
tests/mpls-ldp-hello.pcap \
|
||||
tests/mpls-traceroute.pcap \
|
||||
tests/ospf-gmpls.out \
|
||||
tests/ospf-gmpls.puu \
|
||||
tests/ospf-gmpls.pcap \
|
||||
tests/print-A.out \
|
||||
tests/print-AA.out \
|
||||
tests/print-capX.out \
|
||||
tests/print-capXX.out \
|
||||
tests/print-flags.puu \
|
||||
tests/print-flags.pcap \
|
||||
tests/print-flags.sh \
|
||||
tests/print-x.out \
|
||||
tests/print-xx.out \
|
||||
tests/rsvp-infinite-loop.pcap \
|
||||
tests/sflow_multiple_counter_30_pdus.out \
|
||||
tests/sflow_multiple_counter_30_pdus.pcap \
|
||||
vfprintf.c \
|
||||
win32/Include/Arpa/tftp.h \
|
||||
win32/Include/errno.h \
|
||||
win32/Include/getopt.h \
|
||||
win32/Include/inetprivate.h \
|
||||
win32/Include/telnet.h \
|
||||
win32/Include/w32_fzs.h \
|
||||
win32/Include/Netinet/in_systm.h \
|
||||
win32/Include/Netinet/ip.h \
|
||||
win32/Src/getopt.c \
|
||||
win32/prj/GNUmakefile \
|
||||
win32/prj/WinDump.dsp \
|
||||
@ -356,7 +359,7 @@ all: $(PROG)
|
||||
|
||||
$(PROG): $(OBJ) @V_PCAPDEP@
|
||||
@rm -f $@
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
|
||||
$(CC) $(FULL_CFLAGS) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
|
||||
|
||||
$(LIBNETDISSECT): $(LIBNETDISSECT_OBJ)
|
||||
@rm -f $@
|
||||
@ -364,30 +367,30 @@ $(LIBNETDISSECT): $(LIBNETDISSECT_OBJ)
|
||||
$(RANLIB) $@
|
||||
|
||||
datalinks.o: $(srcdir)/missing/datalinks.c
|
||||
$(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/datalinks.c
|
||||
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/datalinks.c
|
||||
dlnames.o: $(srcdir)/missing/dlnames.c
|
||||
$(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/dlnames.c
|
||||
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/dlnames.c
|
||||
getnameinfo.o: $(srcdir)/missing/getnameinfo.c
|
||||
$(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/getnameinfo.c
|
||||
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/getnameinfo.c
|
||||
getaddrinfo.o: $(srcdir)/missing/getaddrinfo.c
|
||||
$(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/getaddrinfo.c
|
||||
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/getaddrinfo.c
|
||||
inet_pton.o: $(srcdir)/missing/inet_pton.c
|
||||
$(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/inet_pton.c
|
||||
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/inet_pton.c
|
||||
inet_ntop.o: $(srcdir)/missing/inet_ntop.c
|
||||
$(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/inet_ntop.c
|
||||
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/inet_ntop.c
|
||||
inet_aton.o: $(srcdir)/missing/inet_aton.c
|
||||
$(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/inet_aton.c
|
||||
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/inet_aton.c
|
||||
snprintf.o: $(srcdir)/missing/snprintf.c
|
||||
$(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c
|
||||
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c
|
||||
strlcat.o: $(srcdir)/missing/strlcat.c
|
||||
$(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/strlcat.c
|
||||
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strlcat.c
|
||||
strlcpy.o: $(srcdir)/missing/strlcpy.c
|
||||
$(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/strlcpy.c
|
||||
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strlcpy.c
|
||||
strsep.o: $(srcdir)/missing/strsep.c
|
||||
$(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/strsep.c
|
||||
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strsep.c
|
||||
|
||||
version.o: version.c
|
||||
$(CC) $(CFLAGS) -c version.c
|
||||
$(CC) $(FULL_CFLAGS) -c version.c
|
||||
|
||||
version.c: $(srcdir)/VERSION
|
||||
@rm -f $@
|
||||
@ -423,9 +426,9 @@ clean:
|
||||
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
|
||||
rm -rf autom4te.cache
|
||||
|
||||
check: tcpdump
|
||||
uudecode --help || (echo "No uudecode program found, not running tests"; echo "apt-get/rpm install sharutils?"; exit 1)
|
||||
(cd tests && ./TESTrun.sh)
|
||||
|
||||
tags: $(TAGFILES)
|
||||
|
18
acconfig.h
18
acconfig.h
@ -8,12 +8,6 @@
|
||||
/* Define if you enable support for the libsmi. */
|
||||
#undef LIBSMI
|
||||
|
||||
/* define if you have struct __res_state_ext */
|
||||
#undef HAVE_RES_STATE_EXT
|
||||
|
||||
/* define if your struct __res_state has the nsort member */
|
||||
#undef HAVE_NEW_RES_STATE
|
||||
|
||||
/* define if you have the addrinfo function. */
|
||||
#undef HAVE_ADDRINFO
|
||||
|
||||
@ -23,15 +17,6 @@
|
||||
/* define ifyou have the h_errno variable. */
|
||||
#undef HAVE_H_ERRNO
|
||||
|
||||
/* define if IN6ADDRSZ is defined (XXX not used!) */
|
||||
#undef HAVE_IN6ADDRSZ
|
||||
|
||||
/* define if INADDRSZ is defined (XXX not used!) */
|
||||
#undef HAVE_INADDRSZ
|
||||
|
||||
/* define if RES_USE_INET6 is defined */
|
||||
#undef HAVE_RES_USE_INET6
|
||||
|
||||
/* define if you have struct sockaddr_storage */
|
||||
#undef HAVE_SOCKADDR_STORAGE
|
||||
|
||||
@ -68,9 +53,6 @@
|
||||
/* define if you have getrpcbynumber() */
|
||||
#undef HAVE_GETRPCBYNUMBER
|
||||
|
||||
/* AIX hack. */
|
||||
#undef _SUN
|
||||
|
||||
/* Workaround for missing 64-bit formats */
|
||||
#undef PRId64
|
||||
#undef PRIo64
|
||||
|
158
aclocal.m4
vendored
158
aclocal.m4
vendored
@ -47,7 +47,7 @@ AC_DEFUN(AC_LBL_C_INIT_BEFORE_CC,
|
||||
$1="-O"
|
||||
$2=""
|
||||
if test "${srcdir}" != "." ; then
|
||||
$2="-I\$(srcdir)"
|
||||
$2="-I$srcdir"
|
||||
fi
|
||||
if test "${CFLAGS+set}" = set; then
|
||||
LBL_CFLAGS="$CFLAGS"
|
||||
@ -309,14 +309,22 @@ AC_DEFUN(AC_LBL_LIBPCAP,
|
||||
#
|
||||
# Look for pcap-config.
|
||||
#
|
||||
AC_PATH_PROG(PCAP_CONFIG, pcap-config)
|
||||
AC_PATH_TOOL(PCAP_CONFIG, pcap-config)
|
||||
if test -n "$PCAP_CONFIG" ; then
|
||||
#
|
||||
# Found - use it to get the include flags for
|
||||
# libpcap and the flags to link with libpcap.
|
||||
#
|
||||
$2="`\"$PCAP_CONFIG\" --cflags` $$2"
|
||||
libpcap="`\"$PCAP_CONFIG\" --libs`"
|
||||
# Please read section 11.6 "Shell Substitutions"
|
||||
# in the autoconf manual before doing anything
|
||||
# to this that involves quoting. Especially note
|
||||
# the statement "There is just no portable way to use
|
||||
# double-quoted strings inside double-quoted back-quoted
|
||||
# expressions (pfew!)."
|
||||
#
|
||||
cflags=`"$PCAP_CONFIG" --cflags`
|
||||
$2="$cflags $$2"
|
||||
libpcap=`"$PCAP_CONFIG" --libs`
|
||||
else
|
||||
#
|
||||
# Not found; look for pcap.
|
||||
@ -378,9 +386,17 @@ AC_DEFUN(AC_LBL_LIBPCAP,
|
||||
# The libpcap directory has a pcap-config script.
|
||||
# Use it to get any additioal libraries needed
|
||||
# to link with the libpcap archive library in
|
||||
# that directory
|
||||
# that directory.
|
||||
#
|
||||
libpcap="$libpcap `\"$PCAP_CONFIG\" --additional-libs --static`"
|
||||
# Please read section 11.6 "Shell Substitutions"
|
||||
# in the autoconf manual before doing anything
|
||||
# to this that involves quoting. Especially note
|
||||
# the statement "There is just no portable way to use
|
||||
# double-quoted strings inside double-quoted back-quoted
|
||||
# expressions (pfew!)."
|
||||
#
|
||||
additional_libs=`"$PCAP_CONFIG" --additional-libs --static`
|
||||
libpcap="$libpcap $additional_libs"
|
||||
fi
|
||||
fi
|
||||
LIBS="$libpcap $LIBS"
|
||||
@ -417,6 +433,21 @@ AC_DEFUN(AC_LBL_LIBPCAP,
|
||||
esac
|
||||
fi
|
||||
|
||||
dnl
|
||||
dnl Check for "pcap_loop()", to make sure we found a working
|
||||
dnl libpcap and have all the right other libraries with which
|
||||
dnl to link. (Otherwise, the checks below will fail, not
|
||||
dnl because the routines are missing from the library, but
|
||||
dnl because we aren't linking properly with libpcap, and
|
||||
dnl that will cause confusing errors at build time.)
|
||||
dnl
|
||||
AC_CHECK_FUNC(pcap_loop,,
|
||||
[
|
||||
AC_MSG_ERROR(
|
||||
[Report this to tcpdump-workers@lists.tcpdump.org, and include the
|
||||
config.log file in your report])
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl Check for "pcap_list_datalinks()", "pcap_set_datalink()",
|
||||
dnl and "pcap_datalink_name_to_val()", and use substitute versions
|
||||
@ -1056,113 +1087,6 @@ AC_DEFUN(AC_STRUCT_SA_STORAGE, [
|
||||
fi
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl Checks for macro of IP address size
|
||||
AC_DEFUN(AC_CHECK_ADDRSZ, [
|
||||
$1=yes
|
||||
dnl check for INADDRSZ
|
||||
AC_MSG_CHECKING(for INADDRSZ)
|
||||
AC_CACHE_VAL(ac_cv_inaddrsz,
|
||||
AC_TRY_COMPILE([
|
||||
# include <arpa/nameser.h>],
|
||||
[int a = INADDRSZ],
|
||||
ac_cv_inaddrsz=yes,
|
||||
ac_cv_inaddrsz=no))
|
||||
AC_MSG_RESULT($ac_cv_inaddrsz)
|
||||
if test $ac_cv_inaddrsz = yes; then
|
||||
AC_DEFINE(HAVE_INADDRSZ)
|
||||
else
|
||||
$1=no
|
||||
fi
|
||||
dnl check for IN6ADDRSZ
|
||||
AC_MSG_CHECKING(for IN6ADDRSZ)
|
||||
AC_CACHE_VAL(ac_cv_in6addrsz,
|
||||
AC_TRY_COMPILE([
|
||||
# include <arpa/nameser.h>],
|
||||
[int a = IN6ADDRSZ],
|
||||
ac_cv_in6addrsz=yes,
|
||||
ac_cv_in6addrsz=no))
|
||||
AC_MSG_RESULT($ac_cv_in6addrsz)
|
||||
if test $ac_cv_in6addrsz = yes; then
|
||||
AC_DEFINE(HAVE_IN6ADDRSZ)
|
||||
else
|
||||
$1=no
|
||||
fi
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl check for RES_USE_INET6
|
||||
AC_DEFUN(AC_CHECK_RES_USE_INET6, [
|
||||
AC_MSG_CHECKING(for RES_USE_INET6)
|
||||
AC_CACHE_VAL($1,
|
||||
AC_TRY_COMPILE([
|
||||
# include <sys/types.h>
|
||||
# include <netinet/in.h>
|
||||
# include <resolv.h>],
|
||||
[int a = RES_USE_INET6],
|
||||
$1=yes,
|
||||
$1=no))
|
||||
AC_MSG_RESULT($$1)
|
||||
if test $$1 = yes; then
|
||||
AC_DEFINE(HAVE_RES_USE_INET6)
|
||||
fi
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl check for AAAA
|
||||
AC_DEFUN(AC_CHECK_AAAA, [
|
||||
AC_MSG_CHECKING(for AAAA)
|
||||
AC_CACHE_VAL($1,
|
||||
AC_TRY_COMPILE([
|
||||
# include <sys/types.h>
|
||||
# include <arpa/nameser.h>],
|
||||
[int a = T_AAAA],
|
||||
$1=yes,
|
||||
$1=no))
|
||||
AC_MSG_RESULT($$1)
|
||||
if test $$1 = yes; then
|
||||
AC_DEFINE(HAVE_AAAA)
|
||||
fi
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl check for struct res_state_ext
|
||||
AC_DEFUN(AC_STRUCT_RES_STATE_EXT, [
|
||||
AC_MSG_CHECKING(for res_state_ext)
|
||||
AC_CACHE_VAL($1,
|
||||
AC_TRY_COMPILE([
|
||||
# include <sys/types.h>
|
||||
# include <netinet/in.h>
|
||||
# include <netinet6/in6.h>
|
||||
# include <resolv.h>],
|
||||
[struct __res_state_ext e],
|
||||
$1=yes,
|
||||
$1=no))
|
||||
AC_MSG_RESULT($$1)
|
||||
if test $$1 = yes; then
|
||||
AC_DEFINE(HAVE_RES_STATE_EXT)
|
||||
fi
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl check for struct res_state_ext
|
||||
AC_DEFUN(AC_STRUCT_RES_STATE, [
|
||||
AC_MSG_CHECKING(for nsort in res_state)
|
||||
AC_CACHE_VAL($1,
|
||||
AC_TRY_COMPILE([
|
||||
# include <sys/types.h>
|
||||
# include <netinet/in.h>
|
||||
# include <netinet6/in6.h>
|
||||
# include <resolv.h>],
|
||||
[struct __res_state e; e.nsort = 0],
|
||||
$1=yes,
|
||||
$1=no))
|
||||
AC_MSG_RESULT($$1)
|
||||
if test $$1 = yes; then
|
||||
AC_DEFINE(HAVE_NEW_RES_STATE)
|
||||
fi
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl check for h_errno
|
||||
AC_DEFUN(AC_VAR_H_ERRNO, [
|
||||
@ -1187,7 +1111,7 @@ dnl
|
||||
AC_DEFUN(AC_C___ATTRIBUTE__, [
|
||||
AC_MSG_CHECKING(for __attribute__)
|
||||
AC_CACHE_VAL(ac_cv___attribute__, [
|
||||
AC_COMPILE_IFELSE(
|
||||
AC_COMPILE_IFELSE([
|
||||
AC_LANG_SOURCE([[
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -1204,7 +1128,7 @@ main(int argc, char **argv)
|
||||
{
|
||||
foo();
|
||||
}
|
||||
]]),
|
||||
]])],
|
||||
ac_cv___attribute__=yes,
|
||||
ac_cv___attribute__=no)])
|
||||
if test "$ac_cv___attribute__" = "yes"; then
|
||||
@ -1225,7 +1149,7 @@ dnl
|
||||
AC_DEFUN(AC_C___ATTRIBUTE___FORMAT_FUNCTION_POINTER, [
|
||||
AC_MSG_CHECKING([whether __attribute__((format)) can be applied to function pointers])
|
||||
AC_CACHE_VAL(ac_cv___attribute___format_function_pointer, [
|
||||
AC_COMPILE_IFELSE(
|
||||
AC_COMPILE_IFELSE([
|
||||
AC_LANG_SOURCE([[
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -1237,7 +1161,7 @@ main(int argc, char **argv)
|
||||
{
|
||||
(*foo)("%s", "test");
|
||||
}
|
||||
]]),
|
||||
]])],
|
||||
ac_cv___attribute___format_function_pointer=yes,
|
||||
ac_cv___attribute___format_function_pointer=no)])
|
||||
if test "$ac_cv___attribute___format_function_pointer" = "yes"; then
|
||||
|
28
addrtoname.c
28
addrtoname.c
@ -507,6 +507,34 @@ etheraddr_string(register const u_char *ep)
|
||||
return (tp->e_name);
|
||||
}
|
||||
|
||||
const char *
|
||||
le64addr_string(const u_char *ep)
|
||||
{
|
||||
const unsigned int len = 8;
|
||||
register u_int i;
|
||||
register char *cp;
|
||||
register struct enamemem *tp;
|
||||
char buf[BUFSIZE];
|
||||
|
||||
tp = lookup_bytestring(ep, len);
|
||||
if (tp->e_name)
|
||||
return (tp->e_name);
|
||||
|
||||
cp = buf;
|
||||
for (i = len; i > 0 ; --i) {
|
||||
*cp++ = hex[*(ep + i - 1) >> 4];
|
||||
*cp++ = hex[*(ep + i - 1) & 0xf];
|
||||
*cp++ = ':';
|
||||
}
|
||||
cp --;
|
||||
|
||||
*cp = '\0';
|
||||
|
||||
tp->e_name = strdup(buf);
|
||||
|
||||
return (tp->e_name);
|
||||
}
|
||||
|
||||
const char *
|
||||
linkaddr_string(const u_char *ep, const unsigned int type, const unsigned int len)
|
||||
{
|
||||
|
@ -34,6 +34,7 @@ enum {
|
||||
|
||||
extern const char *linkaddr_string(const u_char *, const unsigned int, const unsigned int);
|
||||
extern const char *etheraddr_string(const u_char *);
|
||||
extern const char *le64addr_string(const u_char *);
|
||||
extern const char *etherproto_string(u_short);
|
||||
extern const char *tcpport_string(u_short);
|
||||
extern const char *udpport_string(u_short);
|
||||
|
4
bootp.h
4
bootp.h
@ -37,7 +37,7 @@ struct bootp {
|
||||
u_int8_t bp_sname[64]; /* server host name */
|
||||
u_int8_t bp_file[128]; /* boot file name */
|
||||
u_int8_t bp_vend[64]; /* vendor-specific area */
|
||||
};
|
||||
} UNALIGNED;
|
||||
|
||||
/*
|
||||
* UDP port numbers, server and client.
|
||||
@ -217,7 +217,7 @@ struct cmu_vend {
|
||||
struct in_addr v_ins1, v_ins2; /* IEN-116 name servers */
|
||||
struct in_addr v_ts1, v_ts2; /* Time servers */
|
||||
u_int8_t v_unused[24]; /* currently unused */
|
||||
};
|
||||
} UNALIGNED;
|
||||
|
||||
|
||||
/* v_flags values */
|
||||
|
48
config.h.in
48
config.h.in
@ -8,12 +8,6 @@
|
||||
/* Define if you enable support for the libsmi. */
|
||||
#undef LIBSMI
|
||||
|
||||
/* define if you have struct __res_state_ext */
|
||||
#undef HAVE_RES_STATE_EXT
|
||||
|
||||
/* define if your struct __res_state has the nsort member */
|
||||
#undef HAVE_NEW_RES_STATE
|
||||
|
||||
/* define if you have the addrinfo function. */
|
||||
#undef HAVE_ADDRINFO
|
||||
|
||||
@ -23,15 +17,6 @@
|
||||
/* define ifyou have the h_errno variable. */
|
||||
#undef HAVE_H_ERRNO
|
||||
|
||||
/* define if IN6ADDRSZ is defined (XXX not used!) */
|
||||
#undef HAVE_IN6ADDRSZ
|
||||
|
||||
/* define if INADDRSZ is defined (XXX not used!) */
|
||||
#undef HAVE_INADDRSZ
|
||||
|
||||
/* define if RES_USE_INET6 is defined */
|
||||
#undef HAVE_RES_USE_INET6
|
||||
|
||||
/* define if you have struct sockaddr_storage */
|
||||
#undef HAVE_SOCKADDR_STORAGE
|
||||
|
||||
@ -68,9 +53,6 @@
|
||||
/* define if you have getrpcbynumber() */
|
||||
#undef HAVE_GETRPCBYNUMBER
|
||||
|
||||
/* AIX hack. */
|
||||
#undef _SUN
|
||||
|
||||
/* Workaround for missing 64-bit formats */
|
||||
#undef PRId64
|
||||
#undef PRIo64
|
||||
@ -108,6 +90,9 @@
|
||||
/* 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 `getnameinfo' function. */
|
||||
#undef HAVE_GETNAMEINFO
|
||||
|
||||
@ -165,6 +150,9 @@
|
||||
/* Define to 1 if you have the `pcap_lib_version' function. */
|
||||
#undef HAVE_PCAP_LIB_VERSION
|
||||
|
||||
/* 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
|
||||
|
||||
@ -174,6 +162,9 @@
|
||||
/* 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
|
||||
|
||||
@ -237,6 +228,9 @@
|
||||
/* 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
|
||||
|
||||
@ -276,21 +270,6 @@
|
||||
/* return value of signal handlers */
|
||||
#undef RETSIGVAL
|
||||
|
||||
/* The size of `char', as computed by sizeof. */
|
||||
#undef SIZEOF_CHAR
|
||||
|
||||
/* The size of `int', as computed by sizeof. */
|
||||
#undef SIZEOF_INT
|
||||
|
||||
/* The size of `long', as computed by sizeof. */
|
||||
#undef SIZEOF_LONG
|
||||
|
||||
/* The size of `long long', as computed by sizeof. */
|
||||
#undef SIZEOF_LONG_LONG
|
||||
|
||||
/* The size of `short', as computed by sizeof. */
|
||||
#undef SIZEOF_SHORT
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
@ -303,6 +282,9 @@
|
||||
/* needed on HP-UX */
|
||||
#undef _HPUX_SOURCE
|
||||
|
||||
/* define on AIX to get certain functions */
|
||||
#undef _SUN
|
||||
|
||||
/* define if your compiler allows __attribute__((format)) to be applied to
|
||||
function pointers */
|
||||
#undef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS
|
||||
|
112
configure.in
112
configure.in
@ -29,7 +29,7 @@ AC_C___ATTRIBUTE__
|
||||
if test "$ac_cv___attribute__" = "yes"; then
|
||||
AC_C___ATTRIBUTE___FORMAT_FUNCTION_POINTER
|
||||
fi
|
||||
AC_CHECK_HEADERS(fcntl.h rpc/rpcent.h netdnet/dnetdb.h)
|
||||
AC_CHECK_HEADERS(fcntl.h rpc/rpc.h rpc/rpcent.h netdnet/dnetdb.h)
|
||||
AC_CHECK_HEADERS(net/pfvar.h, , , [#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <net/if.h>])
|
||||
@ -60,6 +60,33 @@ AC_HEADER_TIME
|
||||
|
||||
case "$host_os" in
|
||||
|
||||
darwin*)
|
||||
AC_ARG_ENABLE(universal,
|
||||
AC_HELP_STRING([--disable-universal],[don't build universal on OS X]))
|
||||
if test "$enable_universal" != "no"; then
|
||||
case "$host_os" in
|
||||
|
||||
darwin9.*)
|
||||
#
|
||||
# Leopard. Build for x86 and 32-bit PowerPC, with
|
||||
# x86 first. (That's what Apple does.)
|
||||
#
|
||||
V_CCOPT="$V_CCOPT -arch i386 -arch ppc"
|
||||
LDFLAGS="$LDFLAGS -arch i386 -arch ppc"
|
||||
;;
|
||||
|
||||
darwin10.*)
|
||||
#
|
||||
# Snow Leopard. Build for x86-64 and x86, with
|
||||
# x86-64 first. (That's what Apple does.)
|
||||
#
|
||||
V_CCOPT="$V_CCOPT -arch x86_64 -arch i386"
|
||||
LDFLAGS="$LDFLAGS -arch x86_64 -arch i386"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
;;
|
||||
|
||||
linux*)
|
||||
AC_MSG_CHECKING(Linux kernel version)
|
||||
if test "$cross_compiling" = yes; then
|
||||
@ -172,7 +199,7 @@ AC_ARG_ENABLE(ipv6,
|
||||
--disable-ipv6 disable ipv6 support],
|
||||
[ case "$enableval" in
|
||||
yes) AC_MSG_RESULT(yes)
|
||||
LOCALSRC="print-ip6.c print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c $LOCALSRC"
|
||||
LOCALSRC="print-ip6.c print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c print-babel.c $LOCALSRC"
|
||||
AC_DEFINE(INET6)
|
||||
ipv6=yes
|
||||
;;
|
||||
@ -194,7 +221,7 @@ main()
|
||||
}
|
||||
],
|
||||
[ AC_MSG_RESULT(yes)
|
||||
LOCALSRC="print-ip6.c print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c $LOCALSRC"
|
||||
LOCALSRC="print-ip6.c print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c print-babel.c $LOCALSRC"
|
||||
AC_DEFINE(INET6)
|
||||
ipv6=yes],
|
||||
[ AC_MSG_RESULT(no)
|
||||
@ -467,15 +494,6 @@ if test "$td_cv_decl_netdnet_dnetdb_h_dnet_htoa" = yes; then
|
||||
AC_DEFINE(HAVE_NETDNET_DNETDB_H_DNET_HTOA)
|
||||
fi
|
||||
|
||||
dnl
|
||||
dnl check sizeof basic types.
|
||||
dnl They're very likely to be wrong for cross-compiling.
|
||||
AC_CHECK_SIZEOF(char, 1)
|
||||
AC_CHECK_SIZEOF(short, 2)
|
||||
AC_CHECK_SIZEOF(int, 4)
|
||||
AC_CHECK_SIZEOF(long, 4)
|
||||
AC_CHECK_SIZEOF(long long, 8)
|
||||
|
||||
dnl
|
||||
dnl Checks for addrinfo structure
|
||||
AC_STRUCT_ADDRINFO(ac_cv_addrinfo)
|
||||
@ -504,34 +522,8 @@ if test "$ac_cv_sa_storage" = no; then
|
||||
missing_includes=yes
|
||||
fi
|
||||
|
||||
dnl
|
||||
dnl Checks for IN[6]ADDRSZ
|
||||
AC_CHECK_ADDRSZ(ac_cv_addrsz)
|
||||
if test "$ac_cv_addrsz" = no; then
|
||||
missing_includes=yes
|
||||
fi
|
||||
|
||||
dnl
|
||||
dnl Checks for RES_USE_INET6
|
||||
AC_CHECK_RES_USE_INET6(ac_cv_res_inet6)
|
||||
if test "$ac_cv_res_inet6" = no; then
|
||||
missing_includes=yes
|
||||
fi
|
||||
|
||||
dnl
|
||||
dnl Checks for res_state_ext structure
|
||||
AC_STRUCT_RES_STATE_EXT(ac_cv_res_state_ext)
|
||||
if test "$ac_cv_res_state_ext" = no; then
|
||||
missing_includes=yes
|
||||
fi
|
||||
|
||||
dnl
|
||||
dnl Checks if res_state structure has nsort member.
|
||||
AC_STRUCT_RES_STATE(ac_cv_res_state)
|
||||
|
||||
|
||||
AC_REPLACE_FUNCS(vfprintf strcasecmp strlcat strlcpy strdup strsep)
|
||||
AC_CHECK_FUNCS(strftime)
|
||||
AC_CHECK_FUNCS(fork vfork strftime)
|
||||
AC_CHECK_FUNCS(setlinebuf alarm)
|
||||
|
||||
needsnprintf=no
|
||||
@ -723,8 +715,17 @@ fi
|
||||
|
||||
#
|
||||
# Do we have the new open API? Check for pcap_create, and assume that,
|
||||
# if we do, we also have pcap_activate() and the other new routines.
|
||||
# if we do, we also have pcap_activate() and the other new routines
|
||||
# introduced in libpcap 1.0.0.
|
||||
#
|
||||
AC_CHECK_FUNCS(pcap_create)
|
||||
if test $ac_cv_func_pcap_create = "yes" ; then
|
||||
#
|
||||
# OK, do we have pcap_set_tstamp_type? If so, assume we have
|
||||
# pcap_list_tstamp_types and pcap_free_tstamp_types as well.
|
||||
#
|
||||
AC_CHECK_FUNCS(pcap_set_tstamp_type)
|
||||
fi
|
||||
|
||||
AC_CHECK_FUNCS(pcap_findalldevs pcap_dump_flush pcap_lib_version)
|
||||
if test $ac_cv_func_pcap_findalldevs = "yes" ; then
|
||||
@ -803,7 +804,7 @@ case "$host_os" in
|
||||
|
||||
aix*)
|
||||
dnl Workaround to enable certain features
|
||||
AC_DEFINE(_SUN)
|
||||
AC_DEFINE(_SUN,1,[define on AIX to get certain functions])
|
||||
;;
|
||||
|
||||
hpux*)
|
||||
@ -849,16 +850,6 @@ if test -f /dev/bpf0 ; then
|
||||
V_GROUP=bpf
|
||||
fi
|
||||
|
||||
#
|
||||
# Check for some headers introduced in later versions of libpcap
|
||||
# and used by some printers.
|
||||
#
|
||||
savedcppflags="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS $V_INCLS"
|
||||
AC_CHECK_HEADERS(pcap/bluetooth.h)
|
||||
AC_CHECK_HEADERS(pcap/usb.h)
|
||||
CPPFLAGS="$savedcppflags"
|
||||
|
||||
AC_CHECK_HEADERS(sys/bitypes.h)
|
||||
|
||||
AC_CHECK_TYPE([int8_t], ,
|
||||
@ -980,6 +971,19 @@ if test "$ac_lbl_inttypes_h_defines_formats" = no; then
|
||||
])
|
||||
fi
|
||||
|
||||
#
|
||||
# Check for some headers introduced in later versions of libpcap
|
||||
# and used by some printers.
|
||||
#
|
||||
# Those headers use the {u_}intN_t types, so we must do this after
|
||||
# we check for what's needed to get them defined.
|
||||
#
|
||||
savedcppflags="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS $V_INCLS"
|
||||
AC_CHECK_HEADERS(pcap/bluetooth.h,,,[#include <tcpdump-stdinc.h>])
|
||||
AC_CHECK_HEADERS(pcap/usb.h,,,[#include <tcpdump-stdinc.h>])
|
||||
CPPFLAGS="$savedcppflags"
|
||||
|
||||
AC_PROG_RANLIB
|
||||
|
||||
AC_LBL_DEVEL(V_CCOPT)
|
||||
@ -1063,8 +1067,10 @@ if test "$want_libcrypto" != "no"; then
|
||||
fi
|
||||
AC_CHECK_LIB(crypto, DES_cbc_encrypt)
|
||||
|
||||
savedppflags="$CPPLAGS"
|
||||
CPPFLAGS="$CPPFLAGS $V_INCLS"
|
||||
AC_CHECK_HEADERS(openssl/evp.h)
|
||||
CPPFLAGS="$savedcppflags"
|
||||
else
|
||||
#
|
||||
# Not found. Did the user explicitly ask for it?
|
||||
@ -1079,8 +1085,8 @@ fi
|
||||
dnl
|
||||
dnl set additional include path if necessary
|
||||
if test "$missing_includes" = "yes"; then
|
||||
CPPFLAGS="$CPPFLAGS -I\$(srcdir)/missing"
|
||||
V_INCLS="$V_INCLS -I\$(srcdir)/missing"
|
||||
CPPFLAGS="$CPPFLAGS -I$srcdir/missing"
|
||||
V_INCLS="$V_INCLS -I$srcdir/missing"
|
||||
fi
|
||||
|
||||
AC_SUBST(V_CCOPT)
|
||||
|
4
cpack.c
4
cpack.c
@ -38,7 +38,7 @@
|
||||
#include "cpack.h"
|
||||
#include "extract.h"
|
||||
|
||||
static u_int8_t *
|
||||
u_int8_t *
|
||||
cpack_next_boundary(u_int8_t *buf, u_int8_t *p, size_t alignment)
|
||||
{
|
||||
size_t misalignment = (size_t)(p - buf) % alignment;
|
||||
@ -53,7 +53,7 @@ cpack_next_boundary(u_int8_t *buf, u_int8_t *p, size_t alignment)
|
||||
* wordsize bytes remain in the buffer after the boundary. Otherwise,
|
||||
* return a pointer to the boundary.
|
||||
*/
|
||||
static u_int8_t *
|
||||
u_int8_t *
|
||||
cpack_align_and_reserve(struct cpack_state *cs, size_t wordsize)
|
||||
{
|
||||
u_int8_t *next;
|
||||
|
3
cpack.h
3
cpack.h
@ -43,6 +43,9 @@ int cpack_uint16(struct cpack_state *, u_int16_t *);
|
||||
int cpack_uint32(struct cpack_state *, u_int32_t *);
|
||||
int cpack_uint64(struct cpack_state *, u_int64_t *);
|
||||
|
||||
u_int8_t *cpack_next_boundary(u_int8_t *buf, u_int8_t *p, size_t alignment);
|
||||
u_int8_t *cpack_align_and_reserve(struct cpack_state *cs, size_t wordsize);
|
||||
|
||||
#define cpack_int8(__s, __p) cpack_uint8((__s), (u_int8_t*)(__p))
|
||||
#define cpack_int16(__s, __p) cpack_uint16((__s), (u_int16_t*)(__p))
|
||||
#define cpack_int32(__s, __p) cpack_uint32((__s), (u_int32_t*)(__p))
|
||||
|
14
ethertype.h
14
ethertype.h
@ -103,6 +103,20 @@
|
||||
#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
|
||||
|
2
forces.h
2
forces.h
@ -585,7 +585,7 @@ int pkeyitlv_print(register const u_char * pptr, register u_int len,
|
||||
u_int16_t op_msk, int indent);
|
||||
|
||||
int pdatacnt_print(register const u_char * pptr, register u_int len,
|
||||
u_int32_t IDcnt, u_int16_t op_msk, int indent);
|
||||
u_int16_t IDcnt, u_int16_t op_msk, int indent);
|
||||
int pdata_print(register const u_char * pptr, register u_int len,
|
||||
u_int16_t op_msk, int indent);
|
||||
|
||||
|
@ -158,6 +158,10 @@ struct ieee80211_radiotap_header {
|
||||
* Unitless indication of the Rx/Tx antenna for this packet.
|
||||
* The first antenna is antenna 0.
|
||||
*
|
||||
* IEEE80211_RADIOTAP_RX_FLAGS u_int16_t bitmap
|
||||
*
|
||||
* Properties of received frames. See flags defined below.
|
||||
*
|
||||
* IEEE80211_RADIOTAP_XCHANNEL u_int32_t bitmap
|
||||
* u_int16_t MHz
|
||||
* u_int8_t channel number
|
||||
@ -168,6 +172,25 @@ struct ieee80211_radiotap_header {
|
||||
* finally the maximum regulatory transmit power cap in .5 dBm
|
||||
* units. This property supersedes IEEE80211_RADIOTAP_CHANNEL
|
||||
* and only one of the two should be present.
|
||||
*
|
||||
* IEEE80211_RADIOTAP_MCS u_int8_t known
|
||||
* u_int8_t flags
|
||||
* u_int8_t mcs
|
||||
*
|
||||
* Bitset indicating which fields have known values, followed
|
||||
* by bitset of flag values, followed by the MCS rate index as
|
||||
* in IEEE 802.11n.
|
||||
*
|
||||
* IEEE80211_RADIOTAP_VENDOR_NAMESPACE
|
||||
* u_int8_t OUI[3]
|
||||
* u_int8_t subspace
|
||||
* u_int16_t length
|
||||
*
|
||||
* The Vendor Namespace Field contains three sub-fields. The first
|
||||
* sub-field is 3 bytes long. It contains the vendor's IEEE 802
|
||||
* Organizationally Unique Identifier (OUI). The fourth byte is a
|
||||
* vendor-specific "namespace selector."
|
||||
*
|
||||
*/
|
||||
enum ieee80211_radiotap_type {
|
||||
IEEE80211_RADIOTAP_TSFT = 0,
|
||||
@ -184,8 +207,12 @@ enum ieee80211_radiotap_type {
|
||||
IEEE80211_RADIOTAP_ANTENNA = 11,
|
||||
IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12,
|
||||
IEEE80211_RADIOTAP_DB_ANTNOISE = 13,
|
||||
IEEE80211_RADIOTAP_RX_FLAGS = 14,
|
||||
/* NB: gap for netbsd definitions */
|
||||
IEEE80211_RADIOTAP_XCHANNEL = 18,
|
||||
IEEE80211_RADIOTAP_MCS = 19,
|
||||
IEEE80211_RADIOTAP_NAMESPACE = 29,
|
||||
IEEE80211_RADIOTAP_VENDOR_NAMESPACE = 30,
|
||||
IEEE80211_RADIOTAP_EXT = 31
|
||||
};
|
||||
|
||||
@ -206,6 +233,19 @@ enum ieee80211_radiotap_type {
|
||||
#define IEEE80211_CHAN_HT40U 0x20000 /* HT 40 channel w/ ext above */
|
||||
#define IEEE80211_CHAN_HT40D 0x40000 /* HT 40 channel w/ ext below */
|
||||
|
||||
/* Useful combinations of channel characteristics, borrowed from Ethereal */
|
||||
#define IEEE80211_CHAN_A \
|
||||
(IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM)
|
||||
#define IEEE80211_CHAN_B \
|
||||
(IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_CCK)
|
||||
#define IEEE80211_CHAN_G \
|
||||
(IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN)
|
||||
#define IEEE80211_CHAN_TA \
|
||||
(IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_TURBO)
|
||||
#define IEEE80211_CHAN_TG \
|
||||
(IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN | IEEE80211_CHAN_TURBO)
|
||||
|
||||
|
||||
/* For IEEE80211_RADIOTAP_FLAGS */
|
||||
#define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received
|
||||
* during CFP
|
||||
@ -226,6 +266,26 @@ enum ieee80211_radiotap_type {
|
||||
* (to 32-bit boundary)
|
||||
*/
|
||||
#define IEEE80211_RADIOTAP_F_BADFCS 0x40 /* does not pass FCS check */
|
||||
#define IEEE80211_RADIOTAP_F_SHORTGI 0x80 /* HT short GI */
|
||||
|
||||
/* For IEEE80211_RADIOTAP_RX_FLAGS */
|
||||
#define IEEE80211_RADIOTAP_F_RX_BADFCS 0x0001 /* frame failed crc check */
|
||||
#define IEEE80211_RADIOTAP_F_RX_PLCP_CRC 0x0002 /* frame failed PLCP CRC check */
|
||||
|
||||
/* For IEEE80211_RADIOTAP_MCS known */
|
||||
#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN 0x01
|
||||
#define IEEE80211_RADIOTAP_MCS_MCS_INDEX_KNOWN 0x02 /* MCS index field */
|
||||
#define IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN 0x04
|
||||
#define IEEE80211_RADIOTAP_MCS_HT_FORMAT_KNOWN 0x08
|
||||
#define IEEE80211_RADIOTAP_MCS_FEC_TYPE_KNOWN 0x10
|
||||
|
||||
/* For IEEE80211_RADIOTAP_MCS flags */
|
||||
#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK 0x03
|
||||
#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20 0
|
||||
#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_40 1
|
||||
#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20L 2
|
||||
#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20U 3
|
||||
#define IEEE80211_RADIOTAP_MCS_SHORT_GI 0x04 /* short guard interval */
|
||||
#define IEEE80211_RADIOTAP_MCS_HT_GREENFIELD 0x08
|
||||
#define IEEE80211_RADIOTAP_MCS_FEC_LDPC 0x10
|
||||
|
||||
#endif /* _NET_IF_IEEE80211RADIOTAP_H_ */
|
||||
|
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 <tcpdump-stdinc.h>
|
||||
|
||||
#include "interface.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);}
|
||||
|
||||
u_int16_t
|
||||
in_cksum(const struct cksum_vec *vec, int veclen)
|
||||
{
|
||||
register const u_int16_t *w;
|
||||
register int sum = 0;
|
||||
register int mlen = 0;
|
||||
int byte_swapped = 0;
|
||||
|
||||
union {
|
||||
u_int8_t c[2];
|
||||
u_int16_t s;
|
||||
} s_util;
|
||||
union {
|
||||
u_int16_t s[2];
|
||||
u_int32_t l;
|
||||
} l_util;
|
||||
|
||||
for (; veclen != 0; vec++, veclen--) {
|
||||
if (vec->len == 0)
|
||||
continue;
|
||||
w = (const u_int16_t *)(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 u_int8_t *)w;
|
||||
sum += s_util.s;
|
||||
w = (const u_int16_t *)(void *)((const u_int8_t *)w + 1);
|
||||
mlen = vec->len - 1;
|
||||
} else
|
||||
mlen = vec->len;
|
||||
/*
|
||||
* Force to even boundary.
|
||||
*/
|
||||
if ((1 & (unsigned long) w) && (mlen > 0)) {
|
||||
REDUCE;
|
||||
sum <<= 8;
|
||||
s_util.c[0] = *(const u_int8_t *)w;
|
||||
w = (const u_int16_t *)(void *)((const u_int8_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 u_int8_t *)w;
|
||||
sum += s_util.s;
|
||||
mlen = 0;
|
||||
} else
|
||||
mlen = -1;
|
||||
} else if (mlen == -1)
|
||||
s_util.c[0] = *(const u_int8_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.
|
||||
*/
|
||||
u_int16_t
|
||||
in_cksum_shouldbe(u_int16_t sum, u_int16_t computed_sum)
|
||||
{
|
||||
u_int32_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;
|
||||
}
|
24
interface.h
24
interface.h
@ -28,10 +28,6 @@
|
||||
#include "os-proto.h"
|
||||
#endif
|
||||
|
||||
#ifndef HAVE___ATTRIBUTE__
|
||||
#define __attribute__(x)
|
||||
#endif
|
||||
|
||||
/* snprintf et al */
|
||||
|
||||
#include <stdarg.h>
|
||||
@ -74,6 +70,7 @@ extern char *strsep(char **, const char *);
|
||||
#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 */
|
||||
|
||||
#ifndef min
|
||||
#define min(a,b) ((a)>(b)?(b):(a))
|
||||
@ -166,7 +163,6 @@ extern void hex_and_ascii_print(const char *, const u_char *, u_int);
|
||||
extern void hex_print_with_offset(const char *, const u_char *, u_int, u_int);
|
||||
extern void hex_print(const char *, const u_char *, u_int);
|
||||
extern void telnet_print(const u_char *, u_int);
|
||||
extern int ethertype_print(u_short, const u_char *, u_int, u_int);
|
||||
extern int llc_print(const u_char *, u_int, u_int, const u_char *,
|
||||
const u_char *, u_short *);
|
||||
extern int snap_print(const u_char *, u_int, u_int, u_int);
|
||||
@ -189,9 +185,6 @@ extern u_int enc_if_print(const struct pcap_pkthdr *, const u_char *);
|
||||
extern u_int pflog_if_print(const struct pcap_pkthdr *, const u_char *);
|
||||
extern u_int arcnet_if_print(const struct pcap_pkthdr *, const u_char *);
|
||||
extern u_int arcnet_linux_if_print(const struct pcap_pkthdr *, const u_char *);
|
||||
extern void ether_print(const u_char *, u_int, u_int,
|
||||
void (*)(const u_char *), const u_char *);
|
||||
extern u_int ether_if_print(const struct pcap_pkthdr *, const u_char *);
|
||||
extern u_int token_print(const u_char *, u_int, u_int);
|
||||
extern u_int token_if_print(const struct pcap_pkthdr *, const u_char *);
|
||||
extern void fddi_print(const u_char *, u_int, u_int);
|
||||
@ -231,6 +224,7 @@ extern void cisco_autorp_print(const u_char *, u_int);
|
||||
extern void rsvp_print(const u_char *, u_int);
|
||||
extern void ldp_print(const u_char *, u_int);
|
||||
extern void lldp_print(const u_char *, u_int);
|
||||
extern void rpki_rtr_print(const u_char *, u_int);
|
||||
extern void lmp_print(const u_char *, u_int);
|
||||
extern void lspping_print(const u_char *, u_int);
|
||||
extern void lwapp_control_print(const u_char *, u_int, int);
|
||||
@ -297,6 +291,7 @@ extern const char *nt_errstr(u_int32_t);
|
||||
extern void print_data(const unsigned char *, int);
|
||||
extern void l2tp_print(const u_char *, u_int);
|
||||
extern void vrrp_print(const u_char *, u_int, int);
|
||||
extern void carp_print(const u_char *, u_int, int);
|
||||
extern void slow_print(const u_char *, u_int);
|
||||
extern void sflow_print(const u_char *, u_int);
|
||||
extern void mpcp_print(const u_char *, u_int);
|
||||
@ -322,10 +317,9 @@ extern u_int bt_if_print(const struct pcap_pkthdr *, const u_char *);
|
||||
extern u_int usb_linux_48_byte_print(const struct pcap_pkthdr *, const u_char *);
|
||||
extern u_int usb_linux_64_byte_print(const struct pcap_pkthdr *, const u_char *);
|
||||
|
||||
|
||||
#ifdef INET6
|
||||
extern void ip6_print(const u_char *, u_int);
|
||||
extern void ip6_opt_print(const u_char *, int);
|
||||
extern int nextproto6_cksum(const struct ip6_hdr *, const u_short *, u_int, u_int);
|
||||
extern int hbhopt_print(const u_char *);
|
||||
extern int dstopt_print(const u_char *);
|
||||
extern int frag6_print(const u_char *, const u_char *);
|
||||
@ -334,9 +328,15 @@ extern void ripng_print(const u_char *, unsigned int);
|
||||
extern int rt6_print(const u_char *, const u_char *);
|
||||
extern void ospf6_print(const u_char *, u_int);
|
||||
extern void dhcp6_print(const u_char *, u_int);
|
||||
extern void babel_print(const u_char *, u_int);
|
||||
extern int mask62plen(const u_char *);
|
||||
#endif /*INET6*/
|
||||
extern u_short in_cksum(const u_short *, register u_int, int);
|
||||
|
||||
struct cksum_vec {
|
||||
const u_int8_t *ptr;
|
||||
int len;
|
||||
};
|
||||
extern u_int16_t in_cksum(const struct cksum_vec *, int);
|
||||
extern u_int16_t in_cksum_shouldbe(u_int16_t, u_int16_t);
|
||||
|
||||
#ifndef HAVE_BPF_DUMP
|
||||
@ -356,6 +356,7 @@ extern netdissect_options *gndo;
|
||||
#define bflag gndo->ndo_bflag
|
||||
#define eflag gndo->ndo_eflag
|
||||
#define fflag gndo->ndo_fflag
|
||||
#define jflag gndo->ndo_jflag
|
||||
#define Kflag gndo->ndo_Kflag
|
||||
#define nflag gndo->ndo_nflag
|
||||
#define Nflag gndo->ndo_Nflag
|
||||
@ -384,6 +385,7 @@ extern netdissect_options *gndo;
|
||||
#define Cflag_count gndo->ndo_Cflag_count
|
||||
#define Gflag_count gndo->ndo_Gflag_count
|
||||
#define Gflag_time gndo->ndo_Gflag_time
|
||||
#define Hflag gndo->ndo_Hflag
|
||||
#define snaplen gndo->ndo_snaplen
|
||||
#define snapend gndo->ndo_snapend
|
||||
|
||||
|
6
ip.h
6
ip.h
@ -62,7 +62,7 @@ struct ip {
|
||||
u_int8_t ip_p; /* protocol */
|
||||
u_int16_t ip_sum; /* checksum */
|
||||
struct in_addr ip_src,ip_dst; /* source and dest address */
|
||||
};
|
||||
} UNALIGNED;
|
||||
|
||||
#define IP_MAXPACKET 65535 /* maximum packet size */
|
||||
|
||||
@ -134,7 +134,7 @@ struct ip_timestamp {
|
||||
u_int32_t ipt_time;
|
||||
} ipt_ta[1];
|
||||
} ipt_timestamp;
|
||||
};
|
||||
} UNALIGNED;
|
||||
|
||||
/* flag bits for ipt_flg */
|
||||
#define IPOPT_TS_TSONLY 0 /* timestamps only */
|
||||
@ -161,4 +161,4 @@ struct ip_timestamp {
|
||||
#define IP_MSS 576 /* default maximum segment size */
|
||||
|
||||
/* in print-ip.c */
|
||||
extern u_int32_t ip_finddst(const struct ip *);
|
||||
extern int nextproto4_cksum(const struct ip *, const u_int8_t *, u_int, u_int);
|
||||
|
37
ip6.h
37
ip6.h
@ -86,21 +86,7 @@ struct ip6_hdr {
|
||||
} ip6_ctlun;
|
||||
struct in6_addr ip6_src; /* source address */
|
||||
struct in6_addr ip6_dst; /* destination address */
|
||||
};
|
||||
|
||||
/*
|
||||
* Pseudo header, used for higher layer checksumming.
|
||||
*/
|
||||
union ip6_pseudo_hdr {
|
||||
struct {
|
||||
struct in6_addr ph_src;
|
||||
struct in6_addr ph_dst;
|
||||
u_int32_t ph_len;
|
||||
u_int8_t ph_zero[3];
|
||||
u_int8_t ph_nxt;
|
||||
} ph;
|
||||
u_int16_t pa[20];
|
||||
};
|
||||
} UNALIGNED;
|
||||
|
||||
#define ip6_vfc ip6_ctlun.ip6_un2_vfc
|
||||
#define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow
|
||||
@ -123,25 +109,23 @@ union ip6_pseudo_hdr {
|
||||
*/
|
||||
|
||||
struct ip6_ext {
|
||||
u_char ip6e_nxt;
|
||||
u_char ip6e_len;
|
||||
};
|
||||
u_int8_t ip6e_nxt;
|
||||
u_int8_t ip6e_len;
|
||||
} UNALIGNED;
|
||||
|
||||
/* Hop-by-Hop options header */
|
||||
/* XXX should we pad it to force alignment on an 8-byte boundary? */
|
||||
struct ip6_hbh {
|
||||
u_int8_t ip6h_nxt; /* next header */
|
||||
u_int8_t ip6h_len; /* length in units of 8 octets */
|
||||
/* followed by options */
|
||||
};
|
||||
} UNALIGNED;
|
||||
|
||||
/* Destination options header */
|
||||
/* XXX should we pad it to force alignment on an 8-byte boundary? */
|
||||
struct ip6_dest {
|
||||
u_int8_t ip6d_nxt; /* next header */
|
||||
u_int8_t ip6d_len; /* length in units of 8 octets */
|
||||
/* followed by options */
|
||||
};
|
||||
} UNALIGNED;
|
||||
|
||||
/* Option types and related macros */
|
||||
#define IP6OPT_PAD1 0x00 /* 00 0 00000 */
|
||||
@ -177,7 +161,7 @@ struct ip6_rthdr {
|
||||
u_int8_t ip6r_type; /* routing type */
|
||||
u_int8_t ip6r_segleft; /* segments left */
|
||||
/* followed by routing type specific data */
|
||||
};
|
||||
} UNALIGNED;
|
||||
|
||||
/* Type 0 Routing header */
|
||||
struct ip6_rthdr0 {
|
||||
@ -188,7 +172,7 @@ struct ip6_rthdr0 {
|
||||
u_int8_t ip6r0_reserved; /* reserved field */
|
||||
u_int8_t ip6r0_slmap[3]; /* strict/loose bit map */
|
||||
struct in6_addr ip6r0_addr[1]; /* up to 23 addresses */
|
||||
};
|
||||
} UNALIGNED;
|
||||
|
||||
/* Fragment header */
|
||||
struct ip6_frag {
|
||||
@ -196,10 +180,13 @@ struct ip6_frag {
|
||||
u_int8_t ip6f_reserved; /* reserved field */
|
||||
u_int16_t ip6f_offlg; /* offset, reserved, and flag */
|
||||
u_int32_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 */
|
||||
|
||||
/* in print-ip6.c */
|
||||
extern int nextproto6_cksum(const struct ip6_hdr *, const u_int8_t *, u_int, u_int);
|
||||
|
||||
#endif /* not _NETINET_IP6_H_ */
|
||||
|
@ -55,6 +55,7 @@ const struct tok ipproto_values[] = {
|
||||
{ IPPROTO_PGM, "PGM" },
|
||||
{ IPPROTO_SCTP, "SCTP" },
|
||||
{ IPPROTO_MOBILITY, "Mobility" },
|
||||
{ IPPROTO_CARP, "CARP" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
|
@ -133,6 +133,9 @@ extern const struct tok ipproto_values[];
|
||||
#ifndef IPPROTO_VRRP
|
||||
#define IPPROTO_VRRP 112
|
||||
#endif
|
||||
#ifndef IPPROTO_CARP
|
||||
#define IPPROTO_CARP 112
|
||||
#endif
|
||||
#ifndef IPPROTO_PGM
|
||||
#define IPPROTO_PGM 113
|
||||
#endif
|
||||
|
@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 1999 WIDE Project.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the project nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef INADDRSZ
|
||||
#define INADDRSZ 4 /* IPv4 T_A */
|
||||
#endif
|
||||
|
||||
#ifndef IN6ADDRSZ
|
||||
#define IN6ADDRSZ 16 /* IPv6 T_AAAA */
|
||||
#endif
|
||||
|
@ -1,117 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 1999 WIDE Project.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the project nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef HAVE_U_INT8_T
|
||||
|
||||
#if SIZEOF_CHAR == 1
|
||||
typedef unsigned char u_int8_t;
|
||||
#elif SIZEOF_INT == 1
|
||||
typedef unsigned int u_int8_t;
|
||||
#else /* XXX */
|
||||
#error "there's no appropriate type for u_int8_t"
|
||||
#endif
|
||||
|
||||
#endif /* HAVE_U_INT8_T */
|
||||
|
||||
#ifndef HAVE_U_INT16_T
|
||||
|
||||
#if SIZEOF_SHORT == 2
|
||||
typedef unsigned short u_int16_t;
|
||||
#elif SIZEOF_INT == 2
|
||||
typedef unsigned int u_int16_t;
|
||||
#elif SIZEOF_CHAR == 2
|
||||
typedef unsigned char u_int16_t;
|
||||
#else /* XXX */
|
||||
#error "there's no appropriate type for u_int16_t"
|
||||
#endif
|
||||
|
||||
#endif /* HAVE_U_INT16_T */
|
||||
|
||||
#ifndef HAVE_U_INT32_T
|
||||
|
||||
#if SIZEOF_INT == 4
|
||||
typedef unsigned int u_int32_t;
|
||||
#elif SIZEOF_LONG == 4
|
||||
typedef unsigned long u_int32_t;
|
||||
#elif SIZEOF_SHORT == 4
|
||||
typedef unsigned short u_int32_t;
|
||||
#else /* XXX */
|
||||
#error "there's no appropriate type for u_int32_t"
|
||||
#endif
|
||||
|
||||
#endif /* HAVE_U_INT32_T */
|
||||
|
||||
#ifndef HAVE_U_INT64_T
|
||||
|
||||
#if SIZEOF_LONG_LONG == 8
|
||||
typedef unsigned long long u_int64_t;
|
||||
#elif defined(_MSC_EXTENSIONS)
|
||||
typedef unsigned _int64 u_int64_t;
|
||||
#elif SIZEOF_INT == 8
|
||||
typedef unsigned int u_int64_t;
|
||||
#elif SIZEOF_LONG == 8
|
||||
typedef unsigned long u_int64_t;
|
||||
#elif SIZEOF_SHORT == 8
|
||||
typedef unsigned short u_int64_t;
|
||||
#else /* XXX */
|
||||
#error "there's no appropriate type for u_int64_t"
|
||||
#endif
|
||||
|
||||
#endif /* HAVE_U_INT64_T */
|
||||
|
||||
#ifndef PRId64
|
||||
#ifdef _MSC_EXTENSIONS
|
||||
#define PRId64 "I64d"
|
||||
#else /* _MSC_EXTENSIONS */
|
||||
#define PRId64 "lld"
|
||||
#endif /* _MSC_EXTENSIONS */
|
||||
#endif /* PRId64 */
|
||||
|
||||
#ifndef PRIo64
|
||||
#ifdef _MSC_EXTENSIONS
|
||||
#define PRIo64 "I64o"
|
||||
#else /* _MSC_EXTENSIONS */
|
||||
#define PRIo64 "llo"
|
||||
#endif /* _MSC_EXTENSIONS */
|
||||
#endif /* PRIo64 */
|
||||
|
||||
#ifndef PRIx64
|
||||
#ifdef _MSC_EXTENSIONS
|
||||
#define PRIx64 "I64x"
|
||||
#else /* _MSC_EXTENSIONS */
|
||||
#define PRIx64 "llx"
|
||||
#endif /* _MSC_EXTENSIONS */
|
||||
#endif /* PRIx64 */
|
||||
|
||||
#ifndef PRIu64
|
||||
#ifdef _MSC_EXTENSIONS
|
||||
#define PRIu64 "I64u"
|
||||
#else /* _MSC_EXTENSIONS */
|
||||
#define PRIu64 "llu"
|
||||
#endif /* _MSC_EXTENSIONS */
|
||||
#endif /* PRIu64 */
|
@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 1999 WIDE Project.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the project nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Resolver options for IPv6.
|
||||
* XXX: this should be in an offical include file. There may be conflicts...
|
||||
*/
|
||||
#ifndef HAVE_RES_USE_INET6
|
||||
#define RES_USE_INET6 0x80000000 /* use/map IPv6 in gethostbyname() */
|
||||
#endif
|
@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 1999 WIDE Project.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the project nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MAXRESOLVSORT /* XXX */
|
||||
#define MAXRESOLVSORT 10 /* number of net to sort on */
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_RES_STATE_EXT
|
||||
struct __res_state_ext {
|
||||
struct sockaddr_storage nsaddr_list[MAXNS];
|
||||
struct {
|
||||
int af; /* address family for addr, mask */
|
||||
union {
|
||||
struct in_addr ina;
|
||||
#ifdef INET6
|
||||
struct in6_addr in6a;
|
||||
#endif
|
||||
} addr, mask;
|
||||
} sort_list[MAXRESOLVSORT];
|
||||
};
|
||||
#endif
|
||||
|
||||
extern struct __res_state_ext _res_ext;
|
53
netdissect.h
53
netdissect.h
@ -107,6 +107,7 @@ struct netdissect_options {
|
||||
int ndo_Iflag; /* rfmon (monitor) mode */
|
||||
int ndo_Oflag; /* run filter code optimizer */
|
||||
int ndo_dlt; /* if != -1, ask libpcap for the DLT it names*/
|
||||
int ndo_jflag; /* packet time stamp source */
|
||||
int ndo_pflag; /* don't go promiscuous */
|
||||
|
||||
int ndo_Cflag; /* rotate dump files after this many bytes */
|
||||
@ -116,6 +117,7 @@ struct netdissect_options {
|
||||
time_t ndo_Gflag_time; /* The last time_t the dump file was rotated. */
|
||||
int ndo_Wflag; /* recycle output files after this number of files */
|
||||
int ndo_WflagChars;
|
||||
int ndo_Hflag; /* dissect 802.11s draft mesh standard */
|
||||
int ndo_suppress_default_print; /* don't use default_print() for unknown packet types */
|
||||
const char *ndo_dltname;
|
||||
|
||||
@ -157,7 +159,7 @@ struct netdissect_options {
|
||||
void (*ndo_error)(netdissect_options *,
|
||||
const char *fmt, ...)
|
||||
#ifdef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS
|
||||
__attribute__ ((format (printf, 2, 3)))
|
||||
__attribute__ ((noreturn, format (printf, 2, 3)))
|
||||
#endif
|
||||
;
|
||||
void (*ndo_warning)(netdissect_options *,
|
||||
@ -252,6 +254,9 @@ extern char *copy_argv(netdissect_options *, char **);
|
||||
extern void safeputchar(int);
|
||||
extern void safeputs(const char *, int);
|
||||
|
||||
#define PLURAL_SUFFIX(n) \
|
||||
(((n) != 1) ? "s" : "")
|
||||
|
||||
#if 0
|
||||
extern const char *isonsap_string(netdissect_options *, const u_char *);
|
||||
extern const char *protoid_string(netdissect_options *, const u_char *);
|
||||
@ -263,6 +268,12 @@ extern const char *dnnum_string(netdissect_options *, u_short);
|
||||
|
||||
#include <pcap.h>
|
||||
|
||||
typedef u_int (*if_ndo_printer)(struct netdissect_options *ndo,
|
||||
const struct pcap_pkthdr *, const u_char *);
|
||||
typedef u_int (*if_printer)(const struct pcap_pkthdr *, const u_char *);
|
||||
|
||||
extern if_ndo_printer lookup_ndo_printer(int);
|
||||
extern if_printer lookup_printer(int);
|
||||
|
||||
extern void eap_print(netdissect_options *,const u_char *, u_int);
|
||||
extern int esp_print(netdissect_options *,
|
||||
@ -281,6 +292,22 @@ extern void ip_print_inner(netdissect_options *ndo,
|
||||
const u_char *bp2);
|
||||
extern void rrcp_print(netdissect_options *,const u_char *, u_int);
|
||||
|
||||
extern void ether_print(netdissect_options *,
|
||||
const u_char *, u_int, u_int,
|
||||
void (*)(netdissect_options *, const u_char *),
|
||||
const u_char *);
|
||||
|
||||
extern u_int ether_if_print(netdissect_options *,
|
||||
const struct pcap_pkthdr *,const u_char *);
|
||||
extern u_int netanalyzer_if_print(netdissect_options *,
|
||||
const struct pcap_pkthdr *,const u_char *);
|
||||
extern u_int netanalyzer_transparent_if_print(netdissect_options *,
|
||||
const struct pcap_pkthdr *,
|
||||
const u_char *);
|
||||
|
||||
extern int ethertype_print(netdissect_options *,u_short, const u_char *,
|
||||
u_int, u_int);
|
||||
|
||||
/* stuff that has not yet been rototiled */
|
||||
#if 0
|
||||
extern void ascii_print(netdissect_options *,u_int);
|
||||
@ -291,8 +318,6 @@ extern void hex_print_with_offset(netdissect_options *,const char *,
|
||||
u_int, u_int);
|
||||
extern void hex_print(netdissect_options *,const char *, u_int);
|
||||
extern void telnet_print(netdissect_options *,const u_char *, u_int);
|
||||
extern int ethertype_print(netdissect_options *,u_short, const u_char *,
|
||||
u_int, u_int);
|
||||
extern int llc_print(netdissect_options *,
|
||||
const u_char *, u_int, u_int, const u_char *,
|
||||
const u_char *, u_short *);
|
||||
@ -319,7 +344,6 @@ extern void egp_print(netdissect_options *,const u_char *, u_int,
|
||||
const u_char *);
|
||||
|
||||
extern void arcnet_if_print(u_char*,const struct pcap_pkthdr *,const u_char *);
|
||||
extern void ether_if_print(u_char *,const struct pcap_pkthdr *,const u_char *);
|
||||
extern void token_if_print(u_char *,const struct pcap_pkthdr *,const u_char *);
|
||||
extern void fddi_if_print(u_char *,const struct pcap_pkthdr *, const u_char *);
|
||||
|
||||
@ -333,6 +357,7 @@ extern void igmp_print(netdissect_options *,
|
||||
register const u_char *, u_int);
|
||||
extern void igrp_print(netdissect_options *,const u_char *, u_int,
|
||||
const u_char *);
|
||||
extern int nextproto4_cksum(const struct ip *, const u_int8_t *, u_int, u_int);
|
||||
extern void ipN_print(netdissect_options *,const u_char *, u_int);
|
||||
extern void ipx_print(netdissect_options *,const u_char *, u_int);
|
||||
extern void isoclns_print(netdissect_options *,const u_char *,
|
||||
@ -378,6 +403,7 @@ extern void raw_if_print(u_char *,
|
||||
const struct pcap_pkthdr *, const u_char *);
|
||||
|
||||
extern void rip_print(netdissect_options *,const u_char *, u_int);
|
||||
extern void rpki_rtr_print(netdissect_options *,const u_char *, u_int);
|
||||
|
||||
extern void sctp_print(netdissect_options *ndo,
|
||||
const u_char *bp, const u_char *bp2,
|
||||
@ -424,6 +450,8 @@ extern void l2tp_print(netdissect_options *,const u_char *, u_int);
|
||||
extern void lcp_print(netdissect_options *,const u_char *, u_int);
|
||||
extern void vrrp_print(netdissect_options *,const u_char *bp,
|
||||
u_int len, int ttl);
|
||||
extern void carp_print(netdissect_options *,const u_char *bp,
|
||||
u_int len, int ttl);
|
||||
extern void cdp_print(netdissect_options *,const u_char *,
|
||||
u_int, u_int, const u_char *, const u_char *);
|
||||
extern void stp_print(netdissect_options *,const u_char *p, u_int length);
|
||||
@ -433,12 +461,15 @@ extern void pptp_print(netdissect_options *,const u_char *, u_int);
|
||||
#endif
|
||||
|
||||
extern u_int ipnet_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *);
|
||||
extern u_int ppi_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *);
|
||||
|
||||
extern u_int ieee802_15_4_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *);
|
||||
|
||||
#if 0
|
||||
#ifdef INET6
|
||||
extern void ip6_print(netdissect_options *,const u_char *, u_int);
|
||||
#if 0
|
||||
extern void ip6_opt_print(netdissect_options *,const u_char *, int);
|
||||
extern int nextproto6_cksum(const struct ip6_hdr *, const u_short *, u_int, u_int);
|
||||
extern int nextproto6_cksum(const struct ip6_hdr *, const u_int8_t *, u_int, u_int);
|
||||
extern int hbhopt_print(netdissect_options *,const u_char *);
|
||||
extern int dstopt_print(netdissect_options *,const u_char *);
|
||||
extern int frag6_print(netdissect_options *,const u_char *,
|
||||
@ -453,11 +484,17 @@ extern void dhcp6_print(netdissect_options *,const u_char *,
|
||||
|
||||
extern void zephyr_print(netdissect_options * ndo,
|
||||
const u_char *cp, int length);
|
||||
#endif /* 0 */
|
||||
|
||||
#endif /*INET6*/
|
||||
extern u_short in_cksum(const u_short *,
|
||||
register u_int, int);
|
||||
|
||||
#if 0
|
||||
struct cksum_vec {
|
||||
const u_int8_t *ptr;
|
||||
int len;
|
||||
};
|
||||
extern u_int16_t in_cksum(const struct cksum_vec *, int);
|
||||
extern u_int16_t in_cksum_shouldbe(u_int16_t, u_int16_t);
|
||||
#endif
|
||||
|
||||
extern void esp_print_decodesecret(netdissect_options *ndo);
|
||||
|
4
ospf.h
4
ospf.h
@ -324,5 +324,5 @@ struct ospfhdr {
|
||||
#define ospf_lsa ospf_un.un_lsa
|
||||
|
||||
/* Functions shared by ospf and ospf6 */
|
||||
extern int ospf_print_te_lsa(u_int8_t *, u_int);
|
||||
extern int ospf_print_grace_lsa(u_int8_t *, u_int);
|
||||
extern int ospf_print_te_lsa(const u_int8_t *, u_int);
|
||||
extern int ospf_print_grace_lsa(const u_int8_t *, u_int);
|
||||
|
1
oui.c
1
oui.c
@ -42,6 +42,7 @@ const struct tok oui_values[] = {
|
||||
{ OUI_IEEE_8021_PRIVATE, "IEEE 802.1 Private"},
|
||||
{ OUI_IEEE_8023_PRIVATE, "IEEE 802.3 Private"},
|
||||
{ OUI_TIA, "ANSI/TIA"},
|
||||
{ OUI_DCBX, "DCBX"},
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
|
1
oui.h
1
oui.h
@ -30,6 +30,7 @@ extern const struct tok smi_values[];
|
||||
#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 */
|
||||
|
||||
/*
|
||||
* These are SMI Network Management Private Enterprise Codes for
|
||||
|
9
ppi.h
Normal file
9
ppi.h
Normal file
@ -0,0 +1,9 @@
|
||||
typedef struct ppi_header {
|
||||
uint8_t ppi_ver;
|
||||
uint8_t ppi_flags;
|
||||
uint16_t ppi_len;
|
||||
uint32_t ppi_dlt;
|
||||
} ppi_header_t;
|
||||
|
||||
#define PPI_HDRLEN 8
|
||||
|
634
print-802_11.c
634
print-802_11.c
@ -46,6 +46,15 @@ static const char rcsid[] _U_ =
|
||||
#include "ieee802_11.h"
|
||||
#include "ieee802_11_radio.h"
|
||||
|
||||
/* Radiotap state */
|
||||
/* This is used to save state when parsing/processing parameters */
|
||||
struct radiotap_state
|
||||
{
|
||||
u_int32_t present;
|
||||
|
||||
u_int8_t rate;
|
||||
};
|
||||
|
||||
#define PRINT_SSID(p) \
|
||||
if (p.ssid_present) { \
|
||||
printf(" ("); \
|
||||
@ -74,26 +83,403 @@ static const char rcsid[] _U_ =
|
||||
printf("%s", \
|
||||
CAPABILITY_PRIVACY(p.capability_info) ? ", PRIVACY" : "" );
|
||||
|
||||
static const int ieee80211_htrates[16] = {
|
||||
13, /* IFM_IEEE80211_MCS0 */
|
||||
26, /* IFM_IEEE80211_MCS1 */
|
||||
39, /* IFM_IEEE80211_MCS2 */
|
||||
52, /* IFM_IEEE80211_MCS3 */
|
||||
78, /* IFM_IEEE80211_MCS4 */
|
||||
104, /* IFM_IEEE80211_MCS5 */
|
||||
117, /* IFM_IEEE80211_MCS6 */
|
||||
130, /* IFM_IEEE80211_MCS7 */
|
||||
26, /* IFM_IEEE80211_MCS8 */
|
||||
52, /* IFM_IEEE80211_MCS9 */
|
||||
78, /* IFM_IEEE80211_MCS10 */
|
||||
104, /* IFM_IEEE80211_MCS11 */
|
||||
156, /* IFM_IEEE80211_MCS12 */
|
||||
208, /* IFM_IEEE80211_MCS13 */
|
||||
234, /* IFM_IEEE80211_MCS14 */
|
||||
260, /* IFM_IEEE80211_MCS15 */
|
||||
#define MAX_MCS_INDEX 76
|
||||
|
||||
/*
|
||||
* Indices are:
|
||||
*
|
||||
* the MCS index (0-76);
|
||||
*
|
||||
* 0 for 20 MHz, 1 for 40 MHz;
|
||||
*
|
||||
* 0 for a long guard interval, 1 for a short guard interval.
|
||||
*/
|
||||
static const float ieee80211_float_htrates[MAX_MCS_INDEX+1][2][2] = {
|
||||
/* MCS 0 */
|
||||
{ /* 20 Mhz */ { 6.5, /* SGI */ 7.2, },
|
||||
/* 40 Mhz */ { 13.5, /* SGI */ 15.0, },
|
||||
},
|
||||
|
||||
/* MCS 1 */
|
||||
{ /* 20 Mhz */ { 13.0, /* SGI */ 14.4, },
|
||||
/* 40 Mhz */ { 27.0, /* SGI */ 30.0, },
|
||||
},
|
||||
|
||||
/* MCS 2 */
|
||||
{ /* 20 Mhz */ { 19.5, /* SGI */ 21.7, },
|
||||
/* 40 Mhz */ { 40.5, /* SGI */ 45.0, },
|
||||
},
|
||||
|
||||
/* MCS 3 */
|
||||
{ /* 20 Mhz */ { 26.0, /* SGI */ 28.9, },
|
||||
/* 40 Mhz */ { 54.0, /* SGI */ 60.0, },
|
||||
},
|
||||
|
||||
/* MCS 4 */
|
||||
{ /* 20 Mhz */ { 39.0, /* SGI */ 43.3, },
|
||||
/* 40 Mhz */ { 81.0, /* SGI */ 90.0, },
|
||||
},
|
||||
|
||||
/* MCS 5 */
|
||||
{ /* 20 Mhz */ { 52.0, /* SGI */ 57.8, },
|
||||
/* 40 Mhz */ { 108.0, /* SGI */ 120.0, },
|
||||
},
|
||||
|
||||
/* MCS 6 */
|
||||
{ /* 20 Mhz */ { 58.5, /* SGI */ 65.0, },
|
||||
/* 40 Mhz */ { 121.5, /* SGI */ 135.0, },
|
||||
},
|
||||
|
||||
/* MCS 7 */
|
||||
{ /* 20 Mhz */ { 65.0, /* SGI */ 72.2, },
|
||||
/* 40 Mhz */ { 135.0, /* SGI */ 150.0, },
|
||||
},
|
||||
|
||||
/* MCS 8 */
|
||||
{ /* 20 Mhz */ { 13.0, /* SGI */ 14.4, },
|
||||
/* 40 Mhz */ { 27.0, /* SGI */ 30.0, },
|
||||
},
|
||||
|
||||
/* MCS 9 */
|
||||
{ /* 20 Mhz */ { 26.0, /* SGI */ 28.9, },
|
||||
/* 40 Mhz */ { 54.0, /* SGI */ 60.0, },
|
||||
},
|
||||
|
||||
/* MCS 10 */
|
||||
{ /* 20 Mhz */ { 39.0, /* SGI */ 43.3, },
|
||||
/* 40 Mhz */ { 81.0, /* SGI */ 90.0, },
|
||||
},
|
||||
|
||||
/* MCS 11 */
|
||||
{ /* 20 Mhz */ { 52.0, /* SGI */ 57.8, },
|
||||
/* 40 Mhz */ { 108.0, /* SGI */ 120.0, },
|
||||
},
|
||||
|
||||
/* MCS 12 */
|
||||
{ /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
|
||||
/* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
|
||||
},
|
||||
|
||||
/* MCS 13 */
|
||||
{ /* 20 Mhz */ { 104.0, /* SGI */ 115.6, },
|
||||
/* 40 Mhz */ { 216.0, /* SGI */ 240.0, },
|
||||
},
|
||||
|
||||
/* MCS 14 */
|
||||
{ /* 20 Mhz */ { 117.0, /* SGI */ 130.0, },
|
||||
/* 40 Mhz */ { 243.0, /* SGI */ 270.0, },
|
||||
},
|
||||
|
||||
/* MCS 15 */
|
||||
{ /* 20 Mhz */ { 130.0, /* SGI */ 144.4, },
|
||||
/* 40 Mhz */ { 270.0, /* SGI */ 300.0, },
|
||||
},
|
||||
|
||||
/* MCS 16 */
|
||||
{ /* 20 Mhz */ { 19.5, /* SGI */ 21.7, },
|
||||
/* 40 Mhz */ { 40.5, /* SGI */ 45.0, },
|
||||
},
|
||||
|
||||
/* MCS 17 */
|
||||
{ /* 20 Mhz */ { 39.0, /* SGI */ 43.3, },
|
||||
/* 40 Mhz */ { 81.0, /* SGI */ 90.0, },
|
||||
},
|
||||
|
||||
/* MCS 18 */
|
||||
{ /* 20 Mhz */ { 58.5, /* SGI */ 65.0, },
|
||||
/* 40 Mhz */ { 121.5, /* SGI */ 135.0, },
|
||||
},
|
||||
|
||||
/* MCS 19 */
|
||||
{ /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
|
||||
/* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
|
||||
},
|
||||
|
||||
/* MCS 20 */
|
||||
{ /* 20 Mhz */ { 117.0, /* SGI */ 130.0, },
|
||||
/* 40 Mhz */ { 243.0, /* SGI */ 270.0, },
|
||||
},
|
||||
|
||||
/* MCS 21 */
|
||||
{ /* 20 Mhz */ { 156.0, /* SGI */ 173.3, },
|
||||
/* 40 Mhz */ { 324.0, /* SGI */ 360.0, },
|
||||
},
|
||||
|
||||
/* MCS 22 */
|
||||
{ /* 20 Mhz */ { 175.5, /* SGI */ 195.0, },
|
||||
/* 40 Mhz */ { 364.5, /* SGI */ 405.0, },
|
||||
},
|
||||
|
||||
/* MCS 23 */
|
||||
{ /* 20 Mhz */ { 195.0, /* SGI */ 216.7, },
|
||||
/* 40 Mhz */ { 405.0, /* SGI */ 450.0, },
|
||||
},
|
||||
|
||||
/* MCS 24 */
|
||||
{ /* 20 Mhz */ { 26.0, /* SGI */ 28.9, },
|
||||
/* 40 Mhz */ { 54.0, /* SGI */ 60.0, },
|
||||
},
|
||||
|
||||
/* MCS 25 */
|
||||
{ /* 20 Mhz */ { 52.0, /* SGI */ 57.8, },
|
||||
/* 40 Mhz */ { 108.0, /* SGI */ 120.0, },
|
||||
},
|
||||
|
||||
/* MCS 26 */
|
||||
{ /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
|
||||
/* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
|
||||
},
|
||||
|
||||
/* MCS 27 */
|
||||
{ /* 20 Mhz */ { 104.0, /* SGI */ 115.6, },
|
||||
/* 40 Mhz */ { 216.0, /* SGI */ 240.0, },
|
||||
},
|
||||
|
||||
/* MCS 28 */
|
||||
{ /* 20 Mhz */ { 156.0, /* SGI */ 173.3, },
|
||||
/* 40 Mhz */ { 324.0, /* SGI */ 360.0, },
|
||||
},
|
||||
|
||||
/* MCS 29 */
|
||||
{ /* 20 Mhz */ { 208.0, /* SGI */ 231.1, },
|
||||
/* 40 Mhz */ { 432.0, /* SGI */ 480.0, },
|
||||
},
|
||||
|
||||
/* MCS 30 */
|
||||
{ /* 20 Mhz */ { 234.0, /* SGI */ 260.0, },
|
||||
/* 40 Mhz */ { 486.0, /* SGI */ 540.0, },
|
||||
},
|
||||
|
||||
/* MCS 31 */
|
||||
{ /* 20 Mhz */ { 260.0, /* SGI */ 288.9, },
|
||||
/* 40 Mhz */ { 540.0, /* SGI */ 600.0, },
|
||||
},
|
||||
|
||||
/* MCS 32 */
|
||||
{ /* 20 Mhz */ { 0.0, /* SGI */ 0.0, }, /* not valid */
|
||||
/* 40 Mhz */ { 6.0, /* SGI */ 6.7, },
|
||||
},
|
||||
|
||||
/* MCS 33 */
|
||||
{ /* 20 Mhz */ { 39.0, /* SGI */ 43.3, },
|
||||
/* 40 Mhz */ { 81.0, /* SGI */ 90.0, },
|
||||
},
|
||||
|
||||
/* MCS 34 */
|
||||
{ /* 20 Mhz */ { 52.0, /* SGI */ 57.8, },
|
||||
/* 40 Mhz */ { 108.0, /* SGI */ 120.0, },
|
||||
},
|
||||
|
||||
/* MCS 35 */
|
||||
{ /* 20 Mhz */ { 65.0, /* SGI */ 72.2, },
|
||||
/* 40 Mhz */ { 135.0, /* SGI */ 150.0, },
|
||||
},
|
||||
|
||||
/* MCS 36 */
|
||||
{ /* 20 Mhz */ { 58.5, /* SGI */ 65.0, },
|
||||
/* 40 Mhz */ { 121.5, /* SGI */ 135.0, },
|
||||
},
|
||||
|
||||
/* MCS 37 */
|
||||
{ /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
|
||||
/* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
|
||||
},
|
||||
|
||||
/* MCS 38 */
|
||||
{ /* 20 Mhz */ { 97.5, /* SGI */ 108.3, },
|
||||
/* 40 Mhz */ { 202.5, /* SGI */ 225.0, },
|
||||
},
|
||||
|
||||
/* MCS 39 */
|
||||
{ /* 20 Mhz */ { 52.0, /* SGI */ 57.8, },
|
||||
/* 40 Mhz */ { 108.0, /* SGI */ 120.0, },
|
||||
},
|
||||
|
||||
/* MCS 40 */
|
||||
{ /* 20 Mhz */ { 65.0, /* SGI */ 72.2, },
|
||||
/* 40 Mhz */ { 135.0, /* SGI */ 150.0, },
|
||||
},
|
||||
|
||||
/* MCS 41 */
|
||||
{ /* 20 Mhz */ { 65.0, /* SGI */ 72.2, },
|
||||
/* 40 Mhz */ { 135.0, /* SGI */ 150.0, },
|
||||
},
|
||||
|
||||
/* MCS 42 */
|
||||
{ /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
|
||||
/* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
|
||||
},
|
||||
|
||||
/* MCS 43 */
|
||||
{ /* 20 Mhz */ { 91.0, /* SGI */ 101.1, },
|
||||
/* 40 Mhz */ { 189.0, /* SGI */ 210.0, },
|
||||
},
|
||||
|
||||
/* MCS 44 */
|
||||
{ /* 20 Mhz */ { 91.0, /* SGI */ 101.1, },
|
||||
/* 40 Mhz */ { 189.0, /* SGI */ 210.0, },
|
||||
},
|
||||
|
||||
/* MCS 45 */
|
||||
{ /* 20 Mhz */ { 104.0, /* SGI */ 115.6, },
|
||||
/* 40 Mhz */ { 216.0, /* SGI */ 240.0, },
|
||||
},
|
||||
|
||||
/* MCS 46 */
|
||||
{ /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
|
||||
/* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
|
||||
},
|
||||
|
||||
/* MCS 47 */
|
||||
{ /* 20 Mhz */ { 97.5, /* SGI */ 108.3, },
|
||||
/* 40 Mhz */ { 202.5, /* SGI */ 225.0, },
|
||||
},
|
||||
|
||||
/* MCS 48 */
|
||||
{ /* 20 Mhz */ { 97.5, /* SGI */ 108.3, },
|
||||
/* 40 Mhz */ { 202.5, /* SGI */ 225.0, },
|
||||
},
|
||||
|
||||
/* MCS 49 */
|
||||
{ /* 20 Mhz */ { 117.0, /* SGI */ 130.0, },
|
||||
/* 40 Mhz */ { 243.0, /* SGI */ 270.0, },
|
||||
},
|
||||
|
||||
/* MCS 50 */
|
||||
{ /* 20 Mhz */ { 136.5, /* SGI */ 151.7, },
|
||||
/* 40 Mhz */ { 283.5, /* SGI */ 315.0, },
|
||||
},
|
||||
|
||||
/* MCS 51 */
|
||||
{ /* 20 Mhz */ { 136.5, /* SGI */ 151.7, },
|
||||
/* 40 Mhz */ { 283.5, /* SGI */ 315.0, },
|
||||
},
|
||||
|
||||
/* MCS 52 */
|
||||
{ /* 20 Mhz */ { 156.0, /* SGI */ 173.3, },
|
||||
/* 40 Mhz */ { 324.0, /* SGI */ 360.0, },
|
||||
},
|
||||
|
||||
/* MCS 53 */
|
||||
{ /* 20 Mhz */ { 65.0, /* SGI */ 72.2, },
|
||||
/* 40 Mhz */ { 135.0, /* SGI */ 150.0, },
|
||||
},
|
||||
|
||||
/* MCS 54 */
|
||||
{ /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
|
||||
/* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
|
||||
},
|
||||
|
||||
/* MCS 55 */
|
||||
{ /* 20 Mhz */ { 91.0, /* SGI */ 101.1, },
|
||||
/* 40 Mhz */ { 189.0, /* SGI */ 210.0, },
|
||||
},
|
||||
|
||||
/* MCS 56 */
|
||||
{ /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
|
||||
/* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
|
||||
},
|
||||
|
||||
/* MCS 57 */
|
||||
{ /* 20 Mhz */ { 91.0, /* SGI */ 101.1, },
|
||||
/* 40 Mhz */ { 189.0, /* SGI */ 210.0, },
|
||||
},
|
||||
|
||||
/* MCS 58 */
|
||||
{ /* 20 Mhz */ { 104.0, /* SGI */ 115.6, },
|
||||
/* 40 Mhz */ { 216.0, /* SGI */ 240.0, },
|
||||
},
|
||||
|
||||
/* MCS 59 */
|
||||
{ /* 20 Mhz */ { 117.0, /* SGI */ 130.0, },
|
||||
/* 40 Mhz */ { 243.0, /* SGI */ 270.0, },
|
||||
},
|
||||
|
||||
/* MCS 60 */
|
||||
{ /* 20 Mhz */ { 104.0, /* SGI */ 115.6, },
|
||||
/* 40 Mhz */ { 216.0, /* SGI */ 240.0, },
|
||||
},
|
||||
|
||||
/* MCS 61 */
|
||||
{ /* 20 Mhz */ { 117.0, /* SGI */ 130.0, },
|
||||
/* 40 Mhz */ { 243.0, /* SGI */ 270.0, },
|
||||
},
|
||||
|
||||
/* MCS 62 */
|
||||
{ /* 20 Mhz */ { 130.0, /* SGI */ 144.4, },
|
||||
/* 40 Mhz */ { 270.0, /* SGI */ 300.0, },
|
||||
},
|
||||
|
||||
/* MCS 63 */
|
||||
{ /* 20 Mhz */ { 130.0, /* SGI */ 144.4, },
|
||||
/* 40 Mhz */ { 270.0, /* SGI */ 300.0, },
|
||||
},
|
||||
|
||||
/* MCS 64 */
|
||||
{ /* 20 Mhz */ { 143.0, /* SGI */ 158.9, },
|
||||
/* 40 Mhz */ { 297.0, /* SGI */ 330.0, },
|
||||
},
|
||||
|
||||
/* MCS 65 */
|
||||
{ /* 20 Mhz */ { 97.5, /* SGI */ 108.3, },
|
||||
/* 40 Mhz */ { 202.5, /* SGI */ 225.0, },
|
||||
},
|
||||
|
||||
/* MCS 66 */
|
||||
{ /* 20 Mhz */ { 117.0, /* SGI */ 130.0, },
|
||||
/* 40 Mhz */ { 243.0, /* SGI */ 270.0, },
|
||||
},
|
||||
|
||||
/* MCS 67 */
|
||||
{ /* 20 Mhz */ { 136.5, /* SGI */ 151.7, },
|
||||
/* 40 Mhz */ { 283.5, /* SGI */ 315.0, },
|
||||
},
|
||||
|
||||
/* MCS 68 */
|
||||
{ /* 20 Mhz */ { 117.0, /* SGI */ 130.0, },
|
||||
/* 40 Mhz */ { 243.0, /* SGI */ 270.0, },
|
||||
},
|
||||
|
||||
/* MCS 69 */
|
||||
{ /* 20 Mhz */ { 136.5, /* SGI */ 151.7, },
|
||||
/* 40 Mhz */ { 283.5, /* SGI */ 315.0, },
|
||||
},
|
||||
|
||||
/* MCS 70 */
|
||||
{ /* 20 Mhz */ { 156.0, /* SGI */ 173.3, },
|
||||
/* 40 Mhz */ { 324.0, /* SGI */ 360.0, },
|
||||
},
|
||||
|
||||
/* MCS 71 */
|
||||
{ /* 20 Mhz */ { 175.5, /* SGI */ 195.0, },
|
||||
/* 40 Mhz */ { 364.5, /* SGI */ 405.0, },
|
||||
},
|
||||
|
||||
/* MCS 72 */
|
||||
{ /* 20 Mhz */ { 156.0, /* SGI */ 173.3, },
|
||||
/* 40 Mhz */ { 324.0, /* SGI */ 360.0, },
|
||||
},
|
||||
|
||||
/* MCS 73 */
|
||||
{ /* 20 Mhz */ { 175.5, /* SGI */ 195.0, },
|
||||
/* 40 Mhz */ { 364.5, /* SGI */ 405.0, },
|
||||
},
|
||||
|
||||
/* MCS 74 */
|
||||
{ /* 20 Mhz */ { 195.0, /* SGI */ 216.7, },
|
||||
/* 40 Mhz */ { 405.0, /* SGI */ 450.0, },
|
||||
},
|
||||
|
||||
/* MCS 75 */
|
||||
{ /* 20 Mhz */ { 195.0, /* SGI */ 216.7, },
|
||||
/* 40 Mhz */ { 405.0, /* SGI */ 450.0, },
|
||||
},
|
||||
|
||||
/* MCS 76 */
|
||||
{ /* 20 Mhz */ { 214.5, /* SGI */ 238.3, },
|
||||
/* 40 Mhz */ { 445.5, /* SGI */ 495.0, },
|
||||
},
|
||||
};
|
||||
#define PRINT_HT_RATE(_sep, _r, _suf) \
|
||||
printf("%s%.1f%s", _sep, (.5 * ieee80211_htrates[(_r) & 0xf]), _suf)
|
||||
|
||||
static const char *auth_alg_text[]={"Open System","Shared Key","EAP"};
|
||||
#define NUM_AUTH_ALGS (sizeof auth_alg_text / sizeof auth_alg_text[0])
|
||||
@ -269,6 +655,7 @@ static int
|
||||
parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset,
|
||||
u_int length)
|
||||
{
|
||||
u_int elementlen;
|
||||
struct ssid_t ssid;
|
||||
struct challenge_t challenge;
|
||||
struct rates_t rates;
|
||||
@ -487,12 +874,13 @@ parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset,
|
||||
return 0;
|
||||
if (length < 2)
|
||||
return 0;
|
||||
if (!TTEST2(*(p + offset + 2), *(p + offset + 1)))
|
||||
elementlen = *(p + offset + 1);
|
||||
if (!TTEST2(*(p + offset + 2), elementlen))
|
||||
return 0;
|
||||
if (length < (u_int)(*(p + offset + 1) + 2))
|
||||
if (length < elementlen + 2)
|
||||
return 0;
|
||||
offset += *(p + offset + 1) + 2;
|
||||
length -= *(p + offset + 1) + 2;
|
||||
offset += elementlen + 2;
|
||||
length -= elementlen + 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1321,7 +1709,8 @@ ieee802_11_print(const u_char *p, u_int length, u_int orig_caplen, int pad,
|
||||
hdrlen = extract_header_length(fc);
|
||||
if (pad)
|
||||
hdrlen = roundup2(hdrlen, 4);
|
||||
if (FC_TYPE(fc) == T_DATA && DATA_FRAME_IS_QOS(FC_SUBTYPE(fc))) {
|
||||
if (Hflag && FC_TYPE(fc) == T_DATA &&
|
||||
DATA_FRAME_IS_QOS(FC_SUBTYPE(fc))) {
|
||||
meshdrlen = extract_mesh_header_length(p+hdrlen);
|
||||
hdrlen += meshdrlen;
|
||||
} else
|
||||
@ -1461,7 +1850,8 @@ print_chaninfo(int freq, int flags)
|
||||
}
|
||||
|
||||
static int
|
||||
print_radiotap_field(struct cpack_state *s, u_int32_t bit, u_int8_t *flags)
|
||||
print_radiotap_field(struct cpack_state *s, u_int32_t bit, u_int8_t *flags,
|
||||
struct radiotap_state *state, u_int32_t presentflags)
|
||||
{
|
||||
union {
|
||||
int8_t i8;
|
||||
@ -1476,9 +1866,18 @@ print_radiotap_field(struct cpack_state *s, u_int32_t bit, u_int8_t *flags)
|
||||
switch (bit) {
|
||||
case IEEE80211_RADIOTAP_FLAGS:
|
||||
rc = cpack_uint8(s, &u.u8);
|
||||
if (rc != 0)
|
||||
break;
|
||||
*flags = u.u8;
|
||||
break;
|
||||
case IEEE80211_RADIOTAP_RATE:
|
||||
rc = cpack_uint8(s, &u.u8);
|
||||
if (rc != 0)
|
||||
break;
|
||||
|
||||
/* Save state rate */
|
||||
state->rate = u.u8;
|
||||
break;
|
||||
case IEEE80211_RADIOTAP_DB_ANTSIGNAL:
|
||||
case IEEE80211_RADIOTAP_DB_ANTNOISE:
|
||||
case IEEE80211_RADIOTAP_ANTENNA:
|
||||
@ -1497,6 +1896,7 @@ print_radiotap_field(struct cpack_state *s, u_int32_t bit, u_int8_t *flags)
|
||||
case IEEE80211_RADIOTAP_FHSS:
|
||||
case IEEE80211_RADIOTAP_LOCK_QUALITY:
|
||||
case IEEE80211_RADIOTAP_TX_ATTENUATION:
|
||||
case IEEE80211_RADIOTAP_RX_FLAGS:
|
||||
rc = cpack_uint16(s, &u.u16);
|
||||
break;
|
||||
case IEEE80211_RADIOTAP_DB_TX_ATTENUATION:
|
||||
@ -1520,6 +1920,45 @@ print_radiotap_field(struct cpack_state *s, u_int32_t bit, u_int8_t *flags)
|
||||
break;
|
||||
rc = cpack_uint8(s, &u4.u8);
|
||||
break;
|
||||
case IEEE80211_RADIOTAP_MCS:
|
||||
rc = cpack_uint8(s, &u.u8);
|
||||
if (rc != 0)
|
||||
break;
|
||||
rc = cpack_uint8(s, &u2.u8);
|
||||
if (rc != 0)
|
||||
break;
|
||||
rc = cpack_uint8(s, &u3.u8);
|
||||
break;
|
||||
case IEEE80211_RADIOTAP_VENDOR_NAMESPACE: {
|
||||
u_int8_t vns[3];
|
||||
u_int16_t length;
|
||||
u_int8_t subspace;
|
||||
|
||||
if ((cpack_align_and_reserve(s, 2)) == NULL) {
|
||||
rc = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
rc = cpack_uint8(s, &vns[0]);
|
||||
if (rc != 0)
|
||||
break;
|
||||
rc = cpack_uint8(s, &vns[1]);
|
||||
if (rc != 0)
|
||||
break;
|
||||
rc = cpack_uint8(s, &vns[2]);
|
||||
if (rc != 0)
|
||||
break;
|
||||
rc = cpack_uint8(s, &subspace);
|
||||
if (rc != 0)
|
||||
break;
|
||||
rc = cpack_uint16(s, &length);
|
||||
if (rc != 0)
|
||||
break;
|
||||
|
||||
/* Skip up to length */
|
||||
s->c_next += length;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
/* this bit indicates a field whose
|
||||
* size we do not know, so we cannot
|
||||
@ -1534,18 +1973,64 @@ print_radiotap_field(struct cpack_state *s, u_int32_t bit, u_int8_t *flags)
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Preserve the state present flags */
|
||||
state->present = presentflags;
|
||||
|
||||
switch (bit) {
|
||||
case IEEE80211_RADIOTAP_CHANNEL:
|
||||
/*
|
||||
* If CHANNEL and XCHANNEL are both present, skip
|
||||
* CHANNEL.
|
||||
*/
|
||||
if (presentflags & (1 << IEEE80211_RADIOTAP_XCHANNEL))
|
||||
break;
|
||||
print_chaninfo(u.u16, u2.u16);
|
||||
break;
|
||||
case IEEE80211_RADIOTAP_FHSS:
|
||||
printf("fhset %d fhpat %d ", u.u16 & 0xff, (u.u16 >> 8) & 0xff);
|
||||
break;
|
||||
case IEEE80211_RADIOTAP_RATE:
|
||||
if (u.u8 & 0x80)
|
||||
PRINT_HT_RATE("", u.u8, " Mb/s ");
|
||||
else
|
||||
PRINT_RATE("", u.u8, " Mb/s ");
|
||||
/*
|
||||
* XXX On FreeBSD rate & 0x80 means we have an MCS. On
|
||||
* Linux and AirPcap it does not. (What about
|
||||
* Mac OS X, NetBSD, OpenBSD, and DragonFly BSD?)
|
||||
*
|
||||
* This is an issue either for proprietary extensions
|
||||
* to 11a or 11g, which do exist, or for 11n
|
||||
* implementations that stuff a rate value into
|
||||
* this field, which also appear to exist.
|
||||
*
|
||||
* We currently handle that by assuming that
|
||||
* if the 0x80 bit is set *and* the remaining
|
||||
* bits have a value between 0 and 15 it's
|
||||
* an MCS value, otherwise it's a rate. If
|
||||
* there are cases where systems that use
|
||||
* "0x80 + MCS index" for MCS indices > 15,
|
||||
* or stuff a rate value here between 64 and
|
||||
* 71.5 Mb/s in here, we'll need a preference
|
||||
* setting. Such rates do exist, e.g. 11n
|
||||
* MCS 7 at 20 MHz with a long guard interval.
|
||||
*/
|
||||
if (u.u8 >= 0x80 && u.u8 <= 0x8f) {
|
||||
/*
|
||||
* XXX - we don't know the channel width
|
||||
* or guard interval length, so we can't
|
||||
* convert this to a data rate.
|
||||
*
|
||||
* If you want us to show a data rate,
|
||||
* use the MCS field, not the Rate field;
|
||||
* the MCS field includes not only the
|
||||
* MCS index, it also includes bandwidth
|
||||
* and guard interval information.
|
||||
*
|
||||
* XXX - can we get the channel width
|
||||
* from XChannel and the guard interval
|
||||
* information from Flags, at least on
|
||||
* FreeBSD?
|
||||
*/
|
||||
printf("MCS %u ", u.u8 & 0x7f);
|
||||
} else
|
||||
printf("%2.1f Mb/s ", .5*u.u8);
|
||||
break;
|
||||
case IEEE80211_RADIOTAP_DBM_ANTSIGNAL:
|
||||
printf("%ddB signal ", u.i8);
|
||||
@ -1589,9 +2074,89 @@ print_radiotap_field(struct cpack_state *s, u_int32_t bit, u_int8_t *flags)
|
||||
case IEEE80211_RADIOTAP_TSFT:
|
||||
printf("%" PRIu64 "us tsft ", u.u64);
|
||||
break;
|
||||
case IEEE80211_RADIOTAP_RX_FLAGS:
|
||||
/* Do nothing for now */
|
||||
break;
|
||||
case IEEE80211_RADIOTAP_XCHANNEL:
|
||||
print_chaninfo(u2.u16, u.u32);
|
||||
break;
|
||||
case IEEE80211_RADIOTAP_MCS: {
|
||||
static const char *bandwidth[4] = {
|
||||
"20 MHz",
|
||||
"40 MHz",
|
||||
"20 MHz (L)",
|
||||
"20 MHz (U)"
|
||||
};
|
||||
float htrate;
|
||||
|
||||
if (u.u8 & IEEE80211_RADIOTAP_MCS_MCS_INDEX_KNOWN) {
|
||||
/*
|
||||
* We know the MCS index.
|
||||
*/
|
||||
if (u3.u8 <= MAX_MCS_INDEX) {
|
||||
/*
|
||||
* And it's in-range.
|
||||
*/
|
||||
if (u.u8 & (IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN|IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN)) {
|
||||
/*
|
||||
* And we know both the bandwidth and
|
||||
* the guard interval, so we can look
|
||||
* up the rate.
|
||||
*/
|
||||
htrate =
|
||||
ieee80211_float_htrates \
|
||||
[u3.u8] \
|
||||
[((u2.u8 & IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK) == IEEE80211_RADIOTAP_MCS_BANDWIDTH_40 ? 1 : 0)] \
|
||||
[((u2.u8 & IEEE80211_RADIOTAP_MCS_SHORT_GI) ? 1 : 0)];
|
||||
} else {
|
||||
/*
|
||||
* We don't know both the bandwidth
|
||||
* and the guard interval, so we can
|
||||
* only report the MCS index.
|
||||
*/
|
||||
htrate = 0.0;
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* The MCS value is out of range.
|
||||
*/
|
||||
htrate = 0.0;
|
||||
}
|
||||
if (htrate != 0.0) {
|
||||
/*
|
||||
* We have the rate.
|
||||
* Print it.
|
||||
*/
|
||||
printf("%.1f Mb/s MCS %u ", htrate, u3.u8);
|
||||
} else {
|
||||
/*
|
||||
* We at least have the MCS index.
|
||||
* Print it.
|
||||
*/
|
||||
printf("MCS %u ", u3.u8);
|
||||
}
|
||||
}
|
||||
if (u.u8 & IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN) {
|
||||
printf("%s ",
|
||||
bandwidth[u2.u8 & IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK]);
|
||||
}
|
||||
if (u.u8 & IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN) {
|
||||
printf("%s GI ",
|
||||
(u2.u8 & IEEE80211_RADIOTAP_MCS_SHORT_GI) ?
|
||||
"short" : "lon");
|
||||
}
|
||||
if (u.u8 & IEEE80211_RADIOTAP_MCS_HT_FORMAT_KNOWN) {
|
||||
printf("%s ",
|
||||
(u2.u8 & IEEE80211_RADIOTAP_MCS_HT_GREENFIELD) ?
|
||||
"greenfield" : "mixed");
|
||||
}
|
||||
if (u.u8 & IEEE80211_RADIOTAP_MCS_FEC_TYPE_KNOWN) {
|
||||
printf("%s FEC ",
|
||||
(u2.u8 & IEEE80211_RADIOTAP_MCS_FEC_LDPC) ?
|
||||
"LDPC" : "BCC");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -1611,6 +2176,7 @@ ieee802_11_radio_print(const u_char *p, u_int length, u_int caplen)
|
||||
struct cpack_state cpacker;
|
||||
struct ieee80211_radiotap_header *hdr;
|
||||
u_int32_t present, next_present;
|
||||
u_int32_t presentflags = 0;
|
||||
u_int32_t *presentp, *last_presentp;
|
||||
enum ieee80211_radiotap_type bit;
|
||||
int bit0;
|
||||
@ -1619,6 +2185,7 @@ ieee802_11_radio_print(const u_char *p, u_int length, u_int caplen)
|
||||
u_int8_t flags;
|
||||
int pad;
|
||||
u_int fcslen;
|
||||
struct radiotap_state state;
|
||||
|
||||
if (caplen < sizeof(*hdr)) {
|
||||
printf("[|802.11]");
|
||||
@ -1660,6 +2227,11 @@ ieee802_11_radio_print(const u_char *p, u_int length, u_int caplen)
|
||||
fcslen = 0;
|
||||
for (bit0 = 0, presentp = &hdr->it_present; presentp <= last_presentp;
|
||||
presentp++, bit0 += 32) {
|
||||
presentflags = EXTRACT_LE_32BITS(presentp);
|
||||
|
||||
/* Clear state. */
|
||||
memset(&state, 0, sizeof(state));
|
||||
|
||||
for (present = EXTRACT_LE_32BITS(presentp); present;
|
||||
present = next_present) {
|
||||
/* clear the least significant bit that is set */
|
||||
@ -1669,16 +2241,16 @@ ieee802_11_radio_print(const u_char *p, u_int length, u_int caplen)
|
||||
bit = (enum ieee80211_radiotap_type)
|
||||
(bit0 + BITNO_32(present ^ next_present));
|
||||
|
||||
if (print_radiotap_field(&cpacker, bit, &flags) != 0)
|
||||
if (print_radiotap_field(&cpacker, bit, &flags, &state, presentflags) != 0)
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
if (flags & IEEE80211_RADIOTAP_F_DATAPAD)
|
||||
pad = 1; /* Atheros padding */
|
||||
if (flags & IEEE80211_RADIOTAP_F_FCS)
|
||||
fcslen = 4; /* FCS at end of packet */
|
||||
out:
|
||||
return len + ieee802_11_print(p + len, length - len, caplen - len, pad,
|
||||
fcslen);
|
||||
#undef BITNO_32
|
||||
|
183
print-802_15_4.c
Normal file
183
print-802_15_4.c
Normal file
@ -0,0 +1,183 @@
|
||||
/*
|
||||
* 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 <tcpdump-stdinc.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <pcap.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "interface.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(u_int16_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(struct netdissect_options *ndo,
|
||||
const struct pcap_pkthdr *h, const u_char *p)
|
||||
{
|
||||
u_int caplen = h->caplen;
|
||||
int hdrlen;
|
||||
u_int16_t fc;
|
||||
u_int8_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 (vflag)
|
||||
ND_PRINT((ndo,"seq %02x ", seq));
|
||||
if (hdrlen == -1) {
|
||||
ND_PRINT((ndo,"malformed! "));
|
||||
return caplen;
|
||||
}
|
||||
|
||||
|
||||
if (!vflag) {
|
||||
p+= hdrlen;
|
||||
caplen -= hdrlen;
|
||||
} else {
|
||||
u_int16_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(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(p))));
|
||||
p += 8;
|
||||
break;
|
||||
}
|
||||
|
||||
caplen -= hdrlen;
|
||||
}
|
||||
|
||||
if (!suppress_default_print)
|
||||
(ndo->ndo_default_print)(ndo, p, caplen);
|
||||
|
||||
return 0;
|
||||
}
|
@ -106,7 +106,7 @@ ap1394_if_print(const struct pcap_pkthdr *h, const u_char *p)
|
||||
p += FIREWIRE_HDRLEN;
|
||||
|
||||
ether_type = EXTRACT_16BITS(&fp->firewire_type);
|
||||
if (ethertype_print(ether_type, p, length, caplen) == 0) {
|
||||
if (ethertype_print(gndo, ether_type, p, length, caplen) == 0) {
|
||||
/* ether_type not known, print raw packet */
|
||||
if (!eflag)
|
||||
ap1394_hdr_print((u_char *)fp, length + FIREWIRE_HDRLEN);
|
||||
|
@ -265,14 +265,14 @@ arcnet_encap_print(u_char arctype, const u_char *p,
|
||||
|
||||
#ifdef INET6
|
||||
case ARCTYPE_INET6:
|
||||
ip6_print(p, length);
|
||||
ip6_print(gndo, p, length);
|
||||
return (1);
|
||||
#endif /*INET6*/
|
||||
|
||||
case ARCTYPE_ARP_OLD:
|
||||
case ARCTYPE_ARP:
|
||||
case ARCTYPE_REVARP:
|
||||
arp_print(gndo, p, length, caplen);
|
||||
arp_print(gndo, p, length, caplen);
|
||||
return (1);
|
||||
|
||||
case ARCTYPE_ATALK: /* XXX was this ever used? */
|
||||
|
@ -318,6 +318,7 @@ arp_print(netdissect_options *ndo,
|
||||
return;
|
||||
case ARPHRD_FRELAY:
|
||||
linkaddr = LINKADDR_FRELAY;
|
||||
break;
|
||||
default:
|
||||
linkaddr = LINKADDR_ETHER;
|
||||
break;
|
||||
|
@ -99,14 +99,10 @@ llap_print(register const u_char *bp, u_int length)
|
||||
u_short snet;
|
||||
u_int hdrlen;
|
||||
|
||||
/*
|
||||
* Our packet is on a 4-byte boundary, as we're either called
|
||||
* directly from a top-level link-layer printer (ltalk_if_print)
|
||||
* or from the UDP printer. The LLAP+DDP header is a multiple
|
||||
* of 4 bytes in length, so the DDP payload is also on a 4-byte
|
||||
* boundary, and we don't need to align it before calling
|
||||
* "ddp_print()".
|
||||
*/
|
||||
if (length < sizeof(*lp)) {
|
||||
(void)printf(" [|llap %u]", length);
|
||||
return (length);
|
||||
}
|
||||
lp = (const struct LAP *)bp;
|
||||
bp += sizeof(*lp);
|
||||
length -= sizeof(*lp);
|
||||
@ -115,7 +111,7 @@ llap_print(register const u_char *bp, u_int length)
|
||||
|
||||
case lapShortDDP:
|
||||
if (length < ddpSSize) {
|
||||
(void)printf(" [|sddp %d]", length);
|
||||
(void)printf(" [|sddp %u]", length);
|
||||
return (length);
|
||||
}
|
||||
sdp = (const struct atShortDDP *)bp;
|
||||
@ -131,7 +127,7 @@ llap_print(register const u_char *bp, u_int length)
|
||||
|
||||
case lapDDP:
|
||||
if (length < ddpSize) {
|
||||
(void)printf(" [|ddp %d]", length);
|
||||
(void)printf(" [|ddp %u]", length);
|
||||
return (length);
|
||||
}
|
||||
dp = (const struct atDDP *)bp;
|
||||
@ -154,7 +150,7 @@ llap_print(register const u_char *bp, u_int length)
|
||||
#endif
|
||||
|
||||
default:
|
||||
printf("%d > %d at-lap#%d %d",
|
||||
printf("%d > %d at-lap#%d %u",
|
||||
lp->src, lp->dst, lp->type, length);
|
||||
break;
|
||||
}
|
||||
@ -176,7 +172,7 @@ atalk_print(register const u_char *bp, u_int length)
|
||||
printf("AT ");
|
||||
|
||||
if (length < ddpSize) {
|
||||
(void)printf(" [|ddp %d]", length);
|
||||
(void)printf(" [|ddp %u]", length);
|
||||
return;
|
||||
}
|
||||
dp = (const struct atDDP *)bp;
|
||||
@ -265,6 +261,10 @@ atp_print(register const struct atATP *ap, u_int length)
|
||||
fputs(tstr, stdout);
|
||||
return;
|
||||
}
|
||||
if (length < sizeof(*ap)) {
|
||||
(void)printf(" [|atp %u]", length);
|
||||
return;
|
||||
}
|
||||
length -= sizeof(*ap);
|
||||
switch (ap->control & 0xc0) {
|
||||
|
||||
@ -276,7 +276,7 @@ atp_print(register const struct atATP *ap, u_int length)
|
||||
atp_bitmap_print(ap->bitmap);
|
||||
|
||||
if (length != 0)
|
||||
(void)printf(" [len=%d]", length);
|
||||
(void)printf(" [len=%u]", length);
|
||||
|
||||
switch (ap->control & (atpEOM|atpSTS)) {
|
||||
case atpEOM:
|
||||
@ -292,7 +292,7 @@ atp_print(register const struct atATP *ap, u_int length)
|
||||
break;
|
||||
|
||||
case atpRspCode:
|
||||
(void)printf(" atp-resp%s%d:%d (%d)",
|
||||
(void)printf(" atp-resp%s%d:%d (%u)",
|
||||
ap->control & atpEOM? "*" : " ",
|
||||
EXTRACT_16BITS(&ap->transID), ap->bitmap, length);
|
||||
switch (ap->control & (atpXO|atpSTS)) {
|
||||
@ -315,7 +315,7 @@ atp_print(register const struct atATP *ap, u_int length)
|
||||
|
||||
/* length should be zero */
|
||||
if (length)
|
||||
(void)printf(" [len=%d]", length);
|
||||
(void)printf(" [len=%u]", length);
|
||||
|
||||
/* there shouldn't be any control flags */
|
||||
if (ap->control & (atpXO|atpEOM|atpSTS)) {
|
||||
@ -337,7 +337,7 @@ atp_print(register const struct atATP *ap, u_int length)
|
||||
break;
|
||||
|
||||
default:
|
||||
(void)printf(" atp-0x%x %d (%d)", ap->control,
|
||||
(void)printf(" atp-0x%x %d (%u)", ap->control,
|
||||
EXTRACT_16BITS(&ap->transID), length);
|
||||
break;
|
||||
}
|
||||
@ -387,14 +387,14 @@ nbp_print(register const struct atNBP *np, u_int length, register u_short snet,
|
||||
const u_char *ep;
|
||||
|
||||
if (length < nbpHeaderSize) {
|
||||
(void)printf(" truncated-nbp %d", length);
|
||||
(void)printf(" truncated-nbp %u", length);
|
||||
return;
|
||||
}
|
||||
|
||||
length -= nbpHeaderSize;
|
||||
if (length < 8) {
|
||||
/* must be room for at least one tuple */
|
||||
(void)printf(" truncated-nbp %d", length + nbpHeaderSize);
|
||||
(void)printf(" truncated-nbp %u", length + nbpHeaderSize);
|
||||
return;
|
||||
}
|
||||
/* ep points to end of available data */
|
||||
@ -439,7 +439,7 @@ nbp_print(register const struct atNBP *np, u_int length, register u_short snet,
|
||||
break;
|
||||
|
||||
default:
|
||||
(void)printf(" nbp-0x%x %d (%d)", np->control, np->id,
|
||||
(void)printf(" nbp-0x%x %d (%u)", np->control, np->id,
|
||||
length);
|
||||
break;
|
||||
}
|
||||
@ -551,26 +551,24 @@ ataddr_string(u_short atnet, u_char athost)
|
||||
if (first && (first = 0, !nflag)
|
||||
&& (fp = fopen("/etc/atalk.names", "r"))) {
|
||||
char line[256];
|
||||
int i1, i2, i3;
|
||||
int i1, i2;
|
||||
|
||||
while (fgets(line, sizeof(line), fp)) {
|
||||
if (line[0] == '\n' || line[0] == 0 || line[0] == '#')
|
||||
continue;
|
||||
if (sscanf(line, "%d.%d.%d %256s", &i1, &i2, &i3,
|
||||
nambuf) == 4)
|
||||
if (sscanf(line, "%d.%d %256s", &i1, &i2, nambuf) == 3)
|
||||
/* got a hostname. */
|
||||
i3 |= ((i1 << 8) | i2) << 8;
|
||||
else if (sscanf(line, "%d.%d %256s", &i1, &i2,
|
||||
nambuf) == 3)
|
||||
i2 |= (i1 << 8);
|
||||
else if (sscanf(line, "%d %256s", &i1, nambuf) == 2)
|
||||
/* got a net name */
|
||||
i3 = (((i1 << 8) | i2) << 8) | 255;
|
||||
i2 = (i1 << 8) | 255;
|
||||
else
|
||||
continue;
|
||||
|
||||
for (tp = &hnametable[i3 & (HASHNAMESIZE-1)];
|
||||
for (tp = &hnametable[i2 & (HASHNAMESIZE-1)];
|
||||
tp->nxt; tp = tp->nxt)
|
||||
;
|
||||
tp->addr = i3;
|
||||
tp->addr = i2;
|
||||
tp->nxt = newhnamemem();
|
||||
tp->name = strdup(nambuf);
|
||||
}
|
||||
@ -596,11 +594,9 @@ ataddr_string(u_short atnet, u_char athost)
|
||||
tp->addr = (atnet << 8) | athost;
|
||||
tp->nxt = newhnamemem();
|
||||
if (athost != 255)
|
||||
(void)snprintf(nambuf, sizeof(nambuf), "%d.%d.%d",
|
||||
atnet >> 8, atnet & 0xff, athost);
|
||||
(void)snprintf(nambuf, sizeof(nambuf), "%d.%d", atnet, athost);
|
||||
else
|
||||
(void)snprintf(nambuf, sizeof(nambuf), "%d.%d", atnet >> 8,
|
||||
atnet & 0xff);
|
||||
(void)snprintf(nambuf, sizeof(nambuf), "%d", atnet);
|
||||
tp->name = strdup(nambuf);
|
||||
|
||||
return (tp->name);
|
||||
|
10
print-atm.c
10
print-atm.c
@ -270,10 +270,12 @@ sig_print(const u_char *p, int caplen)
|
||||
printf(":%s ",
|
||||
tok2str(msgtype2str, "msgtype#%d", p[MSG_TYPE_POS]));
|
||||
|
||||
if (caplen < CALL_REF_POS+3) {
|
||||
printf("[|atm]");
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* 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]);
|
||||
printf("CALL_REF:0x%06x", call_ref);
|
||||
} else {
|
||||
|
414
print-babel.c
Normal file
414
print-babel.c
Normal file
@ -0,0 +1,414 @@
|
||||
/*
|
||||
* 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 <tcpdump-stdinc.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "addrtoname.h"
|
||||
#include "interface.h"
|
||||
#include "extract.h"
|
||||
|
||||
static void babel_print_v2(const u_char *cp, u_int length);
|
||||
|
||||
void
|
||||
babel_print(const u_char *cp, u_int length) {
|
||||
printf("babel");
|
||||
|
||||
TCHECK2(*cp, 4);
|
||||
|
||||
if(cp[0] != 42) {
|
||||
printf(" malformed header");
|
||||
return;
|
||||
} else {
|
||||
printf(" %d", cp[1]);
|
||||
}
|
||||
|
||||
switch(cp[1]) {
|
||||
case 2:
|
||||
babel_print_v2(cp,length);
|
||||
break;
|
||||
default:
|
||||
printf(" unknown version");
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
trunc:
|
||||
printf(" [|babel]");
|
||||
return;
|
||||
}
|
||||
|
||||
#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
|
||||
|
||||
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(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(prefix + 12), plen - 96);
|
||||
else
|
||||
snprintf(buf, 50, "%s/%u", ip6addr_string(prefix), plen);
|
||||
buf[49] = '\0';
|
||||
return buf;
|
||||
}
|
||||
|
||||
static const char *
|
||||
format_address(const u_char *prefix)
|
||||
{
|
||||
if(memcmp(prefix, v4prefix, 12) == 0)
|
||||
return ipaddr_string(prefix + 12);
|
||||
else
|
||||
return ip6addr_string(prefix);
|
||||
}
|
||||
|
||||
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];
|
||||
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy(p_r, prefix, 16);
|
||||
return 1;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
#define ICHECK(i, l) \
|
||||
if ((i) + (l) > bodylen || (i) + (l) > length) goto corrupt;
|
||||
|
||||
static void
|
||||
babel_print_v2(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};
|
||||
|
||||
TCHECK2(*cp, 4);
|
||||
if (length < 4)
|
||||
goto corrupt;
|
||||
bodylen = EXTRACT_16BITS(cp + 2);
|
||||
printf(" (%u)", bodylen);
|
||||
|
||||
/* Process the TLVs in the body */
|
||||
i = 0;
|
||||
while(i < bodylen) {
|
||||
const u_char *message;
|
||||
u_char type, len;
|
||||
|
||||
message = cp + 4 + i;
|
||||
TCHECK2(*message, 2);
|
||||
ICHECK(i, 2);
|
||||
type = message[0];
|
||||
len = message[1];
|
||||
|
||||
TCHECK2(*message, 2 + len);
|
||||
ICHECK(i, 2 + len);
|
||||
|
||||
switch(type) {
|
||||
case MESSAGE_PAD1: {
|
||||
if(!vflag)
|
||||
printf(" pad1");
|
||||
else
|
||||
printf("\n\tPad 1");
|
||||
}
|
||||
break;
|
||||
|
||||
case MESSAGE_PADN: {
|
||||
if(!vflag)
|
||||
printf(" padN");
|
||||
else
|
||||
printf("\n\tPad %d", len + 2);
|
||||
}
|
||||
break;
|
||||
|
||||
case MESSAGE_ACK_REQ: {
|
||||
u_short nonce, interval;
|
||||
if(!vflag)
|
||||
printf(" ack-req");
|
||||
else {
|
||||
printf("\n\tAcknowledgment Request ");
|
||||
if(len < 6) goto corrupt;
|
||||
nonce = EXTRACT_16BITS(message + 4);
|
||||
interval = EXTRACT_16BITS(message + 6);
|
||||
printf("%04x %d", nonce, interval);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MESSAGE_ACK: {
|
||||
u_short nonce;
|
||||
if(!vflag)
|
||||
printf(" ack");
|
||||
else {
|
||||
printf("\n\tAcknowledgment ");
|
||||
if(len < 2) goto corrupt;
|
||||
nonce = EXTRACT_16BITS(message + 2);
|
||||
printf("%04x", nonce);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MESSAGE_HELLO: {
|
||||
u_short seqno, interval;
|
||||
if(!vflag)
|
||||
printf(" hello");
|
||||
else {
|
||||
printf("\n\tHello ");
|
||||
if(len < 6) goto corrupt;
|
||||
seqno = EXTRACT_16BITS(message + 4);
|
||||
interval = EXTRACT_16BITS(message + 6);
|
||||
printf("seqno %u interval %u", seqno, interval);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MESSAGE_IHU: {
|
||||
unsigned short txcost, interval;
|
||||
if(!vflag)
|
||||
printf(" ihu");
|
||||
else {
|
||||
u_char address[16];
|
||||
int rc;
|
||||
printf("\n\tIHU ");
|
||||
if(len < 6) goto corrupt;
|
||||
txcost = EXTRACT_16BITS(message + 4);
|
||||
interval = EXTRACT_16BITS(message + 6);
|
||||
rc = network_address(message[2], message + 8, len - 6, address);
|
||||
if(rc < 0) { printf("[|babel]"); break; }
|
||||
printf("%s txcost %u interval %d",
|
||||
format_address(address), txcost, interval);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MESSAGE_ROUTER_ID: {
|
||||
if(!vflag)
|
||||
printf(" router-id");
|
||||
else {
|
||||
printf("\n\tRouter Id");
|
||||
if(len < 10) goto corrupt;
|
||||
printf(" %s", format_id(message + 4));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MESSAGE_NH: {
|
||||
if(!vflag)
|
||||
printf(" nh");
|
||||
else {
|
||||
int rc;
|
||||
u_char nh[16];
|
||||
printf("\n\tNext Hop");
|
||||
if(len < 2) goto corrupt;
|
||||
rc = network_address(message[2], message + 4, len - 2, nh);
|
||||
if(rc < 0) goto corrupt;
|
||||
printf(" %s", format_address(nh));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MESSAGE_UPDATE: {
|
||||
if(!vflag) {
|
||||
printf(" update");
|
||||
if(len < 1)
|
||||
printf("/truncated");
|
||||
else
|
||||
printf("%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];
|
||||
printf("\n\tUpdate");
|
||||
if(len < 10) goto corrupt;
|
||||
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 corrupt;
|
||||
interval = EXTRACT_16BITS(message + 6);
|
||||
seqno = EXTRACT_16BITS(message + 8);
|
||||
metric = EXTRACT_16BITS(message + 10);
|
||||
printf("%s%s%s %s metric %u seqno %u interval %u",
|
||||
(message[3] & 0x80) ? "/prefix": "",
|
||||
(message[3] & 0x40) ? "/id" : "",
|
||||
(message[3] & 0x3f) ? "/unknown" : "",
|
||||
format_prefix(prefix, plen),
|
||||
metric, seqno, interval);
|
||||
if(message[3] & 0x80) {
|
||||
if(message[2] == 1)
|
||||
memcpy(v4_prefix, prefix, 16);
|
||||
else
|
||||
memcpy(v6_prefix, prefix, 16);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MESSAGE_REQUEST: {
|
||||
if(!vflag)
|
||||
printf(" request");
|
||||
else {
|
||||
int rc;
|
||||
u_char prefix[16], plen;
|
||||
printf("\n\tRequest ");
|
||||
if(len < 2) goto corrupt;
|
||||
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 corrupt;
|
||||
plen = message[3] + (message[2] == 1 ? 96 : 0);
|
||||
printf("for %s",
|
||||
message[2] == 0 ? "any" : format_prefix(prefix, plen));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MESSAGE_MH_REQUEST : {
|
||||
if(!vflag)
|
||||
printf(" mh-request");
|
||||
else {
|
||||
int rc;
|
||||
u_short seqno;
|
||||
u_char prefix[16], plen;
|
||||
printf("\n\tMH-Request ");
|
||||
if(len < 14) goto corrupt;
|
||||
seqno = EXTRACT_16BITS(message + 4);
|
||||
rc = network_prefix(message[2], message[3], 0,
|
||||
message + 16, NULL, len - 14, prefix);
|
||||
if(rc < 0) goto corrupt;
|
||||
plen = message[3] + (message[2] == 1 ? 96 : 0);
|
||||
printf("(%u hops) for %s seqno %u id %s",
|
||||
message[6], format_prefix(prefix, plen),
|
||||
seqno, format_id(message + 8));
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if(!vflag)
|
||||
printf(" unknown");
|
||||
else
|
||||
printf("\n\tUnknown message type %d", type);
|
||||
}
|
||||
i += len + 2;
|
||||
}
|
||||
return;
|
||||
|
||||
trunc:
|
||||
printf(" [|babel]");
|
||||
return;
|
||||
|
||||
corrupt:
|
||||
printf(" (corrupt)");
|
||||
return;
|
||||
}
|
134
print-bgp.c
134
print-bgp.c
@ -401,8 +401,11 @@ static struct tok bgp_safi_values[] = {
|
||||
|
||||
#define BGP_EXT_COM_L2INFO 0x800a /* draft-kompella-ppvpn-l2vpn */
|
||||
|
||||
#define BGP_EXT_COM_SOURCE_AS 0x0009 /* draft-ietf-l3vpn-2547bis-mcast-bgp-02.txt */
|
||||
#define BGP_EXT_COM_VRF_RT_IMP 0x010a /* draft-ietf-l3vpn-2547bis-mcast-bgp-02.txt */
|
||||
#define BGP_EXT_COM_SOURCE_AS 0x0009 /* RFC-ietf-l3vpn-2547bis-mcast-bgp-08.txt */
|
||||
#define BGP_EXT_COM_VRF_RT_IMP 0x010b /* RFC-ietf-l3vpn-2547bis-mcast-bgp-08.txt */
|
||||
#define BGP_EXT_COM_L2VPN_RT_0 0x000a /* L2VPN Identifier,Format AS(2bytes):AN(4bytes) */
|
||||
#define BGP_EXT_COM_L2VPN_RT_1 0xF10a /* L2VPN Identifier,Format IP address:AN(2bytes) */
|
||||
|
||||
|
||||
/* http://www.cisco.com/en/US/tech/tk436/tk428/technologies_tech_note09186a00801eb09a.shtml */
|
||||
#define BGP_EXT_COM_EIGRP_GEN 0x8800
|
||||
@ -443,6 +446,8 @@ static struct tok bgp_extd_comm_subtype_values[] = {
|
||||
{ BGP_EXT_COM_EIGRP_EXT_REMPROTO_REMMETRIC , "eigrp-external-route (remote-proto, remote-metric)" },
|
||||
{ BGP_EXT_COM_SOURCE_AS, "source-AS" },
|
||||
{ BGP_EXT_COM_VRF_RT_IMP, "vrf-route-import"},
|
||||
{ BGP_EXT_COM_L2VPN_RT_0, "l2vpn-id"},
|
||||
{ BGP_EXT_COM_L2VPN_RT_1, "l2vpn-id"},
|
||||
{ 0, NULL},
|
||||
};
|
||||
|
||||
@ -951,57 +956,84 @@ decode_labeled_vpn_l2(const u_char *pptr, char *buf, u_int buflen)
|
||||
plen=EXTRACT_16BITS(pptr);
|
||||
tlen=plen;
|
||||
pptr+=2;
|
||||
TCHECK2(pptr[0],15);
|
||||
buf[0]='\0';
|
||||
strlen=snprintf(buf, buflen, "RD: %s, CE-ID: %u, Label-Block Offset: %u, Label Base %u",
|
||||
bgp_vpn_rd_print(pptr),
|
||||
EXTRACT_16BITS(pptr+8),
|
||||
EXTRACT_16BITS(pptr+10),
|
||||
EXTRACT_24BITS(pptr+12)>>4); /* the label is offsetted by 4 bits so lets shift it right */
|
||||
UPDATE_BUF_BUFLEN(buf, buflen, strlen);
|
||||
pptr+=15;
|
||||
tlen-=15;
|
||||
/* Old and new L2VPN NLRI share AFI/SAFI
|
||||
* -> Assume a 12 Byte-length NLRI is auto-discovery-only
|
||||
* and > 17 as old format. Complain for the middle case
|
||||
*/
|
||||
if (plen==12) {
|
||||
/* assume AD-only with RD, BGPNH */
|
||||
TCHECK2(pptr[0],12);
|
||||
buf[0]='\0';
|
||||
strlen=snprintf(buf, buflen, "RD: %s, BGPNH: %s",
|
||||
bgp_vpn_rd_print(pptr),
|
||||
/* need something like getname() here */
|
||||
getname(pptr+8)
|
||||
);
|
||||
UPDATE_BUF_BUFLEN(buf, buflen, strlen);
|
||||
pptr+=12;
|
||||
tlen-=12;
|
||||
return plen;
|
||||
} else if (plen>17) {
|
||||
/* assume old format */
|
||||
/* RD, ID, LBLKOFF, LBLBASE */
|
||||
|
||||
/* ok now the variable part - lets read out TLVs*/
|
||||
while (tlen>0) {
|
||||
if (tlen < 3)
|
||||
return -1;
|
||||
TCHECK2(pptr[0], 3);
|
||||
tlv_type=*pptr++;
|
||||
tlv_len=EXTRACT_16BITS(pptr);
|
||||
ttlv_len=tlv_len;
|
||||
pptr+=2;
|
||||
TCHECK2(pptr[0],15);
|
||||
buf[0]='\0';
|
||||
strlen=snprintf(buf, buflen, "RD: %s, CE-ID: %u, Label-Block Offset: %u, Label Base %u",
|
||||
bgp_vpn_rd_print(pptr),
|
||||
EXTRACT_16BITS(pptr+8),
|
||||
EXTRACT_16BITS(pptr+10),
|
||||
EXTRACT_24BITS(pptr+12)>>4); /* the label is offsetted by 4 bits so lets shift it right */
|
||||
UPDATE_BUF_BUFLEN(buf, buflen, strlen);
|
||||
pptr+=15;
|
||||
tlen-=15;
|
||||
|
||||
switch(tlv_type) {
|
||||
case 1:
|
||||
if (buflen!=0) {
|
||||
strlen=snprintf(buf,buflen, "\n\t\tcircuit status vector (%u) length: %u: 0x",
|
||||
tlv_type,
|
||||
tlv_len);
|
||||
UPDATE_BUF_BUFLEN(buf, buflen, strlen);
|
||||
}
|
||||
ttlv_len=ttlv_len/8+1; /* how many bytes do we need to read ? */
|
||||
while (ttlv_len>0) {
|
||||
TCHECK(pptr[0]);
|
||||
if (buflen!=0) {
|
||||
strlen=snprintf(buf,buflen, "%02x",*pptr++);
|
||||
UPDATE_BUF_BUFLEN(buf, buflen, strlen);
|
||||
}
|
||||
ttlv_len--;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (buflen!=0) {
|
||||
strlen=snprintf(buf,buflen, "\n\t\tunknown TLV #%u, length: %u",
|
||||
tlv_type,
|
||||
tlv_len);
|
||||
UPDATE_BUF_BUFLEN(buf, buflen, strlen);
|
||||
}
|
||||
break;
|
||||
}
|
||||
tlen-=(tlv_len<<3); /* the tlv-length is expressed in bits so lets shift it right */
|
||||
/* ok now the variable part - lets read out TLVs*/
|
||||
while (tlen>0) {
|
||||
if (tlen < 3)
|
||||
return -1;
|
||||
TCHECK2(pptr[0], 3);
|
||||
tlv_type=*pptr++;
|
||||
tlv_len=EXTRACT_16BITS(pptr);
|
||||
ttlv_len=tlv_len;
|
||||
pptr+=2;
|
||||
|
||||
switch(tlv_type) {
|
||||
case 1:
|
||||
if (buflen!=0) {
|
||||
strlen=snprintf(buf,buflen, "\n\t\tcircuit status vector (%u) length: %u: 0x",
|
||||
tlv_type,
|
||||
tlv_len);
|
||||
UPDATE_BUF_BUFLEN(buf, buflen, strlen);
|
||||
}
|
||||
ttlv_len=ttlv_len/8+1; /* how many bytes do we need to read ? */
|
||||
while (ttlv_len>0) {
|
||||
TCHECK(pptr[0]);
|
||||
if (buflen!=0) {
|
||||
strlen=snprintf(buf,buflen, "%02x",*pptr++);
|
||||
UPDATE_BUF_BUFLEN(buf, buflen, strlen);
|
||||
}
|
||||
ttlv_len--;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (buflen!=0) {
|
||||
strlen=snprintf(buf,buflen, "\n\t\tunknown TLV #%u, length: %u",
|
||||
tlv_type,
|
||||
tlv_len);
|
||||
UPDATE_BUF_BUFLEN(buf, buflen, strlen);
|
||||
}
|
||||
break;
|
||||
}
|
||||
tlen-=(tlv_len<<3); /* the tlv-length is expressed in bits so lets shift it right */
|
||||
}
|
||||
return plen+2;
|
||||
|
||||
} else {
|
||||
/* complain bitterly ? */
|
||||
/* fall through */
|
||||
goto trunc;
|
||||
}
|
||||
return plen+2;
|
||||
|
||||
trunc:
|
||||
return -2;
|
||||
@ -1939,6 +1971,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len)
|
||||
switch(extd_comm) {
|
||||
case BGP_EXT_COM_RT_0:
|
||||
case BGP_EXT_COM_RO_0:
|
||||
case BGP_EXT_COM_L2VPN_RT_0:
|
||||
printf(": %u:%u (= %s)",
|
||||
EXTRACT_16BITS(tptr+2),
|
||||
EXTRACT_32BITS(tptr+4),
|
||||
@ -1946,6 +1979,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len)
|
||||
break;
|
||||
case BGP_EXT_COM_RT_1:
|
||||
case BGP_EXT_COM_RO_1:
|
||||
case BGP_EXT_COM_L2VPN_RT_1:
|
||||
case BGP_EXT_COM_VRF_RT_IMP:
|
||||
printf(": %s:%u",
|
||||
getname(tptr+2),
|
||||
|
88
print-carp.c
Normal file
88
print-carp.c
Normal file
@ -0,0 +1,88 @@
|
||||
/* $OpenBSD: print-carp.c,v 1.6 2009/10/27 23:59:55 deraadt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2000 William C. Fenner.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Kevin Steves <ks@hp.se> July 2000
|
||||
* Modified to:
|
||||
* - print version, type string and packet length
|
||||
* - print IP address count if > 1 (-v)
|
||||
* - verify checksum (-v)
|
||||
* - print authentication string (-v)
|
||||
*
|
||||
* Copyright (c) 2011 Advanced Computing Technologies
|
||||
* George V. Neille-Neil
|
||||
*
|
||||
* Modified to:
|
||||
* - work correctly with CARP
|
||||
* - compile into the latest tcpdump
|
||||
* - print out the counter
|
||||
*
|
||||
* 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 William C. Fenner 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <tcpdump-stdinc.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include "interface.h"
|
||||
#include "extract.h"
|
||||
#include "addrtoname.h"
|
||||
|
||||
void
|
||||
carp_print(register const u_char *bp, register u_int len, int ttl)
|
||||
{
|
||||
int version, type;
|
||||
const char *type_s;
|
||||
|
||||
TCHECK(bp[0]);
|
||||
version = (bp[0] & 0xf0) >> 4;
|
||||
type = bp[0] & 0x0f;
|
||||
if (type == 1)
|
||||
type_s = "advertise";
|
||||
else
|
||||
type_s = "unknown";
|
||||
printf("CARPv%d-%s %d: ", version, type_s, len);
|
||||
if (ttl != 255)
|
||||
printf("[ttl=%d!] ", ttl);
|
||||
if (version != 2 || type != 1)
|
||||
return;
|
||||
TCHECK(bp[2]);
|
||||
TCHECK(bp[5]);
|
||||
printf("vhid=%d advbase=%d advskew=%d authlen=%d ",
|
||||
bp[1], bp[5], bp[2], bp[3]);
|
||||
if (vflag) {
|
||||
struct cksum_vec vec[1];
|
||||
vec[0].ptr = (const u_int8_t *)bp;
|
||||
vec[0].len = len;
|
||||
if (TTEST2(bp[0], len) && in_cksum(vec, 1))
|
||||
printf(" (bad carp cksum %x!)",
|
||||
EXTRACT_16BITS(&bp[6]));
|
||||
}
|
||||
printf("counter=%" PRIu64, EXTRACT_64BITS(&bp[8]));
|
||||
|
||||
return;
|
||||
trunc:
|
||||
printf("[|carp]");
|
||||
}
|
@ -124,7 +124,7 @@ cdp_print(const u_char *pptr, u_int length, u_int caplen)
|
||||
tok2str(cdp_tlv_values,"unknown field type", type),
|
||||
type,
|
||||
len,
|
||||
len>1 ? "s" : ""); /* plural */
|
||||
PLURAL_SUFFIX(len)); /* plural */
|
||||
|
||||
switch (type) {
|
||||
|
||||
|
@ -85,7 +85,7 @@ chdlc_print(register const u_char *p, u_int length) {
|
||||
break;
|
||||
#ifdef INET6
|
||||
case ETHERTYPE_IPV6:
|
||||
ip6_print(p, length);
|
||||
ip6_print(gndo, p, length);
|
||||
break;
|
||||
#endif
|
||||
case CHDLC_TYPE_SLARP:
|
||||
|
56
print-dccp.c
56
print-dccp.c
@ -60,7 +60,7 @@ static const char *dccp_feature_nums[] = {
|
||||
"check data checksum",
|
||||
};
|
||||
|
||||
static inline int dccp_csum_coverage(const struct dccp_hdr* dh, u_int len)
|
||||
static inline u_int dccp_csum_coverage(const struct dccp_hdr* dh, u_int len)
|
||||
{
|
||||
u_int cov;
|
||||
|
||||
@ -73,61 +73,15 @@ static inline int dccp_csum_coverage(const struct dccp_hdr* dh, u_int len)
|
||||
static int dccp_cksum(const struct ip *ip,
|
||||
const struct dccp_hdr *dh, u_int len)
|
||||
{
|
||||
int cov = dccp_csum_coverage(dh, len);
|
||||
union phu {
|
||||
struct phdr {
|
||||
u_int32_t src;
|
||||
u_int32_t dst;
|
||||
u_char mbz;
|
||||
u_char proto;
|
||||
u_int16_t len;
|
||||
} ph;
|
||||
u_int16_t pa[6];
|
||||
} phu;
|
||||
const u_int16_t *sp;
|
||||
|
||||
/* pseudo-header.. */
|
||||
phu.ph.mbz = 0;
|
||||
phu.ph.len = htons(len);
|
||||
phu.ph.proto = IPPROTO_DCCP;
|
||||
memcpy(&phu.ph.src, &ip->ip_src.s_addr, sizeof(u_int32_t));
|
||||
if (IP_HL(ip) == 5)
|
||||
memcpy(&phu.ph.dst, &ip->ip_dst.s_addr, sizeof(u_int32_t));
|
||||
else
|
||||
phu.ph.dst = ip_finddst(ip);
|
||||
|
||||
sp = &phu.pa[0];
|
||||
return in_cksum((u_short *)dh, cov, sp[0]+sp[1]+sp[2]+sp[3]+sp[4]+sp[5]);
|
||||
return nextproto4_cksum(ip, (const u_int8_t *)(void *)dh,
|
||||
dccp_csum_coverage(dh, len), IPPROTO_DCCP);
|
||||
}
|
||||
|
||||
#ifdef INET6
|
||||
static int dccp6_cksum(const struct ip6_hdr *ip6, const struct dccp_hdr *dh, u_int len)
|
||||
{
|
||||
size_t i;
|
||||
u_int32_t sum = 0;
|
||||
int cov = dccp_csum_coverage(dh, len);
|
||||
union {
|
||||
struct {
|
||||
struct in6_addr ph_src;
|
||||
struct in6_addr ph_dst;
|
||||
u_int32_t ph_len;
|
||||
u_int8_t ph_zero[3];
|
||||
u_int8_t ph_nxt;
|
||||
} ph;
|
||||
u_int16_t pa[20];
|
||||
} phu;
|
||||
|
||||
/* pseudo-header */
|
||||
memset(&phu, 0, sizeof(phu));
|
||||
phu.ph.ph_src = ip6->ip6_src;
|
||||
phu.ph.ph_dst = ip6->ip6_dst;
|
||||
phu.ph.ph_len = htonl(len);
|
||||
phu.ph.ph_nxt = IPPROTO_DCCP;
|
||||
|
||||
for (i = 0; i < sizeof(phu.pa) / sizeof(phu.pa[0]); i++)
|
||||
sum += phu.pa[i];
|
||||
|
||||
return in_cksum((u_short *)dh, cov, sum);
|
||||
return nextproto6_cksum(ip6, (const u_int8_t *)(void *)dh,
|
||||
dccp_csum_coverage(dh, len), IPPROTO_DCCP);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -229,15 +229,15 @@ dhcp6opt_name(int type)
|
||||
case DH6OPT_SIP_SERVER_A:
|
||||
return "SIP-servers-address";
|
||||
case DH6OPT_DNS:
|
||||
return "DNS";
|
||||
return "DNS-server";
|
||||
case DH6OPT_DNSNAME:
|
||||
return "DNS-name";
|
||||
return "DNS-search-list";
|
||||
case DH6OPT_IA_PD:
|
||||
return "IA_PD";
|
||||
case DH6OPT_IA_PD_PREFIX:
|
||||
return "IA_PD-prefix";
|
||||
case DH6OPT_NTP_SERVERS:
|
||||
return "NTP-Server";
|
||||
return "NTP-server";
|
||||
case DH6OPT_LIFETIME:
|
||||
return "lifetime";
|
||||
case DH6OPT_NIS_SERVERS:
|
||||
|
@ -280,7 +280,7 @@ eigrp_print(register const u_char *pptr, register u_int len) {
|
||||
|
||||
if (eigrp_tlv_len < sizeof(struct eigrp_tlv_header) ||
|
||||
eigrp_tlv_len > tlen) {
|
||||
print_unknown_data(tptr+sizeof(sizeof(struct eigrp_tlv_header)),"\n\t ",tlen);
|
||||
print_unknown_data(tptr+sizeof(struct eigrp_tlv_header),"\n\t ",tlen);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -468,7 +468,7 @@ eigrp_print(register const u_char *pptr, register u_int len) {
|
||||
}
|
||||
/* do we want to see an additionally hexdump ? */
|
||||
if (vflag > 1)
|
||||
print_unknown_data(tptr+sizeof(sizeof(struct eigrp_tlv_header)),"\n\t ",
|
||||
print_unknown_data(tptr+sizeof(struct eigrp_tlv_header),"\n\t ",
|
||||
eigrp_tlv_len-sizeof(struct eigrp_tlv_header));
|
||||
|
||||
tptr+=eigrp_tlv_len;
|
||||
|
@ -80,7 +80,7 @@ enc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
|
||||
break;
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
ip6_print(p, length);
|
||||
ip6_print(gndo, p, length);
|
||||
break;
|
||||
#endif /*INET6*/
|
||||
}
|
||||
|
191
print-ether.c
191
print-ether.c
@ -23,6 +23,7 @@ static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.106 2008-02-06 10:47:53 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#define NETDISSECT_REWORKED
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
@ -45,6 +46,9 @@ const struct tok ethertype_values[] = {
|
||||
{ ETHERTYPE_MPLS_MULTI, "MPLS multicast" },
|
||||
{ ETHERTYPE_IPV6, "IPv6" },
|
||||
{ ETHERTYPE_8021Q, "802.1Q" },
|
||||
{ ETHERTYPE_8021Q9100, "802.1Q-9100" },
|
||||
{ ETHERTYPE_8021QinQ, "802.1Q-QinQ" },
|
||||
{ ETHERTYPE_8021Q9200, "802.1Q-9200" },
|
||||
{ ETHERTYPE_VMAN, "VMAN" },
|
||||
{ ETHERTYPE_PUP, "PUP" },
|
||||
{ ETHERTYPE_ARP, "ARP"},
|
||||
@ -84,33 +88,34 @@ const struct tok ethertype_values[] = {
|
||||
};
|
||||
|
||||
static inline void
|
||||
ether_hdr_print(register const u_char *bp, u_int length)
|
||||
ether_hdr_print(netdissect_options *ndo,
|
||||
const u_char *bp, u_int length)
|
||||
{
|
||||
register const struct ether_header *ep;
|
||||
u_int16_t ether_type;
|
||||
|
||||
ep = (const struct ether_header *)bp;
|
||||
|
||||
(void)printf("%s > %s",
|
||||
(void)ND_PRINT((ndo, "%s > %s",
|
||||
etheraddr_string(ESRC(ep)),
|
||||
etheraddr_string(EDST(ep)));
|
||||
etheraddr_string(EDST(ep))));
|
||||
|
||||
ether_type = EXTRACT_16BITS(&ep->ether_type);
|
||||
if (!qflag) {
|
||||
if (!ndo->ndo_qflag) {
|
||||
if (ether_type <= ETHERMTU)
|
||||
(void)printf(", 802.3");
|
||||
(void)ND_PRINT((ndo, ", 802.3"));
|
||||
else
|
||||
(void)printf(", ethertype %s (0x%04x)",
|
||||
(void)ND_PRINT((ndo, ", ethertype %s (0x%04x)",
|
||||
tok2str(ethertype_values,"Unknown", ether_type),
|
||||
ether_type);
|
||||
ether_type));
|
||||
} else {
|
||||
if (ether_type <= ETHERMTU)
|
||||
(void)printf(", 802.3");
|
||||
(void)ND_PRINT((ndo, ", 802.3"));
|
||||
else
|
||||
(void)printf(", %s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", ether_type));
|
||||
(void)ND_PRINT((ndo, ", %s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", ether_type)));
|
||||
}
|
||||
|
||||
(void)printf(", length %u: ", length);
|
||||
(void)ND_PRINT((ndo, ", length %u: ", length));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -120,8 +125,9 @@ ether_hdr_print(register const u_char *bp, u_int length)
|
||||
* frame's protocol, and an argument to pass to that function.
|
||||
*/
|
||||
void
|
||||
ether_print(const u_char *p, u_int length, u_int caplen,
|
||||
void (*print_encap_header)(const u_char *), const u_char *encap_header_arg)
|
||||
ether_print(netdissect_options *ndo,
|
||||
const u_char *p, u_int length, u_int caplen,
|
||||
void (*print_encap_header)(netdissect_options *ndo, const u_char *), const u_char *encap_header_arg)
|
||||
{
|
||||
struct ether_header *ep;
|
||||
u_int orig_length;
|
||||
@ -129,14 +135,14 @@ ether_print(const u_char *p, u_int length, u_int caplen,
|
||||
u_short extracted_ether_type;
|
||||
|
||||
if (caplen < ETHER_HDRLEN || length < ETHER_HDRLEN) {
|
||||
printf("[|ether]");
|
||||
ND_PRINT((ndo, "[|ether]"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (eflag) {
|
||||
if (ndo->ndo_eflag) {
|
||||
if (print_encap_header != NULL)
|
||||
(*print_encap_header)(encap_header_arg);
|
||||
ether_hdr_print(p, length);
|
||||
(*print_encap_header)(ndo, encap_header_arg);
|
||||
ether_hdr_print(ndo, p, length);
|
||||
}
|
||||
orig_length = length;
|
||||
|
||||
@ -156,36 +162,39 @@ ether_print(const u_char *p, u_int length, u_int caplen,
|
||||
if (llc_print(p, length, caplen, ESRC(ep), EDST(ep),
|
||||
&extracted_ether_type) == 0) {
|
||||
/* ether_type not known, print raw packet */
|
||||
if (!eflag) {
|
||||
if (!ndo->ndo_eflag) {
|
||||
if (print_encap_header != NULL)
|
||||
(*print_encap_header)(encap_header_arg);
|
||||
ether_hdr_print((u_char *)ep, orig_length);
|
||||
(*print_encap_header)(ndo, encap_header_arg);
|
||||
ether_hdr_print(ndo, (u_char *)ep, orig_length);
|
||||
}
|
||||
|
||||
if (!suppress_default_print)
|
||||
default_print(p, caplen);
|
||||
if (!ndo->ndo_suppress_default_print)
|
||||
ndo->ndo_default_print(ndo, p, caplen);
|
||||
}
|
||||
} else if (ether_type == ETHERTYPE_8021Q) {
|
||||
} else if (ether_type == ETHERTYPE_8021Q ||
|
||||
ether_type == ETHERTYPE_8021Q9100 ||
|
||||
ether_type == ETHERTYPE_8021Q9200 ||
|
||||
ether_type == ETHERTYPE_8021QinQ) {
|
||||
/*
|
||||
* Print VLAN information, and then go back and process
|
||||
* the enclosed type field.
|
||||
*/
|
||||
if (caplen < 4 || length < 4) {
|
||||
printf("[|vlan]");
|
||||
ND_PRINT((ndo, "[|vlan]"));
|
||||
return;
|
||||
}
|
||||
if (eflag) {
|
||||
if (ndo->ndo_eflag) {
|
||||
u_int16_t tag = EXTRACT_16BITS(p);
|
||||
|
||||
printf("vlan %u, p %u%s, ",
|
||||
ND_PRINT((ndo, "vlan %u, p %u%s, ",
|
||||
tag & 0xfff,
|
||||
tag >> 13,
|
||||
(tag & 0x1000) ? ", CFI" : "");
|
||||
(tag & 0x1000) ? ", CFI" : ""));
|
||||
}
|
||||
|
||||
ether_type = EXTRACT_16BITS(p + 2);
|
||||
if (eflag && ether_type > ETHERMTU)
|
||||
printf("ethertype %s, ", tok2str(ethertype_values,"0x%04x", ether_type));
|
||||
if (ndo->ndo_eflag && ether_type > ETHERMTU)
|
||||
ND_PRINT((ndo, "ethertype %s, ", tok2str(ethertype_values,"0x%04x", ether_type)));
|
||||
p += 4;
|
||||
length -= 4;
|
||||
caplen -= 4;
|
||||
@ -204,26 +213,26 @@ ether_print(const u_char *p, u_int length, u_int caplen,
|
||||
if (llc_print(p, length, caplen, ESRC(ep), EDST(ep),
|
||||
&extracted_ether_type) == 0) {
|
||||
/* ether_type not known, print raw packet */
|
||||
if (!eflag) {
|
||||
if (!ndo->ndo_eflag) {
|
||||
if (print_encap_header != NULL)
|
||||
(*print_encap_header)(encap_header_arg);
|
||||
ether_hdr_print((u_char *)ep, orig_length);
|
||||
(*print_encap_header)(ndo, encap_header_arg);
|
||||
ether_hdr_print(ndo, (u_char *)ep, orig_length);
|
||||
}
|
||||
|
||||
if (!suppress_default_print)
|
||||
default_print(p, caplen);
|
||||
if (!ndo->ndo_suppress_default_print)
|
||||
ndo->ndo_default_print(ndo, p, caplen);
|
||||
}
|
||||
} else {
|
||||
if (ethertype_print(ether_type, p, length, caplen) == 0) {
|
||||
if (ethertype_print(ndo, ether_type, p, length, caplen) == 0) {
|
||||
/* ether_type not known, print raw packet */
|
||||
if (!eflag) {
|
||||
if (!ndo->ndo_eflag) {
|
||||
if (print_encap_header != NULL)
|
||||
(*print_encap_header)(encap_header_arg);
|
||||
ether_hdr_print((u_char *)ep, orig_length);
|
||||
(*print_encap_header)(ndo, encap_header_arg);
|
||||
ether_hdr_print(ndo, (u_char *)ep, orig_length);
|
||||
}
|
||||
|
||||
if (!suppress_default_print)
|
||||
default_print(p, caplen);
|
||||
if (!ndo->ndo_suppress_default_print)
|
||||
ndo->ndo_default_print(ndo, p, caplen);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -235,13 +244,71 @@ ether_print(const u_char *p, u_int length, u_int caplen,
|
||||
* is the number of bytes actually captured.
|
||||
*/
|
||||
u_int
|
||||
ether_if_print(const struct pcap_pkthdr *h, const u_char *p)
|
||||
ether_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
|
||||
const u_char *p)
|
||||
{
|
||||
ether_print(p, h->len, h->caplen, NULL, NULL);
|
||||
ether_print(ndo, p, h->len, h->caplen, NULL, NULL);
|
||||
|
||||
return (ETHER_HDRLEN);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* This is for DLT_NETANALYZER, which has a 4-byte pseudo-header
|
||||
* before the Ethernet header.
|
||||
*/
|
||||
u_int
|
||||
netanalyzer_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
|
||||
const u_char *p)
|
||||
{
|
||||
/*
|
||||
* Fail if we don't have enough data for the Hilscher pseudo-header.
|
||||
*/
|
||||
if (h->len < 4 || h->caplen < 4) {
|
||||
printf("[|netanalyzer]");
|
||||
return (h->caplen);
|
||||
}
|
||||
|
||||
/* Skip the pseudo-header. */
|
||||
ether_print(ndo, p + 4, h->len - 4, h->caplen - 4, NULL, NULL);
|
||||
|
||||
return (4 + ETHER_HDRLEN);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* This is for DLT_NETANALYZER_TRANSPARENT, which has a 4-byte
|
||||
* pseudo-header, a 7-byte Ethernet preamble, and a 1-byte Ethernet SOF
|
||||
* before the Ethernet header.
|
||||
*/
|
||||
u_int
|
||||
netanalyzer_transparent_if_print(netdissect_options *ndo,
|
||||
const struct pcap_pkthdr *h,
|
||||
const u_char *p)
|
||||
{
|
||||
/*
|
||||
* Fail if we don't have enough data for the Hilscher pseudo-header,
|
||||
* preamble, and SOF.
|
||||
*/
|
||||
if (h->len < 12 || h->caplen < 12) {
|
||||
printf("[|netanalyzer-transparent]");
|
||||
return (h->caplen);
|
||||
}
|
||||
|
||||
/* Skip the pseudo-header, preamble, and SOF. */
|
||||
ether_print(ndo, p + 12, h->len - 12, h->caplen - 12, NULL, NULL);
|
||||
|
||||
return (12 + ETHER_HDRLEN);
|
||||
}
|
||||
|
||||
/*
|
||||
* Prints the packet payload, given an Ethernet type code for the payload's
|
||||
* protocol.
|
||||
@ -250,85 +317,87 @@ ether_if_print(const struct pcap_pkthdr *h, const u_char *p)
|
||||
*/
|
||||
|
||||
int
|
||||
ethertype_print(u_short ether_type, const u_char *p, u_int length, u_int caplen)
|
||||
ethertype_print(netdissect_options *ndo,
|
||||
u_short ether_type, const u_char *p,
|
||||
u_int length, u_int caplen)
|
||||
{
|
||||
switch (ether_type) {
|
||||
|
||||
case ETHERTYPE_IP:
|
||||
ip_print(gndo, p, length);
|
||||
ip_print(ndo, p, length);
|
||||
return (1);
|
||||
|
||||
#ifdef INET6
|
||||
case ETHERTYPE_IPV6:
|
||||
ip6_print(p, length);
|
||||
ip6_print(ndo, p, length);
|
||||
return (1);
|
||||
#endif /*INET6*/
|
||||
|
||||
case ETHERTYPE_ARP:
|
||||
case ETHERTYPE_REVARP:
|
||||
arp_print(gndo, p, length, caplen);
|
||||
arp_print(ndo, p, length, caplen);
|
||||
return (1);
|
||||
|
||||
case ETHERTYPE_DN:
|
||||
decnet_print(p, length, caplen);
|
||||
decnet_print(/*ndo,*/p, length, caplen);
|
||||
return (1);
|
||||
|
||||
case ETHERTYPE_ATALK:
|
||||
if (vflag)
|
||||
if (ndo->ndo_vflag)
|
||||
fputs("et1 ", stdout);
|
||||
atalk_print(p, length);
|
||||
atalk_print(/*ndo,*/p, length);
|
||||
return (1);
|
||||
|
||||
case ETHERTYPE_AARP:
|
||||
aarp_print(p, length);
|
||||
aarp_print(/*ndo,*/p, length);
|
||||
return (1);
|
||||
|
||||
case ETHERTYPE_IPX:
|
||||
printf("(NOV-ETHII) ");
|
||||
ipx_print(p, length);
|
||||
ND_PRINT((ndo, "(NOV-ETHII) "));
|
||||
ipx_print(/*ndo,*/p, length);
|
||||
return (1);
|
||||
|
||||
case ETHERTYPE_ISO:
|
||||
isoclns_print(p+1, length-1, length-1);
|
||||
isoclns_print(/*ndo,*/p+1, length-1, length-1);
|
||||
return(1);
|
||||
|
||||
case ETHERTYPE_PPPOED:
|
||||
case ETHERTYPE_PPPOES:
|
||||
case ETHERTYPE_PPPOED2:
|
||||
case ETHERTYPE_PPPOES2:
|
||||
pppoe_print(p, length);
|
||||
pppoe_print(/*ndo,*/p, length);
|
||||
return (1);
|
||||
|
||||
case ETHERTYPE_EAPOL:
|
||||
eap_print(gndo, p, length);
|
||||
eap_print(ndo, p, length);
|
||||
return (1);
|
||||
|
||||
case ETHERTYPE_RRCP:
|
||||
rrcp_print(gndo, p - 14 , length + 14);
|
||||
rrcp_print(ndo, p - 14 , length + 14);
|
||||
return (1);
|
||||
|
||||
case ETHERTYPE_PPP:
|
||||
if (length) {
|
||||
printf(": ");
|
||||
ppp_print(p, length);
|
||||
ppp_print(/*ndo,*/p, length);
|
||||
}
|
||||
return (1);
|
||||
|
||||
case ETHERTYPE_MPCP:
|
||||
mpcp_print(p, length);
|
||||
mpcp_print(/*ndo,*/p, length);
|
||||
return (1);
|
||||
|
||||
case ETHERTYPE_SLOW:
|
||||
slow_print(p, length);
|
||||
slow_print(/*ndo,*/p, length);
|
||||
return (1);
|
||||
|
||||
case ETHERTYPE_CFM:
|
||||
case ETHERTYPE_CFM_OLD:
|
||||
cfm_print(p, length);
|
||||
cfm_print(/*ndo,*/p, length);
|
||||
return (1);
|
||||
|
||||
case ETHERTYPE_LLDP:
|
||||
lldp_print(p, length);
|
||||
lldp_print(/*ndo,*/p, length);
|
||||
return (1);
|
||||
|
||||
case ETHERTYPE_LOOPBACK:
|
||||
@ -336,7 +405,7 @@ ethertype_print(u_short ether_type, const u_char *p, u_int length, u_int caplen)
|
||||
|
||||
case ETHERTYPE_MPLS:
|
||||
case ETHERTYPE_MPLS_MULTI:
|
||||
mpls_print(p, length);
|
||||
mpls_print(/*ndo,*/p, length);
|
||||
return (1);
|
||||
|
||||
case ETHERTYPE_LAT:
|
||||
|
@ -213,7 +213,7 @@ pkeyitlv_print(register const u_char * pptr, register u_int len,
|
||||
|
||||
int
|
||||
pdatacnt_print(register const u_char * pptr, register u_int len,
|
||||
u_int32_t IDcnt, u_int16_t op_msk, int indent)
|
||||
u_int16_t IDcnt, u_int16_t op_msk, int indent)
|
||||
{
|
||||
u_int i;
|
||||
int rc;
|
||||
@ -270,7 +270,7 @@ pdatacnt_print(register const u_char * pptr, register u_int len,
|
||||
if (vflag >= 3 && ops->v != F_TLV_PDAT) {
|
||||
if (pad)
|
||||
printf
|
||||
("%s %s (Length %d DataLen %d pad %d Bytes)\n",
|
||||
("%s %s (Length %d DataLen %d pad %d Bytes)\n",
|
||||
ib, ops->s, EXTRACT_16BITS(&pdtlv->length),
|
||||
tll, pad);
|
||||
else
|
||||
@ -285,6 +285,7 @@ pdatacnt_print(register const u_char * pptr, register u_int len,
|
||||
rc = ops->print((const u_char *)pdtlv,
|
||||
tll + pad + TLV_HDRL, op_msk,
|
||||
indent + 2);
|
||||
len -= (TLV_HDRL + pad + tll);
|
||||
} else {
|
||||
printf("Invalid path data content type 0x%x len %d\n",
|
||||
type, EXTRACT_16BITS(&pdtlv->length));
|
||||
@ -298,7 +299,7 @@ pdatacnt_print(register const u_char * pptr, register u_int len,
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return len;
|
||||
|
||||
trunc:
|
||||
fputs("[|forces]", stdout);
|
||||
@ -312,6 +313,8 @@ pdata_print(register const u_char * pptr, register u_int len,
|
||||
const struct pathdata_h *pdh = (struct pathdata_h *)pptr;
|
||||
char *ib = indent_pr(indent, 0);
|
||||
u_int minsize = 0;
|
||||
int more_pd = 0;
|
||||
u_int16_t idcnt = 0;
|
||||
|
||||
TCHECK(*pdh);
|
||||
if (len < sizeof(struct pathdata_h))
|
||||
@ -326,7 +329,8 @@ pdata_print(register const u_char * pptr, register u_int len,
|
||||
}
|
||||
pptr += sizeof(struct pathdata_h);
|
||||
len -= sizeof(struct pathdata_h);
|
||||
minsize = EXTRACT_16BITS(&pdh->pIDcnt) * 4;
|
||||
idcnt = EXTRACT_16BITS(&pdh->pIDcnt);
|
||||
minsize = idcnt * 4;
|
||||
if (len < minsize) {
|
||||
printf("\t\t\ttruncated IDs expected %uB got %uB\n", minsize,
|
||||
len);
|
||||
@ -334,7 +338,15 @@ pdata_print(register const u_char * pptr, register u_int len,
|
||||
printf("]\n");
|
||||
return -1;
|
||||
}
|
||||
return pdatacnt_print(pptr, len, EXTRACT_16BITS(&pdh->pIDcnt), op_msk, indent);
|
||||
more_pd = pdatacnt_print(pptr, len, idcnt, op_msk, indent);
|
||||
if (more_pd > 0) {
|
||||
int consumed = len - more_pd;
|
||||
pptr += consumed;
|
||||
len = more_pd;
|
||||
/* XXX: Argh, recurse some more */
|
||||
return recpdoptlv_print(pptr, len, op_msk, indent+1);
|
||||
} else
|
||||
return 0;
|
||||
|
||||
trunc:
|
||||
fputs("[|forces]", stdout);
|
||||
|
@ -256,7 +256,7 @@ fr_print(register const u_char *p, u_int length)
|
||||
if (eflag)
|
||||
fr_hdr_print(length, addr_len, dlci, flags, extracted_ethertype);
|
||||
|
||||
if (ethertype_print(extracted_ethertype,
|
||||
if (ethertype_print(gndo, extracted_ethertype,
|
||||
p+addr_len+ETHERTYPE_LEN,
|
||||
length-addr_len-ETHERTYPE_LEN,
|
||||
length-addr_len-ETHERTYPE_LEN) == 0)
|
||||
@ -286,7 +286,7 @@ fr_print(register const u_char *p, u_int length)
|
||||
|
||||
#ifdef INET6
|
||||
case NLPID_IP6:
|
||||
ip6_print(p, length);
|
||||
ip6_print(gndo, p, length);
|
||||
break;
|
||||
#endif
|
||||
case NLPID_CLNP:
|
||||
|
@ -210,7 +210,7 @@ gre_print_0(const u_char *bp, u_int length)
|
||||
break;
|
||||
#ifdef INET6
|
||||
case ETHERTYPE_IPV6:
|
||||
ip6_print(bp, len);
|
||||
ip6_print(gndo, bp, len);
|
||||
break;
|
||||
#endif
|
||||
case ETHERTYPE_MPLS:
|
||||
@ -226,7 +226,7 @@ gre_print_0(const u_char *bp, u_int length)
|
||||
isoclns_print(bp, len, len);
|
||||
break;
|
||||
case ETHERTYPE_TEB:
|
||||
ether_print(bp, len, len, NULL, NULL);
|
||||
ether_print(gndo, bp, len, len, NULL, NULL);
|
||||
break;
|
||||
default:
|
||||
printf("gre-proto-0x%x", prot);
|
||||
|
21
print-icmp.c
21
print-icmp.c
@ -346,6 +346,7 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
|
||||
const struct icmp_mpls_ext_object_header_t *icmp_mpls_ext_object_header;
|
||||
u_int hlen, dport, mtu, obj_tlen, obj_class_num, obj_ctype;
|
||||
char buf[MAXHOSTNAMELEN + 100];
|
||||
struct cksum_vec vec[1];
|
||||
|
||||
dp = (struct icmp *)bp;
|
||||
ext_dp = (struct icmp_ext_t *)bp;
|
||||
@ -560,8 +561,11 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
|
||||
(void)printf("ICMP %s, length %u", str, plen);
|
||||
if (vflag && !fragmented) { /* don't attempt checksumming if this is a frag */
|
||||
u_int16_t sum, icmp_sum;
|
||||
struct cksum_vec vec[1];
|
||||
if (TTEST2(*bp, plen)) {
|
||||
sum = in_cksum((u_short*)dp, plen, 0);
|
||||
vec[0].ptr = (const u_int8_t *)(void *)dp;
|
||||
vec[0].len = plen;
|
||||
sum = in_cksum(vec, 1);
|
||||
if (sum != 0) {
|
||||
icmp_sum = EXTRACT_16BITS(&dp->icmp_cksum);
|
||||
(void)printf(" (wrong icmp cksum %x (->%x)!)",
|
||||
@ -598,10 +602,12 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
|
||||
* to check if an extension header is present. This is expedient,
|
||||
* however not all implementations set the length field proper.
|
||||
*/
|
||||
if (!ext_dp->icmp_length &&
|
||||
in_cksum((const u_short *)&ext_dp->icmp_ext_version_res,
|
||||
plen - ICMP_EXTD_MINLEN, 0)) {
|
||||
return;
|
||||
if (!ext_dp->icmp_length) {
|
||||
vec[0].ptr = (const u_int8_t *)(void *)&ext_dp->icmp_ext_version_res;
|
||||
vec[0].len = plen - ICMP_EXTD_MINLEN;
|
||||
if (in_cksum(vec, 1)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
printf("\n\tMPLS extension v%u",
|
||||
@ -617,10 +623,11 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
|
||||
}
|
||||
|
||||
hlen = plen - ICMP_EXTD_MINLEN;
|
||||
vec[0].ptr = (const u_int8_t *)(void *)&ext_dp->icmp_ext_version_res;
|
||||
vec[0].len = hlen;
|
||||
printf(", checksum 0x%04x (%scorrect), length %u",
|
||||
EXTRACT_16BITS(ext_dp->icmp_ext_checksum),
|
||||
in_cksum((const u_short *)&ext_dp->icmp_ext_version_res,
|
||||
plen - ICMP_EXTD_MINLEN, 0) ? "in" : "",
|
||||
in_cksum(vec, 1) ? "in" : "",
|
||||
hlen);
|
||||
|
||||
hlen -= 4; /* subtract common header size */
|
||||
|
101
print-icmp6.c
101
print-icmp6.c
@ -197,50 +197,20 @@ print_lladdr(const u_int8_t *p, size_t l)
|
||||
static int icmp6_cksum(const struct ip6_hdr *ip6, const struct icmp6_hdr *icp,
|
||||
u_int len)
|
||||
{
|
||||
size_t i;
|
||||
register const u_int16_t *sp;
|
||||
u_int32_t sum;
|
||||
union {
|
||||
struct {
|
||||
struct in6_addr ph_src;
|
||||
struct in6_addr ph_dst;
|
||||
u_int32_t ph_len;
|
||||
u_int8_t ph_zero[3];
|
||||
u_int8_t ph_nxt;
|
||||
} ph;
|
||||
u_int16_t pa[20];
|
||||
} phu;
|
||||
|
||||
/* pseudo-header */
|
||||
memset(&phu, 0, sizeof(phu));
|
||||
phu.ph.ph_src = ip6->ip6_src;
|
||||
phu.ph.ph_dst = ip6->ip6_dst;
|
||||
phu.ph.ph_len = htonl(len);
|
||||
phu.ph.ph_nxt = IPPROTO_ICMPV6;
|
||||
|
||||
sum = 0;
|
||||
for (i = 0; i < sizeof(phu.pa) / sizeof(phu.pa[0]); i++)
|
||||
sum += phu.pa[i];
|
||||
|
||||
sp = (const u_int16_t *)icp;
|
||||
|
||||
for (i = 0; i < (len & ~1); i += 2)
|
||||
sum += *sp++;
|
||||
|
||||
if (len & 1)
|
||||
sum += htons((*(const u_int8_t *)sp) << 8);
|
||||
|
||||
while (sum > 0xffff)
|
||||
sum = (sum & 0xffff) + (sum >> 16);
|
||||
sum = ~sum & 0xffff;
|
||||
|
||||
return (sum);
|
||||
return (nextproto6_cksum(ip6, (const u_int8_t *)(void *)icp, len,
|
||||
IPPROTO_ICMPV6));
|
||||
}
|
||||
|
||||
enum ND_RPL_CODE {
|
||||
ND_RPL_DAG_IS=0x01,
|
||||
ND_RPL_DAG_IO=0x02,
|
||||
ND_RPL_DAO =0x04
|
||||
ND_RPL_DIS =0x00,
|
||||
ND_RPL_DIO =0x01,
|
||||
ND_RPL_DAO =0x02,
|
||||
ND_RPL_DAO_ACK=0x03,
|
||||
ND_RPL_SDIS =0x80,
|
||||
ND_RPL_SDIO =0x81,
|
||||
ND_RPL_SDAO =0x82,
|
||||
ND_RPL_SDAO_ACK=0x83,
|
||||
ND_RPL_SCC =0x8A,
|
||||
};
|
||||
|
||||
enum ND_RPL_DIO_FLAGS {
|
||||
@ -266,17 +236,25 @@ rpl_print(netdissect_options *ndo,
|
||||
const u_char *bp, u_int length _U_)
|
||||
{
|
||||
struct nd_rpl_dio *dio = (struct nd_rpl_dio *)bp;
|
||||
int secured = hdr->icmp6_code & 0x80;
|
||||
int basecode= hdr->icmp6_code & 0x7f;
|
||||
|
||||
ND_TCHECK(dio->rpl_dagid);
|
||||
|
||||
switch(hdr->icmp6_code) {
|
||||
case ND_RPL_DAG_IS:
|
||||
ND_PRINT((ndo, ", DAG Information Solicitation"));
|
||||
if(secured) {
|
||||
ND_PRINT((ndo, ", (SEC)"));
|
||||
} else {
|
||||
ND_PRINT((ndo, ", (CLR)"));
|
||||
}
|
||||
|
||||
switch(basecode) {
|
||||
case ND_RPL_DIS:
|
||||
ND_PRINT((ndo, "DODAG Information Solicitation"));
|
||||
if(ndo->ndo_vflag) {
|
||||
}
|
||||
break;
|
||||
case ND_RPL_DAG_IO:
|
||||
ND_PRINT((ndo, ", DAG Information Object"));
|
||||
case ND_RPL_DIO:
|
||||
ND_PRINT((ndo, "DODAG Information Object"));
|
||||
if(ndo->ndo_vflag) {
|
||||
char dagid[65];
|
||||
char *d = dagid;
|
||||
@ -299,12 +277,17 @@ rpl_print(netdissect_options *ndo,
|
||||
}
|
||||
break;
|
||||
case ND_RPL_DAO:
|
||||
ND_PRINT((ndo, ", Destination Advertisement Object"));
|
||||
ND_PRINT((ndo, "Destination Advertisement Object"));
|
||||
if(ndo->ndo_vflag) {
|
||||
}
|
||||
break;
|
||||
case ND_RPL_DAO_ACK:
|
||||
ND_PRINT((ndo, "Destination Advertisement Object Ack"));
|
||||
if(ndo->ndo_vflag) {
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ND_PRINT((ndo, ", RPL message, unknown code %u",hdr->icmp6_code));
|
||||
ND_PRINT((ndo, "RPL message, unknown code %u",hdr->icmp6_code));
|
||||
break;
|
||||
}
|
||||
return;
|
||||
@ -336,12 +319,15 @@ icmp6_print(netdissect_options *ndo,
|
||||
TCHECK(dp->icmp6_cksum);
|
||||
|
||||
if (vflag && !fragmented) {
|
||||
int sum = dp->icmp6_cksum;
|
||||
u_int16_t sum, udp_sum;
|
||||
|
||||
if (TTEST2(bp[0], length)) {
|
||||
udp_sum = EXTRACT_16BITS(&dp->icmp6_cksum);
|
||||
sum = icmp6_cksum(ip, dp, length);
|
||||
if (sum != 0)
|
||||
(void)printf("[bad icmp6 cksum %x!] ", sum);
|
||||
(void)printf("[bad icmp6 cksum 0x%04x -> 0x%04x!] ",
|
||||
udp_sum,
|
||||
in_cksum_shouldbe(udp_sum, sum));
|
||||
else
|
||||
(void)printf("[icmp6 sum ok] ");
|
||||
}
|
||||
@ -350,14 +336,13 @@ icmp6_print(netdissect_options *ndo,
|
||||
printf("ICMP6, %s", tok2str(icmp6_type_values,"unknown icmp6 type (%u)",dp->icmp6_type));
|
||||
|
||||
/* display cosmetics: print the packet length for printer that use the vflag now */
|
||||
if (vflag && (dp->icmp6_type ==
|
||||
ND_ROUTER_SOLICIT ||
|
||||
ND_ROUTER_ADVERT ||
|
||||
ND_NEIGHBOR_ADVERT ||
|
||||
ND_NEIGHBOR_SOLICIT ||
|
||||
ND_REDIRECT ||
|
||||
ICMP6_HADISCOV_REPLY ||
|
||||
ICMP6_MOBILEPREFIX_ADVERT ))
|
||||
if (vflag && (dp->icmp6_type == ND_ROUTER_SOLICIT ||
|
||||
dp->icmp6_type == ND_ROUTER_ADVERT ||
|
||||
dp->icmp6_type == ND_NEIGHBOR_ADVERT ||
|
||||
dp->icmp6_type == ND_NEIGHBOR_SOLICIT ||
|
||||
dp->icmp6_type == ND_REDIRECT ||
|
||||
dp->icmp6_type == ICMP6_HADISCOV_REPLY ||
|
||||
dp->icmp6_type == ICMP6_MOBILEPREFIX_ADVERT ))
|
||||
printf(", length %u", length);
|
||||
|
||||
switch (dp->icmp6_type) {
|
||||
|
@ -259,6 +259,8 @@ print_igmpv3_query(register const u_char *bp, register u_int len)
|
||||
void
|
||||
igmp_print(register const u_char *bp, register u_int len)
|
||||
{
|
||||
struct cksum_vec vec[1];
|
||||
|
||||
if (qflag) {
|
||||
(void)printf("igmp");
|
||||
return;
|
||||
@ -327,7 +329,9 @@ igmp_print(register const u_char *bp, register u_int len)
|
||||
|
||||
if (vflag && TTEST2(bp[0], len)) {
|
||||
/* Check the IGMP checksum */
|
||||
if (in_cksum((const u_short*)bp, len, 0))
|
||||
vec[0].ptr = bp;
|
||||
vec[0].len = len;
|
||||
if (in_cksum(vec, 1))
|
||||
printf(" bad igmp cksum %x!", EXTRACT_16BITS(&bp[2]));
|
||||
}
|
||||
return;
|
||||
|
160
print-ip.c
160
print-ip.c
@ -87,7 +87,7 @@ ip_printroute(register const u_char *cp, u_int length)
|
||||
* This is used for UDP and TCP pseudo-header in the checksum
|
||||
* calculation.
|
||||
*/
|
||||
u_int32_t
|
||||
static u_int32_t
|
||||
ip_finddst(const struct ip *ip)
|
||||
{
|
||||
int length;
|
||||
@ -129,6 +129,39 @@ ip_finddst(const struct ip *ip)
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*
|
||||
* Compute a V4-style checksum by building a pseudoheader.
|
||||
*/
|
||||
int
|
||||
nextproto4_cksum(const struct ip *ip, const u_int8_t *data,
|
||||
u_int len, u_int next_proto)
|
||||
{
|
||||
struct phdr {
|
||||
u_int32_t src;
|
||||
u_int32_t dst;
|
||||
u_char mbz;
|
||||
u_char proto;
|
||||
u_int16_t len;
|
||||
} ph;
|
||||
struct cksum_vec vec[2];
|
||||
|
||||
/* pseudo-header.. */
|
||||
ph.len = htons((u_int16_t)len);
|
||||
ph.mbz = 0;
|
||||
ph.proto = next_proto;
|
||||
memcpy(&ph.src, &ip->ip_src.s_addr, sizeof(u_int32_t));
|
||||
if (IP_HL(ip) == 5)
|
||||
memcpy(&ph.dst, &ip->ip_dst.s_addr, sizeof(u_int32_t));
|
||||
else
|
||||
ph.dst = ip_finddst(ip);
|
||||
|
||||
vec[0].ptr = (const u_int8_t *)(void *)&ph;
|
||||
vec[0].len = sizeof(ph);
|
||||
vec[1].ptr = data;
|
||||
vec[1].len = len;
|
||||
return (in_cksum(vec, 2));
|
||||
}
|
||||
|
||||
static void
|
||||
ip_printts(register const u_char *cp, u_int length)
|
||||
{
|
||||
@ -268,92 +301,6 @@ ip_optprint(register const u_char *cp, u_int length)
|
||||
printf("[|ip]");
|
||||
}
|
||||
|
||||
/*
|
||||
* compute an IP header checksum.
|
||||
* don't modifiy the packet.
|
||||
*/
|
||||
u_short
|
||||
in_cksum(const u_short *addr, register u_int len, int csum)
|
||||
{
|
||||
int nleft = len;
|
||||
const u_short *w = addr;
|
||||
u_short answer;
|
||||
int sum = csum;
|
||||
|
||||
/*
|
||||
* Our algorithm is simple, using a 32 bit accumulator (sum),
|
||||
* we add sequential 16 bit words to it, and at the end, fold
|
||||
* back all the carry bits from the top 16 bits into the lower
|
||||
* 16 bits.
|
||||
*/
|
||||
while (nleft > 1) {
|
||||
sum += *w++;
|
||||
nleft -= 2;
|
||||
}
|
||||
if (nleft == 1)
|
||||
sum += htons(*(u_char *)w<<8);
|
||||
|
||||
/*
|
||||
* add back carry outs from top 16 bits to low 16 bits
|
||||
*/
|
||||
sum = (sum >> 16) + (sum & 0xffff); /* add hi 16 to low 16 */
|
||||
sum += (sum >> 16); /* add carry */
|
||||
answer = ~sum; /* truncate to 16 bits */
|
||||
return (answer);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
u_int16_t
|
||||
in_cksum_shouldbe(u_int16_t sum, u_int16_t computed_sum)
|
||||
{
|
||||
u_int32_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;
|
||||
}
|
||||
|
||||
#define IP_RES 0x8000
|
||||
|
||||
static struct tok ip_frag_values[] = {
|
||||
@ -376,6 +323,7 @@ ip_print_demux(netdissect_options *ndo,
|
||||
struct ip_print_demux_state *ipds)
|
||||
{
|
||||
struct protoent *proto;
|
||||
struct cksum_vec vec[1];
|
||||
|
||||
again:
|
||||
switch (ipds->nh) {
|
||||
@ -480,7 +428,7 @@ ip_print_demux(netdissect_options *ndo,
|
||||
|
||||
case IPPROTO_IPV4:
|
||||
/* DVMRP multicast tunnel (ip-in-ip encapsulation) */
|
||||
ip_print(gndo, ipds->cp, ipds->len);
|
||||
ip_print(ndo, ipds->cp, ipds->len);
|
||||
if (! vflag) {
|
||||
ND_PRINT((ndo, " (ipip-proto-4)"));
|
||||
return;
|
||||
@ -490,7 +438,7 @@ ip_print_demux(netdissect_options *ndo,
|
||||
#ifdef INET6
|
||||
case IPPROTO_IPV6:
|
||||
/* ip6-in-ip encapsulation */
|
||||
ip6_print(ipds->cp, ipds->len);
|
||||
ip6_print(ndo, ipds->cp, ipds->len);
|
||||
break;
|
||||
#endif /*INET6*/
|
||||
|
||||
@ -508,12 +456,25 @@ ip_print_demux(netdissect_options *ndo,
|
||||
break;
|
||||
|
||||
case IPPROTO_PIM:
|
||||
pim_print(ipds->cp, ipds->len,
|
||||
in_cksum((const u_short*)ipds->cp, ipds->len, 0));
|
||||
vec[0].ptr = ipds->cp;
|
||||
vec[0].len = ipds->len;
|
||||
pim_print(ipds->cp, ipds->len, in_cksum(vec, 1));
|
||||
break;
|
||||
|
||||
case IPPROTO_VRRP:
|
||||
vrrp_print(ipds->cp, ipds->len, ipds->ip->ip_ttl);
|
||||
if (packettype == PT_CARP) {
|
||||
if (vflag)
|
||||
(void)printf("carp %s > %s: ",
|
||||
ipaddr_string(&ipds->ip->ip_src),
|
||||
ipaddr_string(&ipds->ip->ip_dst));
|
||||
carp_print(ipds->cp, ipds->len, ipds->ip->ip_ttl);
|
||||
} else {
|
||||
if (vflag)
|
||||
(void)printf("vrrp %s > %s: ",
|
||||
ipaddr_string(&ipds->ip->ip_src),
|
||||
ipaddr_string(&ipds->ip->ip_dst));
|
||||
vrrp_print(ipds->cp, ipds->len, ipds->ip->ip_ttl);
|
||||
}
|
||||
break;
|
||||
|
||||
case IPPROTO_PGM:
|
||||
@ -561,6 +522,7 @@ ip_print(netdissect_options *ndo,
|
||||
struct ip_print_demux_state *ipds=&ipd;
|
||||
const u_char *ipend;
|
||||
u_int hlen;
|
||||
struct cksum_vec vec[1];
|
||||
u_int16_t sum, ip_sum;
|
||||
struct protoent *proto;
|
||||
|
||||
@ -573,7 +535,7 @@ ip_print(netdissect_options *ndo,
|
||||
else if (!eflag)
|
||||
printf("IP ");
|
||||
|
||||
if ((u_char *)(ipds->ip + 1) > snapend) {
|
||||
if ((u_char *)(ipds->ip + 1) > ndo->ndo_snapend) {
|
||||
printf("[|ip]");
|
||||
return;
|
||||
}
|
||||
@ -611,8 +573,8 @@ ip_print(netdissect_options *ndo,
|
||||
* Cut off the snapshot length to the end of the IP payload.
|
||||
*/
|
||||
ipend = bp + ipds->len;
|
||||
if (ipend < snapend)
|
||||
snapend = ipend;
|
||||
if (ipend < ndo->ndo_snapend)
|
||||
ndo->ndo_snapend = ipend;
|
||||
|
||||
ipds->len -= hlen;
|
||||
|
||||
@ -658,8 +620,10 @@ ip_print(netdissect_options *ndo,
|
||||
printf(")");
|
||||
}
|
||||
|
||||
if (!Kflag && (u_char *)ipds->ip + hlen <= snapend) {
|
||||
sum = in_cksum((const u_short *)ipds->ip, hlen, 0);
|
||||
if (!Kflag && (u_char *)ipds->ip + hlen <= ndo->ndo_snapend) {
|
||||
vec[0].ptr = (const u_int8_t *)(void *)ipds->ip;
|
||||
vec[0].len = hlen;
|
||||
sum = in_cksum(vec, 1);
|
||||
if (sum != 0) {
|
||||
ip_sum = EXTRACT_16BITS(&ipds->ip->ip_sum);
|
||||
(void)printf(", bad cksum %x (->%x)!", ip_sum,
|
||||
@ -722,7 +686,7 @@ ipN_print(register const u_char *bp, register u_int length)
|
||||
return;
|
||||
#ifdef INET6
|
||||
case 6:
|
||||
ip6_print (bp, length);
|
||||
ip6_print (gndo, bp, length);
|
||||
return;
|
||||
#endif
|
||||
default:
|
||||
|
88
print-ip6.c
88
print-ip6.c
@ -48,32 +48,38 @@ static const char rcsid[] _U_ =
|
||||
* Compute a V6-style checksum by building a pseudoheader.
|
||||
*/
|
||||
int
|
||||
nextproto6_cksum(const struct ip6_hdr *ip6, const u_short *data,
|
||||
nextproto6_cksum(const struct ip6_hdr *ip6, const u_int8_t *data,
|
||||
u_int len, u_int next_proto)
|
||||
{
|
||||
size_t i;
|
||||
u_int32_t sum = 0;
|
||||
union ip6_pseudo_hdr phu;
|
||||
struct {
|
||||
struct in6_addr ph_src;
|
||||
struct in6_addr ph_dst;
|
||||
u_int32_t ph_len;
|
||||
u_int8_t ph_zero[3];
|
||||
u_int8_t ph_nxt;
|
||||
} ph;
|
||||
struct cksum_vec vec[2];
|
||||
|
||||
/* pseudo-header */
|
||||
memset(&phu, 0, sizeof(phu));
|
||||
phu.ph.ph_src = ip6->ip6_src;
|
||||
phu.ph.ph_dst = ip6->ip6_dst;
|
||||
phu.ph.ph_len = htonl(len);
|
||||
phu.ph.ph_nxt = next_proto;
|
||||
memset(&ph, 0, sizeof(ph));
|
||||
ph.ph_src = ip6->ip6_src;
|
||||
ph.ph_dst = ip6->ip6_dst;
|
||||
ph.ph_len = htonl(len);
|
||||
ph.ph_nxt = next_proto;
|
||||
|
||||
for (i = 0; i < sizeof(phu.pa) / sizeof(phu.pa[0]); i++) {
|
||||
sum += phu.pa[i];
|
||||
}
|
||||
vec[0].ptr = (const u_int8_t *)(void *)&ph;
|
||||
vec[0].len = sizeof(ph);
|
||||
vec[1].ptr = data;
|
||||
vec[1].len = len;
|
||||
|
||||
return in_cksum(data, len, sum);
|
||||
return in_cksum(vec, 2);
|
||||
}
|
||||
|
||||
/*
|
||||
* print an IP6 datagram.
|
||||
*/
|
||||
void
|
||||
ip6_print(register const u_char *bp, register u_int length)
|
||||
ip6_print(netdissect_options *ndo, const u_char *bp, u_int length)
|
||||
{
|
||||
register const struct ip6_hdr *ip6;
|
||||
register int advance;
|
||||
@ -89,62 +95,62 @@ ip6_print(register const u_char *bp, register u_int length)
|
||||
|
||||
TCHECK(*ip6);
|
||||
if (length < sizeof (struct ip6_hdr)) {
|
||||
(void)printf("truncated-ip6 %u", length);
|
||||
(void)ND_PRINT((ndo, "truncated-ip6 %u", length));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!eflag)
|
||||
printf("IP6 ");
|
||||
if (!ndo->ndo_eflag)
|
||||
ND_PRINT((ndo, "IP6 "));
|
||||
|
||||
payload_len = EXTRACT_16BITS(&ip6->ip6_plen);
|
||||
len = payload_len + sizeof(struct ip6_hdr);
|
||||
if (length < len)
|
||||
(void)printf("truncated-ip6 - %u bytes missing!",
|
||||
len - length);
|
||||
(void)ND_PRINT((ndo, "truncated-ip6 - %u bytes missing!",
|
||||
len - length));
|
||||
|
||||
if (vflag) {
|
||||
if (ndo->ndo_vflag) {
|
||||
flow = EXTRACT_32BITS(&ip6->ip6_flow);
|
||||
printf("(");
|
||||
ND_PRINT((ndo, "("));
|
||||
#if 0
|
||||
/* rfc1883 */
|
||||
if (flow & 0x0f000000)
|
||||
(void)printf("pri 0x%02x, ", (flow & 0x0f000000) >> 24);
|
||||
(void)ND_PRINT((ndo, "pri 0x%02x, ", (flow & 0x0f000000) >> 24));
|
||||
if (flow & 0x00ffffff)
|
||||
(void)printf("flowlabel 0x%06x, ", flow & 0x00ffffff);
|
||||
(void)ND_PRINT((ndo, "flowlabel 0x%06x, ", flow & 0x00ffffff));
|
||||
#else
|
||||
/* RFC 2460 */
|
||||
if (flow & 0x0ff00000)
|
||||
(void)printf("class 0x%02x, ", (flow & 0x0ff00000) >> 20);
|
||||
(void)ND_PRINT((ndo, "class 0x%02x, ", (flow & 0x0ff00000) >> 20));
|
||||
if (flow & 0x000fffff)
|
||||
(void)printf("flowlabel 0x%05x, ", flow & 0x000fffff);
|
||||
(void)ND_PRINT((ndo, "flowlabel 0x%05x, ", flow & 0x000fffff));
|
||||
#endif
|
||||
|
||||
(void)printf("hlim %u, next-header %s (%u) payload length: %u) ",
|
||||
(void)ND_PRINT((ndo, "hlim %u, next-header %s (%u) payload length: %u) ",
|
||||
ip6->ip6_hlim,
|
||||
tok2str(ipproto_values,"unknown",ip6->ip6_nxt),
|
||||
ip6->ip6_nxt,
|
||||
payload_len);
|
||||
payload_len));
|
||||
}
|
||||
|
||||
/*
|
||||
* Cut off the snapshot length to the end of the IP payload.
|
||||
*/
|
||||
ipend = bp + len;
|
||||
if (ipend < snapend)
|
||||
snapend = ipend;
|
||||
if (ipend < ndo->ndo_snapend)
|
||||
ndo->ndo_snapend = ipend;
|
||||
|
||||
cp = (const u_char *)ip6;
|
||||
advance = sizeof(struct ip6_hdr);
|
||||
nh = ip6->ip6_nxt;
|
||||
while (cp < snapend && advance > 0) {
|
||||
while (cp < ndo->ndo_snapend && advance > 0) {
|
||||
cp += advance;
|
||||
len -= advance;
|
||||
|
||||
if (cp == (const u_char *)(ip6 + 1) &&
|
||||
nh != IPPROTO_TCP && nh != IPPROTO_UDP &&
|
||||
nh != IPPROTO_DCCP && nh != IPPROTO_SCTP) {
|
||||
(void)printf("%s > %s: ", ip6addr_string(&ip6->ip6_src),
|
||||
ip6addr_string(&ip6->ip6_dst));
|
||||
(void)ND_PRINT((ndo, "%s > %s: ", ip6addr_string(&ip6->ip6_src),
|
||||
ip6addr_string(&ip6->ip6_dst)));
|
||||
}
|
||||
|
||||
switch (nh) {
|
||||
@ -158,7 +164,7 @@ ip6_print(register const u_char *bp, register u_int length)
|
||||
break;
|
||||
case IPPROTO_FRAGMENT:
|
||||
advance = frag6_print(cp, (const u_char *)ip6);
|
||||
if (snapend <= cp + advance)
|
||||
if (ndo->ndo_snapend <= cp + advance)
|
||||
return;
|
||||
nh = *cp;
|
||||
fragmented = 1;
|
||||
@ -196,7 +202,7 @@ ip6_print(register const u_char *bp, register u_int length)
|
||||
udp_print(cp, len, (const u_char *)ip6, fragmented);
|
||||
return;
|
||||
case IPPROTO_ICMPV6:
|
||||
icmp6_print(gndo, cp, len, (const u_char *)ip6, fragmented);
|
||||
icmp6_print(ndo, cp, len, (const u_char *)ip6, fragmented);
|
||||
return;
|
||||
case IPPROTO_AH:
|
||||
advance = ah_print(cp);
|
||||
@ -205,7 +211,7 @@ ip6_print(register const u_char *bp, register u_int length)
|
||||
case IPPROTO_ESP:
|
||||
{
|
||||
int enh, padlen;
|
||||
advance = esp_print(gndo, cp, len, (const u_char *)ip6, &enh, &padlen);
|
||||
advance = esp_print(ndo, cp, len, (const u_char *)ip6, &enh, &padlen);
|
||||
nh = enh & 0xff;
|
||||
len -= padlen;
|
||||
break;
|
||||
@ -219,7 +225,7 @@ ip6_print(register const u_char *bp, register u_int length)
|
||||
}
|
||||
|
||||
case IPPROTO_PIM:
|
||||
pim_print(cp, len, nextproto6_cksum(ip6, (u_short *)cp, len,
|
||||
pim_print(cp, len, nextproto6_cksum(ip6, cp, len,
|
||||
IPPROTO_PIM));
|
||||
return;
|
||||
|
||||
@ -228,11 +234,11 @@ ip6_print(register const u_char *bp, register u_int length)
|
||||
return;
|
||||
|
||||
case IPPROTO_IPV6:
|
||||
ip6_print(cp, len);
|
||||
ip6_print(ndo, cp, len);
|
||||
return;
|
||||
|
||||
case IPPROTO_IPV4:
|
||||
ip_print(gndo, cp, len);
|
||||
ip_print(ndo, cp, len);
|
||||
return;
|
||||
|
||||
case IPPROTO_PGM:
|
||||
@ -248,18 +254,18 @@ ip6_print(register const u_char *bp, register u_int length)
|
||||
return;
|
||||
|
||||
case IPPROTO_NONE:
|
||||
(void)printf("no next header");
|
||||
(void)ND_PRINT((ndo, "no next header"));
|
||||
return;
|
||||
|
||||
default:
|
||||
(void)printf("ip-proto-%d %d", nh, len);
|
||||
(void)ND_PRINT((ndo, "ip-proto-%d %d", nh, len));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
trunc:
|
||||
(void)printf("[|ip6]");
|
||||
(void)ND_PRINT((ndo, "[|ip6]"));
|
||||
}
|
||||
|
||||
#endif /* INET6 */
|
||||
|
@ -69,7 +69,7 @@ ipnet_print(struct netdissect_options *ndo, const u_char *p, u_int length, u_int
|
||||
|
||||
#ifdef INET6
|
||||
case IPH_AF_INET6:
|
||||
ip6_print(p, length);
|
||||
ip6_print(ndo, p, length);
|
||||
break;
|
||||
#endif /*INET6*/
|
||||
|
||||
|
@ -196,7 +196,7 @@ ipx_rip_print(const u_short *ipx, u_int length)
|
||||
(void)printf("ipx-rip-req");
|
||||
if (length > 0) {
|
||||
TCHECK(ipx[3]);
|
||||
(void)printf(" %u/%d.%d", EXTRACT_32BITS(&ipx[0]),
|
||||
(void)printf(" %08x/%d.%d", EXTRACT_32BITS(&ipx[0]),
|
||||
EXTRACT_16BITS(&ipx[2]), EXTRACT_16BITS(&ipx[3]));
|
||||
}
|
||||
break;
|
||||
@ -204,7 +204,7 @@ ipx_rip_print(const u_short *ipx, u_int length)
|
||||
(void)printf("ipx-rip-resp");
|
||||
for (i = 0; i < 50 && length > 0; i++) {
|
||||
TCHECK(ipx[3]);
|
||||
(void)printf(" %u/%d.%d", EXTRACT_32BITS(&ipx[0]),
|
||||
(void)printf(" %08x/%d.%d", EXTRACT_32BITS(&ipx[0]),
|
||||
EXTRACT_16BITS(&ipx[2]), EXTRACT_16BITS(&ipx[3]));
|
||||
|
||||
ipx += 4;
|
||||
|
@ -393,12 +393,14 @@ static struct tok isis_subtlv_link_attribute_values[] = {
|
||||
};
|
||||
|
||||
#define ISIS_SUBTLV_AUTH_SIMPLE 1
|
||||
#define ISIS_SUBTLV_AUTH_GENERIC 3 /* rfc 5310 */
|
||||
#define ISIS_SUBTLV_AUTH_MD5 54
|
||||
#define ISIS_SUBTLV_AUTH_MD5_LEN 16
|
||||
#define ISIS_SUBTLV_AUTH_PRIVATE 255
|
||||
|
||||
static struct tok isis_subtlv_auth_values[] = {
|
||||
{ ISIS_SUBTLV_AUTH_SIMPLE, "simple text password"},
|
||||
{ ISIS_SUBTLV_AUTH_GENERIC, "Generic Crypto key-id"},
|
||||
{ ISIS_SUBTLV_AUTH_MD5, "HMAC-MD5 password"},
|
||||
{ ISIS_SUBTLV_AUTH_PRIVATE, "Routing Domain private password"},
|
||||
{ 0, NULL }
|
||||
@ -439,8 +441,8 @@ static struct tok clnp_flag_values[] = {
|
||||
#define ISIS_MASK_MTFLAGS(x) ((x)&0xf000)
|
||||
|
||||
static struct tok isis_mt_flag_values[] = {
|
||||
{ 0x4000, "sub-TLVs present"},
|
||||
{ 0x8000, "ATT bit set"},
|
||||
{ 0x4000, "ATT bit set"},
|
||||
{ 0x8000, "Overload bit set"},
|
||||
{ 0, NULL}
|
||||
};
|
||||
|
||||
@ -616,10 +618,6 @@ struct isis_tlv_lsp {
|
||||
|
||||
void isoclns_print(const u_int8_t *p, u_int length, u_int caplen)
|
||||
{
|
||||
const struct isis_common_header *header;
|
||||
|
||||
header = (const struct isis_common_header *)p;
|
||||
|
||||
if (caplen <= 1) { /* enough bytes on the wire ? */
|
||||
printf("|OSI");
|
||||
return;
|
||||
@ -662,7 +660,7 @@ void isoclns_print(const u_int8_t *p, u_int length, u_int caplen)
|
||||
|
||||
#ifdef INET6
|
||||
case NLPID_IP6:
|
||||
ip6_print(p+1, length-1);
|
||||
ip6_print(gndo, p+1, length-1);
|
||||
break;
|
||||
#endif
|
||||
|
||||
@ -1177,15 +1175,15 @@ esis_print(const u_int8_t *pptr, u_int length)
|
||||
}
|
||||
|
||||
/* now walk the options */
|
||||
while (li >= 2) {
|
||||
while (li != 0) {
|
||||
u_int op, opli;
|
||||
const u_int8_t *tptr;
|
||||
|
||||
TCHECK2(*pptr, 2);
|
||||
if (li < 2) {
|
||||
printf(", bad opts/li");
|
||||
return;
|
||||
}
|
||||
TCHECK2(*pptr, 2);
|
||||
op = *pptr++;
|
||||
opli = *pptr++;
|
||||
li -= 2;
|
||||
@ -1204,8 +1202,11 @@ esis_print(const u_int8_t *pptr, u_int length)
|
||||
switch (op) {
|
||||
|
||||
case ESIS_OPTION_ES_CONF_TIME:
|
||||
TCHECK2(*pptr, 2);
|
||||
printf("%us", EXTRACT_16BITS(tptr));
|
||||
if (opli == 2) {
|
||||
TCHECK2(*pptr, 2);
|
||||
printf("%us", EXTRACT_16BITS(tptr));
|
||||
} else
|
||||
printf("(bad length)");
|
||||
break;
|
||||
|
||||
case ESIS_OPTION_PROTOCOLS:
|
||||
@ -1777,7 +1778,7 @@ static int isis_print (const u_int8_t *p, u_int length)
|
||||
u_int8_t pdu_type, max_area, id_length, tlv_type, tlv_len, tmp, alen, lan_alen, prefix_len;
|
||||
u_int8_t ext_is_len, ext_ip_len, mt_len;
|
||||
const u_int8_t *optr, *pptr, *tptr;
|
||||
u_short packet_len,pdu_len;
|
||||
u_short packet_len,pdu_len, key_id;
|
||||
u_int i,vendor_id;
|
||||
int sigcheck;
|
||||
|
||||
@ -2376,6 +2377,15 @@ static int isis_print (const u_int8_t *p, u_int length)
|
||||
printf(" (%s)", tok2str(signature_check_values, "Unknown", sigcheck));
|
||||
|
||||
break;
|
||||
case ISIS_SUBTLV_AUTH_GENERIC:
|
||||
key_id = EXTRACT_16BITS((tptr+1));
|
||||
printf("%u, password: ", key_id);
|
||||
for(i=1 + sizeof(u_int16_t);i<tlv_len;i++) {
|
||||
if (!TTEST2(*(tptr+i), 1))
|
||||
goto trunctlv;
|
||||
printf("%02x",*(tptr+i));
|
||||
}
|
||||
break;
|
||||
case ISIS_SUBTLV_AUTH_PRIVATE:
|
||||
default:
|
||||
if(!print_unknown_data(tptr+1,"\n\t\t ",tlv_len-1))
|
||||
|
@ -486,7 +486,7 @@ juniper_ggsn_print(const struct pcap_pkthdr *h, register const u_char *p)
|
||||
break;
|
||||
#ifdef INET6
|
||||
case JUNIPER_PROTO_IPV6:
|
||||
ip6_print(p, l2info.length);
|
||||
ip6_print(gndo, p, l2info.length);
|
||||
break;
|
||||
#endif /* INET6 */
|
||||
default:
|
||||
@ -647,7 +647,7 @@ juniper_pppoe_print(const struct pcap_pkthdr *h, register const u_char *p)
|
||||
|
||||
p+=l2info.header_len;
|
||||
/* this DLT contains nothing but raw ethernet frames */
|
||||
ether_print(p, l2info.length, l2info.caplen, NULL, NULL);
|
||||
ether_print(gndo, p, l2info.length, l2info.caplen, NULL, NULL);
|
||||
return l2info.header_len;
|
||||
}
|
||||
#endif
|
||||
@ -664,7 +664,7 @@ juniper_ether_print(const struct pcap_pkthdr *h, register const u_char *p)
|
||||
|
||||
p+=l2info.header_len;
|
||||
/* this DLT contains nothing but raw Ethernet frames */
|
||||
ether_print(p, l2info.length, l2info.caplen, NULL, NULL);
|
||||
ether_print(gndo, p, l2info.length, l2info.caplen, NULL, NULL);
|
||||
return l2info.header_len;
|
||||
}
|
||||
#endif
|
||||
@ -736,7 +736,7 @@ juniper_pppoe_atm_print(const struct pcap_pkthdr *h, register const u_char *p)
|
||||
extracted_ethertype = EXTRACT_16BITS(p);
|
||||
/* this DLT contains nothing but raw PPPoE frames,
|
||||
* prepended with a type field*/
|
||||
if (ethertype_print(extracted_ethertype,
|
||||
if (ethertype_print(gndo, extracted_ethertype,
|
||||
p+ETHERTYPE_LEN,
|
||||
l2info.length-ETHERTYPE_LEN,
|
||||
l2info.caplen-ETHERTYPE_LEN) == 0)
|
||||
@ -779,7 +779,7 @@ juniper_mlppp_print(const struct pcap_pkthdr *h, register const u_char *p)
|
||||
return l2info.header_len;
|
||||
#ifdef INET6
|
||||
case JUNIPER_LSQ_L3_PROTO_IPV6:
|
||||
ip6_print(p,l2info.length);
|
||||
ip6_print(gndo, p,l2info.length);
|
||||
return l2info.header_len;
|
||||
#endif
|
||||
case JUNIPER_LSQ_L3_PROTO_MPLS:
|
||||
@ -834,7 +834,7 @@ juniper_mfr_print(const struct pcap_pkthdr *h, register const u_char *p)
|
||||
return l2info.header_len;
|
||||
#ifdef INET6
|
||||
case JUNIPER_LSQ_L3_PROTO_IPV6:
|
||||
ip6_print(p,l2info.length);
|
||||
ip6_print(gndo, p,l2info.length);
|
||||
return l2info.header_len;
|
||||
#endif
|
||||
case JUNIPER_LSQ_L3_PROTO_MPLS:
|
||||
@ -987,7 +987,7 @@ juniper_atm2_print(const struct pcap_pkthdr *h, register const u_char *p)
|
||||
|
||||
if (l2info.direction != JUNIPER_BPF_PKT_IN && /* ether-over-1483 encaps ? */
|
||||
(EXTRACT_32BITS(l2info.cookie) & ATM2_GAP_COUNT_MASK)) {
|
||||
ether_print(p, l2info.length, l2info.caplen, NULL, NULL);
|
||||
ether_print(gndo, p, l2info.length, l2info.caplen, NULL, NULL);
|
||||
return l2info.header_len;
|
||||
}
|
||||
|
||||
@ -1073,7 +1073,7 @@ ip_heuristic_guess(register const u_char *p, u_int length) {
|
||||
case 0x6d:
|
||||
case 0x6e:
|
||||
case 0x6f:
|
||||
ip6_print(p, length);
|
||||
ip6_print(gndo, p, length);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
|
@ -61,9 +61,9 @@ static const struct tok lecop2str[] = {
|
||||
};
|
||||
|
||||
static void
|
||||
lane_hdr_print(const u_char *bp)
|
||||
lane_hdr_print(netdissect_options *ndo, const u_char *bp)
|
||||
{
|
||||
(void)printf("lecid:%x ", EXTRACT_16BITS(bp));
|
||||
(void)ND_PRINT((ndo, "lecid:%x ", EXTRACT_16BITS(bp)));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -106,7 +106,7 @@ lane_print(const u_char *p, u_int length, u_int caplen)
|
||||
* Now print the encapsulated frame, under the assumption
|
||||
* that it's an Ethernet frame.
|
||||
*/
|
||||
ether_print(p, length, caplen, lane_hdr_print, p - 2);
|
||||
ether_print(gndo, p, length, caplen, lane_hdr_print, p - 2);
|
||||
}
|
||||
|
||||
u_int
|
||||
|
@ -609,7 +609,7 @@ ldp_msg_print(register const u_char *pptr) {
|
||||
}
|
||||
/* do we want to see an additionally hexdump ? */
|
||||
if (vflag > 1 || hexdump==TRUE)
|
||||
print_unknown_data(tptr+sizeof(sizeof(struct ldp_msg_header)),"\n\t ",
|
||||
print_unknown_data(tptr+sizeof(struct ldp_msg_header),"\n\t ",
|
||||
msg_len);
|
||||
|
||||
tptr += msg_len+4;
|
||||
|
@ -417,7 +417,7 @@ snap_print(const u_char *p, u_int length, u_int caplen, u_int bridge_pad)
|
||||
* Cisco hardware; the protocol ID is
|
||||
* an Ethernet protocol type.
|
||||
*/
|
||||
ret = ethertype_print(et, p, length, caplen);
|
||||
ret = ethertype_print(gndo, et, p, length, caplen);
|
||||
if (ret)
|
||||
return (ret);
|
||||
break;
|
||||
@ -432,7 +432,7 @@ snap_print(const u_char *p, u_int length, u_int caplen, u_int bridge_pad)
|
||||
* but used 0x000000 and an Ethernet
|
||||
* packet type for AARP packets.
|
||||
*/
|
||||
ret = ethertype_print(et, p, length, caplen);
|
||||
ret = ethertype_print(gndo, et, p, length, caplen);
|
||||
if (ret)
|
||||
return (ret);
|
||||
}
|
||||
@ -479,7 +479,7 @@ snap_print(const u_char *p, u_int length, u_int caplen, u_int bridge_pad)
|
||||
/*
|
||||
* What remains is an Ethernet packet.
|
||||
*/
|
||||
ether_print(p, length, caplen, NULL, NULL);
|
||||
ether_print(gndo, p, length, caplen, NULL, NULL);
|
||||
return (1);
|
||||
|
||||
case PID_RFC2684_802_5_FCS:
|
||||
|
524
print-lldp.c
524
print-lldp.c
@ -12,10 +12,11 @@
|
||||
* LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* support for the IEEE Link Discovery Protocol as per 802.1ab
|
||||
* support for the IEEE Link Discovery Protocol as per 802.1AB
|
||||
*
|
||||
* Original code by Hannes Gredler (hannes@juniper.net)
|
||||
* IEEE and TIA extensions by Carles Kishimoto <carles.kishimoto@gmail.com>
|
||||
* DCBX extensions by Kaladhar Musunuru <kaladharm@sourceforge.net>
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -541,6 +542,23 @@ static const struct tok lldp_aggregation_values[] = {
|
||||
{ 0, NULL}
|
||||
};
|
||||
|
||||
/*
|
||||
* DCBX protocol subtypes.
|
||||
*/
|
||||
#define LLDP_DCBX_SUBTYPE_1 1
|
||||
#define LLDP_DCBX_SUBTYPE_2 2
|
||||
|
||||
static const struct tok lldp_dcbx_subtype_values[] = {
|
||||
{ LLDP_DCBX_SUBTYPE_1, "DCB Capability Exchange Protocol Rev 1" },
|
||||
{ LLDP_DCBX_SUBTYPE_2, "DCB Capability Exchange Protocol Rev 1.01" },
|
||||
{ 0, NULL}
|
||||
};
|
||||
|
||||
#define LLDP_DCBX_CONTROL_TLV 1
|
||||
#define LLDP_DCBX_PRIORITY_GROUPS_TLV 2
|
||||
#define LLDP_DCBX_PRIORITY_FLOW_CONTROL_TLV 3
|
||||
#define LLDP_DCBX_APPLICATION_TLV 4
|
||||
|
||||
/*
|
||||
* Interface numbering subtypes.
|
||||
*/
|
||||
@ -556,13 +574,17 @@ static const struct tok lldp_intf_numb_subtype_values[] = {
|
||||
#define LLDP_INTF_NUM_LEN 5
|
||||
|
||||
/*
|
||||
* Print IEEE private extensions. (802.1 annex F)
|
||||
* Print IEEE 802.1 private extensions. (802.1AB annex E)
|
||||
*/
|
||||
static int
|
||||
lldp_private_8021_print(const u_char *tptr)
|
||||
lldp_private_8021_print(const u_char *tptr, u_int tlv_len)
|
||||
{
|
||||
int subtype, hexdump = FALSE;
|
||||
u_int sublen;
|
||||
|
||||
if (tlv_len < 4) {
|
||||
return hexdump;
|
||||
}
|
||||
subtype = *(tptr+3);
|
||||
|
||||
printf("\n\t %s Subtype (%u)",
|
||||
@ -571,24 +593,47 @@ lldp_private_8021_print(const u_char *tptr)
|
||||
|
||||
switch (subtype) {
|
||||
case LLDP_PRIVATE_8021_SUBTYPE_PORT_VLAN_ID:
|
||||
if (tlv_len < 6) {
|
||||
return hexdump;
|
||||
}
|
||||
printf("\n\t port vlan id (PVID): %u",
|
||||
EXTRACT_16BITS(tptr+4));
|
||||
break;
|
||||
case LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_VLAN_ID:
|
||||
if (tlv_len < 7) {
|
||||
return hexdump;
|
||||
}
|
||||
printf("\n\t port and protocol vlan id (PPVID): %u, flags [%s] (0x%02x)",
|
||||
EXTRACT_16BITS(tptr+5),
|
||||
bittok2str(lldp_8021_port_protocol_id_values, "none", *(tptr+4)),
|
||||
*(tptr+4));
|
||||
break;
|
||||
case LLDP_PRIVATE_8021_SUBTYPE_VLAN_NAME:
|
||||
if (tlv_len < 6) {
|
||||
return hexdump;
|
||||
}
|
||||
printf("\n\t vlan id (VID): %u",
|
||||
EXTRACT_16BITS(tptr+4));
|
||||
if (tlv_len < 7) {
|
||||
return hexdump;
|
||||
}
|
||||
sublen = *(tptr+6);
|
||||
if (tlv_len < 7+sublen) {
|
||||
return hexdump;
|
||||
}
|
||||
printf("\n\t vlan name: ");
|
||||
safeputs((const char *)tptr+7, *(tptr+6));
|
||||
safeputs((const char *)tptr+7, sublen);
|
||||
break;
|
||||
case LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_IDENTITY:
|
||||
if (tlv_len < 5) {
|
||||
return hexdump;
|
||||
}
|
||||
sublen = *(tptr+4);
|
||||
if (tlv_len < 5+sublen) {
|
||||
return hexdump;
|
||||
}
|
||||
printf("\n\t protocol identity: ");
|
||||
safeputs((const char *)tptr+5, *(tptr+4));
|
||||
safeputs((const char *)tptr+5, sublen);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -600,13 +645,16 @@ lldp_private_8021_print(const u_char *tptr)
|
||||
}
|
||||
|
||||
/*
|
||||
* Print IEEE private extensions. (802.3)
|
||||
* Print IEEE 802.3 private extensions. (802.3bc)
|
||||
*/
|
||||
static int
|
||||
lldp_private_8023_print(const u_char *tptr)
|
||||
lldp_private_8023_print(const u_char *tptr, u_int tlv_len)
|
||||
{
|
||||
int subtype, hexdump = FALSE;
|
||||
|
||||
if (tlv_len < 4) {
|
||||
return hexdump;
|
||||
}
|
||||
subtype = *(tptr+3);
|
||||
|
||||
printf("\n\t %s Subtype (%u)",
|
||||
@ -615,6 +663,9 @@ lldp_private_8023_print(const u_char *tptr)
|
||||
|
||||
switch (subtype) {
|
||||
case LLDP_PRIVATE_8023_SUBTYPE_MACPHY:
|
||||
if (tlv_len < 9) {
|
||||
return hexdump;
|
||||
}
|
||||
printf("\n\t autonegotiation [%s] (0x%02x)",
|
||||
bittok2str(lldp_8023_autonegotiation_values, "none", *(tptr+4)),
|
||||
*(tptr+4));
|
||||
@ -627,6 +678,9 @@ lldp_private_8023_print(const u_char *tptr)
|
||||
break;
|
||||
|
||||
case LLDP_PRIVATE_8023_SUBTYPE_MDIPOWER:
|
||||
if (tlv_len < 7) {
|
||||
return hexdump;
|
||||
}
|
||||
printf("\n\t MDI power support [%s], power pair %s, power class %s",
|
||||
bittok2str(lldp_mdi_values, "none", *(tptr+4)),
|
||||
tok2str(lldp_mdi_power_pairs_values, "unknown", *(tptr+5)),
|
||||
@ -634,6 +688,9 @@ lldp_private_8023_print(const u_char *tptr)
|
||||
break;
|
||||
|
||||
case LLDP_PRIVATE_8023_SUBTYPE_LINKAGGR:
|
||||
if (tlv_len < 9) {
|
||||
return hexdump;
|
||||
}
|
||||
printf("\n\t aggregation status [%s], aggregation port ID %u",
|
||||
bittok2str(lldp_aggregation_values, "none", *(tptr+4)),
|
||||
EXTRACT_32BITS(tptr+5));
|
||||
@ -674,8 +731,12 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len)
|
||||
int subtype, hexdump = FALSE;
|
||||
u_int8_t location_format;
|
||||
u_int16_t power_val;
|
||||
u_int8_t lci_len, ca_type, ca_len;
|
||||
u_int lci_len;
|
||||
u_int8_t ca_type, ca_len;
|
||||
|
||||
if (tlv_len < 4) {
|
||||
return hexdump;
|
||||
}
|
||||
subtype = *(tptr+3);
|
||||
|
||||
printf("\n\t %s Subtype (%u)",
|
||||
@ -684,6 +745,9 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len)
|
||||
|
||||
switch (subtype) {
|
||||
case LLDP_PRIVATE_TIA_SUBTYPE_CAPABILITIES:
|
||||
if (tlv_len < 7) {
|
||||
return hexdump;
|
||||
}
|
||||
printf("\n\t Media capabilities [%s] (0x%04x)",
|
||||
bittok2str(lldp_tia_capabilities_values, "none",
|
||||
EXTRACT_16BITS(tptr+4)), EXTRACT_16BITS(tptr+4));
|
||||
@ -693,6 +757,9 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len)
|
||||
break;
|
||||
|
||||
case LLDP_PRIVATE_TIA_SUBTYPE_NETWORK_POLICY:
|
||||
if (tlv_len < 8) {
|
||||
return hexdump;
|
||||
}
|
||||
printf("\n\t Application type [%s] (0x%02x)",
|
||||
tok2str(lldp_tia_application_type_values, "none", *(tptr+4)),
|
||||
*(tptr+4));
|
||||
@ -707,6 +774,9 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len)
|
||||
break;
|
||||
|
||||
case LLDP_PRIVATE_TIA_SUBTYPE_LOCAL_ID:
|
||||
if (tlv_len < 5) {
|
||||
return hexdump;
|
||||
}
|
||||
location_format = *(tptr+4);
|
||||
printf("\n\t Location data format %s (0x%02x)",
|
||||
tok2str(lldp_tia_location_data_format_values, "unknown", location_format),
|
||||
@ -714,6 +784,9 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len)
|
||||
|
||||
switch (location_format) {
|
||||
case LLDP_TIA_LOCATION_DATA_FORMAT_COORDINATE_BASED:
|
||||
if (tlv_len < 21) {
|
||||
return hexdump;
|
||||
}
|
||||
printf("\n\t Latitude resolution %u, latitude value %" PRIu64,
|
||||
(*(tptr+5)>>2), lldp_extract_latlon(tptr+5));
|
||||
printf("\n\t Longitude resolution %u, longitude value %" PRIu64,
|
||||
@ -730,7 +803,16 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len)
|
||||
break;
|
||||
|
||||
case LLDP_TIA_LOCATION_DATA_FORMAT_CIVIC_ADDRESS:
|
||||
if (tlv_len < 6) {
|
||||
return hexdump;
|
||||
}
|
||||
lci_len = *(tptr+5);
|
||||
if (lci_len < 3) {
|
||||
return hexdump;
|
||||
}
|
||||
if (tlv_len < 7+lci_len) {
|
||||
return hexdump;
|
||||
}
|
||||
printf("\n\t LCI length %u, LCI what %s (0x%02x), Country-code ",
|
||||
lci_len,
|
||||
tok2str(lldp_tia_location_lci_what_values, "unknown", *(tptr+6)),
|
||||
@ -744,6 +826,9 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len)
|
||||
|
||||
/* Decode each civic address element */
|
||||
while (lci_len > 0) {
|
||||
if (lci_len < 2) {
|
||||
return hexdump;
|
||||
}
|
||||
ca_type = *(tptr);
|
||||
ca_len = *(tptr+1);
|
||||
|
||||
@ -758,6 +843,9 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len)
|
||||
if ( ca_type == 0 || ca_len == 0) {
|
||||
return hexdump;
|
||||
}
|
||||
if (lci_len < ca_len) {
|
||||
return hexdump;
|
||||
}
|
||||
|
||||
safeputs((const char *)tptr, ca_len);
|
||||
tptr += ca_len;
|
||||
@ -777,6 +865,9 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len)
|
||||
break;
|
||||
|
||||
case LLDP_PRIVATE_TIA_SUBTYPE_EXTENDED_POWER_MDI:
|
||||
if (tlv_len < 7) {
|
||||
return hexdump;
|
||||
}
|
||||
printf("\n\t Power type [%s]",
|
||||
(*(tptr+4)&0xC0>>6) ? "PD device" : "PSE device");
|
||||
printf(", Power source [%s]",
|
||||
@ -812,24 +903,196 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len)
|
||||
return hexdump;
|
||||
}
|
||||
|
||||
/*
|
||||
* Print DCBX Protocol fields (V 1.01).
|
||||
*/
|
||||
static int
|
||||
lldp_private_dcbx_print(const u_char *pptr, u_int len)
|
||||
{
|
||||
int subtype, hexdump = FALSE;
|
||||
u_int8_t tval;
|
||||
u_int16_t tlv;
|
||||
u_int32_t i, pgval, uval;
|
||||
u_int tlen, tlv_type, tlv_len;
|
||||
const u_char *tptr, *mptr;
|
||||
|
||||
if (len < 4) {
|
||||
return hexdump;
|
||||
}
|
||||
subtype = *(pptr+3);
|
||||
|
||||
printf("\n\t %s Subtype (%u)",
|
||||
tok2str(lldp_dcbx_subtype_values, "unknown", subtype),
|
||||
subtype);
|
||||
|
||||
/* by passing old version */
|
||||
if (subtype == LLDP_DCBX_SUBTYPE_1)
|
||||
return TRUE;
|
||||
|
||||
tptr = pptr + 4;
|
||||
tlen = len - 4;
|
||||
|
||||
while (tlen >= sizeof(tlv)) {
|
||||
|
||||
TCHECK2(*tptr, sizeof(tlv));
|
||||
|
||||
tlv = EXTRACT_16BITS(tptr);
|
||||
|
||||
tlv_type = LLDP_EXTRACT_TYPE(tlv);
|
||||
tlv_len = LLDP_EXTRACT_LEN(tlv);
|
||||
hexdump = FALSE;
|
||||
|
||||
tlen -= sizeof(tlv);
|
||||
tptr += sizeof(tlv);
|
||||
|
||||
/* loop check */
|
||||
if (!tlv_type || !tlv_len) {
|
||||
break;
|
||||
}
|
||||
|
||||
TCHECK2(*tptr, tlv_len);
|
||||
if (tlen < tlv_len) {
|
||||
goto trunc;
|
||||
}
|
||||
|
||||
/* decode every tlv */
|
||||
switch (tlv_type) {
|
||||
case LLDP_DCBX_CONTROL_TLV:
|
||||
if (tlv_len < 10) {
|
||||
goto trunc;
|
||||
}
|
||||
printf("\n\t Control - Protocol Control (type 0x%x, length %d)",
|
||||
LLDP_DCBX_CONTROL_TLV, tlv_len);
|
||||
printf("\n\t Oper_Version: %d", *tptr);
|
||||
printf("\n\t Max_Version: %d", *(tptr+1));
|
||||
printf("\n\t Sequence Number: %d", EXTRACT_32BITS(tptr+2));
|
||||
printf("\n\t Acknowledgement Number: %d",
|
||||
EXTRACT_32BITS(tptr+6));
|
||||
break;
|
||||
case LLDP_DCBX_PRIORITY_GROUPS_TLV:
|
||||
if (tlv_len < 17) {
|
||||
goto trunc;
|
||||
}
|
||||
printf("\n\t Feature - Priority Group (type 0x%x, length %d)",
|
||||
LLDP_DCBX_PRIORITY_GROUPS_TLV, tlv_len);
|
||||
printf("\n\t Oper_Version: %d", *tptr);
|
||||
printf("\n\t Max_Version: %d", *(tptr+1));
|
||||
printf("\n\t Info block(0x%02X): ", *(tptr+2));
|
||||
tval = *(tptr+2);
|
||||
printf("Enable bit: %d, Willing bit: %d, Error Bit: %d",
|
||||
(tval & 0x80) ? 1 : 0, (tval & 0x40) ? 1 : 0,
|
||||
(tval & 0x20) ? 1 : 0);
|
||||
printf("\n\t SubType: %d", *(tptr+3));
|
||||
printf("\n\t Priority Allocation");
|
||||
|
||||
pgval = EXTRACT_32BITS(tptr+4);
|
||||
for (i = 0; i <= 7; i++) {
|
||||
tval = *(tptr+4+(i/2));
|
||||
printf("\n\t PgId_%d: %d",
|
||||
i, (pgval >> (28-4*i)) & 0xF);
|
||||
}
|
||||
printf("\n\t Priority Group Allocation");
|
||||
for (i = 0; i <= 7; i++)
|
||||
printf("\n\t Pg percentage[%d]: %d", i, *(tptr+8+i));
|
||||
printf("\n\t NumTCsSupported: %d", *(tptr+8+8));
|
||||
break;
|
||||
case LLDP_DCBX_PRIORITY_FLOW_CONTROL_TLV:
|
||||
if (tlv_len < 6) {
|
||||
goto trunc;
|
||||
}
|
||||
printf("\n\t Feature - Priority Flow Control");
|
||||
printf(" (type 0x%x, length %d)",
|
||||
LLDP_DCBX_PRIORITY_FLOW_CONTROL_TLV, tlv_len);
|
||||
printf("\n\t Oper_Version: %d", *tptr);
|
||||
printf("\n\t Max_Version: %d", *(tptr+1));
|
||||
printf("\n\t Info block(0x%02X): ", *(tptr+2));
|
||||
tval = *(tptr+2);
|
||||
printf("Enable bit: %d, Willing bit: %d, Error Bit: %d",
|
||||
(tval & 0x80) ? 1 : 0, (tval & 0x40) ? 1 : 0,
|
||||
(tval & 0x20) ? 1 : 0);
|
||||
printf("\n\t SubType: %d", *(tptr+3));
|
||||
tval = *(tptr+4);
|
||||
printf("\n\t PFC Config (0x%02X)", *(tptr+4));
|
||||
for (i = 0; i <= 7; i++)
|
||||
printf("\n\t Priority Bit %d: %s",
|
||||
i, (tval & (1 << i)) ? "Enabled" : "Disabled");
|
||||
printf("\n\t NumTCPFCSupported: %d", *(tptr+5));
|
||||
break;
|
||||
case LLDP_DCBX_APPLICATION_TLV:
|
||||
if (tlv_len < 4) {
|
||||
goto trunc;
|
||||
}
|
||||
printf("\n\t Feature - Application (type 0x%x, length %d)",
|
||||
LLDP_DCBX_APPLICATION_TLV, tlv_len);
|
||||
printf("\n\t Oper_Version: %d", *tptr);
|
||||
printf("\n\t Max_Version: %d", *(tptr+1));
|
||||
printf("\n\t Info block(0x%02X): ", *(tptr+2));
|
||||
tval = *(tptr+2);
|
||||
printf("Enable bit: %d, Willing bit: %d, Error Bit: %d",
|
||||
(tval & 0x80) ? 1 : 0, (tval & 0x40) ? 1 : 0,
|
||||
(tval & 0x20) ? 1 : 0);
|
||||
printf("\n\t SubType: %d", *(tptr+3));
|
||||
tval = tlv_len - 4;
|
||||
mptr = tptr + 4;
|
||||
while (tval >= 6) {
|
||||
printf("\n\t Application Value");
|
||||
printf("\n\t Application Protocol ID: 0x%04x",
|
||||
EXTRACT_16BITS(mptr));
|
||||
uval = EXTRACT_24BITS(mptr+2);
|
||||
printf("\n\t SF (0x%x) Application Protocol ID is %s",
|
||||
(uval >> 22),
|
||||
(uval >> 22) ? "Socket Number" : "L2 EtherType");
|
||||
printf("\n\t OUI: 0x%06x", uval & 0x3fffff);
|
||||
printf("\n\t User Priority Map: 0x%02x", *(mptr+5));
|
||||
tval = tval - 6;
|
||||
mptr = mptr + 6;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
hexdump = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
/* do we also want to see a hex dump ? */
|
||||
if (vflag > 1 || (vflag && hexdump)) {
|
||||
print_unknown_data(tptr,"\n\t ", tlv_len);
|
||||
}
|
||||
|
||||
tlen -= tlv_len;
|
||||
tptr += tlv_len;
|
||||
}
|
||||
|
||||
trunc:
|
||||
return hexdump;
|
||||
}
|
||||
|
||||
static char *
|
||||
lldp_network_addr_print(const u_char *tptr) {
|
||||
lldp_network_addr_print(const u_char *tptr, u_int len) {
|
||||
|
||||
u_int8_t af;
|
||||
static char buf[BUFSIZE];
|
||||
const char * (*pfunc)(const u_char *);
|
||||
|
||||
if (len < 1)
|
||||
return NULL;
|
||||
len--;
|
||||
af = *tptr;
|
||||
switch (af) {
|
||||
case AFNUM_INET:
|
||||
if (len < 4)
|
||||
return NULL;
|
||||
pfunc = getname;
|
||||
break;
|
||||
#ifdef INET6
|
||||
case AFNUM_INET6:
|
||||
if (len < 16)
|
||||
return NULL;
|
||||
pfunc = getname6;
|
||||
break;
|
||||
#endif
|
||||
case AFNUM_802:
|
||||
if (len < 6)
|
||||
return NULL;
|
||||
pfunc = etheraddr_string;
|
||||
break;
|
||||
default:
|
||||
@ -854,10 +1117,14 @@ lldp_mgmt_addr_tlv_print(const u_char *pptr, u_int len) {
|
||||
u_int8_t mgmt_addr_len, intf_num_subtype, oid_len;
|
||||
const u_char *tptr;
|
||||
u_int tlen;
|
||||
char *mgmt_addr;
|
||||
|
||||
tlen = len;
|
||||
tptr = pptr;
|
||||
|
||||
if (tlen < 1) {
|
||||
return 0;
|
||||
}
|
||||
mgmt_addr_len = *tptr++;
|
||||
tlen--;
|
||||
|
||||
@ -865,9 +1132,12 @@ lldp_mgmt_addr_tlv_print(const u_char *pptr, u_int len) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
mgmt_addr = lldp_network_addr_print(tptr, mgmt_addr_len);
|
||||
if (mgmt_addr == NULL) {
|
||||
return 0;
|
||||
}
|
||||
printf("\n\t Management Address length %u, %s",
|
||||
mgmt_addr_len,
|
||||
lldp_network_addr_print(tptr));
|
||||
mgmt_addr_len, mgmt_addr);
|
||||
tptr += mgmt_addr_len;
|
||||
tlen -= mgmt_addr_len;
|
||||
|
||||
@ -890,6 +1160,9 @@ lldp_mgmt_addr_tlv_print(const u_char *pptr, u_int len) {
|
||||
if (tlen) {
|
||||
oid_len = *tptr;
|
||||
|
||||
if (tlen < oid_len) {
|
||||
return 0;
|
||||
}
|
||||
if (oid_len) {
|
||||
printf("\n\t OID length %u", oid_len);
|
||||
safeputs((const char *)tptr+1, oid_len);
|
||||
@ -906,6 +1179,7 @@ lldp_print(register const u_char *pptr, register u_int len) {
|
||||
u_int16_t tlv, cap, ena_cap;
|
||||
u_int oui, tlen, hexdump, tlv_type, tlv_len;
|
||||
const u_char *tptr;
|
||||
char *network_addr;
|
||||
|
||||
tptr = pptr;
|
||||
tlen = len;
|
||||
@ -939,16 +1213,111 @@ lldp_print(register const u_char *pptr, register u_int len) {
|
||||
}
|
||||
|
||||
TCHECK2(*tptr, tlv_len);
|
||||
if (tlen < tlv_len) {
|
||||
goto trunc;
|
||||
}
|
||||
|
||||
switch (tlv_type) {
|
||||
|
||||
case LLDP_CHASSIS_ID_TLV:
|
||||
if (vflag) {
|
||||
if (tlv_len < 2) {
|
||||
goto trunc;
|
||||
}
|
||||
subtype = *tptr;
|
||||
printf("\n\t Subtype %s (%u): ",
|
||||
tok2str(lldp_chassis_subtype_values, "Unknown", subtype),
|
||||
subtype);
|
||||
|
||||
switch (subtype) {
|
||||
case LLDP_CHASSIS_MAC_ADDR_SUBTYPE:
|
||||
if (tlv_len < 1+6) {
|
||||
goto trunc;
|
||||
}
|
||||
printf("%s", etheraddr_string(tptr+1));
|
||||
break;
|
||||
|
||||
case LLDP_CHASSIS_INTF_NAME_SUBTYPE: /* fall through */
|
||||
case LLDP_CHASSIS_LOCAL_SUBTYPE:
|
||||
case LLDP_CHASSIS_CHASSIS_COMP_SUBTYPE:
|
||||
case LLDP_CHASSIS_INTF_ALIAS_SUBTYPE:
|
||||
case LLDP_CHASSIS_PORT_COMP_SUBTYPE:
|
||||
safeputs((const char *)tptr+1, tlv_len-1);
|
||||
break;
|
||||
|
||||
case LLDP_CHASSIS_NETWORK_ADDR_SUBTYPE:
|
||||
network_addr = lldp_network_addr_print(tptr+1, tlv_len-1);
|
||||
if (network_addr == NULL) {
|
||||
goto trunc;
|
||||
}
|
||||
printf("%s", network_addr);
|
||||
break;
|
||||
|
||||
default:
|
||||
hexdump = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case LLDP_PORT_ID_TLV:
|
||||
if (vflag) {
|
||||
if (tlv_len < 2) {
|
||||
goto trunc;
|
||||
}
|
||||
subtype = *tptr;
|
||||
printf("\n\t Subtype %s (%u): ",
|
||||
tok2str(lldp_port_subtype_values, "Unknown", subtype),
|
||||
subtype);
|
||||
|
||||
switch (subtype) {
|
||||
case LLDP_PORT_MAC_ADDR_SUBTYPE:
|
||||
if (tlv_len < 1+6) {
|
||||
goto trunc;
|
||||
}
|
||||
printf("%s", etheraddr_string(tptr+1));
|
||||
break;
|
||||
|
||||
case LLDP_PORT_INTF_NAME_SUBTYPE: /* fall through */
|
||||
case LLDP_PORT_LOCAL_SUBTYPE:
|
||||
case LLDP_PORT_AGENT_CIRC_ID_SUBTYPE:
|
||||
case LLDP_PORT_INTF_ALIAS_SUBTYPE:
|
||||
case LLDP_PORT_PORT_COMP_SUBTYPE:
|
||||
safeputs((const char *)tptr+1, tlv_len-1);
|
||||
break;
|
||||
|
||||
case LLDP_PORT_NETWORK_ADDR_SUBTYPE:
|
||||
network_addr = lldp_network_addr_print(tptr+1, tlv_len-1);
|
||||
if (network_addr == NULL) {
|
||||
goto trunc;
|
||||
}
|
||||
printf("%s", network_addr);
|
||||
break;
|
||||
|
||||
default:
|
||||
hexdump = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case LLDP_TTL_TLV:
|
||||
if (vflag) {
|
||||
if (tlv_len < 2) {
|
||||
goto trunc;
|
||||
}
|
||||
printf(": TTL %us", EXTRACT_16BITS(tptr));
|
||||
}
|
||||
break;
|
||||
|
||||
case LLDP_SYSTEM_NAME_TLV:
|
||||
case LLDP_PORT_DESCR_TLV:
|
||||
if (vflag) {
|
||||
printf(": ");
|
||||
safeputs((const char *)tptr, tlv_len);
|
||||
}
|
||||
break;
|
||||
|
||||
case LLDP_SYSTEM_NAME_TLV:
|
||||
/*
|
||||
* The system name is also print in non-verbose mode
|
||||
* similar to the CDP printer.
|
||||
@ -963,13 +1332,6 @@ lldp_print(register const u_char *pptr, register u_int len) {
|
||||
}
|
||||
break;
|
||||
|
||||
case LLDP_PORT_DESCR_TLV:
|
||||
if (vflag) {
|
||||
printf(": ");
|
||||
safeputs((const char *)tptr, tlv_len);
|
||||
}
|
||||
break;
|
||||
|
||||
case LLDP_SYSTEM_DESCR_TLV:
|
||||
if (vflag) {
|
||||
printf("\n\t ");
|
||||
@ -977,93 +1339,17 @@ lldp_print(register const u_char *pptr, register u_int len) {
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case LLDP_CHASSIS_ID_TLV:
|
||||
if (vflag) {
|
||||
subtype = *tptr;
|
||||
printf("\n\t Subtype %s (%u): ",
|
||||
tok2str(lldp_chassis_subtype_values, "Unknown", subtype),
|
||||
subtype);
|
||||
|
||||
switch (subtype) {
|
||||
case LLDP_CHASSIS_MAC_ADDR_SUBTYPE:
|
||||
printf("%s", etheraddr_string(tptr+1));
|
||||
break;
|
||||
|
||||
case LLDP_CHASSIS_INTF_NAME_SUBTYPE: /* fall through */
|
||||
case LLDP_CHASSIS_LOCAL_SUBTYPE:
|
||||
case LLDP_CHASSIS_CHASSIS_COMP_SUBTYPE:
|
||||
case LLDP_CHASSIS_INTF_ALIAS_SUBTYPE:
|
||||
case LLDP_CHASSIS_PORT_COMP_SUBTYPE:
|
||||
safeputs((const char *)tptr+1, tlv_len-1);
|
||||
break;
|
||||
|
||||
case LLDP_CHASSIS_NETWORK_ADDR_SUBTYPE:
|
||||
printf("%s", lldp_network_addr_print(tptr+1));
|
||||
break;
|
||||
|
||||
default:
|
||||
hexdump = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case LLDP_PORT_ID_TLV:
|
||||
if (vflag) {
|
||||
subtype = *tptr;
|
||||
printf("\n\t Subtype %s (%u): ",
|
||||
tok2str(lldp_port_subtype_values, "Unknown", subtype),
|
||||
subtype);
|
||||
|
||||
switch (subtype) {
|
||||
case LLDP_PORT_MAC_ADDR_SUBTYPE:
|
||||
printf("%s", etheraddr_string(tptr+1));
|
||||
break;
|
||||
|
||||
case LLDP_PORT_INTF_NAME_SUBTYPE: /* fall through */
|
||||
case LLDP_PORT_LOCAL_SUBTYPE:
|
||||
case LLDP_PORT_AGENT_CIRC_ID_SUBTYPE:
|
||||
case LLDP_PORT_INTF_ALIAS_SUBTYPE:
|
||||
case LLDP_PORT_PORT_COMP_SUBTYPE:
|
||||
safeputs((const char *)tptr+1, tlv_len-1);
|
||||
break;
|
||||
|
||||
case LLDP_PORT_NETWORK_ADDR_SUBTYPE:
|
||||
printf("%s", lldp_network_addr_print(tptr+1));
|
||||
break;
|
||||
|
||||
default:
|
||||
hexdump = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case LLDP_PRIVATE_TLV:
|
||||
if (vflag) {
|
||||
oui = EXTRACT_24BITS(tptr);
|
||||
printf(": OUI %s (0x%06x)", tok2str(oui_values, "Unknown", oui), oui);
|
||||
|
||||
switch (oui) {
|
||||
case OUI_IEEE_8021_PRIVATE:
|
||||
hexdump = lldp_private_8021_print(tptr);
|
||||
break;
|
||||
case OUI_IEEE_8023_PRIVATE:
|
||||
hexdump = lldp_private_8023_print(tptr);
|
||||
break;
|
||||
case OUI_TIA:
|
||||
hexdump = lldp_private_tia_print(tptr, tlv_len);
|
||||
break;
|
||||
default:
|
||||
hexdump = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case LLDP_SYSTEM_CAP_TLV:
|
||||
if (vflag) {
|
||||
/*
|
||||
* XXX - IEEE Std 802.1AB-2009 says the first octet
|
||||
* if a chassis ID subtype, with the system
|
||||
* capabilities and enabled capabilities following
|
||||
* it.
|
||||
*/
|
||||
if (tlv_len < 4) {
|
||||
goto trunc;
|
||||
}
|
||||
cap = EXTRACT_16BITS(tptr);
|
||||
ena_cap = EXTRACT_16BITS(tptr+2);
|
||||
printf("\n\t System Capabilities [%s] (0x%04x)",
|
||||
@ -1075,12 +1361,40 @@ lldp_print(register const u_char *pptr, register u_int len) {
|
||||
|
||||
case LLDP_MGMT_ADDR_TLV:
|
||||
if (vflag) {
|
||||
if (!lldp_mgmt_addr_tlv_print(tptr, tlen)) {
|
||||
if (!lldp_mgmt_addr_tlv_print(tptr, tlv_len)) {
|
||||
goto trunc;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case LLDP_PRIVATE_TLV:
|
||||
if (vflag) {
|
||||
if (tlv_len < 3) {
|
||||
goto trunc;
|
||||
}
|
||||
oui = EXTRACT_24BITS(tptr);
|
||||
printf(": OUI %s (0x%06x)", tok2str(oui_values, "Unknown", oui), oui);
|
||||
|
||||
switch (oui) {
|
||||
case OUI_IEEE_8021_PRIVATE:
|
||||
hexdump = lldp_private_8021_print(tptr, tlv_len);
|
||||
break;
|
||||
case OUI_IEEE_8023_PRIVATE:
|
||||
hexdump = lldp_private_8023_print(tptr, tlv_len);
|
||||
break;
|
||||
case OUI_TIA:
|
||||
hexdump = lldp_private_tia_print(tptr, tlv_len);
|
||||
break;
|
||||
case OUI_DCBX:
|
||||
hexdump = lldp_private_dcbx_print(tptr, tlv_len);
|
||||
break;
|
||||
default:
|
||||
hexdump = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
hexdump = TRUE;
|
||||
break;
|
||||
|
@ -871,7 +871,7 @@ lmp_print(register const u_char *pptr, register u_int len) {
|
||||
}
|
||||
/* do we want to see an additionally hexdump ? */
|
||||
if (vflag > 1 || hexdump==TRUE)
|
||||
print_unknown_data(tptr+sizeof(sizeof(struct lmp_object_header)),"\n\t ",
|
||||
print_unknown_data(tptr+sizeof(struct lmp_object_header),"\n\t ",
|
||||
lmp_obj_len-sizeof(struct lmp_object_header));
|
||||
|
||||
tptr+=lmp_obj_len;
|
||||
|
@ -878,7 +878,7 @@ lspping_print(register const u_char *pptr, register u_int len) {
|
||||
}
|
||||
/* do we want to see an additionally tlv hexdump ? */
|
||||
if (vflag > 1 || tlv_hexdump==TRUE)
|
||||
print_unknown_data(tptr+sizeof(sizeof(struct lspping_tlv_header)),"\n\t ",
|
||||
print_unknown_data(tptr+sizeof(struct lspping_tlv_header),"\n\t ",
|
||||
lspping_tlv_len);
|
||||
|
||||
|
||||
|
@ -72,6 +72,7 @@ mobile_print(const u_char *bp, u_int length)
|
||||
{
|
||||
const u_char *cp = bp +8 ;
|
||||
const struct mobile_ip *mob;
|
||||
struct cksum_vec vec[1];
|
||||
u_short proto,crc;
|
||||
u_char osp =0; /* old source address present */
|
||||
|
||||
@ -101,7 +102,9 @@ mobile_print(const u_char *bp, u_int length)
|
||||
(void)printf("> %s ",ipaddr_string(&mob->odst));
|
||||
(void)printf("(oproto=%d)",proto>>8);
|
||||
}
|
||||
if (in_cksum((u_short *)mob, osp ? 12 : 8, 0)!=0) {
|
||||
vec[0].ptr = (const u_int8_t *)(void *)mob;
|
||||
vec[0].len = osp ? 12 : 8;
|
||||
if (in_cksum(vec, 1)!=0) {
|
||||
(void)printf(" (bad checksum %d)",crc);
|
||||
}
|
||||
|
||||
|
206
print-mpls.c
206
print-mpls.c
@ -54,6 +54,13 @@ static const char *mpls_labelname[] = {
|
||||
/*15*/ "rsvd",
|
||||
};
|
||||
|
||||
enum mpls_packet_type {
|
||||
PT_UNKNOWN,
|
||||
PT_IPV4,
|
||||
PT_IPV6,
|
||||
PT_OSI
|
||||
};
|
||||
|
||||
/*
|
||||
* RFC3032: MPLS label stack encoding
|
||||
*/
|
||||
@ -62,7 +69,8 @@ mpls_print(const u_char *bp, u_int length)
|
||||
{
|
||||
const u_char *p;
|
||||
u_int32_t label_entry;
|
||||
u_int16_t label_stack_depth = 0;
|
||||
u_int16_t label_stack_depth = 0;
|
||||
enum mpls_packet_type pt = PT_UNKNOWN;
|
||||
|
||||
p = bp;
|
||||
printf("MPLS");
|
||||
@ -70,9 +78,9 @@ mpls_print(const u_char *bp, u_int length)
|
||||
TCHECK2(*p, sizeof(label_entry));
|
||||
label_entry = EXTRACT_32BITS(p);
|
||||
printf("%s(label %u",
|
||||
label_stack_depth ? "\n\t" : " ",
|
||||
MPLS_LABEL(label_entry));
|
||||
label_stack_depth++;
|
||||
(label_stack_depth && vflag) ? "\n\t" : " ",
|
||||
MPLS_LABEL(label_entry));
|
||||
label_stack_depth++;
|
||||
if (vflag &&
|
||||
MPLS_LABEL(label_entry) < sizeof(mpls_labelname) / sizeof(mpls_labelname[0]))
|
||||
printf(" (%s)", mpls_labelname[MPLS_LABEL(label_entry)]);
|
||||
@ -84,98 +92,128 @@ mpls_print(const u_char *bp, u_int length)
|
||||
p += sizeof(label_entry);
|
||||
} while (!MPLS_STACK(label_entry));
|
||||
|
||||
/*
|
||||
* Try to figure out the packet type.
|
||||
*/
|
||||
switch (MPLS_LABEL(label_entry)) {
|
||||
|
||||
case 0: /* IPv4 explicit NULL label */
|
||||
case 3: /* IPv4 implicit NULL label */
|
||||
if (vflag>0) {
|
||||
printf("\n\t");
|
||||
ip_print(gndo, p, length - (p - bp));
|
||||
}
|
||||
else printf(", IP, length: %u",length);
|
||||
case 3: /* IPv4 implicit NULL label */
|
||||
pt = PT_IPV4;
|
||||
break;
|
||||
#ifdef INET6
|
||||
|
||||
case 2: /* IPv6 explicit NULL label */
|
||||
if (vflag>0) {
|
||||
printf("\n\t");
|
||||
ip6_print(p, length - (p - bp));
|
||||
}
|
||||
else printf(", IPv6, length: %u",length);
|
||||
pt = PT_IPV6;
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
/*
|
||||
* Generally there's no indication of protocol in MPLS label
|
||||
* encoding, however draft-hsmit-isis-aal5mux-00.txt describes
|
||||
* a technique that looks at the first payload byte if the BOS (bottom of stack)
|
||||
* bit is set and tries to determine the network layer protocol
|
||||
* 0x45-0x4f is IPv4
|
||||
* 0x60-0x6f is IPv6
|
||||
* 0x81-0x83 is OSI (CLNP,ES-IS,IS-IS)
|
||||
* this technique is sometimes known as NULL encapsulation
|
||||
* and decoding is particularly useful for control-plane traffic [BGP]
|
||||
* which cisco by default sends MPLS encapsulated
|
||||
* encoding.
|
||||
*
|
||||
* However, draft-hsmit-isis-aal5mux-00.txt describes a
|
||||
* technique for encapsulating IS-IS and IP traffic on the
|
||||
* same ATM virtual circuit; you look at the first payload
|
||||
* byte to determine the network layer protocol, based on
|
||||
* the fact that
|
||||
*
|
||||
* 1) the first byte of an IP header is 0x45-0x4f
|
||||
* for IPv4 and 0x60-0x6f for IPv6;
|
||||
*
|
||||
* 2) the first byte of an OSI CLNP packet is 0x81,
|
||||
* the first byte of an OSI ES-IS packet is 0x82,
|
||||
* and the first byte of an OSI IS-IS packet is
|
||||
* 0x83;
|
||||
*
|
||||
* so the network layer protocol can be inferred from the
|
||||
* first byte of the packet, if the protocol is one of the
|
||||
* ones listed above.
|
||||
*
|
||||
* Cisco sends control-plane traffic MPLS-encapsulated in
|
||||
* this fashion.
|
||||
*/
|
||||
switch(*p) {
|
||||
|
||||
if (MPLS_STACK(label_entry)) { /* only do this if the stack bit is set */
|
||||
switch(*p) {
|
||||
case 0x45:
|
||||
case 0x46:
|
||||
case 0x47:
|
||||
case 0x48:
|
||||
case 0x49:
|
||||
case 0x4a:
|
||||
case 0x4b:
|
||||
case 0x4c:
|
||||
case 0x4d:
|
||||
case 0x4e:
|
||||
case 0x4f:
|
||||
if (vflag>0) {
|
||||
printf("\n\t");
|
||||
ip_print(gndo, p, length - (p - bp));
|
||||
}
|
||||
else printf(", IP, length: %u",length);
|
||||
break;
|
||||
#ifdef INET6
|
||||
case 0x60:
|
||||
case 0x61:
|
||||
case 0x62:
|
||||
case 0x63:
|
||||
case 0x64:
|
||||
case 0x65:
|
||||
case 0x66:
|
||||
case 0x67:
|
||||
case 0x68:
|
||||
case 0x69:
|
||||
case 0x6a:
|
||||
case 0x6b:
|
||||
case 0x6c:
|
||||
case 0x6d:
|
||||
case 0x6e:
|
||||
case 0x6f:
|
||||
if (vflag>0) {
|
||||
printf("\n\t");
|
||||
ip6_print(p, length - (p - bp));
|
||||
}
|
||||
else printf(", IPv6, length: %u",length);
|
||||
break;
|
||||
#endif
|
||||
case 0x81:
|
||||
case 0x82:
|
||||
case 0x83:
|
||||
if (vflag>0) {
|
||||
printf("\n\t");
|
||||
isoclns_print(p, length - (p - bp), length - (p - bp));
|
||||
}
|
||||
else printf(", OSI, length: %u",length);
|
||||
break;
|
||||
default:
|
||||
/* ok bail out - we did not figure out what it is*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
case 0x45:
|
||||
case 0x46:
|
||||
case 0x47:
|
||||
case 0x48:
|
||||
case 0x49:
|
||||
case 0x4a:
|
||||
case 0x4b:
|
||||
case 0x4c:
|
||||
case 0x4d:
|
||||
case 0x4e:
|
||||
case 0x4f:
|
||||
pt = PT_IPV4;
|
||||
break;
|
||||
|
||||
case 0x60:
|
||||
case 0x61:
|
||||
case 0x62:
|
||||
case 0x63:
|
||||
case 0x64:
|
||||
case 0x65:
|
||||
case 0x66:
|
||||
case 0x67:
|
||||
case 0x68:
|
||||
case 0x69:
|
||||
case 0x6a:
|
||||
case 0x6b:
|
||||
case 0x6c:
|
||||
case 0x6d:
|
||||
case 0x6e:
|
||||
case 0x6f:
|
||||
pt = PT_IPV6;
|
||||
break;
|
||||
|
||||
case 0x81:
|
||||
case 0x82:
|
||||
case 0x83:
|
||||
pt = PT_OSI;
|
||||
break;
|
||||
|
||||
default:
|
||||
/* ok bail out - we did not figure out what it is*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Print the payload.
|
||||
*/
|
||||
if (pt == PT_UNKNOWN) {
|
||||
if (!suppress_default_print)
|
||||
default_print(p, length - (p - bp));
|
||||
return;
|
||||
}
|
||||
if (vflag)
|
||||
printf("\n\t");
|
||||
else
|
||||
printf(" ");
|
||||
switch (pt) {
|
||||
|
||||
case PT_IPV4:
|
||||
ip_print(gndo, p, length - (p - bp));
|
||||
break;
|
||||
|
||||
case PT_IPV6:
|
||||
#ifdef INET6
|
||||
ip6_print(gndo, p, length - (p - bp));
|
||||
#else
|
||||
printf("IPv6, length: %u", length);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case PT_OSI:
|
||||
isoclns_print(p, length - (p - bp), length - (p - bp));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return;
|
||||
|
||||
trunc:
|
||||
printf("[|MPLS]");
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ null_if_print(const struct pcap_pkthdr *h, const u_char *p)
|
||||
case BSD_AFNUM_INET6_BSD:
|
||||
case BSD_AFNUM_INET6_FREEBSD:
|
||||
case BSD_AFNUM_INET6_DARWIN:
|
||||
ip6_print(p, length);
|
||||
ip6_print(gndo, p, length);
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
@ -197,7 +197,7 @@ static int ospf_decode_v2(const struct ospfhdr *, const u_char *);
|
||||
static int ospf_decode_lls(const struct ospfhdr *, register u_int);
|
||||
|
||||
int
|
||||
ospf_print_grace_lsa (u_int8_t *tptr, u_int ls_length) {
|
||||
ospf_print_grace_lsa (const u_int8_t *tptr, u_int ls_length) {
|
||||
|
||||
u_int tlv_type, tlv_length;
|
||||
|
||||
@ -279,7 +279,7 @@ ospf_print_grace_lsa (u_int8_t *tptr, u_int ls_length) {
|
||||
}
|
||||
|
||||
int
|
||||
ospf_print_te_lsa (u_int8_t *tptr, u_int ls_length) {
|
||||
ospf_print_te_lsa (const u_int8_t *tptr, u_int ls_length) {
|
||||
|
||||
u_int tlv_type, tlv_length, subtlv_type, subtlv_length;
|
||||
u_int priority_level, te_class, count_srlg;
|
||||
@ -1028,7 +1028,7 @@ ospf_decode_v2(register const struct ospfhdr *op,
|
||||
lsap = op->ospf_lsu.lsu_lsa;
|
||||
TCHECK(op->ospf_lsu.lsu_count);
|
||||
lsa_count_max = EXTRACT_32BITS(&op->ospf_lsu.lsu_count);
|
||||
printf(", %d LSA%s",lsa_count_max, lsa_count_max > 1 ? "s" : "");
|
||||
printf(", %d LSA%s",lsa_count_max, PLURAL_SUFFIX(lsa_count_max));
|
||||
for (lsa_count=1;lsa_count <= lsa_count_max;lsa_count++) {
|
||||
printf("\n\t LSA #%u",lsa_count);
|
||||
lsap = (const struct lsa *)ospf_print_lsa(lsap);
|
||||
|
@ -162,7 +162,7 @@ pflog_if_print(const struct pcap_pkthdr *h, register const u_char *p)
|
||||
#if OPENBSD_AF_INET6 != AF_INET6
|
||||
case OPENBSD_AF_INET6: /* XXX: read pcap files */
|
||||
#endif
|
||||
ip6_print(p, length);
|
||||
ip6_print(gndo, p, length);
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
88
print-pgm.c
88
print-pgm.c
@ -72,6 +72,12 @@ struct pgm_nak {
|
||||
/* ... options */
|
||||
};
|
||||
|
||||
struct pgm_ack {
|
||||
u_int32_t pgma_rx_max_seq;
|
||||
u_int32_t pgma_bitmap;
|
||||
/* ... options */
|
||||
};
|
||||
|
||||
struct pgm_poll {
|
||||
u_int32_t pgmp_seq;
|
||||
u_int16_t pgmp_round;
|
||||
@ -133,6 +139,9 @@ typedef enum _pgm_type {
|
||||
#define PGM_OPT_RST 0x0F
|
||||
#define PGM_OPT_CR 0x10
|
||||
#define PGM_OPT_CRQST 0x11
|
||||
|
||||
#define PGM_OPT_PGMCC_DATA 0x12
|
||||
#define PGM_OPT_PGMCC_FEEDBACK 0x13
|
||||
|
||||
#define PGM_OPT_MASK 0x7f
|
||||
|
||||
@ -446,6 +455,17 @@ pgm_print(register const u_char *bp, register u_int length,
|
||||
break;
|
||||
}
|
||||
|
||||
case PGM_ACK: {
|
||||
struct pgm_ack *ack;
|
||||
|
||||
ack = (struct pgm_ack *)(pgm + 1);
|
||||
TCHECK(*ack);
|
||||
(void)printf("ACK seq %u",
|
||||
EXTRACT_32BITS(&ack->pgma_rx_max_seq));
|
||||
bp = (u_char *) (ack + 1);
|
||||
break;
|
||||
}
|
||||
|
||||
case PGM_SPMR:
|
||||
(void)printf("SPMR");
|
||||
break;
|
||||
@ -736,6 +756,74 @@ pgm_print(register const u_char *bp, register u_int length,
|
||||
opts_len -= 4;
|
||||
break;
|
||||
|
||||
case PGM_OPT_PGMCC_DATA:
|
||||
flags1 = *bp++;
|
||||
flags2 = *bp++;
|
||||
offset = EXTRACT_32BITS(bp);
|
||||
bp += sizeof(u_int32_t);
|
||||
switch (EXTRACT_16BITS(bp)) {
|
||||
case AFI_IP:
|
||||
addr_size = sizeof(struct in_addr);
|
||||
nla_af = AF_INET;
|
||||
break;
|
||||
#ifdef INET6
|
||||
case AFI_IP6:
|
||||
addr_size = sizeof(struct in6_addr);
|
||||
nla_af = AF_INET6;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
goto trunc;
|
||||
break;
|
||||
}
|
||||
bp += (2 * sizeof(u_int16_t));
|
||||
if (opt_len != 12 + addr_size) {
|
||||
(void)printf("[Bad OPT_PGMCC_DATA option, length %u != 12 + address size]", opt_len);
|
||||
return;
|
||||
}
|
||||
TCHECK2(*bp, addr_size);
|
||||
nla = bp;
|
||||
bp += addr_size;
|
||||
|
||||
inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
|
||||
(void)printf(" PGMCC DATA %u %s", offset, (char*)nla);
|
||||
opts_len -= 16;
|
||||
break;
|
||||
|
||||
case PGM_OPT_PGMCC_FEEDBACK:
|
||||
flags1 = *bp++;
|
||||
flags2 = *bp++;
|
||||
offset = EXTRACT_32BITS(bp);
|
||||
bp += sizeof(u_int32_t);
|
||||
switch (EXTRACT_16BITS(bp)) {
|
||||
case AFI_IP:
|
||||
addr_size = sizeof(struct in_addr);
|
||||
nla_af = AF_INET;
|
||||
break;
|
||||
#ifdef INET6
|
||||
case AFI_IP6:
|
||||
addr_size = sizeof(struct in6_addr);
|
||||
nla_af = AF_INET6;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
goto trunc;
|
||||
break;
|
||||
}
|
||||
bp += (2 * sizeof(u_int16_t));
|
||||
if (opt_len != 12 + addr_size) {
|
||||
(void)printf("[Bad OPT_PGMCC_FEEDBACK option, length %u != 12 + address size]", opt_len);
|
||||
return;
|
||||
}
|
||||
TCHECK2(*bp, addr_size);
|
||||
nla = bp;
|
||||
bp += addr_size;
|
||||
|
||||
inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
|
||||
(void)printf(" PGMCC FEEDBACK %u %s", offset, (char*)nla);
|
||||
opts_len -= 16;
|
||||
break;
|
||||
|
||||
default:
|
||||
(void)printf(" OPT_%02X [%d] ", opt_type, opt_len);
|
||||
bp += opt_len;
|
||||
|
28
print-pim.c
28
print-pim.c
@ -29,7 +29,15 @@ static const char rcsid[] _U_ =
|
||||
#endif
|
||||
|
||||
#include <tcpdump-stdinc.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "interface.h"
|
||||
#include "addrtoname.h"
|
||||
#include "extract.h"
|
||||
|
||||
#include "ip.h"
|
||||
|
||||
#define PIMV2_TYPE_HELLO 0
|
||||
#define PIMV2_TYPE_REGISTER 1
|
||||
@ -108,16 +116,6 @@ struct pim {
|
||||
u_short pim_cksum; /* IP style check sum */
|
||||
};
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "interface.h"
|
||||
#include "addrtoname.h"
|
||||
#include "extract.h"
|
||||
|
||||
#include "ip.h"
|
||||
|
||||
static void pimv2_print(register const u_char *bp, register u_int len, u_int cksum);
|
||||
|
||||
static void
|
||||
@ -399,8 +397,12 @@ cisco_autorp_print(register const u_char *bp, register u_int len)
|
||||
TCHECK2(bp[0], 6);
|
||||
(void)printf("%c%s%s/%d", s, bp[0] & 1 ? "!" : "",
|
||||
ipaddr_string(&bp[2]), bp[1]);
|
||||
if (bp[0] & 0xfe)
|
||||
(void)printf("[rsvd=0x%02x]", bp[0] & 0xfe);
|
||||
if (bp[0] & 0x02) {
|
||||
(void)printf(" bidir");
|
||||
}
|
||||
if (bp[0] & 0xfc) {
|
||||
(void)printf("[rsvd=0x%02x]", bp[0] & 0xfc);
|
||||
}
|
||||
s = ',';
|
||||
bp += 6; len -= 6;
|
||||
}
|
||||
@ -768,7 +770,7 @@ pimv2_print(register const u_char *bp, register u_int len, u_int cksum)
|
||||
break;
|
||||
#ifdef INET6
|
||||
case 6: /* IPv6 */
|
||||
ip6_print(bp, len);
|
||||
ip6_print(gndo, bp, len);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
|
104
print-ppi.c
Normal file
104
print-ppi.c
Normal file
@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Oracle
|
||||
*/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <tcpdump-stdinc.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <pcap.h>
|
||||
|
||||
#include "netdissect.h"
|
||||
#include "interface.h"
|
||||
#include "extract.h"
|
||||
#include "ppi.h"
|
||||
|
||||
#ifdef DLT_PPI
|
||||
|
||||
static inline void
|
||||
ppi_header_print(struct netdissect_options *ndo, const u_char *bp, u_int length)
|
||||
{
|
||||
const ppi_header_t *hdr;
|
||||
u_int32_t dlt;
|
||||
u_int16_t len;
|
||||
|
||||
hdr = (const ppi_header_t *)bp;
|
||||
|
||||
len = EXTRACT_16BITS(&hdr->ppi_len);
|
||||
dlt = EXTRACT_32BITS(&hdr->ppi_dlt);
|
||||
|
||||
if (!ndo->ndo_qflag) {
|
||||
ND_PRINT((ndo,", V.%d DLT %s (%d) len %d", hdr->ppi_ver,
|
||||
pcap_datalink_val_to_name(dlt), dlt,
|
||||
len));
|
||||
} else {
|
||||
ND_PRINT((ndo,", %s", pcap_datalink_val_to_name(dlt)));
|
||||
}
|
||||
|
||||
ND_PRINT((ndo, ", length %u: ", length));
|
||||
}
|
||||
|
||||
static void
|
||||
ppi_print(struct netdissect_options *ndo,
|
||||
const struct pcap_pkthdr *h, const u_char *p)
|
||||
{
|
||||
if_ndo_printer ndo_printer;
|
||||
if_printer printer;
|
||||
ppi_header_t *hdr;
|
||||
u_int caplen = h->caplen;
|
||||
u_int length = h->len;
|
||||
u_int32_t dlt;
|
||||
|
||||
if (caplen < sizeof(ppi_header_t)) {
|
||||
ND_PRINT((ndo, "[|ppi]"));
|
||||
return;
|
||||
}
|
||||
hdr = (ppi_header_t *)p;
|
||||
dlt = EXTRACT_32BITS(&hdr->ppi_dlt);
|
||||
|
||||
if (ndo->ndo_eflag)
|
||||
ppi_header_print(ndo, p, length);
|
||||
|
||||
length -= sizeof(ppi_header_t);
|
||||
caplen -= sizeof(ppi_header_t);
|
||||
p += sizeof(ppi_header_t);
|
||||
|
||||
if ((printer = lookup_printer(dlt)) != NULL) {
|
||||
printer(h, p);
|
||||
} else if ((ndo_printer = lookup_ndo_printer(dlt)) != NULL) {
|
||||
ndo_printer(ndo, h, p);
|
||||
} else {
|
||||
if (!ndo->ndo_eflag)
|
||||
ppi_header_print(ndo, (u_char *)hdr,
|
||||
length + sizeof(ppi_header_t));
|
||||
|
||||
if (!ndo->ndo_suppress_default_print)
|
||||
ndo->ndo_default_print(ndo, p, caplen);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
ppi_if_print(struct netdissect_options *ndo,
|
||||
const struct pcap_pkthdr *h, const u_char *p)
|
||||
{
|
||||
ppi_print(ndo, h, p);
|
||||
|
||||
return (sizeof(ppi_header_t));
|
||||
}
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* c-style: whitesmith
|
||||
* c-basic-offset: 8
|
||||
* End:
|
||||
*/
|
||||
|
||||
#endif /* DLT_PPI */
|
20
print-ppp.c
20
print-ppp.c
@ -1303,11 +1303,11 @@ ppp_hdlc(const u_char *p, int length)
|
||||
goto cleanup;
|
||||
#ifdef INET6
|
||||
case PPP_IPV6:
|
||||
ip6_print(b+1, t - b - 1);
|
||||
goto cleanup;
|
||||
ip6_print(gndo, b+1, t - b - 1);
|
||||
goto cleanup;
|
||||
#endif
|
||||
default: /* no luck - try next guess */
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
proto = EXTRACT_16BITS(b); /* next guess - load two octets */
|
||||
@ -1368,7 +1368,7 @@ handle_ppp(u_int proto, const u_char *p, int length)
|
||||
#ifdef INET6
|
||||
case ETHERTYPE_IPV6: /*XXX*/
|
||||
case PPP_IPV6:
|
||||
ip6_print(p, length);
|
||||
ip6_print(gndo, p, length);
|
||||
break;
|
||||
#endif
|
||||
case ETHERTYPE_IPX: /*XXX*/
|
||||
@ -1675,11 +1675,11 @@ ppp_bsdos_if_print(const struct pcap_pkthdr *h _U_, register const u_char *p _U_
|
||||
p += hdrlength;
|
||||
switch (ptype) {
|
||||
case PPP_IP:
|
||||
ip_print(p, length);
|
||||
ip_print(gndo, p, length);
|
||||
break;
|
||||
#ifdef INET6
|
||||
case PPP_IPV6:
|
||||
ip6_print(p, length);
|
||||
ip6_print(gndo, p, length);
|
||||
break;
|
||||
#endif
|
||||
case PPP_MPLS_UCAST:
|
||||
@ -1694,11 +1694,11 @@ ppp_bsdos_if_print(const struct pcap_pkthdr *h _U_, register const u_char *p _U_
|
||||
p += hdrlength;
|
||||
switch (ptype) {
|
||||
case PPP_IP:
|
||||
ip_print(p, length);
|
||||
ip_print(gndo, p, length);
|
||||
break;
|
||||
#ifdef INET6
|
||||
case PPP_IPV6:
|
||||
ip6_print(p, length);
|
||||
ip6_print(gndo, p, length);
|
||||
break;
|
||||
#endif
|
||||
case PPP_MPLS_UCAST:
|
||||
@ -1730,12 +1730,12 @@ ppp_bsdos_if_print(const struct pcap_pkthdr *h _U_, register const u_char *p _U_
|
||||
break;
|
||||
#ifdef INET6
|
||||
case PPP_IPV6:
|
||||
ip6_print(p, length);
|
||||
ip6_print(gndo, p, length);
|
||||
break;
|
||||
#endif
|
||||
case PPP_MPLS_UCAST:
|
||||
case PPP_MPLS_MCAST:
|
||||
mpls_print(p, length);
|
||||
mpls_print(gndo, p, length);
|
||||
break;
|
||||
default:
|
||||
printf("%s ", tok2str(ppptype2str, "unknown PPP protocol (0x%04x)", ptype));
|
||||
|
368
print-rpki-rtr.c
Normal file
368
print-rpki-rtr.c
Normal file
@ -0,0 +1,368 @@
|
||||
/*
|
||||
* Copyright (c) 1998-2011 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.
|
||||
*
|
||||
* support for the The RPKI/Router Protocol Protocol as per draft-ietf-sidr-rpki-rtr-12
|
||||
*
|
||||
* Original code by Hannes Gredler (hannes@juniper.net)
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-rpki_rtr.c,v 1.10 2008-03-20 09:30:56 hannes Exp $";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <tcpdump-stdinc.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "interface.h"
|
||||
#include "extract.h"
|
||||
#include "addrtoname.h"
|
||||
|
||||
/*
|
||||
* RPKI/Router PDU header
|
||||
*
|
||||
* Here's what the PDU header looks like.
|
||||
* The length does include the version and length fields.
|
||||
*/
|
||||
typedef struct rpki_rtr_pdu_ {
|
||||
u_char version; /* Version number */
|
||||
u_char pdu_type; /* PDU type */
|
||||
union {
|
||||
u_char cache_nonce[2]; /* Cache Nonce */
|
||||
u_char error_code[2]; /* Error code */
|
||||
} u;
|
||||
u_char length[4];
|
||||
} rpki_rtr_pdu;
|
||||
#define RPKI_RTR_PDU_OVERHEAD (offsetof(rpki_rtr_pdu, rpki_rtr_pdu_msg))
|
||||
|
||||
/*
|
||||
* IPv4 Prefix PDU.
|
||||
*/
|
||||
typedef struct rpki_rtr_pdu_ipv4_prefix_ {
|
||||
rpki_rtr_pdu pdu_header;
|
||||
u_char flags;
|
||||
u_char prefix_length;
|
||||
u_char max_length;
|
||||
u_char zero;
|
||||
u_char prefix[4];
|
||||
u_char as[4];
|
||||
} rpki_rtr_pdu_ipv4_prefix;
|
||||
|
||||
/*
|
||||
* IPv6 Prefix PDU.
|
||||
*/
|
||||
typedef struct rpki_rtr_pdu_ipv6_prefix_ {
|
||||
rpki_rtr_pdu pdu_header;
|
||||
u_char flags;
|
||||
u_char prefix_length;
|
||||
u_char max_length;
|
||||
u_char zero;
|
||||
u_char prefix[16];
|
||||
u_char as[4];
|
||||
} rpki_rtr_pdu_ipv6_prefix;
|
||||
|
||||
/*
|
||||
* Error report PDU.
|
||||
*/
|
||||
typedef struct rpki_rtr_pdu_error_report_ {
|
||||
rpki_rtr_pdu pdu_header;
|
||||
u_char encapsulated_pdu_length[4]; /* Encapsulated PDU length */
|
||||
} rpki_rtr_pdu_error_report;
|
||||
|
||||
/*
|
||||
* PDU type codes
|
||||
*/
|
||||
#define RPKI_RTR_SERIAL_NOTIFY_PDU 0
|
||||
#define RPKI_RTR_SERIAL_QUERY_PDU 1
|
||||
#define RPKI_RTR_RESET_QUERY_PDU 2
|
||||
#define RPKI_RTR_CACHE_RESPONSE_PDU 3
|
||||
#define RPKI_RTR_IPV4_PREFIX_PDU 4
|
||||
#define RPKI_RTR_IPV6_PREFIX_PDU 6
|
||||
#define RPKI_RTR_END_OF_DATA_PDU 7
|
||||
#define RPKI_RTR_CACHE_RESET_PDU 8
|
||||
#define RPKI_RTR_ERROR_REPORT_PDU 10
|
||||
|
||||
static const struct tok rpki_rtr_pdu_values[] = {
|
||||
{ RPKI_RTR_SERIAL_NOTIFY_PDU, "Serial Notify" },
|
||||
{ RPKI_RTR_SERIAL_QUERY_PDU, "Serial Query" },
|
||||
{ RPKI_RTR_RESET_QUERY_PDU, "Reset Query" },
|
||||
{ RPKI_RTR_CACHE_RESPONSE_PDU, "Cache Response" },
|
||||
{ RPKI_RTR_IPV4_PREFIX_PDU, "IPV4 Prefix" },
|
||||
{ RPKI_RTR_IPV6_PREFIX_PDU, "IPV6 Prefix" },
|
||||
{ RPKI_RTR_END_OF_DATA_PDU, "End of Data" },
|
||||
{ RPKI_RTR_CACHE_RESET_PDU, "Cache Reset" },
|
||||
{ RPKI_RTR_ERROR_REPORT_PDU, "Error Report" },
|
||||
{ 0, NULL}
|
||||
};
|
||||
|
||||
static const struct tok rpki_rtr_error_codes[] = {
|
||||
{ 0, "Corrupt Data" },
|
||||
{ 1, "Internal Error" },
|
||||
{ 2, "No Data Available" },
|
||||
{ 3, "Invalid Request" },
|
||||
{ 4, "Unsupported Protocol Version" },
|
||||
{ 5, "Unsupported PDU Type" },
|
||||
{ 6, "Withdrawal of Unknown Record" },
|
||||
{ 7, "Duplicate Announcement Received" },
|
||||
{ 0, NULL}
|
||||
};
|
||||
|
||||
/*
|
||||
* Build a identation string for a given identation level.
|
||||
* XXX this should be really in util.c
|
||||
*/
|
||||
static char *
|
||||
indent_string (u_int indent)
|
||||
{
|
||||
static char buf[20];
|
||||
u_int idx;
|
||||
|
||||
idx = 0;
|
||||
buf[idx] = '\0';
|
||||
|
||||
/*
|
||||
* Does the static buffer fit ?
|
||||
*/
|
||||
if (sizeof(buf) < ((indent/8) + (indent %8) + 2)) {
|
||||
return buf;
|
||||
}
|
||||
|
||||
/*
|
||||
* Heading newline.
|
||||
*/
|
||||
buf[idx] = '\n';
|
||||
idx++;
|
||||
|
||||
while (indent >= 8) {
|
||||
buf[idx] = '\t';
|
||||
idx++;
|
||||
indent -= 8;
|
||||
}
|
||||
|
||||
while (indent > 0) {
|
||||
buf[idx] = ' ';
|
||||
idx++;
|
||||
indent--;
|
||||
}
|
||||
|
||||
/*
|
||||
* Trailing zero.
|
||||
*/
|
||||
buf[idx] = '\0';
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
/*
|
||||
* Print a single PDU.
|
||||
*/
|
||||
static void
|
||||
rpki_rtr_pdu_print (const u_char *tptr, u_int indent)
|
||||
{
|
||||
const rpki_rtr_pdu *pdu_header;
|
||||
u_int pdu_type, pdu_len, hexdump;
|
||||
const u_char *msg;
|
||||
|
||||
pdu_header = (rpki_rtr_pdu *)tptr;
|
||||
pdu_type = pdu_header->pdu_type;
|
||||
pdu_len = EXTRACT_32BITS(pdu_header->length);
|
||||
hexdump = FALSE;
|
||||
|
||||
printf("%sRPKI-RTRv%u, %s PDU (%u), length: %u",
|
||||
indent_string(8),
|
||||
pdu_header->version,
|
||||
tok2str(rpki_rtr_pdu_values, "Unknown", pdu_type),
|
||||
pdu_type, pdu_len);
|
||||
|
||||
switch (pdu_type) {
|
||||
|
||||
/*
|
||||
* The following PDUs share the message format.
|
||||
*/
|
||||
case RPKI_RTR_SERIAL_NOTIFY_PDU:
|
||||
case RPKI_RTR_SERIAL_QUERY_PDU:
|
||||
case RPKI_RTR_END_OF_DATA_PDU:
|
||||
msg = (const u_char *)(pdu_header + 1);
|
||||
printf("%sCache-Nonce: 0x%04x, Serial: %u",
|
||||
indent_string(indent+2),
|
||||
EXTRACT_16BITS(pdu_header->u.cache_nonce),
|
||||
EXTRACT_32BITS(msg));
|
||||
break;
|
||||
|
||||
/*
|
||||
* The following PDUs share the message format.
|
||||
*/
|
||||
case RPKI_RTR_RESET_QUERY_PDU:
|
||||
case RPKI_RTR_CACHE_RESET_PDU:
|
||||
|
||||
/*
|
||||
* Zero payload PDUs.
|
||||
*/
|
||||
break;
|
||||
|
||||
case RPKI_RTR_CACHE_RESPONSE_PDU:
|
||||
printf("%sCache-Nonce: 0x%04x",
|
||||
indent_string(indent+2),
|
||||
EXTRACT_16BITS(pdu_header->u.cache_nonce));
|
||||
break;
|
||||
|
||||
case RPKI_RTR_IPV4_PREFIX_PDU:
|
||||
{
|
||||
rpki_rtr_pdu_ipv4_prefix *pdu;
|
||||
|
||||
pdu = (rpki_rtr_pdu_ipv4_prefix *)tptr;
|
||||
printf("%sIPv4 Prefix %s/%u-%u, origin-as %u, flags 0x%02x",
|
||||
indent_string(indent+2),
|
||||
ipaddr_string(pdu->prefix),
|
||||
pdu->prefix_length, pdu->max_length,
|
||||
EXTRACT_32BITS(pdu->as), pdu->flags);
|
||||
}
|
||||
break;
|
||||
|
||||
#ifdef INET6
|
||||
case RPKI_RTR_IPV6_PREFIX_PDU:
|
||||
{
|
||||
rpki_rtr_pdu_ipv6_prefix *pdu;
|
||||
|
||||
pdu = (rpki_rtr_pdu_ipv6_prefix *)tptr;
|
||||
printf("%sIPv6 Prefix %s/%u-%u, origin-as %u, flags 0x%02x",
|
||||
indent_string(indent+2),
|
||||
ip6addr_string(pdu->prefix),
|
||||
pdu->prefix_length, pdu->max_length,
|
||||
EXTRACT_32BITS(pdu->as), pdu->flags);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
case RPKI_RTR_ERROR_REPORT_PDU:
|
||||
{
|
||||
rpki_rtr_pdu_error_report *pdu;
|
||||
u_int encapsulated_pdu_length, text_length, tlen, error_code;
|
||||
u_char buf[80];
|
||||
|
||||
pdu = (rpki_rtr_pdu_error_report *)tptr;
|
||||
encapsulated_pdu_length = EXTRACT_32BITS(pdu->encapsulated_pdu_length);
|
||||
tlen = pdu_len;
|
||||
|
||||
error_code = EXTRACT_16BITS(pdu->pdu_header.u.error_code);
|
||||
printf("%sError code: %s (%u), Encapsulated PDU length: %u",
|
||||
indent_string(indent+2),
|
||||
tok2str(rpki_rtr_error_codes, "Unknown", error_code),
|
||||
error_code, encapsulated_pdu_length);
|
||||
|
||||
tptr += sizeof(*pdu);
|
||||
tlen -= sizeof(*pdu);
|
||||
|
||||
/*
|
||||
* Recurse if there is an encapsulated PDU.
|
||||
*/
|
||||
if (encapsulated_pdu_length &&
|
||||
(encapsulated_pdu_length <= tlen)) {
|
||||
printf("%s-----encapsulated PDU-----", indent_string(indent+4));
|
||||
rpki_rtr_pdu_print(tptr, indent+2);
|
||||
}
|
||||
|
||||
tptr += encapsulated_pdu_length;
|
||||
tlen -= encapsulated_pdu_length;
|
||||
|
||||
/*
|
||||
* Extract, trail-zero and print the Error message.
|
||||
*/
|
||||
text_length = 0;
|
||||
if (tlen > 4) {
|
||||
text_length = EXTRACT_32BITS(tptr);
|
||||
tptr += 4;
|
||||
tlen -= 4;
|
||||
}
|
||||
if (text_length && (text_length <= tlen )) {
|
||||
memcpy(buf, tptr, MIN(sizeof(buf)-1, text_length));
|
||||
buf[text_length] = '\0';
|
||||
printf("%sError text: %s", indent_string(indent+2), buf);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
/*
|
||||
* Unknown data, please hexdump.
|
||||
*/
|
||||
hexdump = TRUE;
|
||||
}
|
||||
|
||||
/* do we also want to see a hex dump ? */
|
||||
if (vflag > 1 || (vflag && hexdump)) {
|
||||
print_unknown_data(tptr,"\n\t ", pdu_len);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
rpki_rtr_print(register const u_char *pptr, register u_int len) {
|
||||
|
||||
u_int tlen, pdu_type, pdu_len;
|
||||
const u_char *tptr;
|
||||
const rpki_rtr_pdu *pdu_header;
|
||||
|
||||
tptr = pptr;
|
||||
tlen = len;
|
||||
|
||||
if (!vflag) {
|
||||
printf(", RPKI-RTR");
|
||||
return;
|
||||
}
|
||||
|
||||
while (tlen >= sizeof(rpki_rtr_pdu)) {
|
||||
|
||||
TCHECK2(*tptr, sizeof(rpki_rtr_pdu));
|
||||
|
||||
pdu_header = (rpki_rtr_pdu *)tptr;
|
||||
pdu_type = pdu_header->pdu_type;
|
||||
pdu_len = EXTRACT_32BITS(pdu_header->length);
|
||||
|
||||
/* infinite loop check */
|
||||
if (!pdu_type || !pdu_len) {
|
||||
break;
|
||||
}
|
||||
|
||||
TCHECK2(*tptr, pdu_len);
|
||||
if (tlen < pdu_len) {
|
||||
goto trunc;
|
||||
}
|
||||
|
||||
/*
|
||||
* Print the PDU.
|
||||
*/
|
||||
rpki_rtr_pdu_print(tptr, 8);
|
||||
|
||||
tlen -= pdu_len;
|
||||
tptr += pdu_len;
|
||||
}
|
||||
return;
|
||||
trunc:
|
||||
printf("\n\t[|RPKI-RTR]");
|
||||
}
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* c-style: whitesmith
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
@ -111,8 +111,8 @@ rrcp_print(netdissect_options *ndo,
|
||||
if (rrcp_opcode==1 || rrcp_opcode==2){
|
||||
ND_TCHECK2(*(rrcp + RRCP_REG_ADDR_OFFSET), 6);
|
||||
ND_PRINT((ndo, " addr=0x%04x, data=0x%08x",
|
||||
EXTRACT_16BITS(rrcp + RRCP_REG_ADDR_OFFSET),
|
||||
EXTRACT_32BITS(rrcp + RRCP_REG_DATA_OFFSET)));
|
||||
EXTRACT_LE_16BITS(rrcp + RRCP_REG_ADDR_OFFSET),
|
||||
EXTRACT_LE_32BITS(rrcp + RRCP_REG_DATA_OFFSET)));
|
||||
}
|
||||
if (rrcp_proto==1){
|
||||
ND_TCHECK2(*(rrcp + RRCP_AUTHKEY_OFFSET), 2);
|
||||
|
@ -1790,7 +1790,7 @@ _U_
|
||||
}
|
||||
/* do we also want to see a hex dump ? */
|
||||
if (vflag > 1 || hexdump==TRUE)
|
||||
print_unknown_data(tptr+sizeof(sizeof(struct rsvp_object_header)),"\n\t ", /* FIXME indentation */
|
||||
print_unknown_data(tptr+sizeof(struct rsvp_object_header),"\n\t ", /* FIXME indentation */
|
||||
rsvp_obj_len-sizeof(struct rsvp_object_header));
|
||||
|
||||
tptr+=rsvp_obj_len;
|
||||
|
@ -59,9 +59,9 @@ static const char rcsid[] _U_ =
|
||||
#include "ip6.h"
|
||||
#endif
|
||||
|
||||
#define CHAN_HP 6700
|
||||
#define CHAN_MP 6701
|
||||
#define CHAN_LP 6702
|
||||
#define CHAN_HP 6704
|
||||
#define CHAN_MP 6705
|
||||
#define CHAN_LP 6706
|
||||
|
||||
struct tok ForCES_channels[] = {
|
||||
{ CHAN_HP, "ForCES HP" },
|
||||
|
807
print-sflow.c
807
print-sflow.c
@ -15,6 +15,8 @@
|
||||
* The SFLOW protocol as per http://www.sflow.org/developers/specifications.php
|
||||
*
|
||||
* Original code by Carles Kishimoto <carles.kishimoto@gmail.com>
|
||||
*
|
||||
* Expansion and refactoring by Rick Jones <rick.jones2@hp.com>
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -87,6 +89,18 @@ static const struct tok sflow_format_values[] = {
|
||||
{ 0, NULL}
|
||||
};
|
||||
|
||||
struct sflow_flow_sample_t {
|
||||
u_int8_t seqnum[4];
|
||||
u_int8_t typesource[4];
|
||||
u_int8_t rate[4];
|
||||
u_int8_t pool[4];
|
||||
u_int8_t drops[4];
|
||||
u_int8_t in_interface[4];
|
||||
u_int8_t out_interface[4];
|
||||
u_int8_t records[4];
|
||||
|
||||
};
|
||||
|
||||
struct sflow_expanded_flow_sample_t {
|
||||
u_int8_t seqnum[4];
|
||||
u_int8_t type[4];
|
||||
@ -156,6 +170,36 @@ struct sflow_expanded_flow_raw_t {
|
||||
u_int8_t header_size[4];
|
||||
};
|
||||
|
||||
struct sflow_ethernet_frame_t {
|
||||
u_int8_t length[4];
|
||||
u_int8_t src_mac[8];
|
||||
u_int8_t dst_mac[8];
|
||||
u_int8_t type[4];
|
||||
};
|
||||
|
||||
struct sflow_extended_switch_data_t {
|
||||
u_int8_t src_vlan[4];
|
||||
u_int8_t src_pri[4];
|
||||
u_int8_t dst_vlan[4];
|
||||
u_int8_t dst_pri[4];
|
||||
};
|
||||
|
||||
struct sflow_counter_record_t {
|
||||
u_int8_t format[4];
|
||||
u_int8_t length[4];
|
||||
};
|
||||
|
||||
struct sflow_flow_record_t {
|
||||
u_int8_t format[4];
|
||||
u_int8_t length[4];
|
||||
};
|
||||
|
||||
struct sflow_counter_sample_t {
|
||||
u_int8_t seqnum[4];
|
||||
u_int8_t typesource[4];
|
||||
u_int8_t records[4];
|
||||
};
|
||||
|
||||
struct sflow_expanded_counter_sample_t {
|
||||
u_int8_t seqnum[4];
|
||||
u_int8_t type[4];
|
||||
@ -259,24 +303,525 @@ struct sflow_vlan_counter_t {
|
||||
u_int8_t discards[4];
|
||||
};
|
||||
|
||||
static int
|
||||
print_sflow_counter_generic(const u_char *pointer, u_int len) {
|
||||
|
||||
const struct sflow_generic_counter_t *sflow_gen_counter;
|
||||
|
||||
if (len < sizeof(struct sflow_generic_counter_t))
|
||||
return 1;
|
||||
|
||||
|
||||
sflow_gen_counter = (const struct sflow_generic_counter_t *)pointer;
|
||||
printf("\n\t ifindex %u, iftype %u, ifspeed %" PRIu64 ", ifdirection %u (%s)",
|
||||
EXTRACT_32BITS(sflow_gen_counter->ifindex),
|
||||
EXTRACT_32BITS(sflow_gen_counter->iftype),
|
||||
EXTRACT_64BITS(sflow_gen_counter->ifspeed),
|
||||
EXTRACT_32BITS(sflow_gen_counter->ifdirection),
|
||||
tok2str(sflow_iface_direction_values, "Unknown",
|
||||
EXTRACT_32BITS(sflow_gen_counter->ifdirection)));
|
||||
printf("\n\t ifstatus %u, adminstatus: %s, operstatus: %s",
|
||||
EXTRACT_32BITS(sflow_gen_counter->ifstatus),
|
||||
EXTRACT_32BITS(sflow_gen_counter->ifstatus)&1 ? "up" : "down",
|
||||
(EXTRACT_32BITS(sflow_gen_counter->ifstatus)>>1)&1 ? "up" : "down");
|
||||
printf("\n\t In octets %" PRIu64
|
||||
", unicast pkts %u, multicast pkts %u, broadcast pkts %u, discards %u",
|
||||
EXTRACT_64BITS(sflow_gen_counter->ifinoctets),
|
||||
EXTRACT_32BITS(sflow_gen_counter->ifinunicastpkts),
|
||||
EXTRACT_32BITS(sflow_gen_counter->ifinmulticastpkts),
|
||||
EXTRACT_32BITS(sflow_gen_counter->ifinbroadcastpkts),
|
||||
EXTRACT_32BITS(sflow_gen_counter->ifindiscards));
|
||||
printf("\n\t In errors %u, unknown protos %u",
|
||||
EXTRACT_32BITS(sflow_gen_counter->ifinerrors),
|
||||
EXTRACT_32BITS(sflow_gen_counter->ifinunkownprotos));
|
||||
printf("\n\t Out octets %" PRIu64
|
||||
", unicast pkts %u, multicast pkts %u, broadcast pkts %u, discards %u",
|
||||
EXTRACT_64BITS(sflow_gen_counter->ifoutoctets),
|
||||
EXTRACT_32BITS(sflow_gen_counter->ifoutunicastpkts),
|
||||
EXTRACT_32BITS(sflow_gen_counter->ifoutmulticastpkts),
|
||||
EXTRACT_32BITS(sflow_gen_counter->ifoutbroadcastpkts),
|
||||
EXTRACT_32BITS(sflow_gen_counter->ifoutdiscards));
|
||||
printf("\n\t Out errors %u, promisc mode %u",
|
||||
EXTRACT_32BITS(sflow_gen_counter->ifouterrors),
|
||||
EXTRACT_32BITS(sflow_gen_counter->ifpromiscmode));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
print_sflow_counter_ethernet(const u_char *pointer, u_int len){
|
||||
|
||||
const struct sflow_ethernet_counter_t *sflow_eth_counter;
|
||||
|
||||
if (len < sizeof(struct sflow_ethernet_counter_t))
|
||||
return 1;
|
||||
|
||||
sflow_eth_counter = (const struct sflow_ethernet_counter_t *)pointer;
|
||||
printf("\n\t align errors %u, fcs errors %u, single collision %u, multiple collision %u, test error %u",
|
||||
EXTRACT_32BITS(sflow_eth_counter->alignerrors),
|
||||
EXTRACT_32BITS(sflow_eth_counter->fcserrors),
|
||||
EXTRACT_32BITS(sflow_eth_counter->single_collision_frames),
|
||||
EXTRACT_32BITS(sflow_eth_counter->multiple_collision_frames),
|
||||
EXTRACT_32BITS(sflow_eth_counter->test_errors));
|
||||
printf("\n\t deferred %u, late collision %u, excessive collision %u, mac trans error %u",
|
||||
EXTRACT_32BITS(sflow_eth_counter->deferred_transmissions),
|
||||
EXTRACT_32BITS(sflow_eth_counter->late_collisions),
|
||||
EXTRACT_32BITS(sflow_eth_counter->excessive_collisions),
|
||||
EXTRACT_32BITS(sflow_eth_counter->mac_transmit_errors));
|
||||
printf("\n\t carrier error %u, frames too long %u, mac receive errors %u, symbol errors %u",
|
||||
EXTRACT_32BITS(sflow_eth_counter->carrier_sense_errors),
|
||||
EXTRACT_32BITS(sflow_eth_counter->frame_too_longs),
|
||||
EXTRACT_32BITS(sflow_eth_counter->mac_receive_errors),
|
||||
EXTRACT_32BITS(sflow_eth_counter->symbol_errors));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
print_sflow_counter_token_ring(const u_char *pointer _U_, u_int len _U_) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
print_sflow_counter_basevg(const u_char *pointer, u_int len) {
|
||||
|
||||
const struct sflow_100basevg_counter_t *sflow_100basevg_counter;
|
||||
|
||||
if (len < sizeof(struct sflow_100basevg_counter_t))
|
||||
return 1;
|
||||
|
||||
sflow_100basevg_counter = (const struct sflow_100basevg_counter_t *)pointer;
|
||||
printf("\n\t in high prio frames %u, in high prio octets %" PRIu64,
|
||||
EXTRACT_32BITS(sflow_100basevg_counter->in_highpriority_frames),
|
||||
EXTRACT_64BITS(sflow_100basevg_counter->in_highpriority_octets));
|
||||
printf("\n\t in norm prio frames %u, in norm prio octets %" PRIu64,
|
||||
EXTRACT_32BITS(sflow_100basevg_counter->in_normpriority_frames),
|
||||
EXTRACT_64BITS(sflow_100basevg_counter->in_normpriority_octets));
|
||||
printf("\n\t in ipm errors %u, oversized %u, in data errors %u, null addressed frames %u",
|
||||
EXTRACT_32BITS(sflow_100basevg_counter->in_ipmerrors),
|
||||
EXTRACT_32BITS(sflow_100basevg_counter->in_oversized),
|
||||
EXTRACT_32BITS(sflow_100basevg_counter->in_data_errors),
|
||||
EXTRACT_32BITS(sflow_100basevg_counter->in_null_addressed_frames));
|
||||
printf("\n\t out high prio frames %u, out high prio octets %" PRIu64
|
||||
", trans into frames %u",
|
||||
EXTRACT_32BITS(sflow_100basevg_counter->out_highpriority_frames),
|
||||
EXTRACT_64BITS(sflow_100basevg_counter->out_highpriority_octets),
|
||||
EXTRACT_32BITS(sflow_100basevg_counter->transitioninto_frames));
|
||||
printf("\n\t in hc high prio octets %" PRIu64
|
||||
", in hc norm prio octets %" PRIu64
|
||||
", out hc high prio octets %" PRIu64,
|
||||
EXTRACT_64BITS(sflow_100basevg_counter->hc_in_highpriority_octets),
|
||||
EXTRACT_64BITS(sflow_100basevg_counter->hc_in_normpriority_octets),
|
||||
EXTRACT_64BITS(sflow_100basevg_counter->hc_out_highpriority_octets));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
print_sflow_counter_vlan(const u_char *pointer, u_int len) {
|
||||
|
||||
const struct sflow_vlan_counter_t *sflow_vlan_counter;
|
||||
|
||||
if (len < sizeof(struct sflow_vlan_counter_t))
|
||||
return 1;
|
||||
|
||||
sflow_vlan_counter = (const struct sflow_vlan_counter_t *)pointer;
|
||||
printf("\n\t vlan_id %u, octets %" PRIu64
|
||||
", unicast_pkt %u, multicast_pkt %u, broadcast_pkt %u, discards %u",
|
||||
EXTRACT_32BITS(sflow_vlan_counter->vlan_id),
|
||||
EXTRACT_64BITS(sflow_vlan_counter->octets),
|
||||
EXTRACT_32BITS(sflow_vlan_counter->unicast_pkt),
|
||||
EXTRACT_32BITS(sflow_vlan_counter->multicast_pkt),
|
||||
EXTRACT_32BITS(sflow_vlan_counter->broadcast_pkt),
|
||||
EXTRACT_32BITS(sflow_vlan_counter->discards));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct sflow_processor_counter_t {
|
||||
u_int8_t five_sec_util[4];
|
||||
u_int8_t one_min_util[4];
|
||||
u_int8_t five_min_util[4];
|
||||
u_int8_t total_memory[8];
|
||||
u_int8_t free_memory[8];
|
||||
};
|
||||
|
||||
static int
|
||||
print_sflow_counter_processor(const u_char *pointer, u_int len) {
|
||||
|
||||
const struct sflow_processor_counter_t *sflow_processor_counter;
|
||||
|
||||
if (len < sizeof(struct sflow_processor_counter_t))
|
||||
return 1;
|
||||
|
||||
sflow_processor_counter = (const struct sflow_processor_counter_t *)pointer;
|
||||
printf("\n\t 5sec %u, 1min %u, 5min %u, total_mem %" PRIu64
|
||||
", total_mem %" PRIu64,
|
||||
EXTRACT_32BITS(sflow_processor_counter->five_sec_util),
|
||||
EXTRACT_32BITS(sflow_processor_counter->one_min_util),
|
||||
EXTRACT_32BITS(sflow_processor_counter->five_min_util),
|
||||
EXTRACT_64BITS(sflow_processor_counter->total_memory),
|
||||
EXTRACT_64BITS(sflow_processor_counter->free_memory));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
sflow_print_counter_records(const u_char *pointer, u_int len, u_int records) {
|
||||
|
||||
u_int nrecords;
|
||||
const u_char *tptr;
|
||||
u_int tlen;
|
||||
u_int counter_type;
|
||||
u_int counter_len;
|
||||
u_int enterprise;
|
||||
const struct sflow_counter_record_t *sflow_counter_record;
|
||||
|
||||
nrecords = records;
|
||||
tptr = pointer;
|
||||
tlen = len;
|
||||
|
||||
while (nrecords > 0) {
|
||||
/* do we have the "header?" */
|
||||
if (tlen < sizeof(struct sflow_counter_record_t))
|
||||
return 1;
|
||||
sflow_counter_record = (const struct sflow_counter_record_t *)tptr;
|
||||
|
||||
enterprise = EXTRACT_32BITS(sflow_counter_record->format);
|
||||
counter_type = enterprise & 0x0FFF;
|
||||
enterprise = enterprise >> 20;
|
||||
counter_len = EXTRACT_32BITS(sflow_counter_record->length);
|
||||
printf("\n\t enterprise %u, %s (%u) length %u",
|
||||
enterprise,
|
||||
(enterprise == 0) ? tok2str(sflow_counter_type_values,"Unknown",counter_type) : "Unknown",
|
||||
counter_type,
|
||||
counter_len);
|
||||
|
||||
tptr += sizeof(struct sflow_counter_record_t);
|
||||
tlen -= sizeof(struct sflow_counter_record_t);
|
||||
|
||||
if (tlen < counter_len)
|
||||
return 1;
|
||||
if (enterprise == 0) {
|
||||
switch (counter_type) {
|
||||
case SFLOW_COUNTER_GENERIC:
|
||||
if (print_sflow_counter_generic(tptr,tlen))
|
||||
return 1;
|
||||
break;
|
||||
case SFLOW_COUNTER_ETHERNET:
|
||||
if (print_sflow_counter_ethernet(tptr,tlen))
|
||||
return 1;
|
||||
break;
|
||||
case SFLOW_COUNTER_TOKEN_RING:
|
||||
if (print_sflow_counter_token_ring(tptr,tlen))
|
||||
return 1;
|
||||
break;
|
||||
case SFLOW_COUNTER_BASEVG:
|
||||
if (print_sflow_counter_basevg(tptr,tlen))
|
||||
return 1;
|
||||
break;
|
||||
case SFLOW_COUNTER_VLAN:
|
||||
if (print_sflow_counter_vlan(tptr,tlen))
|
||||
return 1;
|
||||
break;
|
||||
case SFLOW_COUNTER_PROCESSOR:
|
||||
if (print_sflow_counter_processor(tptr,tlen))
|
||||
return 1;
|
||||
break;
|
||||
default:
|
||||
if (vflag <= 1)
|
||||
print_unknown_data(tptr, "\n\t\t", counter_len);
|
||||
break;
|
||||
}
|
||||
}
|
||||
tptr += counter_len;
|
||||
tlen -= counter_len;
|
||||
nrecords--;
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
sflow_print_counter_sample(const u_char *pointer, u_int len) {
|
||||
|
||||
const struct sflow_counter_sample_t *sflow_counter_sample;
|
||||
u_int nrecords;
|
||||
u_int typesource;
|
||||
u_int type;
|
||||
u_int index;
|
||||
|
||||
|
||||
if (len < sizeof(struct sflow_counter_sample_t))
|
||||
return 1;
|
||||
|
||||
sflow_counter_sample = (const struct sflow_counter_sample_t *)pointer;
|
||||
|
||||
typesource = EXTRACT_32BITS(sflow_counter_sample->typesource);
|
||||
nrecords = EXTRACT_32BITS(sflow_counter_sample->records);
|
||||
type = typesource >> 24;
|
||||
index = typesource & 0x0FFF;
|
||||
|
||||
printf(" seqnum %u, type %u, idx %u, records %u",
|
||||
EXTRACT_32BITS(sflow_counter_sample->seqnum),
|
||||
type,
|
||||
index,
|
||||
nrecords);
|
||||
|
||||
return sflow_print_counter_records(pointer + sizeof(struct sflow_counter_sample_t),
|
||||
len - sizeof(struct sflow_counter_sample_t),
|
||||
nrecords);
|
||||
|
||||
}
|
||||
|
||||
static int
|
||||
sflow_print_expanded_counter_sample(const u_char *pointer, u_int len) {
|
||||
|
||||
const struct sflow_expanded_counter_sample_t *sflow_expanded_counter_sample;
|
||||
u_int nrecords;
|
||||
|
||||
|
||||
if (len < sizeof(struct sflow_expanded_counter_sample_t))
|
||||
return 1;
|
||||
|
||||
sflow_expanded_counter_sample = (const struct sflow_expanded_counter_sample_t *)pointer;
|
||||
|
||||
nrecords = EXTRACT_32BITS(sflow_expanded_counter_sample->records);
|
||||
|
||||
printf(" seqnum %u, type %u, idx %u, records %u",
|
||||
EXTRACT_32BITS(sflow_expanded_counter_sample->seqnum),
|
||||
EXTRACT_32BITS(sflow_expanded_counter_sample->type),
|
||||
EXTRACT_32BITS(sflow_expanded_counter_sample->index),
|
||||
nrecords);
|
||||
|
||||
return sflow_print_counter_records(pointer + sizeof(struct sflow_expanded_counter_sample_t),
|
||||
len - sizeof(struct sflow_expanded_counter_sample_t),
|
||||
nrecords);
|
||||
|
||||
}
|
||||
|
||||
static int
|
||||
print_sflow_raw_packet(const u_char *pointer, u_int len) {
|
||||
|
||||
const struct sflow_expanded_flow_raw_t *sflow_flow_raw;
|
||||
|
||||
if (len < sizeof(struct sflow_expanded_flow_raw_t))
|
||||
return 1;
|
||||
|
||||
sflow_flow_raw = (const struct sflow_expanded_flow_raw_t *)pointer;
|
||||
printf("\n\t protocol %s (%u), length %u, stripped bytes %u, header_size %u",
|
||||
tok2str(sflow_flow_raw_protocol_values,"Unknown",EXTRACT_32BITS(sflow_flow_raw->protocol)),
|
||||
EXTRACT_32BITS(sflow_flow_raw->protocol),
|
||||
EXTRACT_32BITS(sflow_flow_raw->length),
|
||||
EXTRACT_32BITS(sflow_flow_raw->stripped_bytes),
|
||||
EXTRACT_32BITS(sflow_flow_raw->header_size));
|
||||
|
||||
/* QUESTION - should we attempt to print the raw header itself?
|
||||
assuming of course there is wnough data present to do so... */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
print_sflow_ethernet_frame(const u_char *pointer, u_int len) {
|
||||
|
||||
const struct sflow_ethernet_frame_t *sflow_ethernet_frame;
|
||||
|
||||
if (len < sizeof(struct sflow_ethernet_frame_t))
|
||||
return 1;
|
||||
|
||||
sflow_ethernet_frame = (const struct sflow_ethernet_frame_t *)pointer;
|
||||
|
||||
printf("\n\t frame len %u, type %u",
|
||||
EXTRACT_32BITS(sflow_ethernet_frame->length),
|
||||
EXTRACT_32BITS(sflow_ethernet_frame->type));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
print_sflow_extended_switch_data(const u_char *pointer, u_int len) {
|
||||
|
||||
const struct sflow_extended_switch_data_t *sflow_extended_sw_data;
|
||||
|
||||
if (len < sizeof(struct sflow_extended_switch_data_t))
|
||||
return 1;
|
||||
|
||||
sflow_extended_sw_data = (const struct sflow_extended_switch_data_t *)pointer;
|
||||
printf("\n\t src vlan %u, src pri %u, dst vlan %u, dst pri %u",
|
||||
EXTRACT_32BITS(sflow_extended_sw_data->src_vlan),
|
||||
EXTRACT_32BITS(sflow_extended_sw_data->src_pri),
|
||||
EXTRACT_32BITS(sflow_extended_sw_data->dst_vlan),
|
||||
EXTRACT_32BITS(sflow_extended_sw_data->dst_pri));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
sflow_print_flow_records(const u_char *pointer, u_int len, u_int records) {
|
||||
|
||||
u_int nrecords;
|
||||
const u_char *tptr;
|
||||
u_int tlen;
|
||||
u_int flow_type;
|
||||
u_int enterprise;
|
||||
u_int flow_len;
|
||||
const struct sflow_flow_record_t *sflow_flow_record;
|
||||
|
||||
nrecords = records;
|
||||
tptr = pointer;
|
||||
tlen = len;
|
||||
|
||||
while (nrecords > 0) {
|
||||
/* do we have the "header?" */
|
||||
if (tlen < sizeof(struct sflow_flow_record_t))
|
||||
return 1;
|
||||
|
||||
sflow_flow_record = (const struct sflow_flow_record_t *)tptr;
|
||||
|
||||
/* so, the funky encoding means we cannot blythly mask-off
|
||||
bits, we must also check the enterprise. */
|
||||
|
||||
enterprise = EXTRACT_32BITS(sflow_flow_record->format);
|
||||
flow_type = enterprise & 0x0FFF;
|
||||
enterprise = enterprise >> 12;
|
||||
flow_len = EXTRACT_32BITS(sflow_flow_record->length);
|
||||
printf("\n\t enterprise %u %s (%u) length %u",
|
||||
enterprise,
|
||||
(enterprise == 0) ? tok2str(sflow_flow_type_values,"Unknown",flow_type) : "Unknown",
|
||||
flow_type,
|
||||
flow_len);
|
||||
|
||||
tptr += sizeof(struct sflow_flow_record_t);
|
||||
tlen -= sizeof(struct sflow_flow_record_t);
|
||||
|
||||
if (tlen < flow_len)
|
||||
return 1;
|
||||
|
||||
if (enterprise == 0) {
|
||||
switch (flow_type) {
|
||||
case SFLOW_FLOW_RAW_PACKET:
|
||||
if (print_sflow_raw_packet(tptr,tlen))
|
||||
return 1;
|
||||
break;
|
||||
case SFLOW_FLOW_EXTENDED_SWITCH_DATA:
|
||||
if (print_sflow_extended_switch_data(tptr,tlen))
|
||||
return 1;
|
||||
break;
|
||||
case SFLOW_FLOW_ETHERNET_FRAME:
|
||||
if (print_sflow_ethernet_frame(tptr,tlen))
|
||||
return 1;
|
||||
break;
|
||||
/* FIXME these need a decoder */
|
||||
case SFLOW_FLOW_IPV4_DATA:
|
||||
case SFLOW_FLOW_IPV6_DATA:
|
||||
case SFLOW_FLOW_EXTENDED_ROUTER_DATA:
|
||||
case SFLOW_FLOW_EXTENDED_GATEWAY_DATA:
|
||||
case SFLOW_FLOW_EXTENDED_USER_DATA:
|
||||
case SFLOW_FLOW_EXTENDED_URL_DATA:
|
||||
case SFLOW_FLOW_EXTENDED_MPLS_DATA:
|
||||
case SFLOW_FLOW_EXTENDED_NAT_DATA:
|
||||
case SFLOW_FLOW_EXTENDED_MPLS_TUNNEL:
|
||||
case SFLOW_FLOW_EXTENDED_MPLS_VC:
|
||||
case SFLOW_FLOW_EXTENDED_MPLS_FEC:
|
||||
case SFLOW_FLOW_EXTENDED_MPLS_LVP_FEC:
|
||||
case SFLOW_FLOW_EXTENDED_VLAN_TUNNEL:
|
||||
break;
|
||||
default:
|
||||
if (vflag <= 1)
|
||||
print_unknown_data(tptr, "\n\t\t", flow_len);
|
||||
break;
|
||||
}
|
||||
}
|
||||
tptr += flow_len;
|
||||
tlen -= flow_len;
|
||||
nrecords--;
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
sflow_print_flow_sample(const u_char *pointer, u_int len) {
|
||||
|
||||
const struct sflow_flow_sample_t *sflow_flow_sample;
|
||||
u_int nrecords;
|
||||
u_int typesource;
|
||||
u_int type;
|
||||
u_int index;
|
||||
|
||||
if (len < sizeof(struct sflow_flow_sample_t))
|
||||
return 1;
|
||||
|
||||
sflow_flow_sample = (struct sflow_flow_sample_t *)pointer;
|
||||
|
||||
typesource = EXTRACT_32BITS(sflow_flow_sample->typesource);
|
||||
nrecords = EXTRACT_32BITS(sflow_flow_sample->records);
|
||||
type = typesource >> 24;
|
||||
index = typesource & 0x0FFF;
|
||||
|
||||
printf(" seqnum %u, type %u, idx %u, rate %u, pool %u, drops %u, input %u output %u records %u",
|
||||
EXTRACT_32BITS(sflow_flow_sample->seqnum),
|
||||
type,
|
||||
index,
|
||||
EXTRACT_32BITS(sflow_flow_sample->rate),
|
||||
EXTRACT_32BITS(sflow_flow_sample->pool),
|
||||
EXTRACT_32BITS(sflow_flow_sample->drops),
|
||||
EXTRACT_32BITS(sflow_flow_sample->in_interface),
|
||||
EXTRACT_32BITS(sflow_flow_sample->out_interface),
|
||||
nrecords);
|
||||
|
||||
return sflow_print_flow_records(pointer + sizeof(struct sflow_flow_sample_t),
|
||||
len - sizeof(struct sflow_flow_sample_t),
|
||||
nrecords);
|
||||
|
||||
}
|
||||
|
||||
static int
|
||||
sflow_print_expanded_flow_sample(const u_char *pointer, u_int len) {
|
||||
|
||||
const struct sflow_expanded_flow_sample_t *sflow_expanded_flow_sample;
|
||||
u_int nrecords;
|
||||
|
||||
if (len < sizeof(struct sflow_expanded_flow_sample_t))
|
||||
return 1;
|
||||
|
||||
sflow_expanded_flow_sample = (const struct sflow_expanded_flow_sample_t *)pointer;
|
||||
|
||||
nrecords = EXTRACT_32BITS(sflow_expanded_flow_sample->records);
|
||||
|
||||
printf(" seqnum %u, type %u, idx %u, rate %u, pool %u, drops %u, records %u",
|
||||
EXTRACT_32BITS(sflow_expanded_flow_sample->seqnum),
|
||||
EXTRACT_32BITS(sflow_expanded_flow_sample->type),
|
||||
EXTRACT_32BITS(sflow_expanded_flow_sample->index),
|
||||
EXTRACT_32BITS(sflow_expanded_flow_sample->rate),
|
||||
EXTRACT_32BITS(sflow_expanded_flow_sample->pool),
|
||||
EXTRACT_32BITS(sflow_expanded_flow_sample->drops),
|
||||
EXTRACT_32BITS(sflow_expanded_flow_sample->records));
|
||||
|
||||
return sflow_print_flow_records(pointer + sizeof(struct sflow_expanded_flow_sample_t),
|
||||
len - sizeof(struct sflow_expanded_flow_sample_t),
|
||||
nrecords);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
sflow_print(const u_char *pptr, u_int len) {
|
||||
|
||||
const struct sflow_datagram_t *sflow_datagram;
|
||||
const struct sflow_sample_header *sflow_sample;
|
||||
const struct sflow_expanded_flow_sample_t *sflow_expanded_flow_sample;
|
||||
const struct sflow_expanded_flow_raw_t *sflow_flow_raw;
|
||||
const struct sflow_expanded_counter_sample_t *sflow_expanded_counter_sample;
|
||||
const struct sflow_generic_counter_t *sflow_gen_counter;
|
||||
const struct sflow_ethernet_counter_t *sflow_eth_counter;
|
||||
const struct sflow_100basevg_counter_t *sflow_100basevg_counter;
|
||||
const struct sflow_vlan_counter_t *sflow_vlan_counter;
|
||||
const u_char *tptr;
|
||||
int tlen;
|
||||
u_int32_t sflow_sample_type, sflow_sample_len;
|
||||
int nsamples, nrecords, counter_len, counter_type, flow_len, flow_type;
|
||||
|
||||
tptr=pptr;
|
||||
const u_char *tptr;
|
||||
u_int tlen;
|
||||
u_int32_t sflow_sample_type, sflow_sample_len;
|
||||
u_int32_t nsamples;
|
||||
|
||||
|
||||
tptr = pptr;
|
||||
tlen = len;
|
||||
sflow_datagram = (const struct sflow_datagram_t *)pptr;
|
||||
TCHECK(*sflow_datagram);
|
||||
@ -313,16 +858,21 @@ sflow_print(const u_char *pptr, u_int len) {
|
||||
len);
|
||||
|
||||
/* skip Common header */
|
||||
tptr+=sizeof(const struct sflow_datagram_t);
|
||||
tlen-=sizeof(const struct sflow_datagram_t);
|
||||
tptr += sizeof(const struct sflow_datagram_t);
|
||||
tlen -= sizeof(const struct sflow_datagram_t);
|
||||
|
||||
while (nsamples > 0 && tlen > 0) {
|
||||
sflow_sample = (const struct sflow_sample_header *)tptr;
|
||||
TCHECK(*sflow_sample);
|
||||
|
||||
sflow_sample_type = (EXTRACT_32BITS(sflow_sample->format)&0x0FFF);
|
||||
sflow_sample_len = EXTRACT_32BITS(sflow_sample->len);
|
||||
|
||||
tptr+=sizeof(struct sflow_sample_header);
|
||||
tlen-=sizeof(struct sflow_sample_header);
|
||||
if (tlen < sizeof(struct sflow_sample_header))
|
||||
goto trunc;
|
||||
|
||||
tptr += sizeof(struct sflow_sample_header);
|
||||
tlen -= sizeof(struct sflow_sample_header);
|
||||
|
||||
printf("\n\t%s (%u), length %u,",
|
||||
tok2str(sflow_format_values, "Unknown", sflow_sample_type),
|
||||
@ -334,226 +884,33 @@ sflow_print(const u_char *pptr, u_int len) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (tlen < sflow_sample_len)
|
||||
goto trunc;
|
||||
|
||||
/* did we capture enough for fully decoding the sample ? */
|
||||
if (!TTEST2(*tptr, sflow_sample_len))
|
||||
goto trunc;
|
||||
TCHECK2(*tptr, sflow_sample_len);
|
||||
|
||||
switch(sflow_sample_type) {
|
||||
case SFLOW_FLOW_SAMPLE: /* XXX */
|
||||
case SFLOW_FLOW_SAMPLE:
|
||||
if (sflow_print_flow_sample(tptr,tlen))
|
||||
goto trunc;
|
||||
break;
|
||||
|
||||
case SFLOW_COUNTER_SAMPLE: /* XXX */
|
||||
case SFLOW_COUNTER_SAMPLE:
|
||||
if (sflow_print_counter_sample(tptr,tlen))
|
||||
goto trunc;
|
||||
break;
|
||||
|
||||
case SFLOW_EXPANDED_FLOW_SAMPLE:
|
||||
sflow_expanded_flow_sample = (const struct sflow_expanded_flow_sample_t *)tptr;
|
||||
nrecords = EXTRACT_32BITS(sflow_expanded_flow_sample->records);
|
||||
|
||||
printf(" seqnum %u, type %u, idx %u, rate %u, pool %u, drops %u, records %u",
|
||||
EXTRACT_32BITS(sflow_expanded_flow_sample->seqnum),
|
||||
EXTRACT_32BITS(sflow_expanded_flow_sample->type),
|
||||
EXTRACT_32BITS(sflow_expanded_flow_sample->index),
|
||||
EXTRACT_32BITS(sflow_expanded_flow_sample->rate),
|
||||
EXTRACT_32BITS(sflow_expanded_flow_sample->pool),
|
||||
EXTRACT_32BITS(sflow_expanded_flow_sample->drops),
|
||||
EXTRACT_32BITS(sflow_expanded_flow_sample->records));
|
||||
|
||||
tptr+= sizeof(struct sflow_expanded_flow_sample_t);
|
||||
tlen-= sizeof(struct sflow_expanded_flow_sample_t);
|
||||
|
||||
while ( nrecords > 0 && tlen > 0) {
|
||||
|
||||
/* decode Flow record - 2 bytes */
|
||||
flow_type = EXTRACT_32BITS(tptr)&0x0FFF;
|
||||
flow_len = EXTRACT_32BITS(tptr+4);
|
||||
printf("\n\t %s (%u) length %u",
|
||||
tok2str(sflow_flow_type_values,"Unknown",flow_type),
|
||||
flow_type,
|
||||
flow_len);
|
||||
|
||||
tptr += 8;
|
||||
tlen -= 8;
|
||||
|
||||
/* did we capture enough for fully decoding the flow ? */
|
||||
if (!TTEST2(*tptr, flow_len))
|
||||
goto trunc;
|
||||
|
||||
switch(flow_type) {
|
||||
case SFLOW_FLOW_RAW_PACKET:
|
||||
sflow_flow_raw = (const struct sflow_expanded_flow_raw_t *)tptr;
|
||||
printf("\n\t protocol %s (%u), length %u, stripped bytes %u, header_size %u",
|
||||
tok2str(sflow_flow_raw_protocol_values,"Unknown",EXTRACT_32BITS(sflow_flow_raw->protocol)),
|
||||
EXTRACT_32BITS(sflow_flow_raw->protocol),
|
||||
EXTRACT_32BITS(sflow_flow_raw->length),
|
||||
EXTRACT_32BITS(sflow_flow_raw->stripped_bytes),
|
||||
EXTRACT_32BITS(sflow_flow_raw->header_size));
|
||||
break;
|
||||
|
||||
/*
|
||||
* FIXME those are the defined flow types that lack a decoder
|
||||
*/
|
||||
case SFLOW_FLOW_ETHERNET_FRAME:
|
||||
case SFLOW_FLOW_IPV4_DATA:
|
||||
case SFLOW_FLOW_IPV6_DATA:
|
||||
case SFLOW_FLOW_EXTENDED_SWITCH_DATA:
|
||||
case SFLOW_FLOW_EXTENDED_ROUTER_DATA:
|
||||
case SFLOW_FLOW_EXTENDED_GATEWAY_DATA:
|
||||
case SFLOW_FLOW_EXTENDED_USER_DATA:
|
||||
case SFLOW_FLOW_EXTENDED_URL_DATA:
|
||||
case SFLOW_FLOW_EXTENDED_MPLS_DATA:
|
||||
case SFLOW_FLOW_EXTENDED_NAT_DATA:
|
||||
case SFLOW_FLOW_EXTENDED_MPLS_TUNNEL:
|
||||
case SFLOW_FLOW_EXTENDED_MPLS_VC:
|
||||
case SFLOW_FLOW_EXTENDED_MPLS_FEC:
|
||||
case SFLOW_FLOW_EXTENDED_MPLS_LVP_FEC:
|
||||
case SFLOW_FLOW_EXTENDED_VLAN_TUNNEL:
|
||||
break;
|
||||
default:
|
||||
if (vflag <= 1)
|
||||
print_unknown_data(tptr, "\n\t ", flow_len);
|
||||
break;
|
||||
|
||||
}
|
||||
tptr += flow_len;
|
||||
tlen -= flow_len;
|
||||
nrecords--;
|
||||
}
|
||||
break;
|
||||
if (sflow_print_expanded_flow_sample(tptr,tlen))
|
||||
goto trunc;
|
||||
break;
|
||||
|
||||
case SFLOW_EXPANDED_COUNTER_SAMPLE:
|
||||
sflow_expanded_counter_sample = (const struct sflow_expanded_counter_sample_t *)tptr;
|
||||
nrecords = EXTRACT_32BITS(sflow_expanded_counter_sample->records);
|
||||
if (sflow_print_expanded_counter_sample(tptr,tlen))
|
||||
goto trunc;
|
||||
break;
|
||||
|
||||
printf(" seqnum %u, type %u, idx %u, records %u",
|
||||
EXTRACT_32BITS(sflow_expanded_counter_sample->seqnum),
|
||||
EXTRACT_32BITS(sflow_expanded_counter_sample->type),
|
||||
EXTRACT_32BITS(sflow_expanded_counter_sample->index),
|
||||
nrecords);
|
||||
|
||||
tptr+= sizeof(struct sflow_expanded_counter_sample_t);
|
||||
tlen-= sizeof(struct sflow_expanded_counter_sample_t);
|
||||
|
||||
while ( nrecords > 0 && tlen > 0) {
|
||||
|
||||
/* decode counter record - 2 bytes */
|
||||
counter_type = EXTRACT_32BITS(tptr)&0x0FFF;
|
||||
counter_len = EXTRACT_32BITS(tptr+4);
|
||||
printf("\n\t %s (%u) length %u",
|
||||
tok2str(sflow_counter_type_values,"Unknown",counter_type),
|
||||
counter_type,
|
||||
counter_len);
|
||||
|
||||
tptr += 8;
|
||||
tlen -= 8;
|
||||
|
||||
/* did we capture enough for fully decoding the counter ? */
|
||||
if (!TTEST2(*tptr, counter_len))
|
||||
goto trunc;
|
||||
|
||||
switch(counter_type) {
|
||||
case SFLOW_COUNTER_GENERIC:
|
||||
sflow_gen_counter = (const struct sflow_generic_counter_t *)tptr;
|
||||
printf("\n\t ifindex %u, iftype %u, ifspeed %u, ifdirection %u (%s)",
|
||||
EXTRACT_32BITS(sflow_gen_counter->ifindex),
|
||||
EXTRACT_32BITS(sflow_gen_counter->iftype),
|
||||
EXTRACT_32BITS(sflow_gen_counter->ifspeed),
|
||||
EXTRACT_32BITS(sflow_gen_counter->ifdirection),
|
||||
tok2str(sflow_iface_direction_values, "Unknown",
|
||||
EXTRACT_32BITS(sflow_gen_counter->ifdirection)));
|
||||
printf("\n\t ifstatus %u, adminstatus: %s, operstatus: %s",
|
||||
EXTRACT_32BITS(sflow_gen_counter->ifstatus),
|
||||
EXTRACT_32BITS(sflow_gen_counter->ifstatus)&1 ? "up" : "down",
|
||||
(EXTRACT_32BITS(sflow_gen_counter->ifstatus)>>1)&1 ? "up" : "down");
|
||||
printf("\n\t In octets %" PRIu64
|
||||
", unicast pkts %u, multicast pkts %u, broadcast pkts %u, discards %u",
|
||||
EXTRACT_64BITS(sflow_gen_counter->ifinoctets),
|
||||
EXTRACT_32BITS(sflow_gen_counter->ifinunicastpkts),
|
||||
EXTRACT_32BITS(sflow_gen_counter->ifinmulticastpkts),
|
||||
EXTRACT_32BITS(sflow_gen_counter->ifinbroadcastpkts),
|
||||
EXTRACT_32BITS(sflow_gen_counter->ifindiscards));
|
||||
printf("\n\t In errors %u, unknown protos %u",
|
||||
EXTRACT_32BITS(sflow_gen_counter->ifinerrors),
|
||||
EXTRACT_32BITS(sflow_gen_counter->ifinunkownprotos));
|
||||
printf("\n\t Out octets %" PRIu64
|
||||
", unicast pkts %u, multicast pkts %u, broadcast pkts %u, discards %u",
|
||||
EXTRACT_64BITS(sflow_gen_counter->ifoutoctets),
|
||||
EXTRACT_32BITS(sflow_gen_counter->ifoutunicastpkts),
|
||||
EXTRACT_32BITS(sflow_gen_counter->ifoutmulticastpkts),
|
||||
EXTRACT_32BITS(sflow_gen_counter->ifoutbroadcastpkts),
|
||||
EXTRACT_32BITS(sflow_gen_counter->ifoutdiscards));
|
||||
printf("\n\t Out errors %u, promisc mode %u",
|
||||
EXTRACT_32BITS(sflow_gen_counter->ifouterrors),
|
||||
EXTRACT_32BITS(sflow_gen_counter->ifpromiscmode));
|
||||
break;
|
||||
case SFLOW_COUNTER_ETHERNET:
|
||||
sflow_eth_counter = (const struct sflow_ethernet_counter_t *)tptr;
|
||||
printf("\n\t align errors %u, fcs errors %u, single collision %u, multiple collision %u, test error %u",
|
||||
EXTRACT_32BITS(sflow_eth_counter->alignerrors),
|
||||
EXTRACT_32BITS(sflow_eth_counter->fcserrors),
|
||||
EXTRACT_32BITS(sflow_eth_counter->single_collision_frames),
|
||||
EXTRACT_32BITS(sflow_eth_counter->multiple_collision_frames),
|
||||
EXTRACT_32BITS(sflow_eth_counter->test_errors));
|
||||
printf("\n\t deferred %u, late collision %u, excessive collision %u, mac trans error %u",
|
||||
EXTRACT_32BITS(sflow_eth_counter->deferred_transmissions),
|
||||
EXTRACT_32BITS(sflow_eth_counter->late_collisions),
|
||||
EXTRACT_32BITS(sflow_eth_counter->excessive_collisions),
|
||||
EXTRACT_32BITS(sflow_eth_counter->mac_transmit_errors));
|
||||
printf("\n\t carrier error %u, frames too long %u, mac receive errors %u, symbol errors %u",
|
||||
EXTRACT_32BITS(sflow_eth_counter->carrier_sense_errors),
|
||||
EXTRACT_32BITS(sflow_eth_counter->frame_too_longs),
|
||||
EXTRACT_32BITS(sflow_eth_counter->mac_receive_errors),
|
||||
EXTRACT_32BITS(sflow_eth_counter->symbol_errors));
|
||||
break;
|
||||
case SFLOW_COUNTER_TOKEN_RING: /* XXX */
|
||||
break;
|
||||
case SFLOW_COUNTER_BASEVG:
|
||||
sflow_100basevg_counter = (const struct sflow_100basevg_counter_t *)tptr;
|
||||
printf("\n\t in high prio frames %u, in high prio octets %" PRIu64,
|
||||
EXTRACT_32BITS(sflow_100basevg_counter->in_highpriority_frames),
|
||||
EXTRACT_64BITS(sflow_100basevg_counter->in_highpriority_octets));
|
||||
printf("\n\t in norm prio frames %u, in norm prio octets %" PRIu64,
|
||||
EXTRACT_32BITS(sflow_100basevg_counter->in_normpriority_frames),
|
||||
EXTRACT_64BITS(sflow_100basevg_counter->in_normpriority_octets));
|
||||
printf("\n\t in ipm errors %u, oversized %u, in data errors %u, null addressed frames %u",
|
||||
EXTRACT_32BITS(sflow_100basevg_counter->in_ipmerrors),
|
||||
EXTRACT_32BITS(sflow_100basevg_counter->in_oversized),
|
||||
EXTRACT_32BITS(sflow_100basevg_counter->in_data_errors),
|
||||
EXTRACT_32BITS(sflow_100basevg_counter->in_null_addressed_frames));
|
||||
printf("\n\t out high prio frames %u, out high prio octets %" PRIu64
|
||||
", trans into frames %u",
|
||||
EXTRACT_32BITS(sflow_100basevg_counter->out_highpriority_frames),
|
||||
EXTRACT_64BITS(sflow_100basevg_counter->out_highpriority_octets),
|
||||
EXTRACT_32BITS(sflow_100basevg_counter->transitioninto_frames));
|
||||
printf("\n\t in hc high prio octets %" PRIu64
|
||||
", in hc norm prio octets %" PRIu64
|
||||
", out hc high prio octets %" PRIu64,
|
||||
EXTRACT_64BITS(sflow_100basevg_counter->hc_in_highpriority_octets),
|
||||
EXTRACT_64BITS(sflow_100basevg_counter->hc_in_normpriority_octets),
|
||||
EXTRACT_64BITS(sflow_100basevg_counter->hc_out_highpriority_octets));
|
||||
break;
|
||||
case SFLOW_COUNTER_VLAN:
|
||||
sflow_vlan_counter = (const struct sflow_vlan_counter_t *)tptr;
|
||||
printf("\n\t vlan_id %u, octets %" PRIu64
|
||||
", unicast_pkt %u, multicast_pkt %u, broadcast_pkt %u, discards %u",
|
||||
EXTRACT_32BITS(sflow_vlan_counter->vlan_id),
|
||||
EXTRACT_64BITS(sflow_vlan_counter->octets),
|
||||
EXTRACT_32BITS(sflow_vlan_counter->unicast_pkt),
|
||||
EXTRACT_32BITS(sflow_vlan_counter->multicast_pkt),
|
||||
EXTRACT_32BITS(sflow_vlan_counter->broadcast_pkt),
|
||||
EXTRACT_32BITS(sflow_vlan_counter->discards));
|
||||
break;
|
||||
case SFLOW_COUNTER_PROCESSOR: /* XXX */
|
||||
break;
|
||||
default:
|
||||
if (vflag <= 1)
|
||||
print_unknown_data(tptr, "\n\t\t", counter_len);
|
||||
break;
|
||||
}
|
||||
tptr += counter_len;
|
||||
tlen -= counter_len;
|
||||
nrecords--;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (vflag <= 1)
|
||||
print_unknown_data(tptr, "\n\t ", sflow_sample_len);
|
||||
|
@ -73,7 +73,7 @@ sl_if_print(const struct pcap_pkthdr *h, const u_char *p)
|
||||
break;
|
||||
#ifdef INET6
|
||||
case 6:
|
||||
ip6_print((u_char *)ip, length);
|
||||
ip6_print(gndo, (u_char *)ip, length);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
|
@ -218,7 +218,7 @@ sll_if_print(const struct pcap_pkthdr *h, const u_char *p)
|
||||
caplen -= 4;
|
||||
goto recurse;
|
||||
} else {
|
||||
if (ethertype_print(ether_type, p, length, caplen) == 0) {
|
||||
if (ethertype_print(gndo, ether_type, p, length, caplen) == 0) {
|
||||
/* ether_type not known, print raw packet */
|
||||
if (!eflag)
|
||||
sll_print(sllp, length + SLL_HDR_LEN);
|
||||
|
@ -368,7 +368,7 @@ void slow_marker_lacp_print(register const u_char *tptr, register u_int tlen) {
|
||||
tlv_header->type != LACP_TLV_TERMINATOR &&
|
||||
tlv_header->type != MARKER_TLV_TERMINATOR) {
|
||||
printf("\n\t-----trailing data-----");
|
||||
print_unknown_data(tptr+sizeof(sizeof(struct tlv_header_t)),"\n\t ",tlen);
|
||||
print_unknown_data(tptr+sizeof(struct tlv_header_t),"\n\t ",tlen);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -441,7 +441,7 @@ void slow_marker_lacp_print(register const u_char *tptr, register u_int tlen) {
|
||||
}
|
||||
/* do we want to see an additional hexdump ? */
|
||||
if (vflag > 1) {
|
||||
print_unknown_data(tptr+sizeof(sizeof(struct tlv_header_t)),"\n\t ",
|
||||
print_unknown_data(tptr+sizeof(struct tlv_header_t),"\n\t ",
|
||||
tlv_len-sizeof(struct tlv_header_t));
|
||||
}
|
||||
|
||||
|
@ -45,12 +45,12 @@ static const char rcsid[] _U_ =
|
||||
|
||||
#include <tcpdump-stdinc.h>
|
||||
|
||||
#ifdef HAVE_GETRPCBYNUMBER
|
||||
#if defined(HAVE_GETRPCBYNUMBER) && defined(HAVE_RPC_RPC_H)
|
||||
#include <rpc/rpc.h>
|
||||
#ifdef HAVE_RPC_RPCENT_H
|
||||
#include <rpc/rpcent.h>
|
||||
#endif /* HAVE_RPC_RPCENT_H */
|
||||
#endif /* HAVE_GETRPCBYNUMBER */
|
||||
#endif /* defined(HAVE_GETRPCBYNUMBER) && defined(HAVE_RPC_RPC_H) */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@ -151,7 +151,7 @@ static char *
|
||||
progstr(prog)
|
||||
u_int32_t prog;
|
||||
{
|
||||
#ifdef HAVE_GETRPCBYNUMBER
|
||||
#if defined(HAVE_GETRPCBYNUMBER) && defined(HAVE_RPC_RPC_H)
|
||||
register struct rpcent *rp;
|
||||
#endif
|
||||
static char buf[32];
|
||||
@ -159,12 +159,12 @@ progstr(prog)
|
||||
|
||||
if (lastprog != 0 && prog == lastprog)
|
||||
return (buf);
|
||||
#ifdef HAVE_GETRPCBYNUMBER
|
||||
#if defined(HAVE_GETRPCBYNUMBER) && defined(HAVE_RPC_RPC_H)
|
||||
rp = getrpcbynumber(prog);
|
||||
if (rp == NULL)
|
||||
#endif
|
||||
(void) snprintf(buf, sizeof(buf), "#%u", prog);
|
||||
#ifdef HAVE_GETRPCBYNUMBER
|
||||
#if defined(HAVE_GETRPCBYNUMBER) && defined(HAVE_RPC_RPC_H)
|
||||
else
|
||||
strlcpy(buf, rp->r_name, sizeof(buf));
|
||||
#endif
|
||||
|
@ -107,7 +107,7 @@ symantec_if_print(const struct pcap_pkthdr *h, const u_char *p)
|
||||
|
||||
if (!suppress_default_print)
|
||||
default_print(p, caplen);
|
||||
} else if (ethertype_print(ether_type, p, length, caplen) == 0) {
|
||||
} else if (ethertype_print(gndo, ether_type, p, length, caplen) == 0) {
|
||||
/* ether_type not known, print raw packet */
|
||||
if (!eflag)
|
||||
symantec_hdr_print((u_char *)sp, length + sizeof (struct symantec_header));
|
||||
|
95
print-tcp.c
95
print-tcp.c
@ -129,31 +129,8 @@ static int tcp_cksum(register const struct ip *ip,
|
||||
register const struct tcphdr *tp,
|
||||
register u_int len)
|
||||
{
|
||||
union phu {
|
||||
struct phdr {
|
||||
u_int32_t src;
|
||||
u_int32_t dst;
|
||||
u_char mbz;
|
||||
u_char proto;
|
||||
u_int16_t len;
|
||||
} ph;
|
||||
u_int16_t pa[6];
|
||||
} phu;
|
||||
const u_int16_t *sp;
|
||||
|
||||
/* pseudo-header.. */
|
||||
phu.ph.len = htons((u_int16_t)len);
|
||||
phu.ph.mbz = 0;
|
||||
phu.ph.proto = IPPROTO_TCP;
|
||||
memcpy(&phu.ph.src, &ip->ip_src.s_addr, sizeof(u_int32_t));
|
||||
if (IP_HL(ip) == 5)
|
||||
memcpy(&phu.ph.dst, &ip->ip_dst.s_addr, sizeof(u_int32_t));
|
||||
else
|
||||
phu.ph.dst = ip_finddst(ip);
|
||||
|
||||
sp = &phu.pa[0];
|
||||
return in_cksum((u_short *)tp, len,
|
||||
sp[0]+sp[1]+sp[2]+sp[3]+sp[4]+sp[5]);
|
||||
return (nextproto4_cksum(ip, (const u_int8_t *)tp, len,
|
||||
IPPROTO_TCP));
|
||||
}
|
||||
|
||||
void
|
||||
@ -294,7 +271,6 @@ tcp_print(register const u_char *bp, register u_int length,
|
||||
* both directions).
|
||||
*/
|
||||
#ifdef INET6
|
||||
memset(&tha, 0, sizeof(tha));
|
||||
rev = 0;
|
||||
if (ip6) {
|
||||
src = &ip6->ip6_src;
|
||||
@ -315,6 +291,27 @@ tcp_print(register const u_char *bp, register u_int length,
|
||||
tha.port = sport << 16 | dport;
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Zero out the tha structure; the src and dst
|
||||
* fields are big enough to hold an IPv6
|
||||
* address, but we only have IPv4 addresses
|
||||
* and thus must clear out the remaining 124
|
||||
* bits.
|
||||
*
|
||||
* XXX - should we just clear those bytes after
|
||||
* copying the IPv4 addresses, rather than
|
||||
* zeroing out the entire structure and then
|
||||
* overwriting some of the zeroes?
|
||||
*
|
||||
* XXX - this could fail if we see TCP packets
|
||||
* with an IPv6 address with the lower 124 bits
|
||||
* all zero and also see TCP packes with an
|
||||
* IPv4 address with the same 32 bits as the
|
||||
* upper 32 bits of the IPv6 address in question.
|
||||
* Can that happen? Is it likely enough to be
|
||||
* an issue?
|
||||
*/
|
||||
memset(&tha, 0, sizeof(tha));
|
||||
src = &ip->ip_src;
|
||||
dst = &ip->ip_dst;
|
||||
if (sport > dport)
|
||||
@ -393,34 +390,40 @@ tcp_print(register const u_char *bp, register u_int length,
|
||||
return;
|
||||
}
|
||||
|
||||
if (IP_V(ip) == 4 && vflag && !Kflag && !fragmented) {
|
||||
if (vflag && !Kflag && !fragmented) {
|
||||
/* Check the checksum, if possible. */
|
||||
u_int16_t sum, tcp_sum;
|
||||
if (TTEST2(tp->th_sport, length)) {
|
||||
sum = tcp_cksum(ip, tp, length);
|
||||
|
||||
(void)printf(", cksum 0x%04x",EXTRACT_16BITS(&tp->th_sum));
|
||||
if (sum != 0) {
|
||||
if (IP_V(ip) == 4) {
|
||||
if (TTEST2(tp->th_sport, length)) {
|
||||
sum = tcp_cksum(ip, tp, length);
|
||||
tcp_sum = EXTRACT_16BITS(&tp->th_sum);
|
||||
(void)printf(" (incorrect -> 0x%04x)",in_cksum_shouldbe(tcp_sum, sum));
|
||||
} else
|
||||
(void)printf(" (correct)");
|
||||
|
||||
(void)printf(", cksum 0x%04x", tcp_sum);
|
||||
if (sum != 0)
|
||||
(void)printf(" (incorrect -> 0x%04x)",
|
||||
in_cksum_shouldbe(tcp_sum, sum));
|
||||
else
|
||||
(void)printf(" (correct)");
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef INET6
|
||||
if (IP_V(ip) == 6 && ip6->ip6_plen && vflag && !Kflag && !fragmented) {
|
||||
u_int16_t sum,tcp_sum;
|
||||
if (TTEST2(tp->th_sport, length)) {
|
||||
sum = nextproto6_cksum(ip6, (u_short *)tp, length, IPPROTO_TCP);
|
||||
(void)printf(", cksum 0x%04x",EXTRACT_16BITS(&tp->th_sum));
|
||||
if (sum != 0) {
|
||||
else if (IP_V(ip) == 6 && ip6->ip6_plen) {
|
||||
if (TTEST2(tp->th_sport, length)) {
|
||||
sum = nextproto6_cksum(ip6, (const u_int8_t *)tp, length, IPPROTO_TCP);
|
||||
tcp_sum = EXTRACT_16BITS(&tp->th_sum);
|
||||
(void)printf(" (incorrect -> 0x%04x)",in_cksum_shouldbe(tcp_sum, sum));
|
||||
} else
|
||||
(void)printf(" (correct)");
|
||||
|
||||
(void)printf(", cksum 0x%04x", tcp_sum);
|
||||
if (sum != 0)
|
||||
(void)printf(" (incorrect -> 0x%04x)",
|
||||
in_cksum_shouldbe(tcp_sum, sum));
|
||||
else
|
||||
(void)printf(" (correct)");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
length -= hlen;
|
||||
if (vflag > 1 || length > 0 || flags & (TH_SYN | TH_FIN | TH_RST)) {
|
||||
@ -661,6 +664,8 @@ tcp_print(register const u_char *bp, register u_int length,
|
||||
ns_print(bp + 2, length - 2, 0);
|
||||
} else if (sport == MSDP_PORT || dport == MSDP_PORT) {
|
||||
msdp_print(bp, length);
|
||||
} else if (sport == RPKI_RTR_PORT || dport == RPKI_RTR_PORT) {
|
||||
rpki_rtr_print(bp, length);
|
||||
}
|
||||
else if (length > 0 && (sport == LDP_PORT || dport == LDP_PORT)) {
|
||||
ldp_print(bp, length);
|
||||
|
@ -99,15 +99,7 @@ tftp_print(register const u_char *bp, u_int length)
|
||||
case RRQ:
|
||||
case WRQ:
|
||||
case OACK:
|
||||
/*
|
||||
* XXX Not all arpa/tftp.h's specify th_stuff as any
|
||||
* array; use address of th_block instead
|
||||
*/
|
||||
#ifdef notdef
|
||||
p = (u_char *)tp->th_stuff;
|
||||
#else
|
||||
p = (u_char *)&tp->th_block;
|
||||
#endif
|
||||
putchar(' ');
|
||||
/* Print filename or first option */
|
||||
if (opcode != OACK)
|
||||
|
130
print-udp.c
130
print-udp.c
@ -33,7 +33,6 @@ static const char rcsid[] _U_ =
|
||||
#ifdef SEGSIZE
|
||||
#undef SEGSIZE
|
||||
#endif
|
||||
#include <arpa/tftp.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@ -287,75 +286,16 @@ static int udp_cksum(register const struct ip *ip,
|
||||
register const struct udphdr *up,
|
||||
register u_int len)
|
||||
{
|
||||
union phu {
|
||||
struct phdr {
|
||||
u_int32_t src;
|
||||
u_int32_t dst;
|
||||
u_char mbz;
|
||||
u_char proto;
|
||||
u_int16_t len;
|
||||
} ph;
|
||||
u_int16_t pa[6];
|
||||
} phu;
|
||||
register const u_int16_t *sp;
|
||||
|
||||
/* pseudo-header.. */
|
||||
phu.ph.len = htons((u_int16_t)len);
|
||||
phu.ph.mbz = 0;
|
||||
phu.ph.proto = IPPROTO_UDP;
|
||||
memcpy(&phu.ph.src, &ip->ip_src.s_addr, sizeof(u_int32_t));
|
||||
if (IP_HL(ip) == 5)
|
||||
memcpy(&phu.ph.dst, &ip->ip_dst.s_addr, sizeof(u_int32_t));
|
||||
else
|
||||
phu.ph.dst = ip_finddst(ip);
|
||||
|
||||
sp = &phu.pa[0];
|
||||
return in_cksum((u_short *)up, len,
|
||||
sp[0]+sp[1]+sp[2]+sp[3]+sp[4]+sp[5]);
|
||||
return (nextproto4_cksum(ip, (const u_int8_t *)(void *)up, len,
|
||||
IPPROTO_UDP));
|
||||
}
|
||||
|
||||
#ifdef INET6
|
||||
static int udp6_cksum(const struct ip6_hdr *ip6, const struct udphdr *up,
|
||||
u_int len)
|
||||
{
|
||||
size_t i;
|
||||
register const u_int16_t *sp;
|
||||
u_int32_t sum;
|
||||
union {
|
||||
struct {
|
||||
struct in6_addr ph_src;
|
||||
struct in6_addr ph_dst;
|
||||
u_int32_t ph_len;
|
||||
u_int8_t ph_zero[3];
|
||||
u_int8_t ph_nxt;
|
||||
} ph;
|
||||
u_int16_t pa[20];
|
||||
} phu;
|
||||
|
||||
/* pseudo-header */
|
||||
memset(&phu, 0, sizeof(phu));
|
||||
phu.ph.ph_src = ip6->ip6_src;
|
||||
phu.ph.ph_dst = ip6->ip6_dst;
|
||||
phu.ph.ph_len = htonl(len);
|
||||
phu.ph.ph_nxt = IPPROTO_UDP;
|
||||
|
||||
sum = 0;
|
||||
for (i = 0; i < sizeof(phu.pa) / sizeof(phu.pa[0]); i++)
|
||||
sum += phu.pa[i];
|
||||
|
||||
sp = (const u_int16_t *)up;
|
||||
|
||||
for (i = 0; i < (len & ~1); i += 2)
|
||||
sum += *sp++;
|
||||
|
||||
if (len & 1)
|
||||
sum += htons((*(const u_int8_t *)sp) << 8);
|
||||
|
||||
while (sum > 0xffff)
|
||||
sum = (sum & 0xffff) + (sum >> 16);
|
||||
sum = ~sum & 0xffff;
|
||||
|
||||
return (sum);
|
||||
return (nextproto6_cksum(ip6, (const u_int8_t *)(void *)up, len,
|
||||
IPPROTO_UDP));
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -568,31 +508,46 @@ udp_print(register const u_char *bp, u_int length,
|
||||
}
|
||||
udpipaddr_print(ip, sport, dport);
|
||||
|
||||
if (IP_V(ip) == 4 && (vflag > 1) && !Kflag && !fragmented) {
|
||||
int sum = up->uh_sum;
|
||||
if (sum == 0) {
|
||||
(void)printf("[no cksum] ");
|
||||
} else if (TTEST2(cp[0], length)) {
|
||||
sum = udp_cksum(ip, up, length + sizeof(struct udphdr));
|
||||
if (sum != 0)
|
||||
(void)printf("[bad udp cksum %x!] ", sum);
|
||||
else
|
||||
(void)printf("[udp sum ok] ");
|
||||
if (vflag && !Kflag && !fragmented) {
|
||||
/* Check the checksum, if possible. */
|
||||
u_int16_t sum, udp_sum;
|
||||
|
||||
/*
|
||||
* XXX - do this even if vflag == 1?
|
||||
* TCP does, and we do so for UDP-over-IPv6.
|
||||
*/
|
||||
if (IP_V(ip) == 4 && (vflag > 1)) {
|
||||
udp_sum = EXTRACT_16BITS(&up->uh_sum);
|
||||
if (udp_sum == 0) {
|
||||
(void)printf("[no cksum] ");
|
||||
} else if (TTEST2(cp[0], length)) {
|
||||
sum = udp_cksum(ip, up, length + sizeof(struct udphdr));
|
||||
|
||||
if (sum != 0) {
|
||||
(void)printf("[bad udp cksum 0x%04x -> 0x%04x!] ",
|
||||
udp_sum,
|
||||
in_cksum_shouldbe(udp_sum, sum));
|
||||
} else
|
||||
(void)printf("[udp sum ok] ");
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef INET6
|
||||
if (IP_V(ip) == 6 && ip6->ip6_plen && vflag && !Kflag && !fragmented) {
|
||||
int sum = up->uh_sum;
|
||||
/* for IPv6, UDP checksum is mandatory */
|
||||
if (TTEST2(cp[0], length)) {
|
||||
sum = udp6_cksum(ip6, up, length + sizeof(struct udphdr));
|
||||
if (sum != 0)
|
||||
(void)printf("[bad udp cksum %x!] ", sum);
|
||||
else
|
||||
(void)printf("[udp sum ok] ");
|
||||
else if (IP_V(ip) == 6 && ip6->ip6_plen) {
|
||||
/* for IPv6, UDP checksum is mandatory */
|
||||
if (TTEST2(cp[0], length)) {
|
||||
sum = udp6_cksum(ip6, up, length + sizeof(struct udphdr));
|
||||
udp_sum = EXTRACT_16BITS(&up->uh_sum);
|
||||
|
||||
if (sum != 0) {
|
||||
(void)printf("[bad udp cksum 0x%04x -> 0x%04x!] ",
|
||||
udp_sum,
|
||||
in_cksum_shouldbe(udp_sum, sum));
|
||||
} else
|
||||
(void)printf("[udp sum ok] ");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!qflag) {
|
||||
#define ISPORT(p) (dport == (p) || sport == (p))
|
||||
@ -652,9 +607,10 @@ udp_print(register const u_char *bp, u_int length,
|
||||
#ifdef INET6
|
||||
else if (ISPORT(RIPNG_PORT))
|
||||
ripng_print((const u_char *)(up + 1), length);
|
||||
else if (ISPORT(DHCP6_SERV_PORT) || ISPORT(DHCP6_CLI_PORT)) {
|
||||
else if (ISPORT(DHCP6_SERV_PORT) || ISPORT(DHCP6_CLI_PORT))
|
||||
dhcp6_print((const u_char *)(up + 1), length);
|
||||
}
|
||||
else if (ISPORT(BABEL_PORT) || ISPORT(BABEL_PORT_OLD))
|
||||
babel_print((const u_char *)(up + 1), length);
|
||||
#endif /*INET6*/
|
||||
/*
|
||||
* Kludge in test for whiteboard packets.
|
||||
|
12
print-vrrp.c
12
print-vrrp.c
@ -110,9 +110,15 @@ vrrp_print(register const u_char *bp, register u_int len, int ttl)
|
||||
int i;
|
||||
char c;
|
||||
|
||||
if (TTEST2(bp[0], len) && in_cksum((const u_short*)bp, len, 0))
|
||||
printf(", (bad vrrp cksum %x)",
|
||||
EXTRACT_16BITS(&bp[6]));
|
||||
if (TTEST2(bp[0], len)) {
|
||||
struct cksum_vec vec[1];
|
||||
|
||||
vec[0].ptr = bp;
|
||||
vec[0].len = len;
|
||||
if (in_cksum(vec, 1))
|
||||
printf(", (bad vrrp cksum %x)",
|
||||
EXTRACT_16BITS(&bp[6]));
|
||||
}
|
||||
printf(", addrs");
|
||||
if (naddrs > 1)
|
||||
printf("(%d)", naddrs);
|
||||
|
1
tcp.h
1
tcp.h
@ -105,6 +105,7 @@ struct tcphdr {
|
||||
#define NFS_PORT 2049
|
||||
#endif
|
||||
#define MSDP_PORT 639
|
||||
#define RPKI_RTR_PORT 2222 /* experimental up until sidr-wg registers a well-known port */
|
||||
#define LDP_PORT 646
|
||||
#ifndef SMB_PORT
|
||||
#define SMB_PORT 445
|
||||
|
@ -131,10 +131,43 @@ typedef char* caddr_t;
|
||||
|
||||
#endif /* WIN32 */
|
||||
|
||||
#ifdef INET6
|
||||
#include "ip6.h"
|
||||
#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)).
|
||||
*/
|
||||
#define UNALIGNED __attribute__((packed))
|
||||
|
||||
#if defined(WIN32) || defined(MSDOS)
|
||||
#define FOPEN_READ_TXT "rt"
|
||||
#define FOPEN_READ_BIN "rb"
|
||||
@ -147,7 +180,7 @@ typedef char* caddr_t;
|
||||
#define FOPEN_WRITE_BIN FOPEN_WRITE_TXT
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && defined(__i386__) && !defined(__ntohl)
|
||||
#if defined(__GNUC__) && defined(__i386__) && !defined(__APPLE__) && !defined(__ntohl)
|
||||
#undef ntohl
|
||||
#undef ntohs
|
||||
#undef htonl
|
||||
|
51
tcpdump.1.in
51
tcpdump.1.in
@ -29,7 +29,7 @@ tcpdump \- dump traffic on a network
|
||||
.na
|
||||
.B tcpdump
|
||||
[
|
||||
.B \-AbdDefIKlLnNOpqRStuUvxX
|
||||
.B \-AbdDefhHIJKlLnNOpqRStuUvxX
|
||||
] [
|
||||
.B \-B
|
||||
.I buffer_size
|
||||
@ -56,6 +56,10 @@ tcpdump \- dump traffic on a network
|
||||
.I interface
|
||||
]
|
||||
[
|
||||
.B \-j
|
||||
.I tstamp_type
|
||||
]
|
||||
[
|
||||
.B \-m
|
||||
.I module
|
||||
]
|
||||
@ -256,7 +260,7 @@ Print the link-level header on each dump line.
|
||||
.B \-E
|
||||
Use \fIspi@ipaddr algo:secret\fP for decrypting IPsec ESP packets that
|
||||
are addressed to \fIaddr\fP and contain Security Parameter Index value
|
||||
\fIspi\fP. This combination may be repeated with comma or newline seperation.
|
||||
\fIspi\fP. This combination may be repeated with comma or newline separation.
|
||||
.IP
|
||||
Note that setting the secret for IPv4 ESP packets is supported at this time.
|
||||
.IP
|
||||
@ -272,7 +276,7 @@ The ability to decrypt packets is only present if \fItcpdump\fP was compiled
|
||||
with cryptography enabled.
|
||||
.IP
|
||||
\fIsecret\fP is the ASCII text for ESP secret key.
|
||||
If preceeded by 0x, then a hex value will be read.
|
||||
If preceded by 0x, then a hex value will be read.
|
||||
.IP
|
||||
The option assumes RFC2406 ESP, not RFC1827 ESP.
|
||||
The option is only for debugging purposes, and
|
||||
@ -319,6 +323,13 @@ If used in conjunction with the
|
||||
.B \-C
|
||||
option, filenames will take the form of `\fIfile\fP<count>'.
|
||||
.TP
|
||||
.B \-h
|
||||
Print the tcpdump and libpcap version strings, print a usage message,
|
||||
and exit.
|
||||
.TP
|
||||
.B \-H
|
||||
Attempt to detect 802.11s draft mesh headers.
|
||||
.TP
|
||||
.B \-i
|
||||
Listen on \fIinterface\fP.
|
||||
If unspecified, \fItcpdump\fP searches the system interface list for the
|
||||
@ -359,6 +370,18 @@ monitor mode will be shown; if
|
||||
is specified, only those link-layer types available when in monitor mode
|
||||
will be shown.
|
||||
.TP
|
||||
.B \-j
|
||||
Set the time stamp type for the capture to \fItstamp_type\fP. The names
|
||||
to use for the time stamp types are given in
|
||||
.BR pcap-tstamp-type (@MAN_MISC_INFO@);
|
||||
not all the types listed there will necessarily be valid for any given
|
||||
interface.
|
||||
.TP
|
||||
.B \-J
|
||||
List the supported time stamp types for the interface and exit. If the
|
||||
time stamp type cannot be set for the interface, no time stamp types are
|
||||
listed.
|
||||
.TP
|
||||
.B \-K
|
||||
Don't attempt to verify IP, TCP, or UDP checksums. This is useful for
|
||||
interfaces that perform some or all of those checksum calculation in
|
||||
@ -615,7 +638,10 @@ savefile name as the only argument, make the flags & arguments arrangements
|
||||
and execute the command that you want.
|
||||
.TP
|
||||
.B \-Z
|
||||
Drops privileges (if root) and changes user ID to
|
||||
If
|
||||
.I tcpdump
|
||||
is running as root, after opening the capture device or input savefile,
|
||||
but before opening any savefiles for output, change the user ID to
|
||||
.I user
|
||||
and the group ID to the primary group of
|
||||
.IR user .
|
||||
@ -871,8 +897,8 @@ The general format of a tcp protocol line is:
|
||||
\fISrc\fP and \fIdst\fP are the source and destination IP
|
||||
addresses and ports.
|
||||
\fIFlags\fP are some combination of S (SYN),
|
||||
F (FIN), P (PUSH), R (RST), W (ECN CWR) or E (ECN-Echo), or a single
|
||||
`.' (no flags).
|
||||
F (FIN), P (PUSH), R (RST), U (URG), W (ECN CWR), E (ECN-Echo) or
|
||||
`.' (ACK), or `none' if no flags are set.
|
||||
\fIData-seqno\fP describes the portion of sequence space covered
|
||||
by the data in this packet (see example below).
|
||||
\fIAck\fP is sequence number of the next data expected the other
|
||||
@ -919,8 +945,7 @@ bytes and there was a max-segment-size option requesting an mss of
|
||||
Csam replies with a similar packet except it includes a piggy-backed
|
||||
ack for rtsg's SYN.
|
||||
Rtsg then acks csam's SYN.
|
||||
The `.' means no
|
||||
flags were set.
|
||||
The `.' means the ACK flag was set.
|
||||
The packet contained no data so there is no data sequence number.
|
||||
Note that the ack sequence
|
||||
number is a small integer (1).
|
||||
@ -1266,7 +1291,6 @@ RA, \fInot\fP set) and `|' (truncated message, TC, set).
|
||||
If the
|
||||
`question' section doesn't contain exactly one entry, `[\fIn\fPq]'
|
||||
is printed.
|
||||
|
||||
.HD
|
||||
SMB/CIFS decoding
|
||||
.LP
|
||||
@ -1274,19 +1298,18 @@ SMB/CIFS decoding
|
||||
on UDP/137, UDP/138 and TCP/139.
|
||||
Some primitive decoding of IPX and
|
||||
NetBEUI SMB data is also done.
|
||||
|
||||
.LP
|
||||
By default a fairly minimal decode is done, with a much more detailed
|
||||
decode done if -v is used.
|
||||
Be warned that with -v a single SMB packet
|
||||
may take up a page or more, so only use -v if you really want all the
|
||||
gory details.
|
||||
|
||||
For information on SMB packet formats and what all te fields mean see
|
||||
.LP
|
||||
For information on SMB packet formats and what all the fields mean see
|
||||
www.cifs.org or the pub/samba/specs/ directory on your favorite
|
||||
samba.org mirror site.
|
||||
The SMB patches were written by Andrew Tridgell
|
||||
(tridge@samba.org).
|
||||
|
||||
.HD
|
||||
NFS Requests and Replies
|
||||
.LP
|
||||
@ -1639,7 +1662,7 @@ Ethernet interface removed the packet from the wire and when the kernel
|
||||
serviced the `new packet' interrupt.
|
||||
.SH "SEE ALSO"
|
||||
stty(1), pcap(3PCAP), bpf(4), nit(4P), pcap-savefile(@MAN_FILE_FORMATS@),
|
||||
pcap-filter(@MAN_MISC_INFO@)
|
||||
pcap-filter(@MAN_MISC_INFO@), pcap-tstamp-type(@MAN_MISC_INFO@)
|
||||
.SH AUTHORS
|
||||
The original authors are:
|
||||
.LP
|
||||
|
212
tcpdump.c
212
tcpdump.c
@ -92,6 +92,9 @@ netdissect_options *gndo = &Gndo;
|
||||
|
||||
static int dflag; /* print filter code */
|
||||
static int Lflag; /* list available data link types and exit */
|
||||
#ifdef HAVE_PCAP_SET_TSTAMP_TYPE
|
||||
static int Jflag; /* list available time stamp types */
|
||||
#endif
|
||||
static char *zflag = NULL; /* compress each savefile using a specified command (like gzip or bzip2) */
|
||||
|
||||
static int infodelay;
|
||||
@ -112,7 +115,8 @@ static void ndo_default_print(netdissect_options *, const u_char *, u_int);
|
||||
static void dump_packet_and_trunc(u_char *, const struct pcap_pkthdr *, const u_char *);
|
||||
static void dump_packet(u_char *, const struct pcap_pkthdr *, const u_char *);
|
||||
static void droproot(const char *, const char *);
|
||||
static void ndo_error(netdissect_options *ndo, const char *fmt, ...);
|
||||
static void ndo_error(netdissect_options *ndo, const char *fmt, ...)
|
||||
__attribute__ ((noreturn, format (printf, 2, 3)));
|
||||
static void ndo_warning(netdissect_options *ndo, const char *fmt, ...);
|
||||
|
||||
#ifdef SIGINFO
|
||||
@ -130,10 +134,6 @@ RETSIGTYPE requestinfo(int);
|
||||
static void info(int);
|
||||
static u_int packets_captured;
|
||||
|
||||
typedef u_int (*if_printer)(const struct pcap_pkthdr *, const u_char *);
|
||||
typedef u_int (*if_ndo_printer)(struct netdissect_options *ndo,
|
||||
const struct pcap_pkthdr *, const u_char *);
|
||||
|
||||
struct printer {
|
||||
if_printer f;
|
||||
int type;
|
||||
@ -151,7 +151,6 @@ static struct printer printers[] = {
|
||||
#ifdef DLT_ARCNET_LINUX
|
||||
{ arcnet_linux_if_print, DLT_ARCNET_LINUX },
|
||||
#endif
|
||||
{ ether_if_print, DLT_EN10MB },
|
||||
{ token_if_print, DLT_IEEE802 },
|
||||
#ifdef DLT_LANE8023
|
||||
{ lane_if_print, DLT_LANE8023 },
|
||||
@ -303,13 +302,29 @@ static struct printer printers[] = {
|
||||
};
|
||||
|
||||
static struct ndo_printer ndo_printers[] = {
|
||||
{ ether_if_print, DLT_EN10MB },
|
||||
#ifdef DLT_IPNET
|
||||
{ ipnet_if_print, DLT_IPNET },
|
||||
#endif
|
||||
#ifdef DLT_IEEE802_15_4
|
||||
{ ieee802_15_4_if_print, DLT_IEEE802_15_4 },
|
||||
#endif
|
||||
#ifdef DLT_IEEE802_15_4_NOFCS
|
||||
{ ieee802_15_4_if_print, DLT_IEEE802_15_4_NOFCS },
|
||||
#endif
|
||||
#ifdef DLT_PPI
|
||||
{ ppi_if_print, DLT_PPI },
|
||||
#endif
|
||||
#ifdef DLT_NETANALYZER
|
||||
{ netanalyzer_if_print, DLT_NETANALYZER },
|
||||
#endif
|
||||
#ifdef DLT_NETANALYZER_TRANSPARENT
|
||||
{ netanalyzer_transparent_if_print, DLT_NETANALYZER_TRANSPARENT },
|
||||
#endif
|
||||
{ NULL, 0 },
|
||||
};
|
||||
|
||||
static if_printer
|
||||
if_printer
|
||||
lookup_printer(int type)
|
||||
{
|
||||
struct printer *p;
|
||||
@ -322,7 +337,7 @@ lookup_printer(int type)
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
static if_ndo_printer
|
||||
if_ndo_printer
|
||||
lookup_ndo_printer(int type)
|
||||
{
|
||||
struct ndo_printer *p;
|
||||
@ -359,6 +374,40 @@ struct dump_info {
|
||||
pcap_dumper_t *p;
|
||||
};
|
||||
|
||||
#ifdef HAVE_PCAP_SET_TSTAMP_TYPE
|
||||
static void
|
||||
show_tstamp_types_and_exit(const char *device, pcap_t *pd)
|
||||
{
|
||||
int n_tstamp_types;
|
||||
int *tstamp_types = 0;
|
||||
const char *tstamp_type_name;
|
||||
int i;
|
||||
|
||||
n_tstamp_types = pcap_list_tstamp_types(pd, &tstamp_types);
|
||||
if (n_tstamp_types < 0)
|
||||
error("%s", pcap_geterr(pd));
|
||||
|
||||
if (n_tstamp_types == 0) {
|
||||
fprintf(stderr, "Time stamp type cannot be set for %s\n",
|
||||
device);
|
||||
exit(0);
|
||||
}
|
||||
fprintf(stderr, "Time stamp types for %s (use option -j to set):\n",
|
||||
device);
|
||||
for (i = 0; i < n_tstamp_types; i++) {
|
||||
tstamp_type_name = pcap_tstamp_type_val_to_name(tstamp_types[i]);
|
||||
if (tstamp_type_name != NULL) {
|
||||
(void) fprintf(stderr, " %s (%s)\n", tstamp_type_name,
|
||||
pcap_tstamp_type_val_to_description(tstamp_types[i]));
|
||||
} else {
|
||||
(void) fprintf(stderr, " %d\n", tstamp_types[i]);
|
||||
}
|
||||
}
|
||||
pcap_free_tstamp_types(tstamp_types);
|
||||
exit(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
show_dlts_and_exit(const char *device, pcap_t *pd)
|
||||
{
|
||||
@ -400,13 +449,13 @@ show_dlts_and_exit(const char *device, pcap_t *pd)
|
||||
if (lookup_printer(dlts[n_dlts]) == NULL
|
||||
&& lookup_ndo_printer(dlts[n_dlts]) == NULL)
|
||||
(void) fprintf(stderr, " (printing not supported)");
|
||||
putchar('\n');
|
||||
fprintf(stderr, "\n");
|
||||
} else {
|
||||
(void) fprintf(stderr, " DLT %d (printing not supported)\n",
|
||||
dlts[n_dlts]);
|
||||
}
|
||||
}
|
||||
free(dlts);
|
||||
pcap_free_datalinks(dlts);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@ -428,6 +477,16 @@ show_dlts_and_exit(const char *device, pcap_t *pd)
|
||||
#define I_FLAG
|
||||
#endif /* HAVE_PCAP_CREATE */
|
||||
|
||||
#ifdef HAVE_PCAP_SET_TSTAMP_TYPE
|
||||
#define j_FLAG "j:"
|
||||
#define j_FLAG_USAGE " [ -j tstamptype ]"
|
||||
#define J_FLAG "J"
|
||||
#else /* PCAP_ERROR_TSTAMP_TYPE_NOTSUP */
|
||||
#define j_FLAG
|
||||
#define j_FLAG_USAGE
|
||||
#define J_FLAG
|
||||
#endif /* PCAP_ERROR_TSTAMP_TYPE_NOTSUP */
|
||||
|
||||
#ifdef HAVE_PCAP_FINDALLDEVS
|
||||
#ifndef HAVE_PCAP_IF_T
|
||||
#undef HAVE_PCAP_FINDALLDEVS
|
||||
@ -572,6 +631,7 @@ main(int argc, char **argv)
|
||||
if(wsockinit() != 0) return 1;
|
||||
#endif /* WIN32 */
|
||||
|
||||
jflag=-1; /* not set */
|
||||
gndo->ndo_Oflag=1;
|
||||
gndo->ndo_Rflag=1;
|
||||
gndo->ndo_dlt=-1;
|
||||
@ -598,9 +658,8 @@ main(int argc, char **argv)
|
||||
smiInit("tcpdump");
|
||||
#endif
|
||||
|
||||
opterr = 0;
|
||||
while (
|
||||
(op = getopt(argc, argv, "aAb" B_FLAG "c:C:d" D_FLAG "eE:fF:G:i:" I_FLAG "KlLm:M:nNOpqr:Rs:StT:u" U_FLAG "vw:W:xXy:Yz:Z:")) != -1)
|
||||
(op = getopt(argc, argv, "aAb" B_FLAG "c:C:d" D_FLAG "eE:fF:G:hHi:" I_FLAG j_FLAG J_FLAG "KlLm:M:nNOpqr:Rs:StT:u" U_FLAG "vw:W:xXy:Yz:Z:")) != -1)
|
||||
switch (op) {
|
||||
|
||||
case 'a':
|
||||
@ -693,6 +752,14 @@ main(int argc, char **argv)
|
||||
}
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
usage();
|
||||
break;
|
||||
|
||||
case 'H':
|
||||
++Hflag;
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
if (optarg[0] == '0' && optarg[1] == 0)
|
||||
error("Invalid adapter index");
|
||||
@ -740,6 +807,18 @@ main(int argc, char **argv)
|
||||
break;
|
||||
#endif /* HAVE_PCAP_CREATE */
|
||||
|
||||
#ifdef HAVE_PCAP_SET_TSTAMP_TYPE
|
||||
case 'j':
|
||||
jflag = pcap_tstamp_type_name_to_val(optarg);
|
||||
if (jflag < 0)
|
||||
error("invalid time stamp type %s", optarg);
|
||||
break;
|
||||
|
||||
case 'J':
|
||||
Jflag++;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case 'l':
|
||||
#ifdef WIN32
|
||||
/*
|
||||
@ -854,6 +933,8 @@ main(int argc, char **argv)
|
||||
packettype = PT_TFTP;
|
||||
else if (strcasecmp(optarg, "aodv") == 0)
|
||||
packettype = PT_AODV;
|
||||
else if (strcasecmp(optarg, "carp") == 0)
|
||||
packettype = PT_CARP;
|
||||
else
|
||||
error("unknown packet type `%s'", optarg);
|
||||
break;
|
||||
@ -1032,6 +1113,10 @@ main(int argc, char **argv)
|
||||
pd = pcap_create(device, ebuf);
|
||||
if (pd == NULL)
|
||||
error("%s", ebuf);
|
||||
#ifdef HAVE_PCAP_SET_TSTAMP_TYPE
|
||||
if (Jflag)
|
||||
show_tstamp_types_and_exit(device, pd);
|
||||
#endif
|
||||
/*
|
||||
* Is this an interface that supports monitor mode?
|
||||
*/
|
||||
@ -1041,16 +1126,16 @@ main(int argc, char **argv)
|
||||
supports_monitor_mode = 0;
|
||||
status = pcap_set_snaplen(pd, snaplen);
|
||||
if (status != 0)
|
||||
error("%s: pcap_set_snaplen failed: %s",
|
||||
error("%s: Can't set snapshot length: %s",
|
||||
device, pcap_statustostr(status));
|
||||
status = pcap_set_promisc(pd, !pflag);
|
||||
if (status != 0)
|
||||
error("%s: pcap_set_promisc failed: %s",
|
||||
error("%s: Can't set promiscuous mode: %s",
|
||||
device, pcap_statustostr(status));
|
||||
if (Iflag) {
|
||||
status = pcap_set_rfmon(pd, 1);
|
||||
if (status != 0)
|
||||
error("%s: pcap_set_rfmon failed: %s",
|
||||
error("%s: Can't set monitor mode: %s",
|
||||
device, pcap_statustostr(status));
|
||||
}
|
||||
status = pcap_set_timeout(pd, 1000);
|
||||
@ -1060,9 +1145,17 @@ main(int argc, char **argv)
|
||||
if (Bflag != 0) {
|
||||
status = pcap_set_buffer_size(pd, Bflag);
|
||||
if (status != 0)
|
||||
error("%s: pcap_set_buffer_size failed: %s",
|
||||
error("%s: Can't set buffer size: %s",
|
||||
device, pcap_statustostr(status));
|
||||
}
|
||||
#ifdef HAVE_PCAP_SET_TSTAMP_TYPE
|
||||
if (jflag != -1) {
|
||||
status = pcap_set_tstamp_type(pd, jflag);
|
||||
if (status < 0)
|
||||
error("%s: Can't set time stamp type: %s",
|
||||
device, pcap_statustostr(status));
|
||||
}
|
||||
#endif
|
||||
status = pcap_activate(pd);
|
||||
if (status < 0) {
|
||||
/*
|
||||
@ -1168,14 +1261,40 @@ main(int argc, char **argv)
|
||||
(void)setsignal(SIGPIPE, cleanup);
|
||||
(void)setsignal(SIGTERM, cleanup);
|
||||
(void)setsignal(SIGINT, cleanup);
|
||||
(void)setsignal(SIGCHLD, child_cleanup);
|
||||
#endif /* WIN32 */
|
||||
#if defined(HAVE_FORK) || defined(HAVE_VFORK)
|
||||
(void)setsignal(SIGCHLD, child_cleanup);
|
||||
#endif
|
||||
/* Cooperate with nohup(1) */
|
||||
#ifndef WIN32
|
||||
if ((oldhandler = setsignal(SIGHUP, cleanup)) != SIG_DFL)
|
||||
(void)setsignal(SIGHUP, oldhandler);
|
||||
#endif /* WIN32 */
|
||||
|
||||
#ifndef WIN32
|
||||
/*
|
||||
* If a user name was specified with "-Z", attempt to switch to
|
||||
* that user's UID. This would probably be used with sudo,
|
||||
* to allow tcpdump to be run in a special restricted
|
||||
* account (if you just want to allow users to open capture
|
||||
* devices, and can't just give users that permission,
|
||||
* you'd make tcpdump set-UID or set-GID).
|
||||
*
|
||||
* Tcpdump doesn't necessarily write only to one savefile;
|
||||
* the general only way to allow a -Z instance to write to
|
||||
* savefiles as the user under whose UID it's run, rather
|
||||
* than as the user specified with -Z, would thus be to switch
|
||||
* to the original user ID before opening a capture file and
|
||||
* then switch back to the -Z user ID after opening the savefile.
|
||||
* Switching to the -Z user ID only after opening the first
|
||||
* savefile doesn't handle the general case.
|
||||
*/
|
||||
if (getuid() == 0 || geteuid() == 0) {
|
||||
if (username || chroot_dir)
|
||||
droproot(username, chroot_dir);
|
||||
}
|
||||
#endif /* WIN32 */
|
||||
|
||||
if (pcap_setfilter(pd, &fcode) < 0)
|
||||
error("%s", pcap_geterr(pd));
|
||||
if (WFileName) {
|
||||
@ -1205,6 +1324,10 @@ main(int argc, char **argv)
|
||||
callback = dump_packet;
|
||||
pcap_userdata = (u_char *)p;
|
||||
}
|
||||
#ifdef HAVE_PCAP_DUMP_FLUSH
|
||||
if (Uflag)
|
||||
pcap_dump_flush(p);
|
||||
#endif
|
||||
} else {
|
||||
type = pcap_datalink(pd);
|
||||
printinfo.ndo_type = 1;
|
||||
@ -1225,16 +1348,7 @@ main(int argc, char **argv)
|
||||
callback = print_packet;
|
||||
pcap_userdata = (u_char *)&printinfo;
|
||||
}
|
||||
#ifndef WIN32
|
||||
/*
|
||||
* We cannot do this earlier, because we want to be able to open
|
||||
* the file (if done) for writing before giving up permissions.
|
||||
*/
|
||||
if (getuid() == 0 || geteuid() == 0) {
|
||||
if (username || chroot_dir)
|
||||
droproot(username, chroot_dir);
|
||||
}
|
||||
#endif /* WIN32 */
|
||||
|
||||
#ifdef SIGINFO
|
||||
/*
|
||||
* We can't get statistics when reading from a file rather
|
||||
@ -1363,13 +1477,13 @@ cleanup(int signo _U_)
|
||||
On windows, we do not use a fork, so we do not care less about
|
||||
waiting a child processes to die
|
||||
*/
|
||||
#ifndef WIN32
|
||||
#if defined(HAVE_FORK) || defined(HAVE_VFORK)
|
||||
static RETSIGTYPE
|
||||
child_cleanup(int signo _U_)
|
||||
{
|
||||
wait(NULL);
|
||||
}
|
||||
#endif /* WIN32 */
|
||||
#endif /* HAVE_FORK && HAVE_VFORK */
|
||||
|
||||
static void
|
||||
info(register int verbose)
|
||||
@ -1390,34 +1504,41 @@ info(register int verbose)
|
||||
if (!verbose)
|
||||
fprintf(stderr, "%s: ", program_name);
|
||||
|
||||
(void)fprintf(stderr, "%u packets captured", packets_captured);
|
||||
(void)fprintf(stderr, "%u packet%s captured", packets_captured,
|
||||
PLURAL_SUFFIX(packets_captured));
|
||||
if (!verbose)
|
||||
fputs(", ", stderr);
|
||||
else
|
||||
putc('\n', stderr);
|
||||
(void)fprintf(stderr, "%u packets received by filter", stat.ps_recv);
|
||||
(void)fprintf(stderr, "%u packet%s received by filter", stat.ps_recv,
|
||||
PLURAL_SUFFIX(stat.ps_recv));
|
||||
if (!verbose)
|
||||
fputs(", ", stderr);
|
||||
else
|
||||
putc('\n', stderr);
|
||||
(void)fprintf(stderr, "%u packets dropped by kernel", stat.ps_drop);
|
||||
(void)fprintf(stderr, "%u packet%s dropped by kernel", stat.ps_drop,
|
||||
PLURAL_SUFFIX(stat.ps_drop));
|
||||
if (stat.ps_ifdrop != 0) {
|
||||
if (!verbose)
|
||||
fputs(", ", stderr);
|
||||
else
|
||||
putc('\n', stderr);
|
||||
(void)fprintf(stderr, "%u packets dropped by interface\n",
|
||||
stat.ps_ifdrop);
|
||||
(void)fprintf(stderr, "%u packet%s dropped by interface\n",
|
||||
stat.ps_ifdrop, PLURAL_SUFFIX(stat.ps_ifdrop));
|
||||
} else
|
||||
putc('\n', stderr);
|
||||
infoprint = 0;
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
#if defined(HAVE_FORK) || defined(HAVE_VFORK)
|
||||
static void
|
||||
compress_savefile(const char *filename)
|
||||
{
|
||||
# ifdef HAVE_FORK
|
||||
if (fork())
|
||||
# else
|
||||
if (vfork())
|
||||
# endif
|
||||
return;
|
||||
/*
|
||||
* Set to lowest priority so that this doesn't disturb the capture
|
||||
@ -1433,15 +1554,20 @@ compress_savefile(const char *filename)
|
||||
zflag,
|
||||
filename,
|
||||
strerror(errno));
|
||||
# ifdef HAVE_FORK
|
||||
exit(1);
|
||||
# else
|
||||
_exit(1);
|
||||
# endif
|
||||
}
|
||||
#else /* WIN32 */
|
||||
#else /* HAVE_FORK && HAVE_VFORK */
|
||||
static void
|
||||
compress_savefile(const char *filename)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"compress_savefile failed. Functionality not implemented under windows\n");
|
||||
"compress_savefile failed. Functionality not implemented under your system\n");
|
||||
}
|
||||
#endif /* WIN32 */
|
||||
#endif /* HAVE_FORK && HAVE_VFORK */
|
||||
|
||||
static void
|
||||
dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
|
||||
@ -1780,17 +1906,17 @@ usage(void)
|
||||
#endif /* WIN32 */
|
||||
#endif /* HAVE_PCAP_LIB_VERSION */
|
||||
(void)fprintf(stderr,
|
||||
"Usage: %s [-aAbd" D_FLAG "ef" I_FLAG "KlLnNOpqRStu" U_FLAG "vxX]" B_FLAG_USAGE " [ -c count ]\n", program_name);
|
||||
"Usage: %s [-aAbd" D_FLAG "efhH" I_FLAG J_FLAG "KlLnNOpqRStu" U_FLAG "vxX]" B_FLAG_USAGE " [ -c count ]\n", program_name);
|
||||
(void)fprintf(stderr,
|
||||
"\t\t[ -C file_size ] [ -E algo:secret ] [ -F file ] [ -G seconds ]\n");
|
||||
(void)fprintf(stderr,
|
||||
"\t\t[ -i interface ] [ -M secret ] [ -r file ]\n");
|
||||
"\t\t[ -i interface ]" j_FLAG_USAGE " [ -M secret ]\n");
|
||||
(void)fprintf(stderr,
|
||||
"\t\t[ -s snaplen ] [ -T type ] [ -w file ] [ -W filecount ]\n");
|
||||
"\t\t[ -r file ] [ -s snaplen ] [ -T type ] [ -w file ]\n");
|
||||
(void)fprintf(stderr,
|
||||
"\t\t[ -y datalinktype ] [ -z command ] [ -Z user ]\n");
|
||||
"\t\t[ -W filecount ] [ -y datalinktype ] [ -z command ]\n");
|
||||
(void)fprintf(stderr,
|
||||
"\t\t[ expression ]\n");
|
||||
"\t\t[ -Z user ] [ expression ]\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
BIN
tests/02-sunrise-sunset-esp.pcap
Normal file
BIN
tests/02-sunrise-sunset-esp.pcap
Normal file
Binary file not shown.
@ -1,34 +0,0 @@
|
||||
begin 644 02-sunrise-sunset-esp.pcap
|
||||
MU,.RH0(`!``````````````&```!``````````````"6````E@```!```&1D
|
||||
M11```&1D(P@`10``B/]G``!`,O:5P`$"%\`!`BT2-%9X`````4P@12\\L)(1
|
||||
MTZ=(S>7($>.<3N@\_I:AY"K/TKAZJP719"NCKYP;PT(0+$"M%=]-X"`*8V.'
|
||||
M-'$1A]02"3N#OZI#&1R]A*1;`G8S@YFQ]<H7S))417Y9!E4:<$'CW)%VZ&_3
|
||||
M_]T`L+P1^!`PEP``````````E@```)8````0``!D9$40``!D9",(`$4``(C_
|
||||
M:```0#+VE,`!`A?``0(M$C16>`````(:<$'CW)%VZ',2KQMB@CN?'"^GJ<=:
|
||||
MD-0`+.V^J'2AK).'XQ_B"B8:[%A_+K[6KS2'XR[UN`,R"BJP?^].ZM#/[$)#
|
||||
M17^!D"8_[BZ>GU4Z*$7I"N$U*>J47?C-4;I>#`%6+#0%]D75YC']*Z\`````
|
||||
M`````)8```"6````$```9&1%$```9&0C"`!%``"(_VD``$`R]I/``0(7P`$"
|
||||
M+1(T5G@````#7?C-4;I>#`%@W%89?QJ#$TJ,4G\FO&HO=F+,,%1E(]);XI]T
|
||||
MV7W.RY$2=JZ1%!QCNX[;^.JD4W91;7)NJWV2MF4?7`=&_3OWW%V&6RIXKB75
|
||||
M#;2TWNL"A:MF!I@_5R^]L6;Z`L?E@1:T&71G``````````"6````E@```!``
|
||||
M`&1D11```&1D(P@`10``B/]J``!`,O:2P`$"%\`!`BT2-%9X````!*MF!I@_
|
||||
M5R^]%';9*Q:S_B]]O_8FV:2K1A!]/SQHI7>OS815*I?4%/:.=BBJUEGJ(X8\
|
||||
M<SZ>P1E/@&P\9MR)DP3[UCWI@,MR%A$\CR]=G(("[CFB7AUN$AENZOO&\:7%
|
||||
M2KLW<'NP,L(I=!;8=0``````````E@```)8````0``!D9$40``!D9",(`$4`
|
||||
M`(C_:P``0#+VD<`!`A?``0(M$C16>`````5NZOO&\:7%2J12,9;LOK"-S,=$
|
||||
MO0]X+J(OJQED#PLBRY[\^352UZK&57<R0L9JQ:KH6`)BUN$`5]1WU@"A!8TM
|
||||
MO^)<;`-SW;1HQO$CE\#`O[W[17GW[0G&M,^T?7>6,Z<:%73AWV3:;Y/:=@(`
|
||||
M`````````)8```"6````$```9&1%$```9&0C"`!%``"(_VP``$`R]I#``0(7
|
||||
MP`$"+1(T5G@````&M,^T?7>6,Z=>N_YZQFV[H1^6\!/I*IMAOHZE\E0M.Z!X
|
||||
M#[0EG3#>%]7`]*2F?@S4X2''TK09J@NG/.HEXCE./..K^'-@":X[\?0L+B`S
|
||||
MQA\HTK\'J]:S]N6O`]\)NQD)9;H2P\K`^NX37`R5``````````"6````E@``
|
||||
M`!```&1D11```&1D(P@`10``B/]M``!`,O:/P`$"%\`!`BT2-%9X````!^6O
|
||||
M`]\)NQD)>BYZ>`/DA=N;A2...3-7FZOK?:5KGXBN`/E?$\[-11-$G#E;(>N"
|
||||
M+<$/YP'SM$>16LU18&Q]9)$]0)/M]:2Z#A6]-,SM*>FI/`X*K-*-:KS3IW<"
|
||||
MO(>(P(K=:X::SJ;O[J>0K```````````E@```)8````0``!D9$40``!D9",(
|
||||
M`$4``(C_;@``0#+VCL`!`A?``0(M$C16>`````C3IW<"O(>(P'-43;C[`MCD
|
||||
M`BMZAX]F!?'Z$8Q"5HYMVDC9"8I^O(Z4!/)`/IVD-(ZK)_52-H2XK+,(-LR)
|
||||
MM)K#XLF">KY0>C?\[MA%3F%$?ORJ@:>O]5H>?-$OQH)J<ZFOW_+K%G=UG0"[
|
||||
"G'T`
|
||||
`
|
||||
end
|
BIN
tests/08-sunrise-sunset-aes.pcap
Normal file
BIN
tests/08-sunrise-sunset-aes.pcap
Normal file
Binary file not shown.
@ -1,36 +0,0 @@
|
||||
begin 644 08-sunrise-sunset-aes.pcap
|
||||
MU,.RH0(`!``````````````&```!``````````````"F````I@```!```&1D
|
||||
M11```&1D(P@`10``F/SJ``!`,OD"P`$"%\`!`BW1(T5G`````>:['.C0J(%P
|
||||
MVF'>(TU6&*"9A,`,/KS\:>DH>O_L(51)_[YY"L<H#LJ/;(BQ)=[*$<APY/A1
|
||||
M-"T@(`_Q&)S!C)$*7S?G3Q4H\F=)OYF+P@S&11%^*]S)N@L*TZ@!:&&:QFZT
|
||||
ML'#7<>9?8'?J4V:_.]B+6UR\T>39D+=NA;$``````````*8```"F````$```
|
||||
M9&1%$```9&0C"`!%``"8_.L``$`R^0'``0(7P`$"+=$C16<````";K2P<-=Q
|
||||
MYE]@=^I39K\[V$1HDU9'L,6BVK.^B4]E6QY&:?3?T)G?"RSU;X!J]]7S)<`,
|
||||
M*L!SYO^RUWR?!EIJMWU=5B406YL-I`]LK`^;-3%(NEY#R`ST=W40=:*[M$*8
|
||||
M#<KX)19@.`.4_5YD^:V;G@3>`GLTK(5ZCS"BC@``````````I@```*8````0
|
||||
M``!D9$40``!D9",(`$4``)C\[```0#+Y`,`!`A?``0(MT2-%9P````,-RO@E
|
||||
M%F`X`Y3]7F3YK9N>=6-;U&'6">_4H80DMY^Z9E3ZL3[ONN*L<"Z@7(VO]XT^
|
||||
M/2JP<(/^8NTO-4\/B5AJEC4N;,\"7-&(;9AM_2G5A1C.[LBK3')P?AE;$I[)
|
||||
M!8N&RC?OTD7<V)AIU4,*E>7ELURFXRD/JD(:@RER``````````"F````I@``
|
||||
M`!```&1D11```&1D(P@`10``F/SM``!`,OC_P`$"%\`!`BW1(T5G````!(;*
|
||||
M-^_21=S8F&G50PJ5Y>5K%@R;)A(E<5YD'@86@GT"-&&MHP*.A=?%=:FDZH=4
|
||||
M*9":>]'G'CB4%2?PJ"2^H*51\8P!9T`X3#;F+H$[<GW7=?K.R30-'6'L3AO8
|
||||
MR=:M3S$GIZ>4Z$7ZL0<\S=S\%`:BW9U2'@U^@D,,:.P``````````*8```"F
|
||||
M````$```9&1%$```9&0C"`!%``"8_.X``$`R^/[``0(7P`$"+=$C16<````%
|
||||
M,2>GIY3H1?JQ!SS-W/P4!BW&*&A[$!XGK<^M^>_X193"G"1QTWG>Q"CO25$"
|
||||
MPM+1+8[6&(17\EE\P:6-WVPT=911?@'-Z,,/UVZ2!QV(X4513U9]P62CJMS>
|
||||
M^ODBGHU=%T.H2&Z<4,8(!4,2[&A4^H="L:+`=4G?*(7,2@``````````I@``
|
||||
M`*8````0``!D9$40``!D9",(`$4``)C\[P``0#+X_<`!`A?``0(MT2-%9P``
|
||||
M``870ZA(;IQ0Q@@%0Q+L:%3Z@*HQPZA]3STWDY#CYJGOJH)K<KVT9G61>>I'
|
||||
MEHMF"X!^G,H@,YWT7^=60.3/$7?AYH)G9GBD%%#,D]!EDA]B*?UE>U96+"5\
|
||||
MK=""/.LO'__^;$N<E@!.2&3^@U:P__8_'D^YC!41E,!@!6<K``````````"F
|
||||
M````I@```!```&1D11```&1D(P@`10``F/SP``!`,OC\P`$"%\`!`BW1(T5G
|
||||
M````!_YL2YR6`$Y(9/Z#5K#_]C_ZJU%7M?L23>I`L#D]@&G?Z7B2O#GI?NDK
|
||||
MF[7JPN,8V\H>%G+)'+%+FL*&\8+H2^KFWF5YQ:$4V!,1?G;=OYD;!,3YD'V(
|
||||
MW[Y!I(U=X9[\:L)(5GBJ,B!-5N$.CGV$VLD^R?Z,KL[AMI(ZC-P`````````
|
||||
M`*8```"F````$```9&1%$```9&0C"`!%``"8_/$``$`R^/O``0(7P`$"+=$C
|
||||
M16<````(PDA6>*HR($U6X0Z.?83:R;Y0<E/4SN)UX;Q:D$D%K(DZZ:^_\K$'
|
||||
MZQ81NT4KBGD#Z=_^`E^!HS*KHEJ!)!KE>&'2065/"*M'ELXD?1%3\L3TC.UK
|
||||
HKWB(C5O@78>9LQ^<0Z6]F=:<;@[>L^;/\-6WB81[GX)<MS0B=>LGD@``
|
||||
`
|
||||
end
|
BIN
tests/08-sunrise-sunset-esp2.pcap
Normal file
BIN
tests/08-sunrise-sunset-esp2.pcap
Normal file
Binary file not shown.
@ -1,43 +0,0 @@
|
||||
begin 644 08-sunrise-sunset-esp2.pcap
|
||||
MU,.RH0(`!``````````````&```!``````````````#.````S@```!```&1D
|
||||
M11```&1D(P@`10``P"E-``!`,LQXP`$"%\`!`BT2-%9X`````4=!+\5+F8`+
|
||||
M[[NOU-#98*AO5\780X[VDXF@2W8<10:J!'!Z!-[7N4CFNRKIH;PUA1SL"Y9\
|
||||
M-?_3N_,W/@*T+C/"]=S[`;D!/;`SR5,3+><9K.^\9N><18TY9Z\!I\S./L8R
|
||||
MFE53,S6Y5X_Z\(T)ZIUS?X$8>&(_MT1"!SV:VPP!\XU$[3S-5L)4-O"&>]`Z
|
||||
M1:./61=%C6`6U1/65"A&KUE902]*``````````#.````S@```!```&1D11``
|
||||
M`&1D(P@`10``P"E/``!`,LQVP`$"%\`!`BT2-%9X`````CIU^SX%;G^!GUSP
|
||||
MSA<?/8FY?L/'^2]6'&3[\-NES3E]33Z$Q]#7D9$8TFS5);?S?)ZJOP4;ZD-M
|
||||
M+0_/@#*U=7A9;FYR*5&/^V%MSFEM`DAZY,8'<0.9M^'::<M+M2G0LG6*S/[3
|
||||
M?T`IIJUJ[GW,L+&PH<AR&K(]^=[K7IMGD[`8[ONL8LD3AM`N@$S!*?=;*8=>
|
||||
ML7P6FM81),N>T/1Z'"P7H5;```````````#.````S@```!```&1D11```&1D
|
||||
M(P@`10``P"E1``!`,LQTP`$"%\`!`BT2-%9X`````R4)-P&F>HPK/?_$MTFC
|
||||
M^TOO=/L#W_APTK6MIH_BC*I7\L<,9(?/0M"HK3[T3F;(Y2V70$P5?D'7GFIB
|
||||
MJZ/C",S/BD!9N8GV"\.;GVME[P!@!B1"DT=1W0_75FMI23H!T2^C);4GY>`I
|
||||
M-2T^O_0_WU&$)&+/P)%[TQUQ-T7G%\RXYJT0HO</^*)F`^2<W8KTY.W<FK4K
|
||||
M8UC+J'.*X)NH%<UTK+K+``````````#.````S@```!```&1D11```&1D(P@`
|
||||
M10``P"E3``!`,LQRP`$"%\`!`BT2-%9X````!)`9]]SHKI[EGW4M?W8>[$=<
|
||||
M`@@TL1#(Y980]E*/!^2@G`*&S9O^QMS1S?/`TL=5F9B(12?(145>Y2I+;+T?
|
||||
MKWUD@&.7U36]K-$[.%9CB*FK^E8>N:K/)4#$]ZO/:=#;MRH-)_139\,W6M4T
|
||||
M7SQ?BBX>,+A3#BB5^O=>+GKIC-4]5VBP)D-S<X2O)H[_/#M*T+&$\7PL.M
|
||||
M>7-)\W&;<@_J@,*!``````````#.````S@```!```&1D11```&1D(P@`10``
|
||||
MP"E5``!`,LQPP`$"%\`!`BT2-%9X````!0OIFA;,@2C4HF3>5!-C(0>5LR0"
|
||||
M='1\OQ.!-?@D(U0!453"<Q/!\*CDK.&OU'+WE:^7J8"AMS<@UYX*,<(&YA2Q
|
||||
MGQ(.3+0\#`!+`.TE,;\3:.<+F:?=T@.KOBL%VAAX9_RY$/^%$C+I*4&S<AM]
|
||||
MP*]SZ"RD'G.AJH76?SV&2HQLF+!J/QZ;.:<LB::-]+AE1+&);M^]`XZ-W2CX
|
||||
M+&CPZINP*9?>``````````#.````S@```!```&1D11```&1D(P@`10``P"E7
|
||||
M``!`,LQNP`$"%\`!`BT2-%9X````!I0M"-THEF=+!L=>A3N,\1+"'Z7(J?O0
|
||||
M.B?)(#X=/5F-.">%3.X'(=JKK:W<MZF2^8#73C[US$-O&ZZ+L:94R9E2#=J=
|
||||
M18HP?AN`5^)A+HW6EB*5P=AZ(S"\TIBZ'\.=]4A,#18'0/R_#C:4XX_?>ZMN
|
||||
M=B+^Q3"(KE\1299]=5E,'.&U(`H9N)+>9FS/`CA*>D^>AV.-C(S\)BM&)*XM
|
||||
M^BF__^<_``````````#.````S@```!```&1D11```&1D(P@`10``P"E9``!`
|
||||
M,LQLP`$"%\`!`BT2-%9X````!R"SQ'[6%(;Q>>O+]CS6D*+AD3IMC\^MMK8[
|
||||
M:T3)KM06!G^.H\>%UAT@)X6JL9\3V.HR"+_Q^_T-O$Y_S":_TP;V,LIV1O]H
|
||||
M-G@DOL'V-5)O@%<%!#O$2V,AS@W7(&$IX.YKK]\K#>FITU)<>O42T2GKFW+^
|
||||
M\/[,>E4P[Q"+7O,Y1(R22LND[H+469(%3,SN&3:U:/I`'&R@<`<TR"-4:&8+
|
||||
MQ5SX``````````#.````S@```!```&1D11```&1D(P@`10``P"E;``!`,LQJ
|
||||
MP`$"%\`!`BT2-%9X````"*',]A6A,Q(*B+]=&6X&T*L^\)Z6N%,G)(.;6X-K
|
||||
MM@&4<FRJ]#IJ%Y'-^T+4[&;0;_%7HM85LR8W(>HKGOV,^#L9,QF%)W^9!VFM
|
||||
MXG'XY]CWI5VF33?7,*P?6:.PS'&[\N$7W<*==+;P*$./4*OH&=O,6G!JIN>I
|
||||
M'ZDP*D&4K>SK-\/!7\Z&<&5J4%NU?NRM&25'*_"'UE3VH&?U]/V@932UYZT\
|
||||
`
|
||||
end
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user