changeset 4291:2650d270ece9

6558517 need DTrace versions of IP address to string functions, like inet_ntop()
author brendan
date Tue, 22 May 2007 10:56:13 -0700
parents b563fe340d47
children d7beef35913b
files usr/src/cmd/dtrace/test/tst/common/aggs/tst.subr.d usr/src/cmd/dtrace/test/tst/common/funcs/err.inet_ntoa6badaddr.d usr/src/cmd/dtrace/test/tst/common/funcs/err.inet_ntoabadaddr.d usr/src/cmd/dtrace/test/tst/common/funcs/err.inet_ntopbadaddr.d usr/src/cmd/dtrace/test/tst/common/funcs/err.inet_ntopbadarg.d usr/src/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa.d usr/src/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa.d.out usr/src/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa6.d usr/src/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa6.d.out usr/src/cmd/dtrace/test/tst/common/funcs/tst.inet_ntop.d usr/src/cmd/dtrace/test/tst/common/funcs/tst.inet_ntop.d.out usr/src/lib/libdtrace/Makefile.com usr/src/lib/libdtrace/common/dt_open.c usr/src/lib/libdtrace/common/ip.d.in usr/src/lib/libdtrace/common/ip.sed.in usr/src/pkgdefs/SUNWdtrc/prototype_com usr/src/pkgdefs/SUNWdtrt/prototype_com usr/src/uts/common/dtrace/dtrace.c usr/src/uts/common/sys/dtrace.h
diffstat 19 files changed, 810 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/dtrace/test/tst/common/aggs/tst.subr.d	Tue May 22 10:21:44 2007 -0700
+++ b/usr/src/cmd/dtrace/test/tst/common/aggs/tst.subr.d	Tue May 22 10:56:13 2007 -0700
@@ -20,7 +20,7 @@
  */
 
 /*
- * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -95,6 +95,9 @@
 INTFUNC(ntohs(0x1234))
 INTFUNC(ntohl(0x12345678))
 INTFUNC(ntohll(0x1234567890abcdefL))
+STRFUNC(inet_ntoa((ipaddr_t *)alloca(sizeof (ipaddr_t))))
+STRFUNC(inet_ntoa6((in6_addr_t *)alloca(sizeof (in6_addr_t))))
+STRFUNC(inet_ntop(AF_INET, (void *)alloca(sizeof (ipaddr_t))))
 
 BEGIN
 /subr == DIF_SUBR_MAX + 1/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/dtrace/test/tst/common/funcs/err.inet_ntoa6badaddr.d	Tue May 22 10:56:13 2007 -0700
@@ -0,0 +1,45 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+
+#pragma D option quiet
+
+struct in6_addr *ip6a;
+
+BEGIN
+{
+	ip6a = 0;
+
+	printf("%s\n", inet_ntop(AF_INET6, ip6a));
+
+	exit(0);
+}
+
+ERROR
+{
+	exit(1);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/dtrace/test/tst/common/funcs/err.inet_ntoabadaddr.d	Tue May 22 10:56:13 2007 -0700
@@ -0,0 +1,45 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+
+#pragma D option quiet
+
+ipaddr_t *ip4a;
+
+BEGIN
+{
+	ip4a = 0;
+
+	printf("%s\n", inet_ntoa(ip4a));
+
+	exit(0);
+}
+
+ERROR
+{
+	exit(1);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/dtrace/test/tst/common/funcs/err.inet_ntopbadaddr.d	Tue May 22 10:56:13 2007 -0700
@@ -0,0 +1,45 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+
+#pragma D option quiet
+
+ipaddr_t *ip4a;
+
+BEGIN
+{
+	ip4a = 0;
+
+	printf("%s\n", inet_ntop(AF_INET, ip4a));
+
+	exit(0);
+}
+
+ERROR
+{
+	exit(1);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/dtrace/test/tst/common/funcs/err.inet_ntopbadarg.d	Tue May 22 10:56:13 2007 -0700
@@ -0,0 +1,47 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+
+#pragma D option quiet
+
+ipaddr_t *ip4a;
+
+BEGIN
+{
+	this->buf4a = alloca(sizeof (ipaddr_t));
+	ip4a = this->buf4a;
+	*ip4a = htonl(0xc0a80117);
+
+	printf("%s\n", inet_ntop(-1, ip4a));
+
+	exit(0);
+}
+
+ERROR
+{
+	exit(1);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa.d	Tue May 22 10:56:13 2007 -0700
@@ -0,0 +1,58 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+
+#pragma D option quiet
+
+ipaddr_t *ip4a;
+ipaddr_t *ip4b;
+ipaddr_t *ip4c;
+ipaddr_t *ip4d;
+
+BEGIN
+{
+	this->buf4a = alloca(sizeof (ipaddr_t));
+	this->buf4b = alloca(sizeof (ipaddr_t));
+	this->buf4c = alloca(sizeof (ipaddr_t));
+	this->buf4d = alloca(sizeof (ipaddr_t));
+	ip4a = this->buf4a;
+	ip4b = this->buf4b;
+	ip4c = this->buf4c;
+	ip4d = this->buf4d;
+
+	*ip4a = htonl(0xc0a80117);
+	*ip4b = htonl(0x7f000001);
+	*ip4c = htonl(0xffffffff);
+	*ip4d = htonl(0x00000000);
+
+	printf("%s\n", inet_ntoa(ip4a));
+	printf("%s\n", inet_ntoa(ip4b));
+	printf("%s\n", inet_ntoa(ip4c));
+	printf("%s\n", inet_ntoa(ip4d));
+
+	exit(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa.d.out	Tue May 22 10:56:13 2007 -0700
@@ -0,0 +1,5 @@
+192.168.1.23
+127.0.0.1
+255.255.255.255
+0.0.0.0
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa6.d	Tue May 22 10:56:13 2007 -0700
@@ -0,0 +1,95 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+
+#pragma D option quiet
+
+struct in6_addr *ip6a;
+struct in6_addr *ip6b;
+struct in6_addr *ip6c;
+struct in6_addr *ip6d;
+struct in6_addr *ip6e;
+struct in6_addr *ip6f;
+struct in6_addr *ip6g;
+
+BEGIN
+{
+	this->buf6a = alloca(sizeof (struct in6_addr));
+	this->buf6b = alloca(sizeof (struct in6_addr));
+	this->buf6c = alloca(sizeof (struct in6_addr));
+	this->buf6d = alloca(sizeof (struct in6_addr));
+	this->buf6e = alloca(sizeof (struct in6_addr));
+	this->buf6f = alloca(sizeof (struct in6_addr));
+	this->buf6g = alloca(sizeof (struct in6_addr));
+	ip6a = this->buf6a;
+	ip6b = this->buf6b;
+	ip6c = this->buf6c;
+	ip6d = this->buf6d;
+	ip6e = this->buf6e;
+	ip6f = this->buf6f;
+	ip6g = this->buf6g;
+
+	ip6a->_S6_un._S6_u8[0] = 0xfe;
+	ip6a->_S6_un._S6_u8[1] = 0x80;
+	ip6a->_S6_un._S6_u8[8] = 0x02;
+	ip6a->_S6_un._S6_u8[9] = 0x14;
+	ip6a->_S6_un._S6_u8[10] = 0x4f;
+	ip6a->_S6_un._S6_u8[11] = 0xff;
+	ip6a->_S6_un._S6_u8[12] = 0xfe;
+	ip6a->_S6_un._S6_u8[13] = 0x0b;
+	ip6a->_S6_un._S6_u8[14] = 0x76;
+	ip6a->_S6_un._S6_u8[15] = 0xc8;
+	ip6b->_S6_un._S6_u8[0] = 0x10;
+	ip6b->_S6_un._S6_u8[1] = 0x80;
+	ip6b->_S6_un._S6_u8[10] = 0x08;
+	ip6b->_S6_un._S6_u8[11] = 0x08;
+	ip6b->_S6_un._S6_u8[13] = 0x20;
+	ip6b->_S6_un._S6_u8[13] = 0x0c;
+	ip6b->_S6_un._S6_u8[14] = 0x41;
+	ip6b->_S6_un._S6_u8[15] = 0x7a;
+	ip6c->_S6_un._S6_u8[15] = 0x01;
+	ip6e->_S6_un._S6_u8[12] = 0x7f;
+	ip6e->_S6_un._S6_u8[15] = 0x01;
+	ip6f->_S6_un._S6_u8[10] = 0xff;
+	ip6f->_S6_un._S6_u8[11] = 0xff;
+	ip6f->_S6_un._S6_u8[12] = 0x7f;
+	ip6f->_S6_un._S6_u8[15] = 0x01;
+	ip6g->_S6_un._S6_u8[10] = 0xff;
+	ip6g->_S6_un._S6_u8[11] = 0xfe;
+	ip6g->_S6_un._S6_u8[12] = 0x7f;
+	ip6g->_S6_un._S6_u8[15] = 0x01;
+
+	printf("%s\n", inet_ntoa6(ip6a));
+	printf("%s\n", inet_ntoa6(ip6b));
+	printf("%s\n", inet_ntoa6(ip6c));
+	printf("%s\n", inet_ntoa6(ip6d));
+	printf("%s\n", inet_ntoa6(ip6e));
+	printf("%s\n", inet_ntoa6(ip6f));
+	printf("%s\n", inet_ntoa6(ip6g));
+
+	exit(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa6.d.out	Tue May 22 10:56:13 2007 -0700
@@ -0,0 +1,8 @@
+fe80::214:4fff:fe0b:76c8
+1080::808:c:417a
+::1
+::
+127.0.0.1
+127.0.0.1
+::fffe:7f00:1
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/dtrace/test/tst/common/funcs/tst.inet_ntop.d	Tue May 22 10:56:13 2007 -0700
@@ -0,0 +1,135 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+
+#pragma D option quiet
+
+ipaddr_t *ip4a;
+ipaddr_t *ip4b;
+ipaddr_t *ip4c;
+ipaddr_t *ip4d;
+struct in6_addr *ip6a;
+struct in6_addr *ip6b;
+struct in6_addr *ip6c;
+struct in6_addr *ip6d;
+struct in6_addr *ip6e;
+struct in6_addr *ip6f;
+struct in6_addr *ip6g;
+struct in6_addr *ip6h;
+
+BEGIN
+{
+	this->buf4a = alloca(sizeof (ipaddr_t));
+	this->buf4b = alloca(sizeof (ipaddr_t));
+	this->buf4c = alloca(sizeof (ipaddr_t));
+	this->buf4d = alloca(sizeof (ipaddr_t));
+	this->buf6a = alloca(sizeof (struct in6_addr));
+	this->buf6b = alloca(sizeof (struct in6_addr));
+	this->buf6c = alloca(sizeof (struct in6_addr));
+	this->buf6d = alloca(sizeof (struct in6_addr));
+	this->buf6e = alloca(sizeof (struct in6_addr));
+	this->buf6f = alloca(sizeof (struct in6_addr));
+	this->buf6g = alloca(sizeof (struct in6_addr));
+	this->buf6h = alloca(sizeof (struct in6_addr));
+	ip4a = this->buf4a;
+	ip4b = this->buf4b;
+	ip4c = this->buf4c;
+	ip4d = this->buf4d;
+	ip6a = this->buf6a;
+	ip6b = this->buf6b;
+	ip6c = this->buf6c;
+	ip6d = this->buf6d;
+	ip6e = this->buf6e;
+	ip6f = this->buf6f;
+	ip6g = this->buf6g;
+	ip6h = this->buf6h;
+
+	*ip4a = htonl(0xc0a80117);
+	*ip4b = htonl(0x7f000001);
+	*ip4c = htonl(0xffffffff);
+	*ip4d = htonl(0x00000000);
+	ip6a->_S6_un._S6_u8[0] = 0xfe;
+	ip6a->_S6_un._S6_u8[1] = 0x80;
+	ip6a->_S6_un._S6_u8[8] = 0x02;
+	ip6a->_S6_un._S6_u8[9] = 0x14;
+	ip6a->_S6_un._S6_u8[10] = 0x4f;
+	ip6a->_S6_un._S6_u8[11] = 0xff;
+	ip6a->_S6_un._S6_u8[12] = 0xfe;
+	ip6a->_S6_un._S6_u8[13] = 0x0b;
+	ip6a->_S6_un._S6_u8[14] = 0x76;
+	ip6a->_S6_un._S6_u8[15] = 0xc8;
+	ip6b->_S6_un._S6_u8[0] = 0x10;
+	ip6b->_S6_un._S6_u8[1] = 0x80;
+	ip6b->_S6_un._S6_u8[10] = 0x08;
+	ip6b->_S6_un._S6_u8[11] = 0x08;
+	ip6b->_S6_un._S6_u8[13] = 0x20;
+	ip6b->_S6_un._S6_u8[13] = 0x0c;
+	ip6b->_S6_un._S6_u8[14] = 0x41;
+	ip6b->_S6_un._S6_u8[15] = 0x7a;
+	ip6c->_S6_un._S6_u8[15] = 0x01;
+	ip6e->_S6_un._S6_u8[12] = 0x7f;
+	ip6e->_S6_un._S6_u8[15] = 0x01;
+	ip6f->_S6_un._S6_u8[10] = 0xff;
+	ip6f->_S6_un._S6_u8[11] = 0xff;
+	ip6f->_S6_un._S6_u8[12] = 0x7f;
+	ip6f->_S6_un._S6_u8[15] = 0x01;
+	ip6g->_S6_un._S6_u8[10] = 0xff;
+	ip6g->_S6_un._S6_u8[11] = 0xfe;
+	ip6g->_S6_un._S6_u8[12] = 0x7f;
+	ip6g->_S6_un._S6_u8[15] = 0x01;
+	ip6h->_S6_un._S6_u8[0] = 0xff;
+	ip6h->_S6_un._S6_u8[1] = 0xff;
+	ip6h->_S6_un._S6_u8[2] = 0xff;
+	ip6h->_S6_un._S6_u8[3] = 0xff;
+	ip6h->_S6_un._S6_u8[4] = 0xff;
+	ip6h->_S6_un._S6_u8[5] = 0xff;
+	ip6h->_S6_un._S6_u8[6] = 0xff;
+	ip6h->_S6_un._S6_u8[7] = 0xff;
+	ip6h->_S6_un._S6_u8[8] = 0xff;
+	ip6h->_S6_un._S6_u8[9] = 0xff;
+	ip6h->_S6_un._S6_u8[10] = 0xff;
+	ip6h->_S6_un._S6_u8[11] = 0xff;
+	ip6h->_S6_un._S6_u8[12] = 0xff;
+	ip6h->_S6_un._S6_u8[13] = 0xff;
+	ip6h->_S6_un._S6_u8[14] = 0xff;
+	ip6h->_S6_un._S6_u8[15] = 0xff;
+
+	printf("%s\n", inet_ntop(AF_INET, ip4a));
+	printf("%s\n", inet_ntop(AF_INET, ip4b));
+	printf("%s\n", inet_ntop(AF_INET, ip4c));
+	printf("%s\n", inet_ntop(AF_INET, ip4d));
+	printf("%s\n", inet_ntop(AF_INET6, ip6a));
+	printf("%s\n", inet_ntop(AF_INET6, ip6b));
+	printf("%s\n", inet_ntop(AF_INET6, ip6c));
+	printf("%s\n", inet_ntop(AF_INET6, ip6d));
+	printf("%s\n", inet_ntop(AF_INET6, ip6e));
+	printf("%s\n", inet_ntop(AF_INET6, ip6f));
+	printf("%s\n", inet_ntop(AF_INET6, ip6g));
+	printf("%s\n", inet_ntop(AF_INET6, ip6h));
+
+	exit(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/dtrace/test/tst/common/funcs/tst.inet_ntop.d.out	Tue May 22 10:56:13 2007 -0700
@@ -0,0 +1,13 @@
+192.168.1.23
+127.0.0.1
+255.255.255.255
+0.0.0.0
+fe80::214:4fff:fe0b:76c8
+1080::808:c:417a
+::1
+::
+::127.0.0.1
+::ffff:127.0.0.1
+::fffe:7f00:1
+ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
+
--- a/usr/src/lib/libdtrace/Makefile.com	Tue May 22 10:21:44 2007 -0700
+++ b/usr/src/lib/libdtrace/Makefile.com	Tue May 22 10:56:13 2007 -0700
@@ -76,6 +76,7 @@
 DLIBSRCS += \
 	errno.d \
 	io.d \
+	ip.d \
 	procfs.d \
 	regs.d \
 	sched.d \
@@ -93,6 +94,7 @@
 CLEANFILES += dt_lex.c dt_grammar.c dt_grammar.h y.output
 CLEANFILES += ../common/procfs.sed ../common/procfs.d
 CLEANFILES += ../common/io.sed ../common/io.d
+CLEANFILES += ../common/ip.sed ../common/ip.d
 CLEANFILES += ../common/errno.d ../common/signal.d
 CLEANFILES += ../common/dt_errtags.c ../common/dt_names.c
 CLEANFILES += ../common/sysevent.sed ../common/sysevent.d
@@ -165,6 +167,9 @@
 ../common/io.d: ../common/io.sed ../common/io.d.in
 	sed -f ../common/io.sed < ../common/io.d.in > $@
 
+../common/ip.d: ../common/ip.sed ../common/ip.d.in
+	sed -f ../common/ip.sed < ../common/ip.d.in > $@
+
 ../common/sysevent.d: ../common/sysevent.sed ../common/sysevent.d.in
 	sed -f ../common/sysevent.sed < ../common/sysevent.d.in > $@
 
--- a/usr/src/lib/libdtrace/common/dt_open.c	Tue May 22 10:21:44 2007 -0700
+++ b/usr/src/lib/libdtrace/common/dt_open.c	Tue May 22 10:56:13 2007 -0700
@@ -232,6 +232,12 @@
 	&dt_idops_type, "uint_t" },
 { "index", DT_IDENT_FUNC, 0, DIF_SUBR_INDEX, DT_ATTR_STABCMN, DT_VERS_1_1,
 	&dt_idops_func, "int(const char *, const char *, [int])" },
+{ "inet_ntoa", DT_IDENT_FUNC, 0, DIF_SUBR_INET_NTOA, DT_ATTR_STABCMN,
+	DT_VERS_1_0, &dt_idops_func, "string(ipaddr_t *)" },
+{ "inet_ntoa6", DT_IDENT_FUNC, 0, DIF_SUBR_INET_NTOA6, DT_ATTR_STABCMN,
+	DT_VERS_1_0, &dt_idops_func, "string(in6_addr_t *)" },
+{ "inet_ntop", DT_IDENT_FUNC, 0, DIF_SUBR_INET_NTOP, DT_ATTR_STABCMN,
+	DT_VERS_1_0, &dt_idops_func, "string(int, void *)" },
 { "ipl", DT_IDENT_SCALAR, 0, DIF_VAR_IPL, DT_ATTR_STABCMN, DT_VERS_1_0,
 	&dt_idops_type, "uint_t" },
 { "jstack", DT_IDENT_ACTFUNC, 0, DT_ACT_JSTACK, DT_ATTR_STABCMN, DT_VERS_1_0,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libdtrace/common/ip.d.in	Tue May 22 10:56:13 2007 -0700
@@ -0,0 +1,31 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+
+inline int AF_INET = @AF_INET@;
+#pragma D binding "1.0" AF_INET
+inline int AF_INET6 = @AF_INET6@;
+#pragma D binding "1.0" AF_INET6
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/libdtrace/common/ip.sed.in	Tue May 22 10:56:13 2007 -0700
@@ -0,0 +1,41 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident	"%Z%%M%	%I%	%E% SMI"
+
+/*
+ * This file is a sed script which is first preprocessed by cpp or cc -E to
+ * define a set of sed directives which replace #define tokens with their
+ * values.  After preprocessing, the sed script is run over ip.d.in to
+ * replace the #define tokens listed below to create the finished ip.d.
+ * Refer to the rules in libdtrace/Makefile.com for more information.
+ */
+
+#include <sys/socket.h>
+
+#define	SED_REPLACE(x)	s/#x/x/g
+
+SED_REPLACE(AF_INET)
+SED_REPLACE(AF_INET6)
--- a/usr/src/pkgdefs/SUNWdtrc/prototype_com	Tue May 22 10:21:44 2007 -0700
+++ b/usr/src/pkgdefs/SUNWdtrc/prototype_com	Tue May 22 10:56:13 2007 -0700
@@ -49,6 +49,7 @@
 f none usr/lib/dtrace/drti.o 644 root bin
 f none usr/lib/dtrace/errno.d 644 root bin
 f none usr/lib/dtrace/io.d 644 root bin
