4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
26 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
30 * A few excerpts from lib/smbsrv/libmlsvc
31 * See longer comment in srvsvc1.ndl
34 #include <sys/errno.h>
40 #include <libmlrpc/libmlrpc.h>
41 #include "srvsvc1_clnt.h"
43 static ndr_service_t srvsvc_service
= {
45 "Server services", /* desc */
46 "\\srvsvc", /* endpoint */
47 "\\PIPE\\ntsvcs", /* sec_addr_port */
48 "4b324fc8-1670-01d3-1278-5a47bf6ee188", 3, /* abstract */
49 NDR_TRANSFER_SYNTAX_UUID
, 2, /* transfer */
50 0, /* no bind_instance_size */
51 0, /* no bind_req() */
52 0, /* no unbind_and_close() */
53 0, /* use generic_call_stub() */
54 &TYPEINFO(srvsvc_interface
), /* interface_ti */
61 * This function registers the SRVSVC RPC interface with the RPC runtime
62 * library. It must be called in order to use either the client side
63 * or the server side functions.
66 srvsvc1_initialize(void)
72 (void) ndr_svc_register(&srvsvc_service
);
76 * Client-side stub for NetServerGetInfo
79 srvsvc_net_server_getinfo(mlrpc_handle_t
*handle
, char *server
,
80 int level
, union mslm_NetServerGetInfo_ru
*resp
)
82 struct mslm_NetServerGetInfo arg
;
85 opnum
= SRVSVC_OPNUM_NetServerGetInfo
;
86 bzero(&arg
, sizeof (arg
));
88 len
= strlen(server
) + 4;
89 arg
.servername
= ndr_rpc_malloc(handle
, len
);
90 if (arg
.servername
== NULL
)
93 (void) snprintf((char *)arg
.servername
, len
, "\\\\%s", server
);
96 rc
= ndr_rpc_call(handle
, opnum
, &arg
);
97 if ((rc
!= 0) || (arg
.status
!= 0))
100 *resp
= arg
.result
.ru
;
105 * Client-side stub for NetShareEnum
108 srvsvc_net_share_enum(mlrpc_handle_t
*handle
, char *server
,
109 int level
, union mslm_NetShareEnum_ru
*resp
)
111 /* Any enum result type is OK for nres. */
112 struct mslm_NetShareInfo_0_result nres
;
113 struct mslm_NetShareEnum arg
;
116 opnum
= SRVSVC_OPNUM_NetShareEnum
;
117 bzero(&nres
, sizeof (nres
));
118 bzero(&arg
, sizeof (arg
));
120 len
= strlen(server
) + 4;
121 arg
.servername
= ndr_rpc_malloc(handle
, len
);
122 if (arg
.servername
== NULL
)
125 (void) snprintf((char *)arg
.servername
, len
, "\\\\%s", server
);
127 arg
.result
.level
= level
;
128 arg
.result
.ru
.bufptr0
= &nres
;
129 arg
.prefmaxlen
= 0xFFFFFFFF;
130 arg
.resume_handle
= NULL
;
132 rc
= ndr_rpc_call(handle
, opnum
, &arg
);
133 if ((rc
!= 0) || (arg
.status
!= 0))
136 *resp
= arg
.result
.ru
;