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"` } // InterfaceLiveRate holds real-time throughput and cumulative counters for an interface. type InterfaceLiveRate struct { Name string `json:"name"` RxBytesPerSec float64 `json:"rx_bytes_sec"` TxBytesPerSec float64 `json:"tx_bytes_sec"` RxHuman string `json:"rx_human"` TxHuman string `json:"tx_human"` 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"` } // TrafficSnapshot represents an instantaneous router-wide live network traffic snapshot. type TrafficSnapshot struct { Timestamp int64 `json:"timestamp"` Interfaces map[string]InterfaceLiveRate `json:"interfaces"` TotalRxRate float64 `json:"total_rx_bytes_sec"` TotalTxRate float64 `json:"total_tx_bytes_sec"` TotalRxHuman string `json:"total_rx_human"` TotalTxHuman string `json:"total_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 { Name *string `json:"name,omitempty"` State *string `json:"state,omitempty"` // "up" or "down" MTU *int `json:"mtu,omitempty"` Role *string `json:"role,omitempty"` Description *string `json:"description,omitempty"` } // RenameInterfaceRequest specifies the new name for an interface. type RenameInterfaceRequest struct { Name string `json:"name,omitempty"` NewName string `json:"new_name,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" } // RoleTag defines an organizational label for classifying interfaces. type RoleTag struct { ID string `json:"id"` Name string `json:"name"` Color string `json:"color"` // e.g. "amber", "blue", "cyan", "emerald", "purple", "rose", "slate", "indigo" Description string `json:"description"` Builtin bool `json:"builtin,omitempty"` } // RoleTagWithUsage includes assigned interface names and usage count. type RoleTagWithUsage struct { RoleTag AssignedCount int `json:"assigned_count"` Interfaces []string `json:"interfaces"` } // InterfaceMetadata stores custom persistent labels, MAC mappings, and IP assignments per interface. type InterfaceMetadata struct { Role string `json:"role"` Description string `json:"description"` IPAddresses []string `json:"ip_addresses,omitempty"` AutoUp bool `json:"auto_up,omitempty"` MAC string `json:"mac,omitempty"` } // MetadataStore is written to disk to preserve user labels across restarts. type MetadataStore struct { Interfaces map[string]InterfaceMetadata `json:"interfaces"` Roles []RoleTag `json:"roles,omitempty"` }