+f none usr/lib/dtrace/ip.d 644 root bin
 f none usr/lib/dtrace/procfs.d 644 root bin
 f none usr/lib/dtrace/regs.d 644 root bin
 f none usr/lib/dtrace/sched.d 644 root bin
--- a/usr/src/pkgdefs/SUNWdtrt/prototype_com	Tue May 22 10:21:44 2007 -0700
+++ b/usr/src/pkgdefs/SUNWdtrt/prototype_com	Tue May 22 10:56:13 2007 -0700
@@ -505,6 +505,10 @@
 f none SUNWdtrt/tst/common/funcs/err.copyout.d 0444 root bin
 f none SUNWdtrt/tst/common/funcs/err.copyoutbadaddr.ksh 0444 root bin
 f none SUNWdtrt/tst/common/funcs/err.copyoutstrbadaddr.ksh 0444 root bin
+f none SUNWdtrt/tst/common/funcs/err.inet_ntopbadarg.d 0444 root bin
+f none SUNWdtrt/tst/common/funcs/err.inet_ntopbadaddr.d 0444 root bin
+f none SUNWdtrt/tst/common/funcs/err.inet_ntoabadaddr.d 0444 root bin
+f none SUNWdtrt/tst/common/funcs/err.inet_ntoa6badaddr.d 0444 root bin
 f none SUNWdtrt/tst/common/funcs/tst.badfreopen.ksh 0444 root bin
 f none SUNWdtrt/tst/common/funcs/tst.basename.d 0444 root bin
 f none SUNWdtrt/tst/common/funcs/tst.basename.d.out 0444 root bin
