aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/protocols/openflow
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/protocols/openflow')
-rw-r--r--framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/ExtensionSelectorInterpreter.java57
-rw-r--r--framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/ExtensionTreatmentInterpreter.java16
-rw-r--r--framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/AbstractOpenFlowSwitch.java1
-rw-r--r--framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OpenFlowControllerImpl.java16
-rw-r--r--framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/OpenFlowControllerImplTest.java5
-rw-r--r--framework/src/onos/protocols/openflow/pom.xml23
6 files changed, 86 insertions, 32 deletions
diff --git a/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/ExtensionSelectorInterpreter.java b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/ExtensionSelectorInterpreter.java
new file mode 100644
index 00000000..7336c3c6
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/ExtensionSelectorInterpreter.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2015 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.openflow.controller;
+
+import com.google.common.annotations.Beta;
+import org.onosproject.net.driver.HandlerBehaviour;
+import org.onosproject.net.flow.criteria.ExtensionSelector;
+import org.onosproject.net.flow.criteria.ExtensionSelectorType;
+import org.projectfloodlight.openflow.protocol.OFFactory;
+import org.projectfloodlight.openflow.protocol.oxm.OFOxm;
+
+/**
+ * Interprets extension selectors and converts them to/from OpenFlow objects.
+ */
+@Beta
+public interface ExtensionSelectorInterpreter extends HandlerBehaviour {
+
+ /**
+ * Returns true if the given extension selector is supported by this
+ * driver.
+ *
+ * @param extensionSelectorType extension selector type
+ * @return true if the instruction is supported, otherwise false
+ */
+ boolean supported(ExtensionSelectorType extensionSelectorType);
+
+ /**
+ * Maps an extension selector to an OpenFlow OXM.
+ *
+ * @param factory OpenFlow factory
+ * @param extensionSelector extension selector
+ * @return OpenFlow action
+ */
+ OFOxm<?> mapSelector(OFFactory factory, ExtensionSelector extensionSelector);
+
+ /**
+ * Maps an OpenFlow OXM to an extension selector.
+ *
+ * @param oxm OpenFlow OXM
+ * @return extension selector
+ */
+ ExtensionSelector mapOxm(OFOxm<?> oxm);
+}
diff --git a/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/ExtensionTreatmentInterpreter.java b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/ExtensionTreatmentInterpreter.java
index dc57977f..88a5353d 100644
--- a/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/ExtensionTreatmentInterpreter.java
+++ b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/ExtensionTreatmentInterpreter.java
@@ -24,34 +24,34 @@ import org.projectfloodlight.openflow.protocol.OFFactory;
import org.projectfloodlight.openflow.protocol.action.OFAction;
/**
- * Interprets extension instructions and converts them to/from OpenFlow objects.
+ * Interprets extension treatments and converts them to/from OpenFlow objects.
*/
@Beta
public interface ExtensionTreatmentInterpreter extends HandlerBehaviour {
/**
- * Returns true if the given extension instruction is supported by this
+ * Returns true if the given extension treatment is supported by this
* driver.
*
- * @param extensionTreatmentType extension instruction type
- * @return true if the instruction is supported, otherwise false
+ * @param extensionTreatmentType extension treatment type
+ * @return true if the extension is supported, otherwise false
*/
boolean supported(ExtensionTreatmentType extensionTreatmentType);
/**
- * Maps an extension instruction to an OpenFlow action.
+ * Maps an extension treatment to an OpenFlow action.
*
* @param factory OpenFlow factory
- * @param extensionTreatment extension instruction
+ * @param extensionTreatment extension treatment
* @return OpenFlow action
*/
OFAction mapInstruction(OFFactory factory, ExtensionTreatment extensionTreatment);
/**
- * Maps an OpenFlow action to an extension instruction.
+ * Maps an OpenFlow action to an extension treatment.
*
* @param action OpenFlow action
- * @return extension instruction
+ * @return extension treatment
*/
ExtensionTreatment mapAction(OFAction action);
diff --git a/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/AbstractOpenFlowSwitch.java b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/AbstractOpenFlowSwitch.java
index c7174192..08444b17 100644
--- a/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/AbstractOpenFlowSwitch.java
+++ b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/AbstractOpenFlowSwitch.java
@@ -98,6 +98,7 @@ public abstract class AbstractOpenFlowSwitch extends AbstractHandlerBehaviour
@Override
public final void disconnectSwitch() {
+ setConnected(false);
this.channel.close();
}
diff --git a/framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OpenFlowControllerImpl.java b/framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OpenFlowControllerImpl.java
index b97c3362..b410158e 100644
--- a/framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OpenFlowControllerImpl.java
+++ b/framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OpenFlowControllerImpl.java
@@ -27,6 +27,7 @@ import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
import org.onosproject.cfg.ComponentConfigService;
+import org.onosproject.core.CoreService;
import org.onosproject.net.driver.DefaultDriverProviderService;
import org.onosproject.net.driver.DriverService;
import org.onosproject.openflow.controller.DefaultOpenFlowPacketContext;
@@ -83,6 +84,7 @@ import static org.onlab.util.Tools.groupedThreads;
@Component(immediate = true)
@Service
public class OpenFlowControllerImpl implements OpenFlowController {
+ private static final String APP_ID = "org.onosproject.openflow-base";
private static final String DEFAULT_OFPORT = "6633,6653";
private static final int DEFAULT_WORKER_THREADS = 16;
@@ -90,6 +92,9 @@ public class OpenFlowControllerImpl implements OpenFlowController {
LoggerFactory.getLogger(OpenFlowControllerImpl.class);
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected CoreService coreService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected DriverService driverService;
// References exists merely for sequencing purpose to assure drivers are loaded
@@ -147,15 +152,24 @@ public class OpenFlowControllerImpl implements OpenFlowController {
@Activate
public void activate(ComponentContext context) {
+ coreService.registerApplication(APP_ID, this::preDeactivate);
cfgService.registerProperties(getClass());
ctrl.setConfigParams(context.getProperties());
ctrl.start(agent, driverService);
}
+ private void preDeactivate() {
+ // Close listening channel and all OF channels before deactivating
+ ctrl.stop();
+ connectedSwitches.values().forEach(OpenFlowSwitch::disconnectSwitch);
+ }
+
@Deactivate
public void deactivate() {
cfgService.unregisterProperties(getClass(), false);
- ctrl.stop();
+ connectedSwitches.clear();
+ activeMasterSwitches.clear();
+ activeEqualSwitches.clear();
}
@Modified
diff --git a/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/OpenFlowControllerImplTest.java b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/OpenFlowControllerImplTest.java
index e079c590..56d422a9 100644
--- a/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/OpenFlowControllerImplTest.java
+++ b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/OpenFlowControllerImplTest.java
@@ -32,6 +32,7 @@ import org.junit.Before;
import org.junit.Test;
import org.onlab.junit.TestTools;
import org.onosproject.cfg.ComponentConfigService;
+import org.onosproject.core.CoreService;
import org.onosproject.openflow.OpenflowSwitchDriverAdapter;
import org.onosproject.openflow.controller.Dpid;
import org.onosproject.openflow.controller.OpenFlowSwitch;
@@ -127,6 +128,10 @@ public class OpenFlowControllerImplTest {
switchListener = new TestSwitchListener();
controller.addListener(switchListener);
+ CoreService mockCoreService =
+ EasyMock.createMock(CoreService.class);
+ controller.coreService = mockCoreService;
+
ComponentConfigService mockConfigService =
EasyMock.createMock(ComponentConfigService.class);
expect(mockConfigService.getProperties(anyObject())).andReturn(ImmutableSet.of());
diff --git a/framework/src/onos/protocols/openflow/pom.xml b/framework/src/onos/protocols/openflow/pom.xml
index 5a136a19..3bf976b5 100644
--- a/framework/src/onos/protocols/openflow/pom.xml
+++ b/framework/src/onos/protocols/openflow/pom.xml
@@ -38,20 +38,6 @@
<dependencies>
<dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onlab-misc</artifactId>
- </dependency>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onlab-junit</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.11</version>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
@@ -74,13 +60,4 @@
</dependency>
</dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
-
</project>