Commit 4d118835 authored by Mikio Hara's avatar Mikio Hara Committed by Russ Cox

syscall: add routing messages support for Linux

R=rsc
CC=golang-dev
https://golang.org/cl/4515135
parent 1b5d04c5
......@@ -17,24 +17,25 @@ GOFILES=\
ztypes_$(GOOS)_$(GOARCH).go\
GOFILES_freebsd=\
exec_unix.go\
syscall_bsd.go\
syscall_unix.go\
exec_unix.go\
GOFILES_darwin=\
exec_unix.go\
syscall_bsd.go\
syscall_unix.go\
exec_unix.go\
GOFILES_linux=\
syscall_unix.go\
exec_unix.go\
netlink_linux.go\
syscall_unix.go\
GOFILES_windows=\
exec_windows.go
exec_windows.go\
GOFILES_plan9=\
exec_plan9.go
exec_plan9.go\
OFILES=\
asm_$(GOOS)_$(GOARCH).$O\
......
......@@ -37,6 +37,7 @@ includes_Linux='
#include <linux/ptrace.h>
#include <linux/wait.h>
#include <net/if.h>
#include <net/if_arp.h>
#include <netpacket/packet.h>
'
......@@ -137,7 +138,7 @@ done
$2 ~ /^LINUX_REBOOT_CMD_/ ||
$2 ~ /^LINUX_REBOOT_MAGIC[12]$/ ||
$2 !~ "NLA_TYPE_MASK" &&
$2 ~ /^(NETLINK|NLM|NLMSG|NLA|IFA|RTM)_/ ||
$2 ~ /^(NETLINK|NLM|NLMSG|NLA|IFA|RTM|RTN|RTPROT|RTA|RTAX|RTNH|ARPHRD)_/ ||
$2 ~ /^SIOC/ ||
$2 ~ /^(IFF|NET_RT|RTM|RTF|RTV|RTA|RTAX)_/ ||
$2 ~ /^BIOC/ ||
......
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Netlink sockets and messages
package syscall
import (
"unsafe"
)
// Round the length of a netlink message up to align it properly.
func nlmAlignOf(msglen int) int {
return (msglen + NLMSG_ALIGNTO - 1) & ^(NLMSG_ALIGNTO - 1)
}
// Round the length of a netlink route attribute up to align it
// properly.
func rtaAlignOf(attrlen int) int {
return (attrlen + RTA_ALIGNTO - 1) & ^(RTA_ALIGNTO - 1)
}
// NetlinkRouteRequest represents the request message to receive
// routing and link states from the kernel.
type NetlinkRouteRequest struct {
Header NlMsghdr
Data RtGenmsg
}
func (rr *NetlinkRouteRequest) toWireFormat() []byte {
b := make([]byte, rr.Header.Len)
b[0] = byte(rr.Header.Len)
b[1] = byte(rr.Header.Len >> 8)
b[2] = byte(rr.Header.Len >> 16)
b[3] = byte(rr.Header.Len >> 24)
b[4] = byte(rr.Header.Type)
b[5] = byte(rr.Header.Type >> 8)
b[6] = byte(rr.Header.Flags)
b[7] = byte(rr.Header.Flags >> 8)
b[8] = byte(rr.Header.Seq)
b[9] = byte(rr.Header.Seq >> 8)
b[10] = byte(rr.Header.Seq >> 16)
b[11] = byte(rr.Header.Seq >> 24)
b[12] = byte(rr.Header.Pid)
b[13] = byte(rr.Header.Pid >> 8)
b[14] = byte(rr.Header.Pid >> 16)
b[15] = byte(rr.Header.Pid >> 24)
b[16] = byte(rr.Data.Family)
return b
}
func newNetlinkRouteRequest(proto, seq, family int) []byte {
rr := &NetlinkRouteRequest{}
rr.Header.Len = NLMSG_HDRLEN + SizeofRtGenmsg
rr.Header.Type = uint16(proto)
rr.Header.Flags = NLM_F_DUMP | NLM_F_REQUEST
rr.Header.Seq = uint32(seq)
rr.Data.Family = uint8(family)
return rr.toWireFormat()
}
// NetlinkRIB returns routing information base, as known as RIB,
// which consists of network facility information, states and
// parameters.
func NetlinkRIB(proto, family int) ([]byte, int) {
var (
s int
e int
lsanl SockaddrNetlink
seq int
tab []byte
)
s, e = Socket(AF_NETLINK, SOCK_RAW, 0)
if e != 0 {
return nil, e
}
defer Close(s)
lsanl.Family = AF_NETLINK
e = Bind(s, &lsanl)
if e != 0 {
return nil, e
}
seq++
wb := newNetlinkRouteRequest(proto, seq, family)
e = Sendto(s, wb, 0, &lsanl)
if e != 0 {
return nil, e
}
for {
var (
rb []byte
nr int
lsa Sockaddr
)
rb = make([]byte, Getpagesize())
nr, _, e = Recvfrom(s, rb, 0)
if e != 0 {
return nil, e
}
if nr < NLMSG_HDRLEN {
return nil, EINVAL
}
rb = rb[:nr]
tab = append(tab, rb...)
msgs, _ := ParseNetlinkMessage(rb)
for _, m := range msgs {
if lsa, e = Getsockname(s); e != 0 {
return nil, e
}
switch v := lsa.(type) {
case *SockaddrNetlink:
if m.Header.Seq != uint32(seq) || m.Header.Pid != v.Pid {
return nil, EINVAL
}
default:
return nil, EINVAL
}
if m.Header.Type == NLMSG_DONE {
goto done
}
if m.Header.Type == NLMSG_ERROR {
return nil, EINVAL
}
}
}
done:
return tab, 0
}
// NetlinkMessage represents the netlink message.
type NetlinkMessage struct {
Header NlMsghdr
Data []byte
}
// ParseNetlinkMessage parses buf as netlink messages and returns
// the slice containing the NetlinkMessage structs.
func ParseNetlinkMessage(buf []byte) ([]NetlinkMessage, int) {
var (
h *NlMsghdr
dbuf []byte
dlen int
e int
msgs []NetlinkMessage
)
for len(buf) >= NLMSG_HDRLEN {
h, dbuf, dlen, e = netlinkMessageHeaderAndData(buf)
if e != 0 {
break
}
m := NetlinkMessage{}
m.Header = *h
m.Data = dbuf[:h.Len-NLMSG_HDRLEN]
msgs = append(msgs, m)
buf = buf[dlen:]
}
return msgs, e
}
func netlinkMessageHeaderAndData(buf []byte) (*NlMsghdr, []byte, int, int) {
h := (*NlMsghdr)(unsafe.Pointer(&buf[0]))
if h.Len < NLMSG_HDRLEN || int(h.Len) > len(buf) {
return nil, nil, 0, EINVAL
}
return h, buf[NLMSG_HDRLEN:], nlmAlignOf(int(h.Len)), 0
}
// NetlinkRouteAttr represents the netlink route attribute.
type NetlinkRouteAttr struct {
Attr RtAttr
Value []byte
}
// ParseNetlinkRouteAttr parses msg's payload as netlink route
// attributes and returns the slice containing the NetlinkRouteAttr
// structs.
func ParseNetlinkRouteAttr(msg *NetlinkMessage) ([]NetlinkRouteAttr, int) {
var (
buf []byte
a *RtAttr
alen int
vbuf []byte
e int
attrs []NetlinkRouteAttr
)
switch msg.Header.Type {
case RTM_NEWLINK:
buf = msg.Data[SizeofIfInfomsg:]
case RTM_NEWADDR:
buf = msg.Data[SizeofIfAddrmsg:]
default:
return nil, EINVAL
}
for len(buf) >= SizeofRtAttr {
a, vbuf, alen, e = netlinkRouteAttrAndValue(buf)
if e != 0 {
break
}
ra := NetlinkRouteAttr{}
ra.Attr = *a
ra.Value = vbuf[:a.Len-SizeofRtAttr]
attrs = append(attrs, ra)
buf = buf[alen:]
}
return attrs, 0
}
func netlinkRouteAttrAndValue(buf []byte) (*RtAttr, []byte, int, int) {
h := (*RtAttr)(unsafe.Pointer(&buf[0]))
if h.Len < SizeofRtAttr || int(h.Len) > len(buf) {
return nil, nil, 0, EINVAL
}
return h, buf[SizeofRtAttr:], rtaAlignOf(int(h.Len)), 0
}
......@@ -165,6 +165,42 @@ enum {
$IFLA_NET_NS_PID = IFLA_NET_NS_PID,
$IFLA_IFALIAS = IFLA_IFALIAS,
$IFLA_MAX = IFLA_MAX,
$RT_SCOPE_UNIVERSE = RT_SCOPE_UNIVERSE,
$RT_SCOPE_SITE = RT_SCOPE_SITE,
$RT_SCOPE_LINK = RT_SCOPE_LINK,
$RT_SCOPE_HOST = RT_SCOPE_HOST,
$RT_SCOPE_NOWHERE = RT_SCOPE_NOWHERE,
$RT_TABLE_UNSPEC = RT_TABLE_UNSPEC,
$RT_TABLE_COMPAT = RT_TABLE_COMPAT,
$RT_TABLE_DEFAULT = RT_TABLE_DEFAULT,
$RT_TABLE_MAIN = RT_TABLE_MAIN,
$RT_TABLE_LOCAL = RT_TABLE_LOCAL,
$RT_TABLE_MAX = RT_TABLE_MAX,
$RTA_UNSPEC = RTA_UNSPEC,
$RTA_DST = RTA_DST,
$RTA_SRC = RTA_SRC,
$RTA_IIF = RTA_IIF,
$RTA_OIF = RTA_OIF,
$RTA_GATEWAY = RTA_GATEWAY,
$RTA_PRIORITY = RTA_PRIORITY,
$RTA_PREFSRC = RTA_PREFSRC,
$RTA_METRICS = RTA_METRICS,
$RTA_MULTIPATH = RTA_MULTIPATH,
$RTA_FLOW = RTA_FLOW,
$RTA_CACHEINFO = RTA_CACHEINFO,
$RTA_TABLE = RTA_TABLE,
$RTN_UNSPEC = RTN_UNSPEC,
$RTN_UNICAST = RTN_UNICAST,
$RTN_LOCAL = RTN_LOCAL,
$RTN_BROADCAST = RTN_BROADCAST,
$RTN_ANYCAST = RTN_ANYCAST,
$RTN_MULTICAST = RTN_MULTICAST,
$RTN_BLACKHOLE = RTN_BLACKHOLE,
$RTN_UNREACHABLE = RTN_UNREACHABLE,
$RTN_PROHIBIT = RTN_PROHIBIT,
$RTN_THROW = RTN_THROW,
$RTN_NAT = RTN_NAT,
$RTN_XRESOLVE = RTN_XRESOLVE,
$SizeofNlMsghdr = sizeof(struct nlmsghdr),
$SizeofNlMsgerr = sizeof(struct nlmsgerr),
$SizeofRtGenmsg = sizeof(struct rtgenmsg),
......@@ -173,6 +209,7 @@ enum {
$SizeofIfInfomsg = sizeof(struct ifinfomsg),
$SizeofIfAddrmsg = sizeof(struct ifaddrmsg),
$SizeofRtmsg = sizeof(struct rtmsg),
$SizeofRtNexthop = sizeof(struct rtnexthop),
};
typedef struct nlmsghdr $NlMsghdr;
......@@ -183,6 +220,7 @@ typedef struct rtattr $RtAttr;
typedef struct ifinfomsg $IfInfomsg;
typedef struct ifaddrmsg $IfAddrmsg;
typedef struct rtmsg $RtMsg;
typedef struct rtnexthop $RtNexthop;
// Inotify
......
......@@ -48,6 +48,64 @@ const (
AF_UNSPEC = 0
AF_WANPIPE = 0x19
AF_X25 = 0x9
ARPHRD_ADAPT = 0x108
ARPHRD_APPLETLK = 0x8
ARPHRD_ARCNET = 0x7
ARPHRD_ASH = 0x30d
ARPHRD_ATM = 0x13
ARPHRD_AX25 = 0x3
ARPHRD_BIF = 0x307
ARPHRD_CHAOS = 0x5
ARPHRD_CISCO = 0x201
ARPHRD_CSLIP = 0x101
ARPHRD_CSLIP6 = 0x103
ARPHRD_DDCMP = 0x205
ARPHRD_DLCI = 0xf
ARPHRD_ECONET = 0x30e
ARPHRD_EETHER = 0x2
ARPHRD_ETHER = 0x1
ARPHRD_EUI64 = 0x1b
ARPHRD_FCAL = 0x311
ARPHRD_FCFABRIC = 0x313
ARPHRD_FCPL = 0x312
ARPHRD_FCPP = 0x310
ARPHRD_FDDI = 0x306
ARPHRD_FRAD = 0x302
ARPHRD_HDLC = 0x201
ARPHRD_HIPPI = 0x30c
ARPHRD_HWX25 = 0x110
ARPHRD_IEEE1394 = 0x18
ARPHRD_IEEE802 = 0x6
ARPHRD_IEEE80211 = 0x321
ARPHRD_IEEE80211_PRISM = 0x322
ARPHRD_IEEE80211_RADIOTAP = 0x323
ARPHRD_IEEE802154 = 0x324
ARPHRD_IEEE802154_PHY = 0x325
ARPHRD_IEEE802_TR = 0x320
ARPHRD_INFINIBAND = 0x20
ARPHRD_IPDDP = 0x309
ARPHRD_IPGRE = 0x30a
ARPHRD_IRDA = 0x30f
ARPHRD_LAPB = 0x204
ARPHRD_LOCALTLK = 0x305
ARPHRD_LOOPBACK = 0x304
ARPHRD_METRICOM = 0x17
ARPHRD_NETROM = 0
ARPHRD_NONE = 0xfffe
ARPHRD_PIMREG = 0x30b
ARPHRD_PPP = 0x200
ARPHRD_PRONET = 0x4
ARPHRD_RAWHDLC = 0x206
ARPHRD_ROSE = 0x10e
ARPHRD_RSRVD = 0x104
ARPHRD_SIT = 0x308
ARPHRD_SKIP = 0x303
ARPHRD_SLIP = 0x100
ARPHRD_SLIP6 = 0x102
ARPHRD_TUNNEL = 0x300
ARPHRD_TUNNEL6 = 0x301
ARPHRD_VOID = 0xffff
ARPHRD_X25 = 0x10f
DT_BLK = 0x6
DT_CHR = 0x2
DT_DIR = 0x4
......@@ -716,6 +774,25 @@ const (
RTM_SETDCB = 0x4f
RTM_SETLINK = 0x13
RTM_SETNEIGHTBL = 0x43
RTNH_ALIGNTO = 0x4
RTNH_F_DEAD = 0x1
RTNH_F_ONLINK = 0x4
RTNH_F_PERVASIVE = 0x2
RTN_MAX = 0xb
RTPROT_BIRD = 0xc
RTPROT_BOOT = 0x3
RTPROT_DHCP = 0x10
RTPROT_DNROUTED = 0xd
RTPROT_GATED = 0x8
RTPROT_KERNEL = 0x2
RTPROT_MRT = 0xa
RTPROT_NTK = 0xf
RTPROT_RA = 0x9
RTPROT_REDIRECT = 0x1
RTPROT_STATIC = 0x4
RTPROT_UNSPEC = 0
RTPROT_XORP = 0xe
RTPROT_ZEBRA = 0xb
SCM_CREDENTIALS = 0x2
SCM_RIGHTS = 0x1
SCM_TIMESTAMP = 0x1d
......
......@@ -48,6 +48,64 @@ const (
AF_UNSPEC = 0
AF_WANPIPE = 0x19
AF_X25 = 0x9
ARPHRD_ADAPT = 0x108
ARPHRD_APPLETLK = 0x8
ARPHRD_ARCNET = 0x7
ARPHRD_ASH = 0x30d
ARPHRD_ATM = 0x13
ARPHRD_AX25 = 0x3
ARPHRD_BIF = 0x307
ARPHRD_CHAOS = 0x5
ARPHRD_CISCO = 0x201
ARPHRD_CSLIP = 0x101
ARPHRD_CSLIP6 = 0x103
ARPHRD_DDCMP = 0x205
ARPHRD_DLCI = 0xf
ARPHRD_ECONET = 0x30e
ARPHRD_EETHER = 0x2
ARPHRD_ETHER = 0x1
ARPHRD_EUI64 = 0x1b
ARPHRD_FCAL = 0x311
ARPHRD_FCFABRIC = 0x313
ARPHRD_FCPL = 0x312
ARPHRD_FCPP = 0x310
ARPHRD_FDDI = 0x306
ARPHRD_FRAD = 0x302
ARPHRD_HDLC = 0x201
ARPHRD_HIPPI = 0x30c
ARPHRD_HWX25 = 0x110
ARPHRD_IEEE1394 = 0x18
ARPHRD_IEEE802 = 0x6
ARPHRD_IEEE80211 = 0x321
ARPHRD_IEEE80211_PRISM = 0x322
ARPHRD_IEEE80211_RADIOTAP = 0x323
ARPHRD_IEEE802154 = 0x324
ARPHRD_IEEE802154_PHY = 0x325
ARPHRD_IEEE802_TR = 0x320
ARPHRD_INFINIBAND = 0x20
ARPHRD_IPDDP = 0x309
ARPHRD_IPGRE = 0x30a
ARPHRD_IRDA = 0x30f
ARPHRD_LAPB = 0x204
ARPHRD_LOCALTLK = 0x305
ARPHRD_LOOPBACK = 0x304
ARPHRD_METRICOM = 0x17
ARPHRD_NETROM = 0
ARPHRD_NONE = 0xfffe
ARPHRD_PIMREG = 0x30b
ARPHRD_PPP = 0x200
ARPHRD_PRONET = 0x4
ARPHRD_RAWHDLC = 0x206
ARPHRD_ROSE = 0x10e
ARPHRD_RSRVD = 0x104
ARPHRD_SIT = 0x308
ARPHRD_SKIP = 0x303
ARPHRD_SLIP = 0x100
ARPHRD_SLIP6 = 0x102
ARPHRD_TUNNEL = 0x300
ARPHRD_TUNNEL6 = 0x301
ARPHRD_VOID = 0xffff
ARPHRD_X25 = 0x10f
DT_BLK = 0x6
DT_CHR = 0x2
DT_DIR = 0x4
......@@ -717,6 +775,25 @@ const (
RTM_SETDCB = 0x4f
RTM_SETLINK = 0x13
RTM_SETNEIGHTBL = 0x43
RTNH_ALIGNTO = 0x4
RTNH_F_DEAD = 0x1
RTNH_F_ONLINK = 0x4
RTNH_F_PERVASIVE = 0x2
RTN_MAX = 0xb
RTPROT_BIRD = 0xc
RTPROT_BOOT = 0x3
RTPROT_DHCP = 0x10
RTPROT_DNROUTED = 0xd
RTPROT_GATED = 0x8
RTPROT_KERNEL = 0x2
RTPROT_MRT = 0xa
RTPROT_NTK = 0xf
RTPROT_RA = 0x9
RTPROT_REDIRECT = 0x1
RTPROT_STATIC = 0x4
RTPROT_UNSPEC = 0
RTPROT_XORP = 0xe
RTPROT_ZEBRA = 0xb
SCM_CREDENTIALS = 0x2
SCM_RIGHTS = 0x1
SCM_TIMESTAMP = 0x1d
......
......@@ -48,6 +48,64 @@ const (
AF_UNSPEC = 0
AF_WANPIPE = 0x19
AF_X25 = 0x9
ARPHRD_ADAPT = 0x108
ARPHRD_APPLETLK = 0x8
ARPHRD_ARCNET = 0x7
ARPHRD_ASH = 0x30d
ARPHRD_ATM = 0x13
ARPHRD_AX25 = 0x3
ARPHRD_BIF = 0x307
ARPHRD_CHAOS = 0x5
ARPHRD_CISCO = 0x201
ARPHRD_CSLIP = 0x101
ARPHRD_CSLIP6 = 0x103
ARPHRD_DDCMP = 0x205
ARPHRD_DLCI = 0xf
ARPHRD_ECONET = 0x30e
ARPHRD_EETHER = 0x2
ARPHRD_ETHER = 0x1
ARPHRD_EUI64 = 0x1b
ARPHRD_FCAL = 0x311
ARPHRD_FCFABRIC = 0x313
ARPHRD_FCPL = 0x312
ARPHRD_FCPP = 0x310
ARPHRD_FDDI = 0x306
ARPHRD_FRAD = 0x302
ARPHRD_HDLC = 0x201
ARPHRD_HIPPI = 0x30c
ARPHRD_HWX25 = 0x110
ARPHRD_IEEE1394 = 0x18
ARPHRD_IEEE802 = 0x6
ARPHRD_IEEE80211 = 0x321
ARPHRD_IEEE80211_PRISM = 0x322
ARPHRD_IEEE80211_RADIOTAP = 0x323
ARPHRD_IEEE802154 = 0x324
ARPHRD_IEEE802154_PHY = 0x325
ARPHRD_IEEE802_TR = 0x320
ARPHRD_INFINIBAND = 0x20
ARPHRD_IPDDP = 0x309
ARPHRD_IPGRE = 0x30a
ARPHRD_IRDA = 0x30f
ARPHRD_LAPB = 0x204
ARPHRD_LOCALTLK = 0x305
ARPHRD_LOOPBACK = 0x304
ARPHRD_METRICOM = 0x17
ARPHRD_NETROM = 0
ARPHRD_NONE = 0xfffe
ARPHRD_PIMREG = 0x30b
ARPHRD_PPP = 0x200
ARPHRD_PRONET = 0x4
ARPHRD_RAWHDLC = 0x206
ARPHRD_ROSE = 0x10e
ARPHRD_RSRVD = 0x104
ARPHRD_SIT = 0x308
ARPHRD_SKIP = 0x303
ARPHRD_SLIP = 0x100
ARPHRD_SLIP6 = 0x102
ARPHRD_TUNNEL = 0x300
ARPHRD_TUNNEL6 = 0x301
ARPHRD_VOID = 0xffff
ARPHRD_X25 = 0x10f
DT_BLK = 0x6
DT_CHR = 0x2
DT_DIR = 0x4
......@@ -707,6 +765,25 @@ const (
RTM_SETDCB = 0x4f
RTM_SETLINK = 0x13
RTM_SETNEIGHTBL = 0x43
RTNH_ALIGNTO = 0x4
RTNH_F_DEAD = 0x1
RTNH_F_ONLINK = 0x4
RTNH_F_PERVASIVE = 0x2
RTN_MAX = 0xb
RTPROT_BIRD = 0xc
RTPROT_BOOT = 0x3
RTPROT_DHCP = 0x10
RTPROT_DNROUTED = 0xd
RTPROT_GATED = 0x8
RTPROT_KERNEL = 0x2
RTPROT_MRT = 0xa
RTPROT_NTK = 0xf
RTPROT_RA = 0x9
RTPROT_REDIRECT = 0x1
RTPROT_STATIC = 0x4
RTPROT_UNSPEC = 0
RTPROT_XORP = 0xe
RTPROT_ZEBRA = 0xb
SCM_CREDENTIALS = 0x2
SCM_RIGHTS = 0x1
SCM_TIMESTAMP = 0x1d
......
......@@ -53,6 +53,42 @@ const (
IFLA_NET_NS_PID = 0x13
IFLA_IFALIAS = 0x14
IFLA_MAX = 0x14
RT_SCOPE_UNIVERSE = 0
RT_SCOPE_SITE = 0xc8
RT_SCOPE_LINK = 0xfd
RT_SCOPE_HOST = 0xfe
RT_SCOPE_NOWHERE = 0xff
RT_TABLE_UNSPEC = 0
RT_TABLE_COMPAT = 0xfc
RT_TABLE_DEFAULT = 0xfd
RT_TABLE_MAIN = 0xfe
RT_TABLE_LOCAL = 0xff
RT_TABLE_MAX = 0xffffffff
RTA_UNSPEC = 0
RTA_DST = 0x1
RTA_SRC = 0x2
RTA_IIF = 0x3
RTA_OIF = 0x4
RTA_GATEWAY = 0x5
RTA_PRIORITY = 0x6
RTA_PREFSRC = 0x7
RTA_METRICS = 0x8
RTA_MULTIPATH = 0x9
RTA_FLOW = 0xb
RTA_CACHEINFO = 0xc
RTA_TABLE = 0xf
RTN_UNSPEC = 0
RTN_UNICAST = 0x1
RTN_LOCAL = 0x2
RTN_BROADCAST = 0x3
RTN_ANYCAST = 0x4
RTN_MULTICAST = 0x5
RTN_BLACKHOLE = 0x6
RTN_UNREACHABLE = 0x7
RTN_PROHIBIT = 0x8
RTN_THROW = 0x9
RTN_NAT = 0xa
RTN_XRESOLVE = 0xb
SizeofNlMsghdr = 0x10
SizeofNlMsgerr = 0x14
SizeofRtGenmsg = 0x1
......@@ -61,6 +97,7 @@ const (
SizeofIfInfomsg = 0x10
SizeofIfAddrmsg = 0x8
SizeofRtmsg = 0xc
SizeofRtNexthop = 0x8
SizeofInotifyEvent = 0x10
)
......@@ -344,6 +381,13 @@ type RtMsg struct {
Flags uint32
}
type RtNexthop struct {
Len uint16
Flags uint8
Hops uint8
Ifindex int32
}
type InotifyEvent struct {
Wd int32
Mask uint32
......
......@@ -53,6 +53,42 @@ const (
IFLA_NET_NS_PID = 0x13
IFLA_IFALIAS = 0x14
IFLA_MAX = 0x14
RT_SCOPE_UNIVERSE = 0
RT_SCOPE_SITE = 0xc8
RT_SCOPE_LINK = 0xfd
RT_SCOPE_HOST = 0xfe
RT_SCOPE_NOWHERE = 0xff
RT_TABLE_UNSPEC = 0
RT_TABLE_COMPAT = 0xfc
RT_TABLE_DEFAULT = 0xfd
RT_TABLE_MAIN = 0xfe
RT_TABLE_LOCAL = 0xff
RT_TABLE_MAX = 0xffffffff
RTA_UNSPEC = 0
RTA_DST = 0x1
RTA_SRC = 0x2
RTA_IIF = 0x3
RTA_OIF = 0x4
RTA_GATEWAY = 0x5
RTA_PRIORITY = 0x6
RTA_PREFSRC = 0x7
RTA_METRICS = 0x8
RTA_MULTIPATH = 0x9
RTA_FLOW = 0xb
RTA_CACHEINFO = 0xc
RTA_TABLE = 0xf
RTN_UNSPEC = 0
RTN_UNICAST = 0x1
RTN_LOCAL = 0x2
RTN_BROADCAST = 0x3
RTN_ANYCAST = 0x4
RTN_MULTICAST = 0x5
RTN_BLACKHOLE = 0x6
RTN_UNREACHABLE = 0x7
RTN_PROHIBIT = 0x8
RTN_THROW = 0x9
RTN_NAT = 0xa
RTN_XRESOLVE = 0xb
SizeofNlMsghdr = 0x10
SizeofNlMsgerr = 0x14
SizeofRtGenmsg = 0x1
......@@ -61,6 +97,7 @@ const (
SizeofIfInfomsg = 0x10
SizeofIfAddrmsg = 0x8
SizeofRtmsg = 0xc
SizeofRtNexthop = 0x8
SizeofInotifyEvent = 0x10
)
......@@ -346,6 +383,13 @@ type RtMsg struct {
Flags uint32
}
type RtNexthop struct {
Len uint16
Flags uint8
Hops uint8
Ifindex int32
}
type InotifyEvent struct {
Wd int32
Mask uint32
......
......@@ -58,6 +58,42 @@ const (
IFLA_NET_NS_PID = 0x13
IFLA_IFALIAS = 0x14
IFLA_MAX = 0x14
RT_SCOPE_UNIVERSE = 0
RT_SCOPE_SITE = 0xc8
RT_SCOPE_LINK = 0xfd
RT_SCOPE_HOST = 0xfe
RT_SCOPE_NOWHERE = 0xff
RT_TABLE_UNSPEC = 0
RT_TABLE_COMPAT = 0xfc
RT_TABLE_DEFAULT = 0xfd
RT_TABLE_MAIN = 0xfe
RT_TABLE_LOCAL = 0xff
RT_TABLE_MAX = 0xffffffff
RTA_UNSPEC = 0
RTA_DST = 0x1
RTA_SRC = 0x2
RTA_IIF = 0x3
RTA_OIF = 0x4
RTA_GATEWAY = 0x5
RTA_PRIORITY = 0x6
RTA_PREFSRC = 0x7
RTA_METRICS = 0x8
RTA_MULTIPATH = 0x9
RTA_FLOW = 0xb
RTA_CACHEINFO = 0xc
RTA_TABLE = 0xf
RTN_UNSPEC = 0
RTN_UNICAST = 0x1
RTN_LOCAL = 0x2
RTN_BROADCAST = 0x3
RTN_ANYCAST = 0x4
RTN_MULTICAST = 0x5
RTN_BLACKHOLE = 0x6
RTN_UNREACHABLE = 0x7
RTN_PROHIBIT = 0x8
RTN_THROW = 0x9
RTN_NAT = 0xa
RTN_XRESOLVE = 0xb
SizeofNlMsghdr = 0x10
SizeofNlMsgerr = 0x14
SizeofRtGenmsg = 0x1
......@@ -66,6 +102,7 @@ const (
SizeofIfInfomsg = 0x10
SizeofIfAddrmsg = 0x8
SizeofRtmsg = 0xc
SizeofRtNexthop = 0x8
SizeofInotifyEvent = 0x10
)
......@@ -351,6 +388,13 @@ type RtMsg struct {
Flags uint32
}
type RtNexthop struct {
Len uint16
Flags uint8
Hops uint8
Ifindex int32
}
type InotifyEvent struct {
Wd int32
Mask uint32
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment