PORTMAP: Add support for V3 DUMP command
[deb_libnfs.git] / examples / nfsclient-raw.c
index 28dd45ceccf77bc469a9d32cd420a8ae27e2d360..fd6575f21fac787d3e0330d9216073bf126861a9 100644 (file)
@@ -44,6 +44,7 @@
 #include "libnfs-raw.h"
 #include "libnfs-raw-mount.h"
 #include "libnfs-raw-nfs.h"
+#include "libnfs-raw-portmap.h"
 #include "libnfs-raw-rquota.h"
 
 struct client {
@@ -345,9 +346,11 @@ void pmap_getport1_cb(struct rpc_context *rpc, int status, void *data, void *pri
        }
 }
 
-void pmap_null_cb(struct rpc_context *rpc, int status, void *data, void *private_data)
+void pmap_dump_cb(struct rpc_context *rpc, int status, void *data, void *private_data)
 {
        struct client *client = private_data;
+       struct pmap_dump_result *dr = data;
+       struct pmap_mapping_list *list = dr->list;
 
        if (status == RPC_STATUS_ERROR) {
                printf("portmapper null call failed with \"%s\"\n", (char *)data);
@@ -358,7 +361,16 @@ void pmap_null_cb(struct rpc_context *rpc, int status, void *data, void *private
                exit(10);
        }
 
-       printf("Got reply from server for PORTMAP/NULL procedure.\n");
+       printf("Got reply from server for PORTMAP/DUMP procedure.\n");
+       while (list) {
+               printf("Prog:%d Vers:%d Protocol:%d Port:%d\n",
+                       list->map.prog,
+                       list->map.vers,
+                       list->map.prot,
+                       list->map.port);
+               list = list->next;
+       }
+
        printf("Send getport request asking for MOUNT port\n");
        if (rpc_pmap_getport_async(rpc, RQUOTA_PROGRAM, RQUOTA_V1, IPPROTO_TCP, pmap_getport1_cb, client) != 0) {
                printf("Failed to send getport request\n");
@@ -366,6 +378,27 @@ void pmap_null_cb(struct rpc_context *rpc, int status, void *data, void *private
        }
 }
 
+void pmap_null_cb(struct rpc_context *rpc, int status, void *data, void *private_data)
+{
+       struct client *client = private_data;
+
+       if (status == RPC_STATUS_ERROR) {
+               printf("portmapper null call failed with \"%s\"\n", (char *)data);
+               exit(10);
+       }
+       if (status != RPC_STATUS_SUCCESS) {
+               printf("portmapper null call to server %s failed, status:%d\n", client->server, status);
+               exit(10);
+       }
+
+       printf("Got reply from server for PORTMAP/NULL procedure.\n");
+       printf("Send PMAP/DUMP command\n");
+       if (rpc_pmap_dump_async(rpc, pmap_dump_cb, client) != 0) {
+               printf("Failed to send getport request\n");
+               exit(10);
+       }
+}
+
 void pmap_connect_cb(struct rpc_context *rpc, int status, void *data _U_, void *private_data)
 {
        struct client *client = private_data;