From Krishnamurthy Mayya and Nikitha Malgi via
authorEvan Huus <eapache@gmail.com>
Sat, 1 Dec 2012 15:39:14 +0000 (15:39 -0000)
committerEvan Huus <eapache@gmail.com>
Sat, 1 Dec 2012 15:39:14 +0000 (15:39 -0000)
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8019

Dissection support for PW-OAM messages (RFC 6478).

svn path=/trunk/; revision=46311

AUTHORS
epan/CMakeLists.txt
epan/dissectors/Makefile.common
epan/dissectors/packet-mpls.c
epan/dissectors/packet-pw-oam.c [new file with mode: 0644]

diff --git a/AUTHORS b/AUTHORS
index 98d083a3201118fa4e4a42dcb176282dea73b478..7c5228615bc3b85158f7bb80fd1a0b3aae97ede0 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -3682,6 +3682,8 @@ Pontus Fuchs              <pontus.fuchs[AT]gmail.com>
 Bill Parker            <wp02855[AT]gmail.com>
 Tomofumi Hayashi       <s1061123[AT]gmail.com>
 Tim Hentenaar          <tim.hentenaar[AT]gmail.com>
+Krishnamurthy Mayya    <krishnamurthymayya[AT]gmail.com>
+Nikitha Malgi          <nikitha01[AT]gmail.com>
 
 Dan Lasley <dlasley[AT]promus.com> gave permission for his
 dumpit() hex-dump routine to be used.
