Search in sources :

Example 96 with IpAddress

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;
}
Also used : PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) ArrayList(java.util.ArrayList) IpAddress(org.onlab.packet.IpAddress)

Example 97 with IpAddress

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;
}
Also used : IpAddress(org.onlab.packet.IpAddress) McastRoute(org.onosproject.mcast.api.McastRoute)

Example 98 with IpAddress

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;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) MulticastRouteService(org.onosproject.mcast.api.MulticastRouteService) IpAddress(org.onlab.packet.IpAddress) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Example 99 with IpAddress

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);
}
Also used : IpAddress(org.onlab.packet.IpAddress)

Example 100 with IpAddress

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());
    }
}
Also used : MulticastRouteService(org.onosproject.mcast.api.MulticastRouteService) IpAddress(org.onlab.packet.IpAddress) McastRoute(org.onosproject.mcast.api.McastRoute)

Aggregations

IpAddress (org.onlab.packet.IpAddress)288 MacAddress (org.onlab.packet.MacAddress)63 VlanId (org.onlab.packet.VlanId)52 ConnectPoint (org.onosproject.net.ConnectPoint)48 Set (java.util.Set)46 DeviceId (org.onosproject.net.DeviceId)44 Logger (org.slf4j.Logger)40 Test (org.junit.Test)37 Collectors (java.util.stream.Collectors)36 Ethernet (org.onlab.packet.Ethernet)36 IpPrefix (org.onlab.packet.IpPrefix)36 HostId (org.onosproject.net.HostId)33 Host (org.onosproject.net.Host)32 Optional (java.util.Optional)30 HostLocation (org.onosproject.net.HostLocation)30 LoggerFactory (org.slf4j.LoggerFactory)30 ApplicationId (org.onosproject.core.ApplicationId)29 CoreService (org.onosproject.core.CoreService)29 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)29 JsonNode (com.fasterxml.jackson.databind.JsonNode)28