Use `register_dissector()` for more protocols

This commit is contained in:
David Perry 2022-11-14 04:48:24 +00:00 committed by AndersBroman
parent 4f3b028d94
commit 52382b2592
19 changed files with 49 additions and 59 deletions

View File

@ -32,6 +32,7 @@
*/
void proto_register_aodv(void);
void proto_reg_handoff_aodv(void);
static dissector_handle_t aodv_handle;
#define INET6_ADDRLEN 16
#define UDP_PORT_AODV 654
@ -852,6 +853,7 @@ proto_register_aodv(void)
/* Register the protocol name and description */
proto_aodv = proto_register_protocol("Ad hoc On-demand Distance Vector Routing Protocol", "AODV", "aodv");
aodv_handle = register_dissector("aodv", dissect_aodv, proto_aodv);
/* Required function calls to register the header fields and subtrees used */
proto_register_field_array(proto_aodv, hf, array_length(hf));
@ -864,10 +866,6 @@ proto_register_aodv(void)
void
proto_reg_handoff_aodv(void)
{
dissector_handle_t aodv_handle;
aodv_handle = create_dissector_handle(dissect_aodv,
proto_aodv);
dissector_add_uint_with_preference("udp.port", UDP_PORT_AODV, aodv_handle);
}

View File

@ -756,6 +756,11 @@ proto_register_asphodel(void)
/* Register the protocol name and description */
proto_asphodel = proto_register_protocol("Asphodel", "Asphodel", "asphodel");
/* Register the dissectors */
asphodel_inquiry_handle = register_dissector("asphodel_inquiry", dissect_asphodel_inquiry, proto_asphodel);
asphodel_response_handle = register_dissector("asphodel_response", dissect_asphodel_response, proto_asphodel);
asphodel_tcp_handle = register_dissector("asphodel_tcp", dissect_asphodel_tcp, proto_asphodel);
/* Required function calls to register the header fields and subtrees */
proto_register_field_array(proto_asphodel, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
@ -768,10 +773,6 @@ proto_register_asphodel(void)
void
proto_reg_handoff_asphodel(void)
{
asphodel_inquiry_handle = create_dissector_handle(dissect_asphodel_inquiry, proto_asphodel);
asphodel_response_handle = create_dissector_handle(dissect_asphodel_response, proto_asphodel);
asphodel_tcp_handle = create_dissector_handle(dissect_asphodel_tcp, proto_asphodel);
heur_dissector_add("udp", dissect_asphodel_heur_udp, "Asphodel over UDP",
"asphodel_inquiry", proto_asphodel, HEURISTIC_ENABLE);
dissector_add_for_decode_as("udp.port", asphodel_response_handle);

View File

@ -364,6 +364,7 @@ static gint ett_bmp_route_policy_tlv_policy = -1;
static expert_field ei_stat_data_unknown = EI_INIT;
static dissector_handle_t bmp_handle;
static dissector_handle_t dissector_bgp;
/* desegmentation */
@ -1560,6 +1561,8 @@ proto_register_bmp(void)
"bmp" /* abbrev */
);
bmp_handle = register_dissector("bmp", dissect_bmp, proto_bmp);
proto_register_field_array(proto_bmp, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
@ -1578,9 +1581,6 @@ proto_register_bmp(void)
void
proto_reg_handoff_bmp(void)
{
static dissector_handle_t bmp_handle;
bmp_handle = create_dissector_handle(dissect_bmp, proto_bmp);
dissector_add_for_decode_as_with_preference("tcp.port", bmp_handle);
dissector_bgp = find_dissector_add_dependency("bgp", proto_bmp);
}

View File

@ -32,6 +32,7 @@ void proto_register_bssap(void);
void proto_reg_handoff_bssap(void);
static dissector_handle_t bssap_handle;
static dissector_handle_t bssap_plus_handle;
static dissector_handle_t bsap_handle;
static dissector_handle_t bssap_le_handle;
@ -2568,7 +2569,7 @@ proto_register_bssap(void)
bsap_handle = register_dissector("bsap", dissect_bsap, proto_bsap);
bssap_le_handle = register_dissector("bssap_le", dissect_bssap_le, proto_bssap_le);
register_dissector("bssap.imei", dissect_bssap_imei_dissector, proto_bssap);
register_dissector("bssap_plus", dissect_bssap_plus, proto_bssap_plus);
bssap_plus_handle = register_dissector("bssap_plus", dissect_bssap_plus, proto_bssap_plus);
/* Required function calls to register the header fields and subtrees used */
proto_register_field_array(proto_bssap, hf, array_length(hf));
@ -2606,12 +2607,10 @@ proto_register_bssap(void)
void
proto_reg_handoff_bssap(void)
{
static dissector_handle_t bssap_plus_handle;
heur_dissector_add("sccp", dissect_bssap_heur, "BSSAP over SCCP", "bssap_sccp", proto_bssap, HEURISTIC_ENABLE);
heur_dissector_add("sua", dissect_bssap_heur, "BSSAP over SUA", "bssap_sua", proto_bssap, HEURISTIC_ENABLE);
/* BSSAP+ */
bssap_plus_handle = create_dissector_handle(dissect_bssap_plus, proto_bssap_plus);
rrlp_handle = find_dissector_add_dependency("rrlp", proto_bssap_plus);
gsm_bssmap_le_dissector_handle = find_dissector_add_dependency("gsm_bssmap_le", proto_bssap);

View File

@ -15,6 +15,8 @@
#include <epan/packet.h>
#include <file-rbm.h>
static dissector_handle_t drb_handle;
static int proto_drb = -1;
static int hf_drb_len = -1;
@ -108,6 +110,7 @@ void proto_register_drb(void)
};
proto_drb = proto_register_protocol("Distributed Ruby", "DRb", "drb");
drb_handle = register_dissector("drb", dissect_drb, proto_drb);
proto_register_field_array(proto_drb, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
@ -115,9 +118,6 @@ void proto_register_drb(void)
void proto_reg_handoff_drb(void)
{
dissector_handle_t drb_handle;
drb_handle = create_dissector_handle(dissect_drb, proto_drb);
dissector_add_for_decode_as_with_preference("tcp.port", drb_handle);
}

View File

@ -18,6 +18,8 @@
void proto_register_dvb_bat(void);
void proto_reg_handoff_dvb_bat(void);
static dissector_handle_t dvb_bat_handle;
static int proto_dvb_bat = -1;
static int hf_dvb_bat_bouquet_id = -1;
static int hf_dvb_bat_reserved1 = -1;
@ -237,6 +239,7 @@ proto_register_dvb_bat(void)
};
proto_dvb_bat = proto_register_protocol("DVB Bouquet Association Table", "DVB BAT", "dvb_bat");
dvb_bat_handle = register_dissector("dvb_bat", dissect_dvb_bat, proto_dvb_bat);
proto_register_field_array(proto_dvb_bat, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
@ -246,10 +249,6 @@ proto_register_dvb_bat(void)
void proto_reg_handoff_dvb_bat(void)
{
dissector_handle_t dvb_bat_handle;
dvb_bat_handle = create_dissector_handle(dissect_dvb_bat, proto_dvb_bat);
dissector_add_uint("mpeg_sect.tid", DVB_BAT_TID, dvb_bat_handle);
}

View File

@ -315,6 +315,7 @@ static expert_field ei_sm_rp_oa_invalid = EI_INIT;
static expert_field ei_gsup_ie_len_invalid = EI_INIT;
static dissector_handle_t gsm_map_handle;
static dissector_handle_t gsup_handle;
static dissector_handle_t gsm_sms_handle;
static dissector_handle_t bssap_imei_handle;
static dissector_handle_t bssap_handle;
@ -1029,6 +1030,8 @@ proto_register_gsup(void)
proto_register_field_array(proto_gsup, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
gsup_handle = register_dissector("gsup", dissect_gsup, proto_gsup);
expert_gsup = expert_register_protocol(proto_gsup);
expert_register_field_array(expert_gsup, ei, array_length(ei));
@ -1043,8 +1046,6 @@ proto_register_gsup(void)
void
proto_reg_handoff_gsup(void)
{
dissector_handle_t gsup_handle;
gsup_handle = create_dissector_handle(dissect_gsup, proto_gsup);
dissector_add_uint_with_preference("ipa.osmo.protocol", IPAC_PROTO_EXT_GSUP, gsup_handle);
gsm_map_handle = find_dissector_add_dependency("gsm_map", proto_gsup);
gsm_sms_handle = find_dissector_add_dependency("gsm_sms", proto_gsup);

View File

@ -29,6 +29,7 @@ static int hf_zdst = -1;
static gint ett_raw = -1;
static dissector_handle_t ipnet_handle;
static dissector_handle_t ip_handle;
static dissector_handle_t ipv6_handle;
@ -126,20 +127,18 @@ proto_register_ipnet(void)
proto_ipnet = proto_register_protocol("Solaris IPNET", "IPNET", "ipnet");
proto_register_field_array(proto_ipnet, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
ipnet_handle = register_dissector("ipnet", dissect_ipnet, proto_ipnet);
}
void
proto_reg_handoff_ipnet(void)
{
dissector_handle_t ipnet_handle;
/*
* Get handles for the IP and IPv6 dissectors.
*/
ip_handle = find_dissector_add_dependency("ip", proto_ipnet);
ipv6_handle = find_dissector_add_dependency("ipv6", proto_ipnet);
ipnet_handle = create_dissector_handle(dissect_ipnet, proto_ipnet);
dissector_add_uint("wtap_encap", WTAP_ENCAP_IPNET, ipnet_handle);
}

View File

@ -22,6 +22,8 @@
void proto_register_dsmcc(void);
void proto_reg_handoff_dsmcc(void);
static dissector_handle_t dsmcc_ts_handle, dsmcc_tcp_handle, dsmcc_udp_handle;
/* NOTE: Please try to keep this status comment up to date until the spec is
* completely implemented - there are a large number of tables in the spec.
*
@ -3279,7 +3281,9 @@ proto_register_dsmcc(void)
proto_register_subtree_array(ett, array_length(ett));
expert_dsmcc = expert_register_protocol(proto_dsmcc);
expert_register_field_array(expert_dsmcc, ei, array_length(ei));
register_dissector("mp2t-dsmcc", dissect_dsmcc_ts, proto_dsmcc);
dsmcc_ts_handle = register_dissector("mp2t-dsmcc", dissect_dsmcc_ts, proto_dsmcc);
dsmcc_tcp_handle = register_dissector("mp2t-dsmcc-tcp", dissect_dsmcc_tcp, proto_dsmcc);
dsmcc_udp_handle = register_dissector("mp2t-dsmcc-udp", dissect_dsmcc_udp, proto_dsmcc);
dsmcc_module = prefs_register_protocol(proto_dsmcc, NULL);
@ -3293,12 +3297,6 @@ proto_register_dsmcc(void)
void
proto_reg_handoff_dsmcc(void)
{
dissector_handle_t dsmcc_ts_handle, dsmcc_tcp_handle, dsmcc_udp_handle;
dsmcc_ts_handle = create_dissector_handle(dissect_dsmcc_ts, proto_dsmcc);
dsmcc_tcp_handle = create_dissector_handle(dissect_dsmcc_tcp, proto_dsmcc);
dsmcc_udp_handle = create_dissector_handle(dissect_dsmcc_udp, proto_dsmcc);
dissector_add_uint("mpeg_sect.tid", DSMCC_TID_LLCSNAP, dsmcc_ts_handle);
dissector_add_uint("mpeg_sect.tid", DSMCC_TID_UN_MSG, dsmcc_ts_handle);
dissector_add_uint("mpeg_sect.tid", DSMCC_TID_DD_MSG, dsmcc_ts_handle);

View File

@ -156,6 +156,7 @@ static gint ett_msdp_not_data = -1;
static expert_field ei_msdp_tlv_len_too_short = EI_INIT;
static expert_field ei_msdp_tlv_len_too_long = EI_INIT;
static dissector_handle_t msdp_handle;
static dissector_handle_t ip_handle;
@ -722,6 +723,7 @@ proto_register_msdp(void)
proto_msdp = proto_register_protocol("Multicast Source Discovery Protocol",
"MSDP", "msdp");
msdp_handle = register_dissector("msdp", dissect_msdp, proto_msdp);
proto_register_field_array(proto_msdp, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
@ -732,9 +734,6 @@ proto_register_msdp(void)
void
proto_reg_handoff_msdp(void)
{
dissector_handle_t msdp_handle;
msdp_handle = create_dissector_handle(dissect_msdp, proto_msdp);
dissector_add_uint_with_preference("tcp.port", MSDP_PORT, msdp_handle);
ip_handle = find_dissector_add_dependency("ip", proto_msdp);

View File

@ -4575,7 +4575,7 @@ proto_register_netlink_nl80211(void)
proto_register_field_array(proto_netlink_nl80211, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
netlink_nl80211_handle = create_dissector_handle(dissect_netlink_nl80211, proto_netlink_nl80211);
netlink_nl80211_handle = register_dissector("nl80211", dissect_netlink_nl80211, proto_netlink_nl80211);
ieee80211_handle = find_dissector_add_dependency("wlan", proto_netlink_nl80211);
ieee80211_tag_dissector_table = find_dissector_table("wlan.tag.number");
}

View File

@ -1267,7 +1267,7 @@ proto_register_netlink_sock_diag(void)
proto_register_field_array(proto_netlink_sock_diag, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
netlink_sock_diag_handle = create_dissector_handle(dissect_netlink_sock_diag, proto_netlink_sock_diag);
netlink_sock_diag_handle = register_dissector("netlink-sock_diag", dissect_netlink_sock_diag, proto_netlink_sock_diag);
}
void

View File

@ -26,6 +26,7 @@
void proto_register_olsr(void);
void proto_reg_handoff_olsr(void);
static dissector_handle_t olsr_handle;
#define UDP_PORT_OLSR 698
#define HELLO 1
@ -964,6 +965,7 @@ void proto_register_olsr(void) {
}
proto_olsr = proto_register_protocol("Optimized Link State Routing Protocol", "OLSR", "olsr");
olsr_handle = register_dissector("olsr", dissect_olsr, proto_olsr);
proto_register_field_array(proto_olsr, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
@ -980,9 +982,6 @@ void proto_register_olsr(void) {
}
void proto_reg_handoff_olsr(void) {
dissector_handle_t olsr_handle;
olsr_handle = create_dissector_handle(dissect_olsr, proto_olsr);
dissector_add_uint_with_preference("udp.port", UDP_PORT_OLSR, olsr_handle);
}

View File

@ -111,6 +111,7 @@
void proto_register_rsvp(void);
void proto_reg_handoff_rsvp(void);
static dissector_handle_t rsvp_handle, rsvpe2ei_handle;
static int proto_rsvp = -1;
static int proto_rsvp_e2e1 = -1;
@ -10200,6 +10201,9 @@ proto_register_rsvp(void)
/* Created to remove Decode As confusion */
proto_rsvp_e2e1 = proto_register_protocol_in_name_only("Resource ReserVation Protocol (RSVP-E2EI)", "RSVP-E2EI", "rsvp-e2ei", proto_rsvp, FT_PROTOCOL);
rsvp_handle = register_dissector("rsvp", dissect_rsvp, proto_rsvp);
rsvpe2ei_handle = register_dissector("rsvp_e2ei", dissect_rsvp_e2ei, proto_rsvp_e2e1);
proto_register_field_array(proto_rsvp, rsvpf_info, array_length(rsvpf_info));
proto_register_subtree_array(ett_tree, array_length(ett_tree));
expert_rsvp = expert_register_protocol(proto_rsvp);
@ -10214,10 +10218,6 @@ proto_register_rsvp(void)
void
proto_reg_handoff_rsvp(void)
{
dissector_handle_t rsvp_handle, rsvpe2ei_handle;
rsvp_handle = create_dissector_handle(dissect_rsvp, proto_rsvp);
rsvpe2ei_handle = create_dissector_handle(dissect_rsvp_e2ei, proto_rsvp_e2e1);
dissector_add_uint("ip.proto", IP_PROTO_RSVP, rsvp_handle);
dissector_add_uint("ip.proto", IP_PROTO_RSVPE2EI, rsvpe2ei_handle);
dissector_add_uint_with_preference("udp.port", UDP_PORT_PRSVP, rsvp_handle);

View File

@ -16,6 +16,7 @@
void proto_register_spp(void);
void proto_reg_handoff_spp(void);
static dissector_handle_t spp_handle;
static int proto_spp = -1;
static int hf_spp_connection_control = -1;
@ -247,6 +248,7 @@ proto_register_spp(void)
"SPP", "spp");
proto_register_field_array(proto_spp, hf_spp, array_length(hf_spp));
proto_register_subtree_array(ett, array_length(ett));
spp_handle = register_dissector("spp", dissect_spp, proto_spp);
spp_socket_dissector_table = register_dissector_table("spp.socket",
"SPP socket", proto_spp, FT_UINT16, BASE_HEX);
@ -255,9 +257,6 @@ proto_register_spp(void)
void
proto_reg_handoff_spp(void)
{
dissector_handle_t spp_handle;
spp_handle = create_dissector_handle(dissect_spp, proto_spp);
dissector_add_uint("idp.packet_type", IDP_PACKET_TYPE_SPP, spp_handle);
}

View File

@ -58,6 +58,7 @@ typedef struct {
static dissector_table_t teredo_dissector_table;
/*static heur_dissector_list_t heur_subdissector_list;*/
static dissector_handle_t teredo_handle;
static dissector_handle_t data_handle;
static int
@ -370,6 +371,7 @@ proto_register_teredo(void)
"Teredo IPv6 over UDP tunneling", "Teredo", "teredo");
proto_register_field_array(proto_teredo, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
teredo_handle = register_dissector("teredo", dissect_teredo, proto_teredo);
/* subdissector code */
teredo_dissector_table = register_dissector_table("teredo", "Teredo", proto_teredo, FT_UINT16, BASE_DEC);
@ -383,9 +385,6 @@ proto_register_teredo(void)
void
proto_reg_handoff_teredo(void)
{
dissector_handle_t teredo_handle;
teredo_handle = create_dissector_handle(dissect_teredo, proto_teredo);
data_handle = find_dissector("ipv6");
teredo_tap = register_tap("teredo");

View File

@ -20,6 +20,7 @@
void proto_register_tsdns(void);
void proto_reg_handoff_tsdns(void);
static dissector_handle_t tsdns_handle;
static int proto_tsdns = -1;
@ -137,14 +138,12 @@ void proto_register_tsdns(void)
proto_register_subtree_array(ett, array_length(ett));
expert_tsdns = expert_register_protocol(proto_tsdns);
expert_register_field_array(expert_tsdns, ei, array_length(ei));
tsdns_handle = register_dissector("tsdns", dissect_tsdns, proto_tsdns);
}
void proto_reg_handoff_tsdns(void)
{
dissector_handle_t tsdns_handle;
tsdns_handle = create_dissector_handle(dissect_tsdns, proto_tsdns);
/* Default port to not dissect the protocol*/
dissector_add_uint_with_preference("tcp.port", 0, tsdns_handle);
}

View File

@ -26,6 +26,7 @@
void proto_register_winsrepl(void);
void proto_reg_handoff_winsrepl(void);
static dissector_handle_t winsrepl_handle;
static gboolean winsrepl_reassemble = TRUE;
@ -851,6 +852,7 @@ proto_register_winsrepl(void)
proto_register_field_array(proto_winsrepl, hf, array_length(hf));
expert_winsrepl = expert_register_protocol(proto_winsrepl);
expert_register_field_array(expert_winsrepl, ei, array_length(ei));
winsrepl_handle = register_dissector("winsrepl", dissect_winsrepl, proto_winsrepl);
winsrepl_module = prefs_register_protocol(proto_winsrepl, NULL);
prefs_register_bool_preference(winsrepl_module, "reassemble",
@ -863,9 +865,6 @@ proto_register_winsrepl(void)
void
proto_reg_handoff_winsrepl(void)
{
dissector_handle_t winsrepl_handle;
winsrepl_handle = create_dissector_handle(dissect_winsrepl, proto_winsrepl);
dissector_add_uint_with_preference("tcp.port", WINS_REPLICATION_PORT, winsrepl_handle);
}

View File

@ -60,6 +60,7 @@
void proto_reg_handoff_woww(void);
void proto_register_woww(void);
static dissector_handle_t woww_handle;
static int proto_woww = -1;
@ -20307,6 +20308,7 @@ proto_register_woww(void)
proto_woww = proto_register_protocol("World of Warcraft World",
"WOWW", "woww");
woww_handle = register_dissector("woww", dissect_woww, proto_woww);
proto_register_field_array(proto_woww, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
@ -20318,7 +20320,6 @@ proto_register_woww(void)
void
proto_reg_handoff_woww(void)
{
dissector_handle_t woww_handle = create_dissector_handle(dissect_woww, proto_woww);
dissector_add_for_decode_as("tcp.port", woww_handle);
}