Initial commit: Simple DHCP Server mit Tkinter-GUI und Start-Skripten
This commit is contained in:
29
src/utils.py
Normal file
29
src/utils.py
Normal file
@@ -0,0 +1,29 @@
|
||||
def get_available_interfaces():
|
||||
import netifaces
|
||||
return netifaces.interfaces()
|
||||
|
||||
def format_ip_address(ip):
|
||||
try:
|
||||
parts = ip.split('.')
|
||||
if len(parts) != 4:
|
||||
raise ValueError("Invalid IP address format")
|
||||
return '.'.join(str(int(part)) for part in parts)
|
||||
except ValueError as e:
|
||||
raise ValueError(f"Error formatting IP address: {e}")
|
||||
|
||||
def validate_subnet_mask(mask):
|
||||
valid_masks = [
|
||||
'255.255.255.255', '255.255.255.254', '255.255.255.252',
|
||||
'255.255.255.248', '255.255.255.240', '255.255.255.224',
|
||||
'255.255.255.192', '255.255.255.128', '255.255.255.0',
|
||||
'255.255.254.0', '255.255.252.0', '255.255.248.0',
|
||||
'255.255.240.0', '255.255.224.0', '255.255.192.0',
|
||||
'255.255.128.0', '255.255.0.0', '255.254.0.0',
|
||||
'255.252.0.0', '255.248.0.0', '255.240.0.0',
|
||||
'255.224.0.0', '255.192.0.0', '255.128.0.0',
|
||||
'255.0.0.0', '254.0.0.0', '252.0.0.0',
|
||||
'248.0.0.0', '240.0.0.0', '224.0.0.0',
|
||||
'192.0.0.0', '128.0.0.0', '0.0.0.0'
|
||||
]
|
||||
if mask not in valid_masks:
|
||||
raise ValueError("Invalid subnet mask")
|
||||
Reference in New Issue
Block a user