Search in sources :

Example 71 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 DataStoreBackEnd method addXtrIdMapping.

// This method assumes that it is only called for southbound originated Map-Registers
public void addXtrIdMapping(XtrIdMapping mapping) {
    XtrId xtrId = mapping.getMappingRecord().getXtrId();
    Preconditions.checkNotNull(xtrId, "Make sure you only call addXtrIdMapping when the MappingRecord " + "contains an xTR-ID");
    if (LOG.isDebugEnabled()) {
        LOG.debug("MD-SAL: Adding mapping for {}, xTR-ID {}", LispAddressStringifier.getString(mapping.getMappingRecord().getEid()), xtrId);
    }
    InstanceIdentifier<XtrIdMapping> path = InstanceIdentifierUtil.createXtrIdMappingIid(mapping.getMappingRecord().getEid(), MappingOrigin.Southbound, xtrId);
    writePutTransaction(path, mapping, LogicalDatastoreType.OPERATIONAL, "Adding xTR-ID mapping to MD-SAL datastore failed");
}
Also used : XtrIdMapping(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.mapping.XtrIdMapping) XtrId(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.XtrId)

Example 72 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 DataStoreBackEnd method removeXtrIdMapping.

public void removeXtrIdMapping(XtrIdMapping mapping) {
    XtrId xtrId = mapping.getMappingRecord().getXtrId();
    Preconditions.checkNotNull(xtrId, "Make sure you only call addXtrIdMapping when the MappingRecord " + "contains an xTR-ID");
    if (LOG.isDebugEnabled()) {
        LOG.debug("MD-SAL: Removing mapping for {}, xTR-ID {}", LispAddressStringifier.getString(mapping.getMappingRecord().getEid()), xtrId);
    }
    InstanceIdentifier<XtrIdMapping> path = InstanceIdentifierUtil.createXtrIdMappingIid(mapping.getMappingRecord().getEid(), MappingOrigin.Southbound, xtrId);
    deleteTransaction(path, LogicalDatastoreType.OPERATIONAL, "Deleting xTR-ID mapping from MD-SAL datastore failed");
}
Also used : XtrIdMapping(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.mapping.XtrIdMapping) XtrId(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.XtrId)

Example 73 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 getMappingWithXtrId.

@Override
public Future<RpcResult<GetMappingWithXtrIdOutput>> getMappingWithXtrId(GetMappingWithXtrIdInput input) {
    Preconditions.checkNotNull(input, "get-mapping RPC input must be not null!");
    LOG.trace("RPC received to get the following mapping: " + input.toString());
    RpcResultBuilder<GetMappingWithXtrIdOutput> rpcResultBuilder;
    MappingData reply = mappingSystem.getMapping(null, convertToBinaryIfNecessary(input.getEid()), input.getXtrId());
    if (reply == null) {
        String message = "No mapping was found in the mapping database";
        rpcResultBuilder = RpcResultBuilder.<GetMappingWithXtrIdOutput>failed().withError(RpcError.ErrorType.APPLICATION, NOT_FOUND_TAG, message);
    } else {
        final MappingRecord convertedReply = convertFromBinaryIfNecessary(reply.getRecord());
        rpcResultBuilder = RpcResultBuilder.success(new GetMappingWithXtrIdOutputBuilder().setMappingRecord(convertedReply));
    }
    return Futures.immediateFuture(rpcResultBuilder.build());
}
Also used : GetMappingWithXtrIdOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetMappingWithXtrIdOutput) MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) GetMappingWithXtrIdOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetMappingWithXtrIdOutputBuilder)

Example 74 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 MapNotifySerializer method serialize.

