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__Simple.
@Test
public void deserialize__Simple() throws Exception {
Rloc address = LispAddressSerializer.getInstance().deserializeRloc(hexToByteBuffer(//
"40 03 00 00 " + //
"0A 00 00 10 " + // IPv4
"00 00 00 01 AA BB CC DD " + // IPv4
"00 00 00 01 11 22 33 44"));
assertEquals(ExplicitLocatorPathLcaf.class, address.getAddressType());
ExplicitLocatorPath elp = (ExplicitLocatorPath) address.getAddress();
List<Hop> hops = elp.getExplicitLocatorPath().getHop();
assertEquals(2, hops.size());
assertEquals("170.187.204.221", String.valueOf(hops.get(0).getAddress().getValue()));
assertEquals("17.34.51.68", String.valueOf(hops.get(1).getAddress().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 ExplicitLocatorPathSerializerTest method deserialize__Bits.
@Test
public void deserialize__Bits() throws Exception {
Rloc address = LispAddressSerializer.getInstance().deserializeRloc(hexToByteBuffer(//
"40 03 00 00 " + //
"0A 00 00 10 " + // IPv4
"00 05 00 01 AA BB CC DD " + // IPv4
"00 02 00 01 11 22 33 44"));
assertEquals(ExplicitLocatorPathLcaf.class, address.getAddressType());
ExplicitLocatorPath elp = (ExplicitLocatorPath) address.getAddress();
List<Hop> hops = elp.getExplicitLocatorPath().getHop();
assertEquals(2, hops.size());
assertEquals("170.187.204.221", String.valueOf(hops.get(0).getAddress().getValue()));
assertEquals(true, hops.get(0).getLrsBits().isLookup().booleanValue());
assertEquals(false, hops.get(0).getLrsBits().isRlocProbe().booleanValue());
assertEquals(true, hops.get(0).getLrsBits().isStrict().booleanValue());
assertEquals("17.34.51.68", String.valueOf(hops.get(1).getAddress().getValue()));
assertEquals(false, hops.get(1).getLrsBits().isLookup().booleanValue());
assertEquals(true, hops.get(1).getLrsBits().isRlocProbe().booleanValue());
assertEquals(false, hops.get(1).getLrsBits().isStrict().booleanValue());
}
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 MappingSystem method updateServicePathMappingRecord.
private MappingData updateServicePathMappingRecord(MappingData mappingData, Eid eid) {
// keep properties of original record
MappingRecordBuilder recordBuilder = new MappingRecordBuilder(mappingData.getRecord());
recordBuilder.setLocatorRecord(new ArrayList<LocatorRecord>());
// there should only be one locator record
if (mappingData.getRecord().getLocatorRecord().size() != 1) {
LOG.warn("MappingRecord associated to ServicePath EID has more than one locator!");
return mappingData;
}
LocatorRecord locatorRecord = mappingData.getRecord().getLocatorRecord().get(0);
long serviceIndex = ((ServicePath) eid.getAddress()).getServicePath().getServiceIndex();
int index = LispAddressUtil.STARTING_SERVICE_INDEX - (int) serviceIndex;
Rloc rloc = locatorRecord.getRloc();
if (rloc.getAddress() instanceof Ipv4 || rloc.getAddress() instanceof Ipv6) {
if (index != 0) {
LOG.warn("Service Index should be 255 for simple IP RLOCs!");
}
return mappingData;
} else if (rloc.getAddress() instanceof ExplicitLocatorPath) {
ExplicitLocatorPath elp = (ExplicitLocatorPath) rloc.getAddress();
List<Hop> hops = elp.getExplicitLocatorPath().getHop();
if (index < 0 || index > hops.size()) {
LOG.warn("Service Index out of bounds!");
return mappingData;
}
SimpleAddress nextHop = hops.get(index).getAddress();
LocatorRecordBuilder lrb = new LocatorRecordBuilder(locatorRecord);
lrb.setRloc(LispAddressUtil.toRloc(nextHop));
recordBuilder.getLocatorRecord().add(lrb.build());
return new MappingData(recordBuilder.build());
} else {
LOG.warn("Nothing to do with ServicePath mapping record");
return mappingData;
}
}
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 getNextELPHop.
private SimpleAddress getNextELPHop(ExplicitLocatorPath elp, List<ItrRloc> itrRlocs) {
SimpleAddress nextHop = null;
List<Hop> hops = elp.getExplicitLocatorPath().getHop();
if (hops != null && hops.size() > 0) {
// By default we return the first hop
nextHop = hops.get(0).getAddress();
for (Hop hop : hops) {
Address hopAddress = LispAddressUtil.addressFromSimpleAddress(hop.getAddress());
for (ItrRloc itrRloc : itrRlocs) {
if (itrRloc.getRloc().getAddress().equals(hopAddress)) {
int iterator = hops.indexOf(hop);
if (iterator < hops.size() - 1) {
nextHop = hops.get(iterator + 1).getAddress();
return nextHop;
}
}
}
}
}
return nextHop;
}
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.
/**
* Tests {@link MappingSystem#getMapping} method with ServicePath type dst address and single ExplicitLocatorPath
* type locator record.
*/
@Test
public void getMappingTest_NbFirst_withServicePathDestinationAddress_singleELPLocatorRecord() throws UnknownHostException {
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)).thenReturn(mappingData);
final MappingData result = (MappingData) mappingSystem.getMapping(EID_IPV4_SRC, EID_SERVICE_PATH);
final Ipv4Binary ipv4Result = (Ipv4Binary) result.getRecord().getLocatorRecord().get(0).getRloc().getAddress();
assertTrue(Arrays.equals(InetAddress.getByName(IPV4_STRING_3).getAddress(), ipv4Result.getIpv4Binary().getValue()));
}
Aggregations