aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgram <gram@f5534014-38df-0310-8fa8-9805f1628bb7>1999-07-08 03:18:20 +0000
committergram <gram@f5534014-38df-0310-8fa8-9805f1628bb7>1999-07-08 03:18:20 +0000
commit2e399412e935c48b599c0b3ce9c731e5965d2d41 (patch)
tree2f9fb4d61d19686ac9ed2907a974b84604bc226e
parentb732cc733855c48a1ec9293510786a4682c0c4b4 (diff)
Documented the proto_register_field_array() function, and converted
the registration functions in packet-fddi.c and packet-eth.c to this new registration method. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@346 f5534014-38df-0310-8fa8-9805f1628bb7
-rw-r--r--doc/proto_tree19
-rw-r--r--packet-eth.c61
-rw-r--r--packet-fddi.c52
3 files changed, 46 insertions, 86 deletions
diff --git a/doc/proto_tree b/doc/proto_tree
index 4f20865272..550c1a47b2 100644
--- a/doc/proto_tree
+++ b/doc/proto_tree
@@ -101,6 +101,24 @@ during registration.
/* parent */ proto_frame,
/* vals[] */ NULL );
+Groups of header fields can be registered with one call to
+proto_register_field_array(). An const array of hf_register_info
+structs is declared, then passed to proto_register_field_array, along
+with a count of the number of records. 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:
+
+ int hf_field_a = -1;
+ int hf_field_b = -1;
+
+ const hf_register_info hf[] = {
+ { "Field A", "proto.field_a", &hf_field_a, FT_UINT8, NULL },
+ { "Field B", "proto.field_a", &hf_field_a, FT_VALS_UINT16, VALS(vs) },
+ };
+
+ 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
@@ -131,6 +149,7 @@ enum ftenum {
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 */
};
diff --git a/packet-eth.c b/packet-eth.c
index 9ee7489bcd..3d3ce12550 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.10 1999/07/07 22:51:42 gram Exp $
+ * $Id: packet-eth.c,v 1.11 1999/07/08 03:18:20 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -195,50 +195,17 @@ dissect_eth(const u_char *pd, frame_data *fd, proto_tree *tree) {
void
proto_register_eth(void)
{
- proto_eth = proto_register_protocol (
- /* name */ "Ethernet",
- /* abbrev */ "eth" );
-
- hf_eth_dst = proto_register_field (
- /* name */ "Destination",
- /* abbrev */ "eth.dst",
- /* ftype */ FT_ETHER,
- /* parent */ proto_eth,
- /* vals[] */ NULL );
-
- hf_eth_src = proto_register_field (
- /* name */ "Source",
- /* abbrev */ "eth.src",
- /* ftype */ FT_ETHER,
- /* parent */ proto_eth,
- /* vals[] */ NULL );
-
- hf_eth_dst_vendor = proto_register_field (
- /* name */ "Destination Hardware Vendor",
- /* abbrev */ "eth.dst_vendor",
- /* ftype */ FT_ETHER_VENDOR,
- /* parent */ proto_eth,
- /* vals[] */ NULL );
-
- hf_eth_src_vendor = proto_register_field (
- /* name */ "Source Hardware Vendor",
- /* abbrev */ "eth.src_vendor",
- /* ftype */ FT_ETHER_VENDOR,
- /* parent */ proto_eth,
- /* vals[] */ NULL );
-
- hf_eth_len = proto_register_field (
- /* name */ "Length",
- /* abbrev */ "eth.len",
- /* ftype */ FT_UINT16,
- /* parent */ proto_eth,
- /* vals[] */ NULL );
-
- /* registered here but handled in ethertype.c */
- hf_eth_type = proto_register_field (
- /* name */ "Type",
- /* abbrev */ "eth.type",
- /* ftype */ FT_VALS_UINT16,
- /* parent */ proto_eth,
- /* vals[] */ VALS(etype_vals) );
+ const hf_register_info hf[] = {
+ { "Destination", "eth.dst", &hf_eth_dst, FT_ETHER, NULL },
+ { "Source", "eth.src", &hf_eth_src, FT_ETHER, NULL },
+ { "Destination Hardware Vendor", "eth.dst_vendor", &hf_eth_dst_vendor, FT_ETHER, NULL },
+ { "Source Hardware Vendor", "eth.src_vendor", &hf_eth_src_vendor, FT_ETHER, NULL },
+ { "Length", "eth.len", &hf_eth_len, FT_UINT16, NULL },
+
+ /* registered here but handled in ethertype.c */
+ { "Type", "eth.type", &hf_eth_type, FT_VALS_UINT16, VALS(etype_vals) }
+ };
+
+ proto_eth = proto_register_protocol ("Ethernet", "eth" );
+ proto_register_field_array(proto_eth, hf, array_length(hf));
}
diff --git a/packet-fddi.c b/packet-fddi.c
index 147922af73..feb0cfd13c 100644
--- a/packet-fddi.c
+++ b/packet-fddi.c
@@ -3,7 +3,7 @@
*
* Laurent Deniel <deniel@worldnet.fr>
*
- * $Id: packet-fddi.c,v 1.12 1999/07/07 22:51:42 gram Exp $
+ * $Id: packet-fddi.c,v 1.13 1999/07/08 03:18:19 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -279,42 +279,16 @@ void dissect_fddi(const u_char *pd, frame_data *fd, proto_tree *tree)
void
proto_register_fddi(void)
{
- proto_fddi = proto_register_protocol (
- /* name */ "Fiber Distributed Data Interface",
- /* abbrev */ "fddi" );
-
- hf_fddi_fc = proto_register_field (
- /* name */ "Frame Control",
- /* abbrev */ "fddi.fc",
- /* ftype */ FT_UINT8,
- /* parent */ proto_fddi,
- /* vals[] */ NULL );
-
- hf_fddi_dst = proto_register_field (
- /* name */ "Destination",
- /* abbrev */ "fddi.dst",
- /* ftype */ FT_ETHER,
- /* parent */ proto_fddi,
- /* vals[] */ NULL );
-
- hf_fddi_src = proto_register_field (
- /* name */ "Source",
- /* abbrev */ "fddi.src",
- /* ftype */ FT_ETHER,
- /* parent */ proto_fddi,
- /* vals[] */ NULL );
-
- hf_fddi_dst_vendor = proto_register_field (
- /* name */ "Destination Hardware Vendor",
- /* abbrev */ "fddi.dst_vendor",
- /* ftype */ FT_ETHER_VENDOR,
- /* parent */ proto_fddi,
- /* vals[] */ NULL );
-
- hf_fddi_src_vendor = proto_register_field (
- /* name */ "Source Hardware Vendor",
- /* abbrev */ "fddi.src_vendor",
- /* ftype */ FT_ETHER_VENDOR,
- /* parent */ proto_fddi,
- /* vals[] */ NULL );
+ const hf_register_info hf[] = {
+ { "Frame Control", "fddi.fc", &hf_fddi_fc, FT_UINT8, NULL },
+ { "Destination", "fddi.dst", &hf_fddi_dst, FT_ETHER, NULL },
+ { "Source", "fddi.src", &hf_fddi_src, FT_ETHER, NULL },
+ { "Destination Hardware Vendor",
+ "fddi.dst_vendor", &hf_fddi_dst_vendor, FT_ETHER_VENDOR, NULL },
+ { "Source Hardware Vendor",
+ "fddi.src_vendor", &hf_fddi_src_vendor, FT_ETHER_VENDOR, NULL }
+ };
+
+ proto_fddi = proto_register_protocol ("Fiber Distributed Data Interface", "fddi" );
+ proto_register_field_array(proto_fddi, hf, array_length(hf));
}