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/PacketModule.java b/src/main/java/net/onrc/onos/core/packetservice/PacketModule.java
index 27bfbb5..1e3cae6 100644
--- a/src/main/java/net/onrc/onos/core/packetservice/PacketModule.java
+++ b/src/main/java/net/onrc/onos/core/packetservice/PacketModule.java
@@ -67,8 +67,14 @@
 
         @Override
         public void entryAdded(PacketOutNotification value) {
+            Multimap<Long, Short> localPorts = HashMultimap.create();
+            for (IOFSwitch sw : floodlightProvider.getSwitches().values()) {
+                for (OFPhysicalPort port : sw.getEnabledPorts()) {
+                    localPorts.put(sw.getId(), port.getPortNumber());
+                }
+            }
             Multimap<Long, Short> outPorts = value.calculateOutPorts(
-                    findLocalEdgePorts());
+                    localPorts, networkGraph);
             sendPacketToSwitches(outPorts, value.getPacketData());
         }
 
@@ -164,6 +170,8 @@
         }
 
         if (networkGraphSwitch == null || inPort == null) {
+            // We can't send packets for switches or ports that aren't in the
+            // network graph yet
             return Command.CONTINUE;
         }
 
@@ -221,21 +229,6 @@
                 PacketOutNotification.class);
     }
 
-    private Multimap<Long, Short> findLocalEdgePorts() {
-        Multimap<Long, Short> edgePorts = HashMultimap.create();
-        Map<Long, IOFSwitch> localSwitches = floodlightProvider.getSwitches();
-        for (IOFSwitch sw : localSwitches.values()) {
-            for (OFPhysicalPort localPort : sw.getEnabledPorts()) {
-                Port globalPort =
-                        networkGraph.getPort(sw.getId(), (long) localPort.getPortNumber());
-                if (globalPort.getOutgoingLink() == null) {
-                    edgePorts.put(sw.getId(), localPort.getPortNumber());
-                }
-            }
-        }
-        return edgePorts;
-    }
-
     private void sendPacketToSwitches(Multimap<Long, Short> outPorts,
             byte[] packetData) {
         for (Long dpid : outPorts.keySet()) {