Add ethertype for IEEE 802.1ag Connectivity Fault Management (CFM) protocol
[obnox/wireshark/wip.git] / epan / dissectors / packet-ethertype.c
index 1d0f36f0c3775478fc448ff7a7e0fdec8111800f..66913350368240989990a08c49fee3bb2af54ce0 100644 (file)
@@ -1,12 +1,12 @@
-/* ethertype.c
+/* packet-ethertype.c
  * Routines for calling the right protocol for the ethertype.
  *
  * $Id$
  *
  * Gilbert Ramirez <gram@alumni.rice.edu>
  *
- * 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
@@ -21,7 +21,7 @@
  *
  * 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.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 
 #ifdef HAVE_CONFIG_H
 #include "packet-ipv6.h"
 #include "packet-ipx.h"
 #include "packet-vlan.h"
+#include "packet-ieee8021ah.h"
 #include "packet-vines.h"
-#include "etypes.h"
-#include "ppptypes.h"
+#include <epan/etypes.h>
+#include <epan/ppptypes.h>
 
 static dissector_table_t ethertype_dissector_table;
 
 static dissector_handle_t data_handle;
 
 const value_string etype_vals[] = {
-    {ETHERTYPE_IP,             "IP"                            },
-    {ETHERTYPE_IPv6,           "IPv6"                          },
-    {ETHERTYPE_CENTRINO_PROMISC, "IEEE 802.11 (Centrino promiscuous)" },
-    {ETHERTYPE_X25L3,          "X.25 Layer 3"                  },
-    {ETHERTYPE_ARP,            "ARP"                           },
-    {ETHERTYPE_REVARP,         "RARP"                          },
-    {ETHERTYPE_DEC_LB,         "DEC LanBridge"                 },
-    {ETHERTYPE_ATALK,          "Appletalk"                     },
-    {ETHERTYPE_SNA,            "SNA-over-Ethernet"             },
-    {ETHERTYPE_AARP,           "AARP"                          },
-    {ETHERTYPE_IPX,            "Netware IPX/SPX"               },
-    {ETHERTYPE_VINES_IP,       "Vines IP"                      },
-    {ETHERTYPE_VINES_ECHO,     "Vines Echo"                    },
-    {ETHERTYPE_TRAIN,          "Netmon Train"                  },
-    {ETHERTYPE_LOOP,           "Loopback"                      }, /* Ethernet Loopback */
-    {ETHERTYPE_WCP,            "Wellfleet Compression Protocol" },
-    {ETHERTYPE_ISMP,           "Cabletron Interswitch Message Protocol" },
-    {ETHERTYPE_ISMP_TBFLOOD,   "Cabletron SFVLAN 1.8 Tag-Based Flood" },
+    {ETHERTYPE_IP,                                     "IP"                            },
+    {ETHERTYPE_IPv6,                           "IPv6"                          },
+    {ETHERTYPE_WLCCP,                          "Cisco Wireless Lan Context Control Protocol"           },
+    {ETHERTYPE_CENTRINO_PROMISC,       "IEEE 802.11 (Centrino promiscuous)" },
+    {ETHERTYPE_XNS_IDP,                                "XNS Internet Datagram Protocol" },
+    {ETHERTYPE_X25L3,                          "X.25 Layer 3"                  },
+    {ETHERTYPE_ARP,                                    "ARP"                           },
+    {ETHERTYPE_WMX_M2M,                                "WiMax Mac-to-Mac"              },
+    {ETHERTYPE_EPL_V1,                         "EPL_V1"                                },
+    {ETHERTYPE_REVARP,                         "RARP"                          },
+    {ETHERTYPE_DEC_LB,                         "DEC LanBridge"                 },
+    {ETHERTYPE_ATALK,                          "Appletalk"                     },
+    {ETHERTYPE_SNA,                                    "SNA-over-Ethernet"             },
+    {ETHERTYPE_AARP,                           "AARP"                          },
+    {ETHERTYPE_IPX,                                    "Netware IPX/SPX"               },
+    {ETHERTYPE_VINES_IP,                       "Vines IP"                      },
+    {ETHERTYPE_VINES_ECHO,                     "Vines Echo"                    },
+    {ETHERTYPE_TRAIN,                          "Netmon Train"                  },
+    {ETHERTYPE_LOOP,                           "Loopback"                      }, /* Ethernet Loopback */
+    {ETHERTYPE_FOUNDRY,                                "Foundry proprietary"           },
+    {ETHERTYPE_WCP,                                    "Wellfleet Compression Protocol" },
+    {ETHERTYPE_STP,                                    "Spanning Tree Protocol"        },
+    {ETHERTYPE_ISMP,                           "Cabletron Interswitch Message Protocol" },
+    {ETHERTYPE_ISMP_TBFLOOD,           "Cabletron SFVLAN 1.8 Tag-Based Flood" },
                                /* for ISMP, see RFC 2641, RFC 2642, RFC 2643 */
