-/**
+/*
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.openflowplugin.impl.util;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
-import java.math.BigInteger;
import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketIn;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint64;
/**
* Created by Tomas Slusny on 23.3.2016.
* @return packet input converted to node connector reference
*/
@Nullable
- public static NodeConnectorRef toNodeConnectorRef(@Nonnull PacketIn packetIn, BigInteger dataPathId) {
+ public static NodeConnectorRef toNodeConnectorRef(@Nonnull final PacketIn packetIn, final Uint64 dataPathId) {
Preconditions.checkNotNull(packetIn);
NodeConnectorRef ref = null;
- Long port = getPortNoFromPacketIn(packetIn);
+ Uint32 port = getPortNoFromPacketIn(packetIn);
if (port != null) {
OpenflowVersion version = OpenflowVersion.get(packetIn.getVersion());
*/
@SuppressWarnings("unchecked")
@Nullable
- public static Long fromNodeConnectorRef(@Nonnull NodeConnectorRef nodeConnectorRef, short version) {
+ public static Uint32 fromNodeConnectorRef(@Nonnull final NodeConnectorRef nodeConnectorRef, final short version) {
Preconditions.checkNotNull(nodeConnectorRef);
- Long port = null;
+ Uint32 port = null;
final InstanceIdentifier<?> value = nodeConnectorRef.getValue();
if (value instanceof KeyedInstanceIdentifier) {
@VisibleForTesting
@Nullable
- static Long getPortNoFromPacketIn(@Nonnull PacketIn packetIn) {
+ static Uint32 getPortNoFromPacketIn(@Nonnull final PacketIn packetIn) {
Preconditions.checkNotNull(packetIn);
- Long port = null;
+ Uint32 port = null;
- if (packetIn.getVersion() == OFConstants.OFP_VERSION_1_0 && packetIn.getInPort() != null) {
- port = packetIn.getInPort().longValue();
- } else if (packetIn.getVersion() == OFConstants.OFP_VERSION_1_3) {
+ if (packetIn.getVersion().toJava() == OFConstants.OFP_VERSION_1_0 && packetIn.getInPort() != null) {
+ port = Uint32.valueOf(packetIn.getInPort());
+ } else if (packetIn.getVersion().toJava() == OFConstants.OFP_VERSION_1_3) {
if (packetIn.getMatch() != null && packetIn.getMatch().getMatchEntry() != null) {
List<MatchEntry> entries = packetIn.getMatch().getMatchEntry();