ZDR: remove dependency on zdr.h from the examples and nfs-ls
[deb_libnfs.git] / examples / nfsclient-raw.c
index 28dd45ceccf77bc469a9d32cd420a8ae27e2d360..5838c2f28a48e622d9bfd909f8e0ecaf8eb1ac59 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include "libnfs-zdr.h"
 #include "libnfs.h"
 #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 {
@@ -339,7 +339,39 @@ void pmap_getport1_cb(struct rpc_context *rpc, int status, void *data, void *pri
        }               
 
        printf("Send getport request asking for MOUNT port\n");
-       if (rpc_pmap_getport_async(rpc, MOUNT_PROGRAM, MOUNT_V3, IPPROTO_TCP, pmap_getport2_cb, client) != 0) {
+       if (rpc_pmap2_getport_async(rpc, MOUNT_PROGRAM, MOUNT_V3, IPPROTO_TCP, pmap_getport2_cb, client) != 0) {
+               printf("Failed to send getport request\n");
+               exit(10);
+       }
+}
+
+void pmap_dump_cb(struct rpc_context *rpc, int status, void *data, void *private_data)
+{
+       struct client *client = private_data;
+       struct pmap2_dump_result *dr = data;
+       struct pmap2_mapping_list *list = dr->list;
+
+       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/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_pmap2_getport_async(rpc, RQUOTA_PROGRAM, RQUOTA_V1, IPPROTO_TCP, pmap_getport1_cb, client) != 0) {
                printf("Failed to send getport request\n");
                exit(10);
        }
@@ -359,8 +391,8 @@ void pmap_null_cb(struct rpc_context *rpc, int status, void *data, void *private
        }
 
        printf("Got reply from server for PORTMAP/NULL procedure.\n");
-       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("Send PMAP/DUMP command\n");
+       if (rpc_pmap2_dump_async(rpc, pmap_dump_cb, client) != 0) {
                printf("Failed to send getport request\n");
                exit(10);
        }
@@ -377,7 +409,7 @@ void pmap_connect_cb(struct rpc_context *rpc, int status, void *data _U_, void *
        }
 
        printf("Send NULL request to check if portmapper is actually running\n");
-       if (rpc_pmap_null_async(rpc, pmap_null_cb, client) != 0) {
+       if (rpc_pmap2_null_async(rpc, pmap_null_cb, client) != 0) {
                printf("Failed to send null request\n");
                exit(10);
        }