Print this page
5007142 Add ntohll and htonll to sys/byteorder.h
6717509 Need to use bswap/bswapq for byte swap of 64-bit integer on x32/x64
PSARC 2008/474

*** 17,32 **** * 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" - #include <sys/types.h> #include <string.h> #include <stdlib.h> #include <stdio.h> #include <errno.h> --- 17,30 ---- * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* ! * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #include <sys/types.h> #include <string.h> #include <stdlib.h> #include <stdio.h> #include <errno.h>
*** 45,56 **** #include <netinet/dhcp6.h> #include "dhcp_symbol.h" #include "dhcp_inittab.h" - static uint64_t dhcp_htonll(uint64_t); - static uint64_t dhcp_ntohll(uint64_t); static void inittab_msg(const char *, ...); static uchar_t category_to_code(const char *); static boolean_t encode_number(uint8_t, uint8_t, boolean_t, uint8_t, const char *, uint8_t *, int *); static boolean_t decode_number(uint8_t, uint8_t, boolean_t, uint8_t, --- 43,52 ----
*** 1476,1486 **** break; case 8: (void) memcpy(&uint64, from, 8); to += sprintf(to, is_signed ? "%lld" : "%llu", ! dhcp_ntohll(uint64)); break; default: *ierrnop = ITAB_BAD_NUMBER; inittab_msg("decode_number: unknown integer size `%d'", --- 1472,1482 ---- break; case 8: (void) memcpy(&uint64, from, 8); to += sprintf(to, is_signed ? "%lld" : "%llu", ! ntohll(uint64)); break; default: *ierrnop = ITAB_BAD_NUMBER; inittab_msg("decode_number: unknown integer size `%d'",
*** 1572,1582 **** } (void) memcpy(to, &uint32, 4); break; case 8: ! uint64 = dhcp_htonll(strtoull(from, &endptr, 0)); if (errno != 0 || from == endptr) { goto error; } (void) memcpy(to, &uint64, 8); break; --- 1568,1578 ---- } (void) memcpy(to, &uint32, 4); break; case 8: ! uint64 = htonll(strtoull(from, &endptr, 0)); if (errno != 0 || from == endptr) { goto error; } (void) memcpy(to, &uint64, 8); break;
*** 1692,1732 **** return (category_map[i].cme_itabcode); return (0); } - /* - * dhcp_htonll(): converts a 64-bit number from host to network byte order - * - * input: uint64_t: the number to convert - * output: uint64_t: its value in network byte order - */ - - static uint64_t - dhcp_htonll(uint64_t uint64_hbo) - { - return (dhcp_ntohll(uint64_hbo)); - } - - /* - * dhcp_ntohll(): converts a 64-bit number from network to host byte order - * - * input: uint64_t: the number to convert - * output: uint64_t: its value in host byte order - */ - - static uint64_t - dhcp_ntohll(uint64_t uint64_nbo) - { - #ifdef _LITTLE_ENDIAN - return ((uint64_t)ntohl(uint64_nbo & 0xffffffff) << 32 | - ntohl(uint64_nbo >> 32)); - #else - return (uint64_nbo); - #endif - } - /* * our internal table of DHCP option values, used by inittab_verify() */ static dhcp_symbol_t inittab_table[] = { --- 1688,1697 ----