Hello, i'm using getifaddrs to get the IP and HW address of an ethernet interface but it seems that the ifap->ifa_next pointer is never NULL so I end up with an infinite loop! If i uncomment the // printf's I get the HW address correctly but after that I get the IP address repeated ad eternum! Any ideas ?
()s Nuno Sucena PS: Please CC to me since i'm not subscribed in this list. i have something like: struct ifaddrs *ifap,*current; /* man getifaddrs */ struct sockaddr_dl *e_tmp; struct sockaddr_in *i_tmp; (...) error = getifaddrs (&ifap); if (error!=0) { perror("getifaddrs()"); return(EXIT_FAILURE); } current = ifap; while (current!=NULL) { if ((strcmp(current->ifa_name,device)==0)&& (((current->ifa_flags)&IFF_UP)==IFF_UP)&& (current->ifa_addr!=NULL)) { /* ethernet physical address - <net/if_dl.h> */ e_tmp = (struct sockaddr_dl*)current->ifa_addr; if (e_tmp->sdl_family==AF_LINK) { /* hope that sdl_alen < ETHER_ADDR_LEN ;) */ memcpy(*eth_address,LLADDR(e_tmp),e_tmp->sdl_alen); // printf("ethernet: %s\n",ethernet_print (*eth_address)); got_eth=1; } /* ethernet IP address - <netinet/in.h> */ i_tmp = (struct sockaddr_in*)current->ifa_addr; if (i_tmp->sin_family==AF_INET) { ip_address->s_addr = i_tmp->sin_addr.s_addr; // printf ("%s\n",inet_ntoa(*ip_address)); got_ip=1; } } current = ifap->ifa_next; } freeifaddrs(ifap); (...) -- To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-net" in the body of the message