@@ -522,6 +526,12 @@
 f none SUNWdtrt/tst/common/funcs/tst.hton.d 0444 root bin
 f none SUNWdtrt/tst/common/funcs/tst.index.d 0444 root bin
 f none SUNWdtrt/tst/common/funcs/tst.index.d.out 0444 root bin
+f none SUNWdtrt/tst/common/funcs/tst.inet_ntoa.d 0444 root bin
+f none SUNWdtrt/tst/common/funcs/tst.inet_ntoa.d.out 0444 root bin
+f none SUNWdtrt/tst/common/funcs/tst.inet_ntoa6.d 0444 root bin
+f none SUNWdtrt/tst/common/funcs/tst.inet_ntoa6.d.out 0444 root bin
+f none SUNWdtrt/tst/common/funcs/tst.inet_ntop.d 0444 root bin
+f none SUNWdtrt/tst/common/funcs/tst.inet_ntop.d.out 0444 root bin
 f none SUNWdtrt/tst/common/funcs/tst.lltostr.d 0444 root bin
 f none SUNWdtrt/tst/common/funcs/tst.lltostr.d.out 0444 root bin
 f none SUNWdtrt/tst/common/funcs/tst.mutex_owned.d 0444 root bin
--- a/usr/src/uts/common/dtrace/dtrace.c	Tue May 22 10:21:44 2007 -0700
+++ b/usr/src/uts/common/dtrace/dtrace.c	Tue May 22 10:56:13 2007 -0700
@@ -91,6 +91,8 @@
 #include <sys/mkdev.h>
 #include <sys/kdi.h>
 #include <sys/zone.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
 
 /*
  * DTrace Tunable Variables
@@ -308,6 +310,8 @@
 
 #define	DTRACE_AGGHASHSIZE_SLEW		17
 
+#define	DTRACE_V4MAPPED_OFFSET		(sizeof (uint32_t) * 3)
+
 /*
  * The key for a thread-local variable consists of the lower 61 bits of the
  * t_did, plus the 3 bits of the highest active interrupt above LOCK_LEVEL.
@@ -4044,6 +4048,211 @@
 		mstate->dtms_scratch_ptr += size;
 		break;
 	}
+
+	case DIF_SUBR_INET_NTOA:
+	case DIF_SUBR_INET_NTOA6:
+	case DIF_SUBR_INET_NTOP: {
+		size_t size;
+		int af, argi, i;
+		char *base, *end;
+
+		if (subr == DIF_SUBR_INET_NTOP) {
+			af = (int)tupregs[0].dttk_value;
+			argi = 1;
+		} else {
+			af = subr == DIF_SUBR_INET_NTOA ? AF_INET: AF_INET6;
+			argi = 0;
+		}
+
+		if (af == AF_INET) {
+			ipaddr_t ip4;
+			uint8_t *ptr8, val;
+
+			/*
+			 * Safely load the IPv4 address.
+			 */
+			ip4 = dtrace_load32(tupregs[argi].dttk_value);
+
+			/*
+			 * Check an IPv4 string will fit in scratch.
+			 */
+			size = INET_ADDRSTRLEN;
+			if (!DTRACE_INSCRATCH(mstate, size)) {
+				DTRACE_CPUFLAG_SET(CPU_DTRACE_NOSCRATCH);
+				regs[rd] = NULL;
+				break;
+			}
+			base = (char *)mstate->dtms_scratch_ptr;
+			end = (char *)mstate->dtms_scratch_ptr + size - 1;
+
+			/*
+			 * Stringify as a dotted decimal quad.
+			 */
+			*end-- = '\0';
+			ptr8 = (uint8_t *)&ip4;
+			for (i = 3; i >= 0; i--) {
+				val = ptr8[i];
+
+				if (val == 0) {
+					*end-- = '0';
+				} else {
+					for (; val; val /= 10) {
+						*end-- = '0' + (val % 10);
+					}
+				}
+
+				if (i > 0)
+					*end-- = '.';
+			}
+			ASSERT(end + 1 >= base);
+
+		} else if (af == AF_INET6) {
+			struct in6_addr ip6;
+			int firstzero, tryzero, numzero, v6end;
+			uint16_t val;
+			const char digits[] = "0123456789abcdef";
+
+			/*
+			 * Stringify using RFC 1884 convention 2 - 16 bit
+			 * hexadecimal values with a zero-run compression.
+			 * Lower case hexadecimal digits are used.
+			 * 	eg, fe80::214:4fff:fe0b:76c8.
+			 * The IPv4 embedded form is returned for inet_ntop,
+			 * just the IPv4 string is returned for inet_ntoa6.
+			 */
+
+			/*
+			 * Safely load the IPv6 address.
+			 */
+			dtrace_bcopy(
+			    (void *)(uintptr_t)tupregs[argi].dttk_value,
+			    (void *)(uintptr_t)&ip6, sizeof (struct in6_addr));
+
+			/*
+			 * Check an IPv6 string will fit in scratch.
+			 */
+			size = INET6_ADDRSTRLEN;
+			if (!DTRACE_INSCRATCH(mstate, size)) {
+				DTRACE_CPUFLAG_SET(CPU_DTRACE_NOSCRATCH);
+				regs[rd] = NULL;
+				break;
+			}
+			base = (char *)mstate->dtms_scratch_ptr;
+			end = (char *)mstate->dtms_scratch_ptr + size - 1;
+			*end-- = '\0';
+
+			/*
+			 * Find the longest run of 16 bit zero values
+			 * for the single allowed zero compression - "::".
+			 */
+			firstzero = -1;
+			tryzero = -1;
+			numzero = 1;
+			for (i = 0; i < sizeof (struct in6_addr); i++) {
+				if (ip6._S6_un._S6_u8[i] == 0 &&
+				    tryzero == -1 && i % 2 == 0) {
+					tryzero = i;
+					continue;
+				}
+
+				if (tryzero != -1 &&
+				    (ip6._S6_un._S6_u8[i] != 0 ||
+				    i == sizeof (struct in6_addr) - 1)) {
+
+					if (i - tryzero <= numzero) {
+						tryzero = -1;
+						continue;
+					}
+
+					firstzero = tryzero;
+					numzero = i - i % 2 - tryzero;
+					tryzero = -1;
+
+					if (ip6._S6_un._S6_u8[i] == 0 &&
+					    i == sizeof (struct in6_addr) - 1)
+						numzero += 2;
+				}
+			}
+			ASSERT(firstzero + numzero <= sizeof (struct in6_addr));
+
+			/*
+			 * Check for an IPv4 embedded address.
+			 */
+			v6end = sizeof (struct in6_addr) - 2;
+			if (IN6_IS_ADDR_V4MAPPED(&ip6) ||
+			    IN6_IS_ADDR_V4COMPAT(&ip6)) {
+				for (i = sizeof (struct in6_addr) - 1;
+				    i >= DTRACE_V4MAPPED_OFFSET; i--) {
+					ASSERT(end >= base);
+
+					val = ip6._S6_un._S6_u8[i];
+
+					if (val == 0) {
+						*end-- = '0';
+					} else {
+						for (; val; val /= 10) {
+							*end-- = '0' + val % 10;
+						}
+					}
+
+					if (i > DTRACE_V4MAPPED_OFFSET)
+						*end-- = '.';
+				}
+
+				if (subr == DIF_SUBR_INET_NTOA6)
+					goto inetout;
+
+				/*
+				 * Set v6end to skip the IPv4 address that
+				 * we have already stringified.
+				 */
+				v6end = 10;
+			}
+
+			/*
+			 * Build the IPv6 string by working through the
+			 * address in reverse.
+			 */
+			for (i = v6end; i >= 0; i -= 2) {
+				ASSERT(end >= base);
+
+				if (i == firstzero + numzero - 2) {
+					*end-- = ':';
+					*end-- = ':';
+					i -= numzero - 2;
+					continue;
+				}
+
+				if (i < 14 && i != firstzero - 2)
+					*end-- = ':';
+
+				val = (ip6._S6_un._S6_u8[i] << 8) +
+				    ip6._S6_un._S6_u8[i + 1];
+
+				if (val == 0) {
+					*end-- = '0';
+				} else {
+					for (; val; val /= 16) {
+						*end-- = digits[val % 16];
+					}
+				}
+			}
+			ASSERT(end + 1 >= base);
+
+		} else {
+			/*
+			 * The user didn't use AH_INET or AH_INET6.
+			 */
+			DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
+			regs[rd] = NULL;
+			break;
+		}
+
+inetout:	regs[rd] = (uintptr_t)end + 1;
+		mstate->dtms_scratch_ptr += size;
+		break;
+	}
+
 	}
 }
 
