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 | |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 6 | /** |
| 7 | * Represents a generalized match & action pair to be applied to |
| 8 | * an infrastucture device. |
| 9 | */ |
| 10 | public interface FlowRule { |
| 11 | |
alshabib | a7f7ca8 | 2014-09-22 11:41:23 -0700 | [diff] [blame] | 12 | |
| 13 | public enum FlowRuleState { |
| 14 | /** |
| 15 | * Indicates that this rule has been created. |
| 16 | */ |
| 17 | CREATED, |
| 18 | |
| 19 | /** |
| 20 | * Indicates that this rule has been submitted for addition. |
| 21 | * Not necessarily in the flow table. |
| 22 | */ |
| 23 | PENDING_ADD, |
| 24 | |
| 25 | /** |
| 26 | * Rule has been added which means it is in the flow table. |
| 27 | */ |
| 28 | ADDED, |
| 29 | |
| 30 | /** |
| 31 | * Flow has been marked for removal, might still be in flow table. |
| 32 | */ |
| 33 | PENDING_REMOVE, |
| 34 | |
| 35 | /** |
| 36 | * Flow has been removed from flow table and can be purged. |
| 37 | */ |
| 38 | REMOVED |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Returns the flow rule state. |
| 43 | * |
| 44 | * @return flow rule state |
| 45 | */ |
| 46 | FlowRuleState state(); |
| 47 | |
alshabib | 369d294 | 2014-09-12 17:59:35 -0700 | [diff] [blame] | 48 | //TODO: build cookie value |
Ayaka Koshibe | d4e53e1 | 2014-09-18 14:24:55 -0700 | [diff] [blame] | 49 | /** |
| 50 | * Returns the ID of this flow. |
| 51 | * |
| 52 | * @return the flow ID |
| 53 | */ |
| 54 | FlowId id(); |
alshabib | 369d294 | 2014-09-12 17:59:35 -0700 | [diff] [blame] | 55 | |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 56 | /** |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 57 | * Returns the application id of this flow. |
| 58 | * |
| 59 | * @return an applicationId |
| 60 | */ |
| 61 | ApplicationId appId(); |
| 62 | |
| 63 | /** |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 64 | * Returns the flow rule priority given in natural order; higher numbers |
| 65 | * mean higher priorities. |
| 66 | * |
| 67 | * @return flow rule priority |
| 68 | */ |
| 69 | int priority(); |
| 70 | |
| 71 | /** |
| 72 | * Returns the identity of the device where this rule applies. |
| 73 | * |
| 74 | * @return device identifier |
| 75 | */ |
| 76 | DeviceId deviceId(); |
| 77 | |
| 78 | /** |
| 79 | * Returns the traffic selector that identifies what traffic this |
| 80 | * rule should apply to. |
| 81 | * |
| 82 | * @return traffic selector |
| 83 | */ |
| 84 | TrafficSelector selector(); |
| 85 | |
| 86 | /** |
| 87 | * Returns the traffic treatment that applies to selected traffic. |
| 88 | * |
| 89 | * @return traffic treatment |
| 90 | */ |
alshabib | 369d294 | 2014-09-12 17:59:35 -0700 | [diff] [blame] | 91 | TrafficTreatment treatment(); |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 92 | |
Ayaka Koshibe | d4e53e1 | 2014-09-18 14:24:55 -0700 | [diff] [blame] | 93 | /** |
| 94 | * Returns the number of milliseconds this flow rule has been applied. |
| 95 | * |
| 96 | * @return number of millis |
| 97 | */ |
| 98 | long lifeMillis(); |
| 99 | |
| 100 | /** |
Ayaka Koshibe | d4e53e1 | 2014-09-18 14:24:55 -0700 | [diff] [blame] | 101 | * Returns the number of packets this flow rule has matched. |
| 102 | * |
| 103 | * @return number of packets |
| 104 | */ |
| 105 | long packets(); |
| 106 | |
| 107 | /** |
| 108 | * Returns the number of bytes this flow rule has matched. |
| 109 | * |
| 110 | * @return number of bytes |
| 111 | */ |
| 112 | long bytes(); |
| 113 | |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 114 | } |