aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-distcc.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2014-08-03 21:10:24 -0400
committerAnders Broman <a.broman58@gmail.com>2014-08-05 07:36:26 +0000
commit9d5f9141af289d3d8b253907eaaae101da1bd9fd (patch)
tree4d2816511482c04e3e8af66bd6251f5f7ce2dc2f /epan/dissectors/packet-distcc.c
parentedbb9edf3928e79b41f9b84d2399205810febef2 (diff)
Eliminate proto_tree_add_text from some dissectors.
Other minor cleanup while in the area. Change-Id: Id8d957d3d68a2e3dd5089f490bd59d773e1be967 Reviewed-on: https://code.wireshark.org/review/3427 Reviewed-by: Michael Mann <mmann78@netscape.net> Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-distcc.c')
-rw-r--r--epan/dissectors/packet-distcc.c50
1 files changed, 28 insertions, 22 deletions
diff --git a/epan/dissectors/packet-distcc.c b/epan/dissectors/packet-distcc.c
index 196ca7a92d..44ac975112 100644
--- a/epan/dissectors/packet-distcc.c
+++ b/epan/dissectors/packet-distcc.c
@@ -32,7 +32,7 @@
#include <glib.h>
#include <epan/packet.h>
-
+#include <epan/expert.h>
#include <epan/prefs.h>
@@ -49,6 +49,8 @@ static int hf_distcc_doto_object = -1;
static gint ett_distcc = -1;
+static expert_field ei_distcc_short_pdu = EI_INIT;
+
static dissector_handle_t data_handle;
@@ -75,7 +77,7 @@ extern void proto_reg_handoff_distcc(void);
/* only attempt reassembly if whe have the full segment */\
if(tvb_length_remaining(tvb, offset)==tvb_reported_length_remaining(tvb, offset)){\
if(parameter>tvb_length_remaining(tvb, offset)){\
- proto_tree_add_text(tree, tvb, offset-12, -1, "[Short " x " PDU]");\
+ proto_tree_add_expert_format(tree, pinfo, &ei_distcc_short_pdu, tvb, offset-12, -1, "[Short " x " PDU]");\
pinfo->desegment_offset=offset-12;\
pinfo->desegment_len=parameter-tvb_length_remaining(tvb, offset);\
return offset+len;\
@@ -133,25 +135,23 @@ dissect_distcc_argv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int
char argv[256];
int argv_len;
gint len=parameter;
-
+ proto_item* ti;
CHECK_PDU_LEN("ARGV");
/* see if we need to desegment the PDU */
DESEGMENT_TCP("ARGV");
-
-
argv_len=len>255?255:len;
tvb_memcpy(tvb, argv, offset, argv_len);
argv[argv_len]=0;
- proto_tree_add_item(tree, hf_distcc_argv, tvb, offset, len, ENC_ASCII|ENC_NA);
+ ti = proto_tree_add_item(tree, hf_distcc_argv, tvb, offset, len, ENC_ASCII|ENC_NA);
col_append_fstr(pinfo->cinfo, COL_INFO, "%s ", argv);
if(len!=parameter){
- proto_tree_add_text(tree, tvb, 0, 0, "[Short ARGV PDU]");
+ expert_add_info_format(pinfo, ti, &ei_distcc_short_pdu, "[Short ARGV PDU]");
}
return offset+len;
}
@@ -162,7 +162,7 @@ dissect_distcc_serr(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int
char argv[256];
int argv_len;
gint len=parameter;
-
+ proto_item* ti;
CHECK_PDU_LEN("SERR");
@@ -175,12 +175,12 @@ dissect_distcc_serr(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int
tvb_memcpy(tvb, argv, offset, argv_len);
argv[argv_len]=0;
- proto_tree_add_item(tree, hf_distcc_serr, tvb, offset, len, ENC_ASCII|ENC_NA);
+ ti = proto_tree_add_item(tree, hf_distcc_serr, tvb, offset, len, ENC_ASCII|ENC_NA);
col_append_fstr(pinfo->cinfo, COL_INFO, "SERR:%s ", argv);
if(len!=parameter){
- proto_tree_add_text(tree, tvb, 0, 0, "[Short SERR PDU]");
+ expert_add_info_format(pinfo, ti, &ei_distcc_short_pdu, "[Short SERR PDU]");
}
return offset+len;
}
@@ -191,25 +191,23 @@ dissect_distcc_sout(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int
char argv[256];
int argv_len;
gint len=parameter;
-
+ proto_item* ti;
CHECK_PDU_LEN("SOUT");
/* see if we need to desegment the PDU */
DESEGMENT_TCP("SOUT");
-
-
argv_len=len>255?255:len;
tvb_memcpy(tvb, argv, offset, argv_len);
argv[argv_len]=0;
- proto_tree_add_item(tree, hf_distcc_sout, tvb, offset, len, ENC_ASCII|ENC_NA);
+ ti = proto_tree_add_item(tree, hf_distcc_sout, tvb, offset, len, ENC_ASCII|ENC_NA);
col_append_fstr(pinfo->cinfo, COL_INFO, "SOUT:%s ", argv);
if(len!=parameter){
- proto_tree_add_text(tree, tvb, 0, 0, "[Short SOUT PDU]");
+ expert_add_info_format(pinfo, ti, &ei_distcc_short_pdu, "[Short SOUT PDU]");
}
return offset+len;
}
@@ -219,7 +217,7 @@ static int
dissect_distcc_doti(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, gint parameter)
{
gint len=parameter;
-
+ proto_item* ti;
CHECK_PDU_LEN("DOTI");
@@ -228,9 +226,9 @@ dissect_distcc_doti(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int off
col_append_str(pinfo->cinfo, COL_INFO, "DOTI source ");
- proto_tree_add_item(tree, hf_distcc_doti_source, tvb, offset, len, ENC_ASCII|ENC_NA);
+ ti = proto_tree_add_item(tree, hf_distcc_doti_source, tvb, offset, len, ENC_ASCII|ENC_NA);
if(len!=parameter){
- proto_tree_add_text(tree, tvb, 0, 0, "[Short DOTI PDU]");
+ expert_add_info_format(pinfo, ti, &ei_distcc_short_pdu, "[Short DOTI PDU]");
}
return offset+len;
}
@@ -239,6 +237,7 @@ static int
dissect_distcc_doto(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, gint parameter)
{
gint len=parameter;
+ proto_item* ti;
CHECK_PDU_LEN("DOTO");
@@ -248,9 +247,9 @@ dissect_distcc_doto(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int off
col_append_str(pinfo->cinfo, COL_INFO, "DOTO object ");
- proto_tree_add_item(tree, hf_distcc_doto_object, tvb, offset, len, ENC_NA);
+ ti = proto_tree_add_item(tree, hf_distcc_doto_object, tvb, offset, len, ENC_NA);
if(len!=parameter){
- proto_tree_add_text(tree, tvb, 0, 0, "[Short DOTO PDU]");
+ expert_add_info_format(pinfo, ti, &ei_distcc_short_pdu, "[Short DOTO PDU]");
}
return offset+len;
}
@@ -359,12 +358,19 @@ proto_register_distcc(void)
&ett_distcc,
};
+ static ei_register_info ei[] = {
+ { &ei_distcc_short_pdu, { "distcc.short_pdu", PI_MALFORMED, PI_ERROR, "Short PDU", EXPFILL }},
+ };
+
module_t *distcc_module;
+ expert_module_t* expert_distcc;
+
+ proto_distcc = proto_register_protocol("Distcc Distributed Compiler", "DISTCC", "distcc");
- proto_distcc = proto_register_protocol("Distcc Distributed Compiler",
- "DISTCC", "distcc");
proto_register_field_array(proto_distcc, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
+ expert_distcc = expert_register_protocol(proto_distcc);
+ expert_register_field_array(expert_distcc, ei, array_length(ei));
distcc_module = prefs_register_protocol(proto_distcc,
proto_reg_handoff_distcc);