In band changes

Add flow_mod_gen to simplify several calls
Check if switch connects in simple protocol and exit if not.
Do not run FlowStatsGet by default
Add in_band parameter to indicate flows should not drop all pkts
diff --git a/tests/basic.py b/tests/basic.py
index 394ab0a..ab97fed 100644
--- a/tests/basic.py
+++ b/tests/basic.py
@@ -85,6 +85,9 @@
         if not self.controller.active:
             print "Controller startup failed; exiting"
             sys.exit(1)
+        if self.controller.switch_addr is None: 
+            print "Controller startup failed (no switch addr); exiting"
+            sys.exit(1)
         basic_logger.info("Connected " + str(self.controller.switch_addr))
 
     def tearDown(self):
@@ -291,9 +294,7 @@
     def runTest(self):
         basic_logger.info("Running StatsGet")
         basic_logger.info("Inserting trial flow")
-        request = message.flow_mod()
-        request.match.wildcards = ofp.OFPFW_ALL
-        request.buffer_id = 0xffffffff
+        request = flow_mod_gen(basic_port_map, True)
         rv = self.controller.message_send(request)
         self.assertTrue(rv != -1, "Failed to insert test flow")
         
@@ -306,6 +307,8 @@
         self.assertTrue(response is not None, "Did not get response")
         basic_logger.debug(response.show())
 
+test_prio["FlowStatsGet"] = -1
+
 class TableStatsGet(SimpleProtocol):
     """
     Get table stats 
@@ -315,9 +318,7 @@
     def runTest(self):
         basic_logger.info("Running TableStatsGet")
         basic_logger.info("Inserting trial flow")
-        request = message.flow_mod()
-        request.match.wildcards = ofp.OFPFW_ALL
-        request.buffer_id = 0xffffffff
+        request = flow_mod_gen(basic_port_map, True)
         rv = self.controller.message_send(request)
         self.assertTrue(rv != -1, "Failed to insert test flow")
         
@@ -336,9 +337,7 @@
 
     def runTest(self):
         basic_logger.info("Running " + str(self))
-        request = message.flow_mod()
-        request.match.wildcards = ofp.OFPFW_ALL
-        request.buffer_id = 0xffffffff
+        request = flow_mod_gen(basic_port_map, True)
         rv = self.controller.message_send(request)
         self.assertTrue(rv != -1, "Error installing flow mod")
 
diff --git a/tests/testutils.py b/tests/testutils.py
index 450b330..c7721fd 100644
--- a/tests/testutils.py
+++ b/tests/testutils.py
@@ -377,16 +377,19 @@
                                str(byte_count))
 
 def flow_msg_create(parent, pkt, ing_port=None, action_list=None, wildcards=0,
-               egr_port=None, egr_queue=None, check_expire=False):
+               egr_port=None, egr_queue=None, check_expire=False, in_band=True):
     """
     Create a flow message
 
     Match on packet with given wildcards.  
     See flow_match_test for other parameter descriptoins
     @param egr_queue if not None, make the output an enqueue action
+    @param in_band if True, do not wildcard ingress port
     """
     match = parse.packet_to_flow_match(pkt)
     parent.assertTrue(match is not None, "Flow match from pkt failed")
+    if in_band:
+        wildcards &= ~ofp.OFPFW_IN_PORT
     match.wildcards = wildcards
     match.in_port = ing_port
 
@@ -677,7 +680,19 @@
     expected_pkt = simple_tcp_packet(**base_pkt_params)
 
     return (ingress_pkt, expected_pkt, new_actions)
-        
+
+# Generate a simple "drop" flow mod
+# If in_band is true, then only drop from first test port
+def flow_mod_gen(port_map, in_band):
+    request = message.flow_mod()
+    request.match.wildcards = ofp.OFPFW_ALL
+    if in_band:
+        request.match.wildcards = ofp.OFPFW_ALL - ofp.OFPFW_IN_PORT
+        for of_port, ifname in port_map.items(): # Grab first port
+            break
+        request.match.in_port = of_port
+    request.buffer_id = 0xffffffff
+    return request
 
 def skip_message_emit(parent, s):
     """
@@ -694,3 +709,4 @@
         sys.stderr.write("(skipped) ")
     else:
         sys.stderr.write("(S)")
+