Implement a required_wildcards setting to allow testing switches that
don't support certain match fields; implement l3-l4 for forcing
wildcarding of all L3 and L4 fields; clean up flow_query test a bit
diff --git a/tests/bsn_ipmask.py b/tests/bsn_ipmask.py
index cc2e893..4d325f6 100644
--- a/tests/bsn_ipmask.py
+++ b/tests/bsn_ipmask.py
@@ -92,6 +92,10 @@
         return x[5]
 
     def runTest(self):
+        self.assertFalse(required_wildcards(self) & ofp.OFPFW_NW_DST_ALL,
+                         "IP dst must be wildcarded")
+        self.assertFalse(required_wildcards(self) & ofp.OFPFW_NW_SRC_ALL,
+                         "IP src must be wildcarded")
         for index in range(0, 64):
             mask = self.bsn_get_ip_mask(index)
             im_logger.info("Index %d mask is %s" %
diff --git a/tests/caps.py b/tests/caps.py
index 4657baa..7c187cc 100644
--- a/tests/caps.py
+++ b/tests/caps.py
@@ -63,7 +63,7 @@
     obj.assertEqual(rv, 0, "Failed to delete all flows")
 
     pkt = simple_tcp_packet()
-    match = parse.packet_to_flow_match(pkt)
+    match = packet_to_flow_match(self, pkt)
     obj.assertTrue(match is not None, "Could not generate flow match from pkt")
     for port in of_ports:
         break;
diff --git a/tests/flow_expire.py b/tests/flow_expire.py
index 1d05b6b..ab5b68a 100644
--- a/tests/flow_expire.py
+++ b/tests/flow_expire.py
@@ -68,7 +68,7 @@
         self.assertEqual(rc, 0, "Failed to delete all flows")
 
         pkt = simple_tcp_packet()
-        match = parse.packet_to_flow_match(pkt)
+        match = packet_to_flow_match(self, pkt)
         match.wildcards &= ~ofp.OFPFW_IN_PORT
         self.assertTrue(match is not None, 
                         "Could not generate flow match from pkt")
diff --git a/tests/flow_query.py b/tests/flow_query.py
index 7c04928..6044758 100644
--- a/tests/flow_query.py
+++ b/tests/flow_query.py
@@ -723,8 +723,8 @@
         return self
 
     # Randomize flow cfg
-    def rand(self, fi, valid_wildcards, valid_actions, valid_ports, valid_queues):
-        wildcards_force = test_param_get(fq_config, "wildcards_force", 0)
+    def rand(self, fi, wildcards_force, valid_wildcards, valid_actions, valid_ports,
+             valid_queues):
         if wildcards_force != 0:
             fq_logger.info("Wildcards forced:")
             fq_logger.info(wildcards_to_str(wildcards_force))
@@ -1186,7 +1186,7 @@
     def count(self):
         return len(self.dict)
 
-    def rand(self, sw, fi, num_flows):
+    def rand(self, wildcards_force, sw, fi, num_flows):
         self.clear()
         i = 0
         tbl = 0
@@ -1194,6 +1194,7 @@
         while i < num_flows:
             fc = Flow_Cfg()
             fc.rand(fi, \
+                    wildcards_force, \
                     sw.tbl_stats.stats[tbl].wildcards, \
                     sw.sw_features.actions, \
                     sw.valid_ports, \
@@ -1211,27 +1212,6 @@
                 j = 0
 
 
-error_msgs   = []
-removed_msgs = []
-
-def error_handler(self, msg, rawmsg):
-    fq_logger.info("Got an ERROR message, type=%d, code=%d" \
-                    % (msg.type, msg.code) \
-                    )
-    fq_logger.info("Message header:")
-    fq_logger.info(msg.header.show())
-    global error_msgs
-    error_msgs.append(msg)
-    pass
-
-def removed_handler(self, msg, rawmsg):
-    fq_logger.info("Got a REMOVED message")
-    fq_logger.info("Message header:")
-    fq_logger.info(msg.header.show())
-    global removed_msgs
-    removed_msgs.append(msg)
-    pass
-
 class Switch:
     # Members:
     # controller   - switch's test controller
@@ -1251,14 +1231,30 @@
         self.tbl_stats    = None
         self.flow_stats   = None
         self.flow_tbl     = Flow_Tbl()
+        self.error_msgs   = []
+        self.removed_msgs = []
+
+    def error_handler(self, controller, msg, rawmsg):
+        fq_logger.info("Got an ERROR message, type=%d, code=%d" \
+                          % (msg.type, msg.code) \
+                          )
+        fq_logger.info("Message header:")
+        fq_logger.info(msg.header.show())
+        self.error_msgs.append(msg)
+
+    def removed_handler(self, controller, msg, rawmsg):
+        fq_logger.info("Got a REMOVED message")
+        fq_logger.info("Message header:")
+        fq_logger.info(msg.header.show())
+        self.removed_msgs.append(msg)
 
     def controller_set(self, controller):
         self.controller = controller
         # Register error message handler
-        global error_msgs
-        error_msgs = []
-        controller.register(ofp.OFPT_ERROR, error_handler)
-        controller.register(ofp.OFPT_FLOW_REMOVED, removed_handler)
+        self.error_msgs = []
+        self.removed_msgs = []
+        controller.register(ofp.OFPT_ERROR, self.error_handler)
+        controller.register(ofp.OFPT_FLOW_REMOVED, self.removed_handler)
 
     def features_get(self):
         # Get switch features
@@ -1437,9 +1433,8 @@
 
     def errors_verify(self, num_exp, type = 0, code = 0):
         result = True
-        global error_msgs
         fq_logger.info("Expecting %d error messages" % (num_exp))
-        num_got = len(error_msgs)
+        num_got = len(self.error_msgs)
         fq_logger.info("Got %d error messages" % (num_got))
         if num_got != num_exp:
             fq_logger.error("Incorrect number of error messages received")
@@ -1451,7 +1446,7 @@
                             % (type, code) \
                             )
             f = False
-            for e in error_msgs:
+            for e in self.error_msgs:
                 if e.type == type and e.code == code:
                     fq_logger.info("Got it")
                     f = True
@@ -1465,9 +1460,8 @@
 
     def removed_verify(self, num_exp):
         result = True
-        global removed_msgs
         fq_logger.info("Expecting %d removed messages" % (num_exp))
-        num_got = len(removed_msgs)
+        num_got = len(self.removed_msgs)
         fq_logger.info("Got %d removed messages" % (num_got))
         if num_got != num_exp:
             fq_logger.error("Incorrect number of removed messages received")
@@ -1642,7 +1636,7 @@
         # Create a flow table
 
         ft = Flow_Tbl()
-        ft.rand(sw, fi, num_flows)
+        ft.rand(required_wildcards(self), sw, fi, num_flows)
 
         # Send flow table to switch
 
@@ -1735,6 +1729,7 @@
         while True:
             fc = Flow_Cfg()
             fc.rand(fi, \
+                    required_wildcards(self), \
                     sw.tbl_stats.stats[0].wildcards, \
                     sw.sw_features.actions, \
                     sw.valid_ports, \
@@ -1852,7 +1847,7 @@
         # Create a flow table, to switch's capacity
 
         ft = Flow_Tbl()
-        ft.rand(sw, fi, num_flows)
+        ft.rand(required_wildcards(self), sw, fi, num_flows)
 
         # Send flow table to switch
 
@@ -1879,6 +1874,7 @@
         while True:
             fc = Flow_Cfg()
             fc.rand(fi, \
+                    required_wildcards(self), \
                     sw.tbl_stats.stats[0].wildcards, \
                     sw.sw_features.actions, \
                     sw.valid_ports, \
@@ -1973,6 +1969,7 @@
 
         fc = Flow_Cfg()
         fc.rand(fi, \
+                required_wildcards(self), \
                 sw.tbl_stats.stats[0].wildcards, \
                 sw.sw_features.actions, \
                 sw.valid_ports, \
@@ -2093,6 +2090,7 @@
         fc = Flow_Cfg()
         while True:
             fc.rand(fi, \
+                    required_wildcards(self), \
                     sw.tbl_stats.stats[0].wildcards, \
                     sw.sw_features.actions, \
                     sw.valid_ports, \
@@ -2216,6 +2214,7 @@
 
         fc = Flow_Cfg()
         fc.rand(fi, \
+                required_wildcards(self), \
                 sw.tbl_stats.stats[0].wildcards, \
                 sw.sw_features.actions, \
                 sw.valid_ports, \
@@ -2340,7 +2339,7 @@
         # Dream up some flows
 
         ft = Flow_Tbl()
-        ft.rand(sw, fi, num_flows)
+        ft.rand(required_wildcards(self), sw, fi, num_flows)
 
         # Send flow table to switch
 
@@ -2487,6 +2486,7 @@
 
         fc = Flow_Cfg()
         fc.rand(fi, \
+                required_wildcards(self), \
                 sw.tbl_stats.stats[0].wildcards, \
                 sw.sw_features.actions, \
                 sw.valid_ports, \
@@ -2577,6 +2577,7 @@
 
         fc = Flow_Cfg()
         fc.rand(fi, \
+                required_wildcards(self), \
                 sw.tbl_stats.stats[0].wildcards, \
                 sw.sw_features.actions, \
                 sw.valid_ports, \
@@ -2688,6 +2689,7 @@
 
         fc = Flow_Cfg()
         fc.rand(fi, \
+                required_wildcards(self), \
                 sw.tbl_stats.stats[0].wildcards, \
                 sw.sw_features.actions, \
                 sw.valid_ports, \
@@ -2809,7 +2811,7 @@
         # Dream up some flows
 
         ft = Flow_Tbl()
-        ft.rand(sw, fi, num_flows)
+        ft.rand(required_wildcards(self), sw, fi, num_flows)
 
         # Send flow table to switch
 
@@ -2962,6 +2964,7 @@
 
         fc = Flow_Cfg()
         fc.rand(fi, \
+                required_wildcards(self), \
                 sw.tbl_stats.stats[0].wildcards, \
                 sw.sw_features.actions, \
                 sw.valid_ports, \
diff --git a/tests/flow_stats.py b/tests/flow_stats.py
index 4e115aa..9c7170e 100644
--- a/tests/flow_stats.py
+++ b/tests/flow_stats.py
@@ -145,7 +145,7 @@
 
         # build packet
         pkt = simple_tcp_packet()
-        match = parse.packet_to_flow_match(pkt)
+        match = packet_to_flow_match(self, pkt)
         match.wildcards &= ~ofp.OFPFW_IN_PORT
         self.assertTrue(match is not None, 
                         "Could not generate flow match from pkt")
@@ -185,7 +185,7 @@
         self.verifyStats(match, ofp.OFPP_NONE, test_timeout, num_sends)
         self.verifyStats(match, egress_port, test_timeout, num_sends)
         for wc in WILDCARD_VALUES:
-            match.wildcards = wc
+            match.wildcards = required_wildcards(self) | wc
             self.verifyStats(match, egress_port, test_timeout, num_sends)
 
 
@@ -203,7 +203,7 @@
     """
 
     def buildFlowModMsg(self, pkt, ingress_port, egress_port):
-        match = parse.packet_to_flow_match(pkt)
+        match = packet_to_flow_match(self, pkt)
         match.wildcards &= ~ofp.OFPFW_IN_PORT
         self.assertTrue(match is not None, 
                         "Could not generate flow match from pkt")
@@ -308,10 +308,10 @@
         for i in range(0,num_pkt2s):
             sendPacket(self, pkt2, ingress_port, egress_port2, test_timeout)
             
-        match1 = parse.packet_to_flow_match(pkt1)
+        match1 = packet_to_flow_match(self, pkt1)
         fs_logger.info("Verifying flow1's " + str(num_pkt1s) + " packets")
         self.verifyStats(match1, ofp.OFPP_NONE, test_timeout, num_pkt1s)
-        match2 = parse.packet_to_flow_match(pkt2)
+        match2 = packet_to_flow_match(self, pkt2)
         fs_logger.info("Verifying flow2's " + str(num_pkt2s) + " packets")
         self.verifyStats(match2, ofp.OFPP_NONE, test_timeout, num_pkt2s)
         match1.wildcards |= ofp.OFPFW_DL_SRC
@@ -333,7 +333,7 @@
     """
 
     def buildFlowModMsg(self, pkt, ingress_port, egress_port):
-        match = parse.packet_to_flow_match(pkt)
+        match = packet_to_flow_match(self, pkt)
         match.wildcards &= ~ofp.OFPFW_IN_PORT
         self.assertTrue(match is not None, 
                         "Could not generate flow match from pkt")
@@ -425,7 +425,7 @@
             sendPacket(self, pkt2, ingress_port, egress_port2, test_timeout)
             
         # loop on flow stats request until timeout
-        match = parse.packet_to_flow_match(pkt1)
+        match = packet_to_flow_match(self, pkt1)
         match.wildcards |= ofp.OFPFW_DL_SRC
         self.verifyAggFlowStats(match, ofp.OFPP_NONE, test_timeout, 
                                 2, num_pkt1s+num_pkt2s)
diff --git a/tests/load.py b/tests/load.py
index d168a17..7b18252 100644
--- a/tests/load.py
+++ b/tests/load.py
@@ -87,7 +87,7 @@
         self.controller.pkt_in_filter_limit = 10
 
         pkt = simple_tcp_packet()
-        match = parse.packet_to_flow_match(pkt)
+        match = packet_to_flow_match(self, pkt)
         match.wildcards &= ~ofp.OFPFW_IN_PORT
         match.in_port = lb_port
         act = action.action_output()
diff --git a/tests/pktact.py b/tests/pktact.py
index 14e540c..b53f13b 100644
--- a/tests/pktact.py
+++ b/tests/pktact.py
@@ -133,7 +133,7 @@
             pkt = simple_icmp_packet()
         else:
             pkt = simple_tcp_packet()
-        match = parse.packet_to_flow_match(pkt)
+        match = packet_to_flow_match(self, pkt)
         match.wildcards &= ~ofp.OFPFW_IN_PORT
         self.assertTrue(match is not None, 
                         "Could not generate flow match from pkt")
@@ -203,7 +203,7 @@
             pkt = simple_icmp_packet()
         else:
             pkt = simple_tcp_packet()
-        match = parse.packet_to_flow_match(pkt)
+        match = packet_to_flow_match(self, pkt)
         match.wildcards &= ~ofp.OFPFW_IN_PORT
         self.assertTrue(match is not None,
                         "Could not generate flow match from pkt")
@@ -274,7 +274,7 @@
             pkt = simple_icmp_packet()
         else:
             pkt = simple_tcp_packet()
-        match = parse.packet_to_flow_match(pkt)
+        match = packet_to_flow_match(self, pkt)
         match.wildcards &= ~ofp.OFPFW_IN_PORT
         self.assertTrue(match is not None, 
                         "Could not generate flow match from pkt")
@@ -398,7 +398,7 @@
             pkt = simple_icmp_packet()
         else:
             pkt = simple_tcp_packet()
-        match = parse.packet_to_flow_match(pkt)
+        match = packet_to_flow_match(self, pkt)
         match.wildcards &= ~ofp.OFPFW_IN_PORT
         self.assertTrue(match is not None, 
                         "Could not generate flow match from pkt")
@@ -533,7 +533,7 @@
         self.assertTrue(len(of_ports) > 2, "Not enough ports for test")
 
         pkt = simple_tcp_packet()
-        match = parse.packet_to_flow_match(pkt)
+        match = packet_to_flow_match(self, pkt)
         match.wildcards &= ~ofp.OFPFW_IN_PORT
         self.assertTrue(match is not None, 
                         "Could not generate flow match from pkt")
@@ -593,7 +593,7 @@
         self.assertTrue(len(of_ports) > 2, "Not enough ports for test")
 
         pkt = simple_tcp_packet()
-        match = parse.packet_to_flow_match(pkt)
+        match = packet_to_flow_match(self, pkt)
         match.wildcards &= ~ofp.OFPFW_IN_PORT
         self.assertTrue(match is not None, 
                         "Could not generate flow match from pkt")
@@ -648,7 +648,7 @@
         self.assertTrue(len(of_ports) > 2, "Not enough ports for test")
 
         pkt = simple_tcp_packet()
-        match = parse.packet_to_flow_match(pkt)
+        match = packet_to_flow_match(self, pkt)
         match.wildcards &= ~ofp.OFPFW_IN_PORT
         self.assertTrue(match is not None, 
                         "Could not generate flow match from pkt")
@@ -699,7 +699,7 @@
         self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
 
         pkt = simple_tcp_packet()
-        match = parse.packet_to_flow_match(pkt)
+        match = packet_to_flow_match(self, pkt)
         match.wildcards &= ~ofp.OFPFW_IN_PORT
         self.assertTrue(match is not None, 
                         "Could not generate flow match from pkt")
@@ -748,7 +748,7 @@
         self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
 
         pkt = simple_tcp_packet()
-        match = parse.packet_to_flow_match(pkt)
+        match = packet_to_flow_match(self, pkt)
         match.wildcards &= ~ofp.OFPFW_IN_PORT
         self.assertTrue(match is not None, 
                         "Could not generate flow match from pkt")
@@ -798,7 +798,7 @@
         self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
 
         pkt = simple_tcp_packet()
-        match = parse.packet_to_flow_match(pkt)
+        match = packet_to_flow_match(self, pkt)
         match.wildcards &= ~ofp.OFPFW_IN_PORT
         self.assertTrue(match is not None, 
                         "Could not generate flow match from pkt")
@@ -847,7 +847,7 @@
         self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
 
         pkt = simple_tcp_packet()
-        match = parse.packet_to_flow_match(pkt)
+        match = packet_to_flow_match(self, pkt)
         match.wildcards &= ~ofp.OFPFW_IN_PORT
         self.assertTrue(match is not None, 
                         "Could not generate flow match from pkt")
@@ -899,7 +899,7 @@
         self.assertTrue(len(of_ports) > 2, "Not enough ports for test")
 
         pkt = simple_tcp_packet()
-        match = parse.packet_to_flow_match(pkt)
+        match = packet_to_flow_match(self, pkt)
         match.wildcards &= ~ofp.OFPFW_IN_PORT
         self.assertTrue(match is not None, 
                         "Could not generate flow match from pkt")
@@ -1068,8 +1068,9 @@
 
 
 
-    def installFlow(self, prio, inp, egp, 
+    def installFlow(self, prio, inp, egp,
                     wildcards=ofp.OFPFW_DL_SRC):
+        wildcards |= required_wildcards(self)
         request = flow_msg_create(self, self.pkt, ing_port=inp, 
                                   wildcards=wildcards,
                                   egr_ports=egp)
@@ -1214,6 +1215,7 @@
     def runTest(self):
         vid = test_param_get(self.config, 'vid', default=TEST_VID_DEFAULT)
         for wc in WILDCARD_VALUES:
+            wc |= required_wildcards(self)
             if wc & ofp.OFPFW_DL_VLAN:
                 # Set nonzero VLAN id to avoid sending priority-tagged packet
                 dl_vlan = vid
@@ -1229,6 +1231,7 @@
     def runTest(self):
         vid = test_param_get(self.config, 'vid', default=TEST_VID_DEFAULT)
         for wc in WILDCARD_VALUES:
+            wc |= required_wildcards(self)
             flow_match_test(self, pa_port_map, wildcards=wc, dl_vlan=vid,
                             max_test=10)
 
@@ -1246,6 +1249,7 @@
     def runTest(self):
         vid = test_param_get(self.config, 'vid', default=TEST_VID_DEFAULT)
         for all_exp_one_wildcard in NO_WILDCARD_VALUES:
+            all_exp_one_wildcard |= required_wildcards(self)
             if all_exp_one_wildcard & ofp.OFPFW_DL_VLAN:
                 # Set nonzero VLAN id to avoid sending priority-tagged packet
                 dl_vlan = vid
@@ -1261,6 +1265,7 @@
     def runTest(self):
         vid = test_param_get(self.config, 'vid', default=TEST_VID_DEFAULT)
         for all_exp_one_wildcard in NO_WILDCARD_VALUES:
+            all_exp_one_wildcard |= required_wildcards(self)
             flow_match_test(self, pa_port_map, wildcards=all_exp_one_wildcard,
                             dl_vlan=vid)
 
@@ -1388,7 +1393,8 @@
                                        dl_vlan_enable=True, dl_vlan=old_vid)
         exp_pkt = simple_tcp_packet(pktlen=len_w_vid, dl_vlan_enable=True,
                                     dl_vlan=new_vid)
-        wildcards=ofp.OFPFW_DL_VLAN|ofp.OFPFW_DL_VLAN_PCP
+        wildcards = (required_wildcards(self) | ofp.OFPFW_DL_VLAN |
+                     ofp.OFPFW_DL_VLAN_PCP)
         vid_act = action.action_set_vlan_vid()
         vid_act.vlan_vid = new_vid
         request = flow_msg_create(self, untagged_pkt, ing_port=ing_port, 
@@ -1465,10 +1471,12 @@
         pkt = simple_tcp_packet(pktlen=len_w_vid, dl_vlan_enable=True, 
                                 dl_vlan=old_vid)
         exp_pkt = simple_tcp_packet(pktlen=len_untagged)
+        wildcards = (required_wildcards(self) | ofp.OFPFW_DL_VLAN |
+                     ofp.OFPFW_DL_VLAN_PCP)
         vid_act = action.action_strip_vlan()
 
         flow_match_test(self, pa_port_map, 
-                        wildcards=ofp.OFPFW_DL_VLAN|ofp.OFPFW_DL_VLAN_PCP,
+                        wildcards=wildcards,
                         pkt=pkt, exp_pkt=exp_pkt,
                         action_list=[vid_act])
 
@@ -1723,13 +1731,14 @@
         flows.append([])
         flows.append([])
     
-        wildcards = ofp.OFPFW_DL_SRC | ofp.OFPFW_DL_DST
+        wildcards = (required_wildcards(self) | ofp.OFPFW_DL_SRC |
+                     ofp.OFPFW_DL_DST)
         # Create up the flows in an array
         for toggle in range(2):
             for f_idx in range(flow_count):
                 pkt = simple_tcp_packet(tcp_sport=f_idx)
                 msg = message.flow_mod()
-                match = parse.packet_to_flow_match(pkt)
+                match = packet_to_flow_match(self, pkt)
                 match.in_port = of_ports[2]
                 match.wildcards = wildcards
                 msg.match = match
diff --git a/tests/port_stats.py b/tests/port_stats.py
index 087e725..0964774 100644
--- a/tests/port_stats.py
+++ b/tests/port_stats.py
@@ -165,7 +165,7 @@
 
         # build packet
         pkt = simple_tcp_packet()
-        match = parse.packet_to_flow_match(pkt)
+        match = packet_to_flow_match(self, pkt)
         match.wildcards &= ~ofp.OFPFW_IN_PORT
         self.assertTrue(match is not None, 
                         "Could not generate flow match from pkt")
@@ -218,7 +218,7 @@
     """
 
     def buildFlowModMsg(self, pkt, ingress_port, egress_port):
-        match = parse.packet_to_flow_match(pkt)
+        match = packet_to_flow_match(self, pkt)
         match.wildcards &= ~ofp.OFPFW_IN_PORT
         self.assertTrue(match is not None, 
                         "Could not generate flow match from pkt")
diff --git a/tests/testutils.py b/tests/testutils.py
index daa8ce1..b9e69d4 100644
--- a/tests/testutils.py
+++ b/tests/testutils.py
@@ -66,6 +66,14 @@
                          0, ofp.OFPPC_NO_FLOOD, logger)
     self.assertEqual(rv, 0, "Failed to reset port config")
 
+def required_wildcards(parent):
+    w = test_param_get(parent.config, 'required_wildcards', default='default')
+    if w == 'l3-l4':
+        return (ofp.OFPFW_NW_SRC_ALL | ofp.OFPFW_NW_DST_ALL | ofp.OFPFW_NW_TOS
+                | ofp.OFPFW_NW_PROTO | ofp.OFPFW_TP_SRC | ofp.OFPFW_TP_DST)
+    else:
+        return 0
+
 def simple_tcp_packet(pktlen=100, 
                       dl_dst='00:01:02:03:04:05',
                       dl_src='00:06:07:08:09:0a',
@@ -421,7 +429,12 @@
                                str(response.byte_count) + " != " + 
                                str(byte_count))
 
-def flow_msg_create(parent, pkt, ing_port=None, action_list=None, wildcards=0,
+def packet_to_flow_match(parent, packet):
+    match = parse.packet_to_flow_match(packet)
+    match.wildcards |= required_wildcards(parent)
+    return match
+
+def flow_msg_create(parent, pkt, ing_port=None, action_list=None, wildcards=None,
                egr_ports=None, egr_queue=None, check_expire=False, in_band=False):
     """
     Create a flow message
@@ -434,6 +447,8 @@
     """
     match = parse.packet_to_flow_match(pkt)
     parent.assertTrue(match is not None, "Flow match from pkt failed")
+    if wildcards is None:
+        wildcards = required_wildcards(parent)
     if in_band:
         wildcards &= ~ofp.OFPFW_IN_PORT
     match.wildcards = wildcards
@@ -503,7 +518,7 @@
     parent.assertTrue(rv != -1, "Error installing flow mod")
     parent.assertEqual(do_barrier(parent.controller), 0, "Barrier failed")
 
-def flow_match_test_port_pair(parent, ing_port, egr_ports, wildcards=0, 
+def flow_match_test_port_pair(parent, ing_port, egr_ports, wildcards=None,
                               dl_vlan=-1, pkt=None, exp_pkt=None,
                               action_list=None, check_expire=False):
     """
@@ -514,6 +529,8 @@
     See flow_match_test for parameter descriptions
     """
 
+    if wildcards is None:
+        wildcards = required_wildcards(parent)
     parent.logger.info("Pkt match test: " + str(ing_port) + " to " + 
                        str(egr_ports))
     parent.logger.debug("  WC: " + hex(wildcards) + " vlan: " + str(dl_vlan) +
@@ -563,7 +580,7 @@
     parent.logger.debug("Could not generate enough egress ports for test")
     return []
     
-def flow_match_test(parent, port_map, wildcards=0, dl_vlan=-1, pkt=None, 
+def flow_match_test(parent, port_map, wildcards=None, dl_vlan=-1, pkt=None, 
                     exp_pkt=None, action_list=None, check_expire=False, 
                     max_test=0, egr_count=1, ing_port=False):
     """
@@ -580,6 +597,8 @@
     @param check_expire Check for flow expiration message
     @param egr_count Number of egress ports; -1 means get from config w/ dflt 2
     """
+    if wildcards is None:
+        wildcards = required_wildcards(parent)
     of_ports = port_map.keys()
     of_ports.sort()
     parent.assertTrue(len(of_ports) > 1, "Not enough ports for test")