Commit Graph

150 Commits

Author SHA1 Message Date
Jörg Mayer 6a1666b35d Add sequence number wrap to tcp window checking.
svn path=/trunk/; revision=5945
2002-08-03 23:20:06 +00:00
Guy Harris 6ed12f6993 Create the TCP protocol tree, and put the source and destination ports
into it, as soon as we've extracted the source and destination ports
from the packet, so that if we throw an exception fetching something
else from the packet, we still have the protocol tree and ports.

svn path=/trunk/; revision=5943
2002-08-03 22:28:16 +00:00
Jörg Mayer 173fe5aef4 Replace the types from sys/types.h and netinet/in.h by their glib.h
equivalents for the toplevel directory. The removal of winsock2.h will
hopefully not cause any problems under MSVC++, as those files using
struct timeval still include wtap.h, which still includes winsock2.h.

svn path=/trunk/; revision=5932
2002-08-02 23:36:07 +00:00
Ronnie Sahlberg ff72b97ee0 Two new options added to TCP.
1, Analyze TCP sequence numbers.
   This option will keep track of sequence numbers for all tcp sessions
   and flag the following:
   a, If a new segment is seen which is beyong the right edge this is
      an indication that the previous segment was lost and this will be
      flagged as previous segment lost.
   b, If a segment is seen which lies left of the right edge this is flagged
      as retransmission.
   c, if a keep-alive is seen (empty segment, seq==expected seq-1)
      this is flagged as a retransmission.
   d, if an ACK is seen which is beyond the right edge this is an indication
      that a segment has been lost and it will be flagged as segment lost.

   All ACKs which advance the left edge get the RTT displayed between the ACKed
   segment and the ACK itself. The ACK also gets an indication of WHICH segment
   it is an ACK for.

2, Relative sequence numbers. This option needs the first option to be selected
as well. This option will as best as it can try to get ethereal to use
relative sequence numbers instead of absolute ones.

The patch does not handle sequence number wrapping and unexpected results
can probably happen for such.

svn path=/trunk/; revision=5931
2002-08-02 22:41:56 +00:00
Guy Harris 77fa06b899 From Joerg Mayer:
dftest.c:
	     Remove #if-0-ed includes

	packet-ieee80211.c, packet-wtls.c, packet-afp.c, packet-wsp.c,
        packet-wtp.c, ethereal_gen.py:
	     Remove redundant include varargs (already in snprintf.h,
	     and required only for snprintf.h)

	Remove unused include of snprintf.h from files not using
	"snprintf()".

svn path=/trunk/; revision=5889
2002-07-17 00:43:03 +00:00
Guy Harris 9cde3af195 Set pinfo->ptype, pinfo->srcport, and pinfo->dstport as soon as we've
fetched the source and destination port numbers, so that they're
available to the "Follow TCP Stream" code even if we throw an exception
dissecting the rest of the TCP header.

svn path=/trunk/; revision=5811
2002-07-02 08:18:45 +00:00
Guy Harris 2be8f3e875 When looking for dissectors for the source and destination port numbers
in TCP, UDP, and SCTP, try the lower port number first, and then the
higher port number; this means that, for packets where a dissector is
registered for *both* port numbers:

	1) we pick the same dissector for traffic going in both directions;

	2) we prefer the port number that's more likely to be the right
	   one (as that prefers well-known ports to reserved ports);

although there is, of course, no guarantee that any such strategy will
always pick the right port number.

Ignore port numbers of 0, as some dissectors use a port number of 0 to
disable the port, and as RFC 768 says that the source port in UDP
datagrams is optional and is 0 if not used.

svn path=/trunk/; revision=5656
2002-06-08 21:54:52 +00:00
Guy Harris 392a7dfc04 Get rid of the "data_src" member of the "frame_data" structure; put it
in the "packet_info" structure instead, as we don't need a pointer for
every single frame in the capture file, just for each frame for which we
currently have an open "epan_dissect_t".

svn path=/trunk/; revision=5614
2002-06-04 07:03:57 +00:00
Guy Harris ded6d3e2f4 Improve a comment.
svn path=/trunk/; revision=5399
2002-05-05 22:25:14 +00:00
Guy Harris d612dab6df Make "tvb_ensure_length_remaining()" return a "guint" - it can't return
a negative value.

Use "tvb_ensure_length_remaining()" in "tcp_dissect_pdus()", rather than
checking the return value of "tvb_length_remaining()" ourselves, and
make various variables and parameters in it "guint" as appropriate.

