[ONOS-5750] Add skeleton code of LISP message provider

Change-Id: Idb9c96902ca30e2bd9c549ab58fae32962e74fee
This commit is contained in:
Jian Li 2016-12-21 02:49:32 +09:00
parent 8419efd32c
commit c4b4b581b9
5 changed files with 240 additions and 0 deletions

View File

@ -0,0 +1,9 @@
COMPILE_DEPS = [
'//lib:CORE_DEPS',
'//protocols/lisp/api:onos-protocols-lisp-api',
'//protocols/lisp/msg:onos-protocols-lisp-msg',
]
osgi_jar_with_tests (
deps = COMPILE_DEPS,
)

View File

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2016-present Open Networking Laboratory
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-lisp-providers</artifactId>
<version>1.9.0-SNAPSHOT</version>
</parent>
<artifactId>onos-lisp-provider-message</artifactId>
<packaging>bundle</packaging>
<description>ONOS LISP protocol message provider</description>
<dependencies>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onlab-junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-lisp-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-lisp-ctl</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-lisp-msg</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onlab-misc</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.onosproject</groupId>
<artifactId>onos-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,137 @@
/*
* Copyright 2016-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.provider.lisp.message.impl;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.onlab.metrics.MetricsService;
import org.onosproject.lisp.ctl.LispController;
import org.onosproject.lisp.ctl.LispMessageListener;
import org.onosproject.lisp.ctl.LispRouterId;
import org.onosproject.lisp.ctl.LispRouterListener;
import org.onosproject.lisp.msg.protocols.LispMessage;
import org.onosproject.net.provider.AbstractProvider;
import org.onosproject.net.provider.ProviderId;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Provider which uses an LISP controller to detect device.
*/
@Component(immediate = true)
public class LispMessageProvider extends AbstractProvider {
private static final Logger log = LoggerFactory.getLogger(LispMessageProvider.class);
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected LispController controller;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected MetricsService metricsService;
private static final String SCHEME_NAME = "lisp";
private static final String MESSAGE_PROVIDER_PACKAGE =
"org.onosproject.lisp.provider.message";
private final InternalDeviceProvider routerListener = new InternalDeviceProvider();
private final InternalControlMessageListener messageListener =
new InternalControlMessageListener();
/**
* Creates a LISP device provider with the supplier identifier.
*/
public LispMessageProvider() {
super(new ProviderId(SCHEME_NAME, MESSAGE_PROVIDER_PACKAGE));
}
@Activate
public void activate() {
// listens all LISP router related events
controller.addRouterListener(routerListener);
// listens all LISP control messages
controller.addMessageListener(messageListener);
attachRouters();
log.info("Started");
}
@Deactivate
public void deactivate() {
detachRouters();
// stops listening all LISP router related events
controller.removeRouterListener(routerListener);
// stops listening all LISP control messages
controller.removeMessageListener(messageListener);
log.info("Stopped");
}
/**
* Attaches all discovered LISP router to listen the router events.
*/
private void attachRouters() {
}
/**
* Detaches all LISP routers from listener.
*/
private void detachRouters() {
}
/**
* A routerListener for LISP router agent.
*/
private class InternalDeviceProvider implements LispRouterListener {
@Override
public void routerAdded(LispRouterId routerId) {
}
@Override
public void routerRemoved(LispRouterId routerId) {
}
@Override
public void routerChanged(LispRouterId routerId) {
}
}
/**
* A routerListener for all LISP control messages.
*/
private class InternalControlMessageListener implements LispMessageListener {
@Override
public void handleIncomingMessage(LispRouterId routerId, LispMessage msg) {
}
@Override
public void handleOutgoingMessage(LispRouterId routerId, LispMessage msg) {
}
}
}

View File

@ -0,0 +1,20 @@
/*
* Copyright 2016-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* LISP Provider.
*/
package org.onosproject.provider.lisp.message.impl;

View File

@ -33,6 +33,7 @@
<modules> <modules>
<module>device</module> <module>device</module>
<module>app</module> <module>app</module>
<module>message</module>
</modules> </modules>
<dependencies> <dependencies>