def int2mask(mask):
 return ((18446744069414584320L >> mask) & 4294967295L)

def int2mask ( mask ) : return ( ( 18446744069414584320 L >> mask ) & 4294967295 L )
converts the number of bits set to 1 in a mask to the integer corresponding to the ip address of the mask (ip2int for 24) from scapy:utils .