Skip to content

Commit

Permalink
fix LLDP handling for freifunk-gluon/packages#189
Browse files Browse the repository at this point in the history
  • Loading branch information
genofire committed Jul 10, 2022
1 parent c5703e0 commit 124215f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
11 changes: 1 addition & 10 deletions data/neighbours.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package data
type Neighbours struct {
Batadv map[string]BatadvNeighbours `json:"batadv"`
Babel map[string]BabelNeighbours `json:"babel"`
LLDP map[string]LLDPNeighbours `json:"lldp"`
LLDP map[string][]string `json:"lldp"`
//WifiNeighbours map[string]WifiNeighbours `json:"wifi"`
NodeID string `json:"node_id"`
}
Expand All @@ -22,12 +22,6 @@ type BatmanLink struct {
Tq int `json:"tq"`
}

// LLDPLink struct
type LLDPLink struct {
Name string `json:"name"`
Description string `json:"descr"`
}

// BabelLink struct
type BabelLink struct {
// How need this:
Expand All @@ -53,6 +47,3 @@ type BabelNeighbours struct {
type WifiNeighbours struct {
Neighbours map[string]WifiLink `json:"neighbours"`
}

// LLDPNeighbours struct
type LLDPNeighbours map[string]LLDPLink
2 changes: 1 addition & 1 deletion output/meshviewer/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (builder *graphBuilder) readNodes(nodes map[string]*runtime.Node) {
}
// LLDP
for _, neighbours := range neighbours.LLDP {
for targetAddress := range neighbours {
for _, targetAddress := range neighbours {
if targetID, found := builder.macToID[targetAddress]; found {
builder.addLink(targetID, sourceID, 255, false)
}
Expand Down
14 changes: 14 additions & 0 deletions runtime/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,20 @@ func (nodes *Nodes) NodeLinks(node *Node) (result []Link) {
}
}
}
for portmac, neighmacs := range neighbours.LLDP {
for _, neighmac := range neighmacs {
if neighbourID := nodes.ifaceToNodeID[neighmac]; neighbourID != "" {
result = append(result, Link{
SourceID: neighbours.NodeID,
SourceAddress: portmac,
TargetID: neighbourID,
TargetAddress: neighmac,
// TODO maybe change LLDP for link quality / 100M or 1GE
TQ: 1.0,
})
}
}
}
return result
}

Expand Down

0 comments on commit 124215f

Please sign in to comment.