SOURCES: wireshark-0.99.5-hip-base05.patch (NEW) - HIP dissector f...
gotar
gotar at pld-linux.org
Mon Mar 12 01:06:39 CET 2007
Author: gotar Date: Mon Mar 12 00:06:39 2007 GMT
Module: SOURCES Tag: HEAD
---- Log message:
- HIP dissector from openhip
---- Files affected:
SOURCES:
wireshark-0.99.5-hip-base05.patch (NONE -> 1.1) (NEW)
---- Diffs:
================================================================
Index: SOURCES/wireshark-0.99.5-hip-base05.patch
diff -u /dev/null SOURCES/wireshark-0.99.5-hip-base05.patch:1.1
--- /dev/null Mon Mar 12 01:06:39 2007
+++ SOURCES/wireshark-0.99.5-hip-base05.patch Mon Mar 12 01:06:34 2007
@@ -0,0 +1,1333 @@
+#
+# HIP protocol patch for wireshark-0.99.5
+# 3/06 draft-ietf-hip-base-05
+# draft-ietf-hip-esp-02
+# draft-ietf-hip-mm-03
+# draft-ietf-hip-registration-01
+# draft-ietf-hip-rvs-04
+#
+# Authors: <thomas.r.henderson at boeing.com>
+# <jeffrey.m.ahrenholz at boeing.com>
+#
+*** ethereal-0.99.0/epan/dissectors/Makefile.in 2006-04-24 09:21:23.000000000 -0700
+--- ethereal-0.99.0-hip/epan/dissectors/Makefile.in 2006-05-01 09:11:13.000000000 -0700
+***************
+*** 209,213 ****
+ packet-h248_annex_e.lo packet-h248_q1950.lo packet-h261.lo \
+ packet-h263.lo packet-h450.lo packet-hci_h4.lo \
+! packet-hclnfsd.lo packet-homeplug.lo packet-hpext.lo \
+ packet-hpsw.lo packet-hsrp.lo packet-http.lo \
+ packet-hyperscsi.lo packet-iapp.lo packet-iax2.lo packet-ib.lo \
+--- 209,213 ----
+ packet-h248_annex_e.lo packet-h248_q1950.lo packet-h261.lo \
+ packet-h263.lo packet-h450.lo packet-hci_h4.lo \
+! packet-hclnfsd.lo packet-homeplug.lo packet-hip.lo packet-hpext.lo \
+ packet-hpsw.lo packet-hsrp.lo packet-http.lo \
+ packet-hyperscsi.lo packet-iapp.lo packet-iax2.lo packet-ib.lo \
+***************
+*** 859,862 ****
+--- 859,863 ----
+ packet-h450.c \
+ packet-hclnfsd.c \
++ packet-hip.c \
+ packet-hpext.c \
+ packet-hpsw.c \
+***************
+*** 1849,1852 ****
+--- 1850,1854 ----
+ @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/packet-h450.Plo at am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/packet-hclnfsd.Plo at am__quote@
++ @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/packet-hip.Plo at am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/packet-hpext.Plo at am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/packet-hpsw.Plo at am__quote@
+*** ethereal-0.99.0/epan/dissectors/Makefile.common 2006-04-17 07:46:42.000000000 -0700
+--- ethereal-0.99.0-hip/epan/dissectors/Makefile.common 2006-05-01 09:10:00.000000000 -0700
+***************
+*** 328,331 ****
+--- 328,332 ----
+ packet-h450.c \
+ packet-hclnfsd.c \
++ packet-hip.c \
+ packet-hpext.c \
+ packet-hpsw.c \
+*** ethereal-0.99.0/epan/dissectors/register.c 2006-04-21 14:57:37.000000000 -0700
+--- ethereal-0.99.0-hip/epan/dissectors/register.c 2006-05-01 09:10:00.000000000 -0700
+***************
+*** 247,250 ****
+--- 247,251 ----
+ {extern void proto_register_h450 (void); proto_register_h450 ();}
+ {extern void proto_register_hclnfsd (void); proto_register_hclnfsd ();}
++ {extern void proto_register_hip (void); proto_register_hip ();}
+ {extern void proto_register_hpext (void); proto_register_hpext ();}
+ {extern void proto_register_hpsw (void); proto_register_hpsw ();}
+***************
+*** 869,872 ****
+--- 870,874 ----
+ {extern void proto_reg_handoff_h4501 (void); proto_reg_handoff_h4501 ();}
+ {extern void proto_reg_handoff_hclnfsd (void); proto_reg_handoff_hclnfsd ();}
++ {extern void proto_reg_handoff_hip (void); proto_reg_handoff_hip ();}
+ {extern void proto_reg_handoff_hpext (void); proto_reg_handoff_hpext ();}
+ {extern void proto_reg_handoff_hpsw (void); proto_reg_handoff_hpsw ();}
+*** ethereal-0.99.0/epan/ipproto.h 2006-04-17 07:46:53.000000000 -0700
+--- ethereal-0.99.0-hip/epan/ipproto.h 2006-05-01 09:10:00.000000000 -0700
+***************
+*** 185,188 ****
+--- 185,189 ----
+ #define IP_PROTO_AX4000 173 /* AX/4000 Testblock - non IANA */
+ #define IP_PROTO_NCS_HEARTBEAT 224 /* Novell NCS Heartbeat - http://support.novell.com/cgi-bin/search/searchtid.cgi?/10071158.htm */
++ #define IP_PROTO_HIP 253 /* Host Identity Protocol */
+
+ extern const char *ipprotostr(int proto);
+*** ethereal-0.99.0/epan/prefs.c 2006-04-17 07:46:53.000000000 -0700
+--- ethereal-0.99.0-hip/epan/prefs.c 2006-05-01 09:10:00.000000000 -0700
+***************
+*** 1993,1996 ****
+--- 1993,2000 ----
+ if (strcmp(dotp, "udp_summary_in_tree") == 0)
+ pref = find_preference(module, "summary_in_tree");
++ } else if (strcmp(module->name, "hip") == 0) {
++ /* Handle old names for HIP preferences. */
++ if (strcmp(dotp, "hip_summary_in_tree") == 0)
++ pref = find_preference(module, "summary_in_tree");
+ } else if (strcmp(module->name, "ndps") == 0) {
+ /* Handle old names for NDPS preferences. */
+*** ethereal-0.99.0/epan/dissectors/packet-hip.c 1969-12-31 16:00:00.000000000 -0800
+--- ethereal-0.99.0-hip/epan/dissectors/packet-hip.c 2006-05-01 09:10:00.000000000 -0700
+***************
+*** 0 ****
+--- 1,1235 ----
++ /* packet-hip.c
++ * Routines for HIP packet disassembly
++ *
++ * 03/2006 draft-ietf-hip-base-05, -esp-02, -mm-03, -registration-01, -rvs-04
++ * 07/2005 draft-ietf-hip-base-03, -esp-00, and -mm-02
++ * 03/2005 draft-ietf-hip-base-01
++ * 11/2004 RSA and draft-ietf-hip-mm-00
++ * 09/2004 draft-nikander-hip-mm-02
++ * 07/2004 draft-ietf-hip-base-00
++ * 02/2004
++ * 03/2003
++ *
++ * Jeff Ahrenholz <jeffrey.m.ahrenholz at boeing.com>
++ * Thomas Henderson <thomas.r.henderson at boeing.com>
++ *
++ * Packet dissector for Host Identity Protocol (HIP) packets.
++ * This tool displays the TLV structure, verifies checksums,
++ * and shows NULL encrypted parameters, but will not verify
++ * signatures or decode encrypted parameters.
++ *
++ * $Id$
++ *
++ * Ethereal - Network traffic analyzer
++ * By Gerald Combs <gerald at ethereal.com>
++ * Copyright 1998 Gerald Combs
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License
++ * as published by the Free Software Foundation; either version 2
++ * of the License, or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
++ */
++
++ #ifdef HAVE_CONFIG_H
++ # include "config.h"
++ #endif
++
++ #include <stdio.h>
++ #include <stdlib.h>
++ #include <string.h>
++
++ #include <glib.h>
++ #include <epan/packet.h>
++ #include <epan/addr_resolv.h>
++ #include "ipproto.h"
++ #include "in_cksum.h"
++ #include "prefs.h"
++
++
++ #include "packet-ip.h"
++ #include <epan/conversation.h>
++
++ static int proto_hip = -1;
++ static int hf_hip_proto = -1;
++ static int hf_hip_hdr_len = -1;
++ static int hf_hip_packet_type = -1;
++ static int hf_hip_version = -1;
++ static int hf_hip_res = -1;
++ static int hf_hip_controls = -1;
++ static int hf_hip_controls_cert = -1;
++ static int hf_hip_controls_anon = -1;
++ static int hf_hip_checksum = -1;
++ static int hf_hip_hit_sndr = -1;
++ static int hf_hip_hit_rcvr = -1;
++
++ static int hf_hip_type = -1;
++ static int hf_hip_tlv_ei_res = -1;
++ static int hf_hip_tlv_ei_keyidx = -1;
++ static int hf_hip_tlv_ei_oldspi = -1;
++ static int hf_hip_tlv_ei_newspi = -1;
++ static int hf_hip_tlv_r1_res = -1;
++ static int hf_hip_tlv_r1count = -1;
++ static int hf_hip_tlv_puzzle_k = -1;
++ static int hf_hip_tlv_puzzle_life = -1;
++ static int hf_hip_tlv_puzzle_o = -1;
++ static int hf_hip_tlv_puzzle_i = -1;
++ static int hf_hip_tlv_puzzle_j = -1;
++ static int hf_hip_tlv_seq_updid = -1;
++ static int hf_hip_tlv_ack_updid = -1;
++ static int hf_hip_tlv_dh_group_id = -1;
++ static int hf_hip_tlv_dh_pub = -1;
++ static int hf_hip_tlv_trans_id = -1;
++ static int hf_hip_tlv_esp_reserved = -1;
++ static int hf_hip_tlv_host_id_len = -1;
++ static int hf_hip_tlv_host_di_type = -1;
++ static int hf_hip_tlv_host_di_len = -1;
++ static int hf_hip_tlv_host_id_hdr = -1;
++ static int hf_hip_tlv_host_id_hdr_flags = -1;
++ static int hf_hip_tlv_host_id_hdr_proto = -1;
++ static int hf_hip_tlv_host_id_hdr_alg = -1;
++ static int hf_hip_tlv_host_id_t = -1;
++ static int hf_hip_tlv_host_id_q = -1;
++ static int hf_hip_tlv_host_id_p = -1;
++ static int hf_hip_tlv_host_id_g = -1;
++ static int hf_hip_tlv_host_id_y = -1;
++ static int hf_hip_tlv_host_id_e_len = -1;
++ static int hf_hip_tlv_host_id_e = -1;
++ static int hf_hip_tlv_host_id_n = -1;
++ static int hf_hip_tlv_cert_count = -1;
++ static int hf_hip_tlv_cert_id = -1;
++ static int hf_hip_tlv_cert_type = -1;
++ static int hf_hip_tlv_certificate = -1;
++ static int hf_hip_tlv_notify_res = -1;
++ static int hf_hip_tlv_notify_type = -1;
++ static int hf_hip_tlv_notify_data = -1;
++ static int hf_hip_tlv_opaque_data = -1;
++ static int hf_hip_tlv_reg_ltmin = -1;
++ static int hf_hip_tlv_reg_ltmax = -1;
++ static int hf_hip_tlv_reg_lt = -1;
++ static int hf_hip_tlv_reg_type = -1;
++ static int hf_hip_tlv_reg_failtype = -1;
++ static int hf_hip_tlv_hmac = -1;
++ static int hf_hip_tlv_sig_alg = -1;
++ static int hf_hip_tlv_sig = -1;
++ static int hf_hip_tlv_id = -1;
++ static int hf_hip_tlv_enc_reserved = -1;
++ static int hf_hip_tlv_enc_iv = -1;
++ static int hf_hip_tlv_locator_traffic_type = -1;
++ static int hf_hip_tlv_locator_type = -1;
++ static int hf_hip_tlv_locator_len = -1;
++ static int hf_hip_tlv_locator_reserved = -1;
++ static int hf_hip_tlv_locator_lifetime = -1;
++ static int hip_transform = 0;
++
++ static gint ett_hip = -1;
++ 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;
++
++ /* Place HIP summary in protocol tree */
++ static gboolean hip_summary_in_tree = TRUE;
++
++ /* This minimal structure used to get at the Type field*/
++ struct newhip {
++ guint16 nextpluslen; /* Next header, plus length */
++ guint8 hiptype; /* Type (what we are after) */
++ guint8 hipreserved; /* Reserved (what we are after) */
++ /*variable size*/ /* (IV and) Payload data */
++ };
++
++ /* 128-bit Host Identity Tag */
++ #define HIT_BITSIZE 128
++ typedef unsigned char hip_hit [HIT_BITSIZE/8];
++
++ #define HI_ALG_DSA 3
++ #define HI_ALG_RSA 5
++
++ /* HIP packet types */
++ typedef enum {
++ HIP_I1=1,
++ HIP_R1,
++ HIP_I2,
++ HIP_R2,
++ CER, /* 5 - removed from draft-ietf-hip-base-03 */
++ BOS=11, /* 11 - removed from draft-ietf-hip-base-01 */
++ UPDATE=16, /* 16 */
++ NOTIFY=17, /* 17 */
++ CLOSE=18, /* 18 */
++ CLOSE_ACK=19, /* 19 */
++ } HIP_PACKETS;
++
++ /* HIP TLV parameters */
++ /* 03/2006 draft-ietf-hip-base-05, -esp-02, -mm-03, -registration-01, -rvs-04 */
++ #define PARAM_ESP_INFO 65
++ #define PARAM_R1_COUNTER 128
++ #define PARAM_LOCATOR 193
++ #define PARAM_PUZZLE 257
++ #define PARAM_SOLUTION 321
++ #define PARAM_SEQ 385
++ #define PARAM_ACK 449
++ #define PARAM_DIFFIE_HELLMAN 513
++ #define PARAM_HIP_TRANSFORM 577
++ #define PARAM_ENCRYPTED 641
++ #define PARAM_HOST_ID 705
++ #define PARAM_CERT 768
++ #define PARAM_NOTIFY 832
++ #define PARAM_ECHO_REQUEST 897
++ #define PARAM_REG_INFO 930
++ #define PARAM_REG_REQUEST 932
++ #define PARAM_REG_RESPONSE 934
++ #define PARAM_REG_FAILED 936
++ #define PARAM_ECHO_RESPONSE 961
++ #define PARAM_ESP_TRANSFORM 4095
++ #define PARAM_TRANSFORM_LOW 2048 /* defines range for transforms */
++ #define PARAM_TRANSFORM_HIGH 4095
++ #define PARAM_HMAC 61505
++ #define PARAM_HMAC_2 61569
++ #define PARAM_HIP_SIGNATURE_2 61633
++ #define PARAM_HIP_SIGNATURE 61697
++ #define PARAM_ECHO_REQUEST_NOSIG 63661
++ #define PARAM_ECHO_RESPONSE_NOSIG 63425
++ #define PARAM_FROM 65498
++ #define PARAM_RVS_HMAC 65500
++ #define PARAM_VIA_RVS 65502
++ #define PARAM_CRITICAL_BIT 0x0001
++
++ #define HIP_CONTROL_C_MASK 0x0002
++ #define HIP_CONTROL_A_MASK 0x0001
++
++ #define HI_HDR_FLAGS_MASK 0xFFFF0000
++ #define HI_HDR_PROTO_MASK 0x0000FF00
++ #define HI_HDR_ALG_MASK 0x000000FF
++
++ const value_string hi_hdr_flags_vals[] = {
++ { 0x0200, "key is associated with a user" },
++ { 0x0201, "zone key" },
++ { 0x0202, "key is associated with non-zone entity" },
++ { 0x0, "Other" },
++ };
++
++ const value_string hi_hdr_proto_vals[] = {
++ { 0x01, "key is used for TLS" },
++ { 0x02, "key is used for email" },
++ { 0x03, "key is used for DNS security" },
++ { 0x04, "key is used for Oakley/IPSEC" },
++ { 0xFF, "key is valid for any protocol" },
++ { 0x0, NULL },
++ };
++
++ const value_string hi_hdr_alg_vals[] = {
++ { 0x00, "reserved" },
++ { 0x01, "RSA/MD5" },
++ { 0x02, "Diffie-Hellman" },
++ { 0x03, "DSA" },
++ { 0x04, "elliptic curve crypto" },
++ { 0x05, "RSA" },
++ { 0xFF, "reserved" },
++ };
++
++ const value_string notify_vals[] = {
++ { 1, "Unsupported critical parameter type" },
++ { 7, "Invalid syntax" },
++ { 14, "No Diffie-Hellman proposal chosen" },
++ { 15, "Invalid Diffie-Hellman chosen" },
++ { 16, "No HIP proposal chosen" },
++ { 17, "Invalid HIP transform chosen" },
++ { 18, "No ESP proposal chosen" },
++ { 19, "Invalid ESP transform chosen" },
++ { 24, "Authentication failed" },
++ { 26, "Checksum failed" },
++ { 28, "HMAC failed" },
++ { 32, "Encryption failed" },
++ { 40, "Invalid HIT" },
++ { 42, "Blocked by policy" },
++ { 44, "Server busy please retry" },
++ { 46, "I2 acknowledgement" },
++ { 0x0, NULL },
++ };
++
++ typedef struct _hiphdr {
++ guint8 proto; /* payload protocol */
++ guint8 hdr_len; /* header length */
++ guint8 packet_type; /* packet type */
++ guint8 res:4,version:4; /* version, reserved */
++ guint16 checksum; /* checksum */
++ guint16 control; /* control */
++ hip_hit hit_sndr; /* Sender's Host Identity Tag */
++ hip_hit hit_rcvr; /* Receiver's Host Identity Tag*/
++ /* HIP parameters ... */
++ } hiphdr;
++
++ typedef struct _tlv_head
++ {
++ guint16 type;
++ guint16 length;
++ } tlv_head;
++
++
++ /* functions */
++ char * hip_param(int n);
++ char *dh_group_id_label(int groupid);
++ char *transform_id_label(int transform);
++ char *sig_alg_label(int alg);
++ int dissect_hip_tlv(tvbuff_t *tvb, int offset, proto_item *ti, int type, int tlv_len);
++
++ static dissector_handle_t data_handle;
++
++ /**** end defs from hip.h ****/
++
++ /*
++ * Dissect the HIP packet
++ */
++ static void
++ dissect_hip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
++ {
++ proto_tree *hip_tree, *hip_tlv_tree=NULL;
++ proto_item *ti, *ti_tlv;
++ hiphdr hiph;
++ tlv_head tlv;
++ int length, offset = 0;
++ guint16 control_h, checksum_h, computed_checksum;
++ guint16 tlv_type_h, tlv_length_h; /* For storing in host order */
++ vec_t cksum_vec[4];
++ guint32 phdr[2];
++
++ /*
++ * load the top pane info. This should be overwritten by
++ * the next protocol in the stack
++ */
++ if (check_col(pinfo->cinfo, COL_PROTOCOL))
++ col_set_str(pinfo->cinfo, COL_PROTOCOL, "HIP");
++ if (check_col(pinfo->cinfo, COL_INFO))
++ col_clear(pinfo->cinfo, COL_INFO);
++
++ /* Convert control and checksum to host order */
++
++ tvb_memcpy(tvb, (guint8 *)&hiph, 0, sizeof(hiphdr));
++ control_h = g_ntohs(hiph.control);
++ checksum_h = g_ntohs(hiph.checksum);
++
++ if (check_col(pinfo->cinfo, COL_INFO)) {
++ switch (hiph.packet_type) {
++ case HIP_I1:
++ col_add_fstr(pinfo->cinfo, COL_INFO,
++ "HIP I1 (HIP Initiator Packet)");
++ break;
++ case HIP_R1:
++ col_add_fstr(pinfo->cinfo, COL_INFO,
++ "HIP R1 (HIP Responder Packet)");
++ break;
++ case HIP_I2:
++ col_add_fstr(pinfo->cinfo, COL_INFO,
++ "HIP I2 (Second HIP Initiator Packet)");
++ break;
++ case HIP_R2:
++ col_add_fstr(pinfo->cinfo, COL_INFO,
++ "HIP R2 (Second HIP Responder Packet)");
++ break;
++ case UPDATE:
++ col_add_fstr(pinfo->cinfo, COL_INFO,
++ "HIP UPDATE (HIP Update Packet)");
++ break;
++ case CER:
++ col_add_fstr(pinfo->cinfo, COL_INFO,
++ "HIP CER (HIP Certificate Packet)");
++ break;
++ case BOS:
++ col_add_fstr(pinfo->cinfo, COL_INFO,
++ "HIP BOS (HIP Bootstrap Packet)");
++ break;
++ case NOTIFY:
++ col_add_fstr(pinfo->cinfo, COL_INFO,
++ "HIP NOTIFY (HIP Notification Packet)");
++ break;
++ case CLOSE:
++ col_add_fstr(pinfo->cinfo, COL_INFO,
++ "HIP CLOSE (HIP Close Packet)");
++ break;
++ case CLOSE_ACK:
++ col_add_fstr(pinfo->cinfo, COL_INFO,
++ "HIP CLOSE_ACK (HIP Close Acknowledgement Packet)");
++ break;
++ default:
++ col_add_fstr(pinfo->cinfo, COL_INFO, "HIP Unknown type");
++ break;
++ }
++ }
++
++ /*
++ * populate a tree in the second pane with the status of the link layer
++ * (ie none)
++ */
++ if(tree) {
++ if (hip_summary_in_tree) {
++ ti = proto_tree_add_protocol_format(tree, proto_hip, tvb, 0, -1, "Host Identity Protocol");
++ } else {
++ ti = proto_tree_add_item(tree, proto_hip, tvb, 0, -1, FALSE);
++ }
++
++ hip_tree = proto_item_add_subtree(ti, ett_hip);
++ proto_tree_add_uint(hip_tree, hf_hip_proto, tvb, offset, 1, hiph.proto);
++ proto_tree_add_uint(hip_tree, hf_hip_hdr_len, tvb, offset+1, 1, hiph.hdr_len);
++ proto_tree_add_uint(hip_tree, hf_hip_packet_type, tvb, offset+2, 1, hiph.packet_type);
++ proto_tree_add_uint_format(hip_tree, hf_hip_version, tvb, offset+3, 1, hiph.version,
++ "Version: %u, Reserved: %u", hiph.version, hiph.res);
++ ti = proto_tree_add_uint(hip_tree, hf_hip_controls, tvb, offset+4, 2, control_h);
++ if (ti) { /* HIP Controls subtree*/
++ ti = proto_item_add_subtree(ti, ett_hip_controls);
++ proto_tree_add_boolean(ti, hf_hip_controls_cert, tvb, offset+5,1, control_h);
++ proto_tree_add_boolean(ti, hf_hip_controls_anon, tvb, offset+5,1, control_h);
++ }
++
++
++ /* Checksum - this is the same algorithm from UDP, ICMPv6 */
++ if (!pinfo->fragmented) {
++ /* IPv4 or IPv6 addresses */
++ cksum_vec[0].ptr = pinfo->src.data;
++ cksum_vec[0].len = pinfo->src.len;
++ cksum_vec[1].ptr = pinfo->dst.data;
++ cksum_vec[1].len = pinfo->dst.len;
++ /* the rest of the pseudo-header */
++ if (pinfo->src.type == AT_IPv6) {
++ cksum_vec[2].ptr = (const guint8 *)&phdr;
++ phdr[0] = g_htonl(tvb_reported_length(tvb));
++ phdr[1] = g_htonl(IP_PROTO_HIP);
++ cksum_vec[2].len = 8;
++ } else {
++ cksum_vec[2].ptr = (const guint8 *)&phdr;
++ phdr[0] = g_htonl((IP_PROTO_HIP<<16)+tvb_reported_length(tvb));
++ cksum_vec[2].len = 4;
++ }
++ /* pointer to the HIP header (packet data) */
++ cksum_vec[3].len = tvb_reported_length(tvb);
++ cksum_vec[3].ptr = tvb_get_ptr(tvb, 0, cksum_vec[3].len);
++ computed_checksum = in_cksum(cksum_vec, 4);
++ if (computed_checksum == 0) {
++ proto_tree_add_uint_format(hip_tree, hf_hip_checksum, tvb,
++ offset+6, 2, checksum_h, "Checksum: 0x%04x (correct)",
++ checksum_h);
++ } else {
++ proto_tree_add_uint_format(hip_tree, hf_hip_checksum, tvb,
++ offset+6, 2, checksum_h,
++ "Checksum: 0x%04x (incorrect, should be 0x%04x)",
++ checksum_h,
++ in_cksum_shouldbe(checksum_h, computed_checksum));
++ }
++ } else {
++ proto_tree_add_uint_format(hip_tree, hf_hip_checksum, tvb,
++ offset+6, 2, checksum_h,"Checksum: 0x%04x (unverified)",
++ checksum_h);
++ }
++ offset += 8;
++ proto_tree_add_bytes(hip_tree, hf_hip_hit_sndr, tvb, offset, sizeof(hip_hit), hiph.hit_sndr);
++ offset += sizeof(hip_hit);
++ proto_tree_add_bytes(hip_tree, hf_hip_hit_rcvr, tvb, offset, sizeof(hip_hit), hiph.hit_rcvr);
++ offset += sizeof(hip_hit);
++
++ length = (hiph.hdr_len+1)*8;
++ /* Begin TLV parsing */
++ if (offset < length) {
++ ti_tlv = proto_tree_add_text(hip_tree, tvb, offset, tvb_length(tvb), "HIP Parameters");
++ hip_tlv_tree = proto_item_add_subtree(ti_tlv, ett_hip_tlv);
++ }
++ /* Parse type and length in TLV */
++ while (offset < length)
++ {
++ tvb_memcpy(tvb, (guint8 *)&tlv, offset, sizeof(tlv_head));
++ tlv_type_h = g_ntohs(tlv.type);
++ tlv_length_h = g_ntohs(tlv.length);
++ ti_tlv = proto_tree_add_uint_format(hip_tlv_tree, hf_hip_type, tvb,
++ offset, 4+tlv_length_h, tlv.type, "%s (type=%u, length=%u)",
++ hip_param(tlv_type_h), 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;
++ }
++
++ }
++ }
++
++ void
++ proto_register_hip(void)
++ {
++ /* Most of this stuff is unused */
++ module_t *hip_module;
++ static hf_register_info hf[] = {
++ { &hf_hip_proto,
++ { "Payload Protocol", "hip.proto", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
++
++ { &hf_hip_hdr_len,
++ { "Header Length", "hip.hdr_len", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
++
++ { &hf_hip_packet_type,
++ { "Packet Type", "hip.packet_type", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
++
++ { &hf_hip_version,
++ { "Version", "hip.version", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
++
++ { &hf_hip_res,
++ { "Reserved", "hip.res", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
++
++ { &hf_hip_controls,
++ { "HIP Controls", "hip.controls", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }},
++
++ { &hf_hip_controls_cert,
++ { "Certificate (One or more CER packets follows)", "hip.controls.c", FT_BOOLEAN, 16, NULL, HIP_CONTROL_C_MASK, "", HFILL }},
++
++ { &hf_hip_controls_anon,
++ { "Anonymous (Sender's HI is anonymous)", "hip.controls.a", FT_BOOLEAN, 16, NULL, HIP_CONTROL_A_MASK, "", HFILL }},
++
++ { &hf_hip_checksum,
++ { "Checksum", "hip.checksum", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }},
<<Diff was trimmed, longer than 597 lines>>
More information about the pld-cvs-commit
mailing list