Search in sources :

Example 31 with MappingRecord

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord in project lispflowmapping by opendaylight.

the class MappingService method getMapping.

@Override
public Future<RpcResult<GetMappingOutput>> getMapping(GetMappingInput input) {
    Preconditions.checkNotNull(input, "get-mapping RPC input must be not null!");
    LOG.trace("RPC received to get the following mapping: " + input.toString());
    RpcResultBuilder<GetMappingOutput> rpcResultBuilder;
    MappingData reply = mappingSystem.getMapping(convertToBinaryIfNecessary(input.getEid()));
    if (reply == null) {
        String message = "No mapping was found in the mapping database";
        rpcResultBuilder = RpcResultBuilder.<GetMappingOutput>failed().withError(RpcError.ErrorType.APPLICATION, NOT_FOUND_TAG, message);
    } else {
        final MappingRecord convertedReply = convertFromBinaryIfNecessary(reply.getRecord());
        rpcResultBuilder = RpcResultBuilder.success(new GetMappingOutputBuilder().setMappingRecord(convertedReply));
    }
    return Futures.immediateFuture(rpcResultBuilder.build());
}
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) GetMappingOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetMappingOutputBuilder) GetMappingOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetMappingOutput)

Example 32 with MappingRecord

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord in project lispflowmapping by opendaylight.

the class MappingSystem method notifyChildren.

private void notifyChildren(Eid eid, MappingRecord mapping, MappingChange mappingChange) {
    // Update/created only happens for NB mappings. We assume no overlapping prefix support for NB mappings - so
    // this NB mapping should not have any children. Both for NB first and NB&SB cases all subscribers for SB
    // prefixes that are equal or more specific to this NB prefix have to be notified of the potential change.
    // Each subscriber is notified for the prefix that it is currently subscribed to, and MS should return to them
    // a Map-Reply with the same prefix and update mapping in cases of EID_INTERSECTION_RLOC_NB_FIRST which is a
    // new option we are creating TODO
    Set<Eid> childPrefixes = getSubtree(MappingOrigin.Southbound, eid);
    if (childPrefixes == null || childPrefixes.isEmpty()) {
        return;
    }
    childPrefixes.remove(eid);
    for (Eid prefix : childPrefixes) {
        Set<Subscriber> subscribers = getSubscribers(prefix);
        // No reason to send a notification when no subscribers exist
        if (subscribers != null) {
            publishNotification(mapping, prefix, subscribers, null, mappingChange);
        }
    }
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) Subscriber(org.opendaylight.lispflowmapping.interfaces.dao.Subscriber)

Example 33 with MappingRecord

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord 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 34 with MappingRecord

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord in project lispflowmapping by opendaylight.

the class MappingDataListener method convertToBinaryIfNecessary.

private static Mapping convertToBinaryIfNecessary(Mapping mapping) {
    MappingRecord originalRecord = mapping.getMappingRecord();
    List<LocatorRecord> originalLocators = originalRecord.getLocatorRecord();
    List<LocatorRecord> convertedLocators = null;
    if (originalLocators != null) {
        // If convertedLocators is non-null, while originalLocators is also non-null, conversion has been made
        convertedLocators = convertToBinaryIfNecessary(originalLocators);
    }
    if (LispAddressUtil.addressNeedsConversionToBinary(originalRecord.getEid().getAddress()) || (originalLocators != null && convertedLocators != null)) {
        MappingRecordBuilder mrb = new MappingRecordBuilder(originalRecord);
        mrb.setEid(LispAddressUtil.convertToBinary(originalRecord.getEid()));
        if (convertedLocators != null) {
            mrb.setLocatorRecord(convertedLocators);
        }
        return new MappingBuilder(mapping).setMappingRecord(mrb.build()).build();
    }
    return mapping;
}
Also used : MappingBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.MappingBuilder) MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)

Example 35 with MappingRecord

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord in project lispflowmapping by opendaylight.

the class LispSouthboundHandlerTest method mapRegister__Ipv6Rloc.

@Test
public void mapRegister__Ipv6Rloc() throws Exception {
    // P bit (Proxy-Map-Reply): Set
    // M bit (Want-Map-Notify): Set
    // Record Counter: 1
    // Nonce: 0
    // Key ID: 1
    // AuthLength: 20
    // Authentication Data: 5bc4d44a57e2a55d577a6f89779c004f5da713fb
    // EID prefix: 2610:d0:ffff:192::1/128, TTL: 10, Authoritative,
    // No-Action
    // Local RLOC: 10.0.58.156, Reachable, Priority/Weight: 1/100, Multicast
    // Priority/Weight: 255/0
    mapRegisterPacket = extractWSUdpByteArray("0000   00 0c 29 34 3e 1b 00 0c 29 f6 d6 0d 08 00 45 00 " + "0010   00 68 00 00 40 00 40 11 ea c3 0a 00 3a 9c 0a 00 " + "0020   01 26 10 f6 10 f6 00 54 f5 9a 38 00 03 01 00 00 " + "0030   00 00 00 00 00 00 00 01 00 14 22 97 ff 61 ec d8 " + "0040   0f 91 c6 c4 01 ef 7f bb 77 58 39 5c 92 23 00 00 " + "0050   00 0a 01 80 10 00 00 00 00 02 26 10 00 d0 ff ff " + "0060   01 92 00 00 00 00 00 00 00 01 01 64 ff 00 00 05 " + "0070   00 01 0a 00 3a 9c");
    ArgumentCaptor<AddMapping> captor = ArgumentCaptor.forClass(AddMapping.class);
    handleMapRegisterPacket(mapRegisterPacket);
    Mockito.verify(mockLispSouthboundPlugin).sendNotificationIfPossible(captor.capture());
    MappingRecord eidToLocatorRecord = captor.getValue().getMapRegister().getMappingRecordItem().get(0).getMappingRecord();
    assertEquals(LispAddressUtil.asIpv6PrefixBinaryEid("2610:d0:ffff:192:0:0:0:1/128"), eidToLocatorRecord.getEid());
    assertEquals(Ipv6PrefixBinaryAfi.class, eidToLocatorRecord.getEid().getAddressType());
    assertEquals(LispAddressUtil.asIpv4Rloc("10.0.58.156"), eidToLocatorRecord.getLocatorRecord().get(0).getRloc());
}
Also used : AddMapping(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping) MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) Test(org.junit.Test)

Aggregations

MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)56 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)31 Test (org.junit.Test)28 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)22 MappingRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder)11 GotMapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply)10 MapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply)10 LocatorRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)10 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)9 MappingRecordItem (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem)6 MappingBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.MappingBuilder)6 ArrayList (java.util.ArrayList)5 Rloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc)5 EidUri (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.EidUri)5 Subscriber (org.opendaylight.lispflowmapping.interfaces.dao.Subscriber)4 InstanceIdType (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.InstanceIdType)4 AddMapping (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping)4 XtrId (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.XtrId)4 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)3 SourceDestKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey)3