Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connector ¶
type Connector interface {
ID() string
SelectNodeByIP(ip, vrf string) (Node, Port, error)
SelectPortsByNetwork(net network.AbbrNet, vrf string) []Port
HitByNetwork(net network.AbbrNet, vrf string) bool
HitByIp(ip, vrf string) bool
}
Connector 连接器接口
type NextHopInfo ¶
type NextHopInfo struct {
Interface string
NextHopIP string
Connected bool
Weight int // 路径权重(用于ECMP)
}
NextHopInfo 下一跳信息
func NewNextHopInfo ¶
func NewNextHopInfo(interfaceName, nextHopIP string, connected bool) *NextHopInfo
NewNextHopInfo 创建下一跳信息
type Node ¶
type Node interface {
ID() string
Name() string
Type() NodeType
// 路由表管理
GetRouteTable(vrf string, ipFamily network.IPFamily) (*RouteTable, error)
SetRouteTable(vrf string, ipFamily network.IPFamily, table *RouteTable) error
// 路由查询
QueryRoute(dst network.NetworkList, inPort, vrf string, ipFamily network.IPFamily) (*RouteResult, error)
// 端口管理
GetPort(portID string) (Port, error)
GetPortByName(name string) (Port, error)
ListPorts() []Port
}
Node 节点接口(抽象,不依赖具体设备类型)
type PathHop ¶
type PathHop struct {
Node string
InPort string
OutPort string
VRF string
NextHopIP string
IsConnected bool
IsECMP bool
HopIndex int // 跳索引(从0开始)
}
PathHop 路径跳
type PathResult ¶
type PathResult struct {
PathID string
Success bool
Hops []*PathHop
TotalHops int
IsECMP bool
Error error
Metadata map[string]interface{}
StartTime time.Time
EndTime time.Time
}
PathResult 路径查询结果
type Port ¶
type Port interface {
ID() string
Name() string
VRF() string
Node() Node
IPAddresses(ipFamily network.IPFamily) []string
ConnectorID() string
}
Port 端口接口
type RouteEntry ¶
type RouteEntry struct {
Network *network.IPNet
NextHops []*NextHopInfo
VRF string
Connected bool
DefaultGw bool
}
RouteEntry 路由条目
type RouteMatchResult ¶
RouteMatchResult 路由匹配结果
type RouteResult ¶
type RouteResult struct {
Matched bool
Routes []*RouteEntry
OutPorts []string
NextHops []*NextHopInfo
IsConnected bool // 是否为直连路由
IsECMP bool // 是否为ECMP路由
}
RouteResult 路由查询结果
type RouteTable ¶
type RouteTable struct {
VRF string
IPFamily network.IPFamily
// contains filtered or unexported fields
}
RouteTable 路由表
func NewRouteTable ¶
func NewRouteTable(vrf string, ipFamily network.IPFamily) *RouteTable
NewRouteTable 创建路由表
func NewRouteTableFromAddressTable ¶
func NewRouteTableFromAddressTable(vrf string, ipFamily network.IPFamily, table *network.AddressTable) *RouteTable
NewRouteTableFromAddressTable 从AddressTable创建RouteTable
func (*RouteTable) GetAddressTable ¶
func (rt *RouteTable) GetAddressTable() *network.AddressTable
GetAddressTable 获取AddressTable
func (*RouteTable) GetDefaultGateway ¶
func (rt *RouteTable) GetDefaultGateway() *network.NextHop
GetDefaultGateway 获取默认网关
func (*RouteTable) QueryRoute ¶
func (rt *RouteTable) QueryRoute(dst network.NetworkList) (*RouteMatchResult, error)
QueryRoute 查询路由
Click to show internal directories.
Click to hide internal directories.