use of org.onlab.packet.IpAddress in project onos by opennetworkinglab.
the class ConnectivityManager method buildSpeakerIntents.
private Collection<PointToPointIntent> buildSpeakerIntents(Peer speaker, Peer peer) {
List<PointToPointIntent> intents = new ArrayList<>();
IpAddress peerAddress = IpAddress.valueOf(peer.getIpAddress());
IpAddress speakerAddress = IpAddress.valueOf(speaker.getIpAddress());
checkNotNull(peerAddress);
intents.addAll(buildIntents(ConnectPoint.deviceConnectPoint(speaker.getPort()), speakerAddress, ConnectPoint.deviceConnectPoint(peer.getPort()), peerAddress));
return intents;
}
use of org.onlab.packet.IpAddress in project onos by opennetworkinglab.
the class McastHostRouteCodec method decode.
@Override
public McastRoute decode(ObjectNode json, CodecContext context) {
if (json == null || !json.isObject()) {
return null;
}
String source = json.path(SOURCE).asText();
IpAddress sourceIp = null;
if (!source.equals("*")) {
sourceIp = IpAddress.valueOf(source);
}
IpAddress group = IpAddress.valueOf(json.path(GROUP).asText());
McastRoute route = new McastRoute(sourceIp, group, McastRoute.Type.STATIC);
return route;
}
use of org.onlab.packet.IpAddress in project onos by opennetworkinglab.
the class McastHostRouteCodec method encode.
@Override
public ObjectNode encode(McastRoute route, CodecContext context) {
checkNotNull(route);
ObjectNode root = context.mapper().createObjectNode().put(TYPE, route.type().toString()).put(GROUP, route.group().toString());
Optional<IpAddress> sourceIp = route.source();
if (sourceIp.isPresent()) {
root.put(SOURCE, sourceIp.get().toString());
} else {
root.put(SOURCE, "*");
}
ObjectNode sources = context.mapper().createObjectNode();
context.getService(MulticastRouteService.class).routeData(route).sources().forEach((k, v) -> {
ArrayNode node = context.mapper().createArrayNode();
v.forEach(source -> {
node.add(source.toString());
});
sources.putPOJO(k.toString(), node);
});
root.putPOJO(SOURCES, sources);
ObjectNode sinks = context.mapper().createObjectNode();
context.getService(MulticastRouteService.class).routeData(route).sinks().forEach((k, v) -> {
ArrayNode node = context.mapper().createArrayNode();
v.forEach(sink -> {
node.add(sink.toString());
});
sinks.putPOJO(k.toString(), node);
});
root.putPOJO(SINKS, sinks);
return root;
}
use of org.onlab.packet.IpAddress in project onos by opennetworkinglab.
the class McastForwarding method createStaticRoute.
public static McastRoute createStaticRoute(String source, String group) {
checkNotNull(source, "Must provide a source");
checkNotNull(group, "Must provide a group");
IpAddress ipSource = IpAddress.valueOf(source);
IpAddress ipGroup = IpAddress.valueOf(group);
return createStaticcreateRoute(ipSource, ipGroup);
}
use of org.onlab.packet.IpAddress in project onos by opennetworkinglab.
the class McastShowHostCommand method doExecute.
@Override
protected void doExecute() {
// Get the service
MulticastRouteService mcastService = get(MulticastRouteService.class);
// Get the routes
Set<McastRoute> routes = mcastService.getRoutes();
// Verify mcast group
if (!isNullOrEmpty(gAddr)) {
// Let's find the group
IpAddress mcastGroup = IpAddress.valueOf(gAddr);
McastRoute mcastRoute = routes.stream().filter(route -> route.group().equals(mcastGroup)).findAny().orElse(null);
// If it exists
if (mcastRoute != null) {
prepareResult(mcastService, mcastRoute);
}
} else {
routes.stream().filter(mcastRoute -> mcastRoute.group().isIp4()).sorted(Comparator.comparing(McastRoute::group)).forEach(route -> {
prepareResult(mcastService, route);
});
routes.stream().filter(mcastRoute -> mcastRoute.group().isIp6()).sorted(Comparator.comparing(McastRoute::group)).forEach(route -> {
prepareResult(mcastService, route);
});
}
if (outputJson()) {
print("%s", routesNode);
} else {
print("%s", routesBuilder.toString());
}
}
Aggregations