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