Fix for bug 1235. Elapsed time is in 10ms units.
[obnox/wireshark/wip.git] / epan / dissectors / packet-dhcpv6.c
index e5f5db2905c6d9106a43470336958645f57200ea..a942cf5b68c9578b9c5320939059ac71cfe3a59e 100644 (file)
@@ -21,8 +21,8 @@
  * Note that protocol constants are still subject to change, based on IANA
  * assignment decisions.
  *
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
  * Copyright 1998 Gerald Combs
  *
  * This program is free software; you can redistribute it and/or
@@ -47,7 +47,6 @@
 #include <string.h>
 #include <glib.h>
 #include <epan/packet.h>
-#include <epan/ipv6-utils.h>
 #include "packet-arp.h"
 
 static int proto_dhcpv6 = -1;
@@ -461,7 +460,7 @@ dhcpv6_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree,
                                   optlen, "IAADDR: malformed option");
               break;
            }
-           tvb_memcpy(tvb, (guint8 *)&in6, off, sizeof(in6));
+           tvb_get_ipv6(tvb, off, &in6);
            proto_tree_add_text(subtree, tvb, off,
                                sizeof(in6), "IPv6 address: %s",
                                ip6_to_str(&in6));
@@ -524,8 +523,8 @@ dhcpv6_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree,
            break;
          }
          proto_tree_add_text(subtree, tvb, off, 2,
-                             "elapsed-time: %d sec",
-                             (guint32)tvb_get_ntohs(tvb, off));
+                             "elapsed-time: %u ms",
+                             10*(guint32)tvb_get_ntohs(tvb, off));
          break;
        case OPTION_RELAY_MSG:
          if (optlen == 0) {
@@ -563,7 +562,7 @@ dhcpv6_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree,
                                optlen, "UNICAST: malformed option");
            break;
          }
-         tvb_memcpy(tvb, (guint8 *)&in6, off, sizeof(in6));
+         tvb_get_ipv6(tvb, off, &in6);
          proto_tree_add_text(subtree, tvb, off,
                              sizeof(in6), "IPv6 address: %s",
                                ip6_to_str(&in6));
@@ -580,7 +579,7 @@ dhcpv6_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree,
                                    status_code);
 
                if (optlen - 2 > 0) {
-                   status_message = ep_tvb_get_string(tvb, off + 2, optlen - 2);
+                   status_message = tvb_get_ephemeral_string(tvb, off + 2, optlen - 2);
                    proto_tree_add_text(subtree, tvb, off + 2, optlen - 2,
                                        "Status Message: %s",
                                        status_message);
@@ -649,7 +648,7 @@ dhcpv6_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree,
                        break;
                }
                for (i = 0; i < optlen; i += 16) {
-                       tvb_memcpy(tvb, (guint8 *)&in6, off + i, sizeof(in6));
+                       tvb_get_ipv6(tvb, off + i, &in6);
                        proto_tree_add_text(subtree, tvb, off + i,
                                sizeof(in6), "SIP servers address: %s",
                                ip6_to_str(&in6));
@@ -662,7 +661,7 @@ dhcpv6_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree,
                        break;
                }
                for (i = 0; i < optlen; i += 16) {
-                       tvb_memcpy(tvb, (guint8 *)&in6, off + i, sizeof(in6));
+                       tvb_get_ipv6(tvb, off + i, &in6);
                        proto_tree_add_text(subtree, tvb, off + i,
                                sizeof(in6), "DNS servers address: %s",
                                ip6_to_str(&in6));
@@ -681,7 +680,7 @@ dhcpv6_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree,
                        break;
                }
                for (i = 0; i < optlen; i += 16) {
-                       tvb_memcpy(tvb, (guint8 *)&in6, off + i, sizeof(in6));
+                       tvb_get_ipv6(tvb, off + i, &in6);
                        proto_tree_add_text(subtree, tvb, off + i,
                                sizeof(in6), "NIS servers address: %s",
                                ip6_to_str(&in6));
@@ -694,7 +693,7 @@ dhcpv6_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree,
                        break;
                }
                for (i = 0; i < optlen; i += 16) {
-                       tvb_memcpy(tvb, (guint8 *)&in6, off + i, sizeof(in6));
+                       tvb_get_ipv6(tvb, off + i, &in6);
                        proto_tree_add_text(subtree, tvb, off + i,
                                sizeof(in6), "NISP servers address: %s",
                                ip6_to_str(&in6));
@@ -719,7 +718,7 @@ dhcpv6_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree,
                        break;
                }
                for (i = 0; i < optlen; i += 16) {
-                       tvb_memcpy(tvb, (guint8 *)&in6, off + i, sizeof(in6));
+                       tvb_get_ipv6(tvb, off + i, &in6);
                        proto_tree_add_text(subtree, tvb, off + i,
                                sizeof(in6), "SNTP servers address: %s",
                                ip6_to_str(&in6));
@@ -727,7 +726,7 @@ dhcpv6_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree,
                break;
        case OPTION_TIME_ZONE:
          if (optlen > 0) {
-             buf = ep_tvb_get_string(tvb, off, optlen);
+             buf = tvb_get_ephemeral_string(tvb, off, optlen);
              proto_tree_add_text(subtree, tvb, off, optlen, "time-zone: %s", buf);
          }
          break;
@@ -793,7 +792,7 @@ dhcpv6_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree,
                }
                proto_tree_add_text(subtree, tvb, off + 8, 1,
                                    "Prefix length: %d", prefix_length);
