blob: 443c15bfbc09cc1bd2eb082c7932c0b4714c8bf7 [file] [log] [blame]
Carmelo Cascone1022a4e2017-05-25 00:16:18 -04001/*
2 * Copyright 2017-present 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 */
16
17package org.onosproject.net.pi.model;
18
19import com.google.common.annotations.Beta;
20import org.onosproject.net.driver.HandlerBehaviour;
21import org.onosproject.net.flow.TrafficTreatment;
22import org.onosproject.net.flow.criteria.Criterion;
23import org.onosproject.net.pi.runtime.PiHeaderFieldId;
24import org.onosproject.net.pi.runtime.PiTableAction;
25
26import java.util.Optional;
27
28/**
29 * An interpreter of a protocol-independent pipeline.
30 */
31@Beta
32public interface PiPipelineInterpreter extends HandlerBehaviour {
33
34 /**
35 * Returns the protocol-independent header field identifier that is equivalent to the given
36 * criterion type, if present. If not present, it means that the given criterion type is not
37 * supported by this interpreter.
38 *
39 * @param type criterion type
40 * @return optional header field identifier
41 */
42 Optional<PiHeaderFieldId> mapCriterionType(Criterion.Type type);
43
44 /**
45 * Returns the criterion type that is equivalent to the given protocol-independent header field
46 * identifier, if present. If not present, it means that the given field identifier is not
47 * supported by this interpreter.
48 *
49 * @param headerFieldId header field identifier
50 * @return optional criterion type
51 */
52 Optional<Criterion.Type> mapPiHeaderFieldId(PiHeaderFieldId headerFieldId);
53
54 /**
55 * Returns a table action of a protocol-independent pipeline that is functionally equivalent to
56 * the given ONOS traffic treatment for the given pipeline configuration.
57 *
58 * @param treatment a ONOS traffic treatment
59 * @param pipeconf a pipeline configuration
60 * @return a table action object
61 * @throws PiInterpreterException if the treatment cannot be mapped to any table action
62 */
63 PiTableAction mapTreatment(TrafficTreatment treatment, PiPipeconf pipeconf)
64 throws PiInterpreterException;
65
66 /**
67 * Signals that an error was encountered while executing the interpreter.
68 */
69 @Beta
70 class PiInterpreterException extends Exception {
71 public PiInterpreterException(String message) {
72 super(message);
73 }
74 }
75}