Implemented global packet-out functionality in the PacketModule.

Updated with javadoc for the interfaces, and fixes to bugs pointed out by
Pavlin and Yuta regarding the implementation of calculateOutPorts in
BroadcastPacketOutNotification.

Change-Id: I6174d27877972cf437955ef8d82e9a02b36d0b5f
diff --git a/src/main/java/net/onrc/onos/core/packetservice/PacketOutNotification.java b/src/main/java/net/onrc/onos/core/packetservice/PacketOutNotification.java
index 30e3986..8fe8efe 100644
--- a/src/main/java/net/onrc/onos/core/packetservice/PacketOutNotification.java
+++ b/src/main/java/net/onrc/onos/core/packetservice/PacketOutNotification.java
@@ -3,6 +3,8 @@
 import java.io.Serializable;
 import java.util.Arrays;
 
+import com.google.common.collect.Multimap;
+
 /**
  * A PacketOutNotification contains data sent between ONOS instances that
  * directs other instances to send a packet out a set of ports. This is an
@@ -16,19 +18,44 @@
     private final byte[] packet;
 
     /**
+     * Default constructor.
+     */
+    protected PacketOutNotification() {
+        packet = null;
+    }
+
+    /**
      * Class constructor.
      *
      * @param packet the packet data to send in the packet-out
      */
-    public PacketOutNotification() {
-        packet = null;
-    }
-
     public PacketOutNotification(byte[] packet) {
         this.packet = Arrays.copyOf(packet, packet.length);
     }
 
+    /**
+     * Gets the packet that needs to be sent into the network.
+     *
+     * @return the packet data as a serialized byte array
+     */
     public byte[] getPacketData() {
         return Arrays.copyOf(packet, packet.length);
     }
+
+    /**
+     * Calculate a list of local ports that the packet should be sent out.
+     * <p/>
+     * A {@link PacketOutNotification} contains a high-level description of the
+     * where to send the packet. The receiver of the notification needs to know
+     * an explicit list of ports to send the packet out. This function will
+     * calculate that list, given the list of edge ports controlled by this
+     * instance.
+     *
+     * @param localSwitches the map of locally-controlled edge ports
+     * @return a multimap of ports that the packet should be sent out,
+     * in the form
+     * {@code {dpid1 => {portnum1, portnum2, ...}, dpid2 => {portnum1}, ...}}
+     */
+    public abstract Multimap<Long, Short> calculateOutPorts(
+            Multimap<Long, Short> localEdgePorts);
 }