xref: /illumos-gate/usr/src/cmd/dtrace/test/tst/common/funcs/tst.inet_ntop.d (revision 5d9d9091f564c198a760790b0bfa72c44e17912b)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #pragma D option quiet
28 
29 ipaddr_t *ip4a;
30 ipaddr_t *ip4b;
31 ipaddr_t *ip4c;
32 ipaddr_t *ip4d;
33 struct in6_addr *ip6a;
34 struct in6_addr *ip6b;
35 struct in6_addr *ip6c;
36 struct in6_addr *ip6d;
37 struct in6_addr *ip6e;
38 struct in6_addr *ip6f;
39 struct in6_addr *ip6g;
40 struct in6_addr *ip6h;
41 
42 BEGIN
43 {
44 	this->buf4a = alloca(sizeof (ipaddr_t));
45 	this->buf4b = alloca(sizeof (ipaddr_t));
46 	this->buf4c = alloca(sizeof (ipaddr_t));
47 	this->buf4d = alloca(sizeof (ipaddr_t));
48 	this->buf6a = alloca(sizeof (struct in6_addr));
49 	this->buf6b = alloca(sizeof (struct in6_addr));
50 	this->buf6c = alloca(sizeof (struct in6_addr));
51 	this->buf6d = alloca(sizeof (struct in6_addr));
52 	this->buf6e = alloca(sizeof (struct in6_addr));
53 	this->buf6f = alloca(sizeof (struct in6_addr));
54 	this->buf6g = alloca(sizeof (struct in6_addr));
55 	this->buf6h = alloca(sizeof (struct in6_addr));
56 	ip4a = this->buf4a;
57 	ip4b = this->buf4b;
58 	ip4c = this->buf4c;
59 	ip4d = this->buf4d;
60 	ip6a = this->buf6a;
61 	ip6b = this->buf6b;
62 	ip6c = this->buf6c;
63 	ip6d = this->buf6d;
64 	ip6e = this->buf6e;
65 	ip6f = this->buf6f;
66 	ip6g = this->buf6g;
67 	ip6h = this->buf6h;
68 
69 	*ip4a = htonl(0xc0a80117);
70 	*ip4b = htonl(0x7f000001);
71 	*ip4c = htonl(0xffffffff);
72 	*ip4d = htonl(0x00000000);
73 	ip6a->_S6_un._S6_u8[0] = 0xfe;
74 	ip6a->_S6_un._S6_u8[1] = 0x80;
75 	ip6a->_S6_un._S6_u8[8] = 0x02;
76 	ip6a->_S6_un._S6_u8[9] = 0x14;
77 	ip6a->_S6_un._S6_u8[10] = 0x4f;
78 	ip6a->_S6_un._S6_u8[11] = 0xff;
79 	ip6a->_S6_un._S6_u8[12] = 0xfe;
80 	ip6a->_S6_un._S6_u8[13] = 0x0b;
81 	ip6a->_S6_un._S6_u8[14] = 0x76;
82 	ip6a->_S6_un._S6_u8[15] = 0xc8;
83 	ip6b->_S6_un._S6_u8[0] = 0x10;
84 	ip6b->_S6_un._S6_u8[1] = 0x80;
85 	ip6b->_S6_un._S6_u8[10] = 0x08;
86 	ip6b->_S6_un._S6_u8[11] = 0x08;
87 	ip6b->_S6_un._S6_u8[13] = 0x20;
88 	ip6b->_S6_un._S6_u8[13] = 0x0c;
89 	ip6b->_S6_un._S6_u8[14] = 0x41;
90 	ip6b->_S6_un._S6_u8[15] = 0x7a;
91 	ip6c->_S6_un._S6_u8[15] = 0x01;
92 	ip6e->_S6_un._S6_u8[12] = 0x7f;
93 	ip6e->_S6_un._S6_u8[15] = 0x01;
94 	ip6f->_S6_un._S6_u8[10] = 0xff;
95 	ip6f->_S6_un._S6_u8[11] = 0xff;
96 	ip6f->_S6_un._S6_u8[12] = 0x7f;
97 	ip6f->_S6_un._S6_u8[15] = 0x01;
98 	ip6g->_S6_un._S6_u8[10] = 0xff;
99 	ip6g->_S6_un._S6_u8[11] = 0xfe;
100 	ip6g->_S6_un._S6_u8[12] = 0x7f;
101 	ip6g->_S6_un._S6_u8[15] = 0x01;
102 	ip6h->_S6_un._S6_u8[0] = 0xff;
103 	ip6h->_S6_un._S6_u8[1] = 0xff;
104 	ip6h->_S6_un._S6_u8[2] = 0xff;
105 	ip6h->_S6_un._S6_u8[3] = 0xff;
106 	ip6h->_S6_un._S6_u8[4] = 0xff;
107 	ip6h->_S6_un._S6_u8[5] = 0xff;
108 	ip6h->_S6_un._S6_u8[6] = 0xff;
109 	ip6h->_S6_un._S6_u8[7] = 0xff;
110 	ip6h->_S6_un._S6_u8[8] = 0xff;
111 	ip6h->_S6_un._S6_u8[9] = 0xff;
112 	ip6h->_S6_un._S6_u8[10] = 0xff;
113 	ip6h->_S6_un._S6_u8[11] = 0xff;
114 	ip6h->_S6_un._S6_u8[12] = 0xff;
115 	ip6h->_S6_un._S6_u8[13] = 0xff;
116 	ip6h->_S6_un._S6_u8[14] = 0xff;
117 	ip6h->_S6_un._S6_u8[15] = 0xff;
118 
119 	printf("%s\n", inet_ntop(AF_INET, ip4a));
120 	printf("%s\n", inet_ntop(AF_INET, ip4b));
121 	printf("%s\n", inet_ntop(AF_INET, ip4c));
122 	printf("%s\n", inet_ntop(AF_INET, ip4d));
123 	printf("%s\n", inet_ntop(AF_INET6, ip6a));
124 	printf("%s\n", inet_ntop(AF_INET6, ip6b));
125 	printf("%s\n", inet_ntop(AF_INET6, ip6c));
126 	printf("%s\n", inet_ntop(AF_INET6, ip6d));
127 	printf("%s\n", inet_ntop(AF_INET6, ip6e));
128 	printf("%s\n", inet_ntop(AF_INET6, ip6f));
129 	printf("%s\n", inet_ntop(AF_INET6, ip6g));
130 	printf("%s\n", inet_ntop(AF_INET6, ip6h));
131 
132 	exit(0);
133 }
134