BUG 2280 - mac address mask translation. 45/14545/2
authorJozef Gloncak <jgloncak@cisco.com>
Tue, 27 Jan 2015 16:32:38 +0000 (17:32 +0100)
committerJozef Gloncak <jgloncak@cisco.com>
Wed, 28 Jan 2015 10:09:17 +0000 (11:09 +0100)
Added ODL to SAL mac addres mask translation.

Change-Id: I6288e5dfa4b9fe77b98f39549e95b9e56e944ab1
Signed-off-by: Jozef Gloncak <jgloncak@cisco.com>
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertorImpl.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertorImplV13Test.java

index ef88ccfaf8fd4b990832365f678c70ddc8bbb538..dba2e92a3f420dc54e1cd79cf5da33610e6e13e7 100644 (file)
@@ -8,6 +8,8 @@
 
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match;
 
+import static org.opendaylight.openflowjava.util.ByteBufUtils.macAddressToString;
+
 import com.google.common.base.Optional;
 import com.google.common.base.Splitter;
 import java.math.BigInteger;
@@ -654,17 +656,25 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
                 }
             } else if (ofMatch.getOxmMatchField().equals(EthSrc.class)) {
                 MacAddressMatchEntry macAddressMatchEntry = ofMatch.getAugmentation(MacAddressMatchEntry.class);
+                final MaskMatchEntry sourceMask = ofMatch.getAugmentation(MaskMatchEntry.class);
                 if (macAddressMatchEntry != null) {
                     EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
                     ethSourceBuilder.setAddress(macAddressMatchEntry.getMacAddress());
+                    if (sourceMask != null) {
+                        ethSourceBuilder.setMask(new MacAddress(macAddressToString(sourceMask.getMask())));
+                    }
                     ethMatchBuilder.setEthernetSource(ethSourceBuilder.build());
                     matchBuilder.setEthernetMatch(ethMatchBuilder.build());
                 }
             } else if (ofMatch.getOxmMatchField().equals(EthDst.class)) {
                 MacAddressMatchEntry macAddressMatchEntry = ofMatch.getAugmentation(MacAddressMatchEntry.class);
+                final MaskMatchEntry destinationMask = ofMatch.getAugmentation(MaskMatchEntry.class);
                 if (macAddressMatchEntry != null) {
                     EthernetDestinationBuilder ethDestinationBuilder = new EthernetDestinationBuilder();
                     ethDestinationBuilder.setAddress(macAddressMatchEntry.getMacAddress());
+                    if (destinationMask != null) {
+                        ethDestinationBuilder.setMask(new MacAddress(macAddressToString(destinationMask.getMask())));
+                    }
                     ethMatchBuilder.setEthernetDestination(ethDestinationBuilder.build());
                     matchBuilder.setEthernetMatch(ethMatchBuilder.build());
                 }
index 98211f49b3b3c5ac9073dfdbbb1c261145839e97..99cb2ebd7f591968960b898fe1fb7c9027aceaf4 100644 (file)
@@ -448,7 +448,7 @@ public class MatchConvertorImplV13Test {
         macAddressBuilder.setMacAddress(new MacAddress("00:00:00:00:00:01"));\r
         entriesBuilder.addAugmentation(MacAddressMatchEntry.class, macAddressBuilder.build());\r
         maskBuilder = new MaskMatchEntryBuilder();\r
-        maskBuilder.setMask(new byte[]{0, 0, 0, 0, 0, 2});\r
+        maskBuilder.setMask(new byte[]{0, 0, 0, 0, 1, 1});\r
         entriesBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build());\r
         entries.add(entriesBuilder.build());\r
         entriesBuilder = new MatchEntriesBuilder();\r
@@ -459,7 +459,7 @@ public class MatchConvertorImplV13Test {
         macAddressBuilder.setMacAddress(new MacAddress("00:00:00:00:00:02"));\r
         entriesBuilder.addAugmentation(MacAddressMatchEntry.class, macAddressBuilder.build());\r
         maskBuilder = new MaskMatchEntryBuilder();\r
-        maskBuilder.setMask(new byte[]{0, 0, 0, 0, 0, 3});\r
+        maskBuilder.setMask(new byte[]{0, 0, 0, 0, 2, 2});\r
         entriesBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build());\r
         entries.add(entriesBuilder.build());\r
         entriesBuilder = new MatchEntriesBuilder();\r
@@ -529,9 +529,9 @@ public class MatchConvertorImplV13Test {
         Assert.assertEquals("Wrong metadata mask", new BigInteger(1, new byte[]{0, 0, 0, 0, 0, 0, 0, 1}),\r
                 builtMatch.getMetadata().getMetadataMask());\r
         Assert.assertEquals("Wrong eth dst", new MacAddress("00:00:00:00:00:01"), builtMatch.getEthernetMatch().getEthernetDestination().getAddress());\r
-//        Assert.assertEquals("Wrong eth dst mask", new MacAddress("00:00:00:00:00:01"), builtMatch.getEthernetMatch().getEthernetDestination().getMask());\r
+        Assert.assertEquals("Wrong eth dst mask", new MacAddress("00:00:00:00:01:01"), builtMatch.getEthernetMatch().getEthernetDestination().getMask());\r
         Assert.assertEquals("Wrong eth src", new MacAddress("00:00:00:00:00:02"), builtMatch.getEthernetMatch().getEthernetSource().getAddress());\r
-//        Assert.assertEquals("Wrong eth src mask", new MacAddress("00:00:00:00:00:03"), builtMatch.getEthernetMatch().getEthernetSource().getMask());\r
+        Assert.assertEquals("Wrong eth src mask", new MacAddress("00:00:00:00:02:02"), builtMatch.getEthernetMatch().getEthernetSource().getMask());\r
         Assert.assertEquals("Wrong vlan id", 4, builtMatch.getVlanMatch().getVlanId().getVlanId().getValue().intValue());\r
         Assert.assertEquals("Wrong vlan id entries", true, builtMatch.getVlanMatch().getVlanId().isVlanIdPresent());\r
         Ipv4Match ipv4Match = (Ipv4Match) builtMatch.getLayer3Match();\r