Commit Graph

184 Commits

Author SHA1 Message Date
Francois-Xavier Le Bail
02c218bf32 Update a comment 2015-09-08 22:37:54 +02:00
Francois-Xavier Le Bail
78689f7b24 Remove obsolete comment 2015-09-08 12:26:38 +02:00
Francois-Xavier Le Bail
bf657452ef Remove no longer used option 'R' 2015-09-08 09:14:13 +02:00
Francois-Xavier Le Bail
0845bc813c Add program_name field in the netdissect_options structure
A program that use the library should set it. Done for tcpdump.
ndo_error() and ndo_warning() print now 'ndo->program_name'.

Moreover:
Fix indent
2015-09-07 19:13:42 +02:00
Francois-Xavier Le Bail
9ea43350e0 Fix a comment 2015-09-06 22:03:23 +02:00
Francois-Xavier Le Bail
71d0745d3d Printers must use ndo_error() function (via ndo->ndo_error) 2015-09-05 20:20:57 +02:00
Francois-Xavier Le Bail
2a59f8ece9 interface.h,netdissect.h: Cleaning unused items 2015-07-03 11:57:31 +02:00
Denis Ovsienko
0938876cd1 refine tok2str() buffer use
Switch RRCP and BGP functions from tok2strbuf() to tok2str() to avoid
unnecessary local buffer management. The latter function does it in a
way to allow up to 4 calls to itself from printf(). After that
tok2strbuf() remains used by tok2str() only and can be refined later.

Remove a duplicate macro and place the remaining definition into the
right file.
2015-06-29 15:53:56 +01:00
Francois-Xavier Le Bail
035c9fc0a9 struct netdissect_options: Remove unused members 'ndo_infodelay' and 'ndo_info'
Remark: ^T is a tcpdump function, not a packet-dissection mechanism.
2015-06-21 09:32:05 +02:00
Francois-Xavier Le Bail
48539e856d struct netdissect_options: Remove unused member 'ndo_aflag'
Moreover:
Remove redundant empty line.
2015-06-20 13:30:29 +02:00
Francois-Xavier Le Bail
1e560c8164 Move more prototypes in netdissect.h 2015-06-10 21:12:38 +02:00
Francois-Xavier Le Bail
8aca26be94 Move some prototypes in netdissect.h 2015-06-10 20:39:54 +02:00
Francois-Xavier Le Bail
2b7aefe80a Checksum stuff must go in netdissect.h (remainder) 2015-06-10 16:17:27 +02:00
Francois-Xavier Le Bail
b0cbbd12f6 Checksum stuff must go in netdissect.h 2015-06-10 15:47:54 +02:00
Guy Harris
0b1de8f73d Merge pull request #455 from brooksdavis/gndo-cleanup
Remove global netdissect_object and remove non-dissection related fields
2015-05-20 16:56:06 -07:00
Guy Harris
9dd6f72a8c Fix checksumming of PIMv2 Register messages.
The checksum only covers the header, not the encapsulated packet, so
only checksum that.  However, if that checksum fails, try checksumming
the entire packet, as, according to RFC 4601, packets with the entire
packet checksummed should also be accepted, for interoperability.
2015-05-02 10:15:42 -07:00
Francois-Xavier Le Bail
79bfaef492 netdissect.h: Add a comment on IS_NOT_NEGATIVE macro 2015-04-28 06:17:16 +02:00
Francois-Xavier Le Bail
cab33b7a0a netdissect.h: Update ND_TTEST2 to fix issue 443
Add IS_NOT_NEGATIVE macro.
Avoid these warnings:
- comparison of unsigned expression >= 0 is always true [-Wtype-limits],
- comparison is always true due to limited range of data type [-Wtype-limits].
2015-04-27 18:20:59 +02:00
Guy Harris
69cb46af91 Fix a bunch of de-constifications. 2015-04-26 17:24:42 -07:00
Brooks Davis
dcfd7c43ad Pass an ndo to the print API rather than using gndo.
Since gndo is only referenced in main() move it there.
2015-04-27 00:10:23 +00:00
Brooks Davis
46b34a84c5 Remove non-dissection related flags from struct netdissect_options. 2015-04-27 00:06:58 +00:00
Andrew Lunn
d729eb478e Add support for the Marvell Extended Distributed Switch Architecture header
This header can be used with Marvell switches to direct packets in/out
of a specific port in a tree of interconnected switches. The header
uses its own Ethertype of 0xdada.

