X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=apps%2Fs_time.c;h=181a7c82f66e80555824575e19084b3177b77536;hp=a43df6bb92ac66b36c423d1be8345ef19ac33810;hb=0bf23d9b2055223c6e7a1398d2243a65dfa4c30d;hpb=396f631458c34469bf12a575f0fccc44282e0d1d diff --git a/apps/s_time.c b/apps/s_time.c index a43df6bb92..181a7c82f6 100644 --- a/apps/s_time.c +++ b/apps/s_time.c @@ -67,26 +67,25 @@ #include #include -#if defined(NO_RSA) && !defined(NO_SSL2) -#define NO_SSL2 -#endif - -#ifdef NO_STDIO +#define USE_SOCKETS +#include "apps.h" +#ifdef OPENSSL_NO_STDIO #define APPS_WIN16 #endif -#define USE_SOCKETS #include #include #include -#include "apps.h" #include "s_apps.h" #include #ifdef WIN32_STUFF #include "winmain.h" #include "wintext.h" #endif +#if !defined(OPENSSL_SYS_MSDOS) +#include OPENSSL_UNISTD +#endif -#if !defined(MSDOS) && (!defined(VMS) || defined(__DECC)) +#if !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VXWORKS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) #define TIMES #endif @@ -102,18 +101,14 @@ The __TMS macro will show if it was. If it wasn't defined, we should undefine TIMES, since that tells the rest of the program how things should be handled. -- Richard Levitte */ -#if defined(VMS) && defined(__DECC) && !defined(__TMS) +#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS) #undef TIMES #endif -#ifndef TIMES +#if !defined(TIMES) && !defined(OPENSSL_SYS_VXWORKS) #include #endif -#ifdef _AIX -#include -#endif - #if defined(sun) || defined(__ultrix) #define _POSIX_SOURCE #include @@ -123,11 +118,19 @@ /* The following if from times(3) man page. It may need to be changed */ #ifndef HZ -#ifndef CLK_TCK -#define HZ 100.0 -#else /* CLK_TCK */ -#define HZ ((double)CLK_TCK) -#endif +# ifdef _SC_CLK_TCK +# define HZ ((double)sysconf(_SC_CLK_TCK)) +# else +# ifndef CLK_TCK +# ifndef _BSD_CLK_TCK_ /* FreeBSD hack */ +# define HZ 100.0 +# else /* _BSD_CLK_TCK_ */ +# define HZ ((double)_BSD_CLK_TCK_) +# endif +# else /* CLK_TCK */ +# define HZ ((double)CLK_TCK) +# endif +# endif #endif #undef PROG @@ -143,6 +146,10 @@ #undef BUFSIZZ #define BUFSIZZ 1024*10 +#define MYBUFSIZ 1024*8 + +#undef min +#undef max #define min(a,b) (((a) < (b)) ? (a) : (b)) #define max(a,b) (((a) > (b)) ? (a) : (b)) @@ -178,7 +185,7 @@ static int perform=0; #ifdef FIONBIO static int t_nbio=0; #endif -#ifdef WIN32 +#ifdef OPENSSL_SYS_WIN32 static int exitNow = 0; /* Set when it's time to exit main */ #endif @@ -202,7 +209,7 @@ static void s_time_init(void) #ifdef FIONBIO t_nbio=0; #endif -#ifdef WIN32 +#ifdef OPENSSL_SYS_WIN32 exitNow = 0; /* Set when it's time to exit main */ #endif } @@ -220,7 +227,7 @@ static void s_time_usage(void) file if not specified by this option\n\ -CApath arg - PEM format directory of CA's\n\ -CAfile arg - PEM format file of CA's\n\ --cipher - prefered cipher to use, play with 'openssl ciphers'\n\n"; +-cipher - preferred cipher to use, play with 'openssl ciphers'\n\n"; printf( "usage: s_time \n\n" ); @@ -229,7 +236,7 @@ static void s_time_usage(void) printf("-nbio - Run with non-blocking IO\n"); printf("-ssl2 - Just use SSLv2\n"); printf("-ssl3 - Just use SSLv3\n"); - printf("-bugs - Turn on SSL bug compatability\n"); + printf("-bugs - Turn on SSL bug compatibility\n"); printf("-new - Just time new connections\n"); printf("-reuse - Just time connection reuse\n"); printf("-www page - Retrieve 'page' from the site\n"); @@ -315,14 +322,19 @@ static int parseArgs(int argc, char **argv) { if (--argc < 1) goto bad; s_www_path= *(++argv); + if(strlen(s_www_path) > MYBUFSIZ-100) + { + BIO_printf(bio_err,"-www option too long\n"); + badop=1; + } } else if(strcmp(*argv,"-bugs") == 0) st_bugs=1; -#ifndef NO_SSL2 +#ifndef OPENSSL_NO_SSL2 else if(strcmp(*argv,"-ssl2") == 0) s_time_meth=SSLv2_client_method(); #endif -#ifndef NO_SSL3 +#ifndef OPENSSL_NO_SSL3 else if(strcmp(*argv,"-ssl3") == 0) s_time_meth=SSLv3_client_method(); #endif @@ -372,6 +384,22 @@ static double tm_Time_F(int s) ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ; return((ret == 0.0)?1e-6:ret); } +#elif defined(OPENSSL_SYS_VXWORKS) + { + static unsigned long tick_start, tick_end; + + if( s == START ) + { + tick_start = tickGet(); + return 0; + } + else + { + tick_end = tickGet(); + ret = (double)(tick_end - tick_start) / (double)sysClkRateGet(); + return((ret == 0.0)?1e-6:ret); + } + } #else /* !times() */ static struct timeb tstart,tend; long i; @@ -392,6 +420,8 @@ static double tm_Time_F(int s) * MAIN - main processing area for client * real name depends on MONOLITH */ +int MAIN(int, char **); + int MAIN(int argc, char **argv) { double totalTime = 0.0; @@ -408,11 +438,11 @@ int MAIN(int argc, char **argv) if (bio_err == NULL) bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); -#if !defined(NO_SSL2) && !defined(NO_SSL3) +#if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3) s_time_meth=SSLv23_client_method(); -#elif !defined(NO_SSL3) +#elif !defined(OPENSSL_NO_SSL3) s_time_meth=SSLv3_client_method(); -#elif !defined(NO_SSL2) +#elif !defined(OPENSSL_NO_SSL2) s_time_meth=SSLv2_client_method(); #endif @@ -420,7 +450,7 @@ int MAIN(int argc, char **argv) if( parseArgs( argc, argv ) < 0 ) goto end; - SSLeay_add_ssl_algorithms(); + OpenSSL_add_ssl_algorithms(); if ((tm_ctx=SSL_CTX_new(s_time_meth)) == NULL) return(1); SSL_CTX_set_quiet_shutdown(tm_ctx,1); @@ -435,7 +465,7 @@ int MAIN(int argc, char **argv) if ((!SSL_CTX_load_verify_locations(tm_ctx,CAfile,CApath)) || (!SSL_CTX_set_default_verify_paths(tm_ctx))) { - /* BIO_printf(bio_err,"error seting default verify locations\n"); */ + /* BIO_printf(bio_err,"error setting default verify locations\n"); */ ERR_print_errors(bio_err); /* goto end; */ } @@ -445,7 +475,6 @@ int MAIN(int argc, char **argv) if (tm_cipher == NULL ) { fprintf( stderr, "No CIPHER specified\n" ); -/* EXIT(1); */ } if (!(perform & 1)) goto next; @@ -458,7 +487,7 @@ int MAIN(int argc, char **argv) tm_Time_F(START); for (;;) { - if (finishtime < time(NULL)) break; + if (finishtime < (long)time(NULL)) break; #ifdef WIN32_STUFF if( flushWinMsgs(0) == -1 ) @@ -509,9 +538,9 @@ int MAIN(int argc, char **argv) } totalTime += tm_Time_F(STOP); /* Add the time for this iteration */ - i=(int)(time(NULL)-finishtime+maxTime); + i=(int)((long)time(NULL)-finishtime+maxTime); printf( "\n\n%d connections in %.2fs; %.2f connections/user sec, bytes read %ld\n", nConn, totalTime, ((double)nConn/totalTime),bytes_read); - printf( "%d connections in %ld real seconds, %ld bytes read per connection\n",nConn,time(NULL)-finishtime+maxTime,bytes_read/nConn); + printf( "%d connections in %ld real seconds, %ld bytes read per connection\n",nConn,(long)time(NULL)-finishtime+maxTime,bytes_read/nConn); /* Now loop and time connections using the same session id over and over */ @@ -543,7 +572,7 @@ next: nConn = 0; totalTime = 0.0; - finishtime=time(NULL)+maxTime; + finishtime=(long)time(NULL)+maxTime; printf( "starting\n" ); bytes_read=0; @@ -551,7 +580,7 @@ next: for (;;) { - if (finishtime < time(NULL)) break; + if (finishtime < (long)time(NULL)) break; #ifdef WIN32_STUFF if( flushWinMsgs(0) == -1 ) @@ -601,7 +630,7 @@ next: printf( "\n\n%d connections in %.2fs; %.2f connections/user sec, bytes read %ld\n", nConn, totalTime, ((double)nConn/totalTime),bytes_read); - printf( "%d connections in %ld real seconds, %ld bytes read per connection\n",nConn,time(NULL)-finishtime+maxTime,bytes_read/nConn); + printf( "%d connections in %ld real seconds, %ld bytes read per connection\n",nConn,(long)time(NULL)-finishtime+maxTime,bytes_read/nConn); ret=0; end: @@ -612,6 +641,7 @@ end: SSL_CTX_free(tm_ctx); tm_ctx=NULL; } + apps_shutdown(); EXIT(ret); } @@ -636,7 +666,7 @@ static SSL *doConnection(SSL *scon) BIO_set_conn_hostname(conn,host); if (scon == NULL) - serverCon=(SSL *)SSL_new(tm_ctx); + serverCon=SSL_new(tm_ctx); else { serverCon=scon;