2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
13 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
17 * Share enumeration using Remote Procedure Call (RPC)
20 #include <sys/types.h>
27 #include <libmlrpc/libmlrpc.h>
28 #include <netsmb/smbfs_api.h>
29 #include "srvsvc1_clnt.h"
33 share_enum_rpc(struct smb_ctx
*ctx
, char *server
)
35 mlrpc_handle_t handle
;
37 union mslm_NetShareEnum_ru res
;
38 struct mslm_NetShareInfo_1
*nsi1
;
42 * Create an RPC handle using the smb_ctx we already have.
43 * Just local allocation and initialization.
46 svc
= ndr_svc_lookup_name("srvsvc");
50 err
= mlrpc_clh_create(&handle
, ctx
);
55 * Try to bind to the RPC service. If it fails,
56 * just return the error and the caller will
59 err
= mlrpc_clh_bind(&handle
, svc
);
63 err
= srvsvc_net_share_enum(&handle
, server
, 1, &res
);
67 /* Print the header line. */
68 view_print_share(NULL
, 0, NULL
);
70 /* Print the share list. */
71 count
= res
.bufptr1
->entriesread
;
72 i
= 0, nsi1
= res
.bufptr1
->entries
;
74 /* Convert UTF-8 to local code set? */
75 view_print_share((char *)nsi1
->shi1_netname
,
76 nsi1
->shi1_type
, (char *)nsi1
->shi1_comment
);
81 (void) mlrpc_clh_free(&handle
);