Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 1 addition & 20 deletions rtslib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down