2 * Unix SMB/CIFS implementation.
4 * Copyright (C) Theodore Ts'o 1996, 1997,
5 * Copyright (C) Jim McDonough 2002.
6 * Copyright (C) Andrew Tridgell 2003.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 void uuid_generate_random(struct GUID *out)
27 generate_random_buffer(out, sizeof(struct GUID), False);
28 out->clock_seq[0] = (out->clock_seq[0] & 0x3F) | 0x80;
29 out->time_hi_and_version = (out->time_hi_and_version & 0x0FFF) | 0x4000;
32 BOOL uuid_all_zero(const struct GUID *u)
34 if (u->time_low != 0 ||
36 u->time_hi_and_version != 0 ||
37 u->clock_seq[0] != 0 ||
38 u->clock_seq[1] != 0 ||
39 !all_zero(u->node, 6)) {
45 BOOL uuid_equal(const struct GUID *u1, const struct GUID *u2)
47 if (u1->time_low != u2->time_low ||
48 u1->time_mid != u2->time_mid ||
49 u1->time_hi_and_version != u2->time_hi_and_version ||
50 u1->clock_seq[0] != u2->clock_seq[0] ||
51 u1->clock_seq[1] != u2->clock_seq[1] ||
52 memcmp(u1->node, u2->node, 6) != 0) {
58 BOOL policy_handle_empty(struct policy_handle *h)
60 return (h->handle_type == 0 && uuid_all_zero(&h->uuid));