UI Flow configuration fix
[controller.git] / opendaylight / sal / api / src / main / java / org / opendaylight / controller / sal / action / ActionType.java
1
2 /*
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
4  *
5  * This program and the accompanying materials are made available under the
6  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7  * and is available at http://www.eclipse.org/legal/epl-v10.html
8  */
9
10 package org.opendaylight.controller.sal.action;
11
12 /**
13  * The enumeration of actions supported by the controller
14  * Each entry has a unique id and the values range for the action element where applicable
15  *
16  *
17  *
18  */
19 public enum ActionType {
20     DROP("drop", 0, 0),
21     LOOPBACK("loopback", 0, 0),
22     FLOOD("flood", 0, 0), // regular switching flood (obeys to stp port state)
23     FLOOD_ALL("floodAll", 0, 0), // flood to all ports regardless of stp port state
24     CONTROLLER("controller", 0, 0),
25     INTERFACE("interface", 0, 0), // Interface
26     SW_PATH("software path", 0, 0), // OF Local
27     HW_PATH("harware path", 0, 0),
28     OUTPUT("output", 0, 0xffff), // physical port
29     ENQUEUE("enqueue", 0, 0xffff),
30     SET_DL_SRC("setDlSrc", 0, 0),
31     SET_DL_DST("setDlDst", 0, 0),
32     SET_VLAN_ID("setVlan", 1, 0xfff),
33     SET_VLAN_PCP("setVlanPcp", 0, 0x7),
34     SET_VLAN_CFI("setVlanCif", 0, 0x1),
35     POP_VLAN("stripVlan", 0, 0), // Pop
36     PUSH_VLAN("pushVlan", 0, 0xffff), // Push (the max value only takes into account the TCI portion of the 802.1q header)
37     SET_DL_TYPE("setDlType", 0, 0xffff), // Set ethertype/length field
38     SET_NW_SRC("setNwSrc", 0, 0),
39     SET_NW_DST("setNwDst", 0, 0),
40     SET_NW_TOS("setNwTos", 0, 0x3f),
41     SET_TP_SRC("setTpSrc", 1, 0xffff),
42     SET_TP_DST("setTpDst", 1, 0xffff),
43     SET_NEXT_HOP("setNextHop", 0, 0);
44
45     private String id;
46     private int minValue;
47     private int maxValue;
48
49     private ActionType(String id, int minValue, int maxValue) {
50         this.id = id;
51         this.minValue = minValue;
52         this.maxValue = maxValue;
53     }
54
55     public String getId() {
56         return id;
57     }
58
59     public boolean isValidTarget(int value) {
60         return (value >= minValue && value <= maxValue);
61     }
62
63     public String getRange() {
64         return "[0x" + Long.toHexString(minValue) + "-0x"
65                 + Long.toHexString(maxValue) + "]";
66     }
67
68     public boolean takesParameter() {
69         switch (this) {
70         case POP_VLAN:
71         case DROP:
72         case SW_PATH:
73         case HW_PATH:
74         case CONTROLLER:
75         case LOOPBACK:
76         case FLOOD:
77         case FLOOD_ALL:
78             return false;
79         default:
80             return true;
81         }
82     }
83 }