blob: d099583dec820bdf25d551c4d38e47bd059cc5c3 [file] [log] [blame]
Carmelo Cascone87b9b392017-10-02 18:33:20 +02001/*
2 * Copyright 2017-present Open Networking Foundation
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.runtime;
18
19import com.google.common.annotations.Beta;
20import org.onosproject.net.flow.FlowRule;
21import org.onosproject.net.group.Group;
22import org.onosproject.net.pi.model.PiPipeconf;
23
24/**
Carmelo Cascone87892e22017-11-13 16:01:29 -080025 * A service to translate protocol-dependent entities to protocol-independent ones.
Carmelo Cascone87b9b392017-10-02 18:33:20 +020026 */
27@Beta
28public interface PiTranslationService {
29
30 /**
31 * Returns a PI table entry equivalent to the given flow rule for the given protocol-independent pipeline
32 * configuration.
33 *
34 * @param rule a flow rule
35 * @param pipeconf a pipeline configuration
36 * @return a table entry
37 * @throws PiTranslationException if the flow rule cannot be translated
38 */
39 PiTableEntry translateFlowRule(FlowRule rule, PiPipeconf pipeconf)
40 throws PiTranslationException;
41
42 /**
43 * Returns a PI action group equivalent to the given group for the given protocol-independent pipeline
44 * configuration.
45 *
46 * @param group a group
47 * @param pipeconf a pipeline configuration
48 * @return a PI action group
49 * @throws PiTranslationException if the group cannot be translated
50 */
51 PiActionGroup translateGroup(Group group, PiPipeconf pipeconf)
52 throws PiTranslationException;
53
54 /**
55 * Signals that an error was encountered while translating an entity.
56 */
57 class PiTranslationException extends Exception {
58
59 /**
60 * Creates a new exception with the given message.
61 *
62 * @param message a message
63 */
64 public PiTranslationException(String message) {
65 super(message);
66 }
67 }
68}