Commit Graph

273 Commits

Author SHA1 Message Date
Guy Harris a2414d8909 Don't wire into the reassembly code the notion that reassemblies should
be done on flows from one address to another; reassembly for protocols
running atop TCP should be done on flows from one TCP endpoint to
another.

We do this by:

	adding "reassembly table" as a data structure;

	associating hash tables for both in-progress reassemblies and
	completed reassemblies with that data structure (currently, not
	all reassemblies use the latter; they might keep completed
	reassemblies in the first table);

	having functions to create and destroy keys in that table;

	offering standard routines for doing address-based and
	address-and-port-based flow processing, so that dissectors not
	needing their own specialized flow processing can just use them.

This fixes some mis-reassemblies of NIS YPSERV YPALL responses (where
the second YPALL response is processed as if it were a continuation of
a previous response between different endpoints, even though said
response is already reassembled), and also allows the DCE RPC-specific
stuff to be moved out of epan/reassembly.c into the DCE RPC dissector.

svn path=/trunk/; revision=48491
2013-03-22 23:59:54 +00:00
Sake Blok a4fe30275f Properly set the ISN's when the SYN and SYN/ACK are received out-of-order.
svn path=/trunk/; revision=48466
2013-03-21 22:25:42 +00:00
Anders Broman 27744ecc2d From beroset:
remove C++ incompatibilities 
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8416

svn path=/trunk/; revision=48337
2013-03-16 08:12:29 +00:00
Evan Huus bbb4058954 Remove slab.h and replace its last remaining usage with glib slices.
Take the opportunity to deduplicate some code that was common to both an
if block and its else block.

svn path=/trunk/; revision=48227
2013-03-10 14:52:14 +00:00
Guy Harris 6b629c4d92 Move show_exception() and show_reported_bounds_error() to
epan/show_exception.c, as it's used outside
epan/dissectors/packet-frame.c.  Update their callers to include
<epan/show_exception.h> to get their declaration.

Add a CATCH_NONFATAL_ERRORS macro that catches all exceptions that, if
there's more stuff in the packet to dissect after the dissector call
that threw the exception, doesn't mean you shouldn't go ahead and
dissect that stuff.  Use it in all those cases, including ones where
BoundsError was inappropriately being caught (you want those passed up
to the top level, so that the packet is reported as having been cut
short in the capture process).

Add a CATCH_BOUNDS_ERRORS macro that catches all exceptions that
correspond to running past the end of the data for a tvbuff; use it
rather than explicitly catching those exceptions individually, and
rather than just catching all exceptions (the only place that
DissectorError should be caught, for example, is at the top level, so
dissector bugs show up in the protocol tree).

Don't catch and then immediately rethrow exceptions without doing
anything else; just let the exceptions go up to the final catcher.

Use show_exception() to report non-fatal errors, rather than doing it
yourself.
 
If a dissector is called from Lua, catch all non-fatal errors and use
show_exception() to report them rather than catching only
ReportedBoundsError and adding a proto_malformed item.

Don't catch exceptions when constructing a trailer tvbuff in
packet-ieee8023.c - just construct it after the payload has been
dissected, and let whatever exceptions that throws be handled at the top
level.

Avoid some TRY/CATCH/ENDTRY cases by using checks such as
tvb_bytes_exist() before even looking in the tvbuff.

svn path=/trunk/; revision=47924
2013-02-27 22:43:54 +00:00
Bill Meier 1823aa007c it's ==> its & its ==> it's as needed.
svn path=/trunk/; revision=47891
2013-02-26 01:06:19 +00:00
Chris Maynard eee4f31ab6 Evan Huus pointed out a duplicate block of code, so delete it. Also, move the other block before the "next_tvb=..." statement. Other changes:
-> Delete some unused header fields found with checkhf.pl
-> Fix a couple of typos.
-> Minor whitespace changes.
-> Add a TODO about replacing strstr with either g_strrstr or g_str_has_suffix


