summaryrefslogtreecommitdiff
path: root/epan/dissectors/packet-hip.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2014-08-09 13:43:44 -0400
committerMichael Mann <mmann78@netscape.net>2014-08-10 21:39:20 +0000
commit3635d7bed70aaf14e8172654f2b40be318e7dbfe (patch)
tree4b0fce1dba327df9a24b4ddc267a83375c817683 /epan/dissectors/packet-hip.c
parent18346c84778019fe6eee6906758daa120f84d5d0 (diff)
downloadwireshark-3635d7bed70aaf14e8172654f2b40be318e7dbfe.tar.gz
Eliminate proto_tree_add_text from some dissectors.
Other minor cleanup while in the neighborhood. Change-Id: Ib76f4a9f89b5933425760af0a980c6a549031b8f Reviewed-on: https://code.wireshark.org/review/3537 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 'epan/dissectors/packet-hip.c')
-rw-r--r--epan/dissectors/packet-hip.c408
1 files changed, 214 insertions, 194 deletions
diff --git a/epan/dissectors/packet-hip.c b/epan/dissectors/packet-hip.c
index 6dd263fd11..71d67178c3 100644
--- a/epan/dissectors/packet-hip.c
+++ b/epan/dissectors/packet-hip.c
@@ -35,6 +35,7 @@
#include "config.h"
#include <epan/packet.h>
+#include <epan/expert.h>
#include <epan/addr_resolv.h>
#include <epan/ipproto.h>
@@ -296,7 +297,7 @@ static const value_string hit_suite_vals[] = {
};
/* functions */
-static int dissect_hip_tlv(tvbuff_t *tvb, int offset, proto_item *ti, int type, int tlv_len);
+static int dissect_hip_tlv(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_item *ti, int type, int tlv_len);
static int proto_hip = -1;
static int hf_hip_proto = -1;
@@ -399,6 +400,9 @@ static int hf_hip_tlv_reg_from_port = -1;
static int hf_hip_tlv_reg_from_protocol = -1;
static int hf_hip_tlv_reg_from_reserved = -1;
static int hf_hip_tlv_reg_from_address = -1;
+static int hf_hip_encrypted_parameter_data = -1;
+static int hf_hip_fqdn = -1;
+static int hf_hip_nai = -1;
static gint ett_hip = -1;
static gint ett_hip_controls = -1;
@@ -407,171 +411,172 @@ static gint ett_hip_tlv_data = -1;
static gint ett_hip_tlv_host_id_hdr = -1;
static gint ett_hip_locator_data = -1;
+static expert_field ei_hip_tlv_host_id_len = EI_INIT;
+static expert_field ei_hip_tlv_host_id_e_len = EI_INIT;
+static expert_field ei_hip_tlv_host_id_hdr_alg = EI_INIT;
+
/* Dissect the HIP packet */
static void
dissect_hip_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean udp)
{
- proto_tree *hip_tree, *hip_tlv_tree=NULL;
- proto_item *ti, *ti_tlv;
- int length, offset = 0, newoffset = 0;
- guint16 control_h, checksum_h, computed_checksum;
- guint16 tlv_type_h, tlv_length_h; /* For storing in host order */
- guint len;
- guint reported_len;
- vec_t cksum_vec[4];
- guint32 phdr[2];
-
- /* Payload format RFC 5201 section 5.1 */
- /* hiph_proto; */ /* payload protocol */
- guint8 hiph_hdr_len; /* header length */
- guint8 hiph_shim6_fixed_bit_s; /* This is always 0 */
- guint8 hiph_packet_type; /* packet type */
- guint8 hiph_res_ver, hiph_version, hiph_reserved;
- /* byte for reserved and version */
- guint8 hiph_shim6_fixed_bit_p; /* This is always 1 */
- /* checksum_h */ /* checksum */
- /* control_h */ /* control */
- /* HIP parameters ... */
-
- /* load the top pane info. This should be overwritten by
- the next protocol in the stack */
- col_set_str(pinfo->cinfo, COL_PROTOCOL, "HIP");
- col_clear(pinfo->cinfo, COL_INFO);
-
- newoffset = offset;
- /* hiph Proto */
- newoffset++;
- hiph_hdr_len = tvb_get_guint8(tvb, newoffset);
- newoffset++;
- hiph_packet_type = tvb_get_guint8(tvb, newoffset);
- /* draft-ietf-shim6-proto-12 see section 5.3 */
- hiph_shim6_fixed_bit_p = (hiph_packet_type & HIP_SHIM6_FIXED_BIT_P_MASK) >> 7;
- hiph_packet_type = hiph_packet_type & HIP_PACKET_TYPE_MASK;
- newoffset++;
- hiph_res_ver = tvb_get_guint8(tvb, newoffset);
- /* divide to reserved and version and shim6_fixed_bit_s
- draft-ietf-shim6-proto-12 see section 5.3 */
- hiph_version = (hiph_res_ver & HIP_VERSION_MASK) >> 4;
- hiph_reserved = hiph_res_ver & HIP_RESERVED_MASK;
- hiph_shim6_fixed_bit_s = hiph_res_ver & HIP_SHIM6_FIXED_BIT_S_MASK;
- newoffset++;
- checksum_h = tvb_get_ntohs(tvb, newoffset);
- newoffset += 2;
- control_h = tvb_get_ntohs(tvb, newoffset);
-
- col_set_str(pinfo->cinfo, COL_INFO, val_to_str_const(hiph_packet_type, pinfo_vals, "Unknown"));
-
- /* populate a tree in the second pane with the status of the link layer (i.e. none) */
- if(tree) {
- ti = proto_tree_add_item(tree, proto_hip, tvb, 0, -1, ENC_NA);
-
- hip_tree = proto_item_add_subtree(ti, ett_hip);
- proto_tree_add_item(hip_tree, hf_hip_proto, tvb, offset, 1, ENC_BIG_ENDIAN);
- proto_tree_add_item(hip_tree, hf_hip_hdr_len, tvb, offset+1, 1, ENC_BIG_ENDIAN);
- proto_tree_add_uint_format(hip_tree, hf_hip_shim6_fixed_bit_p, tvb, offset+2, 1,
- hiph_shim6_fixed_bit_p,
- "Fixed P-bit: %u (Always zero)",
- hiph_shim6_fixed_bit_p);
- proto_tree_add_uint(hip_tree, hf_hip_packet_type, tvb, offset+2, 1,
- hiph_packet_type);
- proto_tree_add_uint_format_value(hip_tree, hf_hip_version, tvb, offset+3, 1,
- hiph_version, "%u, Reserved: %u",
- hiph_version, hiph_reserved);
- proto_tree_add_uint_format(hip_tree, hf_hip_shim6_fixed_bit_s, tvb, offset+3, 1,
- hiph_shim6_fixed_bit_s,
- "Fixed S-bit: %u (%s)",
- hiph_shim6_fixed_bit_s,
- ((hiph_shim6_fixed_bit_s) ? "HIP" : "SHIM6"));
-
- /* Checksum - this is the same algorithm from UDP, ICMPv6 */
- reported_len = tvb_reported_length(tvb);
- len = tvb_captured_length(tvb);
- if (!pinfo->fragmented && len >= reported_len) {
- /* IPv4 or IPv6 addresses */
- SET_CKSUM_VEC_PTR(cksum_vec[0], (const guint8 *)pinfo->src.data, pinfo->src.len);
- SET_CKSUM_VEC_PTR(cksum_vec[1], (const guint8 *)pinfo->dst.data, pinfo->dst.len);
-
- /* the rest of the pseudo-header */
- if (pinfo->src.type == AT_IPv6) {
- phdr[0] = reported_len;
- phdr[0] = g_htonl(phdr[0]); /* Note: g_htonl() macro may eval arg multiple times */
- phdr[1] = g_htonl(IP_PROTO_HIP);
- SET_CKSUM_VEC_PTR(cksum_vec[2], (const guint8 *)&phdr, 8);
- } else {
- phdr[0] = (IP_PROTO_HIP<<16)+reported_len;
- phdr[0] = g_htonl(phdr[0]); /* Note: g_htonl() macro may eval arg multiple times */
- SET_CKSUM_VEC_PTR(cksum_vec[2], (const guint8 *)&phdr, 4);
- }
- /* pointer to the HIP header (packet data) */
- SET_CKSUM_VEC_TVB(cksum_vec[3], tvb, 0, reported_len);
- computed_checksum = in_cksum(cksum_vec, 4);
- if (computed_checksum == 0) {
- proto_tree_add_uint_format_value(hip_tree, hf_hip_checksum, tvb,
- offset+4, 2, checksum_h,
- "0x%04x (correct)",
- checksum_h);
- } else {
- if (checksum_h == 0 && udp) {
- proto_tree_add_uint_format_value(hip_tree, hf_hip_checksum, tvb,
- offset+4, 2, checksum_h,
- "0x%04x (correct)",
- checksum_h);
- } else {
- proto_tree_add_uint_format_value(hip_tree, hf_hip_checksum, tvb,
- offset+4, 2, checksum_h,
- "0x%04x (incorrect, should be 0x%04x)",
- checksum_h,
- in_cksum_shouldbe(checksum_h,
- computed_checksum));
- }
- }
- } else {
- proto_tree_add_uint_format_value(hip_tree, hf_hip_checksum, tvb,
- offset+4, 2, checksum_h,
- "0x%04x (unverified)",
- checksum_h);
- }
-
- ti = proto_tree_add_item(hip_tree, hf_hip_controls, tvb, offset+6, 2, ENC_BIG_ENDIAN);
- if (ti) {
- /* HIP Controls subtree */
- ti = proto_item_add_subtree(ti, ett_hip_controls);
- proto_tree_add_boolean(ti, hf_hip_controls_anon, tvb,
- offset+7,1, control_h);
- }
-
- offset += 8;
- proto_tree_add_item(hip_tree, hf_hip_hit_sndr, tvb, offset,
- 16, ENC_NA);
- offset += 16;
- proto_tree_add_item(hip_tree, hf_hip_hit_rcvr, tvb, offset,
- 16, ENC_NA);
- offset += 16;
-
- length = (hiph_hdr_len + 1) * 8;
- /* Begin TLV parsing */
- if (offset < length) {
- hip_tlv_tree = proto_tree_add_subtree(hip_tree, tvb, offset,
- -1, ett_hip_tlv, NULL, "HIP Parameters");
- }
- /* Parse type and length in TLV */
- while (offset < length)
- {
- tlv_type_h = tvb_get_ntohs(tvb, offset);
- tlv_length_h = tvb_get_ntohs(tvb, offset + 2);
- ti_tlv = proto_tree_add_uint_format(hip_tlv_tree, hf_hip_type, tvb,
- offset, 4 + tlv_length_h, tlv_type_h,
- "%s (type=%u, length=%u)",
- val_to_str_const(tlv_type_h, hip_param_vals, "Unknown"),
- tlv_type_h, tlv_length_h);
-
- /* Parse value */
- dissect_hip_tlv(tvb, offset, ti_tlv, tlv_type_h, tlv_length_h);
-
- offset += 11 + tlv_length_h - (tlv_length_h + 3) % 8;
- }
-
- }
+ proto_tree *hip_tree, *hip_tlv_tree=NULL;
+ proto_item *ti, *ti_tlv;
+ int length, offset = 0, newoffset = 0;
+ guint16 control_h, checksum_h, computed_checksum;
+ guint16 tlv_type_h, tlv_length_h; /* For storing in host order */
+ guint len;
+ guint reported_len;
+ vec_t cksum_vec[4];
+ guint32 phdr[2];
+
+ /* Payload format RFC 5201 section 5.1 */
+ /* hiph_proto; */ /* payload protocol */
+ guint8 hiph_hdr_len; /* header length */
+ guint8 hiph_shim6_fixed_bit_s; /* This is always 0 */
+ guint8 hiph_packet_type; /* packet type */
+ guint8 hiph_res_ver, hiph_version, hiph_reserved;
+ /* byte for reserved and version */
+ guint8 hiph_shim6_fixed_bit_p; /* This is always 1 */
+ /* checksum_h */ /* checksum */
+ /* control_h */ /* control */
+ /* HIP parameters ... */
+
+ /* load the top pane info. This should be overwritten by
+ the next protocol in the stack */
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, "HIP");
+ col_clear(pinfo->cinfo, COL_INFO);
+
+ newoffset = offset;
+ /* hiph Proto */
+ newoffset++;
+ hiph_hdr_len = tvb_get_guint8(tvb, newoffset);
+ newoffset++;
+ hiph_packet_type = tvb_get_guint8(tvb, newoffset);
+ /* draft-ietf-shim6-proto-12 see section 5.3 */
+ hiph_shim6_fixed_bit_p = (hiph_packet_type & HIP_SHIM6_FIXED_BIT_P_MASK) >> 7;
+ hiph_packet_type = hiph_packet_type & HIP_PACKET_TYPE_MASK;
+ newoffset++;
+ hiph_res_ver = tvb_get_guint8(tvb, newoffset);
+ /* divide to reserved and version and shim6_fixed_bit_s
+ draft-ietf-shim6-proto-12 see section 5.3 */
+ hiph_version = (hiph_res_ver & HIP_VERSION_MASK) >> 4;
+ hiph_reserved = hiph_res_ver & HIP_RESERVED_MASK;
+ hiph_shim6_fixed_bit_s = hiph_res_ver & HIP_SHIM6_FIXED_BIT_S_MASK;
+ newoffset++;
+ checksum_h = tvb_get_ntohs(tvb, newoffset);
+ newoffset += 2;
+ control_h = tvb_get_ntohs(tvb, newoffset);
+
+ col_set_str(pinfo->cinfo, COL_INFO, val_to_str_const(hiph_packet_type, pinfo_vals, "Unknown"));
+
+ /* populate a tree in the second pane with the status of the link layer (i.e. none) */
+ ti = proto_tree_add_item(tree, proto_hip, tvb, 0, -1, ENC_NA);
+
+ hip_tree = proto_item_add_subtree(ti, ett_hip);
+ proto_tree_add_item(hip_tree, hf_hip_proto, tvb, offset, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_item(hip_tree, hf_hip_hdr_len, tvb, offset+1, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_uint_format(hip_tree, hf_hip_shim6_fixed_bit_p, tvb, offset+2, 1,
+ hiph_shim6_fixed_bit_p,
+ "Fixed P-bit: %u (Always zero)",
+ hiph_shim6_fixed_bit_p);
+ proto_tree_add_uint(hip_tree, hf_hip_packet_type, tvb, offset+2, 1,
+ hiph_packet_type);
+ proto_tree_add_uint_format_value(hip_tree, hf_hip_version, tvb, offset+3, 1,
+ hiph_version, "%u, Reserved: %u",
+ hiph_version, hiph_reserved);
+ proto_tree_add_uint_format(hip_tree, hf_hip_shim6_fixed_bit_s, tvb, offset+3, 1,
+ hiph_shim6_fixed_bit_s,
+ "Fixed S-bit: %u (%s)",
+ hiph_shim6_fixed_bit_s,
+ ((hiph_shim6_fixed_bit_s) ? "HIP" : "SHIM6"));
+
+ /* Checksum - this is the same algorithm from UDP, ICMPv6 */
+ reported_len = tvb_reported_length(tvb);
+ len = tvb_captured_length(tvb);
+ if (!pinfo->fragmented && len >= reported_len) {
+ /* IPv4 or IPv6 addresses */
+ SET_CKSUM_VEC_PTR(cksum_vec[0], (const guint8 *)pinfo->src.data, pinfo->src.len);
+ SET_CKSUM_VEC_PTR(cksum_vec[1], (const guint8 *)pinfo->dst.data, pinfo->dst.len);
+
+ /* the rest of the pseudo-header */
+ if (pinfo->src.type == AT_IPv6) {
+ phdr[0] = reported_len;
+ phdr[0] = g_htonl(phdr[0]); /* Note: g_htonl() macro may eval arg multiple times */
+ phdr[1] = g_htonl(IP_PROTO_HIP);
+ SET_CKSUM_VEC_PTR(cksum_vec[2], (const guint8 *)&phdr, 8);
+ } else {
+ phdr[0] = (IP_PROTO_HIP<<16)+reported_len;
+ phdr[0] = g_htonl(phdr[0]); /* Note: g_htonl() macro may eval arg multiple times */
+ SET_CKSUM_VEC_PTR(cksum_vec[2], (const guint8 *)&phdr, 4);
+ }
+ /* pointer to the HIP header (packet data) */
+ SET_CKSUM_VEC_TVB(cksum_vec[3], tvb, 0, reported_len);
+ computed_checksum = in_cksum(cksum_vec, 4);
+ if (computed_checksum == 0) {
+ proto_tree_add_uint_format_value(hip_tree, hf_hip_checksum, tvb,
+ offset+4, 2, checksum_h,
+ "0x%04x (correct)",
+ checksum_h);
+ } else {
+ if (checksum_h == 0 && udp) {
+ proto_tree_add_uint_format_value(hip_tree, hf_hip_checksum, tvb,
+ offset+4, 2, checksum_h,
+ "0x%04x (correct)",
+ checksum_h);
+ } else {
+ proto_tree_add_uint_format_value(hip_tree, hf_hip_checksum, tvb,
+ offset+4, 2, checksum_h,
+ "0x%04x (incorrect, should be 0x%04x)",
+ checksum_h,
+ in_cksum_shouldbe(checksum_h,
+ computed_checksum));
+ }
+ }
+ } else {
+ proto_tree_add_uint_format_value(hip_tree, hf_hip_checksum, tvb,
+ offset+4, 2, checksum_h,
+ "0x%04x (unverified)",
+ checksum_h);
+ }
+
+ ti = proto_tree_add_item(hip_tree, hf_hip_controls, tvb, offset+6, 2, ENC_BIG_ENDIAN);
+ if (ti) {
+ /* HIP Controls subtree */
+ ti = proto_item_add_subtree(ti, ett_hip_controls);
+ proto_tree_add_boolean(ti, hf_hip_controls_anon, tvb,
+ offset+7,1, control_h);
+ }
+
+ offset += 8;
+ proto_tree_add_item(hip_tree, hf_hip_hit_sndr, tvb, offset,
+ 16, ENC_NA);
+ offset += 16;
+ proto_tree_add_item(hip_tree, hf_hip_hit_rcvr, tvb, offset,
+ 16, ENC_NA);
+ offset += 16;
+
+ length = (hiph_hdr_len + 1) * 8;
+ /* Begin TLV parsing */
+ if (offset < length) {
+ hip_tlv_tree = proto_tree_add_subtree(hip_tree, tvb, offset,
+ -1, ett_hip_tlv, NULL, "HIP Parameters");
+ }
+ /* Parse type and length in TLV */
+ while (offset < length)
+ {
+ tlv_type_h = tvb_get_ntohs(tvb, offset);
+ tlv_length_h = tvb_get_ntohs(tvb, offset + 2);
+ ti_tlv = proto_tree_add_uint_format(hip_tlv_tree, hf_hip_type, tvb,
+ offset, 4 + tlv_length_h, tlv_type_h,
+ "%s (type=%u, length=%u)",
+ val_to_str_const(tlv_type_h, hip_param_vals, "Unknown"),
+ tlv_type_h, tlv_length_h);
+
+ /* Parse value */
+ dissect_hip_tlv(tvb, pinfo, offset, ti_tlv, tlv_type_h, tlv_length_h);
+
+ offset += 11 + tlv_length_h - (tlv_length_h + 3) % 8;
+ }
}
static void
@@ -594,10 +599,10 @@ dissect_hip_in_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
static int
-dissect_hip_tlv(tvbuff_t *tvb, int offset, proto_item *ti, int type, int tlv_len)
+dissect_hip_tlv(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_item *ti, int type, int tlv_len)
{
proto_tree *t=NULL;
- proto_item *ti_tlv, *ti_loc;
+ proto_item *ti_tlv, *ti_loc, *hi_len_item, *e_len_item, *arg_item;
guint8 n, algorithm, reg_type;
guint16 trans, hi_len, di_len, di_type, e_len, pv_len;
guint32 reserved, hi_hdr;
@@ -871,8 +876,7 @@ dissect_hip_tlv(tvbuff_t *tvb, int offset, proto_item *ti, int type, int tlv_len
* and
* encrypted data after that.
*/
- proto_tree_add_text(t, tvb, newoffset, tlv_len - 4,
- "Encrypted Parameter Data (%u bytes)", tlv_len - 4);
+ proto_tree_add_item(t, hf_hip_encrypted_parameter_data, tvb, newoffset, tlv_len - 4, ENC_NA);
break;
case PARAM_HIP_CIPHER:
while (tlv_len > 0) {
@@ -896,7 +900,7 @@ dissect_hip_tlv(tvbuff_t *tvb, int offset, proto_item *ti, int type, int tlv_len
break;
case PARAM_HOST_ID:
hi_len = tvb_get_ntohs(tvb, newoffset);
- proto_tree_add_item(t, hf_hip_tlv_host_id_len, tvb, newoffset, 2, ENC_BIG_ENDIAN);
+ hi_len_item = proto_tree_add_item(t, hf_hip_tlv_host_id_len, tvb, newoffset, 2, ENC_BIG_ENDIAN);
newoffset += 2;
di_len = tvb_get_ntohs(tvb, newoffset);
di_type = (di_len >> 12) & 0x000F; /* get 4 bits for DI type */
@@ -915,21 +919,21 @@ dissect_hip_tlv(tvbuff_t *tvb, int offset, proto_item *ti, int type, int tlv_len
hi_hdr = tvb_get_ntohl(tvb, newoffset);
ti_tlv = proto_tree_add_item(t, hf_hip_tlv_host_id_hdr,
tvb, newoffset, 4, ENC_BIG_ENDIAN);
- if (ti_tlv) {
- ti_tlv = proto_item_add_subtree(ti_tlv, ett_hip_tlv_host_id_hdr);
- /* HDR Flags*/
- proto_tree_add_uint(ti_tlv, hf_hip_tlv_host_id_hdr_flags, tvb,
- newoffset, 2, hi_hdr);
- newoffset += 2;
- /* HDR Protocol */
- proto_tree_add_uint(ti_tlv, hf_hip_tlv_host_id_hdr_proto, tvb,
- newoffset, 1, hi_hdr);
- newoffset += 1;
- /* HDR Algorithm */
- proto_tree_add_uint(ti_tlv, hf_hip_tlv_host_id_hdr_alg, tvb,
- newoffset, 1, hi_hdr);
- }
+
+ ti_tlv = proto_item_add_subtree(ti_tlv, ett_hip_tlv_host_id_hdr);
+ /* HDR Flags*/
+ proto_tree_add_uint(ti_tlv, hf_hip_tlv_host_id_hdr_flags, tvb,
+ newoffset, 2, hi_hdr);
+ newoffset += 2;
+ /* HDR Protocol */
+ proto_tree_add_uint(ti_tlv, hf_hip_tlv_host_id_hdr_proto, tvb,
+ newoffset, 1, hi_hdr);
+ newoffset += 1;
+ /* HDR Algorithm */
algorithm = tvb_get_guint8(tvb, newoffset);
+ arg_item = proto_tree_add_uint(ti_tlv, hf_hip_tlv_host_id_hdr_alg, tvb,
+ newoffset, 1, hi_hdr);
+
switch (algorithm) {
case HI_ALG_DSA:
/* DSA KEY RR RFC 2536
@@ -972,7 +976,7 @@ dissect_hip_tlv(tvbuff_t *tvb, int offset, proto_item *ti, int type, int tlv_len
newoffset++; /* 12 + offset */
/* E len */
e_len = tvb_get_guint8(tvb, newoffset);
- proto_tree_add_item(t, hf_hip_tlv_host_id_e_len, tvb, newoffset,
+ e_len_item = proto_tree_add_item(t, hf_hip_tlv_host_id_e_len, tvb, newoffset,
(e_len > 255) ? 3 : 1, ENC_BIG_ENDIAN);
newoffset++;
hi_len -= 5; /* subtract RDATA + e_len */
@@ -982,8 +986,7 @@ dissect_hip_tlv(tvbuff_t *tvb, int offset, proto_item *ti, int type, int tlv_len
hi_len -= 2;
}
if (e_len > 512) { /* per, RFC 3110 < 4096 bits */
- proto_tree_add_text(t, tvb, newoffset, 2,
- "<< e_len too large >>");
+ expert_add_info(pinfo, e_len_item, &ei_hip_tlv_host_id_len);
break;
}
/* e */
@@ -993,8 +996,7 @@ dissect_hip_tlv(tvbuff_t *tvb, int offset, proto_item *ti, int type, int tlv_len
hi_len -= e_len;
if (hi_len > 512) {
- proto_tree_add_text(t, tvb, newoffset, 1,
- "<< Invalid HI length >>");
+ expert_add_info(pinfo, hi_len_item, &ei_hip_tlv_host_id_len);
break;
}
@@ -1003,8 +1005,7 @@ dissect_hip_tlv(tvbuff_t *tvb, int offset, proto_item *ti, int type, int tlv_len
hi_len, ENC_NA);
break;
default:
- proto_tree_add_text(t, tvb, newoffset, 1,
- "Unknown algorithm type (%d).\n", algorithm);
+ expert_add_info(pinfo, arg_item, &ei_hip_tlv_host_id_hdr_alg);
break;
}
@@ -1013,12 +1014,10 @@ dissect_hip_tlv(tvbuff_t *tvb, int offset, proto_item *ti, int type, int tlv_len
break;
if (di_type == 1) {
/* RFC 1035 */
- proto_tree_add_text(t, tvb, offset+16+hi_len, di_len,
- "FQDN: %s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset+16+hi_len, di_len, ENC_ASCII));
+ proto_tree_add_item(t, hf_hip_fqdn, tvb, offset+16+hi_len, di_len, ENC_ASCII|ENC_NA);
} else if (di_type == 2) {
/* RFC 4282 */
- proto_tree_add_text(t, tvb, offset+16+hi_len, di_len,
- "NAI: %s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset+16+hi_len, di_len, ENC_ASCII));
+ proto_tree_add_item(t, hf_hip_nai, tvb, offset+16+hi_len, di_len, ENC_ASCII|ENC_NA);
}
break;
case PARAM_CERT: /* CERT */
@@ -1559,6 +1558,18 @@ proto_register_hip(void)
{ "Address" , "hip.tlv_reg_from_address",
FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }},
+ { &hf_hip_encrypted_parameter_data,
+ { "Encrypted Parameter Data" , "hip.encrypted_parameter_data",
+ FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
+
+ { &hf_hip_fqdn,
+ { "FQDN" , "hip.fqdn",
+ FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
+
+ { &hf_hip_nai,
+ { "NAI" , "hip.nai",
+ FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
+
};
static gint *ett[] = {
@@ -1570,11 +1581,20 @@ proto_register_hip(void)
&ett_hip_locator_data,
};
- proto_hip = proto_register_protocol("Host Identity Protocol",
- "HIP", "hip");
+ static ei_register_info ei[] = {
+ { &ei_hip_tlv_host_id_len, { "hip.tlv.host_id_length.invalid", PI_PROTOCOL, PI_WARN, "Invalid HI length", EXPFILL }},
+ { &ei_hip_tlv_host_id_e_len, { "hip.tlv.host_id_e_length.invalid", PI_PROTOCOL, PI_WARN, "e_len too large", EXPFILL }},
+ { &ei_hip_tlv_host_id_hdr_alg, { "hip.tlv.host_id_header_algo.invalid", PI_PROTOCOL, PI_WARN, "Unknown algorithm type", EXPFILL }},
+ };
+
+ expert_module_t* expert_hip;
+
+ proto_hip = proto_register_protocol("Host Identity Protocol", "HIP", "hip");
proto_register_field_array(proto_hip, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
+ expert_hip = expert_register_protocol(proto_hip);
+ expert_register_field_array(expert_hip, ei, array_length(ei));
}
void