X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=examples%2Fnfsclient-bcast.c;h=6f48618259a15ec8a21c04b49ce928e0827b3a01;hb=cb46c8fb9dfde942b531545359ed92313112e668;hp=c74c5b37764b8e12a9aa002ee714aadf24deb17f;hpb=28f7bd66967e39c8f2290f32c9b3dee1306cb11c;p=deb_libnfs.git diff --git a/examples/nfsclient-bcast.c b/examples/nfsclient-bcast.c index c74c5b3..6f48618 100644 --- a/examples/nfsclient-bcast.c +++ b/examples/nfsclient-bcast.c @@ -25,6 +25,9 @@ #include #include #include +#include +#include +#include #include #include "libnfs.h" #include "libnfs-raw.h" @@ -38,6 +41,9 @@ void pm_cb(struct rpc_context *rpc _U_, int status, void *data, void *private_da struct sockaddr *sin; char hostdd[16]; + if (status == RPC_STATUS_CANCEL) { + return; + } if (status != 0) { printf("callback for CALLIT failed\n"); exit(10); @@ -61,6 +67,9 @@ int main(int argc _U_, char *argv[] _U_) { struct rpc_context *rpc; struct pollfd pfd; + struct ifconf ifc; + int i, size; + struct timeval tv_start, tv_current; rpc = rpc_init_udp_context(); if (rpc == NULL) { @@ -73,43 +82,90 @@ int main(int argc _U_, char *argv[] _U_) exit(10); } - if (rpc_set_udp_destination(rpc, "10.1.1.255", 111, 1) < 0) { - printf("failed to set udp destination %s\n", rpc_get_error(rpc)); - exit(10); - } - if (rpc_pmap_callit_async(rpc, 100005, 2, 0, NULL, 0, pm_cb, NULL) < 0) { - printf("Failed to set up callit function\n"); - exit(10); - } - if (rpc_set_udp_destination(rpc, "10.9.2.255", 111, 1) < 0) { - printf("failed to set udp destination %s\n", rpc_get_error(rpc)); - exit(10); - } + /* get list of all interfaces */ + size = sizeof(struct ifreq); + ifc.ifc_buf = NULL; + ifc.ifc_len = size; - if (rpc_pmap_callit_async(rpc, 100005, 2, 0, NULL, 0, pm_cb, NULL) < 0) { - printf("Failed to set up callit function\n"); - exit(10); - } + while (ifc.ifc_len == size) { + size *= 2; - alarm(3); + free(ifc.ifc_buf); + ifc.ifc_len = size; + ifc.ifc_buf = malloc(size); + if (ioctl(rpc_get_fd(rpc), SIOCGIFCONF, (caddr_t)&ifc) < 0) { + printf("ioctl SIOCGIFCONF failed\n"); + exit(10); + } + } + + for (i=0; i