aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-icp.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2014-11-01 16:55:25 -0400
committerAlexis La Goutte <alexis.lagoutte@gmail.com>2014-11-02 15:42:28 +0000
commitba008bf746843b11b98a18b957637431249d5132 (patch)
tree8f1fb2dbbf2d3b89f1a1eee33de3e9bd92ca72dd /epan/dissectors/packet-icp.c
parentf19c70c952e40bb2ec15b2cfa1e1df90919d02a0 (diff)
Eliminate proto_tree_add_text from several dissectors.
Change-Id: I6d3125f15d268edd47ef74dd655eb86cb25ee52d Reviewed-on: https://code.wireshark.org/review/5047 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: Alexis La Goutte <alexis.lagoutte@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-icp.c')
-rw-r--r--epan/dissectors/packet-icp.c89
1 files changed, 53 insertions, 36 deletions
diff --git a/epan/dissectors/packet-icp.c b/epan/dissectors/packet-icp.c
index fb64c0ea10..a4345519e1 100644
--- a/epan/dissectors/packet-icp.c
+++ b/epan/dissectors/packet-icp.c
@@ -23,26 +23,38 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#define MAX_TEXTBUF_LENGTH 600
#include "config.h"
#include <glib.h>
#include <epan/packet.h>
-#include <epan/addr_resolv.h>
+#include <epan/expert.h>
void proto_register_icp(void);
void proto_reg_handoff_icp(void);
-static int proto_icp=-1;
-static int hf_icp_length=-1;
-static int hf_icp_opcode=-1;
-static int hf_icp_version=-1;
-static int hf_icp_request_nr=-1;
+static int proto_icp = -1;
+static int hf_icp_length = -1;
+static int hf_icp_opcode = -1;
+static int hf_icp_version = -1;
+static int hf_icp_request_nr = -1;
+
+/* Generated from convert_proto_tree_add_text.pl */
+static int hf_icp_url = -1;
+static int hf_icp_rtt = -1;
+static int hf_icp_object_data = -1;
+static int hf_icp_requester_host_address = -1;
+static int hf_icp_sender_host_ip_address = -1;
+static int hf_icp_option_src_rtt = -1;
+static int hf_icp_object_length = -1;
+static int hf_icp_option_hit_obj = -1;
static gint ett_icp = -1;
static gint ett_icp_payload = -1;
+/* Generated from convert_proto_tree_add_text.pl */
+static expert_field ei_icp_fragmented_packet = EI_INIT;
+
#define UDP_PORT_ICP 3130
#define CODE_ICP_OP_QUERY 1
@@ -80,25 +92,23 @@ static const value_string opcode_vals[] = {
{ 0, NULL}
};
-static void dissect_icp_payload(tvbuff_t *tvb, int offset,
+static void dissect_icp_payload(tvbuff_t *tvb, packet_info *pinfo, int offset,
proto_tree *pload_tree, guint8 opcode)
{
gint stringlength;
guint16 objectlength;
+ proto_item* object_item;
switch(opcode)
{
case CODE_ICP_OP_QUERY:
/* 4 byte requester host address */
- proto_tree_add_text(pload_tree, tvb,offset,4,
- "Requester Host Address %s",
- tvb_ip_to_str(tvb, offset));
+ proto_tree_add_item(pload_tree, hf_icp_requester_host_address, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
/* null terminated URL */
stringlength = tvb_strsize(tvb, offset);
- proto_tree_add_text(pload_tree, tvb, offset, stringlength,
- "URL: %s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset, stringlength, ENC_ASCII));
+ proto_tree_add_item(pload_tree, hf_icp_url, tvb, offset, stringlength, ENC_ASCII|ENC_NA);
break;
case CODE_ICP_OP_SECHO:
@@ -109,29 +119,26 @@ static void dissect_icp_payload(tvbuff_t *tvb, int offset,
case CODE_ICP_OP_MISS_NOFETCH:
case CODE_ICP_OP_DENIED:
stringlength = tvb_strsize(tvb, offset);
- proto_tree_add_text(pload_tree, tvb, offset, stringlength,
- "URL: %s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset, stringlength, ENC_ASCII));
+ proto_tree_add_item(pload_tree, hf_icp_url, tvb, offset, stringlength, ENC_ASCII|ENC_NA);
break;
case CODE_ICP_OP_HIT_OBJ:
/* null terminated URL */
stringlength = tvb_strsize(tvb, offset);
- proto_tree_add_text(pload_tree, tvb, offset, stringlength,
- "URL: %s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset, stringlength, ENC_ASCII));
+ proto_tree_add_item(pload_tree, hf_icp_url, tvb, offset, stringlength, ENC_ASCII|ENC_NA);
offset += stringlength;
/* 2 byte object size */
/* object data not recommended by standard*/
objectlength=tvb_get_ntohs(tvb, offset);
- proto_tree_add_text(pload_tree, tvb,offset,2,"Object length: %u", objectlength);
+ proto_tree_add_item(pload_tree, hf_icp_object_length, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
/* object data not recommended by standard*/
- proto_tree_add_text(pload_tree, tvb,offset,objectlength,"Object data");
+ object_item = proto_tree_add_item(pload_tree, hf_icp_object_data, tvb, offset, objectlength, ENC_NA);
if (objectlength > tvb_reported_length_remaining(tvb, offset))
{
- proto_tree_add_text(pload_tree, tvb,offset,0,
- "Packet is fragmented, rest of object is in next udp packet");
+ expert_add_info(pinfo, object_item, &ei_icp_fragmented_packet);
}
break;
default:
@@ -147,7 +154,6 @@ static void dissect_icp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
guint16 message_length;
guint32 request_number;
guint32 options;
- guint32 option_data;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "ICP");
col_clear(pinfo->cinfo, COL_INFO);
@@ -178,30 +184,24 @@ static void dissect_icp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
options=tvb_get_ntohl(tvb, 8);
if ( (opcode == CODE_ICP_OP_QUERY) && ((options & 0x80000000 ) != 0) )
{
- proto_tree_add_text(icp_tree, tvb,8,4,
- "option: ICP_FLAG_HIT_OBJ");
+ proto_tree_add_item(icp_tree, hf_icp_option_hit_obj, tvb, 8, 4, ENC_NA);
}
if ( (opcode == CODE_ICP_OP_QUERY)&& ((options & 0x40000000 ) != 0) )
{
- proto_tree_add_text(icp_tree, tvb,8,4,
- "option:ICP_FLAG_SRC_RTT");
+ proto_tree_add_item(icp_tree, hf_icp_option_src_rtt, tvb, 8, 4, ENC_NA);
}
if ((opcode != CODE_ICP_OP_QUERY)&& ((options & 0x40000000 ) != 0))
{
- option_data=tvb_get_ntohl(tvb, 12);
- proto_tree_add_text(icp_tree, tvb,8,8,
- "option: ICP_FLAG_SCR_RTT RTT=%u",
- option_data & 0x0000ffff);
+ proto_tree_add_item(icp_tree, hf_icp_option_src_rtt, tvb, 8, 4, ENC_NA);
+ proto_tree_add_item(icp_tree, hf_icp_rtt, tvb, 12, 4, ENC_BIG_ENDIAN);
}
- proto_tree_add_text(icp_tree, tvb, 16, 4,
- "Sender Host IP address %s",
- tvb_ip_to_str(tvb, 16));
+ proto_tree_add_item(icp_tree, hf_icp_sender_host_ip_address, tvb, 16, 4, ENC_BIG_ENDIAN);
payload_tree = proto_tree_add_subtree(icp_tree, tvb,
20, message_length - 20,
ett_icp_payload, NULL, "Payload");
- dissect_icp_payload(tvb, 20, payload_tree, opcode);
+ dissect_icp_payload(tvb, pinfo, 20, payload_tree, opcode);
}
}
void
@@ -223,16 +223,33 @@ proto_register_icp(void)
{ &hf_icp_request_nr,
{ "Request Number", "icp.nr", FT_UINT32, BASE_DEC, NULL,
0x0, NULL, HFILL }},
+
+ { &hf_icp_requester_host_address, { "Requester Host Address", "icp.requester_host_address", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
+ { &hf_icp_url, { "URL", "icp.url", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
+ { &hf_icp_object_length, { "Object length", "icp.object_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
+ { &hf_icp_object_data, { "Object data", "icp.object_data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
+ { &hf_icp_option_hit_obj, { "Option: ICP_FLAG_HIT_OBJ", "icp.option.hit_obj", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
+ { &hf_icp_option_src_rtt, { "Option: ICP_FLAG_SRC_RTT", "icp.option.src_rtt", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
+ { &hf_icp_rtt, { "RTT", "icp.rtt", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
+ { &hf_icp_sender_host_ip_address, { "Sender Host IP address", "icp.sender_host_ip_address", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }},
};
static gint *ett[] = {
&ett_icp,
&ett_icp_payload,
};
- proto_icp = proto_register_protocol("Internet Cache Protocol",
- "ICP", "icp");
+ static ei_register_info ei[] = {
+ { &ei_icp_fragmented_packet, { "icp.fragmented_packet", PI_PROTOCOL, PI_WARN, "Packet is fragmented", EXPFILL }},
+ };
+
+ expert_module_t* expert_icp;
+
+ proto_icp = proto_register_protocol("Internet Cache Protocol", "ICP", "icp");
+
proto_register_field_array(proto_icp, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
+ expert_icp = expert_register_protocol(proto_icp);
+ expert_register_field_array(expert_icp, ei, array_length(ei));
}
void