Commit Graph

218 Commits

Author SHA1 Message Date
Anders Broman 1d16d95443 From beroset:
changed implicit casts to explicit casts and changed name of field from new to new_d (new dissector)

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

svn path=/trunk/; revision=48290
2013-03-14 06:46:29 +00:00
Jeff Morriss f229d12858 Fix the plurality of the length of a data source if it has only 1 byte (I'm
looking at a "Bitstring tvb" that is only 1 byte long).

svn path=/trunk/; revision=48127
2013-03-06 01:53:03 +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
Evan Huus b9c6f71fe4 Create a wmem pool in pinfo and use it for some address allocations.
A (better?) fix for https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8030

See also thread starting at:
http://www.wireshark.org/lists/wireshark-dev/201212/msg00001.html

svn path=/trunk/; revision=46331
2012-12-02 17:01:04 +00:00
Evan Huus 9f03dfb42d Enter and leave wmem's file scope appropriately.
svn path=/trunk/; revision=45977
2012-11-09 00:08:27 +00:00
Jakub Zawadzki 2fd81fdaf9 Move ep_free_all() *AFTER* packet dissection.
Use glib allocator for data_source.

Thread on wireshark-dev: http://www.wireshark.org/lists/wireshark-dev/201210/msg00116.html

svn path=/trunk/; revision=45673
2012-10-20 20:04:40 +00:00
Jakub Zawadzki b53dbea042 Make data_source opqaue, add getter for tvb.
svn path=/trunk/; revision=45672
2012-10-20 19:54:56 +00:00
Jakub Zawadzki 78631020b8 Add wtap_pseudo_header union to wtap_pkthdr structure.
Use pkthdr instead of pseudo_header as argument for dissecting.

svn path=/trunk/; revision=45601
2012-10-16 21:50:57 +00:00
Gerald Combs c91c1df500 Use seasonal allocation for name resolution. This effectively scrubs our
resolution information between capture files so that we don't leak host
entries from one file to another (e.g. embarassing-host-name.example.com
from file1.pcapng into a name resolution block in file2.pcapng).

host_name_lookup_cleanup and host_name_lookup_init must now be called
after each call to se_free_all. As a result we now end up reading our
various name resolution files much more than we should.

svn path=/trunk/; revision=45511
2012-10-12 21:37:02 +00:00
Jeff Morriss 3729335973 We always HAVE_CONFIG_H so don't bother checking whether we have it or not.
svn path=/trunk/; revision=45016
2012-09-20 01:48:30 +00:00
Jakub Zawadzki a016cd7740 Revert r44978: dissector_add_uint: Legalize formerly improper use of the API when calling it with pattern value of 0
dissector_add_uint() is *not only* used by tcp.port/udp.port dissector tables where 0 is not valid port number,
in some dissector tables 0 is valid protocol number, packet type, etc..

Sample dissectors using dissector_add_uint(.pattern = 0):
  packet-ansi_637.c:2348: dissector_add_uint("ansi_a.sms", 0, ansi_637_trans_handle);
  packet-cip.c:6017:      dissector_add_uint("cip.class.iface", 0, cip_class_generic_handle );
  packet-lon.c:723:       dissector_add_uint("cnip.protocol", 0, lon_handle);
  packet-q931.c:3599:     dissector_add_uint("lapd.sapi", LAPD_SAPI_Q931 /* 0 */, q931_handle);


svn path=/trunk/; revision=44980
2012-09-18 19:29:00 +00:00
Jörg Mayer ce7c79c0a3 dissector_add_uint:
Legalize formerly improper use of the API when calling it with
   pattern value of 0

svn path=/trunk/; revision=44978
2012-09-18 19:04:04 +00:00
Jakub Zawadzki a406bb1a50 Add data parameter to dissector_try_uint_new
svn path=/trunk/; revision=44874
2012-09-11 09:06:48 +00:00
Jakub Zawadzki 27fb6880c4 Add new function: call_dissector_with_data
svn path=/trunk/; revision=44873
2012-09-11 09:06:13 +00:00
Jakub Zawadzki 9f92dc93c5 Add data parameter to call_dissector_only.
svn path=/trunk/; revision=44872
2012-09-11 08:28:07 +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
Jakub Zawadzki 5a8783f5b1 Initial commit to support yet another method of passing data between dissectors.
Add new parameter 'data' to heur_dissector_t and new_dissector_t, for now it's always NULL

svn path=/trunk/; revision=44860
2012-09-10 21:40:21 +00:00
Evan Huus d574361f5c Use g_hash_table_new_full() instead of g_hash_table_new() for subdissector
registration tables, and use g_free as the value_destroy_func. This saves us
from manually freeing the value when we remove an item, and prevents us from
leaking memory when we accidentally overwrite an existing item.

