index : archinstall32 | |
Archlinux32 installer | gitolite user |
summaryrefslogtreecommitdiff |
author | Anton Hvornum <anton.feeds+github@gmail.com> | 2020-08-20 17:08:13 +0000 |
---|---|---|
committer | Anton Hvornum <anton.feeds+github@gmail.com> | 2020-08-20 17:08:13 +0000 |
commit | 056b800c8eb42c4112dce54bd1a7336d52ead2ab (patch) | |
tree | f26df1541224fd11a1d485ff6c463979d7c01983 /archinstall/lib/networking.py | |
parent | aaad480ab845ad644fdb8455d2bbf1763c605d24 (diff) |
-rw-r--r-- | archinstall/lib/networking.py | 20 |
diff --git a/archinstall/lib/networking.py b/archinstall/lib/networking.py new file mode 100644 index 00000000..ae4126a9 --- /dev/null +++ b/archinstall/lib/networking.py @@ -0,0 +1,20 @@ +import fcntl +import socket +import struct +from collections import OrderedDict + +from .exceptions import * + +def getHwAddr(ifname): + s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + info = fcntl.ioctl(s.fileno(), 0x8927, struct.pack('256s', bytes(ifname, 'utf-8')[:15])) + return ':'.join('%02x' % b for b in info[18:24]) + +def list_interfaces(skip_loopback=True): + interfaces = OrderedDict() + for index, iface in socket.if_nameindex(): + if skip_loopback and iface == 'lo': continue + + mac = getHwAddr(iface).replace(':', '-') + interfaces[mac] = iface + return interfaces |