blob: 8600c5440ce067635d96f5369c99207cae286311 [file] [log] [blame]
tom8bb16062014-09-12 14:47:46 -07001package org.onlab.onos.net.flow;
2
alshabiba68eb962014-09-24 20:34:13 -07003import org.onlab.onos.ApplicationId;
tom8bb16062014-09-12 14:47:46 -07004import org.onlab.onos.net.DeviceId;
5
6/**
7 * Service for injecting flow rules into the environment and for obtaining
tom4d0c6632014-09-15 23:27:01 -07008 * 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.
tom8bb16062014-09-12 14:47:46 -070012 */
13public interface FlowRuleService {
14
15 /**
tom9b4030d2014-10-06 10:39:03 -070016 * Returns the number of flow rules in the system.
17 *
18 * @return flow rule count
19 */
20 int getFlowRuleCount();
21
22 /**
tom8bb16062014-09-12 14:47:46 -070023 * Returns the collection of flow entries applied on the specified device.
tom4d0c6632014-09-15 23:27:01 -070024 * This will include flow rules which may not yet have been applied to
25 * the device.
tom8bb16062014-09-12 14:47:46 -070026 *
27 * @param deviceId device identifier
28 * @return collection of flow rules
29 */
alshabib1c319ff2014-10-04 20:29:09 -070030 Iterable<FlowEntry> getFlowEntries(DeviceId deviceId);
tom8bb16062014-09-12 14:47:46 -070031
tom73d6d1e2014-09-17 20:08:01 -070032 // TODO: add createFlowRule factory method and execute operations method
33
tom8bb16062014-09-12 14:47:46 -070034 /**
tom4d0c6632014-09-15 23:27:01 -070035 * 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.
tom8bb16062014-09-12 14:47:46 -070038 *
39 * @param flowRules one or more flow rules
tom8bb16062014-09-12 14:47:46 -070040 */
alshabib219ebaa2014-09-22 15:41:24 -070041 void applyFlowRules(FlowRule... flowRules);
tom8bb16062014-09-12 14:47:46 -070042
43 /**
tom4d0c6632014-09-15 23:27:01 -070044 * 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.
alshabib369d2942014-09-12 17:59:35 -070047 *
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
alshabiba68eb962014-09-24 20:34:13 -070054 /**
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);
tom4d0c6632014-09-15 23:27:01 -070068
alshabib58747a62014-10-07 11:05:30 -070069 //Future<CompletedBatchOperation> applyBatch(BatchOperation<FlowRuleBatchEntry>)
70
alshabib369d2942014-09-12 17:59:35 -070071 /**
tom8bb16062014-09-12 14:47:46 -070072 * Adds the specified flow rule listener.
73 *
74 * @param listener flow rule listener
75 */
76 void addListener(FlowRuleListener listener);
77
78 /**
79 * Removes the specified flow rule listener.
80 *
81 * @param listener flow rule listener
82 */
83 void removeListener(FlowRuleListener listener);
tom8bb16062014-09-12 14:47:46 -070084}