Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 1 | /* |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 2 | * Copyright 2014 Open Networking Laboratory |
Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 3 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 4 | * 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 Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 7 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 8 | * 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 Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 15 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.flow; |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 17 | |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 18 | import org.onosproject.core.ApplicationId; |
| 19 | import org.onosproject.net.DeviceId; |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 20 | |
| 21 | /** |
| 22 | * Service for injecting flow rules into the environment and for obtaining |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 23 | * 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. |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 27 | */ |
| 28 | public interface FlowRuleService { |
| 29 | |
| 30 | /** |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 31 | * The topic used for obtaining globally unique ids. |
| 32 | */ |
| 33 | static String FLOW_OP_TOPIC = "flow-ops-ids"; |
| 34 | |
| 35 | /** |
tom | 9b4030d | 2014-10-06 10:39:03 -0700 | [diff] [blame] | 36 | * Returns the number of flow rules in the system. |
| 37 | * |
| 38 | * @return flow rule count |
| 39 | */ |
| 40 | int getFlowRuleCount(); |
| 41 | |
| 42 | /** |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 43 | * Returns the collection of flow entries applied on the specified device. |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 44 | * This will include flow rules which may not yet have been applied to |
| 45 | * the device. |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 46 | * |
| 47 | * @param deviceId device identifier |
| 48 | * @return collection of flow rules |
| 49 | */ |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 50 | Iterable<FlowEntry> getFlowEntries(DeviceId deviceId); |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 51 | |
tom | 73d6d1e | 2014-09-17 20:08:01 -0700 | [diff] [blame] | 52 | // TODO: add createFlowRule factory method and execute operations method |
| 53 | |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 54 | /** |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 55 | * 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. |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 58 | * |
| 59 | * @param flowRules one or more flow rules |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 60 | */ |
alshabib | 219ebaa | 2014-09-22 15:41:24 -0700 | [diff] [blame] | 61 | void applyFlowRules(FlowRule... flowRules); |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 62 | |
| 63 | /** |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 64 | * 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. |
alshabib | 369d294 | 2014-09-12 17:59:35 -0700 | [diff] [blame] | 67 | * |
| 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 | |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 74 | /** |
| 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); |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 88 | |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 89 | /** |
alshabib | aa7e7de | 2014-11-12 19:20:44 -0800 | [diff] [blame] | 90 | * 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 | /** |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 99 | * Applies a batch operation of FlowRules. |
| 100 | * |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 101 | * @param ops batch operation to apply |
| 102 | */ |
| 103 | void apply(FlowRuleOperations ops); |
| 104 | |
| 105 | /** |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 106 | * 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); |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 118 | } |