diff options
author | Jakub Jelinek <jakub@redhat.com> | 2004-09-27 06:18:18 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2004-09-27 06:18:18 +0000 |
commit | f1750fb9c68854778e6e023ed490ff80e1c90167 (patch) | |
tree | 416f6a0fabb42abbdafde8965810adb5abcf0283 /sunrpc/clnt_udp.c | |
parent | efaf80c5d05102f75864847140bfb8b2bdbd4523 (diff) | |
download | glibc-f1750fb9c68854778e6e023ed490ff80e1c90167.tar.gz glibc-f1750fb9c68854778e6e023ed490ff80e1c90167.tar.xz glibc-f1750fb9c68854778e6e023ed490ff80e1c90167.zip |
Updated to fedora-glibc-20040927T0611 cvs/fedora-glibc-2_3_3-59
Diffstat (limited to 'sunrpc/clnt_udp.c')
-rw-r--r-- | sunrpc/clnt_udp.c | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/sunrpc/clnt_udp.c b/sunrpc/clnt_udp.c index f906173363..1836ff3433 100644 --- a/sunrpc/clnt_udp.c +++ b/sunrpc/clnt_udp.c @@ -50,6 +50,7 @@ static char sccsid[] = "@(#)clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro"; #include <errno.h> #include <rpc/pmap_clnt.h> #include <net/if.h> +#include <ifaddrs.h> #ifdef USE_IN_LIBIO # include <wchar.h> #endif @@ -234,28 +235,24 @@ INTDEF (clntudp_create) static int is_network_up (int sock) { - struct ifconf ifc; - char buf[UDPMSGSIZE]; - struct ifreq ifreq, *ifr; - int n; - - ifc.ifc_len = sizeof (buf); - ifc.ifc_buf = buf; - if (__ioctl(sock, SIOCGIFCONF, (char *) &ifc) == 0) + struct ifaddrs *ifa; + + if (getifaddrs (&ifa) != 0) + return 0; + + struct ifaddrs *run = ifa; + while (run != NULL) { - ifr = ifc.ifc_req; - for (n = ifc.ifc_len / sizeof (struct ifreq); n > 0; n--, ifr++) - { - ifreq = *ifr; - if (__ioctl (sock, SIOCGIFFLAGS, (char *) &ifreq) < 0) - break; + if ((run->ifa_flags & IFF_UP) != 0 + && run->ifa_addr->sa_family == AF_INET) + break; - if ((ifreq.ifr_flags & IFF_UP) - && ifr->ifr_addr.sa_family == AF_INET) - return 1; - } + run = run->ifa_next; } - return 0; + + freeifaddrs (ifa); + + return run != NULL; } static enum clnt_stat |