use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMappingBuilder in project lispflowmapping by opendaylight.
the class LispSouthboundHandler method handleMapRegister.
@SuppressWarnings("checkstyle:IllegalCatch")
private void handleMapRegister(ByteBuffer inBuffer, InetAddress sourceAddress, int port) {
try {
Map.Entry<MapRegisterCacheKey, byte[]> artificialEntry = null;
MapRegisterCacheKey cacheKey = null;
MapRegisterCacheValue cacheValue = null;
if (lispSbPlugin.isMapRegisterCacheEnabled()) {
artificialEntry = MapRegisterPartialDeserializer.deserializePartially(inBuffer, sourceAddress);
cacheKey = artificialEntry == null ? null : artificialEntry.getKey();
cacheValue = resolveCacheValue(artificialEntry);
}
if (cacheValue != null) {
lispSbPlugin.getStats().incrementCacheHits();
MapRegisterCacheMetadata mapRegisterMeta = cacheValue.getMapRegisterCacheMetadata();
LOG.debug("Map register message site-ID: {} xTR-ID: {} from cache.", mapRegisterMeta.getSiteId(), mapRegisterMeta.getXtrId());
cacheValue = refreshEntry(cacheKey);
if (cacheValue != null) {
lispSbPlugin.sendNotificationIfPossible(createMappingKeepAlive(cacheValue));
if (cacheValue.getMapRegisterCacheMetadata().isWantMapNotify()) {
sendMapNotifyMsg(inBuffer, sourceAddress, port, cacheValue);
}
}
} else {
lispSbPlugin.getStats().incrementCacheMisses();
MapRegister mapRegister = MapRegisterSerializer.getInstance().deserialize(inBuffer, sourceAddress);
MappingAuthkey mappingAuthkey = null;
if (authenticationEnabled) {
mappingAuthkey = tryToAuthenticateMessage(mapRegister, inBuffer);
if (mappingAuthkey == null) {
return;
}
}
AddMappingBuilder addMappingBuilder = new AddMappingBuilder();
addMappingBuilder.setMapRegister(LispNotificationHelper.convertMapRegister(mapRegister));
TransportAddressBuilder transportAddressBuilder = new TransportAddressBuilder();
transportAddressBuilder.setIpAddress(LispNotificationHelper.getIpAddressBinaryFromInetAddress(sourceAddress));
transportAddressBuilder.setPort(new PortNumber(port));
addMappingBuilder.setTransportAddress(transportAddressBuilder.build());
lispSbPlugin.sendNotificationIfPossible(addMappingBuilder.build());
if (artificialEntry != null) {
final MapRegisterCacheMetadataBuilder cacheMetadataBldNew = new MapRegisterCacheMetadataBuilder();
cacheMetadataBldNew.setEidLispAddress(provideEidPrefixesFromMessage(mapRegister));
cacheMetadataBldNew.setXtrId(mapRegister.getXtrId());
cacheMetadataBldNew.setSiteId(mapRegister.getSiteId());
cacheMetadataBldNew.setWantMapNotify(mapRegister.isWantMapNotify());
cacheMetadataBldNew.setMergeEnabled(mapRegister.isMergeEnabled());
cacheMetadataBldNew.setTimestamp(System.currentTimeMillis());
final MapRegisterCacheValueBuilder cacheValueBldNew = new MapRegisterCacheValueBuilder();
cacheValueBldNew.setPacketData(artificialEntry.getValue());
cacheValueBldNew.setMappingAuthkey(mappingAuthkey);
cacheValueBldNew.setMapRegisterCacheMetadata(cacheMetadataBldNew.build());
lispSbPlugin.getMapRegisterCache().addEntry(cacheKey, cacheValueBldNew.build());
}
}
} catch (RuntimeException re) {
throw new LispMalformedPacketException("Couldn't deserialize Map-Register (len=" + inBuffer.capacity() + ")", re);
} catch (InterruptedException e) {
LOG.warn("Notification publication interrupted!");
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMappingBuilder in project lispflowmapping by opendaylight.
the class LispNotificationHelperTest method getDefaultAddMapping.
private static AddMapping getDefaultAddMapping(boolean isXtrSiteIdPresent) {
final MappingRecordItem mappingRecordItem_1 = new MappingRecordItemBuilder().setMappingRecord(new MappingRecordBuilder().setEid(EID_IPV4).build()).build();
final MappingRecordItem mappingRecordItem_2 = new MappingRecordItemBuilder().setMappingRecord(new MappingRecordBuilder().setEid(EID_IPV6).build()).build();
final MapRegisterBuilder mapRegisterBuilder = new MapRegisterBuilder().setMappingRecordItem(Lists.newArrayList(mappingRecordItem_1, mappingRecordItem_2)).setXtrSiteIdPresent(isXtrSiteIdPresent).setSiteId(SITE_ID);
return new AddMappingBuilder().setMapRegister(mapRegisterBuilder.build()).build();
}
Aggregations