small fixes to ethtype pattern

Change-Id: Ic58c426821952f66aa21bc828d36fd4f83d8da0d
diff --git a/apps/aaa/src/main/java/org/onosproject/aaa/packet/EAPEthernet.java b/apps/aaa/src/main/java/org/onosproject/aaa/packet/EAPEthernet.java
index be2dae4..f975c15 100644
--- a/apps/aaa/src/main/java/org/onosproject/aaa/packet/EAPEthernet.java
+++ b/apps/aaa/src/main/java/org/onosproject/aaa/packet/EAPEthernet.java
@@ -16,11 +16,13 @@
 
 package org.onosproject.aaa.packet;
 
-import org.onlab.packet.ARP;
+import org.onlab.packet.Deserializer;
+import org.onlab.packet.EthType;
 import org.onlab.packet.Ethernet;
-import org.onlab.packet.IPv4;
-import org.onlab.packet.IPv6;
-import org.onlab.packet.LLDP;
+import org.onlab.packet.IPacket;
+
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * Created by jono on 5/19/15.
@@ -29,17 +31,21 @@
 
     public static final short TYPE_PAE = (short) 0x888e;
 
+    private static final Map<Short, Deserializer<? extends IPacket>> ETHERTYPE_DESERIALIZER_MAP =
+            new HashMap<>();
+
     private EAPEthernet() {
 
     }
 
     static {
-        Ethernet.ETHER_TYPE_CLASS_MAP.put(org.onlab.packet.Ethernet.TYPE_ARP, ARP.class);
-        org.onlab.packet.Ethernet.ETHER_TYPE_CLASS_MAP.put(org.onlab.packet.Ethernet.TYPE_RARP, ARP.class);
-        org.onlab.packet.Ethernet.ETHER_TYPE_CLASS_MAP.put(org.onlab.packet.Ethernet.TYPE_IPV4, IPv4.class);
-        org.onlab.packet.Ethernet.ETHER_TYPE_CLASS_MAP.put(org.onlab.packet.Ethernet.TYPE_IPV6, IPv6.class);
-        org.onlab.packet.Ethernet.ETHER_TYPE_CLASS_MAP.put(org.onlab.packet.Ethernet.TYPE_LLDP, LLDP.class);
-        org.onlab.packet.Ethernet.ETHER_TYPE_CLASS_MAP.put(org.onlab.packet.Ethernet.TYPE_BSN, LLDP.class);
-        org.onlab.packet.Ethernet.ETHER_TYPE_CLASS_MAP.put(TYPE_PAE, EAPOL.class);
+        for (EthType.EtherType ethType : EthType.EtherType.values()) {
+            if (ethType.deserializer() != null) {
+                ETHERTYPE_DESERIALIZER_MAP.put(ethType.ethType().toShort(),
+                                               ethType.deserializer());
+            }
+        }
+        ETHERTYPE_DESERIALIZER_MAP.put((short) 0x888e, EAPOL.deserializer());
     }
+
 }
diff --git a/apps/aaa/src/main/java/org/onosproject/aaa/packet/EAPOL.java b/apps/aaa/src/main/java/org/onosproject/aaa/packet/EAPOL.java
index 3179e28..ac11dcc 100644
--- a/apps/aaa/src/main/java/org/onosproject/aaa/packet/EAPOL.java
+++ b/apps/aaa/src/main/java/org/onosproject/aaa/packet/EAPOL.java
@@ -19,12 +19,15 @@
 package org.onosproject.aaa.packet;
 
 import org.onlab.packet.BasePacket;
+import org.onlab.packet.Deserializer;
 import org.onlab.packet.Ethernet;
 import org.onlab.packet.IPacket;
 import org.onlab.packet.MacAddress;
 
 import java.nio.ByteBuffer;
 
+import static org.onlab.packet.PacketUtils.checkInput;
+
 /**
  *
  */
@@ -133,29 +136,8 @@
         return data;
     }
 
