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");
}
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");
}
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());
}
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;
}
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);
}
}
}
Aggregations