2 * Copyright (c) 2016 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.openflowplugin.openflow.md.core.sal.convertor.match.cases;
11 import java.util.Optional;
12 import javax.annotation.Nonnull;
13 import org.opendaylight.openflowplugin.api.OFConstants;
14 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
15 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanVidCase;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.vlan.vid._case.VlanVid;
23 public class OfToSalVlanVidCase extends ConvertorCase<VlanVidCase, MatchBuilder, MatchResponseConvertorData> {
24 public OfToSalVlanVidCase() {
25 super(VlanVidCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
29 public Optional<MatchBuilder> process(@Nonnull VlanVidCase source, MatchResponseConvertorData data) {
30 final MatchBuilder matchBuilder = data.getMatchBuilder();
31 final VlanMatchBuilder vlanMatchBuilder = data.getVlanMatchBuilder();
33 final VlanVid vlanVid = source.getVlanVid();
35 if (vlanVid != null) {
36 VlanIdBuilder vlanBuilder = new VlanIdBuilder();
37 vlanBuilder.setVlanId(new VlanId(vlanVid.getVlanVid()));
38 vlanBuilder.setVlanIdPresent(vlanVid.isCfiBit());
39 vlanMatchBuilder.setVlanId(vlanBuilder.build());
40 matchBuilder.setVlanMatch(vlanMatchBuilder.build());
43 return Optional.of(matchBuilder);