[PATCH] iphlpapi: Account for structs inpcb and tcpcb being unavailable for userland in FreeBSD 12.

Gerald Pfeifer gerald at pfeifer.com
Sat Aug 17 03:32:31 CDT 2019


FreeBSD 12, specifically __FreeBSD_version 1200026 and later, no longer
exposes struct inpcb and struct tcpcb to userland.  New structs xinpcb 
and xtcpcb shall be used instead.

I have been carrying this patch as part of the FreeBSD ports of Wine 
(both emulators/wine and emulators/wine-devel) since March 2017, and 
Gleb Smirnoff, who contributed this originally, indicated that he was
going to push upstream, see 
https://lists.freebsd.org/pipermail/svn-ports-head/2017-March/143196.html
which just has not happened so far.

This will be good to have on the Wine 4.0 branch as well.

Gerald


From: Gleb Smirnoff <glebius at FreeBSD.org>
Signed-off-by: Gerald Pfeifer <gerald at pfeifer.com>
---
 dlls/iphlpapi/ipstats.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/dlls/iphlpapi/ipstats.c b/dlls/iphlpapi/ipstats.c
index 0b762ebc8e..0e07853b30 100644
--- a/dlls/iphlpapi/ipstats.c
+++ b/dlls/iphlpapi/ipstats.c
@@ -2226,6 +2226,15 @@ DWORD build_tcp_table( TCP_TABLE_CLASS class, void **tablep, BOOL order, HANDLE
              pXIG->xig_len > sizeof (struct xinpgen);
              pXIG = (struct xinpgen *)((char *)pXIG + pXIG->xig_len))
         {
+#if __FreeBSD_version >= 1200026
+            struct xtcpcb *pTCPData;
+            struct xinpcb *pINData;
+            struct xsocket *pSockData;
+
+            pTCPData = (struct xtcpcb *)pXIG;
+            pINData = &pTCPData->xt_inp;
+            pSockData = &pINData->xi_socket;
+#else
             struct tcpcb *pTCPData = NULL;
             struct inpcb *pINData;
             struct xsocket *pSockData;
@@ -2233,6 +2242,7 @@ DWORD build_tcp_table( TCP_TABLE_CLASS class, void **tablep, BOOL order, HANDLE
             pTCPData = &((struct xtcpcb *)pXIG)->xt_tp;
             pINData = &((struct xtcpcb *)pXIG)->xt_inp;
             pSockData = &((struct xtcpcb *)pXIG)->xt_socket;
+#endif
 
             /* Ignore sockets for other protocols */
             if (pSockData->xso_protocol != IPPROTO_TCP)
@@ -2538,11 +2548,19 @@ DWORD build_udp_table( UDP_TABLE_CLASS class, void **tablep, BOOL order, HANDLE
              pXIG->xig_len > sizeof (struct xinpgen);
              pXIG = (struct xinpgen *)((char *)pXIG + pXIG->xig_len))
         {
+#if __FreeBSD_version >= 1200026
+            struct xinpcb *pINData;
+            struct xsocket *pSockData;
+
+            pINData = (struct xinpcb *)pXIG;
+            pSockData = &pINData->xi_socket;
+#else
             struct inpcb *pINData;
             struct xsocket *pSockData;
 
             pINData = &((struct xinpcb *)pXIG)->xi_inp;
             pSockData = &((struct xinpcb *)pXIG)->xi_socket;
+#endif
 
             /* Ignore sockets for other protocols */
             if (pSockData->xso_protocol != IPPROTO_UDP)
-- 
2.22.0



More information about the wine-devel mailing list