mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-28 00:21:52 +03:00
Update.
1999-10-27 Andreas Jaeger <aj@suse.de> * sysdeps/generic/ifreq.h: New file. * resolv/res_hconf.c: Add missing includes to get all prototypes. (_res_hconf_reorder_addrs): Rewrite. This never worked before. Reported by John DiMarco <jdd@cs.toronto.edu>. (_res_hconf_reorder_addrs): Made thread safe. (free_mem): New function, needed for malloc debugging. 1999-10-29 Andreas Jaeger <aj@suse.de> * sysdeps/unix/sysv/linux/if_index.c (opensock): Move function to ... * sysdeps/generic/opensock.c (__opensock): ...here in a new file. * sysdeps/unix/sysv/linux/if_index.c: Change all callers of opensock to use __opensock. * socket/Makefile (routines): Add opensock. * include/sys/socket.h (__opensock): Add prototype declaration.
This commit is contained in:
@ -35,47 +35,6 @@ static int old_siocgifconf;
|
||||
# define old_siocgifconf 0
|
||||
#endif
|
||||
|
||||
/* Try to get a socket to talk to the kernel. */
|
||||
#if defined SIOCGIFINDEX || defined SIOCGIFNAME
|
||||
static int
|
||||
internal_function
|
||||
opensock (void)
|
||||
{
|
||||
/* Cache the last AF that worked, to avoid many redundant calls to
|
||||
socket(). */
|
||||
static int sock_af = -1;
|
||||
int fd = -1;
|
||||
__libc_lock_define_initialized (static, lock);
|
||||
|
||||
if (sock_af != -1)
|
||||
{
|
||||
fd = __socket (sock_af, SOCK_DGRAM, 0);
|
||||
if (fd != -1)
|
||||
return fd;
|
||||
}
|
||||
|
||||
__libc_lock_lock (lock);
|
||||
|
||||
if (sock_af != -1)
|
||||
fd = __socket (sock_af, SOCK_DGRAM, 0);
|
||||
|
||||
if (fd == -1)
|
||||
{
|
||||
fd = __socket (sock_af = AF_INET, SOCK_DGRAM, 0);
|
||||
if (fd < 0)
|
||||
fd = __socket (sock_af = AF_INET6, SOCK_DGRAM, 0);
|
||||
if (fd < 0)
|
||||
fd = __socket (sock_af = AF_IPX, SOCK_DGRAM, 0);
|
||||
if (fd < 0)
|
||||
fd = __socket (sock_af = AF_AX25, SOCK_DGRAM, 0);
|
||||
if (fd < 0)
|
||||
fd = __socket (sock_af = AF_APPLETALK, SOCK_DGRAM, 0);
|
||||
}
|
||||
|
||||
__libc_lock_unlock (lock);
|
||||
return fd;
|
||||
}
|
||||
#endif
|
||||
|
||||
unsigned int
|
||||
if_nametoindex (const char *ifname)
|
||||
@ -85,7 +44,7 @@ if_nametoindex (const char *ifname)
|
||||
return 0;
|
||||
#else
|
||||
struct ifreq ifr;
|
||||
int fd = opensock ();
|
||||
int fd = __opensock ();
|
||||
|
||||
if (fd < 0)
|
||||
return 0;
|
||||
@ -124,7 +83,7 @@ if_nameindex (void)
|
||||
__set_errno (ENOSYS);
|
||||
return NULL;
|
||||
#else
|
||||
int fd = opensock ();
|
||||
int fd = __opensock ();
|
||||
struct ifconf ifc;
|
||||
unsigned int nifs, i;
|
||||
int rq_len;
|
||||
@ -235,7 +194,7 @@ if_indextoname (unsigned int ifindex, char *ifname)
|
||||
# endif
|
||||
int status;
|
||||
|
||||
fd = opensock ();
|
||||
fd = __opensock ();
|
||||
|
||||
if (fd < 0)
|
||||
return NULL;
|
||||
@ -285,7 +244,7 @@ void
|
||||
internal_function
|
||||
__protocol_available (int *have_inet, int *have_inet6)
|
||||
{
|
||||
int fd = opensock ();
|
||||
int fd = __opensock ();
|
||||
unsigned int nifs;
|
||||
int rq_len;
|
||||
struct ifconf ifc;
|
||||
|
Reference in New Issue
Block a user