Commit Graph

15 Commits

Author SHA1 Message Date
Guy Harris 0def9a0b52 We can't use the frame_data structure as a key structure when looking
for reassembled frames - in Tethereal, there's only one frame_data
structure used for all frames.  Instead, use the frame number itself as
the key.

Add a "fragment_add_check()" routine, for fragments where there's a
fragment offset rather than a fragment sequence number, which does the
same sort of thing as "fragment_add_seq_check()" - i.e., once reassembly
is done, it puts the reassembled fragment into a separate hash table, so
that there're only incomplete reassemblies in the fragment hash table.
That's necessary in order to handle cases where the packet ID field can
be reused.

Use that routine for IPv4 fragment reassembly - IP IDs can be reused (in
fact, RFC 791 suggests that doing so might be a feature:

    It is appropriate for some higher level protocols to choose the
    identifier. For example, TCP protocol modules may retransmit an
    identical TCP segment, and the probability for correct reception
    would be enhanced if the retransmission carried the same identifier
    as the original transmission since fragments of either datagram
    could be used to construct a correct TCP segment.

and RFC 1122 says that it's permitted to do so, although it also says
"we believe that retransmitting the same Identification field is not
useful":

         3.2.1.5  Identification: RFC-791 Section 3.2

            When sending an identical copy of an earlier datagram, a
            host MAY optionally retain the same Identification field in
            the copy.

            DISCUSSION:
                 Some Internet protocol experts have maintained that
                 when a host sends an identical copy of an earlier
                 datagram, the new copy should contain the same
                 Identification value as the original.  There are two
                 suggested advantages:  (1) if the datagrams are
                 fragmented and some of the fragments are lost, the
                 receiver may be able to reconstruct a complete datagram
                 from fragments of the original and the copies; (2) a
                 congested gateway might use the IP Identification field
                 (and Fragment Offset) to discard duplicate datagrams
                 from the queue.

                 However, the observed patterns of datagram loss in the
                 Internet do not favor the probability of retransmitted
                 fragments filling reassembly gaps, while other
                 mechanisms (e.g., TCP repacketizing upon
                 retransmission) tend to prevent retransmission of an
                 identical datagram [IP:9].  Therefore, we believe that
                 retransmitting the same Identification field is not
                 useful.  Also, a connectionless transport protocol like
                 UDP would require the cooperation of the application
                 programs to retain the same Identification value in
                 identical datagrams.

and, in any case, I've seen that in at least one capture, and it
confuses the current reassembly code).

Unfortunately, that means that fragments other than the last fragment
can't be tagged with the frame number in which the reassembly was done;
see the comment in packet-ip.c for a discussion of that problem.

svn path=/trunk/; revision=7506
2003-04-20 00:11:28 +00:00
Ronnie Sahlberg 90a6dc4ea0 Added new field reassembled_in to the fragment data structure.
This field gets set to the frame number when this pdu was first completely reassembled.

This is useful since it will allow us to do reassembly properly in say packet-ip.c
instead of printing the full pdu for every fragment and thus making NFSoverUDP  rpc-rtt statistics less than useful.

A dissector using fragment_add() can tehn choose to only dissect the reassembled PDU only for the frame where it was first reassembled.

svn path=/trunk/; revision=7427
2003-04-09 09:04:08 +00:00
Ronnie Sahlberg e4633bc783 Update reassemble.c/show_item and all callers to use FT_FRAMENUM for the list of packets corresponding to a reassembled pdu
svn path=/trunk/; revision=6807
2002-12-19 11:22:38 +00:00
Guy Harris 71f6ebae44 From Tomas Kukosa: export more routines to plugins.
svn path=/trunk/; revision=6630
2002-11-14 18:54:53 +00:00
Guy Harris 07d0032f1c Add a "fragment_add_seq_next()" to reassemble fragments that don't have
sequence numbers or offsets and are thus assumed to be received in order
with no duplicates or dropped fragments (e.g., for NetBIOS Frame, where
802.2 LLC guarantees in-order delivery to NetBIOS with no duplicates or
dropped fragments).

"show_fragment_tree()' and "show_fragment_seq_tree()" don't modify the
"fragment_items" to which the "fit" argument points, so make that
argument a "const fragment_items *".

Make all the "fragment_items" tables "static" (as they're not used
outside the modules defining them) and "const" (as they're not
modified).

Add support for reassembly of NetBIOS fragmented requests and responses.

Get rid of an unnecessary include of "packet-tr.c" in the NetBIOS
dissector, and make its table of dissection function pointers static.

