fix LLDP handling for https://github.com/freifunk-gluon/packages/pull/189
This commit is contained in:
parent
c5703e0975
commit
156d07e7e8
|
@ -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"`
|
||||
}
|
||||
|
@ -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:
|
||||
|
@ -53,6 +47,3 @@ type BabelNeighbours struct {
|
|||
type WifiNeighbours struct {
|
||||
Neighbours map[string]WifiLink `json:"neighbours"`
|
||||
}
|
||||
|
||||
// LLDPNeighbours struct
|
||||
type LLDPNeighbours map[string]LLDPLink
|
||||
|
|
|
@ -98,7 +98,7 @@ func TestToInflux(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
LLDP: map[string]data.LLDPNeighbours{
|
||||
LLDP: map[string][]string{
|
||||
"b-interface-mac": {},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -33,9 +33,9 @@
|
|||
}
|
||||
},
|
||||
"lldp": {
|
||||
"a2": {
|
||||
"c2": {}
|
||||
}
|
||||
"a2": [
|
||||
"c2"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,9 +28,9 @@
|
|||
}
|
||||
},
|
||||
"lldp": {
|
||||
"c2": {
|
||||
"a2": {}
|
||||
}
|
||||
"c2": [
|
||||
"a2"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue