X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=portmap%2Fportmap.c;h=c7820d0a003d3f664522d22f9d5577a763709b7b;hb=1fbe408023d951f45394c27ea5849c4e9702a150;hp=d2ec4b883cba60c7401379a1faa2012c96451829;hpb=5c6b1176c294e9718c5267787537cee7e19df1b4;p=deb_libnfs.git diff --git a/portmap/portmap.c b/portmap/portmap.c index d2ec4b8..c7820d0 100644 --- a/portmap/portmap.c +++ b/portmap/portmap.c @@ -76,6 +76,66 @@ int rpc_pmap_getport_async(struct rpc_context *rpc, int program, int version, in return 0; } +int rpc_pmap_set_async(struct rpc_context *rpc, int program, int version, int protocol, int port, rpc_cb cb, void *private_data) +{ + struct rpc_pdu *pdu; + struct pmap_mapping m; + + pdu = rpc_allocate_pdu(rpc, PMAP_PROGRAM, PMAP_V2, PMAP_SET, cb, private_data, (xdrproc_t)xdr_int, sizeof(uint32_t)); + if (pdu == NULL) { + rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for portmap/set call"); + return -1; + } + + m.prog = program; + m.vers = version; + m.prot = protocol; + m.port = port; + if (xdr_pmap_mapping(&pdu->xdr, &m) == 0) { + rpc_set_error(rpc, "XDR error: Failed to encode data for portmap/set call"); + rpc_free_pdu(rpc, pdu); + return -1; + } + + if (rpc_queue_pdu(rpc, pdu) != 0) { + rpc_set_error(rpc, "Failed to queue portmap/set pdu"); + rpc_free_pdu(rpc, pdu); + return -1; + } + + return 0; +} + +int rpc_pmap_unset_async(struct rpc_context *rpc, int program, int version, int protocol, int port, rpc_cb cb, void *private_data) +{ + struct rpc_pdu *pdu; + struct pmap_mapping m; + + pdu = rpc_allocate_pdu(rpc, PMAP_PROGRAM, PMAP_V2, PMAP_UNSET, cb, private_data, (xdrproc_t)xdr_int, sizeof(uint32_t)); + if (pdu == NULL) { + rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for portmap/unset call"); + return -1; + } + + m.prog = program; + m.vers = version; + m.prot = protocol; + m.port = port; + if (xdr_pmap_mapping(&pdu->xdr, &m) == 0) { + rpc_set_error(rpc, "XDR error: Failed to encode data for portmap/unset call"); + rpc_free_pdu(rpc, pdu); + return -1; + } + + if (rpc_queue_pdu(rpc, pdu) != 0) { + rpc_set_error(rpc, "Failed to queue portmap/unset pdu"); + rpc_free_pdu(rpc, pdu); + return -1; + } + + return 0; +} + int rpc_pmap_callit_async(struct rpc_context *rpc, int program, int version, int procedure, const char *data, int datalen, rpc_cb cb, void *private_data) { struct rpc_pdu *pdu;