Commit Graph

1154 Commits

Author SHA1 Message Date
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
Gerald Combs 21bb925496 Fix a typo.
svn path=/trunk/; revision=6956
2003-01-21 19:20:49 +00:00
Guy Harris 5eb1be46a7 From Ronald Henderson: fix up "snprintf()" and "vsnprintf()" calls in
"epan/proto.c" to properly handle string truncation (by checking both
for -1 and a value larger than the buffer size as an indication of
truncation, as some older versions of those routines return -1, and, if
the string was truncated, putting in a trailing '\0', as "snprintf()" on
some platforms might not put the trailing '\0' in).

svn path=/trunk/; revision=6830
2002-12-31 21:37:29 +00:00
Guy Harris a97b83a7f4 Add a new field type FT_FRAMENUM; an FT_FRAMENUM is a 32-bit unsigned
frame number, which is always decimal.  If you select an FT_FRAMENUM
field, there are menu items that let you go to the frame whose frame
number appears in that field.

Add FT_FRAMENUM fields for the ONC RPC "matching request is in this
frame" and "matching reply is in this frame" protocol tree items.

svn path=/trunk/; revision=6802
2002-12-19 02:58:53 +00:00
Guy Harris 7b743f7d7d Make the "strings" pointer in a "header_field_info" structure a const
pointer, and put "const" into the casts in "VALS()" and "TFS()" macros,
so we don't un-constify pointers to "value_string" arrays and
"true_false_string" structures.

Make some things "const" to keep the compiler happy with the previous
change.

svn path=/trunk/; revision=6684
2002-11-28 01:46:14 +00:00
Guy Harris f0269dd749 Squelch some compiler warnings.
svn path=/trunk/; revision=6426
2002-10-15 05:29:48 +00:00
Guy Harris 86576ce6ac When registering a protocol, make sure there are no other protocols with
the same long name, short name, or filter name, and abort if there are.

Fix the duplicate names that found (and another name error found while
fixing one of those errors).

svn path=/trunk/; revision=6425
2002-10-15 05:21:07 +00:00
Jörg Mayer 48be4e530d Removed trailing whitespaces from .h and .c files using the
winapi_cleanup tool written by Patrik Stridvall for the wine
project.

svn path=/trunk/; revision=6116
2002-08-28 20:41:00 +00:00
Guy Harris 6e56c25c9d From Ulf Lamping: add a new FT_FLOAT type, for single-precision
floating-point numbers, and display all the significant digits for both
single-precision and double-precision floating-point numbers in the
protocol tree, not just what "%g" does (6 digits).

Put in comments explaining how the length of filter strings is computed,
and fix some of the computations.

svn path=/trunk/; revision=6081
2002-08-24 19:45:28 +00:00
Guy Harris 14cff7ceba From Vassilii Khachaturov: put protocol blurbs into tables generated
with the "-G fields" flag.

In the scripts to process that output, handle FT_UINT64, FT_INT64, and
FT_UINT_STRING.

