Skip to content
Snippets Groups Projects
Commit e89258a2 authored by abat's avatar abat
Browse files

Merge into master from pull request #109:

Fix a null pointer exception in DeviceManagerImpl [Bug #436: Resolved]. (https://github.com/floodlight/floodlight/pull/109)
parents 71d58a1a 5b02ebd2
No related branches found
No related tags found
No related merge requests found
...@@ -111,7 +111,7 @@ ...@@ -111,7 +111,7 @@
debug="true" debug="true"
srcdir="${source}:${packetstreamer-gen}" srcdir="${source}:${packetstreamer-gen}"
destdir="${build}"> destdir="${build}">
</javac> </javac>
</target> </target>
<target name="compile-tests" depends="compile-test"/> <target name="compile-tests" depends="compile-test"/>
......
...@@ -621,6 +621,7 @@ public class DeviceManagerImpl implements IDeviceManagerService, IOFMessageListe ...@@ -621,6 +621,7 @@ public class DeviceManagerImpl implements IDeviceManagerService, IOFMessageListe
protected boolean inSamePortChannel(SwitchPortTuple swPort1, protected boolean inSamePortChannel(SwitchPortTuple swPort1,
SwitchPortTuple swPort2) { SwitchPortTuple swPort2) {
IOFSwitch sw = swPort1.getSw(); IOFSwitch sw = swPort1.getSw();
if (sw == null) return false;
String portName = sw.getPort(swPort1.getPort()).getName(); String portName = sw.getPort(swPort1.getPort()).getName();
String key = sw.getStringId() + portName; String key = sw.getStringId() + portName;
String portChannel1 = portChannelMap.get(key); String portChannel1 = portChannelMap.get(key);
...@@ -628,6 +629,7 @@ public class DeviceManagerImpl implements IDeviceManagerService, IOFMessageListe ...@@ -628,6 +629,7 @@ public class DeviceManagerImpl implements IDeviceManagerService, IOFMessageListe
return false; return false;
sw = swPort2.getSw(); sw = swPort2.getSw();
if (sw == null) return false;
portName = sw.getPort(swPort2.getPort()).getName(); portName = sw.getPort(swPort2.getPort()).getName();
key = sw.getStringId() + portName; key = sw.getStringId() + portName;
String portChannel2 = portChannelMap.get(key); String portChannel2 = portChannelMap.get(key);
......
package net.floodlightcontroller.topology; package net.floodlightcontroller.topology;
import net.floodlightcontroller.linkdiscovery.SwitchPortTuple;
import org.openflow.util.HexString; import org.openflow.util.HexString;
/**
* A NodePortTuple is similar to a SwitchPortTuple
* but it only stores IDs instead of references
* to the actual objects.
* @author srini
*/
public class NodePortTuple { public class NodePortTuple {
protected long nodeId; protected long nodeId; // switch DPID
protected short portId; protected short portId; // switch port id
/**
* Creates a NodePortTuple
* @param nodeId The DPID of the switch
* @param portId The port of the switch
*/
public NodePortTuple(long nodeId, short portId) { public NodePortTuple(long nodeId, short portId) {
this.nodeId = nodeId; this.nodeId = nodeId;
this.portId = portId; this.portId = portId;
} }
/**
* Creates a NodePortTuple from the same information
* in a SwitchPortTuple
* @param swt
*/
public NodePortTuple(SwitchPortTuple swt) {
if (swt.getSw() != null)
this.nodeId = swt.getSw().getId();
else
this.nodeId = 0;
this.portId = swt.getPort();
}
public long getNodeId() { public long getNodeId() {
return nodeId; return nodeId;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment