blob: 794dc244f1826ee7f80540cce89ddd6e383b9617 [file] [log] [blame]
Chidambar babu86b3b1a2016-02-16 17:39:52 +05301/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Chidambar babu86b3b1a2016-02-16 17:39:52 +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.ospf.protocol.util;
17
18/**
19 * Representation of an OSPF Interface states.
20 */
21public enum OspfInterfaceState {
22
23 DOWN(1),
24 LOOPBACK(2),
25 WAITING(3),
26 POINT2POINT(4),
27 DROTHER(5),
28 BDR(6),
29 DR(7);
30
31 private int value;
32
33 /**
sunishvkf7c56552016-07-18 16:02:39 +053034 * Creates an instance of interface state.
Chidambar babu86b3b1a2016-02-16 17:39:52 +053035 *
sunishvkf7c56552016-07-18 16:02:39 +053036 * @param value Interface state value
Chidambar babu86b3b1a2016-02-16 17:39:52 +053037 */
38 OspfInterfaceState(int value) {
39 this.value = value;
40 }
41
42 /**
sunishvkf7c56552016-07-18 16:02:39 +053043 * Gets value for Interface state.
Chidambar babu86b3b1a2016-02-16 17:39:52 +053044 *
sunishvkf7c56552016-07-18 16:02:39 +053045 * @return value Interface state
Chidambar babu86b3b1a2016-02-16 17:39:52 +053046 */
47 public int value() {
48 return value;
49 }
sunishvkf7c56552016-07-18 16:02:39 +053050
51 /**
52 * Gets interface state.
53 *
54 * @return interface state
55 */
56 public String interfaceState() {
57 String state = null;
58 switch (value) {
59 case 1:
60 state = "DOWN";
61 break;
62 case 2:
63 state = "LOOPBACK";
64 break;
65 case 3:
66 state = "WAITING";
67 break;
68 case 4:
69 state = "POINT2POINT";
70 break;
71 case 5:
72 state = "DROTHER";
73 break;
74 case 6:
75 state = "BDR";
76 break;
77 case 7:
78 state = "DR";
79 break;
80 default:
81 break;
82 }
83 return state;
84 }
Chidambar babu86b3b1a2016-02-16 17:39:52 +053085}