diff options
author | wmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7> | 2008-09-26 22:07:45 +0000 |
---|---|---|
committer | wmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7> | 2008-09-26 22:07:45 +0000 |
commit | bbec7929c09f36fd4d812db41bf8cfbad15b05fd (patch) | |
tree | 5462bb9beb194a7eec24261edcbb2a50952443ce /epan | |
parent | 824ee3deb73d681f513a0d79d54d433e3eef56f4 (diff) |
Minor cleanup related to proto_register and proto_reg_handoff
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@26281 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'epan')
-rw-r--r-- | epan/dissectors/packet-egd.c | 37 | ||||
-rw-r--r-- | epan/dissectors/packet-homeplug.c | 10 | ||||
-rw-r--r-- | epan/dissectors/packet-i2c.c | 16 | ||||
-rw-r--r-- | epan/dissectors/packet-iwarp-mpa.c | 24 | ||||
-rw-r--r-- | epan/dissectors/packet-roofnet.c | 24 | ||||
-rw-r--r-- | epan/dissectors/packet-scsi.c | 3 | ||||
-rw-r--r-- | epan/dissectors/packet-tivoconnect.c | 18 | ||||
-rw-r--r-- | epan/dissectors/packet-wlccp.c | 27 | ||||
-rw-r--r-- | epan/dissectors/packet-wol.c | 41 | ||||
-rw-r--r-- | epan/dissectors/packet-xtp.c | 14 |
10 files changed, 71 insertions, 143 deletions
diff --git a/epan/dissectors/packet-egd.c b/epan/dissectors/packet-egd.c index f6f278cf2f..aead9cb86d 100644 --- a/epan/dissectors/packet-egd.c +++ b/epan/dissectors/packet-egd.c @@ -34,10 +34,10 @@ #include <epan/packet.h> /* forward reference */ -void proto_register_egd(); -void proto_reg_handoff_egd(); static void dissect_egd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree); +#define EGD_PORT 18246 /* 0x4746 */ + #define EGD_ST_NONEW 0 #define EGD_ST_NOERROR 1 #define EGD_ST_CONSUMED 2 @@ -75,7 +75,7 @@ static const value_string egd_stat_vals[] = { }; static int proto_egd = -1; -static int global_egd_port = 18246; /* 0x4746 */ + static dissector_handle_t egd_handle; static dissector_handle_t data_handle; @@ -167,32 +167,23 @@ static gint *ett[] = void proto_register_egd(void) { - if (proto_egd == -1) - { - proto_egd = proto_register_protocol ( - "Ethernet Global Data", /* name */ - "EGD", /* short name */ - "egd" /* abbrev */ - ); - proto_register_field_array(proto_egd, hf, array_length(hf)); - proto_register_subtree_array(ett, array_length(ett)); - } + proto_egd = proto_register_protocol ( + "Ethernet Global Data", /* name */ + "EGD", /* short name */ + "egd" /* abbrev */ + ); + proto_register_field_array(proto_egd, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); } void proto_reg_handoff_egd(void) { - static int initialized = FALSE; + /* find data dissector */ + data_handle = find_dissector("data"); - if (!initialized) - { - /* find data dissector */ - data_handle = find_dissector("data"); - - egd_handle = create_dissector_handle(dissect_egd, proto_egd); - dissector_add("udp.port", global_egd_port, egd_handle); - initialized = TRUE; - } + egd_handle = create_dissector_handle(dissect_egd, proto_egd); + dissector_add("udp.port", EGD_PORT, egd_handle); } diff --git a/epan/dissectors/packet-homeplug.c b/epan/dissectors/packet-homeplug.c index a775a680e0..4c54e8c218 100644 --- a/epan/dissectors/packet-homeplug.c +++ b/epan/dissectors/packet-homeplug.c @@ -820,16 +820,12 @@ dissect_homeplug(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree) ptvcursor_free(cursor); } -static dissector_handle_t homeplug_handle; void proto_reg_handoff_homeplug(void) { - static gboolean initialised = FALSE; + dissector_handle_t homeplug_handle; - if (!initialised) { - homeplug_handle = create_dissector_handle(dissect_homeplug, proto_homeplug); - dissector_add("ethertype", ETHERTYPE_HOMEPLUG, homeplug_handle); - initialised = TRUE; - } + homeplug_handle = create_dissector_handle(dissect_homeplug, proto_homeplug); + dissector_add("ethertype", ETHERTYPE_HOMEPLUG, homeplug_handle); } diff --git a/epan/dissectors/packet-i2c.c b/epan/dissectors/packet-i2c.c index 02dcfa4508..420c63f9c0 100644 --- a/epan/dissectors/packet-i2c.c +++ b/epan/dissectors/packet-i2c.c @@ -293,14 +293,10 @@ proto_register_i2c(void) void proto_reg_handoff_i2c(void) { - static gboolean inited = FALSE; - if (!inited) { - dissector_handle_t i2c_handle; - - sub_handles[SUB_DATA] = find_dissector("data"); - sub_handles[SUB_IPMB] = find_dissector("ipmi"); - i2c_handle = create_dissector_handle(dissect_i2c, proto_i2c); - dissector_add("wtap_encap", WTAP_ENCAP_I2C, i2c_handle); - inited = TRUE; - } + dissector_handle_t i2c_handle; + + sub_handles[SUB_DATA] = find_dissector("data"); + sub_handles[SUB_IPMB] = find_dissector("ipmi"); + i2c_handle = create_dissector_handle(dissect_i2c, proto_i2c); + dissector_add("wtap_encap", WTAP_ENCAP_I2C, i2c_handle); } diff --git a/epan/dissectors/packet-iwarp-mpa.c b/epan/dissectors/packet-iwarp-mpa.c index 6469a222c8..28cc9e83a9 100644 --- a/epan/dissectors/packet-iwarp-mpa.c +++ b/epan/dissectors/packet-iwarp-mpa.c @@ -119,7 +119,6 @@ static gint ett_mpa_marker = -1; /* handles of our subdissectors */ static dissector_handle_t ddp_rdmap_handle = NULL; -static gboolean initialized = FALSE; static const value_string mpa_messages[] = { { MPA_REQUEST_FRAME, "MPA Request Frame" }, @@ -1001,11 +1000,9 @@ void proto_register_mpa(void) }; /* register the protocol name and description */ - if (proto_iwarp_mpa == -1) { - proto_iwarp_mpa = proto_register_protocol( - "iWARP Marker Protocol data unit Aligned framing", - "IWARP_MPA", "iwarp_mpa"); - } + proto_iwarp_mpa = proto_register_protocol( + "iWARP Marker Protocol data unit Aligned framing", + "IWARP_MPA", "iwarp_mpa"); /* required function calls to register the header fields and subtrees */ proto_register_field_array(proto_iwarp_mpa, hf, array_length(hf)); @@ -1016,13 +1013,10 @@ void proto_register_mpa(void) void proto_reg_handoff_mpa(void) { - if (!initialized) { - /* - * MPA does not use any specific TCP port so, when not on a specific - * port, try this one whenever there is TCP traffic. - */ - heur_dissector_add("tcp", dissect_iwarp_mpa, proto_iwarp_mpa); - ddp_rdmap_handle = find_dissector("iwarp_ddp_rdmap"); - initialized = TRUE; - } + /* + * MPA does not use any specific TCP port so, when not on a specific + * port, try this dissector whenever there is TCP traffic. + */ + heur_dissector_add("tcp", dissect_iwarp_mpa, proto_iwarp_mpa); + ddp_rdmap_handle = find_dissector("iwarp_ddp_rdmap"); } diff --git a/epan/dissectors/packet-roofnet.c b/epan/dissectors/packet-roofnet.c index 1b8e813b6f..acfeb3e25f 100644 --- a/epan/dissectors/packet-roofnet.c +++ b/epan/dissectors/packet-roofnet.c @@ -354,20 +354,16 @@ void proto_register_roofnet(void) void proto_reg_handoff_roofnet(void) { - static gboolean initalised= FALSE; static dissector_handle_t roofnet_handle; - if (!initalised) { - /* Until now there is no other option than having an IPv4 payload (maybe - * extended one day to IPv6 or other?) */ - ip_handle = find_dissector("ip"); - roofnet_handle = create_dissector_handle(dissect_roofnet, proto_roofnet); - /* I did not put the type numbers in the ethertypes.h as they only are - * experimental and not official */ - dissector_add("ethertype", 0x0641, roofnet_handle); - dissector_add("ethertype", 0x0643, roofnet_handle); - dissector_add("ethertype", 0x0644, roofnet_handle); - dissector_add("ethertype", 0x0645, roofnet_handle); - initalised= TRUE; - } + /* Until now there is no other option than having an IPv4 payload (maybe + * extended one day to IPv6 or other?) */ + ip_handle = find_dissector("ip"); + roofnet_handle = create_dissector_handle(dissect_roofnet, proto_roofnet); + /* I did not put the type numbers in the ethertypes.h as they only are + * experimental and not official */ + dissector_add("ethertype", 0x0641, roofnet_handle); + dissector_add("ethertype", 0x0643, roofnet_handle); + dissector_add("ethertype", 0x0644, roofnet_handle); + dissector_add("ethertype", 0x0645, roofnet_handle); } diff --git a/epan/dissectors/packet-scsi.c b/epan/dissectors/packet-scsi.c index 2101b81bc5..f90f69f317 100644 --- a/epan/dissectors/packet-scsi.c +++ b/epan/dissectors/packet-scsi.c @@ -5539,7 +5539,6 @@ proto_register_scsi (void) /* Required function calls to register the header fields and subtrees used */ proto_register_field_array(proto_scsi, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); - data_handle = find_dissector ("data"); /* add preferences to decode SCSI message */ scsi_module = prefs_register_protocol (proto_scsi, NULL); @@ -5561,5 +5560,5 @@ void proto_reg_handoff_scsi(void) { scsi_tap = register_tap("scsi"); - + data_handle = find_dissector ("data"); } diff --git a/epan/dissectors/packet-tivoconnect.c b/epan/dissectors/packet-tivoconnect.c index 6b3c3da41d..78c36e30e5 100644 --- a/epan/dissectors/packet-tivoconnect.c +++ b/epan/dissectors/packet-tivoconnect.c @@ -260,17 +260,9 @@ proto_register_tivoconnect(void) void proto_reg_handoff_tivoconnect(void) { - static gboolean inited = FALSE; - - if( !inited ) { - - dissector_handle_t tivoconnect_handle; - - tivoconnect_handle = new_create_dissector_handle(dissect_tivoconnect, - proto_tivoconnect); - dissector_add("udp.port", 2190, tivoconnect_handle); - dissector_add("tcp.port", 2190, tivoconnect_handle); - - inited = TRUE; - } + dissector_handle_t tivoconnect_handle; + + tivoconnect_handle = new_create_dissector_handle(dissect_tivoconnect, proto_tivoconnect); + dissector_add("udp.port", 2190, tivoconnect_handle); + dissector_add("tcp.port", 2190, tivoconnect_handle); } diff --git a/epan/dissectors/packet-wlccp.c b/epan/dissectors/packet-wlccp.c index 2e82832d97..0ce9721bc1 100644 --- a/epan/dissectors/packet-wlccp.c +++ b/epan/dissectors/packet-wlccp.c @@ -411,8 +411,6 @@ struct subdissector_returns_t /* Forward declarations we need below */ -void proto_reg_handoff_wlccp(void); - static guint dissect_wlccp_ccm_msg(proto_tree *_tree, tvbuff_t *_tvb, guint _offset, guint8 _base_message_type); static guint dissect_wlccp_sec_msg(proto_tree *_tree, tvbuff_t *_tvb, guint _offset, guint8 _base_message_type); static guint dissect_wlccp_rrm_msg(proto_tree *_tree, tvbuff_t *_tvb, guint _offset, guint8 _base_message_type); @@ -434,11 +432,6 @@ static void set_tlv_flag(gboolean flag); static gboolean get_tlv_flag(void); static gboolean get_mic_flag(void); -/* Initialize external dissector handles */ -/* We'll try to use the EAP dissector when necessary */ -static dissector_handle_t eap_handle; - - /* Initialize some utlity variables */ static gboolean mic_flag=0, tlv_flag=0; @@ -3874,29 +3867,20 @@ proto_register_wlccp(void) proto_register_field_array(proto_wlccp, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); - } void proto_reg_handoff_wlccp(void) { - static gboolean inited = FALSE; - - if( !inited ) { + dissector_handle_t wlccp_handle; - dissector_handle_t wlccp_handle; - eap_handle = find_dissector("eap"); + wlccp_handle = create_dissector_handle(dissect_wlccp, proto_wlccp); - wlccp_handle = create_dissector_handle(dissect_wlccp, - proto_wlccp); + dissector_add("ethertype", ETHERTYPE_WLCCP, wlccp_handle); + dissector_add("udp.port", WLCCP_UDP_PORT, wlccp_handle); + dissector_add("llc.wlccp_pid", 0x0000, wlccp_handle); - dissector_add("ethertype", ETHERTYPE_WLCCP, wlccp_handle); - dissector_add("udp.port", WLCCP_UDP_PORT, wlccp_handle); - dissector_add("llc.wlccp_pid", 0x0000, wlccp_handle); - - inited = TRUE; - } } @@ -3912,4 +3896,5 @@ proto_register_wlccp_oui(void) }; llc_add_oui(OUI_CISCOWL, "llc.wlccp_pid", "Cisco WLCCP OUI PID", hf); + } diff --git a/epan/dissectors/packet-wol.c b/epan/dissectors/packet-wol.c index 52225e51f1..035e5518f8 100644 --- a/epan/dissectors/packet-wol.c +++ b/epan/dissectors/packet-wol.c @@ -66,16 +66,12 @@ #include <epan/addr_resolv.h> #include <epan/packet.h> -#include <epan/prefs.h> #include <epan/etypes.h> /* IF PROTO exposes code to other dissectors, then it must be exported in a header file. If not, a header file is not needed at all. */ /* #include "packet-wol.h" */ -/* Forward declaration we need below */ -void proto_reg_handoff_wol(void); - /* Initialize the protocol and registered fields */ static int proto_wol = -1; static int hf_wol_sync = -1; @@ -330,37 +326,28 @@ proto_register_wol(void) This exact format is required because a script is used to find these routines and create the code that calls these routines. - This function is also called by preferences whenever "Apply" is pressed - (see prefs_register_protocol above) so it should accommodate being called - more than once. */ void proto_reg_handoff_wol(void) { - static gboolean inited = FALSE; - - if ( !inited ) - { - dissector_handle_t wol_handle; + dissector_handle_t wol_handle; /* Use new_create_dissector_handle() to indicate that dissect_wol() * returns the number of bytes it dissected (or 0 if it thinks the packet * does not belong to PROTONAME). */ - wol_handle = new_create_dissector_handle(dissect_wol, proto_wol); - - /* We don't really want to register with EVERY possible dissector, - * do we? I know that the AMD white paper specifies that the - * MagicPacket could be present in any frame, but are we seriously - * going to register WOL with every other dissector!? I think not. - * - * Unless anyone has a better idea, just register with only those that - * are in "common usage" and grow this list as needed. Yeah, I'm sure - * we'll miss some, but how else to do this ... add a thousand of - * these dissector_add()'s and heur_dissector_add()'s??? */ - dissector_add("ethertype", ETHERTYPE_WOL, wol_handle); - heur_dissector_add("udp", dissect_wol, proto_wol); - inited = TRUE; - } + wol_handle = new_create_dissector_handle(dissect_wol, proto_wol); + + /* We don't really want to register with EVERY possible dissector, + * do we? I know that the AMD white paper specifies that the + * MagicPacket could be present in any frame, but are we seriously + * going to register WOL with every other dissector!? I think not. + * + * Unless anyone has a better idea, just register with only those that + * are in "common usage" and grow this list as needed. Yeah, I'm sure + * we'll miss some, but how else to do this ... add a thousand of + * these dissector_add()'s and heur_dissector_add()'s??? */ + dissector_add("ethertype", ETHERTYPE_WOL, wol_handle); + heur_dissector_add("udp", dissect_wol, proto_wol); } diff --git a/epan/dissectors/packet-xtp.c b/epan/dissectors/packet-xtp.c index 4b15cb41aa..548de6ec45 100644 --- a/epan/dissectors/packet-xtp.c +++ b/epan/dissectors/packet-xtp.c @@ -111,9 +111,6 @@ static const value_string diag_val_vals[] = { { 0, NULL } }; -/* Forward declaration we need below */ -void proto_reg_handoff_xtp(void); - /* Initialize the protocol and registered fields */ static int proto_xtp = -1; /* common header */ @@ -1322,13 +1319,8 @@ proto_register_xtp(void) void proto_reg_handoff_xtp(void) { - static gboolean inited = FALSE; - - if (!inited) { - dissector_handle_t xtp_handle; + dissector_handle_t xtp_handle; - xtp_handle = new_create_dissector_handle(dissect_xtp, proto_xtp); - dissector_add("ip.proto", IP_PROTO_XTP, xtp_handle); - inited = TRUE; - } + xtp_handle = new_create_dissector_handle(dissect_xtp, proto_xtp); + dissector_add("ip.proto", IP_PROTO_XTP, xtp_handle); } |