support the correct TTL when the response is natively forward TELSDN-30: #close 54/3054/9
authorDavid Goldberg <david.goldberg@contextream.com>
Thu, 21 Nov 2013 06:40:40 +0000 (08:40 +0200)
committerDavid Goldberg <david.goldberg@contextream.com>
Fri, 29 Nov 2013 03:14:40 +0000 (05:14 +0200)
Signed-off-by: David Goldberg <david.goldberg@contextream.com>
Change-Id: Id954a5431af1d732b0000e90ec78e77d8db6f66b
Signed-off-by: David Goldberg <david.goldberg@contextream.com>
27 files changed:
commons/parent/pom.xml
mappingservice/implementation/pom.xml
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/LispMappingService.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/authentication/LispMACAuthentication.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/dao/ClusterDAOService.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/lisp/MapResolver.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/serializer/EidRecordSerializer.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/serializer/EidToLocatorRecordSerializer.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/serializer/LocatorRecordSerializer.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/serializer/MapNotifySerializer.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/serializer/MapRegisterSerializer.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/serializer/MapReplySerializer.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/serializer/MapRequestSerializer.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/serializer/address/LispApplicationDataLCAFAddressSerializer.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/serializer/address/LispLCAFAddressSerializer.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/serializer/address/LispMACAddressSerializer.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/serializer/address/LispSourceDestLCAFAddressSerializer.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/util/ByteUtil.java
mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/lisp/MapResolverTest.java
mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/serializer/address/LispSegmentLCAFAddressTest.java
mappingservice/integrationtest/pom.xml
mappingservice/integrationtest/src/test/java/org/opendaylight/lispflowmapping/integrationtest/MappingServiceIntegrationTest.java
mappingservice/integrationtest/src/test/resources/controller.config [new file with mode: 0644]
mappingservice/southbound/src/main/java/org/opendaylight/lispflowmapping/southbound/LispSouthboundPlugin.java
mappingservice/southbound/src/test/java/org/opendaylight/lispflowmapping/southbound/lisp/LispSouthboundServiceTest.java
mappingservice/yangmodel/pom.xml
mappingservice/yangmodel/src/main/yang/mappingservice.yang

index 50aae672a48991f967aef2529f74cdb993da742c..5bb9379d54b6434ca95d881ce12a6565a74f4835 100644 (file)
@@ -12,8 +12,8 @@
                <connection>scm:git:https://git.opendaylight.org/gerrit/p/lispflowmapping.git</connection>
        </scm>
        <properties>
-       <jacoco.version>0.5.3.201107060350</jacoco.version>
-    <enforcer.version>1.3.1</enforcer.version>
+               <jacoco.version>0.5.3.201107060350</jacoco.version>
+               <enforcer.version>1.3.1</enforcer.version>
                <nexusproxy>http://nexus.opendaylight.org/content</nexusproxy>
                <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
                <projectinfo>2.6</projectinfo>
@@ -27,6 +27,9 @@
                <sonar.branch>${user.name}-private-view</sonar.branch>
                <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
                <sonar.language>java</sonar.language>
+               <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
+        <sonar.jacoco.Reportpath>target/jacoco.exec</sonar.jacoco.Reportpath>
+        <sonar.jacoco.itReportPath>target/jacoco-it.exec</sonar.jacoco.itReportPath>
                <forwardingrulesmanager.version>0.5.0-SNAPSHOT</forwardingrulesmanager.version>
                <statisticsmanager.version>0.5.0-SNAPSHOT</statisticsmanager.version>
                <maven.compile.plugin.version>2.5.1</maven.compile.plugin.version>
                        <dependency>
                                <groupId>org.opendaylight.controller</groupId>
                                <artifactId>clustering.services</artifactId>
-                               <version>0.4.0-SNAPSHOT</version>
+                               <version>0.4.1-SNAPSHOT</version>
                        </dependency>
 
                        <dependency>
                        <dependency>
                                <groupId>org.opendaylight.controller</groupId>
                                <artifactId>sal</artifactId>
-                               <version>0.5.0-SNAPSHOT</version>
+                               <version>0.5.1-SNAPSHOT</version>
                        </dependency>
                        <dependency>
                                <groupId>junit</groupId>
        <build>
                <pluginManagement>
                        <plugins>
+                       <plugin>
+                    <groupId>org.jacoco</groupId>
+                    <artifactId>jacoco-maven-plugin</artifactId>
+                    <version>${jacoco.version}</version>
+                </plugin>
                                <plugin>
                                        <groupId>org.apache.felix</groupId>
                                        <artifactId>maven-bundle-plugin</artifactId>
index 9d6fabf4c439921e00a26a872a18345e033d758c..270cd4a395ae591df7835382dc49b608e05ef2ce 100644 (file)
                <sonar.jacoco.itReportPath>target/jacoco-it.exec</sonar.jacoco.itReportPath>
        </properties>
        <build>
-       <pluginManagement>
-      <plugins>
-        <plugin>
-          <groupId>org.jacoco</groupId>
-          <artifactId>jacoco-maven-plugin</artifactId>
-          <version>${jacoco.version}</version>
-        </plugin>
-      </plugins>
-    </pluginManagement>
+               <pluginManagement>
+                       <plugins>
+                               <plugin>
+                                       <groupId>org.jacoco</groupId>
+                                       <artifactId>jacoco-maven-plugin</artifactId>
+                                       <version>${jacoco.version}</version>
+                               </plugin>
+                       </plugins>
+               </pluginManagement>
                <plugins>
                        <plugin>
                                <groupId>org.apache.felix</groupId>
                                <configuration>
                                        <instructions>
                                                <Export-Package>
+                                                       org.opendaylight.lispflowmapping.implementation,
                                                        org.opendaylight.lispflowmapping.implementation.serializer,
                                                        org.opendaylight.lispflowmapping.implementation.util
                                                </Export-Package>
                                                <Import-Package>
-                                                       javax.xml.bind, 
+                                                       javax.xml.bind,
                                                        org.opendaylight.yang.gen.v1.lispflowmapping.rev131031,
                                                        org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.eidrecords,
                                                        org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.eidtolocatorrecords,
@@ -79,7 +80,6 @@
                                                        org.opendaylight.controller.clustering.services,
                                                        javax.crypto,
                                                        javax.crypto.spec,
-                                                       org.apache.tomcat.util.buf,
                                                        org.opendaylight.controller.sal.binding.api,
                                                        org.opendaylight.yangtools.yang.binding,
                                                        org.opendaylight.yangtools.concepts
                                </configuration>
                        </plugin>
                        <plugin>
