2e6a386204ac377cd50f7bd471235f418ecf12b6
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / sal / convertor / IPProtocols.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
9
10 import com.google.common.collect.ImmutableMap;
11 import com.google.common.collect.ImmutableMap.Builder;
12 import java.util.Map;
13
14 /**
15  * @author tkubas
16  *
17  */
18 //TODO make a model in YANG for protocols 
19 public enum IPProtocols {
20     ICMP((short) 1), 
21     TCP((short) 6), 
22     UDP((short) 17), 
23     ICMPV6((short) 58);
24
25     private short protocol;
26     
27     private static final Map<Short, IPProtocols> VALUE_MAP;
28     static {
29         Builder<Short, IPProtocols> builder = ImmutableMap.builder();
30         for(IPProtocols protocols : IPProtocols.values()) {
31             builder.put(protocols.protocol, protocols);
32         }
33         VALUE_MAP = builder.build();
34     }
35     
36     private IPProtocols(short value) {
37         this.protocol = value;
38     }
39
40     public static IPProtocols fromProtocolNum(Short protocolNum) {
41         return VALUE_MAP.get(protocolNum);
42     }
43 }