-    @Override
-    public IPacket deserialize(final byte[] data, final int offset,
-                               final int length) {
-        final ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
 
 
-        //deserialize the EAPOL header
-        this.version = bb.get();
-        this.eapolType = bb.get();
-        this.packetLength = bb.getShort();
-
-        if (this.packetLength > 0) {
-            //deserialize the EAP Payload
-            this.payload = new EAP();
-
-            this.payload = this.payload.deserialize(data, bb.position(), length - 4);
-            this.payload.setParent(this);
-        }
-
-
-        return this;
-    }
-
     @Override
     public int hashCode() {
         final int prime = 3889;
@@ -196,5 +178,51 @@
         eth.setPad(true);
         return eth;
     }
+
+    public static Deserializer<EAPOL> deserializer() {
+        return (data, offset, length) -> {
+            checkInput(data, offset, length, 0);
+
+            EAPOL eapol = new EAPOL();
+            final ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
+            eapol.setVersion(bb.get());
+            eapol.setEapolType(bb.get());
+            eapol.setPacketLength(bb.getShort());
+
+            if (eapol.packetLength > 0) {
+                //deserialize the EAP Payload
+                eapol.payload = new EAP();
+
+                eapol.payload = eapol.payload.deserialize(data, bb.position(), length - 4);
+                eapol.payload.setParent(eapol);
+            }
+            return eapol;
+        };
+    }
+
+    @Override
+    public IPacket deserialize(final byte[] data, final int offset,
+                               final int length) {
+        final ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
+
+
+        //deserialize the EAPOL header
+        this.version = bb.get();
+        this.eapolType = bb.get();
+        this.packetLength = bb.getShort();
+
+        if (this.packetLength > 0) {
+            //deserialize the EAP Payload
+            this.payload = new EAP();
+
+            this.payload = this.payload.deserialize(data, bb.position(), length - 4);
+            this.payload.setParent(this);
+        }
+
+
+        return this;
+    }
+
+
 }
 
diff --git a/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java b/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java
index fead3bd..e8a131b 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java
@@ -19,6 +19,7 @@
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Lists;
 import org.apache.commons.collections.ListUtils;
+import org.onlab.packet.EthType;
 import org.onlab.packet.IpAddress;
 import org.onlab.packet.MacAddress;
 import org.onlab.packet.MplsLabel;
@@ -309,6 +310,11 @@
 
         @Override
         public Builder popMpls(int etherType) {
+            return add(Instructions.popMpls(new EthType(etherType)));
+        }
+
+        @Override
+        public Builder popMpls(EthType etherType) {
             return add(Instructions.popMpls(etherType));
         }
 
diff --git a/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java b/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java
index a82919f..ba82e92 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java
@@ -15,6 +15,7 @@
  */
 package org.onosproject.net.flow;
 
+import org.onlab.packet.EthType;
 import org.onlab.packet.IpAddress;
 import org.onlab.packet.MacAddress;
 import org.onlab.packet.MplsLabel;
@@ -197,9 +198,18 @@
          * @param etherType an ether type
          * @return a treatment builder.
          */
