Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/networking.py
diff options
context:
space:
mode:
authorAnton Hvornum <anton.feeds@gmail.com>2021-01-25 10:31:02 +0100
committerAnton Hvornum <anton.feeds@gmail.com>2021-01-25 10:31:02 +0100
commit68adb3108f8111b1be434bf63c03562d72bbbe6f (patch)
treec0d0f7c3f86bbb560184f7565982b68387797aed /archinstall/lib/networking.py
parent5c696c4bc1f0d0e3abae105616fe783b85d6771a (diff)
Created an embryo for hardware detection. Supports detecting WiFi and UEFI. This fixes #44 and is a start for #82.
Diffstat (limited to 'archinstall/lib/networking.py')
-rw-r--r--archinstall/lib/networking.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/archinstall/lib/networking.py b/archinstall/lib/networking.py
index 4829a58b..b69a43db 100644
--- a/archinstall/lib/networking.py
+++ b/archinstall/lib/networking.py
@@ -1,9 +1,9 @@
+import os
import fcntl
import socket
import struct
from collections import OrderedDict
-
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]))
@@ -19,5 +19,22 @@ def list_interfaces(skip_loopback=True):
interfaces[mac] = iface
return interfaces
+def enrichIfaceTypes(interfaces :dict):
+ result = {}
+ for iface in interfaces:
+ if os.path.isdir(f"/sys/class/net/{iface}/bridge/"):
+ result[iface] = 'BRIDGE'
+ elif os.path.isfile(f"/sys/class/net/{iface}/tun_flags"):
+ # ethtool -i {iface}
+ result[iface] = 'TUN/TAP'
+ elif os.path.isdir(f"/sys/class/net/{iface}/device"):
+ if os.path.isdir(f"/sys/class/net/{iface}/wireless/"):
+ result[iface] = 'WIRELESS'
+ else:
+ result[iface] = 'PHYSICAL'
+ else:
+ result[iface] = 'UNKNOWN'
+ return result
+
def get_interface_from_mac(mac):
return list_interfaces().get(mac.lower(), None) \ No newline at end of file