svn path=/trunk/; revision=5396
2002-05-05 00:57:59 +00:00
Guy Harris eb70c97a9b Make a "tcp_dissect_pdus()" with the standard loop for a TCP segment,
extracting PDUs from it and possibly doing reassembly.  Make the COPS,
DNS, DSI, Gryphon, and SCCP dissectors use it.

Add "set_actual_length()", "tcp_dissect_pdus()",
"decode_boolean_bitfield()", "decode_numeric_bitfield()", and
"decode_enumerated_bitfield()" to the list of routines available to
dissectors on platforms where routines in the main program aren't
available to dynamically-loaded code.

Declare routines in "to_str.h" as "extern"; as I remember, that's
necessary to allow the "decode_XXX_bitfield()" routines declared therein
to be made available to plugins as per the above.

Note that new exported routines should be added to the end of the table
if that's the only change being made to the table.

Create a new "plugin_api_decls.h" header file, used to declare both the
"p_" variables and the "p_" structure members in the routine-exporting
mechanism; this reduces the number of places you have to change to
change the list of exported routines.

svn path=/trunk/; revision=5394
2002-05-05 00:16:38 +00:00
Richard Sharpe e626714c31 Add the packet len to the protocol tree as well, since it is often not visible in the summary display.
svn path=/trunk/; revision=5379
2002-05-04 02:54:48 +00:00
Richard Sharpe 60d5c327e9 Add a hidden length fild for TCP, tcp.len. Also fixed a small type.
svn path=/trunk/; revision=5210
2002-04-21 02:57:01 +00:00
Guy Harris 08cf4d245f Do the "follow TCP stream" stuff before calling the subdissector, so
that it gets done even if the subdissector throws an exception (and so
that, if the subdissector modifies the addresses or ports, we still hand
the right values to "reassemble_tcp()").

svn path=/trunk/; revision=5140
2002-04-11 08:59:43 +00:00
Guy Harris 7212bcc1e9 Mark unused arguments as such.
svn path=/trunk/; revision=5062
2002-03-31 22:43:03 +00:00
Guy Harris 588c50944d In the protocol tree entries for lists of fragments/segments, make the
top-level item correspond to the reassembled data, and make the item for
each fragment/segment correspond to the part of that reassembled data
that came from that fragment/segment.

svn path=/trunk/; revision=5025
2002-03-27 04:27:05 +00:00
Guy Harris f12ef91219 Free all the stuff pointed to by elements in the "tcp_segment_table"
hash table before freeing the memory chunks for those elements.

Destroy that hash table when we're done, and set the pointer to it to
null so that we'll reallocate it.

svn path=/trunk/; revision=4794
2002-02-24 02:59:30 +00:00
Guy Harris d1afae8393 For TCP segments that are reassembled into larger packets, show the data
as raw TCP segment data under the TCP protocol tree item, rather than as
a top-level data item - and do so even for the last of the segments
reassembled into that packet.

svn path=/trunk/; revision=4754
2002-02-19 00:14:21 +00:00
Guy Harris b505843920 Add support for reassembling RPC-over-TCP fragments, and do that in both
RPC and NDMP.

Show the RPC-over-TCP fragment header as a tree with bitfields below it.

Add a routine to show a reported bounds error as an "Unreassembled
Packet" or a "Malformed Packet" depending on whether "pinfo->fragmented"
is set, and have NBNS and RPC use that.

Add "ett_ndmp_file_stats" to the list of ett_ values to be initialized
(it wasn't in that list, and wasn't getting initialized).

When freeing up various hash tables and memory chunks in the RPC
dissector, zero out the pointers to them, just to make sure we don't try
to free them again.

Always destroy the TCP segment key and address memory chunks in
"tcp_desegment_init()", regardless of whether TCP desegmentation is
enabled - we don't *allocate* them if TCP desegmentation isn't enabled,
but we should free them even if it's not enabled.  Also, when we free
them, set the pointers to them to null, so we don't double-free them.

Supply to subdissectors called from the TCP dissector the sequence
number of the first byte handed to the sub dissector.

svn path=/trunk/; revision=4753
2002-02-18 23:51:55 +00:00
Guy Harris 6a21dc7e44 Don't give tvbuffs names; instead, give data sources names, where a
"data source" has a name and a top-level tvbuff, and frames can have a
list of data sources associated with them.

Use the tvbuff pointer to determine which data source is the data source
for a given field; this means we don't have to worry about multiple data
sources with the same name - the only thing the name does is label the
notebook tab for the display of the data source, and label the hex dump
of the data source in print/Tethereal output.

Clean up a bunch of things discovered in the process of doing the above.

