use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.InstanceIdType in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTest method insertNBMappings.
private void insertNBMappings(long iid, String... prefixes) {
LOG.debug("Adding Northbound mappings in VNI {} for prefixes: {}", iid, prefixes);
final InstanceIdType iiType = new InstanceIdType(iid);
for (String prefix : prefixes) {
MappingRecord record = newMappingRecord(prefix, iiType);
mapService.addMapping(MappingOrigin.Northbound, record.getEid(), null, new MappingData(record));
}
sleepForMilliseconds(100);
MappingServiceIntegrationTestUtil.printMapCacheState(mapService);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.InstanceIdType 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.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.InstanceIdType 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());
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.InstanceIdType in project lispflowmapping by opendaylight.
the class LispAddressUtilTest method toEid_distinguishedName.
/**
* Test
* - {@link LispAddressUtil#toEid(DistinguishedNameType, InstanceIdType)}
* - {@link LispAddressUtil#asDistinguishedNameEid(String)}
* - {@link LispAddressUtil#asDistinguishedNameEid(String, long)}
* methods with various input.
*/
@Test
public void toEid_distinguishedName() {
Eid eidFromDistinguishedName = LispAddressUtil.toEid(DISTINGUISHED_NAME_TYPE_TEST, INSTANCE_ID_TYPE_TEST);
verifyToEidWithDistinguishedName(eidFromDistinguishedName, true);
eidFromDistinguishedName = LispAddressUtil.asDistinguishedNameEid(DISTINGUISHED_NAME_TYPE_VALUE_TEST);
verifyToEidWithDistinguishedName(eidFromDistinguishedName, false);
eidFromDistinguishedName = LispAddressUtil.asDistinguishedNameEid(DISTINGUISHED_NAME_TYPE_VALUE_WITH_MAC_TEST, INSTANCE_ID_TYPE_VALUE_TEST);
verifyToEidWithMacAddress(eidFromDistinguishedName, true);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.InstanceIdType in project lispflowmapping by opendaylight.
the class LispAddressUtilTest method asTeLcafRloc.
/**
* Tests {@link LispAddressUtil#asSrcDstEid(SourceDestKey, InstanceIdType)} method.
*/
@Test
public void asTeLcafRloc() {
final List<IpAddress> ipAddresses = Arrays.asList(IP_ADDRESS_IPV4_TEST, IP_ADDRESS_IPV6_TEST);
final Rloc rloc = LispAddressUtil.asTeLcafRloc(ipAddresses);
assertNotNull(rloc);
assertEquals(ExplicitLocatorPathLcaf.class, rloc.getAddressType());
final List<Hop> hops = ((ExplicitLocatorPath) rloc.getAddress()).getExplicitLocatorPath().getHop();
assertEquals(hops.size(), ipAddresses.size());
for (IpAddress ipAddress : ipAddresses) {
assertTrue("Ip address " + ipAddress + "should be part of hops list.", isIpAddressInHops(ipAddress, hops));
}
for (Hop hop : hops) {
final Hop.LrsBits lrsBits = hop.getLrsBits();
assertFalse(lrsBits.isLookup());
assertFalse(lrsBits.isRlocProbe());
assertFalse(lrsBits.isStrict());
final IpAddress ipAddressFromHop = hop.getAddress().getIpAddress();
assertNotNull(ipAddressFromHop);
}
}
Aggregations