blob: bf5e1a4231da5269202030281da59e2ec11abc6a [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):
Patrick Williams20f38712022-12-08 06:18:26 -06008 bits |= 1 << i
9 packed_value = pack("!I", bits)
Chris Austenb29d2e82016-06-07 12:25:35 -050010 addr = inet_ntoa(packed_value)
11 return addr