def network_size(net, dhcp=None): """ Func return gateway, mask and dhcp pool. """ mask = IP(net).strNetmask() addr = IP(net) if addr[0].strNormal()[-1] == '0': gateway = addr[1].strNormal() dhcp_pool = [addr[2].strNormal(), addr[addr.len() - 2].strNormal()] else: gateway = addr[0].strNormal() dhcp_pool = [addr[1].strNormal(), addr[addr.len() - 2].strNormal()] if dhcp: return gateway, mask, dhcp_pool else: return gateway, mask, None
def network_size(subnet, dhcp=None): """ Func return gateway, mask and dhcp pool. """ mask = IP(subnet).strNetmask() addr = IP(subnet) gateway = addr[1].strCompressed() if addr.version() == 4: dhcp_pool = [addr[2].strCompressed(), addr[addr.len() - 2].strCompressed()] if addr.version() == 6: mask = mask.lstrip('/') if '/' in mask else mask dhcp_pool = [IP(addr[0].strCompressed() + hex(256)), IP(addr[0].strCompressed() + hex(512 - 1))] if dhcp: return gateway, mask, dhcp_pool else: return gateway, mask, None