Exported package for classifier-definitions and action-definitions
[groupbasedpolicy.git] / renderers / ofoverlay / src / main / java / org / opendaylight / groupbasedpolicy / renderer / ofoverlay / sf / EtherTypeClassifier.java
index 70ba21e7aadd2b77c62dea54fdaf014375a27f80..24c1b64435f577dab90d711658de38ad8ad6b714 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 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,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
@@ -16,9 +16,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ClassifierName;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.Description;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ParameterName;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definition.ParameterBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definition.Parameter.IsRequired;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definition.Parameter.Type;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definition.ParameterBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ClassifierDefinition;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ClassifierDefinitionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.instance.ParameterValue;
@@ -34,13 +34,33 @@ import com.google.common.collect.ImmutableList;
  */
 public class EtherTypeClassifier extends Classifier {
 
-    public static final ClassifierDefinitionId ID = new ClassifierDefinitionId("6a48ab45-a462-429d-b18c-3a575b2c8bef");
-    public static final String ETHER_TYPE = "ethertype";
-    protected static final ClassifierDefinition DEF = new ClassifierDefinitionBuilder().setId(ID)
+    /**
+     * Ethertype parameter name
+     */
+    public static final String ETHERTYPE_PARAM = "ethertype";
+    /**
+     * ARP ethertype value
+     */
+    public static final Long ARP_VALUE = Long.valueOf(0x0806);
+    /**
+     * IPv4 ethertype value
+     */
+    public static final Long IPv4_VALUE = Long.valueOf(0x0800);
+    /**
+     * IPv6 ethertype value
+     */
+    public static final Long IPv6_VALUE = Long.valueOf(0x86DD);
+
+    protected static final ClassifierDefinitionId ID = new ClassifierDefinitionId(
+            "6a48ab45-a462-429d-b18c-3a575b2c8bef");
+    /**
+     * Ethertype classifier-definition
+     */
+    public static final ClassifierDefinition DEFINITION = new ClassifierDefinitionBuilder().setId(ID)
         .setName(new ClassifierName("ether_type"))
         .setDescription(new Description("Match on the ether type of the traffic"))
         .setParameter(
-                ImmutableList.of(new ParameterBuilder().setName(new ParameterName(ETHER_TYPE))
+                ImmutableList.of(new ParameterBuilder().setName(new ParameterName(ETHERTYPE_PARAM))
                     .setDescription(new Description("The ethertype to match against"))
                     .setIsRequired(IsRequired.Required)
                     .setType(Type.Int)
@@ -58,16 +78,16 @@ public class EtherTypeClassifier extends Classifier {
 
     @Override
     public ClassifierDefinition getClassDef() {
-        return DEF;
+        return DEFINITION;
     }
 
     @Override
     protected void checkPresenceOfRequiredParams(Map<String, ParameterValue> params) {
-        if (params.get(ETHER_TYPE) == null) {
+        if (params.get(ETHERTYPE_PARAM) == null) {
             throw new IllegalArgumentException("Classifier: {" + this.getClassDef().getName()
                     + "}+ Parameter ethertype not present.");
         }
-        if (params.get(ETHER_TYPE).getIntValue() == null) {
+        if (params.get(ETHERTYPE_PARAM).getIntValue() == null) {
             throw new IllegalArgumentException("Classifier: {" + this.getClassDef().getName()
                     + "}+ Value of ethertype parameter is not present.");
         }
@@ -75,7 +95,7 @@ public class EtherTypeClassifier extends Classifier {
 
     @Override
     protected List<MatchBuilder> update(List<MatchBuilder> matches, Map<String, ParameterValue> params) {
-        Long type = params.get(ETHER_TYPE).getIntValue();
+        Long type = params.get(ETHERTYPE_PARAM).getIntValue();
         for (MatchBuilder match : matches) {
             EthernetMatchBuilder em;
             if (match.getEthernetMatch() != null) {