Print this page
3087 libuuid has a lot of dependencies


   7  *
   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.
  12  *
  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]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  * Copyright 2012 Milan Jurik. All rights reserved.
  25  * Copyright 2015 Joyent, Inc. All rights reserved.
  26  * Copyright 2014 Andrew Stormont.

  27  */
  28 
  29 /*
  30  * The copyright in this file is taken from the original Leach & Salz
  31  * UUID specification, from which this implementation is derived.
  32  */
  33 
  34 /*
  35  * Copyright (c) 1990- 1993, 1996 Open Software Foundation, Inc.
  36  * Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. &
  37  * Digital Equipment Corporation, Maynard, Mass.  Copyright (c) 1998
  38  * Microsoft.  To anyone who acknowledges that this file is provided
  39  * "AS IS" without any express or implied warranty: permission to use,
  40  * copy, modify, and distribute this file for any purpose is hereby
  41  * granted without fee, provided that the above copyright notices and
  42  * this notice appears in all source code copies, and that none of the
  43  * names of Open Software Foundation, Inc., Hewlett-Packard Company,
  44  * or Digital Equipment Corporation be used in advertising or
  45  * publicity pertaining to distribution of the software without
  46  * specific, written prior permission.  Neither Open Software


 171         format_uuid(uuid, data->state.clock, timestamp, system_node);
 172 
 173         (void) mutex_unlock(&data->lock);
 174 
 175         return (0);
 176 }
 177 
 178 /*
 179  * Fills system_node with Ethernet address if available,
 180  * else fills random numbers
 181  */
 182 static void
 183 gen_ethernet_address(uuid_node_t *system_node)
 184 {
 185         uchar_t         node[6];
 186 
 187         if (get_ethernet_address(system_node) != 0) {
 188                 arc4random_buf(node, 6);
 189                 (void) memcpy(system_node->nodeID, node, 6);
 190                 /*
 191                  * use 8:0:20 with the multicast bit set
 192                  * to avoid namespace collisions.
 193                  */
 194                 system_node->nodeID[0] = 0x88;
 195                 system_node->nodeID[1] = 0x00;
 196                 system_node->nodeID[2] = 0x20;
 197         }
 198 }
 199 
 200 /*
 201  * Formats a UUID, given the clock_seq timestamp, and node address.
 202  * Fills in passed-in pointer with the resulting uuid.
 203  */
 204 static void
 205 format_uuid(struct uuid *uuid, uint16_t clock_seq,
 206     uuid_time_t timestamp, uuid_node_t node)
 207 {
 208 
 209         /*
 210          * First set up the first 60 bits from the timestamp
 211          */
 212         uuid->time_low = (uint32_t)(timestamp & 0xFFFFFFFF);
 213         uuid->time_mid = (uint16_t)((timestamp >> 32) & 0xFFFF);
 214         uuid->time_hi_and_version = (uint16_t)((timestamp >> 48) & 0x0FFF);
 215 
 216         /*




   7  *
   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.
  12  *
  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]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  * Copyright 2012 Milan Jurik. All rights reserved.
  25  * Copyright 2015 Joyent, Inc. All rights reserved.
  26  * Copyright 2014 Andrew Stormont.
  27  * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
  28  */
  29 
  30 /*
  31  * The copyright in this file is taken from the original Leach & Salz
  32  * UUID specification, from which this implementation is derived.
  33  */
  34 
  35 /*
  36  * Copyright (c) 1990- 1993, 1996 Open Software Foundation, Inc.
  37  * Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. &
  38  * Digital Equipment Corporation, Maynard, Mass.  Copyright (c) 1998
  39  * Microsoft.  To anyone who acknowledges that this file is provided
  40  * "AS IS" without any express or implied warranty: permission to use,
  41  * copy, modify, and distribute this file for any purpose is hereby
  42  * granted without fee, provided that the above copyright notices and
  43  * this notice appears in all source code copies, and that none of the
  44  * names of Open Software Foundation, Inc., Hewlett-Packard Company,
  45  * or Digital Equipment Corporation be used in advertising or
  46  * publicity pertaining to distribution of the software without
  47  * specific, written prior permission.  Neither Open Software


 172         format_uuid(uuid, data->state.clock, timestamp, system_node);
 173 
 174         (void) mutex_unlock(&data->lock);
 175 
 176         return (0);
 177 }
 178 
 179 /*
 180  * Fills system_node with Ethernet address if available,
 181  * else fills random numbers
 182  */
 183 static void
 184 gen_ethernet_address(uuid_node_t *system_node)
 185 {
 186         uchar_t         node[6];
 187 
 188         if (get_ethernet_address(system_node) != 0) {
 189                 arc4random_buf(node, 6);
 190                 (void) memcpy(system_node->nodeID, node, 6);
 191                 /*
 192                  * use 8:.. with the multicast bit set
 193                  * to reduce namespace collisions.
 194                  */
 195                 system_node->nodeID[0] = 0x88;


 196         }
 197 }
 198 
 199 /*
 200  * Formats a UUID, given the clock_seq timestamp, and node address.
 201  * Fills in passed-in pointer with the resulting uuid.
 202  */
 203 static void
 204 format_uuid(struct uuid *uuid, uint16_t clock_seq,
 205     uuid_time_t timestamp, uuid_node_t node)
 206 {
 207 
 208         /*
 209          * First set up the first 60 bits from the timestamp
 210          */
 211         uuid->time_low = (uint32_t)(timestamp & 0xFFFFFFFF);
 212         uuid->time_mid = (uint16_t)((timestamp >> 32) & 0xFFFF);
 213         uuid->time_hi_and_version = (uint16_t)((timestamp >> 48) & 0x0FFF);
 214 
 215         /*