Removed IP classes because they're obsolete

This commit is contained in:
Marco Cetica 2023-11-11 17:03:16 +01:00
parent 342abbd643
commit bb2a2833d1
Signed by: marco
GPG Key ID: 45060A949E90D0FD
2 changed files with 0 additions and 13 deletions

View File

@ -16,5 +16,4 @@ Subnet Mask: 255.255.255.0 (11111111 11111111 11111111 00000000)
Network Prefix: 10.0.3.0 (00001010 00000000 00000011 00000000)
Host Prefix: 0.0.0.4 (00000000 00000000 00000000 00000100)
Usable Hosts: 254
IP Class: A
```

View File

@ -17,7 +17,6 @@ class IP:
host_prefix: str = ""
host_bin: str = ""
usable_hosts: str = ""
ip_class: str = ""
def __init__(self, cidr):
# Check if CIDR is properly formatted
@ -70,16 +69,6 @@ class IP:
bit_count = bin(mask_complement).count('1')
self.usable_hosts = (2 ** bit_count - 2) if bit_count > 0 else 0
# Get IP Class
first_octet = int(self.ip_addr.split('.')[0])
ip_classes = {
(0 < first_octet <= 127): 'A',
(128 <= first_octet <= 191): 'B',
(192 <= first_octet <= 223): 'C'
}
self.ip_class = next((val for cond, val in ip_classes.items() if cond), None)
def main():
if len(sys.argv) < 2:
print(f"Usage {sys.argv[0]} <CIDR>")
@ -97,7 +86,6 @@ def main():
print(f"Network Prefix: {ip.network_prefix} ({ip.network_bin})")
print(f"Host Prefix: {ip.host_prefix} ({ip.host_bin})")
print(f"Usable Hosts: {ip.usable_hosts}")
print(f"IP Class: {ip.ip_class}")
except ValueError as e:
print(e)
sys.exit(1)