2 * Copyright (c) 2013 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
8 package org.opendaylight.openflowplugin.impl.device;
10 import static org.opendaylight.openflowplugin.api.OFConstants.OFP_VERSION_1_0;
11 import static org.opendaylight.openflowplugin.api.OFConstants.OFP_VERSION_1_3;
14 import org.opendaylight.openflowplugin.api.openflow.md.core.sal.BuildSwitchFeatures;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.flow.node.SwitchFeatures;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
17 import org.opendaylight.yangtools.yang.common.Uint8;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
21 public final class SwitchFeaturesUtil {
22 private static final Logger LOG = LoggerFactory.getLogger(SwitchFeaturesUtil.class);
24 private static final Map<Uint8, BuildSwitchFeatures> SWITCH_FEATURES_BUILDERS = Map.of(
25 OFP_VERSION_1_0, BuildSwitchCapabilitiesOF10.getInstance(),
26 OFP_VERSION_1_3, BuildSwitchCapabilitiesOF13.getInstance());
28 private SwitchFeaturesUtil() {
33 * Returns the features of the switch.
36 * {@link org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput}
37 * @return switch features
39 public static SwitchFeatures buildSwitchFeatures(final GetFeaturesOutput features) {
40 final var version = features.getVersion();
41 final var builder = SWITCH_FEATURES_BUILDERS.get(version);
42 if (builder != null) {
43 LOG.debug("map contains version {}", version);
44 return builder.build(features);
46 LOG.warn("unknown version: {}", version);