2007-11-05 02:12:50 +03:00
|
|
|
/* $NetBSD: test.c,v 1.4 2007/11/04 23:12:50 christos Exp $ */
|
1997-03-10 09:26:19 +03:00
|
|
|
|
2007-11-05 02:12:50 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
1997-10-18 08:01:10 +04:00
|
|
|
#include <sys/cdefs.h>
|
1997-03-10 09:26:19 +03:00
|
|
|
#include <rpc/rpc.h>
|
|
|
|
#include <rpcsvc/nlm_prot.h>
|
2007-11-05 02:12:50 +03:00
|
|
|
|
1997-03-10 09:26:19 +03:00
|
|
|
#ifndef lint
|
1997-10-18 08:01:10 +04:00
|
|
|
#if 0
|
|
|
|
static char sccsid[] = "from: @(#)nlm_prot.x 1.8 87/09/21 Copyr 1987 Sun Micro";
|
|
|
|
static char sccsid[] = "from: * @(#)nlm_prot.x 2.1 88/08/01 4.0 RPCSRC";
|
|
|
|
#else
|
2007-11-05 02:12:50 +03:00
|
|
|
__RCSID("$NetBSD: test.c,v 1.4 2007/11/04 23:12:50 christos Exp $");
|
1997-10-18 08:01:10 +04:00
|
|
|
#endif
|
1997-03-10 09:26:19 +03:00
|
|
|
#endif /* not lint */
|
|
|
|
|
|
|
|
/* Default timeout can be changed using clnt_control() */
|
|
|
|
static struct timeval TIMEOUT = {0, 0};
|
|
|
|
|
|
|
|
nlm_testres *
|
2007-11-05 02:12:50 +03:00
|
|
|
nlm_test_1(struct nlm_testargs *argp, CLIENT *clnt)
|
1997-03-10 09:26:19 +03:00
|
|
|
{
|
|
|
|
static nlm_testres res;
|
|
|
|
|
2007-11-05 02:12:50 +03:00
|
|
|
(void)memset(&res, 0, sizeof(res));
|
|
|
|
if (clnt_call(clnt, NLM_TEST, xdr_nlm_testargs, argp, xdr_nlm_testres,
|
|
|
|
&res, TIMEOUT) != RPC_SUCCESS)
|
|
|
|
return NULL;
|
|
|
|
return &res;
|
1997-03-10 09:26:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nlm_res *
|
2007-11-05 02:12:50 +03:00
|
|
|
nlm_lock_1(struct nlm_lockargs *argp, CLIENT *clnt)
|
1997-03-10 09:26:19 +03:00
|
|
|
{
|
|
|
|
enum clnt_stat st;
|
|
|
|
static nlm_res res;
|
|
|
|
|
2007-11-05 02:12:50 +03:00
|
|
|
(void)memset(&res, 0, sizeof(res));
|
|
|
|
if (st = clnt_call(clnt, NLM_LOCK, xdr_nlm_lockargs, argp, xdr_nlm_res,
|
|
|
|
&res, TIMEOUT) != RPC_SUCCESS) {
|
1997-03-10 09:26:19 +03:00
|
|
|
printf("clnt_call returns %d\n", st);
|
|
|
|
clnt_perror(clnt, "humbug");
|
2007-11-05 02:12:50 +03:00
|
|
|
return NULL;
|
1997-03-10 09:26:19 +03:00
|
|
|
}
|
2007-11-05 02:12:50 +03:00
|
|
|
return &res;
|
1997-03-10 09:26:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nlm_res *
|
2007-11-05 02:12:50 +03:00
|
|
|
nlm_cancel_1(struct nlm_cancargs *argp, CLIENT *clnt)
|
1997-03-10 09:26:19 +03:00
|
|
|
{
|
|
|
|
static nlm_res res;
|
|
|
|
|
2007-11-05 02:12:50 +03:00
|
|
|
(void)memset(&res, 0, sizeof(res));
|
|
|
|
if (clnt_call(clnt, NLM_CANCEL, xdr_nlm_cancargs, argp, xdr_nlm_res,
|
|
|
|
&res, TIMEOUT) != RPC_SUCCESS) {
|
|
|
|
return NULL;
|
1997-03-10 09:26:19 +03:00
|
|
|
}
|
2007-11-05 02:12:50 +03:00
|
|
|
return &res;
|
1997-03-10 09:26:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nlm_res *
|
2007-11-05 02:12:50 +03:00
|
|
|
nlm_unlock_1(struct nlm_unlockargs *argp, CLIENT *clnt)
|
1997-03-10 09:26:19 +03:00
|
|
|
{
|
|
|
|
static nlm_res res;
|
|
|
|
|
2007-11-05 02:12:50 +03:00
|
|
|
(void)memset(&res, 0, sizeof(res));
|
|
|
|
if (clnt_call(clnt, NLM_UNLOCK, xdr_nlm_unlockargs, argp, xdr_nlm_res,
|
|
|
|
&res, TIMEOUT) != RPC_SUCCESS) {
|
|
|
|
return NULL;
|
1997-03-10 09:26:19 +03:00
|
|
|
}
|
2007-11-05 02:12:50 +03:00
|
|
|
return &res;
|
1997-03-10 09:26:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nlm_res *
|
2007-11-05 02:12:50 +03:00
|
|
|
nlm_granted_1(struct nlm_testargs *argp, CLIENT *clnt)
|
1997-03-10 09:26:19 +03:00
|
|
|
{
|
|
|
|
static nlm_res res;
|
|
|
|
|
2007-11-05 02:12:50 +03:00
|
|
|
(void)memset(&res, 0, sizeof(res));
|
|
|
|
if (clnt_call(clnt, NLM_GRANTED, xdr_nlm_testargs, argp, xdr_nlm_res,
|
|
|
|
&res, TIMEOUT) != RPC_SUCCESS) {
|
|
|
|
return NULL;
|
1997-03-10 09:26:19 +03:00
|
|
|
}
|
2007-11-05 02:12:50 +03:00
|
|
|
return &res;
|
1997-03-10 09:26:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-05 02:12:50 +03:00
|
|
|
void *
|
|
|
|
nlm_test_msg_1(struct nlm_testargs *argp, CLIENT *clnt)
|
1997-03-10 09:26:19 +03:00
|
|
|
{
|
|
|
|
static char res;
|
|
|
|
|
2007-11-05 02:12:50 +03:00
|
|
|
(void)memset(&res, 0, sizeof(res));
|
|
|
|
if (clnt_call(clnt, NLM_TEST_MSG, xdr_nlm_testargs, argp, xdr_void,
|
|
|
|
&res, TIMEOUT) != RPC_SUCCESS) {
|
|
|
|
return NULL;
|
1997-03-10 09:26:19 +03:00
|
|
|
}
|
2007-11-05 02:12:50 +03:00
|
|
|
return &res;
|
1997-03-10 09:26:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-05 02:12:50 +03:00
|
|
|
void *
|
|
|
|
nlm_lock_msg_1(struct nlm_lockargs *argp, CLIENT *clnt)
|
1997-03-10 09:26:19 +03:00
|
|
|
{
|
|
|
|
static char res;
|
|
|
|
|
2007-11-05 02:12:50 +03:00
|
|
|
(void)memset(&res, 0, sizeof(res));
|
|
|
|
if (clnt_call(clnt, NLM_LOCK_MSG, xdr_nlm_lockargs, argp, xdr_void,
|
|
|
|
NULL, TIMEOUT) != RPC_SUCCESS) {
|
1997-03-10 09:26:19 +03:00
|
|
|
clnt_perror(clnt, "nlm_lock_msg_1");
|
2007-11-05 02:12:50 +03:00
|
|
|
return NULL;
|
1997-03-10 09:26:19 +03:00
|
|
|
}
|
2007-11-05 02:12:50 +03:00
|
|
|
return &res;
|
1997-03-10 09:26:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-05 02:12:50 +03:00
|
|
|
void *
|
|
|
|
nlm_cancel_msg_1(struct nlm_cancargs *argp, CLIENT *clnt)
|
1997-03-10 09:26:19 +03:00
|
|
|
{
|
|
|
|
static char res;
|
|
|
|
|
2007-11-05 02:12:50 +03:00
|
|
|
(void)memset(&res, 0, sizeof(res));
|
|
|
|
if (clnt_call(clnt, NLM_CANCEL_MSG, xdr_nlm_cancargs, argp, xdr_void,
|
|
|
|
&res, TIMEOUT) != RPC_SUCCESS) {
|
|
|
|
return NULL;
|
1997-03-10 09:26:19 +03:00
|
|
|
}
|
2007-11-05 02:12:50 +03:00
|
|
|
return &res;
|
1997-03-10 09:26:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-05 02:12:50 +03:00
|
|
|
void *
|
|
|
|
nlm_unlock_msg_1(struct nlm_unlockargs *argp, CLIENT *clnt)
|
1997-03-10 09:26:19 +03:00
|
|
|
{
|
|
|
|
static char res;
|
|
|
|
|
2007-11-05 02:12:50 +03:00
|
|
|
(void)memset(&res, 0, sizeof(res));
|
|
|
|
if (clnt_call(clnt, NLM_UNLOCK_MSG, xdr_nlm_unlockargs, argp, xdr_void,
|
|
|
|
&res, TIMEOUT) != RPC_SUCCESS) {
|
|
|
|
return NULL;
|
1997-03-10 09:26:19 +03:00
|
|
|
}
|
2007-11-05 02:12:50 +03:00
|
|
|
return &res;
|
1997-03-10 09:26:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-05 02:12:50 +03:00
|
|
|
void *
|
|
|
|
nlm_granted_msg_1(struct nlm_testargs *argp, CLIENT *clnt)
|
1997-03-10 09:26:19 +03:00
|
|
|
{
|
|
|
|
static char res;
|
|
|
|
|
2007-11-05 02:12:50 +03:00
|
|
|
(void)memset(&res, 0, sizeof(res));
|
|
|
|
if (clnt_call(clnt, NLM_GRANTED_MSG, xdr_nlm_testargs, argp, xdr_void,
|
|
|
|
&res, TIMEOUT) != RPC_SUCCESS) {
|
|
|
|
return NULL;
|
1997-03-10 09:26:19 +03:00
|
|
|
}
|
2007-11-05 02:12:50 +03:00
|
|
|
return &res;
|
1997-03-10 09:26:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-05 02:12:50 +03:00
|
|
|
void *
|
|
|
|
nlm_test_res_1(nlm_testres *argp, CLIENT *clnt)
|
1997-03-10 09:26:19 +03:00
|
|
|
{
|
|
|
|
static char res;
|
|
|
|
|
2007-11-05 02:12:50 +03:00
|
|
|
(void)memset(&res, 0, sizeof(res));
|
|
|
|
if (clnt_call(clnt, NLM_TEST_RES, xdr_nlm_testres, argp, xdr_void, &res,
|
|
|
|
TIMEOUT) != RPC_SUCCESS) {
|
|
|
|
return NULL;
|
1997-03-10 09:26:19 +03:00
|
|
|
}
|
2007-11-05 02:12:50 +03:00
|
|
|
return &res;
|
1997-03-10 09:26:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-05 02:12:50 +03:00
|
|
|
void *
|
|
|
|
nlm_lock_res_1(nlm_res *argp, CLIENT *clnt)
|
1997-03-10 09:26:19 +03:00
|
|
|
{
|
|
|
|
static char res;
|
|
|
|
|
2007-11-05 02:12:50 +03:00
|
|
|
(void)memset(&res, 0, sizeof(res));
|
|
|
|
if (clnt_call(clnt, NLM_LOCK_RES, xdr_nlm_res, argp, xdr_void, &res,
|
|
|
|
TIMEOUT) != RPC_SUCCESS) {
|
|
|
|
return NULL;
|
1997-03-10 09:26:19 +03:00
|
|
|
}
|
2007-11-05 02:12:50 +03:00
|
|
|
return &res;
|
1997-03-10 09:26:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-05 02:12:50 +03:00
|
|
|
void *
|
|
|
|
nlm_cancel_res_1(nlm_res *argp, CLIENT *clnt)
|
1997-03-10 09:26:19 +03:00
|
|
|
{
|
|
|
|
static char res;
|
|
|
|
|
2007-11-05 02:12:50 +03:00
|
|
|
(void)memset(&res, 0, sizeof(res));
|
|
|
|
if (clnt_call(clnt, NLM_CANCEL_RES, xdr_nlm_res, argp, xdr_void, &res,
|
|
|
|
TIMEOUT) != RPC_SUCCESS) {
|
|
|
|
return NULL;
|
1997-03-10 09:26:19 +03:00
|
|
|
}
|
2007-11-05 02:12:50 +03:00
|
|
|
return &res;
|
1997-03-10 09:26:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-05 02:12:50 +03:00
|
|
|
void *
|
|
|
|
nlm_unlock_res_1(nlm_res *argp, CLIENT *clnt)
|
1997-03-10 09:26:19 +03:00
|
|
|
{
|
|
|
|
static char res;
|
|
|
|
|
2007-11-05 02:12:50 +03:00
|
|
|
(void)memset(&res, 0, sizeof(res));
|
|
|
|
if (clnt_call(clnt, NLM_UNLOCK_RES, xdr_nlm_res, argp, xdr_void, &res,
|
|
|
|
TIMEOUT) != RPC_SUCCESS) {
|
|
|
|
return NULL;
|
1997-03-10 09:26:19 +03:00
|
|
|
}
|
2007-11-05 02:12:50 +03:00
|
|
|
return &res;
|
1997-03-10 09:26:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-05 02:12:50 +03:00
|
|
|
void *
|
|
|
|
nlm_granted_res_1(nlm_res *argp, CLIENT *clnt)
|
1997-03-10 09:26:19 +03:00
|
|
|
{
|
|
|
|
static char res;
|
|
|
|
|
2007-11-05 02:12:50 +03:00
|
|
|
(void)memset(&res, 0, sizeof(res));
|
|
|
|
if (clnt_call(clnt, NLM_GRANTED_RES, xdr_nlm_res, argp, xdr_void, &res,
|
|
|
|
TIMEOUT) != RPC_SUCCESS) {
|
|
|
|
return NULL;
|
1997-03-10 09:26:19 +03:00
|
|
|
}
|
2007-11-05 02:12:50 +03:00
|
|
|
return &res;
|
1997-03-10 09:26:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nlm_shareres *
|
2007-11-05 02:12:50 +03:00
|
|
|
nlm_share_3(nlm_shareargs *argp, CLIENT *clnt)
|
1997-03-10 09:26:19 +03:00
|
|
|
{
|
|
|
|
static nlm_shareres res;
|
|
|
|
|
2007-11-05 02:12:50 +03:00
|
|
|
(void)memset(&res, 0, sizeof(res));
|
|
|
|
if (clnt_call(clnt, NLM_SHARE, xdr_nlm_shareargs, argp,
|
|
|
|
xdr_nlm_shareres, &res, TIMEOUT) != RPC_SUCCESS) {
|
|
|
|
return NULL;
|
1997-03-10 09:26:19 +03:00
|
|
|
}
|
2007-11-05 02:12:50 +03:00
|
|
|
return &res;
|
1997-03-10 09:26:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nlm_shareres *
|
2007-11-05 02:12:50 +03:00
|
|
|
nlm_unshare_3(nlm_shareargs *argp, CLIENT *clnt)
|
1997-03-10 09:26:19 +03:00
|
|
|
{
|
|
|
|
static nlm_shareres res;
|
|
|
|
|
2007-11-05 02:12:50 +03:00
|
|
|
(void)memset(&res, 0, sizeof(res));
|
|
|
|
if (clnt_call(clnt, NLM_UNSHARE, xdr_nlm_shareargs, argp,
|
|
|
|
xdr_nlm_shareres, &res, TIMEOUT) != RPC_SUCCESS) {
|
|
|
|
return NULL;
|
1997-03-10 09:26:19 +03:00
|
|
|
}
|
2007-11-05 02:12:50 +03:00
|
|
|
return &res;
|
1997-03-10 09:26:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nlm_res *
|
2007-11-05 02:12:50 +03:00
|
|
|
nlm_nm_lock_3(nlm_lockargs *argp, CLIENT *clnt)
|
1997-03-10 09:26:19 +03:00
|
|
|
{
|
|
|
|
static nlm_res res;
|
|
|
|
|
2007-11-05 02:12:50 +03:00
|
|
|
(void)memset(&res, 0, sizeof(res));
|
|
|
|
if (clnt_call(clnt, NLM_NM_LOCK, xdr_nlm_lockargs, argp, xdr_nlm_res,
|
|
|
|
&res, TIMEOUT) != RPC_SUCCESS) {
|
|
|
|
return NULL;
|
1997-03-10 09:26:19 +03:00
|
|
|
}
|
2007-11-05 02:12:50 +03:00
|
|
|
return &res;
|
1997-03-10 09:26:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-05 02:12:50 +03:00
|
|
|
void *
|
|
|
|
nlm_free_all_3(nlm_notify *argp, CLIENT *clnt)
|
1997-03-10 09:26:19 +03:00
|
|
|
{
|
|
|
|
static char res;
|
|
|
|
|
2007-11-05 02:12:50 +03:00
|
|
|
(void)memset(&res, 0, sizeof(res));
|
|
|
|
if (clnt_call(clnt, NLM_FREE_ALL, xdr_nlm_notify, argp, xdr_void, &res,
|
|
|
|
TIMEOUT) != RPC_SUCCESS) {
|
|
|
|
return NULL;
|
1997-03-10 09:26:19 +03:00
|
|
|
}
|
2007-11-05 02:12:50 +03:00
|
|
|
return &res;
|
1997-03-10 09:26:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
CLIENT *cli;
|
|
|
|
nlm_res res_block;
|
|
|
|
nlm_res *out;
|
|
|
|
nlm_lockargs arg;
|
|
|
|
struct timeval tim;
|
|
|
|
|
|
|
|
printf("Creating client for host %s\n", argv[1]);
|
|
|
|
cli = clnt_create(argv[1], NLM_PROG, NLM_VERS, "udp");
|
|
|
|
if (!cli) {
|
2002-07-20 12:40:16 +04:00
|
|
|
errx(1, "Failed to create client");
|
1997-03-10 09:26:19 +03:00
|
|
|
/* NOTREACHED */
|
|
|
|
}
|
2007-11-05 02:12:50 +03:00
|
|
|
clnt_control(cli, CLGET_TIMEOUT, (void *)&tim);
|
1997-03-10 09:26:19 +03:00
|
|
|
printf("Default timeout was %d.%d\n", tim.tv_sec, tim.tv_usec);
|
|
|
|
tim.tv_usec = -1;
|
|
|
|
tim.tv_sec = -1;
|
2007-11-05 02:12:50 +03:00
|
|
|
clnt_control(cli, CLSET_TIMEOUT, (void *)&tim);
|
|
|
|
clnt_control(cli, CLGET_TIMEOUT, (void *)&tim);
|
1997-03-10 09:26:19 +03:00
|
|
|
printf("timeout now %d.%d\n", tim.tv_sec, tim.tv_usec);
|
|
|
|
|
|
|
|
|
|
|
|
arg.cookie.n_len = 4;
|
|
|
|
arg.cookie.n_bytes = "hello";
|
|
|
|
arg.block = 0;
|
|
|
|
arg.exclusive = 0;
|
|
|
|
arg.reclaim = 0;
|
|
|
|
arg.state = 0x1234;
|
|
|
|
arg.alock.caller_name = "localhost";
|
|
|
|
arg.alock.fh.n_len = 32;
|
|
|
|
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";
|
|
|
|
arg.alock.oh.n_len = 8;
|
|
|
|
arg.alock.oh.n_bytes = "\x00\x00\x02\xff\xff\xff\xd3";
|
|
|
|
arg.alock.svid = 0x5678;
|
|
|
|
arg.alock.l_offset = 0;
|
|
|
|
arg.alock.l_len = 100;
|
|
|
|
|
|
|
|
res_block.stat.stat = nlm_granted;
|
|
|
|
res_block.cookie.n_bytes = "hello";
|
|
|
|
res_block.cookie.n_len = 5;
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
if (nlm_lock_res_1(&res_block, cli))
|
|
|
|
printf("Success!\n");
|
|
|
|
else
|
|
|
|
printf("Fail\n");
|
|
|
|
#else
|
|
|
|
if (out = nlm_lock_msg_1(&arg, cli)) {
|
|
|
|
printf("Success!\n");
|
|
|
|
printf("out->stat = %d", out->stat);
|
|
|
|
} else {
|
|
|
|
printf("Fail\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|