From: Jozef Gloncak Date: Tue, 27 Jan 2015 16:32:38 +0000 (+0100) Subject: BUG 2280 - mac address mask translation. X-Git-Tag: release/lithium~687^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=6e60186c45758ebad30ba962fdb3f41d332f6db3;p=openflowplugin.git BUG 2280 - mac address mask translation. Added ODL to SAL mac addres mask translation. Change-Id: I6288e5dfa4b9fe77b98f39549e95b9e56e944ab1 Signed-off-by: Jozef Gloncak --- diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertorImpl.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertorImpl.java index ef88ccfaf8..dba2e92a3f 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertorImpl.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertorImpl.java @@ -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> { } } 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()); } diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertorImplV13Test.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertorImplV13Test.java index 98211f49b3..99cb2ebd7f 100644 --- a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertorImplV13Test.java +++ b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertorImplV13Test.java @@ -448,7 +448,7 @@ public class MatchConvertorImplV13Test { macAddressBuilder.setMacAddress(new MacAddress("00:00:00:00:00:01")); entriesBuilder.addAugmentation(MacAddressMatchEntry.class, macAddressBuilder.build()); maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0, 0, 0, 0, 0, 2}); + maskBuilder.setMask(new byte[]{0, 0, 0, 0, 1, 1}); entriesBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); entries.add(entriesBuilder.build()); entriesBuilder = new MatchEntriesBuilder(); @@ -459,7 +459,7 @@ public class MatchConvertorImplV13Test { macAddressBuilder.setMacAddress(new MacAddress("00:00:00:00:00:02")); entriesBuilder.addAugmentation(MacAddressMatchEntry.class, macAddressBuilder.build()); maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0, 0, 0, 0, 0, 3}); + maskBuilder.setMask(new byte[]{0, 0, 0, 0, 2, 2}); entriesBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); entries.add(entriesBuilder.build()); entriesBuilder = new MatchEntriesBuilder(); @@ -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}), builtMatch.getMetadata().getMetadataMask()); Assert.assertEquals("Wrong eth dst", new MacAddress("00:00:00:00:00:01"), builtMatch.getEthernetMatch().getEthernetDestination().getAddress()); -// Assert.assertEquals("Wrong eth dst mask", new MacAddress("00:00:00:00:00:01"), builtMatch.getEthernetMatch().getEthernetDestination().getMask()); + Assert.assertEquals("Wrong eth dst mask", new MacAddress("00:00:00:00:01:01"), builtMatch.getEthernetMatch().getEthernetDestination().getMask()); Assert.assertEquals("Wrong eth src", new MacAddress("00:00:00:00:00:02"), builtMatch.getEthernetMatch().getEthernetSource().getAddress()); -// Assert.assertEquals("Wrong eth src mask", new MacAddress("00:00:00:00:00:03"), builtMatch.getEthernetMatch().getEthernetSource().getMask()); + Assert.assertEquals("Wrong eth src mask", new MacAddress("00:00:00:00:02:02"), builtMatch.getEthernetMatch().getEthernetSource().getMask()); Assert.assertEquals("Wrong vlan id", 4, builtMatch.getVlanMatch().getVlanId().getVlanId().getValue().intValue()); Assert.assertEquals("Wrong vlan id entries", true, builtMatch.getVlanMatch().getVlanId().isVlanIdPresent()); Ipv4Match ipv4Match = (Ipv4Match) builtMatch.getLayer3Match();