Refactor to tree-based topology with ASCII visualization
This commit is contained in:
6
lldp.go
6
lldp.go
@@ -51,13 +51,11 @@ func (t *Tendrils) handleLLDPPacket(ifaceName string, packet gopacket.Packet) {
|
||||
return
|
||||
}
|
||||
|
||||
log.Printf("[%s] lldp packet received: ChassisID=%x PortID=%s TTL=%d",
|
||||
ifaceName, lldp.ChassisID.ID, lldp.PortID.ID, lldp.TTL)
|
||||
|
||||
if len(lldp.ChassisID.ID) == 6 {
|
||||
mac := net.HardwareAddr(lldp.ChassisID.ID)
|
||||
if !isBroadcastOrZero(mac) {
|
||||
t.neighbors.Update(nil, []net.HardwareAddr{mac}, "lldp:"+ifaceName)
|
||||
childPort := string(lldp.PortID.ID)
|
||||
t.nodes.Update(nil, []net.HardwareAddr{mac}, ifaceName, childPort, "lldp")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user