sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 1 | /* |
| 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 | package org.onosproject.isis.io.isispacket.tlv.subtlv; |
| 17 | |
| 18 | import org.jboss.netty.buffer.ChannelBuffer; |
| 19 | import org.onosproject.isis.io.isispacket.tlv.TlvHeader; |
| 20 | |
| 21 | /** |
| 22 | * Representation of sub tlv finder. |
| 23 | */ |
| 24 | public final class SubTlvFinder { |
| 25 | /** |
| 26 | * Creates an instance. |
| 27 | */ |
| 28 | private SubTlvFinder() { |
| 29 | |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Sets the value for TLV header and to find sub TLV and populate. |
| 34 | * |
| 35 | * @param tlvHeader tlvHeader |
| 36 | * @param channelBuffer byteBuf |
| 37 | * @return subTlv traffic engineering sub tlv |
| 38 | */ |
| 39 | public static TrafficEngineeringSubTlv findSubTlv(TlvHeader tlvHeader, ChannelBuffer channelBuffer) { |
| 40 | |
| 41 | TrafficEngineeringSubTlv subTlv = null; |
| 42 | |
| 43 | switch (SubTlvType.get(tlvHeader.tlvType())) { |
| 44 | case ADMINISTRATIVEGROUP: |
| 45 | AdministrativeGroup administrativeGroup = new AdministrativeGroup(tlvHeader); |
| 46 | administrativeGroup.readFrom(channelBuffer); |
| 47 | subTlv = administrativeGroup; |
| 48 | break; |
| 49 | case MAXIMUMBANDWIDTH: |
| 50 | MaximumBandwidth maximumBandwidth = new MaximumBandwidth(tlvHeader); |
| 51 | maximumBandwidth.readFrom(channelBuffer); |
| 52 | subTlv = maximumBandwidth; |
| 53 | break; |
| 54 | case MAXIMUMRESERVABLEBANDWIDTH: |
| 55 | MaximumReservableBandwidth maxResBandwidth = new MaximumReservableBandwidth(tlvHeader); |
| 56 | maxResBandwidth.readFrom(channelBuffer); |
| 57 | subTlv = maxResBandwidth; |
| 58 | break; |
| 59 | case TRAFFICENGINEERINGMETRIC: |
| 60 | TrafficEngineeringMetric teMetric = new TrafficEngineeringMetric(tlvHeader); |
| 61 | teMetric.readFrom(channelBuffer); |
| 62 | subTlv = teMetric; |
| 63 | break; |
| 64 | case UNRESERVEDBANDWIDTH: |
| 65 | UnreservedBandwidth unreservedBandwidth = new UnreservedBandwidth(tlvHeader); |
| 66 | unreservedBandwidth.readFrom(channelBuffer); |
| 67 | subTlv = unreservedBandwidth; |
| 68 | break; |
PRASHANTH SHIVANANJAPPA | 491b8af | 2016-04-27 19:23:24 +0530 | [diff] [blame] | 69 | case INTERFACEADDRESS: |
| 70 | InterfaceIpAddress ipInterfaceAddressTlv = new InterfaceIpAddress(tlvHeader); |
| 71 | ipInterfaceAddressTlv.readFrom(channelBuffer); |
| 72 | subTlv = ipInterfaceAddressTlv; |
| 73 | break; |
sunish vk | 7bdf4d4 | 2016-06-24 12:29:43 +0530 | [diff] [blame^] | 74 | case NEIGHBORADDRESS: |
| 75 | NeighborIpAddress ipNeighborAddressTlv = new NeighborIpAddress(tlvHeader); |
| 76 | ipNeighborAddressTlv.readFrom(channelBuffer); |
| 77 | subTlv = ipNeighborAddressTlv; |
| 78 | break; |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 79 | default: |
| 80 | //TODO |
| 81 | break; |
| 82 | } |
| 83 | return subTlv; |
| 84 | } |
| 85 | } |