Commit Graph

67 Commits

Author SHA1 Message Date
Guy Harris 32c0848007 Get rid of END_OF_FRAME references in tvbuffified dissectors.
svn path=/trunk/; revision=3364
2001-04-23 04:29:54 +00:00
Guy Harris 5f89c1d715 Conversation dissectors are called through a mechanism that doesn't
check for disabled protocols or set "pinfo->current_proto", so they have
to do that for themselves.

svn path=/trunk/; revision=3306
2001-04-15 09:05:17 +00:00
Guy Harris 15dcdcf3f8 Fix up a pile of NullTVB uses that were left in the previous checkin.
svn path=/trunk/; revision=3304
2001-04-15 07:51:11 +00:00
Guy Harris b0e06bd8d1 Tvbuffify the ASN.1 code and the Kerberos, LDAP, and SNMP dissectors.
Clean up some problems that revealed.

svn path=/trunk/; revision=3301
2001-04-15 07:30:03 +00:00
Guy Harris 1bfd09545e At least with UCD SNMP 4.1.2, you can safely pass to "sprint_value()" a
variable with a null pointer-to-value and a zero length, so we don't
need to protect the assignment to "variable.val.string" with
"SAFE_STRING()" - and doing so causes complaints from the compiler about
assigning a pointer to a "const gchar" to the non-const pointer
"variable.val.string".

svn path=/trunk/; revision=3267
2001-04-07 08:23:58 +00:00
Guy Harris 3d446c2609 Don't blow up if "asn1_string_value_decode()" supplies a null pointer as
the string because the string value is zero-length.

Don't try to treat an agent address in a V1 trap as an IP address if
it's not 4 bytes long.

svn path=/trunk/; revision=3265
2001-04-07 00:52:07 +00:00
Guy Harris ca49be4d3e In "dissect_snmp_parse_error()" and "dissect_snmp_error()", put an error
indication into the protocol tree as well as the summary line, so people
don't get confused if, say, doing "tethereal -V".

Pass those routines the subtree for the packet, rather than the
top-level tree, so that the error indication and the item for the rest
of the packet show up there rather than at the top level.

svn path=/trunk/; revision=3264
2001-04-06 23:12:33 +00:00
Gilbert Ramirez f75a4d1d87 Do a better job of #ifdef'ing out 3 variables in the case of non-UCD-SNMP
and linux.

svn path=/trunk/; revision=3081
2001-02-27 19:39:48 +00:00
Guy Harris a267b11066 Work around a CMU SNMP bug wherein "sprint_value()" dumps core if there
are no entries in any of the MIBs for any of the components of the
variable's OID.

svn path=/trunk/; revision=2961
2001-01-30 07:16:28 +00:00
Guy Harris 418d1cd9f8 SNMPv2u support.
svn path=/trunk/; revision=2957
2001-01-30 02:13:43 +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
Gilbert Ramirez 5b7f184296 Ensure that all value_string arrays end in {0, NULL}. Dissectors got away
with not terminating their arrays because they knew the limits of the
value used to look up strings in the value_string array, but the
dfilter_expr_dlg does not know these limits and must rely on the terminating
{0, NULL} record.

Also, in SNA fixed a bug in which a field should have been defined as FT_UINT8
but was defined as FT_BOOLEAN.

In WTP, fixed a value string which had duplicate keys.

svn path=/trunk/; revision=2817
2001-01-03 16:41:08 +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 60f9476740 Rename "asn1_octet_string_value_decode()" to
"asn1_string_value_decode()", as it can be used for various character
string types as well.

Turn "asn1_octet_string_decode()" into "asn1_string_decode()", which
takes an additional argument giving the tag expected for the string in
question, and make "asn1_octet_string_decode()" a wrapper around it.

Clean up the ASN.1 dissection in the Kerberos dissector, making more use
of the code in "asn1.c", wrapping more operations up in macros, and
doing some more type checking.

Use "REP" rather than "RESP" in names and strings; "REP" is what the
Kerberos spec uses.

