blob: bf609c81e06dde58d70062b076f0fe50cb3480bc [file] [log] [blame]
mohamed rahile04626f2016-04-05 20:42:53 +05301/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
mohamed rahile04626f2016-04-05 20:42:53 +05303 *
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;
17
sunishvka1dfc3e2016-04-16 12:24:47 +053018import java.util.EnumSet;
19import java.util.HashMap;
20import java.util.Map;
21
mohamed rahile04626f2016-04-05 20:42:53 +053022/**
sunishvka1dfc3e2016-04-16 12:24:47 +053023 * Representation of various values for TLV types.
mohamed rahile04626f2016-04-05 20:42:53 +053024 */
25public enum TlvType {
26 AREAADDRESS(1),
27 ISREACHABILITY(2),
28 ISNEIGHBORS(6),
29 PADDING(8),
30 LSPENTRY(9),
31 AUTHENTICATION(10),
sunishvka1dfc3e2016-04-16 12:24:47 +053032 HOSTNAME(137),
mohamed rahile04626f2016-04-05 20:42:53 +053033 EXTENDEDISREACHABILITY(22),
34 ISALIAS(24),
35 IPINTERNALREACHABILITY(128),
36 PROTOCOLSUPPORTED(129),
37 IPEXTERNALREACHABILITY(130),
sunishvka1dfc3e2016-04-16 12:24:47 +053038 IPEXTENDEDREACHABILITY(135),
mohamed rahile04626f2016-04-05 20:42:53 +053039 IDRPINFORMATION(131),
sunishvka1dfc3e2016-04-16 12:24:47 +053040 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 rahile04626f2016-04-05 20:42:53 +053052
53 private int value;
54
55 /**
56 * Sets the TLV type value.
sunishvka1dfc3e2016-04-16 12:24:47 +053057 *
mohamed rahile04626f2016-04-05 20:42:53 +053058 * @param value value.
59 */
60 TlvType(int value) {
61 this.value = value;
62 }
63
64 /**
sunishvka1dfc3e2016-04-16 12:24:47 +053065 * 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 rahile04626f2016-04-05 20:42:53 +053075 * Gets value.
sunishvka1dfc3e2016-04-16 12:24:47 +053076 *
mohamed rahile04626f2016-04-05 20:42:53 +053077 * @return value
78 */
79 public int value() {
80 return value;
81 }
sunishvka1dfc3e2016-04-16 12:24:47 +053082}