By default, only brief output is printed, showing the switch device,
port, and vlan the packet is to/from. However if -e is given, to print
the link-level header, all fields are printed.
2015-04-25 22:44:15 +02:00
Guy Harris
30b028f9da Use unsigned values in tok2str and bittok2str routines.
This prevents the compiler issue mentioned in GitHub issue #451, and
also cleans up some other signed vs. unsigned stuff.

While we're at it, clean up bittok2str_internal() (just pass it the
separator string, not a Boolean value that's tested to choose the
separator string), and print unknown arguments to the bittok2str
routines in hex, not decimal.
2015-04-18 19:56:49 -07:00
Guy Harris
bd00116d80 Skip the LLC and SNAP headers with -x.
Have llc_print() return the length of the LLC header, plus the length of
the SNAP header, if available - or, if it couldn't dissect the payload,
return the *negative* of that sum.  Use that return value in link-layer
printers.
2015-04-17 23:42:22 -07:00
Guy Harris
59864b113d Clean up printing of LLC packets.
Don't print LLC header information for SNAP packets; if we have a SNAP
header, just call snap_print() and return its return value, regardless
of whether it's 1 or 0, don't fall into the code to print raw LLC header
information - and don't print it with -e, either.

If llc_print() returns 0, just call the default packet printer, don't
print the MAC-layer header or the extracted ethertype - llc_print() will
print the source and destination MAC addresses and whatever type
information is in the LLC or SNAP headers.

If we don't know the DSAP/LSAP, and it's an information frame (numbered
or not) and not an XID frame, return 0, so that we give a hex dump of
the raw payload.

In addition, print the length when printing SNAP header information with
-e.
2015-04-17 18:38:46 -07:00
Brooks Davis
115a063589 Disentangle packet dissection functionally in tcpdump from the internal
libnetdissect.  This greatly narrows the public interface and allows
libnetdissect to be more easily sandboxed.
2015-04-15 18:52:33 +00:00
Michael Richardson
d00877a2d0 ND_TEST2 should validate that l is non-negative 2015-03-10 23:11:25 -07:00
Guy Harris
4405f13804 Get rid of support for non-NDOified printers.
Remove the TTEST{2}/TCHECK{2} macros.  Rename all "ndo_printer" routines,
structures, and structure members to just "printer", and get rid of the
old routines/structures/structure members with those names.
2015-03-10 13:25:52 -07:00
Guy Harris
09b639add1 C compilers can, and some do, optimize away pointer underflow checks.
Cast the pointers to uintptr_t; use AC_TYPE_UINTPTR_T to get uintptr_t
defined on older platforms that don't define it themselves.
2015-03-02 13:25:12 -08:00
Guy Harris
d71793791f Use immediate mode if available.
If libpcap has pcap_set_immediate_mode(), then default to immediate mode
if we're printing packets to a terminal, and use immediate mode if
--immediate-mode is specified.
2015-02-10 14:55:43 -08:00
Guy Harris
e5b3ec43d3 Clean up bounds checking.
Fix link-layer header length for Cisco-style encapsulation while we're
at it.
2014-12-19 12:13:15 -08:00
Guy Harris
f5b75290d9 Merge git://github.com/the-tcpdump-group/tcpdump 2014-11-10 20:49:32 -08:00
Guy Harris
9ed7ddb48f Use ND_TCHECK() to do bounds checking.
While we're at it, just use the record count to when iterating over
records; the ND_TCHECK()s will make sure we don't run past the end of
the captured data.

Also get rid of an unused argument to cnfp_print().
2014-11-09 23:24:53 -08:00
Jesse Gross
e240710e25 Add support for Generic Network Virtualization Encapsulation (Geneve).
Defined in http://tools.ietf.org/html/draft-gross-geneve-02
2014-11-05 21:44:29 -08:00
Guy Harris
5745325a74 More comments. 2014-10-19 13:46:22 -07:00
Guy Harris
b83e04bd09 Add a routine to print "text protocols", and add FTP/HTTP/SMTP/RTSP support.
"Text protocols" are protocols that have the general feel of FTP, with
command lines with a command name and space-separated arguments and
response lines beginning with a 3-digit reply code.  They can also
include HTTP-style headers and an entity body.

