X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=examples%2Fportmap-client.c;h=cae90d7a72f5b4fab5904926e3b3edf08be5a085;hb=2db42ce2fc89bc88050564037688888bbb8876e9;hp=1c3b240a39c509cbbfdf84e04513721e63cc93aa;hpb=75ec99d519800bbc1bda85c0483741cb5d8cac9e;p=deb_libnfs.git diff --git a/examples/portmap-client.c b/examples/portmap-client.c index 1c3b240..cae90d7 100644 --- a/examples/portmap-client.c +++ b/examples/portmap-client.c @@ -34,11 +34,12 @@ #include #endif +#include #include #include #include +#include #include -#include "libnfs-zdr.h" #include "libnfs.h" #include "libnfs-raw.h" #include "libnfs-raw-mount.h" @@ -189,6 +190,8 @@ void pmap3_uaddr2taddr_cb(struct rpc_context *rpc, int status, void *data, void { struct client *client = private_data; struct pmap3_netbuf *nb = data; + struct sockaddr_storage *ss; + char host[256], port[6]; int i; if (status == RPC_STATUS_ERROR) { @@ -210,6 +213,19 @@ void pmap3_uaddr2taddr_cb(struct rpc_context *rpc, int status, void *data, void } } printf("\n"); + printf(" ---\n"); + ss = (struct sockaddr_storage *)&nb->buf.buf_val[0]; + getnameinfo((struct sockaddr *)ss, sizeof(struct sockaddr_storage), + &host[0], sizeof(host), &port[0], sizeof(port), + NI_NUMERICHOST|NI_NUMERICSERV); + switch (ss->ss_family) { + case AF_INET: + printf(" IPv4: %s:%s\n", &host[0], &port[0]); + break; + case AF_INET6: + printf(" IPv6: %s:%s\n", &host[0], &port[0]); + break; + } client->is_finished = 1; }