blob: 01695291418e2fa5958c6d7a385828b38e3d730f [file] [log] [blame]
Kiran Ramachandrac92a1222016-03-30 13:05:31 +05301/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Kiran Ramachandrac92a1222016-03-30 13:05:31 +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 */
Kiran Ramachandrac92a1222016-03-30 13:05:31 +053016package org.onosproject.isis.controller;
17
mohamed rahil8ea09d42016-04-19 20:47:21 +053018import java.util.EnumSet;
19import java.util.HashMap;
20import java.util.Map;
21
Kiran Ramachandrac92a1222016-03-30 13:05:31 +053022/**
23 * Representation of ISIS PDU types.
24 */
25public enum IsisPduType {
26
27 /**
28 * Represents Level-1 LAN hello packet.
29 */
30 L1HELLOPDU(15),
31 /**
32 * Represents Level-2 LAN hello packet.
33 */
34 L2HELLOPDU(16),
35 /**
36 * Represents point-to-point hello packet.
37 */
38 P2PHELLOPDU(17),
39 /**
40 * Represents Level-1 link state packet.
41 */
42 L1LSPDU(18),
43 /**
44 * Represents Level-2 link state packet.
45 */
46 L2LSPDU(20),
47 /**
48 * Represents Level-1 complete sequence number packet.
49 */
50 L1CSNP(24),
51 /**
52 * Represents Level-2 complete sequence number packet.
53 */
54 L2CSNP(25),
55 /**
56 * Represents Level-1 partial sequence number packet.
57 */
58 L1PSNP(26),
59 /**
60 * Represents Level-2 partial sequence number packet.
61 */
62 L2PSNP(27);
63
mohamed rahil8ea09d42016-04-19 20:47:21 +053064 // Reverse lookup table
65 private static final Map<Integer, IsisPduType> LOOKUP = new HashMap<>();
Kiran Ramachandrac92a1222016-03-30 13:05:31 +053066
mohamed rahil8ea09d42016-04-19 20:47:21 +053067 // Populate the lookup table on loading time
68 static {
69 for (IsisPduType isisPduType : EnumSet.allOf(IsisPduType.class)) {
70 LOOKUP.put(isisPduType.value(), isisPduType);
71 }
72 }
73
74 private int value;
Kiran Ramachandrac92a1222016-03-30 13:05:31 +053075
76 /**
77 * Creates an instance of ISIS PDU type.
78 *
79 * @param value represents ISIS PDU type
80 */
81 private IsisPduType(int value) {
82 this.value = value;
83 }
84
85 /**
mohamed rahil8ea09d42016-04-19 20:47:21 +053086 * Gets the enum instance from type value - reverse lookup purpose.
87 *
88 * @param pduTypeValue PDU type value
89 * @return ISIS PDU type instance
90 */
91 public static IsisPduType get(int pduTypeValue) {
92 return LOOKUP.get(pduTypeValue);
93 }
94
95 /**
Kiran Ramachandrac92a1222016-03-30 13:05:31 +053096 * Gets the value representing PDU type.
97 *
98 * @return value represents PDU type
99 */
100 public int value() {
101 return value;
102 }
103}