@@ -7973,6 +8182,9 @@
 			    subr == DIF_SUBR_COPYINTO ||
 			    subr == DIF_SUBR_COPYINSTR ||
 			    subr == DIF_SUBR_INDEX ||
+			    subr == DIF_SUBR_INET_NTOA ||
+			    subr == DIF_SUBR_INET_NTOA6 ||
+			    subr == DIF_SUBR_INET_NTOP ||
 			    subr == DIF_SUBR_LLTOSTR ||
 			    subr == DIF_SUBR_RINDEX ||
 			    subr == DIF_SUBR_STRCHR ||
--- a/usr/src/uts/common/sys/dtrace.h	Tue May 22 10:21:44 2007 -0700
+++ b/usr/src/uts/common/sys/dtrace.h	Tue May 22 10:56:13 2007 -0700
@@ -279,8 +279,11 @@
 #define	DIF_SUBR_NTOHS			38
 #define	DIF_SUBR_NTOHL			39
 #define	DIF_SUBR_NTOHLL			40
+#define	DIF_SUBR_INET_NTOP		41
+#define	DIF_SUBR_INET_NTOA		42
+#define	DIF_SUBR_INET_NTOA6		43
 
-#define	DIF_SUBR_MAX			40	/* max subroutine value */
+#define	DIF_SUBR_MAX			43	/* max subroutine value */
 
 typedef uint32_t dif_instr_t;