svn path=/trunk/; revision=6012
2002-08-18 19:08:30 +00:00
Jörg Mayer 3105ee542f Replace the types from sys/types.h and netinet/in.h by their glib.h
equivalents for the epan/ directory but leave winsock2.h in inet_pton.c
and inet_ntop.c for now (can't estimate the consequences).

svn path=/trunk/; revision=5928
2002-08-02 21:29:45 +00:00
Guy Harris 5adb2d031d From Joerg Mayer: fix a typo in a comment.
svn path=/trunk/; revision=5707
2002-06-19 19:21:15 +00:00
Guy Harris e390d7e0cc Make the "-G" flag take an argument. If no arugment is specified, or if
the argument is "fields", dump out a table of the fields, as we
currently do; if the argument is "protocols", dump out a table of the
protocols.

svn path=/trunk/; revision=5462
2002-05-14 10:15:12 +00:00
Gilbert Ramirez 41cc7f0707 Merge the work in Novell_NCP_branch into the mainline code.
A little work still needs to be done on the new NCP dissector -- make
some of the COL_INFO texts more useful, handle a Unicode issue, and
modify some of the cases that use "request conditions".
But the NCP dissector as it stands is very usable now.

Note: I didn't merge in the PROTO_LENGTH_UNTIL_END macro... I wanted
to think about the various possible macros and review an email conversation
I had with Guy on the subject.

svn path=/trunk/; revision=5432
2002-05-09 23:50:34 +00:00
Guy Harris 30f02bc99c Move the code to build the balanced tree of fields into "proto_init()",
move the code from "dfilter_lookup_token()" into
"proto_registrar_get_byname()", and get rid of "dfilter_lookup_token()"
and have its callers call "proto_registrar_get_byname()" instead.

svn path=/trunk/; revision=5287
2002-04-29 07:55:32 +00:00
Guy Harris dd9f02255d Note in a comment that the display filter code has its own mechanism for
looking up filter fields by name.

svn path=/trunk/; revision=5281
2002-04-28 23:39:58 +00:00
Guy Harris 4fb36a6b1d Use "format_text()" when setting the display representation of string
values, so that non-printable characters are shown as escapes.

svn path=/trunk/; revision=5280
2002-04-28 22:21:09 +00:00
Guy Harris 5984e4ba95 Clean up white space.
Fix the display filter expression generated for protocol tree items
without named fields attached to them; the length defaults to 1 if not
specified in a range expression, so the length should be specified.

svn path=/trunk/; revision=5208
2002-04-20 08:07:56 +00:00
Guy Harris a056c5052d proto_registrar_get_nth(hfinfo->id) == hfinfo, so use the latter rather
than the former.

svn path=/trunk/; revision=5203
2002-04-19 10:03:52 +00:00
Guy Harris 50155a975d From Phil Williams: support for looking up fields by name.
Clean up some white space, and one non-extern declaration in
"epan/proto.h".

svn path=/trunk/; revision=5201
2002-04-18 20:19:10 +00:00
Guy Harris ec005ccd0b Catch attempts to register ett_ values after the array of "tree is
expanded" flags has been allocated.

svn path=/trunk/; revision=5197
2002-04-18 00:50:45 +00:00
Guy Harris 3cf1b5ffa5 Before putting an item into a protocol tree, make sure the item above
it, if it's going to be displayed (i.e., if it's not the root node), has
had an ett_ value associated with it.

svn path=/trunk/; revision=5098
2002-04-04 20:23:50 +00:00
Guy Harris 5de2533f2d Start assigning ett_ values at 0, rather than 1; get rid of the reserved
ETT_NONE entry.

Initialize the "tree_type" field of a "field_info" structure to -1,
meaning "this has not been given a subtree".  Add checks before using
that field that it's in range.  That way, you have to create a subtree
before putting protocol tree items under another item.

We allocate the "tree_is_expanded" array when we've registered all
dissectors; there's no need to allocate it while we're registering
dissectors and, in fact, doing so means we leak memory (the memory for
the version we allocated while registering dissectors).

svn path=/trunk/; revision=5068
2002-04-01 02:00:53 +00:00
Guy Harris 165a8253b2 Allow "proto_item_append_text()" to an item that doesn't have a
representation string - set the representation string to the default
representation.  This lets you append to an item that's been added with
"proto_tree_add_XXX" calls that don't explicitly format the
representation string.

svn path=/trunk/; revision=4973
2002-03-19 08:42:16 +00:00
Gilbert Ramirez 6aad6e40b8 tvb_get_nstringz() needs to terminate a string with a NUL if the
end of the tvbuff is reached before the maximum_length passed by the
caller is reached and before a terminating NUL is found. In this case,
tvb_get_nstringz() returns a -1, but if the string is not artificially
terminated with a NUL by tvb_get_nstringz(), the
caller has no idea where the string should end because 1) the
return value "-1" gives the impression that the string ends
at the end of the buffer but 2) the string does
not end at the end of the buffer, but somewhere in the middle, due
to the packet being shorter than expected.

tvb_get_nstringz() and tvb_get_nstringz0() were both modified.

The FT_STRINGZ case in proto_tree_add_item() is made simpler.

