Commit Graph

331 Commits

Author SHA1 Message Date
Michael Mann 66a430349f Cache the "tcp_tree" with p_add_proto_data. Bug 9518.
This is more reliable than doing "tree math" and corrects the intention of 5470356154 which made the incorrect assumption that tcp_dissect_pdus will be called with the tree that is passed into a protocol's main dissection function (directly from TCP).

Change-Id: I6ffc2188420ab74784c7bc2c69aa79ff071c90b6
Reviewed-on: https://code.wireshark.org/review/1214
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-04-22 13:45:35 +00:00
Guy Harris 97869f2dec More name changes.
Add ep_ to routines that may return ephemeral strings.

Change "get_XXX" to "XXX_to_display" if the routine returns a formatted
string if it can't get a name.

Change-Id: Ia0e82784349752cf4285bf82788316c9588fdd88
Reviewed-on: https://code.wireshark.org/review/1217
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-04-19 19:30:17 +00:00
Guy Harris ad0066c81e Save and restore the current_proto string in tcp_dissect_pdus().
That way, the right protocol gets shown for exceptions in PDUs after the
one for which dissection failed.

Change-Id: I9f212fe55f19a7a818cd58cd0611683cbb723c0c
Reviewed-on: https://code.wireshark.org/review/1189
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-04-17 21:38:38 +00:00
Michael Mann b40cb1adea Apply found fix-encoding-args.pl errors in the dissector directory.
I coincidentally found a few files with errors, so I thought it might be time to run it on the whole directory again.

Change-Id: Ia32e54b3b1b94e5a418ed758ea79807c8bc7e798
Reviewed-on: https://code.wireshark.org/review/978
Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-04-06 15:11:36 +00:00
Guy Harris 8881f3f61a Don't truncate the options field.
Create a placeholder protocol tree item under which to put the options,
do the analysis of fields from the fixed-length portion of the TCP
header (such as sequence numbers), and then do a straightforward
dissection of the options, throwing an exception if we run past the end
of the options field.

This is a bit simpler, and doesn't add confusing notes about
truncation of the options.

XXX - we're currently not including selective acknowledgments in any of
the SEQ/ACK analysis; should we?  That means, of course, that we have to
dissect the options before doing that analysis, and if the options were
cut short by slicing, you lose....

Change-Id: I425a6c83f26512b802267f76739cbf40121b3040
Reviewed-on: https://code.wireshark.org/review/511
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-03-05 02:33:20 +00:00
Alexis La Goutte 296591399f Remove all $Id$ from top of file
(Using sed : sed -i '/^ \* \$Id\$/,+1 d')

Fix manually some typo (in export_object_dicom.c and crc16-plain.c)

Change-Id: I4c1ae68d1c4afeace8cb195b53c715cf9e1227a8
Reviewed-on: https://code.wireshark.org/review/497
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-04 14:27:33 +00:00
Evan Huus 21e0a63b29 Add remove_last_data_source and fix bug 9169
The OP asked 9169 to be reopened because the capture was spewing ~40GB of output
when dissected with tshark. Investigation showed this was because the HTTP
dissector was requesting ONE_MORE_PACKET reassembly a lot, and TCP was adding
each step as a data-source which was being printed by tshark's hex dump. This
was leading to O(n^2) of output.

To fix, introduce function remove_last_data_source which removes the most recent
data source from the list. If the subdissector in TCP reassembly asks for
ONE_MORE_PACKET, assume it hasn't added any tree items (since it shouldn't have)
and remove the data source since it is unnecessary.

This may break dissectors which add tree items and *then* return
ONE_MORE_PACKET, since they will have their data source removed out from under
them. I believe those cases should be fixed to not add tree items until they're
sure they have enough data.

Change-Id: Iff07f959b8b8bd1acda9bff03f7c8684901ba8aa
Reviewed-on: https://code.wireshark.org/review/38
Reviewed-by: Evan Huus <eapache@gmail.com>
Tested-by: Evan Huus <eapache@gmail.com>
2014-01-30 22:11:41 +00:00
Guy Harris dd152d81af Don't cast away constness.
svn path=/trunk/; revision=54769
2014-01-14 05:49:04 +00:00
Jörg Mayer 1242a77e74 Change level off TCP/RST expertitem from chat to warn. Add a comment
that RST is still an indicator for network errors/problems.