+        @Deprecated
         Builder popMpls(int etherType);
 
         /**
+         * Pops MPLS ether type and set the new ethertype.
+         *
+         * @param etherType an ether type
+         * @return a treatment builder.
+         */
+        Builder popMpls(EthType etherType);
+
+        /**
          * Sets the mpls label.
          *
          * @param mplsLabel MPLS label.
diff --git a/core/api/src/main/java/org/onosproject/net/flow/criteria/EthTypeCriterion.java b/core/api/src/main/java/org/onosproject/net/flow/criteria/EthTypeCriterion.java
index 465de6b..b2666d4 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/criteria/EthTypeCriterion.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/criteria/EthTypeCriterion.java
@@ -25,8 +25,9 @@
  * Implementation of Ethernet type criterion (16 bits unsigned integer).
  */
 public final class EthTypeCriterion implements Criterion {
-    private static final int MASK = 0xffff;
-    private final EthType ethType;              // Ethernet type value: 16 bits
+
+
+    private final EthType ethType;
 
     /**
      * Constructor.
@@ -35,7 +36,7 @@
      * integer)
      */
     EthTypeCriterion(int ethType) {
-        this.ethType = new EthType(ethType & MASK);
+        this.ethType = new EthType(ethType);
     }
 
     /**
diff --git a/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java b/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java
index 500ac1c..9703e1c 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java
@@ -15,7 +15,7 @@
  */
 package org.onosproject.net.flow.instructions;
 
-import org.onlab.packet.Ethernet;
+import org.onlab.packet.EthType;
 import org.onlab.packet.IpAddress;
 import org.onlab.packet.MacAddress;
 import org.onlab.packet.MplsLabel;
@@ -265,7 +265,7 @@
     public static Instruction pushMpls() {
         return new L2ModificationInstruction.PushHeaderInstructions(
                 L2ModificationInstruction.L2SubType.MPLS_PUSH,
-                                          Ethernet.MPLS_UNICAST);
+                                          EthType.EtherType.MPLS_UNICAST.ethType());
     }
 
     /**
@@ -276,7 +276,7 @@
     public static Instruction popMpls() {
         return new L2ModificationInstruction.PushHeaderInstructions(
                 L2ModificationInstruction.L2SubType.MPLS_POP,
-                                          Ethernet.MPLS_UNICAST);
+                EthType.EtherType.MPLS_UNICAST.ethType());
     }
 
     /**
@@ -285,9 +285,23 @@
      * @param etherType Ethernet type to set
      * @return a L2 modification.
      */
+    @Deprecated
     public static Instruction popMpls(int etherType) {
         checkNotNull(etherType, "Ethernet type cannot be null");
         return new L2ModificationInstruction.PushHeaderInstructions(
+                L2ModificationInstruction.L2SubType.MPLS_POP, new EthType(etherType));
+    }
+
+
+    /**
+     * Creates a pop MPLS header instruction with a particular ethertype.
+     *
+     * @param etherType Ethernet type to set
+     * @return a L2 modification.
+     */
+    public static Instruction popMpls(EthType etherType) {
+        checkNotNull(etherType, "Ethernet type cannot be null");
+        return new L2ModificationInstruction.PushHeaderInstructions(
                 L2ModificationInstruction.L2SubType.MPLS_POP, etherType);
     }
 
@@ -308,7 +322,8 @@
      */
     public static Instruction pushVlan() {
         return new L2ModificationInstruction.PushHeaderInstructions(
-                L2ModificationInstruction.L2SubType.VLAN_PUSH, Ethernet.TYPE_VLAN);
+                L2ModificationInstruction.L2SubType.VLAN_PUSH,
+                EthType.EtherType.VLAN.ethType());
     }
 
     /**
diff --git a/core/api/src/main/java/org/onosproject/net/flow/instructions/L2ModificationInstruction.java b/core/api/src/main/java/org/onosproject/net/flow/instructions/L2ModificationInstruction.java
index b993848..2fd809f 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/instructions/L2ModificationInstruction.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/instructions/L2ModificationInstruction.java
@@ -15,6 +15,7 @@
  */
 package org.onosproject.net.flow.instructions;
 
+import org.onlab.packet.EthType;
 import org.onlab.packet.MacAddress;
 import org.onlab.packet.MplsLabel;
 import org.onlab.packet.VlanId;
