def fill_wildcards(self, field=None, value=0):
        """Update wildcards attribute.

        This method update a wildcards considering the attributes of the
        current instance.

        Args:
            field (str): Name of the updated field.
            value (GenericType): New value used in the field.
        """
        if field in [None, 'wildcards'] or isinstance(value, Pad):
            return

        default_value = getattr(Match, field)
        if isinstance(default_value, IPAddress):
            if field == 'nw_dst':
                shift = FlowWildCards.OFPFW_NW_DST_SHIFT
                base_mask = FlowWildCards.OFPFW_NW_DST_MASK
            else:
                shift = FlowWildCards.OFPFW_NW_SRC_SHIFT
                base_mask = FlowWildCards.OFPFW_NW_SRC_MASK

            # First we clear the nw_dst/nw_src mask related bits on the current
            # wildcard by setting 0 on all of them while we keep all other bits
            # as they are.
            self.wildcards &= FlowWildCards.OFPFW_ALL ^ base_mask

            # nw_dst and nw_src wildcard fields have 6 bits each.
            # "base_mask" is the 'all ones' for those 6 bits.
            # Once we know the netmask, we can calculate the these 6 bits
            # wildcard value and reverse them in order to insert them at the
            # correct position in self.wildcards
            wildcard = (value.max_prefix - value.netmask) << shift
            self.wildcards |= wildcard
        else:
            wildcard_field = "OFPFW_{}".format(field.upper())
            wildcard = getattr(FlowWildCards, wildcard_field)

            if value == default_value and not (self.wildcards & wildcard) or \
               value != default_value and (self.wildcards & wildcard):
                self.wildcards ^= wildcard
def fill_wildcards ( self , field = None , value = 0 ) : if field in [ None , 'wildcards' ] or isinstance ( value , Pad ) : return default_value = getattr ( Match , field ) if isinstance ( default_value , IPAddress ) : if field == 'nw_dst' : shift = FlowWildCards . OFPFW_NW_DST_SHIFT base_mask = FlowWildCards . OFPFW_NW_DST_MASK else : shift = FlowWildCards . OFPFW_NW_SRC_SHIFT base_mask = FlowWildCards . OFPFW_NW_SRC_MASK self . wildcards &= FlowWildCards . OFPFW_ALL ^ base_mask wildcard = ( value . max_prefix - value . netmask ) << shift self . wildcards |= wildcard else : wildcard_field = "OFPFW_{}" . format ( field . upper ( ) ) wildcard = getattr ( FlowWildCards , wildcard_field ) if value == default_value and not ( self . wildcards & wildcard ) or value != default_value and ( self . wildcards & wildcard ) : self . wildcards ^= wildcard
Update wildcards attribute.

        This method update a wildcards considering the attributes of the
        current instance.

        Args:
            field (str): Name of the updated field.
            value (GenericType): New value used in the field.