summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrendan <none@none>2007-05-22 10:56:13 -0700
committerbrendan <none@none>2007-05-22 10:56:13 -0700
commit4edabff493bc4820f4297f981943f11de1cbf3be (patch)
tree03792f8eb95533562f7b3fea45dcbc94eae7e2c5
parenteee42cb8793fcf3f72a7d16b2a1e9371d5bf60ab (diff)
downloadillumos-gate-4edabff493bc4820f4297f981943f11de1cbf3be.tar.gz
6558517 need DTrace versions of IP address to string functions, like inet_ntop()
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/aggs/tst.subr.d5
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/funcs/err.inet_ntoa6badaddr.d45
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/funcs/err.inet_ntoabadaddr.d45
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/funcs/err.inet_ntopbadaddr.d45
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/funcs/err.inet_ntopbadarg.d47
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa.d58
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa.d.out5
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa6.d95
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa6.d.out8
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/funcs/tst.inet_ntop.d135
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/funcs/tst.inet_ntop.d.out13
-rw-r--r--usr/src/lib/libdtrace/Makefile.com5
-rw-r--r--usr/src/lib/libdtrace/common/dt_open.c6
-rw-r--r--usr/src/lib/libdtrace/common/ip.d.in31
-rw-r--r--usr/src/lib/libdtrace/common/ip.sed.in41
-rw-r--r--usr/src/pkgdefs/SUNWdtrc/prototype_com1
-rw-r--r--usr/src/pkgdefs/SUNWdtrt/prototype_com10
-rw-r--r--usr/src/uts/common/dtrace/dtrace.c212
-rw-r--r--usr/src/uts/common/sys/dtrace.h5
19 files changed, 810 insertions, 2 deletions
diff --git a/usr/src/cmd/dtrace/test/tst/common/aggs/tst.subr.d b/usr/src/cmd/dtrace/test/tst/common/aggs/tst.subr.d
index c7a809b39e..5ca1f1ef93 100644
--- a/usr/src/cmd/dtrace/test/tst/common/aggs/tst.subr.d
+++ b/usr/src/cmd/dtrace/test/tst/common/aggs/tst.subr.d
@@ -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(htonll(0x1234567890abcdefL))
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/
diff --git a/usr/src/cmd/dtrace/test/tst/common/funcs/err.inet_ntoa6badaddr.d b/usr/src/cmd/dtrace/test/tst/common/funcs/err.inet_ntoa6badaddr.d
new file mode 100644
index 0000000000..81ce643f6b
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/funcs/err.inet_ntoa6badaddr.d
@@ -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);
+}
diff --git a/usr/src/cmd/dtrace/test/tst/common/funcs/err.inet_ntoabadaddr.d b/usr/src/cmd/dtrace/test/tst/common/funcs/err.inet_ntoabadaddr.d
new file mode 100644
index 0000000000..3f0d8e45ff
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/funcs/err.inet_ntoabadaddr.d
@@ -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);
+}
diff --git a/usr/src/cmd/dtrace/test/tst/common/funcs/err.inet_ntopbadaddr.d b/usr/src/cmd/dtrace/test/tst/common/funcs/err.inet_ntopbadaddr.d
new file mode 100644
index 0000000000..74ce760d8b
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/funcs/err.inet_ntopbadaddr.d
@@ -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);
+}
diff --git a/usr/src/cmd/dtrace/test/tst/common/funcs/err.inet_ntopbadarg.d b/usr/src/cmd/dtrace/test/tst/common/funcs/err.inet_ntopbadarg.d
new file mode 100644
index 0000000000..2731385d2d
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/funcs/err.inet_ntopbadarg.d
@@ -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);
+}
diff --git a/usr/src/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa.d b/usr/src/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa.d
new file mode 100644
index 0000000000..cf7459d35b
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa.d
@@ -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);
+}
diff --git a/usr/src/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa.d.out b/usr/src/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa.d.out
new file mode 100644
index 0000000000..ab535e78c1
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa.d.out
@@ -0,0 +1,5 @@
+192.168.1.23
+127.0.0.1
+255.255.255.255
+0.0.0.0
+
diff --git a/usr/src/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa6.d b/usr/src/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa6.d
new file mode 100644
index 0000000000..9a00eb782a
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa6.d
@@ -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);
+}
diff --git a/usr/src/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa6.d.out b/usr/src/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa6.d.out
new file mode 100644
index 0000000000..d87c1f6141
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/funcs/tst.inet_ntoa6.d.out
@@ -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
+
diff --git a/usr/src/cmd/dtrace/test/tst/common/funcs/tst.inet_ntop.d b/usr/src/cmd/dtrace/test/tst/common/funcs/tst.inet_ntop.d
new file mode 100644
index 0000000000..c1e4b1bb0c
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/funcs/tst.inet_ntop.d
@@ -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);
+}
diff --git a/usr/src/cmd/dtrace/test/tst/common/funcs/tst.inet_ntop.d.out b/usr/src/cmd/dtrace/test/tst/common/funcs/tst.inet_ntop.d.out
new file mode 100644
index 0000000000..7c8311c2b8
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/funcs/tst.inet_ntop.d.out
@@ -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
+
diff --git a/usr/src/lib/libdtrace/Makefile.com b/usr/src/lib/libdtrace/Makefile.com
index a281d38343..e20ba2320e 100644
--- a/usr/src/lib/libdtrace/Makefile.com
+++ b/usr/src/lib/libdtrace/Makefile.com
@@ -76,6 +76,7 @@ DRTIOBJ = $(DRTISRC:%.c=%.o)
DLIBSRCS += \
errno.d \
io.d \
+ ip.d \
procfs.d \
regs.d \
sched.d \
@@ -93,6 +94,7 @@ SRCDIR = ../common
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 @@ pics/dt_lex.o pics/dt_grammar.o := CCVERBOSE =
../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 > $@
diff --git a/usr/src/lib/libdtrace/common/dt_open.c b/usr/src/lib/libdtrace/common/dt_open.c
index 53e970df26..4859d0040c 100644
--- a/usr/src/lib/libdtrace/common/dt_open.c
+++ b/usr/src/lib/libdtrace/common/dt_open.c
@@ -232,6 +232,12 @@ static const dt_ident_t _dtrace_globals[] = {
&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,
diff --git a/usr/src/lib/libdtrace/common/ip.d.in b/usr/src/lib/libdtrace/common/ip.d.in
new file mode 100644
index 0000000000..da886eea66
--- /dev/null
+++ b/usr/src/lib/libdtrace/common/ip.d.in
@@ -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
diff --git a/usr/src/lib/libdtrace/common/ip.sed.in b/usr/src/lib/libdtrace/common/ip.sed.in
new file mode 100644
index 0000000000..0083edf2de
--- /dev/null
+++ b/usr/src/lib/libdtrace/common/ip.sed.in
@@ -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)
diff --git a/usr/src/pkgdefs/SUNWdtrc/prototype_com b/usr/src/pkgdefs/SUNWdtrc/prototype_com
index ced9fa6784..34b7dfd623 100644
--- a/usr/src/pkgdefs/SUNWdtrc/prototype_com
+++ b/usr/src/pkgdefs/SUNWdtrc/prototype_com
@@ -49,6 +49,7 @@ d none usr/lib/dtrace 755 root bin
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
diff --git a/usr/src/pkgdefs/SUNWdtrt/prototype_com b/usr/src/pkgdefs/SUNWdtrt/prototype_com
index 8eb1b75ceb..f1984e79f0 100644
--- a/usr/src/pkgdefs/SUNWdtrt/prototype_com
+++ b/usr/src/pkgdefs/SUNWdtrt/prototype_com
@@ -505,6 +505,10 @@ f none SUNWdtrt/tst/common/funcs/err.chillbadarg.ksh 0444 root bin
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.ftruncate.ksh.out 0444 root bin
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
diff --git a/usr/src/uts/common/dtrace/dtrace.c b/usr/src/uts/common/dtrace/dtrace.c
index eadda9fdbe..37f1e7dd3b 100644
--- a/usr/src/uts/common/dtrace/dtrace.c
+++ b/usr/src/uts/common/dtrace/dtrace.c
@@ -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 @@ static kmutex_t dtrace_errlock;
#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 @@ next:
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 @@ dtrace_difo_validate_helper(dtrace_difo_t *dp)
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 ||
diff --git a/usr/src/uts/common/sys/dtrace.h b/usr/src/uts/common/sys/dtrace.h
index a42d69a677..01cfa8ba5f 100644
--- a/usr/src/uts/common/sys/dtrace.h
+++ b/usr/src/uts/common/sys/dtrace.h
@@ -279,8 +279,11 @@ typedef enum dtrace_probespec {
#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;