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 | /** |
| 25 | * Abstraction of an OpenstackVtap. |
| 26 | */ |
| 27 | public interface OpenstackVtap extends Annotated { |
| 28 | |
| 29 | /** |
| 30 | * Openstack vTap type. |
| 31 | */ |
| 32 | enum Type { |
| 33 | |
| 34 | /** |
| 35 | * Indicates mirroring both TX and RX traffic. |
| 36 | */ |
| 37 | VTAP_ALL(0x3), |
| 38 | |
| 39 | /** |
| 40 | * Indicates only mirroring RX traffic. |
| 41 | */ |
| 42 | VTAP_RX(0x2), |
| 43 | |
| 44 | /** |
| 45 | * Indicates only mirroring TX traffic. |
| 46 | */ |
| 47 | VTAP_TX(0x1), |
| 48 | |
| 49 | /** |
| 50 | * Indicates do not mirroring any traffic. |
| 51 | */ |
| 52 | VTAP_NONE(0); |
| 53 | |
| 54 | private final int type; |
| 55 | |
| 56 | Type(int type) { |
| 57 | this.type = type; |
| 58 | } |
| 59 | |
| 60 | public boolean isValid(Type comp) { |
| 61 | return (this.type & comp.type) == comp.type; |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * OpenstackVtap identifier. |
| 67 | * |
| 68 | * @return OpenstackVtap id |
| 69 | */ |
| 70 | OpenstackVtapId id(); |
| 71 | |
| 72 | /** |
| 73 | * Returns OpenstackVtap type. |
| 74 | * |
| 75 | * @return type |
| 76 | */ |
| 77 | Type type(); |
| 78 | |
| 79 | /** |
| 80 | * Returns the vTap criterion. |
| 81 | * |
| 82 | * @return vTap criterion |
| 83 | */ |
| 84 | OpenstackVtapCriterion vTapCriterion(); |
| 85 | |
| 86 | /** |
| 87 | * Returns a collection of TX device identifiers. |
| 88 | * |
| 89 | * @return device identifiers |
| 90 | */ |
| 91 | Set<DeviceId> txDeviceIds(); |
| 92 | |
| 93 | /** |
| 94 | * Returns a collection of RX device identifiers. |
| 95 | * |
| 96 | * @return device identifiers |
| 97 | */ |
| 98 | Set<DeviceId> rxDeviceIds(); |
| 99 | |
| 100 | /** |
| 101 | * Builder of new openstack vTap instance. |
| 102 | */ |
| 103 | interface Builder { |
| 104 | |
| 105 | /** |
| 106 | * Returns openstack vTap builder with supplied vTap identifier. |
| 107 | * |
| 108 | * @param id vTap identifier |
| 109 | * @return openstack vTap builder |
| 110 | */ |
| 111 | Builder id(OpenstackVtapId id); |
| 112 | |
| 113 | /** |
| 114 | * Returns openstack vTap builder with supplied vTap type. |
| 115 | * |
| 116 | * @param type vTap type |
| 117 | * @return openstack vTap builder |
| 118 | */ |
| 119 | Builder type(OpenstackVtap.Type type); |
| 120 | |
| 121 | /** |
| 122 | * Returns openstack vTap builder with supplied vTap criterion. |
| 123 | * |
| 124 | * @param vTapCriterion vTap criterion |
| 125 | * @return openstack vTap builder |
| 126 | */ |
| 127 | Builder vTapCriterion(OpenstackVtapCriterion vTapCriterion); |
| 128 | |
| 129 | /** |
| 130 | * Returns openstack vTap builder with supplied TX device identifiers. |
| 131 | * |
| 132 | * @param txDeviceIds TX device identifiers |
| 133 | * @return openstack vTap builder |
| 134 | */ |
| 135 | Builder txDeviceIds(Set<DeviceId> txDeviceIds); |
| 136 | |
| 137 | /** |
| 138 | * Returns openstack vTap builder with supplied RX device identifiers. |
| 139 | * |
| 140 | * @param rxDeviceIds RX device identifiers |
| 141 | * @return openstack vTap builder |
| 142 | */ |
| 143 | Builder rxDeviceIds(Set<DeviceId> rxDeviceIds); |
| 144 | |
| 145 | /** |
| 146 | * Returns openstack vTap builder with supplied annotations. |
| 147 | * |
| 148 | * @param annotations a set of annotations |
| 149 | * @return openstack vTap builder |
| 150 | */ |
| 151 | Builder annotations(SparseAnnotations... annotations); |
| 152 | |
| 153 | /** |
| 154 | * Builds an immutable openstack vTap instance. |
| 155 | * |
| 156 | * @return openstack vTap instance |
| 157 | */ |
| 158 | OpenstackVtap build(); |
| 159 | } |
| 160 | } |