svn path=/trunk/; revision=44814
2012-09-08 15:03:07 +00:00
Evan Huus baf111a23c Add casts to fix compilation with GCC.
Remove * from gconstpointers, they are already pointer types.
Add modelines to packet.c and clean up indentation a bit.

svn path=/trunk/; revision=44698
2012-08-29 22:19:29 +00:00
Jakub Zawadzki 2ec7c89c33 Fix memleak.
svn path=/trunk/; revision=44697
2012-08-29 22:14:55 +00:00
Michael Mann e5e09f7016 Fix Bug 7348 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7348)
svn path=/trunk/; revision=44696
2012-08-29 21:23:07 +00:00
Jeff Morriss 89cfdc3559 Fix https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=3315 -
make Save-As/Displayed/All-Packets save not only the displayed packets but
also any other packets needed (e.g., for reassembly) to fully dissect the
displayed packets.

This works only for the "All packets" case; choosing only the Selected packet,
the Marked packets, or a range of packets would require actually storing which
packets depend on which (too much memory) or going through the packet list many
times (too slow).  Also, this behavior is always the case: you can't save the
displayed packets without their dependencies (I don't see why this would be
desirable).

So far this is done for SCTP and things using the reassembly routines (TCP has
been tested).

The Win32 dialog was modified but hasn't been tested yet.

One confusing aspect of the UI is that the Displayed count in the Save-As
dialog does not match the number of displayed packets.  (I tried renaming the
button "Displayed + Dependencies" but it looked too big.)  The tooltip tries
to explain this and the fact that this works only in the All-Packets case;
suggestions for improvement are welcome.


Implementation details:

Dissectors (or the reassembly code) can list frames which were needed to
build the current frame's tree.  If the current frame passes the display
filter then each listed frame is marked as "depended upon" (this takes up the
last free frame_data flag).

When performing a Save-As/Displayed/All-Packets then choose packets which
passed the dfilter _or_ are depended upon.

svn path=/trunk/; revision=41216
2012-02-28 03:19:49 +00:00
Bill Meier b83e1b218f Add 'heur_dissector_set_enabled()' to allow a dissector to enable/disable heuristic dissection;
Rename some vars;
Do some minor re-indentation and whitespace changes.

svn path=/trunk/; revision=40601
2012-01-20 02:43:37 +00:00
Bill Meier ebe33ba92a Add tshark option '-G heuristic-decodes' to dump heuristic dissector tables.
svn path=/trunk/; revision=40309
2011-12-28 15:05:59 +00:00
Anders Broman 8259fbb105 Preparation to make it possible to dissable heuristic protocols
trough the proto dialouge.

svn path=/trunk/; revision=40215
2011-12-15 20:39:01 +00:00
Guy Harris c1f993eef5 Clamp the reported length of a packet at G_MAXINT for now, to avoid
crashes due to having no tvbuffs for an epan_dissect_t.

Fixes bug 6663 and its soon-to-be-duplicates.

svn path=/trunk/; revision=40164
2011-12-13 00:44:22 +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 ab7ec88be5 Delay freeing of seasonal memory until after the conversation cleanup routine
has been called.

In the conversation cleanup routine, free the GSlist for any proto_data which
may have been hanging off the (se_allocated) conversation.

svn path=/trunk/; revision=39484
2011-10-20 02:29:13 +00:00
Stig Bjørlykke ad6be9beb8 Whitespace cleanup.
svn path=/trunk/; revision=38893
2011-09-06 09:09:36 +00:00
Anders Broman 377bfd19a0 List heuristic tables in Internals->Disscetor tables menu.
svn path=/trunk/; revision=38881
2011-09-05 13:04:23 +00:00
Gerald Combs 713a85de8a Make sure our root tvb is initialized in case its creation fails.
Untested fix for bug 6135.

svn path=/trunk/; revision=38410
2011-08-08 17:25:35 +00:00
Gerald Combs 49b92440de More GLIB_CHECK_VERSION cleanups. Update the minimum GLib/GTK+ versions
in README.devloper. Remove g_gnuc.h since it's no longer needed. Remove
tvbuff_init(), tvbuff_cleanup(), reassemble_init(), and
reassemble_cleanup() since they were only used for older GLib versions
which didn't support GSlices. Assume we always support the "matches"
operator.

svn path=/trunk/; revision=37978
2011-07-11 20:32:19 +00:00
Guy Harris 32726b84d2 If a dissector table doesn't exist, print a more useful message, and
only abort if WIRESHARK_ABORT_ON_DISSECTOR_BUG is set.

