#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <time.h>
#include "libnfs-zdr.h"
#include "libnfs.h"
#include "libnfs-raw.h"
client->is_finished = 1;
}
+void pmap3_gettime_cb(struct rpc_context *rpc, int status, void *data, void *private_data)
+{
+ struct client *client = private_data;
+ time_t t = *(uint32_t *)data;
+
+ if (status == RPC_STATUS_ERROR) {
+ printf("PORTMAP3/GETTIME call failed with \"%s\"\n", (char *)data);
+ exit(10);
+ }
+ if (status != RPC_STATUS_SUCCESS) {
+ printf("PORTMAP3/GETTIME call failed, status:%d\n", status);
+ exit(10);
+ }
+
+ printf("PORTMAP3/GETTIME:\n");
+ printf(" Time:%d %s\n", (int)t, ctime(&t));
+
+ client->is_finished = 1;
+}
+
void pmap2_null_cb(struct rpc_context *rpc, int status, void *data, void *private_data)
{
struct client *client = private_data;
int null3 = 0;
int getaddr3 = 0;
int dump3 = 0;
+ int gettime3 = 0;
int command_found = 0;
int getaddr3prog, getaddr3vers;
} else if (!strcmp(argv[i], "dump3")) {
dump3 = 1;
command_found++;
+ } else if (!strcmp(argv[i], "gettime3")) {
+ gettime3 = 1;
+ command_found++;
} else if (!strcmp(argv[i], "getaddr3")) {
getaddr3 = 1;
getaddr3prog = atoi(argv[++i]);
}
wait_until_finished(rpc, &client);
}
+ if (gettime3) {
+ if (rpc_pmap3_gettime_async(rpc, pmap3_gettime_cb, &client) != 0) {
+ printf("Failed to send GETTIME3 request\n");
+ exit(10);
+ }
+ wait_until_finished(rpc, &client);
+ }
if (getaddr3) {
struct pmap3_mapping map;
*/
EXTERN int rpc_pmap3_dump_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
+/*
+ * Call PORTMAPPER3/GETTIME.
+ * 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 a 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_gettime_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
/*
* MOUNT v3 FUNCTIONS
rpc_pmap3_null_async
rpc_pmap3_getaddr_async
rpc_pmap3_dump_async
+rpc_pmap3_gettime_async
rpc_mount_null_async
rpc_mount_mnt_async
rpc_mount_dump_async
#define PMAP3_DUMP 4
extern pmap3_dump_result * pmap3_dump_3(void *, CLIENT *);
extern pmap3_dump_result * pmap3_dump_3_svc(void *, struct svc_req *);
+#define PMAP3_GETTIME 6
+extern u_int * pmap3_gettime_3(void *, CLIENT *);
+extern u_int * pmap3_gettime_3_svc(void *, struct svc_req *);
extern int pmap_program_3_freeresult (SVCXPRT *, zdrproc_t, caddr_t);
#else /* K&R C */
#define PMAP3_DUMP 4
extern pmap3_dump_result * pmap3_dump_3();
extern pmap3_dump_result * pmap3_dump_3_svc();
+#define PMAP3_GETTIME 6
+extern u_int * pmap3_gettime_3();
+extern u_int * pmap3_gettime_3_svc();
extern int pmap_program_3_freeresult ();
#endif /* K&R C */
return 0;
}
+
+int rpc_pmap3_gettime_async(struct rpc_context *rpc, rpc_cb cb, void *private_data)
+{
+ struct rpc_pdu *pdu;
+
+ pdu = rpc_allocate_pdu(rpc, PMAP_PROGRAM, PMAP_V3, PMAP3_GETTIME, 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/GETTIME call");
+ return -1;
+ }
+
+ if (rpc_queue_pdu(rpc, pdu) != 0) {
+ rpc_set_error(rpc, "Failed to queue PORTMAP3/GETTIME pdu");
+ rpc_free_pdu(rpc, pdu);
+ return -1;
+ }
+
+ return 0;
+}
pmap3_dump_result
PMAP3_DUMP(void) = 4;
+
+ unsigned int
+ PMAP3_GETTIME(void) = 6;
} = 3;
} = 100000;