Jian Li | 38e4d94 | 2018-07-03 22:19:16 +0900 | [diff] [blame] | 1 | /* |
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 | */ | ||||
16 | package org.onosproject.openstackvtap.api; | ||||
17 | |||||
18 | import org.onosproject.net.Annotated; | ||||
19 | import org.onosproject.net.DeviceId; | ||||
20 | import org.onosproject.net.SparseAnnotations; | ||||
21 | |||||
22 | import java.util.Set; | ||||
23 | |||||
24 | /** | ||||
Jimo Jung | 14e87bf | 2018-09-03 16:28:13 +0900 | [diff] [blame] | 25 | * Abstraction of an openstack vtap. |
Jian Li | 38e4d94 | 2018-07-03 22:19:16 +0900 | [diff] [blame] | 26 | */ |
27 | public interface OpenstackVtap extends Annotated { | ||||
28 | |||||
29 | /** | ||||
Jimo Jung | 14e87bf | 2018-09-03 16:28:13 +0900 | [diff] [blame] | 30 | * List of openstack vtap types. |
Jian Li | 38e4d94 | 2018-07-03 22:19:16 +0900 | [diff] [blame] | 31 | */ |
32 | enum Type { | ||||
Jian Li | 38e4d94 | 2018-07-03 22:19:16 +0900 | [diff] [blame] | 33 | /** |
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 Jung | 14e87bf | 2018-09-03 16:28:13 +0900 | [diff] [blame] | 49 | * Indicates selection of mirroring any traffic. |
Jian Li | 38e4d94 | 2018-07-03 22:19:16 +0900 | [diff] [blame] | 50 | */ |
Jimo Jung | 14e87bf | 2018-09-03 16:28:13 +0900 | [diff] [blame] | 51 | VTAP_ANY(0x0); |
Jian Li | 38e4d94 | 2018-07-03 22:19:16 +0900 | [diff] [blame] | 52 | |
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 Jung | 14e87bf | 2018-09-03 16:28:13 +0900 | [diff] [blame] | 65 | * Returns the openstack vtap identifier. |
Jian Li | 38e4d94 | 2018-07-03 22:19:16 +0900 | [diff] [blame] | 66 | * |
Jimo Jung | 14e87bf | 2018-09-03 16:28:13 +0900 | [diff] [blame] | 67 | * @return vtap ID |
Jian Li | 38e4d94 | 2018-07-03 22:19:16 +0900 | [diff] [blame] | 68 | */ |
69 | OpenstackVtapId id(); | ||||
70 | |||||
71 | /** | ||||
Jimo Jung | 14e87bf | 2018-09-03 16:28:13 +0900 | [diff] [blame] | 72 | * Returns the openstack vtap type. |
Jian Li | 38e4d94 | 2018-07-03 22:19:16 +0900 | [diff] [blame] | 73 | * |
Jimo Jung | 14e87bf | 2018-09-03 16:28:13 +0900 | [diff] [blame] | 74 | * @return type of vtap |
Jian Li | 38e4d94 | 2018-07-03 22:19:16 +0900 | [diff] [blame] | 75 | */ |
76 | Type type(); | ||||
77 | |||||
78 | /** | ||||
Jimo Jung | 14e87bf | 2018-09-03 16:28:13 +0900 | [diff] [blame] | 79 | * Returns the openstack vtap criterion. |
Jian Li | 38e4d94 | 2018-07-03 22:19:16 +0900 | [diff] [blame] | 80 | * |
Jimo Jung | 14e87bf | 2018-09-03 16:28:13 +0900 | [diff] [blame] | 81 | * @return criterion of vtap |
Jian Li | 38e4d94 | 2018-07-03 22:19:16 +0900 | [diff] [blame] | 82 | */ |
Jimo Jung | 14e87bf | 2018-09-03 16:28:13 +0900 | [diff] [blame] | 83 | OpenstackVtapCriterion vtapCriterion(); |
Jian Li | 38e4d94 | 2018-07-03 22:19:16 +0900 | [diff] [blame] | 84 | |
85 | /** | ||||
Jimo Jung | 14e87bf | 2018-09-03 16:28:13 +0900 | [diff] [blame] | 86 | * Returns a collection of device identifiers for tx. |
Jian Li | 38e4d94 | 2018-07-03 22:19:16 +0900 | [diff] [blame] | 87 | * |
Jimo Jung | 14e87bf | 2018-09-03 16:28:13 +0900 | [diff] [blame] | 88 | * @return device identifiers for tx |
Jian Li | 38e4d94 | 2018-07-03 22:19:16 +0900 | [diff] [blame] | 89 | */ |
90 | Set<DeviceId> txDeviceIds(); | ||||
91 | |||||
92 | /** | ||||
Jimo Jung | 14e87bf | 2018-09-03 16:28:13 +0900 | [diff] [blame] | 93 | * Returns a collection of device identifiers for rx. |
Jian Li | 38e4d94 | 2018-07-03 22:19:16 +0900 | [diff] [blame] | 94 | * |
Jimo Jung | 14e87bf | 2018-09-03 16:28:13 +0900 | [diff] [blame] | 95 | * @return device identifiers for rx |
Jian Li | 38e4d94 | 2018-07-03 22:19:16 +0900 | [diff] [blame] | 96 | */ |
97 | Set<DeviceId> rxDeviceIds(); | ||||
98 | |||||
99 | /** | ||||
Jimo Jung | 14e87bf | 2018-09-03 16:28:13 +0900 | [diff] [blame] | 100 | * Builder of new openstack vtap instance. |
Jian Li | 38e4d94 | 2018-07-03 22:19:16 +0900 | [diff] [blame] | 101 | */ |
102 | interface Builder { | ||||
Jian Li | 38e4d94 | 2018-07-03 22:19:16 +0900 | [diff] [blame] | 103 | /** |
Jimo Jung | 14e87bf | 2018-09-03 16:28:13 +0900 | [diff] [blame] | 104 | * Returns openstack vtap builder with supplied id. |
Jian Li | 38e4d94 | 2018-07-03 22:19:16 +0900 | [diff] [blame] | 105 | * |
Jimo Jung | 14e87bf | 2018-09-03 16:28:13 +0900 | [diff] [blame] | 106 | * @param id openstack vtap id |
107 | * @return openstack vtap builder | ||||
Jian Li | 38e4d94 | 2018-07-03 22:19:16 +0900 | [diff] [blame] | 108 | */ |
109 | Builder id(OpenstackVtapId id); | ||||
110 | |||||
111 | /** | ||||
Jimo Jung | 14e87bf | 2018-09-03 16:28:13 +0900 | [diff] [blame] | 112 | * Returns openstack vtap builder with supplied type. |
Jian Li | 38e4d94 | 2018-07-03 22:19:16 +0900 | [diff] [blame] | 113 | * |
Jimo Jung | 14e87bf | 2018-09-03 16:28:13 +0900 | [diff] [blame] | 114 | * @param type of the vtap |
115 | * @return openstack vtap builder | ||||
Jian Li | 38e4d94 | 2018-07-03 22:19:16 +0900 | [diff] [blame] | 116 | */ |
117 | Builder type(OpenstackVtap.Type type); | ||||
118 | |||||
119 | /** | ||||
Jimo Jung | 14e87bf | 2018-09-03 16:28:13 +0900 | [diff] [blame] | 120 | * Returns openstack vtap builder with supplied criterion. |
Jian Li | 38e4d94 | 2018-07-03 22:19:16 +0900 | [diff] [blame] | 121 | * |
Jimo Jung | 14e87bf | 2018-09-03 16:28:13 +0900 | [diff] [blame] | 122 | * @param vtapCriterion for the vtap |
123 | * @return openstack vtap builder | ||||
Jian Li | 38e4d94 | 2018-07-03 22:19:16 +0900 | [diff] [blame] | 124 | */ |
Jimo Jung | 14e87bf | 2018-09-03 16:28:13 +0900 | [diff] [blame] | 125 | Builder vtapCriterion(OpenstackVtapCriterion vtapCriterion); |
Jian Li | 38e4d94 | 2018-07-03 22:19:16 +0900 | [diff] [blame] | 126 | |
127 | /** | ||||
Jimo Jung | 14e87bf | 2018-09-03 16:28:13 +0900 | [diff] [blame] | 128 | * Returns openstack vtap builder with supplied tx deviceId set. |
Jian Li | 38e4d94 | 2018-07-03 22:19:16 +0900 | [diff] [blame] | 129 | * |
Jimo Jung | 14e87bf | 2018-09-03 16:28:13 +0900 | [diff] [blame] | 130 | * @param txDeviceIds deviceId set for tx |
131 | * @return openstack vtap builder | ||||
Jian Li | 38e4d94 | 2018-07-03 22:19:16 +0900 | [diff] [blame] | 132 | */ |
133 | Builder txDeviceIds(Set<DeviceId> txDeviceIds); | ||||
134 | |||||
135 | /** | ||||
Jimo Jung | 14e87bf | 2018-09-03 16:28:13 +0900 | [diff] [blame] | 136 | * Returns openstack vtap builder with supplied rx deviceId set. |
Jian Li | 38e4d94 | 2018-07-03 22:19:16 +0900 | [diff] [blame] | 137 | * |
Jimo Jung | 14e87bf | 2018-09-03 16:28:13 +0900 | [diff] [blame] | 138 | * @param rxDeviceIds deviceId set for rx |
139 | * @return openstack vtap builder | ||||
Jian Li | 38e4d94 | 2018-07-03 22:19:16 +0900 | [diff] [blame] | 140 | */ |
141 | Builder rxDeviceIds(Set<DeviceId> rxDeviceIds); | ||||
142 | |||||
143 | /** | ||||
Jimo Jung | 14e87bf | 2018-09-03 16:28:13 +0900 | [diff] [blame] | 144 | * Returns openstack vtap builder with supplied annotations. |
Jian Li | 38e4d94 | 2018-07-03 22:19:16 +0900 | [diff] [blame] | 145 | * |
146 | * @param annotations a set of annotations | ||||
Jimo Jung | 14e87bf | 2018-09-03 16:28:13 +0900 | [diff] [blame] | 147 | * @return openstack vtap builder |
Jian Li | 38e4d94 | 2018-07-03 22:19:16 +0900 | [diff] [blame] | 148 | */ |
Jimo Jung | 14e87bf | 2018-09-03 16:28:13 +0900 | [diff] [blame] | 149 | Builder annotations(SparseAnnotations annotations); |
Jian Li | 38e4d94 | 2018-07-03 22:19:16 +0900 | [diff] [blame] | 150 | |
151 | /** | ||||
Jimo Jung | 14e87bf | 2018-09-03 16:28:13 +0900 | [diff] [blame] | 152 | * Builds an immutable OpenstackVtap instance. |
Jian Li | 38e4d94 | 2018-07-03 22:19:16 +0900 | [diff] [blame] | 153 | * |
Jimo Jung | 14e87bf | 2018-09-03 16:28:13 +0900 | [diff] [blame] | 154 | * @return openstack vtap instance |
Jian Li | 38e4d94 | 2018-07-03 22:19:16 +0900 | [diff] [blame] | 155 | */ |
156 | OpenstackVtap build(); | ||||
157 | } | ||||
158 | } |