Code Review
/
controller.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
When ports are added to a container, construct its topology immediately based on...
[controller.git]
/
opendaylight
/
protocol_plugins
/
openflow
/
src
/
main
/
java
/
org
/
opendaylight
/
controller
/
protocol_plugin
/
openflow
/
internal
/
PortConverter.java
diff --git
a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/PortConverter.java
b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/PortConverter.java
index 8de7693961ced0f40fd902209e961bd14bd3bfd4..0b605ab875a145ff1935f56453d087b2e9115314 100644
(file)
--- a/
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/PortConverter.java
+++ b/
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/PortConverter.java
@@
-1,4
+1,3
@@
-
/*
* Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
*
/*
* Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
*
@@
-9,30
+8,36
@@
package org.opendaylight.controller.protocol_plugin.openflow.internal;
package org.opendaylight.controller.protocol_plugin.openflow.internal;
-import org.openflow.protocol.OFPort;
-
import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.sal.core.NodeConnector;
import org.opendaylight.controller.sal.core.NodeConnector.NodeConnectorIDType;
import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.sal.core.NodeConnector;
import org.opendaylight.controller.sal.core.NodeConnector.NodeConnectorIDType;
+import org.opendaylight.controller.sal.utils.NetUtils;
import org.opendaylight.controller.sal.utils.NodeConnectorCreator;
import org.opendaylight.controller.sal.utils.NodeConnectorCreator;
+import org.openflow.protocol.OFPort;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
/**
- * Abstract class which provides the utilities for converting
- *
the Openflow port
number to the equivalent NodeConnector and vice versa
+ * Abstract class which provides the utilities for converting
the Openflow port
+ * number to the equivalent NodeConnector and vice versa
*
*
*
*/
public abstract class PortConverter {
*
*
*
*/
public abstract class PortConverter {
- private static final int maxOFPhysicalPort = (OFPort.OFPP_MAX.getValue() & 0x7FFF) | 0x8000;
+ private static final Logger log = LoggerFactory
+ .getLogger(PortConverter.class);
+ private static final int maxOFPhysicalPort = NetUtils
+ .getUnsignedShort(OFPort.OFPP_MAX.getValue());
/**
* Converts the Openflow port number to the equivalent NodeConnector.
*/
public static NodeConnector toNodeConnector(short ofPort, Node node) {
// Restore original OF unsigned 16 bits value for the comparison
/**
* Converts the Openflow port number to the equivalent NodeConnector.
*/
public static NodeConnector toNodeConnector(short ofPort, Node node) {
// Restore original OF unsigned 16 bits value for the comparison
- int unsignedOFPort = (ofPort & 0x7FFF) | 0x8000;
-
+ int unsignedOFPort = NetUtils.getUnsignedShort(ofPort);
+ log.trace("Openflow port number signed: {} unsigned: {}", ofPort,
+ unsignedOFPort);
if (unsignedOFPort > maxOFPhysicalPort) {
if (ofPort == OFPort.OFPP_LOCAL.getValue()) {
return NodeConnectorCreator.createNodeConnector(
if (unsignedOFPort > maxOFPhysicalPort) {
if (ofPort == OFPort.OFPP_LOCAL.getValue()) {
return NodeConnectorCreator.createNodeConnector(
@@
-55,13
+60,12
@@
public abstract class PortConverter {
* Converts the NodeConnector to the equivalent Openflow port number
*/
public static short toOFPort(NodeConnector salPort) {
* Converts the NodeConnector to the equivalent Openflow port number
*/
public static short toOFPort(NodeConnector salPort) {
+ log.trace("SAL Port", salPort);
if (salPort.getType().equals(NodeConnectorIDType.SWSTACK)) {
return OFPort.OFPP_LOCAL.getValue();
if (salPort.getType().equals(NodeConnectorIDType.SWSTACK)) {
return OFPort.OFPP_LOCAL.getValue();
- } else if (salPort.getType().equals(
- NodeConnectorIDType.HWPATH)) {
+ } else if (salPort.getType().equals(NodeConnectorIDType.HWPATH)) {
return OFPort.OFPP_NORMAL.getValue();
return OFPort.OFPP_NORMAL.getValue();
- } else if (salPort.getType().equals(
- NodeConnectorIDType.CONTROLLER)) {
+ } else if (salPort.getType().equals(NodeConnectorIDType.CONTROLLER)) {
return OFPort.OFPP_CONTROLLER.getValue();
}
return (Short) salPort.getID();
return OFPort.OFPP_CONTROLLER.getValue();
}
return (Short) salPort.getID();