Commit Graph

40 Commits

Author SHA1 Message Date
Guy Harris 857318d3b7 Use "tvb_get_string()" instead of allocating a (len+1)-sized buffer,
"tvb_memcpy()"ing to it, and putting in a null terminator;
"tvb_get_string()" will check whether all bytes of the string are
present before allocating the buffer, so that you don't leak memory if
the copy throws an exception, and don't crash if the length is absurdly
large.

Use "tvb_memdup()" instead of allocating a buffer and "tvb_memcpy()"ing
to it, so that an exception is thrown before you try to allocate the
buffer (for the same reasons as listed above).

Before allocating a buffer used when processing a chunk of data from a
packet, get a pointer to the chunk with "tvb_get_ptr()", or check that
the data is all there with "tvb_ensure_bytes_exist()", so that an
exception is thrown before you try to allocate the buffer (for the same
reasons as listed above).

Fix up the lengths of the tvbuff used when dissecting ONC RPC opaque data
with a particular dissector.

svn path=/trunk/; revision=10236
2004-02-25 09:31:07 +00:00
Guy Harris 8026255c08 Update Andreas Sikkema's e-mail address.
svn path=/trunk/; revision=10065
2004-02-14 22:48:53 +00:00
Guy Harris d2144984db From Martin Mathieson: display the bitfields for
- the first 2 bytes of RTP headers
	- the first byte of RTCP report.

svn path=/trunk/; revision=8923
2003-11-09 22:55:35 +00:00
Guy Harris 2573a5527a From Laurent Rabret: use "g_free()", not "free()", to free stuff
allocated with "g_malloc()" and related GLib routines.

svn path=/trunk/; revision=7758
2003-05-28 22:40:19 +00:00
Laurent Deniel 4e9e699536 Replace some unchecked malloc calls by g_malloc.
svn path=/trunk/; revision=7584
2003-04-27 20:57:58 +00:00
Jörg Mayer 7c4176d868 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=6117
2002-08-28 21:04:11 +00:00
Jörg Mayer 173fe5aef4 Replace the types from sys/types.h and netinet/in.h by their glib.h
equivalents for the toplevel directory. The removal of winsock2.h will
hopefully not cause any problems under MSVC++, as those files using
struct timeval still include wtap.h, which still includes winsock2.h.

svn path=/trunk/; revision=5932
2002-08-02 23:36:07 +00:00
Guy Harris 91ab6eb809 Change a "proto_tree_add_uint()" call to use "proto_tree_add_item()".
When dissecting a BYE packet, bump the chunk count when dissecting the
SSRC/CSRC identifiers, so the loop terminates properly.

svn path=/trunk/; revision=5892
2002-07-17 10:37:31 +00:00
Guy Harris 8440dc6316 From Jason Lango: a hack to get SDES length correct on QT packets.
svn path=/trunk/; revision=5167
2002-04-15 21:25:05 +00:00
Guy Harris d8d081866f From Joerg Mayer: remove unused parameters.
svn path=/trunk/; revision=5136
2002-04-09 09:04:33 +00:00
Guy Harris ee5ca25d31 Include files from the "epan" directory and subdirectories thereof with
"epan/..." pathnames, so as to avoid collisions with header files in any
of the directories in which we look (e.g., "proto.h", as some other
package has its own "proto.h" file which it installs in the top-level
include directory).

