From 04245dca01dae530ad36275d662a90d6b8a5ee29 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Thu, 22 Apr 2021 10:24:40 +0200 Subject: [PATCH] unix: add IPMreqn and {Get,Set}sockoptIPMreqn on darwin Change-Id: Id145cc8d86b71ff3ef603b5d0aae4bdd0e4c3f2b Reviewed-on: https://go-review.googlesource.com/c/sys/+/312410 Trust: Tobias Klauser Run-TryBot: Tobias Klauser TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- unix/syscall_darwin.go | 11 +++++++++++ unix/types_darwin.go | 3 +++ unix/ztypes_darwin_386.go | 7 +++++++ unix/ztypes_darwin_amd64.go | 7 +++++++ unix/ztypes_darwin_arm.go | 7 +++++++ unix/ztypes_darwin_arm64.go | 7 +++++++ 6 files changed, 42 insertions(+) diff --git a/unix/syscall_darwin.go b/unix/syscall_darwin.go index 1223d7ae..9945e5f9 100644 --- a/unix/syscall_darwin.go +++ b/unix/syscall_darwin.go @@ -378,6 +378,17 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e return } +func GetsockoptIPMreqn(fd, level, opt int) (*IPMreqn, error) { + var value IPMreqn + vallen := _Socklen(SizeofIPMreqn) + errno := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen) + return &value, errno +} + +func SetsockoptIPMreqn(fd, level, opt int, mreq *IPMreqn) (err error) { + return setsockopt(fd, level, opt, unsafe.Pointer(mreq), unsafe.Sizeof(*mreq)) +} + // GetsockoptXucred is a getsockopt wrapper that returns an Xucred struct. // The usual level and opt are SOL_LOCAL and LOCAL_PEERCRED, respectively. func GetsockoptXucred(fd, level, opt int) (*Xucred, error) { diff --git a/unix/types_darwin.go b/unix/types_darwin.go index 81f8875f..e65c0de2 100644 --- a/unix/types_darwin.go +++ b/unix/types_darwin.go @@ -160,6 +160,8 @@ type Iovec C.struct_iovec type IPMreq C.struct_ip_mreq +type IPMreqn C.struct_ip_mreqn + type IPv6Mreq C.struct_ipv6_mreq type Msghdr C.struct_msghdr @@ -185,6 +187,7 @@ const ( SizeofLinger = C.sizeof_struct_linger SizeofIovec = C.sizeof_struct_iovec SizeofIPMreq = C.sizeof_struct_ip_mreq + SizeofIPMreqn = C.sizeof_struct_ip_mreqn SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq SizeofMsghdr = C.sizeof_struct_msghdr SizeofCmsghdr = C.sizeof_struct_cmsghdr diff --git a/unix/ztypes_darwin_386.go b/unix/ztypes_darwin_386.go index 54db4333..883b64a2 100644 --- a/unix/ztypes_darwin_386.go +++ b/unix/ztypes_darwin_386.go @@ -221,6 +221,12 @@ type IPMreq struct { Interface [4]byte /* in_addr */ } +type IPMreqn struct { + Multiaddr [4]byte /* in_addr */ + Address [4]byte /* in_addr */ + Ifindex int32 +} + type IPv6Mreq struct { Multiaddr [16]byte /* in6_addr */ Interface uint32 @@ -272,6 +278,7 @@ const ( SizeofLinger = 0x8 SizeofIovec = 0x8 SizeofIPMreq = 0x8 + SizeofIPMreqn = 0xc SizeofIPv6Mreq = 0x14 SizeofMsghdr = 0x1c SizeofCmsghdr = 0xc diff --git a/unix/ztypes_darwin_amd64.go b/unix/ztypes_darwin_amd64.go index eb73e52f..2673e6c5 100644 --- a/unix/ztypes_darwin_amd64.go +++ b/unix/ztypes_darwin_amd64.go @@ -233,6 +233,12 @@ type IPMreq struct { Interface [4]byte /* in_addr */ } +type IPMreqn struct { + Multiaddr [4]byte /* in_addr */ + Address [4]byte /* in_addr */ + Ifindex int32 +} + type IPv6Mreq struct { Multiaddr [16]byte /* in6_addr */ Interface uint32 @@ -285,6 +291,7 @@ const ( SizeofLinger = 0x8 SizeofIovec = 0x10 SizeofIPMreq = 0x8 + SizeofIPMreqn = 0xc SizeofIPv6Mreq = 0x14 SizeofMsghdr = 0x30 SizeofCmsghdr = 0xc diff --git a/unix/ztypes_darwin_arm.go b/unix/ztypes_darwin_arm.go index 8606d654..eef51338 100644 --- a/unix/ztypes_darwin_arm.go +++ b/unix/ztypes_darwin_arm.go @@ -221,6 +221,12 @@ type IPMreq struct { Interface [4]byte /* in_addr */ } +type IPMreqn struct { + Multiaddr [4]byte /* in_addr */ + Address [4]byte /* in_addr */ + Ifindex int32 +} + type IPv6Mreq struct { Multiaddr [16]byte /* in6_addr */ Interface uint32 @@ -272,6 +278,7 @@ const ( SizeofLinger = 0x8 SizeofIovec = 0x8 SizeofIPMreq = 0x8 + SizeofIPMreqn = 0xc SizeofIPv6Mreq = 0x14 SizeofMsghdr = 0x1c SizeofCmsghdr = 0xc diff --git a/unix/ztypes_darwin_arm64.go b/unix/ztypes_darwin_arm64.go index dcb51f84..1465cbcf 100644 --- a/unix/ztypes_darwin_arm64.go +++ b/unix/ztypes_darwin_arm64.go @@ -233,6 +233,12 @@ type IPMreq struct { Interface [4]byte /* in_addr */ } +type IPMreqn struct { + Multiaddr [4]byte /* in_addr */ + Address [4]byte /* in_addr */ + Ifindex int32 +} + type IPv6Mreq struct { Multiaddr [16]byte /* in6_addr */ Interface uint32 @@ -285,6 +291,7 @@ const ( SizeofLinger = 0x8 SizeofIovec = 0x10 SizeofIPMreq = 0x8 + SizeofIPMreqn = 0xc SizeofIPv6Mreq = 0x14 SizeofMsghdr = 0x30 SizeofCmsghdr = 0xc