BUG-1491: handle SET_TP_SRC/SET_TP_DST actions
[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 java.util.HashMap;
11 import java.util.Map;
12
13 /**
14  * @author tkubas
15  *
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 Map<Short, IPProtocols> valueMap;
28     static {
29         valueMap = new HashMap<>();
30         for(IPProtocols protocols : IPProtocols.values()) {
31             valueMap.put(protocols.protocol, protocols);
32         }
33     }
34     
35     private IPProtocols(short value) {
36         this.protocol = value;
37     }
38
39     private byte getValue() {
40         return (byte) this.protocol;
41     }
42     
43     public static IPProtocols fromProtocolNum(Short protocolNum) {
44         return valueMap.get(protocolNum);
45     }
46 }