blob: 789b6bf50c13d495959ebadbb909e5995231dbfc [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07002 * Copyright 2014 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 */
tom8bb16062014-09-12 14:47:46 -070016package org.onlab.onos.net.flow;
17
alshabib902d41b2014-10-07 16:52:05 -070018import java.util.concurrent.Future;
19
Thomas Vachuskae0f804a2014-10-27 23:40:48 -070020import org.onlab.onos.core.ApplicationId;
tom8bb16062014-09-12 14:47:46 -070021import org.onlab.onos.net.DeviceId;
22
23/**
24 * Service for injecting flow rules into the environment and for obtaining
tom4d0c6632014-09-15 23:27:01 -070025 * information about flow rules already in the environment. This implements
26 * semantics of a distributed authoritative flow table where the master copy
27 * of the flow rules lies with the controller and the devices hold only the
28 * 'cached' copy.
tom8bb16062014-09-12 14:47:46 -070029 */
30public interface FlowRuleService {
31
32 /**
tom9b4030d2014-10-06 10:39:03 -070033 * Returns the number of flow rules in the system.
34 *
35 * @return flow rule count
36 */
37 int getFlowRuleCount();
38
39 /**
tom8bb16062014-09-12 14:47:46 -070040 * Returns the collection of flow entries applied on the specified device.
tom4d0c6632014-09-15 23:27:01 -070041 * This will include flow rules which may not yet have been applied to
42 * the device.
tom8bb16062014-09-12 14:47:46 -070043 *
44 * @param deviceId device identifier
45 * @return collection of flow rules
46 */
alshabib1c319ff2014-10-04 20:29:09 -070047 Iterable<FlowEntry> getFlowEntries(DeviceId deviceId);
tom8bb16062014-09-12 14:47:46 -070048
tom73d6d1e2014-09-17 20:08:01 -070049 // TODO: add createFlowRule factory method and execute operations method
50
tom8bb16062014-09-12 14:47:46 -070051 /**
tom4d0c6632014-09-15 23:27:01 -070052 * Applies the specified flow rules onto their respective devices. These
53 * flow rules will be retained by the system and re-applied anytime the
54 * device reconnects to the controller.
tom8bb16062014-09-12 14:47:46 -070055 *
56 * @param flowRules one or more flow rules
tom8bb16062014-09-12 14:47:46 -070057 */
alshabib219ebaa2014-09-22 15:41:24 -070058 void applyFlowRules(FlowRule... flowRules);
tom8bb16062014-09-12 14:47:46 -070059
60 /**
tom4d0c6632014-09-15 23:27:01 -070061 * Removes the specified flow rules from their respective devices. If the
62 * device is not presently connected to the controller, these flow will
63 * be removed once the device reconnects.
alshabib369d2942014-09-12 17:59:35 -070064 *
65 * @param flowRules one or more flow rules
66 * throws SomeKindOfException that indicates which ones were removed and
67 * which ones failed
68 */
69 void removeFlowRules(FlowRule... flowRules);
70
alshabiba68eb962014-09-24 20:34:13 -070071 /**
72 * Removes all rules by id.
73 *
74 * @param appId id to remove
75 */
76 void removeFlowRulesById(ApplicationId appId);
77
78 /**
79 * Returns a list of rules with this application id.
80 *
81 * @param id the id to look up
82 * @return collection of flow rules
83 */
84 Iterable<FlowRule> getFlowRulesById(ApplicationId id);
tom4d0c6632014-09-15 23:27:01 -070085
alshabib902d41b2014-10-07 16:52:05 -070086 /**
87 * Applies a batch operation of FlowRules.
88 *
89 * @return future indicating the state of the batch operation
90 */
91 Future<CompletedBatchOperation> applyBatch(FlowRuleBatchOperation batch);
alshabib58747a62014-10-07 11:05:30 -070092
alshabib369d2942014-09-12 17:59:35 -070093 /**
tom8bb16062014-09-12 14:47:46 -070094 * Adds the specified flow rule listener.
95 *
96 * @param listener flow rule listener
97 */
98 void addListener(FlowRuleListener listener);
99
100 /**
101 * Removes the specified flow rule listener.
102 *
103 * @param listener flow rule listener
104 */
105 void removeListener(FlowRuleListener listener);
tom8bb16062014-09-12 14:47:46 -0700106}