From: Tim Clem tclem@codeweavers.com
--- dlls/nsiproxy.sys/udp.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/dlls/nsiproxy.sys/udp.c b/dlls/nsiproxy.sys/udp.c index 2248d74234b..9c4b467173d 100644 --- a/dlls/nsiproxy.sys/udp.c +++ b/dlls/nsiproxy.sys/udp.c @@ -296,14 +296,26 @@ static NTSTATUS udp_endpoint_enumerate_all( void *key_data, UINT key_size, void } #elif defined(HAVE_SYS_SYSCTL_H) && defined(UDPCTL_PCBLIST) && defined(HAVE_STRUCT_XINPGEN) { - int mib[] = { CTL_NET, PF_INET, IPPROTO_UDP, UDPCTL_PCBLIST }; size_t len = 0; char *buf = NULL; struct xinpgen *xig, *orig_xig;
- if (sysctl( mib, ARRAY_SIZE(mib), NULL, &len, NULL, 0 ) < 0) +#ifdef __APPLE__ + static int mib[CTL_MAXNAME]; + static size_t mib_len = 0; + if (mib_len == 0) + { + mib_len = CTL_MAXNAME; + sysctlnametomib( "net.inet.udp.pcblist64", mib, &mib_len ); + } +#else + int mib[] = { CTL_NET, PF_INET, IPPROTO_UDP, UDPCTL_PCBLIST }; + size_t mib_len = ARRAY_SIZE(mib); +#endif + + if (sysctl( mib, mib_len, NULL, &len, NULL, 0 ) < 0) { - ERR( "Failure to read net.inet.udp.pcblist via sysctlbyname!\n" ); + ERR( "Failure to read net.inet.udp.pcblist via sysctl!\n" ); status = STATUS_NOT_SUPPORTED; goto err; } @@ -315,9 +327,9 @@ static NTSTATUS udp_endpoint_enumerate_all( void *key_data, UINT key_size, void goto err; }
- if (sysctl( mib, ARRAY_SIZE(mib), buf, &len, NULL, 0 ) < 0) + if (sysctl( mib, mib_len, buf, &len, NULL, 0 ) < 0) { - ERR( "Failure to read net.inet.udp.pcblist via sysctlbyname!\n" ); + ERR( "Failure to read net.inet.udp.pcblist via sysctl!\n" ); status = STATUS_NOT_SUPPORTED; goto err; } @@ -335,7 +347,10 @@ static NTSTATUS udp_endpoint_enumerate_all( void *key_data, UINT key_size, void xig->xig_len > sizeof (struct xinpgen); xig = (struct xinpgen *)((char *)xig + xig->xig_len)) { -#if __FreeBSD_version >= 1200026 +#ifdef __APPLE__ + struct xinpcb64 *in = (struct xinpcb64 *)xig; + struct xsocket64 *sock = &in->xi_socket; +#elif __FreeBSD_version >= 1200026 struct xinpcb *in = (struct xinpcb *)xig; struct xsocket *sock = &in->xi_socket; #else