3328 smbutil view does't work with Win2008 and later
[unleashed.git] / usr / src / cmd / fs.d / smbclnt / smbutil / srvsvc1_clnt.c
blob7ebe614ab6e82358b69bac2e75027afa102a673a
1 /*
2 * CDDL HEADER START
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]
19 * CDDL HEADER END
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>
35 #include <stdio.h>
36 #include <time.h>
37 #include <strings.h>
38 #include <time.h>
40 #include <libmlrpc/libmlrpc.h>
41 #include "srvsvc1_clnt.h"
43 static ndr_service_t srvsvc_service = {
44 "SRVSVC", /* name */
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 */
55 NULL /* stub_table */
59 * srvsvc_initialize
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.
65 void
66 srvsvc1_initialize(void)
68 static int init_done;
69 if (init_done)
70 return;
71 init_done = 1;
72 (void) ndr_svc_register(&srvsvc_service);
76 * Client-side stub for NetServerGetInfo
78 int
79 srvsvc_net_server_getinfo(mlrpc_handle_t *handle, char *server,
80 int level, union mslm_NetServerGetInfo_ru *resp)
82 struct mslm_NetServerGetInfo arg;
83 int len, opnum, rc;
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)
91 return (ENOMEM);
93 (void) snprintf((char *)arg.servername, len, "\\\\%s", server);
94 arg.level = level;
96 rc = ndr_rpc_call(handle, opnum, &arg);
97 if ((rc != 0) || (arg.status != 0))
98 return (EIO);
100 *resp = arg.result.ru;
101 return (0);
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;
114 int len, opnum, rc;
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)
123 return (ENOMEM);
125 (void) snprintf((char *)arg.servername, len, "\\\\%s", server);
126 arg.level = level;
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))
134 return (EIO);
136 *resp = arg.result.ru;
137 return (0);