blob: 62e725e0bb9a7c7e1a1a09720559d562fabe06cf [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2014-present Open Networking Laboratory
Thomas Vachuska83e090e2014-10-22 14:25:35 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * 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
Thomas Vachuska83e090e2014-10-22 14:25:35 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * 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.
Thomas Vachuska83e090e2014-10-22 14:25:35 -070015 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.flow;
tom8bb16062014-09-12 14:47:46 -070017
Brian O'Connorabafb502014-12-02 22:26:20 -080018import org.onosproject.core.ApplicationId;
Thomas Vachuska42e8cce2015-07-29 19:25:18 -070019import org.onosproject.event.ListenerService;
Brian O'Connorabafb502014-12-02 22:26:20 -080020import org.onosproject.net.DeviceId;
tom8bb16062014-09-12 14:47:46 -070021
22/**
23 * Service for injecting flow rules into the environment and for obtaining
tom4d0c6632014-09-15 23:27:01 -070024 * information about flow rules already in the environment. This implements
25 * semantics of a distributed authoritative flow table where the master copy
26 * of the flow rules lies with the controller and the devices hold only the
27 * 'cached' copy.
tom8bb16062014-09-12 14:47:46 -070028 */
Thomas Vachuska42e8cce2015-07-29 19:25:18 -070029public interface FlowRuleService
30 extends ListenerService<FlowRuleEvent, FlowRuleListener> {
tom8bb16062014-09-12 14:47:46 -070031
32 /**
Brian O'Connor72cb19a2015-01-16 16:14:41 -080033 * The topic used for obtaining globally unique ids.
34 */
Sho SHIMIZUe2952e42015-09-11 17:11:21 -070035 String FLOW_OP_TOPIC = "flow-ops-ids";
Brian O'Connor72cb19a2015-01-16 16:14:41 -080036
37 /**
tom9b4030d2014-10-06 10:39:03 -070038 * Returns the number of flow rules in the system.
39 *
40 * @return flow rule count
41 */
42 int getFlowRuleCount();
43
44 /**
tom8bb16062014-09-12 14:47:46 -070045 * Returns the collection of flow entries applied on the specified device.
tom4d0c6632014-09-15 23:27:01 -070046 * This will include flow rules which may not yet have been applied to
47 * the device.
tom8bb16062014-09-12 14:47:46 -070048 *
49 * @param deviceId device identifier
50 * @return collection of flow rules
51 */
alshabib1c319ff2014-10-04 20:29:09 -070052 Iterable<FlowEntry> getFlowEntries(DeviceId deviceId);
tom8bb16062014-09-12 14:47:46 -070053
54 /**
tom4d0c6632014-09-15 23:27:01 -070055 * Applies the specified flow rules onto their respective devices. These
56 * flow rules will be retained by the system and re-applied anytime the
57 * device reconnects to the controller.
tom8bb16062014-09-12 14:47:46 -070058 *
59 * @param flowRules one or more flow rules
tom8bb16062014-09-12 14:47:46 -070060 */
alshabib219ebaa2014-09-22 15:41:24 -070061 void applyFlowRules(FlowRule... flowRules);
tom8bb16062014-09-12 14:47:46 -070062
63 /**
Kavitha Alagesanc69c66a2016-06-15 14:26:04 +053064 * Purges all the flow rules on the specified device.
65 * @param deviceId device identifier
66 */
67 void purgeFlowRules(DeviceId deviceId);
68
69 /**
tom4d0c6632014-09-15 23:27:01 -070070 * Removes the specified flow rules from their respective devices. If the
71 * device is not presently connected to the controller, these flow will
72 * be removed once the device reconnects.
alshabib369d2942014-09-12 17:59:35 -070073 *
74 * @param flowRules one or more flow rules
alshabib369d2942014-09-12 17:59:35 -070075 */
76 void removeFlowRules(FlowRule... flowRules);
77
alshabiba68eb962014-09-24 20:34:13 -070078 /**
Jonathan Hart3fc7e832016-05-23 15:41:11 -070079 * Removes all rules submitted by a particular application.
alshabiba68eb962014-09-24 20:34:13 -070080 *
Jonathan Hart3fc7e832016-05-23 15:41:11 -070081 * @param appId ID of application whose flows will be removed
alshabiba68eb962014-09-24 20:34:13 -070082 */
83 void removeFlowRulesById(ApplicationId appId);
84
85 /**
Jonathan Hart3fc7e832016-05-23 15:41:11 -070086 * Returns a list of rules with this application ID.
alshabiba68eb962014-09-24 20:34:13 -070087 *
Jonathan Hart3fc7e832016-05-23 15:41:11 -070088 * @param id the application ID to look up
alshabiba68eb962014-09-24 20:34:13 -070089 * @return collection of flow rules
90 */
Bharath Thiruveedula99849dc2016-11-17 22:04:38 +053091 @Deprecated
alshabiba68eb962014-09-24 20:34:13 -070092 Iterable<FlowRule> getFlowRulesById(ApplicationId id);
tom4d0c6632014-09-15 23:27:01 -070093
alshabib902d41b2014-10-07 16:52:05 -070094 /**
Bharath Thiruveedula99849dc2016-11-17 22:04:38 +053095 * Returns a list of rules with this application ID.
96 *
97 * @param id the application ID to look up
98 * @return collection of flow rules
99 */
100 Iterable<FlowEntry> getFlowEntriesById(ApplicationId id);
101
102 /**
Jonathan Hart5acc88a2016-05-23 10:50:20 -0700103 * Returns a list of rules filtered by application and group id.
104 * <p>
105 * Note that the group concept here is simply a logical grouping of flows.
106 * This is not the same as a group in the
107 * {@link org.onosproject.net.group.GroupService}, and this method will not
108 * return flows that are mapped to a particular {@link org.onosproject.net.group.Group}.
109 * </p>
alshabibaa7e7de2014-11-12 19:20:44 -0800110 *
Jonathan Hart5acc88a2016-05-23 10:50:20 -0700111 * @param appId the application ID to look up
112 * @param groupId the group ID to look up
alshabibaa7e7de2014-11-12 19:20:44 -0800113 * @return collection of flow rules
114 */
115 Iterable<FlowRule> getFlowRulesByGroupId(ApplicationId appId, short groupId);
116
117 /**
alshabib902d41b2014-10-07 16:52:05 -0700118 * Applies a batch operation of FlowRules.
119 *
Brian O'Connor72cb19a2015-01-16 16:14:41 -0800120 * @param ops batch operation to apply
121 */
122 void apply(FlowRuleOperations ops);
123
Srikanth Vavilapalli95810f52015-09-14 15:49:56 -0700124 /**
125 * Returns the collection of flow table statistics of the specified device.
126 *
127 * @param deviceId device identifier
128 * @return collection of flow table statistics
129 */
130 Iterable<TableStatisticsEntry> getFlowTableStatistics(DeviceId deviceId);
tom8bb16062014-09-12 14:47:46 -0700131}