pythonutil.py (e635ddc0cb252f30990a509ac8314adef394c369) | pythonutil.py (20f38712b324e61a94e174017c487a0af4b373e1) |
---|---|
1from socket import inet_ntoa 2from struct import pack 3 4 5def calcDottedNetmask(mask): 6 bits = 0 7 for i in xrange(32 - mask, 32): | 1from socket import inet_ntoa 2from struct import pack 3 4 5def calcDottedNetmask(mask): 6 bits = 0 7 for i in xrange(32 - mask, 32): |
8 bits |= (1 << i) 9 packed_value = pack('!I', bits) | 8 bits |= 1 << i 9 packed_value = pack("!I", bits) |
10 addr = inet_ntoa(packed_value) 11 return addr | 10 addr = inet_ntoa(packed_value) 11 return addr |