Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 1 | /* |
Ray Milkey | 34c9590 | 2015-04-15 09:47:53 -0700 | [diff] [blame] | 2 | * Copyright 2014-2015 Open Networking Laboratory |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.packet; |
tom | 613d814 | 2014-09-11 15:09:37 -0700 | [diff] [blame] | 17 | |
Jonathan Hart | 3cfce8e | 2015-01-14 16:43:27 -0800 | [diff] [blame] | 18 | import org.onosproject.core.ApplicationId; |
Saurav Das | c313c40 | 2015-02-27 10:09:47 -0800 | [diff] [blame] | 19 | import org.onosproject.net.flow.FlowRule; |
Jonathan Hart | 3cfce8e | 2015-01-14 16:43:27 -0800 | [diff] [blame] | 20 | import org.onosproject.net.flow.TrafficSelector; |
| 21 | |
tom | 613d814 | 2014-09-11 15:09:37 -0700 | [diff] [blame] | 22 | /** |
| 23 | * Service for intercepting data plane packets and for emitting synthetic |
| 24 | * outbound packets. |
| 25 | */ |
| 26 | public interface PacketService { |
| 27 | |
| 28 | // TODO: ponder better ordering scheme that does not require absolute numbers |
| 29 | |
| 30 | /** |
| 31 | * Adds the specified processor to the list of packet processors. |
| 32 | * It will be added into the list in the order of priority. The higher |
| 33 | * numbers will be processing the packets after the lower numbers. |
| 34 | * |
| 35 | * @param processor processor to be added |
| 36 | * @param priority priority in the reverse natural order |
| 37 | * @throws java.lang.IllegalArgumentException if a processor with the |
| 38 | * given priority already exists |
| 39 | */ |
alshabib | 369d294 | 2014-09-12 17:59:35 -0700 | [diff] [blame] | 40 | void addProcessor(PacketProcessor processor, int priority); |
tom | 613d814 | 2014-09-11 15:09:37 -0700 | [diff] [blame] | 41 | |
Jonathan Hart | 3cfce8e | 2015-01-14 16:43:27 -0800 | [diff] [blame] | 42 | // TODO allow processors to register for particular types of packets |
| 43 | |
tom | 613d814 | 2014-09-11 15:09:37 -0700 | [diff] [blame] | 44 | /** |
| 45 | * Removes the specified processor from the processing pipeline. |
| 46 | * |
| 47 | * @param processor packet processor |
| 48 | */ |
| 49 | void removeProcessor(PacketProcessor processor); |
| 50 | |
| 51 | /** |
Jonathan Hart | 3cfce8e | 2015-01-14 16:43:27 -0800 | [diff] [blame] | 52 | * Requests that packets matching the given selector are punted from the |
| 53 | * dataplane to the controller. |
| 54 | * |
| 55 | * @param selector the traffic selector used to match packets |
| 56 | * @param priority the priority of the rule |
| 57 | * @param appId the application ID of the requester |
| 58 | */ |
| 59 | void requestPackets(TrafficSelector selector, PacketPriority priority, |
| 60 | ApplicationId appId); |
| 61 | |
Saurav Das | c313c40 | 2015-02-27 10:09:47 -0800 | [diff] [blame] | 62 | /** |
| 63 | * Requests that packets matching the given selector are punted from the |
| 64 | * dataplane to the controller. Clients of the PacketService should use |
| 65 | * this call to hint at the tableType in the dataplane valid for the selector. |
| 66 | * |
| 67 | * @param selector the traffic selector used to match packets |
| 68 | * @param priority the priority of the rule |
| 69 | * @param appId the application ID of the requester |
| 70 | * @param tableType the abstract table Type in the dataplane where flowrules |
| 71 | * should be inserted to punt the selector packets to the |
| 72 | * control plane |
| 73 | */ |
| 74 | void requestPackets(TrafficSelector selector, PacketPriority priority, |
| 75 | ApplicationId appId, FlowRule.Type tableType); |
| 76 | |
| 77 | |
Jonathan Hart | 3cfce8e | 2015-01-14 16:43:27 -0800 | [diff] [blame] | 78 | // TODO add API to allow applications to revoke requests when they deactivate |
| 79 | |
| 80 | /** |
tom | 613d814 | 2014-09-11 15:09:37 -0700 | [diff] [blame] | 81 | * Emits the specified outbound packet onto the network. |
| 82 | * |
| 83 | * @param packet outbound packet |
| 84 | */ |
| 85 | void emit(OutboundPacket packet); |
| 86 | |
| 87 | } |