コード例 #1
0
ファイル: ipv4.py プロジェクト: animeshinvinci/pycopia
def itodq(addr):
    """itodq(int_address) (integer to dotted-quad)
Return a dotted-quad string given an integer. """
    intval = long(addr) # might get an IPv4 object
    s = "%c%c%c%c" % (((intval >> 24) & 0x000000ff), ((intval & 0x00ff0000) >> 16),
        ((intval & 0x0000ff00) >> 8), (intval & 0x000000ff))
    return socket.inet_ntoa(s)
コード例 #2
0
ファイル: ipv4.py プロジェクト: wildone/pycopia
def itodq(addr):
    """Return a dotted-quad string given an integer. """
    intval = long(addr)  # might get an IPv4 object
    s = struct.pack(b"BBBB", (intval >> 24) & 0x000000ff,
                    (intval & 0x00ff0000) >> 16, (intval & 0x0000ff00) >> 8,
                    intval & 0x000000ff)
    return socket.inet_ntoa(s)
コード例 #3
0
ファイル: ifconfig.py プロジェクト: wildone/pycopia
    def _getaddr(self, ifname, func):
        ifreq = (ifname + '\0' * 32)[:32]
        try:
            result = self._fcntl(func, ifreq)
        except IOError:
            return None

        return socket.inet_ntoa(result[20:24])
コード例 #4
0
ファイル: ifconfig.py プロジェクト: bharathi26/pycopia
    def _getaddr(self, ifname, func):
        ifreq = (ifname + '\0'*32)[:32]
        try:
            result = self._fcntl(func, ifreq)
        except IOError:
            return None

        return socket.inet_ntoa(result[20:24])
コード例 #5
0
ファイル: ipv4.py プロジェクト: bharathi26/pycopia
def itodq(addr):
    """Return a dotted-quad string given an integer. """
    intval = long(addr) # might get an IPv4 object
    s = struct.pack(b"BBBB", (intval >> 24) & 0x000000ff, (intval & 0x00ff0000) >> 16,
        (intval & 0x0000ff00) >> 8, intval & 0x000000ff)
    return socket.inet_ntoa(s)