| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | package snmptopology |
| 4 | |
| 5 | import ( |
| 6 | "sync" |
| 7 | "time" |
| 8 | ) |
| 9 | |
| 10 | type topologyCache struct { |
| 11 | mu sync.RWMutex |
| 12 | lastUpdate time.Time |
| 13 | updateTime time.Time |
| 14 | staleAfter time.Duration |
| 15 | |
| 16 | agentID string |
| 17 | localDevice topologyDevice |
| 18 | |
| 19 | lldpLocPorts map[string]*lldpLocPort |
| 20 | lldpRemotes map[string]*lldpRemote |
| 21 | cdpRemotes map[string]*cdpRemote |
| 22 | |
| 23 | ifNamesByIndex map[string]string |
| 24 | ifStatusByIndex map[string]ifStatus |
| 25 | ifIndexByIP map[string]string |
| 26 | ifNetmaskByIP map[string]string |
| 27 | bridgePortToIf map[string]string |
| 28 | fdbEntries map[string]*fdbEntry |
| 29 | fdbIDToVlanID map[string]string |
| 30 | vlanIDToName map[string]string |
| 31 | fdbRowsDroppedNoMAC int |
| 32 | fdbRowsUnmappedPort int |
| 33 | vtpVersion string |
| 34 | stpBaseBridgeAddress string |
| 35 | stpDesignatedRoot string |
| 36 | stpPorts map[string]*stpPortEntry |
| 37 | arpEntries map[string]*arpEntry |
| 38 | } |
| 39 | |
| 40 | type ifStatus struct { |
| 41 | admin string |
| 42 | oper string |
| 43 | ifType string |
| 44 | ifDescr string |
| 45 | ifAlias string |
| 46 | mac string |
| 47 | speedBps int64 |
| 48 | lastChange int64 |
| 49 | duplex string |
| 50 | } |
| 51 | |
| 52 | type lldpLocPort struct { |
| 53 | portNum string |
| 54 | portID string |
| 55 | portIDSubtype string |
| 56 | portDesc string |
| 57 | } |
| 58 | |
| 59 | type lldpRemote struct { |
| 60 | localPortNum string |
| 61 | remIndex string |
| 62 | chassisID string |
| 63 | chassisIDSubtype string |
| 64 | portID string |
| 65 | portIDSubtype string |
| 66 | portDesc string |
| 67 | sysName string |
| 68 | sysDesc string |
| 69 | sysCapSupported string |
| 70 | sysCapEnabled string |
| 71 | managementAddr string |
| 72 | managementAddrType string |
| 73 | managementAddrs []topologyManagementAddress |
| 74 | } |
| 75 | |
| 76 | type cdpRemote struct { |
| 77 | ifIndex string |
| 78 | ifName string |
| 79 | deviceIndex string |
| 80 | deviceID string |
| 81 | devicePort string |
| 82 | platform string |
| 83 | capabilities string |
| 84 | addressType string |
| 85 | address string |
| 86 | version string |
| 87 | vtpMgmtDomain string |
| 88 | nativeVLAN string |
| 89 | duplex string |
| 90 | powerConsumption string |
| 91 | mtu string |
| 92 | sysName string |
| 93 | sysObjectID string |
| 94 | primaryMgmtAddrType string |
| 95 | primaryMgmtAddr string |
| 96 | secondaryMgmtAddrType string |
| 97 | secondaryMgmtAddr string |
| 98 | physicalLocation string |
| 99 | lastChange string |
| 100 | managementAddrs []topologyManagementAddress |
| 101 | } |
| 102 | |
| 103 | type fdbEntry struct { |
| 104 | mac string |
| 105 | bridgePort string |
| 106 | status string |
| 107 | fdbID string |
| 108 | vlanID string |
| 109 | vlanName string |
| 110 | } |
| 111 | |
| 112 | type stpPortEntry struct { |
| 113 | port string |
| 114 | vlanID string |
| 115 | vlanName string |
| 116 | priority string |
| 117 | state string |
| 118 | enable string |
| 119 | pathCost string |
| 120 | designatedRoot string |
| 121 | designatedCost string |
| 122 | designatedBridge string |
| 123 | designatedPort string |
| 124 | } |
| 125 | |
| 126 | type topologyVLANContext struct { |
| 127 | vlanID string |
| 128 | vlanName string |
| 129 | } |
| 130 | |
| 131 | type arpEntry struct { |
| 132 | ifIndex string |
| 133 | ifName string |
| 134 | ip string |
| 135 | mac string |
| 136 | addrType string |
| 137 | state string |
| 138 | } |