Make the routines in the Kerberos dissector not used outside that
dissector static.

Fix some problems with the dissection of strings in the Kerberos
dissector (it was extracting the data from the wrong place in the
packet).

In Kerberos V5, the "kvno" item in the EncryptedData type is optional;
treat it as such.

Treat integers as unsigned in the Kerberos dissector.

svn path=/trunk/; revision=2777
2000-12-24 09:10:12 +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 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 339c4a4f66 Don't require that all SNMP packets go to or from the SNMP port - the
SNMP request would, but an SNMP reply can come back from another port.
Instead, when an SNMP request is seen, create a conversation with a
wildcard port, if one doesn't already exist, and make its dissector the
SNMP dissector.

svn path=/trunk/; revision=2526
2000-10-21 18:52:17 +00:00
Gilbert Ramirez 348ee93844 Move the dlclose() of libsnmp_handle into the libsnmp_handle != NULL
block.

svn path=/trunk/; revision=2446
2000-09-19 02:25:17 +00:00
Guy Harris b3bffc4741 Close the handle for the SNMP library after we're done with it - shared
objects are reference-counted so that won't make it disappear if
Ethereal is also linked with it as a shared SNMP library.

svn path=/trunk/; revision=2443
2000-09-17 07:23:44 +00:00
Guy Harris 0653c5b18b Load "libsnmp.so.0", not "libsnmp.so":
on the systems that have the problem we're working around, the
	SNMP shared library is "libsnmp.so.0";

	on those systems, there's also no "libsnmp.so" unless the user
	has installed the UCD SNMP development package or has made a
	symlink from "libsnmp.so" to "libsnmp.so.0" by hand, and we
	don't want to force users to do that (some of them may be
	sufficiently new to UNIX that they don't know how to do that);

	the run-time linker, if told to load "libsnmp.so", won't
	necessarily realize that it's the same object as "libsnmp.so.0",
	and may load it again rather than using the already-loaded
	object, which might not be a good idea.

svn path=/trunk/; revision=2398
2000-09-08 07:14:01 +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 56b989e0ad Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.

Have the code that calls those dissectors translate the arguments as
necessary.  (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation.  Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)

This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so.  It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.

Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.

Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_".  Update the
dissectors that use those routines appropriately.

Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".

svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
Guy Harris c3338f03a6 Use the right length when adding the "agent address" entry to the tree
for an SNMP trap PDU.

