blob: 92ea1430fe63d2601637545416a5a4379fcb1cd1 [file] [log] [blame]
sunishvka1dfc3e2016-04-16 12:24:47 +05301/*
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 */
16package org.onosproject.isis.io.isispacket.tlv.subtlv;
17
18import org.jboss.netty.buffer.ChannelBuffer;
19import org.onosproject.isis.io.isispacket.tlv.TlvHeader;
20
21/**
22 * Representation of sub tlv finder.
23 */
24public 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 SHIVANANJAPPA491b8af2016-04-27 19:23:24 +053069 case INTERFACEADDRESS:
70 InterfaceIpAddress ipInterfaceAddressTlv = new InterfaceIpAddress(tlvHeader);
71 ipInterfaceAddressTlv.readFrom(channelBuffer);
72 subTlv = ipInterfaceAddressTlv;
73 break;
sunishvka1dfc3e2016-04-16 12:24:47 +053074 default:
75 //TODO
76 break;
77 }
78 return subTlv;
79 }
80}