mirror of
https://github.com/rwinkhart/sys.git
synced 2026-09-05 16:47:27 -04:00
unix: add support for TCP_CONNECTION_INFO on macOS
x/sys provides support for accessing TCP_INFO on Linux but does not provide support for accessing the equivalent (TCP_CONNECTION_INFO) on macOS. This patch adds that functionality. Fixes golang/go#53330 Change-Id: Ia1c1bf79a8bbb76f3ccfe58c61e1a82e08735152 Reviewed-on: https://go-review.googlesource.com/c/sys/+/411734 Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
committed by
Gopher Robot
parent
bf31f56cad
commit
ff8c426e75
@@ -393,6 +393,13 @@ func GetsockoptXucred(fd, level, opt int) (*Xucred, error) {
|
|||||||
return x, err
|
return x, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetsockoptTCPConnectionInfo(fd, level, opt int) (*TCPConnectionInfo, error) {
|
||||||
|
var value TCPConnectionInfo
|
||||||
|
vallen := _Socklen(SizeofTCPConnectionInfo)
|
||||||
|
err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
|
||||||
|
return &value, err
|
||||||
|
}
|
||||||
|
|
||||||
func SysctlKinfoProc(name string, args ...int) (*KinfoProc, error) {
|
func SysctlKinfoProc(name string, args ...int) (*KinfoProc, error) {
|
||||||
mib, err := sysctlmib(name, args...)
|
mib, err := sysctlmib(name, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -200,6 +200,8 @@ type IPv6MTUInfo C.struct_ip6_mtuinfo
|
|||||||
|
|
||||||
type ICMPv6Filter C.struct_icmp6_filter
|
type ICMPv6Filter C.struct_icmp6_filter
|
||||||
|
|
||||||
|
type TCPConnectionInfo C.struct_tcp_connection_info
|
||||||
|
|
||||||
const (
|
const (
|
||||||
SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
|
SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
|
||||||
SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
|
SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
|
||||||
@@ -224,6 +226,7 @@ const (
|
|||||||
SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
|
SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
|
||||||
SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
|
SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
|
||||||
SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
|
SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
|
||||||
|
SizeofTCPConnectionInfo = C.sizeof_struct_tcp_connection_info
|
||||||
)
|
)
|
||||||
|
|
||||||
// Ptrace requests
|
// Ptrace requests
|
||||||
|
|||||||
@@ -366,6 +366,32 @@ type ICMPv6Filter struct {
|
|||||||
Filt [8]uint32
|
Filt [8]uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type TCPConnectionInfo struct {
|
||||||
|
State uint8
|
||||||
|
Snd_wscale uint8
|
||||||
|
Rcv_wscale uint8
|
||||||
|
_ uint8
|
||||||
|
Options uint32
|
||||||
|
Flags uint32
|
||||||
|
Rto uint32
|
||||||
|
Maxseg uint32
|
||||||
|
Snd_ssthresh uint32
|
||||||
|
Snd_cwnd uint32
|
||||||
|
Snd_wnd uint32
|
||||||
|
Snd_sbbytes uint32
|
||||||
|
Rcv_wnd uint32
|
||||||
|
Rttcur uint32
|
||||||
|
Srtt uint32
|
||||||
|
Rttvar uint32
|
||||||
|
Txpackets uint64
|
||||||
|
Txbytes uint64
|
||||||
|
Txretransmitbytes uint64
|
||||||
|
Rxpackets uint64
|
||||||
|
Rxbytes uint64
|
||||||
|
Rxoutoforderbytes uint64
|
||||||
|
Txretransmitpackets uint64
|
||||||
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
SizeofSockaddrInet4 = 0x10
|
SizeofSockaddrInet4 = 0x10
|
||||||
SizeofSockaddrInet6 = 0x1c
|
SizeofSockaddrInet6 = 0x1c
|
||||||
@@ -390,6 +416,7 @@ const (
|
|||||||
SizeofInet6Pktinfo = 0x14
|
SizeofInet6Pktinfo = 0x14
|
||||||
SizeofIPv6MTUInfo = 0x20
|
SizeofIPv6MTUInfo = 0x20
|
||||||
SizeofICMPv6Filter = 0x20
|
SizeofICMPv6Filter = 0x20
|
||||||
|
SizeofTCPConnectionInfo = 0x70
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
@@ -366,6 +366,32 @@ type ICMPv6Filter struct {
|
|||||||
Filt [8]uint32
|
Filt [8]uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type TCPConnectionInfo struct {
|
||||||
|
State uint8
|
||||||
|
Snd_wscale uint8
|
||||||
|
Rcv_wscale uint8
|
||||||
|
_ uint8
|
||||||
|
Options uint32
|
||||||
|
Flags uint32
|
||||||
|
Rto uint32
|
||||||
|
Maxseg uint32
|
||||||
|
Snd_ssthresh uint32
|
||||||
|
Snd_cwnd uint32
|
||||||
|
Snd_wnd uint32
|
||||||
|
Snd_sbbytes uint32
|
||||||
|
Rcv_wnd uint32
|
||||||
|
Rttcur uint32
|
||||||
|
Srtt uint32
|
||||||
|
Rttvar uint32
|
||||||
|
Txpackets uint64
|
||||||
|
Txbytes uint64
|
||||||
|
Txretransmitbytes uint64
|
||||||
|
Rxpackets uint64
|
||||||
|
Rxbytes uint64
|
||||||
|
Rxoutoforderbytes uint64
|
||||||
|
Txretransmitpackets uint64
|
||||||
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
SizeofSockaddrInet4 = 0x10
|
SizeofSockaddrInet4 = 0x10
|
||||||
SizeofSockaddrInet6 = 0x1c
|
SizeofSockaddrInet6 = 0x1c
|
||||||
@@ -390,6 +416,7 @@ const (
|
|||||||
SizeofInet6Pktinfo = 0x14
|
SizeofInet6Pktinfo = 0x14
|
||||||
SizeofIPv6MTUInfo = 0x20
|
SizeofIPv6MTUInfo = 0x20
|
||||||
SizeofICMPv6Filter = 0x20
|
SizeofICMPv6Filter = 0x20
|
||||||
|
SizeofTCPConnectionInfo = 0x70
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
Reference in New Issue
Block a user