summaryrefslogtreecommitdiff
path: root/plugins/irda
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2014-11-22 23:11:32 -0500
committerMichael Mann <mmann78@netscape.net>2014-11-23 05:13:52 +0000
commite50095c60094e9fa76f07e3c91154d1508e0d42c (patch)
treebc8074373e14c92adb5d446d56d99e58a4fbccf0 /plugins/irda
parente90880477638940645703bc0ddcac6b4079ad4ce (diff)
downloadwireshark-e50095c60094e9fa76f07e3c91154d1508e0d42c.tar.gz
Remove use of pinfo->private_data (which doesn't appear to be used anyway) and pass it as dissector data.
Some other minor cleanup while in the neighborhood. Change-Id: I1b0c0567488fa350c14d21c5f5e4cb9746177af1 Reviewed-on: https://code.wireshark.org/review/5447 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 'plugins/irda')
-rw-r--r--plugins/irda/irda-appl.h2
-rw-r--r--plugins/irda/packet-ircomm.c75
-rw-r--r--plugins/irda/packet-irda.c16
3 files changed, 44 insertions, 49 deletions
diff --git a/plugins/irda/irda-appl.h b/plugins/irda/irda-appl.h
index df0a8f0105..a030a506c3 100644
--- a/plugins/irda/irda-appl.h
+++ b/plugins/irda/irda-appl.h
@@ -67,7 +67,7 @@ extern gboolean check_iap_octet_result(tvbuff_t* tvb, proto_tree* tree, guint of
extern guint8 check_iap_lsap_result(tvbuff_t* tvb, proto_tree* tree, guint offset,
const char* attr_name, guint8 attr_type);
-extern void add_lmp_conversation(packet_info* pinfo, guint8 dlsap, gboolean ttp, dissector_t proto_dissector, guint8 circuit_id);
+extern void add_lmp_conversation(packet_info* pinfo, guint8 dlsap, gboolean ttp, dissector_handle_t dissector, guint8 circuit_id);
extern unsigned dissect_param_tuple(tvbuff_t* tvb, proto_tree* tree, guint offset);
diff --git a/plugins/irda/packet-ircomm.c b/plugins/irda/packet-ircomm.c
index bcfc5f36a6..8eccb48e35 100644
--- a/plugins/irda/packet-ircomm.c
+++ b/plugins/irda/packet-ircomm.c
@@ -126,6 +126,8 @@ static gint ett_ircomm_ctrl = -1;
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;
static int proto_ircomm = -1;
static int hf_ircomm_param = -1;
@@ -160,16 +162,17 @@ ias_attr_dissector_t irlpt_attr_dissector[] = {
/*
* Dissect the cooked IrCOMM protocol
*/
-static void dissect_cooked_ircomm(tvbuff_t* tvb, packet_info* pinfo, proto_tree* root)
+static int dissect_cooked_ircomm(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data _U_)
{
+ proto_item *ti;
+ proto_tree *ircomm_tree, *ctrl_tree;
guint offset = 0;
guint clen;
- char buf[128];
- guint len;
+ guint len = tvb_length(tvb);
- if (tvb_length(tvb) == 0)
- return;
+ if (len == 0)
+ return len;
/* Make entries in Protocol column on summary display */
col_set_str(pinfo->cinfo, COL_PROTOCOL, "IrCOMM");
@@ -177,64 +180,54 @@ static void dissect_cooked_ircomm(tvbuff_t* tvb, packet_info* pinfo, proto_tree*
clen = tvb_get_guint8(tvb, offset);
len = tvb_length(tvb) - 1 - clen;
-
-
if (len > 0)
- g_snprintf(buf, 128, "Clen=%d, UserData: %d byte%s", clen, len, (len > 1)? "s": "");
+ col_add_fstr(pinfo->cinfo, COL_INFO, "Clen=%d, UserData: %d byte%s", clen, len, (len > 1)? "s": "");
else
- g_snprintf(buf, 128, "Clen=%d", clen);
- col_add_str(pinfo->cinfo, COL_INFO, buf);
+ col_add_fstr(pinfo->cinfo, COL_INFO, "Clen=%d", clen);
- if (root)
- {
- /* create display subtree for the protocol */
- proto_item* ti = proto_tree_add_item(root, proto_ircomm, tvb, 0, -1, ENC_NA);
- proto_tree* 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);
- proto_tree* ctrl_tree;
+ ti = proto_tree_add_item(ircomm_tree, hf_control, tvb, 0, clen + 1, ENC_NA);
+ ctrl_tree = proto_item_add_subtree(ti, ett_ircomm_ctrl);
+ 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);
+ offset += clen;
- ti = proto_tree_add_item(tree, hf_control, tvb, 0, clen + 1, ENC_NA);
- ctrl_tree = proto_item_add_subtree(ti, ett_ircomm_ctrl);
- proto_tree_add_item(ctrl_tree, hf_control_len, tvb, offset, 1, ENC_BIG_ENDIAN);
- offset++;
- {
- tvbuff_t *cvalue = tvb_new_subset_length(tvb, offset, clen);
- call_dissector(data_handle, cvalue, pinfo, ctrl_tree);
- offset += clen;
- }
+ call_dissector(data_handle, tvb_new_subset_remaining(tvb, offset), pinfo, ircomm_tree);
- tvb = tvb_new_subset_remaining(tvb, offset);
- call_dissector(data_handle, tvb, pinfo, tree);
- }
+ return len;
}
/*
* Dissect the raw IrCOMM/IrLPT protocol
*/
-static void dissect_raw_ircomm(tvbuff_t* tvb, packet_info* pinfo, proto_tree* root)
+static int dissect_raw_ircomm(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data _U_)
{
guint len = tvb_length(tvb);
- char buf[128];
if (len == 0)
- return;
+ return 0;
/* Make entries in Protocol column on summary display */
col_set_str(pinfo->cinfo, COL_PROTOCOL, "IrCOMM");
- g_snprintf(buf, 128, "User Data: %d byte%s", len, (len > 1)? "s": "");
- col_add_str(pinfo->cinfo, COL_INFO, buf);
+ col_add_fstr(pinfo->cinfo, COL_INFO, "User Data: %d byte%s", len, (len > 1)? "s": "");
- if (root)
+ if (tree)
{
/* create display subtree for the protocol */
- proto_item* ti = proto_tree_add_item(root, proto_ircomm, tvb, 0, -1, ENC_NA);
- proto_tree* tree = proto_item_add_subtree(ti, ett_ircomm);
+ 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);
- call_dissector(data_handle, tvb, pinfo, tree);
+ call_dissector(data_handle, tvb, pinfo, ircomm_tree);
}
+
+ return len;
}
@@ -340,7 +333,7 @@ static gboolean dissect_ircomm_ttp_lsap(tvbuff_t* tvb, guint offset, packet_info
if ((dlsap = check_iap_lsap_result(tvb, tree, offset, "IrDA:TinyTP:LsapSel", attr_type)) == 0)
return FALSE;
- add_lmp_conversation(pinfo, dlsap, TRUE, dissect_cooked_ircomm, circuit_id);
+ add_lmp_conversation(pinfo, dlsap, TRUE, ircomm_cooked_handle, circuit_id);
return FALSE;
}
@@ -358,7 +351,7 @@ static gboolean dissect_ircomm_lmp_lsap(tvbuff_t* tvb, guint offset, packet_info
if ((dlsap = check_iap_lsap_result(tvb, tree, offset, "IrDA:IrLMP:LsapSel", attr_type)) == 0)
return FALSE;
- add_lmp_conversation(pinfo, dlsap, FALSE, dissect_raw_ircomm, circuit_id);
+ add_lmp_conversation(pinfo, dlsap, FALSE, ircomm_raw_handle, circuit_id);
return FALSE;
}
@@ -412,6 +405,8 @@ void proto_register_ircomm(void)
/* Register protocol names and descriptions */
proto_ircomm = proto_register_protocol("IrCOMM Protocol", "IrCOMM", "ircomm");
+ new_register_dissector("ircomm_raw", dissect_raw_ircomm, proto_ircomm);
+ new_register_dissector("ircomm_cooked", dissect_cooked_ircomm, proto_ircomm);
/* Required function calls to register the header fields */
proto_register_field_array(proto_ircomm, hf_ircomm, array_length(hf_ircomm));
@@ -429,6 +424,8 @@ 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 c7b9f30f0a..c858566754 100644
--- a/plugins/irda/packet-irda.c
+++ b/plugins/irda/packet-irda.c
@@ -265,7 +265,7 @@ typedef struct lmp_conversation {
struct lmp_conversation* pnext;
guint32 iap_result_frame;
gboolean ttp;
- dissector_t proto_dissector;
+ dissector_handle_t dissector;
} lmp_conversation_t;
static const true_false_string lap_cr_vals = {
@@ -626,10 +626,10 @@ static void dissect_iap_request(tvbuff_t* tvb, packet_info* pinfo, proto_tree* r
switch (op)
{
case GET_VALUE_BY_CLASS:
- proto_tree_add_item(tree, hf_iap_class_name, tvb, offset, 1, ENC_ASCII|ENC_NA);
+ proto_tree_add_item(tree, hf_iap_class_name, tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN);
offset += 1 + clen;
- proto_tree_add_item(tree, hf_iap_attr_name, tvb, offset, 1, ENC_ASCII|ENC_NA);
+ proto_tree_add_item(tree, hf_iap_attr_name, tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN);
offset += 1 + alen;
break;
}
@@ -841,7 +841,7 @@ static void dissect_iap_result(tvbuff_t* tvb, packet_info* pinfo, proto_tree* ro
if (!iap_conv || !iap_conv->pattr_dissector ||
!iap_conv->pattr_dissector->value_dissector(tvb, offset, pinfo, entry_tree,
n, type, circuit_id))
- proto_tree_add_item(entry_tree, hf_iap_string, tvb, offset + 1, 1, ENC_ASCII|ENC_NA);
+ proto_tree_add_item(entry_tree, hf_iap_string, tvb, offset + 1, 1, ENC_ASCII|ENC_BIG_ENDIAN);
break;
}
offset += attr_len;
@@ -1018,9 +1018,7 @@ static void dissect_appl_proto(tvbuff_t* tvb, packet_info* pinfo, proto_tree* ro
tvb = tvb_new_subset_remaining(tvb, offset);
}
- pinfo->private_data = (void *)pdu_type;
-
- lmp_conv->proto_dissector(tvb, pinfo, root);
+ call_dissector_with_data(lmp_conv->dissector, tvb, pinfo, root, GUINT_TO_POINTER(pdu_type));
}
else
call_dissector(data_handle, tvb, pinfo, root);
@@ -1198,7 +1196,7 @@ static void dissect_irlmp(tvbuff_t* tvb, packet_info* pinfo, proto_tree* root, g
/*
* Add LMP conversation
*/
-void add_lmp_conversation(packet_info* pinfo, guint8 dlsap, gboolean ttp, dissector_t proto_dissector, guint8 circuit_id)
+void add_lmp_conversation(packet_info* pinfo, guint8 dlsap, gboolean ttp, dissector_handle_t dissector, guint8 circuit_id)
{
guint8 dest;
address srcaddr;
@@ -1246,7 +1244,7 @@ void add_lmp_conversation(packet_info* pinfo, guint8 dlsap, gboolean ttp, dissec
lmp_conv->pnext = NULL;
lmp_conv->iap_result_frame = pinfo->fd->num;
lmp_conv->ttp = ttp;
- lmp_conv->proto_dissector = proto_dissector;
+ lmp_conv->dissector = dissector;
/*g_message("%p\n", lmp_conv); */
}