svn path=/trunk/; revision=54709
2014-01-13 10:51:37 +00:00
Jeff Morriss b20e6a20eb Make the SCTP Decode-As dialog more consistent with the TCP one.
Rename the 2nd SCTP Transport tab to "SCTP(PPID)" to make it obvious what it
is.

Fix up casing and code formatting in both SCTP and TCP Decode-As code.

svn path=/trunk/; revision=54391
2013-12-23 16:50:25 +00:00
Jakub Zawadzki e0e86bab5a Fix const warnings.
svn path=/trunk/; revision=54092
2013-12-14 14:33:46 +00:00
Anders Broman 138ce6f204 Try to fix "initializer element is not computable at load time"
svn path=/trunk/; revision=53962
2013-12-12 17:32:22 +00:00
Anders Broman 07c5bb3480 - Forward declaration of register functions.
svn path=/trunk/; revision=53930
2013-12-11 06:10:45 +00:00
Michael Mann 9b7fb8a811 Create the ability to have packet scoped "proto" data. Bug 9470 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9470)
I'm not sold on the name or module the proto_data functions live in, but I believe the function arguments are solid and gives us the most flexibility for the future.  And search/replace of a function name is easy enough to do.

The big driving force for getting this in sooner rather than later is the saved memory on ethernet packets (and IP packets soon), that used to have file_scope() proto data when all it needed was packet_scope() data (technically packet_info->pool scoped), strictly for Decode As.

All dissectors that use p_add_proto_data() only for Decode As functionality have been converted to using packet_scope().  All other dissectors were converted to using file_scope() which was the original scope for "proto" data.

svn path=/trunk/; revision=53520
2013-11-23 02:20:13 +00:00
Michael Mann 76ab93ea94 Provide "Decode As" functionality through dissectors themselves instead of the GUI. Bug 9450 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9450)
The basic idea behind this design is to have dissectors register with a "decode as list" with their name and dissector table.  When "Decode As" dialog is launched, any "registered" dissector found in the packet will cause a tab to be created in the dialog.

This patch includes just the dissector portion of the functionality (minus packet-dcerpc.[ch] because it has hooks to the current GUI)

svn path=/trunk/; revision=53445
2013-11-20 19:17:08 +00:00
Gerald Combs 190bdc32de Add packet information and selection to the Follow Stream dialog.
Collect packet numbers when following streams so that we can correlate
text positions with packets. Add a FollowStreamText class so that we can
track mouse events. Add a hint label that shows the packet under the
cursor along with packet counts and the number of "turns".

Add the packet number to the C array dump. Note that dumping to YAML
might be useful for Scapy users.

svn path=/trunk/; revision=53314
2013-11-14 17:37:40 +00:00
Evan Huus fc08bf1143 Fix what appears to be a mistake during the conversion in r53036 from
dissector_try_uint to dissector_try_uint_new: protocols called due to TCP port
matching were not getting added to the list of protocols in the frame. The
"add_proto_name" parameter should be TRUE except in unusual circumstances.

svn path=/trunk/; revision=53308
2013-11-13 23:43:08 +00:00
Gerald Combs 1d8a895fa4 Try using UTF8_RIGHTWARDS_ARROW to indicate direction.
If this doesn't cause any problems we should probably move
utf8_entities.h from ui to wsutil.

svn path=/trunk/; revision=53276
2013-11-12 17:34:50 +00:00
Michael Mann 5470356154 Remove tcp_tree from packet_info structure.
All dissectors that call tcp_dissect_pdus() have the same relative tree position, so it doesn't need to be specifically saved in the packet_info.

svn path=/trunk/; revision=53253
2013-11-11 19:30:59 +00:00
Jakub Zawadzki ae59b09443 Add missing includes in order to remove exceptions.h from proto.h (next commit).
svn path=/trunk/; revision=53230
2013-11-10 15:59:37 +00:00
Michael Mann 8081cf1d90 Add data parameter to tcp_dissect_pdus() as well as convert it to using "new" style dissectors.
Now that "bytes consumed" can be determined, should tcp_dissect_pdus() take advantage of that?

