Commit Graph

430 Commits

Author SHA1 Message Date
Stephen Fisher b0a09b3c8b Add/fix a few calls to col_custom_set_fstr() for custom columns.
svn path=/trunk/; revision=24328
2008-02-14 06:10:54 +00:00
Stephen Fisher 8f3a1b0d16 Check in changes originally checked in as SVN revision 24308 (new column
type: Custom) that were backed out in SVN revision 24309.

Changes since that revision include a reworking of the handling of the
cfile/cinfo variables in epan/column-utils.c, addition of three new
functions to libwireshark.def and a bug fix to prevent a crash when no
custom columns were not in use.

Compilation verified locally on MacOS X, Linux and Windows.


svn path=/trunk/; revision=24317
2008-02-13 05:05:33 +00:00
Stephen Fisher 5e893a8b1c Revert commit 24308 until I can get it to compile on Windows/Linux/Solaris
(strangely, it compiled fine on my MacOS X machine).


svn path=/trunk/; revision=24309
2008-02-12 08:09:22 +00:00
Stephen Fisher 0a85a9e4c6 Introduce a new column type called custom, which lets you put any display
filter name in the description field and it will display that field in the
packet list if it occurs in that packet.  Note that the more common fields
are implemented, but a number of them remain to be implemented in
epan/proto.c.  I will work on these other fields as I have time.


svn path=/trunk/; revision=24308
2008-02-12 03:16:09 +00:00
Jaap Keuter 90674d7c9e Print the string to STDOUT regardless of the value of tree.
svn path=/trunk/; revision=24114
2008-01-16 18:39:32 +00:00
Stig Bjørlykke a2d1e9005d This patch adds support for configuration profiles, which can be used to
configure and use more than one set of preferences and configuration files.

This can be found in the "Configuration Profiles..." menu item from the Edit
menu, or by pressing Shift-Ctrl-A.  It's also possible to start wireshark
and tshark with a named profile by using the "-C ProfileName" option.
A new status pane in the main window will show the current profile.

The configuration files currently stored in the Profiles are:
- Preferences
- Capture Filters
- Display Filters
- Coloring Rules
- Disabled Protocols
- User Accessible Tables

The recent data are by design not added to the profile.

Planned future enhancements:
- make a more convenient function to switch between profiles
- add a "clone profile" button to copy an existing profile
- make the profiles list active and accept return as OK
- save users "Decode as" in the profile
- make new, clone and deletion of profiles more secure
- make some of the recent values available in the profile

This patch also fixes:
- setting default status pane sizes
- a bug setting status pane for packets when not having main lower pane.

svn path=/trunk/; revision=24089
2008-01-14 16:40:23 +00:00
Jaap Keuter abe4e72137 Describe text only field as "Text Item", shown in status bar.
Improve documentation headers.

svn path=/trunk/; revision=23938
2007-12-22 10:47:26 +00:00
Gerald Combs be6e31fa44 Register the "samr.nt_password" preference as obsolete.
svn path=/trunk/; revision=23794
2007-12-07 18:50:41 +00:00
Ronnie Sahlberg 0c09ac97f6 #if out a function that is only used when building with glib 2 or later
svn path=/trunk/; revision=23730
2007-12-04 00:56:11 +00:00
Guy Harris ce635c2310 Severities are unsigned.
svn path=/trunk/; revision=23727
2007-12-03 23:02:09 +00:00
Tomas Kukosa 6caaafbb6d Next few improvements to speed up startup about 10%.
- use GTree instead of GList for preference module lists

svn path=/trunk/; revision=23679
2007-11-30 09:22:01 +00:00
Tomas Kukosa 7f4df19970 fix GLIB 1.x compatibility
svn path=/trunk/; revision=23668
2007-11-29 07:48:12 +00:00
Tomas Kukosa ff7c20938e Various changes with focus to startup speedup
The startup timeout on Win32 is reduced to 80% without assembler and to 50% with assembler usage (which is optional)
proto.c
 - do not look up in filed tree and inserts in two steps but do it at once
 - next few small speedups
 - some often called elementary functions can be optionally implemented in assembler
 - dispart some functions to see more exact result from profiling
packet-tpnc.c
 - do not reallocate memory for each filed

svn path=/trunk/; revision=23643
2007-11-28 10:18:16 +00:00
Guy Harris 9c89cdaaa3 strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est.  Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our
own versions if they're missing from GLib (as is the case with GLib
1.x).

In the code to build the list of named fields for Diameter, don't use
g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping
in the hash function and use g_ascii_strcasecmp() in the compare
function.

We do this because there is no guarantee that toupper(), tolower(), and
functions that use them will, for example, map between "I" and "i" in
all locales; in Turkish locales, for example, there are, in both
upper case and lower case, versions of "i" with and without a dot, and
the upper-case version of "i" is "I"-with-a-dot and the lower-case
version of "I" is "i"-without-a-dot.  This causes strings that should
match not to match.

This finishes fixing bug 2010 - an earlier checkin prevented the crash
(as there are other ways to produce the same crash, e.g. a bogus
dictionary.xml file), but didn't fix the case-insensitive string matching.

svn path=/trunk/; revision=23623
2007-11-27 18:52:51 +00:00
Stephen Fisher 849e628334 Introduce a new field type called FT_EBCDIC. This field works the same as
FT_STRING, except that it converts the data from the packet from EBCDIC
to ASCII for display in Wireshark.


svn path=/trunk/; revision=23503
2007-11-19 21:27:01 +00:00
Anders Broman dbcabb1938 Get rid of most of the legacy oid stuff.
svn path=/trunk/; revision=23333
2007-11-01 22:07:43 +00:00
Anders Broman 9492700608 Change:
get_oid_str_name() -> oid_resolved_from_string()
get_oid_name() -> oid_resolved_from_encoded()

svn path=/trunk/; revision=23331
2007-11-01 19:36:39 +00:00
Martin Mathieson b40d397b16 Make groups of PDUs filterable as large FT_BYTES items
(where the initial length isn't readily available when item is first added)

Note that this still won't work where an initial length of 0 is given for
the item that will later be extended using proto_item_set_len(), as the
pointer value part of the zero-length array will reamin NULL...

svn path=/trunk/; revision=23253
2007-10-23 11:02:08 +00:00
Stig Bjørlykke 5a58a1435c From Andrew Feren:
Fix an assortment of typos and other minor errors in various README files

svn path=/trunk/; revision=23166
2007-10-12 19:13:31 +00:00
Stig Bjørlykke 675b312626 Added a missing break - fixing bug 1890.
svn path=/trunk/; revision=23050
2007-10-02 16:27:52 +00:00
Stig Bjørlykke 72af3183ab Added functionality to highlight the FCS bytes in Ethernet and IEEE 802.11
packets in the Packet Details View.

This "appendix" bytes are not copied with the Copy functions or in the
Export Selected Packet Bytes.

svn path=/trunk/; revision=22887
2007-09-17 12:12:02 +00:00
Luis Ontanon 00c5e48a17 get users of oid_resolv to use the new oids, rollout packet-snmp.c
svn path=/trunk/; revision=22651
2007-08-25 01:14:24 +00:00
Luis Ontanon fab09c9575 accept 64bit integers where 8 <= len <= 1
svn path=/trunk/; revision=22546
2007-08-18 00:14:52 +00:00
Luis Ontanon 9865b6346f As per Ulf's request add ${proto.field} macros that will use the value of the given field has in the last selected packet.
svn path=/trunk/; revision=22427
2007-07-30 23:32:47 +00:00
Guy Harris 5a43799a17 Use G_GINT64_MODIFIER, rather than the PRI[douxX]64 macros, for GLib
routines and routines using those routines.  GLib might use different
modifiers for 64-bit quantities than the platform's C library does.

svn path=/trunk/; revision=21990
2007-05-29 18:52:42 +00:00
Guy Harris d2ac4f7133 Check for G_GINT64_MODIFIER in Wireshark as we do in Wiretap.
In all the places where a cast to "long long" or "unsigned long long"
was done, use G_GINT64_MODIFIER and get rid of the cast, as

	1) there's no guarantee that "%ll" works

and

	2) there's no guarantee that "long long" works

(the latter definitely does *NOT* work with MSVC++; the former doesn't
work with regular printf in MSVC++, but it might work with the GLib
printf-based functions).

