From: Richard Levitte Date: Mon, 13 Jun 2005 03:23:50 +0000 (+0000) Subject: Netware patch submitted by Verdon Walker" in PR X-Git-Tag: OpenSSL_0_9_8k^2~2021 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=b764ab9537458b37d247a4f7b6d6a5b9657ff6d6;p=oweals%2Fopenssl.git Netware patch submitted by Verdon Walker" in PR 1107. He says: This is a followup to the NetWare patch that was applied to beta3. It does the following: - Fixes a problem in the CLib build with undefined symbols. - Adds the ability to use BSD sockets as the default for the OpenSSL socket BIO. NetWare supports 2 flavors of sockets and our Apache developers need BSD sockets as a configurable option when building OpenSSL. This adds that for them. - Updates to the INSTALL.NW file to explain new options. I have tried very hard to make sure all the changes are in NetWare specific files or guarded carefully to make sure they only impact NetWare builds. I have tested the Windows build to make sure it does not break that since we have made changes to mk1mf.pl. We are still working the gcc cross compile for NetWare issue and hope to have a patch for that before beta 6 is released. --- diff --git a/Configure b/Configure index 22eb550ffa..934d36f3c9 100755 --- a/Configure +++ b/Configure @@ -486,7 +486,10 @@ my %table=( # netware-clib => legacy CLib c-runtime support "netware-clib", "mwccnlm::::::BN_LLONG ${x86_gcc_opts}::", # netware-libc => LibC/NKS support +# NetWare defaults socket bio to WinSock sockets. However, the LibC build can be +# configured to use BSD sockets instead. "netware-libc", "mwccnlm::::::BN_LLONG ${x86_gcc_opts}::", +"netware-libc-bsdsock", "mwccnlm::::::BN_LLONG ${x86_gcc_opts}::", "netware-libc-gcc", "i586-netware-gcc:-nostdinc -I/ndk/libc/include -I/ndk/libc/include/winsock -DL_ENDIAN -DNETWARE_LIBC -DOPENSSL_SYSNAME_NETWARE -DTERMIO -O2 -Wall:::::BN_LLONG ${x86_gcc_opts}::", # DJGPP @@ -530,7 +533,7 @@ my %table=( my @MK1MF_Builds=qw(VC-WIN64I VC-WIN64A VC-NT VC-CE VC-WIN32 - BC-32 OS2-EMX netware-clib netware-libc); + BC-32 OS2-EMX netware-clib netware-libc netware-libc-bsdsock); my $idx = 0; my $idx_cc = $idx++; diff --git a/INSTALL.NW b/INSTALL.NW index 3dae72a144..92715cbbf3 100644 --- a/INSTALL.NW +++ b/INSTALL.NW @@ -32,6 +32,10 @@ The necessary LibC functionality ships with NetWare 6. However, earlier NetWare 5.x versions will require updates in order to run the OpenSSL LibC build. +As of June 2005, the LibC build can be configured to use BSD sockets instead +of WinSock sockets. Call Configure (usually through netware\build.bat) using +a target of "netware-libc-bsdsock" instead of "netware-libc". + REQUIRED TOOLS: --------------- @@ -126,7 +130,8 @@ following tools may be required: NOTE: The LibC SDK includes the necessary WinSock2 support. It It is not necessary to download the WinSock2 Developer when building - for LibC. + for LibC. The LibC SDK also includes the appropriate BSD socket support + if configuring to use BSD sockets. BUILDING: @@ -177,8 +182,9 @@ the assembly code. Always run build.bat from the "openssl" directory. netware\build [target] [debug opts] [assembly opts] [configure opts] - target - "netware-clib" - CLib NetWare build - - "netware-libc" - LibC NetWare build + target - "netware-clib" - CLib NetWare build (WinSock Sockets) + - "netware-libc" - LibC NetWare build (WinSock Sockets) + - "netware-libc-bsdsock" - LibC NetWare build (BSD Sockets) debug opts - "debug" - build debug @@ -197,25 +203,29 @@ the assembly code. Always run build.bat from the "openssl" directory. LibC build, non-debug, using NASM assembly: netware\build.bat netware-libc nw-nasm + LibC build, BSD sockets, non-debug, without assembly: + netware\build.bat netware-libc-bsdsock no-asm + Running build.bat generates a make file to be processed by your make tool (gmake or nmake): - CLIB ex: gmake -f netware\nlm_clib.mak + CLIB ex: gmake -f netware\nlm_clib_dbg.mak LibC ex: gmake -f netware\nlm_libc.mak + LibC ex: gmake -f netware\nlm_libc_bsdsock.mak You can also run the build scripts manually if you do not want to use the build.bat file. Run the following scripts in the "\openssl" subdirectory (in the order listed below): - perl configure no-asm [other config opts] [netware-clib|netware-libc] + perl configure no-asm [other config opts] [netware-clib|netware-libc|netware-libc-bsdsock] configures no assembly build for specified netware environment (CLIB or LibC). perl util\mkfiles.pl >MINFO generates a listing of source files (used by mk1mf) - perl util\mk1mf.pl no-asm [other config opts] [netware-clib|netware-libc >netware\nlm.mak + perl util\mk1mf.pl no-asm [other config opts] [netware-clib|netware-libc|netware-libc-bsdsock >netware\nlm.mak generates the makefile for NetWare gmake -f netware\nlm.mak diff --git a/Netware/build.bat b/Netware/build.bat index ee73da4dff..50ee7d51d0 100644 --- a/Netware/build.bat +++ b/Netware/build.bat @@ -6,14 +6,15 @@ rem rem usage: rem build [target] [debug opts] [assembly opts] [configure opts] rem -rem target - "netware-clib" - CLib NetWare build -rem - "netware-libc" - LibC NKS NetWare build +rem target - "netware-clib" - CLib NetWare build (WinSock Sockets) +rem - "netware-libc" - LibC NKS NetWare build (WinSock Sockets) +rem - "netware-libc-bsdsock" - LibC NKS NetWare build (BSD Sockets) rem rem debug opts - "debug" - build debug rem rem assembly opts - "nw-mwasm" - use Metrowerks assembler -rem "nw-nasm" - use NASM assembler -rem "no-asm" - don't use assembly +rem - "nw-nasm" - use NASM assembler +rem - "no-asm" - don't use assembly rem rem configure opts- all unrecognized arguments are passed to the rem perl configure script @@ -76,6 +77,8 @@ if "%1" == "netware-clib" set BLD_TARGET=netware-clib if "%1" == "netware-clib" set ARG_PROCESSED=YES if "%1" == "netware-libc" set BLD_TARGET=netware-libc if "%1" == "netware-libc" set ARG_PROCESSED=YES +if "%1" == "netware-libc-bsdsock" set BLD_TARGET=netware-libc-bsdsock +if "%1" == "netware-libc-bsdsock" set ARG_PROCESSED=YES rem If we didn't recognize the argument, consider it an option for config if "%ARG_PROCESSED%" == "NO" set CONFIG_OPTS=%CONFIG_OPTS% %1 @@ -92,6 +95,7 @@ rem build the nlm make file name which includes target and debug info set NLM_MAKE= if "%BLD_TARGET%" == "netware-clib" set NLM_MAKE=netware\nlm_clib if "%BLD_TARGET%" == "netware-libc" set NLM_MAKE=netware\nlm_libc +if "%BLD_TARGET%" == "netware-libc-bsdsock" set NLM_MAKE=netware\nlm_libc_bsdsock if "%DEBUG%" == "" set NLM_MAKE=%NLM_MAKE%.mak if "%DEBUG%" == "debug" set NLM_MAKE=%NLM_MAKE%_dbg.mak @@ -184,8 +188,9 @@ echo . No build target specified!!! echo . echo . usage: build [target] [debug opts] [assembly opts] [configure opts] echo . -echo . target - "netware-clib" - CLib NetWare build -echo . - "netware-libc" - LibC NKS NetWare build +echo . target - "netware-clib" - CLib NetWare build (WinSock Sockets) +echo . - "netware-libc" - LibC NKS NetWare build (WinSock Sockets) +echo . - "netware-libc-bsdsock" - LibC NKS NetWare build (BSD Sockets) echo . echo . debug opts - "debug" - build debug echo . diff --git a/apps/s_socket.c b/apps/s_socket.c index c022585978..4a922e16a0 100644 --- a/apps/s_socket.c +++ b/apps/s_socket.c @@ -87,8 +87,12 @@ typedef unsigned int u_int; #ifndef OPENSSL_NO_SOCK +#if defined(OPENSSL_SYS_NETWARE) && defined(NETWARE_BSDSOCK) +#include "netdb.h" +#endif + static struct hostent *GetHostByName(char *name); -#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_NETWARE) +#if defined(OPENSSL_SYS_WINDOWS) || (defined(OPENSSL_SYS_NETWARE) && !defined(NETWARE_BSDSOCK)) static void ssl_sock_cleanup(void); #endif static int ssl_sock_init(void); @@ -104,7 +108,7 @@ static int host_ip(char *str, unsigned char ip[4]); #define SOCKET_PROTOCOL IPPROTO_TCP #endif -#ifdef OPENSSL_SYS_NETWARE +#if defined(OPENSSL_SYS_NETWARE) && !defined(NETWARE_BSDSOCK) static int wsa_init_done=0; #endif @@ -156,7 +160,7 @@ static void ssl_sock_cleanup(void) WSACleanup(); } } -#elif defined(OPENSSL_SYS_NETWARE) +#elif defined(OPENSSL_SYS_NETWARE) && !defined(NETWARE_BSDSOCK) static void sock_cleanup(void) { if (wsa_init_done) @@ -199,7 +203,7 @@ static int ssl_sock_init(void) SetWindowLong(topWnd,GWL_WNDPROC,(LONG)lpTopHookProc); #endif /* OPENSSL_SYS_WIN16 */ } -#elif defined(OPENSSL_SYS_NETWARE) +#elif defined(OPENSSL_SYS_NETWARE) && !defined(NETWARE_BSDSOCK) WORD wVerReq; WSADATA wsaData; int err; @@ -398,7 +402,7 @@ redoit: ret=accept(acc_sock,(struct sockaddr *)&from,(void *)&len); if (ret == INVALID_SOCKET) { -#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_NETWARE) +#if defined(OPENSSL_SYS_WINDOWS) || (defined(OPENSSL_SYS_NETWARE) && !defined(NETWARE_BSDSOCK)) i=WSAGetLastError(); BIO_printf(bio_err,"accept error %d\n",i); #else diff --git a/crypto/bio/b_sock.c b/crypto/bio/b_sock.c index 268517fdc3..4b3860b991 100644 --- a/crypto/bio/b_sock.c +++ b/crypto/bio/b_sock.c @@ -62,6 +62,9 @@ #define USE_SOCKETS #include "cryptlib.h" #include +#if defined(OPENSSL_SYS_NETWARE) && defined(NETWARE_BSDSOCK) +#include "netdb.h" +#endif #ifndef OPENSSL_NO_SOCK @@ -79,7 +82,7 @@ #define MAX_LISTEN 32 #endif -#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_NETWARE) +#if defined(OPENSSL_SYS_WINDOWS) || (defined(OPENSSL_SYS_NETWARE) && !defined(NETWARE_BSDSOCK)) static int wsa_init_done=0; #endif @@ -474,7 +477,7 @@ int BIO_sock_init(void) return (-1); #endif -#if defined(OPENSSL_SYS_NETWARE) +#if defined(OPENSSL_SYS_NETWARE) && !defined(NETWARE_BSDSOCK) WORD wVerReq; WSADATA wsaData; int err; @@ -512,7 +515,7 @@ void BIO_sock_cleanup(void) #endif WSACleanup(); } -#elif defined(OPENSSL_SYS_NETWARE) +#elif defined(OPENSSL_SYS_NETWARE) && !defined(NETWARE_BSDSOCK) if (wsa_init_done) { wsa_init_done=0; diff --git a/e_os.h b/e_os.h index 54982cee00..06e1fe2979 100644 --- a/e_os.h +++ b/e_os.h @@ -182,10 +182,18 @@ extern "C" { #define readsocket(s,b,n) read((s),(b),(n)) #define writesocket(s,b,n) write((s),(char *)(b),(n)) #elif defined(OPENSSL_SYS_NETWARE) +#if defined(NETWARE_BSDSOCK) +#define get_last_socket_error() errno +#define clear_socket_error() errno=0 +#define closesocket(s) close(s) +#define readsocket(s,b,n) recv((s),(b),(n),0) +#define writesocket(s,b,n) send((s),(b),(n),0) +#else #define get_last_socket_error() WSAGetLastError() #define clear_socket_error() WSASetLastError(0) #define readsocket(s,b,n) recv((s),(b),(n),0) #define writesocket(s,b,n) send((s),(b),(n),0) +#endif #else #define get_last_socket_error() errno #define clear_socket_error() errno=0 @@ -436,9 +444,17 @@ extern HINSTANCE _hInstance; # define SHUTDOWN2(fd) MacSocket_close(fd) # elif defined(OPENSSL_SYS_NETWARE) - /* NetWare uses the WinSock2 interfaces + /* NetWare uses the WinSock2 interfaces by default, but can be configured for BSD */ -# include +# if defined(NETWARE_BSDSOCK) +# include +# include +# include +# include +# define INVALID_SOCKET (int)(~0) +# else +# include +# endif # define SSLeay_Write(a,b,c) send((a),(b),(c),0) # define SSLeay_Read(a,b,c) recv((a),(b),(c),0) # define SHUTDOWN(fd) { shutdown((fd),0); closesocket(fd); } diff --git a/util/mk1mf.pl b/util/mk1mf.pl index 5d16b5839e..fa0fbe3673 100755 --- a/util/mk1mf.pl +++ b/util/mk1mf.pl @@ -33,8 +33,9 @@ $infile="MINFO"; "ultrix-mips","DEC mips ultrix", "FreeBSD","FreeBSD distribution", "OS2-EMX", "EMX GCC OS/2", - "netware-clib", "CodeWarrior for NetWare - CLib", - "netware-libc", "CodeWarrior for NetWare - LibC", + "netware-clib", "CodeWarrior for NetWare - CLib - with WinSock Sockets", + "netware-libc", "CodeWarrior for NetWare - LibC - with WinSock Sockets", + "netware-libc-bsdsock", "CodeWarrior for NetWare - LibC - with BSD Sockets", "default","cc under unix", ); @@ -163,9 +164,11 @@ elsif ($platform eq "OS2-EMX") $wc=1; require 'OS2-EMX.pl'; } -elsif (($platform eq "netware-clib") || ($platform eq "netware-libc")) +elsif (($platform eq "netware-clib") || ($platform eq "netware-libc") || + ($platform eq "netware-libc-bsdsock")) { - $LIBC=1 if $platform eq "netware-libc"; + $LIBC=1 if $platform eq "netware-libc" || $platform eq "netware-libc-bsdsock"; + $BSDSOCK=1 if $platform eq "netware-libc-bsdsock"; require 'netware.pl'; } else diff --git a/util/pl/netware.pl b/util/pl/netware.pl index 2258a39920..c05789b22f 100644 --- a/util/pl/netware.pl +++ b/util/pl/netware.pl @@ -2,19 +2,25 @@ # # The import files and other misc imports needed to link +@misc_imports = ("GetProcessSwitchCount", "RunningProcess", + "GetSuperHighResolutionTimer"); if ($LIBC) { - @import_files = ("libc.imp", "ws2nlm.imp"); + @import_files = ("libc.imp"); @module_files = ("libc"); } else { # clib build - @import_files = ("clib.imp", "ws2nlm.imp"); + @import_files = ("clib.imp"); @module_files = ("clib"); + push(@misc_imports, "_rt_modu64%16", "_rt_divu64%16"); } -@misc_imports = ("GetProcessSwitchCount", "RunningProcess", - "GetSuperHighResolutionTimer" ); +if (!$BSDSOCK) +{ + push(@import_files, "ws2nlm.imp"); +} + # The "IMPORTS" environment variable must be set and point to the location # where import files (*.imp) can be found. @@ -122,6 +128,12 @@ else $lflags.=" -entry _Prelude -exit _Stop"; } +# If BSD Socket support is requested, set a define for the compiler +if ($BSDSOCK) +{ + $cflags.=" -DNETWARE_BSDSOCK"; +} + # linking stuff # for the output directories use the mk1mf.pl values with "_nw" appended