diff options
Diffstat (limited to 'sysdeps/generic/ifreq.h')
-rw-r--r-- | sysdeps/generic/ifreq.h | 61 |
1 files changed, 2 insertions, 59 deletions
diff --git a/sysdeps/generic/ifreq.h b/sysdeps/generic/ifreq.h index 4871c8d1d8..6e01fb463e 100644 --- a/sysdeps/generic/ifreq.h +++ b/sysdeps/generic/ifreq.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1999,2002 Free Software Foundation, Inc. +/* Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Andreas Jaeger <aj@suse.de>. @@ -34,64 +34,7 @@ __if_nextreq (struct ifreq *ifr) return ifr + 1; } -static inline void -__ifreq (struct ifreq **ifreqs, int *num_ifs, int sockfd) -{ - int fd = sockfd; - struct ifconf ifc; - int rq_len; - int nifs; -# define RQ_IFS 4 - - if (fd < 0) - fd = __opensock (); - if (fd < 0) - { - *num_ifs = 0; - *ifreqs = NULL; - return; - } - - ifc.ifc_buf = NULL; - rq_len = RQ_IFS * sizeof (struct ifreq) / 2; /* Doubled in the loop. */ - do - { - ifc.ifc_len = rq_len *= 2; - ifc.ifc_buf = realloc (ifc.ifc_buf, ifc.ifc_len); - if (ifc.ifc_buf == NULL || __ioctl (fd, SIOCGIFCONF, &ifc) < 0) - { - if (ifc.ifc_buf) - free (ifc.ifc_buf); - - if (fd != sockfd) - __close (fd); - *num_ifs = 0; - *ifreqs = NULL; - return; - } - } - while (rq_len < sizeof (struct ifreq) + ifc.ifc_len); - - if (fd != sockfd) - __close (fd); - -#ifdef _HAVE_SA_LEN - struct ifreq *ifr = ifreqs; - nifs = 0; - while ((char *) ifr < ifc.ifc_buf + ifc.ifc_len) - { - ++nifs; - ifr = __if_nextreq (ifr); - if (ifr == NULL) - break; - } -#else - nifs = ifc.ifc_len / sizeof (struct ifreq); -#endif - - *num_ifs = nifs; - *ifreqs = realloc (ifc.ifc_buf, nifs * sizeof (struct ifreq)); -} +extern void __ifreq (struct ifreq **ifreqs, int *num_ifs, int sockfd); static inline void |