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,16 +17,14 @@
  * information: Portions Copyright [yyyy] [name of copyright owner]
  *
  * CDDL HEADER END
  */
 /*
- * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2008 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>

@@ -45,12 +43,10 @@
 #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,

@@ -1476,11 +1472,11 @@
                         break;
 
                 case 8:
                         (void) memcpy(&uint64, from, 8);
                         to += sprintf(to, is_signed ? "%lld" : "%llu",
-                            dhcp_ntohll(uint64));
+                            ntohll(uint64));
                         break;
 
                 default:
                         *ierrnop = ITAB_BAD_NUMBER;
                         inittab_msg("decode_number: unknown integer size `%d'",

@@ -1572,11 +1568,11 @@
                         }
                         (void) memcpy(to, &uint32, 4);
                         break;
 
                 case 8:
-                        uint64 = dhcp_htonll(strtoull(from, &endptr, 0));
+                        uint64 = htonll(strtoull(from, &endptr, 0));
                         if (errno != 0 || from == endptr) {
                                 goto error;
                         }
                         (void) memcpy(to, &uint64, 8);
                         break;

@@ -1692,41 +1688,10 @@
                         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[] =
 {