Skip to content

Commit 4c02fe5

Browse files
committed
fix LLDP handling for freifunk-gluon/packages#189
1 parent c5703e0 commit 4c02fe5

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
lines changed

data/neighbours.go

+1-10
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package data
44
type Neighbours struct {
55
Batadv map[string]BatadvNeighbours `json:"batadv"`
66
Babel map[string]BabelNeighbours `json:"babel"`
7-
LLDP map[string]LLDPNeighbours `json:"lldp"`
7+
LLDP map[string][]string `json:"lldp"`
88
//WifiNeighbours map[string]WifiNeighbours `json:"wifi"`
99
NodeID string `json:"node_id"`
1010
}
@@ -22,12 +22,6 @@ type BatmanLink struct {
2222
Tq int `json:"tq"`
2323
}
2424

25-
// LLDPLink struct
26-
type LLDPLink struct {
27-
Name string `json:"name"`
28-
Description string `json:"descr"`
29-
}
30-
3125
// BabelLink struct
3226
type BabelLink struct {
3327
// How need this:
@@ -53,6 +47,3 @@ type BabelNeighbours struct {
5347
type WifiNeighbours struct {
5448
Neighbours map[string]WifiLink `json:"neighbours"`
5549
}
56-
57-
// LLDPNeighbours struct
58-
type LLDPNeighbours map[string]LLDPLink

database/influxdb/node_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ func TestToInflux(t *testing.T) {
9898
},
9999
},
100100
},
101-
LLDP: map[string]data.LLDPNeighbours{
102-
"b-interface-mac": {},
101+
LLDP: map[string][]string{
102+
"b-interface-mac"
103103
},
104104
},
105105
}

output/meshviewer/graph.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func (builder *graphBuilder) readNodes(nodes map[string]*runtime.Node) {
103103
}
104104
// LLDP
105105
for _, neighbours := range neighbours.LLDP {
106-
for targetAddress := range neighbours {
106+
for _, targetAddress := range neighbours {
107107
if targetID, found := builder.macToID[targetAddress]; found {
108108
builder.addLink(targetID, sourceID, 255, false)
109109
}

runtime/nodes.go

+14
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,20 @@ func (nodes *Nodes) NodeLinks(node *Node) (result []Link) {
151151
}
152152
}
153153
}
154+
for portmac, neighmacs := range neighbours.LLDP {
155+
for _, neighmac := range neighmacs {
156+
if neighbourID := nodes.ifaceToNodeID[neighmac]; neighbourID != "" {
157+
result = append(result, Link{
158+
SourceID: neighbours.NodeID,
159+
SourceAddress: portmac,
160+
TargetID: neighbourID,
161+
TargetAddress: neighmac,
162+
// TODO maybe change LLDP for link quality / 100M or 1GE
163+
TQ: 1.0,
164+
})
165+
}
166+
}
167+
}
154168
return result
155169
}
156170

0 commit comments

Comments
 (0)