diff options
author | Piotr Tulpan <piotr.tulpan@netscan.pl> | 2017-06-06 16:26:02 +0200 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2017-06-08 20:22:33 +0000 |
commit | ce93b4d178ec8f8d47d2063387465dff1be822d7 (patch) | |
tree | b824b7e5e9f3afd2e2cc0793b1856104ce84c80b /epan | |
parent | 7cd552b5e0031d63ddecb4ef1d85fd369de10e2a (diff) |
packet-lapd.c: Replace heuristic UDP dissector with "deterministic" one with prefs.
Remove the heuristic dissector that checks for arbitrary UDP ports in favor
of adding a preference for the range of UDP ports that can be used for LAPD.
Change-Id: Ib85fbee4a433727af24279fffb0cbf2c25f7d292
Reviewed-on: https://code.wireshark.org/review/21985
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan')
-rw-r--r-- | epan/dissectors/packet-lapd.c | 25 | ||||
-rw-r--r-- | epan/xdlc.c | 58 | ||||
-rw-r--r-- | epan/xdlc.h | 8 |
3 files changed, 2 insertions, 89 deletions
diff --git a/epan/dissectors/packet-lapd.c b/epan/dissectors/packet-lapd.c index 5f91173504..b686daae68 100644 --- a/epan/dissectors/packet-lapd.c +++ b/epan/dissectors/packet-lapd.c @@ -569,28 +569,6 @@ dissect_lapd_full(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean call_data_dissector(next_tvb, pinfo, tree); } -static gboolean -dissect_udp_lapd(tvbuff_t *tvb, packet_info *pinfo _U_ , proto_tree *tree, void *data _U_) -{ - if (pinfo->srcport < 3001 || pinfo->srcport > 3015 - || pinfo->destport < 3001 || pinfo->destport > 3015 - || pinfo->destport != pinfo->srcport) - return FALSE; - - /* - * XXX - check for a valid LAPD address field. - */ - - /* - * OK, check whether the control field looks valid. - */ - if (!check_xdlc_control(tvb, 2, NULL, NULL, FALSE, FALSE)) - return FALSE; - - dissect_lapd(tvb, pinfo, tree, data); - return TRUE; -} - void proto_register_lapd(void) { @@ -748,10 +726,10 @@ proto_reg_handoff_lapd(void) dissector_add_uint("wtap_encap", WTAP_ENCAP_LINUX_LAPD, lapd_handle); dissector_add_uint("wtap_encap", WTAP_ENCAP_LAPD, lapd_handle); dissector_add_uint("l2tp.pw_type", L2TPv3_PROTOCOL_LAPD, lapd_handle); - heur_dissector_add("udp", dissect_udp_lapd, "LAPD over UDP", "lapd_udp", proto_lapd, HEURISTIC_ENABLE); dissector_add_for_decode_as("sctp.ppi", lapd_handle); dissector_add_for_decode_as("sctp.port", lapd_handle); + dissector_add_uint_range_with_preference("udp.port", "", lapd_handle); init = TRUE; } else { @@ -769,6 +747,7 @@ proto_reg_handoff_lapd(void) lapd_sctp_ppi = pref_lapd_sctp_ppi; if (lapd_sctp_ppi > 0) dissector_add_uint("sctp.ppi", lapd_sctp_ppi, lapd_handle); + } /* diff --git a/epan/xdlc.c b/epan/xdlc.c index d6c5453d14..06af5ec3f0 100644 --- a/epan/xdlc.c +++ b/epan/xdlc.c @@ -166,64 +166,6 @@ get_xdlc_control(const guchar *pd, int offset, gboolean is_extended) return control; } -/* - * Check whether the control field of the packet looks valid. - */ -gboolean -check_xdlc_control(tvbuff_t *tvb, int offset, - const value_string *u_modifier_short_vals_cmd, - const value_string *u_modifier_short_vals_resp, gboolean is_response, - gboolean is_extended _U_) -{ - guint16 control; - - if (!tvb_bytes_exist(tvb, offset, 1)) - return FALSE; /* not enough data to check */ - switch (tvb_get_guint8(tvb, offset) & 0x03) { - - case XDLC_S: - /* - * Supervisory frame. - * No fields to check for validity here. - */ - return TRUE; - - case XDLC_U: - /* - * Unnumbered frame. - * - * XXX - is this two octets, with a P/F bit, in HDLC extended - * operation? It's one octet in LLC, even though the control - * field of I and S frames is a 2-byte extended-operation field - * in LLC. Given that there are no sequence numbers in the - * control field of a U frame, there doesn't appear to be any - * need for it to be 2 bytes in extended operation. - */ - if (u_modifier_short_vals_cmd == NULL) - u_modifier_short_vals_cmd = modifier_short_vals_cmd; - if (u_modifier_short_vals_resp == NULL) - u_modifier_short_vals_resp = modifier_short_vals_resp; - control = tvb_get_guint8(tvb, offset); - if (is_response) { - if (try_val_to_str(control & XDLC_U_MODIFIER_MASK, - u_modifier_short_vals_resp) == NULL) - return FALSE; /* unknown modifier */ - } else { - if (try_val_to_str(control & XDLC_U_MODIFIER_MASK, - u_modifier_short_vals_cmd) == NULL) - return FALSE; /* unknown modifier */ - } - return TRUE; - - default: - /* - * Information frame. - * No fields to check for validity here. - */ - return TRUE; - } -} - int dissect_xdlc_control(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *xdlc_tree, int hf_xdlc_control, gint ett_xdlc_control, diff --git a/epan/xdlc.h b/epan/xdlc.h index 525f30b393..f7fc79fe00 100644 --- a/epan/xdlc.h +++ b/epan/xdlc.h @@ -134,14 +134,6 @@ extern const value_string modifier_vals_resp[]; extern int get_xdlc_control(const guchar *pd, int offset, gboolean is_extended); -/** - * Check whether the control field of the packet looks valid. - */ -WS_DLL_PUBLIC gboolean check_xdlc_control(tvbuff_t *tvb, int offset, - const value_string *u_modifier_short_vals_cmd, - const value_string *u_modifier_short_vals_resp, gboolean is_response, - gboolean is_extended _U_); - WS_DLL_PUBLIC int dissect_xdlc_control(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *xdlc_tree, int hf_xdlc_control, gint ett_xdlc_control, const xdlc_cf_items *cf_items_nonext, const xdlc_cf_items *cf_items_ext, |