blob: 415264ec48e2ee6b60421874aeb3fed8c58d1081 [file] [log] [blame]
alshabib77b88482015-04-07 15:47:50 -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;
alshabib77b88482015-04-07 15:47:50 -070019import org.onosproject.net.DeviceId;
20
alshabib77b88482015-04-07 15:47:50 -070021/**
Thomas Vachuskaca88bb72015-04-08 19:38:02 -070022 * Service for programming data plane flow rules in manner independent of
23 * specific device table pipeline configuration.
alshabib77b88482015-04-07 15:47:50 -070024 */
Thomas Vachuskaa9d491e2015-05-20 11:17:21 -070025@Beta
alshabib77b88482015-04-07 15:47:50 -070026public interface FlowObjectiveService {
27
Thomas Vachuskaca88bb72015-04-08 19:38:02 -070028 /**
29 * Installs the filtering rules onto the specified device.
30 *
Thomas Vachuska00f48162016-02-29 17:07:23 -080031 * @param deviceId device identifier
alshabib2a441c62015-04-13 18:39:38 -070032 * @param filteringObjective the filtering objective
Thomas Vachuskaca88bb72015-04-08 19:38:02 -070033 */
alshabib2a441c62015-04-13 18:39:38 -070034 void filter(DeviceId deviceId, FilteringObjective filteringObjective);
alshabib77b88482015-04-07 15:47:50 -070035
Thomas Vachuskaca88bb72015-04-08 19:38:02 -070036 /**
37 * Installs the forwarding rules onto the specified device.
38 *
Thomas Vachuska00f48162016-02-29 17:07:23 -080039 * @param deviceId device identifier
alshabib2a441c62015-04-13 18:39:38 -070040 * @param forwardingObjective the forwarding objective
Thomas Vachuskaca88bb72015-04-08 19:38:02 -070041 */
alshabib2a441c62015-04-13 18:39:38 -070042 void forward(DeviceId deviceId, ForwardingObjective forwardingObjective);
alshabib77b88482015-04-07 15:47:50 -070043
Thomas Vachuskaca88bb72015-04-08 19:38:02 -070044 /**
45 * Installs the next hop elements into the specified device.
46 *
Thomas Vachuska00f48162016-02-29 17:07:23 -080047 * @param deviceId device identifier
alshabib2a441c62015-04-13 18:39:38 -070048 * @param nextObjective a next objective
Thomas Vachuskaca88bb72015-04-08 19:38:02 -070049 */
alshabib2a441c62015-04-13 18:39:38 -070050 void next(DeviceId deviceId, NextObjective nextObjective);
alshabib77b88482015-04-07 15:47:50 -070051
alshabibf6ea9e62015-04-21 17:08:26 -070052 /**
53 * Obtains a globally unique next objective.
Sho SHIMIZU23aa2e72015-07-01 09:48:40 -070054 *
alshabibf6ea9e62015-04-21 17:08:26 -070055 * @return an integer
56 */
57 int allocateNextId();
58
Xin Jin313708b2015-07-09 13:43:04 -070059 /**
Brian O'Connor3ac85262016-02-29 20:26:23 -080060 * Provides a composition policy expression.
61 * <p>
62 * WARNING: This method is a no-op in the default implementation.
Xin Jin313708b2015-07-09 13:43:04 -070063 *
Thomas Vachuska00f48162016-02-29 17:07:23 -080064 * @param policy policy expression
Xin Jin313708b2015-07-09 13:43:04 -070065 */
66 void initPolicy(String policy);
Thomas Vachuska00f48162016-02-29 17:07:23 -080067
68 /**
69 * Installs the objective onto the specified device.
70 *
71 * @param deviceId device identifier
72 * @param objective the objective
73 */
74 default void apply(DeviceId deviceId, Objective objective) {
75 if (ForwardingObjective.class.isAssignableFrom(objective.getClass())) {
76 forward(deviceId, (ForwardingObjective) objective);
77 } else if (FilteringObjective.class.isAssignableFrom(objective.getClass())) {
78 filter(deviceId, (FilteringObjective) objective);
79 } else if (NextObjective.class.isAssignableFrom(objective.getClass())) {
80 next(deviceId, (NextObjective) objective);
81 } else {
82 throw new UnsupportedOperationException("Unsupported objective of type " + objective.getClass());
83 }
84 }
alshabib77b88482015-04-07 15:47:50 -070085}