summaryrefslogtreecommitdiffstats
path: root/source4/lib/replace/getifaddrs.c
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-12-16 03:22:13 +0100
committerStefan Metzmacher <metze@samba.org>2007-12-21 05:50:32 +0100
commit958864ccdf6062808433fc032577e7b175f027e0 (patch)
tree0589111df84cdb0a5c171b991902cf3d42be26d8 /source4/lib/replace/getifaddrs.c
parent41e45d690ff5074d861b486c8711bf03cffa2efc (diff)
downloadsamba-958864ccdf6062808433fc032577e7b175f027e0.tar.gz
samba-958864ccdf6062808433fc032577e7b175f027e0.tar.xz
samba-958864ccdf6062808433fc032577e7b175f027e0.zip
r26469: Fix paths, only include IPv4 addresses for now.
(This used to be commit fa9e3b6fa871b7541878f836ea54e882e614a3cf)
Diffstat (limited to 'source4/lib/replace/getifaddrs.c')
-rw-r--r--source4/lib/replace/getifaddrs.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/source4/lib/replace/getifaddrs.c b/source4/lib/replace/getifaddrs.c
index a4f16ddb76..e04c023209 100644
--- a/source4/lib/replace/getifaddrs.c
+++ b/source4/lib/replace/getifaddrs.c
@@ -360,20 +360,25 @@ int getifaddrs(struct ifaddrs **ifap)
int main()
{
- struct ifaddrs *ifs;
- int total = get_interfaces(ifaces, MAX_INTERFACES);
- int i;
-
- int ret = getifaddrs(&ifs);
+ struct ifaddrs *ifs = NULL;
+ int ret;
+
+ ret = getifaddrs(&ifs);
if (ret != 0) {
perror("getifaddrs() failed");
return 1;
}
while (ifs) {
- printf("%-10s ", ifs->ifr_name);
- printf("IP=%s ", inet_ntoa(((struct sockaddr_in *)ifs->ifr_addr)->sin_addr));
- printf("NETMASK=%s\n", inet_ntoa(((struct sockaddr_in *)ifs->ifr_netmask)->sin_addr));
+ printf("%-10s ", ifs->ifa_name);
+ if (ifs->ifa_addr != NULL &&
+ ifs->ifa_addr->sa_family == AF_INET) {
+ printf("IP=%s ", inet_ntoa(((struct sockaddr_in *)ifs->ifa_addr)->sin_addr));
+ if (ifs->ifa_netmask != NULL)
+ printf("NETMASK=%s", inet_ntoa(((struct sockaddr_in *)ifs->ifa_netmask)->sin_addr));
+ }
+ printf("\n");
+ ifs = ifs->ifa_next;
}
return 0;
}