Don't add "-I" flags to search "epan", as that's no longer necessary
(and we want includes of "epan" headers to fail if the "epan/" is left
out, so that we don't re-introduce includes lacking "epan/").

svn path=/trunk/; revision=4586
2002-01-21 07:37:49 +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 a4d560eb5b From Nagarjuna Venna: only display the reason in BYE RTCP packets if
it's present.

svn path=/trunk/; revision=4518
2002-01-10 22:21:14 +00:00
Guy Harris 23319ff023 Move the pointer to the "column_info" structure in the "frame_data"
structure to the "packet_info" structure; only stuff that's permanently
stored with each frame should be in the "frame_data" structure, and the
"column_info" structure is not guaranteed to hold the column values for
that frame at all times - it was only in the "frame_data" structure so
that it could be passed to dissectors, and, as all dissectors are now
passed a pointer to a "packet_info" structure, it could just as well be
put in the "packet_info" structure.

That saves memory, by shrinking the "frame_data" structure (there's one
of those per frame), and also lets us clean up the code a bit.

svn path=/trunk/; revision=4370
2001-12-10 00:26:21 +00:00
Guy Harris c22d3fdc96 Get rid of the lists of conversation dissectors; instead, have a
dissector table contain both a hash table, to use to look up port
numbers to find a dissector, and a list of all dissectors that *could*
be assigned to ports in that hash table, to be used by user interface
code.

Make the "Decode As" dialog box code use that.

Also make it *not* let you choose whether to set the dissector for both
the UDP and TCP versions of a port; some protocols run only atop TCP,
some run only atop UDP, and even those that can run atop both may have
different dissector handles to use over TCP and UDP, so handling a
single merged list would be a mess.  (If the user is setting the
dissector for a TCP port, only those protocols that Ethereal can handle
over TCP should be listed; if the user is setting the dissector for a
UDP port, only those protocols that Ethereal can handle over TCP should
be listed; if the user is setting a dissector for both, only those
protocols that Ethereal can handle over *both* TCP *and* UDP should be
listed, *and* there needs to be a way to let the "Decode As" code get
both the TCP handle *and* the UDP handle and use the right ones.  If
somebody really wants that, they need to implement all of the above if
they want the code to be correct.)

Fix the code that handles setting the dissection for the IP protocol
number to correctly update the lists of protocols being dissected as TCP
and as UDP; the code before this change wasn't updating the single such
list to add new protocols.

svn path=/trunk/; revision=4311
2001-12-03 08:47:31 +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
Guy Harris 07b2709f8a Change "conversation_set_dissector()" to take a dissector handle, rather
than a pointer to a dissector function, as an argument.

This means that the conversation dissector is called through
"call_dissector()", so the dissector itself doesn't have to worry about
checking whether the protocol is enabled or setting
"pinfo->current_proto", so get rid of the code that does that in
conversation dissectors.  Also, make the conversation dissectors static.

Get rid of some direct calls to dissectors; replace them with calls
through handles, and, again, get rid of code to check whether a protocol
is enabled and set "pinfo->current_proto" where that code isn't needed.
Make those dissectors static if they aren't already static.

Add a routine "create_dissector_handle()" to create a dissector handle
without registering it by name, if the dissector isn't used outside the
module in which it's defined.

svn path=/trunk/; revision=4281
2001-11-27 07:13:32 +00:00
Ed Warnicke 4877553530 Switched from using CHECK_DISPLAY_AS_DATA to using CHECK_DISPLAY_AS_X
which also takes a handle as an argument and thus doesn't call
dissect_data directly.

svn path=/trunk/; revision=4270
2001-11-26 05:13:14 +00:00
Guy Harris 0ee22efcd6 From Jason Lango:
Clean up RTSP Transport parsing and sub-conversation code.
	Dissect RTP/MP4 (and other RTP/xxx) as RTP/AVP (for now).

svn path=/trunk/; revision=3912
2001-09-08 00:43:51 +00:00
Guy Harris 3388bde488 Instead of having a single datum attached to a conversation, have a list
of protocol-id-plus-datum pairs, so that multiple protocols can attach
information to the same conversation.

Dissectors that attach information to a conversation should not assume
that if they find a conversation it has one of its data attached to it;
the conversation might've been created by another dissector.

svn path=/trunk/; revision=3901
2001-09-03 10:33:12 +00:00
Guy Harris 24ddb0198b Make routines that are passed an unsigned integer as their last argument
have an unsigned integer as that argument; this squelches some compiler
warnings, and it's the right thing to do in any case.

Don't check whether an unsigned integer value is > 0 - that's the same
as checking whether it's != 0.

svn path=/trunk/; revision=3898
2001-09-03 08:10:46 +00:00
Guy Harris c290d9c859 Check first whether there's any data left in the packet before checking
whether that data is an end-marker in an SDES, so we don't report a
malformed frame if the SDES list doesn't end with an RTCP_SDES_END
marker (RFC 1889 says "The list of items in each chunk is terminated by
one or more null octets, the first of which is interpreted as an item
type of zero to denote the end of the list", but the "Parsing RTCP SDES
packets" example doesn't seem to treat hitting the end of the frame
before seeing an RTCP_SDES_END as an error, and at least one Quicktime
capture I have has no RTCP_SDES_END at the end).

Use "tvb_reported_length_remaining()" to do the check, so that we don't
stop until we either hit the *real* end (rather than the capture end) of
the packet, or throw an exception (so that a "Short Frame" indication
shows up if the capture length was such that not all the frame was
captured).

svn path=/trunk/; revision=3848
2001-08-18 09:27:06 +00:00
Guy Harris 541af0c740 Use the "pinfo" argument, rather than the global "pi", to refer to the
packet information in tvbuffified dissectors.

svn path=/trunk/; revision=3645
2001-07-03 04:56:46 +00:00
Guy Harris 8073087bdf RTSP fixes, from nuf si.
svn path=/trunk/; revision=3580
2001-06-20 04:45:52 +00:00
Guy Harris 8412393197 From Joerg Mayer: explicitly fill in all members of a
"header_field_info" structure, including the ones that are later set by
the routines to register fields.

svn path=/trunk/; revision=3561
2001-06-18 02:18:27 +00:00
Guy Harris 22b8c6770f Give a number of files RCS IDs.
Give "proto_hier_stats.h" a standard header.

svn path=/trunk/; revision=3540
2001-06-12 06:32:39 +00:00
Guy Harris 4f10e27d03 Get rid of BYTES_ARE_IN_FRAME references.
svn path=/trunk/; revision=3365
2001-04-23 04:35:39 +00:00
Guy Harris 43ccfd8054 Add an additional "protocol index" argument to "{old_}dissector_add()",
"{old_}heur_dissector_add()", "{old_}conv_dissector_add()", and
"register_dissector()", so that an entry in those tables has associated
with it the protocol index of the protocol the dissector handles (or -1,
if there is no protocol index for it).

This is for future use in a number of places.

(Arguably, "proto_register_protocol()" should take a dissector pointer
as an argument, but

	1) it'd have to handle both regular and heuristic dissectors;

	2) making it take either a "dissector_t" or a union of that and
	   a "heur_dissector_t" introduces some painful header-file
	   interdependencies

