diff options
author | Thomas Haller <thaller@redhat.com> | 2018-07-11 17:53:30 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2018-07-11 17:53:44 +0200 |
commit | 9730961a0233daa7f7d007affc75f2d36bb6552a (patch) | |
tree | 1de3d1a6b83dfbc8cc214defb3fa1b491c2378c6 /tools | |
parent | 260cded3d6a1dc8d8aa02f126908dc1667f163ed (diff) | |
download | NetworkManager-9730961a0233daa7f7d007affc75f2d36bb6552a.tar.gz |
tests/trivial: rename ip4_addr_ne32() to ip4_addr_be32() in test-networkmanager-service.py
The function is supposed to return the IPv4 address as 32 bit integer in
network byte order (bit endian). The ip4_addr_ne32() name is confusing,
because "ne" commonly stands for "native endianness".
Compare also "unaligned.h" and unaligned_read_ne32(), which also
stands for native endianness (host order), not network order (big
endian).
Rename.
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/test-networkmanager-service.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/tools/test-networkmanager-service.py b/tools/test-networkmanager-service.py index 7fbed7ec93..328bcdd9fa 100755 --- a/tools/test-networkmanager-service.py +++ b/tools/test-networkmanager-service.py @@ -108,7 +108,9 @@ class Util: return (Util.ip_addr_ntop(a, family), family) @staticmethod - def ip4_addr_ne32(addr): + def ip4_addr_be32(addr): + # return the IPv4 address as 32 bit integer in network byte order + # (big endian). a, family = Util.ip_addr_pton(addr, socket.AF_INET) n = 0 for i in range(4): @@ -1852,9 +1854,9 @@ class IP4Config(ExportedObj): return { PRP_IP4_CONFIG_ADDRESSES: dbus.Array([ - [ Util.ip4_addr_ne32(a['addr']), + [ Util.ip4_addr_be32(a['addr']), a['prefix'], - Util.ip4_addr_ne32(a['gateway']) if a['gateway'] else 0 + Util.ip4_addr_be32(a['gateway']) if a['gateway'] else 0 ] for a in addrs ], 'au'), @@ -1868,9 +1870,9 @@ class IP4Config(ExportedObj): 'a{sv}'), PRP_IP4_CONFIG_GATEWAY: dbus.String(gateway) if gateway else "", PRP_IP4_CONFIG_ROUTES: dbus.Array([ - [ Util.ip4_addr_ne32(a['dest']), + [ Util.ip4_addr_be32(a['dest']), a['prefix'], - Util.ip4_addr_ne32(a['next-hop'] or '0.0.0.0'), + Util.ip4_addr_be32(a['next-hop'] or '0.0.0.0'), max(a['metric'], 0) ] for a in routes ], @@ -1884,12 +1886,12 @@ class IP4Config(ExportedObj): for a in routes ], 'a{sv}'), - PRP_IP4_CONFIG_NAMESERVERS: dbus.Array([dbus.UInt32(Util.ip4_addr_ne32(n)) for n in nameservers], 'u'), + PRP_IP4_CONFIG_NAMESERVERS: dbus.Array([dbus.UInt32(Util.ip4_addr_be32(n)) for n in nameservers], 'u'), PRP_IP4_CONFIG_DOMAINS: dbus.Array(domains, 's'), PRP_IP4_CONFIG_SEARCHES: dbus.Array(searches, 's'), PRP_IP4_CONFIG_DNSOPTIONS: dbus.Array(dnsoptions, 's'), PRP_IP4_CONFIG_DNSPRIORITY: dbus.Int32(dnspriority), - PRP_IP4_CONFIG_WINSSERVERS: dbus.Array([dbus.UInt32(Util.ip4_addr_ne32(n)) for n in winsservers], 'u'), + PRP_IP4_CONFIG_WINSSERVERS: dbus.Array([dbus.UInt32(Util.ip4_addr_be32(n)) for n in winsservers], 'u'), } def props_regenerate(self, generate_seed): |