From: David van Moolenbroek Date: Fri, 17 Jun 2016 14:11:47 +0000 (+0000) Subject: libc: switch to NetBSD getifaddrs(3) X-Git-Url: http://zhaoyanbai.com/repos//%22https:/www.google.com/jsapi/%22?a=commitdiff_plain;h=a1c660069f6222eb2c465ded9970be27fcd38ebb;p=minix.git libc: switch to NetBSD getifaddrs(3) Change-Id: I698f7cef84506ebd7beed6974a232eb75ab853c3 --- diff --git a/minix/lib/libc/net/getifaddrs.c b/minix/lib/libc/net/getifaddrs.c deleted file mode 100644 index a1ccae88a..000000000 --- a/minix/lib/libc/net/getifaddrs.c +++ /dev/null @@ -1,81 +0,0 @@ -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -#if defined(__weak_alias) -__weak_alias(getifaddrs,_getifaddrs) -__weak_alias(freeifaddrs,_freeifaddrs) -#endif - -int -getifaddrs(struct ifaddrs **ifap) -{ - static int fd = -1; - nwio_ipconf_t ipconf; - int flags; - static struct ifaddrs ifa; - static struct sockaddr_in addr, netmask; - - memset(&ifa, 0, sizeof(ifa)); - memset(&addr, 0, sizeof(addr)); - memset(&netmask, 0, sizeof(netmask)); - ifa.ifa_next = NULL; - ifa.ifa_name = __UNCONST("ip"); - addr.sin_family = netmask.sin_family = AF_INET; - ifa.ifa_addr = (struct sockaddr *) &addr; - ifa.ifa_netmask = (struct sockaddr *) &netmask; - addr.sin_addr.s_addr = 0; - netmask.sin_addr.s_addr = 0; - - *ifap = NULL; - - if(fd < 0) { - char *ipd; - - if(!(ipd = getenv("IP_DEVICE"))) - ipd = __UNCONST("/dev/ip"); - if((fd = open(ipd, O_RDWR)) < 0) - return -1; - } - - /* Code taken from commands/simple/ifconfig.c. */ - - if((flags = fcntl(fd, F_GETFL)) < 0 || - fcntl(fd, F_SETFL, flags | O_NONBLOCK) < 0 || - ioctl(fd, NWIOGIPCONF, &ipconf)) - return 0; /* Report interface as down. */ - - addr.sin_addr.s_addr = ipconf.nwic_ipaddr; - netmask.sin_addr.s_addr = ipconf.nwic_netmask; - if(addr.sin_addr.s_addr) ifa.ifa_flags = IFF_UP; - - /* Just report on this interface. */ - - *ifap = &ifa; - - return 0; -} - -void -freeifaddrs(struct ifaddrs *ifp) -{ - /* getifaddrs points to static data, so no need to free. */ - ; -} -