Damn the torpedos[1], commit it anyway.
[obnox/wireshark/wip.git] / packet-mip.c
index 70eaf54932e94bf9cd32163ce1b8c5e8a4ee2442..c789ee0a071c3bbdf6a3dcf03cbd8e48bf06c126 100644 (file)
@@ -2,10 +2,10 @@
  * Routines for Mobile IP dissection
  * Copyright 2000, Stefan Raab <sraab@cisco.com>
  *
- * $Id: packet-mip.c,v 1.15 2001/02/14 20:03:05 guy Exp $
+ * $Id: packet-mip.c,v 1.19 2001/09/14 07:10:05 guy Exp $
  *
  * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@unicom.net>
+ * By Gerald Combs <gerald@ethereal.com>
  * Copyright 1998 Gerald Combs
  *
  * This program is free software; you can redistribute it and/or
@@ -57,6 +57,7 @@ static int hf_mip_d = -1;
 static int hf_mip_m = -1;
 static int hf_mip_g = -1;
 static int hf_mip_v = -1;
+static int hf_mip_t = -1;
 static int hf_mip_code = -1;
 static int hf_mip_life = -1;
 static int hf_mip_homeaddr = -1;
@@ -96,6 +97,10 @@ static const value_string mip_reply_codes[]= {
   {71, "Reg Deny (FA)- Poorly Formed Reply"},
   {72, "Reg Deny (FA)- Requested Encapsulation Unavailable"},
   {73, "Reg Deny (FA)- VJ Compression Unavailable"},
+  {74, "Reg Deny (FA)- Requested Reverse Tunnel Unavailable"},
+  {75, "Reg Deny (FA)- Reverse Tunnel is Mandatory and 'T' Bit Not Set"},
+  {76, "Reg Deny (FA)- Mobile Node Too Distant"},
+  {79, "Reg Deny (FA)- Delivery Style Not Supported"},
   {80, "Reg Deny (FA)- Home Network Unreachable"},
   {81, "Reg Deny (FA)- HA Host Unreachable"},
   {82, "Reg Deny (FA)- HA Port Unreachable"},
@@ -113,6 +118,9 @@ static const value_string mip_reply_codes[]= {
   {134, "Reg Deny (HA)- Poorly Formed Request"},
   {135, "Reg Deny (HA)- Too Many Simultaneous Bindings"},
   {136, "Reg Deny (HA)- Unknown HA Address"},
+  {137, "Reg Deny (HA)- Requested Reverse Tunnel Unavailable"},
+  {138, "Reg Deny (HA)- Reverse Tunnel is Mandatory and 'T' Bit Not Set"},
+  {139, "Reg Deny (HA)- Requested Encapsulation Unavailable"},
   {0, NULL},
 };
 
@@ -133,8 +141,8 @@ dissect_mip( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        proto_item      *ti;
        proto_tree      *mip_tree=NULL, *ext_tree=NULL;
        guint8          type, code;
-       struct timeval      ident_time;
-       int eoffset, elen;
+       nstime_t        ident_time;
+       int             eoffset, elen;
        
 /* Make entries in Protocol column and Info column on summary display */
 
@@ -163,17 +171,19 @@ dissect_mip( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                 proto_tree_add_boolean(mip_tree, hf_mip_m, tvb, 1, 1, code);
                 proto_tree_add_boolean(mip_tree, hf_mip_g, tvb, 1, 1, code);
                 proto_tree_add_boolean(mip_tree, hf_mip_v, tvb, 1, 1, code);
+                proto_tree_add_boolean(mip_tree, hf_mip_t, tvb, 1, 1, code);
                 
                 proto_tree_add_item(mip_tree, hf_mip_life, tvb, 2, 2, FALSE);
                 proto_tree_add_item(mip_tree, hf_mip_homeaddr, tvb, 4, 4, FALSE);
                 proto_tree_add_item(mip_tree, hf_mip_haaddr, tvb, 8, 4, FALSE);
                 proto_tree_add_item(mip_tree, hf_mip_coa, tvb, 12, 4, FALSE);
-                ident_time.tv_sec =  tvb_get_ntohl(tvb,16)-(guint32) NTP_BASETIME;
-                ident_time.tv_usec = tvb_get_ntohl(tvb,20);
+                ident_time.secs =  tvb_get_ntohl(tvb,16)-(guint32) NTP_BASETIME;
+                ident_time.nsecs = tvb_get_ntohl(tvb,20)*1000;
                 proto_tree_add_time(mip_tree, hf_mip_ident, tvb, 16, 8, &ident_time);
                 
                 eoffset = 24;
-                while (eoffset < tvb_length(tvb)) {             /* Registration Extensions */
+                while (tvb_reported_length_remaining(tvb, eoffset) > 0) {
+                       /* Registration Extensions */
                        if (eoffset ==24) {
                          ti = proto_tree_add_text(mip_tree, tvb, 24, tvb_length(tvb)-24, "Extensions");
                          ext_tree = proto_item_add_subtree(ti, ett_mip_ext);
@@ -223,12 +233,13 @@ dissect_mip( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                 proto_tree_add_item(mip_tree, hf_mip_life, tvb, 2, 2, FALSE);
                 proto_tree_add_item(mip_tree, hf_mip_homeaddr, tvb, 4, 4, FALSE);
                 proto_tree_add_item(mip_tree, hf_mip_haaddr, tvb, 8, 4, FALSE);
-                ident_time.tv_sec =  tvb_get_ntohl(tvb,12)-(guint32) NTP_BASETIME;
-                ident_time.tv_usec = tvb_get_ntohl(tvb,16);
+                ident_time.secs =  tvb_get_ntohl(tvb,12)-(guint32) NTP_BASETIME;
+                ident_time.nsecs = tvb_get_ntohl(tvb,16)*1000;
                 proto_tree_add_time(mip_tree, hf_mip_ident, tvb, 12, 8, &ident_time);
                 
                 eoffset = 20;
-                while (eoffset < tvb_length(tvb)) {             /* Registration Extensions */
+                while (tvb_reported_length_remaining(tvb, eoffset) > 0) {
+                       /* Registration Extensions */
                        if (eoffset==20) {
                          ti = proto_tree_add_text(mip_tree, tvb, 20, tvb_length(tvb)-20, "Extensions");
                          ext_tree = proto_item_add_subtree(ti, ett_mip_ext);
@@ -270,94 +281,99 @@ void proto_register_mip(void)
          { &hf_mip_type,
                 { "Message Type",           "mip.type",
                        FT_INT8, BASE_DEC, VALS(mip_types), 0,          
-                       "Mobile IP Message type." }
+                       "Mobile IP Message type.", HFILL }
          },
          { &hf_mip_s,
                 {"Simultaneous Bindings",           "mip.s",
 
                   FT_BOOLEAN, 8, NULL, 128,          
-                  "Simultaneous Bindings Allowed" }
+                  "Simultaneous Bindings Allowed", HFILL }
          },
          { &hf_mip_b,
                 {"Broadcast Datagrams",           "mip.b",
                   FT_BOOLEAN, 8, NULL, 64,          
-                  "Broadcast Datagrams requested" }
+                  "Broadcast Datagrams requested", HFILL }
          },
          { &hf_mip_d,
                 { "Co-lcated Care-of Address",           "mip.d",
                   FT_BOOLEAN, 8, NULL, 32,          
-                  "MN using Co-located Care-of address" }
+                  "MN using Co-located Care-of address", HFILL }
          },
          { &hf_mip_m,
                 {"Minimal Encapsulation",           "mip.m",
                   FT_BOOLEAN, 8, NULL, 16,          
-                  "MN wants Minimal encapsulation" }
+                  "MN wants Minimal encapsulation", HFILL }
          },
          { &hf_mip_g,
                 {"GRE",           "mip.g",
                   FT_BOOLEAN, 8, NULL, 8,          
-                  "MN wants GRE encapsulation" }
+                  "MN wants GRE encapsulation", HFILL }
          },
          { &hf_mip_v,
                 { "Van Jacobson",           "mip.v",
                   FT_BOOLEAN, 8, NULL, 4,          
-                  "Van Jacobson" }
+                  "Van Jacobson", HFILL }
+         },
+         { &hf_mip_t,
+                { "Reverse Tunneling",           "mip.t",
+                  FT_BOOLEAN, 8, NULL, 2,          
+                  "Reverse tunneling requested", HFILL }
          },
          { &hf_mip_code,
                 { "Reply Code",           "mip.code",
                        FT_UINT8, BASE_DEC, VALS(mip_reply_codes), 0,          
-                       "Mobile IP Reply code." }
+                       "Mobile IP Reply code.", HFILL }
          },
          { &hf_mip_life,
                 { "Lifetime",           "mip.life",
                        FT_UINT16, BASE_DEC, NULL, 0,          
-                       "Mobile IP Lifetime." }
+                       "Mobile IP Lifetime.", HFILL }
          },
          { &hf_mip_homeaddr,
                 { "Home Address",           "mip.homeaddr",
                        FT_IPv4, BASE_NONE, NULL, 0,          
-                       "Mobile Node's home address." }
+                       "Mobile Node's home address.", HFILL }
          },
          
          { &hf_mip_haaddr,
                 { "Home Agent",           "mip.haaddr",
                        FT_IPv4, BASE_NONE, NULL, 0,          
-                       "Home agent IP Address." }
+                       "Home agent IP Address.", HFILL }
          },
          { &hf_mip_coa,
                 { "Care of Address",           "mip.coa",
                        FT_IPv4, BASE_NONE, NULL, 0,          
-                       "Care of Address." }
+                       "Care of Address.", HFILL }
          },
          { &hf_mip_ident,
                 { "Identification",           "mip.ident",
                        FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0,          
-                       "MN Identification." }
+                       "MN Identification.", HFILL }
          },
          { &hf_mip_ext_type,
                 { "Extension Type",           "mip.ext.type",
                        FT_INT8, BASE_DEC, VALS(mip_ext_types), 0,          
-                       "Mobile IP Extension Type." }
+                       "Mobile IP Extension Type.", HFILL }
          },
          { &hf_mip_ext_len,
                 { "Extension Length",         "mip.ext.len",
                        FT_INT8, BASE_DEC, NULL, 0,
-                       "Mobile IP Extension Length."}
+                       "Mobile IP Extension Length.", HFILL }
          },
          { &hf_mip_aext_spi,
                 { "SPI",                      "mip.auth.spi",
                        FT_INT32, BASE_HEX, NULL, 0,
-                       "Authentication Header Security Parameter Index."}
+                       "Authentication Header Security Parameter Index.", HFILL }
          },
          { &hf_mip_aext_auth,
                 { "Authenticator",            "mip.auth.auth",
                        FT_BYTES, BASE_NONE, NULL, 0,
-                       "Authenticator."}
+                       "Authenticator.", HFILL }
          },
          { &hf_mip_next_nai,
                 { "NAI",                      "mip.nai",
                        FT_STRING, BASE_NONE, NULL, 0,
-                       "NAI"}
+                       "NAI", HFILL }
          },
        };