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.math.BigInteger;
12 import java.util.Optional;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.opendaylight.openflowplugin.api.OFConstants;
15 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
16 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
17 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.data.MatchResponseConvertorData;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TunnelBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TunnelIdCase;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.tunnel.id._case.TunnelId;
23 public class OfToSalTunnelIdCase extends ConvertorCase<TunnelIdCase, MatchBuilder, MatchResponseConvertorData> {
24 public OfToSalTunnelIdCase() {
25 super(TunnelIdCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
29 public Optional<MatchBuilder> process(@NonNull TunnelIdCase source, MatchResponseConvertorData data,
30 ConvertorExecutor convertorExecutor) {
31 final MatchBuilder matchBuilder = data.getMatchBuilder();
33 TunnelId tunnelId = source.getTunnelId();
34 TunnelBuilder tunnelBuilder = new TunnelBuilder();
36 if (tunnelId.getTunnelId() != null) {
37 tunnelBuilder.setTunnelId(new BigInteger(OFConstants.SIGNUM_UNSIGNED, tunnelId.getTunnelId()));
38 byte[] mask = tunnelId.getMask();
41 tunnelBuilder.setTunnelMask(new BigInteger(OFConstants.SIGNUM_UNSIGNED, mask));
44 matchBuilder.setTunnel(tunnelBuilder.build());
47 return Optional.of(matchBuilder);