--- dhcp-0.10/client6_addr.c.165882 2005-08-15 20:03:07.000000000 -0400 +++ dhcp-0.10/client6_addr.c 2005-08-15 20:53:09.000000000 -0400 @@ -47,6 +47,7 @@ #include <stdlib.h> #include <unistd.h> #include <net/if_arp.h> +#include <ifaddrs.h> #include "queue.h" #include "dhcp6.h" @@ -695,39 +696,38 @@ create_iaid(struct iaid_table *iaidtab, int num_device) { struct iaid_table *temp = iaidtab; - char buff[1024]; - struct ifconf ifc; - struct ifreq *ifr;//, if_hwaddr; + struct ifaddrs *ifa=0L; int i; - ifc.ifc_len = sizeof(buff); - ifc.ifc_buf = buff; - if (ioctl(nlsock, SIOCGIFCONF, &ifc) < 0) { - dprintf(LOG_ERR, "%s" "ioctl SIOCGIFCONF", FNAME); + if ( getifaddrs( &ifa ) != 0 ) + { + dprintf(LOG_ERR, "%s" "getifaddrs", FNAME); return -1; } - ifr = ifc.ifc_req; - for (i = ifc.ifc_len / sizeof(struct ifreq); --i >= 0 && num_device < MAX_DEVICE; - ifr++) { - if (!strcmp(ifr->ifr_name, "lo")) continue; - temp->hwaddr.len = gethwid(temp->hwaddr.data, sizeof(temp->hwaddr.data), ifr->ifr_name, &temp->hwaddr.type); + for (i=0; + (ifa != 0L) && ( i < MAX_DEVICE ); + i++, ifa = ifa->ifa_next + ) + { + if (!strcmp(ifa->ifa_name, "lo")) continue; + temp->hwaddr.len = gethwid(temp->hwaddr.data, sizeof(temp->hwaddr.data), ifa->ifa_name, &temp->hwaddr.type); switch (temp->hwaddr.type) { case ARPHRD_ETHER: case ARPHRD_IEEE802: memcpy(&temp->iaid, temp->hwaddr.data, sizeof(temp->iaid)); break; case ARPHRD_PPP: - temp->iaid = do_hash(ifr->ifr_name,sizeof(ifr->ifr_name)) - + if_nametoindex(ifr->ifr_name); + temp->iaid = do_hash(ifa->ifa_name,sizeof(ifa->ifa_name)) + + if_nametoindex(ifa->ifa_name); break; default: dprintf(LOG_INFO, "doesn't support %s address family %d", - ifr->ifr_name, temp->hwaddr.type); + ifa->ifa_name, temp->hwaddr.type); continue; } dprintf(LOG_DEBUG, "%s"" create iaid %u for interface %s", - FNAME, temp->iaid, ifr->ifr_name); + FNAME, temp->iaid, ifa->ifa_name); num_device++; temp++; }