PORTMAP: Add support for SET UNSET procedures

libnfs-4.0.0-vitalif
Ronnie Sahlberg 2014-03-16 16:37:33 -07:00
parent 7fbedfdefd
commit d731e94cfa
4 changed files with 101 additions and 1 deletions

View File

@ -239,6 +239,39 @@ EXTERN int rpc_pmap2_callit_async(struct rpc_context *rpc, int program, int vers
*/
EXTERN int rpc_pmap3_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
/*
* Call PORTMAPPER3/SET.
* Function returns
* 0 : The connection was initiated. Once the connection establish finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the connection. 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 portmapper daemon.
* data is uint32_t *
* RPC_STATUS_ERROR : An error occured when trying to contact the portmapper.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct pmap3_mapping;
EXTERN int rpc_pmap3_set_async(struct rpc_context *rpc, struct pmap3_mapping *map, rpc_cb cb, void *private_data);
/*
* Call PORTMAPPER3/UNSET.
* Function returns
* 0 : The connection was initiated. Once the connection establish finishes, the callback will be invoked.
* <0 : An error occured when trying to set up the connection. 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 portmapper daemon.
* data is uint32_t *
* RPC_STATUS_ERROR : An error occured when trying to contact the portmapper.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
EXTERN int rpc_pmap3_unset_async(struct rpc_context *rpc, struct pmap3_mapping *map, rpc_cb cb, void *private_data);
/*
* Call PORTMAPPER3/GETADDR.
* Function returns
@ -253,7 +286,6 @@ EXTERN int rpc_pmap3_null_async(struct rpc_context *rpc, rpc_cb cb, void *privat
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
struct pmap3_mapping;
EXTERN int rpc_pmap3_getaddr_async(struct rpc_context *rpc, struct pmap3_mapping *map, rpc_cb cb, void *private_data);
/*

View File

@ -130,6 +130,12 @@ extern int pmap_program_2_freeresult ();
#define PMAP3_NULL 0
extern void * pmap3_null_3(void *, CLIENT *);
extern void * pmap3_null_3_svc(void *, struct svc_req *);
#define PMAP3_SET 1
extern bool_t * pmap3_set_3(pmap3_mapping *, CLIENT *);
extern bool_t * pmap3_set_3_svc(pmap3_mapping *, struct svc_req *);
#define PMAP3_UNSET 2
extern bool_t * pmap3_unset_3(pmap3_mapping *, CLIENT *);
extern bool_t * pmap3_unset_3_svc(pmap3_mapping *, struct svc_req *);
#define PMAP3_GETADDR 3
extern pmap3_getaddr_result * pmap3_getaddr_3(pmap3_mapping *, CLIENT *);
extern pmap3_getaddr_result * pmap3_getaddr_3_svc(pmap3_mapping *, struct svc_req *);
@ -142,6 +148,12 @@ extern int pmap_program_3_freeresult (SVCXPRT *, zdrproc_t, caddr_t);
#define PMAP3_NULL 0
extern void * pmap3_null_3();
extern void * pmap3_null_3_svc();
#define PMAP3_SET 1
extern bool_t * pmap3_set_3();
extern bool_t * pmap3_set_3_svc();
#define PMAP3_UNSET 2
extern bool_t * pmap3_unset_3();
extern bool_t * pmap3_unset_3_svc();
#define PMAP3_GETADDR 3
extern pmap3_getaddr_result * pmap3_getaddr_3();
extern pmap3_getaddr_result * pmap3_getaddr_3_svc();

View File

@ -209,6 +209,56 @@ int rpc_pmap3_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data)
return 0;
}
int rpc_pmap3_set_async(struct rpc_context *rpc, struct pmap3_mapping *map, rpc_cb cb, void *private_data)
{
struct rpc_pdu *pdu;
pdu = rpc_allocate_pdu(rpc, PMAP_PROGRAM, PMAP_V3, PMAP3_SET, cb, private_data, (zdrproc_t)zdr_int, sizeof(uint32_t));
if (pdu == NULL) {
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for PORTMAP3/SET call");
return -1;
}
if (zdr_pmap3_mapping(&pdu->zdr, map) == 0) {
rpc_set_error(rpc, "ZDR error: Failed to encode data for PORTMAP3/SET call");
rpc_free_pdu(rpc, pdu);
return -1;
}
if (rpc_queue_pdu(rpc, pdu) != 0) {
rpc_set_error(rpc, "Failed to queue PORTMAP3/SET pdu");
rpc_free_pdu(rpc, pdu);
return -1;
}
return 0;
}
int rpc_pmap3_unset_async(struct rpc_context *rpc, struct pmap3_mapping *map, rpc_cb cb, void *private_data)
{
struct rpc_pdu *pdu;
pdu = rpc_allocate_pdu(rpc, PMAP_PROGRAM, PMAP_V3, PMAP3_UNSET, cb, private_data, (zdrproc_t)zdr_int, sizeof(uint32_t));
if (pdu == NULL) {
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for PORTMAP3/UNSET call");
return -1;
}
if (zdr_pmap3_mapping(&pdu->zdr, map) == 0) {
rpc_set_error(rpc, "ZDR error: Failed to encode data for PORTMAP3/UNSET call");
rpc_free_pdu(rpc, pdu);
return -1;
}
if (rpc_queue_pdu(rpc, pdu) != 0) {
rpc_set_error(rpc, "Failed to queue PORTMAP3/UNSET pdu");
rpc_free_pdu(rpc, pdu);
return -1;
}
return 0;
}
int rpc_pmap3_getaddr_async(struct rpc_context *rpc, struct pmap3_mapping *map, rpc_cb cb, void *private_data)
{
struct rpc_pdu *pdu;

View File

@ -77,6 +77,12 @@ program PMAP_PROGRAM {
void
PMAP3_NULL(void) = 0;
bool
PMAP3_SET(pmap3_mapping) = 1;
bool
PMAP3_UNSET(pmap3_mapping) = 2;
pmap3_getaddr_result
PMAP3_GETADDR(pmap3_mapping) = 3;