Example #1
0
def pfxlen2mask(scope, pfxlen):
    """
    Converts the given prefix length(s) (e.g. 30) to IP mask(s).

    :type  pfxlen: int
    :param pfxlen: An IP prefix length.
    :rtype:  string
    :return: The mask(s) that result(s) from converting the prefix length.
    """
    return [ipv4.pfxlen2mask(pfx) for pfx in pfxlen]
Example #2
0
def pfxlen2mask(scope, pfxlen):
    """
    Converts the given prefix length(s) (e.g. 30) to IP mask(s).

    @type  pfxlen: int
    @param pfxlen: An IP prefix length.
    @rtype:  string
    @return: The mask(s) that result(s) from converting the prefix length.
    """
    return [ipv4.pfxlen2mask(pfx) for pfx in pfxlen]
Example #3
0
 def testPfxlen2Mask(self):
     from Exscript.util.ipv4 import pfxlen2mask
     self.assertEqual(pfxlen2mask(32), '255.255.255.255')
     self.assertEqual(pfxlen2mask(31), '255.255.255.254')
     self.assertEqual(pfxlen2mask(30), '255.255.255.252')
     self.assertEqual(pfxlen2mask(2), '192.0.0.0')
     self.assertEqual(pfxlen2mask(1), '128.0.0.0')
     self.assertEqual(pfxlen2mask(0), '0.0.0.0')
Example #4
0
 def testPfxlen2Mask(self):
     from Exscript.util.ipv4 import pfxlen2mask
     self.assertEqual(pfxlen2mask(32), '255.255.255.255')
     self.assertEqual(pfxlen2mask(31), '255.255.255.254')
     self.assertEqual(pfxlen2mask(30), '255.255.255.252')
     self.assertEqual(pfxlen2mask(2),  '192.0.0.0')
     self.assertEqual(pfxlen2mask(1),  '128.0.0.0')
     self.assertEqual(pfxlen2mask(0),  '0.0.0.0')