Fix some typos in the AppleTalk and NetBIOS dissectors.

svn path=/trunk/; revision=6491
2002-10-24 06:17:36 +00:00
Jörg Mayer 7c4176d868 Removed trailing whitespaces from .h and .c files using the
winapi_cleanup tool written by Patrik Stridvall for the wine
project.

svn path=/trunk/; revision=6117
2002-08-28 21:04:11 +00:00
Guy Harris 4f9508837a Add "show_fragment_seq_tree()", which is like "show_fragment_tree()",
but for stuff reassembled with "fragment_add_seq()" or
"fragment_add_seq_check()".

Add a "fragment tag" string to the "fragment_items", so that packets
with fragmentation errors can be properly flagged as having "Illegal
fragments" or "Illegal segments" depending on the term used with the
protocol in question.

Make all the dissectors that can use "show_fragment_tree()" or
"show_fragment_seq_tree()", and don't already use them, do so.

svn path=/trunk/; revision=5644
2002-06-07 10:11:41 +00:00
Ronnie Sahlberg 31823cb851 Added show_fragment_tree() to reassemble. This function will do the common
task of creating a fregment tree for the fragmented packets.
Having this identical code to create this tree in every dissector that does
PDU reassembly is a huge waste and duplication of code.

Updated IP, SMB and DCERPC to use the new function.

svn path=/trunk/; revision=5626
2002-06-05 11:21:49 +00:00
Ronnie Sahlberg 2031280796 Reassembly of fragmented DCE/RPC (only for connection oriented DCE/RPC).
svn path=/trunk/; revision=5548
2002-05-24 11:51:14 +00:00
Guy Harris ed3b0cae65 Add a separate hash table to the reassembly code for reassembled
packets, using the reassembly ID and the frame number of the final frame
as the key.  There is no guarantee that reassembly IDs won't be reused,
even when talking between the same source and destination address; if,
once reassembly is complete, the "fragment_data" structure is moved to
the latter hash table, this will keep reused reassembly IDs from causing
mis-reassembly.

Add a routine "fragment_add_seq_check()", which

	if a fragment has the "more fragments" flag not set but is the
	first fragment of a reassembly, treats that as a non-fragmented
	frame, allocating a "fragment_data" structure for the reassembly
	but not attaching any fragment to it, and adding it to a
	reassembled packet list;

	if a packet has been reassembled, removes it from the table of
	reassemblies and moves it to the table of reassembled packets;

	if the frame's been seen already, looks it up in the table of
	reassembled packets rather than the table of reassemblies.

Add reassembly support for fragmented 802.11 frames.  Use
"fragment_add_seq_check()" to cope with the fact that some
hardware+drivers apparently hands us reassembled frames with a non-zero
fragment number and the "more fragments" bit clear (as if it puts the
802.11 header of the *last* fragment onto the reassembled data).

svn path=/trunk/; revision=5177
2002-04-17 08:25:05 +00:00
Guy Harris f5880dd3bd Rename the "frag_offset" argument of "fragment_add_seq()" to
"frag_number", to make it clearer that it's not a byte offset but a
sequence number.

svn path=/trunk/; revision=5175
2002-04-17 04:54:30 +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 c139b9138a From Ronnie Sahlberg: new infrastructure to reassemble packets where
fragments are identified by block sequence numbers and not byte offsets.

svn path=/trunk/; revision=4398
2001-12-15 05:40:32 +00:00
Guy Harris ac16b7463b Assorted changes from Ronnie Sahlberg:
Add a few small functions to reassemble.c to cope with protocols
	where the total length of defragmented PDUs are specified in the
	first fragment (all previous uses of reassembly has been for
	PDUs where the last fragment is signalled by a flag in the
	header for the last fragment).

	Add a few small functions to reassemble.c to abort-and-delete
	defragmentation of PDUs and also detect IF a PDU is currently
	being defragmented.  (Useful for PDUs where the "unique"
	identifier is rather ununique, or may be reused often enough so
	it can be a problem for Ethereal.)

	Change where NT Cancel presents its Cancelation-to output, and
	makes the three trans secondary requests also output similar
	information.

svn path=/trunk/; revision=4255
2001-11-24 09:36:40 +00:00
Guy Harris c9da803a08 Move the fragment reassembly code into "reassemble.c" and
"reassemble.h", and remove IPv4 dependencies from it.

Use it for OSI CLNP segment reassembly as well.

svn path=/trunk/; revision=3525
2001-06-08 06:27:16 +00:00