import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.opendaylight.controller.md.sal.binding.api.NotificationService;
-import org.opendaylight.lispflowmapping.implementation.authentication.LispAuthenticationUtil;
import org.opendaylight.lispflowmapping.implementation.config.ConfigIni;
import org.opendaylight.lispflowmapping.interfaces.dao.SubKeys;
import org.opendaylight.lispflowmapping.interfaces.dao.SubscriberRLOC;
import org.opendaylight.lispflowmapping.lisp.util.MapNotifyBuilderHelper;
import org.opendaylight.lispflowmapping.lisp.util.MapRequestUtil;
import org.opendaylight.lispflowmapping.lisp.util.SourceDestKeyHelper;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.IpAddressBinary;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.SiteId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingChanged;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingOrigin;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.OdlMappingserviceListener;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.mapping.authkey.container.MappingAuthkey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
protected static final Logger LOG = LoggerFactory.getLogger(MapServer.class);
private IMappingService mapService;
- private boolean authenticate;
private boolean subscriptionService;
private IMapNotifyHandler notifyHandler;
private NotificationService notificationService;
- public MapServer(IMappingService mapService, boolean authenticate, boolean subscriptionService,
+ public MapServer(IMappingService mapService, boolean subscriptionService,
IMapNotifyHandler notifyHandler, NotificationService notificationService) {
Preconditions.checkNotNull(mapService);
this.mapService = mapService;
- this.authenticate = authenticate;
this.subscriptionService = subscriptionService;
this.notifyHandler = notifyHandler;
this.notificationService = notificationService;
this.subscriptionService = subscriptionService;
}
- @Override
- public boolean shouldAuthenticate() {
- return authenticate;
- }
-
- @Override
- public void setShouldAuthenticate(boolean shouldAuthenticate) {
- authenticate = shouldAuthenticate;
- }
-
@SuppressWarnings("unchecked")
public void handleMapRegister(MapRegister mapRegister) {
- boolean authFailed = false;
boolean mappingUpdated = false;
- MappingAuthkey authkey = null;
+ boolean merge = ConfigIni.getInstance().mappingMergeIsSet() && mapRegister.isMergeEnabled();
Set<SubscriberRLOC> subscribers = null;
MappingRecord oldMapping;
for (MappingRecordItem record : mapRegister.getMappingRecordItem()) {
MappingRecord mapping = record.getMappingRecord();
- if (authenticate) {
- authkey = mapService.getAuthenticationKey(mapping.getEid());
- if (!LispAuthenticationUtil.validate(mapRegister, mapping.getEid(), authkey)) {
- authFailed = true;
- break;
- }
- }
oldMapping = (MappingRecord) mapService.getMapping(MappingOrigin.Southbound, mapping.getEid());
- mapService.addMapping(MappingOrigin.Southbound, mapping.getEid(), getSiteId(mapRegister), mapping);
+ mapService.addMapping(MappingOrigin.Southbound, mapping.getEid(), getSiteId(mapRegister), mapping, merge);
if (subscriptionService) {
- MappingRecord newMapping = ConfigIni.getInstance().mappingMergeIsSet() ?
+ MappingRecord newMapping = merge ?
(MappingRecord) mapService.getMapping(MappingOrigin.Southbound, mapping.getEid()) : mapping;
if (mappingChanged(oldMapping, newMapping)) {
}
}
}
- if (!authFailed && BooleanUtils.isTrue(mapRegister.isWantMapNotify())) {
+ if (BooleanUtils.isTrue(mapRegister.isWantMapNotify())) {
LOG.trace("MapRegister wants MapNotify");
MapNotifyBuilder builder = new MapNotifyBuilder();
List<TransportAddress> rlocs = null;
- if (ConfigIni.getInstance().mappingMergeIsSet()) {
- Set<IpAddress> notifyRlocs = new HashSet<IpAddress>();
+ if (merge) {
+ Set<IpAddressBinary> notifyRlocs = new HashSet<IpAddressBinary>();
List<MappingRecordItem> mergedMappings = new ArrayList<MappingRecordItem>();
for (MappingRecordItem record : mapRegister.getMappingRecordItem()) {
MappingRecord mapping = record.getMappingRecord();
MappingRecord currentRecord = (MappingRecord) mapService.getMapping(MappingOrigin.Southbound,
mapping.getEid());
mergedMappings.add(new MappingRecordItemBuilder().setMappingRecord(currentRecord).build());
- Set<IpAddress> sourceRlocs = (Set<IpAddress>) mapService.getData(MappingOrigin.Southbound,
- mapping.getEid(), SubKeys.SRC_RLOCS);
+ Set<IpAddressBinary> sourceRlocs = (Set<IpAddressBinary>) mapService.getData(
+ MappingOrigin.Southbound, mapping.getEid(), SubKeys.SRC_RLOCS);
if (sourceRlocs != null) {
notifyRlocs.addAll(sourceRlocs);
}
} else {
MapNotifyBuilderHelper.setFromMapRegister(builder, mapRegister);
}
- if (authenticate) {
- builder.setAuthenticationData(LispAuthenticationUtil.createAuthenticationData(builder.build(),
- authkey.getKeyString()));
- }
notifyHandler.handleMapNotify(builder.build(), rlocs);
}
}
- private static List<TransportAddress> getTransportAddresses(Set<IpAddress> addresses) {
+ private static List<TransportAddress> getTransportAddresses(Set<IpAddressBinary> addresses) {
List<TransportAddress> rlocs = new ArrayList<TransportAddress>();
- for (IpAddress address : addresses) {
+ for (IpAddressBinary address : addresses) {
TransportAddressBuilder tab = new TransportAddressBuilder();
tab.setIpAddress(address);
tab.setPort(new PortNumber(LispMessage.PORT_NUM));
// For SrcDst LCAF also send SMRs to Dst prefix
if (eid.getAddress() instanceof SourceDestKey) {
- Eid dstAddr = SourceDestKeyHelper.getDst(eid);
+ Eid dstAddr = SourceDestKeyHelper.getDstBinary(eid);
Set<SubscriberRLOC> dstSubs = getSubscribers(dstAddr);
MappingRecord newRecord = new MappingRecordBuilder(record).setEid(dstAddr).build();
handleSmr(newRecord.getEid(), dstSubs, notifyHandler);