dlls/winsock/socket breakage

Gerald Pfeifer gerald at pfeifer.com
Sun Sep 12 16:51:26 CDT 2004


[ Adding wine-patches.  Alexandre, this is for you! ]

On Sun, 12 Sep 2004, Roderick Colenbrander wrote:
> Currently I don't have access to the machine I use for wine stuff, so I
> haven't been able to create a real patch. Anyway I'll try to assist you
> fixing the problem as it isn't that difficult to fix.

This is most welcome.  Thanks a lot, I really appreciate your help!

> //setsockopt code
> struct ipx val; (perhaps we should retrieve this one using a getsockopt call
> and then we set modified one)
> val.ipx_pt = *opt_val;
> setsockopt(fd, 0, SO_DEFAULT_HEADERS, &val, sizeof(struct ipx));
> *opt_val = (int)val.ipx_pt;
>
> I hope this helps.

The last line of code was only a trick to see whether I'm paying 
attention, wasn't it? ;-)

I added a bit of error checking, similiar to the general case, and
guarded variables by #ifdefs as well.  Current winehq.com CVS plus
the following patch was built on FreeBSD 4.10 and SUSE LINUX 9.1.

Thanks again,
Gerald

ChangeLog:
Roderick Colenbrander <thunderbird2k at gmx.net>
Gerald Pfeifer <gerald at pfeifer.com>
Make WS2_Send(), WS_getsockopt(), and WS_setsockopt() work on FreeBSD.

Index: socket.c
===================================================================
RCS file: /home/wine/wine/dlls/winsock/socket.c,v
retrieving revision 1.155
diff -u -3 -p -r1.155 socket.c
--- socket.c	7 Sep 2004 20:47:03 -0000	1.155
+++ socket.c	12 Sep 2004 21:19:09 -0000
@@ -1108,6 +1108,7 @@ static int WS2_send ( int fd, struct iov
  #ifdef HAVE_IPX
          if(to->sa_family == WS_AF_IPX)
          {
+#ifndef __FreeBSD__
              struct sockaddr_ipx* uipx = (struct sockaddr_ipx*)hdr.msg_name;
              int val=0;
              int len=sizeof(int);
@@ -1122,6 +1123,7 @@ static int WS2_send ( int fd, struct iov
                  TRACE("ptype: %d (fd:%d)\n", val, fd);
                  uipx->sipx_type = val;
              }
+#endif
          }
  #endif

@@ -1574,6 +1576,10 @@ INT WINAPI WS_getsockopt(SOCKET s, INT l
  #ifdef HAVE_IPX
      if(level == NSPROTO_IPX)
      {
+#ifdef __FreeBSD__
+	struct ipx val;
+	socklen_t len=sizeof(struct ipx);
+#endif
      	struct WS_sockaddr_ipx addr;
  	IPX_ADDRESS_DATA *data;
  	int namelen;
@@ -1581,11 +1587,20 @@ INT WINAPI WS_getsockopt(SOCKET s, INT l
  	{
  	    case IPX_PTYPE:
  		fd = get_sock_fd( s, 0, NULL );
- 
+#ifdef __FreeBSD__
+
+		if(getsockopt(fd, 0, SO_DEFAULT_HEADERS, &val, &len)
+		    == -1 )
+		{
+		    return SOCKET_ERROR;
+		}
+                *optval = (int)val.ipx_pt;
+#else
  		if(getsockopt(fd, SOL_IPX, IPX_TYPE, optval, optlen) == -1)
  		{
  		    return SOCKET_ERROR;
  		}
+#endif
  		TRACE("ptype: %d (fd: %d)\n", *(int*)optval, fd);
      		release_sock_fd( s, fd );

@@ -2305,18 +2320,30 @@ int WINAPI WS_setsockopt(SOCKET s, int l
  	switch(optname)
  	{
  	    case IPX_PTYPE:
+	    {
+#ifdef __FreeBSD__
+		struct ipx val;
+#endif
  		fd = get_sock_fd( s, 0, NULL );
  		TRACE("trying to set IPX_PTYPE: %d (fd: %d)\n", *(int*)optval, fd);

  		/* We try to set the ipx type on ipx socket level. */
+#ifdef __FreeBSD__
+		/* 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));
+#else
  		if(setsockopt(fd, SOL_IPX, IPX_TYPE, optval, optlen) == -1)
  		{
  		    ERR("IPX: could not set ipx option type; expect weird behaviour\n");
  		    return SOCKET_ERROR;
  		}
+#endif
      		release_sock_fd( s, fd );
  		return 0;
  		break;
+	    }
  	    case IPX_FILTERPTYPE:
  		/* Sets the receive filter packet type, at the moment we don't support it */
  		FIXME("IPX_FILTERPTYPE: %x\n", *optval);



More information about the wine-patches mailing list