diff options
Diffstat (limited to 'src/lib/libcrypto/bio/b_sock.c')
-rw-r--r-- | src/lib/libcrypto/bio/b_sock.c | 60 |
1 files changed, 13 insertions, 47 deletions
diff --git a/src/lib/libcrypto/bio/b_sock.c b/src/lib/libcrypto/bio/b_sock.c index ead477d8a2..c851298d1e 100644 --- a/src/lib/libcrypto/bio/b_sock.c +++ b/src/lib/libcrypto/bio/b_sock.c | |||
@@ -56,21 +56,14 @@ | |||
56 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
57 | */ | 57 | */ |
58 | 58 | ||
59 | #ifndef OPENSSL_NO_SOCK | ||
60 | |||
59 | #include <stdio.h> | 61 | #include <stdio.h> |
60 | #include <stdlib.h> | 62 | #include <stdlib.h> |
61 | #include <errno.h> | 63 | #include <errno.h> |
62 | #define USE_SOCKETS | 64 | #define USE_SOCKETS |
63 | #include "cryptlib.h" | 65 | #include "cryptlib.h" |
64 | #include <openssl/bio.h> | 66 | #include <openssl/bio.h> |
65 | #if defined(OPENSSL_SYS_NETWARE) && defined(NETWARE_BSDSOCK) | ||
66 | #include <netdb.h> | ||
67 | #if defined(NETWARE_CLIB) | ||
68 | #include <sys/ioctl.h> | ||
69 | NETDB_DEFINE_CONTEXT | ||
70 | #endif | ||
71 | #endif | ||
72 | |||
73 | #ifndef OPENSSL_NO_SOCK | ||
74 | 67 | ||
75 | #ifdef OPENSSL_SYS_WIN16 | 68 | #ifdef OPENSSL_SYS_WIN16 |
76 | #define SOCKET_PROTOCOL 0 /* more microsoft stupidity */ | 69 | #define SOCKET_PROTOCOL 0 /* more microsoft stupidity */ |
@@ -86,7 +79,7 @@ NETDB_DEFINE_CONTEXT | |||
86 | #define MAX_LISTEN 32 | 79 | #define MAX_LISTEN 32 |
87 | #endif | 80 | #endif |
88 | 81 | ||
89 | #if defined(OPENSSL_SYS_WINDOWS) || (defined(OPENSSL_SYS_NETWARE) && !defined(NETWARE_BSDSOCK)) | 82 | #ifdef OPENSSL_SYS_WINDOWS |
90 | static int wsa_init_done=0; | 83 | static int wsa_init_done=0; |
91 | #endif | 84 | #endif |
92 | 85 | ||
@@ -182,11 +175,11 @@ int BIO_get_port(const char *str, unsigned short *port_ptr) | |||
182 | /* Note: under VMS with SOCKETSHR, it seems like the first | 175 | /* Note: under VMS with SOCKETSHR, it seems like the first |
183 | * parameter is 'char *', instead of 'const char *' | 176 | * parameter is 'char *', instead of 'const char *' |
184 | */ | 177 | */ |
178 | s=getservbyname( | ||
185 | #ifndef CONST_STRICT | 179 | #ifndef CONST_STRICT |
186 | s=getservbyname((char *)str,"tcp"); | 180 | (char *) |
187 | #else | ||
188 | s=getservbyname(str,"tcp"); | ||
189 | #endif | 181 | #endif |
182 | str,"tcp"); | ||
190 | if(s != NULL) | 183 | if(s != NULL) |
191 | *port_ptr=ntohs((unsigned short)s->s_port); | 184 | *port_ptr=ntohs((unsigned short)s->s_port); |
192 | CRYPTO_w_unlock(CRYPTO_LOCK_GETSERVBYNAME); | 185 | CRYPTO_w_unlock(CRYPTO_LOCK_GETSERVBYNAME); |
@@ -364,11 +357,7 @@ struct hostent *BIO_gethostbyname(const char *name) | |||
364 | #if 1 | 357 | #if 1 |
365 | /* Caching gethostbyname() results forever is wrong, | 358 | /* Caching gethostbyname() results forever is wrong, |
366 | * so we have to let the true gethostbyname() worry about this */ | 359 | * so we have to let the true gethostbyname() worry about this */ |
367 | #if (defined(NETWARE_BSDSOCK) && !defined(__NOVELL_LIBC__)) | ||
368 | return gethostbyname((char*)name); | ||
369 | #else | ||
370 | return gethostbyname(name); | 360 | return gethostbyname(name); |
371 | #endif | ||
372 | #else | 361 | #else |
373 | struct hostent *ret; | 362 | struct hostent *ret; |
374 | int i,lowi=0,j; | 363 | int i,lowi=0,j; |
@@ -408,11 +397,11 @@ struct hostent *BIO_gethostbyname(const char *name) | |||
408 | /* Note: under VMS with SOCKETSHR, it seems like the first | 397 | /* Note: under VMS with SOCKETSHR, it seems like the first |
409 | * parameter is 'char *', instead of 'const char *' | 398 | * parameter is 'char *', instead of 'const char *' |
410 | */ | 399 | */ |
400 | ret=gethostbyname( | ||
411 | # ifndef CONST_STRICT | 401 | # ifndef CONST_STRICT |
412 | ret=gethostbyname((char *)name); | 402 | (char *) |
413 | # else | ||
414 | ret=gethostbyname(name); | ||
415 | # endif | 403 | # endif |
404 | name); | ||
416 | 405 | ||
417 | if (ret == NULL) | 406 | if (ret == NULL) |
418 | goto end; | 407 | goto end; |
@@ -464,6 +453,9 @@ int BIO_sock_init(void) | |||
464 | { | 453 | { |
465 | int err; | 454 | int err; |
466 | 455 | ||
456 | #ifdef SIGINT | ||
457 | signal(SIGINT,(void (*)(int))BIO_sock_cleanup); | ||
458 | #endif | ||
467 | wsa_init_done=1; | 459 | wsa_init_done=1; |
468 | memset(&wsa_state,0,sizeof(wsa_state)); | 460 | memset(&wsa_state,0,sizeof(wsa_state)); |
469 | if (WSAStartup(0x0101,&wsa_state)!=0) | 461 | if (WSAStartup(0x0101,&wsa_state)!=0) |
@@ -481,26 +473,6 @@ int BIO_sock_init(void) | |||
481 | if (sock_init()) | 473 | if (sock_init()) |
482 | return (-1); | 474 | return (-1); |
483 | #endif | 475 | #endif |
484 | |||
485 | #if defined(OPENSSL_SYS_NETWARE) && !defined(NETWARE_BSDSOCK) | ||
486 | WORD wVerReq; | ||
487 | WSADATA wsaData; | ||
488 | int err; | ||
489 | |||
490 | if (!wsa_init_done) | ||
491 | { | ||
492 | wsa_init_done=1; | ||
493 | wVerReq = MAKEWORD( 2, 0 ); | ||
494 | err = WSAStartup(wVerReq,&wsaData); | ||
495 | if (err != 0) | ||
496 | { | ||
497 | SYSerr(SYS_F_WSASTARTUP,err); | ||
498 | BIOerr(BIO_F_BIO_SOCK_INIT,BIO_R_WSASTARTUP); | ||
499 | return(-1); | ||
500 | } | ||
501 | } | ||
502 | #endif | ||
503 | |||
504 | return(1); | 476 | return(1); |
505 | } | 477 | } |
506 | 478 | ||
@@ -511,16 +483,10 @@ void BIO_sock_cleanup(void) | |||
511 | { | 483 | { |
512 | wsa_init_done=0; | 484 | wsa_init_done=0; |
513 | #ifndef OPENSSL_SYS_WINCE | 485 | #ifndef OPENSSL_SYS_WINCE |
514 | WSACancelBlockingCall(); /* Winsock 1.1 specific */ | 486 | WSACancelBlockingCall(); |
515 | #endif | 487 | #endif |
516 | WSACleanup(); | 488 | WSACleanup(); |
517 | } | 489 | } |
518 | #elif defined(OPENSSL_SYS_NETWARE) && !defined(NETWARE_BSDSOCK) | ||
519 | if (wsa_init_done) | ||
520 | { | ||
521 | wsa_init_done=0; | ||
522 | WSACleanup(); | ||
523 | } | ||
524 | #endif | 490 | #endif |
525 | } | 491 | } |
526 | 492 | ||