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