aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-hip.c
diff options
context:
space:
mode:
authorwmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7>2010-03-17 18:23:56 +0000
committerwmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7>2010-03-17 18:23:56 +0000
commit4d8c3486c2f8db550f7f2bd9fc065df70a93e395 (patch)
tree3dae1cf525275ef63987200b567f10b6096ea3b5 /epan/dissectors/packet-hip.c
parentd2a30ecf6eaedeffad9e1a66442405b5e107de58 (diff)
From Samu Varjonen: Locator presentation change for HIP dissector.
See: https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=3378 From me: use consistent (tab) indentation; replace use of C++ style comment. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@32222 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'epan/dissectors/packet-hip.c')
-rw-r--r--epan/dissectors/packet-hip.c134
1 files changed, 78 insertions, 56 deletions
diff --git a/epan/dissectors/packet-hip.c b/epan/dissectors/packet-hip.c
index 9bbe7b558e..250649a6d0 100644
--- a/epan/dissectors/packet-hip.c
+++ b/epan/dissectors/packet-hip.c
@@ -381,6 +381,7 @@ static gint ett_hip_controls = -1;
static gint ett_hip_tlv = -1;
static gint ett_hip_tlv_data = -1;
static gint ett_hip_tlv_host_id_hdr = -1;
+static gint ett_hip_locator_data = -1;
/* Dissect the HIP packet */
static void
@@ -561,7 +562,7 @@ static int
dissect_hip_tlv(tvbuff_t *tvb, int offset, proto_item *ti, int type, int tlv_len)
{
proto_tree *t=NULL;
- proto_item *ti_tlv;
+ proto_item *ti_tlv, *ti_loc;
guint8 n, algorithm, reg_type;
guint16 trans, hi_len, di_len, di_type, e_len, pv_len;
guint32 reserved, hi_hdr;
@@ -603,66 +604,86 @@ dissect_hip_tlv(tvbuff_t *tvb, int offset, proto_item *ti, int type, int tlv_len
tlv_len -= 4;
/* loop through included locators */
while (tlv_len > 0) {
- /* Traffic type */
- proto_tree_add_item(t, hf_hip_tlv_locator_traffic_type, tvb,
- newoffset, 1, FALSE);
- newoffset++;
- /* Locator type */
- locator_type = tvb_get_guint8(tvb, newoffset);
- proto_tree_add_item(t, hf_hip_tlv_locator_type, tvb, newoffset, 1, FALSE);
- newoffset++;
- /* Locator length */
- proto_tree_add_item(t, hf_hip_tlv_locator_len, tvb, newoffset, 1, FALSE);
- newoffset++;
- /* Reserved includes the Preferred bit */
- reserved = tvb_get_guint8(tvb, newoffset);
- proto_tree_add_uint_format(t, hf_hip_tlv_locator_reserved, tvb,
- newoffset, 1, reserved,
- "Reserved: 0x%x %s", reserved,
- (reserved >> 31) ? "(Preferred)" : "");
- newoffset++;
- /* Locator lifetime */
- proto_tree_add_item(t, hf_hip_tlv_locator_lifetime, tvb,
- newoffset, 4, FALSE);
- newoffset += 4;
- /* Locator types 1 and 0 RFC 5206 section 4.2.*/
+ /* Every locator to new tree node
+ Skip ahead and read the 0 or 1 type locator from 8 bytes
+ and type 2 locator from 20 bytes to be used as the top level
+ tree_item for this subtree
+ */
+ locator_type = tvb_get_guint8(tvb, newoffset + 1);
if (locator_type == 1 || locator_type == 0) {
- /* Locator */
- proto_tree_add_item(t, hf_hip_tlv_locator_address, tvb, newoffset, 16, FALSE);
- newoffset += 16;
- tlv_len -= 24;
- /* Locator type 2 draft-ietf-hip-nat-raversal-06.txt section 5.7. */
+ ti_loc = proto_tree_add_item(t, hf_hip_tlv_locator_address,
+ tvb, newoffset + 8, 16, FALSE);
} else if (locator_type == 2) {
- /* Tansport port */
- proto_tree_add_item(t, hf_hip_tlv_locator_port, tvb,
- newoffset, 2, FALSE);
- newoffset += 2;
- /* Transport protocol */
- transport_proto = tvb_get_guint8(tvb, newoffset);
- /* draft-ietf-hip-nat-traversal-06 section 5.6 */
- proto_tree_add_uint_format(t, hf_hip_tlv_locator_transport_protocol,
- tvb, newoffset, 1, transport_proto,
- "Transport protocol: %d %s",
- transport_proto,
- (transport_proto == 17) ?
- "(UDP)" : "");
- newoffset++;
- /* Kind */
- proto_tree_add_item(t, hf_hip_tlv_locator_kind, tvb,
+ ti_loc = proto_tree_add_item(t, hf_hip_tlv_locator_address,
+ tvb, newoffset + 20, 16, FALSE);
+ }
+ if (ti_loc) {
+ ti_loc = proto_item_add_subtree(ti_loc, ett_hip_locator_data);
+ /* Traffic type */
+ proto_tree_add_item(ti_loc, hf_hip_tlv_locator_traffic_type, tvb,
newoffset, 1, FALSE);
+ newoffset++;
+#if 0
+ /* Locator type */
+ locator_type = tvb_get_guint8(tvb, newoffset);
+#endif
+ proto_tree_add_item(ti_loc, hf_hip_tlv_locator_type, tvb, newoffset, 1, FALSE);
newoffset++;
- /* Priority */
- proto_tree_add_item(t, hf_hip_tlv_locator_priority, tvb,
- newoffset, 4, FALSE);
- newoffset += 4;
- /* SPI */
- proto_tree_add_item(t, hf_hip_tlv_locator_spi, tvb,
+ /* Locator length */
+ proto_tree_add_item(ti_loc, hf_hip_tlv_locator_len, tvb, newoffset, 1, FALSE);
+ newoffset++;
+ /* Reserved includes the Preferred bit */
+ reserved = tvb_get_guint8(tvb, newoffset);
+ proto_tree_add_uint_format(ti_loc, hf_hip_tlv_locator_reserved, tvb,
+ newoffset, 1, reserved,
+ "Reserved: 0x%x %s", reserved,
+ (reserved >> 31) ? "(Preferred)" : "");
+ newoffset++;
+ /* Locator lifetime */
+ proto_tree_add_item(ti_loc, hf_hip_tlv_locator_lifetime, tvb,
newoffset, 4, FALSE);
- newoffset += 4;
- /* Locator */
- proto_tree_add_item(t, hf_hip_tlv_locator_address, tvb, newoffset, 16, FALSE);
- newoffset += 16;
- tlv_len -= 36;
+ newoffset += 4;
+ /* Locator types 1 and 0 RFC 5206 section 4.2.*/
+ if (locator_type == 1 || locator_type == 0) {
+ /* Locator */
+ proto_tree_add_item(ti_loc, hf_hip_tlv_locator_address,
+ tvb, newoffset, 16, FALSE);
+ newoffset += 16;
+ tlv_len -= 24;
+ /* Locator type 2 draft-ietf-hip-nat-raversal-06.txt section 5.7. */
+ } else if (locator_type == 2) {
+ /* Tansport port */
+ proto_tree_add_item(ti_loc, hf_hip_tlv_locator_port, tvb,
+ newoffset, 2, FALSE);
+ newoffset += 2;
+ /* Transport protocol */
+ transport_proto = tvb_get_guint8(tvb, newoffset);
+ /* draft-ietf-hip-nat-traversal-06 section 5.6 */
+ proto_tree_add_uint_format(ti_loc, hf_hip_tlv_locator_transport_protocol,
+ tvb, newoffset, 1, transport_proto,
+ "Transport protocol: %d %s",
+ transport_proto,
+ (transport_proto == 17) ?
+ "(UDP)" : "");
+ newoffset++;
+ /* Kind */
+ proto_tree_add_item(ti_loc, hf_hip_tlv_locator_kind, tvb,
+ newoffset, 1, FALSE);
+ newoffset++;
+ /* Priority */
+ proto_tree_add_item(ti_loc, hf_hip_tlv_locator_priority, tvb,
+ newoffset, 4, FALSE);
+ newoffset += 4;
+ /* SPI */
+ proto_tree_add_item(ti_loc, hf_hip_tlv_locator_spi, tvb,
+ newoffset, 4, FALSE);
+ newoffset += 4;
+ /* Locator */
+ proto_tree_add_item(ti_loc, hf_hip_tlv_locator_address,
+ tvb, newoffset, 16, FALSE);
+ newoffset += 16;
+ tlv_len -= 36;
+ }
}
}
break;
@@ -1489,6 +1510,7 @@ proto_register_hip(void)
&ett_hip_tlv,
&ett_hip_tlv_data,
&ett_hip_tlv_host_id_hdr,
+ &ett_hip_locator_data,
};
proto_hip = proto_register_protocol("Host Identity Protocol",