svn path=/trunk/; revision=4749
2002-02-18 01:08:44 +00:00
Guy Harris 6d55906750 From Ricardo Barroetave�a: support dissectors that are handed
reassembled TCP data being able to indicate that they need still more
reassembly, so that, for example, a dissector can indicate that it needs
reassembly in order to dissect a header that says how long the PDU is
and, when that reassembly is done and it dissects the header, it can
then indicate that it needs more reassembly to get the entire PDU.

svn path=/trunk/; revision=4694
2002-02-03 23:28:38 +00:00
Guy Harris 06933d87e3 Get rid of an extra space.
svn path=/trunk/; revision=4693
2002-02-03 21:44:52 +00:00
Guy Harris ee5ca25d31 Include files from the "epan" directory and subdirectories thereof with
"epan/..." pathnames, so as to avoid collisions with header files in any
of the directories in which we look (e.g., "proto.h", as some other
package has its own "proto.h" file which it installs in the top-level
include directory).

Don't add "-I" flags to search "epan", as that's no longer necessary
(and we want includes of "epan" headers to fail if the "epan/" is left
out, so that we don't re-introduce includes lacking "epan/").

svn path=/trunk/; revision=4586
2002-01-21 07:37:49 +00:00
Guy Harris 92915713d3 Allow a length of -1 to be specified when adding FT_NONE and FT_PROTOCOL
items to the protocol tree; it's interpreted as "the rest of the data in
the tvbuff".  This can be used if

	1) the item covers the entire packet or the remaining payload in
	   the packet

or

	2) the item's length won't be known until it's dissected, and
	   will be then set with "proto_item_set_len()" - if an
	   exception is thrown in the dissection, it means the item ran
	   *past* the end of the tvbuff, so saying it runs to the end of
	   the tvbuff is reasonable.

