NLM add TEST procedure

libnfs-4.0.0-vitalif
Ronnie Sahlberg 2012-03-10 21:38:29 +11:00
parent 6916a66546
commit e01ed6a239
3 changed files with 77 additions and 24 deletions

View File

@ -839,4 +839,24 @@ char *nlmstat4_to_str(int stat);
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
int rpc_nlm_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
int rpc_nlm4_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
/*
* Call NLM/TEST
* Call the TEST procedure for the NLM protocol
*
* Function returns
* 0 : The call was initiated. The callback will be invoked when the call completes.
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
* RPC_STATUS_SUCCESS : We got a successful response from the nlm daemon.
* data is NLM4_TESTres
* RPC_STATUS_ERROR : An error occured when trying to contact the nlm daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct NLM4_TESTargs;
int rpc_nlm4_test_async(struct rpc_context *rpc, rpc_cb cb, struct NLM4_TESTargs *args, void *private_data);

View File

@ -28,7 +28,7 @@
#include "libnfs-private.h"
#include "libnfs-raw-nlm.h"
int rpc_nlm_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data)
int rpc_nlm4_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data)
{
struct rpc_pdu *pdu;
@ -47,6 +47,31 @@ int rpc_nlm_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data)
return 0;
}
int rpc_nlm4_test_async(struct rpc_context *rpc, rpc_cb cb, struct NLM4_TESTargs *args, void *private_data)
{
struct rpc_pdu *pdu;
pdu = rpc_allocate_pdu(rpc, NLM_PROGRAM, NLM_V4, NLM4_TEST, cb, private_data, (xdrproc_t)xdr_NLM4_TESTres, sizeof(NLM4_TESTres));
if (pdu == NULL) {
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nlm/test call");
return -1;
}
if (xdr_NLM4_TESTargs(&pdu->xdr, args) == 0) {
rpc_set_error(rpc, "XDR error: Failed to encode NLM4_TESTargs");
rpc_free_pdu(rpc, pdu);
return -2;
}
if (rpc_queue_pdu(rpc, pdu) != 0) {
rpc_set_error(rpc, "Out of memory. Failed to queue pdu for nlm/test call");
rpc_free_pdu(rpc, pdu);
return -1;
}
return 0;
}
char *nlmstat4_to_str(int st)
{
enum nlmstat4 stat = st;

View File

@ -1,7 +1,15 @@
/* based on rfc1813 and wireshark */
const COOKIESIZE = 4;
typedef opaque nlm_cookie[COOKIESIZE];
struct nlm_fh4 {
opaque data<>;
};
typedef string nlm4_oh<>;
struct nlm_cookie {
opaque data<>;
};
enum nlmstat4 {
NLM4_GRANTED = 0,
@ -17,29 +25,29 @@ enum nlmstat4 {
};
struct nlm4_holder {
bool exclusive;
unsigned int svid;
netobj oh;
bool exclusive;
unsigned int svid;
nlm4_oh oh;
unsigned hyper l_offset;
unsigned hyper l_len;
};
const NLM_MAXNAME = 256;
struct nlm4_lock {
string caller_name<NLM_MAXNAME>;
netobj fh;
netobj oh;
unsigned int svid;
string caller_name<NLM_MAXNAME>;
struct nlm_fh4 fh;
nlm4_oh oh;
unsigned int svid;
unsigned hyper l_offset;
unsigned hyper l_len;
};
struct nlm4_share {
string caller_name<NLM_MAXNAME>;
netobj fh;
netobj oh;
unsigned int mode;
unsigned int access;
string caller_name<NLM_MAXNAME>;
struct nlm_fh4 fh;
nlm4_oh oh;
unsigned int mode;
unsigned int access;
};
@ -48,14 +56,14 @@ struct nlm4_testres_ok {
nlm4_holder holder;
};
union nlm4_testres switch (nlmstat4 nlm_status) {
union NLM4_TESTres switch (nlmstat4 status) {
case NLM4_GRANTED:
nlm4_testres_ok lock;
default:
void;
};
struct nlm4_testargs {
struct NLM4_TESTargs {
nlm_cookie cookie;
bool exclusive;
nlm4_lock lock;
@ -66,8 +74,8 @@ program NLM_PROGRAM {
void
NLM4_NULL(void) = 0;
nlm4_testres
NLM4_TEST(nlm4_testargs) = 1;
NLM4_TESTres
NLM4_TEST(NLM4_TESTargs) = 1;
/* nlm4_res */
/* NLM4_LOCK(nlm4_lockargs) = 2; */
@ -81,8 +89,8 @@ program NLM_PROGRAM {
/* nlm4_res */
/* NLM4_GRANTED(nlm4_testargs) = 5; */
/* void */
/* NLM4_TEST_MSG(nlm4_testargs) = 6; */
void
NLM4_TEST_MSG(NLM4_TESTargs) = 6;
/* void */
/* NLM4_LOCK_MSG(nlm4_lockargs) = 7; */
@ -96,8 +104,8 @@ program NLM_PROGRAM {
/* void */
/* NLM4_GRANTED_MSG(nlm4_testargs) = 10; */
/* void */
/* NLM4_TEST_RES(nlm4_testres) = 11; */
void
NLM4_TEST_RES(NLM4_TESTres) = 11;
/* void */
/* NLM4_LOCK_RES(nlm4_res) = 12; */