so I'm punting on that for now.  As with other Ethereal internal APIs,
these APIs are subject to change in the future, at least until Ethereal
1.0 comes out....)

svn path=/trunk/; revision=2849
2001-01-09 06:32:10 +00:00
Guy Harris 925ce16014 Add tables of "conversation" dissectors, which are associated with
particular protocols, and which keep track of all dissectors that could
be associated with conversations using those particular protocols - for
example, the RTP and RTCP dissectors could be assigned to UDP
conversations.

This is for future use with UI features allowing the dissector for a
given conversation to be set from the UI, to allow

	1) conversations between two ports, both of which have
	   dissectors associated with them, that have been given to the
	   wrong dissector to be given to the right dissector;

	2) conversations between two ports, neither of which have
	   dissectors associated with them, to be given to a dissector
	   (RTP and RTCP, for example, typically run on random ports,
	   and if you don't have, in a capture, traffic that would say
	   "OK, traffic between these two hosts and ports will be RTP
	   traffic", you may have to tell Ethereal explicitly what
	   protocol the conversation is).

svn path=/trunk/; revision=2848
2001-01-09 05:53:21 +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 252d55d80f For each column, have both a buffer into which strings for that column
can be put, and a pointer to the string for the column, which might or
might not point to that buffer.

Add a routine "col_set_str()", which sets the string for the column to
the string passed to it as an argument; it should only be handed a
static string (a string constant would be ideal).  It doesn't do any
copying, so it's faster than "col_add_str()".

Make the routines that append to columns check whether the pointer to
the string for the column points to the buffer for the column and, if
not, copy the string for the column to the buffer for the column so that
you can append to it (so you can use "col_set_str()" and then use
"col_append_str()" or "col_append_fstr()").

Convert a bunch of "col_add_str()" calls that take a string constant as
an argument to "col_set_str()" calls.

Convert some "col_add_fstr()" calls that take a string constant as the
only argument - i.e., the format string doesn't have any "%" slots into
which to put strings for subsequent arguments to "col_set_str()" calls
(those calls are just like "col_add_str()" calls).

Replace an END_OF_FRAME reference in a tvbuffified dissector with a
"tvb_length(tvb)" call.

svn path=/trunk/; revision=2670
2000-11-19 08:54:37 +00:00
Guy Harris 9bae9707d3 Make the RTCP, RTP, WSP, and WTP dissectors check whether their
protocols have been disabled.