During regression testing, when investigating a regression that I later
corrected, I discovered that strings added through proto_tree_add_item
(FT_STRING, FT_STRINGZ, and FT_UINT_STRING) leaked memory due to double
allocation of the string. The proto_tree_add_string*() functions do
not leak memory, since they only copy the string once. The memory
leak was fixed by adding another argument to the static function
proto_tree_set_string() to let the string ftype code know to g_strdup()
the string or not.

svn path=/trunk/; revision=4891
2002-03-06 19:17:06 +00:00
Guy Harris 52fb615708 From Joerg Mayer: get rid of "-Wno-unused" flag in some configure
scripts, and check in changes to add _U_ to some unused arguments (some
other should perhaps be used, so we leave the _U_ out so that the
warnings serve as a reminder to check those).

svn path=/trunk/; revision=4848
2002-03-02 20:51:46 +00:00
Gilbert Ramirez 2e6ded0440 Remove unused variables, structure definitions, and functions.
From Joerg Mayer.

svn path=/trunk/; revision=4827
2002-02-27 18:54:33 +00:00
Guy Harris cbf5c537c4 From Joerg Mayer: remove unused variables and declarations of
non-existent functions.

Remove the "filetype" argument from the "can_write_encap" functions for
particular capture file types - the argument value is implicit, in that
the routine being called is the routine for that particular file type.

svn path=/trunk/; revision=4823
2002-02-27 08:57:25 +00:00
Guy Harris 8166da40d5 Have "alloc_field_info()" take a pointer to the field length as an
argument, so if the length was supplied as -1, it can set it to the
length of data remaining in the tvbuff, so that its callers can use that
length when getting the value for the field, rather than leaving the
length in the "field_info" structure as -1.

svn path=/trunk/; revision=4752
2002-02-18 22:26:29 +00:00
Guy Harris 6a21dc7e44 Don't give tvbuffs names; instead, give data sources names, where a
"data source" has a name and a top-level tvbuff, and frames can have a
list of data sources associated with them.

Use the tvbuff pointer to determine which data source is the data source
for a given field; this means we don't have to worry about multiple data
sources with the same name - the only thing the name does is label the
notebook tab for the display of the data source, and label the hex dump
of the data source in print/Tethereal output.

Clean up a bunch of things discovered in the process of doing the above.

svn path=/trunk/; revision=4749
2002-02-18 01:08:44 +00:00
Gilbert Ramirez bd4a9c13eb Provide tvb_ensure_length_remaining(), which is like
tvb_length_remaining() except that it throws BoundsError if 'offset'
is out-of-bounds.

Allow a length argument of -1 for FT_STRING and FT_BYTES fields
in proto_tree_add_item().

Change some dissectors to either use -1 for the length argument in
calls to proto_tree_add_item(), or call tvb_ensure_length_remaining()
instead of tvb_length_remaining(), or to check the return-value
of tvb_length_remaining(). Changes to more dissectors are necessary,
but will follow later.

svn path=/trunk/; revision=4656
2002-02-01 04:34:17 +00:00
Guy Harris 92915713d3 Allow a length of -1 to be specified when adding FT_NONE and FT_PROTOCOL
items to the protocol tree; it's interpreted as "the rest of the data in
the tvbuff".  This can be used if

	1) the item covers the entire packet or the remaining payload in
	   the packet

or

	2) the item's length won't be known until it's dissected, and
	   will be then set with "proto_item_set_len()" - if an
	   exception is thrown in the dissection, it means the item ran
	   *past* the end of the tvbuff, so saying it runs to the end of
	   the tvbuff is reasonable.

