Re: Please, document byte order in org.freedesktop.NetworkManager.IP4Config
- From: Pablo Martí Gamboa <pmarti warp es>
- To: Andrey Batyiev <batyiev gmail com>
- Cc: networkmanager-list gnome org
- Subject: Re: Please, document byte order in org.freedesktop.NetworkManager.IP4Config
- Date: Thu, 22 Oct 2009 11:59:41 +0200
2009/10/22 Pablo Martí Gamboa
<pmarti warp es>
2009/10/22 Andrey Batyiev
<batyiev gmail com>
Hello everyone
Am I right, that every IP address in org.freedesktop.NetworkManager.IP4Config
is in network byte order? Could you explicitly document this behaviour,
please?
implementation in Python:
import sockket
def convert_ip_to_int(ip):
"""
Converts ``ip`` to its integer representation
:param ip: The IP to convert
:type ip: str
:rtype: int
"""
i = struct.unpack('i', socket.inet_pton(socket.AF_INET, ip))[0]
if i < 0:
i += 0xffffffff + 1
return i
Oops, too quick... it should be "import socket" :P
--
Pablo Martí
http://www.linkedin.com/in/pmarti || http://www.warp.es
python -c "print '706d6172746940776172702e6573'.decode('hex')"
--
Pablo Martí
http://www.linkedin.com/in/pmarti ||
http://www.warp.espython -c "print '706d6172746940776172702e6573'.decode('hex')"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]