Merge "BUG-2329 Add test for anyxmls inside rpc resonse for netcfon-connector"
[controller.git] / opendaylight / sal / api / src / main / java / org / opendaylight / controller / sal / action / PushVlan.java
index edb30ae031ac25f344b447aa83a6344c3f0965c6..a1b50edd5116fcc8a451d86ae2dff61d5f2b643e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2013-2014 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -59,6 +59,32 @@ public class PushVlan extends Action {
         runChecks();
     }
 
+    /**
+     * Construct a new action instance which represents OF 1.3 PUSH_VLAN.
+     *
+     * @param tag  An {@link EtherTypes} instance.
+     */
+    public PushVlan(EtherTypes tag) {
+        this(tag.intValue());
+    }
+
+    /**
+     * Construct a new action instance which represents OF 1.3 PUSH_VLAN.
+     *
+     * @param tag  An ethernet type of a new VLAN tag.
+     */
+    public PushVlan(int tag) {
+        type = ActionType.PUSH_VLAN;
+        this.tag = tag;
+
+        if (tag != EtherTypes.VLANTAGGED.intValue() &&
+            tag != EtherTypes.QINQ.intValue()) {
+            // pass a value which will tell fail and tell something about the
+            // original wrong value
+            checkValue(ActionType.SET_DL_TYPE, 0xBAD << 16 | tag);
+        }
+    }
+
     private int createTci() {
         return (pcp & 0x7) << 13 | (cfi & 0x1) << 12 | (vlanId & 0xfff);
     }