[3/4] ws2_32: Use a helper function to set the IPX packet type (try 2)
Bruno Jesus
00cpxxx at gmail.com
Fri Dec 27 14:32:55 CST 2013
try2:
Fix build failure when HAS_IPX is not set.
-------------- next part --------------
---
dlls/ws2_32/socket.c | 55 +++++++++++++++++++++++++++++-----------------------
1 file changed, 31 insertions(+), 24 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index 36f2ac4..ac76e3c 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -1159,6 +1159,36 @@ convert_socktype_u2w(int unixsocktype) {
return -1;
}
+static int set_ipx_ptype(int sock, int ptype)
+{
+#ifdef HAS_IPX
+ int fd = get_sock_fd( sock, 0, NULL ), ret = 0;
+ TRACE("trying to set IPX_PTYPE: %d (fd: %d)\n", ptype, fd);
+
+ /* We try to set the ipx type on ipx socket level. */
+#ifdef SOL_IPX
+ if(setsockopt(fd, SOL_IPX, IPX_TYPE, &ptype, sizeof(ptype)) == -1)
+ {
+ ERR("IPX: could not set ipx option type; expect weird behaviour\n");
+ ret = SOCKET_ERROR;
+ }
+#else
+ {
+ struct ipx val;
+ /* Should we retrieve val using a getsockopt call and then
+ * set the modified one? */
+ val.ipx_pt = ptype;
+ setsockopt(fd, 0, SO_DEFAULT_HEADERS, &val, sizeof(struct ipx));
+ }
+#endif
+ release_sock_fd( sock, fd );
+ return ret;
+#else
+ WARN("IPX support is not enabled, can't set packet type\n");
+ return SOCKET_ERROR;
+#endif
+}
+
/* ----------------------------------- API -----
*
* Init / cleanup / error checking.
@@ -4766,33 +4796,11 @@ int WINAPI WS_setsockopt(SOCKET s, int level, int optname,
}
break; /* case WS_SOL_SOCKET */
-#ifdef HAS_IPX
case WS_NSPROTO_IPX:
switch(optname)
{
case IPX_PTYPE:
- fd = get_sock_fd( s, 0, NULL );
- TRACE("trying to set IPX_PTYPE: %d (fd: %d)\n", *(const int*)optval, fd);
-
- /* We try to set the ipx type on ipx socket level. */
-#ifdef SOL_IPX
- if(setsockopt(fd, SOL_IPX, IPX_TYPE, optval, optlen) == -1)
- {
- ERR("IPX: could not set ipx option type; expect weird behaviour\n");
- release_sock_fd( s, fd );
- return SOCKET_ERROR;
- }
-#else
- {
- struct ipx val;
- /* Should we retrieve val using a getsockopt call and then
- * set the modified one? */
- val.ipx_pt = *optval;
- setsockopt(fd, 0, SO_DEFAULT_HEADERS, &val, sizeof(struct ipx));
- }
-#endif
- release_sock_fd( s, fd );
- return 0;
+ return set_ipx_ptype(s, *(int*)optval);
case IPX_FILTERPTYPE:
/* Sets the receive filter packet type, at the moment we don't support it */
@@ -4805,7 +4813,6 @@ int WINAPI WS_setsockopt(SOCKET s, int level, int optname,
return SOCKET_ERROR;
}
break; /* case WS_NSPROTO_IPX */
-#endif
/* Levels WS_IPPROTO_TCP and WS_IPPROTO_IP convert directly */
case WS_IPPROTO_TCP:
--
1.8.3.2
More information about the wine-patches
mailing list