Refactored the forwarding module to use the new packet API.

It now uses PacketService for both receiving packet-ins and sending
packet-outs, so there is now no dependency on FloodlightProvider or
FlowPusher.

Fixed a bug where the packet module wasn't sending packet-outs correctly.

Change-Id: If738797cdcebabfed975875daf4b40df99226585
diff --git a/src/main/java/net/onrc/onos/core/packetservice/BroadcastPacketOutNotification.java b/src/main/java/net/onrc/onos/core/packetservice/BroadcastPacketOutNotification.java
index 3e098ed..bf5c700 100644
--- a/src/main/java/net/onrc/onos/core/packetservice/BroadcastPacketOutNotification.java
+++ b/src/main/java/net/onrc/onos/core/packetservice/BroadcastPacketOutNotification.java
@@ -2,6 +2,9 @@
 
 import java.util.Map;
 
+import net.onrc.onos.core.topology.NetworkGraph;
+import net.onrc.onos.core.topology.Port;
+
 import com.google.common.collect.HashMultimap;
 import com.google.common.collect.Multimap;
 
@@ -75,12 +78,25 @@
     }
 
     @Override
-    public Multimap<Long, Short> calculateOutPorts(Multimap<Long, Short> localSwitches) {
+    public Multimap<Long, Short> calculateOutPorts(
+            Multimap<Long, Short> localPorts, NetworkGraph networkGraph) {
         Multimap<Long, Short> outPorts = HashMultimap.create();
 
-        for (Map.Entry<Long, Short> entry : localSwitches.entries()) {
-            if (!entry.getKey().equals(inSwitch) ||
-                    !entry.getValue().equals(inPort)) {
+        for (Map.Entry<Long, Short> entry : localPorts.entries()) {
+            Port globalPort;
+            networkGraph.acquireReadLock();
+            try {
+                globalPort = networkGraph.getPort(entry.getKey(),
+                    entry.getValue().longValue());
+            } finally {
+                networkGraph.releaseReadLock();
+            }
+
+            if ((!entry.getKey().equals(inSwitch) ||
+                    !entry.getValue().equals(inPort)) &&
+                    globalPort != null &&
+                    globalPort.getOutgoingLink() == null) {
+
                 outPorts.put(entry.getKey(), entry.getValue());
             }
         }