r3972: use GUID_* naming context and move GUID_* functions to one place
authorStefan Metzmacher <metze@samba.org>
Thu, 25 Nov 2004 20:03:46 +0000 (20:03 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:06:09 +0000 (13:06 -0500)
metze
(This used to be commit 523e6acf4fec5d4946fa7c0c89f40d7d712c9f3a)

13 files changed:
source4/lib/basic.mk
source4/lib/dcom/common/main.c
source4/lib/dcom/common/tables.c
source4/lib/util_uuid.c [deleted file]
source4/librpc/config.mk
source4/librpc/ndr/ndr_basic.c
source4/librpc/ndr/ndr_misc.c [new file with mode: 0644]
source4/librpc/rpc/dcerpc_util.c
source4/rpc_server/epmapper/rpc_epmapper.c
source4/rpc_server/handles.c
source4/torture/rpc/oxidresolve.c
source4/torture/rpc/remact.c
source4/torture/rpc/testjoin.c

index 1f790a8ca20870d1df7b3fcf2217cb0e364f2514..e4275bea49a55d9afeac3019b5c7d9e7612d153c 100644 (file)
@@ -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 \
index 373013726860927aca08d9d8936834f5bb9669ef..61fd7d3ff763d601899ded594b6e021a5cde0d2b 100644 (file)
@@ -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;
index f615662b47344021a8557e2a0bd9b2182975b17c..6b0d99cae3a2e7f930077bbfe559cf26c9914a81 100644 (file)
@@ -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 (file)
index a11b7bd..0000000
+++ /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));
-}
-
index bfc5749abe86e1a62758b36211f07582692ad0c3..6eaa04ffc8159defe3c86a85c75d0df1aa3c7562 100644 (file)
@@ -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
 ################################################
index f26c40e7b7c30eb1211d7abd81ce2359c91b57f6..b790b03aa915dfb9dee811a6234e9f0e0f929998 100644 (file)
@@ -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 (file)
index 0000000..0b5954d
--- /dev/null
@@ -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));
+}
index c53e87980243f1c7e4c389692765713bd699f885..b77c365858c19b787e9e4de06978725b9ab965f0 100644 (file)
@@ -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));
        }
index 6d96850917afb62a17ad8e2f1dde4c30585b11c7..8f4450c2ef02189ef32618247fbdb0a8a326169e 100644 (file)
@@ -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;
                }
index 34ed42799fb590a5cfe61f659a0a8e24bbec22b7..41169aa25dd36e57d4ada187b194c993bbbe6d02 100644 (file)
@@ -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",
index 18cda418d078a3da43611f7de40739fb5d67d81b..cbd287b45327cec49032fb78dc3a6b5bb3afdaf9 100644 (file)
@@ -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;
index 2e09f84da6e23cc76c650b8967815885ec8c1f74..897dd78255443150fd9d498344c114fc6b976e5e 100644 (file)
@@ -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;
index 2568f163234ca1b68cd5f23d571dd3a3165dbfa6..9636b279320ea43d4aef8cbdf4079c939615dbda 100644 (file)
@@ -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;