BUG-2218: Keep existing link augmentations during discovery process
[controller.git] / opendaylight / adsal / sal / api / src / main / java / org / opendaylight / controller / sal / action / ActionType.java
1 /*
2  * Copyright (c) 2013-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.controller.sal.action;
9
10 /**
11  * The enumeration of actions supported by the controller
12  * Each entry has a unique id and the values range for the action element where applicable
13  */
14 public enum ActionType {
15     DROP("drop", 0, 0),
16     LOOPBACK("loopback", 0, 0),
17     FLOOD("flood", 0, 0), // regular switching flood (obeys to stp port state)
18     FLOOD_ALL("floodAll", 0, 0), // flood to all ports regardless of stp port state
19     CONTROLLER("controller", 0, 0),
20     INTERFACE("interface", 0, 0), // Interface
21     SW_PATH("software path", 0, 0), // OF Local
22     HW_PATH("harware path", 0, 0),
23     OUTPUT("output", 0, 0xffff), // physical port
24     ENQUEUE("enqueue", 0, 0xffff),
25     SET_DL_SRC("setDlSrc", 0, 0),
26     SET_DL_DST("setDlDst", 0, 0),
27     SET_VLAN_ID("setVlan", 1, 0xfff),
28     SET_VLAN_PCP("setVlanPcp", 0, 0x7),
29     SET_VLAN_CFI("setVlanCif", 0, 0x1),
30     POP_VLAN("stripVlan", 0, 0), // Pop
31     PUSH_VLAN("pushVlan", 0, 0xffff), // Push (the max value only takes into account the TCI portion of the 802.1q header)
32     SET_DL_TYPE("setDlType", 0, 0xffff), // Set ethertype/length field
33     SET_NW_SRC("setNwSrc", 0, 0),
34     SET_NW_DST("setNwDst", 0, 0),
35     SET_NW_TOS("setNwTos", 0, 0x3f),
36     SET_TP_SRC("setTpSrc", 0, 0xffff), // Set transport source port
37     SET_TP_DST("setTpDst", 0, 0xffff), // Set transport destination port
38     SET_NEXT_HOP("setNextHop", 0, 0);
39
40     private String id;
41     private int minValue;
42     private int maxValue;
43
44     private ActionType(String id, int minValue, int maxValue) {
45         this.id = id;
46         this.minValue = minValue;
47         this.maxValue = maxValue;
48     }
49
50     public String getId() {
51         return id;
52     }
53
54     public boolean isValidTarget(int value) {
55         return (value >= minValue && value <= maxValue);
56     }
57
58     public String getRange() {
59         return "[0x" + Long.toHexString(minValue) + "-0x" + Long.toHexString(maxValue) + "]";
60     }
61
62     public boolean takesParameter() {
63         switch (this) {
64         case POP_VLAN:
65         case DROP:
66         case SW_PATH:
67         case HW_PATH:
68         case CONTROLLER:
69         case LOOPBACK:
70         case FLOOD:
71         case FLOOD_ALL:
72             return false;
73         default:
74             return true;
75         }
76     }
77
78     public int calculateConsistentHashCode() {
79         if (this.id != null) {
80             return this.id.hashCode();
81         } else {
82             return 0;
83         }
84     }
85 }