blob: f0d80982eeebd6c441f73a9cbae2907d7f5b2762 [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2014-present Open Networking Laboratory
Thomas Vachuska83e090e2014-10-22 14:25:35 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
Thomas Vachuska83e090e2014-10-22 14:25:35 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
Thomas Vachuska83e090e2014-10-22 14:25:35 -070015 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.flow;
alshabibca5706c2014-10-04 20:29:41 -070017
18
Thiago Santos877914d2016-07-20 18:29:29 -030019import java.util.concurrent.TimeUnit;
20
alshabibca5706c2014-10-04 20:29:41 -070021/**
22 * Represents a generalized match & action pair to be applied to
Yuta HIGUCHI852fecd2016-09-22 18:39:25 -070023 * an infrastructure device.
alshabibca5706c2014-10-04 20:29:41 -070024 */
25public interface FlowEntry extends FlowRule {
26
27
Sho SHIMIZU3310a342015-05-13 12:14:05 -070028 enum FlowEntryState {
alshabibca5706c2014-10-04 20:29:41 -070029
30 /**
31 * Indicates that this rule has been submitted for addition.
Sho SHIMIZU8f86bb22015-05-27 11:29:17 -070032 * Not necessarily in the flow table.
alshabibca5706c2014-10-04 20:29:41 -070033 */
34 PENDING_ADD,
35
36 /**
37 * Rule has been added which means it is in the flow table.
38 */
39 ADDED,
40
41 /**
42 * Flow has been marked for removal, might still be in flow table.
43 */
44 PENDING_REMOVE,
45
46 /**
47 * Flow has been removed from flow table and can be purged.
48 */
alshabib193525b2014-10-08 18:58:03 -070049 REMOVED,
50
51 /**
52 * Indicates that the installation of this flow has failed.
53 */
54 FAILED
alshabibca5706c2014-10-04 20:29:41 -070055 }
56
57 /**
58 * Returns the flow entry state.
59 *
60 * @return flow entry state
61 */
62 FlowEntryState state();
63
64 /**
Thiago Santos877914d2016-07-20 18:29:29 -030065 * Returns the number of seconds this flow rule has been applied.
alshabibca5706c2014-10-04 20:29:41 -070066 *
Thiago Santos877914d2016-07-20 18:29:29 -030067 * @return number of seconds
alshabibca5706c2014-10-04 20:29:41 -070068 */
69 long life();
70
Sangsik Yoonb1b823f2016-05-16 18:55:39 +090071 enum FlowLiveType {
72
73 /**
74 * Indicates that this rule has been submitted for addition immediately.
75 * Not necessarily collecting flow stats.
76 */
77 IMMEDIATE,
78
79 /**
80 * Indicates that this rule has been submitted for a short time.
81 * Collecting flow stats every SHORT interval, defined by the implementation.
82 */
83 SHORT,
84
85 /**
86 * Indicates that this rule has been submitted for a mid time.
87 * Collecting flow stats every MID interval, defined by the implementation.
88 */
89 MID,
90
91 /**
92 * Indicates that this rule has been submitted for a long time.
93 * Collecting flow stats every LONG interval, defined by the implementation.
94 */
95 LONG,
96
97 /**
98 * Indicates that this rule has been submitted for UNKNOWN or ERROR.
99 * Not necessarily collecting flow stats.
100 */
101 UNKNOWN
102 }
103
104 /**
105 * Gets the flow live type for this entry.
106 *
107 * @return flow live type
108 */
109 FlowLiveType liveType();
110
alshabibca5706c2014-10-04 20:29:41 -0700111 /**
Thiago Santos877914d2016-07-20 18:29:29 -0300112 * Returns the time this flow rule has been applied.
113 *
Ray Milkeybb23e0b2016-08-02 17:00:21 -0700114 * @param unit time unit the result will be converted to
Thiago Santos877914d2016-07-20 18:29:29 -0300115 * @return time in the requested {@link TimeUnit}
116 */
117 long life(TimeUnit unit);
118
119 /**
alshabibca5706c2014-10-04 20:29:41 -0700120 * Returns the number of packets this flow rule has matched.
121 *
122 * @return number of packets
123 */
124 long packets();
125
126 /**
127 * Returns the number of bytes this flow rule has matched.
128 *
129 * @return number of bytes
130 */
131 long bytes();
132
Yuta HIGUCHIf6f50a62014-10-19 15:58:49 -0700133 // TODO: consider removing this attribute
alshabibca5706c2014-10-04 20:29:41 -0700134 /**
135 * When this flow entry was last deemed active.
136 * @return epoch time of last activity
137 */
138 long lastSeen();
139
140 /**
alshabib193525b2014-10-08 18:58:03 -0700141 * Indicates the error type.
142 * @return an integer value of the error
143 */
144 int errType();
145
146 /**
147 * Indicates the error code.
148 * @return an integer value of the error
149 */
150 int errCode();
151
alshabibca5706c2014-10-04 20:29:41 -0700152}