svn path=/trunk/; revision=47420
2013-02-01 16:23:16 +00:00
Evan Huus 45a77360ea Rename tcp.data -> tcp.segment_data and add a description field.
Should clear up the confusion from
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8084

svn path=/trunk/; revision=46843
2012-12-29 18:08:11 +00:00
Guy Harris 8ed7a73e22 Fix a bunch of warnings.
Cast away some implicit 64-bit-to-32-bit conversion errors due to use of
sizeof.

Cast away some implicit 64-bit-to-32-bit conversion errors due to use of
strtol() and strtoul().

Change some data types to avoid those implicit conversion warnings.

When assigning a constant to a float, make sure the constant isn't a
double, by appending "f" to the constant.

Constify a bunch of variables, parameters, and return values to
eliminate warnings due to strings being given const qualifiers.  Cast
away those warnings in some cases where an API we don't control forces
us to do so.

Enable a bunch of additional warnings by default.  Note why at least
some of the other warnings aren't enabled.

randpkt.c and text2pcap.c are used to build programs, so they don't need
to be in EXTRA_DIST.

If the user specifies --enable-warnings-as-errors, add -Werror *even if
the user specified --enable-extra-gcc-flags; assume they know what
they're doing and are willing to have the compile fail due to the extra
GCC warnings being treated as errors.

svn path=/trunk/; revision=46748
2012-12-26 05:57:06 +00:00
Alexis La Goutte 267e5baf55 From Francesco Fondelli via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8128 Add TCP Fast Open
This patch provides
i) support for Shared Use of Experimental TCP Options (draft-ietf-tcpm-experimental-options-03)
ii) support for TCP Fast Open (draft-ietf-tcpm-fastopen-02).

A new 'TFO=R' string is appended at the column info in case a client sends a SYN packet with a Fast Open Cookie Request. Moreover, if the server responds with a SYN-ACK containing a Fast Open Cookie option a 'TFO=C' is shown (as well as in any subsequent client attempt to send SYN + DATA).

tcp.options.tfo display filter can be used in order to easily select the complete TFO three-way handshake.

Chrome (and I think also Firefox) has support for client-side TFO. Linux 3.7 got both client and server-side support.

svn path=/trunk/; revision=46723
2012-12-23 18:40:55 +00:00
Michael Mann bb7217ab4b From bug 6123, Fix further dissection of data in TCP packets with the Riverbed Transparency options (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6123)
Allow Raw Data dissector to dissect TCP packets with Riverbed Transparency options if sport dissector (found only in Riverbed) is not found.

#BACKPORT

svn path=/trunk/; revision=46544
2012-12-15 04:28:41 +00:00
Bill Meier 7cd0417af5 Fix numerous instances of a variable/parameter name "shadowing" a library function name;
(At least some (gcc ?) compilers give a "shadow" warning for these).

svn path=/trunk/; revision=46402
2012-12-05 15:56:36 +00:00
Jeff Morriss 0266cceef3 Make all enum_val_t's const.
svn path=/trunk/; revision=46292
2012-11-29 20:15:37 +00:00
Martin Mathieson 0aebd579e3 Show SACK information in TCP graphs. Also add a generated field for the
number of SACK ranges found in the SACK option.

This involved extending the IP options framework to include an extra
void* data field, which in the case of TCP is filled in with the tap
struct - other users currently pass NULL.

I first implemented the graph to sort the SACK ranges and show (in red)
the unacknowledged regions between them, but this became confusing where
the number of ranges is limited by TCP padding bytes. i.e. you can't
tell how many SACKs could have been encoded, so some of the gaps between
ranges may already have been received.