svn path=/trunk/; revision=2158
2000-07-25 17:30:47 +00:00
Guy Harris 9aaeb58c55 Fix a comment.
svn path=/trunk/; revision=2157
2000-07-25 07:37:54 +00:00
Guy Harris e6fea28e9b The security model values 1 and 2 ("reserved for SNMPv1" and "reserved
for SNMPv2") in SNMPv3 packets shouldn't cause the security parameters
to be interpreted as a character string - those values are apparently
not supposed to show up in packets - so we handle those values in the
default case, with the security parameters treated as opaque data.

svn path=/trunk/; revision=2124
2000-07-08 08:33:29 +00:00
Guy Harris 6f4d2c0cb8 "asn1_octet_string_decode()" sets the pointer to the raw octets to NULL
if the octet string is zero-length; if the octets are to be interpreted
as a character string, we have to check for a null pointer and replace
it with a pointer to a null string.

svn path=/trunk/; revision=2102
2000-07-02 07:10:16 +00:00
Guy Harris 2f5825776b Make "format_oid()" allocate a buffer that's big enough, format the OID
string into it, and return a pointer to that buffer, rather than being
passed a buffer.  This gets rid of some additional fixed-length string
buffers (and makes it more closely resemble the "format_oid()" in the
libsmi-based "packet-snmp.c" under development).

svn path=/trunk/; revision=2099
2000-06-29 09:37:02 +00:00
Guy Harris c53979e981 Make "format_oid()" allocate a buffer that's big enough, format the OID
string into it, and return a pointer to that buffer, rather than being
passed a buffer.  This gets rid of some additional fixed-length string
buffers (and makes it more closely resemble the "format_oid()" in the
libsmi-based "packet-snmp.c" under development).

svn path=/trunk/; revision=2098
2000-06-28 05:15:13 +00:00
Guy Harris 85a7f56ac0 Rename "format_value()" to "format_var()", and have it dynamically
allocate the buffer into which it formats the variable value, and return
that value.  This

	1) makes it more closely resemble the formatting routine in the
	   libsmi-based "packet-snmp.c" under development;

	2) makes it less likely to overrun the buffer (we can't be
	   certain how long the string "sprint_value()" generates will
	   be, but we can make a reasonable guess as to the maximum size
	   based on the type and size of the object we're formatting).

When *not* using "-lsnmp", dynamically allocate the buffers into which
we format octet strings and OID values, based on the size of the object
we're formatting, so that we don't overrun the buffer.

svn path=/trunk/; revision=2091
2000-06-26 00:13:21 +00:00
Guy Harris 33fccd5fa2 Make the string buffers into which stuff is formatted larger, to handle,
for example, larger octet string values.

svn path=/trunk/; revision=2089
2000-06-25 20:55:09 +00:00
Guy Harris 7d67328a2a Instead of calling "snmp_set_full_objid()" to cause OIDs to be displayed
symbolically as full sequences, call "snmp_set_suffix_only(2)" to cause
them to be displayed symbolically as a module name and a name within
that module, as that might make it easier to find the RFC or whatever
that describes the object in question.

Don't just statically call it, though, on Linux, as that causes binaries
built on Red Hat releases prior to 6.2 to fail to run on 6.2, due to the
UCD SNMP 4.1.1 library used in RH 6.2 not being 100% binary-compatible
with the UCD SNMP libraries used in those prior releases.  Instead, on
Linux, try to "dlopen()" the "libsnmp.so" library and, if that succeeds,
try to find "snmp_set_suffix_only()" in that library - if that succeeds,
call it, otherwise try to find "ds_set_int()" in that library and, if
*that* succeeds, call it with the arguments that, in UCD SNMP 4.1.1, the
"snmp_set_suffix_only()" macro passes to it.

svn path=/trunk/; revision=2077
2000-06-17 05:56:22 +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
Guy Harris 86e1e74fb9 Give the IPX dissector dissector hash tables for the IPX type and socket
number, and have the protocols encapsulated inside IPX register
themselves with that table.

svn path=/trunk/; revision=2028
2000-05-30 03:35:55 +00:00
Guy Harris a12762b431 Update a comment to reflect that only UCD SNMP 4.1.1 has
"snmp_set_full_objid()" as a macro rather than a function - 4.1.2 has it
as a function again.

svn path=/trunk/; revision=1995
2000-05-24 05:59:50 +00:00
Guy Harris 17ccdafa03 The only packets that look like SMUX packets *are* SMUX packets (unlike
SNMP, where we let the ATM code tell the SNMP dissector to call it
"ILMI"), so don't pass a protocol name string into "dissect_smux_pdu()",
just have "dissect_smux_pdu()" call it "SMUX".

svn path=/trunk/; revision=1983
2000-05-19 07:00:04 +00:00
Guy Harris 9d92bf4eeb Fix a botch that kept it from compiling if you didn't have an SNMP
library.

svn path=/trunk/; revision=1964
2000-05-15 08:02:39 +00:00
Guy Harris 0d12107436 SMUX and SNMP V3 support from Jochen Friedrich.
svn path=/trunk/; revision=1960
2000-05-15 03:15:12 +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 914f14223b Fix from Ron Flory to suppress a warning GCC issues on at least some
platforms.

svn path=/trunk/; revision=1930
2000-05-09 17:45:02 +00:00
Gilbert Ramirez db187f965c Change the sub-dissector handoff registration routines so that the
sub-dissector table is not stored in the header_field_info struct, but
in a separate namespace. Dissector tables are now registered by name
and not by field ID. For example:

        udp_dissector_table = register_dissector_table("udp.port");

Because of this different namespace, dissector tables can have names
that are not field names.  This is useful for ethertype, since multiple
fields are "ethertypes".

packet-ethertype.c replaces ethertype.c (the name was changed so that it
would be named in the same fashion as all the filenames passed to make-reg-dotc)

Although it registers no protocol or field, it registers one dissector table:

	ethertype_dissector_table = register_dissector_table("ethertype");

All protocols that can be called because of an ethertype field now register
that fact with dissector_add() calls.

In this way, one dissector_table services all ethertype fields
(hf_eth_type, hf_llc_type, hf_null_etype, hf_vlan_etype)

Furthermore, the code allows for names of protocols to exist in the
etype_vals, yet a dissector for that protocol doesn't exist. The name
of the dissector is printed in COL_INFO. You're welcome, Richard. :-)

svn path=/trunk/; revision=1848
2000-04-13 18:18:56 +00:00
Guy Harris 42107e8614 Move calls to "dissector_add()" out of the register routines for TCP and
UDP and into the handoff registration routines for the protocols in
question.

Make the dissectors for those protocols static if they're not called
outside the dissector's source file.

Get rid of header files if all they did was declare dissectors that are
now static; remove declarations of now-static dissectors from header
files that do more than just declare the dissector.

svn path=/trunk/; revision=1823
2000-04-08 07:07:42 +00:00
Guy Harris 3fa89a91c3 Treat the two integers after the request ID in a BulkPDU as
"non-repeaters" and "max-repetitions" rather than as "error status" and
"error index".

svn path=/trunk/; revision=1721
2000-03-15 07:12:55 +00:00
Guy Harris 777335fcc3 Dietmar Petras' fix to the handling of SNMPv2 TRAP PDUs.
Fix a comment.

svn path=/trunk/; revision=1720
2000-03-15 07:05:10 +00:00
Guy Harris cbadb570b2 UCD SNMP 4.1[.x] makes "snmp_set_full_objid()" a macro that calls
"ds_set_boolean()" with the first two arguments being DS_LIBRARY_ID and
DS_LIB_PRINT_FULL_OID; this means that, when building with 4.1[.x]
(which we assume is the case if "snmp_set_full_objid" is defined, we
need to include <ucd-snmp/default_store.h>, to define those two values
and to declare "ds_set_boolean()".

svn path=/trunk/; revision=1657
2000-02-20 03:32:29 +00:00
Guy Harris 7a943b7810 Fix Gerald's e-mail address.
svn path=/trunk/; revision=1437
2000-01-07 22:05:43 +00:00
Guy Harris dbc4cd9530 Sigh. Some versions of CMU SNMP appear to lack the SMI_ #defines; for
now, assume that if they lack that, they lack "sprint_value()".

svn path=/trunk/; revision=1326
1999-12-14 10:16:11 +00:00
Guy Harris a5ce81c250 Don't try to get UCD SNMP to define the CMU SNMP SMI_ values; they may
not have been supported in older versions of CMU SNMP.  Instead, pick
our own names for the values, and define them appropriately for UCD and
CMU SNMP.

svn path=/trunk/; revision=1322
1999-12-14 05:59:16 +00:00
Guy Harris 4a08c26dff If we have an SNMP library, use its routines for printing values; that
way, it checks that the type of the variable matches the type it's
claimed to have in the MIB (and indicates if it isn't), it can decode
enumerated types, and it may also use the DISPLAY-HINT string in the
MIB.

Handle unknown types better.

svn path=/trunk/; revision=1293
1999-12-12 01:51:47 +00:00
Guy Harris 4b41f91139 Fix a couple of typos.
svn path=/trunk/; revision=1290
1999-12-11 06:58:41 +00:00
Guy Harris d300a2bb04 Don't use MAX_NAME_LEN*6 for string buffers, define our own
MAX_STRING_LEN and use that.

svn path=/trunk/; revision=1286
1999-12-10 21:00:53 +00:00