adding EthType to secure handling ether types

this will also pretty print ethertypes in flow output

Change-Id: I9363070ad308f3c756735e29b3992c500e503636
diff --git a/drivers/src/main/java/org/onosproject/driver/pipeline/CentecV350Pipeline.java b/drivers/src/main/java/org/onosproject/driver/pipeline/CentecV350Pipeline.java
index a7be6a1..ae5b621 100644
--- a/drivers/src/main/java/org/onosproject/driver/pipeline/CentecV350Pipeline.java
+++ b/drivers/src/main/java/org/onosproject/driver/pipeline/CentecV350Pipeline.java
@@ -295,7 +295,7 @@
         TrafficSelector selector = fwd.selector();
         EthTypeCriterion ethType =
                 (EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE);
-        if (ethType == null || ethType.ethType() != Ethernet.TYPE_IPV4) {
+        if (ethType == null || ethType.ethType().toShort() != Ethernet.TYPE_IPV4) {
             fail(fwd, ObjectiveError.UNSUPPORTED);
             return Collections.emptySet();
         }
diff --git a/drivers/src/main/java/org/onosproject/driver/pipeline/OFDPA1Pipeline.java b/drivers/src/main/java/org/onosproject/driver/pipeline/OFDPA1Pipeline.java
index 2f5d548..54f8df5 100644
--- a/drivers/src/main/java/org/onosproject/driver/pipeline/OFDPA1Pipeline.java
+++ b/drivers/src/main/java/org/onosproject/driver/pipeline/OFDPA1Pipeline.java
@@ -510,7 +510,7 @@
             fail(fwd, ObjectiveError.UNKNOWN);
             return Collections.emptySet();
         }
