diff options
author | Stefan Metzmacher <metze@samba.org> | 2004-11-25 20:03:46 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:06:09 -0500 |
commit | e90061865467600a9d8a34f92e60a296cbf19234 (patch) | |
tree | 55919aa76141d312b5c288326489dc7b77c81061 /source4 | |
parent | 3308087bae76a99c02687bd11f4237d803f9f605 (diff) | |
download | samba-e90061865467600a9d8a34f92e60a296cbf19234.tar.gz samba-e90061865467600a9d8a34f92e60a296cbf19234.tar.bz2 samba-e90061865467600a9d8a34f92e60a296cbf19234.zip |
r3972: use GUID_* naming context and move GUID_* functions to one place
metze
(This used to be commit 523e6acf4fec5d4946fa7c0c89f40d7d712c9f3a)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/lib/basic.mk | 1 | ||||
-rw-r--r-- | source4/lib/dcom/common/main.c | 8 | ||||
-rw-r--r-- | source4/lib/dcom/common/tables.c | 4 | ||||
-rw-r--r-- | source4/lib/util_uuid.c | 62 | ||||
-rw-r--r-- | source4/librpc/config.mk | 3 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_basic.c | 84 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_misc.c | 143 | ||||
-rw-r--r-- | source4/librpc/rpc/dcerpc_util.c | 2 | ||||
-rw-r--r-- | source4/rpc_server/epmapper/rpc_epmapper.c | 2 | ||||
-rw-r--r-- | source4/rpc_server/handles.c | 4 | ||||
-rw-r--r-- | source4/torture/rpc/oxidresolve.c | 2 | ||||
-rw-r--r-- | source4/torture/rpc/remact.c | 2 | ||||
-rw-r--r-- | source4/torture/rpc/testjoin.c | 2 |
13 files changed, 158 insertions, 161 deletions
diff --git a/source4/lib/basic.mk b/source4/lib/basic.mk index 1f790a8ca2..e4275bea49 100644 --- a/source4/lib/basic.mk +++ b/source4/lib/basic.mk @@ -51,7 +51,6 @@ ADD_OBJ_FILES = \ lib/wins_srv.o \ lib/util_str.o \ lib/util_strlist.o \ - lib/util_uuid.o \ lib/util_unistr.o \ lib/util_file.o \ lib/data_blob.o \ diff --git a/source4/lib/dcom/common/main.c b/source4/lib/dcom/common/main.c index 3730137268..61fd7d3ff7 100644 --- a/source4/lib/dcom/common/main.c +++ b/source4/lib/dcom/common/main.c @@ -162,7 +162,7 @@ static WERROR dcom_create_object_remote(struct dcom_context *ctx, struct GUID *c ZERO_STRUCT(r.in); r.in.this.version.MajorVersion = COM_MAJOR_VERSION; r.in.this.version.MinorVersion = COM_MINOR_VERSION; - uuid_generate_random(&r.in.this.cid); + r.in.this.cid = GUID_random(); r.in.Clsid = *clsid; r.in.ClientImpLevel = RPC_C_IMP_LEVEL_IDENTIFY; r.in.num_protseqs = ARRAY_SIZE(protseq); @@ -279,7 +279,7 @@ WERROR dcom_get_class_object_remote(struct dcom_context *ctx, struct GUID *clsid ZERO_STRUCT(r.in); r.in.this.version.MajorVersion = COM_MAJOR_VERSION; r.in.this.version.MinorVersion = COM_MINOR_VERSION; - uuid_generate_random(&r.in.this.cid); + r.in.this.cid = GUID_random(); r.in.Clsid = *clsid; r.in.ClientImpLevel = RPC_C_IMP_LEVEL_IDENTIFY; r.in.num_protseqs = ARRAY_SIZE(protseq); @@ -355,7 +355,7 @@ NTSTATUS dcom_get_pipe (struct dcom_interface_p *iface, struct dcerpc_pipe **p) iid = iface->interface->iid; if (iface->ox->pipe) { - if (!uuid_equal(&iface->ox->pipe->syntax.uuid, &iid)) { + if (!GUID_equal(&iface->ox->pipe->syntax.uuid, &iid)) { iface->ox->pipe->syntax.uuid = iid; status = dcerpc_alter(iface->ox->pipe, iface->ctx); if (NT_STATUS_IS_ERR(status)) { @@ -538,7 +538,7 @@ struct dcom_interface_p *dcom_new_local_ifacep(struct dcom_context *ctx, const s ip->ctx = ctx; ip->interface = iface; ip->vtable = vtable; - uuid_generate_random(&ip->ipid); + ip->ipid = GUID_random(); ip->object = object; ip->objref_flags = 0; ip->orpc_flags = 0; diff --git a/source4/lib/dcom/common/tables.c b/source4/lib/dcom/common/tables.c index f615662b47..6b0d99cae3 100644 --- a/source4/lib/dcom/common/tables.c +++ b/source4/lib/dcom/common/tables.c @@ -37,7 +37,7 @@ const struct dcom_interface *dcom_interface_by_iid(const struct GUID *iid) while(l) { - if (uuid_equal(iid, &l->interface.iid)) + if (GUID_equal(iid, &l->interface.iid)) return &l->interface; l = l->next; @@ -52,7 +52,7 @@ const struct dcom_class *dcom_class_by_clsid(const struct GUID *clsid) while(c) { - if (uuid_equal(clsid, &c->class.clsid)) { + if (GUID_equal(clsid, &c->class.clsid)) { return &c->class; } diff --git a/source4/lib/util_uuid.c b/source4/lib/util_uuid.c deleted file mode 100644 index a11b7bd3ed..0000000000 --- a/source4/lib/util_uuid.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * UUID server routines - * Copyright (C) Theodore Ts'o 1996, 1997, - * Copyright (C) Jim McDonough 2002. - * Copyright (C) Andrew Tridgell 2003. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "includes.h" - -void uuid_generate_random(struct GUID *out) -{ - generate_random_buffer((unsigned char *)out, sizeof(struct GUID)); - out->clock_seq[0] = (out->clock_seq[0] & 0x3F) | 0x80; - out->time_hi_and_version = (out->time_hi_and_version & 0x0FFF) | 0x4000; -} - -BOOL uuid_all_zero(const struct GUID *u) -{ - if (u->time_low != 0 || - u->time_mid != 0 || - u->time_hi_and_version != 0 || - u->clock_seq[0] != 0 || - u->clock_seq[1] != 0 || - !all_zero(u->node, 6)) { - return False; - } - return True; -} - -BOOL uuid_equal(const struct GUID *u1, const struct GUID *u2) -{ - if (u1->time_low != u2->time_low || - u1->time_mid != u2->time_mid || - u1->time_hi_and_version != u2->time_hi_and_version || - u1->clock_seq[0] != u2->clock_seq[0] || - u1->clock_seq[1] != u2->clock_seq[1] || - memcmp(u1->node, u2->node, 6) != 0) { - return False; - } - return True; -} - -BOOL policy_handle_empty(struct policy_handle *h) -{ - return (h->handle_type == 0 && uuid_all_zero(&h->uuid)); -} - diff --git a/source4/librpc/config.mk b/source4/librpc/config.mk index bfc5749abe..6eaa04ffc8 100644 --- a/source4/librpc/config.mk +++ b/source4/librpc/config.mk @@ -4,7 +4,8 @@ INIT_OBJ_FILES = \ librpc/ndr/ndr.o ADD_OBJ_FILES = \ - librpc/ndr/ndr_basic.o + librpc/ndr/ndr_basic.o \ + librpc/ndr/ndr_misc.o REQUIRED_SUBSYSTEMS = LIBCLI_UTILS # End SUBSYSTEM LIBNDR_RAW ################################################ diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index f26c40e7b7..b790b03aa9 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -1183,90 +1183,6 @@ void ndr_print_array_uint8(struct ndr_print *ndr, const char *name, ndr->depth--; } -/* - build a GUID from a string -*/ -NTSTATUS GUID_from_string(const char *s, struct GUID *guid) -{ - NTSTATUS status = NT_STATUS_INVALID_PARAMETER; - uint32_t time_low; - uint32_t time_mid, time_hi_and_version; - uint32_t clock_seq[2]; - uint32_t node[6]; - int i; - - if (11 == sscanf(s, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", - &time_low, &time_mid, &time_hi_and_version, - &clock_seq[0], &clock_seq[1], - &node[0], &node[1], &node[2], &node[3], &node[4], &node[5])) { - status = NT_STATUS_OK; - } else if (11 == sscanf(s, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", - &time_low, &time_mid, &time_hi_and_version, - &clock_seq[0], &clock_seq[1], - &node[0], &node[1], &node[2], &node[3], &node[4], &node[5])) { - status = NT_STATUS_OK; - } - - if (!NT_STATUS_IS_OK(status)) { - return status; - } - - guid->time_low = time_low; - guid->time_mid = time_mid; - guid->time_hi_and_version = time_hi_and_version; - guid->clock_seq[0] = clock_seq[0]; - guid->clock_seq[1] = clock_seq[1]; - for (i=0;i<6;i++) { - guid->node[i] = node[i]; - } - - return NT_STATUS_OK; -} - -/* generate a random GUID */ -struct GUID GUID_random(void) -{ - struct GUID guid; - - generate_random_buffer((uint8_t *)&guid, sizeof(guid)); - - return guid; -} - -/* - its useful to be able to display these in debugging messages -*/ -char *GUID_string(TALLOC_CTX *mem_ctx, const struct GUID *guid) -{ - return talloc_asprintf(mem_ctx, - "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", - guid->time_low, guid->time_mid, - guid->time_hi_and_version, - guid->clock_seq[0], - guid->clock_seq[1], - guid->node[0], guid->node[1], - guid->node[2], guid->node[3], - guid->node[4], guid->node[5]); -} - -char *GUID_string2(TALLOC_CTX *mem_ctx, const struct GUID *guid) -{ - return talloc_asprintf(mem_ctx, - "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", - guid->time_low, guid->time_mid, - guid->time_hi_and_version, - guid->clock_seq[0], - guid->clock_seq[1], - guid->node[0], guid->node[1], - guid->node[2], guid->node[3], - guid->node[4], guid->node[5]); -} - -void ndr_print_GUID(struct ndr_print *ndr, const char *name, const struct GUID *guid) -{ - ndr->print(ndr, "%-25s: %s", name, GUID_string(ndr, guid)); -} - void ndr_print_DATA_BLOB(struct ndr_print *ndr, const char *name, DATA_BLOB r) { ndr->print(ndr, "%-25s: DATA_BLOB length=%u", name, r.length); diff --git a/source4/librpc/ndr/ndr_misc.c b/source4/librpc/ndr/ndr_misc.c new file mode 100644 index 0000000000..0b5954d7f9 --- /dev/null +++ b/source4/librpc/ndr/ndr_misc.c @@ -0,0 +1,143 @@ +/* + Unix SMB/CIFS implementation. + + UUID/GUID/policy_handle functions + + Copyright (C) Theodore Ts'o 1996, 1997, + Copyright (C) Jim McDonough 2002. + Copyright (C) Andrew Tridgell 2003. + Copyright (C) Stefan (metze) Metzmacher 2004. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +/* + build a GUID from a string +*/ +NTSTATUS GUID_from_string(const char *s, struct GUID *guid) +{ + NTSTATUS status = NT_STATUS_INVALID_PARAMETER; + uint32_t time_low; + uint32_t time_mid, time_hi_and_version; + uint32_t clock_seq[2]; + uint32_t node[6]; + int i; + + if (11 == sscanf(s, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + &time_low, &time_mid, &time_hi_and_version, + &clock_seq[0], &clock_seq[1], + &node[0], &node[1], &node[2], &node[3], &node[4], &node[5])) { + status = NT_STATUS_OK; + } else if (11 == sscanf(s, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", + &time_low, &time_mid, &time_hi_and_version, + &clock_seq[0], &clock_seq[1], + &node[0], &node[1], &node[2], &node[3], &node[4], &node[5])) { + status = NT_STATUS_OK; + } + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + guid->time_low = time_low; + guid->time_mid = time_mid; + guid->time_hi_and_version = time_hi_and_version; + guid->clock_seq[0] = clock_seq[0]; + guid->clock_seq[1] = clock_seq[1]; + for (i=0;i<6;i++) { + guid->node[i] = node[i]; + } + + return NT_STATUS_OK; +} + +/* generate a random GUID */ +struct GUID GUID_random(void) +{ + struct GUID guid; + + generate_random_buffer((uint8_t *)&guid, sizeof(guid)); + guid.clock_seq[0] = (guid.clock_seq[0] & 0x3F) | 0x80; + guid.time_hi_and_version = (guid.time_hi_and_version & 0x0FFF) | 0x4000; + + return guid; +} + +BOOL GUID_all_zero(const struct GUID *u) +{ + if (u->time_low != 0 || + u->time_mid != 0 || + u->time_hi_and_version != 0 || + u->clock_seq[0] != 0 || + u->clock_seq[1] != 0 || + !all_zero(u->node, 6)) { + return False; + } + return True; +} + +BOOL GUID_equal(const struct GUID *u1, const struct GUID *u2) +{ + if (u1->time_low != u2->time_low || + u1->time_mid != u2->time_mid || + u1->time_hi_and_version != u2->time_hi_and_version || + u1->clock_seq[0] != u2->clock_seq[0] || + u1->clock_seq[1] != u2->clock_seq[1] || + memcmp(u1->node, u2->node, 6) != 0) { + return False; + } + return True; +} + +/* + its useful to be able to display these in debugging messages +*/ +char *GUID_string(TALLOC_CTX *mem_ctx, const struct GUID *guid) +{ + return talloc_asprintf(mem_ctx, + "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + guid->time_low, guid->time_mid, + guid->time_hi_and_version, + guid->clock_seq[0], + guid->clock_seq[1], + guid->node[0], guid->node[1], + guid->node[2], guid->node[3], + guid->node[4], guid->node[5]); +} + +char *GUID_string2(TALLOC_CTX *mem_ctx, const struct GUID *guid) +{ + return talloc_asprintf(mem_ctx, + "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", + guid->time_low, guid->time_mid, + guid->time_hi_and_version, + guid->clock_seq[0], + guid->clock_seq[1], + guid->node[0], guid->node[1], + guid->node[2], guid->node[3], + guid->node[4], guid->node[5]); +} + +void ndr_print_GUID(struct ndr_print *ndr, const char *name, const struct GUID *guid) +{ + ndr->print(ndr, "%-25s: %s", name, GUID_string(ndr, guid)); +} + +BOOL policy_handle_empty(struct policy_handle *h) +{ + return (h->handle_type == 0 && GUID_all_zero(&h->uuid)); +} diff --git a/source4/librpc/rpc/dcerpc_util.c b/source4/librpc/rpc/dcerpc_util.c index c53e879802..b77c365858 100644 --- a/source4/librpc/rpc/dcerpc_util.c +++ b/source4/librpc/rpc/dcerpc_util.c @@ -202,7 +202,7 @@ const char *dcerpc_binding_string(TALLOC_CTX *mem_ctx, const struct dcerpc_bindi return NULL; } - if (!uuid_all_zero(&b->object)) { + if (!GUID_all_zero(&b->object)) { s = talloc_asprintf(s, "%s@", GUID_string(mem_ctx, &b->object)); } diff --git a/source4/rpc_server/epmapper/rpc_epmapper.c b/source4/rpc_server/epmapper/rpc_epmapper.c index 6d96850917..8f4450c2ef 100644 --- a/source4/rpc_server/epmapper/rpc_epmapper.c +++ b/source4/rpc_server/epmapper/rpc_epmapper.c @@ -227,7 +227,7 @@ static error_status_t epm_Map(struct dcesrv_call_state *dce_call, TALLOC_CTX *me for (i=0;i<count;i++) { struct epm_tower t; - if (!uuid_equal(&floors[0].lhs.info.uuid.uuid, &eps[i].ep_description.object) || + if (!GUID_equal(&floors[0].lhs.info.uuid.uuid, &eps[i].ep_description.object) || floors[0].lhs.info.uuid.version != eps[i].ep_description.object_version) { continue; } diff --git a/source4/rpc_server/handles.c b/source4/rpc_server/handles.c index 34ed42799f..41169aa25d 100644 --- a/source4/rpc_server/handles.c +++ b/source4/rpc_server/handles.c @@ -40,7 +40,7 @@ struct dcesrv_handle *dcesrv_handle_new(struct dcesrv_connection *dce_conn, h->destroy = NULL; h->wire_handle.handle_type = handle_type; - uuid_generate_random(&h->wire_handle.uuid); + h->wire_handle.uuid = GUID_random(); DLIST_ADD(dce_conn->handles, h); @@ -77,7 +77,7 @@ struct dcesrv_handle *dcesrv_handle_fetch(struct dcesrv_connection *dce_conn, for (h=dce_conn->handles; h; h=h->next) { if (h->wire_handle.handle_type == p->handle_type && - uuid_equal(&p->uuid, &h->wire_handle.uuid)) { + GUID_equal(&p->uuid, &h->wire_handle.uuid)) { if (handle_type != DCESRV_HANDLE_ANY && p->handle_type != handle_type) { DEBUG(0,("client gave us the wrong handle type (%d should be %d)\n", diff --git a/source4/torture/rpc/oxidresolve.c b/source4/torture/rpc/oxidresolve.c index 18cda418d0..cbd287b453 100644 --- a/source4/torture/rpc/oxidresolve.c +++ b/source4/torture/rpc/oxidresolve.c @@ -38,7 +38,7 @@ static int test_RemoteActivation(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, HYP ZERO_STRUCT(r.in); r.in.this.version.MajorVersion = 5; r.in.this.version.MinorVersion = 1; - uuid_generate_random(&r.in.this.cid); + r.in.this.cid = GUID_random(); GUID_from_string(CLSID_SIMPLE, &r.in.Clsid); r.in.ClientImpLevel = RPC_C_IMP_LEVEL_IDENTIFY; r.in.num_protseqs = 3; diff --git a/source4/torture/rpc/remact.c b/source4/torture/rpc/remact.c index 2e09f84da6..897dd78255 100644 --- a/source4/torture/rpc/remact.c +++ b/source4/torture/rpc/remact.c @@ -37,7 +37,7 @@ static int test_RemoteActivation(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) ZERO_STRUCT(r.in); r.in.this.version.MajorVersion = 5; r.in.this.version.MinorVersion = 1; - uuid_generate_random(&r.in.this.cid); + r.in.this.cid = GUID_random(); GUID_from_string(CLSID_SIMPLE, &r.in.Clsid); r.in.ClientImpLevel = RPC_C_IMP_LEVEL_IDENTIFY; r.in.num_protseqs = 3; diff --git a/source4/torture/rpc/testjoin.c b/source4/torture/rpc/testjoin.c index 2568f16323..9636b27932 100644 --- a/source4/torture/rpc/testjoin.c +++ b/source4/torture/rpc/testjoin.c @@ -259,7 +259,7 @@ void torture_leave_domain(struct test_join *join) struct samr_DeleteUser d; NTSTATUS status; - if (!uuid_all_zero(&join->user_handle.uuid)) { + if (!GUID_all_zero(&join->user_handle.uuid)) { d.in.user_handle = &join->user_handle; d.out.user_handle = &join->user_handle; |