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 java.util.EnumSet; |
| 19 | import java.util.HashMap; |
| 20 | import java.util.Map; |
| 21 | |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 22 | /** |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 23 | * Representation of various values for TLV types. |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 24 | */ |
| 25 | public enum TlvType { |
| 26 | AREAADDRESS(1), |
| 27 | ISREACHABILITY(2), |
| 28 | ISNEIGHBORS(6), |
| 29 | PADDING(8), |
| 30 | LSPENTRY(9), |
| 31 | AUTHENTICATION(10), |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 32 | HOSTNAME(137), |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 33 | EXTENDEDISREACHABILITY(22), |
| 34 | ISALIAS(24), |
| 35 | IPINTERNALREACHABILITY(128), |
| 36 | PROTOCOLSUPPORTED(129), |
| 37 | IPEXTERNALREACHABILITY(130), |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 38 | IPEXTENDEDREACHABILITY(135), |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 39 | IDRPINFORMATION(131), |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 40 | IPINTERFACEADDRESS(132), |
| 41 | ADJACENCYSTATE(240); |
| 42 | |
| 43 | // Reverse lookup table |
| 44 | private static final Map<Integer, TlvType> LOOKUP = new HashMap<>(); |
| 45 | |
| 46 | // Populate the lookup table on loading time |
| 47 | static { |
| 48 | for (TlvType isisTlvType : EnumSet.allOf(TlvType.class)) { |
| 49 | LOOKUP.put(isisTlvType.value(), isisTlvType); |
| 50 | } |
| 51 | } |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 52 | |
| 53 | private int value; |
| 54 | |
| 55 | /** |
| 56 | * Sets the TLV type value. |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 57 | * |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 58 | * @param value value. |
| 59 | */ |
| 60 | TlvType(int value) { |
| 61 | this.value = value; |
| 62 | } |
| 63 | |
| 64 | /** |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 65 | * Gets the enum instance from type value - reverse lookup purpose. |
| 66 | * |
| 67 | * @param tlvTypeValue TLV type value |
| 68 | * @return ISIS TLV type instance |
| 69 | */ |
| 70 | public static TlvType get(int tlvTypeValue) { |
| 71 | return LOOKUP.get(tlvTypeValue); |
| 72 | } |
| 73 | |
| 74 | /** |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 75 | * Gets value. |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 76 | * |
mohamed rahil | e04626f | 2016-04-05 20:42:53 +0530 | [diff] [blame] | 77 | * @return value |
| 78 | */ |
| 79 | public int value() { |
| 80 | return value; |
| 81 | } |
sunishvk | a1dfc3e | 2016-04-16 12:24:47 +0530 | [diff] [blame] | 82 | } |