Convert a number of "proto_tree_add_XXX()" calls using
"tvb_length_remaining()", values derived from the result of
"tvb_length()", or 0 (in the case of items whose length is unknown) to
use -1 instead (using 0 means that if an exception is thrown, selecting
the item highlights nothing; using -1 means it highlights all the data
for that item that's available).

In some places where "tvb_length()" or "tvb_length_remaining()" was used
to determine how large a packet is, use "tvb_reported_length()" or
"tvb_reported_length_remaining()", instead - the first two calls
indicate how much captured data was in the packet, the latter two calls
indicate how large the packet actually was (and the fact that using the
latter could cause BoundsError exceptions to be thrown is a feature - if
such an exception is thrown, the frame really *was* short, and it should
be tagged as such).

Replace some "proto_tree_add_XXX()" calls with equivalent
"proto_tree_add_item()" calls.

Fix some indentation.

svn path=/trunk/; revision=4578
2002-01-20 22:12:39 +00:00
Guy Harris 973980e2e3 Add an option to turn off TCP checksum checking (and to *allow*
desegmentation even though we don't know whether the checksum is valid).
I've seen packets with bad TCP checksums in Solaris network traces, but
the traffic appears to indicate that the packet *was* received; I
suspect the packets were sent by the host on which the capture was being
done, on a network interface to which checksumming was offloaded, so
that DLPI supplied an un-checksummed packet to the capture program but a
checksummed packet got put onto the wire.

svn path=/trunk/; revision=4571
2002-01-18 22:35:19 +00:00
Guy Harris 816e7978c4 Mark un-reassembled TCP segments as (possibly) being un-reassembled, by
setting the "pinfo->fragmented" flag.

If a ReportedBoundsError occurs, flag the frame as being an
unreassembled packet, not an unreassembled fragmented packet, as it may
have been segmented across TCP segment boundaries rather than being part
of an IPv4/IPv6/CLNP/etc. fragmented/segmented packet.

svn path=/trunk/; revision=4558
2002-01-17 09:28:22 +00:00
Guy Harris 381c21783e As per a comment from Ronnie Sahlberg, display TCP sequence numbers in
the list of segments in a desegmented PDU as unsigned, rather than
signed.

Fix some other displays of unsigned quantities with "%d" while we're at
it.

svn path=/trunk/; revision=4516
2002-01-10 11:27:57 +00:00
Guy Harris 23319ff023 Move the pointer to the "column_info" structure in the "frame_data"
structure to the "packet_info" structure; only stuff that's permanently
stored with each frame should be in the "frame_data" structure, and the
"column_info" structure is not guaranteed to hold the column values for
that frame at all times - it was only in the "frame_data" structure so
that it could be passed to dissectors, and, as all dissectors are now
passed a pointer to a "packet_info" structure, it could just as well be
put in the "packet_info" structure.

That saves memory, by shrinking the "frame_data" structure (there's one
of those per frame), and also lets us clean up the code a bit.

svn path=/trunk/; revision=4370
2001-12-10 00:26:21 +00:00
Guy Harris 75cc056222 Attach a descriptive name field type and base to dissector tables; that
specifies how the selector values used as keys in those tables are to be
displayed, and the title to use when displaying the table.

Use that information in the code to display the initial and current
entries of various dissector tables.

Have the dissector for BACnet APDUs register itself by name, and have
the BACnet NPDU dissector call it iff the BAC_CONTROL_NET bit isn't set,
rather than doing it with a dissector table.

svn path=/trunk/; revision=4358
2001-12-08 06:41:48 +00:00
Guy Harris 6b253331f0 Support for reassembly of DCERPC over SMB, from Ronnie Sahlberg.
svn path=/trunk/; revision=4335
2001-12-05 08:20:30 +00:00
Guy Harris c22d3fdc96 Get rid of the lists of conversation dissectors; instead, have a
dissector table contain both a hash table, to use to look up port
numbers to find a dissector, and a list of all dissectors that *could*
be assigned to ports in that hash table, to be used by user interface
code.

Make the "Decode As" dialog box code use that.

Also make it *not* let you choose whether to set the dissector for both
the UDP and TCP versions of a port; some protocols run only atop TCP,
some run only atop UDP, and even those that can run atop both may have
different dissector handles to use over TCP and UDP, so handling a
single merged list would be a mess.  (If the user is setting the
dissector for a TCP port, only those protocols that Ethereal can handle
over TCP should be listed; if the user is setting the dissector for a
UDP port, only those protocols that Ethereal can handle over TCP should
be listed; if the user is setting a dissector for both, only those
protocols that Ethereal can handle over *both* TCP *and* UDP should be
listed, *and* there needs to be a way to let the "Decode As" code get
both the TCP handle *and* the UDP handle and use the right ones.  If
somebody really wants that, they need to implement all of the above if
they want the code to be correct.)

Fix the code that handles setting the dissection for the IP protocol
number to correctly update the lists of protocols being dissected as TCP
and as UDP; the code before this change wasn't updating the single such
list to add new protocols.

svn path=/trunk/; revision=4311
2001-12-03 08:47:31 +00:00
Guy Harris bced8711f6 Make "dissector_add()", "dissector_delete()", and "dissector_change()"
take a dissector handle as an argument, rather than a pointer to a
dissector function and a protocol ID.  Associate dissector handles with
dissector table entries.

svn path=/trunk/; revision=4308
2001-12-03 04:00:26 +00:00
Guy Harris 3396fb2777 Update from Ronnie Sahlberg:
1.  Changes how can_desegment works so that can_desegment is
	    only != 0 for whichever dissector is running immediately on
	    top of whoever offers the can_desegment service.

	    Thus DCERPC needs no special handling to see if it can trust
	    can_desegment (which is currently only available ontop of TCP
	    and not ontop of tcp->nbss->smb).

	2.  Changes fragment reassembly of transaction smb to only show
	    the defragmented packet for the transaction smb holding the
	    first fragment.

	    To see why, test it with a transaction SMB containing a ~60kb
	    PDU or larger.  The old behaviour had approximately quadratic
	    behaviour regarding runtime for dissecting such PDUs.

	    (example: NetShareEnum is a command which can grow really really
	    large if the number of shares and comments are large)

svn path=/trunk/; revision=4296
2001-11-29 09:05:25 +00:00
Ed Warnicke fcd5b352af Moved from using dissect_data() to using call_dissector()
svn path=/trunk/; revision=4269
2001-11-26 04:52:51 +00:00
Guy Harris bd90493d46 If we have to worry about subdissectors changing the "packet_info"
structure, we may have to worry about it in more places than the places
that *used* to set "pi.len" and "pi.captured_len", so there's no point
in just saving and restoring it there.  We'll remove those
saves/restores, and worry about saves and restores when we find a
problem.

svn path=/trunk/; revision=4245
2001-11-21 21:37:26 +00:00
Guy Harris 2f10c7f630 Get rid of the "len" and "captured_len" members of the "packet_info"
structure; they're no longer used.

svn path=/trunk/; revision=4236
2001-11-20 22:29:07 +00:00
Guy Harris 4a5538085f Get rid of NullTVB, the "compat_top_tvb" member of the "packet_info"
structure, the check for a null tvbuff pointer in "alloc_field_info()",
and the "tvb_create_from_top()" macro; they're no longer needed, as
there's no non-tvbuffified dissector code remaining.

svn path=/trunk/; revision=4205
2001-11-15 10:58:51 +00:00
Guy Harris 0c13da5c70 Rename the "private" member of the "packet_info" structure to
"private_data", to keep C++ compilers from getting heartburn.

svn path=/trunk/; revision=4130
2001-11-03 00:58:52 +00:00
Guy Harris c132bad423 Fix to desegmentation crash, from Ronnie Sahlberg.
svn path=/trunk/; revision=4111
2001-10-30 22:22:26 +00:00
Guy Harris d627904aba Have a flag in the "packet_info" structure, which indicates whether the
stuff currently being dissected is part of a packet included in an error
packet (e.g., an ICMP Unreachable packet).  Have the TCP dissector not
bother doing reassembly if the TCP segment is part of an error packet,
rather than an actual TCP transmission; other dissectors might want to
treat those packets specially as well.

Add to the "tcpinfo" structure a flag indicating whether the URG flag
was set, rather than having the zero or non-zero value of the urgent
pointer indicate that.  (Yes, at least as I read RFC 793, a zero urgent
pointer value isn't useful, as it means "the stuff before this segment
is urgent", but it's certainly possible to put onto the wire a TCP
segment with URG set and a zero urgent pointer.)

Don't dissect the TCP header by grabbing the entire header with
"tvb_memcpy()" and then pulling stuff out of it - extract stuff with
individual tvbuff calls, and put stuff into the protocol tree and the
Info column as we extract it, so that we can dissect a partial header.
This lets us, for example, get the source and destination ports from the
TCP header of the part of a TCP segment included in a minimum-length
ICMPv4 error packet.

svn path=/trunk/; revision=3986
2001-10-01 08:29:37 +00:00
Guy Harris 1e937e5c0a The length of an NBSS message can be bigger than 64K, so make the
variable that holds it an "int" rather than a "guint16".

Further strengthen the heuristics the NBSS dissector uses to distinguish
NBSS messages from continuations of NBSS messages.

If an frame contains an NBSS continuation, put the protocol tree item
for the continuation data under an NBSS protocol tree item.

Have the TCP dissector supply information to subdissectors via a "struct
tcpinfo" pointed to by "pinfo->private"; move the urgent pointer value
from a global variable into that structure, and add a Boolean flag that
indicates whether the data it's handing to a subdissector is reassembled
data or not.

Make the NBSS dissector check for continuations only in non-reassembled
data.

Fix the computation, in the TCP dissector, of the offset into the tvbuff
handed to the subdissector of the first byte of stuff that needs further
reassembly, and fix the computation of the sequence number corresponding
to that byte.

svn path=/trunk/; revision=3984
2001-09-30 23:14:43 +00:00
Guy Harris 5406cdeb95 Fix indentation.
svn path=/trunk/; revision=3970
2001-09-28 23:34:03 +00:00
Guy Harris f5ae39b540 Use the right #define for the length of the CC.NEW TCP option.
svn path=/trunk/; revision=3958
2001-09-27 10:10:08 +00:00
Guy Harris 2a148564d6 TCP desegmentation support, and changes to the ONC RPC and NBSS
dissectors to use it, from Ronnie Sahlberg, with additional changes to
handle the case where a frame contains messages that don't run past the
end followed by one that does and where a reassembled chunk has, at the
end, a message that runs past the end of that chunk (because the
reassembly was for an earlier message).

svn path=/trunk/; revision=3923
2001-09-13 07:56:53 +00:00
Guy Harris 554eb35fcf Get rid of a no-longer-used #define.
svn path=/trunk/; revision=3902
2001-09-03 17:57:17 +00:00
Guy Harris 8412393197 From Joerg Mayer: explicitly fill in all members of a
"header_field_info" structure, including the ones that are later set by
the routines to register fields.

svn path=/trunk/; revision=3561
2001-06-18 02:18:27 +00:00
Guy Harris 026db5a26f Check for a bogus TCP header length, and don't try to do dissection if
it's bogus.

svn path=/trunk/; revision=3542
2001-06-14 08:09:59 +00:00
Guy Harris f63755f54c There's no need to include "globals.h" - don't include it.
svn path=/trunk/; revision=3529
2001-06-08 08:41:03 +00:00
Guy Harris c75f555d8c Move the declarations of IP protocol numbers to "ipproto.h" from
"packet-ip.h".

Fix Gerald's address in some files while we're at it.

svn path=/trunk/; revision=3366
2001-04-23 17:51:37 +00:00
Guy Harris d8f688ea26 Use "proto_tree_add_boolean_hidden()", not
"proto_tree_add_item_hidden()", to add the "checksum bad" flags to
packets; the value should be "TRUE", not the numerical value of the
checksum field.

svn path=/trunk/; revision=3202
2001-03-28 21:33:31 +00:00