index da5b123fda4be625630b093ac5dce3460684e458..b76f9b031b6ce4260f87e21894fb1b33a98ee125 100644 (file)
@@ -1009,6 +1009,7 @@ set(DISSECTOR_SRC
        dissectors/packet-pw-eth.c
        dissectors/packet-pw-fr.c
        dissectors/packet-pw-hdlc.c
+       dissectors/packet-pw-oam.c
        dissectors/packet-pw-satop.c
        dissectors/packet-q2931.c
        dissectors/packet-q708.c
index ae34870f475c06b44959338019b7f0bcfbdbe8ca..0b8aff550dfa828d0d837c7653596e53ce56a687 100644 (file)
@@ -929,6 +929,7 @@ DISSECTOR_SRC = \
        packet-pw-eth.c         \
        packet-pw-fr.c          \
        packet-pw-hdlc.c        \
+       packet-pw-oam.c         \
        packet-pw-satop.c       \
        packet-q2931.c          \
        packet-q708.c           \
index b2069a8c7bbc52dbe025058971bff7735e7976b9..2a852aa1072a89b540de02387a2ef95f6d07032c 100644 (file)
@@ -102,6 +102,7 @@ static dissector_handle_t dissector_mpls_pm_ilm_dm;
 static dissector_handle_t dissector_mpls_psc;
 static dissector_handle_t dissector_mplstp_lock;
 static dissector_handle_t dissector_mplstp_fm;
+static dissector_handle_t dissector_pw_oam;
 static dissector_handle_t dissector_pw_eth_heuristic;
 static dissector_handle_t dissector_pw_fr;
 static dissector_handle_t dissector_pw_hdlc_nocw_fr;
@@ -298,6 +299,7 @@ static const value_string mpls_pwac_types[] = {
     { 0x0024, "Protection State Coordination Protocol (PSC)"},
     { 0x0025, "On-Demand CV"},
     { 0x0026, "LI"},
+    { 0x0027, "Pseudo-Wire OAM"},
     { 0x0057, "IPv6 packet" },
     { 0x0058, "Fault OAM"},
     { 0x7FF8, "Reserved for Experimental Use"},
@@ -435,6 +437,10 @@ dissect_pw_ach(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
             call_dissector(dissector_mplstp_lock, next_tvb, pinfo, tree);
             break;
 
+        case 0x0027: /* KM: MPLSTP PW-OAM, RFC 6478 */
+            call_dissector(dissector_pw_oam, next_tvb, pinfo, tree);
+            break;
+
         case 0x0058: /* KM: MPLSTP FM, RFC 6427 */
             call_dissector(dissector_mplstp_fm, next_tvb, pinfo, tree);
             break;
@@ -811,6 +817,7 @@ proto_reg_handoff_mpls(void)
     dissector_mpls_psc              = find_dissector("mpls_psc");
     dissector_mplstp_lock           = find_dissector("mplstp_lock");
     dissector_mplstp_fm             = find_dissector("mplstp_fm");
+    dissector_pw_oam                = find_dissector("pw_oam");
     dissector_pw_eth_heuristic      = find_dissector("pw_eth_heuristic");
     dissector_pw_fr                 = find_dissector("pw_fr");
     dissector_pw_hdlc_nocw_fr       = find_dissector("pw_hdlc_nocw_fr");
diff --git a/epan/dissectors/packet-pw-oam.c b/epan/dissectors/packet-pw-oam.c
new file mode 100644 (file)
index 0000000..4c4f521
--- /dev/null
@@ -0,0 +1,218 @@
+/* packet-pw-oam.c
+*
+* Routines for Pseudowire Status for static pseudowires : RFC 6478
+*
+* (c) Copyright 2012, Krishnamurthy Mayya <krishnamurthymayya@gmail.com>
+*                     Nikitha Malgi <nikitha01@gmail.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
+* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#include "config.h"
+#include <glib.h>
+#include <epan/packet.h>
+#include <packet-ip.h>
+
+/* MPLS-TP FM protocol specific variables */
+static gint proto_pw_oam             = -1;
+static gint ett_pw_oam               = -1;
+static gint ett_pw_oam_flags         = -1;
+static gint ett_pw_oam_tlv_tree      = -1;
+
+static int hf_pw_oam_tlv_reserved    = -1;
+static int hf_pw_oam_tlv_type        = -1;
+static int hf_pw_oam_total_tlv_len   = -1;
+static int hf_pw_oam_code            = -1;
+static int hf_pw_oam_flags           = -1;
+static int hf_pw_oam_flags_a         = -1;
+static int hf_pw_oam_refresh_timer   = -1;
+static int hf_pw_oam_tlv_len         = -1;
+
+static const value_string pw_oam_code[] = {
+  {0x00000002, "Local Attachment Circuit(ingress) Receive Fault"},
+  {0x00000004, "Local Attachment Circuit(egress) Transmit Fault"},
+  {0x00000020, "PW Forwarding Standby"},
+  {0x00000040, "Request Switchover to this PW"},
+  {0, NULL}
+};
+
+/* PW-Status TLV dissector */
+void
+dissect_pw_status_tlv (tvbuff_t *tvb, proto_tree *tree, gint offset)
+{
+  proto_item *ti          = NULL;
+  proto_tree *pw_oam_tlv_tree = NULL;
+
+  guint reserved        = 0;
+
+  ti = proto_tree_add_protocol_format (tree, proto_pw_oam, tvb, offset, 8, 
+                                       "Pseudo-Wire Status TLV");
+
+  reserved = (tvb_get_guint8 (tvb, offset) >> 6);
+
+  if (!tree)
+    return;
+
+  pw_oam_tlv_tree = proto_item_add_subtree (ti, ett_pw_oam_tlv_tree);
+
+  proto_tree_add_uint (pw_oam_tlv_tree, hf_pw_oam_tlv_reserved, tvb, offset,
+                                    1, reserved);
+  proto_tree_add_item (pw_oam_tlv_tree, hf_pw_oam_tlv_type, tvb, offset,
+                                    2, ENC_BIG_ENDIAN);
+  offset = offset + 2;
+
+  proto_tree_add_item (pw_oam_tlv_tree, hf_pw_oam_tlv_len, tvb, offset,
+                                    2, ENC_BIG_ENDIAN);
+  offset = offset + 2;
+  proto_tree_add_item (pw_oam_tlv_tree, hf_pw_oam_code, tvb, offset,
+                                    4, ENC_BIG_ENDIAN);
+  offset = offset + 4;
+
+  return ;
+}
+
+/* Dissector for PW OAM protocol: RFC 6478 */
+static void
+dissect_pw_oam(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+{
+  proto_item  *ti = NULL, *ti_flags = NULL;
+  proto_tree  *pw_oam_tree = NULL, *pw_oam_flags = NULL;
+
+  guint8  offset        = 0;
+  guint16 pw_tlv_type   = 0;
+
+  col_set_str(pinfo->cinfo, COL_PROTOCOL, "PW OAM");
+  col_clear(pinfo->cinfo, COL_INFO);
+
+  if (!tree)
+    return;
+
+  ti = proto_tree_add_item(tree, proto_pw_oam, tvb, 0, -1, ENC_NA);
+
+  pw_oam_tree = proto_item_add_subtree (ti, ett_pw_oam);
+
+  /* Refresh-Timer field */
+  proto_tree_add_item (pw_oam_tree, hf_pw_oam_refresh_timer, tvb, offset,
+                       2, ENC_BIG_ENDIAN);
+  offset = offset + 2;
+
+  /* Total-TLV length */
+  proto_tree_add_item (pw_oam_tree, hf_pw_oam_total_tlv_len, tvb, offset,
+                       1, ENC_BIG_ENDIAN);
+  offset = offset + 1;
+
+  /* Flags field */
+  ti_flags = proto_tree_add_item (pw_oam_tree, hf_pw_oam_flags, tvb, 
+                                  offset, 1, ENC_BIG_ENDIAN);
+  pw_oam_flags = proto_item_add_subtree(ti_flags, ett_pw_oam_flags);
+  proto_tree_add_item (pw_oam_flags, hf_pw_oam_flags_a, tvb, offset, 1, FALSE);
+
+  offset = offset + 1;
+  pw_tlv_type = tvb_get_ntohs (tvb, offset);
+
+  /* TLVs  */
+  switch (pw_tlv_type)
+    {
+      /* The switch cases below have to be based on the LDP-name space.
+          http://www.iana.org/assignments/ldp-namespaces/ldp-namespaces.xml */
+
+      case 0x096A: /* PW-Status TLV */
+        dissect_pw_status_tlv (tvb, tree, offset);
+        break;
+
+      default:
+        break;
+    }
+
+  return;
+}
+
+void
+proto_register_pw_oam(void)
+{
+  static hf_register_info hf[] = {
+
+    {&hf_pw_oam_refresh_timer,
+      {"Refresh-Timer", "pw_oam.refresh-timer", FT_UINT16,
+        BASE_HEX, NULL, 0x0, NULL, HFILL }},
+
+    {&hf_pw_oam_total_tlv_len,
+      {"TLV Length", "pw_oam.total-tlv-len", FT_UINT8,
+        BASE_HEX, NULL, 0x0, NULL, HFILL }},
+
+    {&hf_pw_oam_flags,
+      {"Flags", "pw_oam.flags", FT_UINT8,
+        BASE_HEX, NULL, 0x0000, "Flags", HFILL }},
+
+    {&hf_pw_oam_flags_a,
+      {"Acknowledgement", "pw_oam.flags_a",
+        FT_BOOLEAN, 8, NULL, 0x0080, "ACK bit", HFILL}
+    },
+
+    {&hf_pw_oam_tlv_reserved,
+      {"Reserved", "pw_oam.tlv-reserved",
+        FT_UINT8, BASE_HEX, NULL, 0x0000, NULL, HFILL}
+    },
+
+    {&hf_pw_oam_tlv_type,
+      {"TLV Type", "pw_oam.tlv-type",
+        FT_UINT16, BASE_HEX, NULL, 0x00, NULL, HFILL}
+    },
+
+    {&hf_pw_oam_tlv_len,
+      {"TLV Length ", "pw_oam.tlv-len",
+        FT_UINT16, BASE_HEX, NULL, 0x00, NULL, HFILL}
+    },
+
+    {&hf_pw_oam_code,
+      {"Status code", "pw_oam.code", FT_UINT16,
+        BASE_HEX, VALS(pw_oam_code), 0x0, "PW Status Code", HFILL }
+    },
+
+  };
+
+  static gint *ett[] = {
+    &ett_pw_oam,
+    &ett_pw_oam_tlv_tree,
+    &ett_pw_oam_flags,
+  };
+
+  proto_pw_oam =
+    proto_register_protocol("Pseudo-Wire OAM", "PW-OAM "
+        "Pseudo-Wire OAM Protocol",
+        "pw_oam");
+
+  proto_register_field_array (proto_pw_oam, hf, array_length(hf));
+  proto_register_subtree_array (ett, array_length(ett));
+
+  register_dissector("pw_oam", dissect_pw_oam, proto_pw_oam);
+}
+
+/*
+ * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 2
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=2 tabstop=8 expandtab:
+ * :indentSize=2:tabSize=8:noTabs=true:
+ */