<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>
<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>
<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,
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>
}
void unsetBindingAwareBroker(BindingAwareBroker bindingAwareBroker) {
- logger.info("BindingAwareBroker was unset in LispMappingService");
+ logger.debug("BindingAwareBroker was unset in LispMappingService");
}
public void basicInit(ILispDAO dao) {
}
void unsetLispDao(ILispDAO dao) {
- logger.info("LispDAO was unset in LispMappingService");
+ logger.debug("LispDAO was unset in LispMappingService");
mapServer = null;
mapResolver = null;
lispDao = null;
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;
private ScheduledExecutorService scheduler;
void setClusterContainerService(IClusterContainerServices s) {
- logger.debug("Cluster Service set");
this.clusterContainerService = s;
allocateCache();
retrieveCache();
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;
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;
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());
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());
}
}
}
+ private boolean didContainRLOCs(MappingServiceValue value) {
+ return value.getKey() == null;
+ }
+
private Map<String, ?> findMaskLocators(IMappingServiceKey key) {
int mask = key.getMask();
while (mask > 0) {
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());
}
}
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;
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();
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;
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) {
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));
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();
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();
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++) {
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())
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());
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;
@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();
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;
@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());
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));
}
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;
}
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;
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 {
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());
}
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
}
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
<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>
</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>
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(),
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(), //
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(), //
mavenBundle(ODL, "sal-broker-impl").versionAsInProject(), //
mavenBundle(ODL, "sal-connector-api").versionAsInProject(), //
+ mavenBundle(ODL, "config-api").versionAsInProject(), //
+ mavenBundle(ODL, "config-manager").versionAsInProject(), //
+
junitBundles());
}
@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";
}
+ @Test
public void mapRequestMapRegisterAndMapRequestTestTimeout() throws SocketTimeoutException {
LispIpv4Address eid = LispAFIConvertor.asIPAfiAddress("1.2.3.4");
.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()));
}
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!
--- /dev/null
+//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
}
public void onSessionInitiated(ProviderContext session) {
+ logger.info("LISP (RFC6830) Mapping Service is up!");
synchronized (startLock) {
if (!alreadyInit) {
alreadyInit = true;
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;
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);
// 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);
}
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,
leaf probe {
type boolean;
}
- leaf action {
- type enumeration {
- enum NoAction;
- enum NativelyForward;
- enum Drop;
- }
- }
leaf nonce {
type int64;
}