Should tcp_dissect_pdus return length (bytes consumed)?  There are many dissectors that just call tcp_dissect_pdus() then return tvb_length(tvb).  Seems like that could all be rolled into one.

svn path=/trunk/; revision=53198
2013-11-09 17:46:28 +00:00
Evan Huus 389423aaaa Replace pinfo->layer_names as a string with pinfo->layers as a wmem_list of
protocol IDs. This is substantially more efficient, which means we can build it
all the time rather than only if tree (in my benchmarks the extra time taken is
not large enough to be statistically significant even over tens of thousands of
packets).

This fixes what was probably a bug in btobex that relied on layer_names for
non-tree dissection. It also enables a much simpler fix for
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9303

svn path=/trunk/; revision=53089
2013-11-05 17:48:48 +00:00
Michael Mann f8f1f48371 Pass struct tcpinfo into all TCP subdissectors instead of through pinfo->private_data.
svn path=/trunk/; revision=53036
2013-11-02 00:36:30 +00:00
Michael Mann b6484432aa Allow try_conversation_dissector() to pass data to subdissectors.
svn path=/trunk/; revision=53035
2013-11-01 23:45:10 +00:00
Bill Meier 0ad98563a2 From didier gautheron: remove redundant or use faster col_xxx functions
- when the text parameter is constant col_add_str() and col_set_str() are equivalent but col_set_str() is faster.
- same for  replace col_append_fstr and col_append_str
- remove col_clear() when it's redundant:
    + before a col_set/col_add if the dissector can't throw an exception.
- replace col_append() after a col_clear() with faster col_add... or col_set

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


