Development

This commit is contained in:
Matthew Grotke 2026-06-03 02:57:59 -04:00
parent d6f1a74684
commit f518f0e86b
3 changed files with 25 additions and 20 deletions

View file

@ -1,4 +1,5 @@
import ipaddress
import json
import os
import glob
from datetime import datetime, timezone
@ -46,26 +47,10 @@ def _vendor_cell(vendor):
def _get_arp_table():
"""Return {mac_lower: entry} from /proc/net/arp (host-mounted). ATF_COM (0x2) flag means
the entry is complete; entries without it (incomplete) are excluded."""
"""Return {mac_lower: entry} from the ARP cache written by maintenance.py."""
try:
entries = {}
with open('/host/proc/net/arp') as f:
next(f) # skip header line
for line in f:
parts = line.split()
if len(parts) < 6:
continue
ip = parts[0]
flags = int(parts[2], 16)
mac = parts[3].lower()
iface = parts[5]
if not (flags & 0x2):
continue
if mac == '00:00:00:00:00:00':
continue
entries[mac] = {'ip': ip, 'iface': iface, 'state': 'REACHABLE'}
return entries
with open('/var/lib/misc/arp-cache.json') as f:
return json.load(f)
except Exception:
return {}

View file

@ -14,7 +14,6 @@ services:
- /sys/devices:/sys/devices:ro
- /etc/localtime:/etc/localtime:ro
- /var/lib/misc:/var/lib/misc:ro
- /proc/net/arp:/host/proc/net/arp:ro
- /var/log/freeradius:/var/log/freeradius
environment:
- PYTHONPATH=/routlin_location