| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- package network
- // InterfaceInfo holds comprehensive details about a network interface.
- type InterfaceInfo struct {
- Index int `json:"index"`
- Name string `json:"name"`
- Type string `json:"type"` // "ethernet", "vlan", "loopback", "bridge", "dummy", etc.
- State string `json:"state"` // "UP", "DOWN", "UNKNOWN"
- OperState string `json:"operstate"` // "up", "down", "unknown"
- MAC string `json:"mac"`
- MTU int `json:"mtu"`
- IPv4 []string `json:"ipv4"` // e.g. ["192.168.1.1/24"]
- IPv6 []string `json:"ipv6"` // e.g. ["fe80::1/64"]
- Flags []string `json:"flags"`
- IsVLAN bool `json:"is_vlan"`
- VlanID int `json:"vlan_id,omitempty"`
- ParentName string `json:"parent_name,omitempty"`
- ParentIndex int `json:"parent_index,omitempty"`
- Role string `json:"role"` // "WAN", "LAN", "DMZ", "GUEST", "IOT", "MGMT"
- Description string `json:"description"`
- Stats NetStats `json:"stats"`
- Rate TrafficRate `json:"rate"`
- }
- // NetStats holds packet and byte counters.
- type NetStats struct {
- RxBytes uint64 `json:"rx_bytes"`
- TxBytes uint64 `json:"tx_bytes"`
- RxPackets uint64 `json:"rx_packets"`
- TxPackets uint64 `json:"tx_packets"`
- RxErrors uint64 `json:"rx_errors"`
- TxErrors uint64 `json:"tx_errors"`
- RxDropped uint64 `json:"rx_dropped"`
- TxDropped uint64 `json:"tx_dropped"`
- }
- // TrafficRate represents real-time network throughput.
- type TrafficRate struct {
- RxBytesPerSec float64 `json:"rx_bytes_sec"`
- TxBytesPerSec float64 `json:"tx_bytes_sec"`
- RxHuman string `json:"rx_human"`
- TxHuman string `json:"tx_human"`
- }
- // CreateVLANRequest specifies parameters for creating an 802.1Q VLAN interface.
- type CreateVLANRequest struct {
- ParentName string `json:"parent_name"` // e.g. "eth0"
- VlanID int `json:"vlan_id"` // 1 - 4094
- Name string `json:"name"` // optional, e.g. "eth0.10" or "vlan10"
- IPAddress string `json:"ip_address"` // optional CIDR, e.g. "192.168.10.1/24"
- MTU int `json:"mtu"` // defaults to 1500
- Role string `json:"role"` // "LAN", "DMZ", "GUEST", "IOT"
- Description string `json:"description"` // User-friendly label
- AutoUp bool `json:"auto_up"` // bring interface UP immediately
- }
- // UpdateInterfaceRequest specifies parameters for updating interface attributes.
- type UpdateInterfaceRequest struct {
- State *string `json:"state,omitempty"` // "up" or "down"
- MTU *int `json:"mtu,omitempty"`
- Role *string `json:"role,omitempty"`
- Description *string `json:"description,omitempty"`
- }
- // AddIPRequest defines the payload to add an IP address to an interface.
- type AddIPRequest struct {
- IP string `json:"ip"` // CIDR, e.g. "192.168.20.1/24"
- }
- // InterfaceMetadata stores custom persistent labels per interface.
- type InterfaceMetadata struct {
- Role string `json:"role"`
- Description string `json:"description"`
- }
- // MetadataStore is written to disk to preserve user labels across restarts.
- type MetadataStore struct {
- Interfaces map[string]InterfaceMetadata `json:"interfaces"`
- }
|