diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2005-12-27 16:47:09 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:47:49 -0500 |
commit | e748b53e4343fbac00a19e8fc76b42624eb5af02 (patch) | |
tree | bd19a3baa052d404af9452f53ab90ba26244fad2 | |
parent | d658de65d32e6746ac51aeb4da7aa74b3da40c2b (diff) | |
download | samba-e748b53e4343fbac00a19e8fc76b42624eb5af02.tar.gz samba-e748b53e4343fbac00a19e8fc76b42624eb5af02.tar.bz2 samba-e748b53e4343fbac00a19e8fc76b42624eb5af02.zip |
r12513: Similar change as my previous commit, but now for transfer syntaxes.
Avoids converting a static string to GUID every time we check whether
a transfer syntax is equal to that of NDR.
(This used to be commit 8dcfcaf75ab8cf4a54cf5e56f6be25acc68e3989)
-rw-r--r-- | source4/build/smb_build/TODO | 2 | ||||
-rw-r--r-- | source4/librpc/idl/epmapper.idl | 6 | ||||
-rw-r--r-- | source4/librpc/ndr/libndr.h | 2 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr.c | 11 | ||||
-rw-r--r-- | source4/librpc/rpc/dcerpc.c | 7 | ||||
-rw-r--r-- | source4/librpc/rpc/dcerpc_util.c | 29 | ||||
-rw-r--r-- | source4/rpc_server/dcerpc_server.c | 34 | ||||
-rw-r--r-- | source4/rpc_server/epmapper/rpc_epmapper.c | 16 |
8 files changed, 43 insertions, 64 deletions
diff --git a/source4/build/smb_build/TODO b/source4/build/smb_build/TODO index fb58d6b29f..1c2e6c2f61 100644 --- a/source4/build/smb_build/TODO +++ b/source4/build/smb_build/TODO @@ -5,7 +5,7 @@ ldb.h belong in $INCLUDEDIR - add register function to smbtorture - init functions per shared library / binary - - gensec + - gensec, com - rpc/ndr ?? - list not automatically generated - utility function for 'init mutex' diff --git a/source4/librpc/idl/epmapper.idl b/source4/librpc/idl/epmapper.idl index af0bd2483d..223883c366 100644 --- a/source4/librpc/idl/epmapper.idl +++ b/source4/librpc/idl/epmapper.idl @@ -33,12 +33,6 @@ interface epmapper const int EPMAPPER_STATUS_OK = 0; - /* this guid indicates NDR encoding in a protocol tower */ - const string NDR_GUID = "8a885d04-1ceb-11c9-9fe8-08002b104860"; - const string NDR_GUID_VERSION = 2; - - const string NDR64_GUID = "71710533-beba-4937-8319-b5dbef9ccc36"; - const string NDR64_GUID_VERSION = 1; typedef [enum8bit] enum { diff --git a/source4/librpc/ndr/libndr.h b/source4/librpc/ndr/libndr.h index ca66078614..3d8bdf9f36 100644 --- a/source4/librpc/ndr/libndr.h +++ b/source4/librpc/ndr/libndr.h @@ -278,3 +278,5 @@ typedef NTSTATUS (*ndr_pull_flags_fn_t)(struct ndr_pull *, int ndr_flags, void * typedef void (*ndr_print_fn_t)(struct ndr_print *, const char *, const void *); typedef void (*ndr_print_function_t)(struct ndr_print *, const char *, int, const void *); +extern const struct dcerpc_syntax_id ndr_transfer_syntax; +extern const struct dcerpc_syntax_id ndr64_transfer_syntax; diff --git a/source4/librpc/ndr/ndr.c b/source4/librpc/ndr/ndr.c index 2e6fd5b432..260d445870 100644 --- a/source4/librpc/ndr/ndr.c +++ b/source4/librpc/ndr/ndr.c @@ -32,6 +32,17 @@ #define NDR_BASE_MARSHALL_SIZE 1024 +/* this guid indicates NDR encoding in a protocol tower */ +const struct dcerpc_syntax_id ndr_transfer_syntax = { + { 0x8a885d04, 0x1ceb, 0x11c9, {0x9f, 0xe8}, {0x08,0x00,0x2b,0x10,0x48,0x60} }, + 2 +}; + +const struct dcerpc_syntax_id ndr64_transfer_syntax = { + { 0x71710533, 0xbeba, 0x4937, {0x83, 0x19}, {0xb5,0xdb,0xef,0x9c,0xcc,0x36} }, + 1 +}; + /* work out the number of bytes needed to align on a n byte boundary */ diff --git a/source4/librpc/rpc/dcerpc.c b/source4/librpc/rpc/dcerpc.c index 10093cfcbb..14305c3449 100644 --- a/source4/librpc/rpc/dcerpc.c +++ b/source4/librpc/rpc/dcerpc.c @@ -794,15 +794,10 @@ NTSTATUS dcerpc_init_syntaxes(const struct dcerpc_interface_table *table, struct dcerpc_syntax_id *syntax, struct dcerpc_syntax_id *transfer_syntax) { - NTSTATUS status; - syntax->uuid = table->uuid; syntax->if_version = table->if_version; - status = GUID_from_string(NDR_GUID, &transfer_syntax->uuid); - if (!NT_STATUS_IS_OK(status)) return status; - - transfer_syntax->if_version = NDR_GUID_VERSION; + *transfer_syntax = ndr_transfer_syntax; return NT_STATUS_OK; } diff --git a/source4/librpc/rpc/dcerpc_util.c b/source4/librpc/rpc/dcerpc_util.c index 3a1e3c6cff..4e7550c701 100644 --- a/source4/librpc/rpc/dcerpc_util.c +++ b/source4/librpc/rpc/dcerpc_util.c @@ -221,12 +221,16 @@ const char *epm_floor_string(TALLOC_CTX *mem_ctx, struct epm_floor *epm_floor) /* lhs is used: UUID */ char *uuidstr; - uuidstr = GUID_string(mem_ctx, &uuid); - - if (strcasecmp(uuidstr, NDR_GUID) == 0) { + if (GUID_equal(&uuid, &ndr_transfer_syntax.uuid)) { return "NDR"; } + if (GUID_equal(&uuid, &ndr64_transfer_syntax.uuid)) { + return "NDR64"; + } + + uuidstr = GUID_string(mem_ctx, &uuid); + return talloc_asprintf(mem_ctx, " uuid %s/0x%02x", uuidstr, if_version); } else { /* IPX */ return talloc_asprintf(mem_ctx, "IPX:%s", @@ -497,7 +501,7 @@ NTSTATUS dcerpc_floor_get_lhs_data(struct epm_floor *epm_floor, struct GUID *uui return status; } -static DATA_BLOB dcerpc_floor_pack_lhs_data(TALLOC_CTX *mem_ctx, struct GUID *uuid, uint32_t if_version) +static DATA_BLOB dcerpc_floor_pack_lhs_data(TALLOC_CTX *mem_ctx, const struct GUID *uuid, uint32_t if_version) { struct ndr_push *ndr = ndr_push_init_ctx(mem_ctx); @@ -743,7 +747,6 @@ NTSTATUS dcerpc_binding_build_tower(TALLOC_CTX *mem_ctx, struct dcerpc_binding * { const enum epm_protocol *protseq = NULL; int num_protocols = -1, i; - struct GUID ndr_guid; NTSTATUS status; /* Find transport */ @@ -773,12 +776,9 @@ NTSTATUS dcerpc_binding_build_tower(TALLOC_CTX *mem_ctx, struct dcerpc_binding * /* Floor 1 */ tower->floors[1].lhs.protocol = EPM_PROTOCOL_UUID; - status = GUID_from_string(NDR_GUID, &ndr_guid); - if (NT_STATUS_IS_ERR(status)) { - return status; - } - - tower->floors[1].lhs.lhs_data = dcerpc_floor_pack_lhs_data(mem_ctx, &ndr_guid, NDR_GUID_VERSION); + tower->floors[1].lhs.lhs_data = dcerpc_floor_pack_lhs_data(mem_ctx, + &ndr_transfer_syntax.uuid, + ndr_transfer_syntax.if_version); tower->floors[1].rhs.uuid.unknown = data_blob_talloc_zero(mem_ctx, 2); @@ -1340,12 +1340,7 @@ NTSTATUS dcerpc_secondary_context(struct dcerpc_pipe *p, p2->syntax.uuid = table->uuid; p2->syntax.if_version = table->if_version; - status = GUID_from_string(NDR_GUID, &p2->transfer_syntax.uuid); - if (!NT_STATUS_IS_OK(status)) { - talloc_free(p2); - return status; - } - p2->transfer_syntax.if_version = NDR_GUID_VERSION; + p2->transfer_syntax = ndr_transfer_syntax; status = dcerpc_alter_context(p2, p2, &p2->syntax, &p2->transfer_syntax); if (!NT_STATUS_IS_OK(status)) { diff --git a/source4/rpc_server/dcerpc_server.c b/source4/rpc_server/dcerpc_server.c index facf6bc0af..927d88a4ec 100644 --- a/source4/rpc_server/dcerpc_server.c +++ b/source4/rpc_server/dcerpc_server.c @@ -447,9 +447,8 @@ static NTSTATUS dcesrv_bind_nak(struct dcesrv_call_state *call, uint32_t reason) */ static NTSTATUS dcesrv_bind(struct dcesrv_call_state *call) { - const char *transfer_syntax; uint32_t if_version, transfer_syntax_version; - struct GUID uuid; + struct GUID uuid, *transfer_syntax_uuid; struct ncacn_packet pkt; struct data_blob_list_item *rep; NTSTATUS status; @@ -473,13 +472,13 @@ static NTSTATUS dcesrv_bind(struct dcesrv_call_state *call) uuid = call->pkt.u.bind.ctx_list[0].abstract_syntax.uuid; transfer_syntax_version = call->pkt.u.bind.ctx_list[0].transfer_syntaxes[0].if_version; - transfer_syntax = GUID_string(call, - &call->pkt.u.bind.ctx_list[0].transfer_syntaxes[0].uuid); - if (!transfer_syntax || - strcasecmp(NDR_GUID, transfer_syntax) != 0 || - NDR_GUID_VERSION != transfer_syntax_version) { + transfer_syntax_uuid = &call->pkt.u.bind.ctx_list[0].transfer_syntaxes[0].uuid; + if (!GUID_equal(&ndr_transfer_syntax.uuid, transfer_syntax_uuid) != 0 || + ndr_transfer_syntax.if_version != transfer_syntax_version) { + char *uuid_str = GUID_string(call, transfer_syntax_uuid); /* we only do NDR encoded dcerpc */ - DEBUG(0,("Non NDR transfer syntax requested - %s\n", transfer_syntax)); + DEBUG(0,("Non NDR transfer syntax requested - %s\n", uuid_str)); + talloc_free(uuid_str); return dcesrv_bind_nak(call, 0); } @@ -542,8 +541,7 @@ static NTSTATUS dcesrv_bind(struct dcesrv_call_state *call) } pkt.u.bind_ack.ctx_list[0].result = result; pkt.u.bind_ack.ctx_list[0].reason = reason; - GUID_from_string(NDR_GUID, &pkt.u.bind_ack.ctx_list[0].syntax.uuid); - pkt.u.bind_ack.ctx_list[0].syntax.if_version = NDR_GUID_VERSION; + pkt.u.bind_ack.ctx_list[0].syntax = ndr_transfer_syntax; pkt.u.bind_ack.auth_info = data_blob(NULL, 0); if (!dcesrv_auth_bind_ack(call, &pkt)) { @@ -605,22 +603,19 @@ static NTSTATUS dcesrv_auth3(struct dcesrv_call_state *call) static NTSTATUS dcesrv_alter_new_context(struct dcesrv_call_state *call, uint32_t context_id) { uint32_t if_version, transfer_syntax_version; - const char *transfer_syntax; struct dcesrv_connection_context *context; const struct dcesrv_interface *iface; - struct GUID uuid; + struct GUID uuid, *transfer_syntax_uuid; if_version = call->pkt.u.alter.ctx_list[0].abstract_syntax.if_version; uuid = call->pkt.u.alter.ctx_list[0].abstract_syntax.uuid; transfer_syntax_version = call->pkt.u.alter.ctx_list[0].transfer_syntaxes[0].if_version; - transfer_syntax = GUID_string(call, - &call->pkt.u.alter.ctx_list[0].transfer_syntaxes[0].uuid); - if (!transfer_syntax || - strcasecmp(NDR_GUID, transfer_syntax) != 0 || - NDR_GUID_VERSION != transfer_syntax_version) { + transfer_syntax_uuid = &call->pkt.u.alter.ctx_list[0].transfer_syntaxes[0].uuid; + if (!GUID_equal(transfer_syntax_uuid, &ndr_transfer_syntax.uuid) || + ndr_transfer_syntax.if_version != transfer_syntax_version) { /* we only do NDR encoded dcerpc */ - return NT_STATUS_NO_MEMORY; + return NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED; } iface = find_interface_by_uuid(call->conn->endpoint, &uuid, if_version); @@ -694,8 +689,7 @@ static NTSTATUS dcesrv_alter(struct dcesrv_call_state *call) } pkt.u.alter_resp.ctx_list[0].result = result; pkt.u.alter_resp.ctx_list[0].reason = reason; - GUID_from_string(NDR_GUID, &pkt.u.alter_resp.ctx_list[0].syntax.uuid); - pkt.u.alter_resp.ctx_list[0].syntax.if_version = NDR_GUID_VERSION; + pkt.u.alter_resp.ctx_list[0].syntax = ndr_transfer_syntax; pkt.u.alter_resp.auth_info = data_blob(NULL, 0); pkt.u.alter_resp.secondary_address = ""; diff --git a/source4/rpc_server/epmapper/rpc_epmapper.c b/source4/rpc_server/epmapper/rpc_epmapper.c index e7371a632f..8ff4ffdf2d 100644 --- a/source4/rpc_server/epmapper/rpc_epmapper.c +++ b/source4/rpc_server/epmapper/rpc_epmapper.c @@ -38,18 +38,6 @@ struct dcesrv_ep_iface { }; /* - simple routine to compare a GUID string to a GUID structure -*/ -static int guid_cmp(TALLOC_CTX *mem_ctx, const struct GUID *guid, const char *uuid_str) -{ - const char *s = GUID_string(mem_ctx, guid); - if (!s || strcasecmp(s, uuid_str)) { - return -1; - } - return 0; -} - -/* build a list of all interfaces handled by all endpoint servers */ static uint32_t build_ep_list(TALLOC_CTX *mem_ctx, @@ -213,8 +201,8 @@ static error_status_t epm_Map(struct dcesrv_call_state *dce_call, TALLOC_CTX *me dcerpc_floor_get_lhs_data(&r->in.map_tower->tower.floors[1], &ndr_uuid, &ndr_version); if (floors[1].lhs.protocol != EPM_PROTOCOL_UUID || - guid_cmp(mem_ctx, &ndr_uuid, NDR_GUID) != 0 || - ndr_version != NDR_GUID_VERSION) { + !GUID_equal(&ndr_uuid, &ndr_transfer_syntax.uuid) || + ndr_version != ndr_transfer_syntax.if_version) { goto failed; } |