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.
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.
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]
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #include <sys/types.h>
27 #include <netinet/in.h>
30 * htonll(), ntohll(), htonl(), ntohl(), htons(), ntohs()
32 * On little endian machines these functions reverse the byte order of the
33 * input parameter and returns the result. This is to convert the byte order
34 * from host byte order (little endian) to network byte order (big endian),
37 * On big endian machines these functions just return the input parameter,
38 * as the host byte order is the same as the network byte order (big endian).
46 return ((uint64_t)htonl((in
>> 32) & 0xffffffff) |
47 ((uint64_t)htonl(in
& 0xffffffff) << 32));
53 return ((uint64_t)ntohl((in
>> 32) & 0xffffffff) |
54 ((uint64_t)ntohl(in
& 0xffffffff) << 32));
62 i
= (uint32_t)((in
& (uint32_t)0xff000000) >> 24) +
63 (uint32_t)((in
& (uint32_t)0x00ff0000) >> 8) +
64 (uint32_t)((in
& (uint32_t)0x0000ff00) << 8) +
65 (uint32_t)((in
& (uint32_t)0x000000ff) << 24);
78 register int arg
= (int)in
;
81 i
= (uint16_t)(((arg
& 0xff00) >> 8) & 0xff);
82 i
|= (uint16_t)((arg
& 0xff) << 8);
92 #else /* _LITTLE_ENDIAN */
94 #endif /* _LITTLE_ENDIAN */