- merge dante.go and dante_control.go into single dante.go - consolidate buildDantePacket and buildDantePacket28 into one function - fix broken comparison logic in SetDanteClockMaster - split ARP parsing into platform-specific files with build tags - implement Linux ARP table parsing via /proc/net/arp - run gofmt on all files Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
60 lines
864 B
Go
60 lines
864 B
Go
//go:build linux
|
|
|
|
package tendrils
|
|
|
|
import (
|
|
"bufio"
|
|
"net"
|
|
"os/exec"
|
|
"strings"
|
|
)
|
|
|
|
func (t *Tendrils) parseARPTable() []arpEntry {
|
|
cmd := exec.Command("cat", "/proc/net/arp")
|
|
output, err := cmd.Output()
|
|
if err != nil {
|
|
return nil
|
|
}
|
|
|
|
var entries []arpEntry
|
|
scanner := bufio.NewScanner(strings.NewReader(string(output)))
|
|
first := true
|
|
for scanner.Scan() {
|
|
if first {
|
|
first = false
|
|
continue
|
|
}
|
|
|
|
line := scanner.Text()
|
|
fields := strings.Fields(line)
|
|
if len(fields) < 6 {
|
|
continue
|
|
}
|
|
|
|
ip := net.ParseIP(fields[0])
|
|
if ip == nil {
|
|
continue
|
|
}
|
|
|
|
macStr := fields[3]
|
|
if macStr == "00:00:00:00:00:00" {
|
|
continue
|
|
}
|
|
|
|
mac, err := net.ParseMAC(macStr)
|
|
if err != nil {
|
|
continue
|
|
}
|
|
|
|
ifaceName := fields[5]
|
|
|
|
entries = append(entries, arpEntry{
|
|
ip: ip,
|
|
mac: mac,
|
|
iface: ifaceName,
|
|
})
|
|
}
|
|
|
|
return entries
|
|
}
|