3 * $FreeBSD: src/usr.sbin/rpc.statd/test.c,v 1.3 1999/08/28 01:19:39 peter Exp $
4 * $DragonFly: src/usr.sbin/rpc.statd/test.c,v 1.3 2005/11/25 00:32:49 swildner Exp $
8 #include <rpcsvc/sm_inter.h>
11 /* Default timeout can be changed using clnt_control() */
12 static struct timeval TIMEOUT
= { 25, 0 };
15 sm_stat_1(struct sm_name
*argp
, CLIENT
*clnt
)
17 static struct sm_stat_res res
;
19 bzero((char *)&res
, sizeof(res
));
20 if (clnt_call(clnt
, SM_STAT
, xdr_sm_name
, argp
, xdr_sm_stat_res
, &res
, TIMEOUT
) != RPC_SUCCESS
) {
28 sm_mon_1(struct mon
*argp
, CLIENT
*clnt
)
30 static struct sm_stat_res res
;
32 bzero((char *)&res
, sizeof(res
));
33 if (clnt_call(clnt
, SM_MON
, xdr_mon
, argp
, xdr_sm_stat_res
, &res
, TIMEOUT
) != RPC_SUCCESS
) {
41 sm_unmon_1(struct mon_id
*argp
, CLIENT
*clnt
)
43 static struct sm_stat res
;
45 bzero((char *)&res
, sizeof(res
));
46 if (clnt_call(clnt
, SM_UNMON
, xdr_mon_id
, argp
, xdr_sm_stat
, &res
, TIMEOUT
) != RPC_SUCCESS
) {
54 sm_unmon_all_1(struct my_id
*argp
, CLIENT
*clnt
)
56 static struct sm_stat res
;
58 bzero((char *)&res
, sizeof(res
));
59 if (clnt_call(clnt
, SM_UNMON_ALL
, xdr_my_id
, argp
, xdr_sm_stat
, &res
, TIMEOUT
) != RPC_SUCCESS
) {
67 sm_simu_crash_1(void *argp
, CLIENT
*clnt
)
71 bzero((char *)&res
, sizeof(res
));
72 if (clnt_call(clnt
, SM_SIMU_CRASH
, xdr_void
, argp
, xdr_void
, &res
, TIMEOUT
) != RPC_SUCCESS
) {
75 return ((void *)&res
);
80 main(int argc
, char **argv
)
89 fprintf(stderr
, "usage: test <hostname> | crash\n");
90 fprintf(stderr
, "always talks to statd at localhost\n");
94 printf("Creating client for localhost\n" );
95 cli
= clnt_create("localhost", SM_PROG
, SM_VERS
, "udp");
98 printf("Failed to create client\n");
102 mon
.mon_id
.mon_name
= argv
[1];
103 mon
.mon_id
.my_id
.my_name
= argv
[1];
104 mon
.mon_id
.my_id
.my_prog
= SM_PROG
;
105 mon
.mon_id
.my_id
.my_vers
= SM_VERS
;
106 mon
.mon_id
.my_id
.my_proc
= 1; /* have it call sm_stat() !!! */
108 if (strcmp(argv
[1], "crash"))
111 struct sm_stat_res
*res
;
112 if (res
= sm_mon_1(&mon
, cli
))
114 printf("Success!\n");
123 if (out
= sm_simu_crash_1(&dummy
, cli
))
125 printf("Success!\n");