Make use of NetUtils.getBroadcastMacAddr()
[controller.git] / opendaylight / sal / api / src / main / java / org / opendaylight / controller / sal / match / MatchType.java
index 85e505671ef177627c84bff640f2a7596d66b441..800f6d5972bc257c8aecf1ad14b0d650b3797641 100644 (file)
@@ -25,7 +25,7 @@ public enum MatchType {
     IN_PORT("inPort", 1 << 0, NodeConnector.class, 1, 0),
     DL_SRC("dlSrc", 1 << 1, Byte[].class, 0, 0xffffffffffffL),
     DL_DST("dlDst", 1 << 2, Byte[].class, 0, 0xffffffffffffL),
-    DL_VLAN("dlVlan", 1 << 3, Short.class, 1, 0xfff), // 2 bytes
+    DL_VLAN("dlVlan", 1 << 3, Short.class, 0, 0xfff), // 2 bytes
     DL_VLAN_PR("dlVlanPriority", 1 << 4, Byte.class, 0, 0x7), // 3 bits
     DL_OUTER_VLAN("dlOuterVlan", 1 << 5, Short.class, 1, 0xfff),
     DL_OUTER_VLAN_PR("dlOuterVlanPriority", 1 << 6, Short.class, 0, 0x7),
@@ -34,8 +34,11 @@ public enum MatchType {
     NW_PROTO("nwProto", 1 << 9, Byte.class, 0, 0xff), // 1 byte
     NW_SRC("nwSrc", 1 << 10, InetAddress.class, 0, 0),
     NW_DST("nwDst", 1 << 11, InetAddress.class, 0, 0),
-    TP_SRC("tpSrc", 1 << 12, Short.class, 1, 0xffff), // 2 bytes
-    TP_DST("tpDst", 1 << 13, Short.class, 1, 0xffff); // 2 bytes
+    TP_SRC("tpSrc", 1 << 12, Short.class, 0, 0xffff), // 2 bytes
+    TP_DST("tpDst", 1 << 13, Short.class, 0, 0xffff); // 2 bytes
+
+    // Used to indicate that no VLAN ID is set.
+    public static final short DL_VLAN_NONE = (short) 0;
 
     private String id;
     private int index;
@@ -232,7 +235,7 @@ public enum MatchType {
     public int hashCode(Object v, Object m) {
         final int prime = 31;
         int result = 1;
-        result = prime * result + this.hashCode();
+        result = prime * result + this.calculateConsistentHashCode();
 
         switch (this) {
         case DL_SRC:
@@ -313,4 +316,12 @@ public enum MatchType {
             return (this.equalValues(value1, value2) && this.equalMasks(mask1, mask2));
         }
     }
+
+    public int calculateConsistentHashCode() {
+        if (this.id != null) {
+            return this.id.hashCode();
+        } else {
+            return 0;
+        }
+    }
 }