1*2b6e762cSahl /*
2*2b6e762cSahl  * CDDL HEADER START
3*2b6e762cSahl  *
4*2b6e762cSahl  * The contents of this file are subject to the terms of the
5*2b6e762cSahl  * Common Development and Distribution License (the "License").
6*2b6e762cSahl  * You may not use this file except in compliance with the License.
7*2b6e762cSahl  *
8*2b6e762cSahl  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*2b6e762cSahl  * or http://www.opensolaris.org/os/licensing.
10*2b6e762cSahl  * See the License for the specific language governing permissions
11*2b6e762cSahl  * and limitations under the License.
12*2b6e762cSahl  *
13*2b6e762cSahl  * When distributing Covered Code, include this CDDL HEADER in each
14*2b6e762cSahl  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*2b6e762cSahl  * If applicable, add the following below this CDDL HEADER, with the
16*2b6e762cSahl  * fields enclosed by brackets "[]" replaced with your own identifying
17*2b6e762cSahl  * information: Portions Copyright [yyyy] [name of copyright owner]
18*2b6e762cSahl  *
19*2b6e762cSahl  * CDDL HEADER END
20*2b6e762cSahl  */
21*2b6e762cSahl 
22*2b6e762cSahl /*
23*2b6e762cSahl  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24*2b6e762cSahl  * Use is subject to license terms.
25*2b6e762cSahl  */
26*2b6e762cSahl 
27*2b6e762cSahl /*
28*2b6e762cSahl  * ASSERTION: Test network byte-ordering routines.
29*2b6e762cSahl  */
30*2b6e762cSahl 
31*2b6e762cSahl #include <sys/isa_defs.h>
32*2b6e762cSahl 
33*2b6e762cSahl BEGIN
34*2b6e762cSahl {
35*2b6e762cSahl 	before[0] = 0x1122LL;
36*2b6e762cSahl 	before[1] = 0x11223344LL;
37*2b6e762cSahl 	before[2] = 0x1122334455667788LL;
38*2b6e762cSahl 
39*2b6e762cSahl #ifdef _LITTLE_ENDIAN
40*2b6e762cSahl 	after[0] = 0x2211LL;
41*2b6e762cSahl 	after[1] = 0x44332211LL;
42*2b6e762cSahl 	after[2] = 0x8877665544332211LL;
43*2b6e762cSahl #else
44*2b6e762cSahl 	after[0] = 0x1122LL;
45*2b6e762cSahl 	after[1] = 0x11223344LL;
46*2b6e762cSahl 	after[2] = 0x1122334455667788LL;
47*2b6e762cSahl #endif
48*2b6e762cSahl }
49*2b6e762cSahl 
50*2b6e762cSahl BEGIN
51*2b6e762cSahl /after[0] != htons(before[0])/
52*2b6e762cSahl {
53*2b6e762cSahl 	printf("%x rather than %x", htons(before[0]), after[0]);
54*2b6e762cSahl 	exit(1);
55*2b6e762cSahl }
56*2b6e762cSahl 
57*2b6e762cSahl BEGIN
58*2b6e762cSahl /after[0] != ntohs(before[0])/
59*2b6e762cSahl {
60*2b6e762cSahl 	printf("%x rather than %x", ntohs(before[0]), after[0]);
61*2b6e762cSahl 	exit(1);
62*2b6e762cSahl }
63*2b6e762cSahl 
64*2b6e762cSahl BEGIN
65*2b6e762cSahl /after[1] != htonl(before[1])/
66*2b6e762cSahl {
67*2b6e762cSahl 	printf("%x rather than %x", htonl(before[1]), after[1]);
68*2b6e762cSahl 	exit(1);
69*2b6e762cSahl }
70*2b6e762cSahl 
71*2b6e762cSahl BEGIN
72*2b6e762cSahl /after[1] != ntohl(before[1])/
73*2b6e762cSahl {
74*2b6e762cSahl 	printf("%x rather than %x", ntohl(before[1]), after[1]);
75*2b6e762cSahl 	exit(1);
76*2b6e762cSahl }
77*2b6e762cSahl 
78*2b6e762cSahl BEGIN
79*2b6e762cSahl /after[2] != htonll(before[2])/
80*2b6e762cSahl {
81*2b6e762cSahl 	printf("%x rather than %x", htonll(before[2]), after[2]);
82*2b6e762cSahl 	exit(1);
83*2b6e762cSahl }
84*2b6e762cSahl 
85*2b6e762cSahl BEGIN
86*2b6e762cSahl /after[2] != ntohll(before[2])/
87*2b6e762cSahl {
88*2b6e762cSahl 	printf("%x rather than %x", ntohll(before[2]), after[2]);
89*2b6e762cSahl 	exit(1);
90*2b6e762cSahl }
91*2b6e762cSahl 
92*2b6e762cSahl BEGIN
93*2b6e762cSahl {
94*2b6e762cSahl 	exit(0);
95*2b6e762cSahl }
96