Removed enumeration ALL from FlowWildCardsV10 16/3816/1
authorMichal Polkorab <michal.polkorab@pantheon.sk>
Wed, 18 Dec 2013 13:09:39 +0000 (14:09 +0100)
committerMichal Polkorab <michal.polkorab@pantheon.sk>
Wed, 18 Dec 2013 13:10:23 +0000 (14:10 +0100)
Signed-off-by: Michal Polkorab <michal.polkorab@pantheon.sk>
openflow-protocol-api/src/main/yang/openflow-types.yang
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializer.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializer.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializerTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializerTest.java

index e00b8277bd9770d0eb4fcdb87151b49c5e9f01f8..6d7bf2fb4c94cf48a73a3c339afc4ff1677810cf 100644 (file)
@@ -1799,47 +1799,33 @@ module openflow-types {
         type bits {
             bit IN_PORT {
                 position 0;
-                /* Switch input port. */
             }
             bit DL_VLAN {
                 position 1;
-                /* Switch input port. */
             }
             bit DL_SRC {
                 position 2;
-                /* Switch input port. */
             }
             bit DL_DST {
                 position 3;
-                /* Switch input port. */
             }
             bit DL_TYPE {
                 position 4;
-                /* Switch input port. */
             }
             bit NW_PROTO {
                 position 5;
-                /* Switch input port. */
             }
             bit TP_SRC {
                 position 6;
-                /* Switch input port. */
             }
             bit TP_DST {
                 position 7;
-                /* Switch input port. */
             }
             bit DL_VLAN_PCP {
                 position 20;
-                /* Switch input port. */
             }
             bit NW_TOS {
                 position 21;
-                /* Switch input port. */
-            }
-            bit ALL {
-                position 22;
-                /* Switch input port. */
             }
         }
     }
