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