#include "cryptlib.h"
#include <openssl/bio.h>
#if defined(OPENSSL_SYS_NETWARE) && defined(NETWARE_BSDSOCK)
-#include "netdb.h"
+#include <netdb.h>
+#if defined(NETWARE_CLIB)
+#include <sys/ioctl.h>
+NETDB_DEFINE_CONTEXT
+#endif
#endif
#ifndef OPENSSL_NO_SOCK
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;
/* Note: under VMS with SOCKETSHR, it seems like the first
* parameter is 'char *', instead of 'const char *'
*/
- s=getservbyname(
#ifndef CONST_STRICT
- (char *)
+ s=getservbyname((char *)str,"tcp");
+#else
+ s=getservbyname(str,"tcp");
#endif
- str,"tcp");
if(s != NULL)
*port_ptr=ntohs((unsigned short)s->s_port);
CRYPTO_w_unlock(CRYPTO_LOCK_GETSERVBYNAME);
#if 1
/* Caching gethostbyname() results forever is wrong,
* so we have to let the true gethostbyname() worry about this */
+#if (defined(NETWARE_BSDSOCK) && !defined(__NOVELL_LIBC__))
+ return gethostbyname((char*)name);
+#else
return gethostbyname(name);
+#endif
#else
struct hostent *ret;
int i,lowi=0,j;
/* Note: under VMS with SOCKETSHR, it seems like the first
* parameter is 'char *', instead of 'const char *'
*/
- ret=gethostbyname(
# ifndef CONST_STRICT
- (char *)
+ ret=gethostbyname((char *)name);
+# else
+ ret=gethostbyname(name);
# endif
- name);
if (ret == NULL)
goto end;
{
int err;
-#ifdef SIGINT
- signal(SIGINT,(void (*)(int))BIO_sock_cleanup);
-#endif
wsa_init_done=1;
memset(&wsa_state,0,sizeof(wsa_state));
/* Not making wsa_state available to the rest of the
if (!wsa_init_done)
{
-
-# ifdef SIGINT
- signal(SIGINT,(void (*)(int))BIO_sock_cleanup);
-# endif
-
wsa_init_done=1;
wVerReq = MAKEWORD( 2, 0 );
err = WSAStartup(wVerReq,&wsaData);
if (wsa_init_done)
{
wsa_init_done=0;
-#ifndef OPENSSL_SYS_WINCE
+#if 0 /* this call is claimed to be non-present in Winsock2 */
WSACancelBlockingCall();
#endif
WSACleanup();
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)
-# 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)
{