blob: b1d73a7c71cf019a6e7e1d6b50f2c994dcafc116 [file] [log] [blame]
alshabibfaa1e362015-04-02 15:01:54 -07001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
4 * 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
7 *
8 * 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.
15 */
16package org.onosproject.net.flowobjective;
17
Thomas Vachuskaa9d491e2015-05-20 11:17:21 -070018import com.google.common.annotations.Beta;
alshabibfaa1e362015-04-02 15:01:54 -070019import org.onosproject.core.ApplicationId;
20
alshabib2a441c62015-04-13 18:39:38 -070021import java.util.Optional;
22
alshabibfaa1e362015-04-02 15:01:54 -070023/**
Saurav Das8a0732e2015-11-20 15:27:53 -080024 * Base representation of a flow-objective description.
alshabibfaa1e362015-04-02 15:01:54 -070025 */
Thomas Vachuskaa9d491e2015-05-20 11:17:21 -070026@Beta
alshabibfaa1e362015-04-02 15:01:54 -070027public interface Objective {
28
Sho SHIMIZUe2952e42015-09-11 17:11:21 -070029 boolean DEFAULT_PERMANENT = true;
30 int DEFAULT_TIMEOUT = 0;
31 int DEFAULT_PRIORITY = 32768;
alshabibfaa1e362015-04-02 15:01:54 -070032
33 /**
34 * Type of operation.
35 */
36 enum Operation {
37 /**
Saurav Das8a0732e2015-11-20 15:27:53 -080038 * Adds the objective. Can be used for any flow objective. For forwarding
39 * and filtering objectives, existing objectives with identical selector
40 * and priority fields (but different treatments or next) will be replaced.
41 * For next objectives, if modification is desired, ADD will not
42 * do anything - use ADD_TO_EXISTING.
alshabibfaa1e362015-04-02 15:01:54 -070043 */
44 ADD,
45
46 /**
Saurav Das8a0732e2015-11-20 15:27:53 -080047 * Removes the objective. Can be used for any flow objective.
alshabibfaa1e362015-04-02 15:01:54 -070048 */
Saurav Das8a0732e2015-11-20 15:27:53 -080049 REMOVE,
50
51 /**
52 * Add to an existing Next Objective. Should not be used for any other
53 * objective.
54 */
55 ADD_TO_EXISTING,
56
57 /**
58 * Remove from an existing Next Objective. Should not be used for any
59 * other objective.
60 */
61 REMOVE_FROM_EXISTING
alshabibfaa1e362015-04-02 15:01:54 -070062 }
63
64 /**
65 * An identifier for this objective.
66 *
67 * @return an integer
68 */
69 int id();
70
71 /**
72 * The priority for this objective.
73 *
74 * @return an integer
75 */
76 int priority();
77
78 /**
79 * The application which applied this objective.
80 *
81 * @return an application id
82 */
83 ApplicationId appId();
84
85 /**
86 * The timeout for this objective.
87 *
88 * @return an integer
89 */
90 int timeout();
91
92 /**
93 * Whether this objective is permanent.
94 *
95 * @return a boolean
96 */
97 boolean permanent();
98
99 /**
100 * The type of operation for this objective.
101 *
102 * @return an operation
103 */
104 Operation op();
105
106 /**
alshabib2a441c62015-04-13 18:39:38 -0700107 * Obtains an optional context.
108 *
109 * @return optional; which will be empty if there is no context.
110 * Otherwise it will return the context.
111 */
112 Optional<ObjectiveContext> context();
113
114 /**
alshabibfaa1e362015-04-02 15:01:54 -0700115 * An objective builder.
116 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700117 interface Builder {
alshabibfaa1e362015-04-02 15:01:54 -0700118 /**
119 * Makes the filtering objective temporary.
120 *
121 * @param timeout a timeout
122 * @return an objective builder
123 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700124 Builder makeTemporary(int timeout);
alshabibfaa1e362015-04-02 15:01:54 -0700125
126 /**
127 * Makes the filtering objective permanent.
128 *
129 * @return an objective builder
130 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700131 Builder makePermanent();
alshabibfaa1e362015-04-02 15:01:54 -0700132
133 /**
134 * Specifies the application which applied the filter.
135 *
136 * @param appId an application id
137 * @return an objective builder
138 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700139 Builder fromApp(ApplicationId appId);
alshabibfaa1e362015-04-02 15:01:54 -0700140
141 /**
142 * Sets the priority for this objective.
143 *
144 * @param priority an integer
145 * @return an objective builder
146 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700147 Builder withPriority(int priority);
Saurav Das8a0732e2015-11-20 15:27:53 -0800148
alshabibfaa1e362015-04-02 15:01:54 -0700149 }
150
151}