Search in sources :

Example 1 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_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));
}
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) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 2 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 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();
}
Also used : LocatorRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) Rloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc) ItrRloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc) SimpleAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress) LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord) ExplicitLocatorPath(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ExplicitLocatorPath)

Example 3 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 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());
}
Also used : 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) HopBuilder(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.HopBuilder) MapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply) GotMapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply) 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) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) ExplicitLocatorPathBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.ExplicitLocatorPathBuilder) SourceEidBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.SourceEidBuilder) EidBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.EidBuilder) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) SimpleAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) ExplicitLocatorPath(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ExplicitLocatorPath)

Example 4 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 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);
    }
}
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) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) Test(org.junit.Test)

Example 5 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__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());
}
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)

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