blob: 21ecd49bb7e8e9f9a106d1faf3eea26d4a77f272 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2014-present Open Networking Foundation
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
Jonathan Hart3cfce8e2015-01-14 16:43:27 -080018import org.onosproject.core.ApplicationId;
alshabib19e2cea2015-12-07 11:31:49 -080019import org.onosproject.net.DeviceId;
Jonathan Hart3cfce8e2015-01-14 16:43:27 -080020import org.onosproject.net.flow.TrafficSelector;
21
Harshada Chaundkardcd1b142019-03-25 17:27:44 -040022import java.util.ArrayList;
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 /**
Harshada Chaundkardcd1b142019-03-25 17:27:44 -040056 * Adds the specified filter to the list of packet filters.
57 * It will be added into the list in the order in which it is added.
58 *
59 * @param filter filter to be added
60 */
61 default void addFilter(PacketInFilter filter) {}
62
63
64 /**
65 * Removes the specified filter from the filters list.
66 *
67 * @param filter filter to be removed
68 */
69 default void removeFilter(PacketInFilter filter) {}
70
71 /**
Thomas Vachuska924cda42015-09-22 12:11:27 -070072 * Returns priority bindings of all registered packet processor entries.
Thomas Vachuska7f171b22015-08-21 12:49:08 -070073 *
Thomas Vachuska924cda42015-09-22 12:11:27 -070074 * @return list of existing packet processor entries
Thomas Vachuska7f171b22015-08-21 12:49:08 -070075 */
Thomas Vachuska924cda42015-09-22 12:11:27 -070076 List<PacketProcessorEntry> getProcessors();
Thomas Vachuska7f171b22015-08-21 12:49:08 -070077
78 /**
Jonathan Hart3cfce8e2015-01-14 16:43:27 -080079 * Requests that packets matching the given selector are punted from the
80 * dataplane to the controller.
81 *
82 * @param selector the traffic selector used to match packets
83 * @param priority the priority of the rule
Thomas Vachuska27bee092015-06-23 19:03:10 -070084 * @param appId the application ID of the requester
Jonathan Hart3cfce8e2015-01-14 16:43:27 -080085 */
86 void requestPackets(TrafficSelector selector, PacketPriority priority,
87 ApplicationId appId);
88
alshabib19e2cea2015-12-07 11:31:49 -080089
90 /**
91 * Requests that packets matching the given selector are punted from the
92 * dataplane to the controller. If a deviceId is specified then the
93 * packet request is only installed at the device represented by that
94 * deviceId.
95 *
96 * @param selector the traffic selector used to match packets
97 * @param priority the priority of the rule
98 * @param appId the application ID of the requester
99 * @param deviceId an optional deviceId
100 */
101 void requestPackets(TrafficSelector selector, PacketPriority priority,
102 ApplicationId appId, Optional<DeviceId> deviceId);
103
Saurav Dasc313c402015-02-27 10:09:47 -0800104 /**
Thomas Vachuska27bee092015-06-23 19:03:10 -0700105 * Cancels previous packet requests for packets matching the given
106 * selector to be punted from the dataplane to the controller.
Saurav Dasc313c402015-02-27 10:09:47 -0800107 *
108 * @param selector the traffic selector used to match packets
109 * @param priority the priority of the rule
Thomas Vachuska27bee092015-06-23 19:03:10 -0700110 * @param appId the application ID of the requester
Saurav Dasc313c402015-02-27 10:09:47 -0800111 */
Thomas Vachuska27bee092015-06-23 19:03:10 -0700112 void cancelPackets(TrafficSelector selector, PacketPriority priority,
113 ApplicationId appId);
Jonathan Hart3cfce8e2015-01-14 16:43:27 -0800114
115 /**
alshabib19e2cea2015-12-07 11:31:49 -0800116 * Cancels previous packet requests for packets matching the given
117 * selector to be punted from the dataplane to the controller. If a
118 * deviceId is specified then the packet request is only withdrawn from
119 * the device represented by that deviceId.
120 *
121 * @param selector the traffic selector used to match packets
122 * @param priority the priority of the rule
123 * @param appId the application ID of the requester
124 * @param deviceId an optional deviceId
125 */
126 void cancelPackets(TrafficSelector selector, PacketPriority priority,
127 ApplicationId appId, Optional<DeviceId> deviceId);
128
alshabib19e2cea2015-12-07 11:31:49 -0800129 /**
Thomas Vachuska7f171b22015-08-21 12:49:08 -0700130 * Returns list of all existing requests ordered by priority.
131 *
132 * @return list of existing packet requests
133 */
134 List<PacketRequest> getRequests();
135
136 /**
tom613d8142014-09-11 15:09:37 -0700137 * Emits the specified outbound packet onto the network.
138 *
139 * @param packet outbound packet
140 */
141 void emit(OutboundPacket packet);
142
Harshada Chaundkardcd1b142019-03-25 17:27:44 -0400143 /**
144 * Get the list of packet filters present in ONOS.
145 *
146 * @return List of packet filters
147 */
148 default List<PacketInFilter> getFilters() {
149 return new ArrayList<>();
150 }
151
152 /**
153 * Clear all packet filters in one shot.
154 *
155 */
156 default void clearFilters() {}
157
158
tom613d8142014-09-11 15:09:37 -0700159}