Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2014-present 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; |
Thomas Vachuska | 42e8cce | 2015-07-29 19:25:18 -0700 | [diff] [blame] | 19 | import org.onosproject.event.ListenerService; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 20 | import org.onosproject.net.DeviceId; |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 21 | |
| 22 | /** |
| 23 | * Service for injecting flow rules into the environment and for obtaining |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 24 | * information about flow rules already in the environment. This implements |
| 25 | * semantics of a distributed authoritative flow table where the master copy |
| 26 | * of the flow rules lies with the controller and the devices hold only the |
| 27 | * 'cached' copy. |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 28 | */ |
Thomas Vachuska | 42e8cce | 2015-07-29 19:25:18 -0700 | [diff] [blame] | 29 | public interface FlowRuleService |
| 30 | extends ListenerService<FlowRuleEvent, FlowRuleListener> { |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 31 | |
| 32 | /** |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 33 | * The topic used for obtaining globally unique ids. |
| 34 | */ |
Sho SHIMIZU | e2952e4 | 2015-09-11 17:11:21 -0700 | [diff] [blame] | 35 | String FLOW_OP_TOPIC = "flow-ops-ids"; |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 36 | |
| 37 | /** |
tom | 9b4030d | 2014-10-06 10:39:03 -0700 | [diff] [blame] | 38 | * Returns the number of flow rules in the system. |
| 39 | * |
| 40 | * @return flow rule count |
| 41 | */ |
| 42 | int getFlowRuleCount(); |
| 43 | |
| 44 | /** |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 45 | * Returns the collection of flow entries applied on the specified device. |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 46 | * This will include flow rules which may not yet have been applied to |
| 47 | * the device. |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 48 | * |
| 49 | * @param deviceId device identifier |
| 50 | * @return collection of flow rules |
| 51 | */ |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 52 | Iterable<FlowEntry> getFlowEntries(DeviceId deviceId); |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 53 | |
| 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 | /** |
Kavitha Alagesan | c69c66a | 2016-06-15 14:26:04 +0530 | [diff] [blame] | 64 | * Purges all the flow rules on the specified device. |
| 65 | * @param deviceId device identifier |
| 66 | */ |
| 67 | void purgeFlowRules(DeviceId deviceId); |
| 68 | |
| 69 | /** |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 70 | * Removes the specified flow rules from their respective devices. If the |
| 71 | * device is not presently connected to the controller, these flow will |
| 72 | * be removed once the device reconnects. |
alshabib | 369d294 | 2014-09-12 17:59:35 -0700 | [diff] [blame] | 73 | * |
| 74 | * @param flowRules one or more flow rules |
alshabib | 369d294 | 2014-09-12 17:59:35 -0700 | [diff] [blame] | 75 | */ |
| 76 | void removeFlowRules(FlowRule... flowRules); |
| 77 | |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 78 | /** |
Jonathan Hart | 3fc7e83 | 2016-05-23 15:41:11 -0700 | [diff] [blame] | 79 | * Removes all rules submitted by a particular application. |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 80 | * |
Jonathan Hart | 3fc7e83 | 2016-05-23 15:41:11 -0700 | [diff] [blame] | 81 | * @param appId ID of application whose flows will be removed |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 82 | */ |
| 83 | void removeFlowRulesById(ApplicationId appId); |
| 84 | |
| 85 | /** |
Jonathan Hart | 3fc7e83 | 2016-05-23 15:41:11 -0700 | [diff] [blame] | 86 | * Returns a list of rules with this application ID. |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 87 | * |
Jonathan Hart | 3fc7e83 | 2016-05-23 15:41:11 -0700 | [diff] [blame] | 88 | * @param id the application ID to look up |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 89 | * @return collection of flow rules |
| 90 | */ |
| 91 | Iterable<FlowRule> getFlowRulesById(ApplicationId id); |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 92 | |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 93 | /** |
Jonathan Hart | 5acc88a | 2016-05-23 10:50:20 -0700 | [diff] [blame] | 94 | * Returns a list of rules filtered by application and group id. |
| 95 | * <p> |
| 96 | * Note that the group concept here is simply a logical grouping of flows. |
| 97 | * This is not the same as a group in the |
| 98 | * {@link org.onosproject.net.group.GroupService}, and this method will not |
| 99 | * return flows that are mapped to a particular {@link org.onosproject.net.group.Group}. |
| 100 | * </p> |
alshabib | aa7e7de | 2014-11-12 19:20:44 -0800 | [diff] [blame] | 101 | * |
Jonathan Hart | 5acc88a | 2016-05-23 10:50:20 -0700 | [diff] [blame] | 102 | * @param appId the application ID to look up |
| 103 | * @param groupId the group ID to look up |
alshabib | aa7e7de | 2014-11-12 19:20:44 -0800 | [diff] [blame] | 104 | * @return collection of flow rules |
| 105 | */ |
| 106 | Iterable<FlowRule> getFlowRulesByGroupId(ApplicationId appId, short groupId); |
| 107 | |
| 108 | /** |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 109 | * Applies a batch operation of FlowRules. |
| 110 | * |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 111 | * @param ops batch operation to apply |
| 112 | */ |
| 113 | void apply(FlowRuleOperations ops); |
| 114 | |
Srikanth Vavilapalli | 95810f5 | 2015-09-14 15:49:56 -0700 | [diff] [blame] | 115 | /** |
| 116 | * Returns the collection of flow table statistics of the specified device. |
| 117 | * |
| 118 | * @param deviceId device identifier |
| 119 | * @return collection of flow table statistics |
| 120 | */ |
| 121 | Iterable<TableStatisticsEntry> getFlowTableStatistics(DeviceId deviceId); |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 122 | } |