-        <groupId>org.jacoco</groupId>
-        <artifactId>jacoco-maven-plugin</artifactId>
-        <configuration>
-          <includes>org.opendaylight.controller.*</includes>
-        </configuration>
-        <executions>
-          <execution>
-            <id>pre-test</id>
-            <goals>
-              <goal>prepare-agent</goal>
-            </goals>
-          </execution>
-          <execution>
-            <id>post-test</id>
-            <phase>test</phase>
-            <goals>
-              <goal>report</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
+                               <groupId>org.jacoco</groupId>
+                               <artifactId>jacoco-maven-plugin</artifactId>
+                               <configuration>
+                                       <includes>org.opendaylight.controller.*</includes>
+                               </configuration>
+                               <executions>
+                                       <execution>
+                                               <id>pre-test</id>
+                                               <goals>
+                                                       <goal>prepare-agent</goal>
+                                               </goals>
+                                       </execution>
+                                       <execution>
+                                               <id>post-test</id>
+                                               <phase>test</phase>
+                                               <goals>
+                                                       <goal>report</goal>
+                                               </goals>
+                                       </execution>
+                               </executions>
+                       </plugin>
                </plugins>
        </build>
        <dependencies>
                        <artifactId>mappingservice.api</artifactId>
                        <version>0.1.0-SNAPSHOT</version>
                </dependency>
+               <dependency>
+                       <groupId>equinoxSDK381</groupId>
+                       <artifactId>org.eclipse.osgi</artifactId>
+               </dependency>
        </dependencies>
 </project>
