static int wsa_init_done=0;
#endif
-#if defined(OPENSSL_SYS_BEOS_BONE)
-/* BONE's IP6 support is incomplete */
-#undef AF_INET6
-#endif
-
#if 0
static unsigned long BIO_ghbn_hits=0L;
static unsigned long BIO_ghbn_miss=0L;
int BIO_get_accept_socket(char *host, int bind_mode)
{
int ret=0;
+#if OPENSSL_USE_IPV6
+# define ossl_sock_family(s) s.ss_family
+ struct sockaddr_storage server,client;
+#else
+# define ossl_sock_family(s) s.sa_family
struct sockaddr server,client;
+#endif
struct sockaddr_in *sa_in;
int s=INVALID_SOCKET,cs;
unsigned char ip[4];
if (strchr(h,':'))
{
if (h[1]=='\0') h=NULL;
-#ifdef AF_INET6
+#if OPENSSL_USE_IPV6
hint.ai_family = AF_INET6;
#else
h=NULL;
}
if ((*p_getaddrinfo.f)(h,p,&hint,&res)) break;
+#if OPENSSL_USE_IPV6
+ memcpy(&server, res->ai_addr, res->ai_addrlen);
+#else
server = *res->ai_addr;
+#endif
(*p_freeaddrinfo.f)(res);
goto again;
} while (0);
}
again:
- s=socket(server.sa_family,SOCK_STREAM,SOCKET_PROTOCOL);
+ s=socket(ossl_sock_family(server),SOCK_STREAM,SOCKET_PROTOCOL);
if (s == INVALID_SOCKET)
{
SYSerr(SYS_F_SOCKET,get_last_socket_error());
bind_mode=BIO_BIND_NORMAL;
}
#endif
- if (bind(s,&server,sizeof(server)) == -1)
+ if (bind(s,(struct sockaddr *)&server,sizeof(server)) == -1)
{
#ifdef SO_REUSEADDR
err_num=get_last_socket_error();
client = server;
if (h == NULL || strcmp(h,"*") == 0)
{
-#ifdef AF_INET6
- if (client.sa_family == AF_INET6)
+#if OPENSSL_USE_IPV6
+ if (ossl_sock_family(client) == AF_INET6)
{
struct sockaddr_in6 *sin6 =
(struct sockaddr_in6 *)&client;
}
else
#endif
- if (client.sa_family == AF_INET)
+ if (ossl_sock_family(client) == AF_INET)
{
- struct sockaddr_in *sin6 =
+ struct sockaddr_in *sin4 =
(struct sockaddr_in *)&client;
- sin6->sin_addr.s_addr=htonl(0x7F000001);
+ sin4->sin_addr.s_addr=htonl(0x7F000001);
}
else goto err;
}
- cs=socket(client.sa_family,SOCK_STREAM,SOCKET_PROTOCOL);
+ cs=socket(ossl_sock_family(client),SOCK_STREAM,SOCKET_PROTOCOL);
if (cs != INVALID_SOCKET)
{
int ii;
if (addr == NULL) goto end;
#ifdef EAI_FAMILY
-# if defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_BEOS_BONE) || defined(OPENSSL_SYS_MSDOS)
-# define SOCKLEN_T size_t
-# else
-# define SOCKLEN_T socklen_t
-#endif
do {
char h[NI_MAXHOST],s[NI_MAXSERV];
size_t nl;
static union { void *p;
- int (*f)(const struct sockaddr *,SOCKLEN_T,
+ int (*f)(const struct sockaddr *,size_t/*socklen_t*/,
char *,size_t,char *,size_t,int);
} p_getnameinfo = {NULL};
+ /* 2nd argument to getnameinfo is specified to
+ * be socklen_t. Unfortunately there is a number
+ * of environments where socklen_t is not defined.
+ * As it's passed by value, it's safe to pass it
+ * as size_t... <appro> */
if (p_getnameinfo.p==NULL)
{