package dynamicrouting // BGPInstance represents global BGP settings (/routing bgp instance) type BGPInstance struct { Enabled bool `json:"enabled"` AS uint32 `json:"as"` RouterID string `json:"router_id"` HoldTime int `json:"hold_time"` // Default 180 KeepaliveTime int `json:"keepalive_time"` // Default 60 RedistributeConnected bool `json:"redistribute_connected"` RedistributeStatic bool `json:"redistribute_static"` RedistributeOSPF bool `json:"redistribute_ospf"` Running bool `json:"running"` } // BGPPeer represents a BGP peer connection (/routing bgp connection / peer) type BGPPeer struct { ID string `json:"id"` Name string `json:"name"` RemoteAddress string `json:"remote_address"` RemoteAS uint32 `json:"remote_as"` LocalAddress string `json:"local_address,omitempty"` Multihop bool `json:"multihop"` NexthopSelf bool `json:"nexthop_self"` Passive bool `json:"passive"` Password string `json:"password,omitempty"` Disabled bool `json:"disabled"` Comment string `json:"comment,omitempty"` InFilter string `json:"in_filter,omitempty"` // Routing Filter chain for incoming routes OutFilter string `json:"out_filter,omitempty"` // Routing Filter chain for outgoing routes // Runtime telemetry State string `json:"state,omitempty"` // Established, Active, Connect, Idle Uptime string `json:"uptime,omitempty"` PrefixReceived int `json:"prefix_received"` PrefixSent int `json:"prefix_sent"` } // BGPNetwork represents an advertised network (/routing bgp network) type BGPNetwork struct { ID string `json:"id"` Network string `json:"network"` // CIDR, e.g. 10.200.0.0/24 Disabled bool `json:"disabled"` Comment string `json:"comment,omitempty"` } // BGPRoute represents an active BGP route type BGPRoute struct { Prefix string `json:"prefix"` NextHop string `json:"next_hop"` Metric int `json:"metric"` Weight int `json:"weight"` Path string `json:"path"` Origin string `json:"origin"` Best bool `json:"best"` } // OSPFInstance represents global OSPF settings (/routing ospf instance) type OSPFInstance struct { Enabled bool `json:"enabled"` RouterID string `json:"router_id"` RedistributeConnected bool `json:"redistribute_connected"` RedistributeStatic bool `json:"redistribute_static"` RedistributeBGP bool `json:"redistribute_bgp"` DefaultMetric int `json:"default_metric"` Running bool `json:"running"` } // OSPFArea represents an OSPF area (/routing ospf area) type OSPFArea struct { ID string `json:"id"` Name string `json:"name"` AreaID string `json:"area_id"` // e.g. "0.0.0.0" or "0" AreaType string `json:"area_type"` // default, stub, nssa Comment string `json:"comment,omitempty"` } // OSPFInterface represents an OSPF network/interface template (/routing ospf interface-template) type OSPFInterface struct { ID string `json:"id"` Network string `json:"network"` // CIDR, e.g. "192.168.131.0/24" Area string `json:"area"` // Area ID e.g. "0.0.0.0" Interface string `json:"interface,omitempty"` // eth0, vlan10, wg0... Cost int `json:"cost"` // Metric, default 10 Priority int `json:"priority"` // Default 1 HelloInterval int `json:"hello_interval"` // Default 10 DeadInterval int `json:"dead_interval"` // Default 40 Passive bool `json:"passive"` AuthType string `json:"auth_type"` // none, simple, md5 AuthKey string `json:"auth_key,omitempty"` Disabled bool `json:"disabled"` Comment string `json:"comment,omitempty"` } // OSPFNeighbor represents a live OSPF neighbor type OSPFNeighbor struct { NeighborID string `json:"neighbor_id"` Address string `json:"address"` Interface string `json:"interface"` Area string `json:"area"` State string `json:"state"` // Full/DR, Full/Backup, 2-Way... DeadTimer string `json:"dead_timer"` } // OSPFRoute represents an active OSPF route type OSPFRoute struct { Prefix string `json:"prefix"` RouteType string `json:"route_type"` // Intra-Area, Inter-Area, External Cost int `json:"cost"` Area string `json:"area"` NextHop string `json:"next_hop"` Interface string `json:"interface"` } // RoutingFilterRule represents a route filter rule (/routing filter) type RoutingFilterRule struct { ID string `json:"id"` Chain string `json:"chain"` // e.g. "bgp-in", "bgp-out", "isp-in" RuleOrder int `json:"rule_order"` // e.g. 10, 20, 30... Sequence number Action string `json:"action"` // "accept" (permit), "discard" (deny), "reject", "passthrough" Prefix string `json:"prefix,omitempty"` // CIDR e.g. "10.0.0.0/8" or "0.0.0.0/0" PrefixLen string `json:"prefix_len,omitempty"` // e.g. "24-32", "ge 24 le 32", "24" MatchProtocol string `json:"match_protocol,omitempty"` // "any", "bgp", "ospf", "connected", "static" MatchASPath string `json:"match_as_path,omitempty"` // regex e.g. "^65000_" MatchCommunity string `json:"match_community,omitempty"`// e.g. "65001:100" SetLocalPref int `json:"set_local_pref,omitempty"` // BGP Local Preference SetMetric int `json:"set_metric,omitempty"` // BGP MED / OSPF Metric SetASPrepend int `json:"set_as_prepend,omitempty"` // AS Path prepend count SetCommunity string `json:"set_community,omitempty"` // Set BGP community SetNextHop string `json:"set_next_hop,omitempty"` // Custom Next Hop IP SetDistance int `json:"set_distance,omitempty"` // Administrative Distance Disabled bool `json:"disabled"` Comment string `json:"comment,omitempty"` } // DynamicRoutingSummary aggregates status for dashboard & badges type DynamicRoutingSummary struct { BGPEnabled bool `json:"bgp_enabled"` BGPRunning bool `json:"bgp_running"` BGPPeerCount int `json:"bgp_peer_count"` BGPEstablishedCount int `json:"bgp_established_count"` OSPFEnabled bool `json:"ospf_enabled"` OSPFRunning bool `json:"ospf_running"` OSPFNeighborCount int `json:"ospf_neighbor_count"` OSPFAdjacentCount int `json:"ospf_adjacent_count"` RoutingFilterCount int `json:"routing_filter_count"` } // DynamicConfig stores all dynamic routing data on disk type DynamicConfig struct { BGPInstance BGPInstance `json:"bgp_instance"` BGPPeers []BGPPeer `json:"bgp_peers"` BGPNetworks []BGPNetwork `json:"bgp_networks"` OSPFInstance OSPFInstance `json:"ospf_instance"` OSPFAreas []OSPFArea `json:"ospf_areas"` OSPFInterfaces []OSPFInterface `json:"ospf_interfaces"` RoutingFilters []RoutingFilterRule `json:"routing_filters"` }