use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ExplicitLocatorPath in project lispflowmapping by opendaylight.
the class MappingSystemTest method getMappingTest_NbFirst_withServicePathDestinationAddress_singleELPLocatorRecord_IndexOutOfBounds.
/**
* Tests {@link MappingSystem#getMapping} method with ServicePath type dst address and single ExplicitLocatorPath
* type locator record. Service index out of bounds. Returns the original mapping.
*/
@Test
public void getMappingTest_NbFirst_withServicePathDestinationAddress_singleELPLocatorRecord_IndexOutOfBounds() {
final MappingRecord mappingRecord = getDefaultMappingRecordBuilder().setLocatorRecord(Lists.newArrayList(getDefaultLocatorRecordBuilder().setRloc(getELPTypeRloc()).build())).build();
final MappingData mappingData = getDefaultMappingData(mappingRecord);
Mockito.when(pmcMock.getMapping(EID_IPV4_SRC, EID_SERVICE_PATH_INDEX_OOB)).thenReturn(mappingData);
assertEquals(mappingData, mappingSystem.getMapping(EID_IPV4_SRC, EID_SERVICE_PATH_INDEX_OOB));
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ExplicitLocatorPath in project lispflowmapping by opendaylight.
the class MapResolver method updateLocators.
// Process locators according to configured policy
private MappingRecord updateLocators(MappingRecord mapping, List<ItrRloc> itrRlocs) {
// no fixing if elpPolicy is default
if (elpPolicy.equalsIgnoreCase("default")) {
return mapping;
}
List<LocatorRecord> locatorRecords = mapping.getLocatorRecord();
// if no updated is needed, just return the mapping
if (!locatorsNeedFixing(locatorRecords)) {
return mapping;
}
MappingRecordBuilder recordBuilder = new MappingRecordBuilder(mapping);
recordBuilder.setLocatorRecord(new ArrayList<LocatorRecord>());
try {
for (LocatorRecord record : locatorRecords) {
Rloc container = record.getRloc();
// done
if ((!(container.getAddress() instanceof ExplicitLocatorPath)) || elpPolicy.equalsIgnoreCase("default") || itrRlocs == null) {
recordBuilder.getLocatorRecord().add(new LocatorRecordBuilder().setLocalLocator(record.isLocalLocator()).setRlocProbed(record.isRlocProbed()).setWeight(record.getWeight()).setPriority(record.getPriority()).setMulticastWeight(record.getMulticastWeight()).setMulticastPriority(record.getMulticastPriority()).setRouted(record.isRouted()).setRloc(container).setLocatorId(record.getLocatorId()).build());
continue;
}
ExplicitLocatorPath teAddress = ((ExplicitLocatorPath) container.getAddress());
SimpleAddress nextHop = getNextELPHop(teAddress, itrRlocs);
if (nextHop != null) {
java.lang.Short priority = record.getPriority();
if (elpPolicy.equalsIgnoreCase("both")) {
recordBuilder.getLocatorRecord().add(new LocatorRecordBuilder().setLocalLocator(record.isLocalLocator()).setRlocProbed(record.isRlocProbed()).setWeight(record.getWeight()).setPriority(record.getPriority()).setMulticastWeight(record.getMulticastWeight()).setMulticastPriority(record.getMulticastPriority()).setRouted(record.isRouted()).setRloc(container).setLocatorId(record.getLocatorId()).build());
// XXX Complex cases like several ELPs with different priorities are not handled
if (priority != 254 || priority != 255) {
priority++;
}
}
// Build and add the simple RLOC
recordBuilder.getLocatorRecord().add(new LocatorRecordBuilder().setLocalLocator(record.isLocalLocator()).setRlocProbed(record.isRlocProbed()).setWeight(record.getWeight()).setPriority(priority).setMulticastWeight(record.getMulticastWeight()).setMulticastPriority(record.getMulticastPriority()).setRouted(record.isRouted()).setRloc(LispAddressUtil.toRloc(nextHop)).setLocatorId(record.getLocatorId()).build());
}
}
} catch (ClassCastException cce) {
LOG.error("Class Cast Exception while building EidToLocatorRecord: {}", ExceptionUtils.getStackTrace(cce));
}
return recordBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ExplicitLocatorPath in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTest method registerAndQuery__TrafficEngineering.
public void registerAndQuery__TrafficEngineering() throws SocketTimeoutException {
cleanUP();
String macString = "01:02:03:04:05:06";
String ipString = "10.20.255.30";
HopBuilder hopBuilder = new HopBuilder();
hopBuilder.setAddress(new SimpleAddress(new IpAddress(new Ipv4Address(ipString))));
hopBuilder.setLrsBits(new LrsBits(true, false, true));
Hop hop1 = hopBuilder.build();
hopBuilder.setAddress(new SimpleAddress(new MacAddress(macString)));
hopBuilder.setLrsBits(new LrsBits(false, true, false));
Hop hop2 = hopBuilder.build();
ExplicitLocatorPathBuilder elpBuilder = new ExplicitLocatorPathBuilder();
elpBuilder.setHop(new ArrayList<Hop>());
elpBuilder.getHop().add(hop1);
elpBuilder.getHop().add(hop2);
EidBuilder eb = new EidBuilder();
eb.setAddressType(ExplicitLocatorPathLcaf.class);
eb.setVirtualNetworkId(null);
eb.setAddress(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ExplicitLocatorPathBuilder().setExplicitLocatorPath(elpBuilder.build()).build());
MapReply reply = registerAddressAndQuery(eb.build());
assertEquals(ExplicitLocatorPathLcaf.class, reply.getMappingRecordItem().get(0).getMappingRecord().getEid().getAddressType());
ExplicitLocatorPath receivedAddress = (ExplicitLocatorPath) reply.getMappingRecordItem().get(0).getMappingRecord().getEid().getAddress();
Hop receivedHop1 = (Hop) receivedAddress.getExplicitLocatorPath().getHop().get(0);
Hop receivedHop2 = (Hop) receivedAddress.getExplicitLocatorPath().getHop().get(1);
assertEquals(true, receivedHop1.getLrsBits().isLookup());
assertEquals(false, receivedHop1.getLrsBits().isRlocProbe());
assertEquals(true, receivedHop1.getLrsBits().isStrict());
assertEquals(false, receivedHop2.getLrsBits().isLookup());
assertEquals(true, receivedHop2.getLrsBits().isRlocProbe());
assertEquals(false, receivedHop2.getLrsBits().isStrict());
assertNotNull(receivedHop1.getAddress().getIpAddress().getIpv4Address());
assertNotNull(receivedHop2.getAddress().getMacAddress());
assertEquals(ipString, receivedHop1.getAddress().getIpAddress().getIpv4Address().getValue());
assertEquals(macString, receivedHop2.getAddress().getMacAddress().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ExplicitLocatorPath 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);
}
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ExplicitLocatorPath in project lispflowmapping by opendaylight.
the class ExplicitLocatorPathSerializerTest method deserialize__NoAddresses.
@Test
public void deserialize__NoAddresses() throws Exception {
Rloc address = LispAddressSerializer.getInstance().deserializeRloc(hexToByteBuffer(//
"40 03 00 00 " + "0A 00 00 00 "));
assertEquals(ExplicitLocatorPathLcaf.class, address.getAddressType());
ExplicitLocatorPath elp = (ExplicitLocatorPath) address.getAddress();
List<Hop> hops = elp.getExplicitLocatorPath().getHop();
assertEquals(0, hops.size());
}
Aggregations