1178476Sjb/* 2178476Sjb * CDDL HEADER START 3178476Sjb * 4178476Sjb * The contents of this file are subject to the terms of the 5178476Sjb * Common Development and Distribution License (the "License"). 6178476Sjb * You may not use this file except in compliance with the License. 7178476Sjb * 8178476Sjb * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9178476Sjb * or http://www.opensolaris.org/os/licensing. 10178476Sjb * See the License for the specific language governing permissions 11178476Sjb * and limitations under the License. 12178476Sjb * 13178476Sjb * When distributing Covered Code, include this CDDL HEADER in each 14178476Sjb * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15178476Sjb * If applicable, add the following below this CDDL HEADER, with the 16178476Sjb * fields enclosed by brackets "[]" replaced with your own identifying 17178476Sjb * information: Portions Copyright [yyyy] [name of copyright owner] 18178476Sjb * 19178476Sjb * CDDL HEADER END 20178476Sjb */ 21178476Sjb 22178476Sjb/* 23178476Sjb * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 24178476Sjb * Use is subject to license terms. 25178476Sjb */ 26178476Sjb 27178476Sjb#pragma ident "%Z%%M% %I% %E% SMI" 28178476Sjb 29178476Sjb/* 30178476Sjb * ASSERTION: Test network byte-ordering routines. 31178476Sjb */ 32178476Sjb 33178534Sjb#if defined(__amd64__) || defined(__i386__) 34178534Sjb#define _LITTLE_ENDIAN 35178534Sjb#endif 36178476Sjb 37178476SjbBEGIN 38178476Sjb{ 39178476Sjb before[0] = 0x1122LL; 40178476Sjb before[1] = 0x11223344LL; 41178476Sjb before[2] = 0x1122334455667788LL; 42178476Sjb 43178476Sjb#ifdef _LITTLE_ENDIAN 44178476Sjb after[0] = 0x2211LL; 45178476Sjb after[1] = 0x44332211LL; 46178476Sjb after[2] = 0x8877665544332211LL; 47178476Sjb#else 48178476Sjb after[0] = 0x1122LL; 49178476Sjb after[1] = 0x11223344LL; 50178476Sjb after[2] = 0x1122334455667788LL; 51178476Sjb#endif 52178476Sjb} 53178476Sjb 54178476SjbBEGIN 55178476Sjb/after[0] != htons(before[0])/ 56178476Sjb{ 57178476Sjb printf("%x rather than %x", htons(before[0]), after[0]); 58178476Sjb exit(1); 59178476Sjb} 60178476Sjb 61178476SjbBEGIN 62178476Sjb/after[0] != ntohs(before[0])/ 63178476Sjb{ 64178476Sjb printf("%x rather than %x", ntohs(before[0]), after[0]); 65178476Sjb exit(1); 66178476Sjb} 67178476Sjb 68178476SjbBEGIN 69178476Sjb/after[1] != htonl(before[1])/ 70178476Sjb{ 71178476Sjb printf("%x rather than %x", htonl(before[1]), after[1]); 72178476Sjb exit(1); 73178476Sjb} 74178476Sjb 75178476SjbBEGIN 76178476Sjb/after[1] != ntohl(before[1])/ 77178476Sjb{ 78178476Sjb printf("%x rather than %x", ntohl(before[1]), after[1]); 79178476Sjb exit(1); 80178476Sjb} 81178476Sjb 82178476SjbBEGIN 83178476Sjb/after[2] != htonll(before[2])/ 84178476Sjb{ 85178476Sjb printf("%x rather than %x", htonll(before[2]), after[2]); 86178476Sjb exit(1); 87178476Sjb} 88178476Sjb 89178476SjbBEGIN 90178476Sjb/after[2] != ntohll(before[2])/ 91178476Sjb{ 92178476Sjb printf("%x rather than %x", ntohll(before[2]), after[2]); 93178476Sjb exit(1); 94178476Sjb} 95178476Sjb 96178476SjbBEGIN 97178476Sjb{ 98178476Sjb exit(0); 99178476Sjb} 100