Use `register_dissector()` for more protocols

This commit is contained in:
David Perry 2022-09-29 11:21:10 +00:00 committed by AndersBroman
parent b2ace05edc
commit 0e9e35cd29
18 changed files with 58 additions and 66 deletions

View File

@ -345,6 +345,7 @@ proto_register_aarp(void)
proto_aarp = proto_register_protocol("Appletalk Address Resolution Protocol",
"AARP",
"aarp");
register_dissector("aarp", dissect_aarp, proto_aarp);
proto_register_field_array(proto_aarp, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
@ -356,9 +357,8 @@ proto_register_aarp(void)
void
proto_reg_handoff_aarp(void)
{
dissector_handle_t aarp_handle;
dissector_handle_t aarp_handle = find_dissector("aarp");
aarp_handle = create_dissector_handle(dissect_aarp, proto_aarp);
dissector_add_uint("ethertype", ETHERTYPE_AARP, aarp_handle);
dissector_add_uint("chdlc.protocol", ETHERTYPE_AARP, aarp_handle);
}

View File

@ -2038,6 +2038,8 @@ proto_register_arp(void)
expert_register_field_array(expert_arp, ei, array_length(ei));
arp_handle = register_dissector( "arp" , dissect_arp, proto_arp );
register_dissector("atm_arp", dissect_atmarp, proto_atmarp);
register_dissector("ax25_arp", dissect_ax25arp, proto_arp);
arp_hw_table = register_dissector_table("arp.hw.type", "ARP Hardware Type", proto_arp, FT_UINT16, BASE_DEC);
@ -2081,9 +2083,8 @@ proto_register_arp(void)
void
proto_reg_handoff_arp(void)
{
dissector_handle_t atmarp_handle, ax25arp_handle;
atmarp_handle = create_dissector_handle(dissect_atmarp, proto_atmarp);
ax25arp_handle = create_dissector_handle(dissect_ax25arp, proto_arp);
dissector_handle_t atmarp_handle = find_dissector("atm_arp");
dissector_handle_t ax25arp_handle = find_dissector("ax25_arp");
dissector_add_uint("ethertype", ETHERTYPE_ARP, arp_handle);
dissector_add_uint("ethertype", ETHERTYPE_REVARP, arp_handle);

View File

@ -377,6 +377,7 @@ proto_register_slarp(void)
};
proto_slarp = proto_register_protocol("Cisco SLARP", "SLARP", "slarp");
register_dissector("slarp", dissect_slarp, proto_slarp);
proto_register_field_array(proto_slarp, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
@ -387,10 +388,7 @@ proto_register_slarp(void)
void
proto_reg_handoff_slarp(void)
{
dissector_handle_t slarp_handle;
slarp_handle = create_dissector_handle(dissect_slarp, proto_slarp);
dissector_add_uint("chdlc.protocol", CISCO_SLARP, slarp_handle);
dissector_add_uint("chdlc.protocol", CISCO_SLARP, find_dissector("slarp"));
}
/*

View File

@ -70,6 +70,7 @@ static dissector_handle_t cip_handle;
static dissector_handle_t cip_class_generic_handle;
static dissector_handle_t cip_class_cm_handle;
static dissector_handle_t cip_class_pccc_handle;
static dissector_handle_t cip_class_mb_handle;
static dissector_handle_t modbus_handle;
static dissector_handle_t cip_class_cco_handle;
static heur_dissector_list_t heur_subdissector_service;
@ -9067,25 +9068,35 @@ proto_register_cip(void)
/* Register the protocol name and description */
proto_cip_class_generic = proto_register_protocol("CIP Class Generic",
"CIPCLS", "cipcls");
cip_class_generic_handle = register_dissector("cipcls",
dissect_cip_class_generic, proto_cip_class_generic);
/* Register the protocol name and description */
proto_cip_class_cm = proto_register_protocol("CIP Connection Manager",
"CIPCM", "cipcm");
cip_class_cm_handle = register_dissector("cipcm",
dissect_cip_class_cm, proto_cip_class_cm);
proto_register_field_array(proto_cip_class_cm, hf_cm, array_length(hf_cm));
proto_register_subtree_array(ett_cm, array_length(ett_cm));
proto_cip_class_pccc = proto_register_protocol("CIP PCCC Object",
"CIPPCCC", "cippccc");
cip_class_pccc_handle = register_dissector("cippccc",
dissect_cip_class_pccc, proto_cip_class_pccc);
proto_register_field_array(proto_cip_class_pccc, hf_pccc, array_length(hf_pccc));
proto_register_subtree_array(ett_pccc, array_length(ett_pccc));
proto_cip_class_mb = proto_register_protocol("CIP Modbus Object",
"CIPMB", "cipmb");
cip_class_mb_handle = register_dissector("cipmb",
dissect_cip_class_mb, proto_cip_class_mb);
proto_register_field_array(proto_cip_class_mb, hf_mb, array_length(hf_mb));
proto_register_subtree_array(ett_mb, array_length(ett_mb));
proto_cip_class_cco = proto_register_protocol("CIP Connection Configuration Object",
"CIPCCO", "cipcco");
cip_class_cco_handle = register_dissector("cipcco",
dissect_cip_class_cco, proto_cip_class_cco);
proto_register_field_array(proto_cip_class_cco, hf_cco, array_length(hf_cco));
proto_register_subtree_array(ett_cco, array_length(ett_cco));
@ -9099,33 +9110,25 @@ proto_register_cip(void)
void
proto_reg_handoff_cip(void)
{
dissector_handle_t cip_class_mb_handle;
/* Create dissector handles */
/* Register for UCMM CIP data, using EtherNet/IP SendRRData service*/
dissector_add_uint( "enip.srrd.iface", ENIP_CIP_INTERFACE, cip_handle );
dissector_add_uint("cip.connection.class", CI_CLS_MR, cip_handle);
/* Create and register dissector handle for generic class */
cip_class_generic_handle = create_dissector_handle( dissect_cip_class_generic, proto_cip_class_generic );
/* Register dissector handle for generic class */
dissector_add_uint( "cip.class.iface", 0, cip_class_generic_handle );
/* Create and register dissector handle for Connection Manager */
cip_class_cm_handle = create_dissector_handle( dissect_cip_class_cm, proto_cip_class_cm );
/* Register dissector handle for Connection Manager */
dissector_add_uint( "cip.class.iface", CI_CLS_CM, cip_class_cm_handle );
/* Create and register dissector handle for the PCCC class */
cip_class_pccc_handle = create_dissector_handle( dissect_cip_class_pccc, proto_cip_class_pccc );
/* Register dissector handle for the PCCC class */
dissector_add_uint( "cip.class.iface", CI_CLS_PCCC, cip_class_pccc_handle );
/* Create and register dissector handle for Modbus Object */
cip_class_mb_handle = create_dissector_handle( dissect_cip_class_mb, proto_cip_class_mb );
/* Register dissector handle for Modbus Object */
dissector_add_uint( "cip.class.iface", CI_CLS_MB, cip_class_mb_handle );
modbus_handle = find_dissector_add_dependency("modbus", proto_cip_class_mb);
/* Create and register dissector handle for Connection Configuration Object */
cip_class_cco_handle = create_dissector_handle( dissect_cip_class_cco, proto_cip_class_cco );
/* Register dissector handle for Connection Configuration Object */
dissector_add_uint( "cip.class.iface", CI_CLS_CCO, cip_class_cco_handle );
heur_dissector_add("cip.sc", dissect_class_cco_heur, "CIP Connection Configuration Object", "cco_cip", proto_cip_class_cco, HEURISTIC_ENABLE);

View File

@ -46,6 +46,7 @@ static int proto_cip_class_s_validator = -1;
static int proto_cip = -1;
static dissector_table_t subdissector_class_table;
static dissector_handle_t cip_class_s_supervisor_handle;
static dissector_handle_t cip_class_s_validator_handle;
/* CIP Safety field identifiers */
@ -3059,6 +3060,7 @@ proto_register_cipsafety(void)
/* Register CIP Safety objects */
proto_cip_class_s_supervisor = proto_register_protocol("CIP Safety Supervisor",
"CIPSSupervisor", "cipssupervisor");
cip_class_s_supervisor_handle = register_dissector("cipssupervisor", dissect_cip_class_s_supervisor, proto_cip_class_s_supervisor );
proto_register_field_array(proto_cip_class_s_supervisor, hf_ssupervisor, array_length(hf_ssupervisor));
proto_register_subtree_array(ett_ssupervisor, array_length(ett_ssupervisor));
expert_cip_class_s_supervisor = expert_register_protocol(proto_cip_class_s_supervisor);
@ -3066,6 +3068,7 @@ proto_register_cipsafety(void)
proto_cip_class_s_validator = proto_register_protocol("CIP Safety Validator",
"CIPSValidator", "cipsvalidator");
cip_class_s_validator_handle = register_dissector("cipsvalidator", dissect_cip_class_s_validator, proto_cip_class_s_validator );
proto_register_field_array(proto_cip_class_s_validator, hf_svalidator, array_length(hf_svalidator));
proto_register_subtree_array(ett_svalidator, array_length(ett_svalidator));
expert_cip_class_s_validator = expert_register_protocol(proto_cip_class_s_validator);
@ -3083,14 +3086,10 @@ proto_register_cipsafety(void)
void
proto_reg_handoff_cipsafety(void)
{
dissector_handle_t cip_class_s_supervisor_handle;
/* Create and register dissector handle for Safety Supervisor */
cip_class_s_supervisor_handle = create_dissector_handle( dissect_cip_class_s_supervisor, proto_cip_class_s_supervisor );
/* Register dissector handle for Safety Supervisor */
dissector_add_uint( "cip.class.iface", CI_CLS_SAFETY_SUPERVISOR, cip_class_s_supervisor_handle );
/* Create and register dissector handle for Safety Validator */
cip_class_s_validator_handle = create_dissector_handle( dissect_cip_class_s_validator, proto_cip_class_s_validator );
/* Register dissector handle for Safety Validator */
dissector_add_uint( "cip.class.iface", CI_CLS_SAFETY_VALIDATOR, cip_class_s_validator_handle );
heur_dissector_add("cip.sc", dissect_class_svalidator_heur, "CIP Safety Validator", "s_validator_cip", proto_cip_class_s_validator, HEURISTIC_ENABLE);

View File

@ -1503,10 +1503,7 @@ dissect_cql_tcp(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data)
void
proto_reg_handoff_cql(void)
{
static dissector_handle_t cql_handle;
cql_handle = create_dissector_handle(dissect_cql_tcp, proto_cql);
dissector_add_uint_with_preference("tcp.port", CQL_DEFAULT_PORT, cql_handle);
dissector_add_uint_with_preference("tcp.port", CQL_DEFAULT_PORT, find_dissector("cql"));
}
@ -2313,6 +2310,7 @@ proto_register_cql(void)
};
proto_cql = proto_register_protocol("Cassandra CQL Protocol", "CQL", "cql" );
register_dissector("cql", dissect_cql_tcp, proto_cql);
proto_register_field_array(proto_cql, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));

View File

@ -3554,6 +3554,8 @@ proto_register_dhcpv6(void)
expert_register_field_array(expert_dhcpv6, ei, array_length(ei));
proto_dhcpv6_bulk_leasequery = proto_register_protocol("DHCPv6 Bulk Leasequery", "DHCPv6 Bulk Leasequery", "dhcpv6.bulk_leasequery");
register_dissector("dhcpv6.bulk_leasequery", dissect_dhcpv6_bulk_leasequery,
proto_dhcpv6_bulk_leasequery);
proto_register_field_array(proto_dhcpv6_bulk_leasequery, bulk_leasequery_hf, array_length(bulk_leasequery_hf));
proto_register_subtree_array(ett_bulk_leasequery, array_length(ett_bulk_leasequery));
@ -3579,13 +3581,9 @@ proto_register_dhcpv6(void)
void
proto_reg_handoff_dhcpv6(void)
{
dissector_handle_t dhcpv6_bulkquery_handle;
dissector_add_uint_range_with_preference("udp.port", UDP_PORT_DHCPV6_RANGE, dhcpv6_handle);
dhcpv6_bulkquery_handle = create_dissector_handle(dissect_dhcpv6_bulk_leasequery,
proto_dhcpv6_bulk_leasequery);
dissector_add_uint_with_preference("tcp.port", TCP_PORT_DHCPV6_UPSTREAM, dhcpv6_bulkquery_handle);
dissector_add_uint_with_preference("tcp.port", TCP_PORT_DHCPV6_UPSTREAM, find_dissector("dhcpv6.bulk_leasequery"));
}
/*

View File

@ -2539,6 +2539,7 @@ proto_register_diameter(void)
/* Allow dissector to find be found by name. */
diameter_sctp_handle = register_dissector("diameter", dissect_diameter, proto_diameter);
diameter_udp_handle = create_dissector_handle(dissect_diameter, proto_diameter);
diameter_tcp_handle = register_dissector("diameter.tcp", dissect_diameter_tcp, proto_diameter);
/* Diameter AVPs without Diameter header, for EAP-TTLS (RFC 5281, Section 10) */
register_dissector("diameter_avps", dissect_diameter_avps, proto_diameter);
@ -2586,7 +2587,6 @@ proto_register_diameter(void)
void
proto_reg_handoff_diameter(void)
{
diameter_udp_handle = create_dissector_handle(dissect_diameter, proto_diameter);
data_handle = find_dissector("data");
eap_handle = find_dissector_add_dependency("eap", proto_diameter);

View File

@ -3358,6 +3358,7 @@ proto_register_eigrp(void)
"EIGRP", /* short name */
"eigrp" /* abbrev */
);
register_dissector("eigrp", dissect_eigrp, proto_eigrp);
/* Required function calls to register the header fields and subtrees used */
proto_register_field_array(proto_eigrp, hf, array_length(hf));
@ -3386,13 +3387,11 @@ proto_register_eigrp(void)
void
proto_reg_handoff_eigrp(void)
{
dissector_handle_t eigrp_handle;
dissector_handle_t eigrp_handle = find_dissector("eigrp");
ipxsap_handle = find_dissector_add_dependency("ipxsap", proto_eigrp);
media_type_table = find_dissector_table("media_type");
eigrp_handle = create_dissector_handle(dissect_eigrp, proto_eigrp);
dissector_add_uint("ip.proto", IP_PROTO_EIGRP, eigrp_handle);
dissector_add_uint("ddp.type", DDP_EIGRP, eigrp_handle);
dissector_add_uint("ipx.socket", IPX_SOCKET_EIGRP, eigrp_handle);

View File

@ -365,6 +365,9 @@ proto_register_exec(void)
/* Register the protocol name and description */
proto_exec = proto_register_protocol("Remote Process Execution", "EXEC", "exec");
/* Register the dissector function */
register_dissector("exec", dissect_exec, proto_exec);
/* Required function calls to register the header fields and subtrees used */
proto_register_field_array(proto_exec, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
@ -387,10 +390,7 @@ proto_register_exec(void)
void
proto_reg_handoff_exec(void)
{
dissector_handle_t exec_handle;
exec_handle = create_dissector_handle(dissect_exec, proto_exec);
dissector_add_uint_with_preference("tcp.port", EXEC_PORT, exec_handle);
dissector_add_uint_with_preference("tcp.port", EXEC_PORT, find_dissector("exec"));
}
/*

View File

@ -185,6 +185,7 @@ proto_register_finger(void)
};
proto_finger = proto_register_protocol("finger", "FINGER", "finger");
register_dissector("finger", dissect_finger, proto_finger);
proto_register_field_array(proto_finger, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
expert_finger = expert_register_protocol(proto_finger);
@ -194,10 +195,7 @@ proto_register_finger(void)
void
proto_reg_handoff_finger(void)
{
static dissector_handle_t finger_handle;
finger_handle = create_dissector_handle(dissect_finger, proto_finger);
dissector_add_uint_with_preference("tcp.port", FINGER_PORT, finger_handle);
dissector_add_uint_with_preference("tcp.port", FINGER_PORT, find_dissector("finger"));
}
/*

View File

@ -436,6 +436,7 @@ proto_register_flip(void)
"FLIP", /* short name */
"flip" /* abbrev */
);
register_dissector("flip", dissect_flip, proto_flip);
proto_register_field_array(proto_flip, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
@ -458,10 +459,7 @@ proto_register_flip(void)
void
proto_reg_handoff_flip(void)
{
dissector_handle_t flip_handle;
flip_handle = create_dissector_handle(dissect_flip, proto_flip);
dissector_add_uint("ethertype", ETHERTYPE_FLIP, flip_handle);
dissector_add_uint("ethertype", ETHERTYPE_FLIP, find_dissector("flip"));
} /* proto_reg_handoff_flip() */
/*

View File

@ -2171,7 +2171,7 @@ proto_register_gadu_gadu(void)
proto_register_field_array(proto_gadu_gadu, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
gadu_gadu_handle = create_dissector_handle(dissect_gadu_gadu, proto_gadu_gadu);
gadu_gadu_handle = register_dissector("gadugadu", dissect_gadu_gadu, proto_gadu_gadu);
}
void

View File

@ -250,6 +250,9 @@ proto_register_gopher(void)
/* Register the protocol name and description */
proto_gopher = proto_register_protocol("Gopher", "Gopher", "gopher");
/* Register the dissector handle */
gopher_handle = register_dissector("gopher", dissect_gopher, proto_gopher);
/* Required function calls to register the header fields and subtrees used */
proto_register_field_array(proto_gopher, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
@ -264,7 +267,6 @@ proto_register_gopher(void)
void
proto_reg_handoff_gopher(void)
{
gopher_handle = create_dissector_handle(dissect_gopher, proto_gopher);
dissector_add_uint_range_with_preference("tcp.port", TCP_DEFAULT_RANGE, gopher_handle);
gopher_prefs_apply();
}

View File

@ -542,6 +542,7 @@ proto_register_irc(void)
expert_module_t* expert_irc;
proto_irc = proto_register_protocol("Internet Relay Chat", "IRC", "irc");
register_dissector("irc", dissect_irc, proto_irc);
proto_register_field_array(proto_irc, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
expert_irc = expert_register_protocol(proto_irc);
@ -554,10 +555,7 @@ proto_register_irc(void)
void
proto_reg_handoff_irc(void)
{
dissector_handle_t irc_handle;
irc_handle = create_dissector_handle(dissect_irc, proto_irc);
dissector_add_uint_range_with_preference("tcp.port", TCP_PORT_RANGE, irc_handle);
dissector_add_uint_range_with_preference("tcp.port", TCP_PORT_RANGE, find_dissector("irc"));
}
/*

View File

@ -767,7 +767,7 @@ proto_register_lapd(void)
expert_lapd = expert_register_protocol(proto_lapd);
expert_register_field_array(expert_lapd, ei, array_length(ei));
lapd_handle = create_dissector_handle(dissect_lapd, proto_lapd);
lapd_handle = register_dissector("lapd", dissect_lapd, proto_lapd);
lapd_phdr_handle = register_dissector("lapd-phdr", dissect_lapd_phdr, proto_lapd);
linux_lapd_handle = register_dissector("linux-lapd", dissect_linux_lapd, proto_lapd);
lapd_bitstream_handle = register_dissector("lapd-bitstream", dissect_lapd_bitstream, proto_lapd);

View File

@ -361,6 +361,7 @@ proto_register_mactelnet(void)
/* Register the protocol name and description */
proto_mactelnet = proto_register_protocol ("MikroTik MAC-Telnet Protocol", PROTO_TAG_MACTELNET, "mactelnet");
register_dissector("mactelnet", dissect_mactelnet, proto_mactelnet);
/* Required function calls to register the header fields and subtrees used */
proto_register_field_array (proto_mactelnet, hf, array_length (hf));
@ -370,10 +371,7 @@ proto_register_mactelnet(void)
void
proto_reg_handoff_mactelnet(void)
{
dissector_handle_t mactelnet_handle;
mactelnet_handle = create_dissector_handle(dissect_mactelnet, proto_mactelnet);
dissector_add_uint_with_preference("udp.port", MACTELNET_UDP_PORT, mactelnet_handle);
dissector_add_uint_with_preference("udp.port", MACTELNET_UDP_PORT, find_dissector("mactelnet"));
}
/*

View File

@ -143,6 +143,8 @@
void proto_register_netflow(void);
void proto_reg_handoff_netflow(void);
static int dissect_tcp_netflow(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data);
#if 0
#define ipfix_debug(...) ws_warning(__VA_ARGS__)
#else
@ -20942,6 +20944,8 @@ proto_register_netflow(void)
expert_module_t* expert_netflow;
proto_netflow = proto_register_protocol("Cisco NetFlow/IPFIX", "CFLOW", "cflow");
netflow_handle = register_dissector("netflow", dissect_netflow, proto_netflow);
netflow_tcp_handle = register_dissector("netflow_tcp", dissect_tcp_netflow, proto_netflow);
register_dissector("cflow", dissect_netflow, proto_netflow);
@ -21039,8 +21043,6 @@ proto_reg_handoff_netflow(void)
/* Find eth_handle used for IE315*/
eth_handle = find_dissector ("eth_withoutfcs");
netflow_handle = create_dissector_handle(dissect_netflow, proto_netflow);
netflow_tcp_handle = create_dissector_handle(dissect_tcp_netflow, proto_netflow);
netflow_prefs_initialized = TRUE;
dissector_add_uint("wtap_encap", WTAP_ENCAP_RAW_IPFIX, netflow_handle);
dissector_add_uint_range_with_preference("tcp.port", IPFIX_UDP_PORTS, netflow_tcp_handle);