home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / netper21.zip / netlib.h < prev    next >
C/C++ Source or Header  |  1996-01-30  |  9KB  |  288 lines

  1. /*
  2.         Copyright (C) 1993-1995 Hewlett-Packard Company
  3. */
  4.  
  5. /* library routine specifc defines                                      */
  6. #define         MAXSPECDATA     62      /* how many ints worth of data  */
  7.                                         /* can tests send...            */
  8. #define         MAXTIMES        4       /* how many times may we loop   */
  9.                                         /* to calibrate                 */
  10. #define         MAXCPUS         32      /* how many CPU's can we track */
  11. #define         MAXMESSAGESIZE  65536
  12. #define         MAXALIGNMENT    16384
  13. #define         MAXOFFSET        4096
  14. #define         DATABUFFERLEN   MAXMESSAGESIZE+MAXALIGNMENT+MAXOFFSET
  15.  
  16. #define         DEBUG_ON                1
  17. #define         DEBUG_OFF               2
  18. #define         DEBUG_OK                3
  19. #define         NODE_IDENTIFY           4
  20. #define         CPU_CALIBRATE           5
  21.  
  22. #define         DO_TCP_STREAM           10
  23. #define         TCP_STREAM_RESPONSE     11
  24. #define         TCP_STREAM_RESULTS      12
  25.  
  26. #define         DO_TCP_RR               13
  27. #define         TCP_RR_RESPONSE         14
  28. #define         TCP_RR_RESULTS          15
  29.  
  30. #define         DO_UDP_STREAM           16
  31. #define         UDP_STREAM_RESPONSE     17
  32. #define         UDP_STREAM_RESULTS      18
  33.  
  34. #define         DO_UDP_RR               19
  35. #define         UDP_RR_RESPONSE         20
  36. #define         UDP_RR_RESULTS          21
  37.  
  38. #define         DO_DLPI_CO_STREAM       22
  39. #define         DLPI_CO_STREAM_RESPONSE 23
  40. #define         DLPI_CO_STREAM_RESULTS  24
  41.  
  42. #define         DO_DLPI_CO_RR           25
  43. #define         DLPI_CO_RR_RESPONSE     26
  44. #define         DLPI_CO_RR_RESULTS      27
  45.  
  46. #define         DO_DLPI_CL_STREAM       28
  47. #define         DLPI_CL_STREAM_RESPONSE 29
  48. #define         DLPI_CL_STREAM_RESULTS  30
  49.  
  50. #define         DO_DLPI_CL_RR           31
  51. #define         DLPI_CL_RR_RESPONSE     32
  52. #define         DLPI_CL_RR_RESULTS      33
  53.  
  54. #define         DO_TCP_CRR              34
  55. #define         TCP_CRR_RESPONSE        35
  56. #define         TCP_CRR_RESULTS         36
  57.  
  58. #define         DO_STREAM_STREAM        37
  59. #define         STREAM_STREAM_RESPONSE  38
  60. #define         STREAM_STREAM_RESULTS   39
  61.  
  62. #define         DO_STREAM_RR            40
  63. #define         STREAM_RR_RESPONSE      41
  64. #define         STREAM_RR_RESULTS       42
  65.  
  66. #define         DO_DG_STREAM            43
  67. #define         DG_STREAM_RESPONSE      44
  68. #define         DG_STREAM_RESULTS       45
  69.  
  70. #define         DO_DG_RR                46
  71. #define         DG_RR_RESPONSE          47
  72. #define         DG_RR_RESULTS           48
  73.  
  74. #define         DO_FORE_STREAM          49
  75. #define         FORE_STREAM_RESPONSE    50
  76. #define         FORE_STREAM_RESULTS     51
  77.  
  78. #define         DO_FORE_RR              52
  79. #define         FORE_RR_RESPONSE        53
  80. #define         FORE_RR_RESULTS         54
  81.  
  82. #define         DO_HIPPI_STREAM         55
  83. #define         HIPPI_STREAM_RESPONSE   56
  84. #define         HIPPI_STREAM_RESULTS    57
  85.  
  86. #define         DO_HIPPI_RR             52
  87. #define         HIPPI_RR_RESPONSE       53
  88. #define         HIPPI_RR_RESULTS        54
  89.  
  90. #define         DO_XTI_TCP_STREAM       55
  91. #define         XTI_TCP_STREAM_RESPONSE 56
  92. #define         XTI_TCP_STREAM_RESULTS  57
  93.  
  94. #define         DO_XTI_TCP_RR           58
  95. #define         XTI_TCP_RR_RESPONSE     59
  96. #define         XTI_TCP_RR_RESULTS      60
  97.  
  98. #define         DO_XTI_UDP_STREAM       61
  99. #define         XTI_UDP_STREAM_RESPONSE 62
  100. #define         XTI_UDP_STREAM_RESULTS  63
  101.  
  102. #define         DO_XTI_UDP_RR           64
  103. #define         XTI_UDP_RR_RESPONSE     65
  104. #define         XTI_UDP_RR_RESULTS      66
  105.  
  106. #define         DO_XTI_TCP_CRR          67
  107. #define         XTI_TCP_CRR_RESPONSE    68
  108. #define         XTI_TCP_CRR_RESULTS     69
  109.  
  110. #define         DO_TCP_TRR              70
  111. #define         TCP_TRR_RESPONSE        71
  112. #define         TCP_TRR_RESULTS         72
  113.  
  114. #define         DO_TCP_NBRR             73
  115. #define         TCP_NBRR_RESPONSE       74
  116. #define         TCP_NBRR_RESULTS        75
  117.  
  118. #define         DO_TCPIPV6_STREAM           76
  119. #define         TCPIPV6_STREAM_RESPONSE     77
  120. #define         TCPIPV6_STREAM_RESULTS      78
  121.  
  122. #define         DO_TCPIPV6_RR               79
  123. #define         TCPIPV6_RR_RESPONSE         80
  124. #define         TCPIPV6_RR_RESULTS          81
  125.  
  126. #define         DO_UDPIPV6_STREAM           82
  127. #define         UDPIPV6_STREAM_RESPONSE     83
  128. #define         UDPIPV6_STREAM_RESULTS      84
  129.  
  130. #define         DO_UDPIPV6_RR               85
  131. #define         UDPIPV6_RR_RESPONSE         86
  132. #define         UDPIPV6_RR_RESULTS          87
  133.  
  134. #define         DO_TCPIPV6_CRR               88
  135. #define         TCPIPV6_CRR_RESPONSE         89
  136. #define         TCPIPV6_CRR_RESULTS          90
  137.  
  138. #define         DO_TCPIPV6_TRR               91
  139. #define         TCPIPV6_TRR_RESPONSE         92
  140. #define         TCPIPV6_TRR_RESULTS          93
  141.  
  142. #define         DO_LWPSTR_STREAM           100
  143. #define         LWPSTR_STREAM_RESPONSE     110
  144. #define         LWPSTR_STREAM_RESULTS      120
  145.  
  146. #define         DO_LWPSTR_RR               130
  147. #define         LWPSTR_RR_RESPONSE         140
  148. #define         LWPSTR_RR_RESULTS          150
  149.  
  150. #define         DO_LWPDG_STREAM           160
  151. #define         LWPDG_STREAM_RESPONSE     170
  152. #define         LWPDG_STREAM_RESULTS      180
  153.  
  154. #define         DO_LWPDG_RR               190
  155. #define         LWPDG_RR_RESPONSE         200
  156. #define         LWPDG_RR_RESULTS          210
  157.  
  158.  /* some of the fields in these structures are going to be doubles and */
  159.  /* such. so, we probably want to ensure that they will start on */
  160.  /* "double" boundaries. this will break compatability to pre-2.1 */
  161.  /* releases, but then, backwards compatability has never been a */
  162.  /* stated goal of netperf. raj 11/95 */
  163.  
  164. union netperf_request_struct {
  165.   struct {
  166.     int     request_type;
  167.     int     dummy;
  168.     int     test_specific_data[MAXSPECDATA];
  169.   } content;
  170.   double dummy;
  171. };
  172.  
  173. union netperf_response_struct {
  174.   struct {
  175.     int response_type;
  176.     int serv_errno;
  177.     int test_specific_data[MAXSPECDATA];
  178.   } content;
  179.   double dummy;
  180. };
  181.  
  182. struct ring_elt {
  183.   struct ring_elt *next;  /* next element in the ring */
  184.   char *buffer_base;      /* in case we have to free it at somepoint */
  185.   char *buffer_ptr;       /* the aligned and offset pointer */
  186. };
  187.  
  188.  /* the diferent codes to denote the type of CPU utilization */
  189.  /* methods used */
  190. #define CPU_UNKNOWN     0
  191. #define HP_IDLE_COUNTER 1
  192. #define PSTAT           2
  193. #define TIMES           3
  194. #define LOOPER          4
  195. #define GETRUSAGE       5
  196. #define NT_METHOD       6
  197.  
  198. #define BADCH ('?')
  199.  
  200. #ifndef NETLIB
  201. #ifdef WIN32
  202. #ifndef _GETOPT_
  203. #define _GETOPT_
  204.  
  205. int getopt(int argc, char **argv, char *optstring);
  206.  
  207. extern char *optarg;        /* returned arg to go with this option */
  208. extern int optind;        /* index to next argv element to process */
  209. extern int opterr;        /* should error messages be printed? */
  210. extern int optopt;        /* */
  211.  
  212. #endif /* _GETOPT_ */
  213.  
  214. extern  int     win_kludge_socket;
  215. #endif /* WIN32 */
  216.  
  217. extern  union netperf_request_struct netperf_request;
  218. extern  union netperf_response_struct netperf_response;
  219.  
  220. extern  char    libfmt;
  221.  
  222. extern  int     cpu_method;
  223. extern  int     lib_num_loc_cpus;
  224. extern  int     server_sock;
  225. extern  int     times_up;
  226. extern  FILE    *where;
  227. extern  int     loops_per_msec;
  228.   
  229. extern  void    netlib_init();
  230. extern  void    install_signal_catchers();
  231. extern  void    establish_control();
  232. extern  void    shutdown_control();
  233. extern  void    init_stat();
  234. extern  void    send_request();
  235. extern  void    recv_response();
  236. extern  void    send_response();
  237. extern  void    recv_request();
  238. extern  void    dump_request();
  239. extern  void    start_timer();
  240. extern  void    stop_timer();
  241. extern  void    cpu_start();
  242. extern  void    cpu_stop();
  243. extern  void    calculate_confidence();
  244. extern  void    retrieve_confident_values();
  245. extern  void    display_confidence();
  246. extern  char   *format_units();
  247.  
  248. extern  double  ntohd();
  249. extern  double  htond();
  250. extern  void    libmain();
  251. extern  double  calc_thruput();
  252. extern  float   calc_xfered();
  253. extern  float   calibrate_local_cpu();
  254. extern  float   calibrate_remote_cpu();
  255. extern  float   calc_cpu_util();
  256. extern  float   calc_service_demand();
  257. extern  void    catcher();
  258. extern  struct ring_elt *allocate_buffer_ring();
  259. extern  int     dl_connect();
  260. extern  int     dl_bind();
  261. extern  int     dl_open();
  262. extern  char    format_cpu_method();
  263. extern unsigned int convert();
  264.  
  265.  /* these are all for the confidence interval stuff */
  266. extern double confidence;
  267.  
  268. #endif
  269.  
  270.  /* if your system has bcopy and bzero, include it here, otherwise, we */
  271.  /* will try to use memcpy aand memset. fix from Bruce Barnett @ GE. */
  272. #ifdef hpux
  273. #define HAVE_BCOPY
  274. #define HAVE_BZERO
  275. #endif
  276.  
  277. #ifndef HAVE_BCOPY
  278. #define bcopy(s,d,h) memcpy((d),(s),(h))
  279. #endif /* HAVE_BCOPY */
  280.  
  281. #ifndef HAVE_BZERO
  282. #define bzero(p,h) memset((p),0,(h))
  283. #endif /* HAVE_BZERO */
  284.  
  285. #ifndef HAVE_MIN
  286. #define min(a,b) ((a < b) ? a : b)
  287. #endif /* HAVE_MIN */
  288.