X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=portmap%2Fportmap.c;h=c7820d0a003d3f664522d22f9d5577a763709b7b;hb=fab61e3d0384e61553b39860b923d41bc0cf17b1;hp=07aa91276ea07ce06c9653cd56f851c4b22ee4d1;hpb=dabf41528576be84318ce8da010173493c1e1231;p=deb_libnfs.git
diff --git a/portmap/portmap.c b/portmap/portmap.c
index 07aa912..c7820d0 100644
--- a/portmap/portmap.c
+++ b/portmap/portmap.c
@@ -14,6 +14,9 @@
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, see .
*/
+#ifdef WIN32
+#include "win32_compat.h"
+#endif/*WIN32*/
#include
#include
@@ -43,7 +46,7 @@ int rpc_pmap_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data)
return 0;
}
-int rpc_pmap_getport_async(struct rpc_context *rpc, int program, int version, rpc_cb cb, void *private_data)
+int rpc_pmap_getport_async(struct rpc_context *rpc, int program, int version, int protocol, rpc_cb cb, void *private_data)
{
struct rpc_pdu *pdu;
struct pmap_mapping m;
@@ -56,7 +59,7 @@ int rpc_pmap_getport_async(struct rpc_context *rpc, int program, int version, rp
m.prog = program;
m.vers = version;
- m.prot = IPPROTO_TCP;
+ m.prot = protocol;
m.port = 0;
if (xdr_pmap_mapping(&pdu->xdr, &m) == 0) {
rpc_set_error(rpc, "XDR error: Failed to encode data for portmap/getport call");
@@ -73,6 +76,66 @@ int rpc_pmap_getport_async(struct rpc_context *rpc, int program, int version, rp
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;