mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 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; |
| 17 | |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 18 | import org.jboss.netty.buffer.ChannelBuffer; |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 19 | |
| 20 | /** |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 21 | * Representation of TLV Finder. |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 22 | */ |
| 23 | public class TlvFinder extends TlvHeader { |
| 24 | |
| 25 | /** |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 26 | * Sets the value for TLV header. |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 27 | * |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 28 | * @param tlvHeader tlvHeader |
| 29 | * @param channelBuffer byteBuf |
| 30 | * @return isisTlv |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 31 | */ |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 32 | public static IsisTlv findTlv(TlvHeader tlvHeader, ChannelBuffer channelBuffer) { |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 33 | |
| 34 | IsisTlv isisTlv = null; |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 35 | switch (TlvType.get(tlvHeader.tlvType())) { |
| 36 | case AREAADDRESS: |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 37 | AreaAddressTlv areaAddressTlv = new AreaAddressTlv(tlvHeader); |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 38 | areaAddressTlv.readFrom(channelBuffer); |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 39 | isisTlv = areaAddressTlv; |
| 40 | break; |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 41 | case AUTHENTICATION: |
| 42 | //TODO |
| 43 | break; |
| 44 | case EXTENDEDISREACHABILITY: |
tejeshwer degala | 3fe1ed5 | 2016-04-22 17:04:01 +0530 | [diff] [blame] | 45 | IsExtendedReachability isExtendedReachability = |
| 46 | new IsExtendedReachability(tlvHeader); |
| 47 | isExtendedReachability.readFrom(channelBuffer); |
| 48 | isisTlv = isExtendedReachability; |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 49 | break; |
Dhruv Dhody | e64b93e | 2016-04-20 19:26:55 +0530 | [diff] [blame] | 50 | case HOSTNAME: |
| 51 | HostNameTlv hostNameTlv = new HostNameTlv(tlvHeader); |
| 52 | hostNameTlv.readFrom(channelBuffer); |
| 53 | isisTlv = hostNameTlv; |
| 54 | break; |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 55 | case IDRPINFORMATION: |
| 56 | IdrpInformationTlv idrpInformationTlv = new IdrpInformationTlv(tlvHeader); |
| 57 | idrpInformationTlv.readFrom(channelBuffer); |
| 58 | isisTlv = idrpInformationTlv; |
| 59 | break; |
| 60 | case IPEXTENDEDREACHABILITY: |
| 61 | IpExtendedReachabilityTlv iperTlv = new IpExtendedReachabilityTlv(tlvHeader); |
| 62 | iperTlv.readFrom(channelBuffer); |
| 63 | isisTlv = iperTlv; |
| 64 | break; |
| 65 | case IPINTERFACEADDRESS: |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 66 | IpInterfaceAddressTlv ipTlv = new IpInterfaceAddressTlv(tlvHeader); |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 67 | ipTlv.readFrom(channelBuffer); |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 68 | isisTlv = ipTlv; |
| 69 | break; |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 70 | case IPINTERNALREACHABILITY: |
| 71 | IpInternalReachabilityTlv iprTlv = new IpInternalReachabilityTlv(tlvHeader); |
| 72 | iprTlv.readFrom(channelBuffer); |
| 73 | isisTlv = iprTlv; |
| 74 | break; |
| 75 | case ISALIAS: |
| 76 | break; |
| 77 | case PROTOCOLSUPPORTED: |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 78 | ProtocolSupportedTlv psTlv = new ProtocolSupportedTlv(tlvHeader); |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 79 | psTlv.readFrom(channelBuffer); |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 80 | isisTlv = psTlv; |
| 81 | break; |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 82 | case ISREACHABILITY: |
| 83 | IsReachabilityTlv isrTlv = new IsReachabilityTlv(tlvHeader); |
| 84 | isrTlv.readFrom(channelBuffer); |
| 85 | isisTlv = isrTlv; |
| 86 | break; |
| 87 | case ISNEIGHBORS: |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 88 | IsisNeighborTlv isisNeighborTlv = new IsisNeighborTlv(tlvHeader); |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 89 | isisNeighborTlv.readFrom(channelBuffer); |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 90 | isisTlv = isisNeighborTlv; |
| 91 | break; |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 92 | case LSPENTRY: |
| 93 | LspEntriesTlv lspEntriesTlv = new LspEntriesTlv(tlvHeader); |
| 94 | lspEntriesTlv.readFrom(channelBuffer); |
| 95 | isisTlv = lspEntriesTlv; |
| 96 | break; |
| 97 | case PADDING: |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 98 | PaddingTlv paddingTlv = new PaddingTlv(tlvHeader); |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 99 | paddingTlv.readFrom(channelBuffer); |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 100 | isisTlv = paddingTlv; |
| 101 | break; |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 102 | case ADJACENCYSTATE: |
| 103 | AdjacencyStateTlv adjacencyStateTlv = new AdjacencyStateTlv(tlvHeader); |
| 104 | adjacencyStateTlv.readFrom(channelBuffer); |
| 105 | isisTlv = adjacencyStateTlv; |
| 106 | break; |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 107 | default: |
| 108 | break; |
| 109 | } |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 110 | return isisTlv; |
| 111 | } |
| 112 | } |