svn path=/trunk/; revision=37510
2011-06-01 18:02:16 +00:00
Guy Harris 1372515b02 More eradication of old-style function definitions.
svn path=/trunk/; revision=37216
2011-05-17 22:18:32 +00:00
Bill Meier ffeff72f02 Fix a typo in a text string; use consistent indentation.
svn path=/trunk/; revision=36735
2011-04-20 16:35:42 +00:00
Stig Bjørlykke a6476ba91b Added dissector_handle_get_long_name().
svn path=/trunk/; revision=36412
2011-03-31 12:14:59 +00:00
Guy Harris a8bc4a0d13 Rename the routines that handle dissector tables with unsigned integer
keys to have _uint in their names, to match the routines that handle
dissector tables with string keys.  (Using _port can confuse people into
thinking they're intended solely for use with TCP/UDP/etc. ports when,
in fact, they work better for things such as Ethernet types, where the
binding of particular values to particular protocols are a lot
stronger.)

svn path=/trunk/; revision=35224
2010-12-20 05:35:29 +00:00
Jeff Morriss e17b9ccec1 Rev 29427 added packet_add_new_data_source() with a comment indicating that
the data source does not need to be allocated if (!tree).

Rev 30158 took the if (!tree) check out indicating that the check was invalid.

So: (since packet_add_new_data_source() now only calls add_new_data_source()),
remove packet_add_new_data_source().

svn path=/trunk/; revision=34717
2010-10-30 16:00:30 +00:00
Sake Blok 0618e53168 Enable "Decode As..." for ethertype 0x0000 (fix for bug 4721)
svn path=/trunk/; revision=32723
2010-05-08 07:55:12 +00:00
Bill Meier 6812b68eb1 From Yaniv Kaul: constify parameters
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=4422

 From me: Fix a number of instances where the function prototype or
  the function definition wasn't changed so there was a mismatch 
  thus causing Windows (but not gcc) compilation errors.

svn path=/trunk/; revision=32365
2010-04-03 18:18:50 +00:00
Bill Meier d32b4c0758 Revert SVN #32360 until Windows compilation errors corrected.
svn path=/trunk/; revision=32361
2010-04-02 15:18:03 +00:00
Bill Meier 049f9eac85 From Yaniv Kaul: constify parameters
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=4422

svn path=/trunk/; revision=32360
2010-04-02 14:37:49 +00:00
Guy Harris b395a98305 Squelch a bunch of compiler warnings.
svn path=/trunk/; revision=31961
2010-02-23 04:35:23 +00:00
Anders Broman cd0147c004 Make sure we have a handle for the dissector.
svn path=/trunk/; revision=30824
2009-11-04 17:13:01 +00:00
Bill Meier adc374c903 Fix some indentation.
svn path=/trunk/; revision=30527
2009-10-12 01:31:01 +00:00
Kovarththanan Rajaratnam 1b668036d1 Move dissector add sanity check to separate function
svn path=/trunk/; revision=30346
2009-10-05 18:52:46 +00:00
Guy Harris 3a92e1e456 The data sources can be used even if the protocol tree isn't being built
or isn't visible.

Clean up some indentation.

svn path=/trunk/; revision=30158
2009-09-25 21:29:36 +00:00
Kovarththanan Rajaratnam 0e5cef61be Split a bunch of init routines into init() and cleanup(). This allows us to free memory properly on shutdown.
This is an initial step. There's still some work to do.

svn path=/trunk/; revision=29754
2009-09-06 18:25:23 +00:00
Kovarththanan Rajaratnam b3b9be09c7 We track all protocols that appear in each packet in the frame dissector. This is an expensive operation because we:
* Disable the TRY_TO_FAKE_THIS_ITEM optimization
* Use GString to store the protocols

We should only do this if the 'hf_frame_protocols' is referenced (unlikely)

svn path=/trunk/; revision=29733
2009-09-06 07:55:17 +00:00
Kovarththanan Rajaratnam 7d44262406 This patch introduces packet_add_new_data_source() which effectively deprecates add_new_data_source(). This is based on the following observation:
1) The tvb + name (aka. data_source) is only used when the protocol tree is visible

The current implementation of add_new_data_source() doesn't take this into account and simply allocates a data_source regardless. This is what packet_add_new_data_source() tries to rectify.

A couple of dissectors have already been switched over to the new packet_add_new_data_source(). Many are still missing. Help appreciated!

svn path=/trunk/; revision=29427
2009-08-15 06:38:10 +00:00