@@ -145,16 +146,16 @@
     public static final class PushHeaderInstructions extends
             L2ModificationInstruction {
 
-        private static final int MASK = 0xffff;
-        private final L2SubType subtype;
-        private final int ethernetType; // Ethernet type value: 16 bits
 
-        PushHeaderInstructions(L2SubType subType, int ethernetType) {
+        private final L2SubType subtype;
+        private final EthType ethernetType; // Ethernet type value: 16 bits
+
+        PushHeaderInstructions(L2SubType subType, EthType ethernetType) {
             this.subtype = subType;
-            this.ethernetType = ethernetType & MASK;
+            this.ethernetType = ethernetType;
         }
 
-        public int ethernetType() {
+        public EthType ethernetType() {
             return ethernetType;
         }
 
@@ -166,7 +167,7 @@
         @Override
         public String toString() {
             return toStringHelper(subtype().toString())
-                    .add("ethernetType", String.format("0x%04x", ethernetType()))
+                    .add("ethernetType", ethernetType())
                     .toString();
         }
 
diff --git a/core/common/src/main/java/org/onosproject/codec/impl/EncodeInstructionCodec.java b/core/common/src/main/java/org/onosproject/codec/impl/EncodeInstructionCodec.java
index 7fb56fd..20de446 100644
--- a/core/common/src/main/java/org/onosproject/codec/impl/EncodeInstructionCodec.java
+++ b/core/common/src/main/java/org/onosproject/codec/impl/EncodeInstructionCodec.java
@@ -119,7 +119,8 @@
                 final L2ModificationInstruction.PushHeaderInstructions pushHeaderInstructions =
                         (L2ModificationInstruction.PushHeaderInstructions) instruction;
 
-                result.put(InstructionCodec.ETHERNET_TYPE, pushHeaderInstructions.ethernetType());
+                result.put(InstructionCodec.ETHERNET_TYPE,
+                           pushHeaderInstructions.ethernetType().toShort());
                 break;
 
             default:
diff --git a/core/common/src/test/java/org/onosproject/codec/impl/FlowRuleCodecTest.java b/core/common/src/test/java/org/onosproject/codec/impl/FlowRuleCodecTest.java
index 2a93b55..9c778fb 100644
--- a/core/common/src/test/java/org/onosproject/codec/impl/FlowRuleCodecTest.java
+++ b/core/common/src/test/java/org/onosproject/codec/impl/FlowRuleCodecTest.java
@@ -247,15 +247,15 @@
         instruction = getInstruction(Instruction.Type.L2MODIFICATION,
                 L2ModificationInstruction.L2SubType.MPLS_PUSH.name());
         assertThat(instruction.type(), is(Instruction.Type.L2MODIFICATION));
-        assertThat((short) ((L2ModificationInstruction.PushHeaderInstructions) instruction)
-                        .ethernetType(),
+        assertThat(((L2ModificationInstruction.PushHeaderInstructions) instruction)
+                        .ethernetType().toShort(),
                 is(Ethernet.MPLS_UNICAST));
 
         instruction = getInstruction(Instruction.Type.L2MODIFICATION,
                 L2ModificationInstruction.L2SubType.MPLS_POP.name());
         assertThat(instruction.type(), is(Instruction.Type.L2MODIFICATION));
-        assertThat((short) ((L2ModificationInstruction.PushHeaderInstructions) instruction)
-                        .ethernetType(),
+        assertThat(((L2ModificationInstruction.PushHeaderInstructions) instruction)
+                        .ethernetType().toShort(),
                 is(Ethernet.MPLS_UNICAST));
 
         instruction = getInstruction(Instruction.Type.L2MODIFICATION,
diff --git a/core/common/src/test/java/org/onosproject/codec/impl/InstructionJsonMatcher.java b/core/common/src/test/java/org/onosproject/codec/impl/InstructionJsonMatcher.java
index 7281ed5..dbb3bd0 100644
--- a/core/common/src/test/java/org/onosproject/codec/impl/InstructionJsonMatcher.java
+++ b/core/common/src/test/java/org/onosproject/codec/impl/InstructionJsonMatcher.java
@@ -66,7 +66,7 @@
             return false;
         }
 
-        if (instructionToMatch.ethernetType() != ethJson.asInt()) {
+        if (instructionToMatch.ethernetType().toShort() != ethJson.asInt()) {
             description.appendText("ethernetType was " + ethJson);
             return false;
         }
diff --git a/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer13.java b/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer13.java
index 4103b02..63fc63a 100644
--- a/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer13.java
+++ b/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer13.java
@@ -316,12 +316,12 @@
                 PushHeaderInstructions pushHeaderInstructions =
                         (PushHeaderInstructions) l2m;
                 return factory().actions().pushMpls(EthType.of(pushHeaderInstructions
-                                                               .ethernetType()));
+                                                               .ethernetType().toShort()));
             case MPLS_POP:
                 PushHeaderInstructions popHeaderInstructions =
                         (PushHeaderInstructions) l2m;
                 return factory().actions().popMpls(EthType.of(popHeaderInstructions
-                                                              .ethernetType()));
+                                                              .ethernetType().toShort()));
             case MPLS_LABEL:
                 ModMplsLabelInstruction mplsLabel =
                         (ModMplsLabelInstruction) l2m;
@@ -335,7 +335,7 @@
             case VLAN_PUSH:
                 PushHeaderInstructions pushVlanInstruction = (PushHeaderInstructions) l2m;
                 return factory().actions().pushVlan(
-                        EthType.of(pushVlanInstruction.ethernetType()));
+                        EthType.of(pushVlanInstruction.ethernetType().toShort()));
             default:
                 log.warn("Unimplemented action type {}.", l2m.subtype());
                 break;
diff --git a/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/GroupModBuilder.java b/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/GroupModBuilder.java
index 40be643..436fa6e 100644
--- a/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/GroupModBuilder.java
+++ b/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/GroupModBuilder.java
@@ -269,17 +269,17 @@
                 L2ModificationInstruction.PushHeaderInstructions pushVlanInstruction
                         = (L2ModificationInstruction.PushHeaderInstructions) l2m;
                 return factory.actions().pushVlan(
-                        EthType.of(pushVlanInstruction.ethernetType()));
+                        EthType.of(pushVlanInstruction.ethernetType().toShort()));
             case MPLS_PUSH:
                 L2ModificationInstruction.PushHeaderInstructions pushHeaderInstructions =
                         (L2ModificationInstruction.PushHeaderInstructions) l2m;
                 return factory.actions().pushMpls(EthType.of(pushHeaderInstructions
-                                                             .ethernetType()));
+                                                             .ethernetType().toShort()));
             case MPLS_POP:
                 L2ModificationInstruction.PushHeaderInstructions popHeaderInstructions =
                         (L2ModificationInstruction.PushHeaderInstructions) l2m;
                 return factory.actions().popMpls(EthType.of(popHeaderInstructions
-                                                            .ethernetType()));
+                                                            .ethernetType().toShort()));
             case MPLS_LABEL:
                 L2ModificationInstruction.ModMplsLabelInstruction mplsLabel =
                         (L2ModificationInstruction.ModMplsLabelInstruction) l2m;
