summaryrefslogtreecommitdiff
path: root/source4/rpc_server
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-12-27 16:47:09 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:47:49 -0500
commite748b53e4343fbac00a19e8fc76b42624eb5af02 (patch)
treebd19a3baa052d404af9452f53ab90ba26244fad2 /source4/rpc_server
parentd658de65d32e6746ac51aeb4da7aa74b3da40c2b (diff)
downloadsamba-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)
Diffstat (limited to 'source4/rpc_server')
-rw-r--r--source4/rpc_server/dcerpc_server.c34
-rw-r--r--source4/rpc_server/epmapper/rpc_epmapper.c16
2 files changed, 16 insertions, 34 deletions
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;
}