Commit f25f6eab authored by Yuval Pavel Zholkover's avatar Yuval Pavel Zholkover Committed by Russ Cox

syscall: route_freebsd switch routing socket sysctl to use NET_RT_IFLISTL

Switch IfMsghdr and IfaMsghdr to their 'l' variants, make the IfData layout
to be based on FreeBSD-11.0 (freebsdVersion >= 1100011).
Using freebsdVersion, detect the appropriate layout at runtime and decode
routing socket messages into the new IfData layout.

Fixes #11641

Change-Id: Ic7ec550f00c0d15f46a36f560d835e4f138f61e1
Reviewed-on: https://go-review.googlesource.com/14757Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
parent 77328b8d
......@@ -16,7 +16,7 @@ import (
// network interfaces. Otherwise it returns a mapping of a specific
// interface.
func interfaceTable(ifindex int) ([]Interface, error) {
tab, err := syscall.RouteRIB(syscall.NET_RT_IFLIST, ifindex)
tab, err := syscall.RouteRIB(rtSockIfListSyscall, ifindex)
if err != nil {
return nil, os.NewSyscallError("routerib", err)
}
......@@ -102,7 +102,7 @@ func interfaceAddrTable(ifi *Interface) ([]Addr, error) {
if ifi != nil {
index = ifi.Index
}
tab, err := syscall.RouteRIB(syscall.NET_RT_IFLIST, index)
tab, err := syscall.RouteRIB(rtSockIfListSyscall, index)
if err != nil {
return nil, os.NewSyscallError("routerib", err)
}
......
......@@ -9,6 +9,8 @@ import (
"syscall"
)
const rtSockIfListSyscall = syscall.NET_RT_IFLIST
// interfaceMulticastAddrTable returns addresses for a specific
// interface.
func interfaceMulticastAddrTable(ifi *Interface) ([]Addr, error) {
......
......@@ -4,6 +4,10 @@
package net
import "syscall"
const rtSockIfListSyscall = syscall.NET_RT_IFLIST
// interfaceMulticastAddrTable returns addresses for a specific
// interface.
func interfaceMulticastAddrTable(ifi *Interface) ([]Addr, error) {
......
......@@ -9,6 +9,8 @@ import (
"syscall"
)
const rtSockIfListSyscall = syscall.NET_RT_IFLISTL
// interfaceMulticastAddrTable returns addresses for a specific
// interface.
func interfaceMulticastAddrTable(ifi *Interface) ([]Addr, error) {
......
......@@ -4,6 +4,10 @@
package net
import "syscall"
const rtSockIfListSyscall = syscall.NET_RT_IFLIST
// interfaceMulticastAddrTable returns addresses for a specific
// interface.
func interfaceMulticastAddrTable(ifi *Interface) ([]Addr, error) {
......
......@@ -4,6 +4,10 @@
package net
import "syscall"
const rtSockIfListSyscall = syscall.NET_RT_IFLIST
// interfaceMulticastAddrTable returns addresses for a specific
// interface.
func interfaceMulticastAddrTable(ifi *Interface) ([]Addr, error) {
......
......@@ -10,13 +10,18 @@ import (
"fmt"
"net"
"os"
"runtime"
"syscall"
"testing"
"time"
)
func TestRouteRIB(t *testing.T) {
for _, facility := range []int{syscall.NET_RT_DUMP, syscall.NET_RT_IFLIST} {
var rtSockIfListSyscall = syscall.NET_RT_IFLIST
if runtime.GOOS == "freebsd" {
rtSockIfListSyscall = syscall.NET_RT_IFLISTL
}
for _, facility := range []int{syscall.NET_RT_DUMP, rtSockIfListSyscall} {
for _, param := range []int{syscall.AF_UNSPEC, syscall.AF_INET, syscall.AF_INET6} {
var err error
var b []byte
......
......@@ -6,7 +6,7 @@ package syscall
import "unsafe"
// See http://www.freebsd.org/doc/en/books/porters-handbook/freebsd-versions.html.
// See https://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/versions.html#freebsd-versions-table.
var freebsdVersion uint32
func init() {
......@@ -42,8 +42,7 @@ func (any *anyMessage) toRoutingMessage(b []byte) RoutingMessage {
p := (*InterfaceAnnounceMessage)(unsafe.Pointer(any))
return &InterfaceAnnounceMessage{Header: p.Header}
case RTM_NEWADDR, RTM_DELADDR:
p := (*InterfaceAddrMessage)(unsafe.Pointer(any))
return &InterfaceAddrMessage{Header: p.Header, Data: b[SizeofIfaMsghdr:any.Msglen]}
return any.parseInterfaceAddrMessage(b)
case RTM_NEWMADDR, RTM_DELMADDR:
p := (*InterfaceMulticastAddrMessage)(unsafe.Pointer(any))
return &InterfaceMulticastAddrMessage{Header: p.Header, Data: b[SizeofIfmaMsghdr:any.Msglen]}
......@@ -51,6 +50,124 @@ func (any *anyMessage) toRoutingMessage(b []byte) RoutingMessage {
return nil
}
func (any *anyMessage) parseInterfaceMessage(b []byte) *InterfaceMessage {
p := (*ifMsghdrFixed)(unsafe.Pointer(any))
h := IfMsghdr{
Msglen: p.Msglen,
Version: p.Version,
Type: p.Type,
Addrs: p.Addrs,
Flags: p.Flags,
Index: p.Index,
Len: p.Len,
Data_off: p.Data_off,
}
switch {
case freebsdVersion >= 1100011:
// FreeBSD 11 uses a new struct if_data layout
// See https://svnweb.freebsd.org/base?view=revision&revision=263102
data11 := *(*ifData11Raw)(unsafe.Pointer(&b[p.Data_off:p.Len][0]))
h.Data.copyFromV11Raw(&data11)
case freebsdVersion >= 1001000:
// FreeBSD 10.1 and newer
data10 := *(*ifData10)(unsafe.Pointer(&b[p.Data_off:p.Len][0]))
h.Data.copyFromV10(&data10)
case freebsdVersion >= 903000:
// TODO
}
return &InterfaceMessage{Header: h, Data: b[p.Len:any.Msglen]}
}
func (d *IfData) copyFromV11Raw(data11 *ifData11Raw) {
d.Type = data11.Type
d.Physical = data11.Physical
d.Addrlen = data11.Addrlen
d.Hdrlen = data11.Hdrlen
d.Link_state = data11.Link_state
d.Vhid = data11.Vhid
d.Datalen = data11.Datalen
d.Mtu = data11.Mtu
d.Metric = data11.Metric
d.Baudrate = data11.Baudrate
d.Ipackets = data11.Ipackets
d.Ierrors = data11.Ierrors
d.Opackets = data11.Opackets
d.Oerrors = data11.Oerrors
d.Collisions = data11.Collisions
d.Ibytes = data11.Ibytes
d.Obytes = data11.Obytes
d.Imcasts = data11.Imcasts
d.Omcasts = data11.Omcasts
d.Iqdrops = data11.Iqdrops
d.Oqdrops = data11.Oqdrops
d.Noproto = data11.Noproto
d.Hwassist = data11.Hwassist
d.fillEpochLastChange(data11)
}
func (d *IfData) copyFromV10(data10 *ifData10) {
d.Type = data10.Type
d.Physical = data10.Physical
d.Addrlen = data10.Addrlen
d.Hdrlen = data10.Hdrlen
d.Link_state = data10.Link_state
d.Vhid = data10.Vhid
d.Datalen = uint16(data10.Datalen)
d.Mtu = uint32(data10.Mtu)
d.Metric = uint32(data10.Metric)
d.Baudrate = uint64(data10.Baudrate)
d.Ipackets = uint64(data10.Ipackets)
d.Ierrors = uint64(data10.Ierrors)
d.Opackets = uint64(data10.Opackets)
d.Oerrors = uint64(data10.Oerrors)
d.Collisions = uint64(data10.Collisions)
d.Ibytes = uint64(data10.Ibytes)
d.Obytes = uint64(data10.Obytes)
d.Imcasts = uint64(data10.Imcasts)
d.Omcasts = uint64(data10.Omcasts)
d.Iqdrops = uint64(data10.Iqdrops)
d.Oqdrops = uint64(data10.Oqdrops)
d.Noproto = uint64(data10.Noproto)
d.Hwassist = uint64(data10.Hwassist)
d.Epoch = data10.Epoch
d.Lastchange = data10.Lastchange
}
func (any *anyMessage) parseInterfaceAddrMessage(b []byte) *InterfaceAddrMessage {
p := (*IfaMsghdr)(unsafe.Pointer(any))
h := IfaMsghdr{
Msglen: p.Msglen,
Version: p.Version,
Type: p.Type,
Addrs: p.Addrs,
Flags: p.Flags,
Index: p.Index,
Len: p.Len,
Data_off: p.Data_off,
Metric: p.Metric,
}
switch {
case freebsdVersion >= 1100011:
// FreeBSD 11 uses a new struct if_data layout
// See https://svnweb.freebsd.org/base?view=revision&revision=263102
data11 := *(*ifData11Raw)(unsafe.Pointer(&b[p.Data_off:p.Len][0]))
h.Data.copyFromV11Raw(&data11)
case freebsdVersion >= 1001000:
// FreeBSD 10.1 and newer
data10 := *(*ifData10)(unsafe.Pointer(&b[p.Data_off:p.Len][0]))
h.Data.copyFromV10(&data10)
case freebsdVersion >= 903000:
// TODO
}
return &InterfaceAddrMessage{Header: h, Data: b[p.Len:any.Msglen]}
}
// InterfaceAnnounceMessage represents a routing message containing
// network interface arrival and departure information.
type InterfaceAnnounceMessage struct {
......
......@@ -16,18 +16,3 @@ func (any *anyMessage) parseRouteMessage(b []byte) *RouteMessage {
}
return &RouteMessage{Header: p.Header, Data: b[rsaAlignOf(off):any.Msglen]}
}
func (any *anyMessage) parseInterfaceMessage(b []byte) *InterfaceMessage {
p := (*InterfaceMessage)(unsafe.Pointer(any))
// FreeBSD 10 and beyond have a restructured mbuf
// packet header view.
// See http://svnweb.freebsd.org/base?view=revision&revision=254804.
if freebsdVersion >= 1000000 {
m := (*ifMsghdr)(unsafe.Pointer(any))
p.Header.Data.Hwassist = uint32(m.Data.Hwassist)
p.Header.Data.Epoch = m.Data.Epoch
p.Header.Data.Lastchange = m.Data.Lastchange
return &InterfaceMessage{Header: p.Header, Data: b[int(unsafe.Offsetof(p.Header.Data))+int(p.Header.Data.Datalen) : any.Msglen]}
}
return &InterfaceMessage{Header: p.Header, Data: b[int(unsafe.Offsetof(p.Header.Data))+int(p.Header.Data.Datalen) : any.Msglen]}
}
......@@ -12,8 +12,3 @@ func (any *anyMessage) parseRouteMessage(b []byte) *RouteMessage {
p := (*RouteMessage)(unsafe.Pointer(any))
return &RouteMessage{Header: p.Header, Data: b[rsaAlignOf(int(unsafe.Offsetof(p.Header.Rmx))+SizeofRtMetrics):any.Msglen]}
}
func (any *anyMessage) parseInterfaceMessage(b []byte) *InterfaceMessage {
p := (*InterfaceMessage)(unsafe.Pointer(any))
return &InterfaceMessage{Header: p.Header, Data: b[int(unsafe.Offsetof(p.Header.Data))+int(p.Header.Data.Datalen) : any.Msglen]}
}
......@@ -43,6 +43,12 @@ func (cmsg *Cmsghdr) SetLen(length int) {
cmsg.Len = uint32(length)
}
func (d *IfData) fillEpochLastChange(data11 *ifData11Raw) {
d.Epoch = *(*int32)(unsafe.Pointer(&data11.X__ifi_epoch[0]))
d.Lastchange.Sec = *(*int32)(unsafe.Pointer(&data11.X__ifi_lastchange[0:4][0]))
d.Lastchange.Usec = *(*int32)(unsafe.Pointer(&data11.X__ifi_lastchange[4:8][0]))
}
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
var writtenOut uint64 = 0
_, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0)
......
......@@ -43,6 +43,12 @@ func (cmsg *Cmsghdr) SetLen(length int) {
cmsg.Len = uint32(length)
}
func (d *IfData) fillEpochLastChange(data11 *ifData11Raw) {
d.Epoch = *(*int64)(unsafe.Pointer(&data11.X__ifi_epoch[0]))
d.Lastchange.Sec = *(*int64)(unsafe.Pointer(&data11.X__ifi_lastchange[0:8][0]))
d.Lastchange.Usec = *(*int64)(unsafe.Pointer(&data11.X__ifi_lastchange[8:16][0]))
}
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
var writtenOut uint64 = 0
_, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0)
......
......@@ -43,6 +43,12 @@ func (cmsg *Cmsghdr) SetLen(length int) {
cmsg.Len = uint32(length)
}
func (d *IfData) fillEpochLastChange(data11 *ifData11Raw) {
d.Epoch = *(*int64)(unsafe.Pointer(&data11.X__ifi_epoch[0]))
d.Lastchange.Sec = *(*int64)(unsafe.Pointer(&data11.X__ifi_lastchange[0:8][0]))
d.Lastchange.Usec = *(*int32)(unsafe.Pointer(&data11.X__ifi_lastchange[8:12][0]))
}
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
var writtenOut uint64 = 0
_, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0)
......
......@@ -104,47 +104,169 @@ struct stat8 {
#endif
};
// This structure is a duplicate of if_data on FreeBSD 8-STABLE.
// See /usr/include/net/if.h.
struct if_data8 {
u_char ifi_type;
u_char ifi_physical;
u_char ifi_addrlen;
u_char ifi_hdrlen;
u_char ifi_link_state;
u_char ifi_spare_char1;
u_char ifi_spare_char2;
u_char ifi_datalen;
u_long ifi_mtu;
u_long ifi_metric;
u_long ifi_baudrate;
u_long ifi_ipackets;
u_long ifi_ierrors;
u_long ifi_opackets;
u_long ifi_oerrors;
u_long ifi_collisions;
u_long ifi_ibytes;
u_long ifi_obytes;
u_long ifi_imcasts;
u_long ifi_omcasts;
u_long ifi_iqdrops;
u_long ifi_noproto;
u_long ifi_hwassist;
time_t ifi_epoch;
struct timeval ifi_lastchange;
// This structure is a duplicate of if_data on FreeBSD 11-CURRENT 7b9bab6fbb69066f6e2ca96e5ca5b62fe834a2bb.
// See sys/net/if.h.
struct if_data11_raw {
uint8_t ifi_type;
uint8_t ifi_physical;
uint8_t ifi_addrlen;
uint8_t ifi_hdrlen;
uint8_t ifi_link_state;
uint8_t ifi_vhid;
uint16_t ifi_datalen;
uint32_t ifi_mtu;
uint32_t ifi_metric;
uint64_t ifi_baudrate;
uint64_t ifi_ipackets;
uint64_t ifi_ierrors;
uint64_t ifi_opackets;
uint64_t ifi_oerrors;
uint64_t ifi_collisions;
uint64_t ifi_ibytes;
uint64_t ifi_obytes;
uint64_t ifi_imcasts;
uint64_t ifi_omcasts;
uint64_t ifi_iqdrops;
uint64_t ifi_oqdrops;
uint64_t ifi_noproto;
uint64_t ifi_hwassist;
union {
time_t tt;
uint64_t ph;
} __ifi_epoch;
//#define ifi_epoch __ifi_epoch.tt
union {
struct timeval tv;
struct {
uint64_t ph1;
uint64_t ph2;
} ph;
} __ifi_lastchange;
//#define ifi_lastchange __ifi_lastchange.tv
};
// This structure is a duplicate of if_msghdr on FreeBSD 8-STABLE.
// See /usr/include/net/if.h.
struct if_msghdr8 {
u_short ifm_msglen;
u_char ifm_version;
u_char ifm_type;
int ifm_addrs;
int ifm_flags;
u_short ifm_index;
struct if_data8 ifm_data;
// same as if_data11_raw with the unions removed
struct if_data11 {
uint8_t ifi_type;
uint8_t ifi_physical;
uint8_t ifi_addrlen;
uint8_t ifi_hdrlen;
uint8_t ifi_link_state;
uint8_t ifi_vhid;
uint16_t ifi_datalen;
uint32_t ifi_mtu;
uint32_t ifi_metric;
uint64_t ifi_baudrate;
uint64_t ifi_ipackets;
uint64_t ifi_ierrors;
uint64_t ifi_opackets;
uint64_t ifi_oerrors;
uint64_t ifi_collisions;
uint64_t ifi_ibytes;
uint64_t ifi_obytes;
uint64_t ifi_imcasts;
uint64_t ifi_omcasts;
uint64_t ifi_iqdrops;
uint64_t ifi_oqdrops;
uint64_t ifi_noproto;
uint64_t ifi_hwassist;
time_t ifi_epoch;
struct timeval ifi_lastchange;
};
// This structure is a duplicate of if_msghdrl on FreeBSD 11-CURRENT 7b9bab6fbb69066f6e2ca96e5ca5b62fe834a2bb.
// See sys/net/if.h.
struct if_msghdrl11 {
u_short ifm_msglen;
u_char ifm_version;
u_char ifm_type;
int ifm_addrs;
int ifm_flags;
u_short ifm_index;
u_short _ifm_spare1;
u_short ifm_len;
u_short ifm_data_off;
struct if_data11 ifm_data;
};
struct if_msghdrl_fixed {
u_short ifm_msglen;
u_char ifm_version;
u_char ifm_type;
int ifm_addrs;
int ifm_flags;
u_short ifm_index;
u_short _ifm_spare1;
u_short ifm_len;
u_short ifm_data_off;
};
// This structure is a duplicate of ifa_msghdrl on FreeBSD 11-CURRENT 7b9bab6fbb69066f6e2ca96e5ca5b62fe834a2bb.
// See sys/net/if.h.
struct ifa_msghdrl11 {
u_short ifam_msglen;
u_char ifam_version;
u_char ifam_type;
int ifam_addrs;
int ifam_flags;
u_short ifam_index;
u_short _ifam_spare1;
u_short ifam_len;
u_short ifam_data_off;
int ifam_metric;
struct if_data11 ifam_data;
};
struct ifa_msghdrl_fixed {
u_short ifam_msglen;
u_char ifam_version;
u_char ifam_type;
int ifam_addrs;
int ifam_flags;
u_short ifam_index;
u_short _ifam_spare1;
u_short ifam_len;
u_short ifam_data_off;
int ifam_metric;
};
// This structure is a duplicate of if_data on FreeBSD 10.2-RELEASE 1e3b3008927ebb2708c3f6a87ba9f302ad3c0c66.
// See sys/net/if.h.
struct if_data10 {
u_char ifi_type;
u_char ifi_physical;
u_char ifi_addrlen;
u_char ifi_hdrlen;
u_char ifi_link_state;
u_char ifi_vhid;
u_char ifi_baudrate_pf;
u_char ifi_datalen;
u_long ifi_mtu;
u_long ifi_metric;
u_long ifi_baudrate;
u_long ifi_ipackets;
u_long ifi_ierrors;
u_long ifi_opackets;
u_long ifi_oerrors;
u_long ifi_collisions;
u_long ifi_ibytes;
u_long ifi_obytes;
u_long ifi_imcasts;
u_long ifi_omcasts;
u_long ifi_iqdrops;
u_long ifi_noproto;
uint64_t ifi_hwassist;
time_t ifi_epoch;
struct timeval ifi_lastchange;
u_long ifi_oqdrops;
};
*/
import "C"
......@@ -282,26 +404,25 @@ type FdSet C.fd_set
// Routing and interface messages
const (
sizeofIfMsghdr = C.sizeof_struct_if_msghdr
SizeofIfMsghdr = C.sizeof_struct_if_msghdr8
sizeofIfData = C.sizeof_struct_if_data
SizeofIfData = C.sizeof_struct_if_data8
SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr
SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr
SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr
SizeofRtMsghdr = C.sizeof_struct_rt_msghdr
SizeofRtMetrics = C.sizeof_struct_rt_metrics
)
type ifMsghdr C.struct_if_msghdr
type IfData C.struct_if_data11
type IfMsghdr C.struct_if_msghdrl11
type ifMsghdrFixed C.struct_if_msghdrl_fixed
type IfMsghdr C.struct_if_msghdr8
type IfaMsghdr C.struct_ifa_msghdrl11
type ifData C.struct_if_data
type ifaMsghdrFixed C.struct_ifa_msghdrl_fixed
type IfData C.struct_if_data8
type ifData11Raw C.struct_if_data11_raw
type IfaMsghdr C.struct_ifa_msghdr
type ifData10 C.struct_if_data10
type IfmaMsghdr C.struct_ifma_msghdr
......
......@@ -280,40 +280,121 @@ type FdSet struct {
}
const (
sizeofIfMsghdr = 0x64
SizeofIfMsghdr = 0x60
sizeofIfData = 0x54
SizeofIfData = 0x50
SizeofIfaMsghdr = 0x14
SizeofIfmaMsghdr = 0x10
SizeofIfAnnounceMsghdr = 0x18
SizeofRtMsghdr = 0x5c
SizeofRtMetrics = 0x38
)
type ifMsghdr struct {
Msglen uint16
Version uint8
Type uint8
Addrs int32
Flags int32
Index uint16
Pad_cgo_0 [2]byte
Data ifData
type IfData struct {
Type uint8
Physical uint8
Addrlen uint8
Hdrlen uint8
Link_state uint8
Vhid uint8
Datalen uint16
Mtu uint32
Metric uint32
Baudrate uint64
Ipackets uint64
Ierrors uint64
Opackets uint64
Oerrors uint64
Collisions uint64
Ibytes uint64
Obytes uint64
Imcasts uint64
Omcasts uint64
Iqdrops uint64
Oqdrops uint64
Noproto uint64
Hwassist uint64
Epoch int32
Lastchange Timeval
}
type IfMsghdr struct {
Msglen uint16
Version uint8
Type uint8
Addrs int32
Flags int32
Index uint16
Pad_cgo_0 [2]byte
Data IfData
Msglen uint16
Version uint8
Type uint8
Addrs int32
Flags int32
Index uint16
X_ifm_spare1 uint16
Len uint16
Data_off uint16
Data IfData
}
type ifMsghdrFixed struct {
Msglen uint16
Version uint8
Type uint8
Addrs int32
Flags int32
Index uint16
X_ifm_spare1 uint16
Len uint16
Data_off uint16
}
type ifData struct {
type IfaMsghdr struct {
Msglen uint16
Version uint8
Type uint8
Addrs int32
Flags int32
Index uint16
X_ifam_spare1 uint16
Len uint16
Data_off uint16
Metric int32
Data IfData
}
type ifaMsghdrFixed struct {
Msglen uint16
Version uint8
Type uint8
Addrs int32
Flags int32
Index uint16
X_ifam_spare1 uint16
Len uint16
Data_off uint16
Metric int32
}
type ifData11Raw struct {
Type uint8
Physical uint8
Addrlen uint8
Hdrlen uint8
Link_state uint8
Vhid uint8
Datalen uint16
Mtu uint32
Metric uint32
Baudrate uint64
Ipackets uint64
Ierrors uint64
Opackets uint64
Oerrors uint64
Collisions uint64
Ibytes uint64
Obytes uint64
Imcasts uint64
Omcasts uint64
Iqdrops uint64
Oqdrops uint64
Noproto uint64
Hwassist uint64
X__ifi_epoch [8]byte
X__ifi_lastchange [16]byte
}
type ifData10 struct {
Type uint8
Physical uint8
Addrlen uint8
......@@ -339,45 +420,7 @@ type ifData struct {
Hwassist uint64
Epoch int32
Lastchange Timeval
}
type IfData struct {
Type uint8
Physical uint8
Addrlen uint8
Hdrlen uint8
Link_state uint8
Spare_char1 uint8
Spare_char2 uint8
Datalen uint8
Mtu uint32
Metric uint32
Baudrate uint32
Ipackets uint32
Ierrors uint32
Opackets uint32
Oerrors uint32
Collisions uint32
Ibytes uint32
Obytes uint32
Imcasts uint32
Omcasts uint32
Iqdrops uint32
Noproto uint32
Hwassist uint32
Epoch int32
Lastchange Timeval
}
type IfaMsghdr struct {
Msglen uint16
Version uint8
Type uint8
Addrs int32
Flags int32
Index uint16
Pad_cgo_0 [2]byte
Metric int32
Oqdrops uint32
}
type IfmaMsghdr struct {
......
......@@ -282,40 +282,122 @@ type FdSet struct {
}
const (
sizeofIfMsghdr = 0xa8
SizeofIfMsghdr = 0xa8
sizeofIfData = 0x98
SizeofIfData = 0x98
SizeofIfaMsghdr = 0x14
SizeofIfmaMsghdr = 0x10
SizeofIfAnnounceMsghdr = 0x18
SizeofRtMsghdr = 0x98
SizeofRtMetrics = 0x70
)
type ifMsghdr struct {
Msglen uint16
Version uint8
Type uint8
Addrs int32
Flags int32
Index uint16
Pad_cgo_0 [2]byte
Data ifData
type IfData struct {
Type uint8
Physical uint8
Addrlen uint8
Hdrlen uint8
Link_state uint8
Vhid uint8
Datalen uint16
Mtu uint32
Metric uint32
Baudrate uint64
Ipackets uint64
Ierrors uint64
Opackets uint64
Oerrors uint64
Collisions uint64
Ibytes uint64
Obytes uint64
Imcasts uint64
Omcasts uint64
Iqdrops uint64
Oqdrops uint64
Noproto uint64
Hwassist uint64
Epoch int64
Lastchange Timeval
}
type IfMsghdr struct {
Msglen uint16
Version uint8
Type uint8
Addrs int32
Flags int32
Index uint16
Pad_cgo_0 [2]byte
Data IfData
Msglen uint16
Version uint8
Type uint8
Addrs int32
Flags int32
Index uint16
X_ifm_spare1 uint16
Len uint16
Data_off uint16
Pad_cgo_0 [4]byte
Data IfData
}
type ifMsghdrFixed struct {
Msglen uint16
Version uint8
Type uint8
Addrs int32
Flags int32
Index uint16
X_ifm_spare1 uint16
Len uint16
Data_off uint16
}
type ifData struct {
type IfaMsghdr struct {
Msglen uint16
Version uint8
Type uint8
Addrs int32
Flags int32
Index uint16
X_ifam_spare1 uint16
Len uint16
Data_off uint16
Metric int32
Data IfData
}
type ifaMsghdrFixed struct {
Msglen uint16
Version uint8
Type uint8
Addrs int32
Flags int32
Index uint16
X_ifam_spare1 uint16
Len uint16
Data_off uint16
Metric int32
}
type ifData11Raw struct {
Type uint8
Physical uint8
Addrlen uint8
Hdrlen uint8
Link_state uint8
Vhid uint8
Datalen uint16
Mtu uint32
Metric uint32
Baudrate uint64
Ipackets uint64
Ierrors uint64
Opackets uint64
Oerrors uint64
Collisions uint64
Ibytes uint64
Obytes uint64
Imcasts uint64
Omcasts uint64
Iqdrops uint64
Oqdrops uint64
Noproto uint64
Hwassist uint64
X__ifi_epoch [8]byte
X__ifi_lastchange [16]byte
}
type ifData10 struct {
Type uint8
Physical uint8
Addrlen uint8
......@@ -341,45 +423,7 @@ type ifData struct {
Hwassist uint64
Epoch int64
Lastchange Timeval
}
type IfData struct {
Type uint8
Physical uint8
Addrlen uint8
Hdrlen uint8
Link_state uint8
Spare_char1 uint8
Spare_char2 uint8
Datalen uint8
Mtu uint64
Metric uint64
Baudrate uint64
Ipackets uint64
Ierrors uint64
Opackets uint64
Oerrors uint64
Collisions uint64
Ibytes uint64
Obytes uint64
Imcasts uint64
Omcasts uint64
Iqdrops uint64
Noproto uint64
Hwassist uint64
Epoch int64
Lastchange Timeval
}
type IfaMsghdr struct {
Msglen uint16
Version uint8
Type uint8
Addrs int32
Flags int32
Index uint16
Pad_cgo_0 [2]byte
Metric int32
Oqdrops uint64
}
type IfmaMsghdr struct {
......
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