Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/net add and document AF_LOCAL (and the rest that we...
details: https://anonhg.NetBSD.org/src/rev/f3e91ff20143
branches: trunk
changeset: 781731:f3e91ff20143
user: christos <christos%NetBSD.org@localhost>
date: Wed Sep 26 23:13:00 2012 +0000
description:
add and document AF_LOCAL (and the rest that were not)
diffstat:
lib/libc/net/getnameinfo.3 | 18 +++++++++++++-----
lib/libc/net/getnameinfo.c | 33 +++++++++++++++++++++++++++++++--
2 files changed, 44 insertions(+), 7 deletions(-)
diffs (114 lines):
diff -r e94f2677f899 -r f3e91ff20143 lib/libc/net/getnameinfo.3
--- a/lib/libc/net/getnameinfo.3 Wed Sep 26 23:01:04 2012 +0000
+++ b/lib/libc/net/getnameinfo.3 Wed Sep 26 23:13:00 2012 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: getnameinfo.3,v 1.38 2012/03/04 03:23:35 christos Exp $
+.\" $NetBSD: getnameinfo.3,v 1.39 2012/09/26 23:13:00 christos Exp $
.\" $KAME: getnameinfo.3,v 1.37 2005/01/05 03:23:05 itojun Exp $
.\" $OpenBSD: getnameinfo.3,v 1.36 2004/12/21 09:48:20 jmc Exp $
.\"
@@ -17,7 +17,7 @@
.\" OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
.\" PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd March 3, 2012
+.Dd September 26, 2012
.Dt GETNAMEINFO 3
.Os
.Sh NAME
@@ -47,11 +47,19 @@
.Li sockaddr
structure
.Fa sa
-should point to either a
+should point to a
.Li sockaddr_in
+(for IPv4),
+.Li sockaddr_in6
+(for IPv6),
+.Li sockaddr_atalk
+(for AppleTalk),
+.Li sockaddr_link
+(for link layer),
or
-.Li sockaddr_in6
-structure (for IPv4 or IPv6 respectively) that is
+.Li sockaddr_local
+(for local/unix)
+structures that are
.Fa salen
bytes long.
.Pp
diff -r e94f2677f899 -r f3e91ff20143 lib/libc/net/getnameinfo.c
--- a/lib/libc/net/getnameinfo.c Wed Sep 26 23:01:04 2012 +0000
+++ b/lib/libc/net/getnameinfo.c Wed Sep 26 23:13:00 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: getnameinfo.c,v 1.52 2012/03/20 17:44:18 matt Exp $ */
+/* $NetBSD: getnameinfo.c,v 1.53 2012/09/26 23:13:00 christos Exp $ */
/* $KAME: getnameinfo.c,v 1.45 2000/09/25 22:43:56 itojun Exp $ */
/*
@@ -47,12 +47,13 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: getnameinfo.c,v 1.52 2012/03/20 17:44:18 matt Exp $");
+__RCSID("$NetBSD: getnameinfo.c,v 1.53 2012/09/26 23:13:00 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#include <sys/types.h>
#include <sys/socket.h>
+#include <sys/un.h>
#include <net/if.h>
#include <net/if_dl.h>
#include <net/if_ieee1394.h>
@@ -104,6 +105,8 @@
#endif
static int getnameinfo_atalk(const struct sockaddr *, socklen_t, char *,
socklen_t, char *, socklen_t, int);
+static int getnameinfo_local(const struct sockaddr *, socklen_t, char *,
+ socklen_t, char *, socklen_t, int);
static int getnameinfo_link(const struct sockaddr *, socklen_t, char *,
socklen_t, char *, socklen_t, int);
@@ -131,6 +134,9 @@
case AF_LINK:
return getnameinfo_link(sa, salen, host, hostlen,
serv, servlen, flags);
+ case AF_LOCAL:
+ return getnameinfo_local(sa, salen, host, hostlen,
+ serv, servlen, flags);
default:
return EAI_FAMILY;
}
@@ -197,6 +203,29 @@
}
/*
+ * getnameinfo_local():
+ * Format an local address into a printable format.
+ */
+/* ARGSUSED */
+static int
+getnameinfo_local(const struct sockaddr *sa, socklen_t salen,
+ char *host, socklen_t hostlen, char *serv, socklen_t servlen,
+ int flags)
+{
+ const struct sockaddr_un *sun =
+ (const struct sockaddr_un *)(const void *)sa;
+
+ if (serv != NULL && servlen > 0)
+ serv[0] = '\0';
+
+ if (host && hostlen > 0)
+ strlcpy(host, sun->sun_path,
+ MIN(sizeof(sun->sun_path) + 1, hostlen));
+
+ return 0;
+}
+
+/*
* getnameinfo_inet():
* Format an IPv4 or IPv6 sockaddr into a printable string.
*/
Home |
Main Index |
Thread Index |
Old Index