mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-16 18:02:05 +02:00
Carry more information in NextHop
Also update the next-hop CLI to show more information Change-Id: Ia0f2c7b4a40b75513a4ecb4cc022e580e590d9f3
This commit is contained in:
parent
24f6cc01b1
commit
c78a0987ef
@ -40,7 +40,7 @@ public class NextHopsListCommand extends AbstractShellCommand {
|
|||||||
private static final String FORMAT_TABLE = "Table: %s";
|
private static final String FORMAT_TABLE = "Table: %s";
|
||||||
private static final String FORMAT_TOTAL = " Total: %d";
|
private static final String FORMAT_TOTAL = " Total: %d";
|
||||||
|
|
||||||
private static final String FORMAT = "ip=%s, mac=%s, numRoutes=%s";
|
private static final String FORMAT = "ip=%s, mac=%s, loc=%s, numRoutes=%s";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void execute() {
|
protected void execute() {
|
||||||
@ -50,9 +50,8 @@ public class NextHopsListCommand extends AbstractShellCommand {
|
|||||||
|
|
||||||
nextHops.forEach(nextHop -> {
|
nextHops.forEach(nextHop -> {
|
||||||
Collection<Route> routes = service.getRoutesForNextHop(nextHop.ip());
|
Collection<Route> routes = service.getRoutesForNextHop(nextHop.ip());
|
||||||
print(FORMAT, nextHop.ip(), nextHop.mac(), routes.size());
|
print(FORMAT, nextHop.ip(), nextHop.mac(), nextHop.location(), routes.size());
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ package org.onosproject.incubator.net.routing;
|
|||||||
|
|
||||||
import org.onlab.packet.IpAddress;
|
import org.onlab.packet.IpAddress;
|
||||||
import org.onlab.packet.MacAddress;
|
import org.onlab.packet.MacAddress;
|
||||||
|
import org.onosproject.net.ConnectPoint;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@ -29,17 +30,17 @@ import static com.google.common.base.MoreObjects.toStringHelper;
|
|||||||
public class NextHop {
|
public class NextHop {
|
||||||
|
|
||||||
private final IpAddress ip;
|
private final IpAddress ip;
|
||||||
private final MacAddress mac;
|
private final NextHopData nextHopData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new next hop.
|
* Creates a new next hop.
|
||||||
*
|
*
|
||||||
* @param ip IP address
|
* @param ip IP address
|
||||||
* @param mac MAC address
|
* @param nextHopData Next hop data
|
||||||
*/
|
*/
|
||||||
public NextHop(IpAddress ip, MacAddress mac) {
|
public NextHop(IpAddress ip, NextHopData nextHopData) {
|
||||||
this.ip = ip;
|
this.ip = ip;
|
||||||
this.mac = mac;
|
this.nextHopData = nextHopData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -57,12 +58,21 @@ public class NextHop {
|
|||||||
* @return MAC address
|
* @return MAC address
|
||||||
*/
|
*/
|
||||||
public MacAddress mac() {
|
public MacAddress mac() {
|
||||||
return mac;
|
return nextHopData.mac();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the location of the next hop.
|
||||||
|
*
|
||||||
|
* @return Connect point
|
||||||
|
*/
|
||||||
|
public ConnectPoint location() {
|
||||||
|
return nextHopData.location();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(ip, mac);
|
return Objects.hash(ip, nextHopData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -78,14 +88,14 @@ public class NextHop {
|
|||||||
NextHop that = (NextHop) other;
|
NextHop that = (NextHop) other;
|
||||||
|
|
||||||
return Objects.equals(this.ip, that.ip) &&
|
return Objects.equals(this.ip, that.ip) &&
|
||||||
Objects.equals(this.mac, that.mac);
|
Objects.equals(this.nextHopData, that.nextHopData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return toStringHelper(this)
|
return toStringHelper(this)
|
||||||
.add("ip", ip)
|
.add("ip", ip)
|
||||||
.add("mac", mac)
|
.add("nextHopData", nextHopData)
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -177,7 +177,7 @@ public class RouteManager implements ListenerService<RouteEvent, RouteListener>,
|
|||||||
@Override
|
@Override
|
||||||
public Set<NextHop> getNextHops() {
|
public Set<NextHop> getNextHops() {
|
||||||
return routeStore.getNextHops().entrySet().stream()
|
return routeStore.getNextHops().entrySet().stream()
|
||||||
.map(entry -> new NextHop(entry.getKey(), entry.getValue().mac()))
|
.map(entry -> new NextHop(entry.getKey(), entry.getValue()))
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user