def getForward(self): ip = dns.aton(self.address) mask = dns.aton(self.mask) ipmask = dns.ntoa(mask) broadcast = dns.ntoa(ip | ~mask) return (("; %s\n" % self.dn) + formatIPAddress(self.name, self.address) + formatIPAddress("netmask." + self.name, ipmask) + formatIPAddress("broadcast." + self.name, broadcast))
def printZone(self): print("#" + self.dn) printIPAddress(self.name, self.address) printPTR(self.name, self.address) ip = dns.aton(self.address) mask = dns.aton(self.mask) ipmask = dns.ntoa(mask) broadcast = dns.ntoa(ip | ~mask) printIPAddress("netmask." + self.name, ipmask) printIPAddress("broadcast." + self.name, broadcast) printPTR("broadcast." + self.name, broadcast)
def getReverse(self, domain): ip = dns.aton(self.address) mask = dns.aton(self.mask) broadcast = dns.ntoa(ip | ~mask) return (("; %s\n" % self.dn) + formatPTR(self.name + "." + domain, self.address) + formatPTR("broadcast." + self.name + "." + domain, broadcast))
def test_CIDR(self): for i in range(0, 33): mask = dns.ntoa(dns.aton(i)) self.assertEquals(dns.netmaskToNumbits(mask), i)
def test_CIDR(self): for i in range(0, 33): mask = dns.ntoa(dns.aton(i)) self.assertEqual(dns.netmaskToNumbits(mask), i)