-               tvb_memcpy(tvb, (guint8 *)&in6, off + 9 , sizeof(in6));
+               tvb_get_ipv6(tvb, off + 9, &in6);
                proto_tree_add_text(subtree, tvb, off + 9,
                                    16, "Prefix address: %s",
                                    ip6_to_str(&in6));
@@ -816,7 +815,7 @@ dhcpv6_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree,
                        break;
                }
 
-               tvb_memcpy(tvb, (guint8 *)&in6, off , sizeof(in6));
+               tvb_get_ipv6(tvb, off, &in6);
                proto_tree_add_text(subtree, tvb, off,
                        16, "Home Agent: %s", ip6_to_str(&in6));
                break;
@@ -827,7 +826,7 @@ dhcpv6_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree,
                        break;
                }
 
-               tvb_memcpy(tvb, (guint8 *)&in6, off , sizeof(in6));
+               tvb_get_ipv6(tvb, off, &in6);
                proto_tree_add_text(subtree, tvb, off,
                        16, "Home Address: %s", ip6_to_str(&in6));
                break;
@@ -882,11 +881,11 @@ dissect_dhcpv6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
            hop_count = tvb_get_guint8(tvb, off+1);
            proto_tree_add_text(bp_tree, tvb, off+1, 1, "Hop count: %d", hop_count);
 
-           tvb_memcpy(tvb, (guint8 *)&in6, off+2, sizeof(in6));
+           tvb_get_ipv6(tvb, off+2, &in6);
            proto_tree_add_text(bp_tree, tvb, off+2, sizeof(in6), 
                                "Link-address: %s",ip6_to_str(&in6));
 
-           tvb_memcpy(tvb, (guint8 *)&in6, off+18, sizeof(in6));
+           tvb_get_ipv6(tvb, off+18, &in6);
            proto_tree_add_text(bp_tree, tvb, off+18, sizeof(in6), 
                                "Peer-address: %s",ip6_to_str(&in6));
 
@@ -909,7 +908,7 @@ dissect_dhcpv6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
                           msgtype);
                   proto_tree_add_text(bp_tree, tvb, off+1, 3, "Transaction-ID: 0x%08x", xid);
 #if 0
-                  tvb_memcpy(tvb, (guint8 *)&in6, 4, sizeof(in6));
+                  tvb_get_ipv6(tvb, 4, &in6);
                   proto_tree_add_text(bp_tree, tvb, 4, sizeof(in6),
                           "Server address: %s", ip6_to_str(&in6));
 #endif
@@ -956,11 +955,11 @@ proto_register_dhcpv6(void)
     { &hf_fqdn_1,
       { "Reserved", "", FT_UINT8, BASE_HEX, NULL, 0xF8, "", HFILL}},
     { &hf_fqdn_2,
-      { "N", "", FT_BOOLEAN, 8, TFS(&fqdn_n), 0x4, "", HFILL}},
+      { "N", "dhcpv6.msgtype.n", FT_BOOLEAN, 8, TFS(&fqdn_n), 0x4, "", HFILL}},
     { &hf_fqdn_3,
-      { "O", "", FT_BOOLEAN, 8, TFS(&fqdn_o), 0x2, "", HFILL}},
+      { "O", "dhcpv6.msgtype.o", FT_BOOLEAN, 8, TFS(&fqdn_o), 0x2, "", HFILL}},
     { &hf_fqdn_4,
-      { "S", "", FT_BOOLEAN, 8, TFS(&fqdn_s), 0x1, "", HFILL}}
+      { "S", "dhcpv6.msgtype.s", FT_BOOLEAN, 8, TFS(&fqdn_s), 0x1, "", HFILL}}
     
   };
   static gint *ett[] = {