/*
- * Copyright (c) 2013 Contextream, Inc. and others. All rights reserved.
+ * Copyright (c) 2014 Contextream, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import java.net.InetAddress;
import java.net.UnknownHostException;
+import org.apache.commons.lang3.tuple.MutablePair;
+import org.apache.commons.lang3.tuple.Pair;
import org.eclipse.osgi.framework.console.CommandInterpreter;
import org.eclipse.osgi.framework.console.CommandProvider;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
import org.opendaylight.lispflowmapping.interfaces.dao.IRowVisitor;
import org.opendaylight.lispflowmapping.interfaces.lisp.IFlowMapping;
import org.opendaylight.lispflowmapping.interfaces.lisp.IMapNotifyHandler;
-import org.opendaylight.lispflowmapping.interfaces.lisp.IMapReplyHandler;
+import org.opendaylight.lispflowmapping.interfaces.lisp.IMapRequestResultHandler;
import org.opendaylight.lispflowmapping.interfaces.lisp.IMapResolverAsync;
import org.opendaylight.lispflowmapping.interfaces.lisp.IMapServerAsync;
import org.opendaylight.lispflowmapping.type.sbplugin.ILispSouthboundPlugin;
import com.google.common.net.InetAddresses;
public class LispMappingService implements CommandProvider, IFlowMapping, BindingAwareConsumer, //
- IMapReplyHandler, IMapNotifyHandler {
+ IMapRequestResultHandler, IMapNotifyHandler {
protected static final Logger logger = LoggerFactory.getLogger(LispMappingService.class);
private ILispDAO lispDao = null;
private volatile boolean shouldAuthenticate;
private ThreadLocal<MapReply> tlsMapReply = new ThreadLocal<MapReply>();
private ThreadLocal<MapNotify> tlsMapNotify = new ThreadLocal<MapNotify>();
+ private ThreadLocal<Pair<MapRequest, InetAddress>> tlsMapRequest = new ThreadLocal<Pair<MapRequest, InetAddress>>();
private ILispSouthboundPlugin lispSB = null;
}
void setBindingAwareBroker(BindingAwareBroker bindingAwareBroker) {
- logger.debug("BindingAwareBroker set!");
+ logger.trace("BindingAwareBroker set!");
BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
bindingAwareBroker.registerConsumer(this, bundleContext);
}
}
void setLispDao(ILispDAO dao) {
- logger.debug("LispDAO set in LispMappingService");
+ logger.trace("LispDAO set in LispMappingService");
basicInit(dao);
- logger.debug("Registering LispIpv4Address");
+ logger.trace("Registering LispIpv4Address");
lispDao.register(LispIpv4AddressInMemoryConverter.class);
- logger.debug("Registering LispIpv6Address");
+ logger.trace("Registering LispIpv6Address");
lispDao.register(LispIpv6AddressInMemoryConverter.class);
- logger.debug("Registering MappingServiceKey");
+ logger.trace("Registering MappingServiceKey");
lispDao.register(MappingServiceKeyConvertor.class);
- logger.debug("Registering MappingServiceNoMaskKey");
+ logger.trace("Registering MappingServiceNoMaskKey");
lispDao.register(MappingServiceNoMaskKeyConvertor.class);
}
void unsetLispDao(ILispDAO dao) {
- logger.debug("LispDAO was unset in LispMappingService");
+ logger.trace("LispDAO was unset in LispMappingService");
mapServer = null;
mapResolver = null;
lispDao = null;
}
public void destroy() {
- logger.debug("LISP (RFC6830) Mapping Service is destroyed!");
+ logger.info("LISP (RFC6830) Mapping Service is destroyed!");
mapResolver = null;
mapServer = null;
}
public MapReply handleMapRequest(MapRequest request) {
tlsMapReply.set(null);
+ tlsMapRequest.set(null);
mapResolver.handleMapRequest(request, this);
// After this invocation we assume that the thread local is filled with
// the reply
- return tlsMapReply.get();
+ if (tlsMapRequest.get() != null) {
+ getLispSB().handleMapRequest(tlsMapRequest.get().getLeft(), tlsMapRequest.get().getRight());
+ return null;
+ } else {
+ return tlsMapReply.get();
+ }
}
}
public void onSessionInitialized(ConsumerContext session) {
- logger.debug("Lisp Consumer session initialized!");
+ logger.info("Lisp Consumer session initialized!");
NotificationService notificationService = session.getSALService(NotificationService.class);
// notificationService.registerNotificationListener(LispNotification.class,
// this);
public void handleMapNotify(MapNotify notify) {
tlsMapNotify.set(notify);
}
+
+ @Override
+ public void handleNonProxyMapRequest(MapRequest mapRequest, InetAddress targetAddress) {
+ tlsMapRequest.set(new MutablePair<MapRequest, InetAddress>(mapRequest, targetAddress));
+ }
+
}