Commit Graph

32 Commits

Author SHA1 Message Date
Ed Warnicke 10cd0c5f70 Changed packet_init() to look up the frame dissector and cache its
dissector_handle in a static variable in packet.c.  Changed dissect_packet
to call dissector from using the call_dissector() function and the cached
dissector_handle for frame_dissector.  Changed the order of function
calls in epan_init() to allow for this change ( it sucks to look up
a dissector when none are registered ).

svn path=/trunk/; revision=3234
2001-04-01 22:01:34 +00:00
Ed Warnicke cd6ad9d4c0 Moved the the remaining column related routines out of packet.{c,h}
and into column-utils{c,h}.

svn path=/trunk/; revision=3231
2001-04-01 07:32:35 +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
Ed Warnicke 90f7f6184d Moved some definitions and functions from packet-osi.{c,h} to
epan/osi-utils.{c,h} to bring all of the epan dependencies into epan.

svn path=/trunk/; revision=3226
2001-04-01 05:48:15 +00:00
Ed Warnicke dd54ba9396 Moved the packet_info structure and supporting functions out of
packet.{h,c} and into a separate packet_info{h,c}.

svn path=/trunk/; revision=3225
2001-04-01 04:50:42 +00:00
Ed Warnicke 20eee44b70 Moved the frame_data structures and functions from packet.{h,c} to
frame_data{h,c}.  Added a frame_data_init to be called by epan_init.

svn path=/trunk/; revision=3223
2001-04-01 04:11:51 +00:00
Ed Warnicke c832ac2c35 Moved the value_string structures and function from packet.{c,h} into
a separate value_string.{c,h}.

svn path=/trunk/; revision=3221
2001-04-01 03:18:41 +00:00
Ed Warnicke c17e3b00c6 Moved various to_str files from packet.{c,h} to a separate
to_str.{c,h}.  Resolved strange situation where ipx_addr_to_str was
declared in packet.h but defined in packet-ipx.c by moving
ipx_addr_to_str, ipxnet_to_str_punct, and ipxnet_to_str from packet-ipx.{c,h}   to to_str.{c,h}

svn path=/trunk/; revision=3219
2001-04-01 02:47:56 +00:00
Ed Warnicke 3b6554c069 removed #include "print.h" and #include "file.h" from packet.c
svn path=/trunk/; revision=3218
2001-03-31 23:02:31 +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
Gilbert Ramirez a8b0c240e6 Move appletalk- and sna-related address routines out of the dissectors
and into epan.

svn path=/trunk/; revision=3160
2001-03-22 16:24:16 +00:00
Guy Harris a9659200c1 Add a new AT_OSI address type.
In the CLNP dissector, set the source and destination network-layer and
"top-level" addresses; this will cause them to show up in the source and
destination columns of the summary display if you're showing the
network-layer or top-level address (although you'll probably have to
widen those columns significantly to see the entire address), and also
makes them available to subdissectors.

svn path=/trunk/; revision=3131
2001-03-15 06:41:13 +00:00
Guy Harris b1eb3635c2 In "call_dissector()", if the protocol for the dissector referred to by
the handle has been disabled, return after calling "dissect_data()",
rather than driving on and calling the dissector anyway.

svn path=/trunk/; revision=3001
2001-02-08 07:06:55 +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 2072d03e78 Tvbuffify the PIM dissector.
It was the last dissector that used "old_call_dissector()", and
tvbuffifying it got rid of that, so get rid of "old_call_dissector()".

svn path=/trunk/; revision=2892
2001-01-13 06:34:35 +00:00
Guy Harris 2245c85dfe Also save and restore the value of "pinfo->match_port" in
"{old_}dissector_try_port()", so that its value doesn't get changed out
from under a dissector that calls "{old_}dissectory_try_port()".

