def mask2long(mask):
    assert isinstance(mask, (int, long)) and mask >= 0 and mask <= 32
    return -(1 << (32 - mask)) 


# deprecated
Convert numeric CIDR network mask to negative integer representation for bitwise operations.
dataset/ETHPy150Open securitykiss-com/rfw/rfw/iputil.py/mask2long