Exemple #1
0
def mask2pfxlen(scope, masks):
    """
    Converts the given IP mask(s) (e.g. 255.255.255.0) to prefix length(s).

    :type  masks: string
    :param masks: An IP mask, or a list of masks.
    :rtype:  string
    :return: The prefix length(s) that result(s) from converting the mask.
    """
    return [ipv4.mask2pfxlen(mask) for mask in masks]
Exemple #2
0
def mask2pfxlen(scope, masks):
    """
    Converts the given IP mask(s) (e.g. 255.255.255.0) to prefix length(s).

    @type  masks: string
    @param masks: An IP mask, or a list of masks.
    @rtype:  string
    @return: The prefix length(s) that result(s) from converting the mask.
    """
    return [ipv4.mask2pfxlen(mask) for mask in masks]
Exemple #3
0
 def testMask2Pfxlen(self):
     from Exscript.util.ipv4 import mask2pfxlen
     self.assertEqual(32, mask2pfxlen('255.255.255.255'))
     self.assertEqual(31, mask2pfxlen('255.255.255.254'))
     self.assertEqual(30, mask2pfxlen('255.255.255.252'))
     self.assertEqual(2, mask2pfxlen('192.0.0.0'))
     self.assertEqual(1, mask2pfxlen('128.0.0.0'))
     self.assertEqual(0, mask2pfxlen('0.0.0.0'))
Exemple #4
0
 def testMask2Pfxlen(self):
     from Exscript.util.ipv4 import mask2pfxlen
     self.assertEqual(32, mask2pfxlen('255.255.255.255'))
     self.assertEqual(31, mask2pfxlen('255.255.255.254'))
     self.assertEqual(30, mask2pfxlen('255.255.255.252'))
     self.assertEqual(2,  mask2pfxlen('192.0.0.0'))
     self.assertEqual(1,  mask2pfxlen('128.0.0.0'))
     self.assertEqual(0,  mask2pfxlen('0.0.0.0'))