tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 1 | package org.onlab.onos.net.flow; |
| 2 | |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 3 | import org.onlab.onos.ApplicationId; |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 4 | import org.onlab.onos.net.DeviceId; |
| 5 | |
| 6 | /** |
| 7 | * Service for injecting flow rules into the environment and for obtaining |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 8 | * information about flow rules already in the environment. This implements |
| 9 | * semantics of a distributed authoritative flow table where the master copy |
| 10 | * of the flow rules lies with the controller and the devices hold only the |
| 11 | * 'cached' copy. |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 12 | */ |
| 13 | public interface FlowRuleService { |
| 14 | |
| 15 | /** |
tom | 9b4030d | 2014-10-06 10:39:03 -0700 | [diff] [blame^] | 16 | * Returns the number of flow rules in the system. |
| 17 | * |
| 18 | * @return flow rule count |
| 19 | */ |
| 20 | int getFlowRuleCount(); |
| 21 | |
| 22 | /** |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 23 | * Returns the collection of flow entries applied on the specified device. |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 24 | * This will include flow rules which may not yet have been applied to |
| 25 | * the device. |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 26 | * |
| 27 | * @param deviceId device identifier |
| 28 | * @return collection of flow rules |
| 29 | */ |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 30 | Iterable<FlowEntry> getFlowEntries(DeviceId deviceId); |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 31 | |
tom | 73d6d1e | 2014-09-17 20:08:01 -0700 | [diff] [blame] | 32 | // TODO: add createFlowRule factory method and execute operations method |
| 33 | |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 34 | /** |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 35 | * Applies the specified flow rules onto their respective devices. These |
| 36 | * flow rules will be retained by the system and re-applied anytime the |
| 37 | * device reconnects to the controller. |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 38 | * |
| 39 | * @param flowRules one or more flow rules |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 40 | */ |
alshabib | 219ebaa | 2014-09-22 15:41:24 -0700 | [diff] [blame] | 41 | void applyFlowRules(FlowRule... flowRules); |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 42 | |
| 43 | /** |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 44 | * Removes the specified flow rules from their respective devices. If the |
| 45 | * device is not presently connected to the controller, these flow will |
| 46 | * be removed once the device reconnects. |
alshabib | 369d294 | 2014-09-12 17:59:35 -0700 | [diff] [blame] | 47 | * |
| 48 | * @param flowRules one or more flow rules |
| 49 | * throws SomeKindOfException that indicates which ones were removed and |
| 50 | * which ones failed |
| 51 | */ |
| 52 | void removeFlowRules(FlowRule... flowRules); |
| 53 | |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 54 | /** |
| 55 | * Removes all rules by id. |
| 56 | * |
| 57 | * @param appId id to remove |
| 58 | */ |
| 59 | void removeFlowRulesById(ApplicationId appId); |
| 60 | |
| 61 | /** |
| 62 | * Returns a list of rules with this application id. |
| 63 | * |
| 64 | * @param id the id to look up |
| 65 | * @return collection of flow rules |
| 66 | */ |
| 67 | Iterable<FlowRule> getFlowRulesById(ApplicationId id); |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 68 | |
alshabib | 369d294 | 2014-09-12 17:59:35 -0700 | [diff] [blame] | 69 | /** |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 70 | * Adds the specified flow rule listener. |
| 71 | * |
| 72 | * @param listener flow rule listener |
| 73 | */ |
| 74 | void addListener(FlowRuleListener listener); |
| 75 | |
| 76 | /** |
| 77 | * Removes the specified flow rule listener. |
| 78 | * |
| 79 | * @param listener flow rule listener |
| 80 | */ |
| 81 | void removeListener(FlowRuleListener listener); |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 82 | } |