types.go 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package bridge
  2. // BridgeInstance represents a MikroTik-style /interface bridge
  3. type BridgeInstance struct {
  4. ID string `json:"id"`
  5. Name string `json:"name"` // e.g. "bridge1" or "bridge-lan"
  6. MTU int `json:"mtu"` // default 1500
  7. MACAddress string `json:"mac_address"` // Admin MAC or auto
  8. STP string `json:"stp"` // "rstp", "stp", "none"
  9. Priority int `json:"priority"` // STP bridge priority (default 32768 / 0x8000)
  10. VlanFiltering bool `json:"vlan_filtering"` // 802.1Q VLAN aware bridge
  11. PVID int `json:"pvid"` // default VLAN ID (1)
  12. FastForward bool `json:"fast_forward"` // bridge fastpath
  13. Comment string `json:"comment,omitempty"`
  14. Disabled bool `json:"disabled"`
  15. Running bool `json:"running"` // MikroTik 'R' flag
  16. PortsCount int `json:"ports_count"`
  17. IPAddresses []string `json:"ip_addresses,omitempty"`
  18. RxPackets uint64 `json:"rx_packets"`
  19. TxPackets uint64 `json:"tx_packets"`
  20. RxBytes uint64 `json:"rx_bytes"`
  21. TxBytes uint64 `json:"tx_bytes"`
  22. RxHuman string `json:"rx_human,omitempty"`
  23. TxHuman string `json:"tx_human,omitempty"`
  24. }
  25. // BridgePort represents a slave interface attached to a bridge (/interface bridge port)
  26. type BridgePort struct {
  27. ID string `json:"id"`
  28. Bridge string `json:"bridge"` // Parent bridge name, e.g. "bridge1"
  29. Interface string `json:"interface"` // e.g. "eth0", "Goldix", "eth0.10"
  30. PVID int `json:"pvid"` // Port VLAN ID (default 1)
  31. FrameTypes string `json:"frame_types"` // "admit-all", "admit-only-vlan-tagged", "admit-only-untagged-and-priority-tagged"
  32. IngressFiltering bool `json:"ingress_filtering"` // Drop frames with unexpected VLAN tags
  33. Priority int `json:"priority"` // STP port priority (default 128 / 0x80)
  34. PathCost int `json:"path_cost"` // STP port path cost (default 10)
  35. Horizon int `json:"horizon"` // Split-horizon domain (0=none, 1, 2...)
  36. Learn bool `json:"learn"` // MAC learning enabled (default true)
  37. Comment string `json:"comment,omitempty"`
  38. Disabled bool `json:"disabled"`
  39. Status string `json:"status"` // "forwarding", "learning", "blocking", "disabled"
  40. }
  41. // BridgeVLAN represents a VLAN entry in the bridge VLAN filtering table (/interface bridge vlan)
  42. type BridgeVLAN struct {
  43. ID string `json:"id"`
  44. Bridge string `json:"bridge"` // e.g. "bridge1"
  45. VlanIDs string `json:"vlan_ids"` // e.g. "10", "10,20,30", "10-20"
  46. Tagged []string `json:"tagged"` // Tagged member interfaces
  47. Untagged []string `json:"untagged"` // Untagged member interfaces
  48. Comment string `json:"comment,omitempty"`
  49. Disabled bool `json:"disabled"`
  50. CurrentTagged []string `json:"current_tagged,omitempty"`
  51. CurrentUntagged []string `json:"current_untagged,omitempty"`
  52. }
  53. // BridgeHost represents a learned or static MAC address in the FDB table (/interface bridge host)
  54. type BridgeHost struct {
  55. MAC string `json:"mac"`
  56. Interface string `json:"interface"` // Port learned on, or "local"
  57. Bridge string `json:"bridge"`
  58. VlanID int `json:"vlan_id"`
  59. Age float64 `json:"age"` // seconds
  60. Local bool `json:"local"`
  61. Static bool `json:"static"`
  62. Flags string `json:"flags"` // e.g. "D" (Dynamic), "S" (Static), "L" (Local)
  63. }
  64. // BridgeSummary provides count totals for navigation badges
  65. type BridgeSummary struct {
  66. BridgesCount int `json:"bridges_count"`
  67. PortsCount int `json:"ports_count"`
  68. VLANsCount int `json:"vlans_count"`
  69. HostsCount int `json:"hosts_count"`
  70. }