2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.groupbasedpolicy.renderer.vpp.sf;
11 import java.util.List;
14 import org.opendaylight.groupbasedpolicy.api.sf.EtherTypeClassifierDefinition;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ClassifierDefinitionId;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ParameterName;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ClassifierDefinition;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.instance.ParameterValue;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.has.parameters.type.parameter.type.IntBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.supported.classifier.definition.SupportedParameterValues;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.supported.classifier.definition.SupportedParameterValuesBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.supported._int.value.fields.SupportedIntValue;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.supported._int.value.fields.SupportedIntValueBuilder;
25 import com.google.common.collect.ImmutableList;
28 * Match on the ether type of the traffic.
30 public class EtherTypeClassifier extends Classifier {
32 public EtherTypeClassifier(Classifier parent) {
37 public ClassifierDefinitionId getId() {
38 return EtherTypeClassifierDefinition.ID;
42 public ClassifierDefinition getClassifierDefinition() {
43 return EtherTypeClassifierDefinition.DEFINITION;
47 public List<SupportedParameterValues> getSupportedParameterValues() {
49 List<SupportedIntValue> values = ImmutableList.of(
50 new SupportedIntValueBuilder().setValue(EtherTypeClassifierDefinition.IPv4_VALUE).build(),
51 new SupportedIntValueBuilder().setValue(EtherTypeClassifierDefinition.IPv6_VALUE).build());
52 SupportedParameterValuesBuilder builder = new SupportedParameterValuesBuilder();
53 builder.setParameterName(new ParameterName(EtherTypeClassifierDefinition.ETHERTYPE_PARAM));
54 builder.setParameterType(new IntBuilder().setSupportedIntValue(values).build());
56 return ImmutableList.of(builder.build());
60 protected void checkPresenceOfRequiredParams(Map<String, ParameterValue> params) {
61 if (params.get(EtherTypeClassifierDefinition.ETHERTYPE_PARAM) == null) {
62 throw new IllegalArgumentException(
63 "Parameter " + EtherTypeClassifierDefinition.ETHERTYPE_PARAM + " not specified.");
65 if (params.get(EtherTypeClassifierDefinition.ETHERTYPE_PARAM).getIntValue() == null) {
66 throw new IllegalArgumentException(
67 "Value of " + EtherTypeClassifierDefinition.ETHERTYPE_PARAM + " parameter is not present.");