'Normalize the wildcard bits
Note the following from the OpenFlow 1.1 spec:
Protocol-specific fields within ofp_match will be ignored within
a single table when the corresponding protocol is not specified in the
match.  The IP header and transport header fields
will be ignored unless the Ethertype is specified as either IPv4 or
ARP. The tp_src and tp_dst fields will be ignored unless the network
protocol specified is as TCP, UDP or SCTP. Fields that are ignored
don\'t need to be wildcarded and should be set to 0.
OpenFlow 1.0.1 Section 3.4 actually has an improved version of the above,
but we won\'t quote it here because it seems to have a restrictive license.'

def _wire_wildcards(self, wildcards):

    if (self.dl_type == 2048):
        if (self.nw_proto not in (1, 6, 17)):
            return (wildcards & (~ (OFPFW_TP_SRC | OFPFW_TP_DST)))
        else:
            return wildcards
    elif (self.dl_type == 2054):
        return (wildcards & (~ ((OFPFW_NW_TOS | OFPFW_TP_SRC) | OFPFW_TP_DST)))
    else:
        return (wildcards & (~ (((((OFPFW_NW_TOS | OFPFW_NW_PROTO) | OFPFW_NW_SRC_MASK) | OFPFW_NW_DST_MASK) | OFPFW_TP_SRC) | OFPFW_TP_DST)))