-    {ETHERTYPE_PPPOED,         "PPPoE Discovery"               },
-    {ETHERTYPE_PPPOES,         "PPPoE Session"                 },
-    {ETHERTYPE_INTEL_ANS,      "Intel ANS probe"               },
+    {ETHERTYPE_PPPOED,                         "PPPoE Discovery"               },
+    {ETHERTYPE_PPPOES,                         "PPPoE Session"                 },
+    {ETHERTYPE_INTEL_ANS,                      "Intel ANS probe"               },
     {ETHERTYPE_MS_NLB_HEARTBEAT,       "MS NLB heartbeat"      },
-    {ETHERTYPE_VLAN,           "802.1Q Virtual LAN"            },
-    {ETHERTYPE_EAPOL,          "802.1X Authentication"         },
-    {ETHERTYPE_RSN_PREAUTH,    "802.11i Pre-Authentication"    },
-    {ETHERTYPE_MPLS,           "MPLS label switched packet"    },
-    {ETHERTYPE_MPLS_MULTI,     "MPLS multicast label switched packet" },
-    {ETHERTYPE_3C_NBP_DGRAM,   "3Com NBP Datagram"             },
-    {ETHERTYPE_DEC,            "DEC proto"                     },
-    {ETHERTYPE_DNA_DL,         "DEC DNA Dump/Load"             },
-    {ETHERTYPE_DNA_RC,         "DEC DNA Remote Console"        },
-    {ETHERTYPE_DNA_RT,         "DEC DNA Routing"               },
-    {ETHERTYPE_LAT,            "DEC LAT"                       },
-    {ETHERTYPE_DEC_DIAG,       "DEC Diagnostics"               },
-    {ETHERTYPE_DEC_CUST,       "DEC Customer use"              },
-    {ETHERTYPE_DEC_SCA,                "DEC LAVC/SCA"                  },
-    {ETHERTYPE_DEC_LAST,       "DEC LAST"                      },
-    {ETHERTYPE_ETHBRIDGE,      "Transparent Ethernet bridging" },
-    {ETHERTYPE_CGMP,           "Cisco Group Management Protocol" },
-    {ETHERTYPE_MAC_CONTROL,    "MAC Control"                   },
-    {ETHERTYPE_SLOW_PROTOCOLS, "Slow Protocols"                },
-    {ETHERTYPE_RTMAC,          "Real-Time Media Access Control" },
-    {ETHERTYPE_RTCFG,          "Real-Time Configuration Protocol" },
-    {ETHERTYPE_CDMA2000_A10_UBS,"CDMA2000 A10 Unstructured byte stream" },
-    {ETHERTYPE_PROFINET,       "PROFInet"                      },
-    {ETHERTYPE_AOE,            "ATA over Ethernet"             },
+    {ETHERTYPE_HOMEPLUG,                       "Homeplug"                      },
+    {ETHERTYPE_VLAN,                           "802.1Q Virtual LAN"            },
+    {ETHERTYPE_IEEE_802_1AD,                   "802.1ad Provider Bridge (Q-in-Q)"},
+    {ETHERTYPE_IEEE_802_1AH,                   "802.1ah Provider Backbone Bridge (mac-in-mac)"},
+    {ETHERTYPE_EAPOL,                          "802.1X Authentication"         },
+    {ETHERTYPE_RSN_PREAUTH,                    "802.11i Pre-Authentication"    },
+    {ETHERTYPE_MPLS,                           "MPLS label switched packet"    },
+    {ETHERTYPE_MPLS_MULTI,                     "MPLS multicast label switched packet" },
+    {ETHERTYPE_3C_NBP_DGRAM,           "3Com NBP Datagram"             },
+    {ETHERTYPE_DEC,                                    "DEC proto"                     },
+    {ETHERTYPE_DNA_DL,                         "DEC DNA Dump/Load"             },
+    {ETHERTYPE_DNA_RC,                         "DEC DNA Remote Console"        },
+    {ETHERTYPE_DNA_RT,                         "DEC DNA Routing"               },
+    {ETHERTYPE_LAT,                                    "DEC LAT"                       },
+    {ETHERTYPE_DEC_DIAG,                       "DEC Diagnostics"               },
+    {ETHERTYPE_DEC_CUST,                       "DEC Customer use"              },
+    {ETHERTYPE_DEC_SCA,                                "DEC LAVC/SCA"                  },
+    {ETHERTYPE_DEC_LAST,                       "DEC LAST"                      },
+    {ETHERTYPE_ETHBRIDGE,                      "Transparent Ethernet bridging" },
+    {ETHERTYPE_CGMP,                           "Cisco Group Management Protocol" },
+    {ETHERTYPE_MAC_CONTROL,                    "MAC Control"                   },
+    {ETHERTYPE_SLOW_PROTOCOLS,         "Slow Protocols"                },
+    {ETHERTYPE_RTMAC,                          "Real-Time Media Access Control" },
+    {ETHERTYPE_RTCFG,                          "Real-Time Configuration Protocol" },
+    {ETHERTYPE_CDMA2000_A10_UBS,       "CDMA2000 A10 Unstructured byte stream" },
+    {ETHERTYPE_PROFINET,                       "PROFINET"                      },
+    {ETHERTYPE_AOE,                                    "ATA over Ethernet"             },
+    {ETHERTYPE_TELKONET,                       "Telkonet powerline"    },
+    {ETHERTYPE_EPL_V2,                         "ETHERNET Powerlink v2"                 },
+    {ETHERTYPE_CSM_ENCAPS,                     "CSM_ENCAPS Protocol"             },
+    {ETHERTYPE_IEEE802_OUI_EXTENDED, "IEEE 802a OUI Extended Ethertype" },
+    {ETHERTYPE_IEC61850_GOOSE,         "IEC 61850/GOOSE" },
+    {ETHERTYPE_IEC61850_GSE,           "IEC 61850/GSE management services" },
+    {ETHERTYPE_IEC61850_SV,                    "IEC 61850/SV (Sampled Value Transmission" },
+    {ETHERTYPE_TIPC,                           "Transparent Inter Process Communication" },
+    {ETHERTYPE_LLDP,                           "802.1 Link Layer Discovery Protocol (LLDP)" },
+    {ETHERTYPE_3GPP2,                          "CDMA2000 A10 3GPP2 Packet" },
+    {ETHERTYPE_LLTD,                           "Link Layer Topology Discovery (LLTD)" },
+    {ETHERTYPE_COBRANET,                       "Cirrus Cobranet Packet" },
+    {ETHERTYPE_NSRP,                           "Juniper Netscreen Redundant Protocol" },
     /*
      * NDISWAN on Windows translates Ethernet frames from higher-level
      * protocols into PPP frames to hand to the PPP driver, and translates
@@ -111,6 +134,10 @@ const value_string etype_vals[] = {
     {PPP_LCP,                  "PPP Link Control Protocol" },
     {PPP_PAP,                  "PPP Password Authentication Protocol" },
     {PPP_CCP,                  "PPP Compression Control Protocol" },
+    {ETHERTYPE_LLT,            "Veritas Low Latency Transport (not officially registered)"},
+    {ETHERTYPE_CFM,            "IEEE 802.1ag Connectivity Fault Management (CFM) protocol" },
+    {ETHERTYPE_FCOE,   "Fibre Channel over Ethernet" },
+       {ETHERTYPE_PTP,         "PTPv2 over Ethernet (IEEE1588)"},
     {0,                                NULL                            } };
 
 static void add_dix_trailer(proto_tree *fh_tree, int trailer_id, tvbuff_t *tvb,
@@ -137,6 +164,10 @@ capture_ethertype(guint16 etype, const guchar *pd, int offset, int len,
     case ETHERTYPE_VLAN:
       capture_vlan(pd, offset, len, ld);
       break;
+    case ETHERTYPE_IEEE_802_1AD:
+    case ETHERTYPE_IEEE_802_1AH:
+      capture_ieee8021ah(pd, offset, len, ld);
+      break;
     case ETHERTYPE_VINES_IP:
     case ETHERTYPE_VINES_ECHO:
       capture_vines(ld);
@@ -152,10 +183,10 @@ ethertype(guint16 etype, tvbuff_t *tvb, int offset_after_etype,
                packet_info *pinfo, proto_tree *tree, proto_tree *fh_tree,
                int etype_id, int trailer_id, int fcs_len)
 {
-       char                    *description;
+       const char              *description;
        tvbuff_t                *next_tvb;
        guint                   length_before;
-       volatile gboolean       dissector_found;
+       volatile gboolean       dissector_found = FALSE;
        const char              *saved_proto;
 
        /* Add the Ethernet type to the protocol tree */
@@ -199,6 +230,9 @@ ethertype(guint16 etype, tvbuff_t *tvb, int offset_after_etype,
                   else. */
                 RETHROW;
        }
+       CATCH(OutOfMemoryError) {
+                RETHROW;
+       }
        CATCH_ALL {
                /* Somebody threw an exception other than BoundsError, which
                   means that a dissector was found, so we don't need to
@@ -207,7 +241,7 @@ ethertype(guint16 etype, tvbuff_t *tvb, int offset_after_etype,
                   to show the trailer, after noting that a dissector was
                   found and restoring the protocol value that was in effect
                   before we called the subdissector. */
-               show_exception(next_tvb, pinfo, tree, EXCEPT_CODE);
+               show_exception(next_tvb, pinfo, tree, EXCEPT_CODE, GET_MESSAGE);
                dissector_found = TRUE;
                pinfo->current_proto = saved_proto;
        }