Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2014-present 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; |
alshabib | 19e2cea | 2015-12-07 11:31:49 -0800 | [diff] [blame] | 19 | import org.onosproject.net.DeviceId; |
Jonathan Hart | 3cfce8e | 2015-01-14 16:43:27 -0800 | [diff] [blame] | 20 | import org.onosproject.net.flow.TrafficSelector; |
| 21 | |
Thomas Vachuska | 7f171b2 | 2015-08-21 12:49:08 -0700 | [diff] [blame] | 22 | import java.util.List; |
alshabib | 19e2cea | 2015-12-07 11:31:49 -0800 | [diff] [blame] | 23 | import java.util.Optional; |
Thomas Vachuska | 7f171b2 | 2015-08-21 12:49:08 -0700 | [diff] [blame] | 24 | |
tom | 613d814 | 2014-09-11 15:09:37 -0700 | [diff] [blame] | 25 | /** |
| 26 | * Service for intercepting data plane packets and for emitting synthetic |
| 27 | * outbound packets. |
| 28 | */ |
| 29 | public interface PacketService { |
| 30 | |
| 31 | // TODO: ponder better ordering scheme that does not require absolute numbers |
| 32 | |
| 33 | /** |
| 34 | * Adds the specified processor to the list of packet processors. |
| 35 | * It will be added into the list in the order of priority. The higher |
| 36 | * numbers will be processing the packets after the lower numbers. |
| 37 | * |
| 38 | * @param processor processor to be added |
| 39 | * @param priority priority in the reverse natural order |
| 40 | * @throws java.lang.IllegalArgumentException if a processor with the |
| 41 | * given priority already exists |
| 42 | */ |
alshabib | 369d294 | 2014-09-12 17:59:35 -0700 | [diff] [blame] | 43 | void addProcessor(PacketProcessor processor, int priority); |
tom | 613d814 | 2014-09-11 15:09:37 -0700 | [diff] [blame] | 44 | |
Jonathan Hart | 3cfce8e | 2015-01-14 16:43:27 -0800 | [diff] [blame] | 45 | // TODO allow processors to register for particular types of packets |
| 46 | |
tom | 613d814 | 2014-09-11 15:09:37 -0700 | [diff] [blame] | 47 | /** |
| 48 | * Removes the specified processor from the processing pipeline. |
| 49 | * |
| 50 | * @param processor packet processor |
| 51 | */ |
| 52 | void removeProcessor(PacketProcessor processor); |
| 53 | |
| 54 | /** |
Thomas Vachuska | 924cda4 | 2015-09-22 12:11:27 -0700 | [diff] [blame] | 55 | * Returns priority bindings of all registered packet processor entries. |
Thomas Vachuska | 7f171b2 | 2015-08-21 12:49:08 -0700 | [diff] [blame] | 56 | * |
Thomas Vachuska | 924cda4 | 2015-09-22 12:11:27 -0700 | [diff] [blame] | 57 | * @return list of existing packet processor entries |
Thomas Vachuska | 7f171b2 | 2015-08-21 12:49:08 -0700 | [diff] [blame] | 58 | */ |
Thomas Vachuska | 924cda4 | 2015-09-22 12:11:27 -0700 | [diff] [blame] | 59 | List<PacketProcessorEntry> getProcessors(); |
Thomas Vachuska | 7f171b2 | 2015-08-21 12:49:08 -0700 | [diff] [blame] | 60 | |
| 61 | /** |
Jonathan Hart | 3cfce8e | 2015-01-14 16:43:27 -0800 | [diff] [blame] | 62 | * Requests that packets matching the given selector are punted from the |
| 63 | * dataplane to the controller. |
| 64 | * |
| 65 | * @param selector the traffic selector used to match packets |
| 66 | * @param priority the priority of the rule |
Thomas Vachuska | 27bee09 | 2015-06-23 19:03:10 -0700 | [diff] [blame] | 67 | * @param appId the application ID of the requester |
Jonathan Hart | 3cfce8e | 2015-01-14 16:43:27 -0800 | [diff] [blame] | 68 | */ |
| 69 | void requestPackets(TrafficSelector selector, PacketPriority priority, |
| 70 | ApplicationId appId); |
| 71 | |
Charles Chan | 874900e | 2016-12-09 16:55:39 -0800 | [diff] [blame^] | 72 | /** |
| 73 | * Requests that packets matching the given selector are punted from the |
| 74 | * dataplane to the controller. |
| 75 | * |
| 76 | * @param selector the traffic selector used to match packets |
| 77 | * @param priority the priority of the rule |
| 78 | * @param appId the application ID of the requester |
| 79 | * @param copy request a copy of the matching packet to be punted to the controller. |
| 80 | * <p> |
| 81 | * If false, the original packet is always sent to the controller. |
| 82 | * If true, a copy of the packet is sent to the controller, |
| 83 | * as long as the packet can be duplicated. |
| 84 | * If duplication is not supported, the original packet will be sent to the controller. |
| 85 | */ |
| 86 | void requestPackets(TrafficSelector selector, PacketPriority priority, |
| 87 | ApplicationId appId, boolean copy); |
alshabib | 19e2cea | 2015-12-07 11:31:49 -0800 | [diff] [blame] | 88 | |
| 89 | /** |
| 90 | * Requests that packets matching the given selector are punted from the |
| 91 | * dataplane to the controller. If a deviceId is specified then the |
| 92 | * packet request is only installed at the device represented by that |
| 93 | * deviceId. |
| 94 | * |
| 95 | * @param selector the traffic selector used to match packets |
| 96 | * @param priority the priority of the rule |
| 97 | * @param appId the application ID of the requester |
| 98 | * @param deviceId an optional deviceId |
| 99 | */ |
| 100 | void requestPackets(TrafficSelector selector, PacketPriority priority, |
| 101 | ApplicationId appId, Optional<DeviceId> deviceId); |
| 102 | |
Saurav Das | c313c40 | 2015-02-27 10:09:47 -0800 | [diff] [blame] | 103 | /** |
Thomas Vachuska | 27bee09 | 2015-06-23 19:03:10 -0700 | [diff] [blame] | 104 | * Cancels previous packet requests for packets matching the given |
| 105 | * selector to be punted from the dataplane to the controller. |
Saurav Das | c313c40 | 2015-02-27 10:09:47 -0800 | [diff] [blame] | 106 | * |
| 107 | * @param selector the traffic selector used to match packets |
| 108 | * @param priority the priority of the rule |
Thomas Vachuska | 27bee09 | 2015-06-23 19:03:10 -0700 | [diff] [blame] | 109 | * @param appId the application ID of the requester |
Saurav Das | c313c40 | 2015-02-27 10:09:47 -0800 | [diff] [blame] | 110 | */ |
Thomas Vachuska | 27bee09 | 2015-06-23 19:03:10 -0700 | [diff] [blame] | 111 | void cancelPackets(TrafficSelector selector, PacketPriority priority, |
| 112 | ApplicationId appId); |
Jonathan Hart | 3cfce8e | 2015-01-14 16:43:27 -0800 | [diff] [blame] | 113 | |
| 114 | /** |
alshabib | 19e2cea | 2015-12-07 11:31:49 -0800 | [diff] [blame] | 115 | * Cancels previous packet requests for packets matching the given |
Charles Chan | 874900e | 2016-12-09 16:55:39 -0800 | [diff] [blame^] | 116 | * selector to be punted from the dataplane to the controller. |
| 117 | * |
| 118 | * @param selector the traffic selector used to match packets |
| 119 | * @param priority the priority of the rule |
| 120 | * @param appId the application ID of the requester |
| 121 | * @param copy request a copy of the matching packet to be punted to the controller. |
| 122 | * <p> |
| 123 | * If false, the original packet is always sent to the controller. |
| 124 | * If true, a copy of the packet is sent to the controller, |
| 125 | * as long as the packet can be duplicated. |
| 126 | * If duplication is not supported, the original packet will be sent to the controller. |
| 127 | */ |
| 128 | void cancelPackets(TrafficSelector selector, PacketPriority priority, |
| 129 | ApplicationId appId, boolean copy); |
| 130 | |
| 131 | /** |
| 132 | * Cancels previous packet requests for packets matching the given |
alshabib | 19e2cea | 2015-12-07 11:31:49 -0800 | [diff] [blame] | 133 | * selector to be punted from the dataplane to the controller. If a |
| 134 | * deviceId is specified then the packet request is only withdrawn from |
| 135 | * the device represented by that deviceId. |
| 136 | * |
| 137 | * @param selector the traffic selector used to match packets |
| 138 | * @param priority the priority of the rule |
| 139 | * @param appId the application ID of the requester |
| 140 | * @param deviceId an optional deviceId |
| 141 | */ |
| 142 | void cancelPackets(TrafficSelector selector, PacketPriority priority, |
| 143 | ApplicationId appId, Optional<DeviceId> deviceId); |
| 144 | |
alshabib | 19e2cea | 2015-12-07 11:31:49 -0800 | [diff] [blame] | 145 | /** |
Thomas Vachuska | 7f171b2 | 2015-08-21 12:49:08 -0700 | [diff] [blame] | 146 | * Returns list of all existing requests ordered by priority. |
| 147 | * |
| 148 | * @return list of existing packet requests |
| 149 | */ |
| 150 | List<PacketRequest> getRequests(); |
| 151 | |
| 152 | /** |
tom | 613d814 | 2014-09-11 15:09:37 -0700 | [diff] [blame] | 153 | * Emits the specified outbound packet onto the network. |
| 154 | * |
| 155 | * @param packet outbound packet |
| 156 | */ |
| 157 | void emit(OutboundPacket packet); |
| 158 | |
| 159 | } |