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. svn path=/trunk/; revision=346
This commit is contained in:
parent
56c0587491
commit
acad5a3730
|
@ -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 */
|
||||
};
|
||||
|
||||
|
|
57
packet-eth.c
57
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" );
|
||||
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 },
|
||||
|
||||
hf_eth_dst = proto_register_field (
|
||||
/* name */ "Destination",
|
||||
/* abbrev */ "eth.dst",
|
||||
/* ftype */ FT_ETHER,
|
||||
/* parent */ proto_eth,
|
||||
/* vals[] */ NULL );
|
||||
/* registered here but handled in ethertype.c */
|
||||
{ "Type", "eth.type", &hf_eth_type, FT_VALS_UINT16, VALS(etype_vals) }
|
||||
};
|
||||
|
||||
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) );
|
||||
proto_eth = proto_register_protocol ("Ethernet", "eth" );
|
||||
proto_register_field_array(proto_eth, hf, array_length(hf));
|
||||
}
|
||||
|
|
|
@ -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" );
|
||||
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 }
|
||||
};
|
||||
|
||||
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 );
|
||||
proto_fddi = proto_register_protocol ("Fiber Distributed Data Interface", "fddi" );
|
||||
proto_register_field_array(proto_fddi, hf, array_length(hf));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue