Add LLDP links to graph
This commit is contained in:
parent
6450ae05a5
commit
285bb84870
@ -56,6 +56,8 @@ func (builder *GraphBuilder) readNodes(nodes map[string]*Node) {
|
|||||||
if nodeinfo.VPN {
|
if nodeinfo.VPN {
|
||||||
builder.vpn[sourceID] = nil
|
builder.vpn[sourceID] = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Batman neighbours
|
||||||
for _, batinterface := range nodeinfo.Network.Mesh {
|
for _, batinterface := range nodeinfo.Network.Mesh {
|
||||||
interfaces := batinterface.Interfaces
|
interfaces := batinterface.Interfaces
|
||||||
addresses := append(append(interfaces.Other, interfaces.Tunnel...), interfaces.Wireless...)
|
addresses := append(append(interfaces.Other, interfaces.Tunnel...), interfaces.Wireless...)
|
||||||
@ -65,12 +67,20 @@ func (builder *GraphBuilder) readNodes(nodes map[string]*Node) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Iterate over local MAC addresses from LLDP
|
||||||
|
if neighbours := node.Neighbours; neighbours != nil {
|
||||||
|
for sourceAddr, _ := range neighbours.LLDP {
|
||||||
|
builder.macToID[sourceAddr] = sourceID
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add links
|
// Add links
|
||||||
for sourceID, node := range nodes {
|
for sourceID, node := range nodes {
|
||||||
if flag := node.Flags; flag == nil || flag.Online {
|
if flag := node.Flags; flag == nil || flag.Online {
|
||||||
if neighbours := node.Neighbours; neighbours != nil {
|
if neighbours := node.Neighbours; neighbours != nil {
|
||||||
|
// Batman neighbours
|
||||||
for _, batadvNeighbours := range neighbours.Batadv {
|
for _, batadvNeighbours := range neighbours.Batadv {
|
||||||
for targetAddress, link := range batadvNeighbours.Neighbours {
|
for targetAddress, link := range batadvNeighbours.Neighbours {
|
||||||
if targetID, found := builder.macToID[targetAddress]; found {
|
if targetID, found := builder.macToID[targetAddress]; found {
|
||||||
@ -78,6 +88,14 @@ func (builder *GraphBuilder) readNodes(nodes map[string]*Node) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// LLDP
|
||||||
|
for _, neighbours := range neighbours.LLDP {
|
||||||
|
for targetAddress, _ := range neighbours {
|
||||||
|
if targetID, found := builder.macToID[targetAddress]; found {
|
||||||
|
builder.addLink(targetID, sourceID, 255)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user