Exported package for classifier-definitions and action-definitions
[groupbasedpolicy.git] / renderers / ofoverlay / src / main / java / org / opendaylight / groupbasedpolicy / renderer / ofoverlay / sf / IpProtoClassifier.java
index d884cec61db5c99c635fecbdb930a58624f7412d..65d6b0b23c7394eb2501e0bbfecfb2f61893a915 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
@@ -17,9 +17,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;
@@ -32,17 +32,38 @@ import com.google.common.collect.ImmutableList;
  */
 public class IpProtoClassifier extends Classifier {
 
-    public static final Long TCP = Long.valueOf(6);
-    public static final Long UDP = Long.valueOf(17);
-    public static final Long SCTP = Long.valueOf(132);
-    public static final String PROTO = "proto";
-    public static final ClassifierDefinitionId ID = new ClassifierDefinitionId("79c6fdb2-1e1a-4832-af57-c65baf5c2335");
-    protected static final ClassifierDefinition DEF = new ClassifierDefinitionBuilder().setId(ID)
+    /**
+     * Protocol parameter name
+     */
+    public static final String PROTO_PARAM = "proto";
+    /**
+     * TCP protocol value
+     */
+    public static final Long TCP_VALUE = Long.valueOf(6);
+    /**
+     * UDP protocol value
+     */
+    public static final Long UDP_VALUE = Long.valueOf(17);
+    /**
+     * ICMP protocol value
+     */
+    public static final Long ICMP_VALUE = Long.valueOf(1);
+    /**
+     * SCTP protocol value
+     */
+    public static final Long SCTP_VALUE = Long.valueOf(132);
+
+    protected static final ClassifierDefinitionId ID = new ClassifierDefinitionId(
+            "79c6fdb2-1e1a-4832-af57-c65baf5c2335");
+    /**
+     * Protocol classifier-definition
+     */
+    public static final ClassifierDefinition DEFINITION = new ClassifierDefinitionBuilder().setId(ID)
         .setParent(EtherTypeClassifier.ID)
         .setName(new ClassifierName("ip_proto"))
         .setDescription(new Description("Match on the IP protocol of IP traffic"))
         .setParameter(
-                ImmutableList.of(new ParameterBuilder().setName(new ParameterName(PROTO))
+                ImmutableList.of(new ParameterBuilder().setName(new ParameterName(PROTO_PARAM))
                     .setDescription(new Description("The IP protocol to match against"))
                     .setIsRequired(IsRequired.Required)
                     .setType(Type.Int)
@@ -60,16 +81,16 @@ public class IpProtoClassifier extends Classifier {
 
     @Override
     public ClassifierDefinition getClassDef() {
-        return DEF;
+        return DEFINITION;
     }
 
     @Override
     protected void checkPresenceOfRequiredParams(Map<String, ParameterValue> params) {
-        if (params.get(PROTO) == null) {
+        if (params.get(PROTO_PARAM) == null) {
             throw new IllegalArgumentException("Classifier: {" + this.getClassDef().getName()
                     + "}+ Parameter proto not present.");
         }
-        if (params.get(PROTO).getIntValue() == null) {
+        if (params.get(PROTO_PARAM).getIntValue() == null) {
             throw new IllegalArgumentException("Classifier: {" + this.getClassDef().getName()
                     + "}+ Value of proto parameter is not present.");
         }
@@ -77,7 +98,7 @@ public class IpProtoClassifier extends Classifier {
 
     @Override
     protected List<MatchBuilder> update(List<MatchBuilder> matches, Map<String, ParameterValue> params) {
-        Long proto = params.get(PROTO).getIntValue();
+        Long proto = params.get(PROTO_PARAM).getIntValue();
         for (MatchBuilder match : matches) {
             IpMatchBuilder imb;
             if (match.getIpMatch() != null) {
@@ -124,10 +145,10 @@ public class IpProtoClassifier extends Classifier {
         if (params == null) {
             return null;
         }
-        if (params.get(PROTO) == null) {
+        if (params.get(PROTO_PARAM) == null) {
             return null;
         }
-        Long proto = params.get(PROTO).getIntValue();
+        Long proto = params.get(PROTO_PARAM).getIntValue();
         if (proto != null) {
             return proto;
         }