use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTest method testMultipleMappings.
private void testMultipleMappings() throws UnknownHostException {
final InstanceIdType iid = new InstanceIdType(1L);
// prefix from the intersection of NB and SB gaps
final String prefix1 = "1.1.127.10/32";
// prefix with existing mapping in NB
final String prefix2 = "1.1.200.255/32";
final String prefix3 = "1.3.255.255/32";
final MapRequest mapRequest = new MapRequestBuilder().setSmrInvoked(false).setEidItem(Lists.newArrayList(new EidItemBuilder().setEid(LispAddressUtil.asIpv4PrefixBinaryEid(prefix1, iid)).build(), new EidItemBuilder().setEid(LispAddressUtil.asIpv4PrefixBinaryEid(prefix2, iid)).build(), new EidItemBuilder().setEid(LispAddressUtil.asIpv4PrefixBinaryEid(prefix3, iid)).build())).build();
final MapReply mapReply = lms.handleMapRequest(mapRequest);
// expected result
final String resultPrefix1 = "1.1.64.0";
final Address resultNegMapping1 = new Ipv4PrefixBinaryBuilder().setIpv4AddressBinary(new Ipv4AddressBinary(InetAddress.getByName(resultPrefix1).getAddress())).setIpv4MaskLength((short) 18).build();
final String resultPrefix2 = "1.1.128.0";
final Address resultMapping2 = new Ipv4PrefixBinaryBuilder().setIpv4AddressBinary(new Ipv4AddressBinary(InetAddress.getByName(resultPrefix2).getAddress())).setIpv4MaskLength((short) 17).build();
final String resultPrefix3 = "1.3.0.0";
final Address resultNegMapping3 = new Ipv4PrefixBinaryBuilder().setIpv4AddressBinary(new Ipv4AddressBinary(InetAddress.getByName(resultPrefix3).getAddress())).setIpv4MaskLength((short) 16).build();
assertEquals(resultNegMapping1, mapReply.getMappingRecordItem().get(0).getMappingRecord().getEid().getAddress());
assertEquals(resultMapping2, mapReply.getMappingRecordItem().get(1).getMappingRecord().getEid().getAddress());
assertEquals(resultNegMapping3, mapReply.getMappingRecordItem().get(2).getMappingRecord().getEid().getAddress());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTest method testMapRegisterDoesntOverwritesNoSubkey.
public void testMapRegisterDoesntOverwritesNoSubkey() throws SocketTimeoutException {
cleanUP();
mapService.setMappingMerge(true);
Eid eid = LispAddressUtil.asIpv4PrefixBinaryEid("1.2.3.4/32");
Rloc rloc1Value = LispAddressUtil.asIpv4Rloc("4.3.2.1");
Rloc rloc2Value = LispAddressUtil.asIpv4Rloc("4.3.2.2");
MapReply mapReply = sendMapRegisterTwiceWithDiffrentValues(eid, rloc1Value, rloc2Value);
assertEquals(1, mapReply.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().size());
Rloc rloc1ReturnValueContainer = mapReply.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(0).getRloc();
Rloc rloc2ReturnValueContainer = mapReply.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(1).getRloc();
assertTrue((rloc1Value.equals(rloc1ReturnValueContainer) && rloc2Value.equals(rloc2ReturnValueContainer)) || (rloc1Value.equals(rloc2ReturnValueContainer) && rloc2Value.equals(rloc1ReturnValueContainer)));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply in project lispflowmapping by opendaylight.
the class MultiSiteScenario method verifyMappingRecord.
private MappingRecord verifyMappingRecord(MapReply mapReply) {
assertNotNull(mapReply);
final List<MappingRecordItem> mappingRecordItems = mapReply.getMappingRecordItem();
assertNotNull(mappingRecordItems);
assertEquals(1, mappingRecordItems.size());
final MappingRecordItem mappingRecordItem = mappingRecordItems.get(0);
assertNotNull(mappingRecordItem);
final MappingRecord mappingRecord = mappingRecordItem.getMappingRecord();
assertNotNull(mappingRecord);
return mappingRecord;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply in project lispflowmapping by opendaylight.
the class MultiSiteScenario method checkActionAndRloc.
boolean checkActionAndRloc(final Site dstSite, boolean expectedPingWorks, MapReply mapReplyFromSrcToDst, final Site... additionalSitesFromMapping) {
final MappingRecord mappingRecord = verifyMappingRecord(mapReplyFromSrcToDst);
final boolean isNotDroppendSrcDst = !MappingRecord.Action.Drop.equals(mappingRecord.getAction());
if (isPossibleAssertPingResultImmediately(expectedPingWorks, isNotDroppendSrcDst, "Drop action has appeared " + "during ping")) {
return true;
}
final List<LocatorRecord> locatorRecords = verifyLocatorRecordExists(mappingRecord);
for (Site expectedTargetSite : concatenateSites(dstSite, additionalSitesFromMapping)) {
boolean expectedTargetFound = false;
for (LocatorRecord locatorRecord : locatorRecords) {
if (expectedTargetSite.getRloc().equals(rlocToString(locatorRecord))) {
final byte[] ipv4AddressSrcDst = verifyIpv4Address(locatorRecord).getValue();
final byte[] rloc = InetAddresses.forString((expectedTargetSite.getRloc())).getAddress();
final boolean isRlocSrcDstEqual = Arrays.equals(ipv4AddressSrcDst, rloc);
if (isPossibleAssertPingResultImmediately(expectedPingWorks, isRlocSrcDstEqual, "Unexpected RLOC." + "Expected value " + rloc + ". Real value " + ipv4AddressSrcDst + ".")) {
return true;
}
final boolean isWeightEquals = expectedTargetSite.getWeight() == locatorRecord.getWeight();
if (isPossibleAssertPingResultImmediately(expectedPingWorks, isWeightEquals, "Weight isn't equal." + "Expected value " + expectedTargetSite.getWeight() + ". Value from mapping" + locatorRecord.getWeight() + ".")) {
return true;
}
final boolean isPriorityEquals = expectedTargetSite.getPriority() == locatorRecord.getPriority();
if (isPossibleAssertPingResultImmediately(expectedPingWorks, isPriorityEquals, "Priority isn't " + "equal. Expected value " + expectedTargetSite.getPriority() + ". Value from mapping" + locatorRecord.getPriority() + ".")) {
return true;
}
expectedTargetFound = true;
break;
}
}
if (isPossibleAssertPingResultImmediately(expectedPingWorks, expectedTargetFound, "Mapping for " + expectedTargetSite.getRloc() + " was expected but wasn't returned from mapping service." + expectedTargetFound)) {
return true;
}
}
return false;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply in project lispflowmapping by opendaylight.
the class MultiSiteScenario method emitMapRequestMessage.
private MapReply emitMapRequestMessage(final String siteFromEidPrefix, final String siteToEidPrefix, final InstanceIdType vniValue) {
final MapRequestBuilder mapRequestBuilder = new MapRequestBuilder();
final EidItemBuilder eidItemBuilder = new EidItemBuilder();
Eid dstEid = toEid(siteToEidPrefix, vniValue, IP_MASK);
eidItemBuilder.setEid(dstEid);
eidItemBuilder.setEidItemId(siteFromEidPrefix + siteToEidPrefix);
final List<EidItem> eidItem = Collections.singletonList(eidItemBuilder.build());
final Eid srcEid = MappingServiceIntegrationTestUtil.removePrefixIfNecessary(toEid(siteFromEidPrefix, vniValue, IP_MASK));
mapRequestBuilder.setSourceEid(new SourceEidBuilder().setEid(srcEid).build());
mapRequestBuilder.setEidItem(eidItem);
mapRequestBuilder.setItrRloc(MappingServiceIntegrationTestUtil.getDefaultItrRlocList(LispAddressUtil.asIpv4Rloc(ourAddress)));
mapRequestBuilder.setSmrInvoked(false);
return lms.handleMapRequest(mapRequestBuilder.build());
}
Aggregations