You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

31 lines
848 B

  1. from typing import Tuple, Dict, Any, Set, List
  2. from .normalize import normalize_mac, is_mac
  3. def extract_gateway_macs(data: object) -> Tuple[Set[str], Dict[str, Any], List[str]]:
  4. """
  5. ritorna:
  6. - allowed MAC (validi)
  7. - mapping mac->record
  8. - lista raw MAC invalidi (normalizzati quando possibile)
  9. """
  10. allowed: Set[str] = set()
  11. by_mac: Dict[str, Any] = {}
  12. invalid: List[str] = []
  13. if not isinstance(data, list):
  14. return allowed, by_mac, invalid
  15. for item in data:
  16. if not isinstance(item, dict):
  17. continue
  18. raw = item.get("mac", "")
  19. mac = normalize_mac(raw)
  20. if mac and is_mac(mac):
  21. allowed.add(mac)
  22. by_mac[mac] = item
  23. else:
  24. if raw:
  25. invalid.append(str(raw))
  26. return allowed, by_mac, invalid