index e601d95ad075f3a5fc681423151b617b4de27fca..4afd8295c1bb4abfb6f689f169546acdba117c08 100644 (file)
@@ -89,9 +89,7 @@ public abstract class OF10MatchDeserializer {
         boolean _tPDST = (input & (1 << 7)) != 0;
         boolean _dLVLANPCP = (input & (1 << 20)) != 0;
         boolean _nWTOS = (input & (1 << 21)) != 0;
-        int allBits = (1 << 22) - 1;
-        boolean _aLL = (input & allBits) == allBits;
-        return new FlowWildcardsV10(_aLL, _dLDST, _dLSRC, _dLTYPE, _dLVLAN,
+        return new FlowWildcardsV10(_dLDST, _dLSRC, _dLTYPE, _dLVLAN,
                 _dLVLANPCP, _iNPORT, _nWPROTO, _nWTOS, _tPDST, _tPSRC);
     }
     
index aac14a3fe4b8e4ef6bb2689bf4db2a8e9c16aa55..33f31971e89d7ae40c17adc47f9bd6cb8b3168c4 100644 (file)
@@ -26,7 +26,6 @@ public abstract class OF10MatchSerializer {
     private static final byte PADDING_IN_MATCH_2 = 2;
     private static final byte NW_SRC_SHIFT = 8;
     private static final byte NW_DST_SHIFT = 14;
-    private static final int ALL = ((1 << 22) - 1);
     
     /**
      * Encodes ofp_match (OpenFlow v1.0)
@@ -59,24 +58,20 @@ public abstract class OF10MatchSerializer {
     
     private static int encodeWildcards(FlowWildcardsV10 wildcards, short srcMask, short dstMask) {
         int bitmask = 0;
-        if (wildcards.isALL()) {
-            bitmask |= ALL;
-        } else {
-            Map<Integer, Boolean> wildcardsMap = new HashMap<>();
-            wildcardsMap.put(0, wildcards.isINPORT());
-            wildcardsMap.put(1, wildcards.isDLVLAN());
-            wildcardsMap.put(2, wildcards.isDLSRC());
-            wildcardsMap.put(3, wildcards.isDLDST());
-            wildcardsMap.put(4, wildcards.isDLTYPE());
-            wildcardsMap.put(5, wildcards.isNWPROTO());
-            wildcardsMap.put(6, wildcards.isTPSRC());
-            wildcardsMap.put(7, wildcards.isTPDST());
-            wildcardsMap.put(20, wildcards.isDLVLANPCP());
-            wildcardsMap.put(21, wildcards.isNWTOS());
-            bitmask = ByteBufUtils.fillBitMaskFromMap(wildcardsMap);
-            bitmask |= ((32 - srcMask) << NW_SRC_SHIFT);
-            bitmask |= ((32 - dstMask) << NW_DST_SHIFT);
-        }
+        Map<Integer, Boolean> wildcardsMap = new HashMap<>();
+        wildcardsMap.put(0, wildcards.isINPORT());
+        wildcardsMap.put(1, wildcards.isDLVLAN());
+        wildcardsMap.put(2, wildcards.isDLSRC());
+        wildcardsMap.put(3, wildcards.isDLDST());
+        wildcardsMap.put(4, wildcards.isDLTYPE());
+        wildcardsMap.put(5, wildcards.isNWPROTO());
+        wildcardsMap.put(6, wildcards.isTPSRC());
+        wildcardsMap.put(7, wildcards.isTPDST());
+        wildcardsMap.put(20, wildcards.isDLVLANPCP());
+        wildcardsMap.put(21, wildcards.isNWTOS());
+        bitmask = ByteBufUtils.fillBitMaskFromMap(wildcardsMap);
+        bitmask |= ((32 - srcMask) << NW_SRC_SHIFT);
+        bitmask |= ((32 - dstMask) << NW_DST_SHIFT);
         return bitmask;
     }
     
index fbb007575f283dbc78821880a9cde034b279fe86..697eedf3232994c644b1315b1546b331616648cd 100644 (file)
@@ -54,7 +54,7 @@ public class OF10FlowModInputMessageFactoryTest {
         FlowModInputBuilder builder = new FlowModInputBuilder();
         BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
         MatchV10Builder matchBuilder = new MatchV10Builder();
-        matchBuilder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true, true));
+        matchBuilder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true));
         matchBuilder.setNwSrcMask((short) 0);
         matchBuilder.setNwDstMask((short) 0);
         matchBuilder.setInPort(58);
@@ -103,7 +103,7 @@ public class OF10FlowModInputMessageFactoryTest {
         factory.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, message);
         
         BufferHelper.checkHeaderV10(out, factory.getMessageType(), factory.computeLength(message));
-        Assert.assertEquals("Wrong wildcards", 4194303, out.readUnsignedInt());
+        Assert.assertEquals("Wrong wildcards", 3678463, out.readUnsignedInt());
         Assert.assertEquals("Wrong inPort", 58, out.readUnsignedShort());
         byte[] dlSrc = new byte[6];
         out.readBytes(dlSrc);
index 30c2c3f9265040fb1f5f8dc8adf73e1003296fa6..61da809fe65e3e8b6705dfe071de7e31b67c223c 100644 (file)
@@ -33,7 +33,7 @@ public class OF10MatchDeserializerTest {
                 + "50 50 20 20");
         message.skipBytes(4); // skip XID
         MatchV10 match = OF10MatchDeserializer.createMatchV10(message);
-        Assert.assertEquals("Wrong wildcards", new FlowWildcardsV10(false, false, false, true, false,
+        Assert.assertEquals("Wrong wildcards", new FlowWildcardsV10(false, false, true, false,
                 false, true, false, true, true, false), match.getWildcards());
         Assert.assertEquals("Wrong srcMask", 24, match.getNwSrcMask().shortValue());
         Assert.assertEquals("Wrong dstMask", 16, match.getNwDstMask().shortValue());
@@ -61,7 +61,7 @@ public class OF10MatchDeserializerTest {
                 + "50 50 20 20");
         message.skipBytes(4); // skip XID
         MatchV10 match = OF10MatchDeserializer.createMatchV10(message);
-        Assert.assertEquals("Wrong wildcards", new FlowWildcardsV10(true, true, true, true, true,
+        Assert.assertEquals("Wrong wildcards", new FlowWildcardsV10(true, true, true, true,
                 true, true, true, true, true, true), match.getWildcards());
         Assert.assertEquals("Wrong srcMask", 0, match.getNwSrcMask().shortValue());
         Assert.assertEquals("Wrong dstMask", 0, match.getNwDstMask().shortValue());
index 240d64cad79b1988fc050b9db17481618e8edd96..19d745be585af48feb30fbf1b18a3e66590da45f 100644 (file)
@@ -32,7 +32,7 @@ public class OF10MatchSerializerTest {
     public void test() {
         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
         MatchV10Builder builder = new MatchV10Builder();
-        builder.setWildcards(new FlowWildcardsV10(false, false, false, true, false,
+        builder.setWildcards(new FlowWildcardsV10(false, false, true, false,
                 false, true, false, true, true, true));
         builder.setNwSrcMask((short) 24);
         builder.setNwDstMask((short) 16);
@@ -79,7 +79,7 @@ public class OF10MatchSerializerTest {
     public void test2() {
         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
         MatchV10Builder builder = new MatchV10Builder();
-        builder.setWildcards(new FlowWildcardsV10(true, true, true, true, true,
+        builder.setWildcards(new FlowWildcardsV10(true, true, true, true,
                 true, true, true, true, true, true));
         builder.setNwSrcMask((short) 0);
         builder.setNwDstMask((short) 0);
@@ -98,7 +98,7 @@ public class OF10MatchSerializerTest {
         MatchV10 match = builder.build();
         OF10MatchSerializer.encodeMatchV10(out, match);
         
-        Assert.assertEquals("Wrong wildcards", 4194303, out.readUnsignedInt());
+        Assert.assertEquals("Wrong wildcards", 3678463, out.readUnsignedInt());
         Assert.assertEquals("Wrong in-port", 6653, out.readUnsignedShort());
         byte[] dlSrc = new byte[6];
         out.readBytes(dlSrc);