Get rid of the "no tvbuff" dissectors for WSP and WTP - they're not used
(and shouldn't ever be used).

Make "dissect_wtp()" static, as it's not used outside "packet-wtp.c".

svn path=/trunk/; revision=2568
2000-11-05 09:30:11 +00:00
Guy Harris 563f86ee5e Support for conversations with "wildcard" destination addresses, from
Jeff Foster.

svn path=/trunk/; revision=2523
2000-10-21 05:52:28 +00:00
Guy Harris 4e8bb31693 Dissect the allegedly-NTP time stamp in a Sender Report packet as two
32-bit integers, until we figure out what it really is.

svn path=/trunk/; revision=2516
2000-10-19 08:17:45 +00:00
Guy Harris 3f8b7cd0fc Andreas Sikkema's new H.261 and TPKT dissectors, replacement RTCP and
RTP dissectors, and changes to the Q.931 dissector for use with H.323.

svn path=/trunk/; revision=2511
2000-10-19 06:45:11 +00:00
Gilbert Ramirez 9941aabd64 Move format_text(), get_token_len(), and fine_line_end(), into strutil.c
This keeps tvbuff.c generic; it doesn't have to pull in packet.h and all
of it's included files.

svn path=/trunk/; revision=2409
2000-09-11 16:16:13 +00:00
Laurent Deniel cc36f0b931 Add the "Edit:Protocols..." feature which currently only implements
the following:

It is now possible to enable/disable a particular protocol decoding
(i.e. the protocol dissector is void or not). When a protocol
is disabled, it is displayed as Data and of course, all linked
sub-protocols are disabled as well.

Disabling a protocol could be interesting:

- in case of buggy dissectors
- in case of wrong heuristics
- for performance reasons
- to decode the data as another protocol (TODO)

Currently (if I am not wrong), all dissectors but NFS can be disabled
(and dissectors that do not register protocols :-)

I do not like the way the RPC sub-dissectors are disabled (in the
sub-dissectors) since this could be done in the RPC dissector itself,
knowing the sub-protocol hfinfo entry (this is why, I've not modified
the NFS one yet).

Two functions are added in proto.c :

gboolean proto_is_protocol_enabled(int n);
void proto_set_decoding(int n, gboolean enabled);

and two MACROs which can be used in dissectors:

OLD_CHECK_DISPLAY_AS_DATA(index, pd, offset, fd, tree)
CHECK_DISPLAY_AS_DATA(index, tvb, pinfo, tree)

See also the XXX in proto_dlg.c and proto.c around the new functions.

svn path=/trunk/; revision=2267
2000-08-13 14:09:15 +00:00
Guy Harris 283ce59938 Add routines for adding items to a protocol tree that take arguments of
a particular type, rather than taking a varargs list, along the lines of
the "proto_tree_add_XXX_format()" routines.

Replace most calls to "proto_tree_add_item()" and
"proto_tree_add_item_hidden()" with calls to those routines.

Rename "proto_tree_add_item()" and "proto_tree_add_item_hidden()" to
"proto_tree_add_item_old()" and "proto_tree_add_item_hidden_old()", and
add new "proto_tree_add_item()" and "proto_tree_add_item_hidden()"
routines that don't take the item to be added as an argument - instead,
they fetch the argument from the packet whose tvbuff was handed to them,
from the offset handed to them.

svn path=/trunk/; revision=2031
2000-05-31 05:09:07 +00:00
Gilbert Ramirez 292e38e2c6 Add tvbuff class.
Add exceptions routines.
Convert proto_tree_add_*() routines to require tvbuff_t* argument.
Convert all dissectors to pass NULL argument ("NullTVB" macro == NULL) as
the tvbuff_t* argument to proto_tree_add_*() routines.

dissect_packet() creates a tvbuff_t, wraps the next dissect call in
a TRY block, will print "Short Frame" on the proto_tree if a BoundsError
exception is caught.

The FDDI dissector is converted to use tvbuff's.

svn path=/trunk/; revision=1939
2000-05-11 08:18:09 +00:00
Guy Harris cd59d75124 Support for RTCP and RTP, from Jason Lango.
svn path=/trunk/; revision=1885
2000-04-21 01:45:58 +00:00