svn path=/trunk/; revision=21978
2007-05-29 06:56:07 +00:00
Sebastien Tandel 76729e5d0f From David Howells :
Fix compilation failures when building wireshark-0.99.6-SVN-21916 on an
x86_64-unknown-linux-gnu target with gcc version 4.1.2 20070403 (Red Hat
4.1.2-8).

The failures fall into two categories:
  (1) Casts between pointers and 32-bit integers without an intermediary cast
via 'long' or 'unsigned long'.  This results in a compiler warning complaining
about casts between a pointer and an integer of a different size.
  (2) Passing values to "%lld" or similar printf-style format options that the
compiler thinks are a different size.  Such values need to be cast to 'long
long' or 'unsigned long long'.

svn path=/trunk/; revision=21975
2007-05-29 02:43:18 +00:00
Luis Ontanon 11f06217ce Have editcap and capinfos loading the wiretap plugins.
epan/filesystem.c
   have get_plugin_dir() calling init_plugin_dir() if necessary

epan/epan.c and epan/report_err.c
   move the report_failure family into the new report_err.c file, have epan_init() calling the initializer

epan/plugins.h and epan/proto.c
   do not have init_plugins() calling the proto_reg functions instead do it in init_proto()

gtk/main.c and tshark.c
   init_plugin_dir() has become suprefluous

capinfos.c and editcap.c
   load the wiretap plugins

Makefiles
   do what's needed to build withe the above changes.




svn path=/trunk/; revision=21935
2007-05-25 17:22:32 +00:00
Ronnie Sahlberg bded91f43d make proto.c compile again after the recent changes
svn path=/trunk/; revision=21853
2007-05-21 02:36:33 +00:00
Anders Broman b688f9154a Split tvb_get_bits64 into tvb_get_bits8 tvb_get_bits16 tvb_get_bits32 and tvb_get_bits64
and use them in proto_tree_add_bits_ret_val().

svn path=/trunk/; revision=21828
2007-05-18 16:46:35 +00:00
Graeme Lunt cf56e76be9 Updated splash screen for Wireshark that shows the initialisation progress.
The splash screen shows a progress bar and a percentage complete - like the progress dialog.
As dissectors are initialised and handed off the name is shown. However, the names of plugin dissectors are not shown.
The update to the make-dissector-reg shell script has been tested, though I think generally the python version is used.


svn path=/trunk/; revision=21716
2007-05-07 17:55:42 +00:00
Anders Broman 43bb2aea51 Add:
proto_tree_add_bits_ret_val()
tvb_get_bits()
And modify
proto_tree_add_bits() not to return a value.
little endian is not yet implemented.

svn path=/trunk/; revision=21607
2007-04-28 12:13:25 +00:00
Anders Broman ccac0e7983 Change the signature of proto_tree_add_bits() and add proto_tree_add_bits_ret_val()
which will hopefully be more acceptable.
Change name of tvb_get_bits() in ansi_801

svn path=/trunk/; revision=21594
2007-04-26 06:39:29 +00:00
Anders Broman fea883ebec Add a new proto function proto_tree_add_bits() which adds bits to the tree
starting at the bit offset given for the number of bits indicated which wll also return
the value of the bits.
Experimental and for review, documentation to be updated.

svn path=/trunk/; revision=21556
2007-04-24 19:24:14 +00:00
Sebastien Tandel 0ca67aef30 - new ptvcursor subtrees management functions :
* ptvcursor_push_subtree(), ptvcursor_pop_subtree() for pushing/popping
    subtrees. Multiple levels of subtrees (256 max.), allocation per 8 levels.
  * Two new functions creating an item in the tree and pushing a subtree at the
    same time. These two functions accept an undefined length
    (SUBTREE_UNDEFINED_LENGTH). The length of the item is set at the next pop.
        1) ptvcursor_add_with_subtree
	2) ptvcursor_add_text_with_subtree
- get rid of potential memory leaks with g_new in ptvcursor_new().

- Documentation of the new ptvcursor functions in README.developer


svn path=/trunk/; revision=21276
2007-03-30 00:21:39 +00:00
Stephen Fisher 8fd3ee0560 Remove almost all of the casts I committed recently and in place of
them, add -Wno-pointer-sign to CFLAGS when gcc will accept it.


svn path=/trunk/; revision=21253
2007-03-28 21:55:11 +00:00
Stephen Fisher 46b8669566 Fix a bunch more warnings. Add -Werror when using --with-warnings-as-errors
under gcc to tools/lemon, plugins/mate and epan/


svn path=/trunk/; revision=21204
2007-03-26 06:10:52 +00:00
Jeff Morriss 62596bffb3 Fix bug 552:
http://bugs.wireshark.org/bugzilla/show_bug.cgi?id=552

by enforcing that header fields have names of length > 0.  This should fix
the display of those fields and also make them filterable (which was the
subject of the bug).  Abbreviations are (still) optional: if they are empty
then the field is not filterable.

Update README.developer with this information.

Add header field names in several dissectors where they were missing.

In packet-arp.c give "packet-storm-detected" a name (as above) but also set it
as _GENERATED.

Also remove trailing white space from all the files checked in.

svn path=/trunk/; revision=21018
2007-03-11 06:16:00 +00:00
Stephen Fisher aa897723ff From Sebastien Tandel:
Here is an updated patch for proto_tree_add_item and the
range_string structure. The new macro RVALS() can be used as the macro
VALS() in the declaration of your hf_register_info with another
structure (range_string).  Be aware that you *have to* ORed the value of
the field display with BASE_RANGE_STRING constant and it can 'only' be
used with FT_(U)INT* types in a header_field_info.


svn path=/trunk/; revision=20805
2007-02-14 00:39:48 +00:00
Guy Harris 10778a6ab1 DISSECTOR_ASSERT_NOT_REACHED() now, by default, throws a Wireshark
exception rather than aborting the program; using it means that
dissector bugs show up as such rather than as malformed packets.

svn path=/trunk/; revision=20532
2007-01-23 18:31:26 +00:00
Martin Mathieson 997e5415f9 Add separate union entries to fvalue.value for signed and unsigned
32-bit numbers.  Separate signed and unsigned accessors have been
added and used where appropriate.

Definitely not for 0.99.5.

svn path=/trunk/; revision=20472
2007-01-18 11:02:26 +00:00
Ronnie Sahlberg 3e9ac49497 check if we have a finfo before dereferencing it later in PROTO_ITEM_IS_HIDDEN()
this prevents wireshark from crashing on X Liu's kerberos capture files


svn path=/trunk/; revision=20464
2007-01-17 21:05:44 +00:00
Tomas Kukosa 92d8d4e9b4 do not ignore invisible tree, it can break tree creation for coloring/filtering
svn path=/trunk/; revision=20404
2007-01-12 10:21:02 +00:00
Jaap Keuter f8422ab7db Extending true_false_string support
- Separate tfs.[ch]
- Add larger sample collection
- Properly export DATA

svn path=/trunk/; revision=20373
2007-01-10 07:47:00 +00:00
Guy Harris 44c0624bd9 Add a WIRESHARK_RUN_FROM_BUILD_DIRECTORY environment variable on UN*X;
if set, and if the program isn't running with additional privileges,
it'll treat the directory in which the program is found as the data
directory.

If, on Windows, the version-number subdirectory of {data
directory}\plugins doesn't exist (which is assumed to mean that the
program is being run from the build directory), or if, on UN*X,
WIRESHARK_RUN_FROM_BUILD_DIRECTORY is set, the plugin directory is the
"plugins" subdirectory of the data directory, and all subdirectories of
that directory are scanned for plugins, as the "plugins" subdirectory of
the build directory contains subdirectories for the plugins; this means
that if we're running from the build directory, we'll find the plugins
we built in the build tree.

When generating the wireshark-filter man page, run tshark with
WIRESHARK_RUN_FROM_BUILD_DIRECTORY set, so it uses the plugins from the
build to generate the list of filters.

svn path=/trunk/; revision=20261
2007-01-02 06:49:40 +00:00
Ronnie Sahlberg b7817c4e37 proto_tree_set_string() no longer needs an already_allocated parameter since it is now always FALSE.
This should mean that all fvalue_set() for FT_STRING[Z] are always with already_copied==FALSE

(funny that we never saw someone trying to g_free("[ Null ]") which might have happened before)



