mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
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: |
| 45 | //TODO |
| 46 | break; |
| 47 | case IDRPINFORMATION: |
| 48 | IdrpInformationTlv idrpInformationTlv = new IdrpInformationTlv(tlvHeader); |
| 49 | idrpInformationTlv.readFrom(channelBuffer); |
| 50 | isisTlv = idrpInformationTlv; |
| 51 | break; |
| 52 | case IPEXTENDEDREACHABILITY: |
| 53 | IpExtendedReachabilityTlv iperTlv = new IpExtendedReachabilityTlv(tlvHeader); |
| 54 | iperTlv.readFrom(channelBuffer); |
| 55 | isisTlv = iperTlv; |
| 56 | break; |
| 57 | case IPINTERFACEADDRESS: |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 58 | IpInterfaceAddressTlv ipTlv = new IpInterfaceAddressTlv(tlvHeader); |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 59 | ipTlv.readFrom(channelBuffer); |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 60 | isisTlv = ipTlv; |
| 61 | break; |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 62 | case IPINTERNALREACHABILITY: |
| 63 | IpInternalReachabilityTlv iprTlv = new IpInternalReachabilityTlv(tlvHeader); |
| 64 | iprTlv.readFrom(channelBuffer); |
| 65 | isisTlv = iprTlv; |
| 66 | break; |
| 67 | case ISALIAS: |
| 68 | break; |
| 69 | case PROTOCOLSUPPORTED: |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 70 | ProtocolSupportedTlv psTlv = new ProtocolSupportedTlv(tlvHeader); |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 71 | psTlv.readFrom(channelBuffer); |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 72 | isisTlv = psTlv; |
| 73 | break; |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 74 | case ISREACHABILITY: |
| 75 | IsReachabilityTlv isrTlv = new IsReachabilityTlv(tlvHeader); |
| 76 | isrTlv.readFrom(channelBuffer); |
| 77 | isisTlv = isrTlv; |
| 78 | break; |
| 79 | case ISNEIGHBORS: |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 80 | IsisNeighborTlv isisNeighborTlv = new IsisNeighborTlv(tlvHeader); |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 81 | isisNeighborTlv.readFrom(channelBuffer); |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 82 | isisTlv = isisNeighborTlv; |
| 83 | break; |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 84 | case LSPENTRY: |
| 85 | LspEntriesTlv lspEntriesTlv = new LspEntriesTlv(tlvHeader); |
| 86 | lspEntriesTlv.readFrom(channelBuffer); |
| 87 | isisTlv = lspEntriesTlv; |
| 88 | break; |
| 89 | case PADDING: |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 90 | PaddingTlv paddingTlv = new PaddingTlv(tlvHeader); |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 91 | paddingTlv.readFrom(channelBuffer); |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 92 | isisTlv = paddingTlv; |
| 93 | break; |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 94 | case ADJACENCYSTATE: |
| 95 | AdjacencyStateTlv adjacencyStateTlv = new AdjacencyStateTlv(tlvHeader); |
| 96 | adjacencyStateTlv.readFrom(channelBuffer); |
| 97 | isisTlv = adjacencyStateTlv; |
| 98 | break; |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 99 | default: |
| 100 | break; |
| 101 | } |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 102 | return isisTlv; |
| 103 | } |
| 104 | } |