aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGilbert Ramirez <gram@alumni.rice.edu>1999-10-12 06:21:15 +0000
committerGilbert Ramirez <gram@alumni.rice.edu>1999-10-12 06:21:15 +0000
commitbacb9d5bae5e1aa9d9144463cd24d8c5adb9398e (patch)
tree13a576cc1a346d2364a1b13bf493b2efc42a856f
parent10c4bab8e129dc0012e8e341fb74fc725e66fee8 (diff)
New proto_tree header_field_info stuff. Header_field_infos now contain
the base for numbers to be displayed in, bitmasks for bitfields, and blurbs (which are one or two sentences describing the field). proto_tree_add*() routines now automatically handle bitfields. You tell it which header field you are adding, and just pass it the value of the entire field, and the proto_tree routines will do the masking and shifting for you. This means that bitfields are more naturally filtered via dfilter now. Added Phil Techau's support for signed integers in dfilters/proto_tree. Added the beginning of the SNA dissector. It's not complete, but I'm committing it now because it has example after example of how to use bitfields with the new header_field_info struct and proto_tree routines. It was the impetus to change how header_field_info works. svn path=/trunk/; revision=815
-rw-r--r--Makefile.am3
-rw-r--r--dfilter-grammar.y11
-rw-r--r--dfilter-scanner.l19
-rwxr-xr-xdoc/dfilter2pod.in11
-rw-r--r--doc/proto_tree403
-rw-r--r--packet-aarp.c37
-rw-r--r--packet-arp.c37
-rw-r--r--packet-ascend.c11
-rw-r--r--packet-atalk.c41
-rw-r--r--packet-bootp.c68
-rw-r--r--packet-bpdu.c38
-rw-r--r--packet-cdp.c8
-rw-r--r--packet-eth.c14
-rw-r--r--packet-fddi.c11
-rw-r--r--packet-ftp.c25
-rw-r--r--packet-giop.c8
-rw-r--r--packet-icmpv6.c11
-rw-r--r--packet-icp.c18
-rw-r--r--packet-ip.c71
-rw-r--r--packet-ipsec.c14
-rw-r--r--packet-ipv6.c8
-rw-r--r--packet-ipx.c36
-rw-r--r--packet-lapb.c9
-rw-r--r--packet-llc.c19
-rw-r--r--packet-null.c8
-rw-r--r--packet-osi.c45
-rw-r--r--packet-ppp.c11
-rw-r--r--packet-radius.c13
-rw-r--r--packet-rsvp.c112
-rw-r--r--packet-sna.c604
-rw-r--r--packet-tcp.c17
-rw-r--r--packet-tr.c97
-rw-r--r--packet-trmac.c56
-rw-r--r--packet-udp.c17
-rw-r--r--packet-x25.c9
-rw-r--r--packet.c20
-rw-r--r--packet.h21
-rw-r--r--proto.c470
-rw-r--r--proto.h43
39 files changed, 1926 insertions, 548 deletions
diff --git a/Makefile.am b/Makefile.am
index bcafa55bfd..ff0f87414d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,7 +1,7 @@
# Makefile.am
# Automake file for Ethereal
#
-# $Id: Makefile.am,v 1.79 1999/10/11 07:38:21 guy Exp $
+# $Id: Makefile.am,v 1.80 1999/10/12 06:19:58 gram Exp $
#
# Ethereal - Network traffic analyzer
# By Gerald Combs <gerald@zing.org>
@@ -109,6 +109,7 @@ ethereal_SOURCES = \
packet-rtsp.c \
packet-sdp.c \
packet-smb.c \
+ packet-sna.c \
packet-tcp.c \
packet-telnet.c\
packet-tftp.c \
diff --git a/dfilter-grammar.y b/dfilter-grammar.y
index ae47287a43..766f8b9c0b 100644
--- a/dfilter-grammar.y
+++ b/dfilter-grammar.y
@@ -3,7 +3,7 @@
/* dfilter-grammar.y
* Parser for display filters
*
- * $Id: dfilter-grammar.y,v 1.28 1999/10/12 05:21:07 gram Exp $
+ * $Id: dfilter-grammar.y,v 1.29 1999/10/12 06:19:58 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -140,6 +140,9 @@ dfilter *global_df = NULL;
%token <variable> T_FT_UINT8
%token <variable> T_FT_UINT16
%token <variable> T_FT_UINT32
+%token <variable> T_FT_INT8
+%token <variable> T_FT_INT16
+%token <variable> T_FT_INT32
%token <variable> T_FT_ETHER
%token <variable> T_FT_IPv4
%token <variable> T_FT_IPv6
@@ -381,6 +384,9 @@ bytes_value: T_VAL_BYTE_STRING
numeric_variable: T_FT_UINT8 { $$ = dfilter_mknode_numeric_variable($1.id); }
| T_FT_UINT16 { $$ = dfilter_mknode_numeric_variable($1.id); }
| T_FT_UINT32 { $$ = dfilter_mknode_numeric_variable($1.id); }
+ | T_FT_INT8 { $$ = dfilter_mknode_numeric_variable($1.id); }
+ | T_FT_INT16 { $$ = dfilter_mknode_numeric_variable($1.id); }
+ | T_FT_INT32 { $$ = dfilter_mknode_numeric_variable($1.id); }
;
ether_variable: T_FT_ETHER { $$ = dfilter_mknode_ether_variable($1.id); }
@@ -421,6 +427,9 @@ bytes_variable: any_variable_type T_VAL_BYTE_RANGE
any_variable_type: T_FT_UINT8 { $$ = $1; }
| T_FT_UINT16 { $$ = $1; }
| T_FT_UINT32 { $$ = $1; }
+ | T_FT_INT8 { $$ = $1; }
+ | T_FT_INT16 { $$ = $1; }
+ | T_FT_INT32 { $$ = $1; }
| T_FT_ETHER { $$ = $1; }
| T_FT_IPv4 { $$ = $1; }
| T_FT_IPv6 { $$ = $1; }
diff --git a/dfilter-scanner.l b/dfilter-scanner.l
index 1bf22ac53b..252ab5fd69 100644
--- a/dfilter-scanner.l
+++ b/dfilter-scanner.l
@@ -3,7 +3,7 @@
/* dfilter-scanner.l
* Scanner for display filters
*
- * $Id: dfilter-scanner.l,v 1.19 1999/10/12 04:21:10 gram Exp $
+ * $Id: dfilter-scanner.l,v 1.20 1999/10/12 06:19:59 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -88,6 +88,7 @@ static char *in_buffer;
whitespace [\t ]
hex [A-Fa-f0-9]{1,2}
hexsep [-:\.]
+minus [-]
%%
@@ -177,18 +178,23 @@ le|\<\= { dfilter_lval.operand = TOK_LE; return TOK_LE; }
retval = T_FT_BOOLEAN;
break;
case FT_UINT8:
- case FT_VALS_UINT8:
retval = T_FT_UINT8;
break;
case FT_UINT16:
- case FT_VALS_UINT16:
retval = T_FT_UINT16;
break;
case FT_UINT32:
- case FT_VALS_UINT32:
- case FT_VALS_UINT24:
retval = T_FT_UINT32;
break;
+ case FT_INT8:
+ retval = T_FT_INT8;
+ break;
+ case FT_INT16:
+ retval = T_FT_INT16;
+ break;
+ case FT_INT32:
+ retval = T_FT_INT32;
+ break;
case FT_DOUBLE:
dfilter_fail("Sorry, you can't filter on field \"%s\", as we don't yet support filtering on floating-point values.",
yytext);
@@ -225,6 +231,7 @@ le|\<\= { dfilter_lval.operand = TOK_LE; return TOK_LE; }
retval = T_FT_IPXNET;
break;
default:
+ printf("ftype for %s is %d\n", yytext, ftype);
g_assert_not_reached();
retval = 0;
break;
@@ -233,7 +240,7 @@ le|\<\= { dfilter_lval.operand = TOK_LE; return TOK_LE; }
return retval;
}
-[0-9]+ { /* decimal or octal values */
+{minus}?[0-9]+ { /* decimal or octal values */
dfilter_lval.string = g_strdup(yytext);
return T_VAL_NUMBER_STRING;
}
diff --git a/doc/dfilter2pod.in b/doc/dfilter2pod.in
index 7403144ed8..03f2c6d760 100755
--- a/doc/dfilter2pod.in
+++ b/doc/dfilter2pod.in
@@ -9,14 +9,19 @@
# will be replaced by the pod-formatted glossary
# STDOUT is the output
#
-# $Id: dfilter2pod.in,v 1.3 1999/08/03 15:04:33 gram Exp $
+# $Id: dfilter2pod.in,v 1.4 1999/10/12 06:21:15 gram Exp $
%ftenum_names = (
'FT_NONE', 'No value',
'FT_BOOLEAN', 'Boolean',
'FT_UINT8', 'Unsigned 8-bit integer',
'FT_UINT16', 'Unsigned 16-bit integer',
+ 'FT_UINT24', 'Unsigned 24-bit integer',
'FT_UINT32', 'Unsigned 32-bit integer',
+ 'FT_INT8', 'Signed 8-bit integer',
+ 'FT_INT16', 'Signed 16-bit integer',
+ 'FT_INT24', 'Signed 24-bit integer',
+ 'FT_INT32', 'Signed 32-bit integer',
'FT_ABSOLUTE_TIME', 'Date/Time stamp',
'FT_RELATIVE_TIME', 'Time duration',
'FT_STRING', 'String',
@@ -25,10 +30,6 @@
'FT_IPv4', 'IPv4 address',
'FT_IPv6', 'IPv6 address',
'FT_IPXNET', 'IPX network or server name',
- 'FT_VALS_UINT8', 'Unsigned 8-bit integer',
- 'FT_VALS_UINT16', 'Unsigned 16-bit integer',
- 'FT_VALS_UINT24', 'Unsigned 24-bit integer',
- 'FT_VALS_UINT32', 'Unsigned 32-bit integer',
'FT_TEXT_ONLY', 'Text-only. Not filterable'
);
diff --git a/doc/proto_tree b/doc/proto_tree
index 12d322b89e..2a12ed6809 100644
--- a/doc/proto_tree
+++ b/doc/proto_tree
@@ -1,58 +1,56 @@
-$Id: proto_tree,v 1.4 1999/08/27 19:27:22 gram Exp $
+$Id: proto_tree,v 1.5 1999/10/12 06:21:15 gram Exp $
The Ethereal Protocol Tree
==========================
-Up until version 0.6.3 of ethereal, the protocol tree that is displayed
-in the middle pane of the ethereal GUI had been created by having the
-protocol dissection routines add strings to a GTK+ tree. This GUI
-container was not easily manipulated; the print routines had to reach
-inside what should be an opaque structure and pull out the data. The
-tree of strings also did not lend itself to filtering on the data
-available in the tree.
-
-Mostly to solve the display filter problem, I decided to have the
-protocol dissection routines put their data into a logical tree instead
-of a GUI tree. This tree structure would provide a generic way for
-multiple routines, like the dissection routines, the display filter
-routines, and the print routines, to retrieve data about the protocol
-fields. The GUI routines would then be modified to draw the GUI tree
-based on the data in the logical tree. By structuring this logical tree
-well, with well-defined field types, ethereal can have a very powerful
-display filter option. No longer would display filters be limited to the
-ability of the BPF compiler (libpcap or wiretap), but would have access to the
-full range of C field types available within ethereal.
-
-The dissection routines are still passed a proto_tree pointer, but a
-proto_tree is no longer the same as a GtkTree. Now a proto_tree is a
-GNode, the N-way tree structure available within GLIB. Of course the
-protocol dissectors don't care what a proto_tree really is; they just
-pass the proto_tree pointer as an argument to the routines which allow
-them to add items and new branches to the tree.
-
-In packet_list_select_cb() you'll now find this:
-
- if (protocol_tree)
- proto_tree_free(protocol_tree);
- protocol_tree = proto_tree_create_root();
- dissect_packet(cf.pd, fd, protocol_tree);
- proto_tree_draw(protocol_tree, tree_view);
-
-When a packet is selected in the packet-list pane, a new logical
-protocol tree (proto_tree) is created. The pointer to the proto_tree (in
-this case, 'protocol tree'), is passed to the top-level protocol
-dissector, and then the GUI tree is drawn via proto_tree_draw().
+Up until version 0.6.3 of Ethereal, the protocol tree that is displayed
+in the middle pane of the Ethereal GUI had been created by having
+the protocol dissection routines add strings to a GTK+ tree. This
+GUI container was not easily manipulated; the print routines had to
+reach inside what should be an opaque GUI structure and pull out the
+data. The tree of strings also did not lend itself to filtering on the
+data available in the tree.
+
+Mostly to solve the display filter problem, I decided to have the protocol
+dissection routines put their data into a logical tree instead of a
+GUI tree. This tree structure would provide a generic way for multiple
+routines, like the dissection routines, the display filter routines,
+and the print routines, to retrieve data about the protocol fields. The
+GUI routines would then be modified to draw the GUI tree based on the
+data in the logical tree. By structuring this logical tree well, with
+well-defined field types, Ethereal can have a very powerful display
+filter option. No longer would display filters be limited to the ability
+of the BPF compiler (libpcap or wiretap), but would have access to the
+full range of C field types available within Ethereal.
+
+In Ethereal 0.7.6, I decided to extend the information that the
+programmer must provide about each field. I was frustrated by the way
+in which the original proto_tree code handled bitfields. By providing
+a small amount of extra info, bitfields can now be added very easily
+to the proto_tree. In addition, filtering on bitfields now works
+more naturally.
+
+The protocol tree, or proto_tree, is a GNode, the N-way tree structure
+available within GLIB. Of course the protocol dissectors don't care
+what a proto_tree really is; they just pass the proto_tree pointer as an
+argument to the routines which allow them to add items and new branches
+to the tree.
+
+When a packet is selected in the packet-list pane, a new logical protocol
+tree (proto_tree) is created. The pointer to the proto_tree (in this
+case, 'protocol tree'), is passed to the top-level protocol dissector,
+and then to all subsequent protocol dissectors for that packet, and then
+the GUI tree is drawn via proto_tree_draw().
Programming for the proto_tree
==============================
-The logical proto_tree now needs to know detail information about the
+The logical proto_tree needs to know detailed information about the
protocols and fields about which information will be collected from the
-dissection routines. No longer will is the data just a bunch of strings.
-Now the data will be typed so that searching and filtering on protocol
-header fields will be possible. This means that the for every protocol
-and field (which I also call "header fields", since they are fields in
-the protocol headers) which might be attached to a tree, some
-information is needed.
+dissection routines. By strictly defining (or "typing") the data that can
+be attached to a proto tree, searching and filtering becomes possible.
+This means that the for every protocol and field (which I also call
+"header fields", since they are fields in the protocol headers) which
+might be attached to a tree, some information is needed.
Every dissector routine will need to register its protocols and fields
with the central protocol routines (in proto.c). At first I thought I
@@ -89,101 +87,189 @@ Here is how the frame "protocol" is registered.
A header field is also registered with its name and abbreviation, but
-information about the its data type is needed. Some fields will use
-value_strings to represent their values, so the value_string
-is also passed. And of course the parent protocol for the field is indicated
-during registration.
-
- int hf_frame_arrival_time;
-
- hf_frame_arrival_time = proto_register_field (
- /* name */ "Arrival Time",
- /* abbrev */ "frame.time",
- /* ftype */ FT_ABSOLUTE_TIME,
- /* parent */ proto_frame,
- /* vals[] */ NULL );
-
-Groups of header fields can be registered with one call to
-proto_register_field_array(). A static array of hf_register_info
-structs is declared, then passed to proto_register_field_array, along
-with a count of the number of records. Be sure that your array
-of hf_register_info structs is declared 'static', since the
-proto_register_field_array() function does not create a copy of
-the information in the array... it uses that static copy of the
-information that the compiler created inside your array. Here's
-the layout of the hf_register_info struct:
-
-typedef struct hf_register_info {
- int *p_id; /* pointer to parent variable */
- header_field_info hfinfo;
-} hf_register_info;
-
-You can use the handy array_length() macro found in packet.h
-to have the compiler compute the array length for you at compile time:
+information about the its data type is needed. It helps to look at
+the header_field_info struct to see what information is expected:
+
+struct header_field_info {
+ char *name;
+ char *abbrev;
+ enum ftenum type;
+ int display;
+ void *strings;
+ guint bitmask;
+ char *blurb;
+
+ int id; /* calculated */
+ int parent;
+ int bitshift; /* calculated */
+};
+name
+----
+A string representing the name of the field. This is the name
+that will appear in the graphical protocol tree.
+
+abbrev
+------
+A string with an abbreviation of the field. We concatenate the
+abbreviation of the parent protocol with an abbreviation for the field,
+using a period as a separator. For example, the "src" field in an IP packet
+would have "ip.addr" as an abbreviation. It is acceptable to have
+multiple levels of periods if, for example, you have fields in your
+protocol that are then subdivided into subfields. For example, TRMAC
+has multiple error fields, so the abbreviations follow this pattern:
+"trmac.errors.iso", "trmac.errors.noniso", etc.
+
+The abbreviation is the identifier used in a display filter.
+
+type
+----
+The type of value this field holds. The current field types are:
+
+ FT_NONE,
+ FT_BOOLEAN,
+ FT_UINT8,
+ FT_UINT16,
+ FT_UINT24,
+ FT_UINT32,
+ FT_INT8,
+ FT_INT16,
+ FT_INT24,
+ FT_INT32,
+ FT_DOUBLE,
+ FT_ABSOLUTE_TIME,
+ FT_RELATIVE_TIME,
+ FT_STRING,
+ FT_ETHER,
+ FT_BYTES,
+ FT_IPv4,
+ FT_IPv6,
+ FT_IPXNET
+
+Some of these field types are still not handled in the display filter
+routines, but the most common ones are. The FT_UINT* variables all
+represent unsigned integers; the number on the end represent how many
+bits are used to represent the number.
+
+display
+-------
+The display field has a couple of overloaded uses. This is unfortunate,
+but since we're C as an application programming language, this sometimes
+makes for cleaner programs. Right now I still think that overloading
+this variable was okay.
+
+For integer fields (FT_UINT*), this variable represents the base in
+which you would like the value displayed. The acceptable bases are:
+ BASE_DEC,
+ BASE_HEX,
+ BASE_OCT,
+ BASE_BIN
+
+For FT_BOOLEAN fields that are also bitfields, 'display' is used
+to tell the proto_tree how wide the parent bitfield is. With integers
+this is not needed since the type of integer itself (FT_UINT8, FT_UINT16,
+FT_UINT24, FT_UINT32) tells the proto_tree how wide the parent bitfield is.
+
+Additionally, BASE_NONE is used for 'display' as a NULL-value. That is,
+for non-integers and non-bitfield FT_BOOLEANs, you'll want to use BASE_NONE
+in the 'display' field.
+
+It is possible that in the future we will record the endianness of
+integers. If so, it is likely that we'll use a bitmask on the display field
+so that integers would be represented as BEND|BASE_DEC or LEND|BASE_HEX.
+But that has not happened yet.
+
+strings
+-------
+Some integer fields need labels to represent the true value of a field.
+A value_string structure is a way to map values to strings.
+
+typedef struct _value_string {
+ guint32 value;
+ gchar *strptr;
+} value_string;
+
+For FT_UINT* fields, the 'string' field is a pointer to an array of
+such value_string structs. (Note: before Ethereal 0.7.6, we had
+separate field types like FT_VALS_UINT8 which denoted the use of value_strings.
+Now, the non-NULLness of the pointer lets the proto_tree know that
+a value_string is meant for this field).
+
+FT_BOOLEANS have a default map of 0 = "False", 1 (or anything else) = "True".
+Sometimes it is useful to change the labels for boolean values (e.g.,
+to "Yes"/"No", "Fast"/"Slow", etc.). For these mappings, a struct called
+true_false_string is used. (This struct is new as of Ethereal 0.7.6).
+
+typedef struct true_false_string {
+ char *true_string;
+ char *false_string;
+} true_false_string;
+
+It's two fields are pointers to the string representing truth, and
+the string representing falsehood. For FT_BOOLEAN fields that need a
+true_false_string struct, the 'strings' field is a pointer to that struct.
+
+bitmask
+-------
+If the field is not a bitfield, then bitmask should be set to 0.
+If it is a bitfield, then the bitmask is the mask which will
+leave only the bits needed to make the field when ANDed with a value.
+The proto_tree routines will calculate 'bitshift' automatically
+from 'bitmask', by finding the first set bit in the bitmask.
+
+blurb
+-----
+This is a string giving a sentence or two description of the field.
+It is meant to provide a more detailed description of the field than the
+name alone provides. This information will be used in the man page, and
+in a future GUI display-filter creation tool. We might also add tooltips
+to the labels in the GUI protocol tree, in which case the blurb would
+be used as the tooltip text.
+
+Field Registration
+------------------
+Protocol registration is handled by creating an instance of the
+header_field_info struct (or an arry of such structs), and
+calling the registration function along with the registration ID of
+the protocol that is the parent of the fields. Here is a complete example:
+
+ int proto_eg = -1;
int hf_field_a = -1;
int hf_field_b = -1;
static hf_register_info hf[] = {
{ &hf_field_a,
- { "Field A", "proto.field_a", FT_UINT8, NULL }},
+ { "Field A", "proto.field_a", FT_UINT8, BASE_HEX, NULL,
+ 0xf0, "Field A represents Apples" }},
{ &hf_field_b,
- { "Field B", "proto.field_a", FT_VALS_UINT16, VALS(vs) }}
+ { "Field B", "proto.field_a", FT_UINT16, BASE_DEC, VALS(vs),
+ 0x0, "Field B represents Bananas" }}
};
- proto_tr = proto_register_protocol("Token-Ring", "tr");
- proto_register_field_array(proto_tr, hf, array_length(hf));
-
-The name can be used in any type of display, either in the GUI tree, or
-in a display filter UI. The abbreviation is used when representing a
-display filter as a string. For example, the following strings could be a
-valid display filter, depending upon the implementation of the display
-filter parser and engine.
+ proto_eg = proto_register_protocol("Example Protocol", "proto");
+ proto_register_field_array(proto_eg, hf, array_length(hf));
- frame[20:1] = 0x0a
- frame.time > 'May 21, 1999 13:15:00'
+Be sure that your array of hf_register_info structs is declared 'static',
+since the proto_register_field_array() function does not create a copy
+of the information in the array... it uses that static copy of the
+information that the compiler created inside your array. Here's the
+layout of the hf_register_info struct:
-The field type come from an enum. Currently, enum ftenum is comprised
-of:
-
-/* field types */
-enum ftenum {
- FT_NONE, /* used for protocol labels (thus no field type) */
- FT_UINT8,
- FT_UINT16,
- FT_UINT32,
- FT_BOOLEAN,
- FT_ABSOLUTE_TIME,
- FT_RELATIVE_TIME,
- FT_STRING,
- FT_ETHER,
- FT_BYTES,
- FT_IPv4,
- FT_IPv6,
- FT_IPXSERVER,
- FT_VALS_UINT8,
- FT_VALS_UINT16,
- FT_VALS_UINT24,
- FT_VALS_UINT32,
- FT_TEXT_ONLY, /* used internally, but should be used by dissectors */
- NUM_FIELD_TYPES /* last item number plus one */
-};
-
-Previously, the sequence needed within a dissector to add a new branch
-to the GUI tree was this:
+typedef struct hf_register_info {
+ int *p_id; /* pointer to parent variable */
+ header_field_info hfinfo;
+} hf_register_info;
- item = proto_tree_add_item(....);
- new_tree = proto_tree_new();
- proto_item_add_subtree(item, new_tree, tree_type);
+Also be sure to use the handy array_length() macro found in packet.h
+to have the compiler compute the array length for you at compile time.
-With the new system, the call to proto_tree_new() is no longer needed,
-as proto_item_add_subtree creates the new tree for you. The change was
-necessary so that the proto_tree routines could maintain the
-parent/child relationship within the logical tree. But it has a nice
-side-effect of cleaning up the dissector code. The new method is like
-this:
+Adding Items and Values to the Protocol Tree
+--------------------------------------------
+A protocol item is added to an existing protocol tree with one of a
+handful of proto_tree_add_item*() funtions. Subtrees can be made
+with the proto_item_add_subtree() function:
item = proto_tree_add_item(....);
new_tree = proto_item_add_subtree(item, tree_type);
@@ -204,18 +290,73 @@ protocol or field labels to the proto_tree:
proto_item*
proto_tree_add_text(tree, start, length, format, ...);
+proto_tree_add_item()
+---------------------
The first function, proto_tree_add_item, is used when you wish to do no
special formatting. The item added to the GUI tree will contain the name
(as passed in the proto_register_*() function) and any value. If your
field does have a value, it is passed after the length variable (notice
the ellipsis in the function prototype).
-The second function, proto_tree_add_free_format(), is used when the
+Now that the proto_tree has detailed information about bitfield fields,
+you an use proto_tree_add_item() with no extra processing to add bitfield
+values to your tree. Here's an example. Take the Format Identifer (FID)
+field in the Tranmission Header (TH) portion of the SNA protocol. The
+FID is the high nibble of the first byte of the TH. The FID would be
+registered like this:
+
+ name = "Format Identifer"
+ abbrev = "sna.th.fid"
+ type = FT_UINT8
+ display = BASE_HEX
+ strings = sna_th_fid_vals
+ bitmask = 0xf0
+
+The bitmask contains the value which would leave only the FID if bitwise-ANDed
+against the parent field, the first byte of the TH.
+
+The code to add the FID to the tree would be;
+
+ guint8 th_0 = pd[offset];
+ proto_tree_add_item(bf_tree, hf_sna_th_fid, offset, 1, th_0);
+
+Note: we do not do *any* manipulation of th_0 in order to ge the FID value.
+We just pass it to proto_tree_add_item(). The proto_tree already has
+the information about bitmasking and bitshifting, so it does the work
+of masking and shifting for us! This also means that you no longer
+have to crate value_string structs with the values bitshifted. The
+value_string for FID looks like this, even though the FID value is
+actually contained in the high nibble. (You'd expect the values to be
+0x0, 0x10, 0x20, etc.)
+
+/* Format Identifier */
+static const value_string sna_th_fid_vals[] = {
+ { 0x0, "SNA device <--> Non-SNA Device" },
+ { 0x1, "Subarea Node <--> Subarea Node" },
+ { 0x2, "Subarea Node <--> PU2" },
+ { 0x3, "Subarea Node or SNA host <--> Subarea Node" },
+ { 0x4, "?" },
+ { 0x5, "?" },
+ { 0xf, "Adjaced Subarea Nodes" },
+ { 0, NULL }
+};
+
+The final implication of this is that display filters work the way you'd
+naturally expect them to. You'd type "sna.th.fid == 0xf" to find Adjacent
+Subarea Nodes. The user does not have to shift the value of the FID to
+the high nibble of the byte ("sna.th.fid == 0xf0") as was necessary
+before Ethereal 0.7.6.
+
+proto_tree_add_item_format()
+----------------------------
+The second function, proto_tree_add_item_format(), is used when the
dissector routines wants complete control over how the field and value
will be represented on the GUI tree. The caller must pass include the
name of the protocol or field; it is not added automatically as in
proto_tree_add_item().
+proto_tree_add_item_hidden()
+----------------------------
The third function is used to add fields and values to a tree, but not
show them on a GUI tree. The caller may want a value to be included in a
tree so that the packet can be filtered on this field, but the
@@ -262,11 +403,13 @@ filter is then possible:
tr.rif_ring eq 0x013
+proto_tree_add_text()
+---------------------
The fourth function, proto_tree_add_text(), is used to add a label to the GUI tree.
It will contain no value, so it is not searchable in the display filter process.
This function was needed in the transition from the old-style proto_tree to this
-new-style proto_tree so that ethereal would still decode all protocols w/o being
+new-style proto_tree so that Ethereal would still decode all protocols w/o being
able to filter on all protocols and fields. Otherwise we would have had to
-cripple ethereal's functionality while we converted all the old-style proto_tree
+cripple Ethereal's functionality while we converted all the old-style proto_tree
calls to the new-style proto_tree calls.
diff --git a/packet-aarp.c b/packet-aarp.c
index 649c884b1d..5db0fa46cd 100644
--- a/packet-aarp.c
+++ b/packet-aarp.c
@@ -1,7 +1,7 @@
/* packet-aarp.c
* Routines for Appletalk ARP packet disassembly
*
- * $Id: packet-aarp.c,v 1.10 1999/10/03 15:21:11 deniel Exp $
+ * $Id: packet-aarp.c,v 1.11 1999/10/12 06:20:00 gram Exp $
*
* Simon Wilkinson <sxw@dcs.ed.ac.uk>
*
@@ -183,23 +183,40 @@ proto_register_aarp(void)
{
static hf_register_info hf[] = {
{ &hf_aarp_hard_type,
- { "Hardware type", "aarp.hard.type", FT_UINT16, NULL }},
+ { "Hardware type", "aarp.hard.type", FT_UINT16, BASE_HEX, NULL, 0x0,
+ "" }},
+
{ &hf_aarp_proto_type,
- { "Protocol type", "aarp.proto.type", FT_UINT16, NULL }},
+ { "Protocol type", "aarp.proto.type", FT_UINT16, BASE_HEX, NULL, 0x0,
+ "" }},
+
{ &hf_aarp_hard_size,
- { "Hardware size", "aarp.hard.size", FT_UINT8, NULL }},
+ { "Hardware size", "aarp.hard.size", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
+
{ &hf_aarp_proto_size,
- { "Protocol size", "aarp.proto.size", FT_UINT8, NULL }},
+ { "Protocol size", "aarp.proto.size", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
+
{ &hf_aarp_opcode,
- { "Opcode", "aarp.opcode", FT_UINT16, NULL }},
+ { "Opcode", "aarp.opcode", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "" }},
+
{ &hf_aarp_src_ether,
- { "Sender ether", "aarp.src.ether", FT_ETHER, NULL }},
+ { "Sender ether", "aarp.src.ether", FT_ETHER, BASE_NONE, NULL, 0x0,
+ "" }},
+
{ &hf_aarp_src_id,
- { "Sender ID", "aarp.src.id", FT_UINT32, NULL }},
+ { "Sender ID", "aarp.src.id", FT_UINT32, BASE_HEX, NULL, 0x0,
+ "" }},
+
{ &hf_aarp_dst_ether,
- { "Target ether", "aarp.dst.ether", FT_ETHER, NULL }},
+ { "Target ether", "aarp.dst.ether", FT_ETHER, BASE_NONE, NULL, 0x0,
+ "" }},
+
{ &hf_aarp_dst_id,
- { "Target ID", "aarp.dst.id", FT_UINT32, NULL }}
+ { "Target ID", "aarp.dst.id", FT_UINT32, BASE_HEX, NULL, 0x0,
+ "" }},
};
proto_aarp = proto_register_protocol("Appletalk Address Resolution Protocol",
diff --git a/packet-arp.c b/packet-arp.c
index 201b7b9915..c2c8116a09 100644
--- a/packet-arp.c
+++ b/packet-arp.c
@@ -1,7 +1,7 @@
/* packet-arp.c
* Routines for ARP packet disassembly
*
- * $Id: packet-arp.c,v 1.18 1999/10/03 17:12:15 deniel Exp $
+ * $Id: packet-arp.c,v 1.19 1999/10/12 06:20:01 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -297,23 +297,40 @@ proto_register_arp(void)
{
static hf_register_info hf[] = {
{ &hf_arp_hard_type,
- { "Hardware type", "arp.hw.type", FT_UINT16, NULL }},
+ { "Hardware type", "arp.hw.type", FT_UINT16, BASE_HEX, NULL, 0x0,
+ "" }},
+
{ &hf_arp_proto_type,
- { "Protocol type", "arp.proto.type",FT_UINT16, NULL }},
+ { "Protocol type", "arp.proto.type",FT_UINT16, BASE_HEX, NULL, 0x0,
+ "" }},
+
{ &hf_arp_hard_size,
- { "Hardware size", "arp.hw.size", FT_UINT8, NULL }},
+ { "Hardware size", "arp.hw.size", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
+
{ &hf_arp_proto_size,
- { "Protocol size", "arp.proto.size",FT_UINT8, NULL }},
+ { "Protocol size", "arp.proto.size",FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
+
{ &hf_arp_opcode,
- { "Opcode", "arp.opcode", FT_UINT16, NULL }},
+ { "Opcode", "arp.opcode", FT_UINT16, BASE_HEX, NULL, 0x0,
+ "" }},
+
{ &hf_arp_src_ether,
- { "Sender hardware address", "arp.src.hw", FT_BYTES, NULL }},
+ { "Sender hardware address", "arp.src.hw", FT_BYTES, BASE_NONE, NULL, 0x0,
+ "" }},
+
{ &hf_arp_src_proto,
- { "Sender protocol address", "arp.src.proto", FT_BYTES, NULL }},
+ { "Sender protocol address", "arp.src.proto", FT_BYTES, BASE_NONE, NULL, 0x0,
+ "" }},
+
{ &hf_arp_dst_ether,
- { "Target hardware address", "arp.dst.hw", FT_BYTES, NULL }},
+ { "Target hardware address", "arp.dst.hw", FT_BYTES, BASE_NONE, NULL, 0x0,
+ "" }},
+
{ &hf_arp_dst_proto,
- { "Target protocol address", "arp.dst.proto", FT_BYTES, NULL }}
+ { "Target protocol address", "arp.dst.proto", FT_BYTES, BASE_NONE, NULL, 0x0,
+ "" }}
};
proto_arp = proto_register_protocol("Address Resolution Protocol", "arp");
diff --git a/packet-ascend.c b/packet-ascend.c
index 27ab0c851e..d4ef72e512 100644
--- a/packet-ascend.c
+++ b/packet-ascend.c
@@ -1,7 +1,7 @@
/* packet-ascend.c
* Routines for decoding Lucent/Ascend packet traces
*
- * $Id: packet-ascend.c,v 1.4 1999/09/13 03:48:58 gerald Exp $
+ * $Id: packet-ascend.c,v 1.5 1999/10/12 06:20:01 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -110,13 +110,16 @@ proto_register_ascend(void)
{
static hf_register_info hf[] = {
{ &hf_session_id,
- { "Session ID", "ascend.sess", FT_UINT32, NULL }},
+ { "Session ID", "ascend.sess", FT_UINT32, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_chunk,
- { "WDD Chunk", "ascend.chunk", FT_UINT32, NULL }},
+ { "WDD Chunk", "ascend.chunk", FT_UINT32, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_task,
- { "Task", "ascend.task", FT_UINT32, NULL }}
+ { "Task", "ascend.task", FT_UINT32, BASE_DEC, NULL, 0x0,
+ "" }},
};
proto_ascend = proto_register_protocol("Lucent/Ascend debug output", "ascend");
diff --git a/packet-atalk.c b/packet-atalk.c
index c8b83c8f72..28802df5bf 100644
--- a/packet-atalk.c
+++ b/packet-atalk.c
@@ -1,7 +1,7 @@
/* packet-ddp.c
* Routines for DDP packet disassembly.
*
- * $Id: packet-atalk.c,v 1.14 1999/10/07 17:11:11 deniel Exp $
+ * $Id: packet-atalk.c,v 1.15 1999/10/12 06:20:02 gram Exp $
*
* Simon Wilkinson <sxw@dcs.ed.ac.uk>
*
@@ -135,25 +135,44 @@ proto_register_atalk(void)
{
static hf_register_info hf[] = {
{ &hf_ddp_hopcount,
- { "Hop count", "ddp.hopcount", FT_UINT8, NULL }},
+ { "Hop count", "ddp.hopcount", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
+
{ &hf_ddp_len,
- { "Datagram length", "ddp.len", FT_UINT16, NULL }},
+ { "Datagram length", "ddp.len", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "" }},
+
{ &hf_ddp_checksum,
- { "Checksum", "ddp.checksum", FT_UINT16, NULL }},
+ { "Checksum", "ddp.checksum", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "" }},
+
{ &hf_ddp_dst_net,
- { "Destination Net", "ddp.dst.net", FT_UINT16, NULL }},
+ { "Destination Net", "ddp.dst.net", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "" }},
+
{ &hf_ddp_src_net,
- { "Source Net", "ddp.src.net", FT_UINT16, NULL }},
+ { "Source Net", "ddp.src.net", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "" }},
+
{ &hf_ddp_dst_node,
- { "Destination Node", "ddp.dst.node", FT_UINT8, NULL }},
+ { "Destination Node", "ddp.dst.node", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
+
{ &hf_ddp_src_node,
- { "Source Node", "ddp.src.node", FT_UINT8, NULL }},
+ { "Source Node", "ddp.src.node", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
+
{ &hf_ddp_dst_socket,
- { "Destination Socket", "ddp.dst.socket", FT_UINT8, NULL }},
+ { "Destination Socket", "ddp.dst.socket", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
+
{ &hf_ddp_src_socket,
- { "Source Socket", "ddp.src.socket", FT_UINT8, NULL }},
+ { "Source Socket", "ddp.src.socket", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
+
{ &hf_ddp_type,
- { "Protocol type", "ddp.type", FT_UINT8, NULL }}
+ { "Protocol type", "ddp.type", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
};
proto_ddp = proto_register_protocol("Datagram Delivery Protocol", "ddp");
diff --git a/packet-bootp.c b/packet-bootp.c
index 5af4df827a..48a11425d9 100644
--- a/packet-bootp.c
+++ b/packet-bootp.c
@@ -2,7 +2,7 @@
* Routines for BOOTP/DHCP packet disassembly
* Gilbert Ramirez <gram@verdict.uthscsa.edu>
*
- * $Id: packet-bootp.c,v 1.20 1999/10/08 13:57:31 deniel Exp $
+ * $Id: packet-bootp.c,v 1.21 1999/10/12 06:20:02 gram Exp $
*
* The information used comes from:
* RFC 2132: DHCP Options and BOOTP Vendor Extensions
@@ -488,11 +488,8 @@ dissect_bootp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
offset + 2, 1, pd[offset+2]);
proto_tree_add_item(bp_tree, hf_bootp_hops,
offset + 3, 1, pd[offset+3]);
- proto_tree_add_item_format(bp_tree, hf_bootp_id,
- offset + 4, 4,
- pntohl(&pd[offset+4]),
- "Transaction ID: 0x%08x",
- pntohl(&pd[offset+4]));
+ proto_tree_add_item(bp_tree, hf_bootp_id,
+ offset + 4, 4, pntohl(&pd[offset+4]));
proto_tree_add_item(bp_tree, hf_bootp_secs,
offset + 8, 2, pntohs(&pd[offset+8]));
proto_tree_add_item(bp_tree, hf_bootp_flag,
@@ -574,35 +571,64 @@ proto_register_bootp(void)
{
static hf_register_info hf[] = {
{ &hf_bootp_type,
- { "Message type", "bootp.type", FT_UINT8, NULL }},
+ { "Message type", "bootp.type", FT_UINT8, BASE_NONE, NULL, 0x0,
+ "" }},
+
{ &hf_bootp_hw_type,
- { "Hardware type", "bootp.hw.type", FT_UINT8, NULL }},
+ { "Hardware type", "bootp.hw.type", FT_UINT8, BASE_HEX, NULL, 0x0,
+ "" }},
+
{ &hf_bootp_hw_len,
- { "Hardware address length", "bootp.hw.len", FT_UINT8, NULL }},
+ { "Hardware address length", "bootp.hw.len", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
+
{ &hf_bootp_hops,
- { "Hops", "bootp.hops", FT_UINT8, NULL }},
+ { "Hops", "bootp.hops", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
+
{ &hf_bootp_id,
- { "Transaction ID", "bootp.id", FT_UINT32, NULL }},
+ { "Transaction ID", "bootp.id", FT_UINT32, BASE_HEX, NULL, 0x0,
+ "" }},
+
{ &hf_bootp_secs,
- { "Seconds elapsed", "bootp.secs", FT_UINT16, NULL }},
+ { "Seconds elapsed", "bootp.secs", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "" }},
+
{ &hf_bootp_flag,
- { "Broadcast flag", "bootp.flag", FT_UINT16, NULL }},
+ { "Broadcast flag", "bootp.flag", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "" }},
+
{ &hf_bootp_ip_client,
- { "Client IP address", "bootp.ip.client",FT_IPv4, NULL }},
+ { "Client IP address", "bootp.ip.client",FT_IPv4, BASE_NONE, NULL, 0x0,
+ "" }},
+
{ &hf_bootp_ip_your,
- { "Your (client) IP address", "bootp.ip.your", FT_IPv4, NULL }},
+ { "Your (client) IP address", "bootp.ip.your", FT_IPv4, BASE_NONE, NULL, 0x0,
+ "" }},
+
{ &hf_bootp_ip_server,
- { "Next server IP address", "bootp.ip.server",FT_IPv4, NULL }},
+ { "Next server IP address", "bootp.ip.server",FT_IPv4, BASE_NONE, NULL, 0x0,
+ "" }},
+
{ &hf_bootp_ip_relay,
- { "Relay agent IP address", "bootp.ip.relay", FT_IPv4, NULL }},
+ { "Relay agent IP address", "bootp.ip.relay", FT_IPv4, BASE_NONE, NULL, 0x0,
+ "" }},
+
{ &hf_bootp_hw_addr,
- { "Client hardware address", "bootp.hw.addr", FT_BYTES, NULL }},
+ { "Client hardware address", "bootp.hw.addr", FT_BYTES, BASE_NONE, NULL, 0x0,
+ "" }},
+
{ &hf_bootp_server,
- { "Server host name", "bootp.server", FT_STRING, NULL }},
+ { "Server host name", "bootp.server", FT_STRING, BASE_NONE, NULL, 0x0,
+ "" }},
+
{ &hf_bootp_file,
- { "Boot file name", "bootp.file", FT_STRING, NULL }},
+ { "Boot file name", "bootp.file", FT_STRING, BASE_NONE, NULL, 0x0,
+ "" }},
+
{ &hf_bootp_cookie,
- { "Magic cookie", "bootp.cookie", FT_IPv4, NULL }}
+ { "Magic cookie", "bootp.cookie", FT_IPv4, BASE_NONE, NULL, 0x0,
+ "" }},
};
proto_bootp = proto_register_protocol("Bootstrap Protocol", "bootp");
diff --git a/packet-bpdu.c b/packet-bpdu.c
index 789f00bbf6..5e6fc519d0 100644
--- a/packet-bpdu.c
+++ b/packet-bpdu.c
@@ -1,7 +1,7 @@
/* packet-bpdu.c
* Routines for BPDU (Spanning Tree Protocol) disassembly
*
- * $Id: packet-bpdu.c,v 1.3 1999/10/09 13:05:55 deniel Exp $
+ * $Id: packet-bpdu.c,v 1.4 1999/10/12 06:20:03 gram Exp $
*
* Copyright 1999 Christophe Tronche <ch.tronche@computer.org>
*
@@ -212,29 +212,41 @@ proto_register_bpdu(void)
static hf_register_info hf[] = {
{ &hf_bpdu_proto_id,
- { "Protocol Identifier", "stp.protocol", FT_UINT16, NULL }},
+ { "Protocol Identifier", "stp.protocol", FT_UINT16, BASE_HEX, NULL, 0x0,
+ "" }},
{ &hf_bpdu_version_id,
- { "Protocol Version Identifier", "stp.version", FT_UINT8, NULL }},
+ { "Protocol Version Identifier", "stp.version", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_bpdu_type,
- { "BPDU type", "stp.type", FT_UINT8, NULL }},
+ { "BPDU type", "stp.type", FT_UINT8, BASE_HEX, NULL, 0x0,
+ "" }},
{ &hf_bpdu_flags,
- { "BPDU flags", "stp.flags", FT_UINT8, NULL }},
+ { "BPDU flags", "stp.flags", FT_UINT8, BASE_HEX, NULL, 0x0,
+ "" }},
{ &hf_bpdu_root_mac,
- { "Root Identifier", "stp.root.hw", FT_ETHER, NULL }},
+ { "Root Identifier", "stp.root.hw", FT_ETHER, BASE_NONE, NULL, 0x0,
+ "" }},
{ &hf_bpdu_root_cost,
- { "Root Path Cost", "stp.root.cost", FT_UINT32, NULL }},
+ { "Root Path Cost", "stp.root.cost", FT_UINT32, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_bpdu_bridge_mac,
- { "Bridge Identifier", "stp.bridge.hw", FT_ETHER, NULL }},
+ { "Bridge Identifier", "stp.bridge.hw", FT_ETHER, BASE_NONE, NULL, 0x0,
+ ""}},
{ &hf_bpdu_port_id,
- { "Port identifier", "stp.port", FT_UINT16, NULL }},
+ { "Port identifier", "stp.port", FT_UINT16, BASE_HEX, NULL, 0x0,
+ ""}},
{ &hf_bpdu_msg_age,
- { "Message Age", "stp.msg_age", FT_DOUBLE, NULL }},
+ { "Message Age", "stp.msg_age", FT_DOUBLE, BASE_NONE, NULL, 0x0,
+ "" }},
{ &hf_bpdu_max_age,
- { "Max Age", "stp.max_age", FT_DOUBLE, NULL }},
+ { "Max Age", "stp.max_age", FT_DOUBLE, BASE_NONE, NULL, 0x0,
+ "" }},
{ &hf_bpdu_hello_time,
- { "Hello Time", "stp.hello", FT_DOUBLE, NULL }},
+ { "Hello Time", "stp.hello", FT_DOUBLE, BASE_NONE, NULL, 0x0,
+ "" }},
{ &hf_bpdu_forward_delay,
- { "Forward Delay", "stp.forward", FT_DOUBLE, NULL }}
+ { "Forward Delay", "stp.forward", FT_DOUBLE, BASE_NONE, NULL, 0x0,
+ "" }},
};
proto_bpdu = proto_register_protocol("Spanning Tree Protocol", "stp");
diff --git a/packet-cdp.c b/packet-cdp.c
index 29dd383672..1a2602c24e 100644
--- a/packet-cdp.c
+++ b/packet-cdp.c
@@ -2,7 +2,7 @@
* Routines for the disassembly of the "Cisco Discovery Protocol"
* (c) Copyright Hannes R. Boehm <hannes@boehm.org>
*
- * $Id: packet-cdp.c,v 1.14 1999/09/17 05:56:53 guy Exp $
+ * $Id: packet-cdp.c,v 1.15 1999/10/12 06:20:03 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -280,10 +280,12 @@ proto_register_cdp(void)
{
static hf_register_info hf[] = {
{ &hf_cdp_tlvtype,
- { "Type", "cdp.tlv.type", FT_VALS_UINT16, VALS(type_vals) }},
+ { "Type", "cdp.tlv.type", FT_UINT16, BASE_HEX, VALS(type_vals), 0x0,
+ "" }},
{ &hf_cdp_tlvlength,
- { "Length", "cdp.tlv.len", FT_UINT16, NULL }},
+ { "Length", "cdp.tlv.len", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "" }},
};
proto_cdp = proto_register_protocol("Cisco Discovery Protocol", "cdp");
diff --git a/packet-eth.c b/packet-eth.c
index f819a5c583..d8f357ac0e 100644
--- a/packet-eth.c
+++ b/packet-eth.c
@@ -1,7 +1,7 @@
/* packet-eth.c
* Routines for ethernet packet disassembly
*
- * $Id: packet-eth.c,v 1.19 1999/09/15 06:26:42 gram Exp $
+ * $Id: packet-eth.c,v 1.20 1999/10/12 06:20:04 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -215,17 +215,21 @@ proto_register_eth(void)
static hf_register_info hf[] = {
{ &hf_eth_dst,
- { "Destination", "eth.dst", FT_ETHER, NULL }},
+ { "Destination", "eth.dst", FT_ETHER, BASE_NONE, NULL, 0x0,
+ "Destination Hardware Address" }},
{ &hf_eth_src,
- { "Source", "eth.src", FT_ETHER, NULL }},
+ { "Source", "eth.src", FT_ETHER, BASE_NONE, NULL, 0x0,
+ "Source Hardware Address" }},
{ &hf_eth_len,
- { "Length", "eth.len", FT_UINT16, NULL }},
+ { "Length", "eth.len", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "" }},
/* registered here but handled in ethertype.c */
{ &hf_eth_type,
- { "Type", "eth.type", FT_VALS_UINT16, VALS(etype_vals) }}
+ { "Type", "eth.type", FT_UINT16, BASE_HEX, VALS(etype_vals), 0x0,
+ "" }}
};
proto_eth = proto_register_protocol ("Ethernet", "eth" );
diff --git a/packet-fddi.c b/packet-fddi.c
index c14e2d6dde..5c9fb308e5 100644
--- a/packet-fddi.c
+++ b/packet-fddi.c
@@ -3,7 +3,7 @@
*
* Laurent Deniel <deniel@worldnet.fr>
*
- * $Id: packet-fddi.c,v 1.21 1999/09/10 04:53:14 guy Exp $
+ * $Id: packet-fddi.c,v 1.22 1999/10/12 06:20:05 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -348,13 +348,16 @@ proto_register_fddi(void)
* NULL, just show the hex value, else show the string.
*/
{ &hf_fddi_fc,
- { "Frame Control", "fddi.fc", FT_UINT8, NULL }},
+ { "Frame Control", "fddi.fc", FT_UINT8, BASE_HEX, NULL, 0x0,
+ "" }},
{ &hf_fddi_dst,
- { "Destination", "fddi.dst", FT_ETHER, NULL }},
+ { "Destination", "fddi.dst", FT_ETHER, BASE_NONE, NULL, 0x0,
+ "Destination Hardware Address" }},
{ &hf_fddi_src,
- { "Source", "fddi.src", FT_ETHER, NULL }},
+ { "Source", "fddi.src", FT_ETHER, BASE_NONE, NULL, 0x0,
+ "" }},
};
proto_fddi = proto_register_protocol ("Fiber Distributed Data Interface", "fddi" );
diff --git a/packet-ftp.c b/packet-ftp.c
index 01b4ad93de..dcdbf758b7 100644
--- a/packet-ftp.c
+++ b/packet-ftp.c
@@ -2,7 +2,7 @@
* Routines for ftp packet dissection
* Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
*
- * $Id: packet-ftp.c,v 1.8 1999/10/09 11:56:15 deniel Exp $
+ * $Id: packet-ftp.c,v 1.9 1999/10/12 06:20:05 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@@ -162,17 +162,28 @@ proto_register_ftp(void)
{
static hf_register_info hf[] = {
{ &hf_ftp_response,
- { "Response", "ftp.response", FT_BOOLEAN, NULL }},
+ { "Response", "ftp.response", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
+ "" }},
+
{ &hf_ftp_request,
- { "Request", "ftp.request", FT_BOOLEAN, NULL }},
+ { "Request", "ftp.request", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
+ "" }},
+
{ &hf_ftp_request_command,
- { "Request command", "ftp.request.command", FT_STRING, NULL }},
+ { "Request command", "ftp.request.command", FT_STRING, BASE_NONE, NULL, 0x0,
+ "" }},
+
{ &hf_ftp_request_data,
- { "Request data", "ftp.request.data", FT_STRING, NULL }},
+ { "Request data", "ftp.request.data", FT_STRING, BASE_NONE, NULL, 0x0,
+ "" }},
+
{ &hf_ftp_response_code,
- { "Response code", "ftp.response.code", FT_UINT8, NULL }},
+ { "Response code", "ftp.response.code", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
+
{ &hf_ftp_response_data,
- { "Response data", "ftp.reponse.data", FT_STRING, NULL }}
+ { "Response data", "ftp.reponse.data", FT_STRING, BASE_NONE, NULL, 0x0,
+ "" }}
};
proto_ftp = proto_register_protocol("File Transfer Protocol", "ftp");
diff --git a/packet-giop.c b/packet-giop.c
index bae17eca5c..c7562fde7e 100644
--- a/packet-giop.c
+++ b/packet-giop.c
@@ -3,7 +3,7 @@
*
* Laurent Deniel <deniel@worldnet.fr>
*
- * $Id: packet-giop.c,v 1.7 1999/10/09 13:31:30 deniel Exp $
+ * $Id: packet-giop.c,v 1.8 1999/10/12 06:20:05 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -709,9 +709,11 @@ proto_register_giop(void)
{
static hf_register_info hf[] = {
{ &hf_giop_message_type,
- { "Message type", "giop.type", FT_UINT8, NULL }},
+ { "Message type", "giop.type", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_giop_message_size,
- { "Message size", "giop.len", FT_UINT32, NULL }}
+ { "Message size", "giop.len", FT_UINT32, BASE_DEC, NULL, 0x0,
+ "" }},
};
proto_giop = proto_register_protocol("General Inter-ORB Protocol", "giop");
diff --git a/packet-icmpv6.c b/packet-icmpv6.c
index 1a8c32f846..0c6f40738c 100644
--- a/packet-icmpv6.c
+++ b/packet-icmpv6.c
@@ -1,7 +1,7 @@
/* packet-icmpv6.c
* Routines for ICMPv6 packet disassembly
*
- * $Id: packet-icmpv6.c,v 1.8 1999/10/10 16:09:33 deniel Exp $
+ * $Id: packet-icmpv6.c,v 1.9 1999/10/12 06:20:07 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -578,11 +578,14 @@ proto_register_icmpv6(void)
{
static hf_register_info hf[] = {
{ &hf_icmpv6_type,
- { "Type", "icmpv6.type", FT_UINT8, NULL }},
+ { "Type", "icmpv6.type", FT_UINT8, BASE_HEX, NULL, 0x0,
+ "" }},
{ &hf_icmpv6_code,
- { "Code", "icmpv6.code", FT_UINT8, NULL }},
+ { "Code", "icmpv6.code", FT_UINT8, BASE_HEX, NULL, 0x0,
+ "" }},
{ &hf_icmpv6_checksum,
- { "Checksum", "icmpv6.checksum", FT_UINT16, NULL }}
+ { "Checksum", "icmpv6.checksum", FT_UINT16, BASE_HEX, NULL, 0x0,
+ "" }}
};
proto_icmpv6 = proto_register_protocol("Internet Control Message Protocol v6",
diff --git a/packet-icp.c b/packet-icp.c
index 41a39c1f6b..717a2df487 100644
--- a/packet-icp.c
+++ b/packet-icp.c
@@ -2,7 +2,7 @@
* Routines for ICP (internet cache protocol) packet disassembly RFC 2186 && RFC 2187
*
*
- * $Id: packet-icp.c,v 1.1 1999/09/14 08:06:24 guy Exp $
+ * $Id: packet-icp.c,v 1.2 1999/10/12 06:20:07 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Peter Torvals
@@ -260,13 +260,21 @@ proto_register_icp(void)
{
static hf_register_info hf[] = {
{ &hf_icp_opcode,
- { "Opcode","icp.opcode", FT_UINT8, NULL }},
+ { "Opcode","icp.opcode", FT_UINT8, BASE_HEX, NULL, 0x0,
+ "" }},
+
{ &hf_icp_version,
- { "Version", "icp.version", FT_UINT8, NULL }},
+ { "Version", "icp.version", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
+
{ &hf_icp_length,
- { "Length","icp.length", FT_UINT16, NULL }},
+ { "Length","icp.length", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "" }},
+
{ &hf_icp_request_nr,
- { "Request Number","icp.nr", FT_UINT32, NULL }} };
+ { "Request Number","icp.nr", FT_UINT32, BASE_DEC, NULL, 0x0,
+ "" }},
+ };
proto_icp = proto_register_protocol ("Internet Cache protocol", "icp");
proto_register_field_array(proto_icp, hf, array_length(hf));
diff --git a/packet-ip.c b/packet-ip.c
index 8a84dd15be..0775aaa674 100644
--- a/packet-ip.c
+++ b/packet-ip.c
@@ -1,7 +1,7 @@
/* packet-ip.c
* Routines for IP and miscellaneous IP protocol packet disassembly
*
- * $Id: packet-ip.c,v 1.50 1999/10/02 16:21:07 deniel Exp $
+ * $Id: packet-ip.c,v 1.51 1999/10/12 06:20:08 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -1191,19 +1191,24 @@ proto_register_igmp(void)
static hf_register_info hf[] = {
{ &hf_igmp_version,
- { "Version", "igmp.version", FT_UINT8, NULL }},
+ { "Version", "igmp.version", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_igmp_type,
- { "Type", "igmp.type", FT_UINT8, NULL }},
+ { "Type", "igmp.type", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_igmp_unused,
- { "Unused", "igmp.unused", FT_UINT8, NULL }},
+ { "Unused", "igmp.unused", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_igmp_checksum,
- { "Checksum", "igmp.checksum", FT_UINT16, NULL }},
+ { "Checksum", "igmp.checksum", FT_UINT16, BASE_HEX, NULL, 0x0,
+ "" }},
{ &hf_igmp_group,
- { "Group address", "igmp.group", FT_IPv4, NULL }}
+ { "Group address", "igmp.group", FT_IPv4, BASE_NONE, NULL, 0x0,
+ "" }},
};
proto_igmp = proto_register_protocol ("Internet Group Management Protocol", "igmp");
@@ -1216,46 +1221,61 @@ proto_register_ip(void)
static hf_register_info hf[] = {
{ &hf_ip_version,
- { "Version", "ip.version", FT_UINT8, NULL }},
+ { "Version", "ip.version", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_ip_hdr_len,
- { "Header Length", "ip.hdr_len", FT_UINT8, NULL }},
+ { "Header Length", "ip.hdr_len", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_ip_tos,
- { "Type of Service", "ip.tos", FT_UINT8, NULL }},
+ { "Type of Service", "ip.tos", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_ip_tos_precedence,
- { "Precedence", "ip.tos.precedence", FT_VALS_UINT8, VALS(precedence_vals) }},
+ { "Precedence", "ip.tos.precedence", FT_UINT8, BASE_DEC, VALS(precedence_vals),
+ 0x0,
+ "" }},
{ &hf_ip_len,
- { "Total Length", "ip.len", FT_UINT16 }},
+ { "Total Length", "ip.len", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_ip_id,
- { "Identification", "ip.id", FT_UINT32 }},
+ { "Identification", "ip.id", FT_UINT32, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_ip_dst,
- { "Destination", "ip.dst", FT_IPv4, NULL }},
+ { "Destination", "ip.dst", FT_IPv4, BASE_NONE, NULL, 0x0,
+ "" }},
{ &hf_ip_src,
- { "Source", "ip.src", FT_IPv4, NULL }},
+ { "Source", "ip.src", FT_IPv4, BASE_NONE, NULL, 0x0,
+ "" }},
{ &hf_ip_addr,
- { "Source or Destination Address", "ip.addr", FT_IPv4, NULL }},
+ { "Source or Destination Address", "ip.addr", FT_IPv4, BASE_NONE, NULL, 0x0,
+ "" }},
{ &hf_ip_flags,
- { "Flags", "ip.flags", FT_UINT8, NULL }},
+ { "Flags", "ip.flags", FT_UINT8, BASE_HEX, NULL, 0x0,
+ "" }},
{ &hf_ip_frag_offset,
- { "Fragment offset", "ip.frag_offset", FT_UINT16, NULL }},
+ { "Fragment offset", "ip.frag_offset", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_ip_ttl,
- { "Time to live", "ip.ttl", FT_UINT8, NULL }},
+ { "Time to live", "ip.ttl", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_ip_proto,
- { "Protocol", "ip.proto", FT_VALS_UINT8, VALS(proto_vals) }},
+ { "Protocol", "ip.proto", FT_UINT8, BASE_HEX, VALS(proto_vals), 0x0,
+ "" }},
{ &hf_ip_checksum,
- { "Header checksum", "ip.checksum", FT_UINT16, NULL }}
+ { "Header checksum", "ip.checksum", FT_UINT16, BASE_HEX, NULL, 0x0,
+ "" }},
};
proto_ip = proto_register_protocol ("Internet Protocol", "ip");
@@ -1268,11 +1288,16 @@ proto_register_icmp(void)
static hf_register_info hf[] = {
{ &hf_icmp_type,
- { "Type", "icmp.type", FT_UINT8, NULL }},
+ { "Type", "icmp.type", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
+
{ &hf_icmp_code,
- { "Code", "icmp.code", FT_UINT8, NULL }},
+ { "Code", "icmp.code", FT_UINT8, BASE_HEX, NULL, 0x0,
+ "" }},
+
{ &hf_icmp_checksum,
- { "Checksum", "icmp.checksum", FT_UINT16, NULL }}
+ { "Checksum", "icmp.checksum", FT_UINT16, BASE_HEX, NULL, 0x0,
+ "" }},
};
proto_icmp = proto_register_protocol ("Internet Control Message Protocol",
diff --git a/packet-ipsec.c b/packet-ipsec.c
index 7935bb13be..eb6173066a 100644
--- a/packet-ipsec.c
+++ b/packet-ipsec.c
@@ -1,7 +1,7 @@
/* packet-ipsec.c
* Routines for IPsec packet disassembly
*
- * $Id: packet-ipsec.c,v 1.4 1999/10/11 12:37:50 deniel Exp $
+ * $Id: packet-ipsec.c,v 1.5 1999/10/12 06:20:09 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -162,16 +162,20 @@ proto_register_ipsec(void)
static hf_register_info hf_ah[] = {
{ &hf_ah_spi,
- { "SPI", "ah.spi", FT_UINT32, NULL }},
+ { "SPI", "ah.spi", FT_UINT32, BASE_HEX, NULL, 0x0,
+ "" }},
{ &hf_ah_sequence,
- { "Sequence", "ah.sequence", FT_UINT32, NULL }}
+ { "Sequence", "ah.sequence", FT_UINT32, BASE_HEX, NULL, 0x0,
+ "" }}
};
static hf_register_info hf_esp[] = {
{ &hf_esp_spi,
- { "SPI", "esp.spi", FT_UINT32, NULL }},
+ { "SPI", "esp.spi", FT_UINT32, BASE_HEX, NULL, 0x0,
+ "" }},
{ &hf_esp_sequence,
- { "Sequence", "esp.sequence", FT_UINT32, NULL }}
+ { "Sequence", "esp.sequence", FT_UINT32, BASE_HEX, NULL, 0x0,
+ "" }}
};
proto_ah = proto_register_protocol("Authentication Header", "ah");
diff --git a/packet-ipv6.c b/packet-ipv6.c
index 41a6922168..4a2772ea31 100644
--- a/packet-ipv6.c
+++ b/packet-ipv6.c
@@ -1,7 +1,7 @@
/* packet-ipv6.c
* Routines for IPv6 packet disassembly
*
- * $Id: packet-ipv6.c,v 1.14 1999/10/11 17:05:49 deniel Exp $
+ * $Id: packet-ipv6.c,v 1.15 1999/10/12 06:20:09 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -414,9 +414,11 @@ proto_register_ipv6(void)
{
static hf_register_info hf[] = {
{ &hf_ipv6_src,
- { "Source", "ipv6.src", FT_IPv6, NULL }},
+ { "Source", "ipv6.src", FT_IPv6, BASE_NONE, NULL, 0x0,
+ "Source IPv6 Address" }},
{ &hf_ipv6_dst,
- { "Destination", "ipv6.dst", FT_IPv6, NULL }}
+ { "Destination", "ipv6.dst", FT_IPv6, BASE_NONE, NULL, 0x0,
+ "Destination IPv6 Address" }}
};
proto_ipv6 = proto_register_protocol("Internet Protocol Version 6", "ipv6");
diff --git a/packet-ipx.c b/packet-ipx.c
index 78bfb3171a..af313b49a1 100644
--- a/packet-ipx.c
+++ b/packet-ipx.c
@@ -2,7 +2,7 @@
* Routines for NetWare's IPX
* Gilbert Ramirez <gram@verdict.uthscsa.edu>
*
- * $Id: packet-ipx.c,v 1.27 1999/09/15 22:33:17 gram Exp $
+ * $Id: packet-ipx.c,v 1.28 1999/10/12 06:20:10 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@@ -285,8 +285,7 @@ dissect_ipx(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
ti = proto_tree_add_item(tree, proto_ipx, offset, 30, NULL);
ipx_tree = proto_item_add_subtree(ti, ETT_IPX);
- proto_tree_add_item_format(ipx_tree, hf_ipx_checksum, offset, 2, ipx_checksum,
- "Checksum: 0x%04x", ipx_checksum);
+ proto_tree_add_item(ipx_tree, hf_ipx_checksum, offset, 2, ipx_checksum);
proto_tree_add_item_format(ipx_tree, hf_ipx_len, offset+2, 2, ipx_length,
"Length: %d bytes", ipx_length);
proto_tree_add_item_format(ipx_tree, hf_ipx_hops, offset+4, 1, ipx_hops,
@@ -631,34 +630,45 @@ proto_register_ipx(void)
{
static hf_register_info hf_ipx[] = {
{ &hf_ipx_checksum,
- { "Checksum", "ipx.checksum", FT_UINT16, NULL }},
+ { "Checksum", "ipx.checksum", FT_UINT16, BASE_HEX, NULL, 0x0,
+ "" }},
{ &hf_ipx_len,
- { "Length", "ipx.len", FT_UINT16, NULL }},
+ { "Length", "ipx.len", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_ipx_hops,
- { "Transport Control (Hops)", "ipx.hops", FT_UINT8, NULL }},
+ { "Transport Control (Hops)", "ipx.hops", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_ipx_packet_type,
- { "Packet Type", "ipx.packet_type", FT_VALS_UINT8, VALS(ipx_packet_type_vals) }},
+ { "Packet Type", "ipx.packet_type", FT_UINT8, BASE_HEX, VALS(ipx_packet_type_vals),
+ 0x0,
+ "" }},
{ &hf_ipx_dnet,
- { "Destination Network","ipx.dstnet", FT_IPXNET, NULL }},
+ { "Destination Network","ipx.dst.net", FT_IPXNET, BASE_NONE, NULL, 0x0,
+ "" }},
{ &hf_ipx_dnode,
- { "Destination Node", "ipx.dstnode", FT_ETHER, NULL }},
+ { "Destination Node", "ipx.dst.node", FT_ETHER, BASE_NONE, NULL, 0x0,
+ "" }},
{ &hf_ipx_dsocket,
- { "Destination Socket", "ipx.dstsocket", FT_UINT16, NULL }},
+ { "Destination Socket", "ipx.dst.socket", FT_UINT16, BASE_HEX, NULL, 0x0,
+ "" }},
{ &hf_ipx_snet,
- { "Source Network","ipx.srcnet", FT_IPXNET, NULL }},
+ { "Source Network","ipx.src.net", FT_IPXNET, BASE_NONE, NULL, 0x0,
+ "" }},
{ &hf_ipx_snode,
- { "Source Node", "ipx.srcnode", FT_ETHER, NULL }},
+ { "Source Node", "ipx.src.node", FT_ETHER, BASE_NONE, NULL, 0x0,
+ "" }},
{ &hf_ipx_ssocket,
- { "Source Socket", "ipx.srcsocket", FT_UINT16, NULL }},
+ { "Source Socket", "ipx.src.socket", FT_UINT16, BASE_HEX, NULL, 0x0,
+ "" }},
};
proto_ipx = proto_register_protocol ("Internetwork Packet eXchange", "ipx");
diff --git a/packet-lapb.c b/packet-lapb.c
index d748cec1c2..c754c9f833 100644
--- a/packet-lapb.c
+++ b/packet-lapb.c
@@ -2,7 +2,7 @@
* Routines for lapb frame disassembly
* Olivier Abad <abad@daba.dhis.org>
*
- * $Id: packet-lapb.c,v 1.5 1999/09/12 18:37:01 guy Exp $
+ * $Id: packet-lapb.c,v 1.6 1999/10/12 06:20:11 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -105,9 +105,12 @@ proto_register_lapb(void)
{
static hf_register_info hf[] = {
{ &hf_lapb_address,
- { "Address Field", "lapb.address", FT_UINT8, NULL} },
+ { "Address Field", "lapb.address", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
+
{ &hf_lapb_control,
- { "Control Field", "lapb.control", FT_STRING, NULL} },
+ { "Control Field", "lapb.control", FT_STRING, BASE_NONE, NULL, 0x0,
+ "" }},
};
proto_lapb = proto_register_protocol ("LAPB", "lapb");
diff --git a/packet-llc.c b/packet-llc.c
index a0bc8dbf32..d6d3d3e394 100644
--- a/packet-llc.c
+++ b/packet-llc.c
@@ -2,7 +2,7 @@
* Routines for IEEE 802.2 LLC layer
* Gilbert Ramirez <gramirez@tivoli.com>
*
- * $Id: packet-llc.c,v 1.25 1999/10/08 20:50:38 guy Exp $
+ * $Id: packet-llc.c,v 1.26 1999/10/12 06:20:11 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@@ -85,7 +85,7 @@ static struct sap_info saps[] = {
{ 0x00, NULL, NULL },
{ 0x02, NULL, NULL },
{ 0x03, NULL, NULL },
- { 0x04, NULL, NULL },
+ { 0x04, NULL, dissect_sna },
{ 0x05, NULL, NULL },
{ 0x06, capture_ip, dissect_ip },
{ 0x08, NULL, NULL },
@@ -322,20 +322,25 @@ proto_register_llc(void)
{
static hf_register_info hf[] = {
{ &hf_llc_dsap,
- { "DSAP", "llc.dsap", FT_VALS_UINT8, VALS(sap_vals) }},
+ { "DSAP", "llc.dsap", FT_UINT8, BASE_HEX, VALS(sap_vals), 0x0,
+ "" }},
{ &hf_llc_ssap,
- { "SSAP", "llc.ssap", FT_VALS_UINT8, VALS(sap_vals) }},
+ { "SSAP", "llc.ssap", FT_UINT8, BASE_HEX, VALS(sap_vals), 0x0,
+ "" }},
{ &hf_llc_ctrl,
- { "Control", "llc.control", FT_VALS_UINT8, VALS(llc_ctrl_vals) }},
+ { "Control", "llc.control", FT_UINT8, BASE_HEX, VALS(llc_ctrl_vals), 0x0,
+ "" }},
/* registered here but handled in ethertype.c */
{ &hf_llc_type,
- { "Type", "llc.type", FT_VALS_UINT16, VALS(etype_vals) }},
+ { "Type", "llc.type", FT_UINT16, BASE_HEX, VALS(etype_vals), 0x0,
+ "" }},
{ &hf_llc_oui,
- { "Organization Code", "llc.oui", FT_VALS_UINT24, VALS(llc_oui_vals) }}
+ { "Organization Code", "llc.oui", FT_UINT24, BASE_HEX, VALS(llc_oui_vals), 0x0,
+ ""}}
};
proto_llc = proto_register_protocol ("Logical-Link Control", "llc" );
diff --git a/packet-null.c b/packet-null.c
index e9cf2334d6..fb68fb40ab 100644
--- a/packet-null.c
+++ b/packet-null.c
@@ -1,7 +1,7 @@
/* packet-null.c
* Routines for null packet disassembly
*
- * $Id: packet-null.c,v 1.15 1999/08/24 17:26:13 gram Exp $
+ * $Id: packet-null.c,v 1.16 1999/10/12 06:20:12 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -311,10 +311,12 @@ proto_register_null(void)
/* registered here but handled in ethertype.c */
{ &hf_null_etype,
- { "Type", "null.type", FT_VALS_UINT16, VALS(etype_vals) }},
+ { "Type", "null.type", FT_UINT16, BASE_HEX, VALS(etype_vals), 0x0,
+ "" }},
{ &hf_null_family,
- { "Family", "null.family", FT_VALS_UINT32, VALS(family_vals) }}
+ { "Family", "null.family", FT_UINT32, BASE_HEX, VALS(family_vals), 0x0,
+ "" }}
};
proto_null = proto_register_protocol ("Null/Loopback", "null" );
diff --git a/packet-osi.c b/packet-osi.c
index 83943517a9..5c5bbd737f 100644
--- a/packet-osi.c
+++ b/packet-osi.c
@@ -1,7 +1,7 @@
/* packet-osi.c
* Routines for ISO/OSI network and transport protocol packet disassembly
*
- * $Id: packet-osi.c,v 1.10 1999/09/18 15:51:31 deniel Exp $
+ * $Id: packet-osi.c,v 1.11 1999/10/12 06:20:12 gram Exp $
* Laurent Deniel <deniel@worldnet.fr>
*
* Ethereal - Network traffic analyzer
@@ -1633,27 +1633,48 @@ void proto_register_clnp(void)
{
static hf_register_info hf[] = {
{ &hf_clnp_id,
- { "Protocol identifier", "clnp.id", FT_UINT8, NULL }},
+ { "Protocol identifier", "clnp.id", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
+
{ &hf_clnp_length,
- { "Length", "clnp.len", FT_UINT8, NULL }},
+ { "Length", "clnp.len", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
+
{ &hf_clnp_version,
- { "Version", "clnp.version", FT_UINT8, NULL }},
+ { "Version", "clnp.version", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
+
{ &hf_clnp_ttl,
- { "TTL", "clnp.ttl", FT_UINT8, NULL }},
+ { "TTL", "clnp.ttl", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
+
{ &hf_clnp_type,
- { "Type code", "clnp.type", FT_UINT8, NULL }},
+ { "Type code", "clnp.type", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
+
{ &hf_clnp_pdu_length,
- { "PDU segment length", "clnp.pdu.len", FT_UINT16, NULL }},
+ { "PDU segment length", "clnp.pdu.len", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "" }},
+
{ &hf_clnp_checksum,
- { "Checksum", "clnp.checksum",FT_UINT16, NULL }},
+ { "Checksum", "clnp.checksum",FT_UINT16, BASE_DEC, NULL, 0x0,
+ "" }},
+
{ &hf_clnp_dest_length,
- { "Destination address length", "clnp.dsap.len", FT_UINT8, NULL }},
+ { "Destination address length", "clnp.dsap.len", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
+
{ &hf_clnp_dest,
- { "Destination address", "clnp.dsap", FT_BYTES, NULL }},
+ { "Destination address", "clnp.dsap", FT_BYTES, BASE_NONE, NULL, 0x0,
+ "" }},
+
{ &hf_clnp_src_length,
- { "Source address length","clnp.ssap.len",FT_UINT8, NULL }},
+ { "Source address length","clnp.ssap.len",FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
+
{ &hf_clnp_src,
- { "Source address", "clnp.ssap", FT_BYTES, NULL }},
+ { "Source address", "clnp.ssap", FT_BYTES, BASE_NONE, NULL, 0x0,
+ "" }},
};
proto_clnp = proto_register_protocol("ISO CLNP", "clnp");
diff --git a/packet-ppp.c b/packet-ppp.c
index 9a9056be69..c1bc51c305 100644
--- a/packet-ppp.c
+++ b/packet-ppp.c
@@ -1,7 +1,7 @@
/* packet-ppp.c
* Routines for ppp packet disassembly
*
- * $Id: packet-ppp.c,v 1.20 1999/09/11 22:40:30 gerald Exp $
+ * $Id: packet-ppp.c,v 1.21 1999/10/12 06:20:14 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -1151,13 +1151,16 @@ proto_register_mp(void)
{
static hf_register_info hf[] = {
{ &hf_mp_frag_first,
- { "First fragment", "mp.first", FT_BOOLEAN, NULL }},
+ { "First fragment", "mp.first", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
+ "" }},
{ &hf_mp_frag_last,
- { "Last fragment", "mp.last", FT_BOOLEAN, NULL }},
+ { "Last fragment", "mp.last", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
+ "" }},
{ &hf_mp_sequence_num,
- { "Sequence number", "mp.seq", FT_UINT32, NULL }}
+ { "Sequence number", "mp.seq", FT_UINT32, BASE_DEC, NULL, 0x0,
+ "" }}
};
proto_mp = proto_register_protocol("PPP Multilink Protocol", "mp");
diff --git a/packet-radius.c b/packet-radius.c
index 8ea0bfaf25..57e7a279b1 100644
--- a/packet-radius.c
+++ b/packet-radius.c
@@ -1,7 +1,7 @@
/* packet-radius.c
* Routines for RADIUS packet disassembly
*
- * $Id: packet-radius.c,v 1.3 1999/08/03 14:59:16 gram Exp $
+ * $Id: packet-radius.c,v 1.4 1999/10/12 06:20:15 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Johan Feyaerts
@@ -614,11 +614,16 @@ proto_register_radius(void)
{
static hf_register_info hf[] = {
{ &hf_radius_code,
- { "Code","radius.code", FT_UINT8, NULL }},
+ { "Code","radius.code", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
+
{ &hf_radius_id,
- { "Identifier", "radius.id", FT_UINT8, NULL }},
+ { "Identifier", "radius.id", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
+
{ &hf_radius_length,
- { "Length","radius.length", FT_UINT16, NULL }}
+ { "Length","radius.length", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "" }}
};
proto_radius = proto_register_protocol ("Radius Protocol", "radius");
diff --git a/packet-rsvp.c b/packet-rsvp.c
index ed373cbc98..cb46223186 100644
--- a/packet-rsvp.c
+++ b/packet-rsvp.c
@@ -3,7 +3,7 @@
*
* (c) Copyright Ashok Narayanan <ashokn@cisco.com>
*
- * $Id: packet-rsvp.c,v 1.8 1999/08/29 04:15:30 gram Exp $
+ * $Id: packet-rsvp.c,v 1.9 1999/10/12 06:20:16 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -153,73 +153,125 @@ static hf_register_info rsvpf_info[] = {
/* Message type number */
{&rsvp_filter[RSVPF_MSG],
- { "Message Type", "rsvp.msg", FT_VALS_UINT8, VALS(message_type_vals) }},
+ { "Message Type", "rsvp.msg", FT_UINT8, BASE_NONE, message_type_vals, 0x0,
+ "" }},
/* Message type shorthands */
{&rsvp_filter[RSVPF_PATH],
- { "Path Message", "rsvp.path", FT_UINT8, NULL }},
+ { "Path Message", "rsvp.path", FT_UINT8, BASE_NONE, NULL, 0x0,
+ "" }},
+
{&rsvp_filter[RSVPF_RESV],
- { "Resv Message", "rsvp.resv", FT_UINT8, NULL }},
+ { "Resv Message", "rsvp.resv", FT_UINT8, BASE_NONE, NULL, 0x0,
+ "" }},
+
{&rsvp_filter[RSVPF_PATHERR],
- { "Path Error Message", "rsvp.perr", FT_UINT8, NULL }},
+ { "Path Error Message", "rsvp.perr", FT_UINT8, BASE_NONE, NULL, 0x0,
+ "" }},
+
{&rsvp_filter[RSVPF_RESVERR],
- { "Resv Error Message", "rsvp.rerr", FT_UINT8, NULL }},
+ { "Resv Error Message", "rsvp.rerr", FT_UINT8, BASE_NONE, NULL, 0x0,
+ "" }},
+
{&rsvp_filter[RSVPF_PATHTEAR],
- { "Path Tear Message", "rsvp.ptear", FT_UINT8, NULL }},
+ { "Path Tear Message", "rsvp.ptear", FT_UINT8, BASE_NONE, NULL, 0x0,
+ "" }},
+
{&rsvp_filter[RSVPF_RESVTEAR],
- { "Resv Tear Message", "rsvp.rtear", FT_UINT8, NULL }},
+ { "Resv Tear Message", "rsvp.rtear", FT_UINT8, BASE_NONE, NULL, 0x0,
+ "" }},
+
{&rsvp_filter[RSVPF_RCONFIRM],
- { "Resv Confirm Message", "rsvp.resvconf", FT_UINT8, NULL }},
+ { "Resv Confirm Message", "rsvp.resvconf", FT_UINT8, BASE_NONE, NULL, 0x0,
+ "" }},
/* Object present */
{&rsvp_filter[RSVPF_OBJECT],
- { "", "rsvp.object", FT_VALS_UINT8, VALS(rsvp_class_vals) }},
+ { "", "rsvp.object", FT_UINT8, BASE_NONE, rsvp_class_vals, 0x0,
+ "" }},
/* Object present shorthands */
{&rsvp_filter[RSVPF_SESSION],
- { "SESSION", "rsvp.session", FT_UINT8, NULL }},
+ { "SESSION", "rsvp.session", FT_UINT8, BASE_NONE, NULL, 0x0,
+ "" }},
+
{&rsvp_filter[RSVPF_HOP],
- { "HOP", "rsvp.hop", FT_UINT8, NULL }},
+ { "HOP", "rsvp.hop", FT_UINT8, BASE_NONE, NULL, 0x0,
+ "" }},
+
{&rsvp_filter[RSVPF_INTEGRITY],
- { "INTEGRITY", "rsvp.integrity", FT_UINT8, NULL }},
+ { "INTEGRITY", "rsvp.integrity", FT_UINT8, BASE_NONE, NULL, 0x0,
+ "" }},
+
{&rsvp_filter[RSVPF_TIME_VALUES],
- { "TIME VALUES", "rsvp.time", FT_UINT8, NULL }},
+ { "TIME VALUES", "rsvp.time", FT_UINT8, BASE_NONE, NULL, 0x0,
+ "" }},
+
{&rsvp_filter[RSVPF_ERROR],
- { "ERROR", "rsvp.error", FT_UINT8, NULL }},
+ { "ERROR", "rsvp.error", FT_UINT8, BASE_NONE, NULL, 0x0,
+ "" }},
+
{&rsvp_filter[RSVPF_SCOPE],
- { "SCOPE", "rsvp.scope", FT_UINT8, NULL }},
+ { "SCOPE", "rsvp.scope", FT_UINT8, BASE_NONE, NULL, 0x0,
+ "" }},
+
{&rsvp_filter[RSVPF_STYLE],
- { "STYLE", "rsvp.style", FT_UINT8, NULL }},
+ { "STYLE", "rsvp.style", FT_UINT8, BASE_NONE, NULL, 0x0,
+ "" }},
+
{&rsvp_filter[RSVPF_FLOWSPEC],
- { "FLOWSPEC", "rsvp.flowspec", FT_UINT8, NULL }},
+ { "FLOWSPEC", "rsvp.flowspec", FT_UINT8, BASE_NONE, NULL, 0x0,
+ "" }},
+
{&rsvp_filter[RSVPF_FILTER_SPEC],
- { "FILTERSPEC", "rsvp.filter", FT_UINT8, NULL }},
+ { "FILTERSPEC", "rsvp.filter", FT_UINT8, BASE_NONE, NULL, 0x0,
+ "" }},
+
{&rsvp_filter[RSVPF_SENDER],
- { "SENDER TEMPLATE", "rsvp.sender", FT_UINT8, NULL }},
+ { "SENDER TEMPLATE", "rsvp.sender", FT_UINT8, BASE_NONE, NULL, 0x0,
+ "" }},
+
{&rsvp_filter[RSVPF_TSPEC],
- { "SENDER TSPEC", "rsvp.tspec", FT_UINT8, NULL }},
+ { "SENDER TSPEC", "rsvp.tspec", FT_UINT8, BASE_NONE, NULL, 0x0,
+ "" }},
+
{&rsvp_filter[RSVPF_ADSPEC],
- { "ADSPEC", "rsvp.adspec", FT_UINT8, NULL }},
+ { "ADSPEC", "rsvp.adspec", FT_UINT8, BASE_NONE, NULL, 0x0,
+ "" }},
+
{&rsvp_filter[RSVPF_POLICY],
- { "POLICY", "rsvp.policy", FT_UINT8, NULL }},
+ { "POLICY", "rsvp.policy", FT_UINT8, BASE_NONE, NULL, 0x0,
+ "" }},
+
{&rsvp_filter[RSVPF_CONFIRM],
- { "CONFIRM", "rsvp.confirm", FT_UINT8, NULL }},
+ { "CONFIRM", "rsvp.confirm", FT_UINT8, BASE_NONE, NULL, 0x0,
+ "" }},
+
{&rsvp_filter[RSVPF_UNKNOWN_OBJ],
- { "Unknown object", "rsvp.obj_unknown", FT_UINT8, NULL }},
+ { "Unknown object", "rsvp.obj_unknown", FT_UINT8, BASE_NONE, NULL, 0x0,
+ "" }},
/* Session fields */
{&rsvp_filter[RSVPF_SESSION_IP],
- { "Destination address", "rsvp.session.ip", FT_IPv4, NULL }},
+ { "Destination address", "rsvp.session.ip", FT_IPv4, BASE_NONE, NULL, 0x0,
+ "" }},
+
{&rsvp_filter[RSVPF_SESSION_PORT],
- { "Port number", "rsvp.session.port", FT_UINT16, NULL }},
+ { "Port number", "rsvp.session.port", FT_UINT16, BASE_NONE, NULL, 0x0,
+ "" }},
+
{&rsvp_filter[RSVPF_SESSION_PROTO],
- { "Protocol", "rsvp.session.proto", FT_VALS_UINT8, VALS(proto_vals) }},
+ { "Protocol", "rsvp.session.proto", FT_UINT8, BASE_NONE, VALS(proto_vals), 0x0,
+ "" }},
/* Sender template fields */
{&rsvp_filter[RSVPF_SENDER_IP],
- { "Sender Template IPv4 address", "rsvp.template.ip", FT_IPv4, NULL }},
+ { "Sender Template IPv4 address", "rsvp.template.ip", FT_IPv4, BASE_NONE, NULL, 0x0,
+ "" }},
+
{&rsvp_filter[RSVPF_SENDER_PORT],
- { "Sender Template port number", "rsvp.template.port", FT_UINT16, NULL }}
+ { "Sender Template port number", "rsvp.template.port", FT_UINT16, BASE_NONE, NULL, 0x0,
+ "" }}
};
static inline int rsvp_class_to_filter_num(int classnum)
diff --git a/packet-sna.c b/packet-sna.c
new file mode 100644
index 0000000000..d142aaf54a
--- /dev/null
+++ b/packet-sna.c
@@ -0,0 +1,604 @@
+/* packet-sna.c
+ * Routines for SNA
+ * Gilbert Ramirez <gram@xiexie.org>
+ *
+ * $Id: packet-sna.c,v 1.1 1999/10/12 06:20:17 gram Exp $
+ *
+ * Ethereal - Network traffic analyzer
+ * By Gerald Combs <gerald@unicom.net>
+ * Copyright 1998 Gerald Combs
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+
+#include <glib.h>
+#include "packet.h"
+
+/*
+ * http://www.wanresources.com/snacell.html
+ *
+ */
+
+static int proto_sna = -1;
+static int hf_sna_th = -1;
+static int hf_sna_th_0 = -1;
+static int hf_sna_th_fid = -1;
+static int hf_sna_th_mpf = -1;
+static int hf_sna_th_odai = -1;
+static int hf_sna_th_efi = -1;
+static int hf_sna_th_daf = -1;
+static int hf_sna_th_oaf = -1;
+static int hf_sna_th_snf = -1;
+static int hf_sna_th_dcf = -1;
+static int hf_sna_th_lsid = -1;
+static int hf_sna_rh = -1;
+static int hf_sna_rh_0 = -1;
+static int hf_sna_rh_1 = -1;
+static int hf_sna_rh_2 = -1;
+static int hf_sna_rh_rri = -1;
+static int hf_sna_rh_ru_category = -1;
+static int hf_sna_rh_fi = -1;
+static int hf_sna_rh_sdi = -1;
+static int hf_sna_rh_bci = -1;
+static int hf_sna_rh_eci = -1;
+static int hf_sna_rh_dr1 = -1;
+static int hf_sna_rh_lcci = -1;
+static int hf_sna_rh_dr2 = -1;
+static int hf_sna_rh_eri = -1;
+static int hf_sna_rh_rti = -1;
+static int hf_sna_rh_rlwi = -1;
+static int hf_sna_rh_qri = -1;
+static int hf_sna_rh_pi = -1;
+static int hf_sna_rh_bbi = -1;
+static int hf_sna_rh_ebi = -1;
+static int hf_sna_rh_cdi = -1;
+static int hf_sna_rh_csi = -1;
+static int hf_sna_rh_edi = -1;
+static int hf_sna_rh_pdi = -1;
+static int hf_sna_rh_cebi = -1;
+static int hf_sna_ru = -1;
+
+/* Format Identifier */
+static const value_string sna_th_fid_vals[] = {
+ { 0x0, "SNA device <--> Non-SNA Device" },
+ { 0x1, "Subarea Node <--> Subarea Node" },
+ { 0x2, "Subarea Node <--> PU2" },
+ { 0x3, "Subarea Node or SNA host <--> Subarea Node" },
+ { 0x4, "?" },
+ { 0x5, "?" },
+ { 0xf, "Adjaced Subarea Nodes" },
+ { 0x0, NULL }
+};
+
+/* Mapping Field */
+static const value_string sna_th_mpf_vals[] = {
+ { 0, "Middle segment of a BIU" },
+ { 1, "Last segment of a BIU" },
+ { 2, "First segment of a BIU" },
+ { 3 , "Whole BIU" },
+ { 0, NULL }
+};
+
+/* Expedited Flow Indicator */
+static const value_string sna_th_efi_vals[] = {
+ { 0, "Normal Flow" },
+ { 1, "Expedited Flow" }
+};
+
+/* Request/Response Indicator */
+static const value_string sna_rh_rri_vals[] = {
+ { 0, "Request" },
+ { 1, "Response" }
+};
+
+/* Request/Response Unit Category */
+static const value_string sna_rh_ru_category_vals[] = {
+ { 0x00, "Function Management Data (FMD)" },
+ { 0x01, "Network Control (NC)" },
+ { 0x10, "Data Flow Control (DFC)" },
+ { 0x11, "Session Control (SC)" },
+};
+
+/* Format Indicator */
+static const true_false_string sna_rh_fi_truth =
+ { "FM Header", "No FM Header" };
+
+/* Sense Data Included */
+static const true_false_string sna_rh_sdi_truth =
+ { "Included", "Not Included" };
+
+/* Begin Chain Indicator */
+static const true_false_string sna_rh_bci_truth =
+ { "First in Chain", "Not First in Chain" };
+
+/* End Chain Indicator */
+static const true_false_string sna_rh_eci_truth =
+ { "Last in Chain", "Not Last in Chain" };
+
+/* Lengith-Checked Compression Indicator */
+static const true_false_string sna_rh_lcci_truth =
+ { "Compressed", "Not Compressed" };
+
+/* Response Type Indicator */
+static const true_false_string sna_rh_rti_truth =
+ { "Negative", "Positive" };
+
+/* Exception Response Indicator */
+static const true_false_string sna_rh_eri_truth =
+ { "Exception", "Definite" };
+
+/* Queued Response Indicator */
+static const true_false_string sna_rh_qri_truth =
+ { "Enqueue response in TC queues", "Response bypasses TC queues" };
+
+/* Code Selection Indicator */
+static const value_string sna_rh_csi_vals[] = {
+ { 0, "EBCDIC" },
+ { 1, "ASCII" }
+};
+
+static int dissect_fid0_1 (const u_char*, int, frame_data*, proto_tree*);
+static int dissect_fid2 (const u_char*, int, frame_data*, proto_tree*);
+static int dissect_fid3 (const u_char*, int, frame_data*, proto_tree*);
+static void dissect_rh (const u_char*, int, frame_data*, proto_tree*);
+
+void
+dissect_sna(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
+
+ proto_tree *sna_tree = NULL, *th_tree = NULL, *rh_tree = NULL;
+ proto_item *sna_ti, *th_ti, *rh_ti;
+ guint8 th_fid;
+ int sna_header_len = 0, th_header_len = 0;
+
+ if (IS_DATA_IN_FRAME(offset)) {
+ /* Transmission Header Format Identifier */
+ th_fid = hi_nibble(pd[offset]);
+ }
+ else {
+ /* If our first byte isn't here, stop dissecting */
+ return;
+ }
+
+ /* Summary information */
+ if (check_col(fd, COL_PROTOCOL))
+ col_add_str(fd, COL_PROTOCOL, "SNA");
+ if (check_col(fd, COL_INFO))
+ col_add_str(fd, COL_INFO, val_to_str(th_fid, sna_th_fid_vals, "Unknown FID: %01x"));
+
+ if (tree) {
+
+ /* Don't bother setting length. We'll set it later after we find
+ * the lengths of TH/RH/RU */
+ sna_ti = proto_tree_add_item(tree, proto_sna, offset, 0, NULL);
+ sna_tree = proto_item_add_subtree(sna_ti, ETT_SNA);
+
+ /* --- TH --- */
+ /* Don't bother setting length. We'll set it later after we find
+ * the length of TH */
+ th_ti = proto_tree_add_item(sna_tree, hf_sna_th, offset, 0, NULL);
+ th_tree = proto_item_add_subtree(th_ti, ETT_SNA_TH);
+
+ switch(th_fid) {
+ case 0x0:
+ case 0x1:
+ th_header_len = dissect_fid0_1(pd, offset, fd, th_tree);
+ break;
+ case 0x2:
+ th_header_len = dissect_fid2(pd, offset, fd, th_tree);
+ break;
+ case 0x3:
+ th_header_len = dissect_fid3(pd, offset, fd, th_tree);
+ break;
+ default:
+ dissect_data(pd, offset+1, fd, tree);
+ }
+
+ sna_header_len += th_header_len;
+ offset += th_header_len;
+
+ proto_item_set_len(th_ti, th_header_len);
+
+ /* --- RH --- */
+ if (BYTES_ARE_IN_FRAME(offset, 3)) {
+ rh_ti = proto_tree_add_item(sna_tree, hf_sna_rh, offset, 3, NULL);
+ rh_tree = proto_item_add_subtree(rh_ti, ETT_SNA_RH);
+ dissect_rh(pd, offset, fd, rh_tree);
+ sna_header_len += 3;
+ offset += 3;
+ }
+ else {
+ /* If our first byte isn't here, stop dissecting */
+ return;
+ }
+
+ proto_item_set_len(sna_ti, sna_header_len);
+
+ }
+ if (IS_DATA_IN_FRAME(offset+1)) {
+ dissect_data(pd, offset, fd, tree);
+ }
+}
+
+/* FID Types 0 and 1 */
+static int
+dissect_fid0_1 (const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
+
+ proto_tree *bf_tree;
+ proto_item *bf_item;
+ guint8 th_0;
+ guint16 daf, oaf, snf, dcf;
+
+ static int bytes_in_header = 10;
+
+ if (!BYTES_ARE_IN_FRAME(offset, bytes_in_header)) {
+ return 0;
+ }
+
+ th_0 = pd[offset+0];
+ daf = pntohs(&pd[offset+2]);
+ oaf = pntohs(&pd[offset+4]);
+ snf = pntohs(&pd[offset+6]);
+ dcf = pntohs(&pd[offset+8]);
+
+ /* Create the bitfield tree */
+ bf_item = proto_tree_add_item(tree, hf_sna_th_0, offset, 1, th_0);
+ bf_tree = proto_item_add_subtree(bf_item, ETT_SNA_TH_FID);
+
+ proto_tree_add_item(bf_tree, hf_sna_th_fid, offset, 1, th_0);
+ proto_tree_add_item(bf_tree, hf_sna_th_mpf, offset, 1, th_0);
+ proto_tree_add_item(bf_tree, hf_sna_th_efi ,offset, 1, th_0);
+
+ proto_tree_add_text(tree, offset+1, 1, "Reserved");
+ proto_tree_add_item(tree, hf_sna_th_daf ,offset+2, 1, daf);
+ proto_tree_add_item(tree, hf_sna_th_oaf ,offset+4, 1, oaf);
+ proto_tree_add_item(tree, hf_sna_th_snf ,offset+6, 2, snf);
+ proto_tree_add_item(tree, hf_sna_th_dcf ,offset+8, 2, dcf);
+
+ if (check_col(fd, COL_RES_DL_DST))
+ col_add_fstr(fd, COL_RES_DL_DST, "%02X", daf);
+ if (check_col(fd, COL_RES_DL_SRC))
+ col_add_fstr(fd, COL_RES_DL_SRC, "%02X", oaf);
+
+ return bytes_in_header;
+
+}
+
+
+/* FID Type 2 */
+static int
+dissect_fid2 (const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
+
+ proto_tree *bf_tree;
+ proto_item *bf_item;
+ guint8 th_0, daf, oaf;
+ guint16 snf;
+
+ static int bytes_in_header = 6;
+
+ if (!BYTES_ARE_IN_FRAME(offset, bytes_in_header)) {
+ return 0;
+ }
+
+ th_0 = pd[offset+0];
+ daf = pd[offset+2];
+ oaf = pd[offset+3];
+
+ snf = pntohs(&pd[offset+4]);
+
+ /* Create the bitfield tree */
+ bf_item = proto_tree_add_item(tree, hf_sna_th_0, offset, 1, th_0);
+ bf_tree = proto_item_add_subtree(bf_item, ETT_SNA_TH_FID);
+
+ proto_tree_add_item(bf_tree, hf_sna_th_fid, offset, 1, th_0);
+ proto_tree_add_item(bf_tree, hf_sna_th_mpf, offset, 1, th_0);
+ proto_tree_add_item(bf_tree, hf_sna_th_odai ,offset, 1, th_0);
+ proto_tree_add_item(bf_tree, hf_sna_th_efi ,offset, 1, th_0);
+
+ proto_tree_add_text(tree, offset+1, 1, "Reserved");
+ proto_tree_add_item(tree, hf_sna_th_daf ,offset+2, 1, daf);
+ proto_tree_add_item(tree, hf_sna_th_oaf ,offset+3, 1, oaf);
+ proto_tree_add_item(tree, hf_sna_th_snf ,offset+4, 2, snf);
+
+ if (check_col(fd, COL_RES_DL_DST))
+ col_add_fstr(fd, COL_RES_DL_DST, "%02X", daf);
+ if (check_col(fd, COL_RES_DL_SRC))
+ col_add_fstr(fd, COL_RES_DL_SRC, "%02X", oaf);
+
+ return bytes_in_header;
+}
+
+/* FID Type 3 */
+static int
+dissect_fid3 (const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
+
+ proto_tree *bf_tree;
+ proto_item *bf_item;
+ guint8 th_0;
+ guint8 lsid;
+
+ static int bytes_in_header = 2;
+
+ if (!BYTES_ARE_IN_FRAME(offset, bytes_in_header)) {
+ return 0;
+ }
+
+ th_0 = pd[offset+0];
+ lsid = pd[offset+1];
+
+ /* Create the bitfield tree */
+ bf_item = proto_tree_add_item(tree, hf_sna_th_0, offset, 1, th_0);
+ bf_tree = proto_item_add_subtree(bf_item, ETT_SNA_TH_FID);
+
+ proto_tree_add_item(bf_tree, hf_sna_th_fid, offset, 1, th_0);
+ proto_tree_add_item(bf_tree, hf_sna_th_mpf, offset, 1, th_0);
+ proto_tree_add_item(bf_tree, hf_sna_th_efi ,offset, 1, th_0);
+
+ proto_tree_add_item(tree, hf_sna_th_lsid ,offset+1, 1, lsid);
+
+ return bytes_in_header;
+}
+
+/* RH */
+static void
+dissect_rh (const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
+
+ proto_tree *bf_tree;
+ proto_item *bf_item;
+ gboolean is_response;
+ guint8 rh_0, rh_1, rh_2;
+
+ rh_0 = pd[offset+0];
+ rh_1 = pd[offset+1];
+ rh_2 = pd[offset+2];
+
+ is_response = (rh_0 & 0x80);
+
+ /* Create the bitfield tree for byte 0*/
+ bf_item = proto_tree_add_item(tree, hf_sna_rh_0, offset, 1, rh_0);
+ bf_tree = proto_item_add_subtree(bf_item, ETT_SNA_RH_0);
+
+ proto_tree_add_item(bf_tree, hf_sna_rh_rri, offset, 1, rh_0);
+ proto_tree_add_item(bf_tree, hf_sna_rh_ru_category, offset, 1, rh_0);
+ proto_tree_add_item(bf_tree, hf_sna_rh_fi, offset, 1, rh_0);
+ proto_tree_add_item(bf_tree, hf_sna_rh_sdi, offset, 1, rh_0);
+ if (is_response) {
+ proto_tree_add_item(bf_tree, hf_sna_rh_bci, offset, 1, rh_0);
+ proto_tree_add_item(bf_tree, hf_sna_rh_eci, offset, 1, rh_0);
+ }
+
+ offset += 1;
+
+ /* Create the bitfield tree for byte 1*/
+ bf_item = proto_tree_add_item(tree, hf_sna_rh_1, offset, 1, rh_1);
+ bf_tree = proto_item_add_subtree(bf_item, ETT_SNA_RH_1);
+
+ proto_tree_add_item(bf_tree, hf_sna_rh_dr1, offset, 1, rh_1);
+
+ if (!is_response) {
+ proto_tree_add_item(bf_tree, hf_sna_rh_lcci, offset, 1, rh_1);
+ }
+
+ proto_tree_add_item(bf_tree, hf_sna_rh_dr2, offset, 1, rh_1);
+
+ if (is_response) {
+ proto_tree_add_item(bf_tree, hf_sna_rh_rti, offset, 1, rh_1);
+ }
+ else {
+ proto_tree_add_item(bf_tree, hf_sna_rh_eri, offset, 1, rh_1);
+ proto_tree_add_item(bf_tree, hf_sna_rh_rlwi, offset, 1, rh_1);
+ }
+
+ proto_tree_add_item(bf_tree, hf_sna_rh_qri, offset, 1, rh_1);
+ proto_tree_add_item(bf_tree, hf_sna_rh_pi, offset, 1, rh_1);
+
+ offset += 1;
+
+ /* Create the bitfield tree for byte 2*/
+ bf_item = proto_tree_add_item(tree, hf_sna_rh_2, offset, 1, rh_2);
+
+ if (!is_response) {
+ bf_tree = proto_item_add_subtree(bf_item, ETT_SNA_RH_2);
+
+ proto_tree_add_item(bf_tree, hf_sna_rh_bbi, offset, 1, rh_2);
+ proto_tree_add_item(bf_tree, hf_sna_rh_ebi, offset, 1, rh_2);
+ proto_tree_add_item(bf_tree, hf_sna_rh_cdi, offset, 1, rh_2);
+ proto_tree_add_item(bf_tree, hf_sna_rh_csi, offset, 1, rh_2);
+ proto_tree_add_item(bf_tree, hf_sna_rh_edi, offset, 1, rh_2);
+ proto_tree_add_item(bf_tree, hf_sna_rh_pdi, offset, 1, rh_2);
+ proto_tree_add_item(bf_tree, hf_sna_rh_cebi, offset, 1, rh_2);
+ }
+
+ /* XXX - check for sdi. If TRUE, the next 4 bytes will be sense data */
+}
+
+void
+proto_register_sna(void)
+{
+ static hf_register_info hf[] = {
+ { &hf_sna_th,
+ { "Transmission Header", "sna.th", FT_NONE, BASE_NONE, NULL, 0x0,
+ "" }},
+
+ { &hf_sna_th_0,
+ { "Transmission Header Byte 0", "sna.th.0", FT_UINT8, BASE_HEX, NULL, 0x0,
+ "Byte 0 of Tranmission Header contains FID, MPF, ODAI,"
+ " and EFI as bitfields." }},
+
+ { &hf_sna_th_fid,
+ { "Format Identifer", "sna.th.fid", FT_UINT8, BASE_HEX, VALS(sna_th_fid_vals), 0xf0,
+ "Format Identification" }},
+
+ { &hf_sna_th_mpf,
+ { "Mapping Field", "sna.th.mpf", FT_UINT8, BASE_NONE, VALS(sna_th_mpf_vals), 0x0c,
+ "The Mapping Field specifies whether the information field"
+ " associated with the TH is a complete or partial BIU." }},
+
+ { &hf_sna_th_odai,
+ { "ODAI Assignment Indicator", "sna.th.odai", FT_UINT8, BASE_DEC, NULL, 0x02,
+ "The ODAI indicates which node assigned the OAF'-DAF' values"
+ " carried in the TH." }},
+
+ { &hf_sna_th_efi,
+ { "Expedited Flow Indicator", "sna.th.efi", FT_UINT8, BASE_DEC, VALS(sna_th_efi_vals), 0x01,
+ "The EFI designates whether the PIU belongs to the normal"
+ " or expedited flow." }},
+
+ { &hf_sna_th_daf,
+ { "Destination Address Field", "sna.th.daf", FT_UINT16, BASE_HEX, NULL, 0x0,
+ "" }},
+
+ { &hf_sna_th_oaf,
+ { "Origin Address Field", "sna.th.oaf", FT_UINT16, BASE_HEX, NULL, 0x0,
+ "" }},
+
+ { &hf_sna_th_snf,
+ { "Sequence Number Field", "sna.th.snf", FT_UINT16, BASE_NONE, NULL, 0x0,
+ "The Sequence Number Field contains a numerical identifier for"
+ " the associated BIU."}},
+
+ { &hf_sna_th_dcf,
+ { "Data Count Field", "sna.th.dcf", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "A binary count of the number of bytes in the BIU or BIU segment associated "
+ "with the tranmission header. The count does not include any of the bytes "
+ "in the transmission header."}},
+
+ { &hf_sna_th_lsid,
+ { "Local Session Identification", "sna.th.lsid", FT_UINT8, BASE_HEX, NULL, 0x0,
+ "" }},
+
+ { &hf_sna_rh,
+ { "Request/Response Header", "sna.rh", FT_NONE, BASE_NONE, NULL, 0x0,
+ "" }},
+
+ { &hf_sna_rh_0,
+ { "Request/Response Header Byte 0", "sna.rh.0", FT_UINT8, BASE_HEX, NULL, 0x0,
+ "" }},
+
+ { &hf_sna_rh_1,
+ { "Request/Response Header Byte 1", "sna.rh.1", FT_UINT8, BASE_HEX, NULL, 0x0,
+ "" }},
+
+ { &hf_sna_rh_2,
+ { "Request/Response Header Byte 2", "sna.rh.2", FT_UINT8, BASE_HEX, NULL, 0x0,
+ "" }},
+
+ { &hf_sna_rh_rri,
+ { "Request/Response Indicator", "sna.rh.rri", FT_UINT8, BASE_DEC, VALS(sna_rh_rri_vals), 0x80,
+ "Denotes whether this is a request or a response." }},
+
+ { &hf_sna_rh_ru_category,
+ { "Request/Response Unit Category", "sna.rh.ru_category", FT_UINT8, BASE_HEX,
+ VALS(sna_rh_ru_category_vals), 0x60,
+ "" }},
+
+ { &hf_sna_rh_fi,
+ { "Format Indicator", "sna.rh.fi", FT_BOOLEAN, 8, TFS(&sna_rh_fi_truth), 0x08,
+ "" }},
+
+ { &hf_sna_rh_sdi,
+ { "Sense Data Included", "sna.rh.sdi", FT_BOOLEAN, 8, TFS(&sna_rh_sdi_truth), 0x04,
+ "Indicates that a 4-byte sense data field is included in the associated RU." }},
+
+ { &hf_sna_rh_bci,
+ { "Begin Chain Indicator", "sna.rh.bci", FT_BOOLEAN, 8, TFS(&sna_rh_bci_truth), 0x02,
+ "" }},
+
+ { &hf_sna_rh_eci,
+ { "End Chain Indicator", "sna.rh.eci", FT_BOOLEAN, 8, TFS(&sna_rh_eci_truth), 0x01,
+ "" }},
+
+ { &hf_sna_rh_dr1,
+ { "Definite Response 1 Indicator", "sna.rh.dr1", FT_BOOLEAN, 8, NULL, 0x80,
+ "" }},
+
+ { &hf_sna_rh_lcci,
+ { "Length-Checked Compression Indicator", "sna.rh.lcci", FT_BOOLEAN, 8,
+ TFS(&sna_rh_lcci_truth), 0x40,
+ "" }},
+
+ { &hf_sna_rh_dr2,
+ { "Definite Response 2 Indicator", "sna.rh.dr2", FT_BOOLEAN, 8, NULL, 0x20,
+ "" }},
+
+ { &hf_sna_rh_eri,
+ { "Exception Response Indicator", "sna.rh.eri", FT_BOOLEAN, 8, NULL, 0x10,
+ "Used in conjunction with DR1I and DR2I to indicate, in a request, "
+ "the form of response requested." }},
+
+ { &hf_sna_rh_rti,
+ { "Response Type Indicator", "sna.rh.rti", FT_BOOLEAN, 8, TFS(&sna_rh_rti_truth), 0x10,
+ "" }},
+
+ { &hf_sna_rh_rlwi,
+ { "Request Larger Window Indicator", "sna.rh.rlwi", FT_BOOLEAN, 8, NULL, 0x04,
+ "Indicates whether a larger pacing window was requested." }},
+
+ { &hf_sna_rh_qri,
+ { "Queued Response Indicator", "sna.rh.qri", FT_BOOLEAN, 8, TFS(&sna_rh_qri_truth), 0x02,
+ "" }},
+
+ { &hf_sna_rh_pi,
+ { "Pacing Indicator", "sna.rh.pi", FT_BOOLEAN, 8, NULL, 0x01,
+ "" }},
+
+ { &hf_sna_rh_bbi,
+ { "Begin Bracket Indicator", "sna.rh.bbi", FT_BOOLEAN, 8, NULL, 0x80,
+ "" }},
+
+ { &hf_sna_rh_ebi,
+ { "End Bracket Indicator", "sna.rh.ebi", FT_BOOLEAN, 8, NULL, 0x40,
+ "" }},
+
+ { &hf_sna_rh_cdi,
+ { "Change Direction Indicator", "sna.rh.cdi", FT_BOOLEAN, 8, NULL, 0x20,
+ "" }},
+
+ { &hf_sna_rh_csi,
+ { "Code Selection Indicator", "sna.rh.csi", FT_BOOLEAN, 8, VALS(sna_rh_csi_vals), 0x08,
+ "Specifies the encoding used for the associated FMD RU." }},
+
+ { &hf_sna_rh_edi,
+ { "Enciphered Data Indicator", "sna.rh.edi", FT_BOOLEAN, 8, NULL, 0x04,
+ "Indicates that information in the associated RU is enciphered under "
+ "session-level cryptography protocols." }},
+
+ { &hf_sna_rh_pdi,
+ { "Padded Data Indicator", "sna.rh.pdi", FT_BOOLEAN, 8, NULL, 0x02,
+ "Indicates that the RU was padded at the end, before encipherment, to the next "
+ "integral multiple of 8 bytes." }},
+
+ { &hf_sna_rh_cebi,
+ { "Conditional End Bracket Indicator", "sna.rh.cebi", FT_BOOLEAN, 8, NULL, 0x01,
+ "Used to indicate the beginning or end of a group of exchanged "
+ "requests and responses called a bracket. Only used on LU-LU sessions." }},
+
+ { &hf_sna_ru,
+ { "Request/Response Unit", "sna.ru", FT_NONE, BASE_NONE, NULL, 0x0,
+ ""}},
+ };
+
+ proto_sna = proto_register_protocol("Systems Network Architecture", "sna");
+ proto_register_field_array(proto_sna, hf, array_length(hf));
+}
+
diff --git a/packet-tcp.c b/packet-tcp.c
index 672110f857..a3c0f8166e 100644
--- a/packet-tcp.c
+++ b/packet-tcp.c
@@ -1,7 +1,7 @@
/* packet-tcp.c
* Routines for TCP packet disassembly
*
- * $Id: packet-tcp.c,v 1.33 1999/09/17 05:56:56 guy Exp $
+ * $Id: packet-tcp.c,v 1.34 1999/10/12 06:20:17 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -528,19 +528,24 @@ proto_register_tcp(void)
static hf_register_info hf[] = {
{ &hf_tcp_srcport,
- { "Source Port", "tcp.srcport", FT_UINT16, NULL }},
+ { "Source Port", "tcp.srcport", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_tcp_dstport,
- { "Destination Port", "tcp.dstport", FT_UINT16, NULL }},
+ { "Destination Port", "tcp.dstport", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_tcp_port,
- { "Source or Destination Port", "tcp.port", FT_UINT16, NULL }},
+ { "Source or Destination Port", "tcp.port", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_tcp_seq,
- { "Sequence number", "tcp.seq", FT_UINT32, NULL }},
+ { "Sequence number", "tcp.seq", FT_UINT32, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_tcp_ack,
- { "Acknowledgement number", "tcp.ack", FT_UINT32, NULL }},
+ { "Acknowledgement number", "tcp.ack", FT_UINT32, BASE_DEC, NULL, 0x0,
+ "" }},
};
proto_tcp = proto_register_protocol ("Transmission Control Protocol", "tcp");
diff --git a/packet-tr.c b/packet-tr.c
index 6890aa2697..c1c1227791 100644
--- a/packet-tr.c
+++ b/packet-tr.c
@@ -2,7 +2,7 @@
* Routines for Token-Ring packet disassembly
* Gilbert Ramirez <gram@verdict.uthscsa.edu>
*
- * $Id: packet-tr.c,v 1.28 1999/09/22 05:40:12 gram Exp $
+ * $Id: packet-tr.c,v 1.29 1999/10/12 06:20:18 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@@ -59,11 +59,7 @@ static int hf_tr_rif_bridge = -1;
#define TR_MIN_HEADER_LEN 14
#define TR_MAX_HEADER_LEN 32
-static const value_string ac_vals[] = {
- { 0, "Token" },
- { 0x10, "Frame" },
- { 0, NULL }
-};
+static const true_false_string ac_truth = { "Frame", "Token" };
static const value_string pcf_vals[] = {
{ 0, "Normal buffer" },
@@ -78,8 +74,8 @@ static const value_string pcf_vals[] = {
static const value_string frame_vals[] = {
{ 0, "MAC" },
- { 64, "LLC" },
- { 128, "Reserved" },
+ { 1, "LLC" },
+ { 2, "Reserved" },
{ 0, NULL },
};
@@ -419,33 +415,20 @@ dissect_tr(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
tr_tree = proto_item_add_subtree(ti, ETT_TOKEN_RING);
/* Create the Access Control bitfield tree */
- ti = proto_tree_add_item_format(tr_tree, hf_tr_ac, offset, 1, trn_ac,
- "Access Control (0x%02x)", trn_ac);
+ ti = proto_tree_add_item(tr_tree, hf_tr_ac, offset, 1, trn_ac);
bf_tree = proto_item_add_subtree(ti, ETT_TOKEN_RING_AC);
- proto_tree_add_item_format(bf_tree, hf_tr_priority, offset, 1, trn_ac & 0xe0,
- decode_numeric_bitfield(trn_ac, 0xe0, 8, "Priority = %d"));
-
- proto_tree_add_item_format(bf_tree, hf_tr_frame, offset, 1, trn_ac & 0x10,
- decode_enumerated_bitfield(trn_ac, 0x10, 8, ac_vals, "%s"));
-
- proto_tree_add_item_format(bf_tree, hf_tr_monitor_cnt, offset, 1, trn_ac & 0x08,
- decode_numeric_bitfield(trn_ac, 0x08, 8, "Monitor Count"));
-
- proto_tree_add_item_format(bf_tree, hf_tr_priority_reservation, offset, 1, trn_ac & 0x07,
- decode_numeric_bitfield(trn_ac, 0x07, 8, "Priority Reservation = %d"));
+ proto_tree_add_item(bf_tree, hf_tr_priority, offset, 1, trn_ac);
+ proto_tree_add_item(bf_tree, hf_tr_frame, offset, 1, trn_ac);
+ proto_tree_add_item(bf_tree, hf_tr_monitor_cnt, offset, 1, trn_ac);
+ proto_tree_add_item(bf_tree, hf_tr_priority_reservation, offset, 1, trn_ac);
/* Create the Frame Control bitfield tree */
- ti = proto_tree_add_item_format(tr_tree, hf_tr_fc, offset + 1, 1, trn_fc,
- "Frame Control (0x%02x)", trn_fc);
+ ti = proto_tree_add_item(tr_tree, hf_tr_fc, offset + 1, 1, trn_fc);
bf_tree = proto_item_add_subtree(ti, ETT_TOKEN_RING_FC);
- proto_tree_add_item_format(bf_tree, hf_tr_fc_type, offset + 1, 1, trn_fc & 0xc0,
- decode_enumerated_bitfield(trn_fc, 0xc0, 8, frame_vals, "%s"));
-
- proto_tree_add_item_format(bf_tree, hf_tr_fc_pcf, offset + 1, 1, trn_fc & 0x0f,
- decode_enumerated_bitfield(trn_fc, 0x0f, 8, pcf_vals, "%s"));
-
+ proto_tree_add_item(bf_tree, hf_tr_fc_type, offset + 1, 1, trn_fc);
+ proto_tree_add_item(bf_tree, hf_tr_fc_pcf, offset + 1, 1, trn_fc);
proto_tree_add_item(tr_tree, hf_tr_dst, offset + 2, 6, trn_dhost);
proto_tree_add_item(tr_tree, hf_tr_src, offset + 8, 6, trn_shost);
@@ -557,58 +540,78 @@ proto_register_tr(void)
{
static hf_register_info hf[] = {
{ &hf_tr_ac,
- { "Access Control", "tr.ac", FT_UINT8, NULL }},
+ { "Access Control", "tr.ac", FT_UINT8, BASE_HEX, NULL, 0x0,
+ "" }},
{ &hf_tr_priority,
- { "Priority", "tr.priority", FT_UINT8, NULL }},
+ { "Priority", "tr.priority", FT_UINT8, BASE_DEC, NULL, 0xe0,
+ "" }},
{ &hf_tr_frame,
- { "Frame", "tr.frame", FT_VALS_UINT8, VALS(ac_vals) }},
+ { "Frame", "tr.frame", FT_BOOLEAN, 8, TFS(&ac_truth), 0x10,
+ "" }},
{ &hf_tr_monitor_cnt,
- { "Monitor Count", "tr.monitor_cnt", FT_UINT8, NULL }},
+ { "Monitor Count", "tr.monitor_cnt", FT_UINT8, BASE_DEC, NULL, 0x08,
+ "" }},
{ &hf_tr_priority_reservation,
- { "Priority Reservation","tr.priority_reservation", FT_UINT8, NULL }},
+ { "Priority Reservation","tr.priority_reservation", FT_UINT8, BASE_DEC, NULL, 0x07,
+ "" }},
{ &hf_tr_fc,
- { "Frame Control", "tr.fc", FT_UINT8, NULL }},
+ { "Frame Control", "tr.fc", FT_UINT8, BASE_HEX, NULL, 0x0,
+ "" }},
{ &hf_tr_fc_type,
- { "Frame Type", "tr.frame_type", FT_VALS_UINT8, VALS(frame_vals) }},
+ { "Frame Type", "tr.frame_type", FT_UINT8, BASE_DEC, VALS(frame_vals), 0xc0,
+ "" }},
{ &hf_tr_fc_pcf,
- { "Frame PCF", "tr.frame_pcf", FT_VALS_UINT8, VALS(pcf_vals) }},
+ { "Frame PCF", "tr.frame_pcf", FT_UINT8, BASE_DEC, VALS(pcf_vals), 0x0f,
+ "" }},
{ &hf_tr_dst,
- { "Destination", "tr.dst", FT_ETHER, NULL }},
+ { "Destination", "tr.dst", FT_ETHER, BASE_NONE, NULL, 0x0,
+ "Destination Hardware Address" }},
{ &hf_tr_src,
- { "Source", "tr.src", FT_ETHER, NULL }},
+ { "Source", "tr.src", FT_ETHER, BASE_NONE, NULL, 0x0,
+ "Source Hardware Address" }},
{ &hf_tr_sr,
- { "Source Routed", "tr.sr", FT_BOOLEAN, NULL }},
+ { "Source Routed", "tr.sr", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
+ "Source Routed" }},
{ &hf_tr_rif_bytes,
- { "RIF Bytes", "tr.rif_bytes", FT_UINT8, NULL }},
+ { "RIF Bytes", "tr.rif_bytes", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "Number of bytes in Routing Information Fields, including "
+ "the two bytes of Routing Control Field" }},
{ &hf_tr_broadcast,
- { "Broadcast Type", "tr.broadcast", FT_VALS_UINT8, VALS(broadcast_vals) }},
+ { "Broadcast Type", "tr.broadcast", FT_UINT8, BASE_DEC, VALS(broadcast_vals), 0x0,
+ "Type of Token-Ring Broadcast" }},
{ &hf_tr_max_frame_size,
- { "Maximum Frame Size", "tr.max_frame_size", FT_VALS_UINT8, VALS(max_frame_size_vals) }},
+ { "Maximum Frame Size", "tr.max_frame_size", FT_UINT8, BASE_DEC, VALS(max_frame_size_vals),
+ 0x0,
+ "" }},
{ &hf_tr_direction,
- { "Direction", "tr.direction", FT_VALS_UINT8, VALS(direction_vals) }},
+ { "Direction", "tr.direction", FT_UINT8, BASE_DEC, VALS(direction_vals), 0x0,
+ "Direction of RIF" }},
{ &hf_tr_rif,
- { "Ring-Bridge Pairs", "tr.rif", FT_STRING, NULL }},
+ { "Ring-Bridge Pairs", "tr.rif", FT_STRING, BASE_NONE, NULL, 0x0,
+ "String representing Ring-Bridge Pairs" }},
{ &hf_tr_rif_ring,
- { "RIF Ring", "tr.rif.ring", FT_UINT16, NULL }},
+ { "RIF Ring", "tr.rif.ring", FT_UINT16, BASE_HEX, NULL, 0x0,
+ "" }},
{ &hf_tr_rif_bridge,
- { "RIF Bridge", "tr.rif.bridge", FT_UINT8, NULL }}
+ { "RIF Bridge", "tr.rif.bridge", FT_UINT8, BASE_HEX, NULL, 0x0,
+ "" }},
};
proto_tr = proto_register_protocol("Token-Ring", "tr");
diff --git a/packet-trmac.c b/packet-trmac.c
index 07ab0c4c09..baf7c3e493 100644
--- a/packet-trmac.c
+++ b/packet-trmac.c
@@ -2,7 +2,7 @@
* Routines for Token-Ring Media Access Control
* Gilbert Ramirez <gram@verdict.uthscsa.edu>
*
- * $Id: packet-trmac.c,v 1.15 1999/09/17 04:20:23 gram Exp $
+ * $Id: packet-trmac.c,v 1.16 1999/10/12 06:20:19 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@@ -320,58 +320,76 @@ proto_register_trmac(void)
{
static hf_register_info hf[] = {
{ &hf_trmac_mv,
- { "Major Vector", "trmac.mvec", FT_VALS_UINT8, VALS(major_vector_vs) }},
+ { "Major Vector", "trmac.mvec", FT_UINT8, BASE_HEX, major_vector_vs, 0x0,
+ "" }},
{ &hf_trmac_length,
- { "Total Length", "trmac.length", FT_UINT8, NULL }},
+ { "Total Length", "trmac.length", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_trmac_srcclass,
- { "Source Class", "trmac.srcclass", FT_VALS_UINT8, VALS(classes_vs) }},
+ { "Source Class", "trmac.srcclass", FT_UINT8, BASE_HEX, classes_vs, 0x0,
+ "" }},
{ &hf_trmac_dstclass,
- { "Destination Class", "trmac.dstclass", FT_VALS_UINT8, VALS(classes_vs) }},
+ { "Destination Class", "trmac.dstclass", FT_UINT8, BASE_HEX, classes_vs, 0x0,
+ "" }},
{ &hf_trmac_sv,
- { "Sub-Vector", "trmac.svec", FT_UINT8, NULL }},
+ { "Sub-Vector", "trmac.svec", FT_UINT8, BASE_HEX, NULL, 0x0,
+ "" }},
{ &hf_trmac_errors_iso,
- { "Isolating Errors", "trmac.errors.iso", FT_UINT16, NULL }},
+ { "Isolating Errors", "trmac.errors.iso", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_trmac_errors_line,
- { "Line Errors", "trmac.errors.line", FT_UINT8, NULL }},
+ { "Line Errors", "trmac.errors.line", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_trmac_errors_internal,
- { "Internal Errors", "trmac.errors.internal", FT_UINT8, NULL }},
+ { "Internal Errors", "trmac.errors.internal", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_trmac_errors_burst,
- { "Burst Errors", "trmac.errors.burst", FT_UINT8, NULL }},
+ { "Burst Errors", "trmac.errors.burst", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_trmac_errors_ac,
- { "A/C Errors", "trmac.errors.ac", FT_UINT8, NULL }},
+ { "A/C Errors", "trmac.errors.ac", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_trmac_errors_abort,
- { "Abort Delimiter Transmitted Errors", "trmac.errors.abort", FT_UINT8, NULL }},
+ { "Abort Delimiter Transmitted Errors", "trmac.errors.abort", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_trmac_errors_noniso,
- { "Non-Isolating Errors", "trmac.errors.noniso", FT_UINT16, NULL }},
+ { "Non-Isolating Errors", "trmac.errors.noniso", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_trmac_errors_lost,
- { "Lost Frame Errors", "trmac.errors.lost", FT_UINT8, NULL }},
+ { "Lost Frame Errors", "trmac.errors.lost", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_trmac_errors_congestion,
- { "Receiver Congestion Errors", "trmac.errors.congestion", FT_UINT8, NULL }},
+ { "Receiver Congestion Errors", "trmac.errors.congestion", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_trmac_errors_fc,
- { "Frame-Copied Errors", "trmac.errors.fc", FT_UINT8, NULL }},
+ { "Frame-Copied Errors", "trmac.errors.fc", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_trmac_errors_freq,
- { "Frequency Errors", "trmac.errors.freq", FT_UINT8, NULL }},
+ { "Frequency Errors", "trmac.errors.freq", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_trmac_errors_token,
- { "Token Errors", "trmac.errors.token", FT_UINT8, NULL }},
+ { "Token Errors", "trmac.errors.token", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_trmac_naun,
- { "NAUN", "trmac.naun", FT_ETHER, NULL }}
+ { "NAUN", "trmac.naun", FT_ETHER, BASE_DEC, NULL, 0x0,
+ "" }},
};
proto_trmac = proto_register_protocol("Token-Ring Media Access Control", "trmac");
diff --git a/packet-udp.c b/packet-udp.c
index f06d9e91b6..23d56fb863 100644
--- a/packet-udp.c
+++ b/packet-udp.c
@@ -1,7 +1,7 @@
/* packet-udp.c
* Routines for UDP packet disassembly
*
- * $Id: packet-udp.c,v 1.25 1999/10/02 16:58:41 deniel Exp $
+ * $Id: packet-udp.c,v 1.26 1999/10/12 06:20:19 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -287,19 +287,24 @@ proto_register_udp(void)
{
static hf_register_info hf[] = {
{ &hf_udp_srcport,
- { "Source Port", "udp.srcport", FT_UINT16, NULL }},
+ { "Source Port", "udp.srcport", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_udp_dstport,
- { "Destination Port", "udp.dstport", FT_UINT16, NULL }},
+ { "Destination Port", "udp.dstport", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_udp_port,
- { "Source or Destination Port", "udp.port", FT_UINT16, NULL }},
+ { "Source or Destination Port", "udp.port", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_udp_length,
- { "Length", "udp.length", FT_UINT16, NULL }},
+ { "Length", "udp.length", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_udp_checksum,
- { "Checksum", "udp.checksum", FT_UINT16, NULL }}
+ { "Checksum", "udp.checksum", FT_UINT16, BASE_HEX, NULL, 0x0,
+ "" }},
};
proto_udp = proto_register_protocol("User Datagram Protocol", "udp");
diff --git a/packet-x25.c b/packet-x25.c
index 631c6d57be..48f7b67c92 100644
--- a/packet-x25.c
+++ b/packet-x25.c
@@ -2,7 +2,7 @@
* Routines for x25 packet disassembly
* Olivier Abad <abad@daba.dhis.org>
*
- * $Id: packet-x25.c,v 1.6 1999/09/12 18:37:00 guy Exp $
+ * $Id: packet-x25.c,v 1.7 1999/10/12 06:20:20 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -1448,9 +1448,12 @@ proto_register_x25(void)
{
static hf_register_info hf[] = {
{ &hf_x25_lcn,
- { "Logical Channel", "x25.lcn", FT_UINT16, NULL} },
+ { "Logical Channel", "x25.lcn", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "" } },
+
{ &hf_x25_type,
- { "Packet Type", "x25.type", FT_STRING, NULL} },
+ { "Packet Type", "x25.type", FT_STRING, BASE_NONE, NULL, 0x0,
+ "" } },
};
proto_x25 = proto_register_protocol ("X.25", "x25");
diff --git a/packet.c b/packet.c
index dcf12ec83e..8c7e3af8c7 100644
--- a/packet.c
+++ b/packet.c
@@ -1,7 +1,7 @@
/* packet.c
* Routines for packet disassembly
*
- * $Id: packet.c,v 1.45 1999/09/29 22:19:12 guy Exp $
+ * $Id: packet.c,v 1.46 1999/10/12 06:20:21 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -517,7 +517,7 @@ match_strval(guint32 val, const value_string *vs) {
/* Generate, into "buf", a string showing the bits of a bitfield.
Return a pointer to the character after that string. */
-static char *
+char *
decode_bitfield_value(char *buf, guint32 val, guint32 mask, int width)
{
int i;
@@ -728,19 +728,25 @@ proto_register_frame(void)
{
static hf_register_info hf[] = {
{ &hf_frame_arrival_time,
- { "Arrival Time", "frame.time", FT_ABSOLUTE_TIME, NULL }},
+ { "Arrival Time", "frame.time", FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0x0,
+ ""}},
{ &hf_frame_time_delta,
- { "Time delta from previous packet", "frame.time_delta", FT_RELATIVE_TIME, NULL }},
+ { "Time delta from previous packet", "frame.time_delta", FT_RELATIVE_TIME, BASE_NONE, NULL,
+ 0x0,
+ "" }},
{ &hf_frame_number,
- { "Frame Number", "frame.number", FT_UINT32, NULL }},
+ { "Frame Number", "frame.number", FT_UINT32, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_frame_packet_len,
- { "Total Frame Length", "frame.pkt_len", FT_UINT32, NULL }},
+ { "Total Frame Length", "frame.pkt_len", FT_UINT32, BASE_DEC, NULL, 0x0,
+ "" }},
{ &hf_frame_capture_len,
- { "Capture Frame Length", "frame.cap_len", FT_UINT32, NULL }}
+ { "Capture Frame Length", "frame.cap_len", FT_UINT32, BASE_DEC, NULL, 0x0,
+ "" }},
};
proto_frame = proto_register_protocol("Frame", "frame");
diff --git a/packet.h b/packet.h
index 0e25460676..63508ff4d1 100644
--- a/packet.h
+++ b/packet.h
@@ -1,7 +1,7 @@
/* packet.h
* Definitions for packet disassembly structures and routines
*
- * $Id: packet.h,v 1.103 1999/10/10 11:50:45 sharpe Exp $
+ * $Id: packet.h,v 1.104 1999/10/12 06:20:22 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -146,6 +146,13 @@ typedef struct _value_string {
gchar *strptr;
} value_string;
+/* Struct for boolean enumerations */
+typedef struct true_false_string {
+ char *true_string;
+ char *false_string;
+} true_false_string;
+
+
/* Many of the structs and definitions below and in packet-*.c files
* were taken from include files in the Linux distribution. */
@@ -343,6 +350,14 @@ enum {
ETT_IPP,
ETT_IPP_AS,
ETT_IPP_ATTR,
+ ETT_SNA,
+ ETT_SNA_TH,
+ ETT_SNA_TH_FID,
+ ETT_SNA_RH,
+ ETT_SNA_RH_0,
+ ETT_SNA_RH_1,
+ ETT_SNA_RH_2,
+ ETT_SNA_RU,
NUM_TREE_TYPES /* last item number plus one */
};
@@ -363,6 +378,7 @@ int get_token_len(const u_char *linep, const u_char *lineend,
gchar* format_text(const u_char *line, int len);
gchar* val_to_str(guint32, const value_string *, const char *);
gchar* match_strval(guint32, const value_string*);
+char * decode_bitfield_value(char *buf, guint32 val, guint32 mask, int width);
const char *decode_boolean_bitfield(guint32 val, guint32 mask, int width,
const char *truedesc, const char *falsedesc);
const char *decode_enumerated_bitfield(guint32 val, guint32 mask, int width,
@@ -430,6 +446,8 @@ void dissect_raw(const u_char *, frame_data *, proto_tree *);
*/
void dissect_fddi(const u_char *, frame_data *, proto_tree *, gboolean);
+typedef void (*DissectFunc) (const u_char*, int, frame_data*, proto_tree*);
+
/*
* Routines in packet-*.c
* Routines should take four args: packet data *, offset, frame_data *,
@@ -482,6 +500,7 @@ void dissect_rip(const u_char *, int, frame_data *, proto_tree *);
void dissect_rsvp(const u_char *, int, frame_data *, proto_tree *);
void dissect_rtsp(const u_char *, int, frame_data *, proto_tree *);
void dissect_sdp(const u_char *, int, frame_data *, proto_tree *);
+void dissect_sna(const u_char *, int, frame_data *, proto_tree *);
void dissect_snmp(const u_char *, int, frame_data *, proto_tree *);
void dissect_tcp(const u_char *, int, frame_data *, proto_tree *);
void dissect_telnet(const u_char *, int, frame_data *, proto_tree *);
diff --git a/proto.c b/proto.c
index 4550814078..7fb49e49dc 100644
--- a/proto.c
+++ b/proto.c
@@ -1,7 +1,7 @@
/* proto.c
* Routines for protocol tree
*
- * $Id: proto.c,v 1.34 1999/10/12 04:21:12 gram Exp $
+ * $Id: proto.c,v 1.35 1999/10/12 06:20:23 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -81,6 +81,16 @@ static proto_item *
proto_tree_add_item_value(proto_tree *tree, int hfindex, gint start,
gint length, int include_format, int visible, va_list ap);
+static void fill_label_boolean(field_info *fi, gchar *label_str);
+static void fill_label_uint(field_info *fi, gchar *label_str);
+static void fill_label_enumerated_uint(field_info *fi, gchar *label_str);
+static void fill_label_enumerated_bitfield(field_info *fi, gchar *label_str);
+static void fill_label_numeric_bitfield(field_info *fi, gchar *label_str);
+
+static int hfinfo_bitwidth(header_field_info *hfinfo);
+static char* hfinfo_uint_vals_format(header_field_info *hfinfo);
+static char* hfinfo_uint_format(header_field_info *hfinfo);
+
static gboolean check_for_protocol_or_field_id(GNode *node, gpointer data);
static gboolean check_for_field_within_protocol(GNode *node, gpointer data);
@@ -134,6 +144,7 @@ void proto_register_rsvp(void);
void proto_register_rtsp(void);
void proto_register_sdp(void);
void proto_register_smb(void);
+void proto_register_sna(void);
#if defined(WITH_SNMP_CMU) || defined(WITH_SNMP_UCD)
void proto_register_snmp(void);
#endif
@@ -172,6 +183,12 @@ gboolean proto_tree_is_visible = TRUE;
void
proto_init(void)
{
+ static hf_register_info hf[] = {
+ { &hf_text_only,
+ { "Text", "text", FT_TEXT_ONLY, BASE_NONE, NULL, 0x0,
+ "" }},
+ };
+
if (gmc_hfinfo)
g_mem_chunk_destroy(gmc_hfinfo);
if (gmc_field_info)
@@ -242,6 +259,7 @@ proto_init(void)
proto_register_rtsp();
proto_register_sdp();
proto_register_smb();
+ proto_register_sna();
#if defined(WITH_SNMP_CMU) || defined(WITH_SNMP_UCD)
proto_register_snmp();
#endif
@@ -256,12 +274,7 @@ proto_init(void)
/* Register one special-case FT_TEXT_ONLY field for use when
converting ethereal to new-style proto_tree. These fields
are merely strings on the GUI tree; they are not filterable */
- hf_text_only = proto_register_field (
- /* name */ "Text",
- /* abbrev */ "text",
- /* ftype */ FT_TEXT_ONLY,
- /* parent */ -1,
- /* vals[] */ NULL );
+ proto_register_field_array(-1, hf, array_length(hf));
}
void
@@ -370,6 +383,7 @@ proto_tree_add_item_value(proto_tree *tree, int hfindex, gint start,
proto_item *pi;
field_info *fi;
char *junk, *format;
+ header_field_info *hfinfo;
if (!tree)
return(NULL);
@@ -386,6 +400,9 @@ proto_tree_add_item_value(proto_tree *tree, int hfindex, gint start,
fi->tree_type = ETT_NONE;
fi->visible = visible;
+ /* for convenience */
+
+ hfinfo = fi->hfinfo;
/* from the stdarg man page on Solaris 2.6:
NOTES
It is up to the calling routine to specify in some manner
@@ -400,15 +417,11 @@ NOTES
converts float arguments to double before passing them to a
function.
*/
- switch(fi->hfinfo->type) {
+ switch(hfinfo->type) {
case FT_NONE:
junk = va_arg(ap, guint8*);
break;
- case FT_BOOLEAN:
- fi->value.numeric = va_arg(ap, unsigned int) ? TRUE : FALSE;
- break;
-
case FT_BYTES:
/* This g_malloc'ed memory is freed in
proto_tree_free_node() */
@@ -416,19 +429,27 @@ NOTES
memcpy(fi->value.bytes, va_arg(ap, guint8*), length);
break;
+ case FT_BOOLEAN:
case FT_UINT8:
- case FT_VALS_UINT8:
- fi->value.numeric = va_arg(ap, unsigned int);
- break;
-
case FT_UINT16:
- case FT_VALS_UINT16:
+ case FT_UINT24:
+ case FT_UINT32:
+ case FT_INT8:
+ case FT_INT16:
+ case FT_INT24:
+ case FT_INT32:
fi->value.numeric = va_arg(ap, unsigned int);
+ if (hfinfo->bitmask) {
+ /* Mask out irrelevant portions */
+ fi->value.numeric &= hfinfo->bitmask;
+
+ /* Shift bits */
+ if (hfinfo->bitshift > 0) {
+ fi->value.numeric >>= hfinfo->bitshift;
+ }
+ }
break;
- case FT_UINT32:
- case FT_VALS_UINT24:
- case FT_VALS_UINT32:
case FT_IPv4:
case FT_IPXNET:
fi->value.numeric = va_arg(ap, unsigned int);
@@ -462,7 +483,7 @@ NOTES
break;
default:
- g_error("hfinfo->type %d not handled\n", fi->hfinfo->type);
+ g_error("hfinfo->type %d not handled\n", hfinfo->type);
break;
}
@@ -507,7 +528,20 @@ proto_item_add_subtree(proto_item *pi, gint idx) {
int
proto_register_protocol(char *name, char *abbrev)
{
- return proto_register_field(name, abbrev, FT_NONE, -1, NULL);
+ struct header_field_info *hfinfo;
+
+ /* Here we do allocate a new header_field_info struct */
+ hfinfo = g_mem_chunk_alloc(gmc_hfinfo);
+ hfinfo->name = name;
+ hfinfo->abbrev = abbrev;
+ hfinfo->type = FT_NONE;
+ hfinfo->strings = NULL;
+ hfinfo->bitmask = 0;
+ hfinfo->bitshift = 0;
+ hfinfo->blurb = "";
+ hfinfo->parent = -1; /* this field differentiates protos and fields */
+
+ return proto_register_field_init(hfinfo, hfinfo->parent);
}
/* for use with static arrays only, since we don't allocate our own copies
@@ -524,29 +558,26 @@ proto_register_field_array(int parent, hf_register_info *hf, int num_records)
}
}
-
-/* Here we do allocate a new header_field_info struct */
-int
-proto_register_field(char *name, char *abbrev, enum ftenum type, int parent,
- struct value_string* vals)
-{
- struct header_field_info *hfinfo;
-
- hfinfo = g_mem_chunk_alloc(gmc_hfinfo);
- hfinfo->name = name; /* should I g_strdup? */
- hfinfo->abbrev = abbrev; /* should I g_strdup? */
- hfinfo->type = type;
- hfinfo->vals = vals;
- hfinfo->parent = parent; /* this field differentiates protos and fields */
-
- return proto_register_field_init(hfinfo, parent);
-}
-
static int
proto_register_field_init(header_field_info *hfinfo, int parent)
{
- g_assert((hfinfo->vals == NULL) || (hfinfo->type == FT_VALS_UINT8 || hfinfo->type == FT_VALS_UINT16 ||
- hfinfo->type == FT_VALS_UINT24 || hfinfo->type == FT_VALS_UINT32));
+ /* These types of fields are allowed to have value_strings or true_false_strings */
+ g_assert((hfinfo->strings == NULL) || (
+ (hfinfo->type == FT_UINT8) ||
+ (hfinfo->type == FT_UINT16) ||
+ (hfinfo->type == FT_UINT24) ||
+ (hfinfo->type == FT_UINT32) ||
+ (hfinfo->type == FT_INT8) ||
+ (hfinfo->type == FT_INT16) ||
+ (hfinfo->type == FT_INT24) ||
+ (hfinfo->type == FT_INT32) ||
+ (hfinfo->type == FT_BOOLEAN) ));
+
+ /* if this is a bitfield, compure bitshift */
+ if (hfinfo->bitmask) {
+ while ((hfinfo->bitmask & (1 << hfinfo->bitshift)) == 0)
+ hfinfo->bitshift++;
+ }
hfinfo->parent = parent;
@@ -559,32 +590,52 @@ proto_register_field_init(header_field_info *hfinfo, int parent)
void
proto_item_fill_label(field_info *fi, gchar *label_str)
{
- char *s;
+ struct header_field_info *hfinfo = fi->hfinfo;
- switch(fi->hfinfo->type) {
+ switch(hfinfo->type) {
case FT_NONE:
snprintf(label_str, ITEM_LABEL_LENGTH,
- "%s", fi->hfinfo->name);
+ "%s", hfinfo->name);
break;
case FT_BOOLEAN:
- snprintf(label_str, ITEM_LABEL_LENGTH,
- "%s: %s", fi->hfinfo->name,
- fi->value.numeric == TRUE ? "True" : "False");
+ fill_label_boolean(fi, label_str);
break;
case FT_BYTES:
snprintf(label_str, ITEM_LABEL_LENGTH,
- "%s: %s", fi->hfinfo->name,
+ "%s: %s", hfinfo->name,
bytes_to_str(fi->value.bytes, fi->length));
break;
+ /* Four types of integers to take care of:
+ * Bitfield, with val_string
+ * Bitfield, w/o val_string
+ * Non-bitfield, with val_string
+ * Non-bitfield, w/o val_string
+ */
case FT_UINT8:
case FT_UINT16:
case FT_UINT32:
- snprintf(label_str, ITEM_LABEL_LENGTH,
- "%s: %u", fi->hfinfo->name,
- fi->value.numeric);
+ case FT_INT8:
+ case FT_INT16:
+ case FT_INT32:
+ if (hfinfo->bitmask) {
+ if (hfinfo->strings) {
+ fill_label_enumerated_bitfield(fi, label_str);
+ }
+ else {
+ fill_label_numeric_bitfield(fi, label_str);
+ }
+ }
+ else {
+ if (hfinfo->strings) {
+ fill_label_enumerated_uint(fi, label_str);
+ }
+ else {
+ fill_label_uint(fi, label_str);
+ }
+ }
break;
case FT_DOUBLE:
@@ -605,35 +656,6 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
rel_time_to_str(&fi->value.time));
break;
- case FT_VALS_UINT8:
- s = match_strval(fi->value.numeric, cVALS(fi->hfinfo->vals));
- snprintf(label_str, ITEM_LABEL_LENGTH,
- "%s: %s (0x%02x)", fi->hfinfo->name,
- (s ? s : "Unknown"), fi->value.numeric);
- break;
-
- case FT_VALS_UINT16:
- s = match_strval(fi->value.numeric, cVALS(fi->hfinfo->vals));
- snprintf(label_str, ITEM_LABEL_LENGTH,
- "%s: %s (0x%04x)", fi->hfinfo->name,
- (s ? s : "Unknown"), fi->value.numeric);
- break;
-
- case FT_VALS_UINT24:
- s = match_strval(fi->value.numeric, cVALS(fi->hfinfo->vals));
- snprintf(label_str, ITEM_LABEL_LENGTH,
- "%s: %s (0x%06x)", fi->hfinfo->name,
- (s ? s : "Unknown"), fi->value.numeric);
- break;
-
-
- case FT_VALS_UINT32:
- s = match_strval(fi->value.numeric, cVALS(fi->hfinfo->vals));
- snprintf(label_str, ITEM_LABEL_LENGTH,
- "%s: %s (0x%08x)", fi->hfinfo->name,
- (s ? s : "Unknown"), fi->value.numeric);
- break;
-
case FT_IPXNET:
snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: 0x%08X", fi->hfinfo->name, fi->value.numeric);
@@ -671,6 +693,259 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
}
}
+static void
+fill_label_boolean(field_info *fi, gchar *label_str)
+{
+ char *p = label_str;
+ int bitfield_byte_length = 0, bitwidth;
+ guint32 unshifted_value;
+
+ struct header_field_info *hfinfo = fi->hfinfo;
+ struct true_false_string default_tf = { "True", "False" };
+ struct true_false_string *tfstring = &default_tf;
+
+ if (hfinfo->strings) {
+ tfstring = (struct true_false_string*) hfinfo->strings;
+ }
+
+ if (hfinfo->bitmask) {
+ /* Figure out the bit width */
+ bitwidth = hfinfo_bitwidth(hfinfo);
+
+ /* Un-shift bits */
+ unshifted_value = fi->value.numeric;
+ if (hfinfo->bitshift > 0) {
+ unshifted_value <<= hfinfo->bitshift;
+ }
+
+ /* Create the bitfield first */
+ p = decode_bitfield_value(label_str, unshifted_value, hfinfo->bitmask, bitwidth);
+ bitfield_byte_length = p - label_str;
+ }
+
+ /* Fill in the textual info */
+ snprintf(p, ITEM_LABEL_LENGTH - bitfield_byte_length,
+ "%s: %s", hfinfo->name,
+ fi->value.numeric ? tfstring->true_string : tfstring->false_string);
+}
+
+
+/* Fills data for bitfield ints with val_strings */
+static void
+fill_label_enumerated_bitfield(field_info *fi, gchar *label_str)
+{
+ char *format = NULL, *p;
+ int bitfield_byte_length, bitwidth;
+ guint32 unshifted_value;
+
+ struct header_field_info *hfinfo = fi->hfinfo;
+
+ /* Figure out the bit width */
+ bitwidth = hfinfo_bitwidth(hfinfo);
+
+ /* Pick the proper format string */
+ format = hfinfo_uint_vals_format(hfinfo);
+
+ /* Un-shift bits */
+ unshifted_value = fi->value.numeric;
+ if (hfinfo->bitshift > 0) {
+ unshifted_value <<= hfinfo->bitshift;
+ }
+
+ /* Create the bitfield first */
+ p = decode_bitfield_value(label_str, unshifted_value, hfinfo->bitmask, bitwidth);
+ bitfield_byte_length = p - label_str;
+
+ /* Fill in the textual info using stored (shifted) value */
+ snprintf(p, ITEM_LABEL_LENGTH - bitfield_byte_length,
+ format, hfinfo->name,
+ val_to_str(fi->value.numeric, cVALS(hfinfo->strings), "Unknown"),
+ fi->value.numeric);
+}
+
+static void
+fill_label_numeric_bitfield(field_info *fi, gchar *label_str)
+{
+ char *format = NULL, *p;
+ int bitfield_byte_length, bitwidth;
+ guint32 unshifted_value;
+
+ struct header_field_info *hfinfo = fi->hfinfo;
+
+ /* Figure out the bit width */
+ bitwidth = hfinfo_bitwidth(hfinfo);
+
+ /* Pick the proper format string */
+ format = hfinfo_uint_format(hfinfo);
+
+ /* Un-shift bits */
+ unshifted_value = fi->value.numeric;
+ if (hfinfo->bitshift > 0) {
+ unshifted_value <<= hfinfo->bitshift;
+ }
+
+ /* Create the bitfield using */
+ p = decode_bitfield_value(label_str, unshifted_value, hfinfo->bitmask, bitwidth);
+ bitfield_byte_length = p - label_str;
+
+ /* Fill in the textual info using stored (shifted) value */
+ snprintf(p, ITEM_LABEL_LENGTH - bitfield_byte_length,
+ format, hfinfo->name, fi->value.numeric);
+}
+
+static void
+fill_label_enumerated_uint(field_info *fi, gchar *label_str)
+{
+ char *format = NULL;
+ struct header_field_info *hfinfo = fi->hfinfo;
+
+ /* Pick the proper format string */
+ format = hfinfo_uint_vals_format(hfinfo);
+
+ /* Fill in the textual info */
+ snprintf(label_str, ITEM_LABEL_LENGTH,
+ format, hfinfo->name,
+ val_to_str(fi->value.numeric, cVALS(hfinfo->strings), "Unknown"),
+ fi->value.numeric);
+}
+
+static void
+fill_label_uint(field_info *fi, gchar *label_str)
+{
+ char *format = NULL;
+ struct header_field_info *hfinfo = fi->hfinfo;
+
+ /* Pick the proper format string */
+ format = hfinfo_uint_format(hfinfo);
+
+ /* Fill in the textual info */
+ snprintf(label_str, ITEM_LABEL_LENGTH,
+ format, hfinfo->name, fi->value.numeric);
+}
+
+static int
+hfinfo_bitwidth(header_field_info *hfinfo)
+{
+ int bitwidth = 0;
+
+ if (!hfinfo->bitmask) {
+ return 0;
+ }
+
+ switch(hfinfo->type) {
+ case FT_UINT8:
+ case FT_INT8:
+ bitwidth = 8;
+ break;
+ case FT_UINT16:
+ case FT_INT16:
+ bitwidth = 16;
+ break;
+ case FT_UINT24:
+ case FT_INT24:
+ bitwidth = 24;
+ break;
+ case FT_UINT32:
+ case FT_INT32:
+ bitwidth = 32;
+ break;
+ case FT_BOOLEAN:
+ bitwidth = hfinfo->display; /* hacky? :) */
+ break;
+ default:
+ g_assert_not_reached();
+ ;
+ }
+ return bitwidth;
+}
+
+static char*
+hfinfo_uint_vals_format(header_field_info *hfinfo)
+{
+ char *format = NULL;
+
+ switch(hfinfo->display) {
+ case BASE_DEC:
+ case BASE_NONE:
+ case BASE_OCT: /* I'm lazy */
+ case BASE_BIN: /* I'm lazy */
+ format = "%s: %s (%u)";
+ break;
+ case BASE_HEX:
+ switch(hfinfo->type) {
+ case FT_UINT8:
+ case FT_INT8:
+ format = "%s: %s (0x%02x)";
+ break;
+ case FT_UINT16:
+ case FT_INT16:
+ format = "%s: %s (0x%04x)";
+ break;
+ case FT_UINT24:
+ case FT_INT24:
+ format = "%s: %s (0x%06x)";
+ break;
+ case FT_UINT32:
+ case FT_INT32:
+ format = "%s: %s (0x%08x)";
+ break;
+ default:
+ g_assert_not_reached();
+ ;
+ }
+ break;
+ default:
+ g_assert_not_reached();
+ ;
+ }
+ return format;
+}
+
+static char*
+hfinfo_uint_format(header_field_info *hfinfo)
+{
+ char *format = NULL;
+
+ /* Pick the proper format string */
+ switch(hfinfo->display) {
+ case BASE_DEC:
+ case BASE_NONE:
+ case BASE_OCT: /* I'm lazy */
+ case BASE_BIN: /* I'm lazy */
+ format = "%s: %u";
+ break;
+ case BASE_HEX:
+ switch(hfinfo->type) {
+ case FT_UINT8:
+ case FT_INT8:
+ format = "%s: 0x%02x";
+ break;
+ case FT_UINT16:
+ case FT_INT16:
+ format = "%s: 0x%04x";
+ break;
+ case FT_UINT24:
+ case FT_INT24:
+ format = "%s: 0x%06x";
+ break;
+ case FT_UINT32:
+ case FT_INT32:
+ format = "%s: 0x%08x";
+ break;
+ default:
+ g_assert_not_reached();
+ ;
+ }
+ break;
+ default:
+ g_assert_not_reached();
+ ;
+ }
+ return format;
+}
+
+
+
int
proto_registrar_n(void)
{
@@ -752,18 +1027,19 @@ proto_registrar_get_length(int n)
return 0;
case FT_UINT8:
- case FT_VALS_UINT8:
+ case FT_INT8:
return 1;
case FT_UINT16:
- case FT_VALS_UINT16:
+ case FT_INT16:
return 2;
- case FT_VALS_UINT24:
+ case FT_UINT24:
+ case FT_INT24:
return 3;
case FT_UINT32:
- case FT_VALS_UINT32:
+ case FT_INT32:
case FT_IPXNET:
case FT_IPv4:
return 4;
@@ -926,6 +1202,18 @@ proto_registrar_dump(void)
case FT_UINT32:
enum_name = "FT_UINT32";
break;
+ case FT_INT8:
+ enum_name = "FT_INT8";
+ break;
+ case FT_INT16:
+ enum_name = "FT_INT16";
+ break;
+ case FT_INT24:
+ enum_name = "FT_INT24";
+ break;
+ case FT_INT32:
+ enum_name = "FT_INT32";
+ break;
case FT_DOUBLE:
enum_name = "FT_DOUBLE";
break;
@@ -953,18 +1241,6 @@ proto_registrar_dump(void)
case FT_IPXNET:
enum_name = "FT_IPXNET";
break;
- case FT_VALS_UINT8:
- enum_name = "FT_VALS_UINT8";
- break;
- case FT_VALS_UINT16:
- enum_name = "FT_VALS_UINT16";
- break;
- case FT_VALS_UINT24:
- enum_name = "FT_VALS_UINT24";
- break;
- case FT_VALS_UINT32:
- enum_name = "FT_VALS_UINT32";
- break;
case FT_TEXT_ONLY:
enum_name = "FT_TEXT_ONLY";
break;
diff --git a/proto.h b/proto.h
index 13d627a8b9..2e1b45a47d 100644
--- a/proto.h
+++ b/proto.h
@@ -1,7 +1,7 @@
/* proto.h
* Definitions for protocol display
*
- * $Id: proto.h,v 1.16 1999/10/12 04:21:13 gram Exp $
+ * $Id: proto.h,v 1.17 1999/10/12 06:20:24 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -48,6 +48,8 @@ struct value_string;
* need this macro */
#define VALS(x) (struct value_string*)(x)
+/* ... and similarly, */
+#define TFS(x) (struct true_false_string*)(x)
/* field types */
enum ftenum {
@@ -55,7 +57,12 @@ enum ftenum {
FT_BOOLEAN, /* TRUE and FALSE come from <glib.h> */
FT_UINT8,
FT_UINT16,
+ FT_UINT24, /* really a UINT32, but displayed as 3 hex-digits if FD_HEX*/
FT_UINT32,
+ FT_INT8,
+ FT_INT16,
+ FT_INT24,
+ FT_INT32,
FT_DOUBLE,
FT_ABSOLUTE_TIME,
FT_RELATIVE_TIME,
@@ -65,23 +72,32 @@ enum ftenum {
FT_IPv4,
FT_IPv6,
FT_IPXNET,
- FT_VALS_UINT8,
- FT_VALS_UINT16,
- FT_VALS_UINT24,
- FT_VALS_UINT32,
FT_TEXT_ONLY, /* non-filterable, used when converting ethereal
from old-style proto_tree to new-style proto_tree */
NUM_FIELD_TYPES /* last item number plus one */
};
+enum {
+ BASE_NONE,
+ BASE_DEC,
+ BASE_HEX,
+ BASE_OCT,
+ BASE_BIN
+};
+
/* information describing a header field */
typedef struct header_field_info {
char *name;
char *abbrev;
enum ftenum type;
- struct value_string *vals;
- int id; /* assigned by order of registration */
- int parent; /* parent protocol */
+ int display; /* for integers only, so far. Base and Endianness */
+ void *strings; /* val_string or true_false_string */
+ guint32 bitmask;
+ char *blurb; /* Brief description of field. */
+
+ int id; /* assigned by registration function, not programmer */
+ int parent; /* parent protocol */
+ int bitshift; /* bits to shift */
} header_field_info;
/* Used when registering many fields at once */
@@ -90,10 +106,6 @@ typedef struct hf_register_info {
header_field_info hfinfo;
} hf_register_info;
-#ifdef WIN32
-/* 'boolean' is a reserved word on win32 */
-#define boolean truth_value
-#endif
/* Info stored in each proto_item GNode */
typedef struct field_info {
@@ -134,9 +146,16 @@ void proto_init(void);
/* Frees memory used by proto routines. Called at program shutdown */
void proto_cleanup(void);
+/* Set length of proto_item after having already been created. */
void proto_item_set_len(proto_item *ti, gint length);
+
+/* Creates new proto_tree root */
proto_tree* proto_tree_create_root(void);
+
+/* Clear memory for entry proto_tree. Clears proto_tree struct also. */
void proto_tree_free(proto_tree *tree);
+
+/* Create a subtree under an existing item; returns tree pointer */
proto_tree* proto_item_add_subtree(proto_item *ti, gint idx);
int