From: Martin Sunal Date: Mon, 6 Apr 2015 23:25:20 +0000 (+0200) Subject: Exported package for classifier-definitions and action-definitions X-Git-Tag: release/lithium~125 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=39273988286e0431eeabcbda2c0fe9c76a874b9d;p=groupbasedpolicy.git Exported package for classifier-definitions and action-definitions This allows to use classes from this package in other bundles. Added javadoc comments. Corrected visibility of class members on API. Signed-off-by: Martin Sunal --- diff --git a/renderers/ofoverlay/pom.xml b/renderers/ofoverlay/pom.xml index 6b4df61c6..a1cf6576a 100644 --- a/renderers/ofoverlay/pom.xml +++ b/renderers/ofoverlay/pom.xml @@ -65,12 +65,13 @@ - org.apache.http.*;version="4.3.2", - *;resolution:=optional + org.apache.http.*;version="4.3.2", + *;resolution:=optional httpclient,httpcore,commons-lang,commons-exec;type=!pom;inline=false - + org.opendaylight.groupbasedpolicy.renderer.ofoverlay.sf + ${project.basedir}/META-INF diff --git a/renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/flow/PolicyEnforcer.java b/renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/flow/PolicyEnforcer.java index 2ecfd5ebc..9555a1844 100644 --- a/renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/flow/PolicyEnforcer.java +++ b/renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/flow/PolicyEnforcer.java @@ -8,6 +8,11 @@ package org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow; +import static org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.FlowUtils.addNxRegMatch; +import static org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.FlowUtils.applyActionIns; +import static org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.FlowUtils.instructions; +import static org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.FlowUtils.nxOutputRegAction; + import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -23,10 +28,10 @@ import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.OfContext; import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.PolicyManager.Dirty; import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.FlowUtils.RegMatch; +import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.sf.Action; import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.sf.AllowAction; import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.sf.ClassificationResult; import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.sf.Classifier; -import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.sf.Action; import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.sf.ParamDerivator; import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.sf.SubjectFeatures; import org.opendaylight.groupbasedpolicy.resolver.ConditionGroup; @@ -67,8 +72,6 @@ import org.slf4j.LoggerFactory; import com.google.common.collect.ComparisonChain; import com.google.common.collect.Ordering; -import static org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.FlowUtils.*; - /** * Manage the table that enforces policy on the traffic. Traffic is denied * unless specifically allowed by policy @@ -305,7 +308,7 @@ public class PolicyEnforcer extends FlowTable { } } else { - Action act = SubjectFeatures.getAction(AllowAction.ID); + Action act = SubjectFeatures.getAction(AllowAction.DEFINITION.getId()); abl = act.updateAction(abl, new HashMap(), 0); } @@ -386,7 +389,7 @@ public class PolicyEnforcer extends FlowTable { ClassificationResult result = cfier.updateMatch(matches, flowParams); if(!result.isSuccessfull()) { //TODO consider different handling. - throw new IllegalArgumentException(result.getMessage()); + throw new IllegalArgumentException(result.getErrorMessage()); } String baseId = idb.toString(); FlowBuilder flow = base().setPriority(Integer.valueOf(priority)); diff --git a/renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/AllowAction.java b/renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/AllowAction.java index 87bad6048..8a2cc7de4 100644 --- a/renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/AllowAction.java +++ b/renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/AllowAction.java @@ -26,19 +26,18 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev14 * Allow action */ public class AllowAction extends Action { - public static final ActionDefinitionId ID = - new ActionDefinitionId("f942e8fd-e957-42b7-bd18-f73d11266d17"); - protected static final String TYPE = "type"; - protected static final ActionDefinition DEF = - new ActionDefinitionBuilder() - .setId(ID) - .setName(new ActionName("allow")) - .setDescription(new Description("Allow the specified traffic to pass")) - .build(); + + protected static final ActionDefinitionId ID = new ActionDefinitionId("f942e8fd-e957-42b7-bd18-f73d11266d17"); + /** + * Access control - allow action-definition + */ + public static final ActionDefinition DEFINITION = new ActionDefinitionBuilder().setId(ID) + .setName(new ActionName("allow")) + .setDescription(new Description("Allow the specified traffic to pass")) + .build(); // How allow is implemented in the PolicyEnforcer table - private final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action allow = - nxOutputRegAction(NxmNxReg7.class); + private final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action allow = nxOutputRegAction(NxmNxReg7.class); @Override public ActionDefinitionId getId() { @@ -47,7 +46,7 @@ public class AllowAction extends Action { @Override public ActionDefinition getActionDef() { - return DEF; + return DEFINITION; } @Override diff --git a/renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/ClassificationResult.java b/renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/ClassificationResult.java index 5f38f90a6..3c605e437 100644 --- a/renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/ClassificationResult.java +++ b/renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/ClassificationResult.java @@ -16,22 +16,32 @@ import com.google.common.base.Preconditions; public class ClassificationResult { - private final String message; + private final String errorMessage; private final boolean isSuccessful; private final List matchBuilders; + /** + * @param errorMessage cannot be {@code null} + */ public ClassificationResult(String errorMessage) { - this.message = Preconditions.checkNotNull(errorMessage); + this.errorMessage = Preconditions.checkNotNull(errorMessage); this.isSuccessful = false; matchBuilders = null; } + /** + * @param matches cannot be {@code null} + */ public ClassificationResult(List matches) { - message = ""; + errorMessage = ""; this.matchBuilders = Preconditions.checkNotNull(matches); this.isSuccessful = true; } + /** + * @return list of {@link MatchBuilder} + * @throws IllegalStateException if this method is called and {@link #isSuccessfull()} == {@code false} + */ public List getMatchBuilders() { if (isSuccessful == false) { throw new IllegalStateException("Classification was not successfull."); @@ -39,10 +49,16 @@ public class ClassificationResult { return matchBuilders; } - public String getMessage() { - return message; + /** + * @return contains error message if {@link #isSuccessfull()} == {@code false} + */ + public String getErrorMessage() { + return errorMessage; } + /** + * @return {@code true} if {@link ClassificationResult} contains result. {@code false} if {@link ClassificationResult} contains error message. + */ public boolean isSuccessfull() { return isSuccessful; } diff --git a/renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/EtherTypeClassifier.java b/renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/EtherTypeClassifier.java index 70ba21e7a..24c1b6443 100644 --- a/renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/EtherTypeClassifier.java +++ b/renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/EtherTypeClassifier.java @@ -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 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 update(List matches, Map 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) { diff --git a/renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/IpProtoClassifier.java b/renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/IpProtoClassifier.java index d884cec61..65d6b0b23 100644 --- a/renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/IpProtoClassifier.java +++ b/renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/IpProtoClassifier.java @@ -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 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 update(List matches, Map 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; } diff --git a/renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/L4Classifier.java b/renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/L4Classifier.java index ce15981b6..87a016ab8 100755 --- a/renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/L4Classifier.java +++ b/renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/L4Classifier.java @@ -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 @@ -43,31 +43,47 @@ import com.google.common.collect.ImmutableList; */ public class L4Classifier extends Classifier { - public static final String SPORT = "sourceport"; - public static final String SPORT_RANGE = "sourceport_range"; - public static final String DPORT = "destport"; - public static final String DPORT_RANGE = "destport_range"; - public static final ClassifierDefinitionId ID = new ClassifierDefinitionId("4250ab32-e8b8-445a-aebb-e1bd2cdd291f"); - private static final ClassifierDefinition DEF = new ClassifierDefinitionBuilder().setId( + /** + * Source port parameter name + */ + public static final String SRC_PORT_PARAM = "sourceport"; + /** + * Source port range parameter name + */ + public static final String SRC_PORT_RANGE_PARAM = "sourceport_range"; + /** + * Destination port parameter name + */ + public static final String DST_PORT_PARAM = "destport"; + /** + * Destination port range parameter name + */ + public static final String DST_PORT_RANGE_PARAM = "destport_range"; + + protected static final ClassifierDefinitionId ID = new ClassifierDefinitionId( + "4250ab32-e8b8-445a-aebb-e1bd2cdd291f"); + /** + * Layer 4 classifier-definition + */ + public static final ClassifierDefinition DEFINITION = new ClassifierDefinitionBuilder().setId( new ClassifierDefinitionId("4250ab32-e8b8-445a-aebb-e1bd2cdd291f")) .setParent(IpProtoClassifier.ID) .setName(new ClassifierName("l4")) .setDescription(new Description("Match on the port number of UDP or TCP traffic")) .setParameter( ImmutableList.of( - new ParameterBuilder().setName(new ParameterName(SPORT)) + new ParameterBuilder().setName(new ParameterName(SRC_PORT_PARAM)) .setDescription(new Description("The source port number to match against")) .setType(Type.Int) .build(), - new ParameterBuilder().setName(new ParameterName(SPORT_RANGE)) + new ParameterBuilder().setName(new ParameterName(SRC_PORT_RANGE_PARAM)) .setDescription(new Description("The source port range to match against")) .setType(Type.Range) .build(), - new ParameterBuilder().setName(new ParameterName(DPORT)) + new ParameterBuilder().setName(new ParameterName(DST_PORT_PARAM)) .setDescription(new Description("The destination port number to match against")) .setType(Type.Int) - .build(), - new ParameterBuilder().setName(new ParameterName(DPORT_RANGE)) + .build(), new ParameterBuilder().setName(new ParameterName(DST_PORT_RANGE_PARAM)) .setDescription(new Description("The destination port range to match against")) .setType(Type.Range) .build())) @@ -84,40 +100,40 @@ public class L4Classifier extends Classifier { @Override public ClassifierDefinition getClassDef() { - return DEF; + return DEFINITION; } @Override protected void checkPresenceOfRequiredParams(Map params) { - if (params.get(SPORT) != null && params.get(SPORT_RANGE) != null) { + if (params.get(SRC_PORT_PARAM) != null && params.get(SRC_PORT_RANGE_PARAM) != null) { throw new IllegalArgumentException("Classifier: {" + this.getClassDef().getName() + "}+. Illegal source port parameters: 'int' and 'range' values are mutually exclusive."); } - if (params.get(DPORT) != null && params.get(DPORT_RANGE) != null) { + if (params.get(DST_PORT_PARAM) != null && params.get(DST_PORT_RANGE_PARAM) != null) { throw new IllegalArgumentException("Classifier: {" + this.getClassDef().getName() + "}+. Illegal destination port parameters: 'int' and 'range' values are mutually exclusive."); } - if (params.get(SPORT) != null) { - if (params.get(SPORT).getIntValue() == null) { + if (params.get(SRC_PORT_PARAM) != null) { + if (params.get(SRC_PORT_PARAM).getIntValue() == null) { throw new IllegalArgumentException("Classifier: {" + this.getClassDef().getName() + "}+ Value of sourceport parameter is not present."); } } - if (params.get(SPORT_RANGE) != null) { - if (params.get(SPORT_RANGE) != null) { - validateRangeValue(params.get(SPORT_RANGE).getRangeValue()); + if (params.get(SRC_PORT_RANGE_PARAM) != null) { + if (params.get(SRC_PORT_RANGE_PARAM) != null) { + validateRangeValue(params.get(SRC_PORT_RANGE_PARAM).getRangeValue()); } } - if (params.get(DPORT) != null) { - if (params.get(DPORT).getIntValue() == null) { + if (params.get(DST_PORT_PARAM) != null) { + if (params.get(DST_PORT_PARAM).getIntValue() == null) { throw new IllegalArgumentException("Classifier: {" + this.getClassDef().getName() + "}+ Value of destport parameter is not present."); } } - if (params.get(DPORT_RANGE) != null) { - if (params.get(DPORT_RANGE) != null) { - validateRangeValue(params.get(DPORT_RANGE).getRangeValue()); + if (params.get(DST_PORT_RANGE_PARAM) != null) { + if (params.get(DST_PORT_RANGE_PARAM) != null) { + validateRangeValue(params.get(DST_PORT_RANGE_PARAM).getRangeValue()); } } } @@ -139,15 +155,15 @@ public class L4Classifier extends Classifier { public List update(List matches, Map params) { Set sPorts = new HashSet<>(); Set dPorts = new HashSet<>(); - if (params.get(SPORT) != null) { - sPorts.add(params.get(SPORT).getIntValue()); - } else if (params.get(SPORT_RANGE) != null) { - sPorts.addAll(createSetFromRange(params.get(SPORT_RANGE).getRangeValue())); + if (params.get(SRC_PORT_PARAM) != null) { + sPorts.add(params.get(SRC_PORT_PARAM).getIntValue()); + } else if (params.get(SRC_PORT_RANGE_PARAM) != null) { + sPorts.addAll(createSetFromRange(params.get(SRC_PORT_RANGE_PARAM).getRangeValue())); } - if (params.get(DPORT) != null) { - dPorts.add(params.get(DPORT).getIntValue()); - } else if (params.get(DPORT_RANGE) != null) { - dPorts.addAll(createSetFromRange(params.get(DPORT_RANGE).getRangeValue())); + if (params.get(DST_PORT_PARAM) != null) { + dPorts.add(params.get(DST_PORT_PARAM).getIntValue()); + } else if (params.get(DST_PORT_RANGE_PARAM) != null) { + dPorts.addAll(createSetFromRange(params.get(DST_PORT_RANGE_PARAM).getRangeValue())); } List newMatches = new ArrayList<>(); @@ -177,11 +193,11 @@ public class L4Classifier extends Classifier { throw new IllegalArgumentException("Classifier-instance " + this.getClassDef().getName() + ": L4 protocol is null."); } - if (IpProtoClassifier.UDP.equals(ipProto)) { + if (IpProtoClassifier.UDP_VALUE.equals(ipProto)) { return new UdpMatchBuilder().build(); - } else if (IpProtoClassifier.TCP.equals(ipProto)) { + } else if (IpProtoClassifier.TCP_VALUE.equals(ipProto)) { return new TcpMatchBuilder().build(); - } else if (IpProtoClassifier.SCTP.equals(ipProto)) { + } else if (IpProtoClassifier.SCTP_VALUE.equals(ipProto)) { return new SctpMatchBuilder().build(); } throw new IllegalArgumentException("Unsupported L4 protocol."); @@ -300,8 +316,8 @@ public class L4Classifier extends Classifier { } catch (NullPointerException e) { throw new IllegalArgumentException("Ip proto match is missing."); } - if (!IpProtoClassifier.TCP.equals(proto) && !IpProtoClassifier.UDP.equals(proto) - && !IpProtoClassifier.SCTP.equals(proto)) { + if (!IpProtoClassifier.TCP_VALUE.equals(proto) && !IpProtoClassifier.UDP_VALUE.equals(proto) + && !IpProtoClassifier.SCTP_VALUE.equals(proto)) { throw new IllegalArgumentException("Unsupported proto value.\n" + "Classifier: " + this.getClass().getName() + ", proto set: " + proto); } diff --git a/renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/ParamDerivator.java b/renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/ParamDerivator.java index 99b60df9d..b5f66066e 100644 --- a/renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/ParamDerivator.java +++ b/renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/ParamDerivator.java @@ -39,12 +39,12 @@ public abstract class ParamDerivator { @Override public List> deriveParameter(Map params) { - if (!params.containsKey(EtherTypeClassifier.ETHER_TYPE)) { + if (!params.containsKey(EtherTypeClassifier.ETHERTYPE_PARAM)) { Map ipv4Params = new HashMap<>(params); Map ipv6Params = new HashMap<>(params); - ipv4Params.put(EtherTypeClassifier.ETHER_TYPE, new ParameterValueBuilder().setIntValue(FlowUtils.IPv4) + ipv4Params.put(EtherTypeClassifier.ETHERTYPE_PARAM, new ParameterValueBuilder().setIntValue(FlowUtils.IPv4) .build()); - ipv6Params.put(EtherTypeClassifier.ETHER_TYPE, new ParameterValueBuilder().setIntValue(FlowUtils.IPv6) + ipv6Params.put(EtherTypeClassifier.ETHERTYPE_PARAM, new ParameterValueBuilder().setIntValue(FlowUtils.IPv6) .build()); List> derivedParams = new ArrayList<>(); derivedParams.add(ipv4Params); diff --git a/renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/SubjectFeatures.java b/renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/SubjectFeatures.java index 3840f3f8f..64822f1ca 100644 --- a/renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/SubjectFeatures.java +++ b/renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/SubjectFeatures.java @@ -47,7 +47,7 @@ public class SubjectFeatures { ImmutableMap. of(AllowAction.ID, new AllowAction()); - public static final List actionDefs = + private static final List actionDefs = ImmutableList.copyOf(Collections2.transform(actions.values(), new Function() { @Override diff --git a/renderers/ofoverlay/src/test/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/flow/OfTableTest.java b/renderers/ofoverlay/src/test/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/flow/OfTableTest.java index b17756d26..cd7beaf42 100644 --- a/renderers/ofoverlay/src/test/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/flow/OfTableTest.java +++ b/renderers/ofoverlay/src/test/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/flow/OfTableTest.java @@ -157,7 +157,7 @@ public class OfTableTest { .setSubjectFeatureInstances(new SubjectFeatureInstancesBuilder() .setClassifierInstance(ImmutableList.of(new ClassifierInstanceBuilder() .setName(new ClassifierName("tcp_80")) - .setClassifierDefinitionId(L4Classifier.ID) + .setClassifierDefinitionId(L4Classifier.DEFINITION.getId()) .setParameterValue(ImmutableList.of(new ParameterValueBuilder() .setName(new ParameterName("destport")) .setIntValue(Long.valueOf(80)) @@ -195,7 +195,7 @@ public class OfTableTest { .build())) .build())); } - + protected EndpointBuilder baseEP() { return new EndpointBuilder() .setL2Context(bd) @@ -222,5 +222,5 @@ public class OfTableTest { .setMacAddress(new MacAddress("00:00:00:00:00:02")) .addAugmentation(OfOverlayContext.class, ofc); } - + } diff --git a/renderers/ofoverlay/src/test/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/ClassifierTest.java b/renderers/ofoverlay/src/test/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/ClassifierTest.java index d9d461c17..e3deebf9a 100644 --- a/renderers/ofoverlay/src/test/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/ClassifierTest.java +++ b/renderers/ofoverlay/src/test/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/ClassifierTest.java @@ -43,10 +43,10 @@ public class ClassifierTest { Long dstRangeStart = Long.valueOf(8079); Long dstRangeEnd = Long.valueOf(8081); - params.putAll(ClassifierTestUtils.createIntValueParam(EtherTypeClassifier.ETHER_TYPE, FlowUtils.IPv4)); - params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO, ClassifierTestUtils.TCP)); - params.putAll(ClassifierTestUtils.createIntValueParam(L4Classifier.SPORT, 80)); - params.putAll(ClassifierTestUtils.createRangeValueParam(L4Classifier.DPORT_RANGE, dstRangeStart, dstRangeEnd)); + params.putAll(ClassifierTestUtils.createIntValueParam(EtherTypeClassifier.ETHERTYPE_PARAM, FlowUtils.IPv4)); + params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO_PARAM, ClassifierTestUtils.TCP)); + params.putAll(ClassifierTestUtils.createIntValueParam(L4Classifier.SRC_PORT_PARAM, 80)); + params.putAll(ClassifierTestUtils.createRangeValueParam(L4Classifier.DST_PORT_RANGE_PARAM, dstRangeStart, dstRangeEnd)); ClassificationResult result = Classifier.L4_CL.updateMatch(matches, params); assertEquals(true, result.isSuccessfull()); assertEquals(3, result.getMatchBuilders().size()); diff --git a/renderers/ofoverlay/src/test/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/EtherTypeClassifierTest.java b/renderers/ofoverlay/src/test/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/EtherTypeClassifierTest.java index 7ccc63b31..07c330cdc 100644 --- a/renderers/ofoverlay/src/test/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/EtherTypeClassifierTest.java +++ b/renderers/ofoverlay/src/test/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/EtherTypeClassifierTest.java @@ -36,7 +36,7 @@ public class EtherTypeClassifierTest { public void setValueTest() { matches.add(new MatchBuilder() .setIpMatch(ClassifierTestUtils.createIpMatch(ClassifierTestUtils.TCP.shortValue()))); - params.putAll(ClassifierTestUtils.createIntValueParam(EtherTypeClassifier.ETHER_TYPE, FlowUtils.IPv4)); + params.putAll(ClassifierTestUtils.createIntValueParam(EtherTypeClassifier.ETHERTYPE_PARAM, FlowUtils.IPv4)); matches = Classifier.ETHER_TYPE_CL.update(matches, params); assertEquals(true, ClassifierTestUtils.IPV4_ETH_TYPE.equals(matches.get(0).getEthernetMatch().getEthernetType())); assertEquals(true, ClassifierTestUtils.TCP.equals(matches.get(0).getIpMatch().getIpProtocol().longValue())); @@ -47,7 +47,7 @@ public class EtherTypeClassifierTest { matches.add(new MatchBuilder() .setEthernetMatch(ClassifierTestUtils.createEthernetMatch(ClassifierTestUtils.IPV6_ETH_TYPE)) .setIpMatch(ClassifierTestUtils.createIpMatch(ClassifierTestUtils.UDP.shortValue()))); - params.putAll(ClassifierTestUtils.createIntValueParam(EtherTypeClassifier.ETHER_TYPE, FlowUtils.IPv6)); + params.putAll(ClassifierTestUtils.createIntValueParam(EtherTypeClassifier.ETHERTYPE_PARAM, FlowUtils.IPv6)); matches = Classifier.ETHER_TYPE_CL.update(matches, params); assertEquals(true, ClassifierTestUtils.IPV6_ETH_TYPE.equals(matches.get(0).getEthernetMatch().getEthernetType())); assertEquals(true, ClassifierTestUtils.UDP.equals(matches.get(0).getIpMatch().getIpProtocol().longValue())); @@ -58,7 +58,7 @@ public class EtherTypeClassifierTest { matches.add(new MatchBuilder() .setEthernetMatch(ClassifierTestUtils.createEthernetMatch(ClassifierTestUtils.IPV4_ETH_TYPE)) .setIpMatch(ClassifierTestUtils.createIpMatch(ClassifierTestUtils.SCTP.shortValue()))); - params.putAll(ClassifierTestUtils.createIntValueParam(EtherTypeClassifier.ETHER_TYPE, FlowUtils.IPv6)); + params.putAll(ClassifierTestUtils.createIntValueParam(EtherTypeClassifier.ETHERTYPE_PARAM, FlowUtils.IPv6)); thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Trying to override ether-type value:"); matches = Classifier.ETHER_TYPE_CL.update(matches, params); @@ -66,7 +66,7 @@ public class EtherTypeClassifierTest { @Test public void checkPresenceOfRequiredParameters1Test() { - params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO, ClassifierTestUtils.TCP)); + params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO_PARAM, ClassifierTestUtils.TCP)); thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Parameter ethertype not present"); Classifier.ETHER_TYPE_CL.checkPresenceOfRequiredParams(params); @@ -74,7 +74,7 @@ public class EtherTypeClassifierTest { @Test public void checkPresenceOfRequiredParameters2Test() { - params.putAll(ImmutableMap. of(EtherTypeClassifier.ETHER_TYPE, + params.putAll(ImmutableMap. of(EtherTypeClassifier.ETHERTYPE_PARAM, new ParameterValueBuilder().build())); thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Value of ethertype parameter is not present"); diff --git a/renderers/ofoverlay/src/test/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/IpProtoClassifierTest.java b/renderers/ofoverlay/src/test/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/IpProtoClassifierTest.java index d106fd6d5..5db2da601 100644 --- a/renderers/ofoverlay/src/test/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/IpProtoClassifierTest.java +++ b/renderers/ofoverlay/src/test/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/IpProtoClassifierTest.java @@ -36,7 +36,7 @@ public class IpProtoClassifierTest { public void setValueTest() { matches.add(new MatchBuilder() .setEthernetMatch(ClassifierTestUtils.createEthernetMatch(ClassifierTestUtils.IPV4_ETH_TYPE))); - params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO, ClassifierTestUtils.TCP)); + params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO_PARAM, ClassifierTestUtils.TCP)); matches = Classifier.IP_PROTO_CL.update(matches, params); assertEquals(true, ClassifierTestUtils.IPV4_ETH_TYPE.equals(matches.get(0).getEthernetMatch().getEthernetType())); assertEquals(true, ClassifierTestUtils.TCP.equals(matches.get(0).getIpMatch().getIpProtocol().longValue())); @@ -47,7 +47,7 @@ public class IpProtoClassifierTest { matches.add(new MatchBuilder() .setEthernetMatch(ClassifierTestUtils.createEthernetMatch(ClassifierTestUtils.IPV6_ETH_TYPE)) .setIpMatch(ClassifierTestUtils.createIpMatch(ClassifierTestUtils.UDP.shortValue()))); - params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO, ClassifierTestUtils.UDP)); + params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO_PARAM, ClassifierTestUtils.UDP)); matches = Classifier.IP_PROTO_CL.update(matches, params); assertEquals(true, ClassifierTestUtils.IPV6_ETH_TYPE.equals(matches.get(0).getEthernetMatch().getEthernetType())); assertEquals(true, ClassifierTestUtils.UDP.equals(matches.get(0).getIpMatch().getIpProtocol().longValue())); @@ -58,7 +58,7 @@ public class IpProtoClassifierTest { matches.add(new MatchBuilder() .setEthernetMatch(ClassifierTestUtils.createEthernetMatch(ClassifierTestUtils.IPV4_ETH_TYPE)) .setIpMatch(ClassifierTestUtils.createIpMatch(ClassifierTestUtils.SCTP.shortValue()))); - params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO, ClassifierTestUtils.TCP)); + params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO_PARAM, ClassifierTestUtils.TCP)); thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Trying to override proto value"); matches = Classifier.IP_PROTO_CL.update(matches, params); @@ -66,7 +66,7 @@ public class IpProtoClassifierTest { @Test public void checkPresenceOfRequiredParameters1Test() { - params.putAll(ClassifierTestUtils.createIntValueParam(EtherTypeClassifier.ETHER_TYPE, FlowUtils.IPv4)); + params.putAll(ClassifierTestUtils.createIntValueParam(EtherTypeClassifier.ETHERTYPE_PARAM, FlowUtils.IPv4)); thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Parameter proto not present"); Classifier.IP_PROTO_CL.checkPresenceOfRequiredParams(params); @@ -74,7 +74,7 @@ public class IpProtoClassifierTest { @Test public void checkPresenceOfRequiredParameters2Test() { - params.putAll(ImmutableMap. of(IpProtoClassifier.PROTO, + params.putAll(ImmutableMap. of(IpProtoClassifier.PROTO_PARAM, new ParameterValueBuilder().build())); thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Value of proto parameter is not present"); diff --git a/renderers/ofoverlay/src/test/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/L4ClassifierTest.java b/renderers/ofoverlay/src/test/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/L4ClassifierTest.java index 08d52df03..38a44c208 100644 --- a/renderers/ofoverlay/src/test/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/L4ClassifierTest.java +++ b/renderers/ofoverlay/src/test/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/L4ClassifierTest.java @@ -45,8 +45,8 @@ public class L4ClassifierTest { matches.add(new MatchBuilder() .setEthernetMatch(ClassifierTestUtils.createEthernetMatch(ClassifierTestUtils.IPV4_ETH_TYPE))); Long sPort = Long.valueOf(80); - params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO, ClassifierTestUtils.TCP)); - params.putAll(ClassifierTestUtils.createIntValueParam(L4Classifier.SPORT, sPort)); + params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO_PARAM, ClassifierTestUtils.TCP)); + params.putAll(ClassifierTestUtils.createIntValueParam(L4Classifier.SRC_PORT_PARAM, sPort)); matches = Classifier.L4_CL.update(matches, params); assertEquals(true, ClassifierTestUtils.IPV4_ETH_TYPE.equals(matches.get(0).getEthernetMatch().getEthernetType())); TcpMatch match = new TcpMatchBuilder((TcpMatch) matches.get(0).getLayer4Match()).build(); @@ -59,8 +59,8 @@ public class L4ClassifierTest { Long dPort = Long.valueOf(80); matches.add(new MatchBuilder() .setEthernetMatch(ClassifierTestUtils.createEthernetMatch(ClassifierTestUtils.IPV6_ETH_TYPE))); - params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO, ClassifierTestUtils.TCP)); - params.putAll(ClassifierTestUtils.createIntValueParam(L4Classifier.DPORT, dPort)); + params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO_PARAM, ClassifierTestUtils.TCP)); + params.putAll(ClassifierTestUtils.createIntValueParam(L4Classifier.DST_PORT_PARAM, dPort)); matches = Classifier.L4_CL.update(matches, params); assertEquals(true, ClassifierTestUtils.IPV6_ETH_TYPE.equals(matches.get(0).getEthernetMatch().getEthernetType())); TcpMatch match = new TcpMatchBuilder((TcpMatch) matches.get(0).getLayer4Match()).build(); @@ -75,9 +75,9 @@ public class L4ClassifierTest { Long dstRangeStart = Long.valueOf(8079); Long dstRangeEnd = Long.valueOf(8081); Long srcPort = Long.valueOf(80); - params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO, ClassifierTestUtils.TCP)); - params.putAll(ClassifierTestUtils.createIntValueParam(L4Classifier.SPORT, srcPort)); - params.putAll(ClassifierTestUtils.createRangeValueParam(L4Classifier.DPORT_RANGE, dstRangeStart, dstRangeEnd)); + params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO_PARAM, ClassifierTestUtils.TCP)); + params.putAll(ClassifierTestUtils.createIntValueParam(L4Classifier.SRC_PORT_PARAM, srcPort)); + params.putAll(ClassifierTestUtils.createRangeValueParam(L4Classifier.DST_PORT_RANGE_PARAM, dstRangeStart, dstRangeEnd)); Classifier.L4_CL.checkPresenceOfRequiredParams(params); matches = Classifier.L4_CL.update(matches, params); Set dstPorts = new HashSet<>(); @@ -100,8 +100,8 @@ public class L4ClassifierTest { matches.add(new MatchBuilder() .setLayer4Match(ClassifierTestUtils.createUdpDstPort(80)) .setEthernetMatch(ClassifierTestUtils.createEthernetMatch(ClassifierTestUtils.IPV6_ETH_TYPE))); - params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO, ClassifierTestUtils.UDP)); - params.putAll(ClassifierTestUtils.createIntValueParam(L4Classifier.DPORT, dPort)); + params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO_PARAM, ClassifierTestUtils.UDP)); + params.putAll(ClassifierTestUtils.createIntValueParam(L4Classifier.DST_PORT_PARAM, dPort)); matches = Classifier.L4_CL.update(matches, params); assertEquals(true, ClassifierTestUtils.IPV6_ETH_TYPE.equals(matches.get(0).getEthernetMatch().getEthernetType())); UdpMatch match = new UdpMatchBuilder((UdpMatch) matches.get(0).getLayer4Match()).build(); @@ -116,8 +116,8 @@ public class L4ClassifierTest { .setEthernetMatch(ClassifierTestUtils.createEthernetMatch(ClassifierTestUtils.IPV4_ETH_TYPE))); Long srcRangeStart = Long.valueOf(8079); Long srcRangeEnd = Long.valueOf(8081); - params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO, ClassifierTestUtils.UDP)); - params.putAll(ClassifierTestUtils.createRangeValueParam(L4Classifier.SPORT_RANGE, srcRangeStart, srcRangeEnd)); + params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO_PARAM, ClassifierTestUtils.UDP)); + params.putAll(ClassifierTestUtils.createRangeValueParam(L4Classifier.SRC_PORT_RANGE_PARAM, srcRangeStart, srcRangeEnd)); matches = Classifier.L4_CL.update(matches, params); Set srcPorts = new HashSet<>(); for (MatchBuilder match : matches) { @@ -143,9 +143,9 @@ public class L4ClassifierTest { Long dPort = Long.valueOf(80); Long srcRangeStart = Long.valueOf(8079); Long srcRangeEnd = Long.valueOf(8081); - params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO, ClassifierTestUtils.UDP)); - params.putAll(ClassifierTestUtils.createIntValueParam(L4Classifier.DPORT, dPort)); - params.putAll(ClassifierTestUtils.createRangeValueParam(L4Classifier.SPORT_RANGE, srcRangeStart, srcRangeEnd)); + params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO_PARAM, ClassifierTestUtils.UDP)); + params.putAll(ClassifierTestUtils.createIntValueParam(L4Classifier.DST_PORT_PARAM, dPort)); + params.putAll(ClassifierTestUtils.createRangeValueParam(L4Classifier.SRC_PORT_RANGE_PARAM, srcRangeStart, srcRangeEnd)); Classifier.L4_CL.checkPresenceOfRequiredParams(params); matches = Classifier.L4_CL.update(matches, params); Set srcPorts = new HashSet<>(); @@ -169,8 +169,8 @@ public class L4ClassifierTest { matches.add(new MatchBuilder() .setLayer4Match(ClassifierTestUtils.createSctpSrcPort(sPort.intValue())) .setEthernetMatch(ClassifierTestUtils.createEthernetMatch(ClassifierTestUtils.IPV4_ETH_TYPE))); - params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO, ClassifierTestUtils.SCTP)); - params.putAll(ClassifierTestUtils.createIntValueParam(L4Classifier.SPORT, sPort)); + params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO_PARAM, ClassifierTestUtils.SCTP)); + params.putAll(ClassifierTestUtils.createIntValueParam(L4Classifier.SRC_PORT_PARAM, sPort)); matches = Classifier.L4_CL.update(matches, params); assertEquals(true, ClassifierTestUtils.IPV4_ETH_TYPE.equals(matches.get(0).getEthernetMatch().getEthernetType())); SctpMatch match = new SctpMatchBuilder((SctpMatch) matches.get(0).getLayer4Match()).build(); @@ -185,8 +185,8 @@ public class L4ClassifierTest { .setEthernetMatch(ClassifierTestUtils.createEthernetMatch(ClassifierTestUtils.IPV4_ETH_TYPE))); Long dstRangeStart = Long.valueOf(8079); Long dstRangeEnd = Long.valueOf(8081); - params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO, ClassifierTestUtils.SCTP)); - params.putAll(ClassifierTestUtils.createRangeValueParam(L4Classifier.DPORT_RANGE, dstRangeStart, dstRangeEnd)); + params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO_PARAM, ClassifierTestUtils.SCTP)); + params.putAll(ClassifierTestUtils.createRangeValueParam(L4Classifier.DST_PORT_RANGE_PARAM, dstRangeStart, dstRangeEnd)); matches = Classifier.L4_CL.update(matches, params); Set dstPorts = new HashSet<>(); for (MatchBuilder match : matches) { @@ -209,9 +209,9 @@ public class L4ClassifierTest { Long srcRangeEnd = Long.valueOf(81); Long dstRangeStart = Long.valueOf(8079); Long dstRangeEnd = Long.valueOf(8081); - params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO, ClassifierTestUtils.SCTP)); - params.putAll(ClassifierTestUtils.createRangeValueParam(L4Classifier.SPORT_RANGE, srcRangeStart, srcRangeEnd)); - params.putAll(ClassifierTestUtils.createRangeValueParam(L4Classifier.DPORT_RANGE, dstRangeStart, dstRangeEnd)); + params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO_PARAM, ClassifierTestUtils.SCTP)); + params.putAll(ClassifierTestUtils.createRangeValueParam(L4Classifier.SRC_PORT_RANGE_PARAM, srcRangeStart, srcRangeEnd)); + params.putAll(ClassifierTestUtils.createRangeValueParam(L4Classifier.DST_PORT_RANGE_PARAM, dstRangeStart, dstRangeEnd)); Classifier.L4_CL.checkPresenceOfRequiredParams(params); matches = Classifier.L4_CL.update(matches, params); Set> set = new HashSet<>(); @@ -235,9 +235,9 @@ public class L4ClassifierTest { Long srcRangeStart = Long.valueOf(8079); Long srcRangeEnd = Long.valueOf(8081); Long srcPort = Long.valueOf(80); - params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO, ClassifierTestUtils.SCTP)); - params.putAll(ClassifierTestUtils.createIntValueParam(L4Classifier.SPORT, srcPort)); - params.putAll(ClassifierTestUtils.createRangeValueParam(L4Classifier.SPORT_RANGE, srcRangeStart, srcRangeEnd)); + params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO_PARAM, ClassifierTestUtils.SCTP)); + params.putAll(ClassifierTestUtils.createIntValueParam(L4Classifier.SRC_PORT_PARAM, srcPort)); + params.putAll(ClassifierTestUtils.createRangeValueParam(L4Classifier.SRC_PORT_RANGE_PARAM, srcRangeStart, srcRangeEnd)); thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Illegal source port parameters"); Classifier.L4_CL.checkPresenceOfRequiredParams(params); @@ -249,9 +249,9 @@ public class L4ClassifierTest { Long dstRangeStart = Long.valueOf(8079); Long dstRangeEnd = Long.valueOf(8081); Long dstPort = Long.valueOf(80); - params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO, ClassifierTestUtils.UDP)); - params.putAll(ClassifierTestUtils.createIntValueParam(L4Classifier.DPORT, dstPort)); - params.putAll(ClassifierTestUtils.createRangeValueParam(L4Classifier.DPORT_RANGE, dstRangeStart, dstRangeEnd)); + params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO_PARAM, ClassifierTestUtils.UDP)); + params.putAll(ClassifierTestUtils.createIntValueParam(L4Classifier.DST_PORT_PARAM, dstPort)); + params.putAll(ClassifierTestUtils.createRangeValueParam(L4Classifier.DST_PORT_RANGE_PARAM, dstRangeStart, dstRangeEnd)); thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Illegal destination port parameters"); Classifier.L4_CL.checkPresenceOfRequiredParams(params); @@ -262,8 +262,8 @@ public class L4ClassifierTest { matches.add(new MatchBuilder()); Long dstRangeStart = Long.valueOf(8081); Long dstRangeEnd = Long.valueOf(8079); - params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO, ClassifierTestUtils.TCP)); - params.putAll(ClassifierTestUtils.createRangeValueParam(L4Classifier.DPORT_RANGE, dstRangeStart, dstRangeEnd)); + params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO_PARAM, ClassifierTestUtils.TCP)); + params.putAll(ClassifierTestUtils.createRangeValueParam(L4Classifier.DST_PORT_RANGE_PARAM, dstRangeStart, dstRangeEnd)); thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Range value mismatch"); Classifier.L4_CL.checkPresenceOfRequiredParams(params); @@ -274,8 +274,8 @@ public class L4ClassifierTest { matches.add(new MatchBuilder()); Long dstRangeStart = Long.valueOf(8079); Long dstRangeEnd = Long.valueOf(8081); - params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO, 136)); - params.putAll(ClassifierTestUtils.createRangeValueParam(L4Classifier.DPORT_RANGE, dstRangeStart, dstRangeEnd)); + params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO_PARAM, 136)); + params.putAll(ClassifierTestUtils.createRangeValueParam(L4Classifier.DST_PORT_RANGE_PARAM, dstRangeStart, dstRangeEnd)); thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Unsupported L4 protocol."); matches = Classifier.L4_CL.update(matches, params); @@ -287,8 +287,8 @@ public class L4ClassifierTest { .setLayer4Match(ClassifierTestUtils.createSctpDstPort(80))); Long dstRangeStart = Long.valueOf(8079); Long dstRangeEnd = Long.valueOf(8081); - params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO, ClassifierTestUtils.UDP)); - params.putAll(ClassifierTestUtils.createRangeValueParam(L4Classifier.DPORT_RANGE, dstRangeStart, dstRangeEnd)); + params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifier.PROTO_PARAM, ClassifierTestUtils.UDP)); + params.putAll(ClassifierTestUtils.createRangeValueParam(L4Classifier.DST_PORT_RANGE_PARAM, dstRangeStart, dstRangeEnd)); thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Classification conflict"); matches = Classifier.L4_CL.update(matches, params); @@ -299,7 +299,7 @@ public class L4ClassifierTest { matches.add(new MatchBuilder()); Long dstRangeStart = Long.valueOf(8079); Long dstRangeEnd = Long.valueOf(8081); - params.putAll(ClassifierTestUtils.createRangeValueParam(L4Classifier.DPORT_RANGE, dstRangeStart, dstRangeEnd)); + params.putAll(ClassifierTestUtils.createRangeValueParam(L4Classifier.DST_PORT_RANGE_PARAM, dstRangeStart, dstRangeEnd)); thrown.expect(IllegalArgumentException.class); thrown.expectMessage("L4 protocol is null."); matches = Classifier.L4_CL.update(matches, params); @@ -307,7 +307,7 @@ public class L4ClassifierTest { @Test public void checkPresenceOfRequiredParameters1Test() { - params.putAll(ImmutableMap. of(L4Classifier.SPORT, + params.putAll(ImmutableMap. of(L4Classifier.SRC_PORT_PARAM, new ParameterValueBuilder().build())); thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Value of sourceport parameter is not present"); @@ -316,7 +316,7 @@ public class L4ClassifierTest { @Test public void checkPresenceOfRequiredParameters2Test() { - params.putAll(ImmutableMap. of(L4Classifier.DPORT, + params.putAll(ImmutableMap. of(L4Classifier.DST_PORT_PARAM, new ParameterValueBuilder().build())); thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Value of destport parameter is not present"); @@ -325,7 +325,7 @@ public class L4ClassifierTest { @Test public void checkPresenceOfRequiredParameters3Test() { - params.putAll(ImmutableMap. of(L4Classifier.SPORT_RANGE, + params.putAll(ImmutableMap. of(L4Classifier.SRC_PORT_RANGE_PARAM, new ParameterValueBuilder().build())); thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Range value is not present"); @@ -334,7 +334,7 @@ public class L4ClassifierTest { @Test public void checkPresenceOfRequiredParameters4Test() { - params.putAll(ImmutableMap. of(L4Classifier.DPORT_RANGE, + params.putAll(ImmutableMap. of(L4Classifier.DST_PORT_RANGE_PARAM, new ParameterValueBuilder().build())); thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Range value is not present");