3 static char sccsid[] = "from: @(#)nlm_prot.x 1.8 87/09/21 Copyr 1987 Sun Micro";
4 static char sccsid[] = "from: * @(#)nlm_prot.x 2.1 88/08/01 4.0 RPCSRC";
6 static const char rcsid[] =
11 #include <rpcsvc/nlm_prot.h>
13 /* Default timeout can be changed using clnt_control() */
14 static struct timeval TIMEOUT = { 0, 0 };
17 nlm_test_1(argp, clnt)
18 struct nlm_testargs *argp;
21 static nlm_testres res;
23 bzero((char *)&res, sizeof(res));
24 if (clnt_call(clnt, NLM_TEST, xdr_nlm_testargs, argp, xdr_nlm_testres, &res, TIMEOUT) != RPC_SUCCESS) {
32 nlm_lock_1(argp, clnt)
33 struct nlm_lockargs *argp;
39 bzero((char *)&res, sizeof(res));
40 if (st = clnt_call(clnt, NLM_LOCK, xdr_nlm_lockargs, argp, xdr_nlm_res, &res, TIMEOUT) != RPC_SUCCESS) {
41 printf("clnt_call returns %d\n", st);
42 clnt_perror(clnt, "humbug");
50 nlm_cancel_1(argp, clnt)
51 struct nlm_cancargs *argp;
56 bzero((char *)&res, sizeof(res));
57 if (clnt_call(clnt, NLM_CANCEL, xdr_nlm_cancargs, argp, xdr_nlm_res, &res, TIMEOUT) != RPC_SUCCESS) {
65 nlm_unlock_1(argp, clnt)
66 struct nlm_unlockargs *argp;
71 bzero((char *)&res, sizeof(res));
72 if (clnt_call(clnt, NLM_UNLOCK, xdr_nlm_unlockargs, argp, xdr_nlm_res, &res, TIMEOUT) != RPC_SUCCESS) {
80 nlm_granted_1(argp, clnt)
81 struct nlm_testargs *argp;
86 bzero((char *)&res, sizeof(res));
87 if (clnt_call(clnt, NLM_GRANTED, xdr_nlm_testargs, argp, xdr_nlm_res, &res, TIMEOUT) != RPC_SUCCESS) {
95 nlm_test_msg_1(argp, clnt)
96 struct nlm_testargs *argp;
101 bzero((char *)&res, sizeof(res));
102 if (clnt_call(clnt, NLM_TEST_MSG, xdr_nlm_testargs, argp, xdr_void, &res, TIMEOUT) != RPC_SUCCESS) {
105 return ((void *)&res);
110 nlm_lock_msg_1(argp, clnt)
111 struct nlm_lockargs *argp;
116 bzero((char *)&res, sizeof(res));
117 if (clnt_call(clnt, NLM_LOCK_MSG, xdr_nlm_lockargs, argp, xdr_void, NULL, TIMEOUT) != RPC_SUCCESS) {
118 clnt_perror(clnt, "nlm_lock_msg_1");
121 return ((void *)&res);
126 nlm_cancel_msg_1(argp, clnt)
127 struct nlm_cancargs *argp;
132 bzero((char *)&res, sizeof(res));
133 if (clnt_call(clnt, NLM_CANCEL_MSG, xdr_nlm_cancargs, argp, xdr_void, &res, TIMEOUT) != RPC_SUCCESS) {
136 return ((void *)&res);
141 nlm_unlock_msg_1(argp, clnt)
142 struct nlm_unlockargs *argp;
147 bzero((char *)&res, sizeof(res));
148 if (clnt_call(clnt, NLM_UNLOCK_MSG, xdr_nlm_unlockargs, argp, xdr_void, &res, TIMEOUT) != RPC_SUCCESS) {
151 return ((void *)&res);
156 nlm_granted_msg_1(argp, clnt)
157 struct nlm_testargs *argp;
162 bzero((char *)&res, sizeof(res));
163 if (clnt_call(clnt, NLM_GRANTED_MSG, xdr_nlm_testargs, argp, xdr_void, &res, TIMEOUT) != RPC_SUCCESS) {
166 return ((void *)&res);
171 nlm_test_res_1(argp, clnt)
177 bzero((char *)&res, sizeof(res));
178 if (clnt_call(clnt, NLM_TEST_RES, xdr_nlm_testres, argp, xdr_void, &res, TIMEOUT) != RPC_SUCCESS) {
181 return ((void *)&res);
186 nlm_lock_res_1(argp, clnt)
192 bzero((char *)&res, sizeof(res));
193 if (clnt_call(clnt, NLM_LOCK_RES, xdr_nlm_res, argp, xdr_void, &res, TIMEOUT) != RPC_SUCCESS) {
196 return ((void *)&res);
201 nlm_cancel_res_1(argp, clnt)
207 bzero((char *)&res, sizeof(res));
208 if (clnt_call(clnt, NLM_CANCEL_RES, xdr_nlm_res, argp, xdr_void, &res, TIMEOUT) != RPC_SUCCESS) {
211 return ((void *)&res);
216 nlm_unlock_res_1(argp, clnt)
222 bzero((char *)&res, sizeof(res));
223 if (clnt_call(clnt, NLM_UNLOCK_RES, xdr_nlm_res, argp, xdr_void, &res, TIMEOUT) != RPC_SUCCESS) {
226 return ((void *)&res);
231 nlm_granted_res_1(argp, clnt)
237 bzero((char *)&res, sizeof(res));
238 if (clnt_call(clnt, NLM_GRANTED_RES, xdr_nlm_res, argp, xdr_void, &res, TIMEOUT) != RPC_SUCCESS) {
241 return ((void *)&res);
246 nlm_share_3(argp, clnt)
250 static nlm_shareres res;
252 bzero((char *)&res, sizeof(res));
253 if (clnt_call(clnt, NLM_SHARE, xdr_nlm_shareargs, argp, xdr_nlm_shareres, &res, TIMEOUT) != RPC_SUCCESS) {
261 nlm_unshare_3(argp, clnt)
265 static nlm_shareres res;
267 bzero((char *)&res, sizeof(res));
268 if (clnt_call(clnt, NLM_UNSHARE, xdr_nlm_shareargs, argp, xdr_nlm_shareres, &res, TIMEOUT) != RPC_SUCCESS) {
276 nlm_nm_lock_3(argp, clnt)
282 bzero((char *)&res, sizeof(res));
283 if (clnt_call(clnt, NLM_NM_LOCK, xdr_nlm_lockargs, argp, xdr_nlm_res, &res, TIMEOUT) != RPC_SUCCESS) {
291 nlm_free_all_3(argp, clnt)
297 bzero((char *)&res, sizeof(res));
298 if (clnt_call(clnt, NLM_FREE_ALL, xdr_nlm_notify, argp, xdr_void, &res, TIMEOUT) != RPC_SUCCESS) {
301 return ((void *)&res);
305 int main(int argc, char **argv)
313 printf("Creating client for host %s\n", argv[1]);
314 cli = clnt_create(argv[1], NLM_PROG, NLM_VERS, "udp");
317 printf("Failed to create client\n");
322 clnt_control(cli, CLGET_TIMEOUT, &tim);
323 printf("Default timeout was %d.%d\n", tim.tv_sec, tim.tv_usec);
326 clnt_control(cli, CLSET_TIMEOUT, &tim);
327 clnt_control(cli, CLGET_TIMEOUT, &tim);
328 printf("timeout now %d.%d\n", tim.tv_sec, tim.tv_usec);
331 arg.cookie.n_len = 4;
332 arg.cookie.n_bytes = "hello";
337 arg.alock.caller_name = "localhost";
338 arg.alock.fh.n_len = 32;
339 arg.alock.fh.n_bytes = "\x04\x04\x02\x00\x01\x00\x00\x00\x0c\x00\x00\x00\xff\xff\xff\xd0\x16\x00\x00\x5b\x7c\xff\xff\xff\xec\x2f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x19\x54\xef\xbf\xd7\x94";
340 arg.alock.oh.n_len = 8;
341 arg.alock.oh.n_bytes = "\x00\x00\x02\xff\xff\xff\xd3";
342 arg.alock.svid = 0x5678;
343 arg.alock.l_offset = 0;
344 arg.alock.l_len = 100;
346 res_block.stat.stat = nlm_granted;
347 res_block.cookie.n_bytes = "hello";
348 res_block.cookie.n_len = 5;
351 if (nlm_lock_res_1(&res_block, cli)) printf("Success!\n");
352 else printf("Fail\n");
354 if (out = nlm_lock_msg_1(&arg, cli))
356 printf("Success!\n");
357 printf("out->stat = %d", out->stat);