blob: 210b7e098fa879bc621db51dfccca7a53b11f8e2 [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
Carmelo Cascone39c28ca2017-11-15 13:03:57 -080017package org.onosproject.net.pi.service;
Carmelo Cascone87b9b392017-10-02 18:33:20 +020018
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;
Carmelo Cascone39c28ca2017-11-15 13:03:57 -080023import org.onosproject.net.pi.runtime.PiActionGroup;
24import org.onosproject.net.pi.runtime.PiTableEntry;
Carmelo Cascone87b9b392017-10-02 18:33:20 +020025
26/**
Carmelo Cascone87892e22017-11-13 16:01:29 -080027 * A service to translate protocol-dependent entities to protocol-independent ones.
Carmelo Cascone87b9b392017-10-02 18:33:20 +020028 */
29@Beta
30public interface PiTranslationService {
31
32 /**
33 * Returns a PI table entry equivalent to the given flow rule for the given protocol-independent pipeline
34 * configuration.
35 *
36 * @param rule a flow rule
37 * @param pipeconf a pipeline configuration
38 * @return a table entry
39 * @throws PiTranslationException if the flow rule cannot be translated
40 */
41 PiTableEntry translateFlowRule(FlowRule rule, PiPipeconf pipeconf)
42 throws PiTranslationException;
43
44 /**
45 * Returns a PI action group equivalent to the given group for the given protocol-independent pipeline
46 * configuration.
47 *
48 * @param group a group
49 * @param pipeconf a pipeline configuration
50 * @return a PI action group
51 * @throws PiTranslationException if the group cannot be translated
52 */
53 PiActionGroup translateGroup(Group group, PiPipeconf pipeconf)
54 throws PiTranslationException;
55
56 /**
57 * Signals that an error was encountered while translating an entity.
58 */
59 class PiTranslationException extends Exception {
60
61 /**
62 * Creates a new exception with the given message.
63 *
64 * @param message a message
65 */
66 public PiTranslationException(String message) {
67 super(message);
68 }
69 }
70}