svn path=/trunk/; revision=52948
2013-10-29 14:09:20 +00:00
Pascal Quantin debe9b6591 As reported by Didier Gautheron on -dev (http://www.wireshark.org/lists/wireshark-dev/201310/msg00159.html) :
Since r49923, TCP flags are no more displayed in info column when tree is NULL

svn path=/trunk/; revision=52597
2013-10-14 08:36:38 +00:00
Chris Maynard 65accd3c18 Don't assume that tvb_length_remaining() or tvb_reported_length_remaining() always return a value >= 0. Part of fix for https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9263
#BACKPORT(1.10,1.8)

svn path=/trunk/; revision=52570
2013-10-12 18:03:34 +00:00
Evan Huus 2ed259ccbc When TCP options are truncated, we only add the truncated length to the tree,
not the whole length. Fixes an invalid access with the capture from
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9263

svn path=/trunk/; revision=52523
2013-10-10 23:59:57 +00:00
Chris Maynard 59c91b3c52 Safer to compare return value of tvb_reported_length_remaining() > 0 than != 0.
Convert tabs to spaces.

svn path=/trunk/; revision=52495
2013-10-10 16:04:41 +00:00
Cal Turney 16085e8616 If the capture is frame sliced at or beyond the TCP 20-byte fixed length portion of the TCP header and tcp_analyze_seq is enabled, TCP analysis is not conducted: As much of the options field as possible should be dissected and TCP analysis should be performed.
Patch was tested with snaplens of: 
49 and 52:  (TCP fixed header incomplete) TCP analysis NOT performed.
54:  (Fixed header complete but entire options wfield was sliced off) TCP analysis ran and was OK.
64:  (Fixed header complete but a portion of the options field was missing) Options were dissected to the extent possible.  TCP analysis ran and was OK.
66:  (Fixed header and options complete) TCP analysis ran and was OK.
70:  (Fixed header and options complete plus  4 bytes) TCP analysis ran and was OK.

svn path=/trunk/; revision=52467
2013-10-09 16:13:18 +00:00
Michael Mann c70b1a548b Convert proto_tree_add_int_format calls to proto_tree_add_int_format_value where appropriate.
svn path=/trunk/; revision=52301
2013-09-30 16:10:40 +00:00
Pascal Quantin a0c53ffaa1 emem -> wmem conversion:
- ep_tvb_get_bits() -> wmem_packet_tvb_get_bits()
- tvb_g_memdup()/ep_tvb_memdup() -> tvb_memdup()
- tvb_fake_unicode()/tvb_get_ephemeral_faked_unicode() -> tvb_get_faked_unicode()
- tvb_get_g_string()/tvb_get_ephemeral_string()/tvb_get_seasonal_string() -> tvb_get_string()
- tvb_get_g_unicode_string()/tvb_get_ephemeral_unicode_string() -> tvb_get_unicode_string()
- tvb_get_ephemeral_string_enc() -> tvb_get_string_enc()
- update docs accordingly

svn path=/trunk/; revision=52172
2013-09-22 15:50:55 +00:00
Michael Mann 346f803d42 Convert proto_tree_add_uint_format to proto_tree_add_uint_format_value if hf_ field name is the first part of the formatted string. This was all manual inspection and most cases were either:
1. Case sensitivity differences between hf_ field name and formatted string.
2. Unnecessary whitespace between hf_ field name and colon in formatted string

There are cases where the hf_ field name doesn't quite match the proto_tree_add_uint_format, but it's close enough that one of them should be "right", I'm just not sure which is, I just know the string in proto_tree_add_uint_format is the one displayed.

svn path=/trunk/; revision=52098
2013-09-16 10:39:06 +00:00
Michael Mann b38ee917b1 Convert proto_tree_add_uint_format to proto_tree_add_uint_format_value if hf_ field name is the first part of the formatted string. This was done with a perl script on the dissectors directory (packet-*.c), followed by manual inspection of the output. The manual inspection yielded a few cases that really should have been proto_tree_add_uint or proto_tree_add_item, so I updated them accordingly.
The script didn't catch as many as I would have liked, but it's a start.

The most common (ab)use of proto_tree_add_uint_format was for appending strings to CRC/checksum values to note good or bad CRC/checksum.

svn path=/trunk/; revision=52045
2013-09-15 01:48:30 +00:00
Gerald Combs 07c3d057b8 Add previous/next stream navigation to the TCP stream graph dialog.
Add get_tcp_stream_count() to the TCP dissector and modify
graph_segment_list_get() to allow matching based solely on a stream.

Use text instead of icons for the mouse click behavior buttons. Remove
their PNG resources since we aren't using them any more. Fix setting the
cursor in the graph widget.

svn path=/trunk/; revision=51989
2013-09-12 21:37:47 +00:00
Michael Mann 9e3f9b449f expert_add_info_format_text -> expert_add_info_format
svn path=/trunk/; revision=51852
2013-09-09 00:44:09 +00:00
Chris Maynard f0a66b2e3e Another acknowledgment number tweak: If the ACK flag wasn't set such that the base_seq wasn't subtracted from it, then if we need to recover absolute values later on, don't add the base_seq value back either.
svn path=/trunk/; revision=51433
2013-08-19 22:06:48 +00:00
Chris Maynard d0722af6f7 When using relative sequence numbers, don't scale acknowledgment numbers unless the ACK bit is actually set; otherwise doing so results in many erroneous packets matching a filter such as, "(tcp.ack > 0) && (tcp.flags.ack == 0)". With this change, the number of expert infos noting non-zero acknowledgment numbers when the ACK bit is not set is the same as the number of packets that are displayed when applying the above display filter regardless of whether using relative or absolute sequence numbers. (Tested using the menagerie's mond.pcap file)
svn path=/trunk/; revision=51432
2013-08-19 21:41:49 +00:00
Chris Maynard e20e338a9e Someone is bound to miss these expert info items, so add back expert info items for ack and urgent pointer when their respective flags are not set; however, don't indicate "Broken TCP" and only add them as Notes rather than as Warnings as was previously the case prior to r51356 since nowhere does it indicate these fields must be zero when their respective bits aren't set.
Speaking of r51356, a clarification to its commit message is in order: Initially my intention was to only add the urgent pointer field when the URG bit was set; however, I then noticed that the acknowledgment number field was always being added irrespective of the ACK bit.  Had I made the change as I originally intended, it would have introduced an inconsistency.  After some deliberation, I opted for consistency, but botched the commit message.

