tom

Added cubby-holes for new projects.

Showing 1000 changed files with 3271 additions and 98 deletions

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

1 +*~
2 +*.class
3 +.classpath
4 +.project
5 +.pydevproject
6 +.settings
7 +.javacp*
8 +target
9 +*.iml
10 +.idea
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<project xmlns="http://maven.apache.org/POM/4.0.0"
3 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
5 + <modelVersion>4.0.0</modelVersion>
6 +
7 + <parent>
8 + <groupId>org.onlab.onos</groupId>
9 + <artifactId>onos</artifactId>
10 + <version>1.0.0-SNAPSHOT</version>
11 + <relativePath>../pom.xml</relativePath>
12 + </parent>
13 +
14 + <artifactId>onos-cli</artifactId>
15 + <packaging>bundle</packaging>
16 +
17 + <description>ONOS administrative console command-line extensions
18 + </description>
19 +
20 + <dependencies>
21 + <dependency>
22 + <groupId>org.onlab.onos</groupId>
23 + <artifactId>onos-api</artifactId>
24 + </dependency>
25 + <dependency>
26 + <groupId>org.osgi</groupId>
27 + <artifactId>org.osgi.core</artifactId>
28 + </dependency>
29 + <dependency>
30 + <groupId>org.apache.karaf.shell</groupId>
31 + <artifactId>org.apache.karaf.shell.console</artifactId>
32 + </dependency>
33 + </dependencies>
34 +
35 + <build>
36 + <plugins>
37 + <plugin>
38 + <groupId>org.apache.felix</groupId>
39 + <artifactId>maven-bundle-plugin</artifactId>
40 + </plugin>
41 + </plugins>
42 + </build>
43 +
44 +</project>
1 +package org.onlab.onos.cli;
2 +
3 +import org.apache.karaf.shell.console.OsgiCommandSupport;
4 +import org.osgi.framework.BundleContext;
5 +import org.osgi.framework.FrameworkUtil;
6 +
7 +/**
8 + * Base abstraction of Karaf shell commands.
9 + */
10 +public abstract class AbstractShellCommand extends OsgiCommandSupport {
11 +
12 + /**
13 + * Returns the reference to the implementaiton of the specified service.
14 + *
15 + * @param serviceClass service class
16 + * @param <T> type of service
17 + * @return service implementation
18 + */
19 + static <T> T get(Class<T> serviceClass) {
20 + BundleContext bc = FrameworkUtil.getBundle(AbstractShellCommand.class).getBundleContext();
21 + return bc.getService(bc.getServiceReference(serviceClass));
22 + }
23 +
24 +}
1 +package org.onlab.onos.cli;
2 +
3 +import org.apache.karaf.shell.commands.Argument;
4 +import org.apache.karaf.shell.commands.Command;
5 +import org.apache.karaf.shell.console.OsgiCommandSupport;
6 +import org.onlab.onos.net.GreetService;
7 +
8 +/**
9 + * Simple command example to demonstrate use of Karaf shell extensions; shows
10 + * use of an optional parameter as well.
11 + */
12 +@Command(scope = "onos", name = "greet", description = "Issues a greeting")
13 +public class GreetCommand extends OsgiCommandSupport {
14 +
15 + @Argument(index = 0, name = "name", description = "Name to greet",
16 + required = false, multiValued = false)
17 + String name = "dude";
18 +
19 + @Override
20 + protected Object doExecute() throws Exception {
21 + System.out.println(getService(GreetService.class).yo(name));
22 + return null;
23 + }
24 +}
1 +package org.onlab.onos.cli;
2 +
3 +import org.apache.karaf.shell.console.Completer;
4 +import org.apache.karaf.shell.console.completer.StringsCompleter;
5 +import org.onlab.onos.net.GreetService;
6 +
7 +import java.util.Iterator;
8 +import java.util.List;
9 +import java.util.SortedSet;
10 +
11 +/**
12 + * Simple example of a command-line parameter completer.
13 + * For a more open-ended sets a more efficient implementation would be required.
14 + */
15 +public class NameCompleter implements Completer {
16 + @Override
17 + public int complete(String buffer, int cursor, List<String> candidates) {
18 + // Delegate string completer
19 + StringsCompleter delegate = new StringsCompleter();
20 +
21 + // Fetch our service and feed it's offerings to the string completer
22 + GreetService greetService = AbstractShellCommand.get(GreetService.class);
23 + Iterator<String> it = greetService.names().iterator();
24 + SortedSet<String> strings = delegate.getStrings();
25 + while (it.hasNext()) {
26 + strings.add(it.next());
27 + }
28 +
29 + // Now let the completer do the work for figuring out what to offer.
30 + return delegate.complete(buffer, cursor, candidates);
31 + }
32 +
33 +}
1 +<body>
2 +Administrative console command-line extensions.
3 +</body>
1 +<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
2 +
3 + <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
4 + <command>
5 + <action class="org.onlab.onos.cli.GreetCommand"/>
6 + <completers>
7 + <ref component-id="nameCompleter"/>
8 + </completers>
9 + </command>
10 + </command-bundle>
11 +
12 + <bean id="nameCompleter" class="org.onlab.onos.cli.NameCompleter"/>
13 +
14 +</blueprint>
1 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> 1 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2 <features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" 2 <features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
3 - name="net.onrc.onos-1.0.0"> 3 + name="onos-1.0.0">
4 - <repository>mvn:net.onrc.onos/onos-features/1.0.0-SNAPSHOT/xml/features</repository> 4 + <repository>mvn:org.onlab.onos/onos-features/1.0.0-SNAPSHOT/xml/features</repository>
5 5
6 - <feature name="onos-thirdparty" version="1.0.0" 6 + <feature name="onos-thirdparty-base" version="1.0.0"
7 description="ONOS 3rd party dependencies"> 7 description="ONOS 3rd party dependencies">
8 - <bundle>mvn:com.google.code.findbugs/annotations/2.0.2</bundle> 8 + <bundle>mvn:com.google.guava/guava/17.0</bundle>
9 <bundle>mvn:io.netty/netty/3.9.2.Final</bundle> 9 <bundle>mvn:io.netty/netty/3.9.2.Final</bundle>
10 - <bundle>mvn:com.google.guava/guava/17.0</bundle>
11 - <bundle>mvn:com.google.guava/guava/15.0</bundle>
12 </feature> 10 </feature>
13 11
14 - <feature name="onos-of-ctl" version="1.0.0" 12 + <feature name="onos-thirdparty-web" version="1.0.0"
15 - description="ONOS OpenFlow Libraries &amp; Controller"> 13 + description="ONOS 3rd party dependencies">
14 + <feature>war</feature>
15 + <bundle>mvn:com.fasterxml.jackson.core/jackson-core/2.4.2</bundle>
16 + <bundle>mvn:com.fasterxml.jackson.core/jackson-annotations/2.4.2</bundle>
17 + <bundle>mvn:com.fasterxml.jackson.core/jackson-databind/2.4.2</bundle>
18 + <bundle>mvn:com.sun.jersey/jersey-core/1.18.1</bundle>
19 + <bundle>mvn:com.sun.jersey/jersey-server/1.18.1</bundle>
20 + <bundle>mvn:com.sun.jersey/jersey-servlet/1.18.1</bundle>
21 + </feature>
22 +
23 + <feature name="onos-core" version="1.0.0"
24 + description="ONOS core components">
16 <feature>scr</feature> 25 <feature>scr</feature>
17 - <feature>thirdparty</feature> 26 + <feature>onos-thirdparty-base</feature>
18 - <bundle>mvn:net.onrc.onos.sb/onos-sb/0.0.1</bundle> 27 + <bundle>mvn:org.onlab.onos/onos-utils-osgi/1.0.0-SNAPSHOT</bundle>
19 - <bundle>mvn:org.projectfloodlight/openflowj/0.3.6-SNAPSHOT</bundle> 28 + <bundle>mvn:org.onlab.onos/onos-utils-rest/1.0.0-SNAPSHOT</bundle>
29 +
30 + <bundle>mvn:org.onlab.onos/onos-api/1.0.0-SNAPSHOT</bundle>
31 + <bundle>mvn:org.onlab.onos/onos-core/1.0.0-SNAPSHOT</bundle>
32 + </feature>
33 +
34 + <feature name="onos-rest" version="1.0.0"
35 + description="ONOS REST API components">
36 + <feature>onos-core</feature>
37 + <feature>onos-thirdparty-web</feature>
38 + <bundle>mvn:org.onlab.onos/onos-rest/1.0.0-SNAPSHOT</bundle>
39 + </feature>
40 +
41 + <feature name="onos-gui" version="1.0.0"
42 + description="ONOS GUI console components">
43 + <feature>onos-core</feature>
44 + <feature>onos-thirdparty-web</feature>
45 + <bundle>mvn:org.onlab.onos/onos-gui/1.0.0-SNAPSHOT</bundle>
46 + </feature>
47 +
48 + <feature name="onos-cli" version="1.0.0"
49 + description="ONOS admin command console components">
50 + <feature>onos-core</feature>
51 + <bundle>mvn:org.onlab.onos/onos-cli/1.0.0-SNAPSHOT</bundle>
52 + </feature>
53 +
54 + <feature name="onos-openflow" version="1.0.0"
55 + description="ONOS OpenFlow API, Controller &amp; Providers">
56 + <feature>onos-core</feature>
57 + <bundle>mvn:io.netty/netty/3.9.2.Final</bundle>
58 + <bundle>mvn:com.google.guava/guava/15.0</bundle>
59 +
60 + <bundle>mvn:org.onlab.onos/openflow-api/1.0.0-SNAPSHOT</bundle>
61 + <bundle>mvn:org.onlab.onos/openflow-ctl/1.0.0-SNAPSHOT</bundle>
62 + <bundle>mvn:org.onlab.onos/onos-of-providers/1.0.0-SNAPSHOT</bundle>
20 </feature> 63 </feature>
21 64
22 </features> 65 </features>
......
1 -<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 1 +<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2 -<!-- 2 +<!--
3 - ~ Copyright (c) 2014 Hewlett-Packard Development Company, L.P. 3 + ~ Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
4 - ~ 4 + ~
5 - ~ This program and the accompanying materials are made available under the 5 + ~ This program and the accompanying materials are made available under the
6 - ~ terms of the Eclipse Public License v1.0 which accompanies this distribution, 6 + ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 - ~ and is available at http://www.eclipse.org/legal/epl-v10.html 7 + ~ and is available at http://www.eclipse.org/legal/epl-v10.html
8 - --> 8 + -->
9 - 9 +
10 -<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" 10 +<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
11 - name="net.onrc.onos-1.0.0"> 11 + name="net.onrc.onos-1.0.0">
12 - <repository>mvn:net.onrc.onos/onos-features/1.0.0-SNAPSHOT/xml/features</repository> 12 + <repository>mvn:net.onrc.onos/onos-features/1.0.0-SNAPSHOT/xml/features</repository>
13 - 13 +
14 - <feature name="thirdparty" version="1.0.0" 14 + <feature name="thirdparty" version="1.0.0"
15 - description="ONOS 3rd party dependencies"> 15 + description="ONOS 3rd party dependencies">
16 - <bundle>mvn:com.google.code.findbugs/annotations/2.0.2</bundle> 16 + <bundle>mvn:com.google.code.findbugs/annotations/2.0.2</bundle>
17 - <bundle>mvn:io.netty/netty/3.9.2.Final</bundle> 17 + <bundle>mvn:io.netty/netty/3.9.2.Final</bundle>
18 - <bundle>mvn:com.google.guava/guava/17.0</bundle> 18 + <bundle>mvn:com.google.guava/guava/17.0</bundle>
19 - <bundle>mvn:com.google.guava/guava/15.0</bundle> 19 + <bundle>mvn:com.google.guava/guava/15.0</bundle>
20 - 20 +
21 - </feature> 21 + </feature>
22 - 22 +
23 - <feature name="base" version="1.0.0" 23 + <feature name="base" version="1.0.0"
24 - description="ONOS Base"> 24 + description="ONOS Base">
25 - <feature>scr</feature> 25 + <feature>scr</feature>
26 - <feature>thirdparty</feature> 26 + <feature>thirdparty</feature>
27 - <bundle>mvn:net.onrc.onos.sb/onos-sb/0.0.1</bundle> 27 + <bundle>mvn:net.onrc.onos.sb/onos-sb/0.0.1</bundle>
28 - <bundle>mvn:org.projectfloodlight/openflowj/0.3.6-SNAPSHOT</bundle> 28 + <bundle>mvn:org.projectfloodlight/openflowj/0.3.6-SNAPSHOT</bundle>
29 - </feature> 29 + </feature>
30 - 30 +
31 -</features> 31 +</features>
......
...@@ -5,16 +5,15 @@ ...@@ -5,16 +5,15 @@
5 <modelVersion>4.0.0</modelVersion> 5 <modelVersion>4.0.0</modelVersion>
6 6
7 <parent> 7 <parent>
8 - <groupId>net.onrc.onos</groupId> 8 + <groupId>org.onlab.onos</groupId>
9 <artifactId>onos</artifactId> 9 <artifactId>onos</artifactId>
10 <version>1.0.0-SNAPSHOT</version> 10 <version>1.0.0-SNAPSHOT</version>
11 <relativePath>../pom.xml</relativePath> 11 <relativePath>../pom.xml</relativePath>
12 </parent> 12 </parent>
13 13
14 <artifactId>onos-features</artifactId> 14 <artifactId>onos-features</artifactId>
15 - <packaging>jar</packaging> 15 + <packaging>pom</packaging>
16 16
17 - <name>onos-features</name>
18 <description>ONOS Apache Karaf feature definitions</description> 17 <description>ONOS Apache Karaf feature definitions</description>
19 18
20 <build> 19 <build>
...@@ -22,7 +21,7 @@ ...@@ -22,7 +21,7 @@
22 <plugin> 21 <plugin>
23 <groupId>org.codehaus.mojo</groupId> 22 <groupId>org.codehaus.mojo</groupId>
24 <artifactId>build-helper-maven-plugin</artifactId> 23 <artifactId>build-helper-maven-plugin</artifactId>
25 - <version>1.3</version> 24 + <version>1.9</version>
26 <executions> 25 <executions>
27 <execution> 26 <execution>
28 <id>attach-artifacts</id> 27 <id>attach-artifacts</id>
......
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<project xmlns="http://maven.apache.org/POM/4.0.0"
3 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
5 + <modelVersion>4.0.0</modelVersion>
6 +
7 + <parent>
8 + <groupId>org.onlab.onos</groupId>
9 + <artifactId>onos-net</artifactId>
10 + <version>1.0.0-SNAPSHOT</version>
11 + <relativePath>../pom.xml</relativePath>
12 + </parent>
13 +
14 + <artifactId>onos-api</artifactId>
15 + <packaging>bundle</packaging>
16 +
17 + <description>ONOS network control API</description>
18 +
19 +</project>
1 -package net.onrc.onos.api; 1 +package org.onlab.onos.net;
2 2
3 /** 3 /**
4 * Base abstraction of a piece of information about network elements. 4 * Base abstraction of a piece of information about network elements.
......
1 -package net.onrc.onos.api; 1 +package org.onlab.onos.net;
2 2
3 import java.net.URI; 3 import java.net.URI;
4 4
......
1 +package org.onlab.onos.net;
2 +
3 +/**
4 + * Example of a simple service that provides greetings and it
5 + * remembers the names which were greeted.
6 + */
7 +public interface GreetService {
8 +
9 + /**
10 + * Returns a greeting tailored to the specified name.
11 + *
12 + * @param name some name
13 + * @return greeting
14 + */
15 + String yo(String name);
16 +
17 + /**
18 + * Returns an iterable of names encountered thus far.
19 + *
20 + * @return iterable of names
21 + */
22 + Iterable<String> names();
23 +}
1 -package net.onrc.onos.api; 1 +package org.onlab.onos.net;
2 2
3 /** 3 /**
4 * Representation of a port number. 4 * Representation of a port number.
......
1 -package net.onrc.onos.api; 1 +package org.onlab.onos.net;
2 2
3 /** 3 /**
4 * Abstraction of a provider of information about network environment. 4 * Abstraction of a provider of information about network environment.
......
1 -package net.onrc.onos.api; 1 +package org.onlab.onos.net;
2 2
3 /** 3 /**
4 * Broker used for registering/unregistering information providers with the core. 4 * Broker used for registering/unregistering information providers with the core.
......
1 -package net.onrc.onos.api; 1 +package org.onlab.onos.net;
2 2
3 /** 3 /**
4 * Notion of provider identity. 4 * Notion of provider identity.
......
1 -package net.onrc.onos.api; 1 +package org.onlab.onos.net;
2 2
3 /** 3 /**
4 * Abstraction of a service through which providers can inject information 4 * Abstraction of a service through which providers can inject information
......
1 -package net.onrc.onos.api.device; 1 +package org.onlab.onos.net.device;
2 2
3 -import net.onrc.onos.api.Description; 3 +import org.onlab.onos.net.Description;
4 4
5 import java.net.URI; 5 import java.net.URI;
6 6
...@@ -18,4 +18,4 @@ public interface DeviceDescription extends Description { ...@@ -18,4 +18,4 @@ public interface DeviceDescription extends Description {
18 */ 18 */
19 URI deviceURI(); 19 URI deviceURI();
20 20
21 -}
...\ No newline at end of file ...\ No newline at end of file
21 +}
......
1 -package net.onrc.onos.api.device; 1 +package org.onlab.onos.net.device;
2 2
3 -import net.onrc.onos.api.Provider; 3 +import org.onlab.onos.net.Provider;
4 4
5 /** 5 /**
6 * Abstraction of a device information provider. 6 * Abstraction of a device information provider.
......
1 -package net.onrc.onos.api.device; 1 +package org.onlab.onos.net.device;
2 2
3 -import net.onrc.onos.api.ProviderBroker; 3 +import org.onlab.onos.net.ProviderBroker;
4 4
5 /** 5 /**
6 * Abstraction of a device provider brokerage. 6 * Abstraction of a device provider brokerage.
......
1 -package net.onrc.onos.api.device; 1 +package org.onlab.onos.net.device;
2 2
3 -import net.onrc.onos.api.ProviderService; 3 +import org.onlab.onos.net.ProviderService;
4 4
5 import java.util.List; 5 import java.util.List;
6 6
......
1 -package net.onrc.onos.api.device; 1 +package org.onlab.onos.net.device;
2 2
3 /** 3 /**
4 * Information about a port. 4 * Information about a port.
......
1 -package net.onrc.onos.api.flow; 1 +package org.onlab.onos.net.flow;
2 2
3 -package net.onrc.onos.api.Description; 3 +import org.onlab.onos.net.Description;
4 4
5 /** 5 /**
6 * Information about a flow rule. 6 * Information about a flow rule.
......
1 -package net.onrc.onos.api.flow; 1 +package org.onlab.onos.net.flow;
2 2
3 -import net.onrc.onos.api.Provider; 3 +import org.onlab.onos.net.Provider;
4 4
5 /** 5 /**
6 * Abstraction of a flow rule provider. 6 * Abstraction of a flow rule provider.
7 */ 7 */
8 public interface FlowRuleProvider extends Provider { 8 public interface FlowRuleProvider extends Provider {
9 -}
...\ No newline at end of file ...\ No newline at end of file
9 +}
......
1 -package net.onrc.onos.api.flow; 1 +package org.onlab.onos.net.flow;
2 2
3 -import net.onrc.onos.api.ProviderBroker; 3 +import org.onlab.onos.net.ProviderBroker;
4 4
5 /** 5 /**
6 * Abstraction for a flow rule provider brokerage. 6 * Abstraction for a flow rule provider brokerage.
......
1 -package net.onrc.onos.api.flow; 1 +package org.onlab.onos.net.flow;
2 2
3 -import net.onrc.onos.api.ProviderService; 3 +import org.onlab.onos.net.ProviderService;
4 4
5 /** 5 /**
6 * Service through which flowrule providers can inject flowrule information into 6 * Service through which flowrule providers can inject flowrule information into
...@@ -32,4 +32,4 @@ public interface FlowRuleProviderService extends ProviderService { ...@@ -32,4 +32,4 @@ public interface FlowRuleProviderService extends ProviderService {
32 */ 32 */
33 void flowAdded(FlowDescription flowDescription); 33 void flowAdded(FlowDescription flowDescription);
34 34
35 -}
...\ No newline at end of file ...\ No newline at end of file
35 +}
......
1 -package net.onrc.onos.api.host; 1 +package org.onlab.onos.net.host;
2 2
3 /** 3 /**
4 * Information describing host and its location. 4 * Information describing host and its location.
...@@ -6,6 +6,6 @@ package net.onrc.onos.api.host; ...@@ -6,6 +6,6 @@ package net.onrc.onos.api.host;
6 public interface HostDescription { 6 public interface HostDescription {
7 7
8 // IP, MAC, VLAN-ID, HostLocation -> (ConnectionPoint + timestamp) 8 // IP, MAC, VLAN-ID, HostLocation -> (ConnectionPoint + timestamp)
9 -
10 9
11 } 10 }
11 +
......
1 -package net.onrc.onos.api.host; 1 +package org.onlab.onos.net.host;
2 2
3 -import net.onrc.onos.api.Provider; 3 +import org.onlab.onos.net.Provider;
4 4
5 /** 5 /**
6 * Provider of information about hosts and their location on the network. 6 * Provider of information about hosts and their location on the network.
......
1 -package net.onrc.onos.api.host; 1 +package org.onlab.onos.net.host;
2 2
3 -import net.onrc.onos.api.ProviderBroker; 3 +import org.onlab.onos.net.ProviderBroker;
4 4
5 /** 5 /**
6 * Abstraction of a host provider brokerage. 6 * Abstraction of a host provider brokerage.
......
1 -package net.onrc.onos.api.host; 1 +package org.onlab.onos.net.host;
2 2
3 -import net.onrc.onos.api.ProviderService; 3 +import org.onlab.onos.net.ProviderService;
4 4
5 /** 5 /**
6 * Means of conveying host information to the core. 6 * Means of conveying host information to the core.
7 */ 7 */
8 public interface HostProviderService extends ProviderService { 8 public interface HostProviderService extends ProviderService {
9 - 9 +
10 void hostDetected(HostDescription hostDescription); 10 void hostDetected(HostDescription hostDescription);
11 11
12 } 12 }
......
1 -package net.onrc.onos.api.link; 1 +package org.onlab.onos.net.link;
2 2
3 /** 3 /**
4 * Describes an infrastructure link. 4 * Describes an infrastructure link.
......
1 -package net.onrc.onos.api.link; 1 +package org.onlab.onos.net.link;
2 2
3 -import net.onrc.onos.api.Provider; 3 +import org.onlab.onos.net.Provider;
4 4
5 /** 5 /**
6 * Abstraction of an entity providing information about infrastructure links 6 * Abstraction of an entity providing information about infrastructure links
......
1 -package net.onrc.onos.api.link; 1 +package org.onlab.onos.net.link;
2 2
3 -import net.onrc.onos.api.ProviderBroker; 3 +import org.onlab.onos.net.ProviderBroker;
4 4
5 /** 5 /**
6 * Abstraction of an infrastructure link provider brokerage. 6 * Abstraction of an infrastructure link provider brokerage.
......
1 -package net.onrc.onos.api.link; 1 +package org.onlab.onos.net.link;
2 2
3 -import net.onrc.onos.api.ProviderService; 3 +import org.onlab.onos.net.ProviderService;
4 4
5 /** 5 /**
6 * Means for injecting link information into the core. 6 * Means for injecting link information into the core.
......
1 -package net.onrc.onos.api.topology; 1 +package org.onlab.onos.net.topology;
2 2
3 -import net.onrc.onos.api.Description; 3 +import org.onlab.onos.net.Description;
4 4
5 import java.util.Collection; 5 import java.util.Collection;
6 6
...@@ -17,4 +17,4 @@ public interface TopologyDescription extends Description { ...@@ -17,4 +17,4 @@ public interface TopologyDescription extends Description {
17 */ 17 */
18 Collection<Description> details(); 18 Collection<Description> details();
19 19
20 -}
...\ No newline at end of file ...\ No newline at end of file
20 +}
......
1 -package net.onrc.onos.api.topology; 1 +package org.onlab.onos.net.topology;
2 2
3 -import net.onrc.onos.api.Provider; 3 +import org.onlab.onos.net.Provider;
4 4
5 /** 5 /**
6 * Means for injecting topology information into the core. 6 * Means for injecting topology information into the core.
......
1 -package net.onrc.onos.api.topology; 1 +package org.onlab.onos.net.topology;
2 2
3 -import net.onrc.onos.api.ProviderBroker; 3 +import org.onlab.onos.net.ProviderBroker;
4 4
5 /** 5 /**
6 * Abstraction of a network topology provider brokerage. 6 * Abstraction of a network topology provider brokerage.
......
1 -package net.onrc.onos.api.topology; 1 +package org.onlab.onos.net.topology;
2 2
3 -import net.onrc.onos.api.ProviderService; 3 +import org.onlab.onos.net.ProviderService;
4 4
5 /** 5 /**
6 * Means for injecting topology information into the core. 6 * Means for injecting topology information into the core.
......
1 +<body>
2 +ONOS API definitions.
3 +</body>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<project xmlns="http://maven.apache.org/POM/4.0.0"
3 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
5 + <modelVersion>4.0.0</modelVersion>
6 +
7 + <parent>
8 + <groupId>org.onlab.onos</groupId>
9 + <artifactId>onos-net</artifactId>
10 + <version>1.0.0-SNAPSHOT</version>
11 + <relativePath>../pom.xml</relativePath>
12 + </parent>
13 +
14 + <artifactId>onos-core</artifactId>
15 + <packaging>bundle</packaging>
16 +
17 + <description>ONOS network control core subsystems</description>
18 +
19 + <dependencies>
20 + <dependency>
21 + <groupId>org.onlab.onos</groupId>
22 + <artifactId>onos-api</artifactId>
23 + </dependency>
24 + <dependency>
25 + <groupId>org.slf4j</groupId>
26 + <artifactId>slf4j-api</artifactId>
27 + </dependency>
28 + <dependency>
29 + <groupId>org.apache.felix</groupId>
30 + <artifactId>org.apache.felix.scr.annotations</artifactId>
31 + </dependency>
32 + </dependencies>
33 +
34 + <build>
35 + <plugins>
36 + <plugin>
37 + <groupId>org.apache.felix</groupId>
38 + <artifactId>maven-scr-plugin</artifactId>
39 + </plugin>
40 + </plugins>
41 + </build>
42 +
43 +</project>
1 +package org.onlab.onos.net.impl;
2 +
3 +import com.google.common.collect.ImmutableSet;
4 +import org.apache.felix.scr.annotations.Activate;
5 +import org.apache.felix.scr.annotations.Component;
6 +import org.apache.felix.scr.annotations.Deactivate;
7 +import org.apache.felix.scr.annotations.Service;
8 +import org.onlab.onos.net.GreetService;
9 +import org.slf4j.Logger;
10 +import org.slf4j.LoggerFactory;
11 +
12 +import java.util.HashSet;
13 +import java.util.Set;
14 +
15 +import static com.google.common.base.Preconditions.checkNotNull;
16 +
17 +/**
18 + * Trivial implementation of the seed service to demonstrate component and
19 + * service annotations.
20 + */
21 +@Component(immediate = true)
22 +@Service
23 +public class GreetManager implements GreetService {
24 +
25 + private final Logger log = LoggerFactory.getLogger(getClass());
26 +
27 + private final Set<String> names = new HashSet<>();
28 +
29 + @Override
30 + public synchronized String yo(String name) {
31 + checkNotNull(name, "Name cannot be null");
32 + names.add(name);
33 + log.info("Greeted '{}'", name);
34 + return "Whazup " + name + "?";
35 + }
36 +
37 + @Override
38 + public synchronized Iterable<String> names() {
39 + return ImmutableSet.copyOf(names);
40 + }
41 +
42 + @Activate
43 + public void activate() {
44 + log.info("SeedManager started");
45 + }
46 +
47 + @Deactivate
48 + public void deactivate() {
49 + log.info("SeedManager stopped");
50 + }
51 +
52 +}
1 +package org.onlab.onos.net.impl;
2 +
3 +import org.apache.felix.scr.annotations.Activate;
4 +import org.apache.felix.scr.annotations.Component;
5 +import org.apache.felix.scr.annotations.Deactivate;
6 +import org.apache.felix.scr.annotations.Reference;
7 +import org.apache.felix.scr.annotations.ReferenceCardinality;
8 +import org.onlab.onos.net.GreetService;
9 +import org.slf4j.Logger;
10 +import org.slf4j.LoggerFactory;
11 +
12 +/**
13 + * Example of a component that does not provide any service, but consumes one.
14 + */
15 +@Component(immediate = true)
16 +public class SomeOtherComponent {
17 +
18 + private final Logger log = LoggerFactory.getLogger(SomeOtherComponent.class);
19 +
20 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
21 + protected GreetService service;
22 + // protected to allow injection for testing;
23 + // alternative is to write bindSeedService and unbindSeedService, which is more code
24 +
25 + @Activate
26 + public void activate() {
27 + log.info("SomeOtherComponent started");
28 + service.yo("neighbour");
29 + }
30 +
31 + @Deactivate
32 + public void deactivate() {
33 + log.info("SomeOtherComponent stopped");
34 + }
35 +
36 +}
1 +<body>
2 +ONOS core implementations.
3 +</body>
...\ No newline at end of file ...\ No newline at end of file
1 +package org.onlab.onos.net.impl;
2 +
3 +import org.junit.Test;
4 +import org.onlab.onos.net.GreetService;
5 +
6 +import java.util.Iterator;
7 +
8 +import static org.junit.Assert.assertEquals;
9 +import static org.junit.Assert.assertFalse;
10 +
11 +/**
12 + * Example of a component &amp; service implementation unit test.
13 + */
14 +public class GreetManagerTest {
15 +
16 + @Test
17 + public void basics() {
18 + GreetService service = new GreetManager();
19 + assertEquals("incorrect greeting", "Whazup dude?", service.yo("dude"));
20 +
21 + Iterator<String> names = service.names().iterator();
22 + assertEquals("incorrect name", "dude", names.next());
23 + assertFalse("no more names expected", names.hasNext());
24 + }
25 +
26 + @Test(expected = NullPointerException.class)
27 + public void nullArg() {
28 + new GreetManager().yo(null);
29 + }
30 +
31 +}
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<project xmlns="http://maven.apache.org/POM/4.0.0"
3 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
5 + <modelVersion>4.0.0</modelVersion>
6 +
7 + <parent>
8 + <groupId>org.onlab.onos</groupId>
9 + <artifactId>onos</artifactId>
10 + <version>1.0.0-SNAPSHOT</version>
11 + <relativePath>../pom.xml</relativePath>
12 + </parent>
13 +
14 + <artifactId>onos-net</artifactId>
15 + <packaging>pom</packaging>
16 +
17 + <description>ONOS Core root project</description>
18 +
19 + <modules>
20 + <module>api</module>
21 + <module>core</module>
22 + </modules>
23 +
24 + <dependencies>
25 + <dependency>
26 + <groupId>com.google.guava</groupId>
27 + <artifactId>guava</artifactId>
28 + </dependency>
29 + </dependencies>
30 +
31 + <build>
32 + <plugins>
33 + <plugin>
34 + <groupId>org.apache.felix</groupId>
35 + <artifactId>maven-bundle-plugin</artifactId>
36 + </plugin>
37 + </plugins>
38 + </build>
39 +
40 +</project>
1 +# See: http://rolf-engelhard.de/2011/04/using-the-same-suppression-filter-for-checkstyle-in-eclipse-and-maven/
2 +config_loc=conf/checkstyle
This diff is collapsed. Click to expand it.
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!DOCTYPE suppressions PUBLIC "-//Puppy Crawl//DTD Suppressions 1.1//EN" "http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
3 +
4 +<suppressions>
5 + <!--
6 + Note: Exclusion definition exists in multiple places.
7 + - In file ${findbugs.excludeFilterFile} defined at top of pom.xml
8 + - In file conf/checkstyle/onos_suppressions.xml (this file)
9 + - maven-pmd-plugin configuration in pom.xml
10 + (under build and reporting)
11 + -->
12 +
13 + <suppress files=".*" checks="FinalParametersCheck"/>
14 + <suppress files=".*" checks="MagicNumbersCheck"/>
15 + <suppress files=".*" checks="DesignForExtensionCheck"/>
16 + <suppress files=".*" checks="TodoCommentCheck"/>
17 + <suppress files=".*" checks="AvoidInlineConditionalsCheck"/>
18 + <suppress files=".*" checks="OperatorWrapCheck"/>
19 +</suppressions>
20 +
1 +<FindBugsFilter>
2 + <!--
3 + Note: Exclusion definition exists in multiple places.
4 + - In file ${findbugs.excludeFilterFile} defined at top of pom.xml (this file)
5 + - In file conf/checkstyle/onos_suppressions.xml
6 + - maven-pmd-plugin configuration in pom.xml
7 + (under build and reporting)
8 + -->
9 + <Match>
10 + <Class name="~net\.onrc\.onos\.core\.datastore\.serializers\..*" />
11 + </Match>
12 + <Match>
13 + <Class name="~.*edu\.stanford\..*"/>
14 + </Match>
15 + <Match>
16 + <Class name="~.org\.projectfloodlight\..*"/>
17 + </Match>
18 +</FindBugsFilter>
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
1 +package net.onrc.onos.of.ctl;
2 +
3 +import org.projectfloodlight.openflow.protocol.OFVersion;
4 +
5 +import net.onrc.onos.of.ctl.registry.IControllerRegistry;
6 +
7 +/**
8 + * Interface to passed to controller class in order to allow
9 + * it to spawn the appropriate type of switch and furthermore
10 + * specify a registry object (ie. ZooKeeper).
11 + *
12 + */
13 +public interface IOFSwitchManager {
14 +
15 + /**
16 + * Given a description string for a switch spawn the
17 + * concrete representation of that switch.
18 + *
19 + * @param mfr manufacturer description
20 + * @param hwDesc hardware description
21 + * @param swDesc software description
22 + * @param ofv openflow version
23 + * @return A switch of type IOFSwitch.
24 + */
25 + public IOFSwitch getSwitchImpl(String mfr, String hwDesc, String swDesc, OFVersion ofv);
26 +
27 + /**
28 + * Returns the mastership registry used during controller-switch role election.
29 + * @return the registry
30 + */
31 + public IControllerRegistry getRegistry();
32 +
33 +}
1 +package net.onrc.onos.of.ctl;
2 +
3 +import org.projectfloodlight.openflow.protocol.OFControllerRole;
4 +
5 +/**
6 + * The role of the controller as it pertains to a particular switch.
7 + * Note that this definition of the role enum is different from the
8 + * OF1.3 definition. It is maintained here to be backward compatible to
9 + * earlier versions of the controller code. This enum is translated
10 + * to the OF1.3 enum, before role messages are sent to the switch.
11 + * See sendRoleRequestMessage method in OFSwitchImpl
12 + */
13 +public enum Role {
14 + EQUAL(OFControllerRole.ROLE_EQUAL),
15 + MASTER(OFControllerRole.ROLE_MASTER),
16 + SLAVE(OFControllerRole.ROLE_SLAVE);
17 +
18 + private Role(OFControllerRole nxRole) {
19 + nxRole.ordinal();
20 + }
21 + /*
22 + private static Map<Integer,Role> nxRoleToEnum
23 + = new HashMap<Integer,Role>();
24 + static {
25 + for(Role r: Role.values())
26 + nxRoleToEnum.put(r.toNxRole(), r);
27 + }
28 + public int toNxRole() {
29 + return nxRole;
30 + }
31 + // Return the enum representing the given nxRole or null if no
32 + // such role exists
33 + public static Role fromNxRole(int nxRole) {
34 + return nxRoleToEnum.get(nxRole);
35 + }*/
36 +}
1 +/**
2 + * Copyright 2012, Big Switch Networks, Inc.
3 + * Originally created by David Erickson, Stanford University
4 + *
5 + * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 + * not use this file except in compliance with the License. You may obtain
7 + * a copy of the License at
8 + *
9 + * http://www.apache.org/licenses/LICENSE-2.0
10 + *
11 + * Unless required by applicable law or agreed to in writing, software
12 + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 + * License for the specific language governing permissions and limitations
15 + * under the License.
16 + **/
17 +
18 +package net.onrc.onos.of.ctl.annotations;
19 +
20 +import java.lang.annotation.ElementType;
21 +import java.lang.annotation.Target;
22 +
23 +/**
24 + * Annotation used to set the category for log messages for a class.
25 + *
26 + */
27 +@Target({ ElementType.TYPE, ElementType.METHOD })
28 +public @interface LogMessageCategory {
29 +
30 + /**
31 + * The category for the log messages for this class.
32 + *
33 + * @return
34 + */
35 + String value() default "Core";
36 +}
1 +/**
2 + * Copyright 2012, Big Switch Networks, Inc.
3 + * Originally created by David Erickson, Stanford University
4 + *
5 + * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 + * not use this file except in compliance with the License. You may obtain
7 + * a copy of the License at
8 + *
9 + * http://www.apache.org/licenses/LICENSE-2.0
10 + *
11 + * Unless required by applicable law or agreed to in writing, software
12 + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 + * License for the specific language governing permissions and limitations
15 + * under the License.
16 + **/
17 +
18 +package net.onrc.onos.of.ctl.annotations;
19 +
20 +import java.lang.annotation.ElementType;
21 +import java.lang.annotation.Target;
22 +
23 +/**
24 + * Annotation used to document log messages. This can be used to generate
25 + * documentation on syslog output.
26 + *
27 + */
28 +@Target({ ElementType.TYPE, ElementType.METHOD })
29 +public @interface LogMessageDoc {
30 + public static final String NO_ACTION = "No action is required.";
31 + public static final String UNKNOWN_ERROR = "An unknown error occured";
32 + public static final String GENERIC_ACTION =
33 + "Examine the returned error or exception and take " +
34 + "appropriate action.";
35 + public static final String CHECK_SWITCH =
36 + "Check the health of the indicated switch. " +
37 + "Test and troubleshoot IP connectivity.";
38 + public static final String CHECK_CONTROLLER =
39 + "Verify controller system health, CPU usage, and memory. " +
40 + "Rebooting the controller node may help if the controller " +
41 + "node is in a distressed state.";
42 + public static final String REPORT_CONTROLLER_BUG =
43 + "This is likely a defect in the controller. Please report this " +
44 + "issue. Restarting the controller or switch may help to " +
45 + "alleviate.";
46 + public static final String REPORT_SWITCH_BUG =
47 + "This is likely a defect in the switch. Please report this " +
48 + "issue. Restarting the controller or switch may help to " +
49 + "alleviate.";
50 +
51 + /**
52 + * The log level for the log message.
53 + *
54 + * @return the log level as a tring
55 + */
56 + String level() default "INFO";
57 +
58 + /**
59 + * The message that will be printed.
60 + *
61 + * @return the message
62 + */
63 + String message() default UNKNOWN_ERROR;
64 +
65 + /**
66 + * An explanation of the meaning of the log message.
67 + *
68 + * @return the explanation
69 + */
70 + String explanation() default UNKNOWN_ERROR;
71 +
72 + /**
73 + * The recommendated action associated with the log message.
74 + *
75 + * @return the recommendation
76 + */
77 + String recommendation() default NO_ACTION;
78 +}
1 +/**
2 + * Copyright 2012, Big Switch Networks, Inc.
3 + * Originally created by David Erickson, Stanford University
4 + *
5 + * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 + * not use this file except in compliance with the License. You may obtain
7 + * a copy of the License at
8 + *
9 + * http://www.apache.org/licenses/LICENSE-2.0
10 + *
11 + * Unless required by applicable law or agreed to in writing, software
12 + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 + * License for the specific language governing permissions and limitations
15 + * under the License.
16 + **/
17 +
18 +package net.onrc.onos.of.ctl.annotations;
19 +
20 +import java.lang.annotation.ElementType;
21 +import java.lang.annotation.Target;
22 +
23 +/**
24 + * Annotation used to document log messages. This can be used to generate
25 + * documentation on syslog output. This version allows multiple log messages
26 + * to be documentated on an interface.
27 + *
28 + */
29 +@Target({ ElementType.TYPE, ElementType.METHOD })
30 +public @interface LogMessageDocs {
31 + /**
32 + * A list of {@link LogMessageDoc} elements.
33 + *
34 + * @return the list of log message doc
35 + */
36 + LogMessageDoc[] value();
37 +}
1 +package net.onrc.onos.of.ctl.debugcounter;
2 +
3 +public interface IDebugCounter {
4 + /**
5 + * Increments the counter by 1 thread-locally, and immediately flushes to
6 + * the global counter storage. This method should be used for counters that
7 + * are updated outside the OF message processing pipeline.
8 + */
9 + void updateCounterWithFlush();
10 +
11 + /**
12 + * Increments the counter by 1 thread-locally. Flushing to the global
13 + * counter storage is delayed (happens with flushCounters() in IDebugCounterService),
14 + * resulting in higher performance. This method should be used for counters
15 + * updated in the OF message processing pipeline.
16 + */
17 + void updateCounterNoFlush();
18 +
19 + /**
20 + * Increments the counter thread-locally by the 'incr' specified, and immediately
21 + * flushes to the global counter storage. This method should be used for counters
22 + * that are updated outside the OF message processing pipeline.
23 + */
24 + void updateCounterWithFlush(int incr);
25 +
26 + /**
27 + * Increments the counter thread-locally by the 'incr' specified. Flushing to the global
28 + * counter storage is delayed (happens with flushCounters() in IDebugCounterService),
29 + * resulting in higher performance. This method should be used for counters
30 + * updated in the OF message processing pipeline.
31 + */
32 + void updateCounterNoFlush(int incr);
33 +
34 + /**
35 + * Retrieve the value of the counter from the global counter store.
36 + */
37 + long getCounterValue();
38 +}
1 +package net.onrc.onos.of.ctl.debugcounter;
2 +
3 +import java.util.Collections;
4 +import java.util.List;
5 +
6 +import net.onrc.onos.of.ctl.debugcounter.DebugCounter.DebugCounterInfo;
7 +
8 +public class NullDebugCounter implements IDebugCounterService {
9 +
10 + @Override
11 + public void flushCounters() {
12 +
13 + }
14 +
15 + @Override
16 + public void resetAllCounters() {
17 +
18 + }
19 +
20 + @Override
21 + public void resetAllModuleCounters(String moduleName) {
22 +
23 + }
24 +
25 +
26 + @Override
27 + public void resetCounterHierarchy(String moduleName, String counterHierarchy) {
28 +
29 + }
30 +
31 + @Override
32 + public void enableCtrOnDemand(String moduleName, String counterHierarchy) {
33 +
34 + }
35 +
36 + @Override
37 + public void disableCtrOnDemand(String moduleName, String counterHierarchy) {
38 +
39 + }
40 +
41 + @Override
42 + public List<DebugCounterInfo> getCounterHierarchy(String moduleName,
43 + String counterHierarchy) {
44 + return Collections.emptyList();
45 + }
46 +
47 + @Override
48 + public List<DebugCounterInfo> getAllCounterValues() {
49 + return Collections.emptyList();
50 + }
51 +
52 + @Override
53 + public List<DebugCounterInfo> getModuleCounterValues(String moduleName) {
54 + return Collections.emptyList();
55 + }
56 +
57 + @Override
58 + public boolean containsModuleCounterHierarchy(String moduleName,
59 + String counterHierarchy) {
60 + return false;
61 + }
62 +
63 + @Override
64 + public boolean containsModuleName(String moduleName) {
65 + return false;
66 + }
67 +
68 + @Override
69 + public
70 + IDebugCounter
71 + registerCounter(String moduleName, String counterHierarchy,
72 + String counterDescription,
73 + CounterType counterType, String... metaData)
74 + throws MaxCountersRegistered {
75 + return new NullCounterImpl();
76 + }
77 +
78 + @Override
79 + public List<String> getModuleList() {
80 + return Collections.emptyList();
81 + }
82 +
83 + @Override
84 + public List<String> getModuleCounterList(String moduleName) {
85 + return Collections.emptyList();
86 + }
87 +
88 + public static class NullCounterImpl implements IDebugCounter {
89 +
90 + @Override
91 + public void updateCounterWithFlush() {
92 +
93 + }
94 +
95 + @Override
96 + public void updateCounterNoFlush() {
97 +
98 + }
99 +
100 + @Override
101 + public void updateCounterWithFlush(int incr) {
102 + }
103 +
104 + @Override
105 + public void updateCounterNoFlush(int incr) {
106 +
107 + }
108 +
109 + @Override
110 + public long getCounterValue() {
111 + return -1;
112 + }
113 +
114 + }
115 +
116 +}
1 +/**
2 + * Copyright 2011, Big Switch Networks, Inc.
3 + * Originally created by David Erickson, Stanford University
4 + *
5 + * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 + * not use this file except in compliance with the License. You may obtain
7 + * a copy of the License at
8 + *
9 + * http://www.apache.org/licenses/LICENSE-2.0
10 + *
11 + * Unless required by applicable law or agreed to in writing, software
12 + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 + * License for the specific language governing permissions and limitations
15 + * under the License.
16 + **/
17 +
18 +package net.onrc.onos.of.ctl.internal;
19 +
20 +/**
21 + * Exception is thrown when the handshake fails to complete.
22 + * before a specified time
23 + *
24 + */
25 +public class HandshakeTimeoutException extends Exception {
26 +
27 + private static final long serialVersionUID = 6859880268940337312L;
28 +
29 +}
1 +/**
2 +* Copyright 2011, Big Switch Networks, Inc.
3 +* Originally created by David Erickson, Stanford University
4 +*
5 +* Licensed under the Apache License, Version 2.0 (the "License"); you may
6 +* not use this file except in compliance with the License. You may obtain
7 +* a copy of the License at
8 +*
9 +* http://www.apache.org/licenses/LICENSE-2.0
10 +*
11 +* Unless required by applicable law or agreed to in writing, software
12 +* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 +* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 +* License for the specific language governing permissions and limitations
15 +* under the License.
16 +**/
17 +
18 +package net.onrc.onos.of.ctl.internal;
19 +
20 +import java.util.concurrent.TimeUnit;
21 +
22 +import org.jboss.netty.channel.ChannelHandlerContext;
23 +import org.jboss.netty.channel.ChannelStateEvent;
24 +import org.jboss.netty.channel.Channels;
25 +import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
26 +import org.jboss.netty.util.Timeout;
27 +import org.jboss.netty.util.Timer;
28 +import org.jboss.netty.util.TimerTask;
29 +
30 +/**
31 + * Trigger a timeout if a switch fails to complete handshake soon enough.
32 + */
33 +public class HandshakeTimeoutHandler
34 + extends SimpleChannelUpstreamHandler {
35 + static final HandshakeTimeoutException EXCEPTION =
36 + new HandshakeTimeoutException();
37 +
38 + final OFChannelHandler channelHandler;
39 + final Timer timer;
40 + final long timeoutNanos;
41 + volatile Timeout timeout;
42 +
43 + public HandshakeTimeoutHandler(OFChannelHandler channelHandler,
44 + Timer timer,
45 + long timeoutSeconds) {
46 + super();
47 + this.channelHandler = channelHandler;
48 + this.timer = timer;
49 + this.timeoutNanos = TimeUnit.SECONDS.toNanos(timeoutSeconds);
50 +
51 + }
52 +
53 + @Override
54 + public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e)
55 + throws Exception {
56 + if (timeoutNanos > 0) {
57 + timeout = timer.newTimeout(new HandshakeTimeoutTask(ctx),
58 + timeoutNanos, TimeUnit.NANOSECONDS);
59 + }
60 + ctx.sendUpstream(e);
61 + }
62 +
63 + @Override
64 + public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e)
65 + throws Exception {
66 + if (timeout != null) {
67 + timeout.cancel();
68 + timeout = null;
69 + }
70 + }
71 +
72 + private final class HandshakeTimeoutTask implements TimerTask {
73 +
74 + private final ChannelHandlerContext ctx;
75 +
76 + HandshakeTimeoutTask(ChannelHandlerContext ctx) {
77 + this.ctx = ctx;
78 + }
79 +
80 + @Override
81 + public void run(Timeout t) throws Exception {
82 + if (t.isCancelled()) {
83 + return;
84 + }
85 +
86 + if (!ctx.getChannel().isOpen()) {
87 + return;
88 + }
89 + if (!channelHandler.isHandshakeComplete()) {
90 + Channels.fireExceptionCaught(ctx, EXCEPTION);
91 + }
92 + }
93 + }
94 +}
1 +/**
2 + * Copyright 2011, Big Switch Networks, Inc.
3 + * Originally created by David Erickson, Stanford University
4 + *
5 + * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 + * not use this file except in compliance with the License. You may obtain
7 + * a copy of the License at
8 + *
9 + * http://www.apache.org/licenses/LICENSE-2.0
10 + *
11 + * Unless required by applicable law or agreed to in writing, software
12 + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 + * License for the specific language governing permissions and limitations
15 + * under the License.
16 + **/
17 +
18 +package net.onrc.onos.of.ctl.internal;
19 +
20 +
21 +import org.jboss.netty.buffer.ChannelBuffer;
22 +import org.jboss.netty.channel.Channel;
23 +import org.jboss.netty.channel.ChannelHandlerContext;
24 +import org.jboss.netty.handler.codec.frame.FrameDecoder;
25 +import org.projectfloodlight.openflow.protocol.OFFactories;
26 +import org.projectfloodlight.openflow.protocol.OFMessage;
27 +import org.projectfloodlight.openflow.protocol.OFMessageReader;
28 +
29 +/**
30 + * Decode an openflow message from a Channel, for use in a netty pipeline.
31 + */
32 +public class OFMessageDecoder extends FrameDecoder {
33 +
34 + @Override
35 + protected Object decode(ChannelHandlerContext ctx, Channel channel,
36 + ChannelBuffer buffer) throws Exception {
37 + if (!channel.isConnected()) {
38 + // In testing, I see decode being called AFTER decode last.
39 + // This check avoids that from reading corrupted frames
40 + return null;
41 + }
42 +
43 + // Note that a single call to decode results in reading a single
44 + // OFMessage from the channel buffer, which is passed on to, and processed
45 + // by, the controller (in OFChannelHandler).
46 + // This is different from earlier behavior (with the original openflowj),
47 + // where we parsed all the messages in the buffer, before passing on
48 + // a list of the parsed messages to the controller.
49 + // The performance *may or may not* not be as good as before.
50 + OFMessageReader<OFMessage> reader = OFFactories.getGenericReader();
51 + OFMessage message = reader.readFrom(buffer);
52 +
53 + return message;
54 + }
55 +
56 +}
1 +/**
2 + * Copyright 2011, Big Switch Networks, Inc.
3 + * Originally created by David Erickson, Stanford University
4 + *
5 + * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 + * not use this file except in compliance with the License. You may obtain
7 + * a copy of the License at
8 + *
9 + * http://www.apache.org/licenses/LICENSE-2.0
10 + *
11 + * Unless required by applicable law or agreed to in writing, software
12 + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 + * License for the specific language governing permissions and limitations
15 + * under the License.
16 + **/
17 +
18 +package net.onrc.onos.of.ctl.internal;
19 +
20 +import java.util.List;
21 +
22 +import org.jboss.netty.buffer.ChannelBuffer;
23 +import org.jboss.netty.buffer.ChannelBuffers;
24 +import org.jboss.netty.channel.Channel;
25 +import org.jboss.netty.channel.ChannelHandlerContext;
26 +import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
27 +import org.projectfloodlight.openflow.protocol.OFMessage;
28 +
29 +
30 +/**
31 + * Encode an openflow message for output into a ChannelBuffer, for use in a
32 + * netty pipeline.
33 + */
34 +public class OFMessageEncoder extends OneToOneEncoder {
35 +
36 + @Override
37 + protected Object encode(ChannelHandlerContext ctx, Channel channel,
38 + Object msg) throws Exception {
39 + if (!(msg instanceof List)) {
40 + return msg;
41 + }
42 +
43 + @SuppressWarnings("unchecked")
44 + List<OFMessage> msglist = (List<OFMessage>) msg;
45 + /* XXX S can't get length of OFMessage in loxigen's openflowj??
46 + int size = 0;
47 + for (OFMessage ofm : msglist) {
48 + size += ofm.getLengthU();
49 + }*/
50 +
51 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
52 +
53 + for (OFMessage ofm : msglist) {
54 + ofm.writeTo(buf);
55 + }
56 + return buf;
57 + }
58 +
59 +}
1 +/**
2 +* Copyright 2011, Big Switch Networks, Inc.
3 +* Originally created by David Erickson, Stanford University
4 +*
5 +* Licensed under the Apache License, Version 2.0 (the "License"); you may
6 +* not use this file except in compliance with the License. You may obtain
7 +* a copy of the License at
8 +*
9 +* http://www.apache.org/licenses/LICENSE-2.0
10 +*
11 +* Unless required by applicable law or agreed to in writing, software
12 +* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 +* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 +* License for the specific language governing permissions and limitations
15 +* under the License.
16 +**/
17 +
18 +package net.onrc.onos.of.ctl.internal;
19 +
20 +import java.util.concurrent.ThreadPoolExecutor;
21 +
22 +import org.jboss.netty.channel.ChannelPipeline;
23 +import org.jboss.netty.channel.ChannelPipelineFactory;
24 +import org.jboss.netty.channel.Channels;
25 +import org.jboss.netty.handler.execution.ExecutionHandler;
26 +import org.jboss.netty.handler.timeout.IdleStateHandler;
27 +import org.jboss.netty.handler.timeout.ReadTimeoutHandler;
28 +import org.jboss.netty.util.ExternalResourceReleasable;
29 +import org.jboss.netty.util.HashedWheelTimer;
30 +import org.jboss.netty.util.Timer;
31 +
32 +/**
33 + * Creates a ChannelPipeline for a server-side openflow channel.
34 + */
35 +public class OpenflowPipelineFactory
36 + implements ChannelPipelineFactory, ExternalResourceReleasable {
37 +
38 + protected Controller controller;
39 + protected ThreadPoolExecutor pipelineExecutor;
40 + protected Timer timer;
41 + protected IdleStateHandler idleHandler;
42 + protected ReadTimeoutHandler readTimeoutHandler;
43 +
44 + public OpenflowPipelineFactory(Controller controller,
45 + ThreadPoolExecutor pipelineExecutor) {
46 + super();
47 + this.controller = controller;
48 + this.pipelineExecutor = pipelineExecutor;
49 + this.timer = new HashedWheelTimer();
50 + this.idleHandler = new IdleStateHandler(timer, 20, 25, 0);
51 + this.readTimeoutHandler = new ReadTimeoutHandler(timer, 30);
52 + }
53 +
54 + @Override
55 + public ChannelPipeline getPipeline() throws Exception {
56 + OFChannelHandler handler = new OFChannelHandler(controller);
57 +
58 + ChannelPipeline pipeline = Channels.pipeline();
59 + pipeline.addLast("ofmessagedecoder", new OFMessageDecoder());
60 + pipeline.addLast("ofmessageencoder", new OFMessageEncoder());
61 + pipeline.addLast("idle", idleHandler);
62 + pipeline.addLast("timeout", readTimeoutHandler);
63 + // XXX S ONOS: was 15 increased it to fix Issue #296
64 + pipeline.addLast("handshaketimeout",
65 + new HandshakeTimeoutHandler(handler, timer, 60));
66 + if (pipelineExecutor != null) {
67 + pipeline.addLast("pipelineExecutor",
68 + new ExecutionHandler(pipelineExecutor));
69 + }
70 + pipeline.addLast("handler", handler);
71 + return pipeline;
72 + }
73 +
74 + @Override
75 + public void releaseExternalResources() {
76 + timer.stop();
77 + }
78 +}
1 +package net.onrc.onos.of.ctl.internal;
2 +
3 +/**
4 + * Thrown when IOFSwitch.startDriverHandshake() is called more than once.
5 + *
6 + */
7 +public class SwitchDriverSubHandshakeAlreadyStarted extends
8 + SwitchDriverSubHandshakeException {
9 + private static final long serialVersionUID = -5491845708752443501L;
10 +
11 + public SwitchDriverSubHandshakeAlreadyStarted() {
12 + super();
13 + }
14 +}
1 +package net.onrc.onos.of.ctl.internal;
2 +
3 +import org.projectfloodlight.openflow.protocol.OFMessage;
4 +
5 +
6 +/**
7 + * Indicates that a message was passed to a switch driver's subhandshake
8 + * handling code but the driver has already completed the sub-handshake.
9 + *
10 + */
11 +public class SwitchDriverSubHandshakeCompleted
12 + extends SwitchDriverSubHandshakeException {
13 + private static final long serialVersionUID = -8817822245846375995L;
14 +
15 + public SwitchDriverSubHandshakeCompleted(OFMessage m) {
16 + super("Sub-Handshake is already complete but received message "
17 + + m.getType());
18 + }
19 +}
1 +package net.onrc.onos.of.ctl.internal;
2 +
3 +/**
4 + * Base class for exception thrown by switch driver sub-handshake processing.
5 + *
6 + */
7 +public class SwitchDriverSubHandshakeException extends RuntimeException {
8 + private static final long serialVersionUID = -6257836781419604438L;
9 +
10 + protected SwitchDriverSubHandshakeException() {
11 + super();
12 + }
13 +
14 + protected SwitchDriverSubHandshakeException(String arg0, Throwable arg1) {
15 + super(arg0, arg1);
16 + }
17 +
18 + protected SwitchDriverSubHandshakeException(String arg0) {
19 + super(arg0);
20 + }
21 +
22 + protected SwitchDriverSubHandshakeException(Throwable arg0) {
23 + super(arg0);
24 + }
25 +
26 +}
1 +package net.onrc.onos.of.ctl.internal;
2 +
3 +/**
4 + * Thrown when a switch driver's sub-handshake has not been started but an
5 + * operation requiring the sub-handshake has been attempted.
6 + *
7 + */
8 +public class SwitchDriverSubHandshakeNotStarted extends
9 + SwitchDriverSubHandshakeException {
10 + private static final long serialVersionUID = -5491845708752443501L;
11 +
12 + public SwitchDriverSubHandshakeNotStarted() {
13 + super();
14 + }
15 +}
1 +package net.onrc.onos.of.ctl.internal;
2 +
3 +/**
4 + * Thrown when a switch driver's sub-handshake state-machine receives an
5 + * unexpected OFMessage and/or is in an invald state.
6 + *
7 + */
8 +public class SwitchDriverSubHandshakeStateException extends
9 + SwitchDriverSubHandshakeException {
10 + private static final long serialVersionUID = -8249926069195147051L;
11 +
12 + public SwitchDriverSubHandshakeStateException(String msg) {
13 + super(msg);
14 + }
15 +}
1 +/**
2 + * Copyright 2011, Big Switch Networks, Inc.
3 + * Originally created by David Erickson, Stanford University
4 + *
5 + * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 + * not use this file except in compliance with the License. You may obtain
7 + * a copy of the License at
8 + *
9 + * http://www.apache.org/licenses/LICENSE-2.0
10 + *
11 + * Unless required by applicable law or agreed to in writing, software
12 + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 + * License for the specific language governing permissions and limitations
15 + * under the License.
16 + **/
17 +
18 +package net.onrc.onos.of.ctl.internal;
19 +
20 +/**
21 + * This exception indicates an error or unexpected message during
22 + * message handling. E.g., if an OFMessage is received that is illegal or
23 + * unexpected given the current handshake state.
24 + *
25 + * We don't allow wrapping other exception in a switch state exception. We
26 + * only log the SwitchStateExceptions message so the causing exceptions
27 + * stack trace is generally not available.
28 + *
29 + */
30 +public class SwitchStateException extends Exception {
31 +
32 + private static final long serialVersionUID = 9153954512470002631L;
33 +
34 + public SwitchStateException() {
35 + super();
36 + }
37 +
38 + public SwitchStateException(String arg0, Throwable arg1) {
39 + super(arg0, arg1);
40 + }
41 +
42 + public SwitchStateException(String arg0) {
43 + super(arg0);
44 + }
45 +
46 + public SwitchStateException(Throwable arg0) {
47 + super(arg0);
48 + }
49 +
50 +}
1 +package net.onrc.onos.of.ctl.registry;
2 +
3 +
4 +
5 +public class ControllerRegistryEntry implements Comparable<ControllerRegistryEntry> {
6 + //
7 + // TODO: Refactor the implementation and decide whether controllerId
8 + // is needed. If "yes", we might need to consider it inside the
9 + // compareTo(), equals() and hashCode() implementations.
10 + //
11 + private final String controllerId;
12 + private final int sequenceNumber;
13 +
14 + public ControllerRegistryEntry(String controllerId, int sequenceNumber) {
15 + this.controllerId = controllerId;
16 + this.sequenceNumber = sequenceNumber;
17 + }
18 +
19 + public String getControllerId() {
20 + return controllerId;
21 + }
22 +
23 + /**
24 + * Compares this object with the specified object for order.
25 + * NOTE: the test is based on ControllerRegistryEntry sequence numbers,
26 + * and doesn't include the controllerId.
27 + *
28 + * @param o the object to be compared.
29 + * @return a negative integer, zero, or a positive integer as this object
30 + * is less than, equal to, or greater than the specified object.
31 + */
32 + @Override
33 + public int compareTo(ControllerRegistryEntry o) {
34 + return this.sequenceNumber - o.sequenceNumber;
35 + }
36 +
37 + /**
38 + * Test whether some other object is "equal to" this one.
39 + * NOTE: the test is based on ControllerRegistryEntry sequence numbers,
40 + * and doesn't include the controllerId.
41 + *
42 + * @param obj the reference object with which to compare.
43 + * @return true if this object is the same as the obj argument; false
44 + * otherwise.
45 + */
46 + @Override
47 + public boolean equals(Object obj) {
48 + if (obj instanceof ControllerRegistryEntry) {
49 + ControllerRegistryEntry other = (ControllerRegistryEntry) obj;
50 + return this.sequenceNumber == other.sequenceNumber;
51 + }
52 + return false;
53 + }
54 +
55 + /**
56 + * Get the hash code for the object.
57 + * NOTE: the computation is based on ControllerRegistryEntry sequence
58 + * numbers, and doesn't include the controller ID.
59 + *
60 + * @return a hash code value for this object.
61 + */
62 + @Override
63 + public int hashCode() {
64 + return Integer.valueOf(this.sequenceNumber).hashCode();
65 + }
66 +}
1 +package net.onrc.onos.of.ctl.registry;
2 +
3 +import java.util.Collection;
4 +import java.util.List;
5 +import java.util.Map;
6 +
7 +import net.onrc.onos.of.ctl.util.InstanceId;
8 +
9 +/**
10 + * A registry service that allows ONOS to register controllers and switches in a
11 + * way that is global to the entire ONOS cluster. The registry is the arbiter
12 + * for allowing controllers to control switches.
13 + * <p/>
14 + * The OVS/OF1.{2,3} fault tolerance model is a switch connects to multiple
15 + * controllers, and the controllers send role requests to tell the switch their
16 + * role in controlling the switch.
17 + * <p/>
18 + * The ONOS fault tolerance model allows only a single controller to have
19 + * control of a switch (MASTER role) at once. Controllers therefore need a
20 + * mechanism that enables them to decide who should control a each switch. The
21 + * registry service provides this mechanism.
22 + */
23 +public interface IControllerRegistry {
24 +
25 + /**
26 + * Callback interface for control change events.
27 + */
28 + public interface ControlChangeCallback {
29 + /**
30 + * Called whenever the control changes from the point of view of the
31 + * registry. The callee can check whether they have control or not using
32 + * the hasControl parameter.
33 + *
34 + * @param dpid The switch that control has changed for
35 + * @param hasControl Whether the listener now has control or not
36 + */
37 + void controlChanged(long dpid, boolean hasControl);
38 + }
39 +
40 + /**
41 + * Request for control of a switch. This method does not block. When control
42 + * for a switch changes, the controlChanged method on the callback object
43 + * will be called. This happens any time the control changes while the
44 + * request is still active (until releaseControl is called)
45 + *
46 + * @param dpid Switch to request control for
47 + * @param cb Callback that will be used to notify caller of control changes
48 + * @throws RegistryException Errors contacting the registry service
49 + */
50 + public void requestControl(long dpid, ControlChangeCallback cb)
51 + throws RegistryException;
52 +
53 + /**
54 + * Stop trying to take control of a switch. This removes the entry for this
55 + * controller requesting this switch in the registry. If the controller had
56 + * control when this is called, another controller will now gain control of
57 + * the switch. This call doesn't block.
58 + *
59 + * @param dpid Switch to release control of
60 + */
61 + public void releaseControl(long dpid);
62 +
63 + /**
64 + * Check whether the controller has control of the switch This call doesn't
65 + * block.
66 + *
67 + * @param dpid Switch to check control of
68 + * @return true if controller has control of the switch.
69 + */
70 + public boolean hasControl(long dpid);
71 +
72 + /**
73 + * Check whether this instance is the leader for the cluster. This call
74 + * doesn't block.
75 + *
76 + * @return true if the instance is the leader for the cluster, otherwise
77 + * false.
78 + */
79 + public boolean isClusterLeader();
80 +
81 + /**
82 + * Gets the unique ID used to identify this ONOS instance in the cluster.
83 + *
84 + * @return Instance ID.
85 + */
86 + public InstanceId getOnosInstanceId();
87 +
88 + /**
89 + * Register a controller to the ONOS cluster. Must be called before the
90 + * registry can be used to take control of any switches.
91 + *
92 + * @param controllerId A unique string ID identifying this controller in the
93 + * cluster
94 + * @throws RegistryException for errors connecting to registry service,
95 + * controllerId already registered
96 + */
97 + public void registerController(String controllerId)
98 + throws RegistryException;
99 +
100 + /**
101 + * Get all controllers in the cluster.
102 + *
103 + * @return Collection of controller IDs
104 + * @throws RegistryException on error
105 + */
106 + public Collection<String> getAllControllers() throws RegistryException;
107 +
108 + /**
109 + * Get all switches in the cluster, along with which controller is in
110 + * control of them (if any) and any other controllers that have requested
111 + * control.
112 + *
113 + * @return Map of all switches.
114 + */
115 + public Map<String, List<ControllerRegistryEntry>> getAllSwitches();
116 +
117 + /**
118 + * Get the controller that has control of a given switch.
119 + *
120 + * @param dpid Switch to find controller for
121 + * @return controller ID
122 + * @throws RegistryException Errors contacting registry service
123 + */
124 + public String getControllerForSwitch(long dpid) throws RegistryException;
125 +
126 + /**
127 + * Get all switches controlled by a given controller.
128 + *
129 + * @param controllerId ID of the controller
130 + * @return Collection of dpids
131 + */
132 + public Collection<Long> getSwitchesControlledByController(String controllerId);
133 +
134 + /**
135 + * Get a unique Id Block.
136 + *
137 + * @return Id Block.
138 + */
139 + public IdBlock allocateUniqueIdBlock();
140 +
141 + /**
142 + * Get next unique id and retrieve a new range of ids if needed.
143 + *
144 + * @param range range to use for the identifier
145 + * @return Id Block.
146 + */
147 + public IdBlock allocateUniqueIdBlock(long range);
148 +
149 + /**
150 + * Get a globally unique ID.
151 + *
152 + * @return a globally unique ID.
153 + */
154 + public long getNextUniqueId();
155 +}
1 +package net.onrc.onos.of.ctl.registry;
2 +
3 +public class IdBlock {
4 + private final long start;
5 + private final long end;
6 + private final long size;
7 +
8 + public IdBlock(long start, long end, long size) {
9 + this.start = start;
10 + this.end = end;
11 + this.size = size;
12 + }
13 +
14 + public long getStart() {
15 + return start;
16 + }
17 +
18 + public long getEnd() {
19 + return end;
20 + }
21 +
22 + public long getSize() {
23 + return size;
24 + }
25 +
26 + @Override
27 + public String toString() {
28 + return "IdBlock [start=" + start + ", end=" + end + ", size=" + size
29 + + "]";
30 + }
31 +}
32 +
1 +package net.onrc.onos.of.ctl.registry;
2 +
3 +public class RegistryException extends Exception {
4 +
5 + private static final long serialVersionUID = -8276300722010217913L;
6 +
7 + public RegistryException(String message) {
8 + super(message);
9 + }
10 +
11 + public RegistryException(String message, Throwable cause) {
12 + super(message, cause);
13 + }
14 +
15 +}
1 +package net.onrc.onos.of.ctl.util;
2 +
3 +import org.projectfloodlight.openflow.util.HexString;
4 +
5 +/**
6 + * The class representing a network switch DPID.
7 + * This class is immutable.
8 + */
9 +public final class Dpid {
10 + private static final long UNKNOWN = 0;
11 + private final long value;
12 +
13 + /**
14 + * Default constructor.
15 + */
16 + public Dpid() {
17 + this.value = Dpid.UNKNOWN;
18 + }
19 +
20 + /**
21 + * Constructor from a long value.
22 + *
23 + * @param value the value to use.
24 + */
25 + public Dpid(long value) {
26 + this.value = value;
27 + }
28 +
29 + /**
30 + * Constructor from a string.
31 + *
32 + * @param value the value to use.
33 + */
34 + public Dpid(String value) {
35 + this.value = HexString.toLong(value);
36 + }
37 +
38 + /**
39 + * Get the value of the DPID.
40 + *
41 + * @return the value of the DPID.
42 + */
43 + public long value() {
44 + return value;
45 + }
46 +
47 + /**
48 + * Convert the DPID value to a ':' separated hexadecimal string.
49 + *
50 + * @return the DPID value as a ':' separated hexadecimal string.
51 + */
52 + @Override
53 + public String toString() {
54 + return HexString.toHexString(this.value);
55 + }
56 +
57 + @Override
58 + public boolean equals(Object other) {
59 + if (!(other instanceof Dpid)) {
60 + return false;
61 + }
62 +
63 + Dpid otherDpid = (Dpid) other;
64 +
65 + return value == otherDpid.value;
66 + }
67 +
68 + @Override
69 + public int hashCode() {
70 + int hash = 17;
71 + hash += 31 * hash + (int) (value ^ value >>> 32);
72 + return hash;
73 + }
74 +}
1 +package net.onrc.onos.of.ctl.util;
2 +
3 +import java.io.IOException;
4 +import java.util.Collection;
5 +import java.util.Date;
6 +import java.util.List;
7 +import java.util.Map;
8 +import java.util.Set;
9 +import java.util.concurrent.Future;
10 +
11 +import org.jboss.netty.channel.Channel;
12 +import org.projectfloodlight.openflow.protocol.OFActionType;
13 +import org.projectfloodlight.openflow.protocol.OFCapabilities;
14 +import org.projectfloodlight.openflow.protocol.OFDescStatsReply;
15 +import org.projectfloodlight.openflow.protocol.OFFeaturesReply;
16 +import org.projectfloodlight.openflow.protocol.OFMessage;
17 +import org.projectfloodlight.openflow.protocol.OFPortDesc;
18 +import org.projectfloodlight.openflow.protocol.OFPortDescStatsReply;
19 +import org.projectfloodlight.openflow.protocol.OFPortStatus;
20 +import org.projectfloodlight.openflow.protocol.OFStatsReply;
21 +import org.projectfloodlight.openflow.protocol.OFStatsRequest;
22 +import org.projectfloodlight.openflow.protocol.OFVersion;
23 +import org.projectfloodlight.openflow.types.DatapathId;
24 +import org.projectfloodlight.openflow.types.U64;
25 +import org.slf4j.Logger;
26 +import org.slf4j.LoggerFactory;
27 +
28 +import net.onrc.onos.of.ctl.IOFSwitch;
29 +import net.onrc.onos.of.ctl.Role;
30 +import net.onrc.onos.of.ctl.debugcounter.IDebugCounterService;
31 +import net.onrc.onos.of.ctl.debugcounter.IDebugCounterService.CounterException;
32 +
33 +public class DummySwitchForTesting implements IOFSwitch {
34 +
35 + protected static final Logger log = LoggerFactory.getLogger(DummySwitchForTesting.class);
36 +
37 + private Channel channel;
38 + private boolean connected = false;
39 + private OFVersion ofv = OFVersion.OF_10;
40 +
41 + private Collection<OFPortDesc> ports;
42 +
43 + private DatapathId datapathId;
44 +
45 + private Set<OFCapabilities> capabilities;
46 +
47 + private int buffers;
48 +
49 + private byte tables;
50 +
51 + private String stringId;
52 +
53 + private Role role;
54 +
55 + @Override
56 + public void disconnectSwitch() {
57 + this.channel.close();
58 + }
59 +
60 + @Override
61 + public void write(OFMessage m) throws IOException {
62 + this.channel.write(m);
63 +
64 + }
65 +
66 + @Override
67 + public void write(List<OFMessage> msglist) throws IOException {
68 + for (OFMessage m : msglist) {
69 + this.channel.write(m);
70 + }
71 +
72 + }
73 +
74 + @Override
75 + public Date getConnectedSince() {
76 + // TODO Auto-generated method stub
77 + return null;
78 + }
79 +
80 + @Override
81 + public int getNextTransactionId() {
82 + return 0;
83 + }
84 +
85 + @Override
86 + public boolean isConnected() {
87 + return this.connected;
88 + }
89 +
90 + @Override
91 + public void setConnected(boolean connected) {
92 + this.connected = connected;
93 +
94 + }
95 +
96 + @Override
97 + public void flush() {
98 + // TODO Auto-generated method stub
99 +
100 + }
101 +
102 + @Override
103 + public void setChannel(Channel channel) {
104 + this.channel = channel;
105 +
106 + }
107 +
108 + @Override
109 + public long getId() {
110 + if (this.stringId == null) {
111 + throw new RuntimeException("Features reply has not yet been set");
112 + }
113 + return this.datapathId.getLong();
114 + }
115 +
116 + @Override
117 + public String getStringId() {
118 + // TODO Auto-generated method stub
119 + return "DummySwitch";
120 + }
121 +
122 + @Override
123 + public int getNumBuffers() {
124 + // TODO Auto-generated method stub
125 + return 0;
126 + }
127 +
128 + @Override
129 + public Set<OFCapabilities> getCapabilities() {
130 + // TODO Auto-generated method stub
131 + return null;
132 + }
133 +
134 + @Override
135 + public byte getNumTables() {
136 + // TODO Auto-generated method stub
137 + return 0;
138 + }
139 +
140 + @Override
141 + public OFDescStatsReply getSwitchDescription() {
142 + // TODO Auto-generated method stub
143 + return null;
144 + }
145 +
146 + @Override
147 + public void cancelFeaturesReply(int transactionId) {
148 + // TODO Auto-generated method stub
149 +
150 + }
151 +
152 + @Override
153 + public Set<OFActionType> getActions() {
154 + // TODO Auto-generated method stub
155 + return null;
156 + }
157 +
158 + @Override
159 + public void setOFVersion(OFVersion version) {
160 + // TODO Auto-generated method stub
161 +
162 + }
163 +
164 + @Override
165 + public OFVersion getOFVersion() {
166 + return this.ofv;
167 + }
168 +
169 + @Override
170 + public Collection<OFPortDesc> getEnabledPorts() {
171 + // TODO Auto-generated method stub
172 + return null;
173 + }
174 +
175 + @Override
176 + public Collection<Integer> getEnabledPortNumbers() {
177 + // TODO Auto-generated method stub
178 + return null;
179 + }
180 +
181 + @Override
182 + public OFPortDesc getPort(int portNumber) {
183 + // TODO Auto-generated method stub
184 + return null;
185 + }
186 +
187 + @Override
188 + public OFPortDesc getPort(String portName) {
189 + // TODO Auto-generated method stub
190 + return null;
191 + }
192 +
193 + @Override
194 + public OrderedCollection<PortChangeEvent> processOFPortStatus(
195 + OFPortStatus ps) {
196 + // TODO Auto-generated method stub
197 + return null;
198 + }
199 +
200 + @Override
201 + public Collection<OFPortDesc> getPorts() {
202 + return ports;
203 + }
204 +
205 + @Override
206 + public boolean portEnabled(int portName) {
207 + // TODO Auto-generated method stub
208 + return false;
209 + }
210 +
211 + @Override
212 + public OrderedCollection<PortChangeEvent> setPorts(
213 + Collection<OFPortDesc> p) {
214 + this.ports = p;
215 + return null;
216 + }
217 +
218 + @Override
219 + public Map<Object, Object> getAttributes() {
220 + return null;
221 + }
222 +
223 + @Override
224 + public boolean hasAttribute(String name) {
225 + // TODO Auto-generated method stub
226 + return false;
227 + }
228 +
229 + @Override
230 + public Object getAttribute(String name) {
231 + return Boolean.FALSE;
232 + }
233 +
234 + @Override
235 + public void setAttribute(String name, Object value) {
236 + // TODO Auto-generated method stub
237 +
238 + }
239 +
240 + @Override
241 + public Object removeAttribute(String name) {
242 + // TODO Auto-generated method stub
243 + return null;
244 + }
245 +
246 + @Override
247 + public void deliverStatisticsReply(OFMessage reply) {
248 + // TODO Auto-generated method stub
249 +
250 + }
251 +
252 + @Override
253 + public void cancelStatisticsReply(int transactionId) {
254 + // TODO Auto-generated method stub
255 +
256 + }
257 +
258 + @Override
259 + public void cancelAllStatisticsReplies() {
260 + // TODO Auto-generated method stub
261 +
262 + }
263 +
264 + @Override
265 + public Future<List<OFStatsReply>> getStatistics(OFStatsRequest<?> request)
266 + throws IOException {
267 + // TODO Auto-generated method stub
268 + return null;
269 + }
270 +
271 + @Override
272 + public void clearAllFlowMods() {
273 + // TODO Auto-generated method stub
274 +
275 + }
276 +
277 + @Override
278 + public Role getRole() {
279 + return this.role;
280 + }
281 +
282 + @Override
283 + public void setRole(Role role) {
284 + this.role = role;
285 + }
286 +
287 + @Override
288 + public U64 getNextGenerationId() {
289 + // TODO Auto-generated method stub
290 + return null;
291 + }
292 +
293 + @Override
294 + public void setDebugCounterService(IDebugCounterService debugCounter)
295 + throws CounterException {
296 + // TODO Auto-generated method stub
297 +
298 + }
299 +
300 + @Override
301 + public void startDriverHandshake() throws IOException {
302 + // TODO Auto-generated method stub
303 +
304 + }
305 +
306 + @Override
307 + public boolean isDriverHandshakeComplete() {
308 + return true;
309 + }
310 +
311 + @Override
312 + public void processDriverHandshakeMessage(OFMessage m) {
313 +
314 + }
315 +
316 + @Override
317 + public void setTableFull(boolean isFull) {
318 + // TODO Auto-generated method stub
319 +
320 + }
321 +
322 + @Override
323 + public void setFeaturesReply(OFFeaturesReply featuresReply) {
324 + if (featuresReply == null) {
325 + log.error("Error setting featuresReply for switch: {}", getStringId());
326 + return;
327 + }
328 + this.datapathId = featuresReply.getDatapathId();
329 + this.capabilities = featuresReply.getCapabilities();
330 + this.buffers = (int) featuresReply.getNBuffers();
331 + this.tables = (byte) featuresReply.getNTables();
332 + this.stringId = this.datapathId.toString();
333 +
334 + }
335 +
336 + @Override
337 + public void setPortDescReply(OFPortDescStatsReply portDescReply) {
338 + // TODO Auto-generated method stub
339 +
340 + }
341 +
342 + @Override
343 + public void handleMessage(OFMessage m) {
344 + log.info("Got packet {} but I am dumb so I don't know what to do.", m);
345 + }
346 +
347 + @Override
348 + public boolean portEnabled(String portName) {
349 + // TODO Auto-generated method stub
350 + return false;
351 + }
352 +
353 + @Override
354 + public OrderedCollection<PortChangeEvent> comparePorts(
355 + Collection<OFPortDesc> p) {
356 + // TODO Auto-generated method stub
357 + return null;
358 + }
359 +
360 +}
1 +package net.onrc.onos.of.ctl.util;
2 +
3 +import java.util.EnumSet;
4 +import java.util.Set;
5 +
6 +/**
7 + * A utility class to convert between integer based bitmaps for (OpenFlow)
8 + * flags and Enum and EnumSet based representations.
9 + *
10 + * The enum used to represent individual flags needs to implement the
11 + * BitmapableEnum interface.
12 + *
13 + * Example:
14 + * {@code
15 + * int bitmap = 0x11; // OFPPC_PORT_DOWN | OFPPC_NO_STP
16 + * EnumSet<OFPortConfig> s = toEnumSet(OFPortConfig.class, bitmap);
17 + * // s will contain OFPPC_PORT_DOWN and OFPPC_NO_STP
18 + * }
19 + *
20 + * {@code
21 + * EnumSet<OFPortConfig> s = EnumSet.of(OFPPC_NO_STP, OFPPC_PORT_DOWN);
22 + * int bitmap = toBitmap(s); // returns 0x11
23 + * }
24 + *
25 + */
26 +public final class EnumBitmaps {
27 +
28 +
29 + private EnumBitmaps() { }
30 +
31 + /**
32 + * Enums used to represent individual flags needs to implement this
33 + * interface.
34 + */
35 + public interface BitmapableEnum {
36 + /** Return the value in the bitmap that the enum constant represents.
37 + * The returned value must have only a single bit set. E.g.,1 << 3
38 + */
39 + int getValue();
40 + }
41 +
42 +
43 + /**
44 + * Convert an integer bitmap to an EnumSet.
45 + *
46 + * See class description for example
47 + * @param type The Enum class to use. Must implement BitmapableEnum
48 + * @param bitmap The integer bitmap
49 + * @return A newly allocated EnumSet representing the bits set in the
50 + * bitmap
51 + * @throws NullPointerException if type is null
52 + * @throws IllegalArgumentException if any enum constant from type has
53 + * more than one bit set.
54 + * @throws IllegalArgumentException if the bitmap has any bits set not
55 + * represented by an enum constant.
56 + */
57 + public static <E extends Enum<E> & BitmapableEnum>
58 + EnumSet<E> toEnumSet(Class<E> type, int bitmap) {
59 + if (type == null) {
60 + throw new NullPointerException("Given enum type must not be null");
61 + }
62 + EnumSet<E> s = EnumSet.noneOf(type);
63 + // allSetBitmap will eventually have all valid bits for the given
64 + // type set.
65 + int allSetBitmap = 0;
66 + for (E element: type.getEnumConstants()) {
67 + if (Integer.bitCount(element.getValue()) != 1) {
68 + String msg = String.format("The %s (%x) constant of the " +
69 + "enum %s is supposed to represent a bitmap entry but " +
70 + "has more than one bit set.",
71 + element.toString(), element.getValue(), type.getName());
72 + throw new IllegalArgumentException(msg);
73 + }
74 + allSetBitmap |= element.getValue();
75 + if ((bitmap & element.getValue()) != 0) {
76 + s.add(element);
77 + }
78 + }
79 + if (((~allSetBitmap) & bitmap) != 0) {
80 + // check if only valid flags are set in the given bitmap
81 + String msg = String.format("The bitmap %x for enum %s has " +
82 + "bits set that are presented by any enum constant",
83 + bitmap, type.getName());
84 + throw new IllegalArgumentException(msg);
85 + }
86 + return s;
87 + }
88 +
89 + /**
90 + * Return the bitmap mask with all possible bits set. E.g., If a bitmap
91 + * has the individual flags 0x1, 0x2, and 0x8 (note the missing 0x4) then
92 + * the mask will be 0xb (1011 binary)
93 + *
94 + * @param type The Enum class to use. Must implement BitmapableEnum
95 + * @throws NullPointerException if type is null
96 + * @throws IllegalArgumentException if any enum constant from type has
97 + * more than one bit set
98 + * @return an integer with all possible bits for the given bitmap enum
99 + * type set.
100 + */
101 + public static <E extends Enum<E> & BitmapableEnum>
102 + int getMask(Class<E> type) {
103 + if (type == null) {
104 + throw new NullPointerException("Given enum type must not be null");
105 + }
106 + // allSetBitmap will eventually have all valid bits for the given
107 + // type set.
108 + int allSetBitmap = 0;
109 + for (E element: type.getEnumConstants()) {
110 + if (Integer.bitCount(element.getValue()) != 1) {
111 + String msg = String.format("The %s (%x) constant of the " +
112 + "enum %s is supposed to represent a bitmap entry but " +
113 + "has more than one bit set.",
114 + element.toString(), element.getValue(), type.getName());
115 + throw new IllegalArgumentException(msg);
116 + }
117 + allSetBitmap |= element.getValue();
118 + }
119 + return allSetBitmap;
120 + }
121 +
122 + /**
123 + * Convert the given EnumSet to the integer bitmap representation.
124 + * @param set The EnumSet to convert. The enum must implement
125 + * BitmapableEnum
126 + * @return the integer bitmap
127 + * @throws IllegalArgumentException if an enum constant from the set (!) has
128 + * more than one bit set
129 + * @throws NullPointerException if the set is null
130 + */
131 + public static <E extends Enum<E> & BitmapableEnum>
132 + int toBitmap(Set<E> set) {
133 + if (set == null) {
134 + throw new NullPointerException("Given set must not be null");
135 + }
136 + int bitmap = 0;
137 + for (E element: set) {
138 + if (Integer.bitCount(element.getValue()) != 1) {
139 + String msg = String.format("The %s (%x) constant in the set " +
140 + "is supposed to represent a bitmap entry but " +
141 + "has more than one bit set.",
142 + element.toString(), element.getValue());
143 + throw new IllegalArgumentException(msg);
144 + }
145 + bitmap |= element.getValue();
146 + }
147 + return bitmap;
148 + }
149 +}
1 +/**
2 + * Copyright 2012, Big Switch Networks, Inc.
3 + * Originally created by David Erickson, Stanford University
4 + *
5 + * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 + * not use this file except in compliance with the License. You may obtain
7 + * a copy of the License at
8 + *
9 + * http://www.apache.org/licenses/LICENSE-2.0
10 + *
11 + * Unless required by applicable law or agreed to in writing, software
12 + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 + * License for the specific language governing permissions and limitations
15 + * under the License.
16 + **/
17 +
18 +package net.onrc.onos.of.ctl.util;
19 +
20 +import java.util.Iterator;
21 +import java.util.NoSuchElementException;
22 +
23 +/**
24 + * An iterator that will filter values from an iterator and return only
25 + * those values that match the predicate.
26 + */
27 +public abstract class FilterIterator<T> implements Iterator<T> {
28 + protected Iterator<T> subIterator;
29 + protected T next;
30 +
31 + /**
32 + * Construct a filter iterator from the given sub iterator.
33 + *
34 + * @param subIterator the sub iterator over which we'll filter
35 + */
36 + public FilterIterator(Iterator<T> subIterator) {
37 + super();
38 + this.subIterator = subIterator;
39 + }
40 +
41 + /**
42 + * Check whether the given value should be returned by the
43 + * filter.
44 + *
45 + * @param value the value to check
46 + * @return true if the value should be included
47 + */
48 + protected abstract boolean matches(T value);
49 +
50 + // ***********
51 + // Iterator<T>
52 + // ***********
53 +
54 + @Override
55 + public boolean hasNext() {
56 + if (next != null) {
57 + return true;
58 + }
59 +
60 + while (subIterator.hasNext()) {
61 + next = subIterator.next();
62 + if (matches(next)) {
63 + return true;
64 + }
65 + }
66 + next = null;
67 + return false;
68 + }
69 +
70 + @Override
71 + public T next() {
72 + if (hasNext()) {
73 + T cur = next;
74 + next = null;
75 + return cur;
76 + }
77 + throw new NoSuchElementException();
78 + }
79 +
80 + @Override
81 + public void remove() {
82 + throw new UnsupportedOperationException();
83 + }
84 +
85 +}
1 +package net.onrc.onos.of.ctl.util;
2 +
3 +import static com.google.common.base.Preconditions.checkNotNull;
4 +import static com.google.common.base.Preconditions.checkArgument;
5 +
6 +/**
7 + * The class representing an ONOS Instance ID.
8 + *
9 + * This class is immutable.
10 + */
11 +public final class InstanceId {
12 + private final String id;
13 +
14 + /**
15 + * Constructor from a string value.
16 + *
17 + * @param id the value to use.
18 + */
19 + public InstanceId(String id) {
20 + this.id = checkNotNull(id);
21 + checkArgument(!id.isEmpty(), "Empty ONOS Instance ID");
22 + }
23 +
24 + @Override
25 + public int hashCode() {
26 + return id.hashCode();
27 + }
28 +
29 + @Override
30 + public boolean equals(Object obj) {
31 + if (obj == this) {
32 + return true;
33 + }
34 +
35 + if (!(obj instanceof InstanceId)) {
36 + return false;
37 + }
38 +
39 + InstanceId that = (InstanceId) obj;
40 + return this.id.equals(that.id);
41 + }
42 +
43 + @Override
44 + public String toString() {
45 + return id;
46 + }
47 +}
1 +/**
2 + * Copyright 2012 Big Switch Networks, Inc.
3 + * Originally created by David Erickson, Stanford University
4 + *
5 + * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 + * not use this file except in compliance with the License. You may obtain
7 + * a copy of the License at
8 + *
9 + * http://www.apache.org/licenses/LICENSE-2.0
10 + *
11 + * Unless required by applicable law or agreed to in writing, software
12 + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 + * License for the specific language governing permissions and limitations
15 + * under the License.
16 + **/
17 +
18 +package net.onrc.onos.of.ctl.util;
19 +
20 +import java.util.Iterator;
21 +import java.util.NoSuchElementException;
22 +
23 +/**
24 + * Iterator over all values in an iterator of iterators.
25 + *
26 + * @param <T> the type of elements returned by this iterator
27 + */
28 +public class IterableIterator<T> implements Iterator<T> {
29 + Iterator<? extends Iterable<T>> subIterator;
30 + Iterator<T> current = null;
31 +
32 + public IterableIterator(Iterator<? extends Iterable<T>> subIterator) {
33 + super();
34 + this.subIterator = subIterator;
35 + }
36 +
37 + @Override
38 + public boolean hasNext() {
39 + if (current == null) {
40 + if (subIterator.hasNext()) {
41 + current = subIterator.next().iterator();
42 + } else {
43 + return false;
44 + }
45 + }
46 + while (!current.hasNext() && subIterator.hasNext()) {
47 + current = subIterator.next().iterator();
48 + }
49 +
50 + return current.hasNext();
51 + }
52 +
53 + @Override
54 + public T next() {
55 + if (hasNext()) {
56 + return current.next();
57 + }
58 + throw new NoSuchElementException();
59 + }
60 +
61 + @Override
62 + public void remove() {
63 + if (hasNext()) {
64 + current.remove();
65 + }
66 + throw new NoSuchElementException();
67 + }
68 +}
1 +/**
2 + * Copyright 2011, Big Switch Networks, Inc.
3 + * Originally created by David Erickson, Stanford University
4 + *
5 + * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 + * not use this file except in compliance with the License. You may obtain
7 + * a copy of the License at
8 + *
9 + * http://www.apache.org/licenses/LICENSE-2.0
10 + *
11 + * Unless required by applicable law or agreed to in writing, software
12 + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 + * License for the specific language governing permissions and limitations
15 + * under the License.
16 + **/
17 +
18 +package net.onrc.onos.of.ctl.util;
19 +
20 +import java.util.LinkedHashMap;
21 +import java.util.Map;
22 +
23 +public class LRUHashMap<K, V> extends LinkedHashMap<K, V> {
24 +
25 + private static final long serialVersionUID = 1L;
26 +
27 + private final int capacity;
28 +
29 + public LRUHashMap(int capacity) {
30 + super(capacity + 1, 0.75f, true);
31 + this.capacity = capacity;
32 + }
33 +
34 + protected boolean removeEldestEntry(Map.Entry<K, V> eldest) {
35 + return size() > capacity;
36 + }
37 +
38 +}
1 +package net.onrc.onos.of.ctl.util;
2 +
3 +import java.util.Collection;
4 +import java.util.LinkedHashSet;
5 +
6 +import com.google.common.collect.ForwardingCollection;
7 +
8 +/**
9 + * A simple wrapper / forwarder that forwards all calls to a LinkedHashSet.
10 + * This wrappers sole reason for existence is to implement the
11 + * OrderedCollection marker interface.
12 + *
13 + */
14 +public class LinkedHashSetWrapper<E>
15 + extends ForwardingCollection<E> implements OrderedCollection<E> {
16 + private final Collection<E> delegate;
17 +
18 + public LinkedHashSetWrapper() {
19 + super();
20 + this.delegate = new LinkedHashSet<E>();
21 + }
22 +
23 + public LinkedHashSetWrapper(Collection<? extends E> c) {
24 + super();
25 + this.delegate = new LinkedHashSet<E>(c);
26 + }
27 +
28 + @Override
29 + protected Collection<E> delegate() {
30 + return this.delegate;
31 + }
32 +}
1 +/**
2 + * Copyright 2012 Big Switch Networks, Inc.
3 + * Originally created by David Erickson, Stanford University
4 + *
5 + * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 + * not use this file except in compliance with the License. You may obtain
7 + * a copy of the License at
8 + *
9 + * http://www.apache.org/licenses/LICENSE-2.0
10 + *
11 + * Unless required by applicable law or agreed to in writing, software
12 + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 + * License for the specific language governing permissions and limitations
15 + * under the License.
16 + **/
17 +
18 +package net.onrc.onos.of.ctl.util;
19 +
20 +import java.util.Iterator;
21 +import java.util.NoSuchElementException;
22 +
23 +/**
24 + * Iterator over all values in an iterator of iterators.
25 + *
26 + * @param <T> the type of elements returned by this iterator
27 + */
28 +public class MultiIterator<T> implements Iterator<T> {
29 + Iterator<Iterator<T>> subIterator;
30 + Iterator<T> current = null;
31 +
32 + public MultiIterator(Iterator<Iterator<T>> subIterator) {
33 + super();
34 + this.subIterator = subIterator;
35 + }
36 +
37 + @Override
38 + public boolean hasNext() {
39 + if (current == null) {
40 + if (subIterator.hasNext()) {
41 + current = subIterator.next();
42 + } else {
43 + return false;
44 + }
45 + }
46 + while (!current.hasNext() && subIterator.hasNext()) {
47 + current = subIterator.next();
48 + }
49 +
50 + return current.hasNext();
51 + }
52 +
53 + @Override
54 + public T next() {
55 + if (hasNext()) {
56 + return current.next();
57 + }
58 + throw new NoSuchElementException();
59 + }
60 +
61 + @Override
62 + public void remove() {
63 + if (hasNext()) {
64 + current.remove();
65 + }
66 + throw new NoSuchElementException();
67 + }
68 +}
1 +package net.onrc.onos.of.ctl.util;
2 +
3 +import java.util.Collection;
4 +
5 +/**
6 + * A marker interface indicating that this Collection defines a particular
7 + * iteration order. The details about the iteration order are specified by
8 + * the concrete implementation.
9 + *
10 + * @param <E>
11 + */
12 +public interface OrderedCollection<E> extends Collection<E> {
13 +
14 +}
1 +/**
2 + * Copyright 2011, Big Switch Networks, Inc.
3 + * Originally created by David Erickson, Stanford University
4 + *
5 + * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 + * not use this file except in compliance with the License. You may obtain
7 + * a copy of the License at
8 + *
9 + * http://www.apache.org/licenses/LICENSE-2.0
10 + *
11 + * Unless required by applicable law or agreed to in writing, software
12 + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 + * License for the specific language governing permissions and limitations
15 + * under the License.
16 + **/
17 +
18 +package net.onrc.onos.of.ctl.internal;
19 +
20 +import junit.framework.TestCase;
21 +import net.onrc.onos.of.ctl.IOFSwitch;
22 +
23 +import org.easymock.EasyMock;
24 +import org.junit.After;
25 +import org.junit.Before;
26 +import org.junit.Test;
27 +
28 +
29 +public class ControllerTest extends TestCase {
30 +
31 + private Controller controller;
32 + private IOFSwitch sw;
33 + private OFChannelHandler h;
34 +
35 + @Override
36 + @Before
37 + public void setUp() throws Exception {
38 + super.setUp();
39 + sw = EasyMock.createMock(IOFSwitch.class);
40 + h = EasyMock.createMock(OFChannelHandler.class);
41 + controller = new Controller();
42 + ControllerRunThread t = new ControllerRunThread();
43 + t.start();
44 + /*
45 + * Making sure the thread is properly started before making calls
46 + * to controller class.
47 + */
48 + Thread.sleep(200);
49 + }
50 +
51 + /**
52 + * Starts the base mocks used in these tests.
53 + */
54 + private void startMocks() {
55 + EasyMock.replay(sw, h);
56 + }
57 +
58 + /**
59 + * Reset the mocks to a known state.
60 + * Automatically called after tests.
61 + */
62 + @After
63 + private void resetMocks() {
64 + EasyMock.reset(sw);
65 + }
66 +
67 + /**
68 + * Fetches the controller instance.
69 + * @return the controller
70 + */
71 + public Controller getController() {
72 + return controller;
73 + }
74 +
75 + /**
76 + * Run the controller's main loop so that updates are processed.
77 + */
78 + protected class ControllerRunThread extends Thread {
79 + @Override
80 + public void run() {
81 + controller.openFlowPort = 0; // Don't listen
82 + controller.activate();
83 + }
84 + }
85 +
86 + /**
87 + * Verify that we are able to add a switch that just connected.
88 + * If it already exists then this should fail
89 + *
90 + * @throws Exception error
91 + */
92 + @Test
93 + public void testAddConnectedSwitches() throws Exception {
94 + startMocks();
95 + assertTrue(controller.addConnectedSwitch(0, h));
96 + assertFalse(controller.addConnectedSwitch(0, h));
97 + }
98 +
99 + /**
100 + * Add active master but cannot re-add active master.
101 + * @throws Exception an error occurred.
102 + */
103 + @Test
104 + public void testAddActivatedMasterSwitch() throws Exception {
105 + startMocks();
106 + controller.addConnectedSwitch(0, h);
107 + assertTrue(controller.addActivatedMasterSwitch(0, sw));
108 + assertFalse(controller.addActivatedMasterSwitch(0, sw));
109 + }
110 +
111 + /**
112 + * Tests that an activated switch can be added but cannot be re-added.
113 + *
114 + * @throws Exception an error occurred
115 + */
116 + @Test
117 + public void testAddActivatedEqualSwitch() throws Exception {
118 + startMocks();
119 + controller.addConnectedSwitch(0, h);
120 + assertTrue(controller.addActivatedEqualSwitch(0, sw));
121 + assertFalse(controller.addActivatedEqualSwitch(0, sw));
122 + }
123 +
124 + /**
125 + * Move an equal switch to master.
126 + * @throws Exception an error occurred
127 + */
128 + @Test
129 + public void testTranstitionToMaster() throws Exception {
130 + startMocks();
131 + controller.addConnectedSwitch(0, h);
132 + controller.addActivatedEqualSwitch(0, sw);
133 + controller.transitionToMasterSwitch(0);
134 + assertNotNull(controller.getMasterSwitch(0));
135 + }
136 +
137 + /**
138 + * Transition a master switch to equal state.
139 + * @throws Exception an error occurred
140 + */
141 + @Test
142 + public void testTranstitionToEqual() throws Exception {
143 + startMocks();
144 + controller.addConnectedSwitch(0, h);
145 + controller.addActivatedMasterSwitch(0, sw);
146 + controller.transitionToEqualSwitch(0);
147 + assertNotNull(controller.getEqualSwitch(0));
148 + }
149 +
150 + /**
151 + * Remove the switch from the controller instance.
152 + * @throws Exception an error occurred
153 + */
154 + @Test
155 + public void testRemoveSwitch() throws Exception {
156 + sw.cancelAllStatisticsReplies();
157 + EasyMock.expectLastCall().once();
158 + sw.setConnected(false);
159 + EasyMock.expectLastCall().once();
160 + startMocks();
161 + controller.addConnectedSwitch(0, h);
162 + controller.addActivatedMasterSwitch(0, sw);
163 + controller.removeConnectedSwitch(0);
164 + assertNull(controller.getSwitch(0));
165 + EasyMock.verify(sw, h);
166 + }
167 +}
1 +// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2 +// Copyright (c) 2011, 2012 Open Networking Foundation
3 +// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4 +// This library was generated by the LoxiGen Compiler.
5 +// See the file LICENSE.txt which should have been included in the source distribution
6 +
7 +// Automatically generated by LOXI from template const.java
8 +// Do not modify
9 +
10 +package org.projectfloodlight.openflow.protocol;
11 +
12 +import org.projectfloodlight.openflow.protocol.*;
13 +import org.projectfloodlight.openflow.protocol.action.*;
14 +import org.projectfloodlight.openflow.protocol.actionid.*;
15 +import org.projectfloodlight.openflow.protocol.bsntlv.*;
16 +import org.projectfloodlight.openflow.protocol.errormsg.*;
17 +import org.projectfloodlight.openflow.protocol.meterband.*;
18 +import org.projectfloodlight.openflow.protocol.instruction.*;
19 +import org.projectfloodlight.openflow.protocol.instructionid.*;
20 +import org.projectfloodlight.openflow.protocol.match.*;
21 +import org.projectfloodlight.openflow.protocol.oxm.*;
22 +import org.projectfloodlight.openflow.protocol.queueprop.*;
23 +import org.projectfloodlight.openflow.types.*;
24 +import org.projectfloodlight.openflow.util.*;
25 +import org.projectfloodlight.openflow.exceptions.*;
26 +
27 +public enum OFActionType {
28 + OUTPUT,
29 + SET_VLAN_VID,
30 + SET_VLAN_PCP,
31 + STRIP_VLAN,
32 + SET_DL_SRC,
33 + SET_DL_DST,
34 + SET_NW_SRC,
35 + SET_NW_DST,
36 + SET_NW_TOS,
37 + SET_TP_SRC,
38 + SET_TP_DST,
39 + ENQUEUE,
40 + EXPERIMENTER,
41 + SET_NW_ECN,
42 + COPY_TTL_OUT,
43 + COPY_TTL_IN,
44 + SET_MPLS_LABEL,
45 + SET_MPLS_TC,
46 + SET_MPLS_TTL,
47 + DEC_MPLS_TTL,
48 + PUSH_VLAN,
49 + POP_VLAN,
50 + PUSH_MPLS,
51 + POP_MPLS,
52 + SET_QUEUE,
53 + GROUP,
54 + SET_NW_TTL,
55 + DEC_NW_TTL,
56 + SET_FIELD,
57 + PUSH_PBB,
58 + POP_PBB;
59 +}
1 +// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2 +// Copyright (c) 2011, 2012 Open Networking Foundation
3 +// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4 +// This library was generated by the LoxiGen Compiler.
5 +// See the file LICENSE.txt which should have been included in the source distribution
6 +
7 +// Automatically generated by LOXI from template of_interface.java
8 +// Do not modify
9 +
10 +package org.projectfloodlight.openflow.protocol;
11 +
12 +import org.projectfloodlight.openflow.protocol.*;
13 +import org.projectfloodlight.openflow.protocol.action.*;
14 +import org.projectfloodlight.openflow.protocol.actionid.*;
15 +import org.projectfloodlight.openflow.protocol.bsntlv.*;
16 +import org.projectfloodlight.openflow.protocol.errormsg.*;
17 +import org.projectfloodlight.openflow.protocol.meterband.*;
18 +import org.projectfloodlight.openflow.protocol.instruction.*;
19 +import org.projectfloodlight.openflow.protocol.instructionid.*;
20 +import org.projectfloodlight.openflow.protocol.match.*;
21 +import org.projectfloodlight.openflow.protocol.oxm.*;
22 +import org.projectfloodlight.openflow.protocol.queueprop.*;
23 +import org.projectfloodlight.openflow.types.*;
24 +import org.projectfloodlight.openflow.util.*;
25 +import org.projectfloodlight.openflow.exceptions.*;
26 +import java.util.Set;
27 +import org.jboss.netty.buffer.ChannelBuffer;
28 +
29 +public interface OFAggregateStatsReply extends OFObject, OFStatsReply {
30 + OFVersion getVersion();
31 + OFType getType();
32 + long getXid();
33 + OFStatsType getStatsType();
34 + Set<OFStatsReplyFlags> getFlags();
35 + U64 getPacketCount();
36 + U64 getByteCount();
37 + long getFlowCount();
38 +
39 + void writeTo(ChannelBuffer channelBuffer);
40 +
41 + Builder createBuilder();
42 + public interface Builder extends OFStatsReply.Builder {
43 + OFAggregateStatsReply build();
44 + OFVersion getVersion();
45 + OFType getType();
46 + long getXid();
47 + Builder setXid(long xid);
48 + OFStatsType getStatsType();
49 + Set<OFStatsReplyFlags> getFlags();
50 + Builder setFlags(Set<OFStatsReplyFlags> flags);
51 + U64 getPacketCount();
52 + Builder setPacketCount(U64 packetCount);
53 + U64 getByteCount();
54 + Builder setByteCount(U64 byteCount);
55 + long getFlowCount();
56 + Builder setFlowCount(long flowCount);
57 + }
58 +}
1 +// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2 +// Copyright (c) 2011, 2012 Open Networking Foundation
3 +// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4 +// This library was generated by the LoxiGen Compiler.
5 +// See the file LICENSE.txt which should have been included in the source distribution
6 +
7 +// Automatically generated by LOXI from template of_interface.java
8 +// Do not modify
9 +
10 +package org.projectfloodlight.openflow.protocol;
11 +
12 +import org.projectfloodlight.openflow.protocol.*;
13 +import org.projectfloodlight.openflow.protocol.action.*;
14 +import org.projectfloodlight.openflow.protocol.actionid.*;
15 +import org.projectfloodlight.openflow.protocol.bsntlv.*;
16 +import org.projectfloodlight.openflow.protocol.errormsg.*;
17 +import org.projectfloodlight.openflow.protocol.meterband.*;
18 +import org.projectfloodlight.openflow.protocol.instruction.*;
19 +import org.projectfloodlight.openflow.protocol.instructionid.*;
20 +import org.projectfloodlight.openflow.protocol.match.*;
21 +import org.projectfloodlight.openflow.protocol.oxm.*;
22 +import org.projectfloodlight.openflow.protocol.queueprop.*;
23 +import org.projectfloodlight.openflow.types.*;
24 +import org.projectfloodlight.openflow.util.*;
25 +import org.projectfloodlight.openflow.exceptions.*;
26 +import java.util.Set;
27 +import org.jboss.netty.buffer.ChannelBuffer;
28 +
29 +public interface OFAggregateStatsRequest extends OFObject, OFStatsRequest<OFAggregateStatsReply>, OFRequest<OFAggregateStatsReply> {
30 + OFVersion getVersion();
31 + OFType getType();
32 + long getXid();
33 + OFStatsType getStatsType();
34 + Set<OFStatsRequestFlags> getFlags();
35 + TableId getTableId();
36 + OFPort getOutPort();
37 + OFGroup getOutGroup() throws UnsupportedOperationException;
38 + U64 getCookie() throws UnsupportedOperationException;
39 + U64 getCookieMask() throws UnsupportedOperationException;
40 + Match getMatch();
41 +
42 + void writeTo(ChannelBuffer channelBuffer);
43 +
44 + Builder createBuilder();
45 + public interface Builder extends OFStatsRequest.Builder<OFAggregateStatsReply> {
46 + OFAggregateStatsRequest build();
47 + OFVersion getVersion();
48 + OFType getType();
49 + long getXid();
50 + Builder setXid(long xid);
51 + OFStatsType getStatsType();
52 + Set<OFStatsRequestFlags> getFlags();
53 + Builder setFlags(Set<OFStatsRequestFlags> flags);
54 + TableId getTableId();
55 + Builder setTableId(TableId tableId);
56 + OFPort getOutPort();
57 + Builder setOutPort(OFPort outPort);
58 + OFGroup getOutGroup() throws UnsupportedOperationException;
59 + Builder setOutGroup(OFGroup outGroup) throws UnsupportedOperationException;
60 + U64 getCookie() throws UnsupportedOperationException;
61 + Builder setCookie(U64 cookie) throws UnsupportedOperationException;
62 + U64 getCookieMask() throws UnsupportedOperationException;
63 + Builder setCookieMask(U64 cookieMask) throws UnsupportedOperationException;
64 + Match getMatch();
65 + Builder setMatch(Match match);
66 + }
67 +}
1 +// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2 +// Copyright (c) 2011, 2012 Open Networking Foundation
3 +// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4 +// This library was generated by the LoxiGen Compiler.
5 +// See the file LICENSE.txt which should have been included in the source distribution
6 +
7 +// Automatically generated by LOXI from template of_interface.java
8 +// Do not modify
9 +
10 +package org.projectfloodlight.openflow.protocol;
11 +
12 +import org.projectfloodlight.openflow.protocol.*;
13 +import org.projectfloodlight.openflow.protocol.action.*;
14 +import org.projectfloodlight.openflow.protocol.actionid.*;
15 +import org.projectfloodlight.openflow.protocol.bsntlv.*;
16 +import org.projectfloodlight.openflow.protocol.errormsg.*;
17 +import org.projectfloodlight.openflow.protocol.meterband.*;
18 +import org.projectfloodlight.openflow.protocol.instruction.*;
19 +import org.projectfloodlight.openflow.protocol.instructionid.*;
20 +import org.projectfloodlight.openflow.protocol.match.*;
21 +import org.projectfloodlight.openflow.protocol.oxm.*;
22 +import org.projectfloodlight.openflow.protocol.queueprop.*;
23 +import org.projectfloodlight.openflow.types.*;
24 +import org.projectfloodlight.openflow.util.*;
25 +import org.projectfloodlight.openflow.exceptions.*;
26 +import org.jboss.netty.buffer.ChannelBuffer;
27 +
28 +public interface OFAsyncGetReply extends OFObject, OFMessage {
29 + OFVersion getVersion();
30 + OFType getType();
31 + long getXid();
32 + long getPacketInMaskEqualMaster();
33 + long getPacketInMaskSlave();
34 + long getPortStatusMaskEqualMaster();
35 + long getPortStatusMaskSlave();
36 + long getFlowRemovedMaskEqualMaster();
37 + long getFlowRemovedMaskSlave();
38 +
39 + void writeTo(ChannelBuffer channelBuffer);
40 +
41 + Builder createBuilder();
42 + public interface Builder extends OFMessage.Builder {
43 + OFAsyncGetReply build();
44 + OFVersion getVersion();
45 + OFType getType();
46 + long getXid();
47 + Builder setXid(long xid);
48 + long getPacketInMaskEqualMaster();
49 + Builder setPacketInMaskEqualMaster(long packetInMaskEqualMaster);
50 + long getPacketInMaskSlave();
51 + Builder setPacketInMaskSlave(long packetInMaskSlave);
52 + long getPortStatusMaskEqualMaster();
53 + Builder setPortStatusMaskEqualMaster(long portStatusMaskEqualMaster);
54 + long getPortStatusMaskSlave();
55 + Builder setPortStatusMaskSlave(long portStatusMaskSlave);
56 + long getFlowRemovedMaskEqualMaster();
57 + Builder setFlowRemovedMaskEqualMaster(long flowRemovedMaskEqualMaster);
58 + long getFlowRemovedMaskSlave();
59 + Builder setFlowRemovedMaskSlave(long flowRemovedMaskSlave);
60 + }
61 +}
1 +// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2 +// Copyright (c) 2011, 2012 Open Networking Foundation
3 +// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4 +// This library was generated by the LoxiGen Compiler.
5 +// See the file LICENSE.txt which should have been included in the source distribution
6 +
7 +// Automatically generated by LOXI from template of_interface.java
8 +// Do not modify
9 +
10 +package org.projectfloodlight.openflow.protocol;
11 +
12 +import org.projectfloodlight.openflow.protocol.*;
13 +import org.projectfloodlight.openflow.protocol.action.*;
14 +import org.projectfloodlight.openflow.protocol.actionid.*;
15 +import org.projectfloodlight.openflow.protocol.bsntlv.*;
16 +import org.projectfloodlight.openflow.protocol.errormsg.*;
17 +import org.projectfloodlight.openflow.protocol.meterband.*;
18 +import org.projectfloodlight.openflow.protocol.instruction.*;
19 +import org.projectfloodlight.openflow.protocol.instructionid.*;
20 +import org.projectfloodlight.openflow.protocol.match.*;
21 +import org.projectfloodlight.openflow.protocol.oxm.*;
22 +import org.projectfloodlight.openflow.protocol.queueprop.*;
23 +import org.projectfloodlight.openflow.types.*;
24 +import org.projectfloodlight.openflow.util.*;
25 +import org.projectfloodlight.openflow.exceptions.*;
26 +import org.jboss.netty.buffer.ChannelBuffer;
27 +
28 +public interface OFAsyncGetRequest extends OFObject, OFMessage, OFRequest<OFAsyncGetReply> {
29 + OFVersion getVersion();
30 + OFType getType();
31 + long getXid();
32 + long getPacketInMaskEqualMaster();
33 + long getPacketInMaskSlave();
34 + long getPortStatusMaskEqualMaster();
35 + long getPortStatusMaskSlave();
36 + long getFlowRemovedMaskEqualMaster();
37 + long getFlowRemovedMaskSlave();
38 +
39 + void writeTo(ChannelBuffer channelBuffer);
40 +
41 + Builder createBuilder();
42 + public interface Builder extends OFMessage.Builder {
43 + OFAsyncGetRequest build();
44 + OFVersion getVersion();
45 + OFType getType();
46 + long getXid();
47 + Builder setXid(long xid);
48 + long getPacketInMaskEqualMaster();
49 + Builder setPacketInMaskEqualMaster(long packetInMaskEqualMaster);
50 + long getPacketInMaskSlave();
51 + Builder setPacketInMaskSlave(long packetInMaskSlave);
52 + long getPortStatusMaskEqualMaster();
53 + Builder setPortStatusMaskEqualMaster(long portStatusMaskEqualMaster);
54 + long getPortStatusMaskSlave();
55 + Builder setPortStatusMaskSlave(long portStatusMaskSlave);
56 + long getFlowRemovedMaskEqualMaster();
57 + Builder setFlowRemovedMaskEqualMaster(long flowRemovedMaskEqualMaster);
58 + long getFlowRemovedMaskSlave();
59 + Builder setFlowRemovedMaskSlave(long flowRemovedMaskSlave);
60 + }
61 +}
1 +// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2 +// Copyright (c) 2011, 2012 Open Networking Foundation
3 +// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4 +// This library was generated by the LoxiGen Compiler.
5 +// See the file LICENSE.txt which should have been included in the source distribution
6 +
7 +// Automatically generated by LOXI from template of_interface.java
8 +// Do not modify
9 +
10 +package org.projectfloodlight.openflow.protocol;
11 +
12 +import org.projectfloodlight.openflow.protocol.*;
13 +import org.projectfloodlight.openflow.protocol.action.*;
14 +import org.projectfloodlight.openflow.protocol.actionid.*;
15 +import org.projectfloodlight.openflow.protocol.bsntlv.*;
16 +import org.projectfloodlight.openflow.protocol.errormsg.*;
17 +import org.projectfloodlight.openflow.protocol.meterband.*;
18 +import org.projectfloodlight.openflow.protocol.instruction.*;
19 +import org.projectfloodlight.openflow.protocol.instructionid.*;
20 +import org.projectfloodlight.openflow.protocol.match.*;
21 +import org.projectfloodlight.openflow.protocol.oxm.*;
22 +import org.projectfloodlight.openflow.protocol.queueprop.*;
23 +import org.projectfloodlight.openflow.types.*;
24 +import org.projectfloodlight.openflow.util.*;
25 +import org.projectfloodlight.openflow.exceptions.*;
26 +import java.util.Set;
27 +import org.jboss.netty.buffer.ChannelBuffer;
28 +
29 +public interface OFAsyncSet extends OFObject, OFMessage {
30 + OFVersion getVersion();
31 + OFType getType();
32 + long getXid();
33 + long getPacketInMaskEqualMaster();
34 + long getPacketInMaskSlave();
35 + long getPortStatusMaskEqualMaster();
36 + long getPortStatusMaskSlave();
37 + long getFlowRemovedMaskEqualMaster();
38 + long getFlowRemovedMaskSlave();
39 +
40 + void writeTo(ChannelBuffer channelBuffer);
41 +
42 + Builder createBuilder();
43 + public interface Builder extends OFMessage.Builder {
44 + OFAsyncSet build();
45 + OFVersion getVersion();
46 + OFType getType();
47 + long getXid();
48 + Builder setXid(long xid);
49 + long getPacketInMaskEqualMaster();
50 + Builder setPacketInMaskEqualMaster(long packetInMaskEqualMaster);
51 + long getPacketInMaskSlave();
52 + Builder setPacketInMaskSlave(long packetInMaskSlave);
53 + long getPortStatusMaskEqualMaster();
54 + Builder setPortStatusMaskEqualMaster(long portStatusMaskEqualMaster);
55 + long getPortStatusMaskSlave();
56 + Builder setPortStatusMaskSlave(long portStatusMaskSlave);
57 + long getFlowRemovedMaskEqualMaster();
58 + Builder setFlowRemovedMaskEqualMaster(long flowRemovedMaskEqualMaster);
59 + long getFlowRemovedMaskSlave();
60 + Builder setFlowRemovedMaskSlave(long flowRemovedMaskSlave);
61 + }
62 +}
1 +// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2 +// Copyright (c) 2011, 2012 Open Networking Foundation
3 +// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4 +// This library was generated by the LoxiGen Compiler.
5 +// See the file LICENSE.txt which should have been included in the source distribution
6 +
7 +// Automatically generated by LOXI from template const.java
8 +// Do not modify
9 +
10 +package org.projectfloodlight.openflow.protocol;
11 +
12 +import org.projectfloodlight.openflow.protocol.*;
13 +import org.projectfloodlight.openflow.protocol.action.*;
14 +import org.projectfloodlight.openflow.protocol.actionid.*;
15 +import org.projectfloodlight.openflow.protocol.bsntlv.*;
16 +import org.projectfloodlight.openflow.protocol.errormsg.*;
17 +import org.projectfloodlight.openflow.protocol.meterband.*;
18 +import org.projectfloodlight.openflow.protocol.instruction.*;
19 +import org.projectfloodlight.openflow.protocol.instructionid.*;
20 +import org.projectfloodlight.openflow.protocol.match.*;
21 +import org.projectfloodlight.openflow.protocol.oxm.*;
22 +import org.projectfloodlight.openflow.protocol.queueprop.*;
23 +import org.projectfloodlight.openflow.types.*;
24 +import org.projectfloodlight.openflow.util.*;
25 +import org.projectfloodlight.openflow.exceptions.*;
26 +
27 +public enum OFBadActionCode {
28 + BAD_TYPE,
29 + BAD_LEN,
30 + BAD_EXPERIMENTER,
31 + BAD_EXPERIMENTER_TYPE,
32 + BAD_OUT_PORT,
33 + BAD_ARGUMENT,
34 + EPERM,
35 + TOO_MANY,
36 + BAD_QUEUE,
37 + BAD_OUT_GROUP,
38 + MATCH_INCONSISTENT,
39 + UNSUPPORTED_ORDER,
40 + BAD_TAG,
41 + BAD_SET_TYPE,
42 + BAD_SET_LEN,
43 + BAD_SET_ARGUMENT;
44 +}
1 +// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2 +// Copyright (c) 2011, 2012 Open Networking Foundation
3 +// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4 +// This library was generated by the LoxiGen Compiler.
5 +// See the file LICENSE.txt which should have been included in the source distribution
6 +
7 +// Automatically generated by LOXI from template const.java
8 +// Do not modify
9 +
10 +package org.projectfloodlight.openflow.protocol;
11 +
12 +import org.projectfloodlight.openflow.protocol.*;
13 +import org.projectfloodlight.openflow.protocol.action.*;
14 +import org.projectfloodlight.openflow.protocol.actionid.*;
15 +import org.projectfloodlight.openflow.protocol.bsntlv.*;
16 +import org.projectfloodlight.openflow.protocol.errormsg.*;
17 +import org.projectfloodlight.openflow.protocol.meterband.*;
18 +import org.projectfloodlight.openflow.protocol.instruction.*;
19 +import org.projectfloodlight.openflow.protocol.instructionid.*;
20 +import org.projectfloodlight.openflow.protocol.match.*;
21 +import org.projectfloodlight.openflow.protocol.oxm.*;
22 +import org.projectfloodlight.openflow.protocol.queueprop.*;
23 +import org.projectfloodlight.openflow.types.*;
24 +import org.projectfloodlight.openflow.util.*;
25 +import org.projectfloodlight.openflow.exceptions.*;
26 +
27 +public enum OFBadInstructionCode {
28 + UNKNOWN_INST,
29 + UNSUP_INST,
30 + BAD_TABLE_ID,
31 + UNSUP_METADATA,
32 + UNSUP_METADATA_MASK,
33 + UNSUP_EXP_INST,
34 + BAD_EXPERIMENTER,
35 + BAD_EXPERIMENTER_TYPE,
36 + BAD_LEN,
37 + EPERM;
38 +}
1 +// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2 +// Copyright (c) 2011, 2012 Open Networking Foundation
3 +// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4 +// This library was generated by the LoxiGen Compiler.
5 +// See the file LICENSE.txt which should have been included in the source distribution
6 +
7 +// Automatically generated by LOXI from template const.java
8 +// Do not modify
9 +
10 +package org.projectfloodlight.openflow.protocol;
11 +
12 +import org.projectfloodlight.openflow.protocol.*;
13 +import org.projectfloodlight.openflow.protocol.action.*;
14 +import org.projectfloodlight.openflow.protocol.actionid.*;
15 +import org.projectfloodlight.openflow.protocol.bsntlv.*;
16 +import org.projectfloodlight.openflow.protocol.errormsg.*;
17 +import org.projectfloodlight.openflow.protocol.meterband.*;
18 +import org.projectfloodlight.openflow.protocol.instruction.*;
19 +import org.projectfloodlight.openflow.protocol.instructionid.*;
20 +import org.projectfloodlight.openflow.protocol.match.*;
21 +import org.projectfloodlight.openflow.protocol.oxm.*;
22 +import org.projectfloodlight.openflow.protocol.queueprop.*;
23 +import org.projectfloodlight.openflow.types.*;
24 +import org.projectfloodlight.openflow.util.*;
25 +import org.projectfloodlight.openflow.exceptions.*;
26 +
27 +public enum OFBadMatchCode {
28 + BAD_TYPE,
29 + BAD_LEN,
30 + BAD_TAG,
31 + BAD_DL_ADDR_MASK,
32 + BAD_NW_ADDR_MASK,
33 + BAD_WILDCARDS,
34 + BAD_FIELD,
35 + BAD_VALUE,
36 + BAD_MASK,
37 + BAD_PREREQ,
38 + DUP_FIELD,
39 + EPERM;
40 +}