#ifndef _NT_DOMAIN_H /* _NT_DOMAIN_H */
#define _NT_DOMAIN_H
+struct uuid
+{
+ uint32 time_low;
+ uint16 time_mid;
+ uint16 time_hi_and_version;
+ uint8 clock_seq[2];
+ uint8 node[6];
+};
+#define UUID_SIZE 16
+
+#define UUID_FLAT_SIZE 16
+typedef struct uuid_flat
+{
+ uint8 info[UUID_FLAT_SIZE];
+} UUID_FLAT;
+
/* dce/rpc support */
#include "rpc_dce.h"
/* #define MAX_PDU_FRAG_LEN 0x1630 this is what wnt sets */
#define MAX_PDU_FRAG_LEN 0x10b8 /* this is what w2k sets */
-/*
- * Actual structure of a DCE UUID
- */
-
-typedef struct rpc_uuid
-{
- uint32 time_low;
- uint16 time_mid;
- uint16 time_hi_and_version;
- uint8 remaining[8];
-} RPC_UUID;
-
-#define RPC_UUID_LEN 16
-
/* RPC_IFACE */
typedef struct rpc_iface_info
{
- RPC_UUID uuid; /* 16 bytes of rpc interface identification */
+ struct uuid uuid; /* 16 bytes of rpc interface identification */
uint32 version; /* the interface version number */
} RPC_IFACE;
-#define RPC_IFACE_LEN (RPC_UUID_LEN + 4)
+#define RPC_IFACE_LEN (UUID_SIZE + 4)
struct pipe_id_info
{
uint32 dnsname_ptr;
uint32 forestname_ptr;
- GUID domain_guid;
+ struct uuid domain_guid;
UNISTR2 netbios_domain;
uint32 trust_type;
uint32 trust_attributes;
uint32 sid_ptr;
- GUID guid;
+ struct uuid guid;
UNISTR2 netbios_domain;
UNISTR2 dns_domain;
uint16 length;
uint8 protocol;
struct {
- RPC_UUID uuid;
+ struct uuid uuid;
uint16 version;
} uuid;
} lhs;
return s;
}
-
-/*****************************************************************
- Print a GUID structure for debugging.
-*****************************************************************/
-
-void print_guid(GUID *guid)
-{
- int i;
-
- d_printf("%08x-%04x-%04x",
- IVAL(guid->info, 0), SVAL(guid->info, 4), SVAL(guid->info, 6));
- d_printf("-%02x%02x-", guid->info[8], guid->info[9]);
- for (i=10;i<GUID_SIZE;i++)
- d_printf("%02x", guid->info[i]);
- d_printf("\n");
-}
-
/*******************************************************************
Tallocs a duplicate SID.
********************************************************************/
#define TIME_OFFSET_HIGH 0x01B21DD2
#define TIME_OFFSET_LOW 0x13814000
-struct uuid {
- uint32 time_low;
- uint16 time_mid;
- uint16 time_hi_and_version;
- uint8 clock_seq[2];
- uint8 node[6];
-};
-
-
-static void uuid_pack(const struct uuid *uu, GUID *ptr)
+void smb_uuid_pack(const struct uuid *uu, UUID_FLAT *ptr)
{
- uint8 *out = ptr->info;
+ SIVAL(ptr, 0, uu->time_low);
+ SSVAL(ptr, 4, uu->time_mid);
+ SSVAL(ptr, 6, uu->time_hi_and_version);
+ memcpy(ptr+8, uu->clock_seq, 2);
+ memcpy(ptr+10, uu->node, 6);
+}
- SIVAL(out, 0, uu->time_low);
- SSVAL(out, 4, uu->time_mid);
- SSVAL(out, 6, uu->time_hi_and_version);
- memcpy(out+8, uu->clock_seq, 2);
- memcpy(out+10, uu->node, 6);
+void smb_uuid_unpack(const UUID_FLAT in, struct uuid *uu)
+{
+ uu->time_low = IVAL(in.info, 0);
+ uu->time_mid = SVAL(in.info, 4);
+ uu->time_hi_and_version = SVAL(in.info, 6);
+ memcpy(uu->clock_seq, in.info+8, 2);
+ memcpy(uu->node, in.info+10, 6);
}
-static void uuid_unpack(const GUID in, struct uuid *uu)
+const struct uuid smb_uuid_unpack_static(const UUID_FLAT in)
{
- const uint8 *ptr = in.info;
+ static struct uuid uu;
- uu->time_low = IVAL(ptr, 0);
- uu->time_mid = SVAL(ptr, 4);
- uu->time_hi_and_version = SVAL(ptr, 6);
- memcpy(uu->clock_seq, ptr+8, 2);
- memcpy(uu->node, ptr+10, 6);
+ smb_uuid_unpack(in, &uu);
+ return uu;
}
-void smb_uuid_generate_random(GUID *out)
+void smb_uuid_generate_random(struct uuid *uu)
{
- GUID tmp;
- struct uuid uu;
+ UUID_FLAT tmp;
generate_random_buffer(tmp.info, sizeof(tmp.info), True);
- uuid_unpack(tmp, &uu);
+ smb_uuid_unpack(tmp, uu);
- uu.clock_seq[0] = (uu.clock_seq[0] & 0x3F) | 0x80;
- uu.time_hi_and_version = (uu.time_hi_and_version & 0x0FFF) | 0x4000;
- uuid_pack(&uu, out);
+ uu->clock_seq[0] = (uu->clock_seq[0] & 0x3F) | 0x80;
+ uu->time_hi_and_version = (uu->time_hi_and_version & 0x0FFF) | 0x4000;
}
-char *smb_uuid_to_string(const GUID in)
+char *smb_uuid_to_string(const struct uuid uu)
{
- struct uuid uu;
char *out;
- uuid_unpack(in, &uu);
-
asprintf(&out, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
uu.time_low, uu.time_mid, uu.time_hi_and_version,
uu.clock_seq[0], uu.clock_seq[1],
return out;
}
-const char *smb_uuid_string_static(const GUID in)
+const char *smb_uuid_string_static(const struct uuid uu)
{
- struct uuid uu;
static char out[37];
- uuid_unpack(in, &uu);
- slprintf(out, sizeof(out) -1,
+ slprintf(out, sizeof(out),
"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
uu.time_low, uu.time_mid, uu.time_hi_and_version,
uu.clock_seq[0], uu.clock_seq[1],
}
}
-struct uuid {
- uint32 i1;
- uint16 i2;
- uint16 i3;
- uint8 s[8];
-};
-
static void dump_guid(const char *field, struct berval **values)
{
int i;
- GUID guid;
+ UUID_FLAT guid;
for (i=0; values[i]; i++) {
memcpy(guid.info, values[i]->bv_val, sizeof(guid.info));
- printf("%s: %s\n", field, smb_uuid_string_static(guid));
+ printf("%s: %s\n", field,
+ smb_uuid_string_static(smb_uuid_unpack_static(guid)));
}
}
return True;
}
-BOOL secrets_store_domain_guid(const char *domain, GUID *guid)
+BOOL secrets_store_domain_guid(const char *domain, struct uuid *guid)
{
fstring key;
slprintf(key, sizeof(key)-1, "%s/%s", SECRETS_DOMAIN_GUID, domain);
strupper_m(key);
- return secrets_store(key, guid, sizeof(GUID));
+ return secrets_store(key, guid, sizeof(struct uuid));
}
-BOOL secrets_fetch_domain_guid(const char *domain, GUID *guid)
+BOOL secrets_fetch_domain_guid(const char *domain, struct uuid *guid)
{
- GUID *dyn_guid;
+ struct uuid *dyn_guid;
fstring key;
size_t size;
- GUID new_guid;
+ struct uuid new_guid;
slprintf(key, sizeof(key)-1, "%s/%s", SECRETS_DOMAIN_GUID, domain);
strupper_m(key);
- dyn_guid = (GUID *)secrets_fetch(key, &size);
+ dyn_guid = (struct uuid *)secrets_fetch(key, &size);
- DEBUG(6,("key is %s, size is %d\n", key, (int)size));
-
- if ((NULL == dyn_guid) && (ROLE_DOMAIN_PDC == lp_server_role())) {
+ if ((!dyn_guid) && (lp_server_role() == ROLE_DOMAIN_PDC)) {
smb_uuid_generate_random(&new_guid);
if (!secrets_store_domain_guid(domain, &new_guid))
return False;
- dyn_guid = (GUID *)secrets_fetch(key, &size);
+ dyn_guid = (struct uuid *)secrets_fetch(key, &size);
if (dyn_guid == NULL)
return False;
}
- if (size != sizeof(GUID))
+ if (size != sizeof(struct uuid))
{
+ DEBUG(1,("UUID size %d is wrong!\n", (int)size));
SAFE_FREE(dyn_guid);
return False;
}
return False;
if ( !prs_uint32("forestname_ptr", ps, depth, &p->forestname_ptr) )
return False;
-
- if ( !prs_uint8s(False, "domain_guid", ps, depth, p->domain_guid.info, GUID_SIZE) )
+
+ if ( !smb_io_uuid("domain_guid", &p->domain_guid, ps, depth) )
return False;
if ( !smb_io_unistr2( "netbios_domain", &p->netbios_domain, p->netbios_ptr, ps, depth) )
if ( !prs_uint32( "sid_ptr", ps, depth, &trust->sid_ptr ) )
return False;
- if ( !prs_uint8s(False, "guid", ps, depth, trust->guid.info, GUID_SIZE) )
+ if ( !smb_io_uuid("guid", &trust->guid, ps, depth) )
return False;
return True;
inits an EPM_FLOOR structure with a UUID
********************************************************************/
NTSTATUS init_epm_floor_uuid(EPM_FLOOR *floor,
- const RPC_UUID *uuid, uint16 version)
+ const struct uuid uuid, uint16 version)
{
- memcpy(&floor->lhs.uuid.uuid, uuid, sizeof(*uuid));
+ memcpy(&floor->lhs.uuid.uuid, &uuid, sizeof(uuid));
floor->lhs.uuid.version = version;
floor->rhs.unknown = 0;
return init_epm_floor(floor, EPM_FLOOR_UUID);
switch (floor->lhs.protocol) {
case EPM_FLOOR_UUID:
- if (!smb_io_rpc_uuid("uuid", &floor->lhs.uuid.uuid, ps, depth))
+ if (!smb_io_uuid("uuid", &floor->lhs.uuid.uuid, ps, depth))
return False;
if (!prs_uint16("version", ps, depth,
&floor->lhs.uuid.version))
{ \
{ \
0x8a885d04, 0x1ceb, 0x11c9, \
- { 0x9f, 0xe8, 0x08, 0x00, \
- 0x2b, 0x10, 0x48, 0x60 } \
+ { 0x9f, 0xe8 }, \
+ { 0x08, 0x00, \
+ 0x2b, 0x10, 0x48, 0x60 } \
}, 0x02 \
}
{ \
{ \
0x8a885d04, 0x1ceb, 0x11c9, \
- { 0x9f, 0xe8, 0x08, 0x00, \
- 0x2b, 0x10, 0x48, 0x60 } \
+ { 0x9f, 0xe8 }, \
+ { 0x08, 0x00, \
+ 0x2b, 0x10, 0x48, 0x60 } \
}, 0x02 \
}
{ \
{ \
0x6bffd098, 0xa112, 0x3610, \
- { 0x98, 0x33, 0x46, 0xc3, \
- 0xf8, 0x7e, 0x34, 0x5a } \
+ { 0x98, 0x33 }, \
+ { 0x46, 0xc3, \
+ 0xf8, 0x7e, 0x34, 0x5a } \
}, 0x01 \
}
{ \
{ \
0x4b324fc8, 0x1670, 0x01d3, \
- { 0x12, 0x78, 0x5a, 0x47, \
- 0xbf, 0x6e, 0xe1, 0x88 } \
+ { 0x12, 0x78 }, \
+ { 0x5a, 0x47, \
+ 0xbf, 0x6e, 0xe1, 0x88 } \
}, 0x03 \
}
{ \
{ \
0x12345778, 0x1234, 0xabcd, \
- { 0xef, 0x00, 0x01, 0x23, \
- 0x45, 0x67, 0x89, 0xab } \
+ { 0xef, 0x00 }, \
+ { 0x01, 0x23, \
+ 0x45, 0x67, 0x89, 0xab } \
}, 0x00 \
}
{ \
{ \
0x3919286a, 0xb10c, 0x11d0, \
- { 0x9b, 0xa8, 0x00, 0xc0, \
- 0x4f, 0xd9, 0x2e, 0xf5 } \
+ { 0x9b, 0xa8 }, \
+ { 0x00, 0xc0, \
+ 0x4f, 0xd9, 0x2e, 0xf5 } \
}, 0x00 \
}
{ \
{ \
0x12345778, 0x1234, 0xabcd, \
- { 0xef, 0x00, 0x01, 0x23, \
- 0x45, 0x67, 0x89, 0xac } \
+ { 0xef, 0x00 }, \
+ { 0x01, 0x23, \
+ 0x45, 0x67, 0x89, 0xac } \
}, 0x01 \
}
{ \
{ \
0x12345678, 0x1234, 0xabcd, \
- { 0xef, 0x00, 0x01, 0x23, \
- 0x45, 0x67, 0xcf, 0xfb } \
+ { 0xef, 0x00 }, \
+ { 0x01, 0x23, \
+ 0x45, 0x67, 0xcf, 0xfb } \
}, 0x01 \
}
{ \
{ \
0x338cd001, 0x2244, 0x31f1, \
- { 0xaa, 0xaa, 0x90, 0x00, \
- 0x38, 0x00, 0x10, 0x03 } \
+ { 0xaa, 0xaa }, \
+ { 0x90, 0x00, \
+ 0x38, 0x00, 0x10, 0x03 } \
}, 0x01 \
}
{ \
{ \
0x12345678, 0x1234, 0xabcd, \
- { 0xef, 0x00, 0x01, 0x23, \
- 0x45, 0x67, 0x89, 0xab } \
+ { 0xef, 0x00 }, \
+ { 0x01, 0x23, \
+ 0x45, 0x67, 0x89, 0xab } \
}, 0x01 \
}
{ \
{ \
0x0, 0x0, 0x0, \
- { 0x00, 0x00, 0x00, 0x00, \
- 0x00, 0x00, 0x00, 0x00 } \
+ { 0x00, 0x00 }, \
+ { 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00 } \
}, 0x00 \
}
{ \
{ \
0x4fc742e0, 0x4a10, 0x11cf, \
- { 0x82, 0x73, 0x00, 0xaa, \
+ { 0x82, 0x73 }, \
+ { 0x00, 0xaa, \
0x00, 0x4a, 0xe6, 0x73 } \
}, 0x03 \
}
{ \
{ \
0x60a15ec5, 0x4de8, 0x11d7, \
- { 0xa6, 0x37, 0x00, 0x50, \
+ { 0xa6, 0x37 }, \
+ { 0x00, 0x50, \
0x56, 0xa2, 0x01, 0x82 } \
}, 0x01 \
}
{ \
{ \
0x894de0c0, 0x0d55, 0x11d3, \
- { 0xa3, 0x22, 0x00, 0xc0, \
+ { 0xa3, 0x22 }, \
+ { 0x00, 0xc0, \
0x4f, 0xa3, 0x21, 0xa1 } \
}, 0x01 \
}
{ \
{ \
0xe1af8308, 0x5d1f, 0x11c9, \
- { 0x91, 0xa4, 0x08, 0x00, \
- 0x2b, 0x14, 0xa0, 0xfa } \
+ { 0x91, 0xa4 }, \
+ { 0x08, 0x00, \
+ 0x2b, 0x14, 0xa0, 0xfa } \
}, 0x03 \
}
}
/*******************************************************************
- Reads or writes an RPC_UUID structure.
+ Reads or writes a struct uuid
********************************************************************/
-BOOL smb_io_rpc_uuid(const char *desc, RPC_UUID *uuid, prs_struct *ps, int depth)
+BOOL smb_io_uuid(const char *desc, struct uuid *uuid,
+ prs_struct *ps, int depth)
{
if (uuid == NULL)
return False;
- prs_debug(ps, depth, desc, "smb_io_rpc_uuid");
+ prs_debug(ps, depth, desc, "smb_io_uuid");
depth++;
if(!prs_uint32 ("data ", ps, depth, &uuid->time_low))
if(!prs_uint16 ("data ", ps, depth, &uuid->time_hi_and_version))
return False;
- if(!prs_uint8s (False, "data ", ps, depth, uuid->remaining, sizeof(uuid->remaining)))
+ if(!prs_uint8s (False, "data ", ps, depth, uuid->clock_seq, sizeof(uuid->clock_seq)))
+ return False;
+ if(!prs_uint8s (False, "data ", ps, depth, uuid->node, sizeof(uuid->node)))
return False;
return True;
if (!prs_align(ps))
return False;
- if (!smb_io_rpc_uuid( "uuid", &ifc->uuid, ps, depth))
+ if (!smb_io_uuid( "uuid", &ifc->uuid, ps, depth))
return False;
if(!prs_uint32 ("version", ps, depth, &ifc->version))
switch (q_u->tower->floors[i].lhs.protocol) {
case EPM_FLOOR_UUID:
init_epm_floor_uuid(&floors[i],
- &q_u->tower->floors[i].
+ q_u->tower->floors[i].
lhs.uuid.uuid,
q_u->tower->floors[i].
lhs.uuid.version);
{
if ( strequal(pipe_names[i].client_pipe, pname)
&& (abstract->version == pipe_names[i].abstr_syntax.version)
- && (memcmp(&abstract->uuid, &pipe_names[i].abstr_syntax.uuid, sizeof(RPC_UUID)) == 0)
+ && (memcmp(&abstract->uuid, &pipe_names[i].abstr_syntax.uuid, sizeof(struct uuid)) == 0)
&& (transfer->version == pipe_names[i].trans_syntax.version)
- && (memcmp(&transfer->uuid, &pipe_names[i].trans_syntax.uuid, sizeof(RPC_UUID)) == 0) )
+ && (memcmp(&transfer->uuid, &pipe_names[i].trans_syntax.uuid, sizeof(struct uuid)) == 0) )
{
struct api_struct *fns = NULL;
int n_fns = 0;
static BOOL construct_printer_info_7(Printer_entry *print_hnd, PRINTER_INFO_7 *printer, int snum)
{
char *guid_str = NULL;
- GUID guid;
+ UUID_FLAT guid;
if (is_printer_published(print_hnd, snum, &guid)) {
- asprintf(&guid_str, "{%s}", smb_uuid_string_static(guid));
+ asprintf(&guid_str, "{%s}",
+ smb_uuid_string_static(smb_uuid_unpack_static(guid)));
strupper_m(guid_str);
init_unistr(&printer->guid, guid_str);
printer->action = SPOOL_DS_PUBLISH;
uint32 numtowers;
/* need to allow all this stuff to be passed in, but
for now, it demonstrates the call */
- RPC_UUID if_uuid = {0xe3514235, 0x4b06, 0x11d1, \
- { 0xab, 0x04, 0x00, 0xc0, \
- 0x4f, 0xc2, 0xdc, 0xd2 }},
- syn_uuid = {0x8a885d04, 0x1ceb, 0x11c9, \
- { 0x9f, 0xe8, 0x08, 0x00, \
- 0x2b, 0x10, 0x48, 0x60 }};
+ struct uuid if_uuid = {0xe3514235, 0x4b06, 0x11d1, \
+ { 0xab, 0x04 }, \
+ { 0x00, 0xc0, \
+ 0x4f, 0xc2, 0xdc, 0xd2 } },
+ syn_uuid = {0x8a885d04, 0x1ceb, 0x11c9, \
+ { 0x9f, 0xe8 }, \
+ { 0x08, 0x00, \
+ 0x2b, 0x10, 0x48, 0x60 } };
NTSTATUS result;
ZERO_STRUCT(handle);
numtowers = 1;
- init_epm_floor_uuid(&floors[0], &if_uuid, 4);
- init_epm_floor_uuid(&floors[1], &syn_uuid, 2);
+ init_epm_floor_uuid(&floors[0], if_uuid, 4);
+ init_epm_floor_uuid(&floors[1], syn_uuid, 2);
init_epm_floor_rpc(&floors[2]);
/* sample for netbios named pipe query
POLICY_HND pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
DOM_SID dom_sid;
- GUID dom_guid;
+ UUID_FLAT dom_guid;
fstring sid_str, domain_name="", dns_name="", forest_name="";
uint32 info_class = 3;
printf("forest name is %s\n", forest_name);
if (info_class == 12) {
- printf("domain GUID is ");
- print_guid(&dom_guid);
+ printf("domain GUID is %s\n",
+ smb_uuid_string_static(
+ smb_uuid_unpack_static(dom_guid)));
}
done:
return result;
struct cldap_netlogon_reply {
uint32 type;
uint32 flags;
- GUID guid;
+ UUID_FLAT guid;
char forest[MAX_DNS_LABEL];
char domain[MAX_DNS_LABEL];
reply->type = IVAL(p, 0); p += 4;
reply->flags = IVAL(p, 0); p += 4;
- memcpy(&reply->guid.info, p, GUID_SIZE);
- p += GUID_SIZE;
+ memcpy(&reply->guid.info, p, UUID_FLAT_SIZE);
+ p += UUID_FLAT_SIZE;
p += pull_netlogon_string(reply->forest, p, (const char *)os3.data);
p += pull_netlogon_string(reply->domain, p, (const char *)os3.data);
d_printf("0x%x\n", reply.type);
break;
}
- d_printf("GUID: ");
- print_guid(&reply.guid);
+ d_printf("GUID: %s\n",
+ smb_uuid_string_static(smb_uuid_unpack_static(reply.guid)));
d_printf("Flags:\n"
"\tIs a PDC: %s\n"
"\tIs a GC of the forest: %s\n"