BUG-1953: fix SAL compatility layer 84/11384/1
authorRobert Varga <rovarga@cisco.com>
Fri, 19 Sep 2014 19:41:45 +0000 (21:41 +0200)
committerRobert Varga <rovarga@cisco.com>
Fri, 19 Sep 2014 19:41:45 +0000 (21:41 +0200)
Sal compatibility produces pure addresses instead of prefixes as
dictated by the model. Fix moth tests and implementation to emit
prefixes.

Change-Id: I1aca04c0fc22aa973d9578fea33550194c6f9264
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/FromSalConversionsUtils.java
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/MDFlowMapping.java
opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/TestFromSalConversionsUtils.java
opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/TestToSalConversionsUtils.java

index ecf1a94..8468c2d 100644 (file)
@@ -331,11 +331,11 @@ public final class FromSalConversionsUtils {
             final Inet4Address inetDestAddress) {
         String inetSourceAddressStr = InetAddresses
                 .toAddrString(inetSourceAddress);
-        Ipv4Prefix ipv4SourcePrefix = new Ipv4Prefix(inetSourceAddressStr);
+        Ipv4Prefix ipv4SourcePrefix = new Ipv4Prefix(inetSourceAddressStr + "/32");
 
         String inetDestAddressValue = InetAddresses
                 .toAddrString(inetDestAddress);
-        Ipv4Prefix ipv4DestPrefix = new Ipv4Prefix(inetDestAddressValue);
+        Ipv4Prefix ipv4DestPrefix = new Ipv4Prefix(inetDestAddressValue + "/32");
 
         ArpMatchBuilder arpMatchBuilder = new ArpMatchBuilder();
 
@@ -375,13 +375,13 @@ public final class FromSalConversionsUtils {
         if(inetSourceAddress != null) {
             String inetSrcAddressString = InetAddresses
                     .toAddrString(inetSourceAddress);
-            layer4MatchBuild.setIpv4Source(new Ipv4Prefix(inetSrcAddressString));
+            layer4MatchBuild.setIpv4Source(new Ipv4Prefix(inetSrcAddressString + "/32"));
         }
         if(inetDestAddress != null) {
             String inetDstAddressString = InetAddresses
                     .toAddrString(inetDestAddress);
             layer4MatchBuild
-            .setIpv4Destination(new Ipv4Prefix(inetDstAddressString));
+            .setIpv4Destination(new Ipv4Prefix(inetDstAddressString + "/32"));
         }
         return layer4MatchBuild.build();
 
@@ -394,13 +394,13 @@ public final class FromSalConversionsUtils {
         if(inetSourceAddress != null) {
             String inetSrcAddressString = InetAddresses
                     .toAddrString(inetSourceAddress);
-            layer6MatchBuild.setIpv6Source(new Ipv6Prefix(inetSrcAddressString));
+            layer6MatchBuild.setIpv6Source(new Ipv6Prefix(inetSrcAddressString + "/128"));
         }
         if(inetDestAddress != null) {
             String inetDstAddressString = InetAddresses
                     .toAddrString(inetDestAddress);
             layer6MatchBuild
-                    .setIpv6Destination(new Ipv6Prefix(inetDstAddressString));
+                    .setIpv6Destination(new Ipv6Prefix(inetDstAddressString + "/128"));
         }
         return layer6MatchBuild.build();
     }
index 00511bc..d3b96d0 100644 (file)
@@ -429,12 +429,12 @@ public final class MDFlowMapping {
     public static Address toInetAddress(final InetAddress address) {
         if (address instanceof Inet4Address) {
             return new Ipv4Builder()
-            .setIpv4Address(new Ipv4Prefix(InetAddresses.toAddrString(address)))
+            .setIpv4Address(new Ipv4Prefix(InetAddresses.toAddrString(address) + "/32"))
             .build();
         }
         if (address instanceof Inet6Address) {
             return new Ipv6Builder()
-            .setIpv6Address(new Ipv6Prefix(InetAddresses.toAddrString(address)))
+            .setIpv6Address(new Ipv6Prefix(InetAddresses.toAddrString(address) + "/128"))
             .build();
         }
 
index 98df901..35555da 100644 (file)
@@ -129,9 +129,9 @@ public class TestFromSalConversionsUtils {
             Layer3Match layer3Match = match.getLayer3Match();
             boolean arpFound = false;
             if (layer3Match instanceof ArpMatch) {
-                assertEquals("Source IP address is wrong.", "192.168.100.100", ((ArpMatch) layer3Match)
+                assertEquals("Source IP address is wrong.", "192.168.100.100/32", ((ArpMatch) layer3Match)
                         .getArpSourceTransportAddress().getValue());
-                assertEquals("Destination IP address is wrong.", "192.168.100.101", ((ArpMatch) layer3Match)
+                assertEquals("Destination IP address is wrong.", "192.168.100.101/32", ((ArpMatch) layer3Match)
                         .getArpTargetTransportAddress().getValue());
                 assertEquals("Source MAC address is wrong.", "ff:ee:dd:cc:bb:aa", ((ArpMatch) layer3Match)
                         .getArpSourceHardwareAddress().getAddress().getValue());
@@ -147,9 +147,9 @@ public class TestFromSalConversionsUtils {
             boolean ipv4Found = false;
             layer3Match = match.getLayer3Match();
             if (layer3Match instanceof Ipv4Match) {
-                assertEquals("Source IP address is wrong.", "192.168.100.102", ((Ipv4Match) layer3Match)
+                assertEquals("Source IP address is wrong.", "192.168.100.102/32", ((Ipv4Match) layer3Match)
                         .getIpv4Source().getValue());
-                assertEquals("Destination IP address is wrong.", "192.168.100.103", ((Ipv4Match) layer3Match)
+                assertEquals("Destination IP address is wrong.", "192.168.100.103/32", ((Ipv4Match) layer3Match)
                         .getIpv4Destination().getValue());
             }
             assertNotNull("Ipv4 wasn't found", ipv4Found);
@@ -160,9 +160,9 @@ public class TestFromSalConversionsUtils {
             boolean ipv6Found = false;
             layer3Match = match.getLayer3Match();
             if (layer3Match instanceof Ipv6Match) {
-                assertEquals("Source IP address is wrong.", "2001:db8:85a3::8a2e:370:7335", ((Ipv6Match) layer3Match)
+                assertEquals("Source IP address is wrong.", "2001:db8:85a3::8a2e:370:7335/128", ((Ipv6Match) layer3Match)
                         .getIpv6Source().getValue());
-                assertEquals("Destination IP address is wrong.", "2001:db8:85a3::8a2e:370:7336",
+                assertEquals("Destination IP address is wrong.", "2001:db8:85a3::8a2e:370:7336/128",
                         ((Ipv6Match) layer3Match).getIpv6Destination().getValue());
             }
             assertNotNull("Ipv6 wasn't found", ipv6Found);
@@ -288,7 +288,7 @@ public class TestFromSalConversionsUtils {
                     boolean ipv4AddressFound = false;
                     if (address instanceof Ipv4) {
                         ipv4AddressFound = true;
-                        assertEquals("Wrong IP address type in SetNextHopAction.", "192.168.100.100", ((Ipv4) address)
+                        assertEquals("Wrong IP address type in SetNextHopAction.", "192.168.100.100/32", ((Ipv4) address)
                                 .getIpv4Address().getValue());
                     }
                     assertTrue("Ipv4 address wasn't found.", ipv4AddressFound);
@@ -299,7 +299,7 @@ public class TestFromSalConversionsUtils {
                     boolean ipv4AddressFound = false;
                     if (address instanceof Ipv4) {
                         ipv4AddressFound = true;
-                        assertEquals("Wrong IP address type in SetNwDstAction.", "192.168.100.101", ((Ipv4) address)
+                        assertEquals("Wrong IP address type in SetNwDstAction.", "192.168.100.101/32", ((Ipv4) address)
                                 .getIpv4Address().getValue());
                     }
                     assertTrue("Ipv4 address wasn't found.", ipv4AddressFound);
@@ -308,7 +308,7 @@ public class TestFromSalConversionsUtils {
                     boolean ipv4AddressFound = false;
                     if (address instanceof Ipv4) {
                         ipv4AddressFound = true;
-                        assertEquals("Wrong IP address type in SetNwSrcAction.", "192.168.100.102", ((Ipv4) address)
+                        assertEquals("Wrong IP address type in SetNwSrcAction.", "192.168.100.102/32", ((Ipv4) address)
                                 .getIpv4Address().getValue());
                     }
                     assertTrue("Ipv4 address wasn't found.", ipv4AddressFound);
index 16d0bb4..45341fb 100644 (file)
@@ -542,7 +542,7 @@ public class TestToSalConversionsUtils {
 
     private Address prapareIpv4Address(String ipv4Address) {
         Ipv4Builder ipv4Builder = new Ipv4Builder();
-        ipv4Builder.setIpv4Address(new Ipv4Prefix(ipv4Address));
+        ipv4Builder.setIpv4Address(new Ipv4Prefix(ipv4Address + "/32"));
         return ipv4Builder.build();
     }
 
@@ -647,8 +647,8 @@ public class TestToSalConversionsUtils {
 
     private Layer3Match prepLayer3MatchIpv4() {
         Ipv4MatchBuilder ipv4MatchBuilder = new Ipv4MatchBuilder();
-        ipv4MatchBuilder.setIpv4Source(new Ipv4Prefix("192.168.1.104"));
-        ipv4MatchBuilder.setIpv4Destination(new Ipv4Prefix("192.168.1.105"));
+        ipv4MatchBuilder.setIpv4Source(new Ipv4Prefix("192.168.1.104/32"));
+        ipv4MatchBuilder.setIpv4Destination(new Ipv4Prefix("192.168.1.105/32"));
         return ipv4MatchBuilder.build();
     }
 
@@ -661,8 +661,8 @@ public class TestToSalConversionsUtils {
 
     private Layer3Match prepLayer3MatchArp() {
         ArpMatchBuilder arpMatchBuilder = new ArpMatchBuilder();
-        arpMatchBuilder.setArpSourceTransportAddress(new Ipv4Prefix("192.168.1.101"));
-        arpMatchBuilder.setArpTargetTransportAddress(new Ipv4Prefix("192.168.1.102"));
+        arpMatchBuilder.setArpSourceTransportAddress(new Ipv4Prefix("192.168.1.101/32"));
+        arpMatchBuilder.setArpTargetTransportAddress(new Ipv4Prefix("192.168.1.102/32"));
 
         ArpSourceHardwareAddressBuilder arpSourAddressBuild = new ArpSourceHardwareAddressBuilder();
         arpSourAddressBuild.setAddress(new MacAddress("22:44:66:88:AA:CC"));

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.