X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=examples%2Fportmap-client.c;fp=examples%2Fportmap-client.c;h=73c7ab28c1bccbcd0dc9c2939810971664cac64e;hb=5245608a6587cf6b5279ffc4fde701d8dce23bf3;hp=b479888523deec55abbc119e165f3465bc26d819;hpb=6c60e2822f0caccc4563a610aac23efe6b23aae9;p=deb_libnfs.git diff --git a/examples/portmap-client.c b/examples/portmap-client.c index b479888..73c7ab2 100644 --- a/examples/portmap-client.c +++ b/examples/portmap-client.c @@ -37,6 +37,7 @@ #include #include #include +#include #include "libnfs-zdr.h" #include "libnfs.h" #include "libnfs-raw.h" @@ -124,6 +125,26 @@ void pmap3_getaddr_cb(struct rpc_context *rpc, int status, void *data, void *pri 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; @@ -224,6 +245,7 @@ int main(int argc _U_, char *argv[] _U_) int null3 = 0; int getaddr3 = 0; int dump3 = 0; + int gettime3 = 0; int command_found = 0; int getaddr3prog, getaddr3vers; @@ -245,6 +267,9 @@ int main(int argc _U_, char *argv[] _U_) } 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]); @@ -297,6 +322,13 @@ int main(int argc _U_, char *argv[] _U_) } 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;