*.classpath
*target
*logs
+*.ipr
+*.iml
+*.iws
+.idea
--- /dev/null
+[gerrit]
+host=git.opendaylight.org
+port=29418
+project=lispflowmapping.git
<parent>
<groupId>org.opendaylight.lispflowmapping</groupId>
<artifactId>lispflowmapping-commons</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>
<artifactId>common.build.tools</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<scm>
<connection>scm:git:https://git.opendaylight.org/gerrit/p/lispflowmapping.git</connection>
<parent>
<groupId>org.opendaylight.lispflowmapping</groupId>
<artifactId>lispflowmapping-commons</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>
<artifactId>lispflowmapping-code-commons</artifactId>
<packaging>pom</packaging>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
<scm>
<connection>scm:git:https://git.opendaylight.org/gerrit/p/lispflowmapping.git</connection>
<developerConnection>scm:git:ssh://git.opendaylight.org:29418/lispflowmapping.git</developerConnection>
<modelVersion>4.0.0</modelVersion>
<groupId>org.opendaylight.lispflowmapping</groupId>
<artifactId>lispflowmapping-commons</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
<description></description>
<packaging>pom</packaging>
<url>http://www.opendaylight.org</url>
<tag>HEAD</tag>
</scm>
<properties>
- <lispflowmapping.version>1.0.0-SNAPSHOT</lispflowmapping.version>
+ <lispflowmapping.version>1.1.0-SNAPSHOT</lispflowmapping.version>
<jacoco.version>0.5.3.201107060350</jacoco.version>
<enforcer.version>1.3.1</enforcer.version>
<nexusproxy>http://nexus.opendaylight.org/content</nexusproxy>
<parent>
<groupId>org.opendaylight.lispflowmapping</groupId>
<artifactId>lispflowmapping-commons</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>
<artifactId>common.unittest.tools</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<scm>
<connection>scm:git:https://git.opendaylight.org/gerrit/p/lispflowmapping.git</connection>
<parent>
<groupId>org.opendaylight.lispflowmapping</groupId>
<artifactId>lispflowmapping-commons</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
<relativePath>../commons/parent</relativePath>
</parent>
southbound/META-INF
integrationtest/META-INF
northbound/src/main/resources/META-INF
+neutron/src/main/resources/META-INF
config/META-INF
<parent>
<groupId>org.opendaylight.lispflowmapping</groupId>
<artifactId>mappingservice-parent</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<artifactId>mappingservice.api</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<scm>
<connection>scm:git:https://git.opendaylight.org/gerrit/p/lispflowmapping.git</connection>
*/
package org.opendaylight.lispflowmapping.interfaces.lisp;
+import java.net.InetAddress;
+
import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapReply;
+import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapRequest;
/**
* An interface for dealing with a map reply message.
*/
-public interface IMapReplyHandler {
+public interface IMapRequestResultHandler {
public void handleMapReply(MapReply mapReply);
+
+ public void handleNonProxyMapRequest(MapRequest mapRequest, InetAddress targetAddress);
}
* The async map resolver interface for dealing with async map request calls.
*/
public interface IMapResolverAsync extends IGeneralMapResolver {
- public void handleMapRequest(MapRequest request, IMapReplyHandler callback);
+ public void handleMapRequest(MapRequest request, IMapRequestResultHandler callback);
}
import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapNotify;
import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapReply;
+import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapRequest;
import org.opendaylight.yangtools.yang.binding.RpcService;
import org.opendaylight.yangtools.yang.common.RpcResult;
*/
Future<RpcResult<java.lang.Void>> handleMapReply(MapReply mapReply, InetAddress targetAddress);
+ /**
+ * Handle a non proxy map request by sending it to the correct xTR.
+ *
+ * @param mapRequest
+ * @param targetAddress
+ * @return
+ */
+ Future<RpcResult<java.lang.Void>> handleMapRequest(MapRequest mapRequest, InetAddress targetAddress);
+
}
\ No newline at end of file
<parent>
<artifactId>lispflowmapping-commons</artifactId>
<groupId>org.opendaylight.lispflowmapping</groupId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
<relativePath>../../commons/parent</relativePath>
</parent>
<artifactId>mappingservice.config</artifactId>
<parent>
<groupId>org.opendaylight.lispflowmapping</groupId>
<artifactId>mappingservice-parent</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<artifactId>mappingservice.implementation</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<scm>
<connection>scm:git:https://git.opendaylight.org/gerrit/p/lispflowmapping.git</connection>
org.opendaylight.controller.sal.core,
org.apache.felix.dm,
org.apache.commons.lang3,
+ org.apache.commons.lang3.tuple,
org.apache.commons.lang3.builder,
org.osgi.service.component,
org.slf4j,
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;
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 handleMapNotify(MapNotify notify) {
tlsMapNotify.set(notify);
}
+
+ @Override
+ public void handleNonProxyMapRequest(MapRequest mapRequest, InetAddress targetAddress) {
+ tlsMapRequest.set(new MutablePair<MapRequest, InetAddress>(mapRequest, targetAddress));
+ }
+
}
import java.util.Map;
import org.opendaylight.lispflowmapping.implementation.dao.MappingServiceKeyUtil;
+import org.opendaylight.lispflowmapping.implementation.util.LispNotificationHelper;
import org.opendaylight.lispflowmapping.implementation.util.MaskUtil;
import org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO;
import org.opendaylight.lispflowmapping.interfaces.dao.IMappingServiceKey;
import org.opendaylight.lispflowmapping.interfaces.dao.MappingServiceRLOC;
import org.opendaylight.lispflowmapping.interfaces.dao.MappingServiceValue;
-import org.opendaylight.lispflowmapping.interfaces.lisp.IMapReplyHandler;
+import org.opendaylight.lispflowmapping.interfaces.lisp.IMapRequestResultHandler;
import org.opendaylight.lispflowmapping.interfaces.lisp.IMapResolverAsync;
import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapRequest;
import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.eidrecords.EidRecord;
this.shouldIterateMask = iterateMask;
}
- public void handleMapRequest(MapRequest request, IMapReplyHandler callback) {
+ public void handleMapRequest(MapRequest request, IMapRequestResultHandler callback) {
if (dao == null) {
logger.warn("handleMapRequest called while dao is uninitialized");
+ return;
+ }
+ if (request.isPitr()) {
+ if (request.getEidRecord().size() > 0) {
+ EidRecord eid = request.getEidRecord().get(0);
+ Map<String, ?> locators = getLocators(eid);
+ MappingServiceValue value = (MappingServiceValue) locators.get("value");
+ if (value.getRlocs() != null && value.getRlocs().size() > 0) {
+ callback.handleNonProxyMapRequest(request,
+ LispNotificationHelper.getInetAddressFromContainer(value.getRlocs().get(0).getRecord().getLispAddressContainer()));
+ }
+ }
+
} else {
MapReplyBuilder builder = new MapReplyBuilder();
builder.setEchoNonceEnabled(false);
recordBuilder.setMaskLength(eid.getMask());
recordBuilder.setLispAddressContainer(eid.getLispAddressContainer());
recordBuilder.setLocatorRecord(new ArrayList<LocatorRecord>());
- IMappingServiceKey key = MappingServiceKeyUtil.generateMappingServiceKey(eid.getLispAddressContainer(), eid.getMask());
- Map<String, ?> locators = dao.get(key);
- if (shouldIterateMask() && locators == null && MaskUtil.isMaskable(key.getEID().getAddress())) {
- locators = findMaskLocators(key);
- }
+ Map<String, ?> locators = getLocators(eid);
if (locators != null) {
MappingServiceValue value = (MappingServiceValue) locators.get("value");
}
}
+ private Map<String, ?> getLocators(EidRecord eid) {
+ IMappingServiceKey key = MappingServiceKeyUtil.generateMappingServiceKey(eid.getLispAddressContainer(), eid.getMask());
+ Map<String, ?> locators = dao.get(key);
+ if (shouldIterateMask() && locators == null && MaskUtil.isMaskable(key.getEID().getAddress())) {
+ locators = findMaskLocators(key);
+ }
+ return locators;
+ }
+
private Map<String, ?> findMaskLocators(IMappingServiceKey key) {
int mask = key.getMask();
while (mask > 0) {
import java.net.InetAddress;
import java.net.UnknownHostException;
+import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.lispaddress.LispAddressContainer;
+import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.lispaddress.lispaddresscontainer.address.Ipv4;
import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.mapregisternotification.MapRegister;
import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.mapregisternotification.MapRegisterBuilder;
import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.maprequestnotification.MapRequest;
}
public static InetAddress getInetAddressFromIpAddress(IpAddress ipAddress) {
- InetAddress address = InetAddress.getLoopbackAddress();
- if (ipAddress == null) {
- return address;
- }
- if (ipAddress.getIpv4Address() != null) {
- try {
- address = Inet4Address.getByName(ipAddress.getIpv4Address().getValue());
- } catch (UnknownHostException e) {
- }
- } else if (ipAddress.getIpv6Address() != null) {
- try {
- address = Inet4Address.getByName(ipAddress.getIpv6Address().getValue());
- } catch (UnknownHostException e) {
+ InetAddress address = null;
+ if (ipAddress != null) {
+ if (ipAddress.getIpv4Address() != null) {
+ address = getAddressByName(ipAddress.getIpv4Address().getValue());
+ } else if (ipAddress.getIpv6Address() != null) {
+ address = getAddressByName(ipAddress.getIpv6Address().getValue());
}
}
+ if (address == null) {
+ address = InetAddress.getLoopbackAddress();
+ }
return address;
}
+
+ public static InetAddress getInetAddressFromContainer(LispAddressContainer container) {
+ Ipv4Address ipAddress = ((Ipv4) LispAFIConvertor.toAFI(container)).getIpv4Address();
+ return getAddressByName(ipAddress.getValue());
+ }
+
+ public static InetAddress getAddressByName(String IPAddress) {
+ try {
+ InetAddress address = InetAddress.getByName(IPAddress);
+ return address;
+ } catch (UnknownHostException e) {
+ return null;
+ }
+ }
}
</plugins>
</build>
<properties>
- <lispflowmapping.version>1.0.0-SNAPSHOT</lispflowmapping.version>
+ <lispflowmapping.version>1.1.0-SNAPSHOT</lispflowmapping.version>
<exam.version>3.0.0</exam.version>
<url.version>1.5.0</url.version>
<!-- Sonar jacoco plugin to get integration test coverage info -->
<artifactId>jersey-client</artifactId>
<version>${jersey.version}</version>
</dependency>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-json</artifactId>
+ <version>${jersey.version}</version>
+ </dependency>
<dependency>
<groupId>org.opendaylight.yangtools.thirdparty</groupId>
<artifactId>xtend-lib-osgi</artifactId>
// Retrieve the RLOC from the database
MapRequestBuilder mapRequestBuilder = new MapRequestBuilder();
+ mapRequestBuilder.setPitr(false);
mapRequestBuilder.setEidRecord(new ArrayList<EidRecord>());
mapRequestBuilder.getEidRecord().add(
new EidRecordBuilder().setMask((short) mask).setLispAddressContainer(LispAFIConvertor.toContainer(eid)).build());
return mr;
}
+ @Test
+ public void nonProxyTest() throws SocketTimeoutException, SocketException {
+ String eid = "10.0.0.1";
+ String rloc = "127.0.0.3";
+ MapRegister mr = createMapRegister(LispAFIConvertor.asIPAfiAddress(eid));
+ LocatorRecord record = new LocatorRecordBuilder(mr.getEidToLocatorRecord().get(0).getLocatorRecord().get(0)).setLispAddressContainer(
+ LispAFIConvertor.toContainer(LispAFIConvertor.asIPAfiAddress(rloc))).build();
+ mr.getEidToLocatorRecord().get(0).getLocatorRecord().set(0, record);
+ sendMapRegister(mr);
+ receiveMapNotify();
+ MapRequest mapRequest = createMapRequest(LispAFIConvertor.asIPAfiAddress(eid));
+ MapRequestBuilder builder = new MapRequestBuilder(mapRequest);
+ builder.setPitr(true);
+ mapRequest = builder.build();
+ sendMapRequest(mapRequest);
+ socket = new DatagramSocket(new InetSocketAddress(rloc, LispMessage.PORT_NUM));
+ MapRequest recievedMapRequest = receiveMapRequest();
+ assertEquals(mapRequest.getNonce(), recievedMapRequest.getNonce());
+ assertEquals(mapRequest.getSourceEid(), recievedMapRequest.getSourceEid());
+ assertEquals(mapRequest.getItrRloc(), recievedMapRequest.getItrRloc());
+ assertEquals(mapRequest.getEidRecord(), recievedMapRequest.getEidRecord());
+
+ }
+
private MapReply receiveMapReply() throws SocketTimeoutException {
return MapReplySerializer.getInstance().deserialize(ByteBuffer.wrap(receivePacket().getData()));
}
+ private MapRequest receiveMapRequest() throws SocketTimeoutException {
+ return MapRequestSerializer.getInstance().deserialize(ByteBuffer.wrap(receivePacket().getData()));
+ }
+
private MapNotify receiveMapNotify() throws SocketTimeoutException {
return MapNotifySerializer.getInstance().deserialize(ByteBuffer.wrap(receivePacket().getData()));
}
</pattern>
</encoder>
</appender>
+ <logger name="org.opendaylight.lispflowmapping" level="debug"/>
<root level="warn">
<appender-ref ref="STDOUT" />
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.opendaylight.lispflowmapping</groupId>
+ <artifactId>mappingservice-parent</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+
+ <artifactId>mappingservice.neutron</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+ <scm>
+ <connection>scm:git:https://git.opendaylight.org/gerrit/p/lispflowmapping.git</connection>
+ <developerConnection>scm:git:ssh://git.opendaylight.org:29418/lispflowmapping.git</developerConnection>
+ <url>https://wiki.opendaylight.org/view/OpenDaylight_Lisp_Flow_Mapping:Main</url>
+ <tag>HEAD</tag>
+ </scm>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>2.3.6</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Package>
+ </Export-Package>
+ <Import-Package>
+ org.opendaylight.controller.sal.core,
+ org.opendaylight.controller.sal.utils,
+ org.opendaylight.controller.containermanager,
+ org.opendaylight.controller.switchmanager,
+ org.opendaylight.controller.networkconfig.neutron,
+ org.opendaylight.controller.northbound.commons,
+ org.opendaylight.controller.northbound.commons.exception,
+ org.opendaylight.controller.northbound.commons.utils,
+ com.sun.jersey.spi.container.servlet,
+ org.opendaylight.controller.sal.authorization,
+ org.opendaylight.controller.usermanager,
+ org.opendaylight.lispflowmapping.type,
+ org.opendaylight.lispflowmapping.type.lisp,
+ org.opendaylight.lispflowmapping.type.lisp.address,
+ org.opendaylight.lispflowmapping.interfaces.lisp,
+ org.slf4j,
+ org.apache.catalina.filters,
+ org.apache.felix.dm,
+ org.apache.commons.lang3.builder,
+ org.osgi.service.component,
+ org.eclipse.osgi.framework.console,
+ org.osgi.framework,
+ </Import-Package>
+ <Bundle-Activator>
+ org.opendaylight.lispflowmapping.neutron.Activator
+ </Bundle-Activator>
+
+ <Export-Package>
+ </Export-Package>
+ </instructions>
+ <manifestLocation>${project.basedir}/src/main/resources/META-INF</manifestLocation>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.lispflowmapping</groupId>
+ <artifactId>mappingservice.api</artifactId>
+ <version>${lispflowmapping.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal</artifactId>
+ <version>0.5.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>containermanager</artifactId>
+ <version>0.5.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>commons.northbound</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>networkconfig.neutron</artifactId>
+ <version>0.4.1-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
--- /dev/null
+/*
+ * Copyright (c) 2013 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,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.lispflowmapping.neutron;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.apache.felix.dm.Component;
+import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
+import org.opendaylight.lispflowmapping.interfaces.lisp.IFlowMapping;
+import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkAware;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Main application activator class for registering the dependencies and
+ * initialising the Mapping Service application.
+ *
+ */
+
+public class Activator extends ComponentActivatorAbstractBase {
+
+ /*
+ * Logger instance
+ */
+ protected static final Logger logger = LoggerFactory.getLogger(Activator.class);
+
+ /**
+ * Function called when the activator starts just after some initializations
+ * are done by the ComponentActivatorAbstractBase.
+ *
+ */
+ @Override
+ public void init() {
+ }
+
+ /**
+ * Function called when the activator stops just before the cleanup done by
+ * ComponentActivatorAbstractBase
+ *
+ */
+ @Override
+ public void destroy() {
+ }
+
+ /**
+ * Function that is used to communicate to dependency manager the list of
+ * known implementations for services inside a container
+ *
+ *
+ * @return An array containing all the CLASS objects that will be
+ * instantiated in order to get an fully working implementation
+ * Object
+ */
+ @Override
+ public Object[] getImplementations() {
+ Object[] res = { LispNeutronService.class };
+ return res;
+ }
+
+ /**
+ * Function that is called when configuration of the dependencies is
+ * required.
+ *
+ * @param c
+ * dependency manager Component object, used for configuring the
+ * dependencies exported and imported
+ * @param imp
+ * Implementation class that is being configured, needed as long
+ * as the same routine can configure multiple implementations
+ * @param containerName
+ * The containerName being configured, this allow also optional
+ * per-container different behavior if needed, usually should not
+ * be the case though.
+ */
+ @Override
+ public void configureInstance(Component c, Object imp, String containerName) {
+
+ //partially based on OpenDove code
+ if (imp.equals(LispNeutronService.class)) {
+ c.setInterface(
+ new String[] { INeutronNetworkAware.class.getName(),
+ ILispNeutronService.class.getName()}, //Is this necessary?
+ null); // null or props here?
+ Dictionary<String, String> props = new Hashtable<String, String>();
+ props.put("name", "mappingservice");
+ c.add(createContainerServiceDependency(containerName)
+ .setService(IFlowMapping.class)
+ .setCallbacks("setFlowMappingService", "unsetFlowMappingService")
+ .setRequired(true));
+ }
+ }
+
+
+
+ /**
+ * Method which tells how many Global implementations are supported by the
+ * bundle. This way we can tune the number of components created. This
+ * components will be created ONLY at the time of bundle startup and will be
+ * destroyed only at time of bundle destruction, this is the major
+ * difference with the implementation retrieved via getImplementations where
+ * all of them are assumed to be in a container !
+ *
+ *
+ * @return The list of implementations the bundle will support, in Global
+ * version
+ */
+ @Override
+ protected Object[] getGlobalImplementations() {
+ return null;
+ }
+
+ /**
+ * Configure the dependency for a given instance Global
+ *
+ * @param c
+ * Component assigned for this instance, this will be what will
+ * be used for configuration
+ * @param imp
+ * implementation to be configured
+ * @param containerName
+ * container on which the configuration happens
+ */
+ @Override
+ protected void configureGlobalInstance(Component c, Object imp) {
+
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, 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,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.lispflowmapping.neutron;
+
+import org.opendaylight.lispflowmapping.interfaces.lisp.IFlowMapping;
+
+public interface ILispNeutronService {
+
+ public IFlowMapping getMappingService();
+
+}
--- /dev/null
+package org.opendaylight.lispflowmapping.neutron;
+
+import org.eclipse.osgi.framework.console.CommandProvider;
+import org.opendaylight.lispflowmapping.interfaces.lisp.IFlowMapping;
+import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkAware;
+import org.opendaylight.controller.networkconfig.neutron.NeutronNetwork;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class LispNeutronService implements ILispNeutronService, INeutronNetworkAware{
+ protected static final Logger logger = LoggerFactory.getLogger(LispNeutronService.class);
+ private IFlowMapping mappingService;
+
+
+ public IFlowMapping getMappingService(){
+ return this.mappingService;
+ }
+
+ void setFlowMappingService(IFlowMapping mappingService) {
+ logger.debug("FlowMapping set in LispNeutron");
+ this.mappingService = mappingService;
+ }
+
+ void unsetFlowMappingService(IFlowMapping mappingService) {
+ logger.debug("LispDAO was unset in LISP Neutron");
+ this.mappingService = null;
+ }
+
+ public void init() {
+ logger.debug("LISP Neutron Service is initialized!");
+ }
+
+ public void start() {
+ logger.info("LISP Neutron Service is up!");
+
+ // OSGI console
+ registerWithOSGIConsole();
+ }
+
+ private void registerWithOSGIConsole() {
+ BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
+ bundleContext.registerService(CommandProvider.class.getName(), this, null);
+ }
+
+ public void stop() {
+ logger.info("LISP Neutron Service is down!");
+ }
+
+ public void destroy() {
+ logger.debug("LISP Neutron Service is destroyed!");
+ mappingService = null;
+ }
+
+ // callbacks for INeutronNetworkAware. Based on OpenDove project
+
+ public int canCreateNetwork(NeutronNetwork network) {
+ logger.info("hello world!");
+ logger.info("canCreateNetwork called!");
+ logger.info("Network name: "+network.getNetworkName());
+// if (network.getAdminStateUp() != null && !network.isAdminStateUp())
+// return 400;
+ return 200;
+ }
+ public void neutronNetworkCreated(NeutronNetwork input) {
+ logger.info("neutronNetworkCreated called!");
+ return;
+ }
+
+ public int canUpdateNetwork(NeutronNetwork delta, NeutronNetwork original) {
+ logger.info("canUpdateNetwork called!");
+ if (delta.getNetworkName() != null || delta.getAdminStateUp() != null ||
+ delta.getShared() != null || delta.getRouterExternal() != null)
+ return 403;
+ return 200;
+ }
+
+ public void neutronNetworkUpdated(NeutronNetwork network) {
+ logger.info("neutronNetworkUpdated called!");
+ return;
+ }
+
+ public int canDeleteNetwork(NeutronNetwork network) {
+ logger.info("canDeleteNetwork called!");
+ return 200;
+ }
+
+ public void neutronNetworkDeleted(NeutronNetwork network) {
+ logger.info("neutronNetworkDeleted called!");
+ return;
+ }
+
+}
<parent>
<groupId>org.opendaylight.lispflowmapping</groupId>
<artifactId>mappingservice-parent</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<artifactId>mappingservice.northbound</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<scm>
<connection>scm:git:https://git.opendaylight.org/gerrit/p/lispflowmapping.git</connection>
<parent>
<groupId>org.opendaylight.lispflowmapping</groupId>
<artifactId>lispflowmapping-code-commons</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
<relativePath>../commons/code-parent</relativePath>
</parent>
<artifactId>mappingservice-parent</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<scm>
<connection>scm:git:https://git.opendaylight.org/gerrit/p/lispflowmapping.git</connection>
<module>implementation</module>
<module>southbound</module>
<module>northbound</module>
+ <module>neutron</module>
<module>integrationtest</module>
</modules>
<dependencies>
<parent>
<groupId>org.opendaylight.lispflowmapping</groupId>
<artifactId>mappingservice-parent</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<artifactId>mappingservice.southbound</artifactId>
import org.opendaylight.lispflowmapping.implementation.serializer.LispMessage;
import org.opendaylight.lispflowmapping.implementation.serializer.MapNotifySerializer;
import org.opendaylight.lispflowmapping.implementation.serializer.MapReplySerializer;
+import org.opendaylight.lispflowmapping.implementation.serializer.MapRequestSerializer;
import org.opendaylight.lispflowmapping.southbound.lisp.LispSouthboundService;
import org.opendaylight.lispflowmapping.type.sbplugin.IConfigLispPlugin;
import org.opendaylight.lispflowmapping.type.sbplugin.ILispSouthboundPlugin;
import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapNotify;
import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapReply;
+import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapRequest;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
private volatile DatagramSocket socket = null;
private final String MAP_NOTIFY = "MapNotify";
private final String MAP_REPlY = "MapReply";
+ private final String MAP_REQUEST = "MapRequest";
private volatile String bindingAddress = null;
private volatile boolean stillRunning = false;
private volatile boolean alreadyInit = false;
return null;
}
+ public Future<RpcResult<Void>> handleMapRequest(MapRequest mapRequest, InetAddress address) {
+ logger.trace("handleMapRequest called!!");
+ if (mapRequest != null) {
+ ByteBuffer outBuffer = MapRequestSerializer.getInstance().serialize(mapRequest);
+ handleSerializedLispBuffer(address, outBuffer, MAP_REQUEST);
+ } else {
+ logger.debug("MapRequest was null");
+ }
+ return null;
+ }
+
public void setLispAddress(String address) {
synchronized (startLock) {
if (bindingAddress != null && bindingAddress.equals(address)) {
/target
/META-INF
+/target
<parent>
<artifactId>mappingservice-parent</artifactId>
<groupId>org.opendaylight.lispflowmapping</groupId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<artifactId>mappingservice.yangmodel</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<scm>
<connection>scm:git:https://git.opendaylight.org/gerrit/p/lispflowmapping.git</connection>