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>
This commit is contained in:
Piotr Tulpan 2017-06-06 16:26:02 +02:00 committed by Michael Mann
parent 7cd552b5e0
commit ce93b4d178
4 changed files with 2 additions and 90 deletions

View File

@ -92,7 +92,6 @@ libwireshark.so.0 libwireshark0 #MINVER#
capture_dissector_add_uint@Base 2.3.0
capture_dissector_get_count@Base 2.1.0
capture_dissector_increment_count@Base 2.1.0
check_xdlc_control@Base 1.9.1
chunk_type_values@Base 2.1.0
circuit_add_proto_data@Base 1.9.1
circuit_get_proto_data@Base 1.9.1

View File

@ -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);
}
/*

View File

@ -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,

View File

@ -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,