Search in sources :

Example 1 with DefaultPacketRequest

use of org.onosproject.net.packet.DefaultPacketRequest in project onos by opennetworkinglab.

the class PacketRequestCodec method decode.

@Override
public PacketRequest decode(ObjectNode json, CodecContext context) {
    if (json == null || !json.isObject()) {
        return null;
    }
    final JsonCodec<TrafficSelector> trafficSelectorCodec = context.codec(TrafficSelector.class);
    TrafficSelector trafficSelector = trafficSelectorCodec.decode(get(json, TRAFFIC_SELECTOR), context);
    NodeId nodeId = NodeId.nodeId(extractMember(NODE_ID, json));
    PacketPriority priority = PacketPriority.valueOf(extractMember(PRIORITY, json));
    CoreService coreService = context.getService(CoreService.class);
    // TODO check appId (currently hardcoded - should it be read from json node?)
    ApplicationId appId = coreService.registerApplication(REST_APP_ID);
    DeviceId deviceId = null;
    JsonNode node = json.get(DEVICE_ID);
    if (node != null) {
        deviceId = DeviceId.deviceId(node.asText());
    }
    return new DefaultPacketRequest(trafficSelector, priority, appId, nodeId, Optional.ofNullable(deviceId));
}
Also used : PacketPriority(org.onosproject.net.packet.PacketPriority) DefaultPacketRequest(org.onosproject.net.packet.DefaultPacketRequest) DeviceId(org.onosproject.net.DeviceId) NodeId(org.onosproject.cluster.NodeId) TrafficSelector(org.onosproject.net.flow.TrafficSelector) CoreService(org.onosproject.core.CoreService) JsonNode(com.fasterxml.jackson.databind.JsonNode) ApplicationId(org.onosproject.core.ApplicationId)

Example 2 with DefaultPacketRequest

use of org.onosproject.net.packet.DefaultPacketRequest in project onos by opennetworkinglab.

the class PacketManager method cancelPackets.

@Override
public void cancelPackets(TrafficSelector selector, PacketPriority priority, ApplicationId appId) {
    checkPermission(PACKET_READ);
    checkNotNull(selector, ERROR_NULL_SELECTOR);
    checkNotNull(appId, ERROR_NULL_APP_ID);
    PacketRequest request = new DefaultPacketRequest(selector, priority, appId, localNodeId, Optional.empty());
    store.cancelPackets(request);
}
Also used : PacketRequest(org.onosproject.net.packet.PacketRequest) DefaultPacketRequest(org.onosproject.net.packet.DefaultPacketRequest) DefaultPacketRequest(org.onosproject.net.packet.DefaultPacketRequest)

Example 3 with DefaultPacketRequest

use of org.onosproject.net.packet.DefaultPacketRequest in project onos by opennetworkinglab.

the class PacketManager method cancelPackets.

@Override
public void cancelPackets(TrafficSelector selector, PacketPriority priority, ApplicationId appId, Optional<DeviceId> deviceId) {
    checkPermission(PACKET_READ);
    checkNotNull(selector, ERROR_NULL_SELECTOR);
    checkNotNull(appId, ERROR_NULL_APP_ID);
    checkNotNull(deviceId, ERROR_NULL_DEVICE_ID);
    PacketRequest request = new DefaultPacketRequest(selector, priority, appId, localNodeId, deviceId);
    store.cancelPackets(request);
}
Also used : PacketRequest(org.onosproject.net.packet.PacketRequest) DefaultPacketRequest(org.onosproject.net.packet.DefaultPacketRequest) DefaultPacketRequest(org.onosproject.net.packet.DefaultPacketRequest)

Example 4 with DefaultPacketRequest

use of org.onosproject.net.packet.DefaultPacketRequest in project onos by opennetworkinglab.

the class VirtualNetworkPacketManager method requestPackets.

@Override
public void requestPackets(TrafficSelector selector, PacketPriority priority, ApplicationId appId) {
    PacketRequest request = new DefaultPacketRequest(selector, priority, appId, localNodeId, Optional.empty());
    store.requestPackets(networkId(), request);
}
Also used : DefaultPacketRequest(org.onosproject.net.packet.DefaultPacketRequest) PacketRequest(org.onosproject.net.packet.PacketRequest) DefaultPacketRequest(org.onosproject.net.packet.DefaultPacketRequest)

Example 5 with DefaultPacketRequest

use of org.onosproject.net.packet.DefaultPacketRequest in project onos by opennetworkinglab.

the class VirtualNetworkPacketManager method cancelPackets.

@Override
public void cancelPackets(TrafficSelector selector, PacketPriority priority, ApplicationId appId) {
    PacketRequest request = new DefaultPacketRequest(selector, priority, appId, localNodeId, Optional.empty());
    store.cancelPackets(networkId(), request);
}
Also used : DefaultPacketRequest(org.onosproject.net.packet.DefaultPacketRequest) PacketRequest(org.onosproject.net.packet.PacketRequest) DefaultPacketRequest(org.onosproject.net.packet.DefaultPacketRequest)

Aggregations

DefaultPacketRequest (org.onosproject.net.packet.DefaultPacketRequest)9 PacketRequest (org.onosproject.net.packet.PacketRequest)8 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 NodeId (org.onosproject.cluster.NodeId)1 ApplicationId (org.onosproject.core.ApplicationId)1 CoreService (org.onosproject.core.CoreService)1 DeviceId (org.onosproject.net.DeviceId)1 TrafficSelector (org.onosproject.net.flow.TrafficSelector)1 PacketPriority (org.onosproject.net.packet.PacketPriority)1