Satish K | f6d87cb | 2015-11-30 19:59:22 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
Satish K | f6d87cb | 2015-11-30 19:59:22 +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.iptopology.api; |
| 17 | |
Priyanka B | 8c37858 | 2015-12-07 21:09:56 +0530 | [diff] [blame] | 18 | import java.util.HashMap; |
| 19 | import java.util.Map; |
| 20 | |
Satish K | f6d87cb | 2015-11-30 19:59:22 +0530 | [diff] [blame] | 21 | /** |
| 22 | * Abstraction of Router ID to identify the router with a distinct IP address. |
| 23 | */ |
| 24 | public interface RouteIdentifier { |
| 25 | /** |
| 26 | * Enum to provide Protocol type. |
| 27 | */ |
| 28 | public enum ProtocolType { |
| 29 | ISIS_LevelOne(1), ISIS_LevelTwo(2), OSPFv2(3), Direct(4), Static_Configuration(5), OSPFv3(6); |
| 30 | int value; |
| 31 | |
| 32 | /** |
| 33 | * Sets protocol ID. |
| 34 | * |
| 35 | * @param val protocol ID |
| 36 | */ |
| 37 | ProtocolType(int val) { |
| 38 | value = val; |
| 39 | } |
| 40 | |
Priyanka B | 8c37858 | 2015-12-07 21:09:56 +0530 | [diff] [blame] | 41 | static Map<Integer, ProtocolType> map = new HashMap<>(); |
| 42 | |
| 43 | static { |
| 44 | for (ProtocolType type : ProtocolType.values()) { |
| 45 | map.put(type.value, type); |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * A method that returns enum value. |
| 51 | * |
| 52 | * @param value protocol type |
| 53 | * @return Enum value |
| 54 | */ |
| 55 | public static ProtocolType getEnumType(int value) { |
| 56 | return map.get(value); |
| 57 | } |
| 58 | |
Satish K | f6d87cb | 2015-11-30 19:59:22 +0530 | [diff] [blame] | 59 | /** |
| 60 | * Provides Protocol ID. |
| 61 | * |
| 62 | * @return Protocol ID |
| 63 | */ |
| 64 | public byte getType() { |
| 65 | return (byte) value; |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Provides Protocol ID to identify which protocol routing instance is used. |
| 71 | * |
| 72 | * @return Protocol type |
| 73 | */ |
| 74 | ProtocolType type(); |
| 75 | } |