Add MCP73, MCP77 and MCP79 support.
[dragonfly.git] / usr.sbin / rpc.statd / test.c
blob981fa57664e0b960aab6fd8af3d8c8ece9777e8a
2 /*
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 $
5 */
6 #include <stdio.h>
7 #include <rpc/rpc.h>
8 #include <rpcsvc/sm_inter.h>
11 /* Default timeout can be changed using clnt_control() */
12 static struct timeval TIMEOUT = { 25, 0 };
14 struct sm_stat_res *
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) {
21 return (NULL);
23 return (&res);
27 struct sm_stat_res *
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) {
34 return (NULL);
36 return (&res);
40 struct sm_stat *
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) {
47 return (NULL);
49 return (&res);
53 struct sm_stat *
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) {
60 return (NULL);
62 return (&res);
66 void *
67 sm_simu_crash_1(void *argp, CLIENT *clnt)
69 static char res;
71 bzero((char *)&res, sizeof(res));
72 if (clnt_call(clnt, SM_SIMU_CRASH, xdr_void, argp, xdr_void, &res, TIMEOUT) != RPC_SUCCESS) {
73 return (NULL);
75 return ((void *)&res);
79 int
80 main(int argc, char **argv)
82 CLIENT *cli;
83 char dummy;
84 void *out;
85 struct mon mon;
87 if (argc < 2)
89 fprintf(stderr, "usage: test <hostname> | crash\n");
90 fprintf(stderr, "always talks to statd at localhost\n");
91 exit(1);
94 printf("Creating client for localhost\n" );
95 cli = clnt_create("localhost", SM_PROG, SM_VERS, "udp");
96 if (!cli)
98 printf("Failed to create client\n");
99 exit(1);
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"))
110 /* Hostname given */
111 struct sm_stat_res *res;
112 if (res = sm_mon_1(&mon, cli))
114 printf("Success!\n");
116 else
118 printf("Fail\n");
121 else
123 if (out = sm_simu_crash_1(&dummy, cli))
125 printf("Success!\n");
127 else
129 printf("Fail\n");
133 return 0;