Fix Issue #235: Deleting flows doesn't delete all the flow entries

Add missing setting for the OpenFlow field out_port in
the "Modify Flow Entry Message". Appararently, its value
is important for DELETE or DELETE_STRICT messages if
in the matching includes checking of the output port.

If the matching does NOT include the output port,
its value must be set to OFPP_NONE (0xffff for OpenFlow 1.0).
Previously, it was initialized to zero (a valid port number),
and the deleting of flow entries would succeed only if the outgoing
port number was zero.
diff --git a/src/main/java/net/floodlightcontroller/flowcache/FlowManager.java b/src/main/java/net/floodlightcontroller/flowcache/FlowManager.java
index 9c31924..a604969 100644
--- a/src/main/java/net/floodlightcontroller/flowcache/FlowManager.java
+++ b/src/main/java/net/floodlightcontroller/flowcache/FlowManager.java
@@ -46,6 +46,7 @@
 import org.openflow.protocol.OFFlowMod;
 import org.openflow.protocol.OFMatch;
 import org.openflow.protocol.OFPacketOut;
+import org.openflow.protocol.OFPort;
 import org.openflow.protocol.OFType;
 import org.openflow.protocol.action.OFAction;
 import org.openflow.protocol.action.OFActionOutput;
@@ -62,10 +63,15 @@
 
     protected OFMessageDamper messageDamper;
 
-    protected static int OFMESSAGE_DAMPER_CAPACITY = 50000; // TODO: find sweet spot
-    protected static int OFMESSAGE_DAMPER_TIMEOUT = 250;	// ms
-    public static short FLOWMOD_DEFAULT_IDLE_TIMEOUT = 0;	// infinity
-    public static short FLOWMOD_DEFAULT_HARD_TIMEOUT = 0;	// infinite
+    //
+    // TODO: Values copied from elsewhere (class LearningSwitch).
+    // The local copy should go away!
+    //
+    protected static final int OFMESSAGE_DAMPER_CAPACITY = 50000; // TODO: find sweet spot
+    protected static final int OFMESSAGE_DAMPER_TIMEOUT = 250;	// ms
+    public static final short FLOWMOD_DEFAULT_IDLE_TIMEOUT = 0;	// infinity
+    public static final short FLOWMOD_DEFAULT_HARD_TIMEOUT = 0;	// infinite
+    public static final short PRIORITY_DEFAULT = 100;
 
     /** The logger. */
     private static Logger log = LoggerFactory.getLogger(FlowManager.class);
@@ -176,12 +182,20 @@
 
 		    fm.setIdleTimeout(FLOWMOD_DEFAULT_IDLE_TIMEOUT)
 			.setHardTimeout(FLOWMOD_DEFAULT_HARD_TIMEOUT)
+			.setPriority(PRIORITY_DEFAULT)
 			.setBufferId(OFPacketOut.BUFFER_ID_NONE)
 			.setCookie(cookie)
 			.setCommand(flowModCommand)
 			.setMatch(match)
 			.setActions(actions)
 			.setLengthU(OFFlowMod.MINIMUM_LENGTH+OFActionOutput.MINIMUM_LENGTH);
+		    fm.setOutPort(OFPort.OFPP_NONE.getValue());
+		    if ((flowModCommand == OFFlowMod.OFPFC_DELETE) ||
+			(flowModCommand == OFFlowMod.OFPFC_DELETE_STRICT)) {
+			if (actionOutputPort != null)
+			    fm.setOutPort(actionOutputPort);
+		    }
+
 		    //
 		    // TODO: Set the following flag
 		    // fm.setFlags(OFFlowMod.OFPFF_SEND_FLOW_REM);