From 5e7cf194d2d25787e3af807a3a37f570ce5298dc Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 7 Sep 2011 19:07:51 +0200 Subject: smbXcli: split out a smb1cli_req_flags() function metze --- libcli/smb/smbXcli_base.c | 81 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 55 insertions(+), 26 deletions(-) (limited to 'libcli/smb/smbXcli_base.c') diff --git a/libcli/smb/smbXcli_base.c b/libcli/smb/smbXcli_base.c index ed5f5a5776..22bd34175e 100644 --- a/libcli/smb/smbXcli_base.c +++ b/libcli/smb/smbXcli_base.c @@ -737,6 +737,52 @@ static uint8_t *smbXcli_iov_concat(TALLOC_CTX *mem_ctx, return buf; } +static void smb1cli_req_flags(enum protocol_types protocol, + uint32_t smb1_capabilities, + uint8_t smb_command, + uint8_t additional_flags, + uint8_t clear_flags, + uint8_t *_flags, + uint16_t additional_flags2, + uint16_t clear_flags2, + uint16_t *_flags2) +{ + uint8_t flags = 0; + uint16_t flags2 = 0; + + if (protocol >= PROTOCOL_LANMAN1) { + flags |= FLAG_CASELESS_PATHNAMES; + flags |= FLAG_CANONICAL_PATHNAMES; + } + + if (protocol >= PROTOCOL_LANMAN2) { + flags2 |= FLAGS2_LONG_PATH_COMPONENTS; + flags2 |= FLAGS2_EXTENDED_ATTRIBUTES; + } + + if (protocol >= PROTOCOL_NT1) { + flags2 |= FLAGS2_IS_LONG_NAME; + + if (smb1_capabilities & CAP_UNICODE) { + flags2 |= FLAGS2_UNICODE_STRINGS; + } + if (smb1_capabilities & CAP_STATUS32) { + flags2 |= FLAGS2_32_BIT_ERROR_CODES; + } + if (smb1_capabilities & CAP_EXTENDED_SECURITY) { + flags2 |= FLAGS2_EXTENDED_SECURITY; + } + } + + flags |= additional_flags; + flags &= ~clear_flags; + flags2 |= additional_flags2; + flags2 &= ~clear_flags2; + + *_flags = flags; + *_flags2 = flags2; +} + struct tevent_req *smb1cli_req_create(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct smbXcli_conn *conn, @@ -773,32 +819,15 @@ struct tevent_req *smb1cli_req_create(TALLOC_CTX *mem_ctx, state->ev = ev; state->conn = conn; - if (conn->protocol >= PROTOCOL_LANMAN1) { - flags |= FLAG_CASELESS_PATHNAMES; - flags |= FLAG_CANONICAL_PATHNAMES; - } - - if (conn->protocol >= PROTOCOL_LANMAN2) { - flags2 |= FLAGS2_LONG_PATH_COMPONENTS; - flags2 |= FLAGS2_EXTENDED_ATTRIBUTES; - } - - if (conn->protocol >= PROTOCOL_NT1) { - if (conn->smb1.capabilities & CAP_UNICODE) { - flags2 |= FLAGS2_UNICODE_STRINGS; - } - if (conn->smb1.capabilities & CAP_STATUS32) { - flags2 |= FLAGS2_32_BIT_ERROR_CODES; - } - if (conn->smb1.capabilities & CAP_EXTENDED_SECURITY) { - flags2 |= FLAGS2_EXTENDED_SECURITY; - } - } - - flags |= additional_flags; - flags &= ~clear_flags; - flags2 |= additional_flags2; - flags2 &= ~clear_flags2; + smb1cli_req_flags(conn->protocol, + conn->smb1.capabilities, + smb_command, + additional_flags, + clear_flags, + &flags, + additional_flags2, + clear_flags2, + &flags2); SIVAL(state->smb1.hdr, 0, SMB_MAGIC); SCVAL(state->smb1.hdr, HDR_COM, smb_command); -- cgit