mlsvc_client.c revision b1352070d318187b41b088da3533692976f3f225
/*
* 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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Client NDR RPC interface.
*/
#include <strings.h>
#include <assert.h>
#include <smbsrv/libsmbrdr.h>
#include <smbsrv/libmlrpc.h>
#include <smbsrv/libmlsvc.h>
static void ndr_xa_release(ndr_client_t *);
/*
* This call must be made to initialize an RPC client structure and bind
* to the remote service before any RPCs can be exchanged with that service.
*
* The mlsvc_handle_t is a wrapper that is used to associate an RPC handle
* with the client context for an instance of the interface. The handle
* is zeroed to ensure that it doesn't look like a valid handle -
* handle content is provided by the remove service.
*
* The client points to this top-level handle so that we know when to
* unbind and teardown the connection. As each handle is initialized it
* will inherit a reference to the client context.
*/
int
{
int fid;
int rc;
return (-1);
return (-1);
return (-1);
if (fid < 0) {
return (-1);
}
return (-1);
}
if (NDR_DRC_IS_FAULT(rc)) {
(void) smbrdr_close_pipe(fid);
return (-1);
}
return (0);
}
/*
* Unbind and close the pipe to an RPC service.
*
* If the heap has been preserved we need to go through an xa release.
* The heap is preserved during an RPC call because that's where data
* returned from the server is stored.
*
* Otherwise we destroy the heap directly.
*/
void
{
if (clnt->heap_preserved)
else
}
/*
* Call the RPC function identified by opnum. The remote service is
* identified by the handle, which should have been initialized by
* ndr_rpc_bind.
*
* If the RPC call is successful (returns 0), the caller must call
* ndr_rpc_release to release the heap. Otherwise, we release the
* heap here.
*/
int
{
int rc;
return (-1);
if (NDR_DRC_IS_FAULT(rc)) {
return (-1);
}
return (0);
}
/*
* Returns the Native-OS of the RPC server.
*/
int
{
}
void *
{
return (NULL);
}
{
}
/*
* Must be called by RPC clients to free the heap after a successful RPC
* call, i.e. ndr_rpc_call returned 0. The caller should take a copy
* of any data returned by the RPC prior to calling this function because
* returned data is in the heap.
*/
void
{
if (clnt->heap_preserved)
else
}
/*
* Returns true if the handle is null.
* Otherwise returns false.
*/
{
static ndr_hdid_t zero_handle;
return (B_TRUE);
return (B_TRUE);
return (B_FALSE);
}
/*
* Returns true if the handle is the top level bind handle.
* Otherwise returns false.
*/
{
}
/*
* Pass the client reference from parent to child.
*/
void
{
}
void
{
char *name = "NDR RPC";
char *s = "unknown";
if (status == 0)
s = "success";
else if (NT_SC_IS_ERROR(status))
s = "error";
else if (NT_SC_IS_WARNING(status))
s = "warning";
else if (NT_SC_IS_INFO(status))
s = "info";
if (handle) {
}
smb_tracef("%s[0x%02x]: %s: %s (0x%08x)",
}
/*
* The following functions provide the client callback interface.
* If the caller hasn't provided a heap, create one here.
*/
static int
{
return (-1);
}
return (0);
}
/*
* This is the entry pointy for an RPC client call exchange with
* a server, which will result in an smbrdr SmbTransact request.
*
* SmbTransact should return the number of bytes received, which
* we record as the PDU size, or a negative error code.
*/
static int
{
int nbytes;
if (nbytes < 0) {
return (-1);
}
return (nbytes);
}
/*
* This entry point will be invoked if the xa-exchange response contained
* only the first fragment of a multi-fragment response. The RPC client
* code will then make repeated xa-read requests to obtain the remaining
* fragments, which will result in smbrdr SmbReadX requests.
*
* SmbReadX should return the number of bytes received, in which case we
* expand the PDU size to include the received data, or a negative error
* code.
*/
static int
{
int len;
int nbytes;
return (-1);
if (nbytes < 0)
return (-1);
return (-1);
}
return (nbytes);
}
/*
* Preserve the heap so that the client application has access to data
* returned from the server after an RPC call.
*/
static void
{
}
/*
* Dispose of the transaction streams. If the heap has not been
* preserved, we can destroy it here.
*/
static void
{
if (!clnt->heap_preserved) {
}
}
/*
* Dispose of a preserved heap.
*/
static void
{
if (clnt->heap_preserved) {
}
}