Merge branch 'master' into merge
Change-Id: Id77bb2de77dd288404c83e331b076aaf9aafacc5
diff --git a/apps/simplefabric/BUCK b/apps/simplefabric/BUCK
new file mode 100644
index 0000000..e181a98
--- /dev/null
+++ b/apps/simplefabric/BUCK
@@ -0,0 +1,13 @@
+BUNDLES = [
+ '//apps/simplefabric/api:onos-apps-simplefabric-api',
+ '//apps/simplefabric/app:onos-apps-simplefabric-app',
+]
+
+onos_app (
+ title = 'SONA SimpleFabric',
+ category = 'Traffic Engineering',
+ url = 'http://onosproject.org',
+ included_bundles = BUNDLES,
+ description = 'SONA Simple Fabric Application',
+ required_apps = [ 'org.onosproject.openflow-base', 'org.onosproject.lldpprovider', 'org.onosproject.hostprovider' ],
+)
\ No newline at end of file
diff --git a/apps/simplefabric/BUILD b/apps/simplefabric/BUILD
index 007b701..3fabae0 100644
--- a/apps/simplefabric/BUILD
+++ b/apps/simplefabric/BUILD
@@ -1,27 +1,17 @@
-COMPILE_DEPS = CORE_DEPS + JACKSON + CLI + REST + [
- "@concurrent_trees//jar",
-]
-
BUNDLES = [
- "//apps/simplefabric:onos-apps-simplefabric",
+ "//apps/simplefabric/api:onos-apps-simplefabric-api",
+ "//apps/simplefabric/app:onos-apps-simplefabric-app",
]
-osgi_jar_with_tests(
- karaf_command_packages = ["org.onosproject.simplefabric"],
- test_deps = TEST_ADAPTERS,
- web_context = "/onos/v1/simplefabric",
- deps = COMPILE_DEPS,
-)
-
onos_app(
category = "Traffic Engineering",
- description = "Simple Fabric application",
+ description = "SONA Simple Fabric Application",
included_bundles = BUNDLES,
required_apps = [
"org.onosproject.openflow-base",
"org.onosproject.lldpprovider",
"org.onosproject.hostprovider",
],
- title = "SimpleFabric",
+ title = "SONA SimpleFabric",
url = "http://onosproject.org",
)
diff --git a/apps/simplefabric/api/BUCK b/apps/simplefabric/api/BUCK
new file mode 100644
index 0000000..520bddf
--- /dev/null
+++ b/apps/simplefabric/api/BUCK
@@ -0,0 +1,16 @@
+COMPILE_DEPS = [
+ '//lib:CORE_DEPS',
+ '//lib:org.apache.karaf.shell.console',
+ '//cli:onos-cli',
+]
+
+TEST_DEPS = [
+ '//lib:TEST_ADAPTERS',
+ '//core/api:onos-api-tests',
+ '//core/common:onos-core-common-tests',
+]
+
+osgi_jar_with_tests (
+ deps = COMPILE_DEPS,
+ test_deps = TEST_DEPS,
+)
diff --git a/apps/simplefabric/api/BUILD b/apps/simplefabric/api/BUILD
new file mode 100644
index 0000000..b22d9f6
--- /dev/null
+++ b/apps/simplefabric/api/BUILD
@@ -0,0 +1,11 @@
+COMPILE_DEPS = CORE_DEPS + CLI
+
+TEST_DEPS = TEST_ADAPTERS + [
+ "//core/api:onos-api-tests",
+ "//core/common:onos-core-common-tests",
+]
+
+osgi_jar_with_tests(
+ test_deps = TEST_DEPS,
+ deps = COMPILE_DEPS,
+)
diff --git a/apps/simplefabric/api/src/main/java/org/onosproject/simplefabric/api/Constants.java b/apps/simplefabric/api/src/main/java/org/onosproject/simplefabric/api/Constants.java
new file mode 100644
index 0000000..703e01b
--- /dev/null
+++ b/apps/simplefabric/api/src/main/java/org/onosproject/simplefabric/api/Constants.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.simplefabric.api;
+
+/**
+ * Provides constants used in simple fabric services.
+ */
+public final class Constants {
+
+ private Constants() {
+ }
+
+ // App symbols
+ public static final String APP_ID = "org.onosproject.simplefabric";
+ public static final String FORWARDING_APP_ID = "org.onosproject.simplefabric.forwarding";
+ public static final String ROUTING_APP_ID = "org.onosproject.simplefabric.routing";
+
+ // Priority for l2NetworkRouting: L2NETWORK_UNICAST or L2NETWORK_BROADCAST
+ public static final int PRI_L2NETWORK_UNICAST = 601;
+ public static final int PRI_L2NETWORK_BROADCAST = 600;
+
+ // Reactive Routing within Local Subnets
+ // ASSUME: local subnets NEVER overlaps each other
+ public static final int PRI_REACTIVE_LOCAL_FORWARD = 501;
+ public static final int PRI_REACTIVE_LOCAL_INTERCEPT = 500;
+ // Reactive Routing for Border Routes with local subnet
+ // Priority: REACTIVE_BROUTE_BASE + routeIpPrefix * REACTIVE_BROUTE_STEP
+ // + REACTIVE_BROUTE_FORWARD or REACTIVE_BROUTE_INTERCEPT
+ public static final int PRI_REACTIVE_BORDER_BASE = 100;
+ public static final int PRI_REACTIVE_BORDER_STEP = 2;
+ public static final int PRI_REACTIVE_BORDER_FORWARD = 1;
+ public static final int PRI_REACTIVE_BORDER_INTERCEPT = 0;
+
+ // Simple fabric event related timers
+ public static final long IDLE_INTERVAL_MSEC = 5000;
+
+ // Feature control parameters
+ public static final boolean ALLOW_IPV6 = false;
+ public static final boolean ALLOW_ETH_ADDRESS_SELECTOR = true;
+ public static final boolean REACTIVE_SINGLE_TO_SINGLE = false;
+ public static final boolean REACTIVE_ALLOW_LINK_CP = false; // MUST BE false (yjlee, 2017-10-18)
+ public static final boolean REACTIVE_HASHED_PATH_SELECTION = false;
+ public static final boolean REACTIVE_MATCH_IP_PROTO = false;
+}
diff --git a/apps/simplefabric/api/src/main/java/org/onosproject/simplefabric/api/FabricNetwork.java b/apps/simplefabric/api/src/main/java/org/onosproject/simplefabric/api/FabricNetwork.java
new file mode 100644
index 0000000..bae189d
--- /dev/null
+++ b/apps/simplefabric/api/src/main/java/org/onosproject/simplefabric/api/FabricNetwork.java
@@ -0,0 +1,188 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.simplefabric.api;
+
+import org.onlab.packet.VlanId;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.EncapsulationType;
+import org.onosproject.net.Host;
+import org.onosproject.net.HostId;
+import org.onosproject.net.intf.Interface;
+
+import java.util.Set;
+
+/**
+ * Interface of fabric network.
+ */
+public interface FabricNetwork {
+
+ /**
+ * Gets DefaultFabricNetwork name.
+ *
+ * @return the name of DefaultFabricNetwork
+ */
+ String name();
+
+ /**
+ * Gets DefaultFabricNetwork interfaceNames.
+ *
+ * @return the interfaceNames of DefaultFabricNetwork
+ */
+ Set<String> interfaceNames();
+
+ /**
+ * Gets DefaultFabricNetwork encapsulation type.
+ *
+ * @return the encapsulation type of DefaultFabricNetwork
+ */
+ EncapsulationType encapsulation();
+
+ /**
+ * Gets DefaultFabricNetwork forward flag.
+ *
+ * @return the forward flag of DefaultFabricNetwork
+ */
+ boolean isForward();
+
+ /**
+ * Gets DefaultFabricNetwork broadcast flag.
+ *
+ * @return the broadcast flag of DefaultFabricNetwork
+ */
+ boolean isBroadcast();
+
+ /**
+ * Gets DefaultFabricNetwork interfaces.
+ *
+ * @return the interfaces of DefaultFabricNetwork
+ */
+ Set<Interface> interfaces();
+
+ /**
+ * Gets DefaultFabricNetwork hosts.
+ *
+ * @return the hosts of DefaultFabricNetwork
+ */
+ Set<HostId> hostIds();
+
+ /**
+ * Gets DefaultFabricNetwork isDirty flag.
+ *
+ * @return the isDirty flag of DefaultFabricNetwork
+ */
+ boolean isDirty();
+
+ /**
+ * Checks if the interface is of DefaultFabricNetwork.
+ *
+ * @param iface the interface to be checked
+ * @return true if DefaultFabricNetwork contains the interface
+ */
+ boolean contains(Interface iface);
+
+ /**
+ * Checks if the ConnectPoint and Vlan is of DefaultFabricNetwork.
+ *
+ * @param port the ConnectPoint to be checked
+ * @param vlanId the VlanId of the ConnectPoint to be checked
+ * @return true if DefaultFabricNetwork contains the interface of the ConnnectPoint and VlanId
+ */
+ boolean contains(ConnectPoint port, VlanId vlanId);
+
+ /**
+ * Checks if the DeviceId is of DefaultFabricNetwork.
+ *
+ * @param deviceId the DeviceId to be checked
+ * @return true if DefaultFabricNetwork contains any interface of the DeviceId
+ */
+ boolean contains(DeviceId deviceId);
+
+ /**
+ * Adds interface to DefaultFabricNetwork.
+ *
+ * @param iface the Interface to be added
+ */
+ void addInterface(Interface iface);
+
+ /**
+ * Adds host to DefaultFabricNetwork.
+ *
+ * @param host the Host to be added
+ */
+ void addHost(Host host);
+
+ /**
+ * Sets DefaultFabricNetwork isDirty flag.
+ *
+ * @param newDirty the isDirty flag to be set
+ */
+ void setDirty(boolean newDirty);
+
+ /**
+ * Builder of FabricNetwork.
+ */
+ interface Builder {
+
+ /**
+ * Returns FabricNetwork builder with supplied network name.
+ *
+ * @param name network name
+ * @return FabricNetwork instance builder
+ */
+ Builder name(String name);
+
+ /**
+ * Returns FabricNetwork builder with supplied interface names.
+ *
+ * @param interfaceNames interface names
+ * @return FabricNetwork instance builder
+ */
+ Builder interfaceNames(Set<String> interfaceNames);
+
+ /**
+ * Returns FabricNetwork builder with supplied encapsulation type.
+ *
+ * @param encapsulation encapsulation type
+ * @return FabricNetwork instance builder
+ */
+ Builder encapsulation(EncapsulationType encapsulation);
+
+ /**
+ * Returns FabricNetwork builder with supplied forward flag.
+ *
+ * @param forward forward flag
+ * @return FabricNetwork instance builder
+ */
+ Builder forward(boolean forward);
+
+ /**
+ * Returns FabricNetwork builder with supplied broadcast flag.
+ *
+ * @param broadcast broadcast flag
+ * @return FabricNetwork instance builder
+ */
+ Builder broadcast(boolean broadcast);
+
+ /**
+ * Builds an immutable FabricNetwork instance.
+ *
+ * @return FabricNetwork instance
+ */
+ FabricNetwork build();
+ }
+}
diff --git a/apps/simplefabric/api/src/main/java/org/onosproject/simplefabric/api/FabricRoute.java b/apps/simplefabric/api/src/main/java/org/onosproject/simplefabric/api/FabricRoute.java
new file mode 100644
index 0000000..f12260a
--- /dev/null
+++ b/apps/simplefabric/api/src/main/java/org/onosproject/simplefabric/api/FabricRoute.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.simplefabric.api;
+
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpPrefix;
+import org.onosproject.cluster.NodeId;
+
+/**
+ * Interface of fabric route.
+ */
+public interface FabricRoute {
+
+ /**
+ * Source of the route.
+ */
+ enum Source {
+ /**
+ * Route came from the iBGP route source.
+ */
+ BGP,
+
+ /**
+ * Route came from the FPM route source.
+ */
+ FPM,
+
+ /**
+ * Route can from the static route source.
+ */
+ STATIC,
+
+ /**
+ * Route source was not defined.
+ */
+ UNDEFINED
+ }
+
+ /**
+ * Returns the route source.
+ *
+ * @return route source
+ */
+ Source source();
+
+ /**
+ * Returns the IP prefix of the route.
+ *
+ * @return IP prefix
+ */
+ IpPrefix prefix();
+
+ /**
+ * Returns the next hop IP address.
+ *
+ * @return next hop
+ */
+ IpAddress nextHop();
+
+ /**
+ * Returns the ONOS node the route was sourced from.
+ *
+ * @return ONOS node ID
+ */
+ NodeId sourceNode();
+
+ /**
+ * Builder of FabricRoute.
+ */
+ interface Builder {
+
+ /**
+ * Returns FabricRoute builder with supplied source.
+ *
+ * @param source source of route
+ * @return FabricRoute instance builder
+ */
+ Builder source(Source source);
+
+ /**
+ * Returns FabricRoute builder with supplied IP prefix.
+ *
+ * @param prefix IP prefix
+ * @return FabricRoute instance builder
+ */
+ Builder prefix(IpPrefix prefix);
+
+ /**
+ * Returns Fabric builder with supplied next hop.
+ *
+ * @param nextHop next hop
+ * @return FabricRoute instance builder
+ */
+ Builder nextHop(IpAddress nextHop);
+
+ /**
+ * Returns Fabric builder with supplied source node identifier.
+ *
+ * @param sourceNode source node identifier
+ * @return FabricRoute instance builder
+ */
+ Builder sourceNode(NodeId sourceNode);
+
+ /**
+ * Builds an immutable FabricRoute instance.
+ *
+ * @return FabricRoute instance
+ */
+ FabricRoute build();
+ }
+}
diff --git a/apps/simplefabric/api/src/main/java/org/onosproject/simplefabric/api/FabricSubnet.java b/apps/simplefabric/api/src/main/java/org/onosproject/simplefabric/api/FabricSubnet.java
new file mode 100644
index 0000000..ca56946
--- /dev/null
+++ b/apps/simplefabric/api/src/main/java/org/onosproject/simplefabric/api/FabricSubnet.java
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.simplefabric.api;
+
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpPrefix;
+import org.onlab.packet.MacAddress;
+import org.onosproject.net.EncapsulationType;
+
+/**
+ * Interface of FabricSubnet.
+ */
+public interface FabricSubnet {
+
+ /**
+ * Gets the IP subnet of the IP subnet entry.
+ *
+ * @return the IP subnet
+ */
+ IpPrefix prefix();
+
+ /**
+ * Gets the virtual gateway IP address of the IP subnet entry.
+ *
+ * @return the virtual gateway IP address
+ */
+ IpAddress gatewayIp();
+
+ /**
+ * Gets the virtual gateway Mac address of the IP subnet entry.
+ *
+ * @return the virtuai gateway Mac address
+ */
+ MacAddress gatewayMac();
+
+ /**
+ * Gets the encapsulation type of IP subnet entry.
+ *
+ * @return the encapsulation type
+ */
+ EncapsulationType encapsulation();
+
+ /**
+ * Gets the network name.
+ *
+ * @return the network name
+ */
+ String networkName();
+
+ /**
+ * Tests whether the IP version of this entry is IPv4.
+ *
+ * @return true if the IP version of this entry is IPv4, otherwise false.
+ */
+ boolean isIp4();
+
+ /**
+ * Tests whether the IP version of this entry is IPv6.
+ *
+ * @return true if the IP version of this entry is IPv6, otherwise false.
+ */
+ boolean isIp6();
+
+ /**
+ * Builder of Ip Subnet.
+ */
+ interface Builder {
+
+ /**
+ * Returns FabricSubnet builder with supplied IpPrefix.
+ *
+ * @param ipPrefix IP prefix
+ * @return FabricSubnet instance builder
+ */
+ Builder prefix(IpPrefix ipPrefix);
+
+ /**
+ * Returns FabricSubnet builder with supplied gatewayIp.
+ *
+ * @param gatewayIp gateway IP
+ * @return FabricSubnet instance builder
+ */
+ Builder gatewayIp(IpAddress gatewayIp);
+
+ /**
+ * Returns FabricSubnet builder with supplied gatewayMac.
+ *
+ * @param gatewayMac gateway MAC
+ * @return FabricSubnet instance builder
+ */
+ Builder gatewayMac(MacAddress gatewayMac);
+
+ /**
+ * Returns FabricSubnet builder with supplied encapsulation type.
+ *
+ * @param encapsulation encapsulation type
+ * @return FabricSubnet instance builder
+ */
+ Builder encapsulation(EncapsulationType encapsulation);
+
+ /**
+ * Returns FabricSubnet builder with supplied network name.
+ *
+ * @param networkName network name
+ * @return FabricSubnet instance builder
+ */
+ Builder networkName(String networkName);
+
+ /**
+ * Builds an immutable FabricSubnet instance.
+ *
+ * @return FabricSubnet instance
+ */
+ FabricSubnet build();
+ }
+}
diff --git a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricEvent.java b/apps/simplefabric/api/src/main/java/org/onosproject/simplefabric/api/SimpleFabricEvent.java
similarity index 95%
rename from apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricEvent.java
rename to apps/simplefabric/api/src/main/java/org/onosproject/simplefabric/api/SimpleFabricEvent.java
index cac1276..aac465b 100644
--- a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricEvent.java
+++ b/apps/simplefabric/api/src/main/java/org/onosproject/simplefabric/api/SimpleFabricEvent.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017-present Open Networking Foundation
+ * Copyright 2018-present Open Networking Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.onosproject.simplefabric;
+package org.onosproject.simplefabric.api;
import org.onosproject.event.AbstractEvent;
diff --git a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricListener.java b/apps/simplefabric/api/src/main/java/org/onosproject/simplefabric/api/SimpleFabricListener.java
similarity index 88%
rename from apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricListener.java
rename to apps/simplefabric/api/src/main/java/org/onosproject/simplefabric/api/SimpleFabricListener.java
index 726d578..25bf529 100644
--- a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricListener.java
+++ b/apps/simplefabric/api/src/main/java/org/onosproject/simplefabric/api/SimpleFabricListener.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017-present Open Networking Foundation
+ * Copyright 2018-present Open Networking Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.simplefabric;
+package org.onosproject.simplefabric.api;
import org.onosproject.event.EventListener;
diff --git a/apps/simplefabric/api/src/main/java/org/onosproject/simplefabric/api/SimpleFabricService.java b/apps/simplefabric/api/src/main/java/org/onosproject/simplefabric/api/SimpleFabricService.java
new file mode 100644
index 0000000..33b9c5e
--- /dev/null
+++ b/apps/simplefabric/api/src/main/java/org/onosproject/simplefabric/api/SimpleFabricService.java
@@ -0,0 +1,155 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.simplefabric.api;
+
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.MacAddress;
+import org.onlab.packet.VlanId;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.event.ListenerService;
+import org.onosproject.net.intf.Interface;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.Host;
+
+import java.io.OutputStream;
+import java.util.Set;
+import java.util.Collection;
+
+/**
+ * Provides information about the routing configuration.
+ */
+public interface SimpleFabricService
+ extends ListenerService<SimpleFabricEvent, SimpleFabricListener> {
+
+ /**
+ * Gets appId.
+ *
+ * @return appId of simple fabric app
+ */
+ ApplicationId appId();
+
+ /**
+ * Gets all the fabric networks.
+ *
+ * @return all the fabric networks
+ */
+ Collection<FabricNetwork> fabricNetworks();
+
+ /**
+ * Retrieves the entire set of fabricSubnets configuration.
+ *
+ * @return all the fabricSubnets
+ */
+ Set<FabricSubnet> defaultFabricSubnets();
+
+ /**
+ * Retrieves the entire set of static routes to outer networks.
+ *
+ * @return the set of static routes to outer networks.
+ */
+ Set<FabricRoute> fabricRoutes();
+
+ /**
+ * Evaluates whether a MAC is of virtual gateway MAC addresses.
+ *
+ * @param mac the MAC address to evaluate
+ * @return true if the mac is of any virtual gateway MAC address of fabricSubnets
+ */
+ boolean isVirtualGatewayMac(MacAddress mac);
+
+ /**
+ * Evaluates whether an interface belongs to fabric network or not.
+ *
+ * @param intf the interface to evaluate
+ * @return true if the interface belongs to fabric network, otherwise false
+ */
+ boolean isFabricNetworkInterface(Interface intf);
+
+ /**
+ * Finds virtual gateway MAC address for local subnet virtual gateway IP.
+ *
+ * @param ip the IP to check for virtual gateway IP
+ * @return MAC address of virtual gateway
+ */
+ MacAddress vMacForIp(IpAddress ip);
+
+ /**
+ * Finds the L2 fabric network with given port and vlanId.
+ *
+ * @param port the port to be matched
+ * @param vlanId the vlanId to be matched
+ * @return the L2 Network for specific port and vlanId or null
+ */
+ FabricNetwork fabricNetwork(ConnectPoint port, VlanId vlanId);
+
+ /**
+ * Finds the fabric network by its name.
+ *
+ * @param name the name to be matched
+ * @return the fabric network
+ */
+ FabricNetwork fabricNetwork(String name);
+
+ /**
+ * Finds the FabricSubnet which contains the given IP address.
+ *
+ * @param ipAddress the IP address to be matched
+ * @return the FabricSubnet
+ */
+ FabricSubnet fabricSubnet(IpAddress ipAddress);
+
+ /**
+ * Finds the FabricRoute which contains the given IP address.
+ *
+ * @param ipAddress the IP address to be matched
+ * @return the FabricRoute
+ */
+ FabricRoute fabricRoute(IpAddress ipAddress);
+
+ /**
+ * Finds the network interface which associated with the host.
+ *
+ * @param host the host
+ * @return the interface associated with the host
+ */
+ Interface hostInterface(Host host);
+
+ /**
+ * Sends neighbour query (ARP or NDP) to find host location.
+ *
+ * @param ip the IP address to resolve
+ * @return true if request MAC packets are emitted, false otherwise
+ */
+ boolean requestMac(IpAddress ip);
+
+ /**
+ * Sends dump event to all SimpleFabricListeners to dump info on the subject.
+ *
+ * @param subject the subject to dump
+ * @param out the output stream to dump
+ */
+ void dumpToStream(String subject, OutputStream out);
+
+ /**
+ * Triggers to send refresh notification to all sub modules.
+ */
+ void triggerRefresh();
+
+ /**
+ * Triggers to send flush notification to all sub modules.
+ */
+ void triggerFlush();
+}
diff --git a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricListener.java b/apps/simplefabric/api/src/main/java/org/onosproject/simplefabric/api/package-info.java
similarity index 67%
copy from apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricListener.java
copy to apps/simplefabric/api/src/main/java/org/onosproject/simplefabric/api/package-info.java
index 726d578..a11519f 100644
--- a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricListener.java
+++ b/apps/simplefabric/api/src/main/java/org/onosproject/simplefabric/api/package-info.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017-present Open Networking Foundation
+ * Copyright 2018-present Open Networking Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,13 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.simplefabric;
-
-import org.onosproject.event.EventListener;
/**
- * Entity capable of receiving alarm related events.
+ * Simple fabric API package.
*/
-public interface SimpleFabricListener extends EventListener<SimpleFabricEvent> {
-}
-
+package org.onosproject.simplefabric.api;
\ No newline at end of file
diff --git a/apps/simplefabric/app/BUCK b/apps/simplefabric/app/BUCK
new file mode 100644
index 0000000..6aefd2c
--- /dev/null
+++ b/apps/simplefabric/app/BUCK
@@ -0,0 +1,24 @@
+COMPILE_DEPS = [
+ '//lib:CORE_DEPS',
+ '//lib:JACKSON',
+ '//lib:concurrent-trees',
+ '//lib:javax.ws.rs-api',
+ '//lib:org.apache.karaf.shell.console',
+ '//cli:onos-cli',
+ '//utils/rest:onlab-rest',
+ '//apps/simplefabric/api:onos-apps-simplefabric-api',
+]
+
+TEST_DEPS = [
+ '//lib:TEST_ADAPTERS',
+]
+
+osgi_jar_with_tests (
+ api_description = 'REST API for Simple Fabric',
+ api_package = 'org.onosproject.simplefabric.web',
+ api_title = 'Simple Fabric API',
+ api_version = '1.0',
+ deps = COMPILE_DEPS,
+ test_deps = TEST_DEPS,
+ web_context = '/onos/v1/simplefabric',
+)
\ No newline at end of file
diff --git a/apps/simplefabric/app/BUILD b/apps/simplefabric/app/BUILD
new file mode 100644
index 0000000..69d12f7
--- /dev/null
+++ b/apps/simplefabric/app/BUILD
@@ -0,0 +1,21 @@
+COMPILE_DEPS = CORE_DEPS + JACKSON + CLI + REST + [
+ "//apps/simplefabric/api:onos-apps-simplefabric-api",
+ "@concurrent_trees//jar",
+]
+
+TEST_DEPS = TEST_ADAPTERS + TEST_REST + [
+ "//core/api:onos-api-tests",
+ "//core/common:onos-core-common-tests",
+ "//web/api:onos-rest-tests",
+]
+
+osgi_jar_with_tests(
+ api_description = "REST API for Simple Fabric",
+ api_package = "org.onosproject.simplefabric.web",
+ api_title = "Simple Fabric API",
+ api_version = "1.0",
+ karaf_command_packages = ["org.onosproject.simplefabric.cli"],
+ test_deps = TEST_DEPS,
+ web_context = "/onos/v1/simplefabric",
+ deps = COMPILE_DEPS,
+)
diff --git a/apps/simplefabric/app.xml b/apps/simplefabric/app/app.xml
similarity index 100%
rename from apps/simplefabric/app.xml
rename to apps/simplefabric/app/app.xml
diff --git a/apps/simplefabric/features.xml b/apps/simplefabric/app/features.xml
similarity index 100%
rename from apps/simplefabric/features.xml
rename to apps/simplefabric/app/features.xml
diff --git a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricCommand.java b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/cli/SimpleFabricCommand.java
similarity index 93%
rename from apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricCommand.java
rename to apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/cli/SimpleFabricCommand.java
index 8d88f08..3271e8d 100644
--- a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricCommand.java
+++ b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/cli/SimpleFabricCommand.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017-present Open Networking Foundation
+ * Copyright 2018-present Open Networking Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,13 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.simplefabric;
+package org.onosproject.simplefabric.cli;
import org.apache.karaf.shell.api.action.Argument;
import org.apache.karaf.shell.api.action.Command;
import org.apache.karaf.shell.api.action.Completion;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.simplefabric.api.SimpleFabricService;
/**
* CLI to interact with the SIMPLE_FABRIC application.
diff --git a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricCommandCompleter.java b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/cli/SimpleFabricCommandCompleter.java
similarity index 93%
rename from apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricCommandCompleter.java
rename to apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/cli/SimpleFabricCommandCompleter.java
index 43d79d8..a643539 100644
--- a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricCommandCompleter.java
+++ b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/cli/SimpleFabricCommandCompleter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017-present Open Networking Foundation
+ * Copyright 2018-present Open Networking Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.simplefabric;
+package org.onosproject.simplefabric.cli;
import com.google.common.collect.Lists;
import org.apache.karaf.shell.api.action.lifecycle.Service;
diff --git a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricListener.java b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/cli/package-info.java
similarity index 67%
copy from apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricListener.java
copy to apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/cli/package-info.java
index 726d578..1a92219 100644
--- a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricListener.java
+++ b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/cli/package-info.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017-present Open Networking Foundation
+ * Copyright 2018-present Open Networking Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,13 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.simplefabric;
-
-import org.onosproject.event.EventListener;
/**
- * Entity capable of receiving alarm related events.
+ * Simple fabric CLI package.
*/
-public interface SimpleFabricListener extends EventListener<SimpleFabricEvent> {
-}
-
+package org.onosproject.simplefabric.cli;
\ No newline at end of file
diff --git a/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/DefaultFabricNetwork.java b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/DefaultFabricNetwork.java
new file mode 100644
index 0000000..386a345
--- /dev/null
+++ b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/DefaultFabricNetwork.java
@@ -0,0 +1,316 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.simplefabric.impl;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
+import org.onlab.packet.VlanId;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.EncapsulationType;
+import org.onosproject.net.Host;
+import org.onosproject.net.HostId;
+import org.onosproject.net.intf.Interface;
+import org.onosproject.simplefabric.api.FabricNetwork;
+
+import java.util.Collection;
+import java.util.Objects;
+import java.util.Set;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static org.onosproject.simplefabric.api.Constants.ALLOW_ETH_ADDRESS_SELECTOR;
+
+
+/**
+ * Class stores a DefaultFabricNetwork information.
+ */
+public final class DefaultFabricNetwork implements FabricNetwork {
+
+ private static final String NOT_NULL_MSG = "FabricNetwork % cannot be null";
+
+ private final String name;
+ private final Set<String> interfaceNames;
+ private final EncapsulationType encapsulation;
+ private boolean forward;
+ private boolean broadcast;
+
+ /* status variables */
+ private final Set<Interface> interfaces;
+ private final Set<HostId> hostIds;
+ private boolean dirty;
+
+ /**
+ * Constructs a DefaultFabricNetwork instance.
+ *
+ * @param name fabric name name
+ * @param interfaceNames a collection of interface names
+ * @param encapsulation encapsulation type
+ * @param forward flag for forward intents to be installed or not
+ * @param broadcast flag for broadcast intents to be installed or not
+ */
+ private DefaultFabricNetwork(String name, Collection<String> interfaceNames,
+ EncapsulationType encapsulation,
+ boolean forward, boolean broadcast) {
+ this.name = name;
+ this.interfaceNames = Sets.newHashSet();
+
+ if (interfaceNames != null) {
+ this.interfaceNames.addAll(interfaceNames);
+ }
+
+ this.encapsulation = encapsulation;
+ this.forward = (ALLOW_ETH_ADDRESS_SELECTOR) && forward;
+ this.broadcast = (ALLOW_ETH_ADDRESS_SELECTOR) && broadcast;
+ this.interfaces = Sets.newHashSet();
+ this.hostIds = Sets.newHashSet();
+ this.dirty = false;
+ }
+
+ /**
+ * Constructs a DefaultFabricNetwork instance.
+ *
+ * @param name fabric network name
+ * @param encapsulation encapsulation type
+ */
+ private DefaultFabricNetwork(String name, EncapsulationType encapsulation) {
+ this.name = name;
+ this.interfaceNames = Sets.newHashSet();
+ this.encapsulation = encapsulation;
+ this.forward = ALLOW_ETH_ADDRESS_SELECTOR;
+ this.broadcast = ALLOW_ETH_ADDRESS_SELECTOR;
+ this.interfaces = Sets.newHashSet();
+ this.hostIds = Sets.newHashSet();
+ this.dirty = false;
+ }
+
+ /**
+ * Creates a DefaultFabricNetwork data by given name.
+ * The encapsulation type of the DefaultFabricNetwork will be NONE.
+ *
+ * @param name fabric network name
+ * @return DefaultFabricNetwork instance
+ */
+ public static FabricNetwork of(String name) {
+ Objects.requireNonNull(name);
+ return new DefaultFabricNetwork(name, EncapsulationType.NONE);
+ }
+
+ /**
+ * Creates a copy of DefaultFabricNetwork instance.
+ *
+ * @param fabricNetwork DefaultFabricNetwork instance
+ * @return the copy of the DefaultFabricNetwork instance
+ */
+ public static FabricNetwork of(FabricNetwork fabricNetwork) {
+ Objects.requireNonNull(fabricNetwork);
+ DefaultFabricNetwork fabricNetworkCopy =
+ new DefaultFabricNetwork(fabricNetwork.name(), fabricNetwork.encapsulation());
+ fabricNetworkCopy.interfaceNames.addAll(fabricNetwork.interfaceNames());
+ fabricNetworkCopy.forward = (ALLOW_ETH_ADDRESS_SELECTOR) && fabricNetwork.isForward();
+ fabricNetworkCopy.broadcast = (ALLOW_ETH_ADDRESS_SELECTOR) && fabricNetwork.isBroadcast();
+ fabricNetworkCopy.interfaces.addAll(fabricNetwork.interfaces());
+ fabricNetworkCopy.hostIds.addAll(fabricNetwork.hostIds());
+ fabricNetworkCopy.setDirty(fabricNetwork.isDirty());
+ return fabricNetworkCopy;
+ }
+
+ // field queries
+
+ @Override
+ public String name() {
+ return name;
+ }
+
+ @Override
+ public Set<String> interfaceNames() {
+ return ImmutableSet.copyOf(interfaceNames);
+ }
+
+ @Override
+ public EncapsulationType encapsulation() {
+ return encapsulation;
+ }
+
+ @Override
+ public boolean isForward() {
+ return forward;
+ }
+
+ @Override
+ public boolean isBroadcast() {
+ return broadcast;
+ }
+
+ @Override
+ public Set<Interface> interfaces() {
+ return ImmutableSet.copyOf(interfaces);
+ }
+
+ @Override
+ public Set<HostId> hostIds() {
+ return ImmutableSet.copyOf(hostIds);
+ }
+
+ @Override
+ public boolean isDirty() {
+ return dirty;
+ }
+
+ @Override
+ public boolean contains(Interface iface) {
+ return interfaces.contains(iface);
+ }
+
+ @Override
+ public boolean contains(ConnectPoint port, VlanId vlanId) {
+ for (Interface iface : interfaces) {
+ if (iface.connectPoint().equals(port) && iface.vlan().equals(vlanId)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public boolean contains(DeviceId deviceId) {
+ for (Interface iface : interfaces) {
+ if (iface.connectPoint().deviceId().equals(deviceId)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public void addInterface(Interface iface) {
+ Objects.requireNonNull(iface);
+ if (interfaces.add(iface)) {
+ setDirty(true);
+ }
+ }
+
+ @Override
+ public void addHost(Host host) {
+ Objects.requireNonNull(host);
+ if (hostIds.add(host.id())) {
+ setDirty(true);
+ }
+ }
+
+ @Override
+ public void setDirty(boolean newDirty) {
+ dirty = newDirty;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("name", name)
+ .add("interfaceNames", interfaceNames)
+ .add("encapsulation", encapsulation)
+ .add("forward", forward)
+ .add("broadcast", broadcast)
+ .add("interfaces", interfaces)
+ .add("hostIds", hostIds)
+ .add("isDirty", dirty)
+ .toString();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof DefaultFabricNetwork)) {
+ return false;
+ }
+ DefaultFabricNetwork other = (DefaultFabricNetwork) obj;
+ return Objects.equals(other.name, this.name)
+ && Objects.equals(other.interfaceNames, this.interfaceNames)
+ && Objects.equals(other.encapsulation, this.encapsulation)
+ && Objects.equals(other.forward, this.forward)
+ && Objects.equals(other.broadcast, this.broadcast)
+ && Objects.equals(other.interfaces, this.interfaces)
+ && Objects.equals(other.hostIds, this.hostIds);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(name, interfaces, encapsulation, forward, broadcast);
+ }
+
+ /**
+ * Returns new builder instance.
+ *
+ * @return fabric network builder
+ */
+ public static DefaultFabricNetworkBuilder builder() {
+ return new DefaultFabricNetworkBuilder();
+ }
+
+ /**
+ * A builder class for fabric network.
+ */
+ public static final class DefaultFabricNetworkBuilder implements Builder {
+ private String name;
+ private Set<String> interfaceNames;
+ private EncapsulationType encapsulation;
+ private boolean forward;
+ private boolean broadcast;
+
+ private DefaultFabricNetworkBuilder() {
+ }
+
+ @Override
+ public Builder name(String name) {
+ this.name = name;
+ return this;
+ }
+
+ @Override
+ public Builder interfaceNames(Set<String> interfaceNames) {
+ this.interfaceNames = interfaceNames;
+ return this;
+ }
+
+ @Override
+ public Builder encapsulation(EncapsulationType encapsulation) {
+ this.encapsulation = encapsulation;
+ return this;
+ }
+
+ @Override
+ public Builder forward(boolean forward) {
+ this.forward = forward;
+ return this;
+ }
+
+ @Override
+ public Builder broadcast(boolean broadcast) {
+ this.broadcast = broadcast;
+ return this;
+ }
+
+ @Override
+ public FabricNetwork build() {
+ checkArgument(name != null, NOT_NULL_MSG, "name");
+ return new DefaultFabricNetwork(name, interfaceNames,
+ encapsulation, forward, broadcast);
+ }
+ }
+}
\ No newline at end of file
diff --git a/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/DefaultFabricRoute.java b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/DefaultFabricRoute.java
new file mode 100644
index 0000000..6b9a132
--- /dev/null
+++ b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/DefaultFabricRoute.java
@@ -0,0 +1,180 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.simplefabric.impl;
+
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpPrefix;
+import org.onosproject.cluster.NodeId;
+import org.onosproject.simplefabric.api.FabricRoute;
+
+import java.util.Objects;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Represents a route.
+ */
+public final class DefaultFabricRoute implements FabricRoute {
+
+ private static final String VERSION_MISMATCH =
+ "Prefix and next hop must be in the same address family";
+
+ private static final NodeId UNDEFINED = new NodeId("-");
+
+ private final Source source;
+ private final IpPrefix prefix;
+ private final IpAddress nextHop;
+ private final NodeId sourceNode;
+
+ /**
+ * Creates a route.
+ *
+ * @param source route source
+ * @param prefix IP prefix
+ * @param nextHop next hop IP address
+ */
+ private DefaultFabricRoute(Source source, IpPrefix prefix, IpAddress nextHop) {
+ this(source, prefix, nextHop, UNDEFINED);
+ }
+
+ /**
+ * Creates a route.
+ *
+ * @param source route source
+ * @param prefix IP prefix
+ * @param nextHop next hop IP address
+ * @param sourceNode ONOS node the route was sourced from
+ */
+ private DefaultFabricRoute(Source source, IpPrefix prefix,
+ IpAddress nextHop, NodeId sourceNode) {
+ this.source = checkNotNull(source);
+ this.prefix = prefix;
+ this.nextHop = nextHop;
+ this.sourceNode = checkNotNull(sourceNode);
+ }
+
+ @Override
+ public Source source() {
+ return source;
+ }
+
+ @Override
+ public IpPrefix prefix() {
+ return prefix;
+ }
+
+ @Override
+ public IpAddress nextHop() {
+ return nextHop;
+ }
+
+ @Override
+ public NodeId sourceNode() {
+ return sourceNode;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(prefix, nextHop);
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (this == other) {
+ return true;
+ }
+
+ if (!(other instanceof DefaultFabricRoute)) {
+ return false;
+ }
+
+ DefaultFabricRoute that = (DefaultFabricRoute) other;
+
+ return Objects.equals(this.prefix, that.prefix) &&
+ Objects.equals(this.nextHop, that.nextHop);
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("prefix", prefix)
+ .add("nextHop", nextHop)
+ .toString();
+ }
+
+ /**
+ * Returns new builder instance.
+ *
+ * @return fabric route builder
+ */
+ public static DefaultFabricRouteBuilder builder() {
+ return new DefaultFabricRouteBuilder();
+ }
+
+ /**
+ * A builder class for fabric route.
+ */
+ public static final class DefaultFabricRouteBuilder implements Builder {
+ private Source source;
+ private IpPrefix prefix;
+ private IpAddress nextHop;
+ private NodeId sourceNode;
+
+ private DefaultFabricRouteBuilder() {
+ }
+
+ @Override
+ public Builder source(Source source) {
+ this.source = source;
+ return this;
+ }
+
+ @Override
+ public Builder prefix(IpPrefix prefix) {
+ this.prefix = prefix;
+ return this;
+ }
+
+ @Override
+ public Builder nextHop(IpAddress nextHop) {
+ this.nextHop = nextHop;
+ return this;
+ }
+
+ @Override
+ public Builder sourceNode(NodeId sourceNode) {
+ this.sourceNode = sourceNode;
+ return this;
+ }
+
+ @Override
+ public FabricRoute build() {
+
+ checkNotNull(prefix);
+ checkNotNull(nextHop);
+ checkArgument(prefix.version().equals(nextHop.version()), VERSION_MISMATCH);
+
+ if (sourceNode != null) {
+ return new DefaultFabricRoute(source, prefix, nextHop, sourceNode);
+ } else {
+ return new DefaultFabricRoute(source, prefix, nextHop);
+ }
+ }
+ }
+}
diff --git a/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/DefaultFabricSubnet.java b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/DefaultFabricSubnet.java
new file mode 100644
index 0000000..b7fec47
--- /dev/null
+++ b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/DefaultFabricSubnet.java
@@ -0,0 +1,195 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.simplefabric.impl;
+
+import com.google.common.base.MoreObjects;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpPrefix;
+import org.onlab.packet.MacAddress;
+import org.onosproject.net.EncapsulationType;
+import org.onosproject.simplefabric.api.FabricSubnet;
+
+import java.util.Objects;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+/**
+ * Configuration details for an ip subnet entry.
+ */
+public final class DefaultFabricSubnet implements FabricSubnet {
+
+ private static final String NOT_NULL_MSG = "FabricSubnet % cannot be null";
+
+ private final IpPrefix prefix;
+ private final IpAddress gatewayIp;
+ private final MacAddress gatewayMac;
+ private EncapsulationType encapsulation;
+ private final String networkName;
+
+ /**
+ * Creates a new subnet entry.
+ *
+ * @param prefix an ip subnet
+ * @param gatewayIp IP of the virtual gateway
+ * @param gatewayMac MacAddress of the virtual gateway
+ * @param encapsulation encapsulation type
+ * @param networkName network name
+ */
+ private DefaultFabricSubnet(IpPrefix prefix, IpAddress gatewayIp,
+ MacAddress gatewayMac, EncapsulationType encapsulation,
+ String networkName) {
+ this.prefix = prefix;
+ this.gatewayIp = gatewayIp;
+ this.gatewayMac = gatewayMac;
+ this.encapsulation = encapsulation;
+ this.networkName = networkName;
+ }
+
+ @Override
+ public IpPrefix prefix() {
+ return prefix;
+ }
+
+ @Override
+ public IpAddress gatewayIp() {
+ return gatewayIp;
+ }
+
+ @Override
+ public MacAddress gatewayMac() {
+ return gatewayMac;
+ }
+
+ @Override
+ public EncapsulationType encapsulation() {
+ return encapsulation;
+ }
+
+ @Override
+ public String networkName() {
+ return networkName;
+ }
+
+ @Override
+ public boolean isIp4() {
+ return prefix.isIp4();
+ }
+
+ @Override
+ public boolean isIp6() {
+ return prefix.isIp6();
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(prefix, gatewayIp, gatewayMac, encapsulation, networkName);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof DefaultFabricSubnet)) {
+ return false;
+ }
+ DefaultFabricSubnet that = (DefaultFabricSubnet) obj;
+ return Objects.equals(this.prefix, that.prefix)
+ && Objects.equals(this.gatewayIp, that.gatewayIp)
+ && Objects.equals(this.gatewayMac, that.gatewayMac)
+ && Objects.equals(this.encapsulation, that.encapsulation)
+ && Objects.equals(this.networkName, that.networkName);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("prefix", prefix)
+ .add("gatewayIp", gatewayIp)
+ .add("gatewayMac", gatewayMac)
+ .add("encapsulation", encapsulation)
+ .add("networkName", networkName)
+ .toString();
+ }
+
+ /**
+ * Returns new builder instance.
+ *
+ * @return fabric IP subnet builder
+ */
+ public static DefaultSubnetBuilder builder() {
+ return new DefaultSubnetBuilder();
+ }
+
+ /**
+ * A builder class for Ip Subnet.
+ */
+ public static final class DefaultSubnetBuilder implements Builder {
+ private IpPrefix prefix;
+ private IpAddress gatewayIp;
+ private MacAddress gatewayMac;
+ private EncapsulationType encapsulation;
+ private String networkName;
+
+ private DefaultSubnetBuilder() {
+ }
+
+ @Override
+ public Builder prefix(IpPrefix prefix) {
+ this.prefix = prefix;
+ return this;
+ }
+
+ @Override
+ public Builder gatewayIp(IpAddress gatewayIp) {
+ this.gatewayIp = gatewayIp;
+ return this;
+ }
+
+ @Override
+ public Builder gatewayMac(MacAddress gatewayMac) {
+ this.gatewayMac = gatewayMac;
+ return this;
+ }
+
+ @Override
+ public Builder encapsulation(EncapsulationType encapsulation) {
+ this.encapsulation = encapsulation;
+ return this;
+ }
+
+ @Override
+ public Builder networkName(String networkName) {
+ this.networkName = networkName;
+ return this;
+ }
+
+ @Override
+ public FabricSubnet build() {
+ checkArgument(prefix != null, NOT_NULL_MSG, "prefix");
+ checkArgument(gatewayIp != null, NOT_NULL_MSG, "gatewayIp");
+ checkArgument(gatewayMac != null, NOT_NULL_MSG, "gatewayMac");
+ checkArgument(networkName != null, NOT_NULL_MSG, "name");
+
+ if (this.encapsulation == null) {
+ encapsulation = EncapsulationType.NONE;
+ }
+
+ return new DefaultFabricSubnet(prefix, gatewayIp, gatewayMac,
+ encapsulation, networkName);
+ }
+ }
+}
\ No newline at end of file
diff --git a/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricConfig.java b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricConfig.java
new file mode 100644
index 0000000..1d4b97c
--- /dev/null
+++ b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricConfig.java
@@ -0,0 +1,169 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.simplefabric.impl;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.common.collect.Sets;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpPrefix;
+import org.onlab.packet.MacAddress;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.net.EncapsulationType;
+import org.onosproject.net.config.Config;
+import org.onosproject.simplefabric.api.FabricNetwork;
+import org.onosproject.simplefabric.api.FabricRoute;
+import org.onosproject.simplefabric.api.FabricSubnet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Set;
+
+/**
+ * Configuration object for prefix config.
+ */
+public class SimpleFabricConfig extends Config<ApplicationId> {
+ public static final String KEY = "simpleFabric";
+
+ private static final String FABRIC_NETWORKS = "fabricNetworks";
+ private static final String NAME = "name";
+ private static final String INTERFACES = "interfaces";
+ private static final String ENCAPSULATION = "encapsulation";
+ private static final String IS_FORWARD = "isForward";
+ private static final String IS_BROADCAST = "isBroadcast";
+
+ private static final String FABRIC_SUBNETS = "fabricSubnets";
+ private static final String PREFIX = "prefix";
+ private static final String GATEWAY_IP = "gatewayIp";
+ private static final String GATEWAY_MAC = "gatewayMac";
+ private static final String NETWORK_NAME = "networkName";
+
+ private static final String FABRIC_ROUTES = "fabricRoutes";
+ private static final String NEXT_HOP = "nextHop";
+
+ private static final String NONE_ENCAPSULATION = "NONE";
+
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ /**
+ * Returns all fabric networks in this configuration.
+ *
+ * @return a set of fabric networks
+ */
+ public Set<FabricNetwork> fabricNetworks() {
+ Set<FabricNetwork> fabricNetworks = Sets.newHashSet();
+ JsonNode fabricNetworkNodes = object.get(FABRIC_NETWORKS);
+ if (fabricNetworkNodes == null) {
+ return fabricNetworks;
+ }
+
+ fabricNetworkNodes.forEach(jsonNode -> {
+ Set<String> ifaces = Sets.newHashSet();
+ JsonNode fabricNetworkIfaces = jsonNode.path(INTERFACES);
+ if (fabricNetworkIfaces == null) {
+ log.warn("Fabric network interfaces cannot find {}; skip: jsonNode={}", INTERFACES, jsonNode);
+ } else if (!fabricNetworkIfaces.toString().isEmpty()) {
+ fabricNetworkIfaces.forEach(ifacesNode -> ifaces.add(ifacesNode.asText()));
+ }
+ String encapsulation = NONE_ENCAPSULATION; // NONE or VLAN
+ if (jsonNode.hasNonNull(ENCAPSULATION)) {
+ encapsulation = jsonNode.get(ENCAPSULATION).asText();
+ }
+ boolean isForward = true;
+ if (jsonNode.hasNonNull(IS_FORWARD)) {
+ isForward = jsonNode.get(IS_FORWARD).asBoolean();
+ }
+ boolean isBroadcast = true;
+ if (jsonNode.hasNonNull(IS_BROADCAST)) {
+ isBroadcast = jsonNode.get(IS_BROADCAST).asBoolean();
+ }
+ try {
+ fabricNetworks.add(DefaultFabricNetwork.builder()
+ .name(jsonNode.get(NAME).asText())
+ .interfaceNames(ifaces)
+ .encapsulation(EncapsulationType.enumFromString(encapsulation))
+ .forward(isForward)
+ .broadcast(isBroadcast)
+ .build());
+ } catch (Exception e) {
+ log.warn("Fabric network parse failed; skip: jsonNode={}", jsonNode);
+ }
+ });
+ return fabricNetworks;
+ }
+
+ /**
+ * Gets the set of configured local subnets.
+ *
+ * @return a set of subnets
+ */
+ public Set<FabricSubnet> fabricSubnets() {
+ Set<FabricSubnet> subnets = Sets.newHashSet();
+ JsonNode subnetsNode = object.get(FABRIC_SUBNETS);
+ if (subnetsNode == null) {
+ log.warn("FabricSubnets is null!");
+ return subnets;
+ }
+
+ subnetsNode.forEach(jsonNode -> {
+ String encapsulation = NONE_ENCAPSULATION; // NONE or VLAN
+ if (jsonNode.hasNonNull(ENCAPSULATION)) {
+ encapsulation = jsonNode.get(ENCAPSULATION).asText();
+ }
+ try {
+ subnets.add(DefaultFabricSubnet.builder()
+ .prefix(IpPrefix.valueOf(jsonNode.get(PREFIX).asText()))
+ .gatewayIp(IpAddress.valueOf(jsonNode.get(GATEWAY_IP).asText()))
+ .gatewayMac(MacAddress.valueOf(jsonNode.get(GATEWAY_MAC).asText()))
+ .encapsulation(EncapsulationType.enumFromString(encapsulation))
+ .networkName(jsonNode.get(NETWORK_NAME).asText())
+ .build());
+ } catch (Exception e) {
+ log.warn("Fabric subnet parse failed; skip: jsonNode={}", jsonNode);
+ }
+ });
+
+ return subnets;
+ }
+
+ /**
+ * Returns all routes in this configuration.
+ *
+ * @return a set of routes.
+ */
+ public Set<FabricRoute> fabricRoutes() {
+ Set<FabricRoute> routes = Sets.newHashSet();
+
+ JsonNode routesNode = object.get(FABRIC_ROUTES);
+ if (routesNode == null) {
+ return routes;
+ }
+
+ routesNode.forEach(jsonNode -> {
+ try {
+ routes.add(DefaultFabricRoute.builder()
+ .source(FabricRoute.Source.STATIC)
+ .prefix(IpPrefix.valueOf(jsonNode.path(PREFIX).asText()))
+ .nextHop(IpAddress.valueOf(jsonNode.path(NEXT_HOP).asText()))
+ .build());
+ } catch (IllegalArgumentException e) {
+ log.warn("Fabric router parse error; skip: jsonNode={}", jsonNode);
+ }
+ });
+
+ return routes;
+ }
+}
diff --git a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricL2Forward.java b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricForwarding.java
similarity index 74%
rename from apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricL2Forward.java
rename to apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricForwarding.java
index c8ecdd7..48fdf34 100644
--- a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricL2Forward.java
+++ b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricForwarding.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017-present Open Networking Foundation
+ * Copyright 2018-present Open Networking Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.onosproject.simplefabric;
+package org.onosproject.simplefabric.impl;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
@@ -29,7 +29,6 @@
import org.onlab.packet.VlanId;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
-import org.onosproject.net.intf.Interface;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.EncapsulationType;
import org.onosproject.net.FilteredConnectPoint;
@@ -46,19 +45,28 @@
import org.onosproject.net.intent.SinglePointToMultiPointIntent;
import org.onosproject.net.intent.constraint.EncapsulationConstraint;
import org.onosproject.net.intent.constraint.PartialFailureConstraint;
+import org.onosproject.net.intf.Interface;
+import org.onosproject.simplefabric.api.FabricNetwork;
+import org.onosproject.simplefabric.api.SimpleFabricEvent;
+import org.onosproject.simplefabric.api.SimpleFabricListener;
+import org.onosproject.simplefabric.api.SimpleFabricService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Set;
import java.util.HashSet;
import java.util.List;
-import java.util.Objects;
import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
import java.util.stream.Collectors;
+import static org.onosproject.simplefabric.api.Constants.FORWARDING_APP_ID;
+import static org.onosproject.simplefabric.api.Constants.PRI_L2NETWORK_BROADCAST;
+import static org.onosproject.simplefabric.api.Constants.PRI_L2NETWORK_UNICAST;
+
/**
* An implementation of L2NetworkOperationService.
@@ -66,13 +74,13 @@
* application.
*/
@Component(immediate = true, enabled = false)
-public class SimpleFabricL2Forward {
+public class SimpleFabricForwarding {
public static final String BROADCAST = "BCAST";
public static final String UNICAST = "UNI";
private final Logger log = LoggerFactory.getLogger(getClass());
- protected ApplicationId l2ForwardAppId;
+ protected ApplicationId appId;
@Reference(cardinality = ReferenceCardinality.MANDATORY)
protected CoreService coreService;
@@ -97,20 +105,20 @@
@Activate
public void activate() {
- l2ForwardAppId = coreService.registerApplication(simpleFabric.L2FORWARD_APP_ID);
- log.info("simple fabric l2 forwaring starting with l2net app id {}", l2ForwardAppId.toString());
+ appId = coreService.registerApplication(FORWARDING_APP_ID);
+ log.info("simple fabric forwarding starting with l2net app id {}", appId.toString());
simpleFabric.addListener(simpleFabricListener);
refresh();
checkIntentsPurge();
- log.info("simple fabric l2forward started");
+ log.info("simple fabric forwarding started");
}
@Deactivate
public void deactivate() {
- log.info("simple fabric l2forward stopping");
+ log.info("simple fabric forwarding stopping");
simpleFabric.removeListener(simpleFabricListener);
@@ -133,26 +141,27 @@
//bctIntentsMap.clear();
//uniIntentsMap.clear();
- log.info("simple fabric l2forward stopped");
+ log.info("simple fabric forwarding stopped");
}
private void refresh() {
- log.debug("simple fabric l2forward refresh");
+ log.debug("simple fabric forwarding refresh");
Map<Key, SinglePointToMultiPointIntent> newBctIntentsMap = Maps.newConcurrentMap();
Map<Key, MultiPointToSinglePointIntent> newUniIntentsMap = Maps.newConcurrentMap();
- for (L2Network l2Network : simpleFabric.getL2Networks()) {
- // scans all l2network regardless of dirty flag
- // if l2Network.l2Forward == false or number of interfaces() < 2, no Intents generated
- for (SinglePointToMultiPointIntent intent : buildBrcIntents(l2Network)) {
+ for (FabricNetwork fabricNetwork : simpleFabric.fabricNetworks()) {
+ // scans all l2network regardless of isDirty flag
+ // if fabricNetwork.isForward == false or number of interfaces() < 2, no Intents generated
+ for (SinglePointToMultiPointIntent intent : buildBrcIntents(fabricNetwork)) {
newBctIntentsMap.put(intent.key(), intent);
}
- for (MultiPointToSinglePointIntent intent : buildUniIntents(l2Network, hostsFromL2Network(l2Network))) {
+ for (MultiPointToSinglePointIntent intent :
+ buildUniIntents(fabricNetwork, hostsFromL2Network(fabricNetwork))) {
newUniIntentsMap.put(intent.key(), intent);
}
- if (l2Network.dirty()) {
- l2Network.setDirty(false);
+ if (fabricNetwork.isDirty()) {
+ fabricNetwork.setDirty(false);
}
}
@@ -160,7 +169,8 @@
for (SinglePointToMultiPointIntent intent : bctIntentsMap.values()) {
SinglePointToMultiPointIntent newIntent = newBctIntentsMap.get(intent.key());
if (newIntent == null) {
- log.info("simple fabric l2forward withdraw broadcast intent: {}", intent.key().toString());
+ log.info("simple fabric forwarding withdraw broadcast intent: {}",
+ intent.key().toString());
toBePurgedIntentKeys.add(intent.key());
intentService.withdraw(intent);
bctUpdated = true;
@@ -174,7 +184,8 @@
!oldIntent.selector().equals(intent.selector()) ||
!oldIntent.treatment().equals(intent.treatment()) ||
!oldIntent.constraints().equals(intent.constraints())) {
- log.info("simple fabric l2forward submit broadcast intent: {}", intent.key().toString());
+ log.info("simple fabric forwarding submit broadcast intent: {}",
+ intent.key().toString());
toBePurgedIntentKeys.remove(intent.key());
intentService.submit(intent);
bctUpdated = true;
@@ -185,7 +196,8 @@
for (MultiPointToSinglePointIntent intent : uniIntentsMap.values()) {
MultiPointToSinglePointIntent newIntent = newUniIntentsMap.get(intent.key());
if (newIntent == null) {
- log.info("simple fabric l2forward withdraw unicast intent: {}", intent.key().toString());
+ log.info("simple fabric forwarding withdraw unicast intent: {}",
+ intent.key().toString());
toBePurgedIntentKeys.add(intent.key());
intentService.withdraw(intent);
uniUpdated = true;
@@ -199,7 +211,8 @@
!oldIntent.selector().equals(intent.selector()) ||
!oldIntent.treatment().equals(intent.treatment()) ||
!oldIntent.constraints().equals(intent.constraints())) {
- log.info("simple fabric l2forward submit unicast intent: {}", intent.key().toString());
+ log.info("simple fabric forwarding submit unicast intent: {}",
+ intent.key().toString());
toBePurgedIntentKeys.remove(intent.key());
intentService.submit(intent);
uniUpdated = true;
@@ -221,13 +234,14 @@
for (Key key : toBePurgedIntentKeys) {
Intent intentToPurge = intentService.getIntent(key);
if (intentToPurge == null) {
- log.info("simple fabric l2forward purged intent: key={}", key.toString());
+ log.info("simple fabric forwarding purged intent: key={}", key.toString());
purgedKeys.add(key);
} else {
switch (intentService.getIntentState(key)) {
case FAILED:
case WITHDRAWN:
- log.info("simple fabric l2forward try to purge intent: key={}", key.toString());
+ log.info("simple fabric forwarding try to purge intent: key={}",
+ key.toString());
intentService.purge(intentToPurge);
break;
case INSTALL_REQ:
@@ -235,7 +249,7 @@
case INSTALLING:
case RECOMPILING:
case COMPILING:
- log.warn("simple fabric l2forward withdraw intent to purge: key={}", key);
+ log.warn("simple fabric forwarding withdraw intent to purge: key={}", key);
intentService.withdraw(intentToPurge);
break;
case WITHDRAW_REQ:
@@ -254,21 +268,21 @@
// Generates Unicast Intents and broadcast Intents for the L2 Network.
- private Set<Intent> generateL2NetworkIntents(L2Network l2Network) {
+ private Set<Intent> generateL2NetworkIntents(FabricNetwork fabricNetwork) {
return new ImmutableSet.Builder<Intent>()
- .addAll(buildBrcIntents(l2Network))
- .addAll(buildUniIntents(l2Network, hostsFromL2Network(l2Network)))
+ .addAll(buildBrcIntents(fabricNetwork))
+ .addAll(buildUniIntents(fabricNetwork, hostsFromL2Network(fabricNetwork)))
.build();
}
// Build Boadcast Intents for a L2 Network.
- private Set<SinglePointToMultiPointIntent> buildBrcIntents(L2Network l2Network) {
- Set<Interface> interfaces = l2Network.interfaces();
- if (interfaces.size() < 2 || !l2Network.l2Forward() || !l2Network.l2Broadcast()) {
+ private Set<SinglePointToMultiPointIntent> buildBrcIntents(FabricNetwork fabricNetwork) {
+ Set<Interface> interfaces = fabricNetwork.interfaces();
+ if (interfaces.size() < 2 || !fabricNetwork.isForward() || !fabricNetwork.isBroadcast()) {
return ImmutableSet.of();
}
Set<SinglePointToMultiPointIntent> brcIntents = Sets.newHashSet();
- ResourceGroup resourceGroup = ResourceGroup.of(l2Network.name());
+ ResourceGroup resourceGroup = ResourceGroup.of(fabricNetwork.name());
// Generates broadcast Intents from any network interface to other
// network interface from the L2 Network.
@@ -279,18 +293,21 @@
.filter(iface -> !iface.equals(src))
.map(this::buildFilteredConnectedPoint)
.collect(Collectors.toSet());
- Key key = buildKey(l2Network.name(), "BCAST", srcFcp.connectPoint(), MacAddress.BROADCAST);
+ Key key = buildKey(fabricNetwork.name(), "BCAST",
+ srcFcp.connectPoint(), MacAddress.BROADCAST);
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchEthDst(MacAddress.BROADCAST)
.build();
- SinglePointToMultiPointIntent.Builder intentBuilder = SinglePointToMultiPointIntent.builder()
- .appId(l2ForwardAppId)
+ SinglePointToMultiPointIntent.Builder
+ intentBuilder = SinglePointToMultiPointIntent.builder()
+ .appId(appId)
.key(key)
.selector(selector)
.filteredIngressPoint(srcFcp)
.filteredEgressPoints(dstFcps)
- .constraints(buildConstraints(L2NETWORK_CONSTRAINTS, l2Network.encapsulation()))
- .priority(SimpleFabricService.PRI_L2NETWORK_BROADCAST)
+ .constraints(buildConstraints(L2NETWORK_CONSTRAINTS,
+ fabricNetwork.encapsulation()))
+ .priority(PRI_L2NETWORK_BROADCAST)
.resourceGroup(resourceGroup);
brcIntents.add(intentBuilder.build());
});
@@ -298,30 +315,33 @@
}
// Builds unicast Intents for a L2 Network.
- private Set<MultiPointToSinglePointIntent> buildUniIntents(L2Network l2Network, Set<Host> hosts) {
- Set<Interface> interfaces = l2Network.interfaces();
- if (!l2Network.l2Forward() || interfaces.size() < 2) {
+ private Set<MultiPointToSinglePointIntent> buildUniIntents(FabricNetwork fabricNetwork,
+ Set<Host> hosts) {
+ Set<Interface> interfaces = fabricNetwork.interfaces();
+ if (!fabricNetwork.isForward() || interfaces.size() < 2) {
return ImmutableSet.of();
}
Set<MultiPointToSinglePointIntent> uniIntents = Sets.newHashSet();
- ResourceGroup resourceGroup = ResourceGroup.of(l2Network.name());
+ ResourceGroup resourceGroup = ResourceGroup.of(fabricNetwork.name());
hosts.forEach(host -> {
FilteredConnectPoint hostFcp = buildFilteredConnectedPoint(host);
Set<FilteredConnectPoint> srcFcps = interfaces.stream()
.map(this::buildFilteredConnectedPoint)
.filter(fcp -> !fcp.equals(hostFcp))
.collect(Collectors.toSet());
- Key key = buildKey(l2Network.name(), "UNI", hostFcp.connectPoint(), host.mac());
+ Key key = buildKey(fabricNetwork.name(), "UNI", hostFcp.connectPoint(), host.mac());
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchEthDst(host.mac()).build();
- MultiPointToSinglePointIntent.Builder intentBuilder = MultiPointToSinglePointIntent.builder()
- .appId(l2ForwardAppId)
+ MultiPointToSinglePointIntent.Builder
+ intentBuilder = MultiPointToSinglePointIntent.builder()
+ .appId(appId)
.key(key)
.selector(selector)
.filteredIngressPoints(srcFcps)
.filteredEgressPoint(hostFcp)
- .constraints(buildConstraints(L2NETWORK_CONSTRAINTS, l2Network.encapsulation()))
- .priority(SimpleFabricService.PRI_L2NETWORK_UNICAST)
+ .constraints(buildConstraints(L2NETWORK_CONSTRAINTS,
+ fabricNetwork.encapsulation()))
+ .priority(PRI_L2NETWORK_UNICAST)
.resourceGroup(resourceGroup);
uniIntents.add(intentBuilder.build());
});
@@ -331,8 +351,8 @@
// Intent generate utilities
- private Set<Host> hostsFromL2Network(L2Network l2Network) {
- Set<Interface> interfaces = l2Network.interfaces();
+ private Set<Host> hostsFromL2Network(FabricNetwork fabricNetwork) {
+ Set<Interface> interfaces = fabricNetwork.interfaces();
return interfaces.stream()
.map(this::hostsFromInterface)
.flatMap(Collection::stream)
@@ -346,11 +366,14 @@
.collect(Collectors.toSet());
}
- private Key buildKey(String l2NetworkName, String type, ConnectPoint cPoint, MacAddress dstMac) {
- return Key.of(l2NetworkName + "-" + type + "-" + cPoint.toString() + "-" + dstMac, l2ForwardAppId);
+ private Key buildKey(String l2NetworkName, String type,
+ ConnectPoint cPoint, MacAddress dstMac) {
+ return Key.of(l2NetworkName + "-" + type + "-" +
+ cPoint.toString() + "-" + dstMac, appId);
}
- private List<Constraint> buildConstraints(List<Constraint> constraints, EncapsulationType encapsulation) {
+ private List<Constraint> buildConstraints(List<Constraint> constraints,
+ EncapsulationType encapsulation) {
if (!encapsulation.equals(EncapsulationType.NONE)) {
List<Constraint> newConstraints = new ArrayList<>(constraints);
constraints.stream()
@@ -385,25 +408,27 @@
// Dump command handler
private void dump(String subject, PrintStream out) {
if ("intents".equals(subject)) {
- out.println("L2Forward Broadcast Intents:\n");
+ out.println("Forwarding Broadcast Intents:\n");
for (SinglePointToMultiPointIntent intent: bctIntentsMap.values()) {
out.println(" " + intent.key().toString()
+ ": " + intent.selector().criteria()
+ ", [" + intent.filteredIngressPoint().connectPoint()
+ "] -> " + intent.filteredEgressPoints().stream()
- .map(FilteredConnectPoint::connectPoint).collect(Collectors.toSet()));
+ .map(FilteredConnectPoint::connectPoint)
+ .collect(Collectors.toSet()));
}
out.println("");
- out.println("L2Forward Unicast Intents:\n");
+ out.println("Forwarding Unicast Intents:\n");
for (MultiPointToSinglePointIntent intent: uniIntentsMap.values()) {
out.println(" " + intent.key().toString()
+ ": " + intent.selector().criteria()
+ ", [" + intent.filteredIngressPoints().stream()
- .map(FilteredConnectPoint::connectPoint).collect(Collectors.toSet())
+ .map(FilteredConnectPoint::connectPoint)
+ .collect(Collectors.toSet())
+ "] -> " + intent.filteredEgressPoint().connectPoint());
}
out.println("");
- out.println("L2Forward Intents to Be Purged:\n");
+ out.println("Forwarding Intents to Be Purged:\n");
for (Key key: toBePurgedIntentKeys) {
out.println(" " + key.toString());
}
diff --git a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricManager.java b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricManager.java
similarity index 72%
rename from apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricManager.java
rename to apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricManager.java
index d42f8e1..7a4e5d8 100644
--- a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricManager.java
+++ b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017-present Open Networking Foundation
+ * Copyright 2018-present Open Networking Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.onosproject.simplefabric;
+package org.onosproject.simplefabric.impl;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
@@ -64,6 +64,12 @@
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
+import org.onosproject.simplefabric.api.FabricNetwork;
+import org.onosproject.simplefabric.api.FabricRoute;
+import org.onosproject.simplefabric.api.FabricSubnet;
+import org.onosproject.simplefabric.api.SimpleFabricEvent;
+import org.onosproject.simplefabric.api.SimpleFabricListener;
+import org.onosproject.simplefabric.api.SimpleFabricService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -75,7 +81,15 @@
import java.util.Map;
import java.util.Set;
-import static org.onosproject.simplefabric.RouteTools.createBinaryString;
+import static org.onosproject.simplefabric.api.Constants.ALLOW_ETH_ADDRESS_SELECTOR;
+import static org.onosproject.simplefabric.api.Constants.ALLOW_IPV6;
+import static org.onosproject.simplefabric.api.Constants.APP_ID;
+import static org.onosproject.simplefabric.api.Constants.IDLE_INTERVAL_MSEC;
+import static org.onosproject.simplefabric.api.Constants.REACTIVE_ALLOW_LINK_CP;
+import static org.onosproject.simplefabric.api.Constants.REACTIVE_HASHED_PATH_SELECTION;
+import static org.onosproject.simplefabric.api.Constants.REACTIVE_MATCH_IP_PROTO;
+import static org.onosproject.simplefabric.api.Constants.REACTIVE_SINGLE_TO_SINGLE;
+import static org.onosproject.simplefabric.util.RouteTools.createBinaryString;
/**
@@ -118,25 +132,25 @@
// SimpleFabric variables
private ApplicationId appId = null;
- // l2 broadcast networks
- private Set<L2Network> l2Networks = new HashSet<>();
- private Set<Interface> l2NetworkInterfaces = new HashSet<>();
+ // fabric networks
+ private Set<FabricNetwork> fabricNetworks = new HashSet<>();
+ private Set<Interface> networkInterfaces = new HashSet<>();
// Subnet table
- private Set<IpSubnet> ipSubnets = new HashSet<>();
- private InvertedRadixTree<IpSubnet> ip4SubnetTable =
+ private Set<FabricSubnet> fabricSubnets = new HashSet<>();
+ private InvertedRadixTree<FabricSubnet> ip4SubnetTable =
new ConcurrentInvertedRadixTree<>(new DefaultByteArrayNodeFactory());
- private InvertedRadixTree<IpSubnet> ip6SubnetTable =
+ private InvertedRadixTree<FabricSubnet> ip6SubnetTable =
new ConcurrentInvertedRadixTree<>(new DefaultByteArrayNodeFactory());
- // Border Route table
- private Set<Route> borderRoutes = new HashSet<>();
- private InvertedRadixTree<Route> ip4BorderRouteTable =
+ // Fabric Route table
+ private Set<FabricRoute> fabricRoutes = new HashSet<>();
+ private InvertedRadixTree<FabricRoute> ip4BorderRouteTable =
new ConcurrentInvertedRadixTree<>(new DefaultByteArrayNodeFactory());
- private InvertedRadixTree<Route> ip6BorderRouteTable =
+ private InvertedRadixTree<FabricRoute> ip6BorderRouteTable =
new ConcurrentInvertedRadixTree<>(new DefaultByteArrayNodeFactory());
- // VirtialGateway
+ // Virtual gateway
private Map<IpAddress, MacAddress> virtualGatewayIpMacMap = Maps.newConcurrentMap();
// Refresh monitor thread
@@ -149,7 +163,6 @@
private final InternalNetworkConfigListener configListener = new InternalNetworkConfigListener();
private final InternalDeviceListener deviceListener = new InternalDeviceListener();
private final InternalHostListener hostListener = new InternalHostListener();
- private final InternalInterfaceListener interfaceListener = new InternalInterfaceListener();
private ConfigFactory<ApplicationId, SimpleFabricConfig> simpleFabricConfigFactory =
new ConfigFactory<ApplicationId, SimpleFabricConfig>(
@@ -178,9 +191,9 @@
hostService.addListener(hostListener);
componentService.activate(appId, SimpleFabricNeighbour.class.getName());
- componentService.activate(appId, SimpleFabricReactiveRouting.class.getName());
- if (SimpleFabricService.ALLOW_ETH_ADDRESS_SELECTOR) {
- componentService.activate(appId, SimpleFabricL2Forward.class.getName());
+ componentService.activate(appId, SimpleFabricRouting.class.getName());
+ if (ALLOW_ETH_ADDRESS_SELECTOR) {
+ componentService.activate(appId, SimpleFabricForwarding.class.getName());
}
refreshThread = new InternalRefreshThread();
@@ -194,9 +207,9 @@
log.info("simple fabric stopping");
componentService.deactivate(appId, SimpleFabricNeighbour.class.getName());
- componentService.deactivate(appId, SimpleFabricReactiveRouting.class.getName());
- if (SimpleFabricService.ALLOW_ETH_ADDRESS_SELECTOR) {
- componentService.deactivate(appId, SimpleFabricL2Forward.class.getName());
+ componentService.deactivate(appId, SimpleFabricRouting.class.getName());
+ if (ALLOW_ETH_ADDRESS_SELECTOR) {
+ componentService.deactivate(appId, SimpleFabricForwarding.class.getName());
}
deviceService.removeListener(deviceListener);
@@ -211,7 +224,7 @@
}
// Set up from configuration
- // returns found dirty and refresh listners are called (true) or not (false)
+ // returns found isDirty and refresh listeners are called (true) or not (false)
private boolean refresh() {
log.debug("simple fabric refresh");
boolean dirty = false;
@@ -223,66 +236,66 @@
return false;
}
- // l2Networks
- Set<L2Network> newL2Networks = new HashSet<>();
- Set<Interface> newL2NetworkInterfaces = new HashSet<>();
- for (L2Network newL2NetworkConfig : config.getL2Networks()) {
- L2Network newL2Network = L2Network.of(newL2NetworkConfig);
+ // fabricNetworks
+ Set<FabricNetwork> newFabricNetworks = new HashSet<>();
+ Set<Interface> newInterfaces = new HashSet<>();
+ for (FabricNetwork newFabricNetworkConfig : config.fabricNetworks()) {
+ FabricNetwork newFabricNetwork = DefaultFabricNetwork.of(newFabricNetworkConfig);
// fill up interfaces and Hosts with active port only
- for (String ifaceName : newL2NetworkConfig.interfaceNames()) {
+ for (String ifaceName : newFabricNetworkConfig.interfaceNames()) {
Interface iface = getInterfaceByName(ifaceName);
if (iface != null && deviceService.isAvailable(iface.connectPoint().deviceId())) {
- newL2Network.addInterface(iface);
- newL2NetworkInterfaces.add(iface);
+ newFabricNetwork.addInterface(iface);
+ newInterfaces.add(iface);
}
}
for (Host host : hostService.getHosts()) {
// consider host with ip only
if (!host.ipAddresses().isEmpty()) {
Interface iface = findAvailableDeviceHostInterface(host);
- if (iface != null && newL2Network.contains(iface)) {
- newL2Network.addHost(host);
+ if (iface != null && newFabricNetwork.contains(iface)) {
+ newFabricNetwork.addHost(host);
}
}
}
- newL2Network.setDirty(true);
+ newFabricNetwork.setDirty(true);
- // update newL2Network's dirty flags if same entry already exists
- for (L2Network prevL2Network : l2Networks) {
- if (prevL2Network.equals(newL2Network)) {
- newL2Network.setDirty(prevL2Network.dirty());
+ // update newFabricNetwork's isDirty flags if same entry already exists
+ for (FabricNetwork prevFabricNetwork : fabricNetworks) {
+ if (prevFabricNetwork.equals(newFabricNetwork)) {
+ newFabricNetwork.setDirty(prevFabricNetwork.isDirty());
break;
}
}
- newL2Networks.add(newL2Network);
+ newFabricNetworks.add(newFabricNetwork);
}
- if (!l2Networks.equals(newL2Networks)) {
- l2Networks = newL2Networks;
+ if (!fabricNetworks.equals(newFabricNetworks)) {
+ fabricNetworks = newFabricNetworks;
dirty = true;
}
- if (!l2NetworkInterfaces.equals(newL2NetworkInterfaces)) {
- l2NetworkInterfaces = newL2NetworkInterfaces;
+ if (!networkInterfaces.equals(newInterfaces)) {
+ networkInterfaces = newInterfaces;
dirty = true;
}
- // ipSubnets
- Set<IpSubnet> newIpSubnets = config.ipSubnets();
- InvertedRadixTree<IpSubnet> newIp4SubnetTable =
+ // default Fabric Subnets
+ Set<FabricSubnet> newFabricSubnets = config.fabricSubnets();
+ InvertedRadixTree<FabricSubnet> newIp4SubnetTable =
new ConcurrentInvertedRadixTree<>(new DefaultByteArrayNodeFactory());
- InvertedRadixTree<IpSubnet> newIp6SubnetTable =
+ InvertedRadixTree<FabricSubnet> newIp6SubnetTable =
new ConcurrentInvertedRadixTree<>(new DefaultByteArrayNodeFactory());
Map<IpAddress, MacAddress> newVirtualGatewayIpMacMap = Maps.newConcurrentMap();
- for (IpSubnet subnet : newIpSubnets) {
- if (subnet.ipPrefix().isIp4()) {
- newIp4SubnetTable.put(createBinaryString(subnet.ipPrefix()), subnet);
+ for (FabricSubnet subnet : newFabricSubnets) {
+ if (subnet.prefix().isIp4()) {
+ newIp4SubnetTable.put(createBinaryString(subnet.prefix()), subnet);
} else {
- newIp6SubnetTable.put(createBinaryString(subnet.ipPrefix()), subnet);
+ newIp6SubnetTable.put(createBinaryString(subnet.prefix()), subnet);
}
newVirtualGatewayIpMacMap.put(subnet.gatewayIp(), subnet.gatewayMac());
}
- if (!ipSubnets.equals(newIpSubnets)) {
- ipSubnets = newIpSubnets;
+ if (!fabricSubnets.equals(newFabricSubnets)) {
+ fabricSubnets = newFabricSubnets;
ip4SubnetTable = newIp4SubnetTable;
ip6SubnetTable = newIp6SubnetTable;
dirty = true;
@@ -292,21 +305,21 @@
dirty = true;
}
- // borderRoutes config handling
- Set<Route> newBorderRoutes = config.borderRoutes();
- if (!borderRoutes.equals(newBorderRoutes)) {
- InvertedRadixTree<Route> newIp4BorderRouteTable =
+ // fabricRoutes config handling
+ Set<FabricRoute> newFabricRoutes = config.fabricRoutes();
+ if (!fabricRoutes.equals(newFabricRoutes)) {
+ InvertedRadixTree<FabricRoute> newIp4BorderRouteTable =
new ConcurrentInvertedRadixTree<>(new DefaultByteArrayNodeFactory());
- InvertedRadixTree<Route> newIp6BorderRouteTable =
+ InvertedRadixTree<FabricRoute> newIp6BorderRouteTable =
new ConcurrentInvertedRadixTree<>(new DefaultByteArrayNodeFactory());
- for (Route route : newBorderRoutes) {
+ for (FabricRoute route : newFabricRoutes) {
if (route.prefix().isIp4()) {
newIp4BorderRouteTable.put(createBinaryString(route.prefix()), route);
} else {
newIp6BorderRouteTable.put(createBinaryString(route.prefix()), route);
}
}
- borderRoutes = newBorderRoutes;
+ fabricRoutes = newFabricRoutes;
ip4BorderRouteTable = newIp4BorderRouteTable;
ip6BorderRouteTable = newIp6BorderRouteTable;
dirty = true;
@@ -332,7 +345,7 @@
}
@Override
- public ApplicationId getAppId() {
+ public ApplicationId appId() {
if (appId == null) {
appId = coreService.registerApplication(APP_ID);
}
@@ -340,57 +353,57 @@
}
@Override
- public Collection<L2Network> getL2Networks() {
- return ImmutableSet.copyOf(l2Networks);
+ public Collection<FabricNetwork> fabricNetworks() {
+ return ImmutableSet.copyOf(fabricNetworks);
}
@Override
- public Set<IpSubnet> getIpSubnets() {
- return ImmutableSet.copyOf(ipSubnets);
+ public Set<FabricSubnet> defaultFabricSubnets() {
+ return ImmutableSet.copyOf(fabricSubnets);
}
@Override
- public Set<Route> getBorderRoutes() {
- return ImmutableSet.copyOf(borderRoutes);
+ public Set<FabricRoute> fabricRoutes() {
+ return ImmutableSet.copyOf(fabricRoutes);
}
@Override
- public boolean isVMac(MacAddress mac) {
+ public boolean isVirtualGatewayMac(MacAddress mac) {
return virtualGatewayIpMacMap.containsValue(mac);
}
@Override
- public boolean isL2NetworkInterface(Interface intf) {
- return l2NetworkInterfaces.contains(intf);
+ public boolean isFabricNetworkInterface(Interface intf) {
+ return networkInterfaces.contains(intf);
}
@Override
- public MacAddress findVMacForIp(IpAddress ip) {
+ public MacAddress vMacForIp(IpAddress ip) {
return virtualGatewayIpMacMap.get(ip);
}
@Override
- public L2Network findL2Network(ConnectPoint port, VlanId vlanId) {
- for (L2Network l2Network : l2Networks) {
- if (l2Network.contains(port, vlanId)) {
- return l2Network;
+ public FabricNetwork fabricNetwork(ConnectPoint port, VlanId vlanId) {
+ for (FabricNetwork fabricNetwork : fabricNetworks) {
+ if (fabricNetwork.contains(port, vlanId)) {
+ return fabricNetwork;
}
}
return null;
}
@Override
- public L2Network findL2Network(String name) {
- for (L2Network l2Network : l2Networks) {
- if (l2Network.name().equals(name)) {
- return l2Network;
+ public FabricNetwork fabricNetwork(String name) {
+ for (FabricNetwork fabricNetwork : fabricNetworks) {
+ if (fabricNetwork.name().equals(name)) {
+ return fabricNetwork;
}
}
return null;
}
@Override
- public IpSubnet findIpSubnet(IpAddress ip) {
+ public FabricSubnet fabricSubnet(IpAddress ip) {
if (ip.isIp4()) {
return ip4SubnetTable.getValueForLongestKeyPrefixing(
createBinaryString(IpPrefix.valueOf(ip, Ip4Address.BIT_LENGTH)));
@@ -401,8 +414,8 @@
}
@Override
- public Route findBorderRoute(IpAddress ip) {
- // ASSUME: ipAddress is out of ipSubnet
+ public FabricRoute fabricRoute(IpAddress ip) {
+ // ASSUME: ipAddress is out of fabricSubnet
if (ip.isIp4()) {
return ip4BorderRouteTable.getValueForLongestKeyPrefixing(
createBinaryString(IpPrefix.valueOf(ip, Ip4Address.BIT_LENGTH)));
@@ -414,7 +427,7 @@
@Override
- public Interface findHostInterface(Host host) {
+ public Interface hostInterface(Host host) {
return interfaceService.getInterfaces().stream()
.filter(iface -> iface.connectPoint().equals(host.location()) &&
iface.vlan().equals(host.vlan()))
@@ -433,32 +446,32 @@
@Override
public boolean requestMac(IpAddress ip) {
- IpSubnet ipSubnet = findIpSubnet(ip);
- if (ipSubnet == null) {
- log.warn("simple fabric request mac failed for unknown IpSubnet: {}", ip);
+ FabricSubnet fabricSubnet = fabricSubnet(ip);
+ if (fabricSubnet == null) {
+ log.warn("simple fabric request mac failed for unknown fabricSubnet: {}", ip);
return false;
}
- L2Network l2Network = findL2Network(ipSubnet.l2NetworkName());
- if (l2Network == null) {
- log.warn("simple fabric request mac failed for unknown l2Network name {}: {}",
- ipSubnet.l2NetworkName(), ip);
+ FabricNetwork fabricNetwork = fabricNetwork(fabricSubnet.networkName());
+ if (fabricNetwork == null) {
+ log.warn("simple fabric request mac failed for unknown fabricNetwork name {}: {}",
+ fabricSubnet.networkName(), ip);
return false;
}
- log.debug("simple fabric send request mac L2Network {}: {}", l2Network.name(), ip);
- for (Interface iface : l2Network.interfaces()) {
+ log.debug("simple fabric send request mac fabricNetwork {}: {}", fabricNetwork.name(), ip);
+ for (Interface iface : fabricNetwork.interfaces()) {
Ethernet neighbourReq;
if (ip.isIp4()) {
- neighbourReq = ARP.buildArpRequest(ipSubnet.gatewayMac().toBytes(),
- ipSubnet.gatewayIp().toOctets(),
+ neighbourReq = ARP.buildArpRequest(fabricSubnet.gatewayMac().toBytes(),
+ fabricSubnet.gatewayIp().toOctets(),
ip.toOctets(),
iface.vlan().toShort());
} else {
byte[] soliciteIp = IPv6.getSolicitNodeAddress(ip.toOctets());
neighbourReq = NeighborSolicitation.buildNdpSolicit(
ip.toOctets(),
- ipSubnet.gatewayIp().toOctets(),
+ fabricSubnet.gatewayIp().toOctets(),
soliciteIp,
- ipSubnet.gatewayMac().toBytes(),
+ fabricSubnet.gatewayMac().toBytes(),
IPv6.getMCastMacAddress(soliciteIp),
iface.vlan());
}
@@ -482,34 +495,28 @@
protected void dump(String subject, PrintStream out) {
if ("show".equals(subject)) {
out.println("Static Configuration Flag:");
- out.println(" ALLOW_IPV6="
- + SimpleFabricService.ALLOW_IPV6);
- out.println(" ALLOW_ETH_ADDRESS_SELECTOR="
- + SimpleFabricService.ALLOW_ETH_ADDRESS_SELECTOR);
- out.println(" REACTIVE_SINGLE_TO_SINGLE="
- + SimpleFabricService.REACTIVE_SINGLE_TO_SINGLE);
- out.println(" REACTIVE_ALLOW_LINK_CP="
- + SimpleFabricService.REACTIVE_ALLOW_LINK_CP);
- out.println(" REACTIVE_HASHED_PATH_SELECTION="
- + SimpleFabricService.REACTIVE_HASHED_PATH_SELECTION);
- out.println(" REACTIVE_MATCH_IP_PROTO="
- + SimpleFabricService.REACTIVE_MATCH_IP_PROTO);
+ out.println(" ALLOW_IPV6=" + ALLOW_IPV6);
+ out.println(" ALLOW_ETH_ADDRESS_SELECTOR=" + ALLOW_ETH_ADDRESS_SELECTOR);
+ out.println(" REACTIVE_SINGLE_TO_SINGLE=" + REACTIVE_SINGLE_TO_SINGLE);
+ out.println(" REACTIVE_ALLOW_LINK_CP=" + REACTIVE_ALLOW_LINK_CP);
+ out.println(" REACTIVE_HASHED_PATH_SELECTION=" + REACTIVE_HASHED_PATH_SELECTION);
+ out.println(" REACTIVE_MATCH_IP_PROTO=" + REACTIVE_MATCH_IP_PROTO);
out.println("");
out.println("SimpleFabricAppId:");
- out.println(" " + getAppId());
+ out.println(" " + appId());
out.println("");
- out.println("l2Networks:");
- for (L2Network l2Network : getL2Networks()) {
- out.println(" " + l2Network);
+ out.println("fabricNetworks:");
+ for (FabricNetwork fabricNetwork : fabricNetworks()) {
+ out.println(" " + fabricNetwork);
}
out.println("");
- out.println("ipSubnets:");
- for (IpSubnet ipSubnet : getIpSubnets()) {
- out.println(" " + ipSubnet);
+ out.println("fabricSubnets:");
+ for (FabricSubnet fabricIpSubnet : defaultFabricSubnets()) {
+ out.println(" " + fabricIpSubnet);
}
out.println("");
- out.println("borderRoutes:");
- for (Route route : getBorderRoutes()) {
+ out.println("fabricRoutes:");
+ for (FabricRoute route : fabricRoutes()) {
out.println(" " + route);
}
}
diff --git a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricNeighbour.java b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricNeighbour.java
similarity index 88%
rename from apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricNeighbour.java
rename to apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricNeighbour.java
index d506a7e..5d7c8b0 100644
--- a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricNeighbour.java
+++ b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricNeighbour.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017-present Open Networking Foundation
+ * Copyright 2018-present Open Networking Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.simplefabric;
+package org.onosproject.simplefabric.impl;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
@@ -30,6 +30,10 @@
import org.onosproject.net.neighbour.NeighbourResolutionService;
import org.onosproject.net.Host;
import org.onosproject.net.host.HostService;
+import org.onosproject.simplefabric.api.FabricNetwork;
+import org.onosproject.simplefabric.api.SimpleFabricEvent;
+import org.onosproject.simplefabric.api.SimpleFabricListener;
+import org.onosproject.simplefabric.api.SimpleFabricService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -73,7 +77,7 @@
@Activate
public void activate() {
- appId = simpleFabric.getAppId();
+ appId = simpleFabric.appId();
simpleFabric.addListener(simpleFabricListener);
refresh();
log.info("simple fabric neighbour started");
@@ -94,7 +98,7 @@
Set<Interface> interfaces = interfaceService.getInterfaces();
// check for new interfaces
for (Interface intf : interfaces) {
- if (!monitoredInterfaces.contains(intf) && simpleFabric.isL2NetworkInterface(intf)) {
+ if (!monitoredInterfaces.contains(intf) && simpleFabric.isFabricNetworkInterface(intf)) {
log.info("simple fabric neighbour register handler: {}", intf);
neighbourService.registerNeighbourHandler(intf, neighbourHandler, appId);
monitoredInterfaces.add(intf);
@@ -130,7 +134,7 @@
* @param context the message context
*/
protected void handleRequest(NeighbourMessageContext context) {
- MacAddress mac = simpleFabric.findVMacForIp(context.target());
+ MacAddress mac = simpleFabric.vMacForIp(context.target());
if (mac != null) {
log.trace("simple fabric neightbour request on virtualGatewayAddress {}; response to {} {} mac={}",
context.target(), context.inPort(), context.vlan(), mac);
@@ -139,8 +143,8 @@
}
// else forward to corresponding host
- L2Network l2Network = simpleFabric.findL2Network(context.inPort(), context.vlan());
- if (l2Network != null) {
+ FabricNetwork fabricNetwork = simpleFabric.fabricNetwork(context.inPort(), context.vlan());
+ if (fabricNetwork != null) {
int numForwards = 0;
if (!context.dstMac().isBroadcast() && !context.dstMac().isMulticast()) {
for (Host host : hostService.getHostsByMac(context.dstMac())) {
@@ -156,7 +160,7 @@
// else do broadcast to all host in the same l2 network
log.trace("simple fabric neightbour request forward broadcast: {} {}",
context.inPort(), context.vlan());
- for (Interface iface : l2Network.interfaces()) {
+ for (Interface iface : fabricNetwork.interfaces()) {
if (!context.inPort().equals(iface.connectPoint())) {
log.trace("simple fabric forward neighbour request broadcast to {}", iface);
context.forward(iface);
@@ -178,10 +182,10 @@
protected void handleReply(NeighbourMessageContext context,
HostService hostService) {
// Find target L2 Network, then reply to the host
- L2Network l2Network = simpleFabric.findL2Network(context.inPort(), context.vlan());
- if (l2Network != null) {
- // TODO: need to check and update simpleFabric.L2Network
- MacAddress mac = simpleFabric.findVMacForIp(context.target());
+ FabricNetwork fabricNetwork = simpleFabric.fabricNetwork(context.inPort(), context.vlan());
+ if (fabricNetwork != null) {
+ // TODO: need to check and update simpleFabric.DefaultFabricNetwork
+ MacAddress mac = simpleFabric.vMacForIp(context.target());
if (mac != null) {
log.trace("simple fabric neightbour response message to virtual gateway; drop: {} {} target={}",
context.inPort(), context.vlan(), context.target());
@@ -192,14 +196,14 @@
log.trace("simple fabric neightbour response message forward: {} {} target={} -> {}",
context.inPort(), context.vlan(), context.target(), hosts);
hosts.stream()
- .map(host -> simpleFabric.findHostInterface(host))
+ .map(host -> simpleFabric.hostInterface(host))
.filter(Objects::nonNull)
.forEach(context::forward);
}
} else {
// this might be happened when we remove an interface from L2 Network
// just ignore this message
- log.warn("simple fabric neightbour response message drop for unknown l2Network: {} {}",
+ log.warn("simple fabric neightbour response message drop for unknown fabricNetwork: {} {}",
context.inPort(), context.vlan());
context.drop();
}
diff --git a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricReactiveRouting.java b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricRouting.java
similarity index 85%
rename from apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricReactiveRouting.java
rename to apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricRouting.java
index ee37a95..cbca9a5 100644
--- a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricReactiveRouting.java
+++ b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/SimpleFabricRouting.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017-present Open Networking Foundation
+ * Copyright 2018-present Open Networking Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.simplefabric;
+package org.onosproject.simplefabric.impl;
import com.google.common.collect.ImmutableList;
import org.osgi.service.component.annotations.Activate;
@@ -27,41 +27,41 @@
import org.onlab.packet.ICMP6;
import org.onlab.packet.IPv4;
import org.onlab.packet.IPv6;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
import org.onlab.packet.Ip4Address;
import org.onlab.packet.Ip4Prefix;
import org.onlab.packet.Ip6Address;
import org.onlab.packet.Ip6Prefix;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpPrefix;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
-import org.onosproject.net.FilteredConnectPoint;
-import org.onosproject.net.intf.InterfaceService;
import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.EncapsulationType;
import org.onosproject.net.Device;
import org.onosproject.net.DeviceId;
+import org.onosproject.net.EncapsulationType;
+import org.onosproject.net.FilteredConnectPoint;
+import org.onosproject.net.Host;
import org.onosproject.net.device.DeviceService;
import org.onosproject.net.flow.DefaultFlowRule;
import org.onosproject.net.flow.DefaultTrafficSelector;
import org.onosproject.net.flow.DefaultTrafficTreatment;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
import org.onosproject.net.flow.FlowRule;
import org.onosproject.net.flow.FlowRuleService;
-import org.onosproject.net.Host;
+import org.onosproject.net.flow.TrafficSelector;
+import org.onosproject.net.flow.TrafficTreatment;
import org.onosproject.net.host.HostService;
import org.onosproject.net.intent.Constraint;
-import org.onosproject.net.intent.constraint.EncapsulationConstraint;
-import org.onosproject.net.intent.constraint.PartialFailureConstraint;
-import org.onosproject.net.intent.constraint.HashedPathSelectionConstraint;
import org.onosproject.net.intent.Intent;
import org.onosproject.net.intent.IntentService;
import org.onosproject.net.intent.Key;
import org.onosproject.net.intent.MultiPointToSinglePointIntent;
+import org.onosproject.net.intent.constraint.EncapsulationConstraint;
+import org.onosproject.net.intent.constraint.HashedPathSelectionConstraint;
+import org.onosproject.net.intent.constraint.PartialFailureConstraint;
import org.onosproject.net.intf.Interface;
+import org.onosproject.net.intf.InterfaceService;
import org.onosproject.net.link.LinkService;
import org.onosproject.net.packet.DefaultOutboundPacket;
import org.onosproject.net.packet.InboundPacket;
@@ -70,6 +70,12 @@
import org.onosproject.net.packet.PacketPriority;
import org.onosproject.net.packet.PacketProcessor;
import org.onosproject.net.packet.PacketService;
+import org.onosproject.simplefabric.api.FabricNetwork;
+import org.onosproject.simplefabric.api.FabricSubnet;
+import org.onosproject.simplefabric.api.FabricRoute;
+import org.onosproject.simplefabric.api.SimpleFabricEvent;
+import org.onosproject.simplefabric.api.SimpleFabricListener;
+import org.onosproject.simplefabric.api.SimpleFabricService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -82,15 +88,29 @@
import java.util.List;
import java.util.Set;
+import static org.onosproject.simplefabric.api.Constants.ALLOW_ETH_ADDRESS_SELECTOR;
+import static org.onosproject.simplefabric.api.Constants.ALLOW_IPV6;
+import static org.onosproject.simplefabric.api.Constants.PRI_REACTIVE_BORDER_BASE;
+import static org.onosproject.simplefabric.api.Constants.PRI_REACTIVE_BORDER_FORWARD;
+import static org.onosproject.simplefabric.api.Constants.PRI_REACTIVE_BORDER_INTERCEPT;
+import static org.onosproject.simplefabric.api.Constants.PRI_REACTIVE_BORDER_STEP;
+import static org.onosproject.simplefabric.api.Constants.PRI_REACTIVE_LOCAL_FORWARD;
+import static org.onosproject.simplefabric.api.Constants.PRI_REACTIVE_LOCAL_INTERCEPT;
+import static org.onosproject.simplefabric.api.Constants.REACTIVE_ALLOW_LINK_CP;
+import static org.onosproject.simplefabric.api.Constants.ROUTING_APP_ID;
+import static org.onosproject.simplefabric.api.Constants.REACTIVE_HASHED_PATH_SELECTION;
+import static org.onosproject.simplefabric.api.Constants.REACTIVE_MATCH_IP_PROTO;
+import static org.onosproject.simplefabric.api.Constants.REACTIVE_SINGLE_TO_SINGLE;
+
/**
- * SimpleFabricReactiveRouting handles L3 Reactive Routing.
+ * SimpleFabricRouting handles Routing.
*/
@Component(immediate = true, enabled = false)
-public class SimpleFabricReactiveRouting {
+public class SimpleFabricRouting {
private final Logger log = LoggerFactory.getLogger(getClass());
- private ApplicationId reactiveAppId;
+ private ApplicationId appId;
@Reference(cardinality = ReferenceCardinality.MANDATORY)
protected CoreService coreService;
@@ -130,36 +150,36 @@
// NOTE: manage purged intents by key for intentService.getIntent() supports key only
private final InternalSimpleFabricListener simpleFabricListener = new InternalSimpleFabricListener();
- private ReactiveRoutingProcessor processor = new ReactiveRoutingProcessor();
+ private InternalRoutingProcessor processor = new InternalRoutingProcessor();
@Activate
public void activate() {
- reactiveAppId = coreService.registerApplication(simpleFabric.REACTIVE_APP_ID);
- log.info("simple fabric reactive routing starting with app id {}", reactiveAppId.toString());
+ appId = coreService.registerApplication(ROUTING_APP_ID);
+ log.info("simple fabric routing starting with app id {}", appId.toString());
// NOTE: may not clear at init for MIGHT generate pending_remove garbages
// use flush event from simple fabric cli command
- if (simpleFabric.REACTIVE_HASHED_PATH_SELECTION) {
+ if (REACTIVE_HASHED_PATH_SELECTION) {
reactiveConstraints = ImmutableList.of(new PartialFailureConstraint(),
new HashedPathSelectionConstraint());
} else {
reactiveConstraints = ImmutableList.of(new PartialFailureConstraint());
}
- processor = new ReactiveRoutingProcessor();
+ processor = new InternalRoutingProcessor();
packetService.addProcessor(processor, PacketProcessor.director(2));
simpleFabric.addListener(simpleFabricListener);
registerIntercepts();
refreshIntercepts();
- log.info("simple fabric reactive routing started");
+ log.info("simple fabric routing started");
}
@Deactivate
public void deactivate() {
- log.info("simple fabric reactive routing stopping");
+ log.info("simple fabric routing stopping");
packetService.removeProcessor(processor);
simpleFabric.removeListener(simpleFabricListener);
@@ -171,11 +191,11 @@
toBePurgedIntentKeys.clear();
- flowRuleService.removeFlowRulesById(reactiveAppId);
+ flowRuleService.removeFlowRulesById(appId);
processor = null;
- log.info("simple fabric reactive routing stopped");
+ log.info("simple fabric routing stopped");
}
/**
@@ -186,15 +206,15 @@
packetService.requestPackets(
DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).build(),
- PacketPriority.REACTIVE, reactiveAppId);
+ PacketPriority.REACTIVE, appId);
- if (simpleFabric.ALLOW_IPV6) {
+ if (ALLOW_IPV6) {
packetService.requestPackets(
DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV6).build(),
- PacketPriority.REACTIVE, reactiveAppId);
+ PacketPriority.REACTIVE, appId);
}
- log.info("simple fabric reactive routing ip packet intercepts started");
+ log.info("simple fabric routing ip packet intercepts started");
}
/**
@@ -205,35 +225,35 @@
packetService.cancelPackets(
DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4).build(),
- PacketPriority.REACTIVE, reactiveAppId);
+ PacketPriority.REACTIVE, appId);
- if (simpleFabric.ALLOW_IPV6) {
+ if (ALLOW_IPV6) {
packetService.cancelPackets(
DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV6).build(),
- PacketPriority.REACTIVE, reactiveAppId);
+ PacketPriority.REACTIVE, appId);
}
- log.info("simple fabric reactive routing ip packet intercepts stopped");
+ log.info("simple fabric routing ip packet intercepts stopped");
}
/**
- * Refresh device flow rules for reative intercepts on local ipSubnets.
+ * Refresh device flow rules for intercepts on local fabricSubnets.
*/
private void refreshIntercepts() {
Set<FlowRule> newInterceptFlowRules = new HashSet<>();
for (Device device : deviceService.getAvailableDevices()) {
- for (IpSubnet subnet : simpleFabric.getIpSubnets()) {
- newInterceptFlowRules.add(generateInterceptFlowRule(true, device.id(), subnet.ipPrefix()));
- // check if this devices has the ipSubnet, then add ip broadcast flue rule
- L2Network l2Network = simpleFabric.findL2Network(subnet.l2NetworkName());
- if (l2Network != null && l2Network.contains(device.id())) {
- newInterceptFlowRules.add(generateLocalSubnetIpBctFlowRule(device.id(), subnet.ipPrefix(),
- l2Network));
+ for (FabricSubnet subnet : simpleFabric.defaultFabricSubnets()) {
+ newInterceptFlowRules.add(generateInterceptFlowRule(true, device.id(), subnet.prefix()));
+ // check if this devices has the fabricSubnet, then add ip broadcast flue rule
+ FabricNetwork fabricNetwork = simpleFabric.fabricNetwork(subnet.networkName());
+ if (fabricNetwork != null && fabricNetwork.contains(device.id())) {
+ newInterceptFlowRules.add(generateLocalSubnetIpBctFlowRule(device.id(), subnet.prefix(),
+ fabricNetwork));
}
// JUST FOR FLOW RULE TEST ONLY
//newInterceptFlowRules.add(generateTestFlowRule(device.id(), subnet.ipPrefix()));
}
- for (Route route : simpleFabric.getBorderRoutes()) {
+ for (FabricRoute route : simpleFabric.fabricRoutes()) {
newInterceptFlowRules.add(generateInterceptFlowRule(false, device.id(), route.prefix()));
}
}
@@ -252,7 +272,7 @@
.filter(rule -> !interceptFlowRules.contains(rule))
.forEach(rule -> {
flowRuleService.applyFlowRules(rule);
- log.info("simple fabric reactive routing apply intercept flow rule: {}", rule);
+ log.info("simple fabric routing apply intercept flow rule: {}", rule);
});
interceptFlowRules = newInterceptFlowRules;
}
@@ -276,13 +296,13 @@
.withPriority(reactivePriority(false, isDstLocalSubnet, prefix.prefixLength()))
.withSelector(selector.build())
.withTreatment(DefaultTrafficTreatment.builder().punt().build())
- .fromApp(reactiveAppId)
+ .fromApp(appId)
.makePermanent()
.forTable(0).build();
return rule;
}
- private FlowRule generateLocalSubnetIpBctFlowRule(DeviceId deviceId, IpPrefix prefix, L2Network l2Network) {
+ private FlowRule generateLocalSubnetIpBctFlowRule(DeviceId deviceId, IpPrefix prefix, FabricNetwork fabricNetwork) {
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
IpPrefix bctPrefix;
if (prefix.isIp4()) {
@@ -303,7 +323,7 @@
}
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
Set<ConnectPoint> newEgressPoints = new HashSet<>();
- for (Interface iface : l2Network.interfaces()) {
+ for (Interface iface : fabricNetwork.interfaces()) {
if (iface.connectPoint().deviceId().equals(deviceId)) {
treatment.setOutput(iface.connectPoint().port());
}
@@ -313,7 +333,7 @@
.withPriority(reactivePriority(true, true, bctPrefix.prefixLength()))
.withSelector(selector.build())
.withTreatment(treatment.build())
- .fromApp(reactiveAppId)
+ .fromApp(appId)
.makePermanent()
.forTable(0).build();
return rule;
@@ -324,7 +344,7 @@
*/
private void refreshRouteIntents() {
for (Intent entry : intentService.getIntents()) {
- if (!reactiveAppId.equals(entry.appId())) {
+ if (!appId.equals(entry.appId())) {
continue;
}
@@ -362,8 +382,8 @@
toBePurgedIntentKeys.add(intent.key());
continue;
}
- if (!(simpleFabric.findL2Network(intent.egressPoint(), VlanId.NONE) != null ||
- (simpleFabric.REACTIVE_ALLOW_LINK_CP &&
+ if (!(simpleFabric.fabricNetwork(intent.egressPoint(), VlanId.NONE) != null ||
+ (REACTIVE_ALLOW_LINK_CP &&
!linkService.getEgressLinks(intent.egressPoint()).isEmpty()))) {
log.info("refresh route intents; remove intent for egress point not available: key={}", intent.key());
intentService.withdraw(intentService.getIntent(intent.key()));
@@ -372,7 +392,7 @@
}
// MAY NEED TO CHECK: intent.egressPoint and intent.treatment's dstMac is valid against hosts
- if (simpleFabric.REACTIVE_SINGLE_TO_SINGLE && !simpleFabric.REACTIVE_ALLOW_LINK_CP) {
+ if (REACTIVE_SINGLE_TO_SINGLE && !REACTIVE_ALLOW_LINK_CP) {
// single path intent only; no need to check ingress points
continue;
}
@@ -381,8 +401,8 @@
boolean ingressPointChanged = false;
for (FilteredConnectPoint cp : intent.filteredIngressPoints()) {
if (deviceService.isAvailable(cp.connectPoint().deviceId()) &&
- (simpleFabric.findL2Network(cp.connectPoint(), VlanId.NONE) != null ||
- (simpleFabric.REACTIVE_ALLOW_LINK_CP &&
+ (simpleFabric.fabricNetwork(cp.connectPoint(), VlanId.NONE) != null ||
+ (REACTIVE_ALLOW_LINK_CP &&
!linkService.getIngressLinks(cp.connectPoint()).isEmpty()))) {
newIngressPoints.add(cp);
} else {
@@ -402,7 +422,7 @@
if (ingressPointChanged) {
MultiPointToSinglePointIntent updatedIntent =
MultiPointToSinglePointIntent.builder()
- .appId(reactiveAppId)
+ .appId(appId)
.key(intent.key())
.selector(intent.selector())
.treatment(intent.treatment())
@@ -466,7 +486,7 @@
// NOTE: cli calls are handling within the cli called node only; so should not user inents.isLocal()
Set<Intent> myIntents = new HashSet<>();
for (Intent intent : intentService.getIntents()) {
- if (reactiveAppId.equals(intent.appId())) {
+ if (appId.equals(intent.appId())) {
myIntents.add(intent);
}
}
@@ -503,9 +523,9 @@
}
/**
- * Reactive Packet Handling.
+ * Internal Packet Handling.
*/
- private class ReactiveRoutingProcessor implements PacketProcessor {
+ private class InternalRoutingProcessor implements PacketProcessor {
@Override
public void process(PacketContext context) {
InboundPacket pkt = context.inPacket();
@@ -552,8 +572,8 @@
private boolean checkVirtualGatewayIpPacket(InboundPacket pkt, IpAddress srcIp, IpAddress dstIp) {
Ethernet ethPkt = pkt.parsed(); // assume valid
- MacAddress mac = simpleFabric.findVMacForIp(dstIp);
- if (mac == null || !simpleFabric.isVMac(ethPkt.getDestinationMAC())) {
+ MacAddress mac = simpleFabric.vMacForIp(dstIp);
+ if (mac == null || !simpleFabric.isVirtualGatewayMac(ethPkt.getDestinationMAC())) {
/* Destination MAC should be any of virtual gateway macs */
return false;
} else if (dstIp.isIp4()) {
@@ -621,12 +641,12 @@
IpAddress dstNextHop = dstIp;
MacAddress treatmentSrcMac = ethPkt.getDestinationMAC();
int borderRoutePrefixLength = 0;
- boolean updateMac = simpleFabric.isVMac(ethPkt.getDestinationMAC());
+ boolean updateMac = simpleFabric.isVirtualGatewayMac(ethPkt.getDestinationMAC());
// check subnet local or route
- IpSubnet srcSubnet = simpleFabric.findIpSubnet(srcIp);
+ FabricSubnet srcSubnet = simpleFabric.fabricSubnet(srcIp);
if (srcSubnet == null) {
- Route route = simpleFabric.findBorderRoute(srcIp);
+ FabricRoute route = simpleFabric.fabricRoute(srcIp);
if (route == null) {
log.warn("unknown srcIp; drop: srcCp={} srcIp={} dstIp={} ipProto={}",
srcCp, srcIp, dstIp, ipProto);
@@ -636,9 +656,9 @@
srcNextHop = route.nextHop();
borderRoutePrefixLength = route.prefix().prefixLength();
}
- IpSubnet dstSubnet = simpleFabric.findIpSubnet(dstIp);
+ FabricSubnet dstSubnet = simpleFabric.fabricSubnet(dstIp);
if (dstSubnet == null) {
- Route route = simpleFabric.findBorderRoute(dstIp);
+ FabricRoute route = simpleFabric.fabricRoute(dstIp);
if (route == null) {
log.warn("unknown dstIp; drop: srcCp={} srcIp={} dstIp={} ipProto={}",
srcCp, srcIp, dstIp, ipProto);
@@ -651,11 +671,11 @@
if (dstSubnet != null) {
// destination is local subnet ip
- if (SimpleFabricService.ALLOW_ETH_ADDRESS_SELECTOR && dstSubnet.equals(srcSubnet)) {
- // NOTE: if ALLOW_ETH_ADDRESS_SELECTOR=false; l2Forward is always false
- L2Network l2Network = simpleFabric.findL2Network(dstSubnet.l2NetworkName());
+ if (ALLOW_ETH_ADDRESS_SELECTOR && dstSubnet.equals(srcSubnet)) {
+ // NOTE: if ALLOW_ETH_ADDRESS_SELECTOR=false; isForward is always false
+ FabricNetwork fabricNetwork = simpleFabric.fabricNetwork(dstSubnet.networkName());
treatmentSrcMac = ethPkt.getSourceMAC();
- if (l2Network != null && l2Network.l2Forward()) {
+ if (fabricNetwork != null && fabricNetwork.isForward()) {
// NOTE: no reactive route action but do forward packet for L2Forward do not handle packet
// update mac only if dstMac is virtualGatewayMac, else assume valid mac already for the l2 network
log.info("LOCAL FORWARD ONLY: "
@@ -709,7 +729,7 @@
log.warn("forward packet nextHopIp host_mac unknown: nextHopIp={}", nextHopIp);
hostService.startMonitoringIp(nextHopIp);
simpleFabric.requestMac(nextHopIp);
- // CONSIDER: make flood on all port of the dstHost's L2Network
+ // CONSIDER: make flood on all port of the dstHost's DefaultFabricNetwork
return;
}
TrafficTreatment treatment = DefaultTrafficTreatment.builder()
@@ -736,15 +756,15 @@
*
* ToHost: dstPrefix = dstHostIp.toIpPrefix(), nextHopIp = destHostIp
* ToInternet: dstPrefix = route.prefix(), nextHopIp = route.nextHopIp
- * returns intent submited or not
+ * returns intent submitted or not
*/
private boolean setUpConnectivity(ConnectPoint srcCp, byte ipProto, IpPrefix srcPrefix, IpPrefix dstPrefix,
IpAddress nextHopIp, MacAddress treatmentSrcMac,
EncapsulationType encap, boolean updateMac,
boolean isDstLocalSubnet, int borderRoutePrefixLength) {
- if (!(simpleFabric.findL2Network(srcCp, VlanId.NONE) != null ||
- (simpleFabric.REACTIVE_ALLOW_LINK_CP && !linkService.getIngressLinks(srcCp).isEmpty()))) {
- log.warn("NO REGI for srcCp not in L2Network; srcCp={} srcPrefix={} dstPrefix={} nextHopIp={}",
+ if (!(simpleFabric.fabricNetwork(srcCp, VlanId.NONE) != null ||
+ (REACTIVE_ALLOW_LINK_CP && !linkService.getIngressLinks(srcCp).isEmpty()))) {
+ log.warn("NO REGI for srcCp not in DefaultFabricNetwork; srcCp={} srcPrefix={} dstPrefix={} nextHopIp={}",
srcCp, srcPrefix, dstPrefix, nextHopIp);
return false;
}
@@ -766,7 +786,7 @@
return false;
}
TrafficTreatment treatment;
- if (updateMac && simpleFabric.ALLOW_ETH_ADDRESS_SELECTOR) {
+ if (updateMac && ALLOW_ETH_ADDRESS_SELECTOR) {
treatment = generateSetMacTreatment(nextHopMac, treatmentSrcMac);
} else {
treatment = DefaultTrafficTreatment.builder().build();
@@ -775,39 +795,39 @@
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
if (dstPrefix.isIp4()) {
selector.matchEthType(Ethernet.TYPE_IPV4);
- if (simpleFabric.REACTIVE_SINGLE_TO_SINGLE && srcPrefix.prefixLength() > 0) {
+ if (REACTIVE_SINGLE_TO_SINGLE && srcPrefix.prefixLength() > 0) {
selector.matchIPSrc(srcPrefix);
}
if (dstPrefix.prefixLength() > 0) {
selector.matchIPDst(dstPrefix);
}
- if (ipProto != 0 && simpleFabric.REACTIVE_MATCH_IP_PROTO) {
+ if (ipProto != 0 && REACTIVE_MATCH_IP_PROTO) {
selector.matchIPProtocol(ipProto);
}
} else {
selector.matchEthType(Ethernet.TYPE_IPV6);
- if (simpleFabric.REACTIVE_SINGLE_TO_SINGLE && srcPrefix.prefixLength() > 0) {
+ if (REACTIVE_SINGLE_TO_SINGLE && srcPrefix.prefixLength() > 0) {
selector.matchIPv6Src(srcPrefix);
}
if (dstPrefix.prefixLength() > 0) {
selector.matchIPv6Dst(dstPrefix);
}
- if (ipProto != 0 && simpleFabric.REACTIVE_MATCH_IP_PROTO) {
+ if (ipProto != 0 && REACTIVE_MATCH_IP_PROTO) {
selector.matchIPProtocol(ipProto);
}
}
Key key;
String keyProtoTag = "";
- if (simpleFabric.REACTIVE_MATCH_IP_PROTO) {
+ if (REACTIVE_MATCH_IP_PROTO) {
keyProtoTag = "-p" + ipProto;
}
- if (simpleFabric.REACTIVE_SINGLE_TO_SINGLE) {
+ if (REACTIVE_SINGLE_TO_SINGLE) {
// allocate intent per (srcPrefix, dstPrefix)
- key = Key.of(srcPrefix.toString() + "-to-" + dstPrefix.toString() + keyProtoTag, reactiveAppId);
+ key = Key.of(srcPrefix.toString() + "-to-" + dstPrefix.toString() + keyProtoTag, appId);
} else {
// allocate intent per (srcDeviceId, dstPrefix)
- key = Key.of(srcCp.deviceId().toString() + "-to-" + dstPrefix.toString() + keyProtoTag, reactiveAppId);
+ key = Key.of(srcCp.deviceId().toString() + "-to-" + dstPrefix.toString() + keyProtoTag, appId);
}
// check and merge already existing ingress points
@@ -835,7 +855,7 @@
MultiPointToSinglePointIntent newIntent = MultiPointToSinglePointIntent.builder()
.key(key)
- .appId(reactiveAppId)
+ .appId(appId)
.selector(selector.build())
.treatment(treatment)
.filteredIngressPoints(ingressPoints)
@@ -843,7 +863,7 @@
.priority(priority)
.constraints(buildConstraints(reactiveConstraints, encap))
.build();
- log.info("submmit mp2p intent: srcPrefix={} dstPrefix={} srcCp={} "
+ log.info("submit mp2p intent: srcPrefix={} dstPrefix={} srcCp={} "
+ "newIntent={} nextHopIp={} nextHopMac={} priority={}",
srcPrefix, dstPrefix, ingressPoints, newIntent, nextHopIp, nextHopMac, priority);
toBePurgedIntentKeys.remove(newIntent.key());
@@ -862,7 +882,7 @@
// monitor border peers for routeService lookup to be effective
private void monitorBorderPeers() {
- for (Route route : simpleFabric.getBorderRoutes()) {
+ for (FabricRoute route : simpleFabric.fabricRoutes()) {
hostService.startMonitoringIp(route.nextHop());
simpleFabric.requestMac(route.nextHop());
}
@@ -872,19 +892,19 @@
private int reactivePriority(boolean isForward, boolean isDstLocalSubnet, int borderRoutePrefixLength) {
if (isDstLocalSubnet) { // -> dst:localSubnet
if (isForward) {
- return simpleFabric.PRI_REACTIVE_LOCAL_FORWARD;
+ return PRI_REACTIVE_LOCAL_FORWARD;
} else { // isInterncept
- return simpleFabric.PRI_REACTIVE_LOCAL_INTERCEPT;
+ return PRI_REACTIVE_LOCAL_INTERCEPT;
}
} else { // -> dst:boarderRouteNextHop
int offset;
if (isForward) {
- offset = simpleFabric.PRI_REACTIVE_BORDER_FORWARD;
+ offset = PRI_REACTIVE_BORDER_FORWARD;
} else { // isIntercept
- offset = simpleFabric.PRI_REACTIVE_BORDER_INTERCEPT;
+ offset = PRI_REACTIVE_BORDER_INTERCEPT;
}
- return simpleFabric.PRI_REACTIVE_BORDER_BASE
- + borderRoutePrefixLength * simpleFabric.PRI_REACTIVE_BORDER_STEP + offset;
+ return PRI_REACTIVE_BORDER_BASE
+ + borderRoutePrefixLength * PRI_REACTIVE_BORDER_STEP + offset;
}
}
@@ -904,9 +924,9 @@
// Dump Cli Handler
private void dump(String subject, PrintStream out) {
if ("intents".equals(subject)) {
- out.println("Reactive Routing Route Intents:\n");
+ out.println("Routing Route Intents:\n");
for (Intent entry : intentService.getIntents()) {
- if (reactiveAppId.equals(entry.appId())) {
+ if (appId.equals(entry.appId())) {
MultiPointToSinglePointIntent intent = (MultiPointToSinglePointIntent) entry;
out.println(" " + intent.key().toString()
+ " to " + intent.egressPoint().toString()
@@ -916,7 +936,7 @@
}
out.println("");
- out.println("Reactive Routing Intercept Flow Rules:\n");
+ out.println("Routing Intercept Flow Rules:\n");
List<FlowRule> rules = new ArrayList(interceptFlowRules);
Collections.sort(rules, new Comparator<FlowRule>() {
@Override
@@ -931,7 +951,7 @@
+ " selector=" + rule.selector().criteria().toString());
}
out.println("");
- out.println("Reactive Routing Intents to Be Purged:\n");
+ out.println("Routing Intents to Be Purged:\n");
for (Key key: toBePurgedIntentKeys) {
out.println(" " + key.toString());
}
@@ -939,7 +959,7 @@
} else if ("reactive-intents".equals(subject)) {
for (Intent entry : intentService.getIntents()) {
- if (reactiveAppId.equals(entry.appId())) {
+ if (appId.equals(entry.appId())) {
MultiPointToSinglePointIntent intent = (MultiPointToSinglePointIntent) entry;
out.println(intent.key().toString()
+ " to " + intent.egressPoint().toString()
diff --git a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricListener.java b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/package-info.java
similarity index 67%
copy from apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricListener.java
copy to apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/package-info.java
index 726d578..d190b08 100644
--- a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricListener.java
+++ b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/impl/package-info.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017-present Open Networking Foundation
+ * Copyright 2018-present Open Networking Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,13 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.simplefabric;
-
-import org.onosproject.event.EventListener;
/**
- * Entity capable of receiving alarm related events.
+ * Simple fabric implementation package.
*/
-public interface SimpleFabricListener extends EventListener<SimpleFabricEvent> {
-}
-
+package org.onosproject.simplefabric.impl;
\ No newline at end of file
diff --git a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/package-info.java b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/package-info.java
similarity index 100%
rename from apps/simplefabric/src/main/java/org/onosproject/simplefabric/package-info.java
rename to apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/package-info.java
diff --git a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/RouteTools.java b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/util/RouteTools.java
similarity index 94%
rename from apps/simplefabric/src/main/java/org/onosproject/simplefabric/RouteTools.java
rename to apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/util/RouteTools.java
index b14438a..d02fed2 100644
--- a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/RouteTools.java
+++ b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/util/RouteTools.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017-present Open Networking Foundation
+ * Copyright 2018-present Open Networking Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
* to remove dependency on onos.incubator.routing services, since 2017-08-09.
*/
-package org.onosproject.simplefabric;
+package org.onosproject.simplefabric.util;
import org.onlab.packet.IpPrefix;
diff --git a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricListener.java b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/util/package-info.java
similarity index 67%
copy from apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricListener.java
copy to apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/util/package-info.java
index 726d578..9b3dde3 100644
--- a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricListener.java
+++ b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/util/package-info.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017-present Open Networking Foundation
+ * Copyright 2018-present Open Networking Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,13 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.simplefabric;
-
-import org.onosproject.event.EventListener;
/**
- * Entity capable of receiving alarm related events.
+ * Simple fabric utility package.
*/
-public interface SimpleFabricListener extends EventListener<SimpleFabricEvent> {
-}
-
+package org.onosproject.simplefabric.util;
\ No newline at end of file
diff --git a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricWebApplication.java b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/web/SimpleFabricWebApplication.java
similarity index 89%
rename from apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricWebApplication.java
rename to apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/web/SimpleFabricWebApplication.java
index d82de73..960b4df 100644
--- a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricWebApplication.java
+++ b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/web/SimpleFabricWebApplication.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017-present Open Networking Foundation
+ * Copyright 2018-present Open Networking Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.onosproject.simplefabric;
+package org.onosproject.simplefabric.web;
import org.onlab.rest.AbstractWebApplication;
diff --git a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricWebResource.java b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/web/SimpleFabricWebResource.java
similarity index 94%
rename from apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricWebResource.java
rename to apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/web/SimpleFabricWebResource.java
index f1e9af7..cc68d6b 100644
--- a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricWebResource.java
+++ b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/web/SimpleFabricWebResource.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017-present Open Networking Foundation
+ * Copyright 2018-present Open Networking Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,9 +14,10 @@
* limitations under the License.
*/
-package org.onosproject.simplefabric;
+package org.onosproject.simplefabric.web;
import org.onosproject.rest.AbstractWebResource;
+import org.onosproject.simplefabric.api.SimpleFabricService;
import java.io.ByteArrayOutputStream;
import javax.ws.rs.GET;
diff --git a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricListener.java b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/web/package-info.java
similarity index 67%
copy from apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricListener.java
copy to apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/web/package-info.java
index 726d578..596ded0 100644
--- a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricListener.java
+++ b/apps/simplefabric/app/src/main/java/org/onosproject/simplefabric/web/package-info.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017-present Open Networking Foundation
+ * Copyright 2018-present Open Networking Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,13 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.simplefabric;
-
-import org.onosproject.event.EventListener;
/**
- * Entity capable of receiving alarm related events.
+ * Simple fabric web package.
*/
-public interface SimpleFabricListener extends EventListener<SimpleFabricEvent> {
-}
-
+package org.onosproject.simplefabric.web;
\ No newline at end of file
diff --git a/apps/simplefabric/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/apps/simplefabric/app/src/main/resources/OSGI-INF/blueprint/shell-config.xml
similarity index 88%
rename from apps/simplefabric/src/main/resources/OSGI-INF/blueprint/shell-config.xml
rename to apps/simplefabric/app/src/main/resources/OSGI-INF/blueprint/shell-config.xml
index 7b6893b..2aad546 100644
--- a/apps/simplefabric/src/main/resources/OSGI-INF/blueprint/shell-config.xml
+++ b/apps/simplefabric/app/src/main/resources/OSGI-INF/blueprint/shell-config.xml
@@ -17,12 +17,12 @@
<command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
<command>
- <action class="org.onosproject.simplefabric.SimpleFabricCommand"/>
+ <action class="org.onosproject.simplefabric.cli.SimpleFabricCommand"/>
<completers>
<ref component-id="SimpleFabricCommandCompleter"/>
</completers>
</command>
</command-bundle>
- <bean id="SimpleFabricCommandCompleter" class="org.onosproject.simplefabric.SimpleFabricCommandCompleter"/>
+ <bean id="SimpleFabricCommandCompleter" class="org.onosproject.simplefabric.cli.SimpleFabricCommandCompleter"/>
</blueprint>
diff --git a/apps/simplefabric/src/main/webapp/WEB-INF/web.xml b/apps/simplefabric/app/src/main/webapp/WEB-INF/web.xml
similarity index 95%
rename from apps/simplefabric/src/main/webapp/WEB-INF/web.xml
rename to apps/simplefabric/app/src/main/webapp/WEB-INF/web.xml
index e136671..ebcac0e 100644
--- a/apps/simplefabric/src/main/webapp/WEB-INF/web.xml
+++ b/apps/simplefabric/app/src/main/webapp/WEB-INF/web.xml
@@ -46,7 +46,7 @@
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
- <param-value>org.onosproject.simplefabric.SimpleFabricWebApplication</param-value>
+ <param-value>org.onosproject.simplefabric.web.SimpleFabricWebApplication</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
diff --git a/apps/simplefabric/app/src/test/java/org/onosproject/simplefabric/impl/DefaultFabricNetworkTest.java b/apps/simplefabric/app/src/test/java/org/onosproject/simplefabric/impl/DefaultFabricNetworkTest.java
new file mode 100644
index 0000000..57152e7
--- /dev/null
+++ b/apps/simplefabric/app/src/test/java/org/onosproject/simplefabric/impl/DefaultFabricNetworkTest.java
@@ -0,0 +1,134 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.simplefabric.impl;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.testing.EqualsTester;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.MacAddress;
+import org.onlab.packet.VlanId;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.EncapsulationType;
+import org.onosproject.net.host.InterfaceIpAddress;
+import org.onosproject.net.intf.Interface;
+import org.onosproject.simplefabric.api.FabricNetwork;
+
+import java.util.List;
+import java.util.Set;
+
+import static junit.framework.TestCase.assertEquals;
+
+/**
+ * Unit tests for the default fabric network class.
+ */
+public final class DefaultFabricNetworkTest {
+
+ private static final String NAME_1 = "network1";
+ private static final String NAME_2 = "network2";
+
+ private static final String INTF_NAMES_1_1 = "h11";
+ private static final String INTF_NAMES_1_2 = "h12";
+ private static final String INTF_NAMES_2_1 = "h21";
+ private static final String INTF_NAMES_2_2 = "h22";
+
+ private static final Set<String> INTF_NAME_SET_1 =
+ ImmutableSet.of(INTF_NAMES_1_1, INTF_NAMES_1_2);
+ private static final Set<String> INTF_NAME_SET_2 =
+ ImmutableSet.of(INTF_NAMES_2_1, INTF_NAMES_2_2);
+
+ private static final EncapsulationType ENCAP_TYPE_1 = EncapsulationType.NONE;
+ private static final EncapsulationType ENCAP_TYPE_2 = EncapsulationType.NONE;
+
+ private static final boolean IS_FORWARD_1 = false;
+ private static final boolean IS_FORWARD_2 = true;
+ private static final boolean IS_BROADCAST_1 = false;
+ private static final boolean IS_BROADCAST_2 = true;
+
+ private FabricNetwork fabricNetwork1;
+ private FabricNetwork sameAsFabricNetwork1;
+ private FabricNetwork fabricNetwork2;
+
+ private static Interface createInterface(int index) {
+
+ String name = "INTF_NAME_" + index;
+ ConnectPoint cp = ConnectPoint.fromString("of:0011223344556677/" + index);
+ InterfaceIpAddress intfIp1 = InterfaceIpAddress.valueOf("10.10.10." + index + "/32");
+ InterfaceIpAddress intfIp2 = InterfaceIpAddress.valueOf("20.20.20." + index + "/32");
+ List<InterfaceIpAddress> intfIps = ImmutableList.of(intfIp1, intfIp2);
+ MacAddress mac = MacAddress.valueOf("00:00:00:00:00:00");
+ VlanId vlanId = VlanId.NONE;
+
+ return new Interface(name, cp, intfIps, mac, vlanId);
+ }
+
+ /**
+ * Initial setup for this unit test.
+ */
+ @Before
+ public void setUp() {
+
+ fabricNetwork1 = DefaultFabricNetwork.builder()
+ .name(NAME_1)
+ .interfaceNames(INTF_NAME_SET_1)
+ .encapsulation(ENCAP_TYPE_1)
+ .forward(IS_FORWARD_1)
+ .broadcast(IS_BROADCAST_1)
+ .build();
+
+ sameAsFabricNetwork1 = DefaultFabricNetwork.builder()
+ .name(NAME_1)
+ .interfaceNames(INTF_NAME_SET_1)
+ .encapsulation(ENCAP_TYPE_1)
+ .forward(IS_FORWARD_1)
+ .broadcast(IS_BROADCAST_1)
+ .build();
+
+ fabricNetwork2 = DefaultFabricNetwork.builder()
+ .name(NAME_2)
+ .interfaceNames(INTF_NAME_SET_2)
+ .encapsulation(ENCAP_TYPE_2)
+ .forward(IS_FORWARD_2)
+ .broadcast(IS_BROADCAST_2)
+ .build();
+ }
+
+ /**
+ * Tests object equality.
+ */
+ @Test
+ public void testEquality() {
+ new EqualsTester().addEqualityGroup(fabricNetwork1, sameAsFabricNetwork1)
+ .addEqualityGroup(fabricNetwork2)
+ .testEquals();
+ }
+
+ /**
+ * Test object construction.
+ */
+ @Test
+ public void testConstruction() {
+ FabricNetwork network = fabricNetwork1;
+
+ assertEquals(network.name(), NAME_1);
+ assertEquals(network.interfaceNames(), INTF_NAME_SET_1);
+ assertEquals(network.encapsulation(), ENCAP_TYPE_1);
+ assertEquals(network.isForward(), IS_FORWARD_1);
+ assertEquals(network.isBroadcast(), IS_BROADCAST_1);
+ }
+}
diff --git a/apps/simplefabric/app/src/test/java/org/onosproject/simplefabric/impl/DefaultFabricRouteTest.java b/apps/simplefabric/app/src/test/java/org/onosproject/simplefabric/impl/DefaultFabricRouteTest.java
new file mode 100644
index 0000000..8a39179
--- /dev/null
+++ b/apps/simplefabric/app/src/test/java/org/onosproject/simplefabric/impl/DefaultFabricRouteTest.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.simplefabric.impl;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpPrefix;
+import org.onosproject.cluster.NodeId;
+import org.onosproject.simplefabric.api.FabricRoute;
+import org.onosproject.simplefabric.api.FabricRoute.Source;
+
+import static junit.framework.TestCase.assertEquals;
+import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+
+/**
+ * Unit tests for the default fabric router.
+ */
+public final class DefaultFabricRouteTest {
+
+ private static final Source SOURCE_1 = Source.STATIC;
+ private static final Source SOURCE_2 = Source.BGP;
+
+ private static final IpPrefix IP_PREFIX_1 = IpPrefix.valueOf("10.10.10.1/32");
+ private static final IpPrefix IP_PREFIX_2 = IpPrefix.valueOf("20.20.20.2/32");
+
+ private static final IpAddress NEXT_HOP_1 = IpAddress.valueOf("10.10.10.1");
+ private static final IpAddress NEXT_HOP_2 = IpAddress.valueOf("20.20.20.2");
+
+ private static final NodeId SOURCE_NODE_1 = NodeId.nodeId("1");
+ private static final NodeId SOURCE_NODE_2 = NodeId.nodeId("2");
+
+ private FabricRoute fabricRoute1;
+ private FabricRoute sameAsFabricRoute1;
+ private FabricRoute fabricRoute2;
+
+ /**
+ * Tests class immutability.
+ */
+ @Test
+ public void testImmutability() {
+ assertThatClassIsImmutable(DefaultFabricRoute.class);
+ }
+
+ /**
+ * Initial setup for this unit test.
+ */
+ @Before
+ public void setUp() {
+ fabricRoute1 = DefaultFabricRoute.builder()
+ .source(SOURCE_1)
+ .prefix(IP_PREFIX_1)
+ .nextHop(NEXT_HOP_1)
+ .sourceNode(SOURCE_NODE_1)
+ .build();
+
+ sameAsFabricRoute1 = DefaultFabricRoute.builder()
+ .source(SOURCE_1)
+ .prefix(IP_PREFIX_1)
+ .nextHop(NEXT_HOP_1)
+ .sourceNode(SOURCE_NODE_1)
+ .build();
+
+ fabricRoute2 = DefaultFabricRoute.builder()
+ .source(SOURCE_2)
+ .prefix(IP_PREFIX_2)
+ .nextHop(NEXT_HOP_2)
+ .sourceNode(SOURCE_NODE_2)
+ .build();
+ }
+
+ /**
+ * Tests object equality.
+ */
+ @Test
+ public void testEquality() {
+ new EqualsTester().addEqualityGroup(fabricRoute1, sameAsFabricRoute1)
+ .addEqualityGroup(fabricRoute2)
+ .testEquals();
+ }
+
+ /**
+ * Test object construction.
+ */
+ @Test
+ public void testConstruction() {
+ FabricRoute route = fabricRoute1;
+
+ assertEquals(route.source(), SOURCE_1);
+ assertEquals(route.prefix(), IP_PREFIX_1);
+ assertEquals(route.nextHop(), NEXT_HOP_1);
+ assertEquals(route.sourceNode(), SOURCE_NODE_1);
+ }
+}
diff --git a/apps/simplefabric/app/src/test/java/org/onosproject/simplefabric/impl/DefaultFabricSubnetTest.java b/apps/simplefabric/app/src/test/java/org/onosproject/simplefabric/impl/DefaultFabricSubnetTest.java
new file mode 100644
index 0000000..82efd14
--- /dev/null
+++ b/apps/simplefabric/app/src/test/java/org/onosproject/simplefabric/impl/DefaultFabricSubnetTest.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.simplefabric.impl;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpPrefix;
+import org.onlab.packet.MacAddress;
+import org.onosproject.net.EncapsulationType;
+import org.onosproject.simplefabric.api.FabricSubnet;
+
+import static junit.framework.TestCase.assertEquals;
+
+/**
+ * Unit tests for the default fabric IP subnet class.
+ */
+public final class DefaultFabricSubnetTest {
+
+ private static final IpPrefix IP_PREFIX_1 = IpPrefix.valueOf("10.10.10.11/32");
+ private static final IpPrefix IP_PREFIX_2 = IpPrefix.valueOf("20.20.20.11/32");
+
+ private static final IpAddress GATEWAY_IP_1 = IpAddress.valueOf("10.10.10.1");
+ private static final IpAddress GATEWAY_IP_2 = IpAddress.valueOf("20.20.20.1");
+
+ private static final MacAddress GATEWAY_MAC_1 = MacAddress.valueOf("00:11:22:33:44:55");
+ private static final MacAddress GATEWAY_MAC_2 = MacAddress.valueOf("11:22:33:44:55:66");
+
+ private static final EncapsulationType ENCAP_TYPE_1 = EncapsulationType.NONE;
+ private static final EncapsulationType ENCAP_TYPE_2 = EncapsulationType.NONE;
+
+ private static final String NETWORK_NAME_1 = "sonaFabric1";
+ private static final String NETWORK_NAME_2 = "sonaFabric2";
+
+ private FabricSubnet subnet1;
+ private FabricSubnet sameAsSubnet1;
+ private FabricSubnet subnet2;
+
+ /**
+ * Initial setup for this unit test.
+ */
+ @Before
+ public void setUp() {
+
+ subnet1 = DefaultFabricSubnet.builder()
+ .prefix(IP_PREFIX_1)
+ .gatewayIp(GATEWAY_IP_1)
+ .gatewayMac(GATEWAY_MAC_1)
+ .encapsulation(ENCAP_TYPE_1)
+ .networkName(NETWORK_NAME_1)
+ .build();
+
+ sameAsSubnet1 = DefaultFabricSubnet.builder()
+ .prefix(IP_PREFIX_1)
+ .gatewayIp(GATEWAY_IP_1)
+ .gatewayMac(GATEWAY_MAC_1)
+ .encapsulation(ENCAP_TYPE_1)
+ .networkName(NETWORK_NAME_1)
+ .build();
+
+ subnet2 = DefaultFabricSubnet.builder()
+ .prefix(IP_PREFIX_2)
+ .gatewayIp(GATEWAY_IP_2)
+ .gatewayMac(GATEWAY_MAC_2)
+ .encapsulation(ENCAP_TYPE_2)
+ .networkName(NETWORK_NAME_2)
+ .build();
+ }
+
+ /**
+ * Tests object equality.
+ */
+ @Test
+ public void testEquality() {
+ new EqualsTester().addEqualityGroup(subnet1, sameAsSubnet1)
+ .addEqualityGroup(subnet2)
+ .testEquals();
+ }
+
+ /**
+ * Test object construction.
+ */
+ @Test
+ public void testConstruction() {
+ FabricSubnet subnet = subnet1;
+
+ assertEquals(subnet.prefix(), IP_PREFIX_1);
+ assertEquals(subnet.gatewayIp(), GATEWAY_IP_1);
+ assertEquals(subnet.gatewayMac(), GATEWAY_MAC_1);
+ assertEquals(subnet.encapsulation(), ENCAP_TYPE_1);
+ assertEquals(subnet.networkName(), NETWORK_NAME_1);
+ }
+}
diff --git a/apps/simplefabric/network-cfg.json b/apps/simplefabric/network-cfg.json
index c8e118b..c7ba9c8 100644
--- a/apps/simplefabric/network-cfg.json
+++ b/apps/simplefabric/network-cfg.json
@@ -1,56 +1,229 @@
{
-
- "devices":{
- "of:0000000000000011":{ "basic":{ "name":"LS1", "latitude":35, "longitude":-100 } },
- "of:0000000000000012":{ "basic":{ "name":"LS2", "latitude":35, "longitude":-90 } },
- "of:0000000000000021":{ "basic":{ "name":"SS1", "latitude":40, "longitude":-100 } },
- "of:0000000000000022":{ "basic":{ "name":"SS2", "latitude":40, "longitude":-90 } }
+ "devices": {
+ "of:0000000000000011": {
+ "basic": {
+ "name": "LS1",
+ "latitude": 35,
+ "longitude": -100
+ }
+ },
+ "of:0000000000000012": {
+ "basic": {
+ "name": "LS2",
+ "latitude": 35,
+ "longitude": -90
+ }
+ },
+ "of:0000000000000021": {
+ "basic": {
+ "name": "SS1",
+ "latitude": 40,
+ "longitude": -100
+ }
+ },
+ "of:0000000000000022": {
+ "basic": {
+ "name": "SS2",
+ "latitude": 40,
+ "longitude": -90
+ }
+ }
},
-
- "ports" : {
- "of:0000000000000011/1" : { "interfaces" : [ { "name" : "h11" } ] },
- "of:0000000000000011/2" : { "interfaces" : [ { "name" : "h12" } ] },
- "of:0000000000000011/3" : { "interfaces" : [ { "name" : "h13" } ] },
- "of:0000000000000011/4" : { "interfaces" : [ { "name" : "h14" } ] },
- "of:0000000000000011/5" : { "interfaces" : [ { "name" : "d11" } ] },
- "of:0000000000000011/6" : { "interfaces" : [ { "name" : "d12" } ] },
- "of:0000000000000011/7" : { "interfaces" : [ { "name" : "LS1_SS1" } ] },
- "of:0000000000000011/8" : { "interfaces" : [ { "name" : "LS1_SS2" } ] },
-
- "of:0000000000000012/1" : { "interfaces" : [ { "name" : "h21" } ] } ,
- "of:0000000000000012/2" : { "interfaces" : [ { "name" : "h22" } ] },
- "of:0000000000000012/3" : { "interfaces" : [ { "name" : "h23" } ] },
- "of:0000000000000012/4" : { "interfaces" : [ { "name" : "h24" } ] },
- "of:0000000000000012/5" : { "interfaces" : [ { "name" : "d21" } ] },
- "of:0000000000000012/6" : { "interfaces" : [ { "name" : "d22" } ] },
- "of:0000000000000012/7" : { "interfaces" : [ { "name" : "LS2_SS1" } ] },
- "of:0000000000000012/8" : { "interfaces" : [ { "name" : "LS2_SS2" } ] },
-
- "of:0000000000000021/1" : { "interfaces" : [ { "name" : "SS1_LS1" } ] },
- "of:0000000000000021/2" : { "interfaces" : [ { "name" : "SS1_LS2" } ] },
-
- "of:0000000000000022/1" : { "interfaces" : [ { "name" : "SS2_LS1" } ] },
- "of:0000000000000022/2" : { "interfaces" : [ { "name" : "SS2_LS2" } ] }
-
+ "ports": {
+ "of:0000000000000011/1": {
+ "interfaces": [
+ {
+ "name": "h11"
+ }
+ ]
+ },
+ "of:0000000000000011/2": {
+ "interfaces": [
+ {
+ "name": "h12"
+ }
+ ]
+ },
+ "of:0000000000000011/3": {
+ "interfaces": [
+ {
+ "name": "h13"
+ }
+ ]
+ },
+ "of:0000000000000011/4": {
+ "interfaces": [
+ {
+ "name": "h14"
+ }
+ ]
+ },
+ "of:0000000000000011/5": {
+ "interfaces": [
+ {
+ "name": "d11"
+ }
+ ]
+ },
+ "of:0000000000000011/6": {
+ "interfaces": [
+ {
+ "name": "d12"
+ }
+ ]
+ },
+ "of:0000000000000011/7": {
+ "interfaces": [
+ {
+ "name": "LS1_SS1"
+ }
+ ]
+ },
+ "of:0000000000000011/8": {
+ "interfaces": [
+ {
+ "name": "LS1_SS2"
+ }
+ ]
+ },
+ "of:0000000000000012/1": {
+ "interfaces": [
+ {
+ "name": "h21"
+ }
+ ]
+ },
+ "of:0000000000000012/2": {
+ "interfaces": [
+ {
+ "name": "h22"
+ }
+ ]
+ },
+ "of:0000000000000012/3": {
+ "interfaces": [
+ {
+ "name": "h23"
+ }
+ ]
+ },
+ "of:0000000000000012/4": {
+ "interfaces": [
+ {
+ "name": "h24"
+ }
+ ]
+ },
+ "of:0000000000000012/5": {
+ "interfaces": [
+ {
+ "name": "d21"
+ }
+ ]
+ },
+ "of:0000000000000012/6": {
+ "interfaces": [
+ {
+ "name": "d22"
+ }
+ ]
+ },
+ "of:0000000000000012/7": {
+ "interfaces": [
+ {
+ "name": "LS2_SS1"
+ }
+ ]
+ },
+ "of:0000000000000012/8": {
+ "interfaces": [
+ {
+ "name": "LS2_SS2"
+ }
+ ]
+ },
+ "of:0000000000000021/1": {
+ "interfaces": [
+ {
+ "name": "SS1_LS1"
+ }
+ ]
+ },
+ "of:0000000000000021/2": {
+ "interfaces": [
+ {
+ "name": "SS1_LS2"
+ }
+ ]
+ },
+ "of:0000000000000022/1": {
+ "interfaces": [
+ {
+ "name": "SS2_LS1"
+ }
+ ]
+ },
+ "of:0000000000000022/2": {
+ "interfaces": [
+ {
+ "name": "SS2_LS2"
+ }
+ ]
+ }
},
-
- "apps" : {
- "org.onosproject.simplefabric" : {
- "simpleFabric" : {
- "l2Networks" : [
- { "name" : "LEAF1", "interfaces" : ["h11", "h12", "h13", "h14", "d11", "d12" ], "l2Forward" : true, "l2Broadcast" : true },
- { "name" : "LEAF2", "interfaces" : ["h21", "h22", "h23", "h24", "d21", "d22" ], "l2Forward" : true, "l2Broadcast" : true }
+ "apps": {
+ "org.onosproject.simplefabric": {
+ "simpleFabric": {
+ "fabricNetworks": [
+ {
+ "name": "LEAF1",
+ "interfaces": [
+ "h11",
+ "h12",
+ "h13",
+ "h14",
+ "d11",
+ "d12"
+ ],
+ "isForward": true,
+ "isBroadcast": true
+ },
+ {
+ "name": "LEAF2",
+ "interfaces": [
+ "h21",
+ "h22",
+ "h23",
+ "h24",
+ "d21",
+ "d22"
+ ],
+ "isForward": true,
+ "isBroadcast": true
+ }
],
- "ipSubnets" : [
- { "ipPrefix" : "10.0.1.0/24", "gatewayIp" : "10.0.1.1", "gatewayMac" : "00:00:10:00:01:01", "l2NetworkName" : "LEAF1" },
- { "ipPrefix" : "10.0.2.0/24", "gatewayIp" : "10.0.2.1", "gatewayMac" : "00:00:10:00:02:01", "l2NetworkName" : "LEAF2" }
+ "fabricSubnets": [
+ {
+ "prefix": "10.0.1.0/24",
+ "gatewayIp": "10.0.1.1",
+ "gatewayMac": "00:00:10:00:01:01",
+ "networkName": "LEAF1"
+ },
+ {
+ "prefix": "10.0.2.0/24",
+ "gatewayIp": "10.0.2.1",
+ "gatewayMac": "00:00:10:00:02:01",
+ "networkName": "LEAF2"
+ }
],
- "borderRoutes" : [
- { "ipPrefix" : "0.0.0.0/0", "nextHop" : "10.0.1.2" }
+ "fabricRoutes": [
+ {
+ "prefix": "0.0.0.0/0",
+ "nextHop": "10.0.1.2"
+ }
]
}
}
}
-
}
diff --git a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/IpSubnet.java b/apps/simplefabric/src/main/java/org/onosproject/simplefabric/IpSubnet.java
deleted file mode 100644
index 596c659..0000000
--- a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/IpSubnet.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.simplefabric;
-
-import com.google.common.base.MoreObjects;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.MacAddress;
-import org.onosproject.net.EncapsulationType;
-
-import java.util.Objects;
-
-/**
- * Configuration details for an ip subnet entry.
- */
-public class IpSubnet {
- private final IpPrefix ipPrefix;
- private final IpAddress gatewayIp;
- private final MacAddress gatewayMac;
- private EncapsulationType encapsulation;
- private final String l2NetworkName;
-
- /**
- * Creates a new ip subnet entry.
- *
- * @param ipPrefix an ip subnet
- * @param gatewayIp IP of the virtual gateway
- * @param gatewayMac MacAddress of the virtual gateway
- * @param encapsulation EnacaptulatioType for routes related to this subnet
- * @param l2NetworkName Name of L2 Network this subnet is bound
- */
- public IpSubnet(IpPrefix ipPrefix, IpAddress gatewayIp, MacAddress gatewayMac,
- EncapsulationType encapsulation, String l2NetworkName) {
- this.ipPrefix = ipPrefix;
- this.gatewayIp = gatewayIp;
- this.gatewayMac = gatewayMac;
- this.encapsulation = EncapsulationType.NONE;
- this.l2NetworkName = l2NetworkName;
- }
-
- /**
- * Gets the ip subnet of the ip subnet entry.
- *
- * @return the ip subnet
- */
- public IpPrefix ipPrefix() {
- return ipPrefix;
- }
-
- /**
- * Gets the virtual gateway IP address of the ip subnet entry.
- *
- * @return the virtual gateway IP address
- */
- public IpAddress gatewayIp() {
- return gatewayIp;
- }
-
- /**
- * Gets the virtual gateway Mac address of the ip subnet entry.
- *
- * @return the virtuai gateway Mac address
- */
- public MacAddress gatewayMac() {
- return gatewayMac;
- }
-
- /**
- * Gets the encapsulation type of ip subnet entry.
- *
- * @return the encapsulation type
- */
- public EncapsulationType encapsulation() {
- return encapsulation;
- }
-
- /**
- * Gets the name of L2 Network this subnet is bound.
- *
- * @return the l2Network name this subnet is allocated
- */
- public String l2NetworkName() {
- return l2NetworkName;
- }
-
- /**
- * Tests whether the IP version of this entry is IPv4.
- *
- * @return true if the IP version of this entry is IPv4, otherwise false.
- */
- public boolean isIp4() {
- return ipPrefix.isIp4();
- }
-
- /**
- * Tests whether the IP version of this entry is IPv6.
- *
- * @return true if the IP version of this entry is IPv6, otherwise false.
- */
- public boolean isIp6() {
- return ipPrefix.isIp6();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(ipPrefix, gatewayIp, gatewayMac, encapsulation, l2NetworkName);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
- if (!(obj instanceof IpSubnet)) {
- return false;
- }
- IpSubnet that = (IpSubnet) obj;
- return Objects.equals(this.ipPrefix, that.ipPrefix)
- && Objects.equals(this.gatewayIp, that.gatewayIp)
- && Objects.equals(this.gatewayMac, that.gatewayMac)
- && Objects.equals(this.encapsulation, that.encapsulation)
- && Objects.equals(this.l2NetworkName, that.l2NetworkName);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("ipPrefix", ipPrefix)
- .add("gatewayIp", gatewayIp)
- .add("gatewayMac", gatewayMac)
- .add("encapsulation", encapsulation)
- .add("l2NetworkName", l2NetworkName)
- .toString();
- }
-}
diff --git a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/L2Network.java b/apps/simplefabric/src/main/java/org/onosproject/simplefabric/L2Network.java
deleted file mode 100644
index 5579159..0000000
--- a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/L2Network.java
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.simplefabric;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Sets;
-import org.onlab.packet.VlanId;
-import org.onosproject.net.intf.Interface;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Host;
-import org.onosproject.net.HostId;
-import org.onosproject.net.EncapsulationType;
-
-import java.util.Collection;
-import java.util.Objects;
-import java.util.Set;
-
-
-/**
- * Class stores a L2Network information.
- */
-public final class L2Network {
-
- private String name; // also for network configuration
- private Set<String> interfaceNames; // also for network configuration
- private EncapsulationType encapsulation; // also for network configuration
- private boolean l2Forward; // do l2Forward (default:true) or not
- private boolean l2Broadcast; // do l2Broadcast (default:true) or not
-
- /* status variables */
- private Set<Interface> interfaces; // available interfaces from interfaceNames
- private Set<HostId> hostIds; // available hosts from interfaces
- private boolean dirty;
-
- /**
- * Constructs a L2Network data for Config value.
- *
- * @param name the given name
- * @param ifaceNames the interface names
- * @param encapsulation the encapsulation type
- * @param l2Forward flag for l2Forward intents to be installed or not
- * @param l2Broadcast flag for l2Broadcast intents to be installed or not
- */
- L2Network(String name, Collection<String> ifaceNames, EncapsulationType encapsulation,
- boolean l2Forward, boolean l2Broadcast) {
- this.name = name;
- this.interfaceNames = Sets.newHashSet();
- this.interfaceNames.addAll(ifaceNames);
- this.encapsulation = encapsulation;
- this.l2Forward = (SimpleFabricService.ALLOW_ETH_ADDRESS_SELECTOR) ? l2Forward : false;
- this.l2Broadcast = (SimpleFabricService.ALLOW_ETH_ADDRESS_SELECTOR) ? l2Broadcast : false;
- this.interfaces = Sets.newHashSet();
- this.hostIds = Sets.newHashSet();
- this.dirty = false;
- }
-
- /**
- * Constructs a L2Network data by given name and encapsulation type.
- *
- * @param name the given name
- * @param encapsulation the encapsulation type
- */
- private L2Network(String name, EncapsulationType encapsulation) {
- this.name = name;
- this.interfaceNames = Sets.newHashSet();
- this.encapsulation = encapsulation;
- this.l2Forward = (SimpleFabricService.ALLOW_ETH_ADDRESS_SELECTOR) ? true : false;
- this.l2Broadcast = (SimpleFabricService.ALLOW_ETH_ADDRESS_SELECTOR) ? true : false;
- this.interfaces = Sets.newHashSet();
- this.hostIds = Sets.newHashSet();
- this.dirty = false;
- }
-
- /**
- * Creates a L2Network data by given name.
- * The encapsulation type of the L2Network will be NONE.
- *
- * @param name the given name
- * @return the L2Network data
- */
- public static L2Network of(String name) {
- Objects.requireNonNull(name);
- return new L2Network(name, EncapsulationType.NONE);
- }
-
- /**
- * Creates a copy of L2Network data.
- *
- * @param l2Network the L2Network data
- * @return the copy of the L2Network data
- */
- public static L2Network of(L2Network l2Network) {
- Objects.requireNonNull(l2Network);
- L2Network l2NetworkCopy = new L2Network(l2Network.name(), l2Network.encapsulation());
- l2NetworkCopy.interfaceNames.addAll(l2Network.interfaceNames());
- l2NetworkCopy.l2Forward = (SimpleFabricService.ALLOW_ETH_ADDRESS_SELECTOR) ? l2Network.l2Forward() : false;
- l2NetworkCopy.l2Broadcast = (SimpleFabricService.ALLOW_ETH_ADDRESS_SELECTOR) ? l2Network.l2Broadcast() : false;
- l2NetworkCopy.interfaces.addAll(l2Network.interfaces());
- l2NetworkCopy.hostIds.addAll(l2Network.hostIds());
- l2NetworkCopy.setDirty(l2Network.dirty());
- return l2NetworkCopy;
- }
-
- // field queries
-
- /**
- * Gets L2Network name.
- *
- * @return the name of L2Network
- */
- public String name() {
- return name;
- }
-
- /**
- * Gets L2Network interfaceNames.
- *
- * @return the interfaceNames of L2Network
- */
- public Set<String> interfaceNames() {
- return ImmutableSet.copyOf(interfaceNames);
- }
-
- /**
- * Gets L2Network encapsulation type.
- *
- * @return the encapsulation type of L2Network
- */
- public EncapsulationType encapsulation() {
- return encapsulation;
- }
-
- /**
- * Gets L2Network l2Forward flag.
- *
- * @return the l2Forward flag of L2Network
- */
- public boolean l2Forward() {
- return l2Forward;
- }
-
- /**
- * Gets L2Network l2Broadcast flag.
- *
- * @return the l2Broadcast flag of L2Network
- */
- public boolean l2Broadcast() {
- return l2Broadcast;
- }
-
- /**
- * Gets L2Network interfaces.
- *
- * @return the interfaces of L2Network
- */
- public Set<Interface> interfaces() {
- return ImmutableSet.copyOf(interfaces);
- }
-
- /**
- * Gets L2Network hosts.
- *
- * @return the hosts of L2Network
- */
- public Set<HostId> hostIds() {
- return ImmutableSet.copyOf(hostIds);
- }
-
- /**
- * Gets L2Network dirty flag.
- *
- * @return the dirty flag of L2Network
- */
- public boolean dirty() {
- return dirty;
- }
-
- /**
- * Checks if the interface is of L2Network.
- *
- * @param iface the interface to be checked
- * @return true if L2Network contains the interface
- */
- public boolean contains(Interface iface) {
- return interfaces.contains(iface);
- }
-
- /**
- * Checks if the ConnectPoint and Vlan is of L2Network.
- *
- * @param port the ConnectPoint to be checked
- * @param vlanId the VlanId of the ConnectPoint to be checked
- * @return true if L2Network contains the interface of the ConnnectPoint and VlanId
- */
- public boolean contains(ConnectPoint port, VlanId vlanId) {
- for (Interface iface : interfaces) {
- if (iface.connectPoint().equals(port) && iface.vlan().equals(vlanId)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Checks if the DeviceId is of L2Network.
- *
- * @param deviceId the DeviceId to be checked
- * @return true if L2Network contains any interface of the DeviceId
- */
- public boolean contains(DeviceId deviceId) {
- for (Interface iface : interfaces) {
- if (iface.connectPoint().deviceId().equals(deviceId)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Adds interface to L2Network.
- *
- * @param iface the Interface to be added
- */
- public void addInterface(Interface iface) {
- Objects.requireNonNull(iface);
- if (interfaces.add(iface)) {
- setDirty(true);
- }
- }
-
- /**
- * Adds host to L2Network.
- *
- * @param host the Host to be added
- */
- public void addHost(Host host) {
- Objects.requireNonNull(host);
- if (hostIds.add(host.id())) {
- setDirty(true);
- }
- }
-
- /**
- * Sets L2Network dirty flag.
- *
- * @param newDirty the dirty flag to be set
- */
- public void setDirty(boolean newDirty) {
- dirty = newDirty;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("name", name)
- .add("interfaceNames", interfaceNames)
- .add("encapsulation", encapsulation)
- .add("l2Forward", l2Forward)
- .add("l2Broadcast", l2Broadcast)
- .add("interfaces", interfaces)
- .add("hostIds", hostIds)
- .add("dirty", dirty)
- .toString();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
- if (!(obj instanceof L2Network)) {
- return false;
- }
- L2Network other = (L2Network) obj;
- return Objects.equals(other.name, this.name)
- && Objects.equals(other.interfaceNames, this.interfaceNames)
- && Objects.equals(other.encapsulation, this.encapsulation)
- && Objects.equals(other.l2Forward, this.l2Forward)
- && Objects.equals(other.l2Broadcast, this.l2Broadcast)
- && Objects.equals(other.interfaces, this.interfaces)
- && Objects.equals(other.hostIds, this.hostIds);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(name, interfaces, encapsulation, l2Forward, l2Broadcast);
- }
-}
diff --git a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/Route.java b/apps/simplefabric/src/main/java/org/onosproject/simplefabric/Route.java
deleted file mode 100644
index 8eabb95..0000000
--- a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/Route.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/*
- * local copy of onos/incubator/api/src/main/java/org/onosproject/incubator/net/routing/Route.java
- * to remove dependency on onos.incubator.routing services, since 2017-08-09.
- */
-
-package org.onosproject.simplefabric;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onosproject.cluster.NodeId;
-
-import java.util.Objects;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Represents a route.
- */
-public class Route {
-
- private static final String VERSION_MISMATCH =
- "Prefix and next hop must be in the same address family";
-
- private static final NodeId UNDEFINED = new NodeId("-");
-
- /**
- * Source of the route.
- */
- public enum Source {
- /**
- * Route came from the iBGP route source.
- */
- BGP,
-
- /**
- * Route came from the FPM route source.
- */
- FPM,
-
- /**
- * Route can from the static route source.
- */
- STATIC,
-
- /**
- * Route source was not defined.
- */
- UNDEFINED
- }
-
- private final Source source;
- private final IpPrefix prefix;
- private final IpAddress nextHop;
- private final NodeId sourceNode;
-
- /**
- * Creates a route.
- *
- * @param source route source
- * @param prefix IP prefix
- * @param nextHop next hop IP address
- */
- public Route(Source source, IpPrefix prefix, IpAddress nextHop) {
- this(source, prefix, nextHop, UNDEFINED);
- }
-
- /**
- * Creates a route.
- *
- * @param source route source
- * @param prefix IP prefix
- * @param nextHop next hop IP address
- * @param sourceNode ONOS node the route was sourced from
- */
- public Route(Source source, IpPrefix prefix, IpAddress nextHop, NodeId sourceNode) {
- checkNotNull(prefix);
- checkNotNull(nextHop);
- checkArgument(prefix.version().equals(nextHop.version()), VERSION_MISMATCH);
-
- this.source = checkNotNull(source);
- this.prefix = prefix;
- this.nextHop = nextHop;
- this.sourceNode = checkNotNull(sourceNode);
- }
-
- /**
- * Returns the route source.
- *
- * @return route source
- */
- public Source source() {
- return source;
- }
-
- /**
- * Returns the IP prefix of the route.
- *
- * @return IP prefix
- */
- public IpPrefix prefix() {
- return prefix;
- }
-
- /**
- * Returns the next hop IP address.
- *
- * @return next hop
- */
- public IpAddress nextHop() {
- return nextHop;
- }
-
- /**
- * Returns the ONOS node the route was sourced from.
- *
- * @return ONOS node ID
- */
- public NodeId sourceNode() {
- return sourceNode;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(prefix, nextHop);
- }
-
- @Override
- public boolean equals(Object other) {
- if (this == other) {
- return true;
- }
-
- if (!(other instanceof Route)) {
- return false;
- }
-
- Route that = (Route) other;
-
- return Objects.equals(this.prefix, that.prefix) &&
- Objects.equals(this.nextHop, that.nextHop);
- }
-
- @Override
- public String toString() {
- return toStringHelper(this)
- .add("prefix", prefix)
- .add("nextHop", nextHop)
- .toString();
- }
-}
diff --git a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricConfig.java b/apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricConfig.java
deleted file mode 100644
index 7bae152..0000000
--- a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricConfig.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.simplefabric;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.google.common.collect.Sets;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.MacAddress;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.net.config.Config;
-import org.onosproject.net.EncapsulationType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Set;
-
-/**
- * Configuration object for prefix config.
- */
-public class SimpleFabricConfig extends Config<ApplicationId> {
- public static final String KEY = "simpleFabric";
-
- private static final String L2NETWORKS = "l2Networks";
- private static final String NAME = "name";
- private static final String INTERFACES = "interfaces";
- private static final String ENCAPSULATION = "encapsulation";
- private static final String L2FORWARD = "l2Forward";
- private static final String L2BROADCAST = "l2Broadcast";
- private static final String IPSUBNETS = "ipSubnets";
- private static final String BORDERROUTES = "borderRoutes";
- private static final String IPPREFIX = "ipPrefix";
- private static final String GATEWAYIP = "gatewayIp";
- private static final String GATEWAYMAC = "gatewayMac";
- private static final String L2NETWORKNAME = "l2NetworkName";
- private static final String NEXTHOP = "nextHop";
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- /**
- * Returns all l2Networks in this configuration.
- *
- * @return A set of L2Network.
- */
- public Set<L2Network> getL2Networks() {
- Set<L2Network> l2Networks = Sets.newHashSet();
- JsonNode l2NetworkNode = object.get(L2NETWORKS);
- if (l2NetworkNode == null) {
- return l2Networks;
- }
-
- l2NetworkNode.forEach(jsonNode -> {
- Set<String> ifaces = Sets.newHashSet();
- JsonNode l2NetworkIfaces = jsonNode.path(INTERFACES);
- if (l2NetworkIfaces == null) {
- log.warn("simple fabric network config cannot find {}; skip: jsonNode={}", INTERFACES, jsonNode);
- } else if (!l2NetworkIfaces.toString().isEmpty()) {
- l2NetworkIfaces.forEach(ifacesNode -> ifaces.add(new String(ifacesNode.asText())));
- }
- String encapsulation = "NONE"; // NONE or VLAN
- if (jsonNode.hasNonNull(ENCAPSULATION)) {
- encapsulation = jsonNode.get(ENCAPSULATION).asText();
- }
- boolean l2Forward = true;
- if (jsonNode.hasNonNull(L2FORWARD)) {
- l2Forward = jsonNode.get(L2FORWARD).asBoolean();
- }
- boolean l2Broadcast = true;
- if (jsonNode.hasNonNull(L2BROADCAST)) {
- l2Broadcast = jsonNode.get(L2BROADCAST).asBoolean();
- }
- try {
- l2Networks.add(new L2Network(
- jsonNode.get(NAME).asText(), ifaces, EncapsulationType.enumFromString(encapsulation),
- l2Forward, l2Broadcast));
- } catch (Exception e) {
- log.warn("simple fabric network config l2Network parse failed; skip: error={} jsonNode={}", jsonNode);
- }
- });
- return l2Networks;
- }
-
- /**
- * Gets the set of configured local IP subnets.
- *
- * @return IP Subnets
- */
- public Set<IpSubnet> ipSubnets() {
- Set<IpSubnet> subnets = Sets.newHashSet();
- JsonNode subnetsNode = object.get(IPSUBNETS);
- if (subnetsNode == null) {
- log.warn("simple fabric network config ipSubnets is null!");
- return subnets;
- }
-
- subnetsNode.forEach(jsonNode -> {
- String encapsulation = "NONE"; // NONE or VLAN
- if (jsonNode.hasNonNull(ENCAPSULATION)) {
- encapsulation = jsonNode.get(ENCAPSULATION).asText();
- }
- try {
- subnets.add(new IpSubnet(
- IpPrefix.valueOf(jsonNode.get(IPPREFIX).asText()),
- IpAddress.valueOf(jsonNode.get(GATEWAYIP).asText()),
- MacAddress.valueOf(jsonNode.get(GATEWAYMAC).asText()),
- EncapsulationType.enumFromString(encapsulation),
- jsonNode.get(L2NETWORKNAME).asText()));
- } catch (Exception e) {
- log.warn("simple fabric network config ipSubnet parse failed; skip: error={} jsonNode={}", jsonNode);
- }
- });
-
- return subnets;
- }
-
- /**
- * Returns all routes in this configuration.
- *
- * @return A set of route.
- */
- public Set<Route> borderRoutes() {
- Set<Route> routes = Sets.newHashSet();
-
- JsonNode routesNode = object.get(BORDERROUTES);
- if (routesNode == null) {
- //log.warn("simple fabric network config borderRoutes is null!");
- return routes;
- }
-
- routesNode.forEach(jsonNode -> {
- try {
- routes.add(new Route(
- Route.Source.STATIC,
- IpPrefix.valueOf(jsonNode.path(IPPREFIX).asText()),
- IpAddress.valueOf(jsonNode.path(NEXTHOP).asText())));
- } catch (IllegalArgumentException e) {
- log.warn("simple fabric network config parse error; skip: {}", jsonNode);
- }
- });
-
- return routes;
- }
-
-}
diff --git a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricService.java b/apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricService.java
deleted file mode 100644
index be2bed3..0000000
--- a/apps/simplefabric/src/main/java/org/onosproject/simplefabric/SimpleFabricService.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.simplefabric;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.MacAddress;
-import org.onlab.packet.VlanId;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.event.ListenerService;
-import org.onosproject.net.intf.Interface;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.Host;
-
-import java.io.OutputStream;
-import java.util.Set;
-import java.util.Collection;
-
-/**
- * Provides information about the routing configuration.
- */
-public interface SimpleFabricService
- extends ListenerService<SimpleFabricEvent, SimpleFabricListener> {
-
- // App symbols
- static final String APP_ID = "org.onosproject.simplefabric";
- static final String L2FORWARD_APP_ID = "org.onosproject.simplefabric.l2forward";
- static final String REACTIVE_APP_ID = "org.onosproject.simplefabric.reactive";
-
- // Priority for l2NetworkRouting: L2NETWORK_UNICAST or L2NETWORK_BROADCAST
- static final int PRI_L2NETWORK_UNICAST = 601;
- static final int PRI_L2NETWORK_BROADCAST = 600;
-
- // Reactive Routing within Local Subnets
- // ASSUME: local subnets NEVER overlaps each other
- static final int PRI_REACTIVE_LOCAL_FORWARD = 501;
- static final int PRI_REACTIVE_LOCAL_INTERCEPT = 500;
- // Reactive Routing for Border Routes with local subnet
- // Priority: REACTIVE_BROUTE_BASE + routeIpPrefix * REACTIVE_BROUTE_STEP
- // + REACTIVE_BROUTE_FORWARD or REACTIVE_BROUTE_INTERCEPT
- static final int PRI_REACTIVE_BORDER_BASE = 100;
- static final int PRI_REACTIVE_BORDER_STEP = 2;
- static final int PRI_REACTIVE_BORDER_FORWARD = 1;
- static final int PRI_REACTIVE_BORDER_INTERCEPT = 0;
-
- // Simple fabric event related timers
- static final long IDLE_INTERVAL_MSEC = 5000;
-
- // Feature control parameters
- static final boolean ALLOW_IPV6 = false;
- static final boolean ALLOW_ETH_ADDRESS_SELECTOR = true;
- static final boolean REACTIVE_SINGLE_TO_SINGLE = false;
- static final boolean REACTIVE_ALLOW_LINK_CP = false; // MUST BE false (yjlee, 2017-10-18)
- static final boolean REACTIVE_HASHED_PATH_SELECTION = false;
- static final boolean REACTIVE_MATCH_IP_PROTO = false;
-
- /**
- * Gets appId.
- *
- * @return appId of simple fabric app
- */
- ApplicationId getAppId();
-
- /**
- * Gets all the l2Networks.
- *
- * @return all the l2Networks
- */
- Collection<L2Network> getL2Networks();
-
- /**
- * Retrieves the entire set of ipSubnets configuration.
- *
- * @return all the ipSubnets
- */
- Set<IpSubnet> getIpSubnets();
-
- /**
- * Retrieves the entire set of static routes to outer networks.
- *
- * @return the set of static routes to outer networks.
- */
- Set<Route> getBorderRoutes();
-
- /**
- * Evaluates whether a mac is of Virtual Gateway Mac Addresses.
- *
- * @param mac the MacAddress to evaluate
- * @return true if the mac is of any Vitrual Gateway Mac Address of ipSubnets
- */
- boolean isVMac(MacAddress mac);
-
- /**
- * Evaluates whether an Interface belongs to l2Networks.
- *
- * @param intf the interface to evaluate
- * @return true if the inteface belongs to l2Networks configed, otherwise false
- */
- boolean isL2NetworkInterface(Interface intf);
-
- /**
- * Find Virtual Gateway Mac Address for Local Subnet Virtual Gateway Ip.
- *
- * @param ip the ip to check for Virtual Gateway Ip
- * @return mac address of virtual gateway
- */
- MacAddress findVMacForIp(IpAddress ip);
-
- /**
- * Finds the L2 Network with given port and vlanId.
- *
- * @param port the port to be matched
- * @param vlanId the vlanId to be matched
- * @return the L2 Network for specific port and vlanId or null
- */
- L2Network findL2Network(ConnectPoint port, VlanId vlanId);
-
- /**
- * Finds the L2 Network of the name.
- *
- * @param name the name to be matched
- * @return the L2 Network for specific name
- */
- L2Network findL2Network(String name);
-
- /**
- * Finds the IpSubnet containing the ipAddress.
- *
- * @param ipAddress the ipAddress to be matched
- * @return the IpSubnet for specific ipAddress
- */
- IpSubnet findIpSubnet(IpAddress ipAddress);
-
- /**
- * Finds the Border Route containing the ipAddress.
- * ASSUME: ipAddress is out of ipSubnets
- *
- * @param ipAddress the ipAddress to be matched
- * @return the IpSubnet for specific ipAddress
- */
- Route findBorderRoute(IpAddress ipAddress);
-
- /**
- * Finds the network interface related to the host.
- *
- * @param host the host
- * @return the interface related to the host
- */
- Interface findHostInterface(Host host);
-
- /**
- * Sends Neighbour Query (ARP or NDP) to Find Host Location.
- *
- * @param ip the ip address to resolve
- * @return true if request mac packets are emitted. otherwise false
- */
- boolean requestMac(IpAddress ip);
-
- /**
- * Sends Dump Event to all SimpleFabricListeners to Dump Info on the Subject.
- *
- * @param subject the subject to dump
- * @param out the output stream to dump
- */
- void dumpToStream(String subject, OutputStream out);
-
- /**
- * Triggers to send Refresh Notification to all sub modules.
- */
- void triggerRefresh();
-
- /**
- * Triggers to send Flush Notification to all sub modules.
- */
- void triggerFlush();
-
-}