diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2007-12-16 02:49:52 +0100 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2008-02-19 21:56:41 +0100 |
commit | d0d4fc5f5412bcf2977afc01edee92107e995c80 (patch) | |
tree | 37f69aa5ab21e799134fe8e51e0429b595d954dc /source3/lib/replace/getifaddrs.c | |
parent | 2235ffe2f754da543b796446377b1419bf046204 (diff) | |
download | samba-d0d4fc5f5412bcf2977afc01edee92107e995c80.tar.gz samba-d0d4fc5f5412bcf2977afc01edee92107e995c80.tar.bz2 samba-d0d4fc5f5412bcf2977afc01edee92107e995c80.zip |
r26468: Match getifaddrs more closely, add trivial test.
(cherry picked from commit 92898c043b5a2649a2e423d02bcdaea78ae55737)
(This used to be commit 3f9c0c210022905c7811b2e07b3b655929daf930)
Diffstat (limited to 'source3/lib/replace/getifaddrs.c')
-rw-r--r-- | source3/lib/replace/getifaddrs.c | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/source3/lib/replace/getifaddrs.c b/source3/lib/replace/getifaddrs.c index 3969535a0b..a4f16ddb76 100644 --- a/source3/lib/replace/getifaddrs.c +++ b/source3/lib/replace/getifaddrs.c @@ -112,7 +112,6 @@ int getifaddrs(struct ifaddrs **ifap) } curif->ifa_name = strdup(ifr[i].ifr_name); - curif->ifa_flags = ifreq.ifr_flags; curif->ifa_addr = sockaddr_dup(&ifr[i].ifr_addr); curif->ifa_dstaddr = NULL; curif->ifa_data = NULL; @@ -124,10 +123,7 @@ int getifaddrs(struct ifaddrs **ifap) return -1; } - if (!(ifr[i].ifr_flags & IFF_UP)) { - freeifaddrs(curif); - continue; - } + curif->ifa_flags = ifr[i].ifr_flags; if (ioctl(fd, SIOCGIFNETMASK, &ifr[i]) != 0) { freeifaddrs(*ifap); @@ -201,6 +197,13 @@ int getifaddrs(struct ifaddrs **ifap) for (i = 0; i<n && total < max_interfaces; i++) { ifreq = ifr[i]; + curif = calloc(1, sizeof(struct ifaddrs)); + if (lastif == NULL) { + *ifap = curif; + } else { + lastif->ifa_next = (*ifap); + } + strioctl.ic_cmd = SIOCGIFFLAGS; strioctl.ic_dp = (char *)&ifreq; strioctl.ic_len = sizeof(struct ifreq); @@ -208,11 +211,9 @@ int getifaddrs(struct ifaddrs **ifap) freeifaddrs(*ifap); return -1; } - - if (!(ifreq.ifr_flags & IFF_UP)) { - continue; - } + curif->ifa_flags = ifreq.ifr_flags; + strioctl.ic_cmd = SIOCGIFADDR; strioctl.ic_dp = (char *)&ifreq; strioctl.ic_len = sizeof(struct ifreq); @@ -221,15 +222,7 @@ int getifaddrs(struct ifaddrs **ifap) return -1; } - curif = calloc(1, sizeof(struct ifaddrs)); - if (lastif == NULL) { - *ifap = curif; - } else { - lastif->ifa_next = (*ifap); - } - curif->ifa_name = strdup(ifreq.ifr_name); - curif->ifa_flags = ifreq.ifr_flags; curif->ifa_addr = sockaddr_dup(&ifreq.ifr_addr); curif->ifa_dstaddr = NULL; curif->ifa_data = NULL; @@ -310,7 +303,6 @@ int getifaddrs(struct ifaddrs **ifap) } curif->ifa_name = strdup(ifr->ifr_name); - curif->ifa_flags = ifr->ifr_flags; curif->ifa_addr = sockaddr_dup(&ifr->ifr_addr); curif->ifa_dstaddr = NULL; curif->ifa_data = NULL; @@ -322,10 +314,7 @@ int getifaddrs(struct ifaddrs **ifap) return -1; } - if (!(ifr->ifr_flags & IFF_UP)) { - freeaddrinfo(curif); - continue; - } + curif->ifa_flags = ifr->ifr_flags; if (ioctl(fd, SIOCGIFNETMASK, ifr) != 0) { freeaddrinfo(*ifap); |