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.ConvertorExecutor;
15 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
16 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthTypeCase;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.type._case.EthType;
24 public class OfToSalEthTypeCase extends ConvertorCase<EthTypeCase, MatchBuilder, MatchResponseConvertorData> {
25 public OfToSalEthTypeCase() {
26 super(EthTypeCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
30 public Optional<MatchBuilder> process(@Nonnull EthTypeCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
31 final MatchBuilder matchBuilder = data.getMatchBuilder();
32 final EthernetMatchBuilder ethMatchBuilder = data.getEthernetMatchBuilder();
34 final EthType ethTypeCase = source.getEthType();
36 if (ethTypeCase != null) {
37 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
38 ethTypeBuilder.setType(new EtherType((long) ethTypeCase.getEthType().getValue()));
39 ethMatchBuilder.setEthernetType(ethTypeBuilder.build());
40 matchBuilder.setEthernetMatch(ethMatchBuilder.build());
43 return Optional.of(matchBuilder);