Creating an IPv6 socket if AF_INET6 is defined on the system. If IPv6

2003-06-10  Shailesh Mittal  <shailesh.mittal@wipro.com>

	* libuuid/gen_uuid.c (get_node_id): Creating an IPv6 socket if AF_INET6
	is defined on the system. If IPv6 socket cannot be created, then we are
	falling back to IPv4 socket creation, as was done previously.
This commit is contained in:
Shailesh Mittal 2004-04-21 18:18:58 +00:00 committed by Jody Goldberg
parent aee28fa902
commit dbb7a4c042
3 changed files with 24 additions and 3 deletions

View file

@ -104,11 +104,19 @@ static int get_node_id(unsigned char *node_id)
#else
#define ifreq_size(i) sizeof(struct ifreq)
#endif /* HAVE_SA_LEN*/
#ifdef AF_INET6
sd = socket(AF_INET6, SOCK_DGRAM, IPPROTO_IP);
sd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
if (sd < 0) {
return -1;
/* If IPv6 fails then try with IPv4 socket. */
if (sd < 0)
#endif
{
sd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
if (sd < 0) {
return -1;
}
}
memset(buf, 0, sizeof(buf));
ifc.ifc_len = sizeof(buf);
ifc.ifc_buf = buf;