Logo Search packages:      
Sourcecode: virt-manager version File versions  Download package

def virtManager::IPy::IPint::netmask (   self  ) 

Return netmask as an integer.

>>> print hex(IP('195.185.0.0/16').netmask().int())
0xFFFF0000L

Reimplemented in virtManager::IPy::IP.

Definition at line 553 of file IPy.py.

00553                      :
        """Return netmask as an integer.

        >>> print hex(IP('195.185.0.0/16').netmask().int())
        0xFFFF0000L
        """

        # TODO: unify with prefixlenToNetmask?
        if self._ipversion == 4:
            locallen = 32 - self._prefixlen
        elif self._ipversion == 6:
            locallen = 128 - self._prefixlen
        else:
            raise ValueError, "only IPv4 and IPv6 supported"

        return ((2L ** self._prefixlen) - 1) << locallen


    def strNetmask(self):


Generated by  Doxygen 1.6.0   Back to index