Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NormalizeLLDPEntries ¶
func NormalizeLLDPEntries(raw json.RawMessage) ([]entry, error)
lldpd's `json` format renders a list as an object when it has one element and as an array of single-key objects when it has several, so the same field (interface, chassis, ...) has no single static Go type. NormalizeLLDPEntries cleans up this misery
Types ¶
type EthernetPort ¶
type EthernetPort struct {
Id string
Name string
Speed string
Bridge string
PortTaggingName string
UntaggedVlan string
}
EthernetPort is a physical port opensoho knows about for a device (from the ethernet collection), annotated with the bridge it is a member of (from bridges, "" when it belongs to no bridge) and its VLAN config (the port_tagging record of ethernet.config, "" when it has none) with the name of its untagged VLAN.
type Info ¶
type Info struct {
Neighbors []Neighbor
}
func (Info) Normalized ¶
func (*Info) UnmarshalJSON ¶
UnmarshalJSON decodes the verbatim lldpcli output shaped {"lldp":{"interface":<flex list>}}, into Neighbors. Each interface entry's key is the local port; the neighbour name comes from its chassis.
type Neighbor ¶
type Neighbor struct {
Port string // local interface the neighbour is seen on, e.g. "eth0"
Name string // neighbour's advertised system name; may be "" when unknown
Mac string // neighbour's chassis MAC address, e.g. "00:11:22:33:44:55"
}
Neighbor is a single LLDP neighbour seen from this device's viewpoint.
type OverviewNeighbor ¶
type OverviewNeighbor struct {
Name string `json:"name"`
Mac string `json:"mac"`
KnownDeviceId string `json:"knownDeviceId"`
}
OverviewNeighbor is the render model for one LLDP neighbour seen on a port. KnownDeviceId is the id of the opensoho-managed device that owns this MAC, or "" when the neighbour is not managed by opensoho (the UI then renders it as plain text rather than a link).
type Port ¶
type Port struct {
Port string `json:"port"`
Speed string `json:"speed"`
Bridge string `json:"bridge"`
EthernetId string `json:"ethernetId"`
PortTaggingName string `json:"portTaggingName"`
UntaggedVlan string `json:"untaggedVlan"`
Neighbors []OverviewNeighbor `json:"neighbors"`
Poe *float64 `json:"poe,omitempty"`
}
Port is the render model for one known port: its name, link speed, the bridge it belongs to (or ""), its VLAN config, any LLDP neighbours seen on it, and its PoE draw in watts. EthernetId is "" for ports only known from LLDP. UntaggedVlan names the VLAN the UI colors the VLAN config with. Poe is nil when the port has no PoE record (the UI then omits the PoE cell); a PoE-capable port drawing 0W still carries a non-nil pointer so the column renders.
func BuildPortOverview ¶
func BuildPortOverview(ports []EthernetPort, rows []Row, macOwners map[string]string, poeByPort map[string]float64) []Port
BuildPortOverview lists every known port of a device (sourced from the ethernet + bridges collections) and overlays the LLDP neighbours seen on each. LLDP rows whose local port is not among the known ethernet ports are appended as extra port rows so no neighbour is lost. macOwners maps a MAC -> owning device id; matching is case-insensitive. poeByPort maps a port name -> its PoE consumption in watts; a port present in this map gets a non-nil Poe pointer (even at 0W). The result is sorted by port name.