1package netlink 2 3import ( 4 "fmt" 5 "net" 6 "syscall" 7) 8 9// Scope is an enum representing a route scope. 10type Scope uint8 11 12const ( 13 SCOPE_UNIVERSE Scope = syscall.RT_SCOPE_UNIVERSE 14 SCOPE_SITE Scope = syscall.RT_SCOPE_SITE 15 SCOPE_LINK Scope = syscall.RT_SCOPE_LINK 16 SCOPE_HOST Scope = syscall.RT_SCOPE_HOST 17 SCOPE_NOWHERE Scope = syscall.RT_SCOPE_NOWHERE 18) 19 20// Route represents a netlink route. A route is associated with a link, 21// has a destination network, an optional source ip, and optional 22// gateway. Advanced route parameters and non-main routing tables are 23// currently not supported. 24type Route struct { 25 LinkIndex int 26 Scope Scope 27 Dst *net.IPNet 28 Src net.IP 29 Gw net.IP 30} 31 32func (r Route) String() string { 33 return fmt.Sprintf("{Ifindex: %d Dst: %s Src: %s Gw: %s}", r.LinkIndex, r.Dst, 34 r.Src, r.Gw) 35} 36