blob: d26956eba7d3c41f061b01da940da955bb5e2683 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
Ray Milkey34c95902015-04-15 09:47:53 -07002 * Copyright 2014-2015 Open Networking Laboratory
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07003 *
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'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.packet;
tom613d8142014-09-11 15:09:37 -070017
Thomas Vachuska7f171b22015-08-21 12:49:08 -070018import com.google.common.annotations.Beta;
Jonathan Hart3cfce8e2015-01-14 16:43:27 -080019import org.onosproject.core.ApplicationId;
alshabib19e2cea2015-12-07 11:31:49 -080020import org.onosproject.net.DeviceId;
Jonathan Hart3cfce8e2015-01-14 16:43:27 -080021import org.onosproject.net.flow.TrafficSelector;
22
Thomas Vachuska7f171b22015-08-21 12:49:08 -070023import java.util.List;
alshabib19e2cea2015-12-07 11:31:49 -080024import java.util.Optional;
Thomas Vachuska7f171b22015-08-21 12:49:08 -070025
tom613d8142014-09-11 15:09:37 -070026/**
27 * Service for intercepting data plane packets and for emitting synthetic
28 * outbound packets.
29 */
30public interface PacketService {
31
32 // TODO: ponder better ordering scheme that does not require absolute numbers
33
34 /**
35 * Adds the specified processor to the list of packet processors.
36 * It will be added into the list in the order of priority. The higher
37 * numbers will be processing the packets after the lower numbers.
38 *
39 * @param processor processor to be added
40 * @param priority priority in the reverse natural order
41 * @throws java.lang.IllegalArgumentException if a processor with the
42 * given priority already exists
43 */
alshabib369d2942014-09-12 17:59:35 -070044 void addProcessor(PacketProcessor processor, int priority);
tom613d8142014-09-11 15:09:37 -070045
Jonathan Hart3cfce8e2015-01-14 16:43:27 -080046 // TODO allow processors to register for particular types of packets
47
tom613d8142014-09-11 15:09:37 -070048 /**
49 * Removes the specified processor from the processing pipeline.
50 *
51 * @param processor packet processor
52 */
53 void removeProcessor(PacketProcessor processor);
54
55 /**
Thomas Vachuska924cda42015-09-22 12:11:27 -070056 * Returns priority bindings of all registered packet processor entries.
Thomas Vachuska7f171b22015-08-21 12:49:08 -070057 *
Thomas Vachuska924cda42015-09-22 12:11:27 -070058 * @return list of existing packet processor entries
Thomas Vachuska7f171b22015-08-21 12:49:08 -070059 */
60 @Beta
Thomas Vachuska924cda42015-09-22 12:11:27 -070061 List<PacketProcessorEntry> getProcessors();
Thomas Vachuska7f171b22015-08-21 12:49:08 -070062
63 /**
Jonathan Hart3cfce8e2015-01-14 16:43:27 -080064 * Requests that packets matching the given selector are punted from the
65 * dataplane to the controller.
66 *
67 * @param selector the traffic selector used to match packets
68 * @param priority the priority of the rule
Thomas Vachuska27bee092015-06-23 19:03:10 -070069 * @param appId the application ID of the requester
Jonathan Hart3cfce8e2015-01-14 16:43:27 -080070 */
alshabib19e2cea2015-12-07 11:31:49 -080071 @Deprecated
Jonathan Hart3cfce8e2015-01-14 16:43:27 -080072 void requestPackets(TrafficSelector selector, PacketPriority priority,
73 ApplicationId appId);
74
alshabib19e2cea2015-12-07 11:31:49 -080075
76 /**
77 * Requests that packets matching the given selector are punted from the
78 * dataplane to the controller. If a deviceId is specified then the
79 * packet request is only installed at the device represented by that
80 * deviceId.
81 *
82 * @param selector the traffic selector used to match packets
83 * @param priority the priority of the rule
84 * @param appId the application ID of the requester
85 * @param deviceId an optional deviceId
86 */
87 void requestPackets(TrafficSelector selector, PacketPriority priority,
88 ApplicationId appId, Optional<DeviceId> deviceId);
89
Saurav Dasc313c402015-02-27 10:09:47 -080090 /**
Thomas Vachuska27bee092015-06-23 19:03:10 -070091 * Cancels previous packet requests for packets matching the given
92 * selector to be punted from the dataplane to the controller.
Saurav Dasc313c402015-02-27 10:09:47 -080093 *
94 * @param selector the traffic selector used to match packets
95 * @param priority the priority of the rule
Thomas Vachuska27bee092015-06-23 19:03:10 -070096 * @param appId the application ID of the requester
Saurav Dasc313c402015-02-27 10:09:47 -080097 */
alshabib19e2cea2015-12-07 11:31:49 -080098 @Deprecated
Thomas Vachuska27bee092015-06-23 19:03:10 -070099 void cancelPackets(TrafficSelector selector, PacketPriority priority,
100 ApplicationId appId);
Jonathan Hart3cfce8e2015-01-14 16:43:27 -0800101
102 /**
alshabib19e2cea2015-12-07 11:31:49 -0800103 * Cancels previous packet requests for packets matching the given
104 * selector to be punted from the dataplane to the controller. If a
105 * deviceId is specified then the packet request is only withdrawn from
106 * the device represented by that deviceId.
107 *
108 * @param selector the traffic selector used to match packets
109 * @param priority the priority of the rule
110 * @param appId the application ID of the requester
111 * @param deviceId an optional deviceId
112 */
113 void cancelPackets(TrafficSelector selector, PacketPriority priority,
114 ApplicationId appId, Optional<DeviceId> deviceId);
115
116
117 /**
Thomas Vachuska7f171b22015-08-21 12:49:08 -0700118 * Returns list of all existing requests ordered by priority.
119 *
120 * @return list of existing packet requests
121 */
122 List<PacketRequest> getRequests();
123
124 /**
tom613d8142014-09-11 15:09:37 -0700125 * Emits the specified outbound packet onto the network.
126 *
127 * @param packet outbound packet
128 */
129 void emit(OutboundPacket packet);
130
131}