smb_winpipe.c revision 6537f381d2d9e7b4e2f7b29c3e7a3f13be036f2e
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Winpipe door interface to MSRPC services.
*/
#define START_UPDOOR_SIZE 16384
#define START_INPIPE_SIZE 16384
#include <smbsrv/smb_incl.h>
#include <sys/door_data.h>
#include <smbsrv/mlsvc_util.h>
static int smb_winpipe_door_id = -1;
static uint64_t smb_winpipe_ncall = 0;
static kmutex_t smb_winpipe_mutex;
static kcondvar_t smb_winpipe_cv;
static void smb_winpipe_ctx_free(smb_dr_user_ctx_t *);
void
smb_winpipe_init(void)
{
}
void
smb_winpipe_fini(void)
{
}
/*
* Open the winpipe (user space) door. If the door is already
* open, close it because the door-id has probably changed.
* Returns 0 on success. Otherwise -1 to indicate a lookup failure.
*/
int
smb_winpipe_open(int door_id)
{
smb_winpipe_ncall = 0;
if (smb_winpipe_dh == NULL) {
}
}
/*
* Close the winpipe (user space) door.
*/
void
smb_winpipe_close(void)
{
if (smb_winpipe_dh != NULL) {
while (smb_winpipe_ncall > 0)
}
}
/*
* Winpipe call interface: called by smb_rpc_transact and smb_rpc_read.
* Serialization and call reference accounting handled here.
*
* The sr will be null on a flush operation, which will result in ctx
* being null. A null ctx must be handled by smb_winpipe_upcall.
*/
int
{
unsigned char *lbuf;
smb_pipe_t *pp;
int rc;
if (smb_winpipe_dh == NULL) {
if (smb_winpipe_open(smb_winpipe_door_id) != 0)
return (-1);
}
if (rc == 0) {
switch (call_type) {
case SMB_RPC_TRANSACT:
case SMB_RPC_READ:
case SMB_RPC_FLUSH:
break;
default:
/*
* A write just queues the data and returns.
*/
break;
}
}
return (rc);
}
/*
* Door upcall wrapper - handles data marshalling.
* This function should only be called by smb_winpipe_call.
*/
static int
unsigned char *lbuf,
smb_pipe_t *pp,
{
int user_ctx_bytes;
int total_bytes = 0;
int cnt;
int bytes_off = 0;
/*
* copy the pipe hdr into flat buf, this contains the thread id,
* version and a couple of reserved fields for future expansion
*/
/*
* rpc_transact, rpc_read or rpc_write
*/
mdhin.md_reserved = 0;
/*
* Most of the marshalling isn't needed for flush.
* The pipe-id is needed to find the rpc_context and
* free the input and output pipes.
*/
if (call_type == SMB_RPC_FLUSH) {
total_bytes += sizeof (uint32_t);
} else {
if (user_ctx_selfrel == NULL) {
return (-1);
}
total_bytes += cnt;
/*
* based on uio stuff and smb_pipe_t size
* calculate size of buffer needed
*/
SMB_MAX_PIPENAMELEN, sizeof (uint32_t));
}
/* copy the pipe data len into flat buf */
/* we only want the least 4 significant bytes here */
total_bytes += sizeof (uint32_t);
total_bytes += sizeof (uint32_t);
}
return (-1);
}
/* RPC_WRITE just queues the data and returns */
return (0);
}
bytes_off = 0;
user_ctx_bytes = 0;
total_bytes += sizeof (uint32_t);
total_bytes += sizeof (uint32_t);
sizeof (uint32_t));
total_bytes += sizeof (uint32_t);
if (pp->sp_datalen > 0) {
}
return (0);
}
/*
* Allocate a user context structure and initialize it based on the
* specified SMB request data. Resources allocated here must be
* released using smb_winpipe_ctx_free.
*
* If sr is null, a null pointer is returned.
*/
static smb_dr_user_ctx_t *
{
return (NULL);
KM_SLEEP);
return (ctx);
}
/*
* Free resources associated with a user context structure.
*/
static void
{
return;
}
/*
* Convert a user context structure from absolute to self-relative format.
*
* On success, a pointer to an allocated XDR encoded buffer is returned,
* with the buffer size in ret_len. The caller is responsible for freeing
* this buffer when it is no longer required. If the return value is NULL,
* it is not valid to interpret ret_len.
*/
static uint8_t *
{
return (NULL);
}
len = 0;
}
xdr_destroy(&xdrs);
return (buf);
}