1da6c28aaSamw /*
2da6c28aaSamw * CDDL HEADER START
3da6c28aaSamw *
4da6c28aaSamw * The contents of this file are subject to the terms of the
5da6c28aaSamw * Common Development and Distribution License (the "License").
6da6c28aaSamw * You may not use this file except in compliance with the License.
7da6c28aaSamw *
8da6c28aaSamw * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9da6c28aaSamw * or http://www.opensolaris.org/os/licensing.
10da6c28aaSamw * See the License for the specific language governing permissions
11da6c28aaSamw * and limitations under the License.
12da6c28aaSamw *
13da6c28aaSamw * When distributing Covered Code, include this CDDL HEADER in each
14da6c28aaSamw * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15da6c28aaSamw * If applicable, add the following below this CDDL HEADER, with the
16da6c28aaSamw * fields enclosed by brackets "[]" replaced with your own identifying
17da6c28aaSamw * information: Portions Copyright [yyyy] [name of copyright owner]
18da6c28aaSamw *
19da6c28aaSamw * CDDL HEADER END
20da6c28aaSamw */
21da6c28aaSamw /*
229fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
23da6c28aaSamw * Use is subject to license terms.
24*12b65585SGordon Ross *
25*12b65585SGordon Ross * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
26da6c28aaSamw */
27da6c28aaSamw
28da6c28aaSamw /*
29da6c28aaSamw * This file was originally generated using rpcgen.
30da6c28aaSamw */
31da6c28aaSamw
32b819cea2SGordon Ross #if !defined(_KERNEL) && !defined(_FAKE_KERNEL)
33da6c28aaSamw #include <stdlib.h>
34da6c28aaSamw #endif /* !_KERNEL */
35da6c28aaSamw #include <smbsrv/wintypes.h>
366537f381Sas200622 #include <smbsrv/smb_sid.h>
37da6c28aaSamw #include <smbsrv/smb_xdr.h>
38da6c28aaSamw #include <smbsrv/smb_token.h>
39da6c28aaSamw
409fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static bool_t smb_privset_xdr(XDR *, smb_privset_t *);
419fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static bool_t smb_sid_xdr(XDR *, smb_sid_t *);
427f667e74Sjose borrego
436537f381Sas200622 static bool_t
smb_privset_helper_xdr(XDR * xdrs,char ** privs)449fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_privset_helper_xdr(XDR *xdrs, char **privs)
45da6c28aaSamw {
46da6c28aaSamw uint32_t pos, len;
47da6c28aaSamw uint32_t cnt;
48da6c28aaSamw bool_t rc;
49da6c28aaSamw smb_privset_t *p;
50da6c28aaSamw
51da6c28aaSamw if (xdrs->x_op == XDR_DECODE) {
52da6c28aaSamw pos = xdr_getpos(xdrs);
53da6c28aaSamw
54da6c28aaSamw if (!xdr_bool(xdrs, &rc))
55da6c28aaSamw return (FALSE);
56da6c28aaSamw
57da6c28aaSamw if (!xdr_uint32_t(xdrs, &cnt))
58da6c28aaSamw return (FALSE);
59da6c28aaSamw
60da6c28aaSamw rc = xdr_setpos(xdrs, pos);
61da6c28aaSamw
62da6c28aaSamw if (rc == FALSE)
63da6c28aaSamw return (FALSE);
64da6c28aaSamw } else {
65da6c28aaSamw if (*privs == NULL)
66da6c28aaSamw return (FALSE);
67da6c28aaSamw
68da6c28aaSamw p = (smb_privset_t *)(uintptr_t)*privs;
69da6c28aaSamw cnt = p->priv_cnt;
70da6c28aaSamw }
71da6c28aaSamw
72da6c28aaSamw len = sizeof (smb_privset_t)
73da6c28aaSamw - sizeof (smb_luid_attrs_t)
74da6c28aaSamw + (cnt * sizeof (smb_luid_attrs_t));
75da6c28aaSamw
769fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!xdr_pointer(xdrs, privs, len, (xdrproc_t)smb_privset_xdr))
77da6c28aaSamw return (FALSE);
78da6c28aaSamw
79da6c28aaSamw return (TRUE);
80da6c28aaSamw }
81da6c28aaSamw
827f667e74Sjose borrego static bool_t
smb_id_xdr(XDR * xdrs,smb_id_t * objp)839fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_id_xdr(XDR *xdrs, smb_id_t *objp)
84da6c28aaSamw {
857f667e74Sjose borrego uint8_t len;
867f667e74Sjose borrego
877f667e74Sjose borrego if ((xdrs->x_op == XDR_ENCODE) || (xdrs->x_op == XDR_FREE))
887f667e74Sjose borrego len = smb_sid_len(objp->i_sid);
897f667e74Sjose borrego
907f667e74Sjose borrego if (!xdr_uint32_t(xdrs, &objp->i_attrs))
91da6c28aaSamw return (FALSE);
927f667e74Sjose borrego
937f667e74Sjose borrego if (!xdr_uint8_t(xdrs, &len))
947f667e74Sjose borrego return (FALSE);
957f667e74Sjose borrego
967f667e74Sjose borrego if (!xdr_pointer(xdrs, (char **)&objp->i_sid, len,
979fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (xdrproc_t)smb_sid_xdr))
987f667e74Sjose borrego return (FALSE);
997f667e74Sjose borrego
100da6c28aaSamw if (!xdr_uint32_t(xdrs, (uint32_t *)&objp->i_id))
101da6c28aaSamw return (FALSE);
1027f667e74Sjose borrego
103da6c28aaSamw return (TRUE);
104da6c28aaSamw }
105da6c28aaSamw
1067f667e74Sjose borrego static bool_t
smb_ids_xdr(XDR * xdrs,smb_ids_t * objp)1079fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_ids_xdr(XDR *xdrs, smb_ids_t *objp)
108da6c28aaSamw {
1097f667e74Sjose borrego if (!xdr_array(xdrs, (char **)&objp->i_ids, (uint32_t *)&objp->i_cnt,
1109fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States ~0, sizeof (smb_id_t), (xdrproc_t)smb_id_xdr))
111da6c28aaSamw return (FALSE);
1127f667e74Sjose borrego
113da6c28aaSamw return (TRUE);
114da6c28aaSamw }
115da6c28aaSamw
1167f667e74Sjose borrego static bool_t
smb_posix_grps_xdr(XDR * xdrs,smb_posix_grps_t * objp)1179fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_posix_grps_xdr(XDR *xdrs, smb_posix_grps_t *objp)
118da6c28aaSamw {
119da6c28aaSamw if (!xdr_uint32_t(xdrs, &objp->pg_ngrps))
120da6c28aaSamw return (FALSE);
121da6c28aaSamw if (!xdr_vector(xdrs, (char *)objp->pg_grps, objp->pg_ngrps,
122da6c28aaSamw sizeof (uint32_t), (xdrproc_t)xdr_uint32_t))
123da6c28aaSamw return (FALSE);
124da6c28aaSamw return (TRUE);
125da6c28aaSamw }
126da6c28aaSamw
1277f667e74Sjose borrego static bool_t
smb_posix_grps_helper_xdr(XDR * xdrs,char ** identity)1289fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_posix_grps_helper_xdr(XDR *xdrs, char **identity)
129da6c28aaSamw {
130da6c28aaSamw uint32_t pos, len;
131da6c28aaSamw uint32_t cnt;
132da6c28aaSamw bool_t rc;
133da6c28aaSamw
134da6c28aaSamw if (xdrs->x_op == XDR_DECODE) {
135da6c28aaSamw pos = xdr_getpos(xdrs);
136da6c28aaSamw
137da6c28aaSamw if (!xdr_bool(xdrs, &rc))
138da6c28aaSamw return (FALSE);
139da6c28aaSamw
140da6c28aaSamw if (!xdr_uint32_t(xdrs, &cnt))
141da6c28aaSamw return (FALSE);
142da6c28aaSamw
143da6c28aaSamw rc = xdr_setpos(xdrs, pos);
144da6c28aaSamw if (rc == FALSE)
145da6c28aaSamw return (FALSE);
146da6c28aaSamw } else {
147da6c28aaSamw if (*identity == NULL)
148da6c28aaSamw return (FALSE);
149da6c28aaSamw cnt = ((smb_posix_grps_t *)(uintptr_t)*identity)->pg_ngrps;
150da6c28aaSamw }
151da6c28aaSamw
152da6c28aaSamw len = SMB_POSIX_GRPS_SIZE(cnt);
153da6c28aaSamw
1549fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!xdr_pointer(xdrs, identity, len, (xdrproc_t)smb_posix_grps_xdr))
155da6c28aaSamw return (FALSE);
156da6c28aaSamw return (TRUE);
157da6c28aaSamw }
158da6c28aaSamw
159da6c28aaSamw bool_t
smb_logon_xdr(XDR * xdrs,smb_logon_t * objp)1609fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_logon_xdr(XDR *xdrs, smb_logon_t *objp)
161da6c28aaSamw {
1629fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!xdr_uint16_t(xdrs, &objp->lg_level))
163da6c28aaSamw return (FALSE);
1649fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!xdr_string(xdrs, &objp->lg_username, ~0))
165da6c28aaSamw return (FALSE);
1669fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!xdr_string(xdrs, &objp->lg_domain, ~0))
167da6c28aaSamw return (FALSE);
1689fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!xdr_string(xdrs, &objp->lg_e_username, ~0))
1697f667e74Sjose borrego return (FALSE);
1709fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!xdr_string(xdrs, &objp->lg_e_domain, ~0))
1717f667e74Sjose borrego return (FALSE);
1729fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!xdr_string(xdrs, &objp->lg_workstation, ~0))
173da6c28aaSamw return (FALSE);
1749fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!smb_inaddr_xdr(xdrs, &objp->lg_clnt_ipaddr))
175da6c28aaSamw return (FALSE);
1769fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!smb_inaddr_xdr(xdrs, &objp->lg_local_ipaddr))
177da6c28aaSamw return (FALSE);
1789fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!xdr_uint16_t(xdrs, &objp->lg_local_port))
179da6c28aaSamw return (FALSE);
1809fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!smb_buf32_xdr(xdrs, &objp->lg_challenge_key))
181da6c28aaSamw return (FALSE);
1829fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!smb_buf32_xdr(xdrs, &objp->lg_nt_password))
183da6c28aaSamw return (FALSE);
1849fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!smb_buf32_xdr(xdrs, &objp->lg_lm_password))
185da6c28aaSamw return (FALSE);
186*12b65585SGordon Ross if (!xdr_uint32_t(xdrs, &objp->lg_ntlm_flags))
187*12b65585SGordon Ross return (FALSE);
1889fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!xdr_int(xdrs, &objp->lg_native_os))
189da6c28aaSamw return (FALSE);
1909fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!xdr_int(xdrs, &objp->lg_native_lm))
191da6c28aaSamw return (FALSE);
1929fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!xdr_uint32_t(xdrs, &objp->lg_flags))
1939fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (FALSE);
1949fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!xdr_uint32_t(xdrs, &objp->lg_logon_id))
1959fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (FALSE);
1969fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!xdr_uint32_t(xdrs, &objp->lg_domain_type))
1979fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (FALSE);
1989fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!xdr_uint32_t(xdrs, &objp->lg_secmode))
1999fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (FALSE);
2009fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!xdr_uint32_t(xdrs, &objp->lg_status))
201da6c28aaSamw return (FALSE);
202da6c28aaSamw return (TRUE);
203da6c28aaSamw }
204da6c28aaSamw
2057f667e74Sjose borrego static bool_t
smb_sid_xdr(XDR * xdrs,smb_sid_t * objp)2069fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_sid_xdr(XDR *xdrs, smb_sid_t *objp)
207da6c28aaSamw {
2086537f381Sas200622 if (!xdr_uint8_t(xdrs, &objp->sid_revision))
209da6c28aaSamw return (FALSE);
2106537f381Sas200622 if (!xdr_uint8_t(xdrs, &objp->sid_subauthcnt))
211da6c28aaSamw return (FALSE);
2126537f381Sas200622 if (!xdr_vector(xdrs, (char *)objp->sid_authority, NT_SID_AUTH_MAX,
213da6c28aaSamw sizeof (uint8_t), (xdrproc_t)xdr_uint8_t))
214da6c28aaSamw return (FALSE);
2156537f381Sas200622 if (!xdr_vector(xdrs, (char *)objp->sid_subauth, objp->sid_subauthcnt,
216da6c28aaSamw sizeof (uint32_t), (xdrproc_t)xdr_uint32_t))
217da6c28aaSamw return (FALSE);
218da6c28aaSamw return (TRUE);
219da6c28aaSamw }
220da6c28aaSamw
2217f667e74Sjose borrego static bool_t
smb_luid_xdr(XDR * xdrs,smb_luid_t * objp)2229fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_luid_xdr(XDR *xdrs, smb_luid_t *objp)
223da6c28aaSamw {
224da6c28aaSamw if (!xdr_uint32_t(xdrs, &objp->lo_part))
225da6c28aaSamw return (FALSE);
226da6c28aaSamw if (!xdr_uint32_t(xdrs, &objp->hi_part))
227da6c28aaSamw return (FALSE);
228da6c28aaSamw return (TRUE);
229da6c28aaSamw }
230da6c28aaSamw
2317f667e74Sjose borrego static bool_t
smb_luid_attrs_xdr(XDR * xdrs,smb_luid_attrs_t * objp)2329fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_luid_attrs_xdr(XDR *xdrs, smb_luid_attrs_t *objp)
233da6c28aaSamw {
2349fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!smb_luid_xdr(xdrs, &objp->luid))
235da6c28aaSamw return (FALSE);
236da6c28aaSamw if (!xdr_uint32_t(xdrs, &objp->attrs))
237da6c28aaSamw return (FALSE);
238da6c28aaSamw return (TRUE);
239da6c28aaSamw }
240da6c28aaSamw
2417f667e74Sjose borrego static bool_t
smb_privset_xdr(XDR * xdrs,smb_privset_t * objp)2429fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_privset_xdr(XDR *xdrs, smb_privset_t *objp)
243da6c28aaSamw {
244da6c28aaSamw if (!xdr_uint32_t(xdrs, &objp->priv_cnt))
245da6c28aaSamw return (FALSE);
246da6c28aaSamw if (!xdr_uint32_t(xdrs, &objp->control))
247da6c28aaSamw return (FALSE);
248da6c28aaSamw if (!xdr_vector(xdrs, (char *)objp->priv, objp->priv_cnt,
249da6c28aaSamw sizeof (smb_luid_attrs_t),
2509fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (xdrproc_t)smb_luid_attrs_xdr))
251da6c28aaSamw return (FALSE);
252da6c28aaSamw return (TRUE);
253da6c28aaSamw }
254da6c28aaSamw
255da6c28aaSamw bool_t
smb_token_xdr(XDR * xdrs,smb_token_t * objp)2569fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_token_xdr(XDR *xdrs, smb_token_t *objp)
257da6c28aaSamw {
2589fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!smb_id_xdr(xdrs, &objp->tkn_user))
259da6c28aaSamw return (FALSE);
2609fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!smb_id_xdr(xdrs, &objp->tkn_owner))
261da6c28aaSamw return (FALSE);
2629fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!smb_id_xdr(xdrs, &objp->tkn_primary_grp))
263da6c28aaSamw return (FALSE);
2649fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!smb_ids_xdr(xdrs, &objp->tkn_win_grps))
265da6c28aaSamw return (FALSE);
2669fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!smb_privset_helper_xdr(xdrs, (char **)&objp->tkn_privileges))
267da6c28aaSamw return (FALSE);
268da6c28aaSamw if (!xdr_string(xdrs, &objp->tkn_account_name, ~0))
269da6c28aaSamw return (FALSE);
270da6c28aaSamw if (!xdr_string(xdrs, &objp->tkn_domain_name, ~0))
271da6c28aaSamw return (FALSE);
272da6c28aaSamw if (!xdr_uint32_t(xdrs, &objp->tkn_flags))
273da6c28aaSamw return (FALSE);
274da6c28aaSamw if (!xdr_uint32_t(xdrs, &objp->tkn_audit_sid))
275da6c28aaSamw return (FALSE);
276*12b65585SGordon Ross if (!smb_buf32_xdr(xdrs, &objp->tkn_ssnkey))
277da6c28aaSamw return (FALSE);
2789fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!smb_posix_grps_helper_xdr(xdrs, (char **)&objp->tkn_posix_grps))
279da6c28aaSamw return (FALSE);
280da6c28aaSamw return (TRUE);
281da6c28aaSamw }
282