Convert a number of "proto_tree_add_XXX()" calls using
"tvb_length_remaining()", values derived from the result of
"tvb_length()", or 0 (in the case of items whose length is unknown) to
use -1 instead (using 0 means that if an exception is thrown, selecting
the item highlights nothing; using -1 means it highlights all the data
for that item that's available).

In some places where "tvb_length()" or "tvb_length_remaining()" was used
to determine how large a packet is, use "tvb_reported_length()" or
"tvb_reported_length_remaining()", instead - the first two calls
indicate how much captured data was in the packet, the latter two calls
indicate how large the packet actually was (and the fact that using the
latter could cause BoundsError exceptions to be thrown is a feature - if
such an exception is thrown, the frame really *was* short, and it should
be tagged as such).

Replace some "proto_tree_add_XXX()" calls with equivalent
"proto_tree_add_item()" calls.

Fix some indentation.

svn path=/trunk/; revision=4578
2002-01-20 22:12:39 +00:00
Guy Harris e35851244c Clean up white space.
svn path=/trunk/; revision=4492
2002-01-07 01:05:33 +00:00
Gilbert Ramirez 791f5774d0 Provide for per-protocol-tree data in the proto_tree code.
Put a hash-table of "interesting" fields in the per-proto-tree data.
The dfilter code records which fields/protocols are "interesting" (by which
I mean, their value or existence is checked). Thus, the proto_tree routines
can create special arrays of field_info*'s that are ready for the dfilter
engine to use during a filter operation.

Also store the "proto_tree_is_visible" boolean, renamed "visible", in
the per-proto-tree data.

Move epan_dissect_t to its own header file to make #include dependencies
easier to handle.

Provide epan_dissect_fill_in_columns(), which accepts just the epan_dissect_t*
as an argument.

epan_dissect_new() needs to be followed by epan_dissect_run() for the
dissection to actually take place. Between those two calls,
epan_dissect_prime_dfilter() can be run 0, 1, or multiple times in order to
prime the empty proto_tree with the "intersesting" fields from the dfilter_t.

svn path=/trunk/; revision=4422
2001-12-18 19:09:08 +00:00
Gilbert Ramirez f1b64de80e Dfilter code finds field under *any* parent's subtree, not just
the parent under which the field was registered.

This is the *unoptimized* version, to give developers something
to use while the optimized version is being created.

svn path=/trunk/; revision=4351
2001-12-07 03:39:26 +00:00
Guy Harris bced8711f6 Make "dissector_add()", "dissector_delete()", and "dissector_change()"
take a dissector handle as an argument, rather than a pointer to a
dissector function and a protocol ID.  Associate dissector handles with
dissector table entries.

svn path=/trunk/; revision=4308
2001-12-03 04:00:26 +00:00
Ed Warnicke b7420272e7 Moved int-64bit.{c,h} into epan/
svn path=/trunk/; revision=4248
2001-11-22 03:07:07 +00:00
Guy Harris ecaca4b768 Fix an earlier typo of mine.
svn path=/trunk/; revision=4238
2001-11-21 01:01:17 +00:00
Guy Harris 8550cfcc6f Allow the tvbuff pointer to various "proto_tree_add" routines to be null
if (and only if) the length of the item being added is 0 (so that it has
no data backing it).

This means the data stream name pointer for the item in question is
null; make sure we handle that.

Use that for some "uses the value from the matching request" fields in
the SMB Pipe protocol.

svn path=/trunk/; revision=4231
2001-11-20 09:07:34 +00:00
Guy Harris 4a5538085f Get rid of NullTVB, the "compat_top_tvb" member of the "packet_info"
structure, the check for a null tvbuff pointer in "alloc_field_info()",
and the "tvb_create_from_top()" macro; they're no longer needed, as
there's no non-tvbuffified dissector code remaining.

svn path=/trunk/; revision=4205
2001-11-15 10:58:51 +00:00
Guy Harris f2676ba1c9 Tvbuffification of Negotiate Protocol, from Ronnie Sahlberg.
Fix up Info column to put "Request" or "Response" *after* the name of
the request.

Give the Negotiate Protocol request its full name.

svn path=/trunk/; revision=4139
2001-11-03 11:42:50 +00:00
Guy Harris 66c2940031 When freeing the "gpa_hfinfo" pointer array, free the array itself, as
well as the structure containing it.

svn path=/trunk/; revision=4131
2001-11-03 01:19:59 +00:00
Guy Harris 5511e79593 Add support for 64-bit signed integers in "int-64bit.[ch]", add an
FT_INT64 type, and make the Diameter dissector use it.

Handle the 64-bit integer types in the display filter semantics checks.

svn path=/trunk/; revision=4125
2001-11-02 10:09:51 +00:00
Guy Harris d82c74d757 From Ronnie Sahlberg: FT_UINT64 support, code to handle 64-bit integers
without requiring compiler support for them, and updates to the
Diameter, L2TP, NFS, and NLM dissectors to use it and to the ONC RPC
dissector to allow ONC RPC subdissectors to use it.

svn path=/trunk/; revision=4099
2001-10-29 21:13:13 +00:00
Gilbert Ramirez 038da8730a Fix some signed/unsigned comparison warnings. In the case of tvbuff.h,
there were 2 functions which accepted 'maxlength' == -1, but the function
prototypes had maxlength as a guint --- fixed.

svn path=/trunk/; revision=4087
2001-10-26 17:29:12 +00:00
Guy Harris 6f54015711 When putting protocols into the list of protocols, do a case-insensitive
sort.

Give iSCSI the short name "iSCSI" rather than "ISCSI".

svn path=/trunk/; revision=4067
2001-10-23 05:40:36 +00:00
Guy Harris 1d42c94b05 Make the resolution for time values be nanoseconds rather than
microseconds.

Fix some "signed vs. unsigned" comparison warnings.

svn path=/trunk/; revision=3934
2001-09-14 07:10:13 +00:00
Guy Harris fbe8da33f5 Add a "proto_item_append_text()" routine, which is like
"proto_item_set_text()" except that it appends the result of the
formatting to the item's current text, rather than replacing the item's
current text.  Use it in the DNS dissector.

svn path=/trunk/; revision=3880
2001-08-29 00:51:10 +00:00
Guy Harris aa4cd01b9b Get rid of "proto_tree_add_notext()" - if you create a subtree using it,
but, before you set the text, you throw an exception while putting stuff
under the subtree, you end up with an absolutely blank protocol tree
item, which is really gross.  Instead of calling
"proto_tree_add_notext()", call "proto_tree_add_text()" with at least a
minimal label - yes, it does mean you do some work that will probably be
unnecessary, but, absent a scheme to arrange to do that work if it *is*
necessary (e.g., catching exceptions), the alternative is an ugly
protocol tree display.

svn path=/trunk/; revision=3879
2001-08-28 08:28:19 +00:00
Guy Harris 74262f37de Patch from Lee Berger to properly skip past the length in FT_UINT_STRING
data objects if the length isn't 1.

svn path=/trunk/; revision=3821
2001-08-04 19:57:30 +00:00
Guy Harris d451acb66c Add a "time_secs_to_str_buf()" routine, which takes seconds and
fractions-of-a-second (the units of which are either milliseconds or
microseconds, specified by a Boolean argument), and formats it into a
"DD days, HH hours, MM minutes, SS seconds" using a buffer supplied to
it.  Have "time_secs_to_str()" and "time_msecs_to_str()" both use it.
Also, have it correctly handle the case of SS being > 0 but < 1 (which
"time_msecs_to_str()" didn't do).

Rename "rel_time_to_str()" to "rel_time_to_secs_str()", and add a
"rel_time_to_str()" routine that takes a "struct timeval" and hands its
seconds and microseconds values to "time_secs_to_str_buf()".  Use
"rel_time_to_secs_str()" to format FT_RELATIVE_TIME values for now; we
might want to use "rel_time_to_str()" for them, though, or make it an
option (either a user option, or a per-field option, using the field
that also holds BASE_ values).

svn path=/trunk/; revision=3806
2001-08-01 08:27:00 +00:00
Guy Harris f7b50ca754 From Joerg Mayer:
* gcc 3.0 warning fixes:
  - text2pcap.c: The number of characters to scan should probably not be 0
  - wiretap/csids.c: using preincrement on a variable used on both
    sides of an assignment might be undefined by the C99(?) standard
 * turn on additional warnings for epan and wiretap too
  - epan/configure.in
  - wiretap/configure.in
 * Fix some warnings (missing includes, signed/unsigned, missing
    initializers) found by turning on the warnings
  - all other files :-)

svn path=/trunk/; revision=3709
2001-07-13 00:55:58 +00:00
Guy Harris 2851b7ef76 Enable "Match Selected" only if there's a field selected *and* we can do
a "Match Selected" on it - we can't do a "Match Selected" if the field
has no value (e.g., FT_NULL) and has a length of 0.

If we unselect the current packet, we don't have a protocol tree, so we
don't have a currently selected field - clear the "Match Selected" menu
item and the display in the status line of information about the
currently selected field.

Move the low-level statusbar manipulation into "gtk/main.c", in routines
whose API doesn't expose anything GTK+-ish.

"close_cap_file()" calls one of those routines to clear out the status
bar, so it doesn't need to take a pointer to the statusbar widget as an
argument.

"clear_tree_and_hex_views()" is purely a display-manipulating routine;
move it to "gtk/proto_draw.c".

Extract from "tree_view_unselect_row_cb()" an "unselect_field()" routine
to do all the work that needs to be done if the currently selected
protocol tree row is unselected, and call it if the currently selected
packet list row is unselected (if it's unselected, there *is* no
protocol tree, so no row can be selected), as well as from
"tree_view_unselect_row_cb()".

Before pushing a new field-description message onto the statusbar, pop
the old one off.

Get rid of an unused variable (set, but not used).

svn path=/trunk/; revision=3513
2001-06-05 07:39:31 +00:00
Guy Harris 6200054304 Add support for "Match Selected" on FT_ABSOLUTE_TIME and
FT_RELATIVE_TIME fields.

svn path=/trunk/; revision=3488
2001-05-31 07:15:23 +00:00
Guy Harris a0dfbbbee5 When generating a filter expression to match a protocol tree line not
corresponding to a named field, by matching stuff at a particular offset
in the frame, don't treat a length of 1 byte specially - the syntax for
a one-byte byte string is the same as for longer byte strings, with no
leading "0x" allowed.

Clean up white space.

svn path=/trunk/; revision=3406
2001-05-09 01:22:46 +00:00
Guy Harris 3d2a6831d0 If "proto_item_set_len()" is passed a null pointer as its first
argument, have it just return; this allows dissectors that don't
explicitly check for a null protocol-tree argument to pass the
protocol-tree argument to "proto_tree_add_XXX()" routines - which means
they'll get a null pointer back if the protocol-tree argument is null
because we're not constructing a protocol tree - and then later use
"proto_item_set_len()" without having to check for a null
protocol-tree-item pointer.

svn path=/trunk/; revision=3402
2001-05-07 21:06:59 +00:00
Guy Harris ae84ef77de When registering numeric fields, check that a base other than BASE_NONE
was specified.

This should obviate the need to handle BASE_NONE specially in the
formatting routines, so revert to the previous version.

svn path=/trunk/; revision=3359
2001-04-23 01:19:39 +00:00
Ed Warnicke c16aaa518b Put BASE_NONE back into the FT_INTn and FT_UINTn display functions
with useful error messages.  Some dissector are registering
FT_INTn or FT_UINTn fields with BASE_NONE.  Now when ethereal dies
because of it the offending field will be identified so that it
can be fixed.

svn path=/trunk/; revision=3340
2001-04-20 03:59:11 +00:00
Guy Harris 7961bd2692 Don't allow BASE_NONE to be used with FT_INTn and FT_UINTn variables -
you have to select a base (even before this change, you had to select
one, otherwise the filter-construction GUI would crash if you selected
an FT_INTn or FT_UINTn field with BASE_NONE and then selected a
comparison operator).

svn path=/trunk/; revision=3337
2001-04-19 23:21:44 +00:00
Guy Harris 4caa331d21 Patch from Ronnie Sahlberg to cause the field description section of the
status bar to display nothing, rather than "Text (text)", when a
"proto_tree_add_text()" field is selected.

While we're at it, use a similar test to eliminate the text pseudo-field
from the output of "{ethereal,tethereal} -G", as well.

svn path=/trunk/; revision=3335
2001-04-19 23:06:23 +00:00
Guy Harris 7f0aaa324d If the tvbuff pointer is null in "alloc_field_info()", get the data
source name from "pi.compat_top_tvb", which should always be set to the
tvbuff that refers to the data that old-style dissectors are currently
working on.

Arrange that it be so set in those dissectors that create alternate data
sources and call other dissectors, and also arrange that "pi.len" and
"pi.captured_len" be set appropriately as well.

svn path=/trunk/; revision=3286
2001-04-10 19:10:10 +00:00
Guy Harris 00be3b8f13 Don't call "register_all_plugin_handoffs()" if we don't have plugin
support.

svn path=/trunk/; revision=3262
2001-04-05 19:25:16 +00:00
Ed Warnicke f5cf9c8dca Added two new arguments to epan_init() and proto_init() to
allow the passing of register_all_protocols() and
register_all_protocol_handoffs() through epan_init() to proto_init().
This allows the removal of the compile time dependence of proto.c
on register.h.  Modified dftest.c, tethereal.c, and gtk/main.c to
use the new style epan_init() and depend on register.h.

svn path=/trunk/; revision=3237
2001-04-02 00:38:36 +00:00
Ed Warnicke cb21a9735a Added a function proto_get_id_by_filter_name() function to proto.{c,h}
to allow the lookup of proto_ids by filter_name.

svn path=/trunk/; revision=3235
2001-04-01 22:50:08 +00:00
Ed Warnicke 21d1ad6375 Moved some ipv6 definitions from packet-ipv6.h to epan/ipv6-utils.h.
Fixed some typos.

svn path=/trunk/; revision=3230
2001-04-01 07:06:24 +00:00
Jeff Foster 486d964200 Change proto_item_add_subtree to test for NULL pi value and return NULL.
This is the same behavior as the proto_tree_add routines with NULL tree values.

svn path=/trunk/; revision=3191
2001-03-26 17:58:33 +00:00
Jeff Foster 395b68ea19 Changes required to support multiple named data sources.
Tvbuffers changed to added the data source name,
GUI and printing code changed to support these changes
and display the multiple hex views.

svn path=/trunk/; revision=3165
2001-03-23 14:44:04 +00:00
Guy Harris 022cfcf826 The other "proto_tree_add" routines will, if the "tree" argument is
null, just return NULL without doing any work; make
"proto_tree_add_item()" do so as well.

svn path=/trunk/; revision=3139
2001-03-15 22:08:41 +00:00
Gilbert Ramirez 712548da3e In the code that handles finding a field after a user clicks on
a byte in the hex dump,

1. Fix an off-by-one error when finding the field. This only showed up
if the selected byte had no field of its own and was only designated
as part of the parent protocol (like the 00-padding at the beginning of
TCP options).

2. Fix an off-by-one error when clicking on a character in the second
half of the "text dump" portion of the hex dump. I forgot about the
extra space between the first 8 characters and the second 8 characters.

svn path=/trunk/; revision=3117
2001-03-07 19:33:24 +00:00
Gilbert Ramirez 540f564993 Calculate the height and width of m_r_font globally, since various
routines need it.

When a user clicks on a hex digit or on the corresponding character
(the "text dump" portion) in the hex dump, find the field in the
proto_tree that the byte corresponds to, expand the GtkCTree so that
the field is viewable, select the field, and center it vertically.
LanAlyzer has this feature, and I've missed it in Ethereal.

svn path=/trunk/; revision=3096
2001-03-02 23:10:12 +00:00
Gilbert Ramirez 187934cad4 Create proper display filter for FT_BOOLEAN when using "Match Selected".
svn path=/trunk/; revision=3089
2001-03-01 20:24:05 +00:00
Guy Harris bea00e22cf In a display filter expression, make a field name refer to any of the
fields with that name.

svn path=/trunk/; revision=3030
2001-02-13 18:34:51 +00:00
Guy Harris 0196634a17 If there are multiple fields with the same name, list only one of them
in the output of "{ethereal,tethereal} -G", so that it appears only once
in the documentation.

Expand some comments to give more details.

svn path=/trunk/; revision=3024
2001-02-12 10:06:51 +00:00
Guy Harris c3ad47d04c Declare "proto_tree_set_protocol_tvb()" at the top, along with the other
"proto_tree_set_XXX_tvb()" routines.

svn path=/trunk/; revision=2971
2001-02-01 21:48:02 +00:00
Gilbert Ramirez 8f1fff2e6a Create a more modular type system for the FT_* types. Put them
into epan/ftypes.

Re-write display filter routines using Lemon parser instead of yacc.
Besides using a different tool, the new grammar is much simpler, while
the display filter engine itself is more powerful and more easily extended.

Add dftest executable, to test display filter "bytecode" generation.
Add option to "configure" to build dftest or randpkt, both of which are not
built by default.

Implement Ed Warnicke's ideas about dranges in the new display filter and
ftype code.

Remove type FT_TEXT_ONLY in favor of FT_NONE, and have protocols registered
as FT_PROTOCOL. Thus, FT_NONE is used only for simple labels in the proto tree,
while FT_PROTOCOL is used for protocols. This was necessary for being
able to make byte slices (ranges) out of protocols, like "frame[0:3]"

Win32 Makefile.nmake's will be added tonight.

svn path=/trunk/; revision=2967
2001-02-01 20:21:25 +00:00
Guy Harris 8b51643203 "Decode As" dialog, from David Hampton.
svn path=/trunk/; revision=2965
2001-02-01 07:34:33 +00:00
Guy Harris e7ea7a34e9 Clean up the dissector registration up a bit - arrange that all plugins
be loaded and their initialization routines called in right after we
call the initialization routines for built-in dissectors, but don't call
their handoff registration routines yet, and then call the handoff
registration routines right after calling the handoff registration
routines for built-in dissectors.

Do all that in "proto_init()", rather than "epan_init()".

That way, we call all dissector registration routines together, and then
call all dissector handoff registration routines together; all the
registration routines are called before any handoff registration
routines, as is required, and, as "proto_init()" is called by
"epan_init()" before "dfilter_init()" is called, all filterable fields
have been registered before "dfilter_init()" is called, and no plugins
have to call "dfilter_init()" themselves to get their fields registered.

Remove pointers to "dfilter_init()" and "dfilter_cleanup()" from the
plugin address table, as plugins shouldn't be calling them any more, and
remove calls to them from plugins.

svn path=/trunk/; revision=2940
2001-01-26 06:14:53 +00:00
Guy Harris 0e7c1de08a Have "proto_register_protocol()" build a list of data structures for
protocols, in addition to adding structures to the list of filterable
fields.  Give it an extra argument that specifies a "short name" for the
protocol, for use in such places as

	pinfo->current_proto;

	the dialog box for constructing filters;

	the preferences tab for the protocol;

and so on (although we're not yet using it in all those places).

Make the preference name that appears in the preferences file and the
command line for the DIAMETER protocol "diameter", not "Diameter"; the
convention is that the name in question be all-lower-case.

Make some routines and variables that aren't exported static.

Update a comment in the ICP dissector to make it clear that the
dissector won't see fragments other than the first fragment of a
fragmented datagram.

svn path=/trunk/; revision=2810
2001-01-03 06:56:03 +00:00
Guy Harris 99c98f9e74 Move "bytes_to_str()" to "strutil.c" from "packet.c" - it's just a
string formatter, like "format_text()", and, as "tvbuff.c" now calls it
(*vide infra*), we don't want to have to make "tvbuff.c" drag "packet.h"
in just to declare "bytes_to_str()".  It's now declared in "strutil.h",
so include it in modules that use "bytes_to_str()" and weren't already
including it.

Add a "tvb_bytes_to_str()" wrapper that calls "tvb_get_ptr()" to get a
pointer to a chunk of N bytes at a given offset in a tvbuff and then
hands that chunk to "bytes_to_str()".  Convert the code that was doing
that to use "tvb_bytes_to_str()" instead (which caught what I suspect is
a bug in the Q.2931 dissector, where it was handing an offset of 0 to
"tvb_get_ptr()" - a cut-and-pasteo, I think).

Tvbuffify the ARP dissector.

svn path=/trunk/; revision=2634
2000-11-13 07:19:37 +00:00
Nathan Neulinger e636484bf2 Corrected BASE_OCT support for display formats. Note - it probably isn't
correct to display ints.

svn path=/trunk/; revision=2552
2000-11-03 17:26:47 +00:00
Gilbert Ramirez 83ec54675c First step in moving core Ethereal routines to libepan.
svn path=/trunk/; revision=2458
2000-09-27 04:55:05 +00:00