public ByteBuffer serialize(MapNotify mapNotify) {
    int size = Length.HEADER_SIZE;
    if (mapNotify.getAuthenticationData() != null) {
        size += mapNotify.getAuthenticationData().length;
    }
    if (mapNotify.isXtrSiteIdPresent() != null && mapNotify.isXtrSiteIdPresent()) {
        size += org.opendaylight.lispflowmapping.lisp.serializer.MapRegisterSerializer.Length.XTRID_SIZE + org.opendaylight.lispflowmapping.lisp.serializer.MapRegisterSerializer.Length.SITEID_SIZE;
    }
    for (MappingRecordItem mappingRecord : mapNotify.getMappingRecordItem()) {
        size += MappingRecordSerializer.getInstance().getSerializationSize(mappingRecord.getMappingRecord());
    }
    ByteBuffer replyBuffer = ByteBuffer.allocate(size);
    replyBuffer.put((byte) ((byte) (MessageType.MapNotify.getIntValue() << 4) | ByteUtil.boolToBit(BooleanUtils.isTrue(mapNotify.isXtrSiteIdPresent()), Flags.XTRSITEID)));
    replyBuffer.position(replyBuffer.position() + Length.RES);
    replyBuffer.put(ByteUtil.boolToBit(BooleanUtils.isTrue(mapNotify.isMergeEnabled()), Flags.MERGE_ENABLED));
    if (mapNotify.getMappingRecordItem() != null) {
        replyBuffer.put((byte) mapNotify.getMappingRecordItem().size());
    } else {
        replyBuffer.put((byte) 0);
    }
    replyBuffer.putLong(NumberUtil.asLong(mapNotify.getNonce()));
    replyBuffer.putShort(NumberUtil.asShort(mapNotify.getKeyId()));
    if (mapNotify.getAuthenticationData() != null) {
        replyBuffer.putShort((short) mapNotify.getAuthenticationData().length);
        replyBuffer.put(mapNotify.getAuthenticationData());
    } else {
        replyBuffer.putShort((short) 0);
    }
    if (mapNotify.getMappingRecordItem() != null) {
        for (MappingRecordItem mappingRecord : mapNotify.getMappingRecordItem()) {
            MappingRecordSerializer.getInstance().serialize(replyBuffer, mappingRecord.getMappingRecord());
        }
    }
    if (mapNotify.isXtrSiteIdPresent() != null && mapNotify.isXtrSiteIdPresent()) {
        replyBuffer.put(mapNotify.getXtrId().getValue());
        replyBuffer.put(mapNotify.getSiteId().getValue());
    }
    replyBuffer.clear();
    return replyBuffer;
}
Also used : MappingRecordItem(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem) ByteBuffer(java.nio.ByteBuffer)

Example 75 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 MappingRecordSerializer method serialize.

public void serialize(ByteBuffer replyBuffer, MappingRecord record) {
    replyBuffer.putInt(NumberUtil.asInt(record.getRecordTtl()));
    if (record.getLocatorRecord() != null) {
        replyBuffer.put((byte) record.getLocatorRecord().size());
    } else {
        replyBuffer.put((byte) 0);
    }
    if (record.getEid() != null && MaskUtil.getMaskForAddress(record.getEid().getAddress()) != -1) {
        replyBuffer.put((byte) NumberUtil.asShort(MaskUtil.getMaskForAddress(record.getEid().getAddress())));
    } else {
        replyBuffer.put((byte) 0);
    }
    Action act = Action.NoAction;
    if (record.getAction() != null) {
        act = record.getAction();
    }
    replyBuffer.put((byte) ((act.getIntValue() << 5) | ByteUtil.boolToBit(BooleanUtils.isTrue(record.isAuthoritative()), Flags.AUTHORITATIVE)));
    replyBuffer.position(replyBuffer.position() + Length.RESERVED);
    replyBuffer.putShort(NumberUtil.asShort(record.getMapVersion()));
    if (record.getEid() != null && record.getEid().getAddress() != null) {
        LispAddressSerializer.getInstance().serialize(replyBuffer, record.getEid());
    }
    if (record.getLocatorRecord() != null) {
        for (LocatorRecord locatorRecord : record.getLocatorRecord()) {
            LocatorRecordSerializer.getInstance().serialize(replyBuffer, locatorRecord);
        }
    }
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord.Action) LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)

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