blob: ad189e2f582b565dc1e25b73b902d2168539b94e [file] [log] [blame]
Jian Li38e4d942018-07-03 22:19:16 +09001/*
2 * Copyright 2018-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 */
16package org.onosproject.openstackvtap.api;
17
18import org.onosproject.net.Annotated;
19import org.onosproject.net.DeviceId;
20import org.onosproject.net.SparseAnnotations;
21
22import java.util.Set;
23
24/**
Jimo Jung14e87bf2018-09-03 16:28:13 +090025 * Abstraction of an openstack vtap.
Jian Li38e4d942018-07-03 22:19:16 +090026 */
27public interface OpenstackVtap extends Annotated {
28
29 /**
Jimo Jung14e87bf2018-09-03 16:28:13 +090030 * List of openstack vtap types.
Jian Li38e4d942018-07-03 22:19:16 +090031 */
32 enum Type {
Jian Li38e4d942018-07-03 22:19:16 +090033 /**
34 * Indicates mirroring both TX and RX traffic.
35 */
36 VTAP_ALL(0x3),
37
38 /**
39 * Indicates only mirroring RX traffic.
40 */
41 VTAP_RX(0x2),
42
43 /**
44 * Indicates only mirroring TX traffic.
45 */
46 VTAP_TX(0x1),
47
48 /**
Jimo Jung14e87bf2018-09-03 16:28:13 +090049 * Indicates selection of mirroring any traffic.
Jian Li38e4d942018-07-03 22:19:16 +090050 */
Jimo Jung14e87bf2018-09-03 16:28:13 +090051 VTAP_ANY(0x0);
Jian Li38e4d942018-07-03 22:19:16 +090052
53 private final int type;
54
55 Type(int type) {
56 this.type = type;
57 }
58
59 public boolean isValid(Type comp) {
60 return (this.type & comp.type) == comp.type;
61 }
62 }
63
64 /**
Jimo Jung14e87bf2018-09-03 16:28:13 +090065 * Returns the openstack vtap identifier.
Jian Li38e4d942018-07-03 22:19:16 +090066 *
Jimo Jung14e87bf2018-09-03 16:28:13 +090067 * @return vtap ID
Jian Li38e4d942018-07-03 22:19:16 +090068 */
69 OpenstackVtapId id();
70
71 /**
Jimo Jung14e87bf2018-09-03 16:28:13 +090072 * Returns the openstack vtap type.
Jian Li38e4d942018-07-03 22:19:16 +090073 *
Jimo Jung14e87bf2018-09-03 16:28:13 +090074 * @return type of vtap
Jian Li38e4d942018-07-03 22:19:16 +090075 */
76 Type type();
77
78 /**
Jimo Jung14e87bf2018-09-03 16:28:13 +090079 * Returns the openstack vtap criterion.
Jian Li38e4d942018-07-03 22:19:16 +090080 *
Jimo Jung14e87bf2018-09-03 16:28:13 +090081 * @return criterion of vtap
Jian Li38e4d942018-07-03 22:19:16 +090082 */
Jimo Jung14e87bf2018-09-03 16:28:13 +090083 OpenstackVtapCriterion vtapCriterion();
Jian Li38e4d942018-07-03 22:19:16 +090084
85 /**
Jimo Jung14e87bf2018-09-03 16:28:13 +090086 * Returns a collection of device identifiers for tx.
Jian Li38e4d942018-07-03 22:19:16 +090087 *
Jimo Jung14e87bf2018-09-03 16:28:13 +090088 * @return device identifiers for tx
Jian Li38e4d942018-07-03 22:19:16 +090089 */
90 Set<DeviceId> txDeviceIds();
91
92 /**
Jimo Jung14e87bf2018-09-03 16:28:13 +090093 * Returns a collection of device identifiers for rx.
Jian Li38e4d942018-07-03 22:19:16 +090094 *
Jimo Jung14e87bf2018-09-03 16:28:13 +090095 * @return device identifiers for rx
Jian Li38e4d942018-07-03 22:19:16 +090096 */
97 Set<DeviceId> rxDeviceIds();
98
99 /**
Jimo Jung14e87bf2018-09-03 16:28:13 +0900100 * Builder of new openstack vtap instance.
Jian Li38e4d942018-07-03 22:19:16 +0900101 */
102 interface Builder {
Jian Li38e4d942018-07-03 22:19:16 +0900103 /**
Jimo Jung14e87bf2018-09-03 16:28:13 +0900104 * Returns openstack vtap builder with supplied id.
Jian Li38e4d942018-07-03 22:19:16 +0900105 *
Jimo Jung14e87bf2018-09-03 16:28:13 +0900106 * @param id openstack vtap id
107 * @return openstack vtap builder
Jian Li38e4d942018-07-03 22:19:16 +0900108 */
109 Builder id(OpenstackVtapId id);
110
111 /**
Jimo Jung14e87bf2018-09-03 16:28:13 +0900112 * Returns openstack vtap builder with supplied type.
Jian Li38e4d942018-07-03 22:19:16 +0900113 *
Jimo Jung14e87bf2018-09-03 16:28:13 +0900114 * @param type of the vtap
115 * @return openstack vtap builder
Jian Li38e4d942018-07-03 22:19:16 +0900116 */
117 Builder type(OpenstackVtap.Type type);
118
119 /**
Jimo Jung14e87bf2018-09-03 16:28:13 +0900120 * Returns openstack vtap builder with supplied criterion.
Jian Li38e4d942018-07-03 22:19:16 +0900121 *
Jimo Jung14e87bf2018-09-03 16:28:13 +0900122 * @param vtapCriterion for the vtap
123 * @return openstack vtap builder
Jian Li38e4d942018-07-03 22:19:16 +0900124 */
Jimo Jung14e87bf2018-09-03 16:28:13 +0900125 Builder vtapCriterion(OpenstackVtapCriterion vtapCriterion);
Jian Li38e4d942018-07-03 22:19:16 +0900126
127 /**
Jimo Jung14e87bf2018-09-03 16:28:13 +0900128 * Returns openstack vtap builder with supplied tx deviceId set.
Jian Li38e4d942018-07-03 22:19:16 +0900129 *
Jimo Jung14e87bf2018-09-03 16:28:13 +0900130 * @param txDeviceIds deviceId set for tx
131 * @return openstack vtap builder
Jian Li38e4d942018-07-03 22:19:16 +0900132 */
133 Builder txDeviceIds(Set<DeviceId> txDeviceIds);
134
135 /**
Jimo Jung14e87bf2018-09-03 16:28:13 +0900136 * Returns openstack vtap builder with supplied rx deviceId set.
Jian Li38e4d942018-07-03 22:19:16 +0900137 *
Jimo Jung14e87bf2018-09-03 16:28:13 +0900138 * @param rxDeviceIds deviceId set for rx
139 * @return openstack vtap builder
Jian Li38e4d942018-07-03 22:19:16 +0900140 */
141 Builder rxDeviceIds(Set<DeviceId> rxDeviceIds);
142
143 /**
Jimo Jung14e87bf2018-09-03 16:28:13 +0900144 * Returns openstack vtap builder with supplied annotations.
Jian Li38e4d942018-07-03 22:19:16 +0900145 *
146 * @param annotations a set of annotations
Jimo Jung14e87bf2018-09-03 16:28:13 +0900147 * @return openstack vtap builder
Jian Li38e4d942018-07-03 22:19:16 +0900148 */
Jimo Jung14e87bf2018-09-03 16:28:13 +0900149 Builder annotations(SparseAnnotations annotations);
Jian Li38e4d942018-07-03 22:19:16 +0900150
151 /**
Jimo Jung14e87bf2018-09-03 16:28:13 +0900152 * Builds an immutable OpenstackVtap instance.
Jian Li38e4d942018-07-03 22:19:16 +0900153 *
Jimo Jung14e87bf2018-09-03 16:28:13 +0900154 * @return openstack vtap instance
Jian Li38e4d942018-07-03 22:19:16 +0900155 */
156 OpenstackVtap build();
157 }
158}