blob: 3fd6ffb1804f7d31c3e9eb7d601100192e0eee94 [file] [log] [blame]
Chris Austenb29d2e82016-06-07 12:25:35 -05001from socket import inet_ntoa
2from struct import pack
3
4
5def calcDottedNetmask(mask):
6 bits = 0
Joy Onyerikwu004ad3c2018-06-11 16:29:56 -05007 for i in xrange(32 - mask, 32):
Chris Austenb29d2e82016-06-07 12:25:35 -05008 bits |= (1 << i)
9 packed_value = pack('!I', bits)
10 addr = inet_ntoa(packed_value)
11 return addr