blob: 6fbc0538844bb4214a3ed6750651f69d0c4a8c65 [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
tom8bb16062014-09-12 14:47:46 -070019package org.onlab.onos.net.flow;
20
alshabib902d41b2014-10-07 16:52:05 -070021import java.util.concurrent.Future;
22
Thomas Vachuskae0f804a2014-10-27 23:40:48 -070023import org.onlab.onos.core.ApplicationId;
tom8bb16062014-09-12 14:47:46 -070024import org.onlab.onos.net.DeviceId;
25
26/**
27 * Service for injecting flow rules into the environment and for obtaining
tom4d0c6632014-09-15 23:27:01 -070028 * information about flow rules already in the environment. This implements
29 * semantics of a distributed authoritative flow table where the master copy
30 * of the flow rules lies with the controller and the devices hold only the
31 * 'cached' copy.
tom8bb16062014-09-12 14:47:46 -070032 */
33public interface FlowRuleService {
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 /**
90 * Applies a batch operation of FlowRules.
91 *
92 * @return future indicating the state of the batch operation
93 */
94 Future<CompletedBatchOperation> applyBatch(FlowRuleBatchOperation batch);
alshabib58747a62014-10-07 11:05:30 -070095
alshabib369d2942014-09-12 17:59:35 -070096 /**
tom8bb16062014-09-12 14:47:46 -070097 * Adds the specified flow rule listener.
98 *
99 * @param listener flow rule listener
100 */
101 void addListener(FlowRuleListener listener);
102
103 /**
104 * Removes the specified flow rule listener.
105 *
106 * @param listener flow rule listener
107 */
108 void removeListener(FlowRuleListener listener);
tom8bb16062014-09-12 14:47:46 -0700109}