goto err;
}
- /* cast to short because of win16 winsock definition */
- if ((short)he->h_addrtype != AF_INET)
+ if (he->h_addrtype != AF_INET)
{
BIOerr(BIO_F_BIO_GET_HOST_IP,BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET);
goto err;
int BIO_sock_error(int sock)
{
int j,i;
- int size;
+ union { size_t s; int i; } size;
-#if defined(OPENSSL_SYS_BEOS_R5)
- return 0;
-#endif
-
- size=sizeof(int);
+ /* heuristic way to adapt for platforms that expect 64-bit optlen */
+ size.s=0, size.i=sizeof(j);
/* Note: under Windows the third parameter is of type (char *)
* whereas under other systems it is (void *) if you don't have
* a cast it will choke the compiler: if you do have a cast then
#ifdef __DJGPP__
i=ioctlsocket(fd,type,(char *)arg);
#else
- i=ioctlsocket(fd,type,arg);
+# if defined(OPENSSL_SYS_VMS)
+ /*-
+ * 2011-02-18 SMS.
+ * VMS ioctl() can't tolerate a 64-bit "void *arg", but we
+ * observe that all the consumers pass in an "unsigned long *",
+ * so we arrange a local copy with a short pointer, and use
+ * that, instead.
+ */
+# if __INITIAL_POINTER_SIZE == 64
+# define ARG arg_32p
+# pragma pointer_size save
+# pragma pointer_size 32
+ unsigned long arg_32;
+ unsigned long *arg_32p;
+# pragma pointer_size restore
+ arg_32p = &arg_32;
+ arg_32 = *((unsigned long *) arg);
+# else /* __INITIAL_POINTER_SIZE == 64 */
+# define ARG arg
+# endif /* __INITIAL_POINTER_SIZE == 64 [else] */
+# else /* defined(OPENSSL_SYS_VMS) */
+# define ARG arg
+# endif /* defined(OPENSSL_SYS_VMS) [else] */
+
+ i=ioctlsocket(fd,type,ARG);
#endif /* __DJGPP__ */
if (i < 0)
SYSerr(SYS_F_IOCTLSOCKET,get_last_socket_error());
struct sockaddr_in6 sa_in6;
#endif
} server,client;
- int s=INVALID_SOCKET,cs;
+ int s=INVALID_SOCKET,cs,addrlen;
unsigned char ip[4];
unsigned short port;
char *str=NULL,*e;
* note that commonly IPv6 wildchard socket can service
* IPv4 connections just as well... */
memset(&hint,0,sizeof(hint));
+ hint.ai_flags = AI_PASSIVE;
if (h)
{
if (strchr(h,':'))
#endif
}
else if (h[0]=='*' && h[1]=='\0')
+ {
+ hint.ai_family = AF_INET;
h=NULL;
+ }
}
if ((*p_getaddrinfo.f)(h,p,&hint,&res)) break;
- memcpy(&server, res->ai_addr,
- res->ai_addrlen<=sizeof(server)?res->ai_addrlen:sizeof(server));
+ addrlen = res->ai_addrlen<=sizeof(server) ?
+ res->ai_addrlen :
+ sizeof(server);
+ memcpy(&server, res->ai_addr, addrlen);
(*p_freeaddrinfo.f)(res);
goto again;
memset((char *)&server,0,sizeof(server));
server.sa_in.sin_family=AF_INET;
server.sa_in.sin_port=htons(port);
+ addrlen = sizeof(server.sa_in);
if (h == NULL || strcmp(h,"*") == 0)
server.sa_in.sin_addr.s_addr=INADDR_ANY;
bind_mode=BIO_BIND_NORMAL;
}
#endif
- if (bind(s,&server.sa,sizeof(server)) == -1)
+ if (bind(s,&server.sa,addrlen) == -1)
{
#ifdef SO_REUSEADDR
err_num=get_last_socket_error();
if ((bind_mode == BIO_BIND_REUSEADDR_IF_UNUSED) &&
+#ifdef OPENSSL_SYS_WINDOWS
+ /* Some versions of Windows define EADDRINUSE to
+ * a dummy value.
+ */
+ (err_num == WSAEADDRINUSE))
+#else
(err_num == EADDRINUSE))
+#endif
{
client = server;
if (h == NULL || strcmp(h,"*") == 0)
if (cs != INVALID_SOCKET)
{
int ii;
- ii=connect(cs,&client.sa,sizeof(client));
+ ii=connect(cs,&client.sa,addrlen);
closesocket(cs);
if (ii == INVALID_SOCKET)
{
#endif
return(ret == 0);
}
-#endif
int BIO_socket_nbio(int s, int mode)
{
#endif
return(ret == 0);
}
+#endif