blob: 43d0f5d620b7e75a815fa43c1106107bc2dacbab [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
Ray Milkey34c95902015-04-15 09:47:53 -07002 * Copyright 2014-2015 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;
19import org.onosproject.net.DeviceId;
tom8bb16062014-09-12 14:47:46 -070020
21/**
22 * Service for injecting flow rules into the environment and for obtaining
tom4d0c6632014-09-15 23:27:01 -070023 * information about flow rules already in the environment. This implements
24 * semantics of a distributed authoritative flow table where the master copy
25 * of the flow rules lies with the controller and the devices hold only the
26 * 'cached' copy.
tom8bb16062014-09-12 14:47:46 -070027 */
28public interface FlowRuleService {
29
30 /**
Brian O'Connor72cb19a2015-01-16 16:14:41 -080031 * The topic used for obtaining globally unique ids.
32 */
33 static String FLOW_OP_TOPIC = "flow-ops-ids";
34
35 /**
tom9b4030d2014-10-06 10:39:03 -070036 * Returns the number of flow rules in the system.
37 *
38 * @return flow rule count
39 */
40 int getFlowRuleCount();
41
42 /**
tom8bb16062014-09-12 14:47:46 -070043 * Returns the collection of flow entries applied on the specified device.
tom4d0c6632014-09-15 23:27:01 -070044 * This will include flow rules which may not yet have been applied to
45 * the device.
tom8bb16062014-09-12 14:47:46 -070046 *
47 * @param deviceId device identifier
48 * @return collection of flow rules
49 */
alshabib1c319ff2014-10-04 20:29:09 -070050 Iterable<FlowEntry> getFlowEntries(DeviceId deviceId);
tom8bb16062014-09-12 14:47:46 -070051
tom73d6d1e2014-09-17 20:08:01 -070052 // TODO: add createFlowRule factory method and execute operations method
53
tom8bb16062014-09-12 14:47:46 -070054 /**
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 /**
tom4d0c6632014-09-15 23:27:01 -070064 * Removes the specified flow rules from their respective devices. If the
65 * device is not presently connected to the controller, these flow will
66 * be removed once the device reconnects.
alshabib369d2942014-09-12 17:59:35 -070067 *
68 * @param flowRules one or more flow rules
69 * throws SomeKindOfException that indicates which ones were removed and
70 * which ones failed
71 */
72 void removeFlowRules(FlowRule... flowRules);
73
alshabiba68eb962014-09-24 20:34:13 -070074 /**
75 * Removes all rules by id.
76 *
77 * @param appId id to remove
78 */
79 void removeFlowRulesById(ApplicationId appId);
80
81 /**
82 * Returns a list of rules with this application id.
83 *
84 * @param id the id to look up
85 * @return collection of flow rules
86 */
87 Iterable<FlowRule> getFlowRulesById(ApplicationId id);
tom4d0c6632014-09-15 23:27:01 -070088
alshabib902d41b2014-10-07 16:52:05 -070089 /**
alshabibaa7e7de2014-11-12 19:20:44 -080090 * Returns a list of rules filterd by application and group id.
91 *
92 * @param appId the application id to lookup
93 * @param groupId the groupid to lookup
94 * @return collection of flow rules
95 */
96 Iterable<FlowRule> getFlowRulesByGroupId(ApplicationId appId, short groupId);
97
98 /**
alshabib902d41b2014-10-07 16:52:05 -070099 * Applies a batch operation of FlowRules.
100 *
Brian O'Connor72cb19a2015-01-16 16:14:41 -0800101 * @param ops batch operation to apply
102 */
103 void apply(FlowRuleOperations ops);
104
105 /**
tom8bb16062014-09-12 14:47:46 -0700106 * Adds the specified flow rule listener.
107 *
108 * @param listener flow rule listener
109 */
110 void addListener(FlowRuleListener listener);
111
112 /**
113 * Removes the specified flow rule listener.
114 *
115 * @param listener flow rule listener
116 */
117 void removeListener(FlowRuleListener listener);
tom8bb16062014-09-12 14:47:46 -0700118}