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.openflow.md.core.translator;
10 import java.math.BigInteger;
11 import java.util.Collections;
12 import java.util.List;
13 import java.util.concurrent.CopyOnWriteArrayList;
15 import org.opendaylight.openflowplugin.openflow.md.core.IMDMessageTranslator;
16 import org.opendaylight.openflowplugin.openflow.md.core.SwitchConnectionDistinguisher;
17 import org.opendaylight.openflowplugin.openflow.md.core.session.SessionContext;
18 import org.opendaylight.openflowplugin.openflow.md.util.PortTranslatorUtil;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPort;
22 import org.opendaylight.yangtools.yang.binding.DataObject;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
26 public class FeaturesV10ToNodeConnectorUpdatedTranslator implements IMDMessageTranslator<OfHeader, List<DataObject>> {
27 protected static final Logger LOG = LoggerFactory
28 .getLogger(FeaturesV10ToNodeConnectorUpdatedTranslator.class);
31 public List<DataObject> translate(SwitchConnectionDistinguisher cookie,
32 SessionContext sc, OfHeader msg) {
33 if(msg instanceof GetFeaturesOutput) {
34 GetFeaturesOutput features = (GetFeaturesOutput) msg;
35 List<DataObject> list = new CopyOnWriteArrayList<DataObject>();
36 BigInteger datapathId = sc.getFeatures().getDatapathId();
37 if( features.getPhyPort() != null ) {
38 for (PhyPort port : features.getPhyPort()) {
39 list.add(PortTranslatorUtil.translatePort(msg.getVersion(), datapathId, port.getPortNo(), port));
44 // TODO - Do something smarter than returning null if translation fails... what Exception should we throw here?
45 return Collections.emptyList();