svn path=/trunk/; revision=20245
2006-12-30 00:41:41 +00:00
Ronnie Sahlberg 62040d3638 make the FT_STRINGZ case in proto_tree_new_item() use ep allocated memory
svn path=/trunk/; revision=20244
2006-12-30 00:36:29 +00:00
Ronnie Sahlberg ee4ceb8947 make proto_tree_set_string_tvb use ep allocated memory and thus push the memory allocation/free for this field down into ftype-string.c
svn path=/trunk/; revision=20243
2006-12-30 00:27:33 +00:00
Ronnie Sahlberg 459d5f66a4 use ep allocated memory for the string in proto_item_append_string and let ftype-string.c handle the allocation/freeing of storage by setting already_copied to FALSE
svn path=/trunk/; revision=20240
2006-12-29 23:05:55 +00:00
Ronnie Sahlberg 8fc740a53e hmm
best to revert this for a while.



revert all changes from previous patch.



svn path=/trunk/; revision=20195
2006-12-22 09:01:12 +00:00
Ronnie Sahlberg 8433f6d589 change some slab allocated memory into ep/emem allocated structures instead.
this primarily removes code and simplifies (==eliminates) the need to track the data that is allocated and should potentially be slightly faster than a slab allocator.
however these functions are called A LOT so there might be a performance hit when using emem with full debugging canary values and all the bells and whistles activated.


this change also makes any future attempt to parallellize dissection of frames easier if we just make the ep allocator allocate from a threads specific ep pool.
(something we would have to do anyway to make ep allocations multithreaded)



this works in all my tests so far but needs more test coverage.



svn path=/trunk/; revision=20194
2006-12-22 08:35:43 +00:00
Ronnie Sahlberg 41c258daf3 create a nice helper to dissect bitmasks and implement some test useage of it in the scsi dissector
svn path=/trunk/; revision=20002
2006-11-27 14:50:23 +00:00
Guy Harris d3fed959bc Have separate proto_construct_match_selected_string() and
proto_can_match_selected() routines, to more clearly separate the two
functions - but have them both call the same underlying routine, so
they both make the same decisions as to whether a match-selected string
can be constructed or not.

svn path=/trunk/; revision=19976
2006-11-24 18:25:23 +00:00
Guy Harris 37a6c02697 Rename proto_construct_dfilter_string() to
proto_construct_match_selected_string() to indicate what it does - and
have it return a Boolean indication of whether the string could be
built, returning the string through a pointer, and, if that pointer is
null, have it just return the Boolean and not construct the string.

Get rid of proto_can_match_selected() -
proto_construct_match_selected_string() can be used for that, which
means we have only one piece of code that knows whether a "match
selected" string can be constructed or not.

