From c96858b5fe9d60ef66c42d93000813249d7363af Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sun, 21 Dec 2014 13:05:46 -0800 Subject: Use the "netbios" heuristic dissector list elsewhere. Use find_heur_dissector_list() to find the "netbios" heuristic dissector list, rather than using code from packet-netbios.c. Change-Id: Ieeab58d7c6eb32491b026b242c687bd18c4d5cdb Reviewed-on: https://code.wireshark.org/review/5955 Reviewed-by: Guy Harris --- epan/dissectors/packet-nbipx.c | 20 ++++++++++++++++++++ epan/dissectors/packet-nbns.c | 21 +++++++++++++++++++++ epan/dissectors/packet-netbios.c | 2 +- epan/dissectors/packet-netbios.h | 2 -- 4 files changed, 42 insertions(+), 3 deletions(-) (limited to 'epan') diff --git a/epan/dissectors/packet-nbipx.c b/epan/dissectors/packet-nbipx.c index 3ee08612b7..b362579cf6 100644 --- a/epan/dissectors/packet-nbipx.c +++ b/epan/dissectors/packet-nbipx.c @@ -66,6 +66,10 @@ static gint ett_nbipx_name_type_flags = -1; static void dissect_conn_control(tvbuff_t *tvb, int offset, proto_tree *tree); +static heur_dissector_list_t netbios_heur_subdissector_list; + +static dissector_handle_t data_handle; + /* There is no RFC or public specification of Netware or Microsoft * NetBIOS over IPX packets. I have had to decode the protocol myself, * so there are holes and perhaps errors in this code. (gram) @@ -261,6 +265,20 @@ add_routers(proto_tree *tree, tvbuff_t *tvb, int offset) } } +static void +dissect_netbios_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +{ + heur_dtbl_entry_t *hdtbl_entry; + + /* + * Try the heuristic dissectors for NetBIOS; if none of them + * accept the packet, dissect it as data. + */ + if (!dissector_try_heuristic(netbios_heur_subdissector_list, + tvb, pinfo, tree, &hdtbl_entry, NULL)) + call_dissector(data_handle,tvb, pinfo, tree); +} + static int dissect_nbipx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) { @@ -642,6 +660,8 @@ proto_reg_handoff_nbipx(void) nbipx_handle = new_create_dissector_handle(dissect_nbipx, proto_nbipx); dissector_add_uint("ipx.socket", IPX_SOCKET_NETBIOS, nbipx_handle); + netbios_heur_subdissector_list = find_heur_dissector_list("netbios"); + data_handle = find_dissector("data"); } /* diff --git a/epan/dissectors/packet-nbns.c b/epan/dissectors/packet-nbns.c index 1fb22fa4bd..16e114453c 100644 --- a/epan/dissectors/packet-nbns.c +++ b/epan/dissectors/packet-nbns.c @@ -1103,6 +1103,24 @@ dissect_nbns(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) "Additional records"); } +static heur_dissector_list_t netbios_heur_subdissector_list; + +static dissector_handle_t data_handle; + +static void +dissect_netbios_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +{ + heur_dtbl_entry_t *hdtbl_entry; + + /* + * Try the heuristic dissectors for NetBIOS; if none of them + * accept the packet, dissect it as data. + */ + if (!dissector_try_heuristic(netbios_heur_subdissector_list, + tvb, pinfo, tree, &hdtbl_entry, NULL)) + call_dissector(data_handle,tvb, pinfo, tree); +} + /* NetBIOS datagram packet, from RFC 1002, page 32 */ struct nbdgm_header { guint8 msg_type; @@ -2096,6 +2114,9 @@ proto_reg_handoff_nbt(void) nbss_handle = new_create_dissector_handle(dissect_nbss, proto_nbss); dissector_add_uint("tcp.port", TCP_PORT_NBSS, nbss_handle); dissector_add_uint("tcp.port", TCP_PORT_CIFS, nbss_handle); + + netbios_heur_subdissector_list = find_heur_dissector_list("netbios"); + data_handle = find_dissector("data"); } /* diff --git a/epan/dissectors/packet-netbios.c b/epan/dissectors/packet-netbios.c index 4ecd5ef154..b4f58d0001 100644 --- a/epan/dissectors/packet-netbios.c +++ b/epan/dissectors/packet-netbios.c @@ -1062,7 +1062,7 @@ static guint32 (*const dissect_netb[])(tvbuff_t *, packet_info *, int, proto_tre static heur_dissector_list_t netbios_heur_subdissector_list; -void +static void dissect_netbios_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { heur_dtbl_entry_t *hdtbl_entry; diff --git a/epan/dissectors/packet-netbios.h b/epan/dissectors/packet-netbios.h index a57a43441b..7ea79ee03e 100644 --- a/epan/dissectors/packet-netbios.h +++ b/epan/dissectors/packet-netbios.h @@ -38,7 +38,5 @@ extern int get_netbios_name(tvbuff_t *tvb, int offset, extern const char *netbios_name_type_descr(int name_type); extern void netbios_add_name( const char* label, tvbuff_t *tvb, int offset, proto_tree *tree); -extern void dissect_netbios_payload(tvbuff_t *tvb, packet_info *pinfo, - proto_tree *tree); #endif -- cgit v1.2.3