/*
* This file and its contents are supplied under the terms of the
* Common Development and Distribution License ("CDDL"), version 1.0.
* You may only use this file in accordance with the terms of version
* 1.0 of the CDDL.
*
* A full copy of the text of the CDDL should have accompanied this
* source. A copy of the CDDL is also available via the Internet at
*/
/*
* Copyright 2014 Nexenta Systems, Inc. All rights reserved.
*/
/*
* Dispatch function for SMB2_SESSION_SETUP
*
* Note that the Capabilities supplied in this request are an inferior
* subset of those given to us previously in the SMB2 Negotiate request.
* We need to remember the full set of capabilities from SMB2 Negotiate,
* and therefore ignore the subset of capabilities supplied here.
*/
#include <smbsrv/smb2_kproto.h>
static void smb2_ss_adjust_credits(smb_request_t *);
{
int skip;
int rc = 0;
&StructureSize, /* w */
&Flags, /* b */
&SecurityMode, /* b */
&Capabilities, /* l */
&Channel, /* l */
&SecBufOffset, /* w */
&SecBufLength, /* w */
&PrevSessionId); /* q */
if (rc)
return (SDRC_ERROR);
/*
* We're normally positioned at the security buffer now,
* but there could be some padding before it.
*/
if (skip < 0)
return (SDRC_ERROR);
if (skip > 0)
/*
* Get the security buffer
*/
if (rc)
return (SDRC_ERROR);
/*
* The real auth. work happens in here.
*/
SessionFlags = 0;
switch (status) {
case NT_STATUS_SUCCESS: /* Authenticated */
break;
/*
* This is not really an error, but tells the client
* it should send another session setup request.
* Not smb2_put_error because we send a payload.
*/
break;
default:
SecBufLength = 0;
break;
}
/*
* SMB2 Session Setup reply
*/
"wwww#c",
9, /* StructSize */ /* w */
SessionFlags, /* w */
SecBufOffset, /* w */
SecBufLength, /* w */
SecBufLength, /* # */
if (rc)
return (SDRC_ERROR);
return (SDRC_SUCCESS);
}
/*
* After a successful authentication, raise s_max_credits up to the
* normal maximum that clients are allowed to request. Also, if we
* haven't yet given them their initial credits, do that now.
*
* Normally, clients will request some credits with session setup,
* but in case they don't request enough to raise s_cur_credits
* up to the configured initial_credits, increase the requested
* credits of this SR sufficiently to make that happen. The actual
* increase happens in the dispatch code after we return.
*/
static void
{
mutex_enter(&s->s_credits_mutex);
/* How many credits we want to grant with this SR. */
/*
* Do we need to increase the smb2_credit_request?
* One might prefer to read this expression as:
* ((credit_request - credit_charge) < grant)
* but we know credit_charge == 1 and would rather not
* deal with a possibly negative value on the left,
* so adding credit_charge to both sides...
*/
}
}
mutex_exit(&s->s_credits_mutex);
}