From f141c1d9882c6780257a1227a466b9632e1c6e24 Mon Sep 17 00:00:00 2001 From: Kevin Otte Date: Sat, 12 Nov 2016 21:27:40 -0500 Subject: [PATCH] utils.py: remove list_eth_names() Removes list_eth_names() function as it appears to only be used by list_eth_ips(). The latter now calls netifaces.interfaces() directly. Fixes #17 --- rtslib/utils.py | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/rtslib/utils.py b/rtslib/utils.py index 6974235..dbb5943 100644 --- a/rtslib/utils.py +++ b/rtslib/utils.py @@ -613,25 +613,6 @@ def exec_argv(argv, strip=True, shell=False): else: return stdoutdata -def list_eth_names(max_eth=1024): - ''' - List the max_eth first local ethernet interfaces names from SIOCGIFCONF - struct. - ''' - SIOCGIFCONF = 0x8912 - if os.uname()[4].endswith("_64"): - offset = 40 - else: - offset = 32 - bytes = 32 * max_eth - sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - ifaces = array('B', '\0' * bytes) - packed = pack('iL', bytes, ifaces.buffer_info()[0]) - outbytes = unpack('iL', ioctl(sock.fileno(), SIOCGIFCONF, packed))[0] - names = ifaces.tostring() - return [names[i:i+offset].split('\0', 1)[0] - for i in range(0, outbytes, offset)] - def list_eth_ips(ifnames=None): ''' List the IPv4 and IPv6 non-loopback, non link-local addresses (in the @@ -640,7 +621,7 @@ def list_eth_ips(ifnames=None): of all ifaces excepted for lo. ''' if ifnames is None: - ifnames = [iface for iface in list_eth_names() if iface != 'lo'] + ifnames = [iface for iface in netifaces.interfaces() if iface != 'lo'] addrs = [] for iface in ifnames: ifaddresses = netifaces.ifaddresses(iface)