index 75c02d7d50522f48f0cbfe34e7b3ce8b37a82bc7..213057cec6223da83de7c91da1c7053dce2ce92a 100644 (file)
@@ -90,7 +90,7 @@ public class LispMappingService implements CommandProvider, IFlowMapping, Bindin
     }
 
     void unsetBindingAwareBroker(BindingAwareBroker bindingAwareBroker) {
-        logger.info("BindingAwareBroker was unset in LispMappingService");
+        logger.debug("BindingAwareBroker was unset in LispMappingService");
     }
 
     public void basicInit(ILispDAO dao) {
@@ -113,7 +113,7 @@ public class LispMappingService implements CommandProvider, IFlowMapping, Bindin
     }
 
     void unsetLispDao(ILispDAO dao) {
-        logger.info("LispDAO was unset in LispMappingService");
+        logger.debug("LispDAO was unset in LispMappingService");
         mapServer = null;
         mapResolver = null;
         lispDao = null;
index 2b3722d79ed22fbe189777b2f2842f30a7a7f6d5..82a9b3bfe2d1428e582a4ae43a1e840b3e8c390f 100644 (file)
@@ -8,7 +8,6 @@ import java.util.Arrays;
 import javax.crypto.Mac;
 import javax.crypto.spec.SecretKeySpec;
 
-import org.apache.tomcat.util.buf.HexUtils;
 import org.opendaylight.lispflowmapping.implementation.serializer.MapNotifySerializer;
 import org.opendaylight.lispflowmapping.implementation.serializer.MapRegisterSerializer;
 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapNotify;
index 236a38df1d4bedd9e54e628672cb0f4a95985ee8..b65d8119a7c1fc12b26b6b2bff853619db942b40 100644 (file)
@@ -45,7 +45,6 @@ public class ClusterDAOService implements ILispDAO, IQueryAll {
     private ScheduledExecutorService scheduler;
 
     void setClusterContainerService(IClusterContainerServices s) {
-        logger.debug("Cluster Service set");
         this.clusterContainerService = s;
         allocateCache();
         retrieveCache();
index cb2a01fc857000051f1fae0150892b710d21e57a..2ce297b2837334445e09d00165a0d93666104ac8 100644 (file)
@@ -19,10 +19,10 @@ import org.opendaylight.lispflowmapping.interfaces.dao.MappingServiceRLOC;
 import org.opendaylight.lispflowmapping.interfaces.dao.MappingServiceValue;
 import org.opendaylight.lispflowmapping.interfaces.lisp.IMapReplyHandler;
 import org.opendaylight.lispflowmapping.interfaces.lisp.IMapResolverAsync;
-import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapReply.Action;
 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapRequest;
 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.eidrecords.EidRecord;
 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.eidtolocatorrecords.EidToLocatorRecord;
+import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.eidtolocatorrecords.EidToLocatorRecord.Action;
 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.eidtolocatorrecords.EidToLocatorRecordBuilder;
 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.lispaddress.LispAddressContainerBuilder;
 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.locatorrecords.LocatorRecord;
@@ -32,6 +32,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class MapResolver implements IMapResolverAsync {
+    private static final int TTL_RLOC_TIMED_OUT = 1;
+    private static final int TTL_NO_RLOC_KNOWN = 15;
     private ILispDAO dao;
     private volatile boolean shouldAuthenticate;
     private volatile boolean shouldIterateMask;
@@ -52,16 +54,15 @@ public class MapResolver implements IMapResolverAsync {
             logger.warn("handleMapRequest called while dao is uninitialized");
         } else {
             MapReplyBuilder builder = new MapReplyBuilder();
-            builder.setAction(Action.NoAction);
             builder.setEchoNonceEnabled(false);
             builder.setProbe(false);
             builder.setSecurityEnabled(false);
             builder.setNonce(request.getNonce());
+            builder.setEidToLocatorRecord(new ArrayList<EidToLocatorRecord>());
             for (EidRecord eid : request.getEidRecord()) {
                 EidToLocatorRecordBuilder recordBuilder = new EidToLocatorRecordBuilder();
                 recordBuilder.setRecordTtl(0);
-                recordBuilder
-                        .setAction(org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.eidtolocatorrecords.EidToLocatorRecord.Action.NoAction);
+                recordBuilder.setAction(Action.NoAction);
                 recordBuilder.setAuthoritative(false);
                 recordBuilder.setMapVersion((short) 0);
                 recordBuilder.setMaskLength(eid.getMask());
@@ -73,10 +74,24 @@ public class MapResolver implements IMapResolverAsync {
                     locators = findMaskLocators(key);
                 }
                 if (locators != null) {
-                    addLocators(recordBuilder, locators);
-                }
-                if (builder.getEidToLocatorRecord() == null) {
-                    builder.setEidToLocatorRecord(new ArrayList<EidToLocatorRecord>());
+                    MappingServiceValue value = (MappingServiceValue) locators.get("value");
+
+                    if (value.getRlocs() != null && value.getRlocs().size() > 0) {
+                        addLocators(recordBuilder, value);
+                    } else {
+                        recordBuilder
+                                .setAction(org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.eidtolocatorrecords.EidToLocatorRecord.Action.NativelyForward);
+
+                        if (didContainRLOCs(value)) {
+                            recordBuilder.setRecordTtl(TTL_RLOC_TIMED_OUT);
+                        } else {
+                            recordBuilder.setRecordTtl(TTL_NO_RLOC_KNOWN);
+                        }
+                    }
+                } else {
+                    recordBuilder
+                            .setAction(org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.eidtolocatorrecords.EidToLocatorRecord.Action.NativelyForward);
+                    recordBuilder.setRecordTtl(TTL_NO_RLOC_KNOWN);
                 }
                 builder.getEidToLocatorRecord().add(recordBuilder.build());
             }
@@ -84,6 +99,10 @@ public class MapResolver implements IMapResolverAsync {
         }
     }
 
+    private boolean didContainRLOCs(MappingServiceValue value) {
+        return value.getKey() == null;
+    }
+
     private Map<String, ?> findMaskLocators(IMappingServiceKey key) {
         int mask = key.getMask();
         while (mask > 0) {
@@ -98,14 +117,10 @@ public class MapResolver implements IMapResolverAsync {
         return null;
     }
 
-    private void addLocators(EidToLocatorRecordBuilder recordBuilder, Map<String, ?> locators) {
-        try {
-            MappingServiceValue value = (MappingServiceValue) locators.get("value");
-            for (MappingServiceRLOC rloc : value.getRlocs()) {
-                addLocator(recordBuilder, rloc);
-                recordBuilder.setRecordTtl(rloc.getTtl());
-            }
-        } catch (ClassCastException cce) {
+    private void addLocators(EidToLocatorRecordBuilder recordBuilder, MappingServiceValue value) {
+        for (MappingServiceRLOC rloc : value.getRlocs()) {
+            addLocator(recordBuilder, rloc);
+            recordBuilder.setRecordTtl(rloc.getTtl());
         }
     }
 
index 2a1d6d262c7ccabc2d6416744c9d5ef61382e1d4..0b18699432edb33b2201b78ac0a010889529461c 100644 (file)
@@ -3,6 +3,7 @@ package org.opendaylight.lispflowmapping.implementation.serializer;
 import java.nio.ByteBuffer;
 
 import org.opendaylight.lispflowmapping.implementation.serializer.address.LispAddressSerializer;
+import org.opendaylight.lispflowmapping.implementation.util.ByteUtil;
 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.LispAFIAddress;
 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.eidrecords.EidRecord;
 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.eidrecords.EidRecordBuilder;
@@ -23,7 +24,7 @@ public class EidRecordSerializer {
 
     public EidRecord deserialize(ByteBuffer requestBuffer) {
         /* byte reserved = */requestBuffer.get();
-        short maskLength = (short) (requestBuffer.get() & 0xff);
+        short maskLength = (short) (ByteUtil.getUnsignedByte(requestBuffer));
         LispAFIAddress prefix = LispAddressSerializer.getInstance().deserialize(requestBuffer);
         return new EidRecordBuilder().setLispAddressContainer(new LispAddressContainerBuilder().setAddress((Address) prefix).build())
                 .setMask(maskLength).build();
index 4f9b0c063f1a4c6fb8e7cfaedcf4867e5bdcc200..f9a7fb52eb02f27d441d1b2f52d129fa269e5058 100644 (file)
@@ -4,7 +4,6 @@ import java.nio.ByteBuffer;
 import java.util.ArrayList;
 
 import org.apache.commons.lang3.BooleanUtils;
-import org.apache.tomcat.util.buf.HexUtils;
 import org.opendaylight.lispflowmapping.implementation.serializer.address.LispAddressSerializer;
 import org.opendaylight.lispflowmapping.implementation.util.ByteUtil;
 import org.opendaylight.lispflowmapping.implementation.util.LispAFIConvertor;
@@ -34,8 +33,8 @@ public class EidToLocatorRecordSerializer {
     public EidToLocatorRecord deserialize(ByteBuffer buffer) {
         EidToLocatorRecordBuilder builder = new EidToLocatorRecordBuilder();
         builder.setRecordTtl(buffer.getInt());
-        byte locatorCount = buffer.get();
-        builder.setMaskLength((short) (buffer.get() & 0xff));
+        byte locatorCount = (byte) ByteUtil.getUnsignedByte(buffer);
+        builder.setMaskLength((short) ByteUtil.getUnsignedByte(buffer));
         byte actionAndAuthoritative = buffer.get();
         Action act = Action.forValue(actionAndAuthoritative >> 5);
         if (act == null) {
index 5f5878efc5c74e595f565d6a3ee06d4dc5512299..3fbd3b97cc50429dfb7439f763e817bf25e8c13a 100644 (file)
@@ -28,10 +28,10 @@ public class LocatorRecordSerializer {
 
     protected LocatorRecord deserialize(ByteBuffer buffer) {
         LocatorRecordBuilder builder = new LocatorRecordBuilder();
-        builder.setPriority(ByteUtil.asUnsignedByte(buffer.get()));
-        builder.setWeight(ByteUtil.asUnsignedByte(buffer.get()));
-        builder.setMulticastPriority(ByteUtil.asUnsignedByte(buffer.get()));
-        builder.setMulticastWeight(ByteUtil.asUnsignedByte(buffer.get()));
+        builder.setPriority((short) ByteUtil.getUnsignedByte(buffer));
+        builder.setWeight((short) ByteUtil.getUnsignedByte(buffer));
+        builder.setMulticastPriority((short) ByteUtil.getUnsignedByte(buffer));
+        builder.setMulticastWeight((short) ByteUtil.getUnsignedByte(buffer));
         byte flags = (byte) buffer.getShort();
         builder.setLocalLocator(ByteUtil.extractBit(flags, Flags.LOCAL_LOCATOR));
         builder.setRlocProbed(ByteUtil.extractBit(flags, Flags.RLOC_PROBED));
index a26d1eee9e57dc849007717d3ec7ca9882215fae..0ee7810c7dfa67e9b2854dab9db38afd11ecb627 100644 (file)
@@ -67,7 +67,7 @@ public class MapNotifySerializer {
 
             notifyBuffer.position(notifyBuffer.position() + Length.RES);
 
-            byte recordCount = notifyBuffer.get();
+            byte recordCount = (byte) ByteUtil.getUnsignedByte(notifyBuffer);
             builder.setNonce(notifyBuffer.getLong());
             builder.setKeyId(notifyBuffer.getShort());
             short authenticationLength = notifyBuffer.getShort();
index 8de8235b0d1a37a47ad8a5818e08d5404913c533..7d5de297eb81be45192c1af65964fc2abdb5b409 100644 (file)
@@ -66,7 +66,7 @@ public class MapRegisterSerializer {
 
             registerBuffer.position(registerBuffer.position() + Length.RES);
             builder.setWantMapNotify(ByteUtil.extractBit(registerBuffer.get(), Flags.WANT_MAP_REPLY));
-            byte recordCount = registerBuffer.get();
+            byte recordCount = (byte) ByteUtil.getUnsignedByte(registerBuffer);
             builder.setNonce(registerBuffer.getLong());
             builder.setKeyId(registerBuffer.getShort());
             short authenticationLength = registerBuffer.getShort();
index 3254cd158ad2fdea1c539ecc9483b7e0907f6ed3..5afac0bfe62051059c07772d0e07313a5e6d5a77 100644 (file)
@@ -60,7 +60,7 @@ public class MapReplySerializer {
         builder.setEchoNonceEnabled(ByteUtil.extractBit(typeAndFlags, Flags.ECHO_NONCE_ENABLED));
         builder.setSecurityEnabled(ByteUtil.extractBit(typeAndFlags, Flags.SECURITY_ENABLED));
         replyBuffer.getShort();
-        int recordCount = replyBuffer.get();
+        int recordCount = ByteUtil.getUnsignedByte(replyBuffer);
         builder.setNonce(replyBuffer.getLong());
         builder.setEidToLocatorRecord(new ArrayList<EidToLocatorRecord>());
         for (int i = 0; i < recordCount; i++) {
index 94cf62d446572eaa11db665f6596df880d242704..da5535d57e2646111bb6df945d62f8556c2069b7 100644 (file)
@@ -111,8 +111,8 @@ public class MapRequestSerializer {
             builder.setPitr(ByteUtil.extractBit(moreFlags, Flags.PITR));
             builder.setSmrInvoked(ByteUtil.extractBit(moreFlags, Flags.SMR_INVOKED));
 
-            int itrCount = requestBuffer.get() + 1;
-            int recordCount = requestBuffer.get();
+            int itrCount = ByteUtil.getUnsignedByte(requestBuffer) + 1;
+            int recordCount = ByteUtil.getUnsignedByte(requestBuffer);
             builder.setNonce(requestBuffer.getLong());
             builder.setSourceEid(new SourceEidBuilder().setLispAddressContainer(
                     new LispAddressContainerBuilder().setAddress((Address) LispAddressSerializer.getInstance().deserialize(requestBuffer)).build())
index e019afd0145730e95a9c8626106f5c836535eb2b..06d6f9ac7ff1171317de716ea66ff6c960669161 100644 (file)
@@ -50,9 +50,9 @@ public class LispApplicationDataLCAFAddressSerializer extends LispLCAFAddressSer
         byte[] rawIPTos = new byte[3];
         buffer.get(rawIPTos);
         builder.setIpTos(ByteUtil.getPartialInt(rawIPTos));
-        builder.setProtocol(ByteUtil.asUnsignedByte(buffer.get()));
-        builder.setLocalPort(new PortNumber(ByteUtil.asUnsignedShort(buffer.getShort())));
-        builder.setRemotePort(new PortNumber(ByteUtil.asUnsignedShort(buffer.getShort())));
+        builder.setProtocol((short) ByteUtil.getUnsignedByte(buffer));
+        builder.setLocalPort(new PortNumber(new Integer(buffer.getShort())));
+        builder.setRemotePort(new PortNumber(new Integer(buffer.getShort())));
         LispAFIAddress address = LispAddressSerializer.getInstance().deserialize(buffer);
         builder.setAfi(AddressFamilyNumberEnum.LCAF.getIanaCode()).setLcafType((short) LispCanonicalAddressFormatEnum.APPLICATION_DATA.getLispCode())
                 .setAddress(new AddressBuilder().setPrimitiveAddress((PrimitiveAddress) LispAFIConvertor.toPrimitive(address)).build());
index 733ebed5b9a1f9234faed7e2ddadfd250a118698..ea80fa118815d91cf3cf67e24c6918e6a0bf95ed 100644 (file)
@@ -11,6 +11,7 @@ import java.nio.ByteBuffer;
 
 import org.opendaylight.lispflowmapping.implementation.lisp.exception.LispSerializationException;
 import org.opendaylight.lispflowmapping.implementation.serializer.address.factory.LispLCAFAddressSerializerFactory;
+import org.opendaylight.lispflowmapping.implementation.util.ByteUtil;
 import org.opendaylight.lispflowmapping.type.LispCanonicalAddressFormatEnum;
 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.LispAFIAddress;
 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.LispLcafAddress;
@@ -30,7 +31,7 @@ public class LispLCAFAddressSerializer extends LispAddressSerializer {
     @Override
     protected LispLcafAddress deserializeData(ByteBuffer buffer) {
         buffer.position(buffer.position() + Length.RES + Length.FLAGS);
-        byte lispCode = buffer.get();
+        byte lispCode = (byte) ByteUtil.getUnsignedByte(buffer);
         LispCanonicalAddressFormatEnum lcafType = LispCanonicalAddressFormatEnum.valueOf(lispCode);
         byte res2 = buffer.get();
         short length = buffer.getShort();
index 66c0d71abddca8512fd3ebc3e383a783e59e9886..c095a50dd5a402d0ebec34cf4933b199703847ae 100644 (file)
@@ -4,7 +4,6 @@ import java.nio.ByteBuffer;
 
 import javax.xml.bind.DatatypeConverter;
 
-import org.apache.tomcat.util.buf.HexUtils;
 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.LispAFIAddress;
 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.LispMacAddress;
 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.lispaddress.lispaddresscontainer.address.MacBuilder;
index 396270c4bfe7d70c19ff55f888a63f0847b843b2..077ba3dcf688a0b849cfd9502ad66e0bb06107cd 100644 (file)
@@ -46,12 +46,12 @@ public class LispSourceDestLCAFAddressSerializer extends LispLCAFAddressSerializ
     @Override
     protected LcafSourceDestAddress deserializeData(ByteBuffer buffer, byte res2, short length) {
         short res = buffer.getShort();
-        byte srcMaskLength = buffer.get();
-        byte dstMaskLength = buffer.get();
+        int srcMaskLength = ByteUtil.getUnsignedByte(buffer);
+        int dstMaskLength = ByteUtil.getUnsignedByte(buffer);
         LispAFIAddress srcAddress = LispAddressSerializer.getInstance().deserialize(buffer);
         LispAFIAddress dstAddress = LispAddressSerializer.getInstance().deserialize(buffer);
         LcafSourceDestBuilder builder = new LcafSourceDestBuilder();
-        builder.setDstMaskLength(ByteUtil.asUnsignedByte(dstMaskLength)).setSrcMaskLength(ByteUtil.asUnsignedByte(srcMaskLength));
+        builder.setDstMaskLength((short) dstMaskLength).setSrcMaskLength((short) srcMaskLength);
         builder.setSrcAddress(new SrcAddressBuilder().setPrimitiveAddress((PrimitiveAddress) LispAFIConvertor.toPrimitive(srcAddress)).build());
         builder.setDstAddress(new DstAddressBuilder().setPrimitiveAddress((PrimitiveAddress) LispAFIConvertor.toPrimitive(dstAddress)).build());
         builder.setAfi(AddressFamilyNumberEnum.LCAF.getIanaCode());
index 58703e86fbb2687165c4fd5340fabd403f7f7d09..4d2cf50c4c263998edafadefa0795bebcca1e208 100644 (file)
@@ -20,6 +20,10 @@ public class ByteUtil {
         return inBuffer.get(pos) & 0xFF;
     }
 
+    public static int getUnsignedByte(ByteBuffer inBuffer) {
+        return inBuffer.get() & 0xFF;
+    }
+
     public static int getUnsignedShort(byte[] inBuffer, int pos) {
         return asUnsignedShort(getShort(inBuffer, pos));
     }
@@ -35,32 +39,32 @@ public class ByteUtil {
     public static int getInt(byte[] inBuffer, int pos) {
         return ByteBuffer.wrap(inBuffer, pos, 4).getInt();
     }
-    
+
     public static int getPartialInt(byte[] inBuffer) {
         ByteBuffer buffer = ByteBuffer.allocate(4);
-        buffer.position(4-inBuffer.length);
+        buffer.position(4 - inBuffer.length);
         buffer.put(inBuffer);
         buffer.position(0);
         return buffer.getInt();
     }
-    
+
     public static short asUnsignedByte(byte b) {
-       return (short)((short)b & 0xFF);
+        return (short) ((short) b & 0xFF);
     }
 
     public static int asUnsignedShort(short s) {
-       return s & 0xFFFF;
+        return s & 0xFFFF;
     }
-    
+
     public static long asUnsignedInteger(int i) {
-       return i & 0xFFFFFFFF;
+        return i & 0xFFFFFFFF;
     }
-    
+
     public static byte[] partialIntToByteArray(int number, int length) {
         ByteBuffer buffer = ByteBuffer.allocate(4);
         buffer.putInt(number);
-        byte[] result  = new byte[length];
-        buffer.position(4-length);
+        byte[] result = new byte[length];
+        buffer.position(4 - length);
         buffer.get(result);
         return result;
     }
index 9cfeacd2139b9e226ad0abf3d646ed14b981e030..e2c44dcc5dd3be5764e945bf45363688abd5752a 100644 (file)
@@ -14,6 +14,7 @@ import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.opendaylight.lispflowmapping.implementation.LispMappingService;
+import org.opendaylight.lispflowmapping.implementation.authentication.LispKeyIDEnum;
 import org.opendaylight.lispflowmapping.implementation.dao.MappingServiceKeyUtil;
 import org.opendaylight.lispflowmapping.implementation.util.LispAFIConvertor;
 import org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO;
@@ -203,6 +204,52 @@ public class MapResolverTest extends BaseTestCase {
         assertEquals(0, eidToLocators.getLocatorRecord().size());
     }
 
+    @Test
+    public void handleMapRequest_VerifyNativelyForwardAutherized() {
+        MapRequest mr = getDefaultMapRequest();
+
+        MappingServiceValue value = new MappingServiceValue();
+        value.setKey("pass");
+        Map<String, MappingServiceValue> result = new HashMap<String, MappingServiceValue>();
+        result.put("value", value);
+
+        MapReply mapReply = getNativelyForwardMapReply(mr, result);
+
+        EidToLocatorRecord eidToLocators = mapReply.getEidToLocatorRecord().get(0);
+        assertEquals(15, eidToLocators.getRecordTtl().intValue());
+        assertEquals(Action.NativelyForward, eidToLocators.getAction());
+    }
+
+    private MapReply getNativelyForwardMapReply(MapRequest mr, Map<String, MappingServiceValue> result) {
+        allowing(lispDAO).get(MappingServiceKeyUtil.generateMappingServiceKey(LispAFIConvertor.toContainer(v4Address), 32));
+        ret(result);
+        MapReply mapReply = testedMapResolver.handleMapRequest(mr);
+        return mapReply;
+    }
+
+    @Test
+    public void handleMapRequest_VerifyNativelyForwardOldRegister() {
+        MapRequest mr = getDefaultMapRequest();
+
+        MappingServiceValue value = new MappingServiceValue();
+        Map<String, MappingServiceValue> result = new HashMap<String, MappingServiceValue>();
+        result.put("value", value);
+
+        MapReply mapReply = getNativelyForwardMapReply(mr, result);
+
+        EidToLocatorRecord eidToLocators = mapReply.getEidToLocatorRecord().get(0);
+        assertEquals(1, eidToLocators.getRecordTtl().intValue());
+        assertEquals(Action.NativelyForward, eidToLocators.getAction());
+    }
+
+    private MapRequest getDefaultMapRequest() {
+        mapRequest = getDefaultMapRequestBuilder();
+        mapRequest.getEidRecord().add(
+                new EidRecordBuilder().setMask((short) 32).setLispAddressContainer(LispAFIConvertor.toContainer(v4Address)).build());
+        MapRequest mr = mapRequest.build();
+        return mr;
+    }
+
     @Test
     public void handleMapRequest__VerifyMaskNoMatch() throws Exception {
 
index ab96d97199e11462cfd6a18fb40e015c8d9224dc..4c2f4b54f210cf8c252676eceb2bd62528adcb90 100644 (file)
@@ -30,14 +30,14 @@ public class LispSegmentLCAFAddressTest extends BaseTestCase {
     public void deserialize__Simple() throws Exception {
         LispAFIAddress address = LispAddressSerializer.getInstance().deserialize(hexToByteBuffer("40 03 00 00 " + //
                 "02 20 00 0A " + //
-                "AA BB CC DD " + // instance ID
+                "00 BB CC DD " + // instance ID
                 "00 01 11 22 33 44")); // AFI=1, IP=0x11223344
 
         assertEquals(AddressFamilyNumberEnum.LCAF.getIanaCode(), address.getAfi().shortValue());
         LcafSegmentAddress segAddress = (LcafSegmentAddress) address;
 
         assertEquals(LispAFIConvertor.asPrimitiveIPAfiAddress("17.34.51.68"), segAddress.getAddress().getPrimitiveAddress());
-        assertEquals(0x00BBCCDD, segAddress.getInstanceId().intValue()); // only first 24bit are relevant.
+        assertEquals(0x00BBCCDD, segAddress.getInstanceId().intValue());
         assertEquals(LispCanonicalAddressFormatEnum.SEGMENT.getLispCode(), segAddress.getLcafType().byteValue());
     }
 
@@ -52,6 +52,14 @@ public class LispSegmentLCAFAddressTest extends BaseTestCase {
     public void deserialize__UnknownLCAFType() throws Exception {
         LispAddressSerializer.getInstance().deserialize(hexToByteBuffer("40 03 00 00 " + //
                 "AA 20 00 0A " + // Type AA is unknown
+                "00 BB CC DD " + // instance ID
+                "00 01 11 22 33 44")); // AFI=1, IP=0x11223344
+    }
+
+    @Test(expected = LispSerializationException.class)
+    public void deserialize__LongInstanceID() throws Exception {
+        LispAddressSerializer.getInstance().deserialize(hexToByteBuffer("40 03 00 00 " + //
+                "02 20 00 0A " + // Type AA is unknown
                 "AA BB CC DD " + // instance ID
                 "00 01 11 22 33 44")); // AFI=1, IP=0x11223344
     }
@@ -60,7 +68,7 @@ public class LispSegmentLCAFAddressTest extends BaseTestCase {
     public void deserialize__Ipv6() throws Exception {
         LcafSegmentAddress segAddress = (LcafSegmentAddress) LispAddressSerializer.getInstance().deserialize(hexToByteBuffer("40 03 00 00 " + //
                 "02 20 00 0A " + //
-                "AA BB CC DD " + // instance ID
+                "00 BB CC DD " + // instance ID
                 "00 02 11 22 33 44 55 66 77 88 99 AA BB CC AA BB CC DD")); // AFI=2,
         // IPv6
 
index fe39fc1bcaefb66a25889de73f893006bd1580bc..952df70437f46870dd12757141b96a9345c309d3 100644 (file)
@@ -7,7 +7,7 @@
                <groupId>org.opendaylight.controller</groupId>
                <artifactId>commons.integrationtest</artifactId>
                <version>0.5.1-SNAPSHOT</version>
-                <relativePath></relativePath>
+               <relativePath></relativePath>
        </parent>
        <groupId>org.opendaylight.lispflowmapping</groupId>
        <artifactId>mappingservice.integrationtest</artifactId>
@@ -27,7 +27,6 @@
                </repository>
        </repositories>
        <build>
-
                <pluginManagement>
                        <plugins>
                                <plugin>
                                        <artifactId>jacoco-maven-plugin</artifactId>
                                        <version>0.5.3.201107060350</version>
                                </plugin>
+                               <plugin>
+                                       <groupId>org.eclipse.m2e</groupId>
+                                       <artifactId>lifecycle-mapping</artifactId>
+                                       <version>1.0.0</version>
+                                       <configuration>
+                                               <lifecycleMappingMetadata>
+                                                       <pluginExecutions>
+                                                               <pluginExecution>
+                                                                       <pluginExecutionFilter>
+                                                                               <groupId>org.ops4j.pax.exam</groupId>
+                                                                               <artifactId>maven-paxexam-plugin</artifactId>
+                                                                               <versionRange>[1.2.4,)</versionRange>
+                                                                               <goals>
+                                                                                       <goal>generate-depends-file</goal>
+                                                                               </goals>
+                                                                       </pluginExecutionFilter>
+                                                                       <action>
+                                                                               <execute>
+                                                                                       <runOnIncremental>false</runOnIncremental>
+                                                                               </execute>
+                                                                       </action>
+                                                               </pluginExecution>
+                                                       </pluginExecutions>
+                                               </lifecycleMappingMetadata>
+                                       </configuration>
+                               </plugin>
                        </plugins>
                </pluginManagement>
                <plugins>
+               <plugin>
+                <groupId>org.ops4j.pax.exam</groupId>
+                <artifactId>maven-paxexam-plugin</artifactId>
+                <version>1.2.4</version>
+                <executions>
+                    <execution>
+                        <id>generate-config</id>
+                        <goals>
+                            <goal>generate-depends-file</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-checkstyle-plugin</artifactId>
                                        </execution>
                                </executions>
                        </plugin>
-
                </plugins>
        </build>
        <properties>
                <exam.version>3.0.0</exam.version>
-               <url.version>1.5.2</url.version>
+               <url.version>1.5.0</url.version>
                <!-- Sonar jacoco plugin to get integration test coverage info -->
                <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
                <sonar.jacoco.reportPath>../implementation/target/jacoco.exec</sonar.jacoco.reportPath>
                        <artifactId>mappingservice.yangmodel</artifactId>
                        <version>0.1.0-SNAPSHOT</version>
                </dependency>
+               <dependency>
+                       <groupId>org.opendaylight.lispflowmapping</groupId>
+                       <artifactId>mappingservice.config</artifactId>
+                       <version>0.1.0-SNAPSHOT</version>
+               </dependency>
                <dependency>
                        <groupId>org.opendaylight.lispflowmapping</groupId>
                        <artifactId>mappingservice.api</artifactId>
                <dependency>
                        <groupId>org.opendaylight.controller</groupId>
                        <artifactId>containermanager</artifactId>
-                       <version>0.5.1-SNAPSHOT</version>
+                       <version>0.5.0-SNAPSHOT</version>
                </dependency>
-
+               <dependency>
+          <groupId>org.opendaylight.controller</groupId>
+          <artifactId>netconf-impl</artifactId>
+          <version>${netconf.version}</version>
+        </dependency>
                <dependency>
                        <groupId>org.opendaylight.controller</groupId>
                        <artifactId>containermanager.it.implementation</artifactId>
-                       <version>0.5.1-SNAPSHOT</version>
+                       <version>0.5.0-SNAPSHOT</version>
                </dependency>
                <dependency>
                        <groupId>org.opendaylight.controller</groupId>
                <dependency>
                        <groupId>org.opendaylight.controller</groupId>
                        <artifactId>clustering.stub</artifactId>
-                       <version>0.4.1-SNAPSHOT</version>
+                       <version>0.4.0-SNAPSHOT</version>
                </dependency>
 
                <dependency>
                <dependency>
                        <groupId>commons-codec</groupId>
                        <artifactId>commons-codec</artifactId>
-                       <version>1.8</version>
                </dependency>
                <dependency>
                        <groupId>equinoxSDK381</groupId>
                <dependency>
                        <groupId>org.ops4j.pax.exam</groupId>
                        <artifactId>pax-exam-container-native</artifactId>
-                       <version>${exam.version}</version>
                        <scope>test</scope>
                </dependency>
                <dependency>
                        <groupId>org.ops4j.pax.exam</groupId>
                        <artifactId>pax-exam-junit4</artifactId>
-                       <version>${exam.version}</version>
                        <scope>test</scope>
                </dependency>
+               <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam</artifactId>
+            <version>${exam.version}</version>
+            <!-- Compile scope here is intentional, it is used in TestHelper 
+                class which could be downloaded via nexus and reused in other integration 
+                tests. -->
+            <scope>compile</scope>
+        </dependency>
                <dependency>
                        <groupId>org.ops4j.pax.exam</groupId>
                        <artifactId>pax-exam-link-mvn</artifactId>
-                       <version>${exam.version}</version>
-                       <scope>test</scope>
-               </dependency>
-               <dependency>
-                       <groupId>org.ops4j.pax.url</groupId>
-                       <artifactId>pax-url-aether</artifactId>
-                       <version>${url.version}</version>
                        <scope>test</scope>
                </dependency>
                <dependency>
                        <artifactId>switchmanager.implementation</artifactId>
                        <version>0.4.1-SNAPSHOT</version>
                </dependency>
-               <dependency>
-                       <groupId>org.opendaylight.controller</groupId>
-                       <artifactId>commons.httpclient</artifactId>
-                       <version>0.1.1-SNAPSHOT</version>
-               </dependency>
                <dependency>
                        <groupId>org.opendaylight.controller</groupId>
                        <artifactId>connectionmanager</artifactId>
index ce4b2b3e8d608707789dd1bb51427b139348aa0f..a3ced2e25d89b8b005f5a4af5065fa3934350972 100644 (file)
@@ -285,8 +285,6 @@ public class MappingServiceIntegrationTest {
                 mavenBundle("ch.qos.logback", "logback-core").versionAsInProject(),
                 mavenBundle("ch.qos.logback", "logback-classic").versionAsInProject(),
 
-                mavenBundle(ODL, "config-api").versionAsInProject(), //
-                mavenBundle(ODL, "config-manager").versionAsInProject(), //
                 mavenBundle("commons-io", "commons-io").versionAsInProject(),
 
                 mavenBundle("commons-fileupload", "commons-fileupload").versionAsInProject(),
@@ -394,7 +392,6 @@ public class MappingServiceIntegrationTest {
                 mavenBundle("org.opendaylight.controller", "switchmanager").versionAsInProject(),//
                 mavenBundle("org.opendaylight.controller", "connectionmanager").versionAsInProject(),//
                 mavenBundle("org.opendaylight.controller", "connectionmanager.implementation").versionAsInProject(),//
-                mavenBundle("org.opendaylight.controller", "commons.httpclient").versionAsInProject(), //
                 mavenBundle("org.opendaylight.controller", "configuration").versionAsInProject(),//
                 mavenBundle("org.opendaylight.controller", "configuration.implementation").versionAsInProject(),//
                 mavenBundle("org.opendaylight.controller", "usermanager").versionAsInProject(), //
@@ -435,7 +432,9 @@ public class MappingServiceIntegrationTest {
                 mavenBundle("org.opendaylight.controller", "clustering.stub").versionAsInProject(),
                 mavenBundle("org.opendaylight.controller", "clustering.services").versionAsInProject(),
                 mavenBundle("org.opendaylight.controller", "sal").versionAsInProject(),
+
                 mavenBundle("org.opendaylight.lispflowmapping", "mappingservice.yangmodel").versionAsInProject(),
+                mavenBundle("org.opendaylight.lispflowmapping", "mappingservice.config").versionAsInProject(),
                 mavenBundle("org.opendaylight.lispflowmapping", "mappingservice.api").versionAsInProject(),
                 mavenBundle("org.opendaylight.lispflowmapping", "mappingservice.implementation").versionAsInProject(), //
                 mavenBundle("org.opendaylight.lispflowmapping", "mappingservice.southbound").versionAsInProject(), //
@@ -447,6 +446,9 @@ public class MappingServiceIntegrationTest {
                 mavenBundle(ODL, "sal-broker-impl").versionAsInProject(), //
                 mavenBundle(ODL, "sal-connector-api").versionAsInProject(), //
 
+                mavenBundle(ODL, "config-api").versionAsInProject(), //
+                mavenBundle(ODL, "config-manager").versionAsInProject(), //
+
                 junitBundles());
     }
 
@@ -469,7 +471,7 @@ public class MappingServiceIntegrationTest {
     @Test
     public void northboundAddKey() throws Exception {
 
-        LispIpv4Address address = LispAFIConvertor.asIPAfiAddress("10.0.0.1");
+        LispIpv4Address address = LispAFIConvertor.asIPAfiAddress("1.2.3.4");
         int mask = 32;
         String pass = "asdf";
 
@@ -1231,6 +1233,7 @@ public class MappingServiceIntegrationTest {
 
     }
 
+    @Test
     public void mapRequestMapRegisterAndMapRequestTestTimeout() throws SocketTimeoutException {
 
         LispIpv4Address eid = LispAFIConvertor.asIPAfiAddress("1.2.3.4");
@@ -1271,19 +1274,110 @@ public class MappingServiceIntegrationTest {
                 .getLispAddressContainer());
         ServiceReference r = bc.getServiceReference(ILispDAO.class.getName());
         if (r != null) {
-            ClusterDAOService clusterService = (ClusterDAOService) bc.getService(r);
-            clusterService.setTimeUnit(TimeUnit.NANOSECONDS);
+            causeEntryToBeCleaned(r);
             sendMapRequest(mapRequestBuilder.build());
             mapReply = receiveMapReply();
             assertEquals(0, mapReply.getEidToLocatorRecord().get(0).getLocatorRecord().size());
-            clusterService.setTimeUnit(TimeUnit.MINUTES);
-            sendMapRequest(mapRequestBuilder.build());
-            mapReply = receiveMapReply();
-            assertEquals(recordBuilder.getLispAddressContainer(), mapReply.getEidToLocatorRecord().get(0).getLocatorRecord().get(0)
-                    .getLispAddressContainer());
         }
     }
 
+    @Test
+    public void mapRequestMapRegisterAndMapRequestTestNativelyForwardTimeoutResponse() throws Exception {
+
+        LispIpv4Address eid = LispAFIConvertor.asIPAfiAddress("1.2.3.4");
+        MapRequest mapRequest = createMapRequest(eid);
+        MapReply mapReply = null;
+
+        testTTLBeforeRegister(mapRequest);
+
+        registerForTTL(eid);
+
+        testTTLAfterRegister(mapRequest);
+
+        ServiceReference r = bc.getServiceReference(ILispDAO.class.getName());
+        if (r != null) {
+            causeEntryToBeCleaned(r);
+            testTTLAfterClean(mapRequest);
+
+            northboundAddKey();
+            testTTLBeforeRegister(mapRequest);
+
+        }
+    }
+
+    private void testTTLAfterClean(MapRequest mapRequest) throws SocketTimeoutException {
+        MapReply mapReply;
+        sendMapRequest(mapRequest);
+        mapReply = receiveMapReply();
+        assertCorrectMapReplyTTLAndAction(mapReply, 1, Action.NativelyForward);
+    }
+
+    private void causeEntryToBeCleaned(ServiceReference r) {
+        ClusterDAOService clusterService = (ClusterDAOService) bc.getService(r);
+        clusterService.setTimeUnit(TimeUnit.NANOSECONDS);
+        clusterService.cleanOld();
+    }
+
+    private void testTTLAfterRegister(MapRequest mapRequest) throws SocketTimeoutException {
+        MapReply mapReply;
+        sendMapRequest(mapRequest);
+        mapReply = receiveMapReply();
+        assertEquals(LispAFIConvertor.toContainer(asIPAfiAddress("4.3.2.1")), mapReply.getEidToLocatorRecord().get(0).getLocatorRecord().get(0)
+                .getLispAddressContainer());
+        assertCorrectMapReplyTTLAndAction(mapReply, 254, Action.NoAction);
+    }
+
+    private void registerForTTL(LispIpv4Address eid) throws SocketTimeoutException {
+        MapRegister mapRegister = createMapRegister(eid);
+        sendMapRegister(mapRegister);
+        receiveMapNotify();
+    }
+
+    private void testTTLBeforeRegister(MapRequest mapRequest) throws SocketTimeoutException {
+        MapReply mapReply;
+        sendMapRequest(mapRequest);
+        mapReply = receiveMapReply();
+        assertCorrectMapReplyTTLAndAction(mapReply, 15, Action.NativelyForward);
+    }
+
+    private void assertCorrectMapReplyTTLAndAction(MapReply mapReply, int expectedTTL, Action expectedAction) {
+        assertEquals(expectedTTL, mapReply.getEidToLocatorRecord().get(0).getRecordTtl().byteValue());
+        assertEquals(expectedAction, mapReply.getEidToLocatorRecord().get(0).getAction());
+    }
+
+    private MapRegister createMapRegister(LispIpv4Address eid) {
+        MapRegisterBuilder mapRegisterbuilder = new MapRegisterBuilder();
+        mapRegisterbuilder.setWantMapNotify(true);
+        mapRegisterbuilder.setNonce((long) 8);
+        EidToLocatorRecordBuilder etlrBuilder = new EidToLocatorRecordBuilder();
+        etlrBuilder.setLispAddressContainer(LispAFIConvertor.toContainer(eid));
+        etlrBuilder.setMaskLength((short) 24);
+        etlrBuilder.setRecordTtl(254);
+        LocatorRecordBuilder recordBuilder = new LocatorRecordBuilder();
+        recordBuilder.setLispAddressContainer(LispAFIConvertor.toContainer(asIPAfiAddress("4.3.2.1")));
+        etlrBuilder.setLocatorRecord(new ArrayList<LocatorRecord>());
+        etlrBuilder.getLocatorRecord().add(recordBuilder.build());
+        mapRegisterbuilder.setEidToLocatorRecord(new ArrayList<EidToLocatorRecord>());
+        mapRegisterbuilder.getEidToLocatorRecord().add(etlrBuilder.build());
+        MapRegister mapRegister = mapRegisterbuilder.build();
+        return mapRegister;
+    }
+
+    private MapRequest createMapRequest(LispIpv4Address eid) {
+        MapRequestBuilder mapRequestBuilder = new MapRequestBuilder();
+        mapRequestBuilder.setNonce((long) 4);
+        mapRequestBuilder.setSourceEid(new SourceEidBuilder().setLispAddressContainer(
+                LispAFIConvertor.toContainer(new NoBuilder().setAfi((short) 0).build())).build());
+        mapRequestBuilder.setEidRecord(new ArrayList<EidRecord>());
+        mapRequestBuilder.getEidRecord().add(
+                new EidRecordBuilder().setMask((short) 32).setLispAddressContainer(LispAFIConvertor.toContainer(eid)).build());
+        mapRequestBuilder.setItrRloc(new ArrayList<ItrRloc>());
+        mapRequestBuilder.getItrRloc().add(
+                new ItrRlocBuilder().setLispAddressContainer(LispAFIConvertor.toContainer(asIPAfiAddress(ourAddress))).build());
+        MapRequest mr = mapRequestBuilder.build();
+        return mr;
+    }
+
     private MapReply receiveMapReply() throws SocketTimeoutException {
         return MapReplySerializer.getInstance().deserialize(ByteBuffer.wrap(receivePacket().getData()));
     }
@@ -1411,8 +1505,10 @@ public class MappingServiceIntegrationTest {
         Bundle b[] = bc.getBundles();
         for (Bundle element : b) {
             int state = element.getState();
+            logger.debug("Bundle:" + element.getSymbolicName() + ",v" + element.getVersion() + ", state:" + stateToString(state));
             if (state != Bundle.ACTIVE && state != Bundle.RESOLVED) {
-                System.out.println("Bundle:" + element.getSymbolicName() + " state:" + stateToString(state));
+                // System.out.println("Bundle:" + element.getSymbolicName() +
+                // " state:" + stateToString(state));
 
                 // UNCOMMENT to see why bundles didn't resolve!
 
diff --git a/mappingservice/integrationtest/src/test/resources/controller.config b/mappingservice/integrationtest/src/test/resources/controller.config
new file mode 100644 (file)
index 0000000..e49ba67
--- /dev/null
@@ -0,0 +1,23 @@
+//START OF CONFIG-LAST
+<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+<modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+    <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:cluster:store">prefix:dom-clustered-store-impl</type>
+        <name>cluster-data-store</name>
+    </module>
+</modules>
+</data>
+
+
+//END OF SNAPSHOT
+urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:cluster:store?module=odl-sal-dom-clustered-store-cfg&revision=2013-10-28
+urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom?module=opendaylight-md-sal-dom&revision=2013-10-28
+urn:opendaylight:params:xml:ns:yang:controller:config?module=config&revision=2013-04-05
+urn:ietf:params:netconf:capability:candidate:1.0
+urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring?module=ietf-netconf-monitoring&revision=2010-10-04
+urn:ietf:params:xml:ns:yang:rpc-context?module=rpc-context&revision=2013-06-17
+urn:ietf:params:xml:ns:yang:ietf-inet-types?module=ietf-inet-types&revision=2010-09-24
+urn:ietf:params:netconf:capability:rollback-on-error:1.0
+urn:ietf:params:xml:ns:yang:ietf-yang-types?module=ietf-yang-types&revision=2010-09-24
+urn:opendaylight:params:xml:ns:yang:controller:md:sal:common?module=opendaylight-md-sal-common&revision=2013-10-28
+//END OF CONFIG
index cae3a2979bd1a67b8b1cac03e0bcb25d87edbee1..e37e2ff0eff80e8f38a8f29e6e40dba584625ff1 100644 (file)
@@ -150,6 +150,7 @@ public class LispSouthboundPlugin extends AbstractBindingAwareProvider implement
     }
 
     public void onSessionInitiated(ProviderContext session) {
+        logger.info("LISP (RFC6830) Mapping Service is up!");
         synchronized (startLock) {
             if (!alreadyInit) {
                 alreadyInit = true;
index 915754abcf4a1bf33ed710cec95248937cae9f7f..898b44573a0d8642f0103389eb29db327f9be048 100644 (file)
@@ -21,7 +21,6 @@ import junitx.framework.ArrayAssert;
 import junitx.framework.Assert;
 
 import org.apache.commons.lang3.ArrayUtils;
-import org.apache.tomcat.util.buf.HexUtils;
 import org.jmock.api.Invocation;
 import org.junit.Before;
 import org.junit.Ignore;
@@ -126,7 +125,6 @@ public class LispSouthboundServiceTest extends BaseTestCase {
         mapReplyBuilder = new MapReplyBuilder();
         mapReplyBuilder.setEidToLocatorRecord(new ArrayList<EidToLocatorRecord>());
         mapReplyBuilder.setNonce((long) 0);
-        mapReplyBuilder.setAction(org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapReply.Action.NativelyForward);
         mapReplyBuilder.setEchoNonceEnabled(false);
         mapReplyBuilder.setProbe(true);
         mapReplyBuilder.setSecurityEnabled(true);
@@ -373,8 +371,6 @@ public class LispSouthboundServiceTest extends BaseTestCase {
         // XXX: test
         // byte[] notifyResult = testedLispService.handlePacket(dp).getData();
         byte[] notifyResult = lastMapNotifyPacket().getData();
-        System.out.println(HexUtils.toHexString(mapRegisterPacket));
-        System.out.println(HexUtils.toHexString(notifyResult));
         assertEquals(mapRegisterPacket.length, notifyResult.length);
 
     }
index 823cf5441c67dd8b72ea9ba5529768b03490d2d2..1d37e092258c71fa585509331e3d008cf1d7c4e1 100755 (executable)
@@ -42,6 +42,7 @@
                                                        org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.reencaphop
                                                </Export-Package>
                                                <Import-Package>
+                                                       com.google.common.collect,
                                                        org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924,
                                                        org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924,
                                                        org.opendaylight.yangtools.yang.binding,
index 3f5e5ce1d6cdb5d485b877ecf31da352ed144c91..cfbb62765d58e53b3ced65cb9aadfac5229f7aa9 100755 (executable)
        leaf probe {
                type boolean;
        }
-       leaf action {
-      type enumeration {
-          enum NoAction;
-          enum NativelyForward;
-          enum Drop;
-      }
-  }
        leaf nonce {
                type int64;
        }