From 1e60d63c8c6882c8c0bdb00cf6df594e1bb6fccf Mon Sep 17 00:00:00 2001 From: Michael Mann Date: Sat, 19 Mar 2016 20:33:14 -0400 Subject: Create call_data_dissector() to call data dissector. This saves many dissectors the need to find the data dissector and store a handle to it. There were also some that were finding it, but not using it. For others this was the only reason for their handoff function, so it could be eliminated. Change-Id: I5d3f951ee1daa3d30c060d21bd12bbc881a8027b Reviewed-on: https://code.wireshark.org/review/14530 Petri-Dish: Michael Mann Reviewed-by: Michael Mann --- plugins/irda/packet-ircomm.c | 19 ++++++++----------- plugins/irda/packet-irda.c | 15 ++++++--------- plugins/irda/packet-sir.c | 4 ---- 3 files changed, 14 insertions(+), 24 deletions(-) (limited to 'plugins/irda') diff --git a/plugins/irda/packet-ircomm.c b/plugins/irda/packet-ircomm.c index 7458f19e25..e9d79c122c 100644 --- a/plugins/irda/packet-ircomm.c +++ b/plugins/irda/packet-ircomm.c @@ -123,7 +123,6 @@ static gint ett_ircomm_ctrl = -1; #define MAX_PARAMETERS 32 static gint ett_param[MAX_IAP_ENTRIES * MAX_PARAMETERS]; -static dissector_handle_t data_handle; static dissector_handle_t ircomm_raw_handle; static dissector_handle_t ircomm_cooked_handle; @@ -191,10 +190,10 @@ static int dissect_cooked_ircomm(tvbuff_t* tvb, packet_info* pinfo, proto_tree* proto_tree_add_item(ctrl_tree, hf_control_len, tvb, offset, 1, ENC_BIG_ENDIAN); offset++; - call_dissector(data_handle, tvb_new_subset_length(tvb, offset, clen), pinfo, ctrl_tree); + call_data_dissector(tvb_new_subset_length(tvb, offset, clen), pinfo, ctrl_tree); offset += clen; - call_dissector(data_handle, tvb_new_subset_remaining(tvb, offset), pinfo, ircomm_tree); + call_data_dissector(tvb_new_subset_remaining(tvb, offset), pinfo, ircomm_tree); return len; } @@ -206,6 +205,8 @@ static int dissect_cooked_ircomm(tvbuff_t* tvb, packet_info* pinfo, proto_tree* static int dissect_raw_ircomm(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data _U_) { guint len = tvb_reported_length(tvb); + proto_item* ti; + proto_tree* ircomm_tree; if (len == 0) return 0; @@ -215,14 +216,11 @@ static int dissect_raw_ircomm(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tre col_add_fstr(pinfo->cinfo, COL_INFO, "User Data: %d byte%s", len, (len > 1)? "s": ""); - if (tree) - { - /* create display subtree for the protocol */ - proto_item* ti = proto_tree_add_item(tree, proto_ircomm, tvb, 0, -1, ENC_NA); - proto_tree* ircomm_tree = proto_item_add_subtree(ti, ett_ircomm); + /* create display subtree for the protocol */ + ti = proto_tree_add_item(tree, proto_ircomm, tvb, 0, -1, ENC_NA); + ircomm_tree = proto_item_add_subtree(ti, ett_ircomm); - call_dissector(data_handle, tvb, pinfo, ircomm_tree); - } + call_data_dissector(tvb, pinfo, ircomm_tree); return len; } @@ -420,7 +418,6 @@ void proto_register_ircomm(void) void proto_reg_handoff_ircomm(void) { - data_handle = find_dissector("data"); ircomm_raw_handle = find_dissector("ircomm_raw"); ircomm_cooked_handle = find_dissector("ircomm_cooked"); } diff --git a/plugins/irda/packet-irda.c b/plugins/irda/packet-irda.c index 322b739ba0..f9c46d33da 100644 --- a/plugins/irda/packet-irda.c +++ b/plugins/irda/packet-irda.c @@ -139,8 +139,6 @@ void proto_reg_handoff_irda(void); void proto_register_irda(void); -static dissector_handle_t data_handle; - /* Initialize the protocol and registered fields */ static int proto_irlap = -1; static int hf_lap_a = -1; @@ -645,7 +643,7 @@ static void dissect_iap_request(tvbuff_t* tvb, packet_info* pinfo, proto_tree* r /* If any bytes remain, send it to the generic data dissector */ tvb = tvb_new_subset_remaining(tvb, offset); - call_dissector(data_handle, tvb, pinfo, root); + call_data_dissector(tvb, pinfo, root); } @@ -895,7 +893,7 @@ static void dissect_iap_result(tvbuff_t* tvb, packet_info* pinfo, proto_tree* ro /* If any bytes remain, send it to the generic data dissector */ tvb = tvb_new_subset_remaining(tvb, offset); - call_dissector(data_handle, tvb, pinfo, root); + call_data_dissector(tvb, pinfo, root); } @@ -1007,7 +1005,7 @@ static void dissect_appl_proto(tvbuff_t* tvb, packet_info* pinfo, proto_tree* ro call_dissector_with_data(lmp_conv->dissector, tvb, pinfo, root, GUINT_TO_POINTER(pdu_type)); } else - call_dissector(data_handle, tvb, pinfo, root); + call_data_dissector(tvb, pinfo, root); } @@ -1159,7 +1157,7 @@ static void dissect_irlmp(tvbuff_t* tvb, packet_info* pinfo, proto_tree* root, g else { if ((dlsap == LSAP_IAS) || (slsap == LSAP_IAS)) - call_dissector(data_handle, tvb, pinfo, root); + call_data_dissector(tvb, pinfo, root); else switch (opcode) { @@ -1173,7 +1171,7 @@ static void dissect_irlmp(tvbuff_t* tvb, packet_info* pinfo, proto_tree* root, g break; default: - call_dissector(data_handle, tvb, pinfo, root); + call_data_dissector(tvb, pinfo, root); } } } @@ -1828,7 +1826,7 @@ static void dissect_irlap(tvbuff_t* tvb, packet_info* pinfo, proto_tree* root) if (tvb_reported_length_remaining(tvb, offset) > 0) { tvb = tvb_new_subset_remaining(tvb, offset); - call_dissector(data_handle, tvb, pinfo, root); + call_data_dissector(tvb, pinfo, root); } } @@ -2248,7 +2246,6 @@ void proto_reg_handoff_irda(void) irda_handle = find_dissector("irda"); dissector_add_uint("wtap_encap", WTAP_ENCAP_IRDA, irda_handle); dissector_add_uint("sll.ltype", LINUX_SLL_P_IRDA_LAP, irda_handle); - data_handle = find_dissector("data"); } /* diff --git a/plugins/irda/packet-sir.c b/plugins/irda/packet-sir.c index 526db940c7..98ee323390 100644 --- a/plugins/irda/packet-sir.c +++ b/plugins/irda/packet-sir.c @@ -47,7 +47,6 @@ void proto_reg_handoff_irsir(void); void proto_register_irsir(void); /** Protocol handles. */ -static dissector_handle_t data_handle; static dissector_handle_t irda_handle; /** Protocol fields. */ @@ -181,10 +180,7 @@ proto_reg_handoff_irsir(void) { dissector_add_uint("tcp.port", TCP_PORT_SIR, find_dissector("sir")); - data_handle = find_dissector("data"); irda_handle = find_dissector("irda"); - if (irda_handle == NULL) - irda_handle = data_handle; } -- cgit v1.2.3