mirror of
https://github.com/golang/net.git
synced 2026-03-31 10:27:08 +09:00
Revert "route: change from syscall to x/sys/unix"
This reverts CL 632816. Reason for revert: This CL causes x/net to depend on x/sys. We have a policy that prevents us from vendoring x/sys into std, but x/net needs to be vendored. Change-Id: I0fe3bc9861d559d888db6fa7febd48a201f060b8 Reviewed-on: https://go-review.googlesource.com/c/net/+/634196 Auto-Submit: Michael Knyszek <mknyszek@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
committed by
Gopher Robot
parent
13a7c0108b
commit
552d8ac903
@@ -8,8 +8,7 @@ package route
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// An Addr represents an address associated with packet routing.
|
||||
@@ -26,7 +25,7 @@ type LinkAddr struct {
|
||||
}
|
||||
|
||||
// Family implements the Family method of Addr interface.
|
||||
func (a *LinkAddr) Family() int { return unix.AF_LINK }
|
||||
func (a *LinkAddr) Family() int { return syscall.AF_LINK }
|
||||
|
||||
func (a *LinkAddr) lenAndSpace() (int, int) {
|
||||
l := 8 + len(a.Name) + len(a.Addr)
|
||||
@@ -43,7 +42,7 @@ func (a *LinkAddr) marshal(b []byte) (int, error) {
|
||||
return 0, errInvalidAddr
|
||||
}
|
||||
b[0] = byte(l)
|
||||
b[1] = unix.AF_LINK
|
||||
b[1] = syscall.AF_LINK
|
||||
if a.Index > 0 {
|
||||
nativeEndian.PutUint16(b[2:4], uint16(a.Index))
|
||||
}
|
||||
@@ -65,7 +64,7 @@ func parseLinkAddr(b []byte) (Addr, error) {
|
||||
if len(b) < 8 {
|
||||
return nil, errInvalidAddr
|
||||
}
|
||||
_, a, err := parseKernelLinkAddr(unix.AF_LINK, b[4:])
|
||||
_, a, err := parseKernelLinkAddr(syscall.AF_LINK, b[4:])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -125,10 +124,10 @@ type Inet4Addr struct {
|
||||
}
|
||||
|
||||
// Family implements the Family method of Addr interface.
|
||||
func (a *Inet4Addr) Family() int { return unix.AF_INET }
|
||||
func (a *Inet4Addr) Family() int { return syscall.AF_INET }
|
||||
|
||||
func (a *Inet4Addr) lenAndSpace() (int, int) {
|
||||
return unix.SizeofSockaddrInet4, roundup(unix.SizeofSockaddrInet4)
|
||||
return sizeofSockaddrInet, roundup(sizeofSockaddrInet)
|
||||
}
|
||||
|
||||
func (a *Inet4Addr) marshal(b []byte) (int, error) {
|
||||
@@ -137,7 +136,7 @@ func (a *Inet4Addr) marshal(b []byte) (int, error) {
|
||||
return 0, errShortBuffer
|
||||
}
|
||||
b[0] = byte(l)
|
||||
b[1] = unix.AF_INET
|
||||
b[1] = syscall.AF_INET
|
||||
copy(b[4:8], a.IP[:])
|
||||
return ll, nil
|
||||
}
|
||||
@@ -149,10 +148,10 @@ type Inet6Addr struct {
|
||||
}
|
||||
|
||||
// Family implements the Family method of Addr interface.
|
||||
func (a *Inet6Addr) Family() int { return unix.AF_INET6 }
|
||||
func (a *Inet6Addr) Family() int { return syscall.AF_INET6 }
|
||||
|
||||
func (a *Inet6Addr) lenAndSpace() (int, int) {
|
||||
return unix.SizeofSockaddrInet6, roundup(unix.SizeofSockaddrInet6)
|
||||
return sizeofSockaddrInet6, roundup(sizeofSockaddrInet6)
|
||||
}
|
||||
|
||||
func (a *Inet6Addr) marshal(b []byte) (int, error) {
|
||||
@@ -161,7 +160,7 @@ func (a *Inet6Addr) marshal(b []byte) (int, error) {
|
||||
return 0, errShortBuffer
|
||||
}
|
||||
b[0] = byte(l)
|
||||
b[1] = unix.AF_INET6
|
||||
b[1] = syscall.AF_INET6
|
||||
copy(b[8:24], a.IP[:])
|
||||
if a.ZoneID > 0 {
|
||||
nativeEndian.PutUint32(b[24:28], uint32(a.ZoneID))
|
||||
@@ -176,7 +175,7 @@ func parseInetAddr(af int, b []byte) (Addr, error) {
|
||||
off6 = 8 // offset of in6_addr
|
||||
)
|
||||
switch af {
|
||||
case unix.AF_INET:
|
||||
case syscall.AF_INET:
|
||||
if len(b) < (off4+1) || len(b) < int(b[0]) || b[0] == 0 {
|
||||
return nil, errInvalidAddr
|
||||
}
|
||||
@@ -188,7 +187,7 @@ func parseInetAddr(af int, b []byte) (Addr, error) {
|
||||
}
|
||||
copy(a.IP[:], b[off4:n])
|
||||
return a, nil
|
||||
case unix.AF_INET6:
|
||||
case syscall.AF_INET6:
|
||||
if len(b) < (off6+1) || len(b) < int(b[0]) || b[0] == 0 {
|
||||
return nil, errInvalidAddr
|
||||
}
|
||||
@@ -198,7 +197,7 @@ func parseInetAddr(af int, b []byte) (Addr, error) {
|
||||
n = sockAddrLen
|
||||
}
|
||||
a := &Inet6Addr{}
|
||||
if sockAddrLen == unix.SizeofSockaddrInet6 {
|
||||
if sockAddrLen == sizeofSockaddrInet6 {
|
||||
a.ZoneID = int(nativeEndian.Uint32(b[24:28]))
|
||||
}
|
||||
copy(a.IP[:], b[off6:n])
|
||||
@@ -261,11 +260,11 @@ func parseKernelInetAddr(af int, b []byte) (int, Addr, error) {
|
||||
off6 = 8 // offset of in6_addr
|
||||
)
|
||||
switch {
|
||||
case b[0] == unix.SizeofSockaddrInet6:
|
||||
case b[0] == sizeofSockaddrInet6:
|
||||
a := &Inet6Addr{}
|
||||
copy(a.IP[:], b[off6:off6+16])
|
||||
return int(b[0]), a, nil
|
||||
case af == unix.AF_INET6:
|
||||
case af == syscall.AF_INET6:
|
||||
a := &Inet6Addr{}
|
||||
if l-1 < off6 {
|
||||
copy(a.IP[:], b[1:l])
|
||||
@@ -273,7 +272,7 @@ func parseKernelInetAddr(af int, b []byte) (int, Addr, error) {
|
||||
copy(a.IP[:], b[l-off6:l])
|
||||
}
|
||||
return int(b[0]), a, nil
|
||||
case b[0] == unix.SizeofSockaddrInet4:
|
||||
case b[0] == sizeofSockaddrInet:
|
||||
a := &Inet4Addr{}
|
||||
copy(a.IP[:], b[off4:off4+4])
|
||||
return int(b[0]), a, nil
|
||||
@@ -385,15 +384,15 @@ func marshalAddrs(b []byte, as []Addr) (uint, error) {
|
||||
}
|
||||
|
||||
func parseAddrs(attrs uint, fn func(int, []byte) (int, Addr, error), b []byte) ([]Addr, error) {
|
||||
var as [unix.RTAX_MAX]Addr
|
||||
af := int(unix.AF_UNSPEC)
|
||||
for i := uint(0); i < unix.RTAX_MAX && len(b) >= roundup(0); i++ {
|
||||
var as [syscall.RTAX_MAX]Addr
|
||||
af := int(syscall.AF_UNSPEC)
|
||||
for i := uint(0); i < syscall.RTAX_MAX && len(b) >= roundup(0); i++ {
|
||||
if attrs&(1<<i) == 0 {
|
||||
continue
|
||||
}
|
||||
if i <= unix.RTAX_BRD {
|
||||
if i <= syscall.RTAX_BRD {
|
||||
switch b[1] {
|
||||
case unix.AF_LINK:
|
||||
case syscall.AF_LINK:
|
||||
a, err := parseLinkAddr(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -404,7 +403,7 @@ func parseAddrs(attrs uint, fn func(int, []byte) (int, Addr, error), b []byte) (
|
||||
return nil, errMessageTooShort
|
||||
}
|
||||
b = b[l:]
|
||||
case unix.AF_INET, unix.AF_INET6:
|
||||
case syscall.AF_INET, syscall.AF_INET6:
|
||||
// #70528: if the sockaddrlen is 0, no address to parse inside,
|
||||
// skip over the record.
|
||||
if b[0] > 0 {
|
||||
|
||||
@@ -6,9 +6,8 @@ package route
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"syscall"
|
||||
"testing"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
type parseAddrsOnDarwinTest struct {
|
||||
@@ -20,7 +19,7 @@ type parseAddrsOnDarwinTest struct {
|
||||
|
||||
var parseAddrsOnDarwinLittleEndianTests = []parseAddrsOnDarwinTest{
|
||||
{
|
||||
unix.RTA_DST | unix.RTA_GATEWAY | unix.RTA_NETMASK,
|
||||
syscall.RTA_DST | syscall.RTA_GATEWAY | syscall.RTA_NETMASK,
|
||||
parseKernelInetAddr,
|
||||
[]byte{
|
||||
0x10, 0x2, 0x0, 0x0, 0xc0, 0xa8, 0x56, 0x0,
|
||||
@@ -44,7 +43,7 @@ var parseAddrsOnDarwinLittleEndianTests = []parseAddrsOnDarwinTest{
|
||||
},
|
||||
},
|
||||
{
|
||||
unix.RTA_DST | unix.RTA_GATEWAY | unix.RTA_NETMASK,
|
||||
syscall.RTA_DST | syscall.RTA_GATEWAY | syscall.RTA_NETMASK,
|
||||
parseKernelInetAddr,
|
||||
[]byte{
|
||||
0x10, 0x02, 0x00, 0x00, 0x64, 0x71, 0x00, 0x00,
|
||||
@@ -70,7 +69,7 @@ var parseAddrsOnDarwinLittleEndianTests = []parseAddrsOnDarwinTest{
|
||||
// route -n add -inet6 fd84:1b4e:6281:: -prefixlen 48 fe80::f22f:4bff:fe09:3bff%utun4319
|
||||
// gw fe80:0000:0000:0000:f22f:4bff:fe09:3bff
|
||||
{
|
||||
unix.RTA_DST | unix.RTA_GATEWAY | unix.RTA_NETMASK,
|
||||
syscall.RTA_DST | syscall.RTA_GATEWAY | syscall.RTA_NETMASK,
|
||||
parseKernelInetAddr,
|
||||
[]byte{
|
||||
0x1c, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
@@ -99,7 +98,7 @@ var parseAddrsOnDarwinLittleEndianTests = []parseAddrsOnDarwinTest{
|
||||
},
|
||||
// golang/go#70528, the kernel can produce addresses of length 0
|
||||
{
|
||||
unix.RTA_DST | unix.RTA_GATEWAY | unix.RTA_NETMASK,
|
||||
syscall.RTA_DST | syscall.RTA_GATEWAY | syscall.RTA_NETMASK,
|
||||
parseKernelInetAddr,
|
||||
[]byte{
|
||||
0x00, 0x1e, 0x00, 0x00,
|
||||
@@ -125,7 +124,7 @@ var parseAddrsOnDarwinLittleEndianTests = []parseAddrsOnDarwinTest{
|
||||
},
|
||||
// Additional case: golang/go/issues/70528#issuecomment-2498692877
|
||||
{
|
||||
unix.RTA_DST | unix.RTA_GATEWAY | unix.RTA_NETMASK,
|
||||
syscall.RTA_DST | syscall.RTA_GATEWAY | syscall.RTA_NETMASK,
|
||||
parseKernelInetAddr,
|
||||
[]byte{
|
||||
0x84, 0x00, 0x05, 0x04, 0x01, 0x00, 0x00, 0x00, 0x03, 0x08, 0x00, 0x01, 0x15, 0x00, 0x00, 0x00,
|
||||
|
||||
@@ -8,9 +8,8 @@ package route
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"syscall"
|
||||
"testing"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
type parseAddrsTest struct {
|
||||
@@ -22,7 +21,7 @@ type parseAddrsTest struct {
|
||||
|
||||
var parseAddrsLittleEndianTests = []parseAddrsTest{
|
||||
{
|
||||
unix.RTA_DST | unix.RTA_GATEWAY | unix.RTA_NETMASK | unix.RTA_BRD,
|
||||
syscall.RTA_DST | syscall.RTA_GATEWAY | syscall.RTA_NETMASK | syscall.RTA_BRD,
|
||||
parseKernelInetAddr,
|
||||
[]byte{
|
||||
0x38, 0x12, 0x0, 0x0, 0xff, 0xff, 0xff, 0x0,
|
||||
@@ -59,7 +58,7 @@ var parseAddrsLittleEndianTests = []parseAddrsTest{
|
||||
},
|
||||
},
|
||||
{
|
||||
unix.RTA_NETMASK | unix.RTA_IFP | unix.RTA_IFA,
|
||||
syscall.RTA_NETMASK | syscall.RTA_IFP | syscall.RTA_IFA,
|
||||
parseKernelInetAddr,
|
||||
[]byte{
|
||||
0x7, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0x0,
|
||||
|
||||
@@ -19,8 +19,19 @@ package route
|
||||
import "C"
|
||||
|
||||
const (
|
||||
sizeofIfMsghdr2Darwin15 = C.sizeof_struct_if_msghdr2
|
||||
sizeofIfData64Darwin15 = C.sizeof_struct_if_data64
|
||||
sizeofIfMsghdrDarwin15 = C.sizeof_struct_if_msghdr
|
||||
sizeofIfaMsghdrDarwin15 = C.sizeof_struct_ifa_msghdr
|
||||
sizeofIfmaMsghdrDarwin15 = C.sizeof_struct_ifma_msghdr
|
||||
sizeofIfMsghdr2Darwin15 = C.sizeof_struct_if_msghdr2
|
||||
sizeofIfmaMsghdr2Darwin15 = C.sizeof_struct_ifma_msghdr2
|
||||
sizeofIfDataDarwin15 = C.sizeof_struct_if_data
|
||||
sizeofIfData64Darwin15 = C.sizeof_struct_if_data64
|
||||
|
||||
sizeofRtMsghdrDarwin15 = C.sizeof_struct_rt_msghdr
|
||||
sizeofRtMsghdr2Darwin15 = C.sizeof_struct_rt_msghdr2
|
||||
sizeofRtMetricsDarwin15 = C.sizeof_struct_rt_metrics
|
||||
|
||||
sizeofSockaddrStorage = C.sizeof_struct_sockaddr_storage
|
||||
sizeofSockaddrInet = C.sizeof_struct_sockaddr_in
|
||||
sizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
|
||||
)
|
||||
|
||||
56
route/defs_dragonfly.go
Normal file
56
route/defs_dragonfly.go
Normal file
@@ -0,0 +1,56 @@
|
||||
// Copyright 2016 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.
|
||||
|
||||
//go:build ignore
|
||||
|
||||
package route
|
||||
|
||||
/*
|
||||
#include <sys/socket.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/route.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
||||
struct ifa_msghdr_dfly4 {
|
||||
u_short ifam_msglen;
|
||||
u_char ifam_version;
|
||||
u_char ifam_type;
|
||||
int ifam_addrs;
|
||||
int ifam_flags;
|
||||
u_short ifam_index;
|
||||
int ifam_metric;
|
||||
};
|
||||
|
||||
struct ifa_msghdr_dfly58 {
|
||||
u_short ifam_msglen;
|
||||
u_char ifam_version;
|
||||
u_char ifam_type;
|
||||
u_short ifam_index;
|
||||
int ifam_flags;
|
||||
int ifam_addrs;
|
||||
int ifam_addrflags;
|
||||
int ifam_metric;
|
||||
};
|
||||
*/
|
||||
import "C"
|
||||
|
||||
const (
|
||||
sizeofIfMsghdrDragonFlyBSD4 = C.sizeof_struct_if_msghdr
|
||||
sizeofIfaMsghdrDragonFlyBSD4 = C.sizeof_struct_ifa_msghdr_dfly4
|
||||
sizeofIfmaMsghdrDragonFlyBSD4 = C.sizeof_struct_ifma_msghdr
|
||||
sizeofIfAnnouncemsghdrDragonFlyBSD4 = C.sizeof_struct_if_announcemsghdr
|
||||
|
||||
sizeofIfaMsghdrDragonFlyBSD58 = C.sizeof_struct_ifa_msghdr_dfly58
|
||||
|
||||
sizeofRtMsghdrDragonFlyBSD4 = C.sizeof_struct_rt_msghdr
|
||||
sizeofRtMetricsDragonFlyBSD4 = C.sizeof_struct_rt_metrics
|
||||
|
||||
sizeofSockaddrStorage = C.sizeof_struct_sockaddr_storage
|
||||
sizeofSockaddrInet = C.sizeof_struct_sockaddr_in
|
||||
sizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
|
||||
)
|
||||
@@ -218,6 +218,12 @@ struct if_msghdr_freebsd11 {
|
||||
import "C"
|
||||
|
||||
const (
|
||||
sizeofIfMsghdrlFreeBSD10 = C.sizeof_struct_if_msghdrl
|
||||
sizeofIfaMsghdrFreeBSD10 = C.sizeof_struct_ifa_msghdr
|
||||
sizeofIfaMsghdrlFreeBSD10 = C.sizeof_struct_ifa_msghdrl
|
||||
sizeofIfmaMsghdrFreeBSD10 = C.sizeof_struct_ifma_msghdr
|
||||
sizeofIfAnnouncemsghdrFreeBSD10 = C.sizeof_struct_if_announcemsghdr
|
||||
|
||||
sizeofRtMsghdrFreeBSD10 = C.sizeof_struct_rt_msghdr
|
||||
sizeofRtMetricsFreeBSD10 = C.sizeof_struct_rt_metrics
|
||||
|
||||
@@ -233,6 +239,12 @@ const (
|
||||
sizeofIfDataFreeBSD10 = C.sizeof_struct_if_data_freebsd10
|
||||
sizeofIfDataFreeBSD11 = C.sizeof_struct_if_data_freebsd11
|
||||
|
||||
sizeofIfMsghdrlFreeBSD10Emu = C.sizeof_struct_if_msghdrl
|
||||
sizeofIfaMsghdrFreeBSD10Emu = C.sizeof_struct_ifa_msghdr
|
||||
sizeofIfaMsghdrlFreeBSD10Emu = C.sizeof_struct_ifa_msghdrl
|
||||
sizeofIfmaMsghdrFreeBSD10Emu = C.sizeof_struct_ifma_msghdr
|
||||
sizeofIfAnnouncemsghdrFreeBSD10Emu = C.sizeof_struct_if_announcemsghdr
|
||||
|
||||
sizeofRtMsghdrFreeBSD10Emu = C.sizeof_struct_rt_msghdr
|
||||
sizeofRtMetricsFreeBSD10Emu = C.sizeof_struct_rt_metrics
|
||||
|
||||
|
||||
32
route/defs_netbsd.go
Normal file
32
route/defs_netbsd.go
Normal file
@@ -0,0 +1,32 @@
|
||||
// Copyright 2016 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.
|
||||
|
||||
//go:build ignore
|
||||
|
||||
package route
|
||||
|
||||
/*
|
||||
#include <sys/socket.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/route.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
const (
|
||||
sizeofIfMsghdrNetBSD7 = C.sizeof_struct_if_msghdr
|
||||
sizeofIfaMsghdrNetBSD7 = C.sizeof_struct_ifa_msghdr
|
||||
sizeofIfAnnouncemsghdrNetBSD7 = C.sizeof_struct_if_announcemsghdr
|
||||
|
||||
sizeofRtMsghdrNetBSD7 = C.sizeof_struct_rt_msghdr
|
||||
sizeofRtMetricsNetBSD7 = C.sizeof_struct_rt_metrics
|
||||
|
||||
sizeofSockaddrStorage = C.sizeof_struct_sockaddr_storage
|
||||
sizeofSockaddrInet = C.sizeof_struct_sockaddr_in
|
||||
sizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
|
||||
)
|
||||
27
route/defs_openbsd.go
Normal file
27
route/defs_openbsd.go
Normal file
@@ -0,0 +1,27 @@
|
||||
// Copyright 2016 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.
|
||||
|
||||
//go:build ignore
|
||||
|
||||
package route
|
||||
|
||||
/*
|
||||
#include <sys/socket.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/route.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
const (
|
||||
sizeofRtMsghdr = C.sizeof_struct_rt_msghdr
|
||||
|
||||
sizeofSockaddrStorage = C.sizeof_struct_sockaddr_storage
|
||||
sizeofSockaddrInet = C.sizeof_struct_sockaddr_in
|
||||
sizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
|
||||
)
|
||||
@@ -8,8 +8,7 @@ package route
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func (w *wireFormat) parseInterfaceMessage(_ RIBType, b []byte) (Message, error) {
|
||||
@@ -21,13 +20,13 @@ func (w *wireFormat) parseInterfaceMessage(_ RIBType, b []byte) (Message, error)
|
||||
return nil, errInvalidMessage
|
||||
}
|
||||
attrs := uint(nativeEndian.Uint32(b[4:8]))
|
||||
if attrs&unix.RTA_IFP == 0 {
|
||||
if attrs&syscall.RTA_IFP == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
m := &InterfaceMessage{
|
||||
Version: int(b[2]),
|
||||
Type: int(b[3]),
|
||||
Addrs: make([]Addr, unix.RTAX_MAX),
|
||||
Addrs: make([]Addr, syscall.RTAX_MAX),
|
||||
Flags: int(nativeEndian.Uint32(b[8:12])),
|
||||
Index: int(nativeEndian.Uint16(b[12:14])),
|
||||
extOff: w.extOff,
|
||||
@@ -37,7 +36,7 @@ func (w *wireFormat) parseInterfaceMessage(_ RIBType, b []byte) (Message, error)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
m.Addrs[unix.RTAX_IFP] = a
|
||||
m.Addrs[syscall.RTAX_IFP] = a
|
||||
m.Name = a.(*LinkAddr).Name
|
||||
return m, nil
|
||||
}
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
|
||||
package route
|
||||
|
||||
import "golang.org/x/sys/unix"
|
||||
import "syscall"
|
||||
|
||||
func (w *wireFormat) parseInterfaceMessage(typ RIBType, b []byte) (Message, error) {
|
||||
var extOff, bodyOff int
|
||||
if typ == unix.NET_RT_IFLISTL {
|
||||
if typ == syscall.NET_RT_IFLISTL {
|
||||
if len(b) < 20 {
|
||||
return nil, errMessageTooShort
|
||||
}
|
||||
@@ -26,7 +26,7 @@ func (w *wireFormat) parseInterfaceMessage(typ RIBType, b []byte) (Message, erro
|
||||
return nil, errInvalidMessage
|
||||
}
|
||||
attrs := uint(nativeEndian.Uint32(b[4:8]))
|
||||
if attrs&unix.RTA_IFP == 0 {
|
||||
if attrs&syscall.RTA_IFP == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
m := &InterfaceMessage{
|
||||
@@ -34,7 +34,7 @@ func (w *wireFormat) parseInterfaceMessage(typ RIBType, b []byte) (Message, erro
|
||||
Type: int(b[3]),
|
||||
Flags: int(nativeEndian.Uint32(b[8:12])),
|
||||
Index: int(nativeEndian.Uint16(b[12:14])),
|
||||
Addrs: make([]Addr, unix.RTAX_MAX),
|
||||
Addrs: make([]Addr, syscall.RTAX_MAX),
|
||||
extOff: extOff,
|
||||
raw: b[:l],
|
||||
}
|
||||
@@ -42,14 +42,14 @@ func (w *wireFormat) parseInterfaceMessage(typ RIBType, b []byte) (Message, erro
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
m.Addrs[unix.RTAX_IFP] = a
|
||||
m.Addrs[syscall.RTAX_IFP] = a
|
||||
m.Name = a.(*LinkAddr).Name
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (w *wireFormat) parseInterfaceAddrMessage(typ RIBType, b []byte) (Message, error) {
|
||||
var bodyOff int
|
||||
if typ == unix.NET_RT_IFLISTL {
|
||||
if typ == syscall.NET_RT_IFLISTL {
|
||||
if len(b) < 24 {
|
||||
return nil, errMessageTooShort
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
package route
|
||||
|
||||
import "golang.org/x/sys/unix"
|
||||
import "syscall"
|
||||
|
||||
func (*wireFormat) parseInterfaceMessage(_ RIBType, b []byte) (Message, error) {
|
||||
if len(b) < 32 {
|
||||
@@ -15,7 +15,7 @@ func (*wireFormat) parseInterfaceMessage(_ RIBType, b []byte) (Message, error) {
|
||||
return nil, errInvalidMessage
|
||||
}
|
||||
attrs := uint(nativeEndian.Uint32(b[12:16]))
|
||||
if attrs&unix.RTA_IFP == 0 {
|
||||
if attrs&syscall.RTA_IFP == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
m := &InterfaceMessage{
|
||||
@@ -23,7 +23,7 @@ func (*wireFormat) parseInterfaceMessage(_ RIBType, b []byte) (Message, error) {
|
||||
Type: int(b[3]),
|
||||
Flags: int(nativeEndian.Uint32(b[16:20])),
|
||||
Index: int(nativeEndian.Uint16(b[6:8])),
|
||||
Addrs: make([]Addr, unix.RTAX_MAX),
|
||||
Addrs: make([]Addr, syscall.RTAX_MAX),
|
||||
raw: b[:l],
|
||||
}
|
||||
ll := int(nativeEndian.Uint16(b[4:6]))
|
||||
@@ -34,7 +34,7 @@ func (*wireFormat) parseInterfaceMessage(_ RIBType, b []byte) (Message, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
m.Addrs[unix.RTAX_IFP] = a
|
||||
m.Addrs[syscall.RTAX_IFP] = a
|
||||
m.Name = a.(*LinkAddr).Name
|
||||
return m, nil
|
||||
}
|
||||
|
||||
@@ -5,16 +5,15 @@
|
||||
package route
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"testing"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func TestFetchAndParseRIBOnDarwin(t *testing.T) {
|
||||
for _, typ := range []RIBType{unix.NET_RT_FLAGS, unix.NET_RT_DUMP2, unix.NET_RT_IFLIST2} {
|
||||
for _, typ := range []RIBType{syscall.NET_RT_FLAGS, syscall.NET_RT_DUMP2, syscall.NET_RT_IFLIST2} {
|
||||
var lastErr error
|
||||
var ms []Message
|
||||
for _, af := range []int{unix.AF_UNSPEC, unix.AF_INET, unix.AF_INET6} {
|
||||
for _, af := range []int{syscall.AF_UNSPEC, syscall.AF_INET, syscall.AF_INET6} {
|
||||
rs, err := fetchAndParseRIB(af, typ)
|
||||
if err != nil {
|
||||
lastErr = err
|
||||
|
||||
@@ -5,16 +5,15 @@
|
||||
package route
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"testing"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func TestFetchAndParseRIBOnFreeBSD(t *testing.T) {
|
||||
for _, typ := range []RIBType{unix.NET_RT_IFMALIST} {
|
||||
for _, typ := range []RIBType{syscall.NET_RT_IFMALIST} {
|
||||
var lastErr error
|
||||
var ms []Message
|
||||
for _, af := range []int{unix.AF_UNSPEC, unix.AF_INET, unix.AF_INET6} {
|
||||
for _, af := range []int{syscall.AF_UNSPEC, syscall.AF_INET, syscall.AF_INET6} {
|
||||
rs, err := fetchAndParseRIB(af, typ)
|
||||
if err != nil {
|
||||
lastErr = err
|
||||
@@ -38,7 +37,7 @@ func TestFetchAndParseRIBOnFreeBSD(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFetchAndParseRIBOnFreeBSD10AndAbove(t *testing.T) {
|
||||
if _, err := FetchRIB(unix.AF_UNSPEC, unix.NET_RT_IFLISTL, 0); err != nil {
|
||||
if _, err := FetchRIB(syscall.AF_UNSPEC, syscall.NET_RT_IFLISTL, 0); err != nil {
|
||||
t.Skip("NET_RT_IFLISTL not supported")
|
||||
}
|
||||
if compatFreeBSD32 {
|
||||
@@ -51,12 +50,12 @@ func TestFetchAndParseRIBOnFreeBSD10AndAbove(t *testing.T) {
|
||||
msgs []Message
|
||||
ss []string
|
||||
}{
|
||||
{typ: unix.NET_RT_IFLIST},
|
||||
{typ: unix.NET_RT_IFLISTL},
|
||||
{typ: syscall.NET_RT_IFLIST},
|
||||
{typ: syscall.NET_RT_IFLISTL},
|
||||
}
|
||||
for i := range tests {
|
||||
var lastErr error
|
||||
for _, af := range []int{unix.AF_UNSPEC, unix.AF_INET, unix.AF_INET6} {
|
||||
for _, af := range []int{syscall.AF_UNSPEC, syscall.AF_INET, syscall.AF_INET6} {
|
||||
rs, err := fetchAndParseRIB(af, tests[i].typ)
|
||||
if err != nil {
|
||||
lastErr = err
|
||||
|
||||
@@ -8,17 +8,16 @@ package route
|
||||
|
||||
import (
|
||||
"os"
|
||||
"syscall"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func TestFetchAndParseRIB(t *testing.T) {
|
||||
for _, typ := range []RIBType{unix.NET_RT_DUMP, unix.NET_RT_IFLIST} {
|
||||
for _, typ := range []RIBType{syscall.NET_RT_DUMP, syscall.NET_RT_IFLIST} {
|
||||
var lastErr error
|
||||
var ms []Message
|
||||
for _, af := range []int{unix.AF_UNSPEC, unix.AF_INET, unix.AF_INET6} {
|
||||
for _, af := range []int{syscall.AF_UNSPEC, syscall.AF_INET, syscall.AF_INET6} {
|
||||
rs, err := fetchAndParseRIB(af, typ)
|
||||
if err != nil {
|
||||
lastErr = err
|
||||
@@ -49,7 +48,7 @@ var (
|
||||
func init() {
|
||||
// We need to keep rtmonSock alive to avoid treading on
|
||||
// recycled socket descriptors.
|
||||
rtmonSock, rtmonErr = unix.Socket(unix.AF_ROUTE, unix.SOCK_RAW, unix.AF_UNSPEC)
|
||||
rtmonSock, rtmonErr = syscall.Socket(syscall.AF_ROUTE, syscall.SOCK_RAW, syscall.AF_UNSPEC)
|
||||
}
|
||||
|
||||
// TestMonitorAndParseRIB leaks a worker goroutine and a socket
|
||||
@@ -85,7 +84,7 @@ func TestMonitorAndParseRIB(t *testing.T) {
|
||||
// use the net package of standard library due
|
||||
// to the lack of support for routing socket
|
||||
// and circular dependency.
|
||||
n, err := unix.Read(rtmonSock, b)
|
||||
n, err := syscall.Read(rtmonSock, b)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -145,60 +144,60 @@ func TestParseRIBWithFuzz(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRouteMessage(t *testing.T) {
|
||||
s, err := unix.Socket(unix.AF_ROUTE, unix.SOCK_RAW, unix.AF_UNSPEC)
|
||||
s, err := syscall.Socket(syscall.AF_ROUTE, syscall.SOCK_RAW, syscall.AF_UNSPEC)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer unix.Close(s)
|
||||
defer syscall.Close(s)
|
||||
|
||||
var ms []RouteMessage
|
||||
for _, af := range []int{unix.AF_INET, unix.AF_INET6} {
|
||||
if _, err := fetchAndParseRIB(af, unix.NET_RT_DUMP); err != nil {
|
||||
for _, af := range []int{syscall.AF_INET, syscall.AF_INET6} {
|
||||
if _, err := fetchAndParseRIB(af, syscall.NET_RT_DUMP); err != nil {
|
||||
t.Log(err)
|
||||
continue
|
||||
}
|
||||
switch af {
|
||||
case unix.AF_INET:
|
||||
case syscall.AF_INET:
|
||||
ms = append(ms, []RouteMessage{
|
||||
{
|
||||
Type: unix.RTM_GET,
|
||||
Type: syscall.RTM_GET,
|
||||
Addrs: []Addr{
|
||||
unix.RTAX_DST: &Inet4Addr{IP: [4]byte{127, 0, 0, 1}},
|
||||
unix.RTAX_GATEWAY: nil,
|
||||
unix.RTAX_NETMASK: nil,
|
||||
unix.RTAX_GENMASK: nil,
|
||||
unix.RTAX_IFP: &LinkAddr{},
|
||||
unix.RTAX_IFA: &Inet4Addr{},
|
||||
unix.RTAX_AUTHOR: nil,
|
||||
unix.RTAX_BRD: &Inet4Addr{},
|
||||
syscall.RTAX_DST: &Inet4Addr{IP: [4]byte{127, 0, 0, 1}},
|
||||
syscall.RTAX_GATEWAY: nil,
|
||||
syscall.RTAX_NETMASK: nil,
|
||||
syscall.RTAX_GENMASK: nil,
|
||||
syscall.RTAX_IFP: &LinkAddr{},
|
||||
syscall.RTAX_IFA: &Inet4Addr{},
|
||||
syscall.RTAX_AUTHOR: nil,
|
||||
syscall.RTAX_BRD: &Inet4Addr{},
|
||||
},
|
||||
},
|
||||
{
|
||||
Type: unix.RTM_GET,
|
||||
Type: syscall.RTM_GET,
|
||||
Addrs: []Addr{
|
||||
unix.RTAX_DST: &Inet4Addr{IP: [4]byte{127, 0, 0, 1}},
|
||||
syscall.RTAX_DST: &Inet4Addr{IP: [4]byte{127, 0, 0, 1}},
|
||||
},
|
||||
},
|
||||
}...)
|
||||
case unix.AF_INET6:
|
||||
case syscall.AF_INET6:
|
||||
ms = append(ms, []RouteMessage{
|
||||
{
|
||||
Type: unix.RTM_GET,
|
||||
Type: syscall.RTM_GET,
|
||||
Addrs: []Addr{
|
||||
unix.RTAX_DST: &Inet6Addr{IP: [16]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}},
|
||||
unix.RTAX_GATEWAY: nil,
|
||||
unix.RTAX_NETMASK: nil,
|
||||
unix.RTAX_GENMASK: nil,
|
||||
unix.RTAX_IFP: &LinkAddr{},
|
||||
unix.RTAX_IFA: &Inet6Addr{},
|
||||
unix.RTAX_AUTHOR: nil,
|
||||
unix.RTAX_BRD: &Inet6Addr{},
|
||||
syscall.RTAX_DST: &Inet6Addr{IP: [16]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}},
|
||||
syscall.RTAX_GATEWAY: nil,
|
||||
syscall.RTAX_NETMASK: nil,
|
||||
syscall.RTAX_GENMASK: nil,
|
||||
syscall.RTAX_IFP: &LinkAddr{},
|
||||
syscall.RTAX_IFA: &Inet6Addr{},
|
||||
syscall.RTAX_AUTHOR: nil,
|
||||
syscall.RTAX_BRD: &Inet6Addr{},
|
||||
},
|
||||
},
|
||||
{
|
||||
Type: unix.RTM_GET,
|
||||
Type: syscall.RTM_GET,
|
||||
Addrs: []Addr{
|
||||
unix.RTAX_DST: &Inet6Addr{IP: [16]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}},
|
||||
syscall.RTAX_DST: &Inet6Addr{IP: [16]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}},
|
||||
},
|
||||
},
|
||||
}...)
|
||||
@@ -211,11 +210,11 @@ func TestRouteMessage(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("%v: %v", m, err)
|
||||
}
|
||||
if _, err := unix.Write(s, wb); err != nil {
|
||||
if _, err := syscall.Write(s, wb); err != nil {
|
||||
t.Fatalf("%v: %v", m, err)
|
||||
}
|
||||
rb := make([]byte, os.Getpagesize())
|
||||
n, err := unix.Read(s, rb)
|
||||
n, err := syscall.Read(s, rb)
|
||||
if err != nil {
|
||||
t.Fatalf("%v: %v", m, err)
|
||||
}
|
||||
|
||||
@@ -15,8 +15,7 @@ package route
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -93,8 +92,8 @@ func (m *RouteMessage) Marshal() ([]byte, error) {
|
||||
type RIBType int
|
||||
|
||||
const (
|
||||
RIBTypeRoute RIBType = unix.NET_RT_DUMP
|
||||
RIBTypeInterface RIBType = unix.NET_RT_IFLIST
|
||||
RIBTypeRoute RIBType = syscall.NET_RT_DUMP
|
||||
RIBTypeInterface RIBType = syscall.NET_RT_IFLIST
|
||||
)
|
||||
|
||||
// FetchRIB fetches a routing information base from the operating
|
||||
@@ -111,7 +110,7 @@ func FetchRIB(af int, typ RIBType, arg int) ([]byte, error) {
|
||||
try := 0
|
||||
for {
|
||||
try++
|
||||
mib := [6]int32{unix.CTL_NET, unix.AF_ROUTE, 0, int32(af), int32(typ), int32(arg)}
|
||||
mib := [6]int32{syscall.CTL_NET, syscall.AF_ROUTE, 0, int32(af), int32(typ), int32(arg)}
|
||||
n := uintptr(0)
|
||||
if err := sysctl(mib[:], nil, &n, nil, 0); err != nil {
|
||||
return nil, os.NewSyscallError("sysctl", err)
|
||||
@@ -125,7 +124,7 @@ func FetchRIB(af int, typ RIBType, arg int) ([]byte, error) {
|
||||
// between the two sysctl calls, try a few times
|
||||
// before failing. (golang.org/issue/45736).
|
||||
const maxTries = 3
|
||||
if err == unix.ENOMEM && try < maxTries {
|
||||
if err == syscall.ENOMEM && try < maxTries {
|
||||
continue
|
||||
}
|
||||
return nil, os.NewSyscallError("sysctl", err)
|
||||
|
||||
@@ -8,8 +8,7 @@ package route
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func (m *RouteMessage) marshal() ([]byte, error) {
|
||||
@@ -63,7 +62,7 @@ func (w *wireFormat) parseRouteMessage(typ RIBType, b []byte) (Message, error) {
|
||||
extOff: w.extOff,
|
||||
raw: b[:l],
|
||||
}
|
||||
errno := unix.Errno(nativeEndian.Uint32(b[28:32]))
|
||||
errno := syscall.Errno(nativeEndian.Uint32(b[28:32]))
|
||||
if errno != 0 {
|
||||
m.Err = errno
|
||||
}
|
||||
|
||||
@@ -5,25 +5,25 @@
|
||||
package route
|
||||
|
||||
import (
|
||||
"golang.org/x/sys/unix"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func (m *RouteMessage) marshal() ([]byte, error) {
|
||||
l := unix.SizeofRtMsghdr + addrsSpace(m.Addrs)
|
||||
l := sizeofRtMsghdr + addrsSpace(m.Addrs)
|
||||
b := make([]byte, l)
|
||||
nativeEndian.PutUint16(b[:2], uint16(l))
|
||||
if m.Version == 0 {
|
||||
b[2] = unix.RTM_VERSION
|
||||
b[2] = syscall.RTM_VERSION
|
||||
} else {
|
||||
b[2] = byte(m.Version)
|
||||
}
|
||||
b[3] = byte(m.Type)
|
||||
nativeEndian.PutUint16(b[4:6], uint16(unix.SizeofRtMsghdr))
|
||||
nativeEndian.PutUint16(b[4:6], uint16(sizeofRtMsghdr))
|
||||
nativeEndian.PutUint32(b[16:20], uint32(m.Flags))
|
||||
nativeEndian.PutUint16(b[6:8], uint16(m.Index))
|
||||
nativeEndian.PutUint32(b[24:28], uint32(m.ID))
|
||||
nativeEndian.PutUint32(b[28:32], uint32(m.Seq))
|
||||
attrs, err := marshalAddrs(b[unix.SizeofRtMsghdr:], m.Addrs)
|
||||
attrs, err := marshalAddrs(b[sizeofRtMsghdr:], m.Addrs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -34,7 +34,7 @@ func (m *RouteMessage) marshal() ([]byte, error) {
|
||||
}
|
||||
|
||||
func (*wireFormat) parseRouteMessage(_ RIBType, b []byte) (Message, error) {
|
||||
if len(b) < unix.SizeofRtMsghdr {
|
||||
if len(b) < sizeofRtMsghdr {
|
||||
return nil, errMessageTooShort
|
||||
}
|
||||
l := int(nativeEndian.Uint16(b[:2]))
|
||||
@@ -54,7 +54,7 @@ func (*wireFormat) parseRouteMessage(_ RIBType, b []byte) (Message, error) {
|
||||
if len(b) < ll {
|
||||
return nil, errInvalidMessage
|
||||
}
|
||||
errno := unix.Errno(nativeEndian.Uint32(b[32:36]))
|
||||
errno := syscall.Errno(nativeEndian.Uint32(b[32:36]))
|
||||
if errno != 0 {
|
||||
m.Err = errno
|
||||
}
|
||||
|
||||
@@ -10,8 +10,7 @@ import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func (m *RouteMessage) String() string {
|
||||
@@ -177,13 +176,13 @@ type addrFamily int
|
||||
|
||||
func (af addrFamily) String() string {
|
||||
switch af {
|
||||
case unix.AF_UNSPEC:
|
||||
case syscall.AF_UNSPEC:
|
||||
return "unspec"
|
||||
case unix.AF_LINK:
|
||||
case syscall.AF_LINK:
|
||||
return "link"
|
||||
case unix.AF_INET:
|
||||
case syscall.AF_INET:
|
||||
return "inet4"
|
||||
case unix.AF_INET6:
|
||||
case syscall.AF_INET6:
|
||||
return "inet6"
|
||||
default:
|
||||
return fmt.Sprintf("%d", af)
|
||||
@@ -282,24 +281,24 @@ func (as addrs) String() string {
|
||||
|
||||
func (as addrs) match(attrs addrAttrs) error {
|
||||
var ts addrAttrs
|
||||
af := unix.AF_UNSPEC
|
||||
af := syscall.AF_UNSPEC
|
||||
for i := range as {
|
||||
if as[i] != nil {
|
||||
ts |= 1 << uint(i)
|
||||
}
|
||||
switch as[i].(type) {
|
||||
case *Inet4Addr:
|
||||
if af == unix.AF_UNSPEC {
|
||||
af = unix.AF_INET
|
||||
if af == syscall.AF_UNSPEC {
|
||||
af = syscall.AF_INET
|
||||
}
|
||||
if af != unix.AF_INET {
|
||||
if af != syscall.AF_INET {
|
||||
return fmt.Errorf("got %v; want %v", addrs(as), addrFamily(af))
|
||||
}
|
||||
case *Inet6Addr:
|
||||
if af == unix.AF_UNSPEC {
|
||||
af = unix.AF_INET6
|
||||
if af == syscall.AF_UNSPEC {
|
||||
af = syscall.AF_INET6
|
||||
}
|
||||
if af != unix.AF_INET6 {
|
||||
if af != syscall.AF_INET6 {
|
||||
return fmt.Errorf("got %v; want %v", addrs(as), addrFamily(af))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
package route
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -28,7 +27,7 @@ func init() {
|
||||
nativeEndian = bigEndian
|
||||
}
|
||||
// might get overridden in probeRoutingStack
|
||||
rtmVersion = unix.RTM_VERSION
|
||||
rtmVersion = syscall.RTM_VERSION
|
||||
kernelAlign, wireFormats = probeRoutingStack()
|
||||
}
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
|
||||
package route
|
||||
|
||||
import "golang.org/x/sys/unix"
|
||||
import "syscall"
|
||||
|
||||
func (typ RIBType) parseable() bool {
|
||||
switch typ {
|
||||
case unix.NET_RT_STAT, unix.NET_RT_TRASH:
|
||||
case syscall.NET_RT_STAT, syscall.NET_RT_TRASH:
|
||||
return false
|
||||
default:
|
||||
return true
|
||||
@@ -52,38 +52,38 @@ func (m *InterfaceMessage) Sys() []Sys {
|
||||
}
|
||||
|
||||
func probeRoutingStack() (int, map[int]*wireFormat) {
|
||||
rtm := &wireFormat{extOff: 36, bodyOff: unix.SizeofRtMsghdr}
|
||||
rtm := &wireFormat{extOff: 36, bodyOff: sizeofRtMsghdrDarwin15}
|
||||
rtm.parse = rtm.parseRouteMessage
|
||||
rtm2 := &wireFormat{extOff: 36, bodyOff: sizeofRtMsghdr2Darwin15}
|
||||
rtm2.parse = rtm2.parseRouteMessage
|
||||
ifm := &wireFormat{extOff: 16, bodyOff: unix.SizeofIfMsghdr}
|
||||
ifm := &wireFormat{extOff: 16, bodyOff: sizeofIfMsghdrDarwin15}
|
||||
ifm.parse = ifm.parseInterfaceMessage
|
||||
ifm2 := &wireFormat{extOff: 32, bodyOff: sizeofIfMsghdr2Darwin15}
|
||||
ifm2.parse = ifm2.parseInterfaceMessage
|
||||
ifam := &wireFormat{extOff: unix.SizeofIfaMsghdr, bodyOff: unix.SizeofIfaMsghdr}
|
||||
ifam := &wireFormat{extOff: sizeofIfaMsghdrDarwin15, bodyOff: sizeofIfaMsghdrDarwin15}
|
||||
ifam.parse = ifam.parseInterfaceAddrMessage
|
||||
ifmam := &wireFormat{extOff: unix.SizeofIfmaMsghdr, bodyOff: unix.SizeofIfmaMsghdr}
|
||||
ifmam := &wireFormat{extOff: sizeofIfmaMsghdrDarwin15, bodyOff: sizeofIfmaMsghdrDarwin15}
|
||||
ifmam.parse = ifmam.parseInterfaceMulticastAddrMessage
|
||||
ifmam2 := &wireFormat{extOff: unix.SizeofIfmaMsghdr2, bodyOff: unix.SizeofIfmaMsghdr2}
|
||||
ifmam2 := &wireFormat{extOff: sizeofIfmaMsghdr2Darwin15, bodyOff: sizeofIfmaMsghdr2Darwin15}
|
||||
ifmam2.parse = ifmam2.parseInterfaceMulticastAddrMessage
|
||||
// Darwin kernels require 32-bit aligned access to routing facilities.
|
||||
return 4, map[int]*wireFormat{
|
||||
unix.RTM_ADD: rtm,
|
||||
unix.RTM_DELETE: rtm,
|
||||
unix.RTM_CHANGE: rtm,
|
||||
unix.RTM_GET: rtm,
|
||||
unix.RTM_LOSING: rtm,
|
||||
unix.RTM_REDIRECT: rtm,
|
||||
unix.RTM_MISS: rtm,
|
||||
unix.RTM_LOCK: rtm,
|
||||
unix.RTM_RESOLVE: rtm,
|
||||
unix.RTM_NEWADDR: ifam,
|
||||
unix.RTM_DELADDR: ifam,
|
||||
unix.RTM_IFINFO: ifm,
|
||||
unix.RTM_NEWMADDR: ifmam,
|
||||
unix.RTM_DELMADDR: ifmam,
|
||||
unix.RTM_IFINFO2: ifm2,
|
||||
unix.RTM_NEWMADDR2: ifmam2,
|
||||
unix.RTM_GET2: rtm2,
|
||||
syscall.RTM_ADD: rtm,
|
||||
syscall.RTM_DELETE: rtm,
|
||||
syscall.RTM_CHANGE: rtm,
|
||||
syscall.RTM_GET: rtm,
|
||||
syscall.RTM_LOSING: rtm,
|
||||
syscall.RTM_REDIRECT: rtm,
|
||||
syscall.RTM_MISS: rtm,
|
||||
syscall.RTM_LOCK: rtm,
|
||||
syscall.RTM_RESOLVE: rtm,
|
||||
syscall.RTM_NEWADDR: ifam,
|
||||
syscall.RTM_DELADDR: ifam,
|
||||
syscall.RTM_IFINFO: ifm,
|
||||
syscall.RTM_NEWMADDR: ifmam,
|
||||
syscall.RTM_DELMADDR: ifmam,
|
||||
syscall.RTM_IFINFO2: ifm2,
|
||||
syscall.RTM_NEWMADDR2: ifmam2,
|
||||
syscall.RTM_GET2: rtm2,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,8 @@
|
||||
package route
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func (typ RIBType) parseable() bool { return true }
|
||||
@@ -50,42 +49,40 @@ func (m *InterfaceMessage) Sys() []Sys {
|
||||
|
||||
func probeRoutingStack() (int, map[int]*wireFormat) {
|
||||
var p uintptr
|
||||
rtm := &wireFormat{extOff: 40, bodyOff: unix.SizeofRtMsghdr}
|
||||
rtm := &wireFormat{extOff: 40, bodyOff: sizeofRtMsghdrDragonFlyBSD4}
|
||||
rtm.parse = rtm.parseRouteMessage
|
||||
ifm := &wireFormat{extOff: 16, bodyOff: unix.SizeofIfMsghdr}
|
||||
ifm := &wireFormat{extOff: 16, bodyOff: sizeofIfMsghdrDragonFlyBSD4}
|
||||
ifm.parse = ifm.parseInterfaceMessage
|
||||
ifam := &wireFormat{extOff: unix.SizeofIfmaMsghdr, bodyOff: unix.SizeofIfaMsghdr}
|
||||
ifam := &wireFormat{extOff: sizeofIfaMsghdrDragonFlyBSD4, bodyOff: sizeofIfaMsghdrDragonFlyBSD4}
|
||||
ifam.parse = ifam.parseInterfaceAddrMessage
|
||||
ifmam := &wireFormat{extOff: unix.SizeofIfmaMsghdr, bodyOff: unix.SizeofIfmaMsghdr}
|
||||
ifmam := &wireFormat{extOff: sizeofIfmaMsghdrDragonFlyBSD4, bodyOff: sizeofIfmaMsghdrDragonFlyBSD4}
|
||||
ifmam.parse = ifmam.parseInterfaceMulticastAddrMessage
|
||||
ifanm := &wireFormat{extOff: unix.SizeofIfAnnounceMsghdr, bodyOff: unix.SizeofIfAnnounceMsghdr}
|
||||
ifanm := &wireFormat{extOff: sizeofIfAnnouncemsghdrDragonFlyBSD4, bodyOff: sizeofIfAnnouncemsghdrDragonFlyBSD4}
|
||||
ifanm.parse = ifanm.parseInterfaceAnnounceMessage
|
||||
|
||||
rel, _ := unix.SysctlUint32("kern.osreldate")
|
||||
if rel < 500705 {
|
||||
rel, _ := syscall.SysctlUint32("kern.osreldate")
|
||||
if rel >= 500705 {
|
||||
// https://github.com/DragonFlyBSD/DragonFlyBSD/commit/43a373152df2d405c9940983e584e6a25e76632d
|
||||
// but only the size of struct ifa_msghdr actually changed.
|
||||
// The type is not in current header files,
|
||||
// so we just use constants here.
|
||||
// but only the size of struct ifa_msghdr actually changed
|
||||
rtmVersion = 7
|
||||
ifam.bodyOff = 0x14
|
||||
ifam.bodyOff = sizeofIfaMsghdrDragonFlyBSD58
|
||||
}
|
||||
|
||||
return int(unsafe.Sizeof(p)), map[int]*wireFormat{
|
||||
unix.RTM_ADD: rtm,
|
||||
unix.RTM_DELETE: rtm,
|
||||
unix.RTM_CHANGE: rtm,
|
||||
unix.RTM_GET: rtm,
|
||||
unix.RTM_LOSING: rtm,
|
||||
unix.RTM_REDIRECT: rtm,
|
||||
unix.RTM_MISS: rtm,
|
||||
unix.RTM_LOCK: rtm,
|
||||
unix.RTM_RESOLVE: rtm,
|
||||
unix.RTM_NEWADDR: ifam,
|
||||
unix.RTM_DELADDR: ifam,
|
||||
unix.RTM_IFINFO: ifm,
|
||||
unix.RTM_NEWMADDR: ifmam,
|
||||
unix.RTM_DELMADDR: ifmam,
|
||||
unix.RTM_IFANNOUNCE: ifanm,
|
||||
syscall.RTM_ADD: rtm,
|
||||
syscall.RTM_DELETE: rtm,
|
||||
syscall.RTM_CHANGE: rtm,
|
||||
syscall.RTM_GET: rtm,
|
||||
syscall.RTM_LOSING: rtm,
|
||||
syscall.RTM_REDIRECT: rtm,
|
||||
syscall.RTM_MISS: rtm,
|
||||
syscall.RTM_LOCK: rtm,
|
||||
syscall.RTM_RESOLVE: rtm,
|
||||
syscall.RTM_NEWADDR: ifam,
|
||||
syscall.RTM_DELADDR: ifam,
|
||||
syscall.RTM_IFINFO: ifm,
|
||||
syscall.RTM_NEWMADDR: ifmam,
|
||||
syscall.RTM_DELMADDR: ifmam,
|
||||
syscall.RTM_IFANNOUNCE: ifanm,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,8 @@
|
||||
package route
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func (typ RIBType) parseable() bool { return true }
|
||||
@@ -65,7 +64,7 @@ func probeRoutingStack() (int, map[int]*wireFormat) {
|
||||
// to know the underlying kernel's architecture because the
|
||||
// alignment for routing facilities are set at the build time
|
||||
// of the kernel.
|
||||
conf, _ := unix.Sysctl("kern.conftxt")
|
||||
conf, _ := syscall.Sysctl("kern.conftxt")
|
||||
for i, j := 0, 0; j < len(conf); j++ {
|
||||
if conf[j] != '\n' {
|
||||
continue
|
||||
@@ -89,17 +88,21 @@ func probeRoutingStack() (int, map[int]*wireFormat) {
|
||||
if align != wordSize {
|
||||
compatFreeBSD32 = true // 386 emulation on amd64
|
||||
}
|
||||
var rtm *wireFormat
|
||||
ifam := &wireFormat{extOff: unix.SizeofIfaMsghdr, bodyOff: unix.SizeofIfaMsghdr}
|
||||
ifmam := &wireFormat{extOff: unix.SizeofIfmaMsghdr, bodyOff: unix.SizeofIfmaMsghdr}
|
||||
ifanm := &wireFormat{extOff: unix.SizeofIfAnnounceMsghdr, bodyOff: unix.SizeofIfAnnounceMsghdr}
|
||||
ifm := &wireFormat{extOff: 16}
|
||||
var rtm, ifm, ifam, ifmam, ifanm *wireFormat
|
||||
if compatFreeBSD32 {
|
||||
rtm = &wireFormat{extOff: sizeofRtMsghdrFreeBSD10Emu - sizeofRtMetricsFreeBSD10Emu, bodyOff: sizeofRtMsghdrFreeBSD10Emu}
|
||||
ifm = &wireFormat{extOff: 16}
|
||||
ifam = &wireFormat{extOff: sizeofIfaMsghdrFreeBSD10Emu, bodyOff: sizeofIfaMsghdrFreeBSD10Emu}
|
||||
ifmam = &wireFormat{extOff: sizeofIfmaMsghdrFreeBSD10Emu, bodyOff: sizeofIfmaMsghdrFreeBSD10Emu}
|
||||
ifanm = &wireFormat{extOff: sizeofIfAnnouncemsghdrFreeBSD10Emu, bodyOff: sizeofIfAnnouncemsghdrFreeBSD10Emu}
|
||||
} else {
|
||||
rtm = &wireFormat{extOff: sizeofRtMsghdrFreeBSD10 - sizeofRtMetricsFreeBSD10, bodyOff: sizeofRtMsghdrFreeBSD10}
|
||||
ifm = &wireFormat{extOff: 16}
|
||||
ifam = &wireFormat{extOff: sizeofIfaMsghdrFreeBSD10, bodyOff: sizeofIfaMsghdrFreeBSD10}
|
||||
ifmam = &wireFormat{extOff: sizeofIfmaMsghdrFreeBSD10, bodyOff: sizeofIfmaMsghdrFreeBSD10}
|
||||
ifanm = &wireFormat{extOff: sizeofIfAnnouncemsghdrFreeBSD10, bodyOff: sizeofIfAnnouncemsghdrFreeBSD10}
|
||||
}
|
||||
rel, _ := unix.SysctlUint32("kern.osreldate")
|
||||
rel, _ := syscall.SysctlUint32("kern.osreldate")
|
||||
switch {
|
||||
case rel < 800000:
|
||||
if compatFreeBSD32 {
|
||||
@@ -138,20 +141,20 @@ func probeRoutingStack() (int, map[int]*wireFormat) {
|
||||
ifmam.parse = ifmam.parseInterfaceMulticastAddrMessage
|
||||
ifanm.parse = ifanm.parseInterfaceAnnounceMessage
|
||||
return align, map[int]*wireFormat{
|
||||
unix.RTM_ADD: rtm,
|
||||
unix.RTM_DELETE: rtm,
|
||||
unix.RTM_CHANGE: rtm,
|
||||
unix.RTM_GET: rtm,
|
||||
unix.RTM_LOSING: rtm,
|
||||
unix.RTM_REDIRECT: rtm,
|
||||
unix.RTM_MISS: rtm,
|
||||
unix.RTM_LOCK: rtm,
|
||||
unix.RTM_RESOLVE: rtm,
|
||||
unix.RTM_NEWADDR: ifam,
|
||||
unix.RTM_DELADDR: ifam,
|
||||
unix.RTM_IFINFO: ifm,
|
||||
unix.RTM_NEWMADDR: ifmam,
|
||||
unix.RTM_DELMADDR: ifmam,
|
||||
unix.RTM_IFANNOUNCE: ifanm,
|
||||
syscall.RTM_ADD: rtm,
|
||||
syscall.RTM_DELETE: rtm,
|
||||
syscall.RTM_CHANGE: rtm,
|
||||
syscall.RTM_GET: rtm,
|
||||
syscall.RTM_LOSING: rtm,
|
||||
syscall.RTM_REDIRECT: rtm,
|
||||
syscall.RTM_MISS: rtm,
|
||||
syscall.RTM_LOCK: rtm,
|
||||
syscall.RTM_RESOLVE: rtm,
|
||||
syscall.RTM_NEWADDR: ifam,
|
||||
syscall.RTM_DELADDR: ifam,
|
||||
syscall.RTM_IFINFO: ifm,
|
||||
syscall.RTM_NEWMADDR: ifmam,
|
||||
syscall.RTM_DELMADDR: ifmam,
|
||||
syscall.RTM_IFANNOUNCE: ifanm,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
package route
|
||||
|
||||
import "golang.org/x/sys/unix"
|
||||
import "syscall"
|
||||
|
||||
func (typ RIBType) parseable() bool { return true }
|
||||
|
||||
@@ -45,29 +45,29 @@ func (m *InterfaceMessage) Sys() []Sys {
|
||||
}
|
||||
|
||||
func probeRoutingStack() (int, map[int]*wireFormat) {
|
||||
rtm := &wireFormat{extOff: 40, bodyOff: unix.SizeofRtMsghdr}
|
||||
rtm := &wireFormat{extOff: 40, bodyOff: sizeofRtMsghdrNetBSD7}
|
||||
rtm.parse = rtm.parseRouteMessage
|
||||
ifm := &wireFormat{extOff: 16, bodyOff: unix.SizeofIfMsghdr}
|
||||
ifm := &wireFormat{extOff: 16, bodyOff: sizeofIfMsghdrNetBSD7}
|
||||
ifm.parse = ifm.parseInterfaceMessage
|
||||
ifam := &wireFormat{extOff: unix.SizeofIfaMsghdr, bodyOff: unix.SizeofIfaMsghdr}
|
||||
ifam := &wireFormat{extOff: sizeofIfaMsghdrNetBSD7, bodyOff: sizeofIfaMsghdrNetBSD7}
|
||||
ifam.parse = ifam.parseInterfaceAddrMessage
|
||||
ifanm := &wireFormat{extOff: unix.SizeofIfAnnounceMsghdr, bodyOff: unix.SizeofIfAnnounceMsghdr}
|
||||
ifanm := &wireFormat{extOff: sizeofIfAnnouncemsghdrNetBSD7, bodyOff: sizeofIfAnnouncemsghdrNetBSD7}
|
||||
ifanm.parse = ifanm.parseInterfaceAnnounceMessage
|
||||
// NetBSD 6 and above kernels require 64-bit aligned access to
|
||||
// routing facilities.
|
||||
return 8, map[int]*wireFormat{
|
||||
unix.RTM_ADD: rtm,
|
||||
unix.RTM_DELETE: rtm,
|
||||
unix.RTM_CHANGE: rtm,
|
||||
unix.RTM_GET: rtm,
|
||||
unix.RTM_LOSING: rtm,
|
||||
unix.RTM_REDIRECT: rtm,
|
||||
unix.RTM_MISS: rtm,
|
||||
unix.RTM_LOCK: rtm,
|
||||
unix.RTM_RESOLVE: rtm,
|
||||
unix.RTM_NEWADDR: ifam,
|
||||
unix.RTM_DELADDR: ifam,
|
||||
unix.RTM_IFANNOUNCE: ifanm,
|
||||
unix.RTM_IFINFO: ifm,
|
||||
syscall.RTM_ADD: rtm,
|
||||
syscall.RTM_DELETE: rtm,
|
||||
syscall.RTM_CHANGE: rtm,
|
||||
syscall.RTM_GET: rtm,
|
||||
syscall.RTM_LOSING: rtm,
|
||||
syscall.RTM_REDIRECT: rtm,
|
||||
syscall.RTM_MISS: rtm,
|
||||
syscall.RTM_LOCK: rtm,
|
||||
syscall.RTM_RESOLVE: rtm,
|
||||
syscall.RTM_NEWADDR: ifam,
|
||||
syscall.RTM_DELADDR: ifam,
|
||||
syscall.RTM_IFANNOUNCE: ifanm,
|
||||
syscall.RTM_IFINFO: ifm,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,14 +5,13 @@
|
||||
package route
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func (typ RIBType) parseable() bool {
|
||||
switch typ {
|
||||
case unix.NET_RT_STATS, unix.NET_RT_TABLE:
|
||||
case syscall.NET_RT_STATS, syscall.NET_RT_TABLE:
|
||||
return false
|
||||
default:
|
||||
return true
|
||||
@@ -66,18 +65,18 @@ func probeRoutingStack() (int, map[int]*wireFormat) {
|
||||
ifanm := &wireFormat{extOff: -1, bodyOff: -1}
|
||||
ifanm.parse = ifanm.parseInterfaceAnnounceMessage
|
||||
return int(unsafe.Sizeof(p)), map[int]*wireFormat{
|
||||
unix.RTM_ADD: rtm,
|
||||
unix.RTM_DELETE: rtm,
|
||||
unix.RTM_CHANGE: rtm,
|
||||
unix.RTM_GET: rtm,
|
||||
unix.RTM_LOSING: rtm,
|
||||
unix.RTM_REDIRECT: rtm,
|
||||
unix.RTM_MISS: rtm,
|
||||
unix.RTM_RESOLVE: rtm,
|
||||
unix.RTM_NEWADDR: ifam,
|
||||
unix.RTM_DELADDR: ifam,
|
||||
unix.RTM_IFINFO: ifm,
|
||||
unix.RTM_IFANNOUNCE: ifanm,
|
||||
unix.RTM_DESYNC: rtm,
|
||||
syscall.RTM_ADD: rtm,
|
||||
syscall.RTM_DELETE: rtm,
|
||||
syscall.RTM_CHANGE: rtm,
|
||||
syscall.RTM_GET: rtm,
|
||||
syscall.RTM_LOSING: rtm,
|
||||
syscall.RTM_REDIRECT: rtm,
|
||||
syscall.RTM_MISS: rtm,
|
||||
syscall.RTM_RESOLVE: rtm,
|
||||
syscall.RTM_NEWADDR: ifam,
|
||||
syscall.RTM_DELADDR: ifam,
|
||||
syscall.RTM_IFINFO: ifm,
|
||||
syscall.RTM_IFANNOUNCE: ifanm,
|
||||
syscall.RTM_DESYNC: rtm,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,19 @@
|
||||
package route
|
||||
|
||||
const (
|
||||
sizeofIfMsghdr2Darwin15 = 0xa0
|
||||
sizeofIfData64Darwin15 = 0x80
|
||||
sizeofIfMsghdrDarwin15 = 0x70
|
||||
sizeofIfaMsghdrDarwin15 = 0x14
|
||||
sizeofIfmaMsghdrDarwin15 = 0x10
|
||||
sizeofIfMsghdr2Darwin15 = 0xa0
|
||||
sizeofIfmaMsghdr2Darwin15 = 0x14
|
||||
sizeofIfDataDarwin15 = 0x60
|
||||
sizeofIfData64Darwin15 = 0x80
|
||||
|
||||
sizeofRtMsghdrDarwin15 = 0x5c
|
||||
sizeofRtMsghdr2Darwin15 = 0x5c
|
||||
sizeofRtMetricsDarwin15 = 0x38
|
||||
|
||||
sizeofSockaddrStorage = 0x80
|
||||
sizeofSockaddrInet = 0x10
|
||||
sizeofSockaddrInet6 = 0x1c
|
||||
)
|
||||
|
||||
20
route/zsys_dragonfly.go
Normal file
20
route/zsys_dragonfly.go
Normal file
@@ -0,0 +1,20 @@
|
||||
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||
// cgo -godefs defs_dragonfly.go
|
||||
|
||||
package route
|
||||
|
||||
const (
|
||||
sizeofIfMsghdrDragonFlyBSD4 = 0xb0
|
||||
sizeofIfaMsghdrDragonFlyBSD4 = 0x14
|
||||
sizeofIfmaMsghdrDragonFlyBSD4 = 0x10
|
||||
sizeofIfAnnouncemsghdrDragonFlyBSD4 = 0x18
|
||||
|
||||
sizeofIfaMsghdrDragonFlyBSD58 = 0x18
|
||||
|
||||
sizeofRtMsghdrDragonFlyBSD4 = 0x98
|
||||
sizeofRtMetricsDragonFlyBSD4 = 0x70
|
||||
|
||||
sizeofSockaddrStorage = 0x80
|
||||
sizeofSockaddrInet = 0x10
|
||||
sizeofSockaddrInet6 = 0x1c
|
||||
)
|
||||
@@ -4,6 +4,12 @@
|
||||
package route
|
||||
|
||||
const (
|
||||
sizeofIfMsghdrlFreeBSD10 = 0x68
|
||||
sizeofIfaMsghdrFreeBSD10 = 0x14
|
||||
sizeofIfaMsghdrlFreeBSD10 = 0x6c
|
||||
sizeofIfmaMsghdrFreeBSD10 = 0x10
|
||||
sizeofIfAnnouncemsghdrFreeBSD10 = 0x18
|
||||
|
||||
sizeofRtMsghdrFreeBSD10 = 0x5c
|
||||
sizeofRtMetricsFreeBSD10 = 0x38
|
||||
|
||||
@@ -22,6 +28,12 @@ const (
|
||||
// MODIFIED BY HAND FOR 386 EMULATION ON AMD64
|
||||
// 386 EMULATION USES THE UNDERLYING RAW DATA LAYOUT
|
||||
|
||||
sizeofIfMsghdrlFreeBSD10Emu = 0xb0
|
||||
sizeofIfaMsghdrFreeBSD10Emu = 0x14
|
||||
sizeofIfaMsghdrlFreeBSD10Emu = 0xb0
|
||||
sizeofIfmaMsghdrFreeBSD10Emu = 0x10
|
||||
sizeofIfAnnouncemsghdrFreeBSD10Emu = 0x18
|
||||
|
||||
sizeofRtMsghdrFreeBSD10Emu = 0x98
|
||||
sizeofRtMetricsFreeBSD10Emu = 0x70
|
||||
|
||||
|
||||
@@ -4,6 +4,12 @@
|
||||
package route
|
||||
|
||||
const (
|
||||
sizeofIfMsghdrlFreeBSD10 = 0xb0
|
||||
sizeofIfaMsghdrFreeBSD10 = 0x14
|
||||
sizeofIfaMsghdrlFreeBSD10 = 0xb0
|
||||
sizeofIfmaMsghdrFreeBSD10 = 0x10
|
||||
sizeofIfAnnouncemsghdrFreeBSD10 = 0x18
|
||||
|
||||
sizeofRtMsghdrFreeBSD10 = 0x98
|
||||
sizeofRtMetricsFreeBSD10 = 0x70
|
||||
|
||||
@@ -19,6 +25,12 @@ const (
|
||||
sizeofIfDataFreeBSD10 = 0x98
|
||||
sizeofIfDataFreeBSD11 = 0x98
|
||||
|
||||
sizeofIfMsghdrlFreeBSD10Emu = 0xb0
|
||||
sizeofIfaMsghdrFreeBSD10Emu = 0x14
|
||||
sizeofIfaMsghdrlFreeBSD10Emu = 0xb0
|
||||
sizeofIfmaMsghdrFreeBSD10Emu = 0x10
|
||||
sizeofIfAnnouncemsghdrFreeBSD10Emu = 0x18
|
||||
|
||||
sizeofRtMsghdrFreeBSD10Emu = 0x98
|
||||
sizeofRtMetricsFreeBSD10Emu = 0x70
|
||||
|
||||
|
||||
@@ -4,6 +4,12 @@
|
||||
package route
|
||||
|
||||
const (
|
||||
sizeofIfMsghdrlFreeBSD10 = 0x68
|
||||
sizeofIfaMsghdrFreeBSD10 = 0x14
|
||||
sizeofIfaMsghdrlFreeBSD10 = 0x6c
|
||||
sizeofIfmaMsghdrFreeBSD10 = 0x10
|
||||
sizeofIfAnnouncemsghdrFreeBSD10 = 0x18
|
||||
|
||||
sizeofRtMsghdrFreeBSD10 = 0x5c
|
||||
sizeofRtMetricsFreeBSD10 = 0x38
|
||||
|
||||
@@ -19,6 +25,12 @@ const (
|
||||
sizeofIfDataFreeBSD10 = 0x60
|
||||
sizeofIfDataFreeBSD11 = 0x98
|
||||
|
||||
sizeofIfMsghdrlFreeBSD10Emu = 0x68
|
||||
sizeofIfaMsghdrFreeBSD10Emu = 0x14
|
||||
sizeofIfaMsghdrlFreeBSD10Emu = 0x6c
|
||||
sizeofIfmaMsghdrFreeBSD10Emu = 0x10
|
||||
sizeofIfAnnouncemsghdrFreeBSD10Emu = 0x18
|
||||
|
||||
sizeofRtMsghdrFreeBSD10Emu = 0x5c
|
||||
sizeofRtMetricsFreeBSD10Emu = 0x38
|
||||
|
||||
|
||||
@@ -4,6 +4,12 @@
|
||||
package route
|
||||
|
||||
const (
|
||||
sizeofIfMsghdrlFreeBSD10 = 0xb0
|
||||
sizeofIfaMsghdrFreeBSD10 = 0x14
|
||||
sizeofIfaMsghdrlFreeBSD10 = 0xb0
|
||||
sizeofIfmaMsghdrFreeBSD10 = 0x10
|
||||
sizeofIfAnnouncemsghdrFreeBSD10 = 0x18
|
||||
|
||||
sizeofRtMsghdrFreeBSD10 = 0x98
|
||||
sizeofRtMetricsFreeBSD10 = 0x70
|
||||
|
||||
@@ -19,6 +25,12 @@ const (
|
||||
sizeofIfDataFreeBSD10 = 0x98
|
||||
sizeofIfDataFreeBSD11 = 0x98
|
||||
|
||||
sizeofIfMsghdrlFreeBSD10Emu = 0xb0
|
||||
sizeofIfaMsghdrFreeBSD10Emu = 0x14
|
||||
sizeofIfaMsghdrlFreeBSD10Emu = 0xb0
|
||||
sizeofIfmaMsghdrFreeBSD10Emu = 0x10
|
||||
sizeofIfAnnouncemsghdrFreeBSD10Emu = 0x18
|
||||
|
||||
sizeofRtMsghdrFreeBSD10Emu = 0x98
|
||||
sizeofRtMetricsFreeBSD10Emu = 0x70
|
||||
|
||||
|
||||
@@ -4,6 +4,12 @@
|
||||
package route
|
||||
|
||||
const (
|
||||
sizeofIfMsghdrlFreeBSD10 = 0xb0
|
||||
sizeofIfaMsghdrFreeBSD10 = 0x14
|
||||
sizeofIfaMsghdrlFreeBSD10 = 0xb0
|
||||
sizeofIfmaMsghdrFreeBSD10 = 0x10
|
||||
sizeofIfAnnouncemsghdrFreeBSD10 = 0x18
|
||||
|
||||
sizeofRtMsghdrFreeBSD10 = 0x98
|
||||
sizeofRtMetricsFreeBSD10 = 0x70
|
||||
|
||||
@@ -19,6 +25,12 @@ const (
|
||||
sizeofIfDataFreeBSD10 = 0x98
|
||||
sizeofIfDataFreeBSD11 = 0x98
|
||||
|
||||
sizeofIfMsghdrlFreeBSD10Emu = 0xb0
|
||||
sizeofIfaMsghdrFreeBSD10Emu = 0x14
|
||||
sizeofIfaMsghdrlFreeBSD10Emu = 0xb0
|
||||
sizeofIfmaMsghdrFreeBSD10Emu = 0x10
|
||||
sizeofIfAnnouncemsghdrFreeBSD10Emu = 0x18
|
||||
|
||||
sizeofRtMsghdrFreeBSD10Emu = 0x98
|
||||
sizeofRtMetricsFreeBSD10Emu = 0x70
|
||||
|
||||
|
||||
17
route/zsys_netbsd.go
Normal file
17
route/zsys_netbsd.go
Normal file
@@ -0,0 +1,17 @@
|
||||
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||
// cgo -godefs defs_netbsd.go
|
||||
|
||||
package route
|
||||
|
||||
const (
|
||||
sizeofIfMsghdrNetBSD7 = 0x98
|
||||
sizeofIfaMsghdrNetBSD7 = 0x18
|
||||
sizeofIfAnnouncemsghdrNetBSD7 = 0x18
|
||||
|
||||
sizeofRtMsghdrNetBSD7 = 0x78
|
||||
sizeofRtMetricsNetBSD7 = 0x50
|
||||
|
||||
sizeofSockaddrStorage = 0x80
|
||||
sizeofSockaddrInet = 0x10
|
||||
sizeofSockaddrInet6 = 0x1c
|
||||
)
|
||||
12
route/zsys_openbsd.go
Normal file
12
route/zsys_openbsd.go
Normal file
@@ -0,0 +1,12 @@
|
||||
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||
// cgo -godefs defs_openbsd.go
|
||||
|
||||
package route
|
||||
|
||||
const (
|
||||
sizeofRtMsghdr = 0x60
|
||||
|
||||
sizeofSockaddrStorage = 0x100
|
||||
sizeofSockaddrInet = 0x10
|
||||
sizeofSockaddrInet6 = 0x1c
|
||||
)
|
||||
Reference in New Issue
Block a user