Have proto_construct_match_selected_string() support matching
zero-length FT_NONE (and FT_PCRE, but that shouldn't happen) fields even
if there's no epan_dissect_t, as such a match just checks whether the
field is present.

svn path=/trunk/; revision=19967
2006-11-23 21:16:46 +00:00
Guy Harris 621c7fe650 When checking whether a field supports "match selected", do the same
checks that we do when we try to construct the filter expression for
"match selected" - this means we don't just assert that all FT_NONEs are
filterable, as they aren't.

svn path=/trunk/; revision=19961
2006-11-23 00:15:49 +00:00
Guy Harris 8532eef3c6 Make the "standard" case in proto_can_match_selected() and
proto_construct_dfilter_string() the default, so you add explicit cases
only when the type needs to be treated specially, so we don't end up
with types where we forget to have a case.

svn path=/trunk/; revision=19959
2006-11-22 22:11:38 +00:00
Martin Mathieson 268a3dff57 Make FT_STRINGZ items work as apply/prepare as filter menu items
svn path=/trunk/; revision=19936
2006-11-20 14:53:22 +00:00
Gerald Combs fe557f6296 Throw an exception if we try to add more than a million items to the tree.
svn path=/trunk/; revision=19767
2006-11-01 20:32:23 +00:00
Gilbert Ramirez 63ec12f392 When processing '-G fields', ignore the "proto_tree_add_text"
pseudo-field by looking at the ID for hf_text_only. Apparently
some fields really don't have 'name' fields, but we still want
their info to be dumped out.

svn path=/trunk/; revision=19763
2006-10-31 22:00:41 +00:00
Gerald Combs 9e23f31e5f Add support for reading from stdin under Windows. Based on a patch sent
in last year by Gianluca Varenni.

Add partial support for reading from named pipes (currently disabled).

Move utf_8to16() and utf_16to8() to a separate module (unicode-utils.[ch])
so that we don't have to cut and paste code in dumpcap.c.

Fix up whitespace.

svn path=/trunk/; revision=19291
2006-09-22 21:14:54 +00:00
Tomas Kukosa 539102ca60 - new function ssl_dissector_delete()
- register H.225.0 over TLS (configurable port 1300)
- register SIP over TLS (fixed port 5061)
- new function proto_tree_get_root()

svn path=/trunk/; revision=19059
2006-08-28 07:05:02 +00:00
Martin Mathieson f8aadddf70 Make apply-as-filter strings work for FT_UINT_STRING (rather than using frame[...])
svn path=/trunk/; revision=18969
2006-08-21 11:45:37 +00:00
Martin Mathieson 0669def03d Fix for bug 1023 (problem with 'apply as filter' strings)
svn path=/trunk/; revision=18817
2006-08-02 09:14:31 +00:00
Ronnie Sahlberg 64fba459da from martin m
Hi,

This patch allows FT_NONE items to be built into filter expressions
(i.e. testing for their presence or absence rather than comparing with a
value) using the Apply|Prepare a Filter menus.  What drove me to add
this was having to type in !tcp.analysis.out_of_order.

Does this seem reasonable?

Regards,
Martin




svn path=/trunk/; revision=18782
2006-07-22 03:24:28 +00:00
Gerald Combs 20093fdaa4 snprintf -> g_snprintf. Fix up whitespace.
svn path=/trunk/; revision=18776
2006-07-20 21:29:45 +00:00
Guy Harris f6f7bd756d The joys of the C switch statement - you have to remember to use
"break;" between cases except in those rare situations where you *want*
fallthrough.

svn path=/trunk/; revision=18550
2006-06-22 21:55:24 +00:00
Anders Broman 996d4db495 Ethereal->Wireshark
svn path=/trunk/; revision=18234
2006-05-28 19:49:07 +00:00
Ronnie Sahlberg 89f022b12b name change
svn path=/trunk/; revision=18197
2006-05-21 05:12:17 +00:00
Guy Harris 3b34a4f260 Squelch a compiler warning (for a problem that doesn't actually occur).
svn path=/trunk/; revision=17758
2006-03-29 21:53:26 +00:00
Luis Ontanon 850dfe8fa2 add proto_all_finfos() that will return a GPtrArray containing every finfo found in a tree.
svn path=/trunk/; revision=17741
2006-03-27 19:28:02 +00:00
Tomas Kukosa 923855bb20 new FT_GUID handling - big/little endian supported
svn path=/trunk/; revision=17566
2006-03-10 11:58:22 +00:00
Lars Roland e271ba9a3c Display g_error messages in the console window unconditionally, if preferences aren't loaded yet.
This way we ensure that errors are displayed during protocol registration.

Use g_error instead of g_warning, if not allowed characters are used in display filter names for protocols. Extend the error message in this case.

svn path=/trunk/; revision=17248
2006-02-11 03:50:25 +00:00
Guy Harris 55c64cec5e Add "proto_tree_add_XXX_format_value()" routines, which are like the
"proto_tree_add_XXX_format()" routines except that the format doesn't
have to include the field name - the field name, followed by ": ", are
put into the representation string, followed by the result of the
formatting, so you just format the value with the format string, not the
entire representation.

svn path=/trunk/; revision=17221
2006-02-09 04:18:23 +00:00
Jörg Mayer b446d51eb1 Didier Gautheron:
proto.c uses the wrong pointer in error msg.

Me:
        Be more verbose in case of illegal characters when
        registering filter names.

svn path=/trunk/; revision=16986
2006-01-10 16:19:56 +00:00
Jörg Mayer 9a490f4b73 Jaap Keuter:
While looking into bug 239 I found a type mismatch in proto.c. Even
though tree_is_expanded is defined as a (gboolean *) the memory
allocation is carried out using sizeof (gint *). The attached patch
fixes this.


svn path=/trunk/; revision=16877
2005-12-22 01:36:42 +00:00
Tomas Kukosa a5bfb48c2f OBJECT IDENTIFIER name resolution moved to oid_resolv.c
svn path=/trunk/; revision=16699
2005-12-06 11:45:55 +00:00
Guy Harris 46325167d9 Check for a null blurb pointer for a field, as is done in some other
locations, and initialize the blurb field to NULL for protocols, now
that we support the blurb being a null pointer.

svn path=/trunk/; revision=16672
2005-12-04 04:22:43 +00:00
Tomas Kukosa dcae7d303f new field type FT_OID for OBJECT IDENTIFIERs
svn path=/trunk/; revision=16652
2005-12-02 13:16:58 +00:00
Guy Harris cdd6ccea1d Don't pass signed characters to the <ctype.h> macros.
svn path=/trunk/; revision=16457
2005-11-10 07:42:23 +00:00
Ulf Lamping 820aaac6b0 MSVC warning fixed:
proto.c(4694) : warning C4101: 'stringified' : unreferenced local variable

svn path=/trunk/; revision=16381
2005-11-02 20:50:54 +00:00
Guy Harris cbce856e9e When printing the code for a display filter:
print register numbers as unsigned (they're guint32);

	when printing a PUT_FVALUE instruction, show the value as well
	as the type of the value.

That requires that a bunch of types get to_repr methods; add them for
PCRE (FTREPR_DFILTER-only - show the regular expression as text),
tvbuffs (FTREPR_DFILTER_only - show the data as a hex string), integral
types, string types other than FT_STRING, and FT_IPv6.

That means we can use fvalue_to_string_repr() for FT_IPXNET and FT_IPv6
in proto_construct_dfilter_string(), and that we don't need to handle
integer and floating types specially in MATE.

Fix some problems with the PCRE execution code for tvbuff types.

svn path=/trunk/; revision=16369
2005-10-31 02:42:22 +00:00
Guy Harris c72ffd259d Move the ptvcursor.c code to epan/proto, and make ptvcursor_add() handle
FT_UINT_BYTES and FT_UINT_STRING correctly when the tree argument is
null (which involves carving proto_tree_add_item() into bits and having
both ptvcursor_add() and proto_tree_add_item() call those bits).

svn path=/trunk/; revision=16287
2005-10-22 05:43:09 +00:00
Guy Harris ef966c3377 If we don't want to dump core when a field is registered twice, at least
make the message give enough information to give us some hope of finding
the offending field.

svn path=/trunk/; revision=16179
2005-10-10 18:06:50 +00:00
Guy Harris f6ef22c553 Have show_exception() take a "const char *" as its exception message,
and not free the string to which it points.  Pass to
REPORT_DISSECTOR_BUG() strings allocated with ep_strdup_printf(), so
that they're freed automatically.

svn path=/trunk/; revision=16039
2005-09-28 16:16:37 +00:00
Olivier Biot 3452023b80 The TRY_TO_FAKE_THIS_ITEM() speed optimization has a side effect in that it
will only process FT_PROTOCOL fields. As a result, proto_item_append_string()
calls may throw a dissector exception, as only a FT_STRING or FT_STRINGZ can be
appended to with this call.

In order to prevent these dissector assertions, silently return from the append
call if the field is a FT_PROTOCOL.

Note that when the tree is visible, the updates of the fields occur normally,
as expected.

svn path=/trunk/; revision=16035
2005-09-28 07:08:57 +00:00
Anders Broman cb932a2514 From Peter Johansson
I added a description for the call to DISSECTOR_ASSERT in proto.c to be 
printed to stderr.

svn path=/trunk/; revision=15802
2005-09-14 19:14:23 +00:00
Guy Harris 25c4bc9379 Replace tvb_memcpy() calls that extract IPv4 addresses into a guint32,
and that extract IPv6 addresses into a "struct e_in6_addr", with
tvb_get_ipv4() and tvb_get_ipv6() calls - except for some that we
remove, by using proto_tree_add_item(), rather than replacing.

Have epan/tvbuff.h include epan/ipv6-utils.h, to define "struct
e_in6_addr" (not necessary to declare the tvbuff routines, but including
it there means "struct e_in6_addr" is guaranteed to be defined before
those declarations, so we don't get compiler complaints if we define it
*after* those declarations).

svn path=/trunk/; revision=15758
2005-09-11 21:25:37 +00:00
Ulf Lamping 642467ad5c I'm adding the "Expert Info" prototype now, as it seems to be in a state where others might have a look and probably already find it useful :-). Anyway, we can easily disable it at one or two places in the code if it get's in our way of a new release.
Please see: http://wiki.ethereal.com/Development/ExpertInfo for a complete overview of the intended feature and it's current state of implementation.

While I'm working on this, I've also added some more status result codes to the DCE/RPC and DCOM dissectors.

svn path=/trunk/; revision=15754
2005-09-11 16:55:34 +00:00
Guy Harris 266e1a3491 Add "tvb_get_ipv4()" and "tvb_get_ipv6()" addresses, to fetch IPv4 and
IPv6 addresses.  Use "tvb_get_ipv4()" in the WINS Replication dissector,
so that it gets the right answer on little-endian *AND* big-endian
machines.

svn path=/trunk/; revision=15753
2005-09-10 19:43:41 +00:00
Tomas Kukosa c53bf17cda new BASE_DEC_HEX and BASE_HEX_DEC displaying numbers in "dual" format
svn path=/trunk/; revision=15682
2005-09-05 10:56:41 +00:00
Ronnie Sahlberg 5521c10492 hmmm i though i removed some sprintf in the previous commit apparently not.
remove all sprintf and replace with g_snprintf()


svn path=/trunk/; revision=15652
2005-09-01 09:29:21 +00:00
Ronnie Sahlberg 55add7077f convert one sprintf into g_snprintf()
at the same time, make proto_construct_dfilter_string() return an emem allocated string.
This fixes a tiny memleak in print.c that never freed the string returned by this function.


svn path=/trunk/; revision=15651
2005-09-01 09:03:29 +00:00
Ulf Lamping 994496a184 several times replacing:
sprintf -> g_snprintf
snprintf -> g_snprintf
vsnprintf -> g_vsnprintf
strdup -> g_strdup

svn path=/trunk/; revision=15412
2005-08-18 19:31:15 +00:00
Ulf Lamping 495eb1b788 snprintf -> g_snprintf
svn path=/trunk/; revision=15398
2005-08-17 23:10:28 +00:00
Gerald Combs 2f2a3fedd3 In packet-sflow.c, don't pass a NULL value pointer to
proto_tree_add_ipv6().  Add tree items for the extended router source
and dest mask, and fix offsets.  These changes appear to be correct,
but I don't have a valid capture with extended router data.

In proto.c, throw a dissector error if we try to pass a NULL value to
various proto_tree_set_*() routines.

Fixes bug 356.


svn path=/trunk/; revision=15375
2005-08-16 16:04:30 +00:00
Ulf Lamping 0dc9fb3d4a various code cleanup:
-use g_snprintf instead of sprintf and snprintf
-use g_strdup_printf where appropriate
-remove #include "snprintf.h" (as only g_snprintf should be used)
-replace some more alloc/realloc/calloc/free with their glib pendants

svn path=/trunk/; revision=15264
2005-08-08 18:50:39 +00:00
Jörg Mayer 74a75d72fe char -> const char warning fixes
svn path=/trunk/; revision=15223
2005-08-05 13:23:47 +00:00
Guy Harris 554f620001 Constify to remove a bunch of warnings. Add some casts to squelch
(presumably-)harmless-but-otherwise-unremovable const-to-nonconst
warnings.

In the TACACS dissector, clean up the variables used in option parsing
to avoid some const-to-nonconst warnings.

Clean up some white space.

svn path=/trunk/; revision=15043
2005-07-24 19:01:28 +00:00
Jörg Mayer 30a8557868 More 'char*' -> 'const char*' changes to fix warnings.
svn path=/trunk/; revision=15015
2005-07-23 11:41:25 +00:00
Jörg Mayer ca322883d6 Change proto_register_protocol to use 'const char*' instead of 'char*'
svn path=/trunk/; revision=14966
2005-07-20 11:01:35 +00:00
Tomas Kukosa bab34b522b new field type FT_GUID
svn path=/trunk/; revision=14845
2005-07-04 13:04:53 +00:00
Ulf Lamping d5ae7ee8af proto.c(2941) : warning C4090: 'function' : different 'const' qualifiers
proto.c(2941) : warning C4022: 'g_tree_insert' : pointer mismatch for actual parameter 2

svn path=/trunk/; revision=14782
2005-06-26 11:29:04 +00:00
Guy Harris b67f63560e More constification.
svn path=/trunk/; revision=14740
2005-06-24 02:51:01 +00:00
Gerald Combs dce31be366 When we add an FT_STRINGZ item, throw an exception if the length is
less than -1.  If the length is 0, set the item string to "[Empty]".
This fixes bug 219.


svn path=/trunk/; revision=14634
2005-06-15 15:10:02 +00:00
Ulf Lamping 9784fa242a add new function proto_tree_move_item(), which will move an already existing proto_item inside the tree (but it can't be moved to a different "tree level")
svn path=/trunk/; revision=14524
2005-06-02 18:35:20 +00:00
Ulf Lamping 4984c5e949 show Ethernet and IPX addresses the same way as we do with other fields as well (e.g. IP addresses), first the converted value (e.g. IP address or manufaturer name) and then in brackets the "raw data"
svn path=/trunk/; revision=14523
2005-06-02 18:29:29 +00:00
Ulf Lamping 7c07e00f1d fix #11: add a [truncated] to the label, if the message to display is too long
svn path=/trunk/; revision=14477
2005-05-29 11:23:42 +00:00
Gilbert Ramirez c2454f0260 Add a "-G fields3" report which prints the bitmask of the field, and avoids
printing the blurb twice, like fields2 does.
Add a script, fsanity.py, to check sanity of FT definitions. Right now the
only check is for bitmasks for integer-like fields.

svn path=/trunk/; revision=14454
2005-05-27 15:13:09 +00:00
Ronnie Sahlberg 864245ef6e cket wsp is creating string items and later appending to them and their value at runtime which breaks when the TRY_TO_FAKE_THIS_ITEM() is used.
Add a comment to proto_item_append_string() explaining the "danger" and what needs to be done if one decides to use proto_item_append_string()

Add a small change to WSP so that it will disable this speed optimization so not to trigger a DISSECTOR_BUG in proto_item_append_string()




svn path=/trunk/; revision=14452
2005-05-27 06:00:08 +00:00
Gerald Combs 4a5deae575 In some places we call proto_tree_add_item() with hfindex and length
values that may not be valid (e.g. dissect_ber_octet_string()
in packet-ber.c).  If the length is invalid, get_uint_value() or
get_int_value() will abort.  Change them to throw an exception instead.
This keeps us from having to do a lot of extra work in the dissector.

Fixes bug 182.


svn path=/trunk/; revision=14437
2005-05-26 14:53:39 +00:00
Gerald Combs 985f94ec24 In proto_tree_set_string(), don't set a null fvalue or Ethereal will throw
a hissy fit.  Fixes bug 157.

svn path=/trunk/; revision=14299
2005-05-03 19:33:02 +00:00
Gerald Combs a80ebce3f2 Some dissectors apparently call proto_tree_add_*() with a null tvb.
This makes tvb_ensure_bytes_exist() throw a fit, so just throw an
exception instead.

svn path=/trunk/; revision=14212
2005-04-28 04:03:30 +00:00
Gerald Combs 7323cb267c Back out the previous change, and use tvb_ensure_bytes_exist() instead of
throwing an exception ourselves.

svn path=/trunk/; revision=14209
2005-04-28 03:30:07 +00:00
Gerald Combs 5ec0554c24 In alloc_field_info, throw a ReportedBoundsError if we're passed an
invalid length.

svn path=/trunk/; revision=14203
2005-04-27 16:22:24 +00:00
Ronnie Sahlberg c27c30ba02 Bugfix for proto_item_get_subtree()
Not all proto_item* fields have a subtree associated to it.
If it doesnt have a subtree  fi  will be NULL,
test fi for NULL before trying to dereference it to avoid a coredump.



svn path=/trunk/; revision=14134
2005-04-19 11:59:40 +00:00
Ronnie Sahlberg 2bc81b2a48 Major speed improvement for filtering and dissection.
It should not dump core as far as all my tests are concerned and Menu_Statistics/ProtocolHierStats work

It needs more testing and there might still be cases where it will crash that will need to be fixed  but I feel it will be worth it since it will decrease the time to filter very large capture files dramatically.

Real significant performance boost for very large captures.


(If we cant fix all the problems we can just revert this patch)



svn path=/trunk/; revision=14051
2005-04-11 08:43:51 +00:00
Ronnie Sahlberg df98534657 From Didier:
optimization for COLUMNS to make ethereal faster when filtering

optimization to make the slow find_protocol_by_id() fast.
(idea from Didier, implementation modified by me to be less intrusive)



svn path=/trunk/; revision=14026
2005-04-07 12:00:03 +00:00
Gerald Combs 8b95cd38d5 Don't generate a "dissector bug" warning in cases where a dissector calls
proto_tree_add_*(tree, tvb, offset, 0, ...);

and "offset" is greater than the length remaining in the tvbuff.

svn path=/trunk/; revision=14014
2005-04-04 18:10:42 +00:00
Gerald Combs b2c4af01c2 Remove a g_assert() left over from debugging.
svn path=/trunk/; revision=13971
2005-03-29 19:52:04 +00:00
Gerald Combs 4198c72a69 Fix a compiler warning.
svn path=/trunk/; revision=13969
2005-03-29 16:02:02 +00:00
Gerald Combs 9ead15a6eb README.developer says:
"PROTOABBREV     A name for the protocol for use in filter expressions;
                 it should contain only lower-case letters, digits, and
                 hyphens."

In proto_register_protocol(), generate a warning if PROTOABBREV contains
invalid characters.  Along with the list above, allow underscores and
periods.  Fix up whitespace.

Lower-case PROTOABBREV in several dissectors.

svn path=/trunk/; revision=13967
2005-03-29 14:56:09 +00:00
Ulf Lamping c475807aab bugfix: don't call tvb_length_remaining() if tvb is NULL
but what to do instead?

svn path=/trunk/; revision=13958
2005-03-28 18:08:31 +00:00
Guy Harris 48217e0bee For protocol tree items of type FT_NONE and FT_PROTOCOL, treat negative
length values (other than -1) as very large positive values, and for
values larger than the amount of data remaining in the tvbuff, clip the
value to the length of the tvbuff, so that dissectors don't have to
worry about doing that clipping themselves.

svn path=/trunk/; revision=13913
2005-03-26 03:27:22 +00:00
Ulf Lamping 79daa1e80e use DISSECTOR_ASSERT instead of g_assert
svn path=/trunk/; revision=13871
2005-03-23 00:09:12 +00:00
Ulf Lamping f6dbe26f6c add another REPORT_DISSECTOR_BUG() call, if tfi->tree_type is existing and not in valid range.
Question remains: Is it safe to continue in that case?

svn path=/trunk/; revision=13180
2005-01-26 23:17:00 +00:00
Guy Harris 5e4584e186 Add the source file name and line number to the dissector bug report
(not as useful as for bugs caught in the dissector itself, but still may
be useful).

svn path=/trunk/; revision=13082
2005-01-17 01:11:39 +00:00
Guy Harris df98de72ed Use REPORT_DISSECTOR_BUG() for the "bogus length" error in
"alloc_field_info()", so the error report can include the field with the
problem.  (The file and line number isn't interesting - the bug isn't in
"alloc_field_info()", it's in the dissector that called the routine
calling "alloc_field_info()" - but the field name/abbrevition is
interesting, as it'd help developers identify the place in the dissector
where we're passing in a bogus length.)

svn path=/trunk/; revision=13081
2005-01-17 00:56:56 +00:00
Guy Harris 2bdef3c122 Rename the FieldError exception to DissectorError.
Add a DISSECTOR_ASSERT() macro, which is the usual type of assertion
macro, but throws a DissectorError exception with a message giving the
flien and line number and the failed test as a string.  Use that macro
in "alloc_field_info()".

Report that exception in the Info column and the protocol tree, as well
as logging the exception failure with g_warning().

svn path=/trunk/; revision=13078
2005-01-16 23:30:55 +00:00
Ulf Lamping 1c9781b4ec throw the new FieldError exception, if a dissector tries to add a field with invalid parameters
add a message parameter to the show_exception function

svn path=/trunk/; revision=13074
2005-01-16 16:06:15 +00:00
Ulf Lamping 86bd4b30c5 performance improvement:
In the past: to prevent duplicate protocol names (and alike), each time a new protocol was registered, the list of protocols were iterated and the name compared with each existing name using strcasecmp, which is slow as we have >500 protocols right now.

Now: the protocol name to check against duplicates is first converted into a hashvalue and then only this value is checked and stored in a hashtable. This way the string to check for, has to be converted/compared only a single time!

svn path=/trunk/; revision=13007
2005-01-12 21:31:22 +00:00
Guy Harris cbddfd0793 From Luis Ontanon: if new ett values are registered after the
tree_is_expanded array is initially allocated, grow the array

svn path=/trunk/; revision=12997
2005-01-08 23:43:29 +00:00
Guy Harris 4c45795dab Constify a pointer, so that the array of pointers to ett_ values can be
const, although the pointers can't point to consts (as the values get
filled in as they're registered).

svn path=/trunk/; revision=12981
2005-01-07 12:56:21 +00:00
Guy Harris c1e2dc025b Cast away the constness of the argument to "g_tree_lookup()" - another
GLib function with an unfortunate signature.

svn path=/trunk/; revision=12923
2005-01-02 03:58:08 +00:00
Guy Harris 55465228b2 "proto_registrar_get_byname()" doesn't modify its argument, so make it
"const char *".

svn path=/trunk/; revision=12888
2004-12-31 02:02:19 +00:00
Guy Harris 948d61bae1 Check to make sure we don't give a protocol tree item a negative length.
Clean up indentation.

If we dissect an octet string and then re-dissect it as a particular
type of data, don't use the end offset from the re-dissection as the
offset of the end of the octet string - just use the result of
"dissect_per_octet_string()".

svn path=/trunk/; revision=12406
2004-10-27 10:02:45 +00:00
Guy Harris cc6754d659 Fix a typo.
svn path=/trunk/; revision=12062
2004-09-21 23:15:59 +00:00
Guy Harris 799bc411a1 From Dave Richards: fix a format string.
svn path=/trunk/; revision=11969
2004-09-11 22:36:16 +00:00
Gilbert Ramirez f676f7107b Add a "-G fields2" option which is like "-G fields", but extends the field
records by tw fields: base (for integers), and blurb

Add a "-G values" option which shows value strings and true_false strings for
the fields that have them.

svn path=/trunk/; revision=11954
2004-09-10 15:21:20 +00:00
Guy Harris 8b92640589 To conert a little-endian value to a big-endian value, use
GUINT32_SWAP_LE_BE(), not GUINT32_TO_BE() - the latter converts a
host-byte-order value to big-endian, but the host might be big-endian.

svn path=/trunk/; revision=11945
2004-09-08 19:36:25 +00:00
Ronnie Sahlberg 1141542d06 From Peter Johansson, make proto_tree_add_item() handle IPv4 addresses
stored in little endian format.


svn path=/trunk/; revision=11939
2004-09-08 10:32:53 +00:00
Guy Harris c68f62210f Add "tvb_get_ntoh64()" and "tvb_get_letoh64()" routines to fetch 64-bit
integers.

Make FT_INT64 and FT_UINT64 add numerical values, rather than byte-array
values, to the protocol tree, and add routines to add specified 64-bit
integer values to the protocol tree.

Use those routines in the RSVP dissector.

svn path=/trunk/; revision=11796
2004-08-22 00:31:58 +00:00
Guy Harris a6c45e1f0b Add support for FT_FLOAT and FT_DOUBLE in "proto_tree_add_item()"
(untested).

svn path=/trunk/; revision=11646
2004-08-10 21:23:34 +00:00
Guy Harris 3a583aeb59 From Albert Chin: rename resolv.{ch} to addr_resolv.{ch}, so that an
include of <resolv.h> in any system header file gets the system
<resolv.h> (needed for builds on Tru64 with GTK+ 1.2[.x]).

svn path=/trunk/; revision=11615
2004-08-06 19:57:49 +00:00
Guy Harris 8a8b883450 Set the svn:eol-style property on all text files to "native", so that
they have LF at the end of the line on UN*X and CR/LF on Windows;
hopefully this means that if a CR/LF version is checked in on Windows,
the CRs will be stripped so that they show up only when checked out on
Windows, not on UN*X.

svn path=/trunk/; revision=11400
2004-07-18 00:24:25 +00:00
Guy Harris 50ac581613 "length" is relative to the start of the field, so don't subtract the
start of the field from it.

svn path=/trunk/; revision=11354
2004-07-09 21:52:03 +00:00
Ulf Lamping 97c4ef6cfb bugfix: don't try to print data, if tvb is too short
svn path=/trunk/; revision=11318
2004-07-05 16:42:19 +00:00
Guy Harris 003ecf68bb Instead of using pointer casts in the slab allocator stuff, add a
"SLAB_ITEM_TYPE_DEFINE()" macro to define a union of the type of object
for the slab and a pointer to an object of that union type, and use that
type for items on the slab allocator free lists; that *should* avoid
having the compiler think two pointers to an item being added to or
removed from the free list don't point to the same object just because
they have different types.

svn path=/trunk/; revision=11306
2004-07-04 02:29:43 +00:00
Guy Harris 456c6cab66 Make the "SLAB_ALLOC()" and "SLAB_FREE()" macros take the type of the
object being allocated, rather than the name of the free list, as an
argument (with the name of the free list constructed from the name of
the type), and add macros to define and declare the free list, also
taking the type of the object being allocated.

svn path=/trunk/; revision=11305
2004-07-04 00:28:11 +00:00
Ulf Lamping d9118dc089 add PROTO_ITEM_SET_HIDDEN() and PROTO_ITEM_SET_GENERATED(),
this sets flags for later rendering of the field data

svn path=/trunk/; revision=10752
2004-05-01 15:15:08 +00:00
Guy Harris 044f075c66 From Tomas Kukosa: add APIs to get the parent of a protocol tree item
and the item N levels up from a protocol tree item.

svn path=/trunk/; revision=10486
2004-03-25 23:55:21 +00:00
Guy Harris a6ed2d499a From Tomas Kukosa: BER dissector enhancements and proto.c updates to
support them.

From Ronnie Sahlberg: Kerberos updates with new constants from the
current draft, decryption and dissection of Kerberos blobs, and changes
to work with the changed BER dissector.

svn path=/trunk/; revision=10479
2004-03-25 09:18:03 +00:00
Richard Sharpe fa9874ef73 Apply the patches from Tadaaki Nagao for a global version of disabled
protocols ...

svn path=/trunk/; revision=9538
2004-01-03 18:40:08 +00:00
Guy Harris 20788302e3 In "alloc_field_info()", handle the case where the offset is past the
byte past the end of the tvbuff.

svn path=/trunk/; revision=9445
2003-12-24 23:37:28 +00:00
Guy Harris cde3ec1e33 Let FT_PROTOCOL fields, if the length specified is -1, have a length of
0 - now that "tvb_ensure_length_remaining()" ensures that there's at
least one byte of data, we should use "tvb_length_remaining()" for
FT_PROTOCOL fields.

svn path=/trunk/; revision=9440
2003-12-24 11:07:03 +00:00
Gilbert Ramirez 058ef64db8 Add the ability to print packet dissections in PDML (an XML-based format)
to tethereal. It could be added to Ethereal, but the GUI changes to
allow the user to select PDML as a print format have not been added.

Provide a python module (EtherealXML.py) to help parse PDML.

Provide a sample app (msnchat) which uses tethereal and EtherealXML.py
to reconstruct MSN Chat sessions from packet capture files. It produces
a nice HTML report of the chat sessions.

Document tethereal's PDML and EtherealXML.py usage in doc/README.xml-output

Update tethereal's manpage to reflect the new [-T pdml|ps|text] option

svn path=/trunk/; revision=9180
2003-12-06 06:09:13 +00:00
Guy Harris fa1de9d824 It turns out the protocol tree parent link was used, so we need it in
our new scheme.

svn path=/trunk/; revision=9172
2003-12-04 19:53:54 +00:00
Guy Harris f0b9d12b6a Don't use GNodes for the protocol tree, put the sibling pointer, and
pointers to the first *and* last child, in the "proto_node" structure
itself.  That saves us one level of indirection and memory allocation,
and lets us append to a tree by appending to the last child directly,
rather than having to scan through the list of siblings of the first
child to find the end of that list.

svn path=/trunk/; revision=9171
2003-12-04 10:59:34 +00:00
Ronnie Sahlberg 5ff0237060 performance update
replace tvb_raw_offset() which is essentially a simple assignment and which
is called a lot with a macro.

this makes my tethereal testcase 2-3% faster.

svn path=/trunk/; revision=9152
2003-12-03 09:50:40 +00:00
Guy Harris dcd98ae8d3 The "ptr_u" unions no longer have a "next" pointer - they now just have
one member - or have one that's not used, so get rid of those unions.

svn path=/trunk/; revision=9151
2003-12-03 09:28:26 +00:00
Guy Harris ed2ae2d8d3 Instead of requiring slab-allocated structures to have a "next" pointer,
when adding them to the free list, cast the pointer to the structure to
a pointer to a "freed_item_t" which contains the "next" pointer.

This reduces the memory requirement for some of those structures, and
leaves us free to slab-allocate structures that have a "next" pointer
for other reasons.

svn path=/trunk/; revision=9150
2003-12-03 08:53:37 +00:00
Guy Harris bd9f96738c From Didier Gautheron: put an "fvalue_t" structure into a "field_info"
structure, rather than separately allocating "fvalue_t"s and having the
"field_info" structure point to them - this appears to speed up protocol
tree construction a bit.

svn path=/trunk/; revision=9146
2003-12-02 21:15:49 +00:00
Ronnie Sahlberg bfaca0cab6 Move the definition of the tvbuff_t structure and friends to tvbuff.h
so that we can change tvb_get_ds_tvb() into a macro.

This function was a single line assignment and was called a lot.

This made tethereal ~2.5% faster in one testcase I use.

svn path=/trunk/; revision=9141
2003-12-02 10:23:18 +00:00
Ronnie Sahlberg 266b5a4b2e Use the LSAB_ALLOC and SLAB_FREE macros to allocate/free fvalue_t data
svn path=/trunk/; revision=9140
2003-12-02 09:47:23 +00:00
Ronnie Sahlberg 917c9da95e Moving SLAB_ALLOC and SLAB_FREE to its own header file
svn path=/trunk/; revision=9139
2003-12-02 09:11:16 +00:00
Ronnie Sahlberg eb39a99b2c Speed updates
create generic macros for allocating/freeing structures.

remove one more slow GMemChunk and replace it with a simple linked list

~4% speed improvement in my tests.

the allocated data is never freed.   this may be a problem if ethereal is
ever supported on a platform lacking resource tracking but makes the
implementation faster and simpler.

svn path=/trunk/; revision=9095
2003-11-26 12:22:22 +00:00
Guy Harris 26d021d8eb As with fvalue_t, so with field_info and item_label - the individual
items aren't individually g_mallocated and can't be g_freed, only the
chunks can.

svn path=/trunk/; revision=9091
2003-11-25 20:02:42 +00:00
Ronnie Sahlberg 06ed59a1ec replace free_node_field_info with a macro since it is only called from one other place in the code and this reduces one unnecessary function call overhead.
and it makes ethereal ~1% faster.

svn path=/trunk/; revision=9088
2003-11-25 14:16:30 +00:00
Ronnie Sahlberg c68fddc5e1 rename FREE_FIELD_INFO to FIELD_INFO_FREE for consistency
svn path=/trunk/; revision=9087
2003-11-25 14:11:44 +00:00
Ronnie Sahlberg fec720051f create a FIELD_INFO_NEW for consistency
svn path=/trunk/; revision=9086
2003-11-25 14:10:27 +00:00
Ronnie Sahlberg 9d88e58e51 remove another slow GMemChunk from ethereal making ethereal a little bit faster
svn path=/trunk/; revision=9085
2003-11-25 14:07:45 +00:00
Ronnie Sahlberg 04d07e6578 change free_field_info to FREE_FIELD_INFO to indicate it is a macro and not a function
svn path=/trunk/; revision=9084
2003-11-25 13:23:10 +00:00
Ronnie Sahlberg 4f84e65c50 fvalue_free() is one of the most called functions.
This function is also very small, so small that teh overhead for the actual function call and return is likely to be a significant part
of its execution time.

change it into a macro and make it thus slightly faster by eliminating the function call overhead.

svn path=/trunk/; revision=9083
2003-11-25 13:20:36 +00:00
Guy Harris 122dd3959c Make the recent epan/proto.{c,h} change compile.
svn path=/trunk/; revision=9075
2003-11-24 22:11:55 +00:00
Ronnie Sahlberg fa1ee7667b performance enhancement to proto.c
Removed the GMemChunk used to allocate/free field_info structures
and used a free list to store the freed structs until they are allocated again.

Ethereal will allocate more field_info structs as it needs to but never free them. Instead the are just placed in a cheap and fast free list so that if we
want to use the struct again, this will be fast.

This affects the speed of the two functions
alloc_field_info() that should be slightly faster now
free_field_info() that was replaced with a 2 line macro.

All in all  my testing suggests that ethereal is 2-3% faster with this patch.

svn path=/trunk/; revision=9073
2003-11-24 21:12:10 +00:00
Ronnie Sahlberg ac1608f3c6 As per Guys suggestion, continue optimizing proto.c to macroize it
and make it even faster

svn path=/trunk/; revision=9064
2003-11-22 04:41:31 +00:00
Ronnie Sahlberg 7eef1914e0 Performance fix
In the GPROF logs proto_registrar_get_nth() used to take anything between 2.5 and 5.5% of the time.

Replace the GLIB array with a handroleld one for one of the private structures.

the function should now be virtually zero cost
and thus ethereal should be 2.5-5.5% faster on those traces.

anyone that wants to, please rerun GPROF with this fix and see what has changed.

svn path=/trunk/; revision=9058
2003-11-21 14:58:49 +00:00
Guy Harris 92b2d0f796 Use "tvb_get_string()" in "proto_tree_set_string_tvb()" - it won't leak
memory if it throws an exception, as it checks whether the entire string
is in the tvbuff *before* allocating a buffer for it, and that also
means that if the length is absurdly large, an exception will be thrown,
rather than the memory allocation failing.

svn path=/trunk/; revision=9043
2003-11-20 05:20:17 +00:00
Guy Harris 7bd2e232a9 Export "protocol_t" as an opaque type.
Make "proto_is_protocol_enabled()" and "proto_get_protocol_short_name()"
take a "protocol_t *" as an argument, so they don't have to look up the
"protocol_t" - this will probably speed them up considerably, and
they're called on almost every dissector handoff.

Get rid of a number of "proto_is_protocol_enabled()" calls that aren't
necessary (dissectors called through handles, including those called
through dissector tables, or called as heuristic dissectors, aren't even
called if their protocol isn't enabled).

Change some direct dissector calls to go through handles.

svn path=/trunk/; revision=8979
2003-11-16 23:17:27 +00:00
Guy Harris 624fe0ec15 Require that field names contain only alphanumerics, "-", "_", and ".".
Fix the names that contained other characters.

svn path=/trunk/; revision=8959
2003-11-13 23:38:33 +00:00
Guy Harris 0c0ef44095 Make the "fvalue_set" methods for types whose value is allocated free
any previously-allocated version first, so that they don't leak memory.

From Olivier Biot: add a "proto_item_append_string()" routine, to append
to the string value a protocol tree item has.

svn path=/trunk/; revision=8821
2003-10-29 23:48:14 +00:00
Guy Harris af5b47a0c2 When registering a field, make sure its ID is -1 or 0 - if it's not,
that probably means you've registered two fields with the same field ID
variable, which is an error.

Fix the bugs doing so found.

svn path=/trunk/; revision=8629
2003-10-06 20:46:52 +00:00
Guy Harris e4e0150ffa From Matthijs Melchior:
support for registering fields after all the protocol
	    registration routines are called (i.e., adding fields to the
	    named field tree as they're registered);

	fix the GTK 2.x version of the field list dialog to show the
	    correct name.

svn path=/trunk/; revision=8248
2003-08-25 00:15:02 +00:00
Guy Harris 5b04b9a4ff Give FT_IPv4 val_repr_len and val_to_repr methods, and use them for
generating display filters from FT_IPv4 fields.

svn path=/trunk/; revision=8110
2003-07-31 04:18:01 +00:00
Guy Harris adf711d5fb Add val_repr_len and val_to_repr methods for FT_FLOAT and FT_DOUBLE, and
use them when generating display filters to match field values.  Use
"%{FLT_DIG}g" rather than "%{FLT_DIG}f" for FT_FLOAT.

svn path=/trunk/; revision=8109
2003-07-31 03:52:43 +00:00
Guy Harris b37514b435 Give FT_ABSOLUTE_TIME and FT_RELATIVE_TIME val_repr_len and val_to_repr
methods, and use them when constructing display filters.

svn path=/trunk/; revision=8107
2003-07-30 22:50:39 +00:00
Guy Harris 2bb321d981 Mark the "plugin_dir" argument to "proto_init()" as unused if we don't
have plugin support.  (Don't do so if we *do* have it, because if
"proto_init()" ever changes so that it doesn't use the argument even if
we have plugin support, we want a warning so we know that we should get
rid of that argument.)

svn path=/trunk/; revision=7972
2003-07-07 20:29:45 +00:00
Gilbert Ramirez 803619a6dd Use FLT_DIG and DBL_DIG from float.h to create printf-style print format
for FT_FLOAT and FT_DOUBLE values.

svn path=/trunk/; revision=7962
2003-07-04 03:41:00 +00:00
Guy Harris ee97ce3196 Add new routines:
tvb_get_string() - takes a tvbuff, an offset, and a length as
	arguments, allocates a buffer big enough to hold a string with
	the specified number of bytes plus an added null terminator
	(i.e., length+1), copies the specified number of bytes from the
	tvbuff, at the specified offset, to that buffer and puts in a
	null terminator, and returns a pointer to that buffer (or throws
	an exception before allocating the buffer if that many bytes
	aren't available in the tvbuff);

	tvb_get_stringz() - takes a tvbuff, an offset, and a pointer to
	a "gint" as arguments, gets the size of the null-terminated
	string starting at the specified offset in the tvbuff (throwing
	an exception if the null terminator isn't found), allocates a
	buffer big enough to hold that string, copies the string to that
	buffer, and returns a pointer to that buffer and stores the
	length of the string (including the terminating null) in the
	variable pointed to by the "gint" pointer.

Replace many pieces of code allocating a buffer and copying a string
with calls to "tvb_get_string()" (for one thing, "tvb_get_string()"
doesn't require you to remember that the argument to
"tvb_get_nstringz0()" is the size of the buffer into which you're
copying the string, which might be the length of the string to be copied
*plus 1*).

Don't use fixed-length buffers for null-terminated strings (even if the
code that generates those packets has a #define to limit the length of
the string).  Use "tvb_get_stringz()", instead.

In some cases where a value is fetched but is only used to pass an
argument to a "proto_tree_add_XXX" routine, use "proto_tree_add_item()"
instead.

svn path=/trunk/; revision=7859
2003-06-12 08:33:32 +00:00
Guy Harris 6fc868b2c9 Put in a missing "break" statement.
svn path=/trunk/; revision=7850
2003-06-11 21:48:39 +00:00
Gilbert Ramirez 6823d063ee Expand the ability of fvalue_to_string_repr, and modify more FT_* types
to provide that method.

svn path=/trunk/; revision=7849
2003-06-11 21:24:54 +00:00
Guy Harris 9472b08c4e Get rid of an unused variable.
svn path=/trunk/; revision=7832
2003-06-10 18:03:23 +00:00
Gerald Combs 37521e54a5 Use "=" instead of "==" in an assignment.
svn path=/trunk/; revision=7792
2003-06-05 21:54:54 +00:00
Guy Harris 85ada1dec6 When "proto_tree_add_item()" is used with FT_STRINGZ with a length
value, just copy the specified number of bytes and stick a '\0' at the
end, don't use "tvb_get_nstringz0()" - yes, you end up copying more
bytes, but you don't have to bother looking for a '\0' that might not
even be present (if the string is null-padded rather than
null-terminated).

Also, set the length of the item to the specified length, rather than to
the length up to the terminating '\0' - if the string is null-padded,
the field should include all the padding bytes.

svn path=/trunk/; revision=7785
2003-06-05 03:57:38 +00:00
Guy Harris aa1c605ba3 When "proto_tree_add_item()" is used with an FT_STRINGZ and given a
length (rather than being given -1), the length is, in most cases, the
maximum length of a null-*padded* string, rather than the actual length
of a null-*terminated* string.  Treat it as such - allocate a buffer one
larger than the length (to leave room for a terminating '\0'), and pass
the size of that buffer to "tvb_get_nstringz0()".  (Otherwise, in those
cases, the last character of the string is chopped off.)

Allow "proto_tree_add_string()" to add FT_STRINGZ items to the protocol
tree, as well as FT_STRING items.

In "alloc_field_info()", if we're passed a length of -1 and the field is
an FT_STRINGZ, don't make the length be the length remaining in the
tvbuff; that way, you *can* use a length of -1 in
"proto_tree_add_item()" for an FT_STRINGZ item, and have it get the
actual length by looking for the terminating '\0'.

(We might want to distinguish between null-terminated and null-padded
strings, e.g. with an FT_STRINGZPAD type.  Null-terminated strings
rarely, if ever, have a specified length; the length is found by
scanning for the terminating '\0'.  Null-padded strings presumably
always have a specified length, which is the length to which the string
is padded.)

svn path=/trunk/; revision=7784
2003-06-04 21:51:54 +00:00
Gerald Combs 7a132e5b48 More tvb_get_nstringz0() fixes. Timo Sirainen pointed out that Bad
Things can happen if we pass a zero buffer length to tvb_get_nstringz0().
Throw an exception if this happens.

In various dissectors make sure the tvb_get_nstringz0()'s buffer length
is greater than zero.

svn path=/trunk/; revision=7688
2003-05-19 03:23:12 +00:00
Guy Harris 5105311cb1 Add a note about the "val_to_string_repr" and "string_repr_len" for
ftypes, and how to add them to more types and use them in more places.

svn path=/trunk/; revision=7636
2003-05-03 01:11:29 +00:00
Guy Harris ca318813a4 Rename "proto_alloc_dfilter_string()" to
"proto_construct_dfilter_string()", to more accurately reflect what it
does.

Give it, and "proto_can_match_selected()", an "epan_dissect_t *"
argument, which replaces the raw data pointer argument to
"proto_construct_dfilter_string()".

For fields that don't have a type we can directly filter on, we don't
support filtering on the field as raw data if:

	the "epan_dissect_t *" argument is null;

	the data source tvbuff for the field isn't the tvbuff for the
	"epan_dissect_t" in question (i.e., it's in the result of a
	reassembly, and "frame[N:M]" can't get at it).

Trim the length the raw data in the case of such a field to the length
of the tvbuff for the "epan_dissect_t" in question, so we don't go past
it.  Fetch the raw data bytes to match from that tvbuff.

Have "proto_construct_dfilter_string()" return a null pointer if it
can't construct the filter string, and have "protocolinfo_packet()" in
the tap-protocolinfo tap ignore a field if
"proto_construct_dfilter_string()" can't construct a filter string for
it - and have it pass NULL as the "epan_dissect_t *", for now.  If
somebody decides it makes sense to dump out a "frame[N:M] =" value for
non-registered fields, it can be changed to pass "edt".

svn path=/trunk/; revision=7635
2003-05-03 00:48:37 +00:00
Guy Harris 1025817e84 Add a "proto_item_set_end()" routine that sets the length of an item
given a tvbuff/offset pair referring to the byte past the end of the
item.  Use it in one place in the SMB dissector (there are plenty of
other places where it could be used as well).

svn path=/trunk/; revision=7603
2003-04-29 21:27:19 +00:00
Gilbert Ramirez 9615c4ef25 Provide a way for ftype modules to provide a string representation
of their value. Provide such a method for FT_BYTES, FT_UINT_BYTES,
and FT_ETHER. Have proto_alloc_dfilter_string() use the new methods.

This is part of a movement of ftype-related code out of proto.c and
into the ftype code. The immediate effect is that generated display
filters for long byte sequences don't incorrectly have trailing periods
("...") to indicate continuation.

svn path=/trunk/; revision=7100
2003-02-08 04:22:37 +00:00
Guy Harris ab552d3746 Get rid of BASE_BIN - it's just the same as BASE_DEC, but people seemed
to be using it for stuff that should be hex, and for stuff that should
be Boolean.  Use BASE_DEC if it should be decimal, BASE_HEX if it should
be hex, and make it Boolean if it should be Boolean.

svn path=/trunk/; revision=7053
2003-01-31 03:17:56 +00:00