Search in sources :

Example 6 with ExplicitLocatorPath

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()));
}
Also used : Rloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc) Hop(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.explicit.locator.path.Hop) ExplicitLocatorPath(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ExplicitLocatorPath) Test(org.junit.Test)

Example 7 with ExplicitLocatorPath

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());
}
Also used : Rloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc) Hop(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.explicit.locator.path.Hop) ExplicitLocatorPath(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ExplicitLocatorPath) Test(org.junit.Test)

Example 8 with ExplicitLocatorPath

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;
    }
}
Also used : LocatorRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder) Ipv6(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) Ipv4(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4) Rloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc) LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) List(java.util.List) ArrayList(java.util.ArrayList) SimpleAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress) ExplicitLocatorPath(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ExplicitLocatorPath)

Example 9 with ExplicitLocatorPath

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;
}
Also used : ItrRloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc) NoAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.NoAddress) Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address) SimpleAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress) Hop(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.explicit.locator.path.Hop) SimpleAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)

Example 10 with ExplicitLocatorPath

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()));
}
Also used : MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) Ipv4Binary(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4Binary) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

Hop (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.explicit.locator.path.Hop)9 ExplicitLocatorPath (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ExplicitLocatorPath)8 Test (org.junit.Test)6 Rloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc)6 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)4 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)3 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)2 LrsBits (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.explicit.locator.path.Hop.LrsBits)2 LocatorRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)2 LocatorRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder)2 MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)2 MappingRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder)2 ItrRloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)1 Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address)1 Ipv4 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4)1 Ipv6 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6)1