mirror of
https://github.com/vishvananda/netlink
synced 2024-12-18 12:44:55 +00:00
37 lines
850 B
Go
37 lines
850 B
Go
package netlink
|
|
|
|
import (
|
|
"fmt"
|
|
"net"
|
|
"syscall"
|
|
)
|
|
|
|
// Scope is an enum representing a route scope.
|
|
type Scope uint8
|
|
|
|
const (
|
|
SCOPE_UNIVERSE Scope = syscall.RT_SCOPE_UNIVERSE
|
|
SCOPE_SITE Scope = syscall.RT_SCOPE_SITE
|
|
SCOPE_LINK Scope = syscall.RT_SCOPE_LINK
|
|
SCOPE_HOST Scope = syscall.RT_SCOPE_HOST
|
|
SCOPE_NOWHERE Scope = syscall.RT_SCOPE_NOWHERE
|
|
)
|
|
|
|
// Route represents a netlink route. A route is associated with a link,
|
|
// has a destination network, an optional source ip, and optional
|
|
// gateway. Advanced route parameters and non-main routing tables are
|
|
// currently not supported.
|
|
type Route struct {
|
|
Link Link
|
|
Scope Scope
|
|
Dst *net.IPNet
|
|
Src net.IP
|
|
Gw net.IP
|
|
}
|
|
|
|
func (r Route) String() string {
|
|
base := r.Link.Attrs()
|
|
return fmt.Sprintf("{%s Dst: %s Src: %s Gw: %s}", base.Name, r.Dst.String(),
|
|
r.Src, r.Gw)
|
|
}
|