summaryrefslogtreecommitdiffstats
path: root/framework/src/onos/apps/routing-api/src
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/apps/routing-api/src')
-rw-r--r--framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/BgpService.java34
-rw-r--r--framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/FibEntry.java100
-rw-r--r--framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/FibListener.java35
-rw-r--r--framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/FibUpdate.java98
-rw-r--r--framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/IntentRequestListener.java86
-rw-r--r--framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/IntentSynchronizationService.java51
-rw-r--r--framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/RouteEntry.java150
-rw-r--r--framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/RouteListener.java30
-rw-r--r--framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/RouteUpdate.java107
-rw-r--r--framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/RoutingService.java72
-rw-r--r--framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/SdnIpService.java39
-rw-r--r--framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/StaticRoutingService.java24
-rw-r--r--framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/BgpConfig.java268
-rw-r--r--framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/BgpPeer.java96
-rw-r--r--framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/BgpSpeaker.java153
-rw-r--r--framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/Interface.java120
-rw-r--r--framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/InterfaceAddress.java101
-rw-r--r--framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/LocalIpPrefixEntry.java141
-rw-r--r--framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/RoutingConfigurationService.java125
-rw-r--r--framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/package-info.java20
-rw-r--r--framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/package-info.java20
-rw-r--r--framework/src/onos/apps/routing-api/src/test/java/org/onosproject/routing/RouteEntryTest.java255
-rw-r--r--framework/src/onos/apps/routing-api/src/test/java/org/onosproject/routing/config/BgpConfigTest.java244
23 files changed, 0 insertions, 2369 deletions
diff --git a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/BgpService.java b/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/BgpService.java
deleted file mode 100644
index f5d95f22..00000000
--- a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/BgpService.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.routing;
-
-/**
- * Provides a way of interacting with the BGP protocol component.
- */
-public interface BgpService {
-
- /**
- * Starts the BGP service.
- *
- * @param routeListener listener to send route updates to
- */
- void start(RouteListener routeListener);
-
- /**
- * Stops the BGP service.
- */
- void stop();
-}
diff --git a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/FibEntry.java b/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/FibEntry.java
deleted file mode 100644
index e2e20498..00000000
--- a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/FibEntry.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.routing;
-
-import com.google.common.base.MoreObjects;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.MacAddress;
-
-import java.util.Objects;
-
-/**
- * An entry in the Forwarding Information Base (FIB).
- */
-public class FibEntry {
-
- private final IpPrefix prefix;
- private final IpAddress nextHopIp;
- private final MacAddress nextHopMac;
-
- /**
- * Creates a new FIB entry.
- *
- * @param prefix IP prefix of the FIB entry
- * @param nextHopIp IP address of the next hop
- * @param nextHopMac MAC address of the next hop
- */
- public FibEntry(IpPrefix prefix, IpAddress nextHopIp, MacAddress nextHopMac) {
- this.prefix = prefix;
- this.nextHopIp = nextHopIp;
- this.nextHopMac = nextHopMac;
- }
-
- /**
- * Returns the IP prefix of the FIB entry.
- *
- * @return the IP prefix
- */
- public IpPrefix prefix() {
- return prefix;
- }
-
- /**
- * Returns the IP address of the next hop.
- *
- * @return the IP address
- */
- public IpAddress nextHopIp() {
- return nextHopIp;
- }
-
- /**
- * Returns the MAC address of the next hop.
- *
- * @return the MAC address
- */
- public MacAddress nextHopMac() {
- return nextHopMac;
- }
-
- @Override
- public boolean equals(Object o) {
- if (!(o instanceof FibEntry)) {
- return false;
- }
-
- FibEntry that = (FibEntry) o;
-
- return Objects.equals(this.prefix, that.prefix) &&
- Objects.equals(this.nextHopIp, that.nextHopIp) &&
- Objects.equals(this.nextHopMac, that.nextHopMac);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(prefix, nextHopIp, nextHopMac);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("prefix", prefix)
- .add("nextHopIp", nextHopIp)
- .add("nextHopMac", nextHopMac)
- .toString();
- }
-}
diff --git a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/FibListener.java b/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/FibListener.java
deleted file mode 100644
index 0c8e6272..00000000
--- a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/FibListener.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.routing;
-
-import java.util.Collection;
-
-/**
- * A component that is able to process Forwarding Information Base (FIB) updates.
- */
-public interface FibListener {
-
- /**
- * Signals the FIB component of changes to the FIB.
- *
- * @param updates FIB updates of the UDPATE type
- * @param withdraws FIB updates of the WITHDRAW type
- */
- // TODO this interface should use only one collection when we have the new
- // intent key API
- void update(Collection<FibUpdate> updates, Collection<FibUpdate> withdraws);
-
-}
diff --git a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/FibUpdate.java b/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/FibUpdate.java
deleted file mode 100644
index dacb1596..00000000
--- a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/FibUpdate.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.routing;
-
-import com.google.common.base.MoreObjects;
-
-import java.util.Objects;
-
-/**
- * Represents a change to the Forwarding Information Base (FIB).
- */
-public class FibUpdate {
-
- /**
- * Specifies the type of the FIB update.
- */
- public enum Type {
- /**
- * The update contains a new or updated FIB entry for a prefix.
- */
- UPDATE,
-
- /**
- * The update signals that a prefix should be removed from the FIB.
- */
- DELETE
- }
-
- private final Type type;
- private final FibEntry entry;
-
- /**
- * Creates a new FIB update.
- *
- * @param type type of the update
- * @param entry FIB entry describing the update
- */
- public FibUpdate(Type type, FibEntry entry) {
- this.type = type;
- this.entry = entry;
- }
-
- /**
- * Returns the type of the update.
- *
- * @return update type
- */
- public Type type() {
- return type;
- }
-
- /**
- * Returns the FIB entry which contains update information.
- *
- * @return the FIB entry
- */
- public FibEntry entry() {
- return entry;
- }
-
- @Override
- public boolean equals(Object o) {
- if (!(o instanceof FibUpdate)) {
- return false;
- }
-
- FibUpdate that = (FibUpdate) o;
-
- return Objects.equals(this.type, that.type) &&
- Objects.equals(this.entry, that.entry);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(type, entry);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("type", type)
- .add("entry", entry)
- .toString();
- }
-}
diff --git a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/IntentRequestListener.java b/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/IntentRequestListener.java
deleted file mode 100644
index 1069ec5a..00000000
--- a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/IntentRequestListener.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.routing;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.MacAddress;
-import org.onosproject.net.ConnectPoint;
-
-/**
- * An interface to process intent requests.
- */
-public interface IntentRequestListener {
-
- /**
- * Sets up connectivity for packet from Internet to a host in local
- * SDN network.
- *
- * @param dstIpAddress IP address of destination host in local SDN network
- */
- void setUpConnectivityInternetToHost(IpAddress dstIpAddress);
-
- /**
- * Sets up the connectivity for two hosts in local SDN network.
- *
- * @param dstIpAddress the destination IP address
- * @param srcIpAddress the source IP address
- * @param srcMacAddress the source MAC address
- * @param srcConnectPoint the connectPoint of the source host
- */
- void setUpConnectivityHostToHost(IpAddress dstIpAddress,
- IpAddress srcIpAddress,
- MacAddress srcMacAddress,
- ConnectPoint srcConnectPoint);
-
- /**
- * Sets up connectivity for packet from a local host to the Internet.
- *
- * @param hostIp IP address of the local host
- * @param prefix external IP prefix that the host is talking to
- * @param nextHopIpAddress IP address of the next hop router for the prefix
- */
- void setUpConnectivityHostToInternet(IpAddress hostIp, IpPrefix prefix,
- IpAddress nextHopIpAddress);
-
- /**
- * Adds one new ingress connect point into ingress points of an existing
- * intent and resubmits the new intent.
- * <p>
- * If there is already an intent for an IP prefix in the system, we do not
- * need to create a new one, we only need to update this existing intent by
- * adding more ingress points.
- * </p>
- *
- * @param ipPrefix the IP prefix used to search the existing
- * MultiPointToSinglePointIntent
- * @param ingressConnectPoint the ingress connect point to be added into
- * the exiting intent
- */
- void updateExistingMp2pIntent(IpPrefix ipPrefix,
- ConnectPoint ingressConnectPoint);
-
- /**
- * Checks whether there is a MultiPointToSinglePointIntent in memory for a
- * given IP prefix.
- *
- * @param ipPrefix the IP prefix used to search the existing
- * MultiPointToSinglePointIntent
- * @return true if there is a MultiPointToSinglePointIntent, otherwise false
- */
- boolean mp2pIntentExists(IpPrefix ipPrefix);
-
-}
diff --git a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/IntentSynchronizationService.java b/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/IntentSynchronizationService.java
deleted file mode 100644
index dc6a838d..00000000
--- a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/IntentSynchronizationService.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.routing;
-
-import org.onosproject.net.intent.Intent;
-
-/**
- * Submits and withdraws intents to the IntentService from a single point in
- * the cluster at any one time. The provided intents will be synchronized with
- * the IntentService on leadership change.
- */
-public interface IntentSynchronizationService {
-
- /**
- * Submits and intent to the synchronizer.
- * <p>
- * The intent will be submitted directly to the IntentService if this node
- * is the leader, otherwise it will be stored in the synchronizer for
- * synchronization if this node becomes the leader.
- * </p>
- *
- * @param intent intent to submit
- */
- void submit(Intent intent);
-
- /**
- * Withdraws an intent from the synchronizer.
- * <p>
- * The intent will be withdrawn directly from the IntentService if this node
- * is the leader. The intent will be removed from the synchronizer's
- * in-memory storage.
- * </p>
- *
- * @param intent intent to withdraw
- */
- void withdraw(Intent intent);
-}
diff --git a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/RouteEntry.java b/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/RouteEntry.java
deleted file mode 100644
index 8204a109..00000000
--- a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/RouteEntry.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.routing;
-
-import com.google.common.base.MoreObjects;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Represents a route entry for an IP prefix.
- */
-public class RouteEntry {
- private final IpPrefix prefix; // The IP prefix
- private final IpAddress nextHop; // Next-hop IP address
-
- /**
- * Class constructor.
- *
- * @param prefix the IP prefix of the route
- * @param nextHop the next hop IP address for the route
- */
- public RouteEntry(IpPrefix prefix, IpAddress nextHop) {
- this.prefix = checkNotNull(prefix);
- this.nextHop = checkNotNull(nextHop);
- }
-
- /**
- * Returns the IP version of the route.
- *
- * @return the IP version of the route
- */
- public IpAddress.Version version() {
- return nextHop.version();
- }
-
- /**
- * Tests whether the IP version of this address is IPv4.
- *
- * @return true if the IP version of this address is IPv4, otherwise false.
- */
- public boolean isIp4() {
- return nextHop.isIp4();
- }
-
- /**
- * Tests whether the IP version of this address is IPv6.
- *
- * @return true if the IP version of this address is IPv6, otherwise false.
- */
- public boolean isIp6() {
- return nextHop.isIp6();
- }
-
- /**
- * Returns the IP prefix of the route.
- *
- * @return the IP prefix of the route
- */
- public IpPrefix prefix() {
- return prefix;
- }
-
- /**
- * Returns the next hop IP address for the route.
- *
- * @return the next hop IP address for the route
- */
- public IpAddress nextHop() {
- return nextHop;
- }
-
- /**
- * Creates the binary string representation of an IP prefix.
- * The prefix can be either IPv4 or IPv6.
- * The string length is equal to the prefix length + 1.
- *
- * For each string, we put a extra "0" in the front. The purpose of
- * doing this is to store the default route inside InvertedRadixTree.
- *
- * @param ipPrefix the IP prefix to use
- * @return the binary string representation
- */
- public static String createBinaryString(IpPrefix ipPrefix) {
- if (ipPrefix.prefixLength() == 0) {
- return "0";
- }
-
- byte[] octets = ipPrefix.address().toOctets();
- StringBuilder result = new StringBuilder(ipPrefix.prefixLength());
- for (int i = 0; i < ipPrefix.prefixLength(); i++) {
- int byteOffset = i / Byte.SIZE;
- int bitOffset = i % Byte.SIZE;
- int mask = 1 << (Byte.SIZE - 1 - bitOffset);
- byte value = octets[byteOffset];
- boolean isSet = ((value & mask) != 0);
- result.append(isSet ? "1" : "0");
- }
-
- return "0" + result.toString();
- }
-
- @Override
- public boolean equals(Object other) {
- if (this == other) {
- return true;
- }
-
- //
- // NOTE: Subclasses are considered as change of identity, hence
- // equals() will return false if the class type doesn't match.
- //
- if (other == null || getClass() != other.getClass()) {
- return false;
- }
-
- RouteEntry otherRoute = (RouteEntry) other;
- return Objects.equals(this.prefix, otherRoute.prefix) &&
- Objects.equals(this.nextHop, otherRoute.nextHop);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(prefix, nextHop);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("prefix", prefix)
- .add("nextHop", nextHop)
- .toString();
- }
-}
diff --git a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/RouteListener.java b/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/RouteListener.java
deleted file mode 100644
index 85752164..00000000
--- a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/RouteListener.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.routing;
-
-import java.util.Collection;
-
-/**
- * An interface to receive route updates from route providers.
- */
-public interface RouteListener {
- /**
- * Receives a route update from a route provider.
- *
- * @param routeUpdates the collection with updated route information
- */
- void update(Collection<RouteUpdate> routeUpdates);
-}
diff --git a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/RouteUpdate.java b/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/RouteUpdate.java
deleted file mode 100644
index 0a3c2f31..00000000
--- a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/RouteUpdate.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.routing;
-
-import com.google.common.base.MoreObjects;
-
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Represents a change in routing information.
- */
-public class RouteUpdate {
- private final Type type; // The route update type
- private final RouteEntry routeEntry; // The updated route entry
-
- /**
- * Specifies the type of a route update.
- * <p>
- * Route updates can either provide updated information for a route, or
- * withdraw a previously updated route.
- * </p>
- */
- public enum Type {
- /**
- * The update contains updated route information for a route.
- */
- UPDATE,
- /**
- * The update withdraws the route, meaning any previous information is
- * no longer valid.
- */
- DELETE
- }
-
- /**
- * Class constructor.
- *
- * @param type the type of the route update
- * @param routeEntry the route entry with the update
- */
- public RouteUpdate(Type type, RouteEntry routeEntry) {
- this.type = type;
- this.routeEntry = checkNotNull(routeEntry);
- }
-
- /**
- * Returns the type of the route update.
- *
- * @return the type of the update
- */
- public Type type() {
- return type;
- }
-
- /**
- * Returns the route entry the route update is for.
- *
- * @return the route entry the route update is for
- */
- public RouteEntry routeEntry() {
- return routeEntry;
- }
-
- @Override
- public boolean equals(Object other) {
- if (other == this) {
- return true;
- }
-
- if (!(other instanceof RouteUpdate)) {
- return false;
- }
-
- RouteUpdate otherUpdate = (RouteUpdate) other;
-
- return Objects.equals(this.type, otherUpdate.type) &&
- Objects.equals(this.routeEntry, otherUpdate.routeEntry);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(type, routeEntry);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("type", type)
- .add("routeEntry", routeEntry)
- .toString();
- }
-}
diff --git a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/RoutingService.java b/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/RoutingService.java
deleted file mode 100644
index 7399ed75..00000000
--- a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/RoutingService.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.routing;
-
-import org.onlab.packet.IpAddress;
-import org.onosproject.routing.config.BgpConfig;
-
-import java.util.Collection;
-
-/**
- * Provides a way of interacting with the RIB management component.
- */
-public interface RoutingService {
-
- String ROUTER_APP_ID = "org.onosproject.router";
-
- Class<BgpConfig> CONFIG_CLASS = BgpConfig.class;
-
- /**
- * Starts the routing service.
- */
- void start();
-
- /**
- * Adds FIB listener.
- *
- * @param fibListener listener to send FIB updates to
- */
- void addFibListener(FibListener fibListener);
-
- /**
- * Stops the routing service.
- */
- void stop();
-
- /**
- * Gets all IPv4 routes known to SDN-IP.
- *
- * @return the SDN-IP IPv4 routes
- */
- Collection<RouteEntry> getRoutes4();
-
- /**
- * Gets all IPv6 routes known to SDN-IP.
- *
- * @return the SDN-IP IPv6 routes
- */
- Collection<RouteEntry> getRoutes6();
-
- /**
- * Finds out the route entry which has the longest matchable IP prefix.
- *
- * @param ipAddress IP address used to find out longest matchable IP prefix
- * @return a route entry which has the longest matchable IP prefix if
- * found, otherwise null
- */
- RouteEntry getLongestMatchableRouteEntry(IpAddress ipAddress);
-
-}
diff --git a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/SdnIpService.java b/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/SdnIpService.java
deleted file mode 100644
index 0945336c..00000000
--- a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/SdnIpService.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.routing;
-
-/**
- * Service interface exported by SDN-IP.
- */
-public interface SdnIpService {
-
- /**
- * Changes whether this SDN-IP instance is the primary or not based on the
- * boolean parameter.
- *
- * @param isPrimary true if the instance is primary, false if it is not
- */
- void modifyPrimary(boolean isPrimary);
-
- /**
- * Gets the intent synchronization service.
- *
- * @return intent synchronization service
- */
- // TODO fix service resolution in SDN-IP
- IntentSynchronizationService getIntentSynchronizationService();
-
-}
diff --git a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/StaticRoutingService.java b/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/StaticRoutingService.java
deleted file mode 100644
index 7d75f5c8..00000000
--- a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/StaticRoutingService.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.routing;
-
-/**
- * Convenience interface to obtain the FIB listener.
- */
-public interface StaticRoutingService {
-
- FibListener getFibListener();
-}
diff --git a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/BgpConfig.java b/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/BgpConfig.java
deleted file mode 100644
index 6085c60a..00000000
--- a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/BgpConfig.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.routing.config;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.JsonNodeFactory;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.collect.Sets;
-import org.onlab.packet.IpAddress;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.config.Config;
-
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Configuration object for BGP config.
- */
-public class BgpConfig extends Config<ApplicationId> {
-
- public static final String SPEAKERS = "bgpSpeakers";
- public static final String CONNECT_POINT = "connectPoint";
- public static final String NAME = "name";
- public static final String PEERS = "peers";
-
- // TODO add methods for updating config
-
- /**
- * Gets the set of configured BGP speakers.
- *
- * @return BGP speakers
- */
- public Set<BgpSpeakerConfig> bgpSpeakers() {
- Set<BgpSpeakerConfig> speakers = Sets.newHashSet();
-
- JsonNode speakersNode = object.get(SPEAKERS);
-
- if (speakersNode == null) {
- return speakers;
- }
-
- speakersNode.forEach(jsonNode -> {
- Set<IpAddress> listenAddresses = Sets.newHashSet();
- jsonNode.path(PEERS).forEach(addressNode ->
- listenAddresses.add(IpAddress.valueOf(addressNode.asText()))
- );
-
- Optional<String> name;
- if (jsonNode.get(NAME) == null) {
- name = Optional.empty();
- } else {
- name = Optional.of(jsonNode.get(NAME).asText());
- }
-
- speakers.add(new BgpSpeakerConfig(name,
- ConnectPoint.deviceConnectPoint(jsonNode.path(CONNECT_POINT).asText()),
- listenAddresses));
- });
-
- return speakers;
- }
-
- /**
- * Examines whether a name of BGP speaker exists in configuration.
- *
- * @param name name of BGP speaker being search
- * @return speaker
- */
- public BgpSpeakerConfig getSpeakerWithName(String name) {
- for (BgpConfig.BgpSpeakerConfig speaker : bgpSpeakers()) {
- if (speaker.name().isPresent() && speaker.name().get().equals(name)) {
- return speaker;
- }
- }
- return null;
- }
-
- /**
- * Adds BGP speaker to configuration.
- *
- * @param speaker BGP speaker configuration entry
- */
- public void addSpeaker(BgpSpeakerConfig speaker) {
- ObjectNode speakerNode = JsonNodeFactory.instance.objectNode();
-
- speakerNode.put(NAME, speaker.name().get());
-
- speakerNode.put(CONNECT_POINT, speaker.connectPoint().elementId().toString()
- + "/" + speaker.connectPoint().port().toString());
-
- ArrayNode peersNode = speakerNode.putArray(PEERS);
- for (IpAddress peerAddress: speaker.peers()) {
- peersNode.add(peerAddress.toString());
- }
-
- ArrayNode speakersArray = bgpSpeakers().isEmpty() ?
- initBgpConfiguration() : (ArrayNode) object.get(SPEAKERS);
- speakersArray.add(speakerNode);
- }
-
- /**
- * Removes BGP speaker from configuration.
- *
- * @param speakerName BGP speaker name
- */
- public void removeSpeaker(String speakerName) {
- ArrayNode speakersArray = (ArrayNode) object.get(SPEAKERS);
-
- for (int i = 0; i < speakersArray.size(); i++) {
- if (speakersArray.get(i).hasNonNull(NAME) &&
- speakersArray.get(i).get(NAME).asText().equals(speakerName)) {
- speakersArray.remove(i);
- return;
- }
- }
- }
-
- /**
- * Adds peering address to BGP speaker.
- *
- * @param speakerName name of BGP speaker
- * @param peerAddress peering address to be added
- */
- public void addPeerToSpeaker(String speakerName, IpAddress peerAddress) {
- JsonNode speakersNode = object.get(SPEAKERS);
- speakersNode.forEach(jsonNode -> {
- if (jsonNode.hasNonNull(NAME) &&
- jsonNode.get(NAME).asText().equals(speakerName)) {
- ArrayNode peersNode = (ArrayNode) jsonNode.get(PEERS);
- for (int i = 0; i < peersNode.size(); i++) {
- if (peersNode.get(i).asText().equals(peerAddress.toString())) {
- return; // Peer already exists.
- }
- }
- peersNode.add(peerAddress.toString());
- }
- });
- }
-
- /**
- * Finds BGP speaker peering with a given external peer.
- *
- * @param peerAddress peering address to be removed
- * @return speaker
- */
- public BgpSpeakerConfig getSpeakerFromPeer(IpAddress peerAddress) {
- for (BgpConfig.BgpSpeakerConfig speaker : bgpSpeakers()) {
- if (speaker.peers().contains(peerAddress)) {
- return speaker;
- }
- }
- return null;
- }
-
- /**
- * Removes peering address from BGP speaker.
- *
- * @param speaker BGP speaker configuration entries
- * @param peerAddress peering address to be removed
- */
- public void removePeerFromSpeaker(BgpSpeakerConfig speaker, IpAddress peerAddress) {
- JsonNode speakersNode = object.get(SPEAKERS);
- speakersNode.forEach(jsonNode -> {
- if (jsonNode.hasNonNull(NAME) &&
- jsonNode.get(NAME).asText().equals(speaker.name().get())) {
- ArrayNode peersNode = (ArrayNode) jsonNode.get(PEERS);
- for (int i = 0; i < peersNode.size(); i++) {
- if (peersNode.get(i).asText().equals(peerAddress.toString())) {
- peersNode.remove(i);
- return;
- }
- }
- }
- });
- }
-
- /**
- * Creates empty configuration for BGP speakers.
- *
- * @return empty array of BGP speakers
- */
- private ArrayNode initBgpConfiguration() {
- return object.putArray(SPEAKERS);
- }
-
-
- /**
- * Configuration for a BGP speaker.
- */
- public static class BgpSpeakerConfig {
-
- private Optional<String> name;
- private ConnectPoint connectPoint;
- private Set<IpAddress> peers;
-
- public BgpSpeakerConfig(Optional<String> name, ConnectPoint connectPoint,
- Set<IpAddress> peers) {
- this.name = checkNotNull(name);
- this.connectPoint = checkNotNull(connectPoint);
- this.peers = checkNotNull(peers);
- }
-
- public Optional<String> name() {
- return name;
- }
-
- public ConnectPoint connectPoint() {
- return connectPoint;
- }
-
- public Set<IpAddress> peers() {
- return peers;
- }
-
- /**
- * Examines if BGP peer is connected.
- *
- * @param peer IP address of peer
- * @return result of search
- */
- public boolean isConnectedToPeer(IpAddress peer) {
- for (final IpAddress entry : peers()) {
- if (entry.equals(peer)) {
- return true;
- }
- }
- return false;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof BgpSpeakerConfig) {
- final BgpSpeakerConfig that = (BgpSpeakerConfig) obj;
- return Objects.equals(this.name, that.name) &&
- Objects.equals(this.connectPoint, that.connectPoint) &&
- Objects.equals(this.peers, that.peers);
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(name, connectPoint, peers);
- }
- }
-}
diff --git a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/BgpPeer.java b/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/BgpPeer.java
deleted file mode 100644
index bf9e7def..00000000
--- a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/BgpPeer.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.routing.config;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.google.common.base.MoreObjects;
-import org.onlab.packet.IpAddress;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.NetTools;
-import org.onosproject.net.PortNumber;
-
-import java.util.Objects;
-
-/**
- * Configuration details for a BGP peer.
- */
-public class BgpPeer {
- private final ConnectPoint connectPoint;
- private final IpAddress ipAddress;
-
- /**
- * Creates a new BgpPeer.
- *
- * @param dpid the DPID of the switch the peer is attached at, as a String
- * @param port the port the peer is attached at
- * @param ipAddress the IP address of the peer as a String
- */
- public BgpPeer(@JsonProperty("attachmentDpid") String dpid,
- @JsonProperty("attachmentPort") long port,
- @JsonProperty("ipAddress") String ipAddress) {
- this.connectPoint = new ConnectPoint(
- DeviceId.deviceId(NetTools.dpidToUri(dpid)),
- PortNumber.portNumber(port));
- this.ipAddress = IpAddress.valueOf(ipAddress);
- }
-
- /**
- * Gets the connection point of the peer.
- *
- * @return the connection point
- */
- public ConnectPoint connectPoint() {
- return connectPoint;
- }
-
- /**
- * Gets the IP address of the peer.
- *
- * @return the IP address
- */
- public IpAddress ipAddress() {
- return ipAddress;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(connectPoint, ipAddress);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
-
- if (!(obj instanceof BgpPeer)) {
- return false;
- }
-
- BgpPeer that = (BgpPeer) obj;
- return Objects.equals(this.connectPoint, that.connectPoint)
- && Objects.equals(this.ipAddress, that.ipAddress);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("connectPoint", connectPoint)
- .add("ipAddress", ipAddress)
- .toString();
- }
-}
diff --git a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/BgpSpeaker.java b/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/BgpSpeaker.java
deleted file mode 100644
index d0df5e70..00000000
--- a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/BgpSpeaker.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.routing.config;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.google.common.base.MoreObjects;
-import org.onlab.packet.MacAddress;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.NetTools;
-import org.onosproject.net.PortNumber;
-
-import java.util.List;
-import java.util.Objects;
-
-/**
- * Represents a BGP daemon in SDN network.
- * <p>
- * Each BGP speaker has a attachment point, which includes a switch DPID and a
- * switch port. Each BGP speaker has one MAC address and several IP addresses,
- * which are used to peer with BGP peers outside the SDN network. For each
- * peer outside the SDN network, we configure a different IP address to BGP
- * speaker inside the SDN network.
- * </p>
- * <p>
- * Each BGP speaker has a name, which is a unique identifying String that is
- * used to reference this speaker in the configuration.
- * </p>
- */
-public class BgpSpeaker {
- private final String name;
- private final ConnectPoint connectPoint;
- private final MacAddress macAddress;
- private List<InterfaceAddress> interfaceAddresses;
-
- /**
- * Class constructor used by the JSON library to create an object.
- *
- * @param name the name of the BGP speaker inside SDN network
- * @param attachmentDpid the DPID where the BGP speaker is attached to
- * @param attachmentPort the port where the BGP speaker is attached to
- * @param macAddress the MAC address of the BGP speaker
- */
- @JsonCreator
- public BgpSpeaker(@JsonProperty("name") String name,
- @JsonProperty("attachmentDpid") String attachmentDpid,
- @JsonProperty("attachmentPort") long attachmentPort,
- @JsonProperty("macAddress") String macAddress) {
-
- this.name = name;
- this.macAddress = MacAddress.valueOf(macAddress);
- this.connectPoint = new ConnectPoint(
- DeviceId.deviceId(NetTools.dpidToUri(attachmentDpid)),
- PortNumber.portNumber(attachmentPort));
- }
-
- /**
- * Sets the addresses we configured for the BGP speaker on all virtual
- * {@link Interface}s.
- *
- * @param interfaceAddresses a list of IP addresses of the BGP speaker
- * configured on all virtual interfaces
- */
- @JsonProperty("interfaceAddresses")
- public void setInterfaceAddresses(
- List<InterfaceAddress> interfaceAddresses) {
- this.interfaceAddresses = interfaceAddresses;
- }
-
- /**
- * Gets the BGP speaker name.
- *
- * @return the BGP speaker name
- */
- public String name() {
- return name;
- }
-
- /**
- * Gets the connect point where the BGP speaker is attached.
- *
- * @return the connect point
- */
- public ConnectPoint connectPoint() {
- return connectPoint;
- }
-
- /**
- * Gets the MAC address of the BGP speaker.
- *
- * @return the MAC address
- */
- public MacAddress macAddress() {
- return macAddress;
- }
-
- /**
- * Gets all IP addresses configured on all {@link Interface}s of the
- * BGP speaker.
- *
- * @return a list of IP addresses of the BGP speaker configured on all
- * virtual interfaces
- */
- public List<InterfaceAddress> interfaceAddresses() {
- return interfaceAddresses;
- }
-
- @Override
- public boolean equals(Object other) {
- if (!(other instanceof BgpSpeaker)) {
- return false;
- }
-
- BgpSpeaker otherBgpSpeaker = (BgpSpeaker) other;
-
- return name.equals(otherBgpSpeaker.name) &&
- connectPoint.equals(
- otherBgpSpeaker.connectPoint) &&
- macAddress.equals(otherBgpSpeaker.macAddress) &&
- interfaceAddresses.equals(otherBgpSpeaker.interfaceAddresses);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(name, connectPoint, macAddress,
- interfaceAddresses);
-
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("speakerName", name)
- .add("connectPoint", connectPoint)
- .add("macAddress", macAddress)
- .add("interfaceAddresses", interfaceAddresses)
- .toString();
- }
-}
diff --git a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/Interface.java b/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/Interface.java
deleted file mode 100644
index 8d563b87..00000000
--- a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/Interface.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.routing.config;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.collect.Sets;
-import org.onlab.packet.MacAddress;
-import org.onlab.packet.VlanId;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.host.InterfaceIpAddress;
-
-import java.util.Objects;
-import java.util.Set;
-
-/**
- * An Interface is a set of addresses that are logically mapped to a switch
- * port in the network.
- */
-public class Interface {
- private final ConnectPoint connectPoint;
- private final Set<InterfaceIpAddress> ipAddresses;
- private final MacAddress macAddress;
- private final VlanId vlan;
-
- /**
- * Creates an Interface based on a connection point, a set of interface
- * IP addresses, and a MAC address.
- *
- * @param connectPoint the connect point this interface is mapped to
- * @param ipAddresses the IP addresses for the interface
- * @param macAddress the MAC address of the interface
- * @param vlan VLAN identifier
- */
- public Interface(ConnectPoint connectPoint,
- Set<InterfaceIpAddress> ipAddresses,
- MacAddress macAddress, VlanId vlan) {
- this.connectPoint = connectPoint;
- this.ipAddresses = Sets.newHashSet(ipAddresses);
- this.macAddress = macAddress;
- this.vlan = vlan;
- }
-
- /**
- * Retrieves the connection point that this interface maps to.
- *
- * @return the connection point
- */
- public ConnectPoint connectPoint() {
- return connectPoint;
- }
-
- /**
- * Retrieves the set of IP addresses that are assigned to the interface.
- *
- * @return the set of interface IP addresses
- */
- public Set<InterfaceIpAddress> ipAddresses() {
- return ipAddresses;
- }
-
- /**
- * Retrieves the MAC address that is assigned to the interface.
- *
- * @return the MAC address
- */
- public MacAddress mac() {
- return macAddress;
- }
-
- /**
- * Retrieves the VLAN ID that is assigned to the interface.
- *
- * @return the VLAN ID
- */
- public VlanId vlan() {
- return vlan;
- }
-
- @Override
- public boolean equals(Object other) {
- if (!(other instanceof Interface)) {
- return false;
- }
-
- Interface otherInterface = (Interface) other;
-
- return connectPoint.equals(otherInterface.connectPoint) &&
- ipAddresses.equals(otherInterface.ipAddresses) &&
- macAddress.equals(otherInterface.macAddress) &&
- vlan.equals(otherInterface.vlan);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(connectPoint, ipAddresses, macAddress, vlan);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("connectPoint", connectPoint)
- .add("ipAddresses", ipAddresses)
- .add("macAddress", macAddress)
- .add("vlan", vlan)
- .toString();
- }
-}
diff --git a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/InterfaceAddress.java b/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/InterfaceAddress.java
deleted file mode 100644
index e0d40fb4..00000000
--- a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/InterfaceAddress.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.routing.config;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.google.common.base.MoreObjects;
-import org.onlab.packet.IpAddress;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.NetTools;
-import org.onosproject.net.PortNumber;
-
-import java.util.Objects;
-
-/**
- * Represents an address of a {@link BgpSpeaker} configured on an
- * {@link Interface}.
- * <p>
- * Each InterfaceAddress includes the interface name and an IP address.
- * </p>
- */
-public class InterfaceAddress {
- private final ConnectPoint connectPoint;
- private final IpAddress ipAddress;
-
- /**
- * Creates an InterfaceAddress object.
- *
- * @param dpid the DPID of the interface as a String
- * @param port the port of the interface
- * @param ipAddress the IP address of a {@link BgpSpeaker} configured on
- * the interface
- */
- public InterfaceAddress(@JsonProperty("interfaceDpid") String dpid,
- @JsonProperty("interfacePort") int port,
- @JsonProperty("ipAddress") String ipAddress) {
- this.connectPoint = new ConnectPoint(
- DeviceId.deviceId(NetTools.dpidToUri(dpid)),
- PortNumber.portNumber(port));
- this.ipAddress = IpAddress.valueOf(ipAddress);
- }
-
- /**
- * Gets the connection point of the peer.
- *
- * @return the connection point
- */
- public ConnectPoint connectPoint() {
- return connectPoint;
- }
-
- /**
- * Gets the IP address of a BGP speaker configured on an {@link Interface}.
- *
- * @return the IP address
- */
- public IpAddress ipAddress() {
- return ipAddress;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(connectPoint, ipAddress);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
-
- if (!(obj instanceof InterfaceAddress)) {
- return false;
- }
-
- InterfaceAddress that = (InterfaceAddress) obj;
- return Objects.equals(this.connectPoint, that.connectPoint)
- && Objects.equals(this.ipAddress, that.ipAddress);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("connectPoint", connectPoint)
- .add("ipAddress", ipAddress)
- .toString();
- }
-}
diff --git a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/LocalIpPrefixEntry.java b/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/LocalIpPrefixEntry.java
deleted file mode 100644
index d9d1824b..00000000
--- a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/LocalIpPrefixEntry.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.routing.config;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.google.common.base.MoreObjects;
-
-import java.util.Objects;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-
-/**
- * Configuration details for an IP prefix entry.
- */
-public class LocalIpPrefixEntry {
- private final IpPrefix ipPrefix;
- private final IpPrefixType type;
- private final IpAddress gatewayIpAddress;
-
- /**
- * Specifies the type of local IP prefix.
- */
- public enum IpPrefixType {
- /**
- * Public IP prefixes should be exchanged by eBGP.
- */
- PUBLIC,
- /**
- * Private IP prefixes should be used only locally and not exchanged
- * by eBGP.
- */
- PRIVATE,
- /**
- * For IP prefixes in blacklist.
- */
- BLACK_LIST
- }
-
- /**
- * Creates a new IP prefix entry.
- *
- * @param ipPrefix an IP prefix as a String
- * @param type an IP prefix type as an IpPrefixType
- * @param gatewayIpAddress IP of the gateway
- */
- public LocalIpPrefixEntry(@JsonProperty("ipPrefix") String ipPrefix,
- @JsonProperty("type") IpPrefixType type,
- @JsonProperty("gatewayIp") IpAddress
- gatewayIpAddress) {
- this.ipPrefix = IpPrefix.valueOf(ipPrefix);
- this.type = type;
- this.gatewayIpAddress = gatewayIpAddress;
- }
-
- /**
- * Gets the IP prefix of the IP prefix entry.
- *
- * @return the IP prefix
- */
- public IpPrefix ipPrefix() {
- return ipPrefix;
- }
-
- /**
- * Gets the IP prefix type of the IP prefix entry.
- *
- * @return the IP prefix type
- */
- public IpPrefixType ipPrefixType() {
- return type;
- }
-
- /**
- * Gets the gateway IP address of the IP prefix entry.
- *
- * @return the gateway IP address
- */
- public IpAddress getGatewayIpAddress() {
- return gatewayIpAddress;
- }
-
- /**
- * 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, type);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
-
- if (!(obj instanceof LocalIpPrefixEntry)) {
- return false;
- }
-
- LocalIpPrefixEntry that = (LocalIpPrefixEntry) obj;
- return Objects.equals(this.ipPrefix, that.ipPrefix)
- && Objects.equals(this.type, that.type);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("ipPrefix", ipPrefix)
- .add("ipPrefixType", type)
- .toString();
- }
-}
diff --git a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/RoutingConfigurationService.java b/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/RoutingConfigurationService.java
deleted file mode 100644
index f8ee21b9..00000000
--- a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/RoutingConfigurationService.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.routing.config;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.MacAddress;
-import org.onosproject.net.ConnectPoint;
-
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Provides information about the routing configuration.
- */
-public interface RoutingConfigurationService {
-
- /**
- * Gets the list of BGP speakers inside the SDN network.
- *
- * @return the map of BGP speaker names to BGP speaker objects
- */
- Map<String, BgpSpeaker> getBgpSpeakers();
-
- /**
- * Gets the list of configured BGP peers.
- *
- * @return the map from peer IP address to BgpPeer object
- */
- Map<IpAddress, BgpPeer> getBgpPeers();
-
- /**
- * Gets the MAC address configured for virtual gateway in SDN network.
- *
- * @return the MAC address of virtual gateway
- */
- MacAddress getVirtualGatewayMacAddress();
-
- /**
- * Evaluates whether an IP address is a virtual gateway IP address.
- *
- * @param ipAddress the IP address to evaluate
- * @return true if the IP address is a virtual gateway address, otherwise false
- */
- boolean isVirtualGatewayIpAddress(IpAddress ipAddress);
-
- /**
- * Evaluates whether an IP address belongs to local SDN network.
- *
- * @param ipAddress the IP address to evaluate
- * @return true if the IP address belongs to local SDN network, otherwise false
- */
- boolean isIpAddressLocal(IpAddress ipAddress);
-
- /**
- * Evaluates whether an IP prefix belongs to local SDN network.
- *
- * @param ipPrefix the IP prefix to evaluate
- * @return true if the IP prefix belongs to local SDN network, otherwise false
- */
- boolean isIpPrefixLocal(IpPrefix ipPrefix);
-
- /**
- * Retrieves the entire set of interfaces in the network.
- *
- * @return the set of interfaces
- * @deprecated in Drake release - use InterfaceService instead
- */
- @Deprecated
- Set<Interface> getInterfaces();
-
- /**
- * Retrieves the entire set of connect points connected to BGP peers in the
- * network.
- *
- * @return the set of connect points connected to BGP peers
- */
- Set<ConnectPoint> getBgpPeerConnectPoints();
-
- /**
- * Retrieves the interface associated with the given connect point.
- *
- * @param connectPoint the connect point to retrieve interface information
- * for
- * @return the interface
- * @deprecated in Drake release - use InterfaceService instead
- */
- @Deprecated
- Interface getInterface(ConnectPoint connectPoint);
-
- /**
- * Retrieves the interface associated with the given IP address.
- *
- * @param ip IP address of the interface
- * @return the interface
- * @deprecated in Drake release - use InterfaceService instead
- */
- @Deprecated
- Interface getInterface(IpAddress ip);
-
- /**
- * Retrieves the interface that matches the given IP address. Matching
- * means that the IP address is in one of the interface's assigned subnets.
- *
- * @param ipAddress IP address to match
- * @return the matching interface
- * @deprecated in Drake release - use InterfaceService instead
- */
- @Deprecated
- Interface getMatchingInterface(IpAddress ipAddress);
-
-}
diff --git a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/package-info.java b/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/package-info.java
deleted file mode 100644
index c54c19d7..00000000
--- a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Routing configuration interfaces.
- */
-package org.onosproject.routing.config;
diff --git a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/package-info.java b/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/package-info.java
deleted file mode 100644
index 66e590b1..00000000
--- a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * API for routing libraries.
- */
-package org.onosproject.routing;
diff --git a/framework/src/onos/apps/routing-api/src/test/java/org/onosproject/routing/RouteEntryTest.java b/framework/src/onos/apps/routing-api/src/test/java/org/onosproject/routing/RouteEntryTest.java
deleted file mode 100644
index 981d6a09..00000000
--- a/framework/src/onos/apps/routing-api/src/test/java/org/onosproject/routing/RouteEntryTest.java
+++ /dev/null
@@ -1,255 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.routing;
-
-import org.hamcrest.Matchers;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.Ip4Prefix;
-import org.onlab.packet.Ip6Address;
-import org.onlab.packet.Ip6Prefix;
-
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.not;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Unit tests for the RouteEntry class.
- */
-public class RouteEntryTest {
- /**
- * Tests valid class constructor.
- */
- @Test
- public void testConstructor() {
- Ip4Prefix prefix = Ip4Prefix.valueOf("1.2.3.0/24");
- Ip4Address nextHop = Ip4Address.valueOf("5.6.7.8");
- RouteEntry routeEntry = new RouteEntry(prefix, nextHop);
- assertThat(routeEntry.toString(),
- is("RouteEntry{prefix=1.2.3.0/24, nextHop=5.6.7.8}"));
-
- Ip6Prefix prefix6 = Ip6Prefix.valueOf("1000::/64");
- Ip6Address nextHop6 = Ip6Address.valueOf("2000::1");
- RouteEntry routeEntry6 = new RouteEntry(prefix6, nextHop6);
- assertThat(routeEntry6.toString(),
- is("RouteEntry{prefix=1000::/64, nextHop=2000::1}"));
- }
-
- /**
- * Tests invalid class constructor for null IPv4 prefix.
- */
- @Test(expected = NullPointerException.class)
- public void testInvalidConstructorNullIpv4Prefix() {
- Ip4Prefix prefix = null;
- Ip4Address nextHop = Ip4Address.valueOf("5.6.7.8");
-
- new RouteEntry(prefix, nextHop);
- }
-
- /**
- * Tests invalid class constructor for null IPv6 prefix.
- */
- @Test(expected = NullPointerException.class)
- public void testInvalidConstructorNullIpv6Prefix() {
- Ip6Prefix prefix = null;
- Ip6Address nextHop = Ip6Address.valueOf("2000::1");
-
- new RouteEntry(prefix, nextHop);
- }
-
- /**
- * Tests invalid class constructor for null IPv4 next-hop.
- */
- @Test(expected = NullPointerException.class)
- public void testInvalidConstructorNullIpv4NextHop() {
- Ip4Prefix prefix = Ip4Prefix.valueOf("1.2.3.0/24");
- Ip4Address nextHop = null;
-
- new RouteEntry(prefix, nextHop);
- }
-
- /**
- * Tests invalid class constructor for null IPv6 next-hop.
- */
- @Test(expected = NullPointerException.class)
- public void testInvalidConstructorNullIpv6NextHop() {
- Ip6Prefix prefix = Ip6Prefix.valueOf("1000::/64");
- Ip6Address nextHop = null;
-
- new RouteEntry(prefix, nextHop);
- }
-
- /**
- * Tests getting the fields of a route entry.
- */
- @Test
- public void testGetFields() {
- Ip4Prefix prefix = Ip4Prefix.valueOf("1.2.3.0/24");
- Ip4Address nextHop = Ip4Address.valueOf("5.6.7.8");
- RouteEntry routeEntry = new RouteEntry(prefix, nextHop);
- assertThat(routeEntry.prefix(), is(prefix));
- assertThat(routeEntry.nextHop(), is(nextHop));
-
- Ip6Prefix prefix6 = Ip6Prefix.valueOf("1000::/64");
- Ip6Address nextHop6 = Ip6Address.valueOf("2000::1");
- RouteEntry routeEntry6 = new RouteEntry(prefix6, nextHop6);
- assertThat(routeEntry6.prefix(), is(prefix6));
- assertThat(routeEntry6.nextHop(), is(nextHop6));
- }
-
- /**
- * Tests creating a binary string from IPv4 prefix.
- */
- @Test
- public void testCreateBinaryString() {
- Ip4Prefix prefix;
-
- prefix = Ip4Prefix.valueOf("0.0.0.0/0");
- assertThat(RouteEntry.createBinaryString(prefix), is("0"));
-
- prefix = Ip4Prefix.valueOf("192.168.166.0/22");
- assertThat(RouteEntry.createBinaryString(prefix),
- is("0" + "1100000010101000101001"));
-
- prefix = Ip4Prefix.valueOf("192.168.166.0/23");
- assertThat(RouteEntry.createBinaryString(prefix),
- is("0" + "11000000101010001010011"));
-
- prefix = Ip4Prefix.valueOf("192.168.166.0/24");
- assertThat(RouteEntry.createBinaryString(prefix),
- is("0" + "110000001010100010100110"));
-
- prefix = Ip4Prefix.valueOf("130.162.10.1/25");
- assertThat(RouteEntry.createBinaryString(prefix),
- is("0" + "1000001010100010000010100"));
-
- prefix = Ip4Prefix.valueOf("255.255.255.255/32");
- assertThat(RouteEntry.createBinaryString(prefix),
- is("0" + "11111111111111111111111111111111"));
-
- Ip6Prefix prefix6;
- Pattern pattern;
- Matcher matcher;
-
- prefix6 = Ip6Prefix.valueOf("::/0");
- assertThat(RouteEntry.createBinaryString(prefix6), is("0"));
-
- prefix6 = Ip6Prefix.valueOf("2000::1000/112");
- pattern = Pattern.compile("0" + "00100{108}");
- matcher = pattern.matcher(RouteEntry.createBinaryString(prefix6));
- assertTrue(matcher.matches());
-
- prefix6 = Ip6Prefix.valueOf("2000::1000/116");
- pattern = Pattern.compile("0" + "00100{108}0001");
- matcher = pattern.matcher(RouteEntry.createBinaryString(prefix6));
- assertTrue(matcher.matches());
-
- prefix6 = Ip6Prefix.valueOf("2000::2000/116");
- pattern = Pattern.compile("0" + "00100{108}0010");
- matcher = pattern.matcher(RouteEntry.createBinaryString(prefix6));
- assertTrue(matcher.matches());
-
- prefix6 = Ip6Prefix.valueOf("2000::1234/128");
- pattern = Pattern.compile("0" + "00100{108}0001001000110100");
- matcher = pattern.matcher(RouteEntry.createBinaryString(prefix6));
- assertTrue(matcher.matches());
- }
-
- /**
- * Tests equality of {@link RouteEntry}.
- */
- @Test
- public void testEquality() {
- Ip4Prefix prefix1 = Ip4Prefix.valueOf("1.2.3.0/24");
- Ip4Address nextHop1 = Ip4Address.valueOf("5.6.7.8");
- RouteEntry routeEntry1 = new RouteEntry(prefix1, nextHop1);
-
- Ip4Prefix prefix2 = Ip4Prefix.valueOf("1.2.3.0/24");
- Ip4Address nextHop2 = Ip4Address.valueOf("5.6.7.8");
- RouteEntry routeEntry2 = new RouteEntry(prefix2, nextHop2);
-
- assertThat(routeEntry1, is(routeEntry2));
-
- Ip6Prefix prefix3 = Ip6Prefix.valueOf("1000::/64");
- Ip6Address nextHop3 = Ip6Address.valueOf("2000::2");
- RouteEntry routeEntry3 = new RouteEntry(prefix3, nextHop3);
-
- Ip6Prefix prefix4 = Ip6Prefix.valueOf("1000::/64");
- Ip6Address nextHop4 = Ip6Address.valueOf("2000::2");
- RouteEntry routeEntry4 = new RouteEntry(prefix4, nextHop4);
-
- assertThat(routeEntry3, is(routeEntry4));
- }
-
- /**
- * Tests non-equality of {@link RouteEntry}.
- */
- @Test
- public void testNonEquality() {
- Ip4Prefix prefix1 = Ip4Prefix.valueOf("1.2.3.0/24");
- Ip4Address nextHop1 = Ip4Address.valueOf("5.6.7.8");
- RouteEntry routeEntry1 = new RouteEntry(prefix1, nextHop1);
-
- Ip4Prefix prefix2 = Ip4Prefix.valueOf("1.2.3.0/25"); // Different
- Ip4Address nextHop2 = Ip4Address.valueOf("5.6.7.8");
- RouteEntry routeEntry2 = new RouteEntry(prefix2, nextHop2);
-
- Ip4Prefix prefix3 = Ip4Prefix.valueOf("1.2.3.0/24");
- Ip4Address nextHop3 = Ip4Address.valueOf("5.6.7.9"); // Different
- RouteEntry routeEntry3 = new RouteEntry(prefix3, nextHop3);
-
- assertThat(routeEntry1, Matchers.is(not(routeEntry2)));
- assertThat(routeEntry1, Matchers.is(not(routeEntry3)));
-
- Ip6Prefix prefix4 = Ip6Prefix.valueOf("1000::/64");
- Ip6Address nextHop4 = Ip6Address.valueOf("2000::1");
- RouteEntry routeEntry4 = new RouteEntry(prefix4, nextHop4);
-
- Ip6Prefix prefix5 = Ip6Prefix.valueOf("1000::/65");
- Ip6Address nextHop5 = Ip6Address.valueOf("2000::1");
- RouteEntry routeEntry5 = new RouteEntry(prefix5, nextHop5);
-
- Ip6Prefix prefix6 = Ip6Prefix.valueOf("1000::/64");
- Ip6Address nextHop6 = Ip6Address.valueOf("2000::2");
- RouteEntry routeEntry6 = new RouteEntry(prefix6, nextHop6);
-
- assertThat(routeEntry4, Matchers.is(not(routeEntry5)));
- assertThat(routeEntry4, Matchers.is(not(routeEntry6)));
- }
-
- /**
- * Tests object string representation.
- */
- @Test
- public void testToString() {
- Ip4Prefix prefix = Ip4Prefix.valueOf("1.2.3.0/24");
- Ip4Address nextHop = Ip4Address.valueOf("5.6.7.8");
- RouteEntry routeEntry = new RouteEntry(prefix, nextHop);
-
- assertThat(routeEntry.toString(),
- is("RouteEntry{prefix=1.2.3.0/24, nextHop=5.6.7.8}"));
-
- Ip6Prefix prefix6 = Ip6Prefix.valueOf("1000::/64");
- Ip6Address nextHop6 = Ip6Address.valueOf("2000::1");
- RouteEntry routeEntry6 = new RouteEntry(prefix6, nextHop6);
-
- assertThat(routeEntry6.toString(),
- is("RouteEntry{prefix=1000::/64, nextHop=2000::1}"));
- }
-}
diff --git a/framework/src/onos/apps/routing-api/src/test/java/org/onosproject/routing/config/BgpConfigTest.java b/framework/src/onos/apps/routing-api/src/test/java/org/onosproject/routing/config/BgpConfigTest.java
deleted file mode 100644
index 28f52b79..00000000
--- a/framework/src/onos/apps/routing-api/src/test/java/org/onosproject/routing/config/BgpConfigTest.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.routing.config;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.IpAddress;
-import org.onosproject.TestApplicationId;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.config.Config;
-import org.onosproject.net.config.ConfigApplyDelegate;
-import org.onosproject.routing.RoutingService;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Optional;
-import java.util.Set;
-
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertNull;
-import static junit.framework.TestCase.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-public class BgpConfigTest {
-
- private static final ApplicationId APP_ID =
- new TestApplicationId(RoutingService.ROUTER_APP_ID);
-
- private static final IpAddress IP1 = IpAddress.valueOf("10.0.1.1");
- private static final IpAddress IP2 = IpAddress.valueOf("10.0.2.1");
- private static final IpAddress IP3 = IpAddress.valueOf("10.0.3.1");
- private static final IpAddress IP4 = IpAddress.valueOf("10.0.101.1");
- private static final IpAddress IP5 = IpAddress.valueOf("10.0.201.1");
- public static final IpAddress IP_NON_EXIST = IpAddress.valueOf("10.101.1.1");
-
- public static final ConnectPoint CONNECT_POINT1 = ConnectPoint.
- deviceConnectPoint("of:0000000000000001/1");
- public static final ConnectPoint CONNECT_POINT2 = ConnectPoint.
- deviceConnectPoint("of:00000000000000a3/1");
-
- private static final String JSON_TREE = "{\"" + BgpConfig.SPEAKERS +
- "\" : [{\"" + BgpConfig.NAME + "\" : \"bgp1\"," +
- "\"" + BgpConfig.CONNECT_POINT +
- "\" : \"of:0000000000000001/1\"," +
- "\"" + BgpConfig.PEERS + "\" : [" +
- "\"10.0.1.1\",\"10.0.2.1\",\"10.0.3.1\"]}]}";
- private static final String EMPTY_JSON_TREE = "{}";
-
- private final ObjectMapper mapper = new ObjectMapper();
- private final ConfigApplyDelegate delegate = new MockCfgDelegate();
- private final BgpConfig.BgpSpeakerConfig initialSpeaker = createInitialSpeaker();
-
- private Set<BgpConfig.BgpSpeakerConfig> speakers = new HashSet<>();
- private BgpConfig bgpConfig = new BgpConfig();
- private BgpConfig emptyBgpConfig = new BgpConfig();
-
- @Before
- public void setUp() throws Exception {
- JsonNode tree = new ObjectMapper().readTree(JSON_TREE);
- bgpConfig.init(APP_ID, "bgp-test", tree, mapper, delegate);
- JsonNode emptyTree = new ObjectMapper().readTree(EMPTY_JSON_TREE);
- emptyBgpConfig.init(APP_ID, "bgp-test", emptyTree, mapper, delegate);
- speakers.add(initialSpeaker);
- }
-
- /**
- * Tests if speakers can be retrieved from JSON.
- */
- @Test
- public void testBgpSpeakers() throws Exception {
- assertEquals(speakers, bgpConfig.bgpSpeakers());
- }
-
- /**
- * Tests if speakers can be retrieved from empty JSON.
- */
- @Test
- public void testEmptyBgpSpeakers() throws Exception {
- assertTrue(emptyBgpConfig.bgpSpeakers().isEmpty());
- }
-
- /**
- * Tests if speaker can be found by name.
- */
- @Test
- public void testGetSpeakerWithName() throws Exception {
- assertNotNull(bgpConfig.getSpeakerWithName("bgp1"));
- assertNull(bgpConfig.getSpeakerWithName("bgp2"));
- }
-
- /**
- * Tests addition of new speaker.
- */
- @Test
- public void testAddSpeaker() throws Exception {
- int initialSize = bgpConfig.bgpSpeakers().size();
- BgpConfig.BgpSpeakerConfig newSpeaker = createNewSpeaker();
- bgpConfig.addSpeaker(newSpeaker);
- assertEquals(initialSize + 1, bgpConfig.bgpSpeakers().size());
- speakers.add(newSpeaker);
- assertEquals(speakers, bgpConfig.bgpSpeakers());
- }
-
- /**
- * Tests addition of new speaker to empty configuration.
- */
- @Test
- public void testAddSpeakerToEmpty() throws Exception {
- BgpConfig.BgpSpeakerConfig newSpeaker = createNewSpeaker();
- emptyBgpConfig.addSpeaker(newSpeaker);
-
- assertFalse(emptyBgpConfig.bgpSpeakers().isEmpty());
- }
-
- /**
- * Tests removal of existing speaker.
- */
- @Test
- public void testRemoveExistingSpeaker() throws Exception {
- int initialSize = bgpConfig.bgpSpeakers().size();
- bgpConfig.removeSpeaker("bgp1");
-
- assertEquals(initialSize - 1, bgpConfig.bgpSpeakers().size());
- }
-
- /**
- * Tests removal of non-existing speaker.
- */
- @Test
- public void testRemoveInexistingSpeaker() throws Exception {
- int initialSize = bgpConfig.bgpSpeakers().size();
- bgpConfig.removeSpeaker("bgp2");
-
- assertEquals(initialSize, bgpConfig.bgpSpeakers().size());
- }
-
- /**
- * Tests addition of new speaker.
- */
- @Test
- public void testAddPeerToSpeaker() throws Exception {
- int initialSize = bgpConfig.getSpeakerWithName("bgp1").peers().size();
- bgpConfig.addPeerToSpeaker("bgp1", IP4);
-
- assertEquals(initialSize + 1, bgpConfig.getSpeakerWithName("bgp1").peers().size());
- }
-
- /**
- * Tests addition of new speaker when peer already exists.
- */
- @Test
- public void testAddExistingPeerToSpeaker() throws Exception {
- int initialSize = bgpConfig.getSpeakerWithName("bgp1").peers().size();
- bgpConfig.addPeerToSpeaker("bgp1", IP1);
-
- assertEquals(initialSize, bgpConfig.getSpeakerWithName("bgp1").peers().size());
- }
-
- /**
- * Tests retrieval of speaker based on peering address.
- */
- @Test
- public void testGetSpeakerFromPeer() throws Exception {
- assertNotNull(bgpConfig.getSpeakerFromPeer(IP1));
- assertNull(bgpConfig.getSpeakerFromPeer(IP_NON_EXIST));
- }
-
- /**
- * Tests removal of peer.
- */
- @Test
- public void testRemoveExistingPeerFromSpeaker() throws Exception {
- int initialSize = bgpConfig.getSpeakerWithName("bgp1").peers().size();
- bgpConfig.removePeerFromSpeaker(initialSpeaker, IP1);
-
- assertEquals(initialSize - 1, bgpConfig.getSpeakerWithName("bgp1").peers().size());
- }
-
- /**
- * Tests peer removal when peer does not exist.
- */
- @Test
- public void testRemoveNonExistingPeerFromSpeaker() throws Exception {
- int initialSize = bgpConfig.getSpeakerWithName("bgp1").peers().size();
- bgpConfig.removePeerFromSpeaker(initialSpeaker, IP_NON_EXIST);
-
- assertEquals(initialSize, bgpConfig.getSpeakerWithName("bgp1").peers().size());
- }
-
- /**
- * Tests if connections to peers are found.
- */
- @Test
- public void testIsConnectedToPeer() {
- BgpConfig.BgpSpeakerConfig speaker = createNewSpeaker();
-
- assertTrue(speaker.isConnectedToPeer(IP4));
- assertFalse(speaker.isConnectedToPeer(IP_NON_EXIST));
- }
-
- private class MockCfgDelegate implements ConfigApplyDelegate {
-
- @Override
- public void onApply(@SuppressWarnings("rawtypes") Config config) {
- config.apply();
- }
-
- }
-
- private BgpConfig.BgpSpeakerConfig createInitialSpeaker() {
- Optional<String> speakerName = Optional.of("bgp1");
- ConnectPoint connectPoint = CONNECT_POINT1;
- Set<IpAddress> connectedPeers = new HashSet<>(Arrays.asList(IP1, IP2, IP3));
-
- return new BgpConfig.BgpSpeakerConfig(speakerName, connectPoint, connectedPeers);
- }
-
- private BgpConfig.BgpSpeakerConfig createNewSpeaker() {
- Optional<String> speakerName = Optional.of("newSpeaker");
- ConnectPoint connectPoint = CONNECT_POINT2;
- Set<IpAddress> connectedPeers = new HashSet<>(
- Arrays.asList(IP4, IP5));
-
- return new BgpConfig.BgpSpeakerConfig(speakerName, connectPoint, connectedPeers);
- }
-}