blob: 9b27c0c1e2ebe79a951bede7df5be0d1c1a17940 [file] [log] [blame]
Jonathan Hart3930f632015-10-19 12:12:51 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Jonathan Hart3930f632015-10-19 12:12:51 -07003 *
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
17package org.onosproject.routing.fpm.protocol;
18
19/**
20 * Netlink message types.
21 * <p>
22 * This is a subset of the types used for routing messages (rtnelink).
23 * Taken from linux/rtnetlink.h
24 * </p>
25 */
26public enum NetlinkMessageType {
27 RTM_NEWROUTE(24),
28 RTM_DELROUTE(25),
29 RTM_GETROUTE(26);
30
31 private final int type;
32
33 /**
34 * Enum constructor.
35 *
36 * @param type integer type value
37 */
38 NetlinkMessageType(int type) {
39 this.type = type;
40 }
41
42 /**
43 * Returns the integer type value for this message type.
44 *
45 * @return type value
46 */
47 public int type() {
48 return type;
49 }
50
51 /**
52 * Gets the NetlinkMessageType for the given integer type value.
53 *
54 * @param type type value
55 * @return Netlink message type, or null if unsupported type value
56 */
57 public static NetlinkMessageType get(int type) {
58 for (NetlinkMessageType m : NetlinkMessageType.values()) {
59 if (m.type() == type) {
60 return m;
61 }
62 }
63 return null;
64 }
65}