We add support for the FTP control channel, HTTP, SMTP, and RTSP.  We
also change the SIP printer to use it.
2014-10-19 11:21:44 -07:00
Guy Harris
a6f81d534d Leave it up to ip6_print() to handle non-IPv6-capable systems.
Always define and declare ip6_print(), always compile print-ip6.c, and
always call it if we recognize a payload as IPv6.  If INET6 isn't
defined, ip6_print() will just print the length and note that printing
isn't supported.

That way, we don't do weird dissection of IPv6 packets on systems
without IPv6 support, due to, for example, ethertype_print() returning 0
("not dissected") for IPv6 packets on those systems (IPv6-over-Frame
Relay was dissected weirdly due to this).
2014-10-01 15:32:11 -07:00
Michael Richardson
5bcbcc7485 added some comments about ndo functions 2014-07-07 22:05:14 -04:00
Guy Harris
993f6a83fe Boost the maximum snapshot length to 262144, for USBPcap. 2014-06-25 13:41:22 -07:00
Guy Harris
d033c1bc38 Don't treat 65535 as the maximum snapshot length.
Make it 131072, instead; the MTU on the Linux loopback interface, in at
least some versions of the kernel, is 65536, and that doesn't count the
fake Ethernet header, so we need a value bigger than 65536.  We don't
want a value that's *too* large, so that it causes attempts to allocate
huge amounts of memory, however.

This (plus the corresponding change to libpcap) should fix GitHub issue
2014-06-25 13:18:18 -07:00
Michal Sekletar
52b27d11fc Introduce --time-stamp-precision
A while ago we introduced new API in libpcap which made possible to
request time stamps with higher precision (nanoseconds). This commit
aims to move things forward and implement missing bits. It introduces
new long option --time-stamp-precision. Note that there is no equivalent
short option.

When used for a live capture tcpdump will ask the kernel for time stamp
with desired precision and tcpdump will print fraction part of the time
stamp using respective format. We currently support only microsecond and
nanosecond precision. In the future we might support even more granular
time stamp precision, but we should be fine to support only
microseconds and nanoseconds for now. libpcap doesn't provide anything
else at the moment anyway.

When used in combination with -r/-w options then we obtain time stamps
appropriately scaled up or down from libpcap. Also note that distinct
magic number is used for savefiles containing nanosecond time stamps.
2014-05-14 14:18:40 +02:00
Francois-Xavier Le Bail
ab3d424294 Print an optional packet number in the beginning of line
The new option is '--number'.
2014-05-06 12:07:55 +02:00
Denis Ovsienko
35043f3507 AoE: add version 1 decoder (GH #298)
The sample capture was produced with two Linux hosts (aoetools version
36, kernel module version 85, vblade version 21). One of the hosts
exported a 1MB block device containing a freshly created filesystem and
the other mounted it, wrote a small file and then unmounted.
2014-05-04 20:48:03 +04:00
Guy Harris
dbddfda2c8 More getting rid of old u_intN_t. 2014-04-23 00:45:13 -07:00
Denis Ovsienko
1cd6519c4e M3UA: improve code style
Merge m3ua.h into the only file that includes it (print-m3ua.c). Make
M3UA functions follow naming pattern, constify some of their arguments
and switch to ND_PRINT(). Make use of tok2str() and ternary conditional.
Eliminate declarations in the middle of code (C89).
2014-04-21 18:56:55 +04:00
Denis Ovsienko
24598ce6b7 NDOize the rest of util.c 2014-04-14 10:53:46 +04:00
Denis Ovsienko
d6a7593fd9 remove unused function nfsreq_print() 2014-04-11 18:31:40 +04:00
Denis Ovsienko
8863fc0e5d NDOize some generic code 2014-04-03 17:43:33 +04:00
Denis Ovsienko
f274a23dc1 improve previous NDO conversions 2014-04-03 17:41:02 +04:00
Denis Ovsienko
302c32f84f NDOize timed decoder 2014-04-03 15:37:46 +04:00