diff --git a/utils/misc/src/main/java/org/onlab/packet/EthType.java b/utils/misc/src/main/java/org/onlab/packet/EthType.java
index 7573ae8..90439eb 100644
--- a/utils/misc/src/main/java/org/onlab/packet/EthType.java
+++ b/utils/misc/src/main/java/org/onlab/packet/EthType.java
@@ -15,52 +15,106 @@
  */
 package org.onlab.packet;
 
-import com.google.common.collect.Maps;
-
-import java.util.Map;
-
 /**
  * Representation of an Ethertype.
  */
 public class EthType {
 
-    public static final short ARP = EtherType.ARP.ethType.toShort();
-    public static final short RARP = EtherType.RARP.ethType.toShort();
-    public static final short VLAN = EtherType.VLAN.ethType.toShort();
-    public static final short IPV4 = EtherType.IPV4.ethType.toShort();
-    public static final short IPV6 = EtherType.IPV6.ethType.toShort();
-    public static final short LLDP = EtherType.LLDP.ethType.toShort();
-    public static final short BDDP = EtherType.BDDP.ethType.toShort();
-    public static final short MPLS_MULTICAST = EtherType.MPLS_UNICAST.ethType.toShort();
-    public static final short MPLS_UNICAST = EtherType.MPLS_UNICAST.ethType.toShort();
-
-    private short etherType;
-
-    /*
-     * Reverse-lookup map for getting a EtherType enum
+    /**
+     * A list of known ethertypes. Adding a fully defined enum here will
+     * associated the ethertype with a textual representation and a parsing
+     * class.
      */
-    private static final Map<Short, EtherType> LOOKUP = Maps.newHashMap();
+    public enum EtherType {
 
-    static {
-        for (EtherType eth : EtherType.values()) {
-            LOOKUP.put(eth.ethType().toShort(), eth);
+        ARP(0x806, "arp", org.onlab.packet.ARP.deserializer()),
+        RARP(0x8035, "rarp", org.onlab.packet.ARP.deserializer()),
+        IPV4(0x800, "ipv4", org.onlab.packet.IPv4.deserializer()),
+        IPV6(0x86dd, "ipv6", org.onlab.packet.IPv6.deserializer()),
+        LLDP(0x88cc, "lldp", org.onlab.packet.LLDP.deserializer()),
+        VLAN(0x8100, "vlan", null),
+        BDDP(0x8942, "bddp", org.onlab.packet.LLDP.deserializer()),
+        MPLS_UNICAST(0x8847, "mpls_unicast", org.onlab.packet.MPLS.deserializer()),
+        MPLS_MULTICAST(0x8848, "mpls_unicast", org.onlab.packet.MPLS.deserializer());
+
+
+
+        private final EthType etherType;
+        private final String type;
+        private final Deserializer<?> deserializer;
+
+        /**
+         * Constucts a new ethertype.
+         *
+         * @param ethType The actual ethertype
+         * @param type it's textual representation
+         * @param deserializer a parser for this ethertype
+         */
+        EtherType(int ethType, String type, Deserializer<?> deserializer) {
+            this.etherType = new EthType(ethType);
+            this.type = type;
+            this.deserializer = deserializer;
         }
+
+        public EthType ethType() {
+            return etherType;
+        }
+
+        @Override
+        public String toString() {
+            return type;
+        }
+
+        public Deserializer<?> deserializer() {
+            return deserializer;
+        }
+
     }
 
+
+    private final short etherType;
+
+    /**
+     * Builds the EthType.
+     *
+     * @param etherType an integer representing an ethtype
+     */
     public EthType(int etherType) {
         this.etherType = (short) (etherType & 0xFFFF);
     }
 
+    /**
+     * Builds the EthType.
+     *
+     * @param etherType a short representing the ethtype
+     */
     public EthType(short etherType) {
         this.etherType = etherType;
     }
 
+    /**
+     * Returns the short value for this ethtype.
+     *
+     * @return a short value
+     */
     public short toShort() {
         return etherType;
     }
 
-    public static EtherType lookup(short etherType) {
-        return LOOKUP.get(etherType);
+    /**
+     * Looks up the ethertype by it's numerical representation
+     * and returns it's textual format.
+     *
+     * @param etherType the short value of the ethertype
+     * @return a textual representation
+     */
+    public EtherType lookup(short etherType) {
+        for (EtherType ethType : EtherType.values()) {
+            if (ethType.ethType().toShort() == etherType) {
+                return ethType;
+            }
+        }
+        return null;
     }
 
     @Override
@@ -88,49 +142,8 @@
 
     public String toString() {
         EtherType ethType = lookup(this.etherType);
-        return (ethType == null ? "unknown" : ethType.toString());
+        return (ethType == null ? String.format("0x%04x", etherType) :
+                ethType.toString());
     }
 
-    public static enum EtherType {
-
-        ARP(0x806, "arp", ARP.class, org.onlab.packet.ARP.deserializer()),
-        RARP(0x8035, "rarp", null, org.onlab.packet.ARP.deserializer()),
-        IPV4(0x800, "ipv4", IPv4.class, org.onlab.packet.IPv4.deserializer()),
-        IPV6(0x86dd, "ipv6", IPv6.class, org.onlab.packet.IPv6.deserializer()),
-        LLDP(0x88cc, "lldp", LLDP.class, org.onlab.packet.LLDP.deserializer()),
-        VLAN(0x8100, "vlan", null, null),
-        BDDP(0x8942, "bddp", LLDP.class, org.onlab.packet.LLDP.deserializer()),
-        MPLS_UNICAST(0x8847, "mpls_unicast", null, org.onlab.packet.MPLS.deserializer()),
-        MPLS_MULTICAST(0x8848, "mpls_unicast", null, org.onlab.packet.MPLS.deserializer());
-
-
-        private final Class clazz;
-        private EthType ethType;
-        private String type;
-        private Deserializer<?> deserializer;
-
-        EtherType(int ethType, String type, Class clazz, Deserializer deserializer) {
-            this.ethType = new EthType(ethType);
-            this.type = type;
-            this.clazz = clazz;
-            this.deserializer = deserializer;
-        }
-
-        public EthType ethType() {
-            return ethType;
-        }
-
-        @Override
-        public String toString() {
-            return type;
-        }
-
-        public Class clazz() {
-            return clazz;
-        }
-
-        public Deserializer<?> deserializer() {
-            return deserializer;
-        }
-    }
 }
diff --git a/utils/misc/src/main/java/org/onlab/packet/Ethernet.java b/utils/misc/src/main/java/org/onlab/packet/Ethernet.java
index 700bdfc..003c177 100644
--- a/utils/misc/src/main/java/org/onlab/packet/Ethernet.java
+++ b/utils/misc/src/main/java/org/onlab/packet/Ethernet.java
@@ -32,16 +32,17 @@
  */
 public class Ethernet extends BasePacket {
     private static final String HEXES = "0123456789ABCDEF";
-    public static final short TYPE_ARP = EthType.ARP;
-    public static final short TYPE_RARP = EthType.RARP;
-    public static final short TYPE_IPV4 = EthType.IPV4;
-    public static final short TYPE_IPV6 = EthType.IPV6;
-    public static final short TYPE_LLDP = EthType.LLDP;
-    public static final short TYPE_VLAN = EthType.VLAN;
-    public static final short TYPE_BSN = EthType.BDDP;
 
-    public static final short MPLS_UNICAST = EthType.MPLS_UNICAST;
-    public static final short MPLS_MULTICAST = EthType.MPLS_MULTICAST;
+    public static final short TYPE_ARP = EthType.EtherType.ARP.ethType().toShort();
+    public static final short TYPE_RARP = EthType.EtherType.RARP.ethType().toShort();
+    public static final short TYPE_IPV4 = EthType.EtherType.IPV4.ethType().toShort();
+    public static final short TYPE_IPV6 = EthType.EtherType.IPV6.ethType().toShort();
+    public static final short TYPE_LLDP = EthType.EtherType.LLDP.ethType().toShort();
+    public static final short TYPE_VLAN = EthType.EtherType.VLAN.ethType().toShort();
+    public static final short TYPE_BSN = EthType.EtherType.BDDP.ethType().toShort();
+
+    public static final short MPLS_UNICAST = EthType.EtherType.MPLS_UNICAST.ethType().toShort();;
+    public static final short MPLS_MULTICAST = EthType.EtherType.MPLS_MULTICAST.ethType().toShort();
 
 
     public static final short VLAN_UNTAGGED = (short) 0xffff;
@@ -56,7 +57,7 @@
 
     static {
        for (EthType.EtherType ethType : EthType.EtherType.values()) {
-           if (ethType.clazz() != null) {
+           if (ethType.deserializer() != null) {
                ETHERTYPE_DESERIALIZER_MAP.put(ethType.ethType().toShort(), ethType.deserializer());
            }
        }