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