-        if (ethType.ethType() == Ethernet.TYPE_ARP) {
+        if (ethType.ethType().toShort() == Ethernet.TYPE_ARP) {
             log.warn("Installing ARP rule to table 60");
 
             // currently need to punt from ACL table should use:
@@ -551,7 +551,7 @@
         EthTypeCriterion ethType =
                 (EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE);
         // XXX currently supporting only the L3 unicast table
-        if (ethType == null || ethType.ethType() != Ethernet.TYPE_IPV4) {
+        if (ethType == null || ethType.ethType().toShort() != Ethernet.TYPE_IPV4) {
             fail(fwd, ObjectiveError.UNSUPPORTED);
             return Collections.emptySet();
         }
diff --git a/drivers/src/main/java/org/onosproject/driver/pipeline/OVSCorsaPipeline.java b/drivers/src/main/java/org/onosproject/driver/pipeline/OVSCorsaPipeline.java
index ddcb4d9..5993d96 100644
--- a/drivers/src/main/java/org/onosproject/driver/pipeline/OVSCorsaPipeline.java
+++ b/drivers/src/main/java/org/onosproject/driver/pipeline/OVSCorsaPipeline.java
@@ -257,17 +257,17 @@
             fail(fwd, ObjectiveError.UNKNOWN);
             return Collections.emptySet();
         }
-        if (ethType.ethType() == Ethernet.TYPE_ARP) {
+        if (ethType.ethType().toShort() == Ethernet.TYPE_ARP) {
             log.warn("Driver automatically handles ARP packets by punting to controller "
                     + " from ETHER table");
             pass(fwd);
             return Collections.emptySet();
-        } else if (ethType.ethType() == Ethernet.TYPE_LLDP ||
-                ethType.ethType() == Ethernet.TYPE_BSN) {
+        } else if (ethType.ethType().toShort() == Ethernet.TYPE_LLDP ||
+                ethType.ethType().toShort() == Ethernet.TYPE_BSN) {
             log.warn("Driver currently does not currently handle LLDP packets");
             fail(fwd, ObjectiveError.UNSUPPORTED);
             return Collections.emptySet();
-        } else if (ethType.ethType() == Ethernet.TYPE_IPV4) {
+        } else if (ethType.ethType().toShort() == Ethernet.TYPE_IPV4) {
             IPCriterion ipSrc = (IPCriterion) selector
                     .getCriterion(Criterion.Type.IPV4_SRC);
             IPCriterion ipDst = (IPCriterion) selector
@@ -303,7 +303,7 @@
         TrafficSelector selector = fwd.selector();
         EthTypeCriterion ethType =
                 (EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE);
-        if (ethType == null || ethType.ethType() != Ethernet.TYPE_IPV4) {
+        if (ethType == null || ethType.ethType().toShort() != Ethernet.TYPE_IPV4) {
             fail(fwd, ObjectiveError.UNSUPPORTED);
             return Collections.emptySet();
         }
diff --git a/drivers/src/main/java/org/onosproject/driver/pipeline/PicaPipeline.java b/drivers/src/main/java/org/onosproject/driver/pipeline/PicaPipeline.java
index 21541b0..0c3d8a2 100644
--- a/drivers/src/main/java/org/onosproject/driver/pipeline/PicaPipeline.java
+++ b/drivers/src/main/java/org/onosproject/driver/pipeline/PicaPipeline.java
@@ -243,7 +243,7 @@
             return Collections.emptySet();
         }
 
-        if (ethType.ethType() == Ethernet.TYPE_ARP) {
+        if (ethType.ethType().toShort() == Ethernet.TYPE_ARP) {
             if (filters.isEmpty()) {
                 pendingVersatiles.add(fwd);
                 return Collections.emptySet();
@@ -253,12 +253,12 @@
                 flowrules.addAll(processVersatilesWithFilters(filter, fwd));
             }
             return flowrules;
-        } else if (ethType.ethType() == Ethernet.TYPE_LLDP ||
-                ethType.ethType() == Ethernet.TYPE_BSN) {
+        } else if (ethType.ethType().toShort() == Ethernet.TYPE_LLDP ||
+                ethType.ethType().toShort() == Ethernet.TYPE_BSN) {
             log.warn("Driver currently does not currently handle LLDP packets");
             fail(fwd, ObjectiveError.UNSUPPORTED);
             return Collections.emptySet();
-        } else if (ethType.ethType() == Ethernet.TYPE_IPV4) {
+        } else if (ethType.ethType().toShort() == Ethernet.TYPE_IPV4) {
             IPCriterion ipSrc = (IPCriterion) selector
                     .getCriterion(Criterion.Type.IPV4_SRC);
             IPCriterion ipDst = (IPCriterion) selector
@@ -339,7 +339,7 @@
         TrafficSelector selector = fwd.selector();
         EthTypeCriterion ethType =
                 (EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE);
-        if (ethType == null || ethType.ethType() != Ethernet.TYPE_IPV4) {
+        if (ethType == null || ethType.ethType().toShort() != Ethernet.TYPE_IPV4) {
             fail(fwd, ObjectiveError.UNSUPPORTED);
             return Collections.emptySet();
         }
diff --git a/drivers/src/main/java/org/onosproject/driver/pipeline/SoftRouterPipeline.java b/drivers/src/main/java/org/onosproject/driver/pipeline/SoftRouterPipeline.java
index 2240520..220be86 100644
--- a/drivers/src/main/java/org/onosproject/driver/pipeline/SoftRouterPipeline.java
+++ b/drivers/src/main/java/org/onosproject/driver/pipeline/SoftRouterPipeline.java
@@ -367,7 +367,7 @@
             return Collections.emptySet();
         }
 
-        if (ethType.ethType() == Ethernet.TYPE_ARP) {
+        if (ethType.ethType().toShort() == Ethernet.TYPE_ARP) {
             // need to install ARP request & reply flow rules for each interface filter
 
             // rule for ARP replies
@@ -425,7 +425,7 @@
         EthTypeCriterion ethType =
                 (EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE);
         // XXX currently supporting only the L3 unicast table
-        if (ethType == null || ethType.ethType() != Ethernet.TYPE_IPV4) {
+        if (ethType == null || ethType.ethType().toShort() != Ethernet.TYPE_IPV4) {
             fail(fwd, ObjectiveError.UNSUPPORTED);
             return Collections.emptySet();
         }
@@ -474,7 +474,7 @@
      * the dummy group is fetched from the distributed store and the enclosed
      * treatment is applied as a flow rule action.
      *
-     * @param nextObjective the next objective of type simple
+     * @param nextObj the next objective of type simple
      */
     private void processSimpleNextObjective(NextObjective nextObj) {
         // Simple next objective has a single treatment (not a collection)
diff --git a/drivers/src/main/java/org/onosproject/driver/pipeline/SpringOpenTTP.java b/drivers/src/main/java/org/onosproject/driver/pipeline/SpringOpenTTP.java
index d2948e9..c02ba3c 100644
--- a/drivers/src/main/java/org/onosproject/driver/pipeline/SpringOpenTTP.java
+++ b/drivers/src/main/java/org/onosproject/driver/pipeline/SpringOpenTTP.java
@@ -440,8 +440,8 @@
         EthTypeCriterion ethType = (EthTypeCriterion) selector
                 .getCriterion(Criterion.Type.ETH_TYPE);
         if ((ethType == null) ||
-                ((((short) ethType.ethType()) != Ethernet.TYPE_IPV4) &&
-                (((short) ethType.ethType()) != Ethernet.MPLS_UNICAST))) {
+                (ethType.ethType().toShort() != Ethernet.TYPE_IPV4) &&
+                (ethType.ethType().toShort() != Ethernet.MPLS_UNICAST)) {
             log.warn("processSpecific: Unsupported "
                     + "forwarding objective criteraia");
             fail(fwd, ObjectiveError.UNSUPPORTED);
@@ -451,7 +451,7 @@
         TrafficSelector.Builder filteredSelectorBuilder =
                 DefaultTrafficSelector.builder();
         int forTableId = -1;
-        if (((short) ethType.ethType()) == Ethernet.TYPE_IPV4) {
+        if (ethType.ethType().toShort() == Ethernet.TYPE_IPV4) {
             filteredSelectorBuilder = filteredSelectorBuilder
                 .matchEthType(Ethernet.TYPE_IPV4)
                 .matchIPDst(((IPCriterion) selector
diff --git a/drivers/src/main/java/org/onosproject/driver/pipeline/SpringOpenTTPDell.java b/drivers/src/main/java/org/onosproject/driver/pipeline/SpringOpenTTPDell.java
index f68a665..3267d550 100644
--- a/drivers/src/main/java/org/onosproject/driver/pipeline/SpringOpenTTPDell.java
+++ b/drivers/src/main/java/org/onosproject/driver/pipeline/SpringOpenTTPDell.java
@@ -81,8 +81,8 @@
         EthTypeCriterion ethType = (EthTypeCriterion) selector
                 .getCriterion(Criterion.Type.ETH_TYPE);
         if ((ethType == null) ||
-                ((((short) ethType.ethType()) != Ethernet.TYPE_IPV4) &&
-                (((short) ethType.ethType()) != Ethernet.MPLS_UNICAST))) {
+                (ethType.ethType().toShort() != Ethernet.TYPE_IPV4) &&
+                (ethType.ethType().toShort() != Ethernet.MPLS_UNICAST)) {
             log.debug("processSpecific: Unsupported "
                     + "forwarding objective criteraia");
             fail(fwd, ObjectiveError.UNSUPPORTED);
@@ -92,7 +92,7 @@
         TrafficSelector.Builder filteredSelectorBuilder =
                 DefaultTrafficSelector.builder();
         int forTableId = -1;
-        if (((short) ethType.ethType()) == Ethernet.TYPE_IPV4) {
+        if (ethType.ethType().toShort() == Ethernet.TYPE_IPV4) {
             if (deviceTMac == null) {
                 log.debug("processSpecific: ETH_DST filtering "
                         + "objective is not set which is required "