Hi,

maybe add a hint about the needed check?

comments?
ok?

diff --git lib/libc/net/getifaddrs.3 lib/libc/net/getifaddrs.3
index 26eac493202..946c2d9a9b0 100644
--- lib/libc/net/getifaddrs.3
+++ lib/libc/net/getifaddrs.3
@@ -74,13 +74,13 @@ Contains the interface flags, as set by
 References either the address of the interface or the link level
 address of the interface, if one exists, otherwise it is
 .Dv NULL .
-(The
+After checking for NULL, the
 .Fa sa_family
 field of the
 .Fa ifa_addr
-field should be consulted to determine the format of the
+struct should be consulted to determine the format of the
 .Fa ifa_addr
-address.)
+address.
 .It Fa ifa_netmask
 References the netmask associated with
 .Fa ifa_addr ,
@@ -119,6 +119,23 @@ is dynamically allocated and should be freed using
 when no longer needed.
 .Sh RETURN VALUES
 .Rv -std
+.Sh EXAMPLES
+The interface addresses can be accessed through
+*ifa_addr
+like this:
+.Bd -literal -offset indent
+        struct ifaddrs          *ifap, *ifa;
+        struct sockaddr_in6     *sin6;
+
+        if (getifaddrs(&ifap) == -1)
+                fatal("getifaddrs");
+
+        for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
+                if (ifa->ifa_addr == NULL ||
+                   ifa->ifa_addr->sa_family != AF_INET6)
+                        continue;
+        sin6 = (struct sockaddr_in6 *)ifa->ifa_addr;
+.Ed
 .Sh ERRORS
 The
 .Fn getifaddrs

Reply via email to