Make sure invokeOperation is set once
[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 @Deprecated
15 public enum ActionType {
16     DROP("drop", 0, 0),
17     LOOPBACK("loopback", 0, 0),
18     FLOOD("flood", 0, 0), // regular switching flood (obeys to stp port state)
19     FLOOD_ALL("floodAll", 0, 0), // flood to all ports regardless of stp port state
20     CONTROLLER("controller", 0, 0),
21     INTERFACE("interface", 0, 0), // Interface
22     SW_PATH("software path", 0, 0), // OF Local
23     HW_PATH("harware path", 0, 0),
24     OUTPUT("output", 0, 0xffff), // physical port
25     ENQUEUE("enqueue", 0, 0xffff),
26     SET_DL_SRC("setDlSrc", 0, 0),
27     SET_DL_DST("setDlDst", 0, 0),
28     SET_VLAN_ID("setVlan", 1, 0xfff),
29     SET_VLAN_PCP("setVlanPcp", 0, 0x7),
30     SET_VLAN_CFI("setVlanCif", 0, 0x1),
31     POP_VLAN("stripVlan", 0, 0), // Pop
32     PUSH_VLAN("pushVlan", 0, 0xffff), // Push (the max value only takes into account the TCI portion of the 802.1q header)
33     SET_DL_TYPE("setDlType", 0, 0xffff), // Set ethertype/length field
34     SET_NW_SRC("setNwSrc", 0, 0),
35     SET_NW_DST("setNwDst", 0, 0),
36     SET_NW_TOS("setNwTos", 0, 0x3f),
37     SET_TP_SRC("setTpSrc", 0, 0xffff), // Set transport source port
38     SET_TP_DST("setTpDst", 0, 0xffff), // Set transport destination port
39     SET_NEXT_HOP("setNextHop", 0, 0);
40
41     private String id;
42     private int minValue;
43     private int maxValue;
44
45     private ActionType(String id, int minValue, int maxValue) {
46         this.id = id;
47         this.minValue = minValue;
48         this.maxValue = maxValue;
49     }
50
51     public String getId() {
52         return id;
53     }
54
55     public boolean isValidTarget(int value) {
56         return (value >= minValue && value <= maxValue);
57     }
58
59     public String getRange() {
60         return "[0x" + Long.toHexString(minValue) + "-0x" + Long.toHexString(maxValue) + "]";
61     }
62
63     public boolean takesParameter() {
64         switch (this) {
65         case POP_VLAN:
66         case DROP:
67         case SW_PATH:
68         case HW_PATH:
69         case CONTROLLER:
70         case LOOPBACK:
71         case FLOOD:
72         case FLOOD_ALL:
73             return false;
74         default:
75             return true;
76         }
77     }
78
79     public int calculateConsistentHashCode() {
80         if (this.id != null) {
81             return this.id.hashCode();
82         } else {
83             return 0;
84         }
85     }
86 }