svn path=/trunk/; revision=2890
2001-01-13 04:28:42 +00:00
Guy Harris 6c9d2c3d67 In all the routines that set "pinfo->current_proto" before calling a
dissector, save the current value of "pinfo->current_proto" and restore
it before returning; when you return, you're back in the dissector that
called the routine to call a dissector, so the current protocol is the
one for that dissector.  This may be important if a dissector calls a
subdissector and, after it returns, processes stuff in the packet after
the stuff dissected by the subdissectror.

This means it's safe for "dissector_try_heuristic()" to set it before
calling a heuristic dissector, as it'll put back the previous value when
it returns.

svn path=/trunk/; revision=2886
2001-01-12 09:25:29 +00:00
Guy Harris bd1d96cd6f In "{old_}dissector_try_port()", check whether the protocol for the
dissector is enabled and, if not, return FALSE, just as if there hadn't
been any entry for that port number in the table.  If it is enabled, set
"pinfo->current_proto" from its short name before calling the dissector.

In "dissector_try_heuristic()", check whether the protocols for
dissectors are enabled and, if not, skip those dissectors, just as if
they hadn't been in the table.  (We don't set "pinfo->current_proto"
before calling a dissector, as we don't know whether the dissector in
question will be the one to dissect the packet.  Arguably, we should
have, for heuristic dissectors, separate "recognize" and "dissect"
routines, where the former never throws an exception and returns TRUE or
FALSE, and the latter is called only if the "recognize" routine claimed
the frame, and is just a "dissector_t" that doesn't return a value.)

In "{old_}call_dissector()", check whether the protocol for the
dissector is enabled and, if not, call "{old_}dissect_data()".  if it is
enabled, set "pinfo->current_proto" from its short name before calling
the dissector.

svn path=/trunk/; revision=2861
2001-01-10 10:44:48 +00:00
Guy Harris 0ae122c3a9 Add a new "ip_to_str_buf()" routine that takes a pointer to an IP
address and a pointer to a character buffer as arguments, and puts a
printable form of the IP address into the buffer.  Make "ip_to_str()"
use it.

Make "host_name_lookup()" use "ip_to_str_buf()", not "ip_to_str()", so
that it doesn't trash any strings that a dissector has gotten with
"ip_to_str()" (for example, the ARP dissector gets strings for the
source and target protocol addresses, and then may attempt to register
names for the source and target hardware addresses with
"add_ether_byip()"; if "host_name_lookup()" fails to find a host name
for the IP address, it shouldn't use "ip_to_str()" to generate an IP
address string to associate with the IP address, as if that's done twice
it'll run out of "ip_to_str()" buffers - there're only 3 of them - and
trash one of the IP address strings the ARP dissector got).

svn path=/trunk/; revision=2850
2001-01-09 09:57:06 +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 a3fa5541a8 Add a "col_clear()" routine, to clear a column; it appears (and it
doesn't just seem to be a profiling artifact) that, at least on FreeBSD
3.4, it's significantly more efficient to clear out a column by stuffing
a '\0' into the first byte of the column data than to do so by copying a
null string (I guess when copying one byte, the fixed overhead of the
procedure call and of "strcpy()" is significant).

Have the TCP dissector set the Protocol column, and clear the Info
column, before doing anything that might cause an exception to be
thrown, so that if we *do* get an exception thrown, the frame at least
shows up as TCP.

Instead of, in the TCP dissector, constructing a string and then
stuffing it into the Info column, just append to the Info column, which
avoids one string copy.

Pass a "frame_data" pointer to dissectors for TCP and IP (and PPP)
options, so they can use it to append to the Info column.

svn path=/trunk/; revision=2744
2000-12-04 06:37:46 +00:00
Guy Harris 79d456e315 Declare "proto_malformed" in "packet-frame.h", as "packet-frame.c"
exports it.

Make the pointer that points to the GMemChunk for per-frame data static
to "epan/packet.c", as it's not used outside "epan/packet.c".

svn path=/trunk/; revision=2741
2000-12-03 22:32:10 +00:00
Guy Harris 6b744058c3 Nothing in "packet.c" uses the global "cfile", so there's no need to
declare it there.

svn path=/trunk/; revision=2740
2000-12-03 22:26:26 +00:00
Guy Harris 35b1907af8 Pull the code to set the fields in the "cfile.cinfo" structure into a
common routine to initialize a "column_info()" structure, shared by
Ethereal and Tethereal.

svn path=/trunk/; revision=2739
2000-12-03 22:12:21 +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 ea00ad9f58 Nobody calls "old_try_conversation_dissector()" or
"old_dissector_try_heuristic()" any more, as their users have all been
tvbuffified - get rid of them.

svn path=/trunk/; revision=2660
2000-11-18 11:47:21 +00:00
Guy Harris 77ad89b12d Add a mechanism by which a dissector can be registered by name, another
dissector can get a "handle" for that dissector by name and then call
that dissector through the handle.

This allows dissectors that can't be called through a port table or a
heuristic table to be called from other dissectors without directly
referring to the dissector function - dynamically-loaded modules, under
Windows, cannot directly call functions in the main program, and
non-plugin dissectors are in the main program and thus cannot be called
from plugin dissectors unless either

	1) a pointer to the dissector is put in the Big Transfer Vector

