Update dependencies

This commit is contained in:
bluepython508
2025-04-09 01:00:12 +01:00
parent f0641ffd6e
commit 5a9cfc022c
882 changed files with 68930 additions and 24201 deletions

View File

@@ -170,29 +170,56 @@ func (a *Inet6Addr) marshal(b []byte) (int, error) {
// parseInetAddr parses b as an internet address for IPv4 or IPv6.
func parseInetAddr(af int, b []byte) (Addr, error) {
const (
off4 = 4 // offset of in_addr
off6 = 8 // offset of in6_addr
ipv4Len = 4 // length of IPv4 address in bytes
ipv6Len = 16 // length of IPv6 address in bytes
)
switch af {
case syscall.AF_INET:
if len(b) < sizeofSockaddrInet {
if len(b) < int(b[0]) {
return nil, errInvalidAddr
}
sockAddrLen := int(b[0])
a := &Inet4Addr{}
copy(a.IP[:], b[4:8])
// sockAddrLen of 0 is valid and represents 0.0.0.0
if sockAddrLen > off4 {
// Calculate how many bytes of the address to copy:
// either full IPv4 length or the available length.
n := off4 + ipv4Len
if sockAddrLen < n {
n = sockAddrLen
}
copy(a.IP[:], b[off4:n])
}
return a, nil
case syscall.AF_INET6:
if len(b) < sizeofSockaddrInet6 {
if len(b) < int(b[0]) {
return nil, errInvalidAddr
}
a := &Inet6Addr{ZoneID: int(nativeEndian.Uint32(b[24:28]))}
copy(a.IP[:], b[8:24])
if a.IP[0] == 0xfe && a.IP[1]&0xc0 == 0x80 || a.IP[0] == 0xff && (a.IP[1]&0x0f == 0x01 || a.IP[1]&0x0f == 0x02) {
// KAME based IPv6 protocol stack usually
// embeds the interface index in the
// interface-local or link-local address as
// the kernel-internal form.
id := int(bigEndian.Uint16(a.IP[2:4]))
if id != 0 {
a.ZoneID = id
a.IP[2], a.IP[3] = 0, 0
sockAddrLen := int(b[0])
a := &Inet6Addr{}
// sockAddrLen of 0 is valid and represents ::
if sockAddrLen > off6 {
n := off6 + ipv6Len
if sockAddrLen < n {
n = sockAddrLen
}
if sockAddrLen == sizeofSockaddrInet6 {
a.ZoneID = int(nativeEndian.Uint32(b[24:28]))
}
copy(a.IP[:], b[off6:n])
if a.IP[0] == 0xfe && a.IP[1]&0xc0 == 0x80 || a.IP[0] == 0xff && (a.IP[1]&0x0f == 0x01 || a.IP[1]&0x0f == 0x02) {
// KAME based IPv6 protocol stack usually
// embeds the interface index in the
// interface-local or link-local address as
// the kernel-internal form.
id := int(bigEndian.Uint16(a.IP[2:4]))
if id != 0 {
a.ZoneID = id
a.IP[2], a.IP[3] = 0, 0
}
}
}
return a, nil
@@ -369,13 +396,19 @@ 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 [syscall.RTAX_MAX]Addr
af := int(syscall.AF_UNSPEC)
isInet := func(fam int) bool {
return fam == syscall.AF_INET || fam == syscall.AF_INET6
}
isMask := func(addrType uint) bool {
return addrType == syscall.RTAX_NETMASK || addrType == syscall.RTAX_GENMASK
}
for i := uint(0); i < syscall.RTAX_MAX && len(b) >= roundup(0); i++ {
if attrs&(1<<i) == 0 {
continue
}
if i <= syscall.RTAX_BRD {
switch b[1] {
case syscall.AF_LINK:
switch {
case b[1] == syscall.AF_LINK:
a, err := parseLinkAddr(b)
if err != nil {
return nil, err
@@ -386,8 +419,10 @@ func parseAddrs(attrs uint, fn func(int, []byte) (int, Addr, error), b []byte) (
return nil, errMessageTooShort
}
b = b[l:]
case syscall.AF_INET, syscall.AF_INET6:
af = int(b[1])
case isInet(int(b[1])) || (isMask(i) && isInet(af)):
if isInet(int(b[1])) {
af = int(b[1])
}
a, err := parseInetAddr(af, b)
if err != nil {
return nil, err

View File

@@ -25,7 +25,7 @@ func (m *RouteMessage) Sys() []Sys {
}
}
// RouteMetrics represents route metrics.
// InterfaceMetrics represents route metrics.
type InterfaceMetrics struct {
Type int // interface type
MTU int // maximum transmission unit

View File

@@ -9,14 +9,10 @@ const (
sizeofIfmaMsghdrDarwin15 = 0x10
sizeofIfMsghdr2Darwin15 = 0xa0
sizeofIfmaMsghdr2Darwin15 = 0x14
sizeofIfDataDarwin15 = 0x60
sizeofIfData64Darwin15 = 0x80
sizeofRtMsghdrDarwin15 = 0x5c
sizeofRtMsghdr2Darwin15 = 0x5c
sizeofRtMetricsDarwin15 = 0x38
sizeofSockaddrStorage = 0x80
sizeofSockaddrInet = 0x10
sizeofSockaddrInet6 = 0x1c
sizeofSockaddrInet = 0x10
sizeofSockaddrInet6 = 0x1c
)

View File

@@ -11,10 +11,8 @@ const (
sizeofIfaMsghdrDragonFlyBSD58 = 0x18
sizeofRtMsghdrDragonFlyBSD4 = 0x98
sizeofRtMetricsDragonFlyBSD4 = 0x70
sizeofRtMsghdrDragonFlyBSD4 = 0x98
sizeofSockaddrStorage = 0x80
sizeofSockaddrInet = 0x10
sizeofSockaddrInet6 = 0x1c
sizeofSockaddrInet = 0x10
sizeofSockaddrInet6 = 0x1c
)

View File

@@ -6,7 +6,6 @@ package route
const (
sizeofIfMsghdrlFreeBSD10 = 0x68
sizeofIfaMsghdrFreeBSD10 = 0x14
sizeofIfaMsghdrlFreeBSD10 = 0x6c
sizeofIfmaMsghdrFreeBSD10 = 0x10
sizeofIfAnnouncemsghdrFreeBSD10 = 0x18
@@ -19,18 +18,10 @@ const (
sizeofIfMsghdrFreeBSD10 = 0x64
sizeofIfMsghdrFreeBSD11 = 0xa8
sizeofIfDataFreeBSD7 = 0x50
sizeofIfDataFreeBSD8 = 0x50
sizeofIfDataFreeBSD9 = 0x50
sizeofIfDataFreeBSD10 = 0x54
sizeofIfDataFreeBSD11 = 0x98
// 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
@@ -43,13 +34,6 @@ const (
sizeofIfMsghdrFreeBSD10Emu = 0xa8
sizeofIfMsghdrFreeBSD11Emu = 0xa8
sizeofIfDataFreeBSD7Emu = 0x98
sizeofIfDataFreeBSD8Emu = 0x98
sizeofIfDataFreeBSD9Emu = 0x98
sizeofIfDataFreeBSD10Emu = 0x98
sizeofIfDataFreeBSD11Emu = 0x98
sizeofSockaddrStorage = 0x80
sizeofSockaddrInet = 0x10
sizeofSockaddrInet6 = 0x1c
sizeofSockaddrInet = 0x10
sizeofSockaddrInet6 = 0x1c
)

View File

@@ -6,7 +6,6 @@ package route
const (
sizeofIfMsghdrlFreeBSD10 = 0xb0
sizeofIfaMsghdrFreeBSD10 = 0x14
sizeofIfaMsghdrlFreeBSD10 = 0xb0
sizeofIfmaMsghdrFreeBSD10 = 0x10
sizeofIfAnnouncemsghdrFreeBSD10 = 0x18
@@ -19,15 +18,7 @@ const (
sizeofIfMsghdrFreeBSD10 = 0xa8
sizeofIfMsghdrFreeBSD11 = 0xa8
sizeofIfDataFreeBSD7 = 0x98
sizeofIfDataFreeBSD8 = 0x98
sizeofIfDataFreeBSD9 = 0x98
sizeofIfDataFreeBSD10 = 0x98
sizeofIfDataFreeBSD11 = 0x98
sizeofIfMsghdrlFreeBSD10Emu = 0xb0
sizeofIfaMsghdrFreeBSD10Emu = 0x14
sizeofIfaMsghdrlFreeBSD10Emu = 0xb0
sizeofIfmaMsghdrFreeBSD10Emu = 0x10
sizeofIfAnnouncemsghdrFreeBSD10Emu = 0x18
@@ -40,13 +31,6 @@ const (
sizeofIfMsghdrFreeBSD10Emu = 0xa8
sizeofIfMsghdrFreeBSD11Emu = 0xa8
sizeofIfDataFreeBSD7Emu = 0x98
sizeofIfDataFreeBSD8Emu = 0x98
sizeofIfDataFreeBSD9Emu = 0x98
sizeofIfDataFreeBSD10Emu = 0x98
sizeofIfDataFreeBSD11Emu = 0x98
sizeofSockaddrStorage = 0x80
sizeofSockaddrInet = 0x10
sizeofSockaddrInet6 = 0x1c
sizeofSockaddrInet = 0x10
sizeofSockaddrInet6 = 0x1c
)

View File

@@ -6,7 +6,6 @@ package route
const (
sizeofIfMsghdrlFreeBSD10 = 0x68
sizeofIfaMsghdrFreeBSD10 = 0x14
sizeofIfaMsghdrlFreeBSD10 = 0x6c
sizeofIfmaMsghdrFreeBSD10 = 0x10
sizeofIfAnnouncemsghdrFreeBSD10 = 0x18
@@ -19,15 +18,7 @@ const (
sizeofIfMsghdrFreeBSD10 = 0x70
sizeofIfMsghdrFreeBSD11 = 0xa8
sizeofIfDataFreeBSD7 = 0x60
sizeofIfDataFreeBSD8 = 0x60
sizeofIfDataFreeBSD9 = 0x60
sizeofIfDataFreeBSD10 = 0x60
sizeofIfDataFreeBSD11 = 0x98
sizeofIfMsghdrlFreeBSD10Emu = 0x68
sizeofIfaMsghdrFreeBSD10Emu = 0x14
sizeofIfaMsghdrlFreeBSD10Emu = 0x6c
sizeofIfmaMsghdrFreeBSD10Emu = 0x10
sizeofIfAnnouncemsghdrFreeBSD10Emu = 0x18
@@ -40,13 +31,6 @@ const (
sizeofIfMsghdrFreeBSD10Emu = 0x70
sizeofIfMsghdrFreeBSD11Emu = 0xa8
sizeofIfDataFreeBSD7Emu = 0x60
sizeofIfDataFreeBSD8Emu = 0x60
sizeofIfDataFreeBSD9Emu = 0x60
sizeofIfDataFreeBSD10Emu = 0x60
sizeofIfDataFreeBSD11Emu = 0x98
sizeofSockaddrStorage = 0x80
sizeofSockaddrInet = 0x10
sizeofSockaddrInet6 = 0x1c
sizeofSockaddrInet = 0x10
sizeofSockaddrInet6 = 0x1c
)

View File

@@ -6,7 +6,6 @@ package route
const (
sizeofIfMsghdrlFreeBSD10 = 0xb0
sizeofIfaMsghdrFreeBSD10 = 0x14
sizeofIfaMsghdrlFreeBSD10 = 0xb0
sizeofIfmaMsghdrFreeBSD10 = 0x10
sizeofIfAnnouncemsghdrFreeBSD10 = 0x18
@@ -19,15 +18,7 @@ const (
sizeofIfMsghdrFreeBSD10 = 0xa8
sizeofIfMsghdrFreeBSD11 = 0xa8
sizeofIfDataFreeBSD7 = 0x98
sizeofIfDataFreeBSD8 = 0x98
sizeofIfDataFreeBSD9 = 0x98
sizeofIfDataFreeBSD10 = 0x98
sizeofIfDataFreeBSD11 = 0x98
sizeofIfMsghdrlFreeBSD10Emu = 0xb0
sizeofIfaMsghdrFreeBSD10Emu = 0x14
sizeofIfaMsghdrlFreeBSD10Emu = 0xb0
sizeofIfmaMsghdrFreeBSD10Emu = 0x10
sizeofIfAnnouncemsghdrFreeBSD10Emu = 0x18
@@ -40,13 +31,6 @@ const (
sizeofIfMsghdrFreeBSD10Emu = 0xa8
sizeofIfMsghdrFreeBSD11Emu = 0xa8
sizeofIfDataFreeBSD7Emu = 0x98
sizeofIfDataFreeBSD8Emu = 0x98
sizeofIfDataFreeBSD9Emu = 0x98
sizeofIfDataFreeBSD10Emu = 0x98
sizeofIfDataFreeBSD11Emu = 0x98
sizeofSockaddrStorage = 0x80
sizeofSockaddrInet = 0x10
sizeofSockaddrInet6 = 0x1c
sizeofSockaddrInet = 0x10
sizeofSockaddrInet6 = 0x1c
)

View File

@@ -6,7 +6,6 @@ package route
const (
sizeofIfMsghdrlFreeBSD10 = 0xb0
sizeofIfaMsghdrFreeBSD10 = 0x14
sizeofIfaMsghdrlFreeBSD10 = 0xb0
sizeofIfmaMsghdrFreeBSD10 = 0x10
sizeofIfAnnouncemsghdrFreeBSD10 = 0x18
@@ -19,15 +18,7 @@ const (
sizeofIfMsghdrFreeBSD10 = 0xa8
sizeofIfMsghdrFreeBSD11 = 0xa8
sizeofIfDataFreeBSD7 = 0x98
sizeofIfDataFreeBSD8 = 0x98
sizeofIfDataFreeBSD9 = 0x98
sizeofIfDataFreeBSD10 = 0x98
sizeofIfDataFreeBSD11 = 0x98
sizeofIfMsghdrlFreeBSD10Emu = 0xb0
sizeofIfaMsghdrFreeBSD10Emu = 0x14
sizeofIfaMsghdrlFreeBSD10Emu = 0xb0
sizeofIfmaMsghdrFreeBSD10Emu = 0x10
sizeofIfAnnouncemsghdrFreeBSD10Emu = 0x18
@@ -40,13 +31,6 @@ const (
sizeofIfMsghdrFreeBSD10Emu = 0xa8
sizeofIfMsghdrFreeBSD11Emu = 0xa8
sizeofIfDataFreeBSD7Emu = 0x98
sizeofIfDataFreeBSD8Emu = 0x98
sizeofIfDataFreeBSD9Emu = 0x98
sizeofIfDataFreeBSD10Emu = 0x98
sizeofIfDataFreeBSD11Emu = 0x98
sizeofSockaddrStorage = 0x80
sizeofSockaddrInet = 0x10
sizeofSockaddrInet6 = 0x1c
sizeofSockaddrInet = 0x10
sizeofSockaddrInet6 = 0x1c
)

View File

@@ -8,10 +8,8 @@ const (
sizeofIfaMsghdrNetBSD7 = 0x18
sizeofIfAnnouncemsghdrNetBSD7 = 0x18
sizeofRtMsghdrNetBSD7 = 0x78
sizeofRtMetricsNetBSD7 = 0x50
sizeofRtMsghdrNetBSD7 = 0x78
sizeofSockaddrStorage = 0x80
sizeofSockaddrInet = 0x10
sizeofSockaddrInet6 = 0x1c
sizeofSockaddrInet = 0x10
sizeofSockaddrInet6 = 0x1c
)

View File

@@ -6,7 +6,6 @@ package route
const (
sizeofRtMsghdr = 0x60
sizeofSockaddrStorage = 0x100
sizeofSockaddrInet = 0x10
sizeofSockaddrInet6 = 0x1c
sizeofSockaddrInet = 0x10
sizeofSockaddrInet6 = 0x1c
)