home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / netper21.zip / netperf.c < prev    next >
C/C++ Source or Header  |  1996-02-26  |  7KB  |  249 lines

  1.  
  2. /*
  3.  
  4.             Copyright (C) 1993,1994,1995 Hewlett-Packard Company
  5.                          ALL RIGHTS RESERVED.
  6.  
  7.   The enclosed software and documention includes copyrighted works of
  8.   Hewlett-Packard Co. For as long as you comply with the following
  9.   limitations, you are hereby authorized to (i) use, reproduce, and
  10.   modify the software and documentation, and to (ii) distribute the
  11.   software and documentation, including modifications, for
  12.   non-commercial purposes only.
  13.       
  14.   1.  The enclosed software and documentation is made available at no
  15.       charge in order to advance the general development of
  16.       high-performance networking products.
  17.  
  18.   2.  You may not delete any copyright notices contained in the
  19.       software or documentation. All hard copies, and copies in
  20.       source code or object code form, of the software or
  21.       documentation (including modifications) must contain at least
  22.       one of the copyright notices.
  23.  
  24.   3.  The enclosed software and documentation has not been subjected
  25.       to testing and quality control and is not a Hewlett-Packard Co.
  26.       product. At a future time, Hewlett-Packard Co. may or may not
  27.       offer a version of the software and documentation as a product.
  28.   
  29.   4.  THE SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS".
  30.       HEWLETT-PACKARD COMPANY DOES NOT WARRANT THAT THE USE,
  31.       REPRODUCTION, MODIFICATION OR DISTRIBUTION OF THE SOFTWARE OR
  32.       DOCUMENTATION WILL NOT INFRINGE A THIRD PARTY'S INTELLECTUAL
  33.       PROPERTY RIGHTS. HP DOES NOT WARRANT THAT THE SOFTWARE OR
  34.       DOCUMENTATION IS ERROR FREE. HP DISCLAIMS ALL WARRANTIES,
  35.       EXPRESS AND IMPLIED, WITH REGARD TO THE SOFTWARE AND THE
  36.       DOCUMENTATION. HP SPECIFICALLY DISCLAIMS ALL WARRANTIES OF
  37.       MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  38.   
  39.   5.  HEWLETT-PACKARD COMPANY WILL NOT IN ANY EVENT BE LIABLE FOR ANY
  40.       DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
  41.       (INCLUDING LOST PROFITS) RELATED TO ANY USE, REPRODUCTION,
  42.       MODIFICATION, OR DISTRIBUTION OF THE SOFTWARE OR DOCUMENTATION.
  43.  
  44. */
  45. char    netperf_id[]="\
  46. @(#)netperf.c (c) Copyright 1993, 1994 Hewlett-Packard Company. Version 2.1";
  47.  
  48. #include <stdio.h>
  49. #include <stdlib.h>
  50.  
  51. #ifdef WIN32
  52. #include <windows.h>
  53. #include <winsock.h>
  54. #endif /* WIN32 */
  55.  
  56. #include "netsh.h"
  57. #include "netlib.h"
  58. #include "nettest_bsd.h"
  59. #ifdef DO_UNIX
  60. #include "nettest_unix.h"
  61. #endif /* DO_UNIX */
  62. #ifdef DO_FORE
  63. #include "nettest_fore.h"
  64. #endif /* DO_FORE */
  65. #ifdef DO_HIPPI
  66. #include "nettest_hippi.h"
  67. #endif /* DO_HIPPI */
  68. #ifdef DO_XTI
  69. #include "nettest_xti.h"
  70. #endif /* DO_XTI */
  71. #ifdef DO_DLPI
  72. #include "nettest_dlpi.h"
  73. #endif /* DO_DLPI */
  74. #ifdef DO_IPV6
  75. #include "nettest_ipv6.h"
  76. #endif /* DO_IPV6 */
  77.  
  78.  /* this file contains the main for the netperf program. all the other */
  79.  /* routines can be found in the file netsh.c */
  80.  
  81.  
  82. int
  83. main(argc,argv)
  84. int    argc;
  85. char    *argv[];
  86.  
  87. {
  88.  
  89. #ifdef WIN32
  90.     WSADATA    wsa_data ;
  91.  
  92.     /* Initialise the wsock lib ( version 1.1 ) */
  93.     if ( WSAStartup(0x0101,&wsa_data) == SOCKET_ERROR ){
  94.         printf("WSAStartup() fauled : %d\n",GetLastError()) ;
  95.         return 1 ;
  96.     }
  97. #endif /* WIN32 */
  98.  
  99. netlib_init();
  100. set_defaults();
  101. scan_cmd_line(argc,argv);
  102.  
  103. if (debug) {
  104.     dump_globals();
  105.     install_signal_catchers();
  106. }
  107.  
  108. if (debug) {
  109.     printf("remotehost is %s and port %d\n",host_name,test_port);
  110.     fflush(stdout);
  111. }
  112.  
  113.  
  114. establish_control(host_name,test_port);
  115.  
  116. if (strcmp(test_name,"TCP_STREAM") == 0) {
  117.     send_tcp_stream(host_name);
  118. }
  119. else if (strcmp(test_name,"TCP_RR") == 0) {
  120.     send_tcp_rr(host_name);
  121. }
  122. else if (strcmp(test_name,"TCP_CRR") == 0) {
  123.     send_tcp_conn_rr(host_name);
  124. }
  125. #ifdef DO_1644
  126. else if (strcmp(test_name,"TCP_TRR") == 0) {
  127.     send_tcp_tran_rr(host_name);
  128. }
  129. #endif /* DO_1644 */
  130. #ifdef DO_NBRR
  131. else if (strcmp(test_name,"TCP_NBRR") == 0) {
  132.     send_tcp_nbrr(host_name);
  133. }
  134. #endif /* DO_NBRR */
  135. else if (strcmp(test_name,"UDP_STREAM") == 0) {
  136.     send_udp_stream(host_name);
  137. }
  138. else if (strcmp(test_name,"UDP_RR") == 0) {
  139.     send_udp_rr(host_name);
  140. }
  141. else if (strcmp(test_name,"LOC_CPU") == 0) {
  142.     loc_cpu_rate();
  143. }
  144. else if (strcmp(test_name,"REM_CPU") == 0) {
  145.     rem_cpu_rate();
  146. }
  147. #ifdef DO_DLPI
  148. else if (strcmp(test_name,"DLCO_RR") == 0) {
  149.     send_dlpi_co_rr();
  150. }
  151. else if (strcmp(test_name,"DLCL_RR") == 0) {
  152.     send_dlpi_cl_rr();
  153. }
  154. else if (strcmp(test_name,"DLCO_STREAM") == 0) {
  155.     send_dlpi_co_stream();
  156. }
  157. else if (strcmp(test_name,"DLCL_STREAM") == 0) {
  158.     send_dlpi_cl_stream();
  159. }
  160. #endif /* DO_DLPI */
  161. #ifdef DO_UNIX
  162. else if (strcmp(test_name,"STREAM_RR") == 0) {
  163.     send_stream_rr();
  164. }
  165. else if (strcmp(test_name,"DG_RR") == 0) {
  166.     send_dg_rr();
  167. }
  168. else if (strcmp(test_name,"STREAM_STREAM") == 0) {
  169.     send_stream_stream();
  170. }
  171. else if (strcmp(test_name,"DG_STREAM") == 0) {
  172.     send_dg_stream();
  173. }
  174. #endif /* DO_UNIX */
  175. #ifdef DO_FORE
  176. else if (strcmp(test_name,"FORE_STREAM") == 0) {
  177.     send_fore_stream(host_name);
  178. }
  179. else if (strcmp(test_name,"FORE_RR") == 0) {
  180.     send_fore_rr(host_name);
  181. }
  182. #endif /* DO_FORE */
  183. #ifdef DO_HIPPI
  184. else if (strcmp(test_name,"HIPPI_STREAM") == 0) {
  185.     send_hippi_stream(host_name);
  186. }
  187. else if (strcmp(test_name,"HIPPI_RR") == 0) {
  188.     send_hippi_rr(host_name);
  189. }
  190. #endif /* DO_HIPPI */
  191. #ifdef DO_XTI
  192. else if (strcmp(test_name,"XTI_TCP_STREAM") == 0) {
  193.     send_xti_tcp_stream(host_name);
  194. }
  195. else if (strcmp(test_name,"XTI_TCP_RR") == 0) {
  196.     send_xti_tcp_rr(host_name);
  197. }
  198. else if (strcmp(test_name,"XTI_UDP_STREAM") == 0) {
  199.     send_xti_udp_stream(host_name);
  200. }
  201. else if (strcmp(test_name,"XTI_UDP_RR") == 0) {
  202.     send_xti_udp_rr(host_name);
  203. }
  204. #endif /* DO_XTI */
  205. #ifdef DO_LWP
  206. else if (strcmp(test_name,"LWPSTR_STREAM") == 0) {
  207.     send_lwpstr_stream(host_name);
  208. }
  209. else if (strcmp(test_name,"LWPSTR_RR") == 0) {
  210.     send_lwpstr_rr(host_name);
  211. }
  212. else if (strcmp(test_name,"LWPDG_STREAM") == 0) {
  213.     send_lwpdg_stream(host_name);
  214. }
  215. else if (strcmp(test_name,"LWPDG_RR") == 0) {
  216.     send_lwpdg_rr(host_name);
  217. }
  218. #endif /* DO_LWP */
  219. #ifdef DO_IPV6
  220. else if (strcmp(test_name,"TCPIPV6_STREAM") == 0) {
  221.     send_tcpipv6_stream(host_name);
  222. }
  223. else if (strcmp(test_name,"TCPIPV6_RR") == 0) {
  224.     send_tcpipv6_rr(host_name);
  225. }
  226. else if (strcmp(test_name,"TCPIPV6_CRR") == 0) {
  227.     send_tcpipv6_rr(host_name);
  228. }
  229. else if (strcmp(test_name,"UDPIPV6_STREAM") == 0) {
  230.     send_udpipv6_stream(host_name);
  231. }
  232. else if (strcmp(test_name,"UDPIPV6_RR") == 0) {
  233.     send_udpipv6_rr(host_name);
  234. }
  235. #endif /* DO_IPV6 */
  236. else {
  237.     printf("The test you requested is unknown to this netperf.\n");
  238.     printf("Please verify that you have the correct test name, \n");
  239.     printf("and that test family has been compiled into this netperf.\n");
  240.     exit(1);
  241. }
  242.  
  243. shutdown_control();
  244.  
  245. return(0);
  246. }
  247.  
  248.  
  249.