or

	2) some other mechanism for getting a pointer to the dissector
	   is provided.

This mechanism could also support registering old-style dissectors and
calling them from new-style dissectors without the new-style dissector
having to do the argument translation itself (I didn't add support for
registering old-style dissectors because I'd prefer to have people
tvbuffify their code if they have to register a dissector...).

It could also, in the future, perhaps support

	disabling of protocols;

	setting "pinfo->current_proto";

inside "call_dissector()" - and inside "{old_}dissector_try_port()" and
"{old_"dissector_try_heuristic()" - allowing a pile of stuff that
currently has to be done in every dissector be done by common code.
(I have some ideas about how to do this, by

	having "proto_register_protocol()" take an abbreviation - of the
	sort that would be put in, for example, "pinfo->current_proto" -
	as an argument;

	having the calls to register dissectors take an index returned
	by "proto_register_protocol()" as an argument.

The abbreviation could be used elsewhere as well, e.g. in the "Decoding"
tab of the "Edit->Protocols" dialog box, and in a GUI for constructing
protocol filters.  Watch this space.)

Make "dissect_sdp()" the first client of this mechanism; it's now static
to "packet-sdp.c", and all dissectors that call it - including the MGCP
plugin - now call it through a dissector handle fetched by
"find_dissector()".  (Next step - see if Ethereal can now compile on
Windows as a result of this.)

svn path=/trunk/; revision=2647
2000-11-15 07:07:52 +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
Guy Harris 7d663fe7b0 Add a fourth choice of time format in the packet list display, which
shows the date (in YYYY-MM-DD format) as well as the time of day when
the packet arrived.

svn path=/trunk/; revision=2547
2000-11-01 08:31:36 +00:00
Gilbert Ramirez e69b5278aa Implement epan_dissect_new() and epan_dissect_free(). These are the
"top-level" dissectors that libepan-users call, instead of dissect_packet().
The epan_dissect_t holds the tvbuff after dissection so that the tvbuff's
memory is not cleared until after the proto_tree is freed. (I might stuff
the proto_tree into the epan_dissect_t, too).

What remains of dissect_packet() in packet.c handles the tvbuff initialiation.
The real meat of dissect_packet() is now in dissect_frame(), in packet-frame.c
This means that "packet.c" is no longer a dissector, os it is no longer
passed to make-reg-dotc.

Once dissect_fddi() gets two wrapper functions (dissect_fddi_swapped()
and dissect_fddi_nonswapped()), the a dissector handoff routine could
be used instead of the switch statement in dissect_frame(). I'd register
a field like "wtap.encap"

svn path=/trunk/; revision=2478
2000-10-06 10:11:40 +00:00
Gilbert Ramirez cba2930d6b Move packet.[ch] to epan
svn path=/trunk/; revision=2460
2000-09-27 05:18:06 +00:00