svn path=/trunk/; revision=46006
2012-11-12 03:55:46 +00:00
Jeff Morriss 2552c750e5 We always HAVE_CONFIG_H so don't bother checking whether we have it or not.
svn path=/trunk/; revision=45017
2012-09-20 02:03:38 +00:00
Jeff Morriss 670dff46e4 Fix up the (#if'd out) sequence number analysis debug code so that it compiles and is easier to read. Also fix up some white space.
svn path=/trunk/; revision=44903
2012-09-14 18:20:59 +00:00
Jakub Zawadzki dee4443809 Add data parameter to dissector_try_heuristic
svn path=/trunk/; revision=44871
2012-09-11 08:26:48 +00:00
Jeff Morriss aa5d9d78dd From Robert Bullen via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7683 :
The reassembled fragments tree in the Packet Details view is awesome, but it
lacks one thing: a field that exposes the reassembled data.

tcp.data already exists for exposing a single TCP segment's payload as a byte
array. It would be handy to have something similar for a single application
layer PDU when TCP segment reassembly is involved. I propose
tcp.reassembled.data, named and placed after the already existing field
tcp.reassembled.length.

My primary use case for this feature is outputting tcp.reassembled.data with
tshark for further processing with a script.

The attached patch implements this very feature. Because the reassembled
fragment tree code is general purpose, i.e. not specific to just TCP, any
dissector that relies upon it can add a similar field very cheaply. In that
vein I've also implemented ip.reassembled.data and ipv6.reassembled.data, which
expose reassembled fragment data as a single byte stream for IPv4 and IPv6,
respectively. All other protocols that use the reassembly code have been left
alone, other than inserting NULL into their initializer lists for the newly
introduced struct field reassemble.h:fragment_items.hf_reassembled_data.

svn path=/trunk/; revision=44802
2012-09-07 02:09:59 +00:00
Anders Broman 2aa9312c14 From Ilarion Ishkulov Multisegment PDUs are not reassembled properly with TCP dissector https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7544
svn path=/trunk/; revision=44680
2012-08-26 16:39:11 +00:00
Bill Meier 638d74d43f Use val_to_str_const() where appropriate;
Also (for a few files):
- create/use some extended value strings;
- remove unneeded #include files;
- remove unneeded variable initialization;
- re-order fcns slightly so prefs_reg_handoff...() at end, etc

svn path=/trunk/; revision=44438
2012-08-10 22:55:02 +00:00
Martin Mathieson 99bd7cfe44 Add a preference to that when the window scaling options are not
visible, we can still configure a scaling factor and therefore get
better TCP sequence analysis and see better stream graphs.

A single preference is used for any/all streams for which the true value
isn't known.  I tried to make it obvious when showing the calculated
window size that it came fromt he preference setting.  The default value
for this preference is off, i.e. it won't change existing behaviour.

This was discussed a little at Sharkfest and raised on the developers
list last week.

svn path=/trunk/; revision=43686
2012-07-12 23:57:51 +00:00
Pascal Quantin 472f036552 Do not use same name for filters with incompatible types
svn path=/trunk/; revision=43448
2012-06-23 14:36:21 +00:00
Bill Meier 70cc6362fe Don't define value_string arrays in a .h file (included in multiple places).
Also:
 - don't use val_to_str_const() with a "format" default string;
 - rename 'opt_len_type' enumeration  identifiers to be less generic.

svn path=/trunk/; revision=43210
2012-06-11 18:47:42 +00:00
Chris Maynard ebe8ed3a3e Fix the other part of Coverity CID 703086. I thought I got it with r42798, but apparently that was only 1/2 the fix as sometimes they group more than one bug into a single CID.
svn path=/trunk/; revision=43185
2012-06-10 19:02:03 +00:00
Gerald Combs c408151a80 Try to be a bit more clear that "lost" is from Wireshark's perspective,
not necessarily one of the TCP endpoints.

svn path=/trunk/; revision=42990
2012-06-01 20:54:04 +00:00
Anders Broman 0832853fa8 From Robert Bullen:
The Wireshark and tshark TCP conversations stats tables aggregate reused connections into a single line item

https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7248

svn path=/trunk/; revision=42806
2012-05-23 06:36:47 +00:00
Chris Maynard 509917229b Fix Coverity CID 703086: Dereference after null check in decode_tcp_ports().
svn path=/trunk/; revision=42798
2012-05-23 00:56:15 +00:00
Ronnie Sahlberg 2a2dc8c5f3 TCP: Some protocols running ontop of TCP needs the PDUs to be delivered in order. for example decryption of DCERPCoverHTTP.
For such protocols, hte state gets out of sync of for example the same PDU is invoked twice in a row, which sometimes can happen if there is tcp retransmission and we see the same PDU twice. First for hte original segment and a second time for the tcp retransmission.
These protocols might lack an easy way to detect that a PDU is seen twice or out of order.

To handle this a little better, offer a TCP option that defaults to being disabled but when enabled skips invoking any subdissector for retransmitted or out of order packets.
(For some virtualization environments it sometimes becomes VERY common to see false tcp retransmissions due to segments being captured twice making this even worse)


We dont want this option to default to ON because for most cases we do want the current behaviour where the subdissector is called twice, or more, for any PDU that is retrasnmitted on the TPC layer.
For example, assume a SMB response packet is retransmitted on the TCP level.
This may result in a capture file that looks like
1 -> SMB request
2 <- SMB response to 1  
... 1 second ...
3 <- SMB response to 1   TCP retransmission

For this case we definitely want packet 3 to be passed to the SMB layer so that 
the request/respons ematching will detect that the response time for this transaction was > 1.0 second
We want smb.time to indicate the delta betwenn packets 1 and 3
as well as the SMB Service Response Time to indicate that this command took very long.





svn path=/trunk/; revision=42774
2012-05-22 07:51:12 +00:00
Jakub Zawadzki 8fca2eb7e5 Add missing consts.
svn path=/trunk/; revision=42004
2012-04-10 10:20:20 +00:00
Anders Broman d04de670f8 From Michael Mann:
TCP picks wrong sub-dissector if both dissector choices have the same "minimum segment size"

https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7008

svn path=/trunk/; revision=41954
2012-04-05 11:18:49 +00:00
Martin Mathieson 2570bef0c2 When storing sequence analysis results, add (raw) sequence number and
ack number to the lookup key (which was previously just the frame number).

This helps with situations where multiple segments of the same TCP
conversation can be found in the same frame in a capture (e.g. with LTE
user-plane traffic carried in logged MAC or RLC frames).

svn path=/trunk/; revision=41788
2012-03-27 02:08:48 +00:00
Alexis La Goutte fa68273f40 Add Quick Start IPv6 Option ( And shared Quick Start option between IPv4/IPv6/TCP )
svn path=/trunk/; revision=41681
2012-03-20 08:51:05 +00:00
Chris Maynard e3fdb92a67 Since the nonce and reserved bits were added in r34084, tcp.flags is now 12 bits, so its type needs to be changed from an FT_UINT8 to an FT_UINT16. This should avoid the crash experienced by Lanell Allen as reported on -dev: http://article.gmane.org/gmane.network.wireshark.devel/24846 (although in my testing on Windows XP SP3 (32-bit), Wireshark did not crash).
svn path=/trunk/; revision=40949
2012-02-10 03:37:28 +00:00
Graham Bloice 6a33236a0d Fixed bug with calculation of bytes in flight.
A corner case was posted to the Q&A site showing incorrect calculation of bytes in flight (http://ask.wireshark.org/questions/8843/bytes-in-flight-problems-with-retransmissions)

The capture in question has a tcp segment (frame 12) that is a retransmission of unacked earlier data (frames 4, 9, 10) and also contains some new data.  Eventually an ACK is received for the earlier segments (frame 16) but the code doesn't remove frame 12 from the linked list of unacked segments because it extends past the received ACK.  When more data is received in frame 17, the bytes in flight is calculated from the start of frame 12 rather than from the unacked portion of it, leading to a larger incorrect value.

The change simply updates the starting sequence number in the unacked segment list for any partially acked segment to be the start of unacked data.

The capture in question now shows correct information for bytes in flight, and hopefully the nature of the change won't cause issues elsewhere.

svn path=/trunk/; revision=40929
2012-02-08 11:52:35 +00:00
Chris Maynard f88e871171 Fix some typos.
svn path=/trunk/; revision=40786
2012-02-01 01:41:11 +00:00
Alexis La Goutte dbe733fcfc Fix some Dead Store (Dead assignement/Dead increment) Warning found by Clang
svn path=/trunk/; revision=40375
2012-01-04 17:44:50 +00:00
Alexis La Goutte c3c5e75678 From Andrei Maruseac via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6705
Multipath TCP Option

Extensions for Multipath Operation with Multiple Addresses, as defined in http://tools.ietf.org/html/draft-ietf-mptcp-multiaddressed-04. I implemented this as a TCP option.

From me :
Remove a subtree
Add Subtype in top of multiPath subtree


svn path=/trunk/; revision=40370
2012-01-04 13:01:53 +00:00
Chris Maynard fe290f10f6 Appease the buildbots.
svn path=/trunk/; revision=40281
2011-12-22 19:41:13 +00:00
Chris Maynard a856a7ec53 Revert some of the changes made as part of the patch from bug 6194 committed in r38326. Also, change the 3 separate reserved bit fields to a single 3-bit reserved field to more closely match the spec. Lastly, in accordance with NOTE 2 of Table 3-1 of the spec, display the connection id, whatever it is, rather than assuming it's zero just because the Com bit isn't set.
svn path=/trunk/; revision=40280
2011-12-22 19:22:43 +00:00
Guy Harris bd0e6c50cb The TCP Packet Mood Option was a cute April 1 RFC, but TCP option 25 is
officially listed as "Unassigned", and people might use it for their own
purposes (and, in fact, one bug-submitter was doing so; they probably
should have used 253 or 254, but...).  Get rid of the code to dissect
it.

svn path=/trunk/; revision=40075
2011-12-03 03:01:08 +00:00
Chris Maynard 647c5c0b27 packet_info's in_error_pkt is now a bitfield like in_gre_pkt.
svn path=/trunk/; revision=39764
2011-11-08 18:39:11 +00:00
Jeff Morriss f5e838b602 Remove comma at the end of several enumerator lists.
svn path=/trunk/; revision=39700
2011-11-01 01:23:10 +00:00
Bill Meier 794757ae8f For proto_tree_add_item(..., proto_xxx, ...)use ENC_NA as the encoding arg.
Also: remove trailing whitespace for a number of files.

svn path=/trunk/; revision=39503
2011-10-21 02:10:19 +00:00
Bill Meier 293049dfba Do some conversions of proto_tree_add_item() 'encoding' arg.
(previously missed).

    57   FT_BOOLEAN:       FALSE-->ENC_BIG_ENDIAN
    31   FT_BOOLEAN:       TRUE-->ENC_LITTLE_ENDIAN

    10   FT_BYTES:         ENC_BIG_ENDIAN-->ENC_NA
     1   FT_BYTES:         ENC_LITTLE_ENDIAN-->ENC_NA
    21   FT_BYTES:         FALSE-->ENC_NA
     2   FT_BYTES:         TRUE-->ENC_NA

     2   FT_IPXNET:        ENC_BIG_ENDIAN-->ENC_NA

     6   FT_IPv6:          ENC_BIG_ENDIAN-->ENC_NA
     1   FT_IPv6:          FALSE-->ENC_NA

     6   FT_NONE:          ENC_BIG_ENDIAN-->ENC_NA
    19   FT_NONE:          FALSE-->ENC_NA
     3   FT_NONE:          TRUE-->ENC_NA

     1   FT_STRING:        ENC_BIG_ENDIAN-->ENC_ASCII|ENC_NA
     1   FT_STRING:        ENC_LITTLE_ENDIAN-->ENC_ASCII|ENC_NA
     5   FT_STRING:        FALSE-->ENC_ASCII|ENC_NA
     1   FT_STRING:        TRUE-->ENC_ASCII|ENC_NA

     4   FT_STRINGZ:       ENC_NA-->ENC_ASCII|ENC_NA
     8   FT_STRINGZ:       FALSE-->ENC_ASCII|ENC_NA

     1   FT_INT32:         FALSE-->ENC_BIG_ENDIAN
     1   FT_INT32:         TRUE-->ENC_LITTLE_ENDIAN

    11   FT_UINT8:         0-->ENC_BIG_ENDIAN
   111   FT_UINT8:         FALSE-->ENC_BIG_ENDIAN
    17   FT_UINT8:         TRUE-->ENC_LITTLE_ENDIAN
     1   FT_UINT16:        0-->ENC_BIG_ENDIAN
    68   FT_UINT16:        FALSE-->ENC_BIG_ENDIAN
    18   FT_UINT16:        TRUE-->ENC_LITTLE_ENDIAN
     4   FT_UINT24:        FALSE-->ENC_BIG_ENDIAN
    70   FT_UINT32:        FALSE-->ENC_BIG_ENDIAN
     1   FT_UINT32:        TRUE-->ENC_LITTLE_ENDIAN
     4   FT_UINT64:        FALSE-->ENC_BIG_ENDIAN
     1   FT_UINT64:        TRUE-->ENC_LITTLE_ENDIAN

     1   FT_UINT_STRING:   FALSE-->ENC_ASCII|ENC_BIG_ENDIAN


svn path=/trunk/; revision=39442
2011-10-16 23:38:49 +00:00
Bill Meier 67ee5049d4 Convert 'encoding' parameter of certain proto_tree_add_item() calls in non-autogenerated epan/dissectors:
Specifically:  Replace FALSE|0 and TRUE|1 by ENC_BIG_ENDIAN|ENC_LITTLE_ENDIAN as
  the encoding parameter for proto_tree_add_item() calls which directly reference
  an item in hf[] which has a type of:
     FT_BOOLEAN
     FT_IPv4
     FT_EUI64
     FT_GUID
     FT_UINT_STRING

Also: For type FT_ITv6 use ENC_NA. (This was missed in SVN #39260)

svn path=/trunk/; revision=39328
2011-10-10 00:39:31 +00:00
Bill Meier 4e57694d4a Convert 'encoding' parameter of certain proto_tree_add_item() calls in non-autogenerated epan/dissectors:
Specifically:  Replace FALSE|0 and TRUE|1 by ENC_BIG_ENDIAN|ENC_LITTLE_ENDIAN as
 the encoding parameter for proto_tree_add_item() calls which directly reference
 an item in hf[] which has a type of:
    FT_UINT8
    FT_UINT16
    FT_UINT24
    FT_UINT32
    FT_UINT64
    FT_INT8
    FT_INT16
    FT_INT24
    FT_INT32
    FT_INT64
    FT_FLOAT
    FT_DOUBLE


svn path=/trunk/; revision=39288
2011-10-06 03:35:44 +00:00
Bill Meier 94f36ca4ff Use ENC_NA as encoding for proto_tree_add_item() calls which directly reference an hf item (in hf[] with types:
FT_NONE
   FT_BYTES
   FT_IPV6
   FT_IPXNET
   FT_OID

Note: Encoding field set to ENC_NA only if the field was previously TRUE|FALSE|ENC_LITTLE_ENDIAN|ENC_BIG_ENDIAN

svn path=/trunk/; revision=39260
2011-10-04 22:44:31 +00:00
Bill Meier e6bd9d1a8c Whitespace cleanup:
Use consistent indentation;
 Convert "4 space tabs" to spaces;
 Remove trailing whitespace.

svn path=/trunk/; revision=39082
2011-09-21 18:55:03 +00:00
Bill Meier 781129806f Fix ex "modeline" so it works;
See https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5748

svn path=/trunk/; revision=39081
2011-09-21 17:49:11 +00:00
Stig Bjørlykke 027bfdf5f3 Check for valid tcpd, as it may be NULL.
svn path=/trunk/; revision=38894
2011-09-06 09:18:09 +00:00