[WIP] Glean from DDP

This commit is contained in:
Josh Deprez 2024-04-05 18:03:26 +11:00
parent f2b3b20a71
commit 49fc568bee
Signed by: josh
SSH key fingerprint: SHA256:zZji7w1Ilh2RuUpbQcqkLPrqmRwpiCSycbF2EfKm6Kw

21
main.go
View file

@ -164,20 +164,20 @@ func main() {
log.Fatalf("Couldn't read AppleTalk / AARP packet data: %v", err) log.Fatalf("Couldn't read AppleTalk / AARP packet data: %v", err)
} }
var pkt ethertalk.Packet var ethFrame ethertalk.Packet
if err := ethertalk.Unmarshal(rawPkt, &pkt); err != nil { if err := ethertalk.Unmarshal(rawPkt, &ethFrame); err != nil {
log.Printf("Couldn't unmarshal EtherTalk frame: %v", err) log.Printf("Couldn't unmarshal EtherTalk frame: %v", err)
continue continue
} }
if bytes.Equal(pkt.Src[:], localMAC) { if bytes.Equal(ethFrame.Src[:], localMAC) {
continue continue
} }
switch pkt.SNAPProto { switch ethFrame.SNAPProto {
case ethertalk.AARPProto: case ethertalk.AARPProto:
var aapkt aarp.Packet var aapkt aarp.Packet
if err := aarp.Unmarshal(pkt.Payload, &aapkt); err != nil { if err := aarp.Unmarshal(ethFrame.Payload, &aapkt); err != nil {
log.Printf("Couldn't unmarshal AARP packet: %v", err) log.Printf("Couldn't unmarshal AARP packet: %v", err)
continue continue
} }
@ -206,14 +206,21 @@ func main() {
case ethertalk.AppleTalkProto: case ethertalk.AppleTalkProto:
var ddpkt ddp.ExtPacket var ddpkt ddp.ExtPacket
if err := ddp.ExtUnmarshal(pkt.Payload, &ddpkt); err != nil { if err := ddp.ExtUnmarshal(ethFrame.Payload, &ddpkt); err != nil {
log.Printf("Couldn't unmarshal DDP packet: %v", err) log.Printf("Couldn't unmarshal DDP packet: %v", err)
continue continue
} }
log.Printf("Read AppleTalk packet with src (net %d node %d socket %d) dst (net %d node %d socket %d) data len %d", ddpkt.SrcNet, ddpkt.SrcNode, ddpkt.SrcSocket, ddpkt.DstNet, ddpkt.DstNode, ddpkt.DstSocket, len(ddpkt.Data)) log.Printf("Read AppleTalk packet with src (net %d node %d socket %d) dst (net %d node %d socket %d) data len %d", ddpkt.SrcNet, ddpkt.SrcNode, ddpkt.SrcSocket, ddpkt.DstNet, ddpkt.DstNode, ddpkt.DstSocket, len(ddpkt.Data))
// Glean address info for AMT
srcAddr := ddp.Addr{Network: ddpkt.SrcNet, Node: ddpkt.SrcNode}
amt[srcAddr] = amtEntry{
hwAddr: ethFrame.Src,
last: time.Now(),
}
log.Printf("DDP: Gleaned that %v -> %v", srcAddr, ethFrame.Src)
default: default:
log.Printf("Read unknown packet %s -> %s with payload %x", pkt.Src, pkt.Dst, pkt.Payload) log.Printf("Read unknown packet %s -> %s with payload %x", ethFrame.Src, ethFrame.Dst, ethFrame.Payload)
} }
} }