MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / is_link_local_ip

Function is_link_local_ip

wifi_interfaces.py:22–34  ·  view source on GitHub ↗

Check if an IP address is in the link-local range (169.254.x.x). These addresses are auto-assigned when DHCP fails and should not be treated as valid network connections.

(ip_address: Optional[str])

Source from the content-addressed store, hash-verified

20
21
22def is_link_local_ip(ip_address: Optional[str]) -> bool:
23 """Check if an IP address is in the link-local range (169.254.x.x).
24
25 These addresses are auto-assigned when DHCP fails and should not be
26 treated as valid network connections.
27 """
28 if not ip_address:
29 return False
30 try:
31 ip = ipaddress.ip_address(ip_address)
32 return ip in _LINK_LOCAL_NETWORK
33 except ValueError:
34 return False
35
36
37def _get_interface_ipv4_details(interface_name: str) -> Dict[str, Optional[str]]:

Callers 3

Calls

no outgoing calls

Tested by

no test coverage detected