home *** CD-ROM | disk | FTP | other *** search
- /**
- * This program may be copied, redistributed in any form,
- * source or binary, and used for any purpose, provided
- * this copyright notice is retained.
- * @(#)rperf.h 3.1 12/15/93 (c) Copyright Brian P. Fitzgerald
- * Rensselaer Polytechnic Institute
- **/
-
- #ifndef PORTMAP
- #define PORTMAP
- /**
- * ... so that for Solaris 2, in <rpc/clnt.h>
- * we include <rpc/clnt_soc.h>, which declares clntudp_create()
- **/
- #endif /* !PORTMAP */
- /**
- * <rpc/rpc.h> includes <rpc/types.h>
- * <rpc/types.h> includes <sys/types.h>
- * <rpc/types.h> includes <sys/time.h>
- * <rpc/types.h> ifndef KERNEL includes <malloc.h>
- * <rpc/rpc.h> includes <netinet/in.h>
- * (I hope!)
- **/
- #include <rpc/rpc.h>
- #include <rpc/pmap_clnt.h> /* declare clnt_broadcast() */
- #include "rstat.h"
-
- #include <time.h>
- #include <stdio.h>
- #include <signal.h>
- #include <string.h>
- #include <ctype.h>
- #include <sys/socket.h>
-
- #include <arpa/inet.h>
- #include <netdb.h>
-
- /**
- * The C library hsearch on some systems is incompatible.
- * Use the hsearch that came with this package.
- **/
- #include "hsearch.h"
-
- #ifdef HAVE_SYS_RESOURCE_H
- #include <sys/resource.h>
- #endif /* HAVE_SYS_RESOURCE_H */
- #ifdef RLIMIT_NOFILE
- #define Rlimit rlimit
- #else /* !RLIMIT_NOFILE */
- struct Rlimit {
- int rlim_cur; /* current (soft) limit */
- int rlim_max; /* maximum value for rlim_cur */
- };
- #endif /* !RLIMIT_NOFILE */
-
- typedef statsvar stats_default;
-
- #define STATS_CONVERT(version) (stats_convert[(version)-1])
-
- #define EACH_RESULT(version) (each_result_vers[(version)-1])
-
- #define XDR_STATSPROC(version) (xdr_statsproc[(version)-1])
-
- union stats_all {
- struct stats s1;
- struct statsswtch s2;
- struct statstime s3;
- struct statsvar s4;
- };
- typedef union stats_all stats_all;
-
- /**
- * the server's rpc.rstatd reports cp_time as clock ticks since boot time
- * (cumulative), or clock ticks since the previous query (incremental).
- **/
- enum cp_time_kind {
- CP_TIME_CUM, /* Sun ... */
- CP_TIME_INC /* IBM ... */
- };
- typedef enum cp_time_kind cp_time_kind;
-
- struct hash_info {
- struct in_addr ident_addr;
- struct data *datap;
- };
- typedef struct hash_info hash_info;
-
- struct data {
- struct data *datap;
- u_long nn;
- u_long no;
- struct in_addr addr;
- char *host;
- char *host_dup;
- CLIENT *cl;
- u_long clnt_vers;
- u_long bcst_vers;
- u_long ok_to_call;
- stats_default sn;
- stats_default so;
- stats_default sd; /* delta or rate. uptime = sd.boottime */
- cp_time_kind cp_kind;
- };
- extern struct data *dp;
-
- struct array {
- u_int len;
- int *val;
- };
- typedef struct array array;
-
- /* <sys/dk.h> */
- #define CP_USER 0
- #define CP_NICE 1
- #define CP_SYS 2
- #define CP_IDLE 3
-
- #define cpu(dt) (dcpu ? ((dt) * 100 + hdcpu ) / dcpu : 0)
- #define loadav(nrun) ( (float) (nrun) / FSCALE )
- #define delta(x) ((*dpp)->sn.x - (*dpp)->so.x) /* use this macro with care */
- #define rate(x) (dt ? ((x) * 1000L + hdt ) / dt : 0)
-
- #define t_d(j) tbl[(j)].dp->sd
- #define t_o(j) tbl[(j)].dp->so
- #define t_n(j) tbl[(j)].dp->sn
-
- struct key {
- char *k_name;
- int k_noffset;
- int k_doffset;
- int k_flag;
- int k_index;
- };
- typedef struct key key;
-
- #define K_DELTA 0x1 /* need delta before sorting */
- #define K_NZERO 0x2 /* must be nonzero for sorting */
- #define K_ARRAY 0x4 /* the member is an xdr_array */
-
- /* C faq */
- #ifndef offsetof
- #define offsetof(type, mem) ((size_t) \
- ((char *)&((type *) 0)->mem - (char *)((type *) 0)))
- #endif /* !offsetof */
- #define sd_offset(mem) offsetof(struct data,sd.mem)
- #define sn_offset(mem) offsetof(struct data,sn.mem)
-
- #define AV1 0
- #define AV5 1
- #define AV15 2
-
- struct datatbl {
- int val;
- struct data *dp;
- };
-
- #define P_DATA 0
- #define P_UP 1
-
- #define cp_val cp_time.cp_time_val
- #define cp_len cp_time.cp_time_len
- #define dk_val dk_xfer.dk_xfer_val
- #define dk_len dk_xfer.dk_xfer_len
-
- #define MODE_BCST 0 /* no host args were supplied. */
- #define MODE_CALL 1 /* one or more host args was supplied. */
- extern unsigned long mode;
- extern unsigned long thiscount;
- extern unsigned long nhosts;
-
- struct data *new_host();
- void create_array();
- void destroy_array();
- void doclnt_calls();
- void do_broadcast();
-