feat(mac-locations): VLAN-aware port MAC counts, access/trunk thresholds, likely_attachment
Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package scans
|
||||
|
||||
import "strconv"
|
||||
|
||||
// PortFDBLocationKey — ключ «где в FDB»: IP коммутатора, порт и VLAN (Q-BRIDGE).
|
||||
func PortFDBLocationKey(ip string, ifIndex, bridgePort, vlan int) string {
|
||||
return ip + "|" + strconv.Itoa(ifIndex) + "|" + strconv.Itoa(bridgePort) + "|" + strconv.Itoa(vlan)
|
||||
}
|
||||
|
||||
// ClassifyPortKind по числу уникальных MAC на порту и порогам (ожидается accessMax < trunkMin).
|
||||
func ClassifyPortKind(macsOnPort, accessMax, trunkMin int) string {
|
||||
if macsOnPort <= accessMax {
|
||||
return "access"
|
||||
}
|
||||
if macsOnPort >= trunkMin {
|
||||
return "strong_transit"
|
||||
}
|
||||
return "ambiguous"
|
||||
}
|
||||
|
||||
// PortKindRank для сортировки: access → ambiguous → strong_transit.
|
||||
func PortKindRank(kind string) int {
|
||||
switch kind {
|
||||
case "access":
|
||||
return 0
|
||||
case "ambiguous":
|
||||
return 1
|
||||
case "strong_transit":
|
||||
return 2
|
||||
default:
|
||||
return 9
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user