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; |
Dhruv Dhody | e64b93e | 2016-04-20 19:26:55 +0530 | [diff] [blame^] | 47 | case HOSTNAME: |
| 48 | HostNameTlv hostNameTlv = new HostNameTlv(tlvHeader); |
| 49 | hostNameTlv.readFrom(channelBuffer); |
| 50 | isisTlv = hostNameTlv; |
| 51 | break; |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 52 | case IDRPINFORMATION: |
| 53 | IdrpInformationTlv idrpInformationTlv = new IdrpInformationTlv(tlvHeader); |
| 54 | idrpInformationTlv.readFrom(channelBuffer); |
| 55 | isisTlv = idrpInformationTlv; |
| 56 | break; |
| 57 | case IPEXTENDEDREACHABILITY: |
| 58 | IpExtendedReachabilityTlv iperTlv = new IpExtendedReachabilityTlv(tlvHeader); |
| 59 | iperTlv.readFrom(channelBuffer); |
| 60 | isisTlv = iperTlv; |
| 61 | break; |
| 62 | case IPINTERFACEADDRESS: |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 63 | IpInterfaceAddressTlv ipTlv = new IpInterfaceAddressTlv(tlvHeader); |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 64 | ipTlv.readFrom(channelBuffer); |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 65 | isisTlv = ipTlv; |
| 66 | break; |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 67 | case IPINTERNALREACHABILITY: |
| 68 | IpInternalReachabilityTlv iprTlv = new IpInternalReachabilityTlv(tlvHeader); |
| 69 | iprTlv.readFrom(channelBuffer); |
| 70 | isisTlv = iprTlv; |
| 71 | break; |
| 72 | case ISALIAS: |
| 73 | break; |
| 74 | case PROTOCOLSUPPORTED: |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 75 | ProtocolSupportedTlv psTlv = new ProtocolSupportedTlv(tlvHeader); |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 76 | psTlv.readFrom(channelBuffer); |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 77 | isisTlv = psTlv; |
| 78 | break; |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 79 | case ISREACHABILITY: |
| 80 | IsReachabilityTlv isrTlv = new IsReachabilityTlv(tlvHeader); |
| 81 | isrTlv.readFrom(channelBuffer); |
| 82 | isisTlv = isrTlv; |
| 83 | break; |
| 84 | case ISNEIGHBORS: |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 85 | IsisNeighborTlv isisNeighborTlv = new IsisNeighborTlv(tlvHeader); |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 86 | isisNeighborTlv.readFrom(channelBuffer); |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 87 | isisTlv = isisNeighborTlv; |
| 88 | break; |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 89 | case LSPENTRY: |
| 90 | LspEntriesTlv lspEntriesTlv = new LspEntriesTlv(tlvHeader); |
| 91 | lspEntriesTlv.readFrom(channelBuffer); |
| 92 | isisTlv = lspEntriesTlv; |
| 93 | break; |
| 94 | case PADDING: |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 95 | PaddingTlv paddingTlv = new PaddingTlv(tlvHeader); |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 96 | paddingTlv.readFrom(channelBuffer); |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 97 | isisTlv = paddingTlv; |
| 98 | break; |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 99 | case ADJACENCYSTATE: |
| 100 | AdjacencyStateTlv adjacencyStateTlv = new AdjacencyStateTlv(tlvHeader); |
| 101 | adjacencyStateTlv.readFrom(channelBuffer); |
| 102 | isisTlv = adjacencyStateTlv; |
| 103 | break; |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 104 | default: |
| 105 | break; |
| 106 | } |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 107 | return isisTlv; |
| 108 | } |
| 109 | } |