blob: 8d44494bc2f20b99b3fcbf98630b7f1e9fbbfd0a [file] [log] [blame]
Carmelo Cascone17fc9e42016-05-31 11:29:21 -07001/*
2 * Copyright 2016-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.bmv2.api.context;
18
19import com.google.common.annotations.Beta;
20import com.google.common.collect.ImmutableBiMap;
21import org.onosproject.bmv2.api.runtime.Bmv2Action;
22import org.onosproject.net.flow.TrafficTreatment;
23import org.onosproject.net.flow.criteria.Criterion;
24
25/**
26 * A BMv2 configuration interpreter.
27 */
28@Beta
29public interface Bmv2Interpreter {
30
31 /**
32 * Returns a bi-map describing a one-to-one relationship between ONOS flow rule table IDs and BMv2 table names.
33 *
34 * @return a {@link com.google.common.collect.BiMap} where the key is a ONOS flow rule table id and
35 * the value is a BMv2 table names
36 */
37 ImmutableBiMap<Integer, String> tableIdMap();
38
39 /**
40 * Returns a bi-map describing a one-to-one relationship between ONOS criterion types and BMv2 header field names.
41 * Header field names are formatted using the notation {@code header_name.field_member_name}.
42 *
43 * @return a {@link com.google.common.collect.BiMap} where the keys are ONOS criterion types and the values are
44 * BMv2 header field names
45 */
46 ImmutableBiMap<Criterion.Type, String> criterionTypeMap();
47
48 /**
49 * Return a BMv2 action that is functionally equivalent to the given ONOS traffic treatment for the given
50 * configuration.
51 *
52 * @param treatment a ONOS traffic treatment
53 * @param configuration a BMv2 configuration
54 * @return a BMv2 action object
55 * @throws Bmv2InterpreterException if the treatment cannot be mapped to any BMv2 action
56 */
57 Bmv2Action mapTreatment(TrafficTreatment treatment, Bmv2Configuration configuration)
58 throws Bmv2InterpreterException;
59
60}