Sean Condon | 0e89bda | 2017-03-21 14:23:19 +0000 | [diff] [blame^] | 1 | /* |
| 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 | package org.onosproject.incubator.net.l2monitoring.cfm; |
| 17 | |
| 18 | import com.google.common.annotations.Beta; |
| 19 | import org.onlab.packet.EthType; |
| 20 | import org.onlab.packet.VlanId; |
| 21 | |
| 22 | import java.util.Collection; |
| 23 | |
| 24 | /** |
| 25 | * Components which can be managed in a manner equivalent to an 802.1Q bridge. |
| 26 | * |
| 27 | * Direct child of the {@link org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation}. |
| 28 | */ |
| 29 | public interface Component { |
| 30 | |
| 31 | int componentId(); |
| 32 | |
| 33 | /** |
| 34 | * The VID(s) monitored by this MA, or 0, if the MA is not attached to any VID. |
| 35 | * |
| 36 | * The first VID returned is the MA's Primary VID |
| 37 | * @return A collection of VIDs |
| 38 | */ |
| 39 | Collection<VlanId> vidList(); |
| 40 | |
| 41 | /** |
| 42 | * Defines how the MA can create MHFs (MIP Half Function) for this VID at this MA. |
| 43 | * @return An enumerated value |
| 44 | */ |
| 45 | MhfCreationType mhfCreationType(); |
| 46 | |
| 47 | /** |
| 48 | * indicates what, if anything, is to be included in the Sender ID TLV. |
| 49 | * The Sender ID TLV is transmitted by MPs configured in this MA. |
| 50 | * @return An enumerated value |
| 51 | */ |
| 52 | IdPermissionType idPermission(); |
| 53 | |
| 54 | /** |
| 55 | * Indicates the tag type for this component. |
| 56 | * @return The type of Tag active on this VLAN |
| 57 | */ |
| 58 | @Beta |
| 59 | TagType tagType(); |
| 60 | |
| 61 | /** |
| 62 | * Builder for {@link org.onosproject.incubator.net.l2monitoring.cfm.Component}. |
| 63 | */ |
| 64 | interface ComponentBuilder { |
| 65 | |
| 66 | ComponentBuilder addToVidList(VlanId vid); |
| 67 | |
| 68 | ComponentBuilder mhfCreationType(MhfCreationType mhfCreationType); |
| 69 | |
| 70 | ComponentBuilder idPermission(IdPermissionType idPermission); |
| 71 | |
| 72 | ComponentBuilder tagType(TagType tagType); |
| 73 | |
| 74 | Component build(); |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * An enumerated type defining how MHFs (MIP Half Function) can be created. |
| 79 | */ |
| 80 | public enum MhfCreationType { |
| 81 | /** |
| 82 | * No MHFs can be created for this VID(s). |
| 83 | */ |
| 84 | NONE, |
| 85 | |
| 86 | /** |
| 87 | * MHFs can be created for this VID(s) on any Bridge Port through which the. |
| 88 | * VID(s) can pass where: |
| 89 | * - There are no lower active MD levels; or |
| 90 | * - There is a MEP at the next lower active MD-level on the port |
| 91 | */ |
| 92 | DEFAULT, |
| 93 | |
| 94 | /** |
| 95 | * MHFs can be created for this VID(s) only on Bridge Ports through which. |
| 96 | * this VID(s) can pass, and only if there is a MEP at the next |
| 97 | * lower active MD-level on the port. |
| 98 | */ |
| 99 | EXPLICIT, |
| 100 | |
| 101 | /** |
| 102 | * In the Maintenance Association managed object only, the control of MHF. |
| 103 | * creation is deferred to the corresponding variable in the |
| 104 | * enclosing Maintenance Domain |
| 105 | */ |
| 106 | DEFER |
| 107 | } |
| 108 | |
| 109 | /** |
| 110 | * An enumerated value indicating what, if anything, is to be included in. |
| 111 | * the Sender ID TLV transmitted by maintenance-points configured in the |
| 112 | * default Maintenance Domain |
| 113 | * reference |
| 114 | * [802.1q] 21.5.3, 12.14.3.1.3:e"; |
| 115 | */ |
| 116 | public enum IdPermissionType { |
| 117 | /** |
| 118 | * The Sender ID TLV is not to be sent. |
| 119 | */ |
| 120 | NONE, |
| 121 | |
| 122 | /** |
| 123 | * The Chassis ID Length, Chassis ID Subtype, and Chassis ID fields of the. |
| 124 | * Sender ID TLV are to be sent, but not the Management Address |
| 125 | * Length or Management Address fields. |
| 126 | */ |
| 127 | CHASSIS, |
| 128 | |
| 129 | /** |
| 130 | * The Management Address Length and Management Address of the Sender ID. |
| 131 | * TLV are to be sent, but the Chassis ID Length is to be |
| 132 | * transmitted with a 0 value, and the Chassis ID Subtype and |
| 133 | * Chassis ID fields not sent |
| 134 | */ |
| 135 | MANAGE, |
| 136 | |
| 137 | /** |
| 138 | * The Chassis ID Length, Chassis ID Subtype, Chassis ID, Management. |
| 139 | * Address Length, and Management Address fields are all to be sent |
| 140 | */ |
| 141 | CHASSIS_MANAGE, |
| 142 | |
| 143 | /** |
| 144 | * The contents of the Sender ID TLV are determined by the Maintenance. |
| 145 | * Domain managed object |
| 146 | */ |
| 147 | DEFER |
| 148 | } |
| 149 | |
| 150 | /** |
| 151 | * A choice of VLan tag type. |
| 152 | */ |
| 153 | public enum TagType { |
| 154 | VLAN_NONE(EthType.EtherType.IPV4), |
| 155 | VLAN_CTAG(EthType.EtherType.VLAN), |
| 156 | VLAN_STAG(EthType.EtherType.QINQ); |
| 157 | |
| 158 | private EthType.EtherType type = EthType.EtherType.IPV4; |
| 159 | |
| 160 | TagType(EthType.EtherType type) { |
| 161 | this.type = type; |
| 162 | } |
| 163 | |
| 164 | public EthType.EtherType getType() { |
| 165 | return type; |
| 166 | } |
| 167 | |
| 168 | public static TagType fromEtherType(EthType.EtherType type) { |
| 169 | for (TagType tt:values()) { |
| 170 | if (tt.type.equals(type)) { |
| 171 | return tt; |
| 172 | } |
| 173 | } |
| 174 | throw new IllegalArgumentException("Unsupported EtherType: " + type); |
| 175 | } |
| 176 | } |
| 177 | } |