Added ODL to SAL mac addres mask translation.
Change-Id: I6288e5dfa4b9fe77b98f39549e95b9e56e944ab1
Signed-off-by: Jozef Gloncak <jgloncak@cisco.com>
package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match;
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;
import com.google.common.base.Optional;
import com.google.common.base.Splitter;
import java.math.BigInteger;
}
} else if (ofMatch.getOxmMatchField().equals(EthSrc.class)) {
MacAddressMatchEntry macAddressMatchEntry = ofMatch.getAugmentation(MacAddressMatchEntry.class);
}
} 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 (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);
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 (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());
}
ethMatchBuilder.setEthernetDestination(ethDestinationBuilder.build());
matchBuilder.setEthernetMatch(ethMatchBuilder.build());
}
macAddressBuilder.setMacAddress(new MacAddress("00:00:00:00:00:01"));\r
entriesBuilder.addAugmentation(MacAddressMatchEntry.class, macAddressBuilder.build());\r
maskBuilder = new MaskMatchEntryBuilder();\r
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
entriesBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build());\r
entries.add(entriesBuilder.build());\r
entriesBuilder = new MatchEntriesBuilder();\r
macAddressBuilder.setMacAddress(new MacAddress("00:00:00:00:00:02"));\r
entriesBuilder.addAugmentation(MacAddressMatchEntry.class, macAddressBuilder.build());\r
maskBuilder = new MaskMatchEntryBuilder();\r
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
entriesBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build());\r
entries.add(entriesBuilder.build());\r
entriesBuilder = new MatchEntriesBuilder();\r
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 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", 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
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