blob: 2e7a1b91d0845d0b03f0437226f3d00b1e2fefe8 [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;
20import org.onosproject.net.flow.TrafficSelector;
21
Thomas Vachuska7f171b22015-08-21 12:49:08 -070022import java.util.List;
Thomas Vachuska7f171b22015-08-21 12:49:08 -070023
tom613d8142014-09-11 15:09:37 -070024/**
25 * Service for intercepting data plane packets and for emitting synthetic
26 * outbound packets.
27 */
28public interface PacketService {
29
30 // TODO: ponder better ordering scheme that does not require absolute numbers
31
32 /**
33 * Adds the specified processor to the list of packet processors.
34 * It will be added into the list in the order of priority. The higher
35 * numbers will be processing the packets after the lower numbers.
36 *
37 * @param processor processor to be added
38 * @param priority priority in the reverse natural order
39 * @throws java.lang.IllegalArgumentException if a processor with the
40 * given priority already exists
41 */
alshabib369d2942014-09-12 17:59:35 -070042 void addProcessor(PacketProcessor processor, int priority);
tom613d8142014-09-11 15:09:37 -070043
Jonathan Hart3cfce8e2015-01-14 16:43:27 -080044 // TODO allow processors to register for particular types of packets
45
tom613d8142014-09-11 15:09:37 -070046 /**
47 * Removes the specified processor from the processing pipeline.
48 *
49 * @param processor packet processor
50 */
51 void removeProcessor(PacketProcessor processor);
52
53 /**
Thomas Vachuska924cda42015-09-22 12:11:27 -070054 * Returns priority bindings of all registered packet processor entries.
Thomas Vachuska7f171b22015-08-21 12:49:08 -070055 *
Thomas Vachuska924cda42015-09-22 12:11:27 -070056 * @return list of existing packet processor entries
Thomas Vachuska7f171b22015-08-21 12:49:08 -070057 */
58 @Beta
Thomas Vachuska924cda42015-09-22 12:11:27 -070059 List<PacketProcessorEntry> getProcessors();
Thomas Vachuska7f171b22015-08-21 12:49:08 -070060
61 /**
Jonathan Hart3cfce8e2015-01-14 16:43:27 -080062 * 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 Vachuska27bee092015-06-23 19:03:10 -070067 * @param appId the application ID of the requester
Jonathan Hart3cfce8e2015-01-14 16:43:27 -080068 */
69 void requestPackets(TrafficSelector selector, PacketPriority priority,
70 ApplicationId appId);
71
Saurav Dasc313c402015-02-27 10:09:47 -080072 /**
Thomas Vachuska27bee092015-06-23 19:03:10 -070073 * Cancels previous packet requests for packets matching the given
74 * selector to be punted from the dataplane to the controller.
Saurav Dasc313c402015-02-27 10:09:47 -080075 *
76 * @param selector the traffic selector used to match packets
77 * @param priority the priority of the rule
Thomas Vachuska27bee092015-06-23 19:03:10 -070078 * @param appId the application ID of the requester
Saurav Dasc313c402015-02-27 10:09:47 -080079 */
Thomas Vachuska27bee092015-06-23 19:03:10 -070080 void cancelPackets(TrafficSelector selector, PacketPriority priority,
81 ApplicationId appId);
Jonathan Hart3cfce8e2015-01-14 16:43:27 -080082
83 /**
Thomas Vachuska7f171b22015-08-21 12:49:08 -070084 * Returns list of all existing requests ordered by priority.
85 *
86 * @return list of existing packet requests
87 */
88 List<PacketRequest> getRequests();
89
90 /**
tom613d8142014-09-11 15:09:37 -070091 * Emits the specified outbound packet onto the network.
92 *
93 * @param packet outbound packet
94 */
95 void emit(OutboundPacket packet);
96
97}