1*0baf9d8dSJessica Hamilton /*
2*0baf9d8dSJessica Hamilton * Internal routine for unpacking UUID
3*0baf9d8dSJessica Hamilton *
4*0baf9d8dSJessica Hamilton * Copyright (C) 1996, 1997 Theodore Ts'o.
5*0baf9d8dSJessica Hamilton *
6*0baf9d8dSJessica Hamilton * %Begin-Header%
7*0baf9d8dSJessica Hamilton * Redistribution and use in source and binary forms, with or without
8*0baf9d8dSJessica Hamilton * modification, are permitted provided that the following conditions
9*0baf9d8dSJessica Hamilton * are met:
10*0baf9d8dSJessica Hamilton * 1. Redistributions of source code must retain the above copyright
11*0baf9d8dSJessica Hamilton * notice, and the entire permission notice in its entirety,
12*0baf9d8dSJessica Hamilton * including the disclaimer of warranties.
13*0baf9d8dSJessica Hamilton * 2. Redistributions in binary form must reproduce the above copyright
14*0baf9d8dSJessica Hamilton * notice, this list of conditions and the following disclaimer in the
15*0baf9d8dSJessica Hamilton * documentation and/or other materials provided with the distribution.
16*0baf9d8dSJessica Hamilton * 3. The name of the author may not be used to endorse or promote
17*0baf9d8dSJessica Hamilton * products derived from this software without specific prior
18*0baf9d8dSJessica Hamilton * written permission.
19*0baf9d8dSJessica Hamilton *
20*0baf9d8dSJessica Hamilton * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
21*0baf9d8dSJessica Hamilton * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22*0baf9d8dSJessica Hamilton * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
23*0baf9d8dSJessica Hamilton * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
24*0baf9d8dSJessica Hamilton * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25*0baf9d8dSJessica Hamilton * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
26*0baf9d8dSJessica Hamilton * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27*0baf9d8dSJessica Hamilton * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28*0baf9d8dSJessica Hamilton * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29*0baf9d8dSJessica Hamilton * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
30*0baf9d8dSJessica Hamilton * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
31*0baf9d8dSJessica Hamilton * DAMAGE.
32*0baf9d8dSJessica Hamilton * %End-Header%
33*0baf9d8dSJessica Hamilton */
34*0baf9d8dSJessica Hamilton
35*0baf9d8dSJessica Hamilton #include <string.h>
36*0baf9d8dSJessica Hamilton #include "uuidP.h"
37*0baf9d8dSJessica Hamilton
uuid_unpack(const uuid_t in,struct uuid * uu)38*0baf9d8dSJessica Hamilton void uuid_unpack(const uuid_t in, struct uuid *uu)
39*0baf9d8dSJessica Hamilton {
40*0baf9d8dSJessica Hamilton const uint8_t *ptr = in;
41*0baf9d8dSJessica Hamilton uint32_t tmp;
42*0baf9d8dSJessica Hamilton
43*0baf9d8dSJessica Hamilton tmp = *ptr++;
44*0baf9d8dSJessica Hamilton tmp = (tmp << 8) | *ptr++;
45*0baf9d8dSJessica Hamilton tmp = (tmp << 8) | *ptr++;
46*0baf9d8dSJessica Hamilton tmp = (tmp << 8) | *ptr++;
47*0baf9d8dSJessica Hamilton uu->time_low = tmp;
48*0baf9d8dSJessica Hamilton
49*0baf9d8dSJessica Hamilton tmp = *ptr++;
50*0baf9d8dSJessica Hamilton tmp = (tmp << 8) | *ptr++;
51*0baf9d8dSJessica Hamilton uu->time_mid = tmp;
52*0baf9d8dSJessica Hamilton
53*0baf9d8dSJessica Hamilton tmp = *ptr++;
54*0baf9d8dSJessica Hamilton tmp = (tmp << 8) | *ptr++;
55*0baf9d8dSJessica Hamilton uu->time_hi_and_version = tmp;
56*0baf9d8dSJessica Hamilton
57*0baf9d8dSJessica Hamilton tmp = *ptr++;
58*0baf9d8dSJessica Hamilton tmp = (tmp << 8) | *ptr++;
59*0baf9d8dSJessica Hamilton uu->clock_seq = tmp;
60*0baf9d8dSJessica Hamilton
61*0baf9d8dSJessica Hamilton memcpy(uu->node, ptr, 6);
62*0baf9d8dSJessica Hamilton }
63*0baf9d8dSJessica Hamilton
64