Remove deprecated routing classes in preparation for refactoring
Change-Id: Ia2a16432be93197907113ab2962804485fad5fdb
diff --git a/apps/routing-api/src/main/java/org/onosproject/routing/FibEntry.java b/apps/routing-api/src/main/java/org/onosproject/routing/FibEntry.java
deleted file mode 100644
index 3c5d550..0000000
--- a/apps/routing-api/src/main/java/org/onosproject/routing/FibEntry.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.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).
- *
- * @deprecated use RouteService instead
- */
-@Deprecated
-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/apps/routing-api/src/main/java/org/onosproject/routing/FibListener.java b/apps/routing-api/src/main/java/org/onosproject/routing/FibListener.java
deleted file mode 100644
index 868fd02..0000000
--- a/apps/routing-api/src/main/java/org/onosproject/routing/FibListener.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.routing;
-
-import java.util.Collection;
-
-/**
- * A component that is able to process Forwarding Information Base (FIB) updates.
- *
- * @deprecated use RouteService instead
- */
-@Deprecated
-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/apps/routing-api/src/main/java/org/onosproject/routing/FibUpdate.java b/apps/routing-api/src/main/java/org/onosproject/routing/FibUpdate.java
deleted file mode 100644
index d8acae7..0000000
--- a/apps/routing-api/src/main/java/org/onosproject/routing/FibUpdate.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.routing;
-
-import com.google.common.base.MoreObjects;
-
-import java.util.Objects;
-
-/**
- * Represents a change to the Forwarding Information Base (FIB).
- *
- * @deprecated use RouteService instead
- */
-@Deprecated
-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/apps/routing-api/src/main/java/org/onosproject/routing/RouteListener.java b/apps/routing-api/src/main/java/org/onosproject/routing/RouteListener.java
deleted file mode 100644
index 5183712..0000000
--- a/apps/routing-api/src/main/java/org/onosproject/routing/RouteListener.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.routing;
-
-import java.util.Collection;
-
-/**
- * An interface to receive route updates from route providers.
- *
- * @deprecated in Goldeneye. Use RouteService instead.
- */
-@Deprecated
-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/apps/routing-api/src/main/java/org/onosproject/routing/RouteSourceService.java b/apps/routing-api/src/main/java/org/onosproject/routing/RouteSourceService.java
deleted file mode 100644
index 262698b..0000000
--- a/apps/routing-api/src/main/java/org/onosproject/routing/RouteSourceService.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.routing;
-
-/**
- * A source of route updates.
- *
- * @deprecated in Goldeneye. Use RouteService instead.
- */
-@Deprecated
-public interface RouteSourceService {
-
- /**
- * Starts the route source.
- *
- * @param routeListener listener to send route updates to
- */
- void start(RouteListener routeListener);
-
- /**
- * Stops the route source.
- */
- void stop();
-}
diff --git a/apps/routing-api/src/main/java/org/onosproject/routing/RoutingService.java b/apps/routing-api/src/main/java/org/onosproject/routing/RoutingService.java
index f04c798..e555209 100644
--- a/apps/routing-api/src/main/java/org/onosproject/routing/RoutingService.java
+++ b/apps/routing-api/src/main/java/org/onosproject/routing/RoutingService.java
@@ -15,18 +15,13 @@
*/
package org.onosproject.routing;
-import org.onlab.packet.IpAddress;
import org.onosproject.routing.config.BgpConfig;
import org.onosproject.routing.config.RouterConfig;
-import java.util.Collection;
-
/**
- * Provides a way of interacting with the RIB management component.
- *
- * @deprecated in Goldeneye. Use RouteService instead.
+ * Historical interface now used only as a centralised place to define routing
+ * config related constants.
*/
-@Deprecated
public interface RoutingService {
String ROUTER_APP_ID = "org.onosproject.router";
@@ -35,43 +30,8 @@
Class<RouterConfig> ROUTER_CONFIG_CLASS = RouterConfig.class;
/**
- * Starts the routing service.
+ * Empty method to pacify checkstyle.
*/
- 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 from the RIB.
- *
- * @return the IPv4 routes
- */
- Collection<RouteEntry> getRoutes4();
-
- /**
- * Gets all IPv6 routes from the RIB.
- *
- * @return the 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);
-
+ default void nothing() {
+ }
}
diff --git a/apps/routing-api/src/test/java/org/onosproject/routing/RoutingServiceAdapter.java b/apps/routing-api/src/test/java/org/onosproject/routing/RoutingServiceAdapter.java
deleted file mode 100644
index 149db8a..0000000
--- a/apps/routing-api/src/test/java/org/onosproject/routing/RoutingServiceAdapter.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.routing;
-
-import org.onlab.packet.IpAddress;
-
-import java.util.Collection;
-
-/**
- * Routing service adapter.
- */
-public class RoutingServiceAdapter implements RoutingService {
-
- @Override
- public void start() {
-
- }
-
- @Override
- public void addFibListener(FibListener fibListener) {
-
- }
-
- @Override
- public void stop() {
-
- }
-
- @Override
- public Collection<RouteEntry> getRoutes4() {
- return null;
- }
-
- @Override
- public Collection<RouteEntry> getRoutes6() {
- return null;
- }
-
- @Override
- public RouteEntry getLongestMatchableRouteEntry(IpAddress ipAddress) {
- return null;
- }
-}
diff --git a/apps/routing/src/main/java/org/onosproject/routing/bgp/BgpRouteEntry.java b/apps/routing/src/main/java/org/onosproject/routing/bgp/BgpRouteEntry.java
index 40b68d0..adf00904 100644
--- a/apps/routing/src/main/java/org/onosproject/routing/bgp/BgpRouteEntry.java
+++ b/apps/routing/src/main/java/org/onosproject/routing/bgp/BgpRouteEntry.java
@@ -19,7 +19,6 @@
import org.onlab.packet.Ip4Address;
import org.onlab.packet.IpAddress;
import org.onlab.packet.IpPrefix;
-import org.onosproject.routing.RouteEntry;
import java.util.ArrayList;
import java.util.Objects;
diff --git a/apps/routing/src/main/java/org/onosproject/routing/bgp/BgpRouteSelector.java b/apps/routing/src/main/java/org/onosproject/routing/bgp/BgpRouteSelector.java
index 92c4e7d..36b4b6e 100644
--- a/apps/routing/src/main/java/org/onosproject/routing/bgp/BgpRouteSelector.java
+++ b/apps/routing/src/main/java/org/onosproject/routing/bgp/BgpRouteSelector.java
@@ -17,7 +17,6 @@
import org.onlab.packet.IpPrefix;
import org.onosproject.incubator.net.routing.Route;
-import org.onosproject.routing.RouteUpdate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/apps/routing-api/src/main/java/org/onosproject/routing/RouteEntry.java b/apps/routing/src/main/java/org/onosproject/routing/bgp/RouteEntry.java
similarity index 71%
rename from apps/routing-api/src/main/java/org/onosproject/routing/RouteEntry.java
rename to apps/routing/src/main/java/org/onosproject/routing/bgp/RouteEntry.java
index 2baf686..8053ecd 100644
--- a/apps/routing-api/src/main/java/org/onosproject/routing/RouteEntry.java
+++ b/apps/routing/src/main/java/org/onosproject/routing/bgp/RouteEntry.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015-present Open Networking Laboratory
+ * Copyright 2017-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.routing;
+package org.onosproject.routing.bgp;
import com.google.common.base.MoreObjects;
import org.onlab.packet.IpAddress;
@@ -25,10 +25,7 @@
/**
* Represents a route entry for an IP prefix.
- *
- * @deprecated use RouteService instead
*/
-@Deprecated
public class RouteEntry {
private final IpPrefix prefix; // The IP prefix
private final IpAddress nextHop; // Next-hop IP address
@@ -89,36 +86,6 @@
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) {
diff --git a/apps/routing-api/src/main/java/org/onosproject/routing/RouteUpdate.java b/apps/routing/src/main/java/org/onosproject/routing/bgp/RouteUpdate.java
similarity index 94%
rename from apps/routing-api/src/main/java/org/onosproject/routing/RouteUpdate.java
rename to apps/routing/src/main/java/org/onosproject/routing/bgp/RouteUpdate.java
index 9f95f3b..332933d 100644
--- a/apps/routing-api/src/main/java/org/onosproject/routing/RouteUpdate.java
+++ b/apps/routing/src/main/java/org/onosproject/routing/bgp/RouteUpdate.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015-present Open Networking Laboratory
+ * Copyright 2017-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.routing;
+package org.onosproject.routing.bgp;
import com.google.common.base.MoreObjects;
@@ -23,10 +23,7 @@
/**
* Represents a change in routing information.
- *
- * @deprecated use RouteService instead
*/
-@Deprecated
public class RouteUpdate {
private final Type type; // The route update type
private final RouteEntry routeEntry; // The updated route entry
diff --git a/apps/routing/src/main/java/org/onosproject/routing/config/impl/RoutingConfigurationImpl.java b/apps/routing/src/main/java/org/onosproject/routing/config/impl/RoutingConfigurationImpl.java
index f3533a5..5fbfe7f 100644
--- a/apps/routing/src/main/java/org/onosproject/routing/config/impl/RoutingConfigurationImpl.java
+++ b/apps/routing/src/main/java/org/onosproject/routing/config/impl/RoutingConfigurationImpl.java
@@ -54,8 +54,6 @@
import java.util.Set;
import java.util.stream.Collectors;
-import static org.onosproject.routing.RouteEntry.createBinaryString;
-
/**
* Implementation of RoutingConfigurationService which reads routing
* configuration from the network configuration service.
@@ -219,6 +217,41 @@
return virtualGatewayMacAddress;
}
+ @Override
+ public Set<ConnectPoint> getBgpPeerConnectPoints() {
+ return ImmutableSet.copyOf(bgpPeerConnectPoints);
+ }
+
+ /**
+ * 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
+ */
+ private 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();
+ }
+
private class InternalNetworkConfigListener implements NetworkConfigListener {
@Override
@@ -240,10 +273,4 @@
}
}
}
-
- @Override
- public Set<ConnectPoint> getBgpPeerConnectPoints() {
- return ImmutableSet.copyOf(bgpPeerConnectPoints);
- }
-
}
diff --git a/apps/routing/src/main/java/org/onosproject/routing/impl/Router.java b/apps/routing/src/main/java/org/onosproject/routing/impl/Router.java
deleted file mode 100644
index 55d65b6..0000000
--- a/apps/routing/src/main/java/org/onosproject/routing/impl/Router.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.routing.impl;
-
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.apache.felix.scr.annotations.Service;
-import org.onlab.packet.IpAddress;
-import org.onosproject.incubator.net.routing.ResolvedRoute;
-import org.onosproject.incubator.net.routing.Route;
-import org.onosproject.incubator.net.routing.RouteEvent;
-import org.onosproject.incubator.net.routing.RouteListener;
-import org.onosproject.incubator.net.routing.RouteService;
-import org.onosproject.incubator.net.routing.RouteTableId;
-import org.onosproject.routing.FibEntry;
-import org.onosproject.routing.FibListener;
-import org.onosproject.routing.FibUpdate;
-import org.onosproject.routing.RouteEntry;
-import org.onosproject.routing.RoutingService;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.stream.Collectors;
-
-/**
- * Adapts new route service interface to old RoutingService interface.
- */
-@Service
-@Component(immediate = true, enabled = false)
-public class Router implements RoutingService {
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected RouteService routeService;
-
- @Override
- public void start() {
- }
-
- @Override
- public void addFibListener(FibListener fibListener) {
- routeService.addListener(new InternalRouteListener(fibListener));
- }
-
- @Override
- public void stop() {
- }
-
- @Override
- public Collection<RouteEntry> getRoutes4() {
- return routeService.getAllRoutes().get(new RouteTableId("ipv4")).stream()
- .map(route -> new RouteEntry(route.prefix(), route.nextHop()))
- .collect(Collectors.toList());
- }
-
- @Override
- public Collection<RouteEntry> getRoutes6() {
- return routeService.getAllRoutes().get(new RouteTableId("ipv6")).stream()
- .map(route -> new RouteEntry(route.prefix(), route.nextHop()))
- .collect(Collectors.toList());
- }
-
- @Override
- public RouteEntry getLongestMatchableRouteEntry(IpAddress ipAddress) {
- Route route = routeService.longestPrefixMatch(ipAddress);
- if (route != null) {
- return new RouteEntry(route.prefix(), route.nextHop());
- }
- return null;
- }
-
- /**
- * Internal route listener.
- */
- private class InternalRouteListener implements RouteListener {
-
- private final FibListener fibListener;
-
- /**
- * Constructor.
- *
- * @param fibListener FIB listener
- */
- public InternalRouteListener(FibListener fibListener) {
- this.fibListener = fibListener;
- }
-
- @Override
- public void event(RouteEvent event) {
- ResolvedRoute route = event.subject();
- FibEntry entry = new FibEntry(route.prefix(), route.nextHop(), route.nextHopMac());
-
- switch (event.type()) {
- case ROUTE_ADDED:
- case ROUTE_UPDATED:
- fibListener.update(Collections.singleton(new FibUpdate(FibUpdate.Type.UPDATE, entry)),
- Collections.emptyList());
- break;
- case ROUTE_REMOVED:
- fibListener.update(Collections.emptyList(),
- Collections.singleton(new FibUpdate(FibUpdate.Type.DELETE, entry)));
- break;
- default:
- break;
- }
- }
- }
-}
diff --git a/apps/routing-api/src/test/java/org/onosproject/routing/RouteEntryTest.java b/apps/routing/src/test/java/org/onosproject/routing/bgp/RouteEntryTest.java
similarity index 63%
rename from apps/routing-api/src/test/java/org/onosproject/routing/RouteEntryTest.java
rename to apps/routing/src/test/java/org/onosproject/routing/bgp/RouteEntryTest.java
index c7bbe94..95982a8 100644
--- a/apps/routing-api/src/test/java/org/onosproject/routing/RouteEntryTest.java
+++ b/apps/routing/src/test/java/org/onosproject/routing/bgp/RouteEntryTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015-present Open Networking Laboratory
+ * Copyright 2017-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onosproject.routing;
+package org.onosproject.routing.bgp;
import org.hamcrest.Matchers;
import org.junit.Test;
@@ -23,33 +23,12 @@
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.
@@ -114,64 +93,6 @@
}
/**
- * 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
@@ -214,8 +135,8 @@
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)));
+ assertThat(routeEntry1, Matchers.is(Matchers.not(routeEntry2)));
+ assertThat(routeEntry1, Matchers.is(Matchers.not(routeEntry3)));
Ip6Prefix prefix4 = Ip6Prefix.valueOf("1000::/64");
Ip6Address nextHop4 = Ip6Address.valueOf("2000::1");
@@ -229,8 +150,8 @@
Ip6Address nextHop6 = Ip6Address.valueOf("2000::2");
RouteEntry routeEntry6 = new RouteEntry(prefix6, nextHop6);
- assertThat(routeEntry4, Matchers.is(not(routeEntry5)));
- assertThat(routeEntry4, Matchers.is(not(routeEntry6)));
+ assertThat(routeEntry4, Matchers.is(Matchers.not(routeEntry5)));
+ assertThat(routeEntry4, Matchers.is(Matchers.not(routeEntry6)));
}
/**