svn path=/trunk/; revision=51431
2013-08-19 21:17:04 +00:00
Chris Maynard 618c6eeb3c Fix Coverity CID 1062616: Unused pointer value.
svn path=/trunk/; revision=51384
2013-08-15 17:37:14 +00:00
Chris Maynard 6730531348 Nowhere in the RFC's (793 or otherwise) does it indicate that if the URG bit is not set that the urgent pointer field must be zero.
References:
http://tools.ietf.org/html/rfc793, http://tools.ietf.org/html/rfc1122, ...
http://www.wireshark.org/lists/ethereal-dev/200307/msg00297.html

Similarly, nowhere does it say that the acknowledgment number field must be zero if the ACK bit is not set.

This patch effectively reverts r37721.  If non-zero urgent pointers are of interest to you when the URG bit is not set, then a filter such as follows can be used:

    (tcp.flags.urg == 0) && !(tcp[18:2] == 00:00)

Similarly, if non-zero acknowledgment numbers are of interest to you when the ACK bit is not set, then use this filter:

    (tcp.flags.ack == 0) && !(tcp.ack == 0)

For consistency, should we avoid adding the ack field in this case as well?  The above filter would then change to:

    (tcp.flags.ack == 0) && !(tcp[8:4] == 00:00:00:00)

This change was prompted by the following question on ask.wireshark.org:
http://ask.wireshark.org/questions/23753/tcp-urgent-pointer-value-not-displayed

svn path=/trunk/; revision=51356
2013-08-14 18:35:36 +00:00
Evan Huus 960a461c8a Convert SSL and TCP dissectors to wmem (with the exception of UAT).
svn path=/trunk/; revision=51043
2013-07-31 01:26:05 +00:00
Jakub Zawadzki a18172147f Remove fragment_data, add fragment_head, fragment_item - for now alias it to the same structure.
This is begin of work to split fragment head and fragments items.

svn path=/trunk/; revision=50708
2013-07-17 21:12:24 +00:00
Evan Huus a430b138e9 Replace glib memory with wmem. Fixes a substantial memory leak in the TCP
dissector (potentially several megabytes for a large capture).

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

svn path=/trunk/; revision=50652
2013-07-16 01:57:30 +00:00
Jakub Zawadzki c766e78cfa Rewrite reassemble API to use TVBs instead of raw data.
(it seems to be working for TCP ^^)

svn path=/trunk/; revision=50580
2013-07-14 14:42:05 +00:00
Evan Huus 8dfe279520 Remove unused parameters.
svn path=/trunk/; revision=50304
2013-07-01 19:55:39 +00:00
Michael Mann 71e6d4be77 Made an attempt at making all TCP expert info filterable. Many of the expert info "items" are shared with a FT_NONE (hf_ display) filter, so I replaced the FT_NONE filter used with proto_tree_add_none_format() and just went with an expert info "item" with the same display filter name. The text between the "text" item and the "expert info" item varied, so I'd tried to best merge the two.
"tcp.analysis.duplicate_ack" has both an hf_ and ei_ "item" so that the duplicate ack # and frame # can be assembled properly in the tree.  Since hf_tcp_analysis_duplicate_ack is of type FT_NONE, the duplicative display filter name is okay.

svn path=/trunk/; revision=50302
2013-07-01 16:32:52 +00:00
Bill Meier 8d5bbb4146 Define certain 'const char *...' arrays as static.
Reduces code memory usage and execution time.
(See SVN #50271)


svn path=/trunk/; revision=50292
2013-07-01 13:03:23 +00:00
Michael Mann 4d18fdf67d Add expert info to dissect_ip_tcp_options(). The proto_tree_add_text seems a bit duplicative, but the byte highlighting over the whole option is nice.
svn path=/trunk/; revision=50248
2013-06-30 03:16:32 +00:00
Michael Mann e5af2f55ee Separate IP option header fields for each dissector that uses dissect_ip_tcp_options(). Bug 8823 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8823)
svn path=/trunk/; revision=50230
2013-06-29 19:59:08 +00:00