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]
22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
25 * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
29 * This file was originally generated using rpcgen.
35 #include <smbsrv/wintypes.h>
36 #include <smbsrv/smb_sid.h>
37 #include <smbsrv/smb_xdr.h>
38 #include <smbsrv/smb_token.h>
40 static bool_t
smb_privset_xdr(XDR
*, smb_privset_t
*);
41 static bool_t
smb_sid_xdr(XDR
*, smb_sid_t
*);
44 smb_privset_helper_xdr(XDR
*xdrs
, char **privs
)
51 if (xdrs
->x_op
== XDR_DECODE
) {
52 pos
= xdr_getpos(xdrs
);
54 if (!xdr_bool(xdrs
, &rc
))
57 if (!xdr_uint32_t(xdrs
, &cnt
))
60 rc
= xdr_setpos(xdrs
, pos
);
68 p
= (smb_privset_t
*)(uintptr_t)*privs
;
72 len
= sizeof (smb_privset_t
)
73 - sizeof (smb_luid_attrs_t
)
74 + (cnt
* sizeof (smb_luid_attrs_t
));
76 if (!xdr_pointer(xdrs
, privs
, len
, (xdrproc_t
)smb_privset_xdr
))
83 smb_id_xdr(XDR
*xdrs
, smb_id_t
*objp
)
87 if ((xdrs
->x_op
== XDR_ENCODE
) || (xdrs
->x_op
== XDR_FREE
))
88 len
= smb_sid_len(objp
->i_sid
);
90 if (!xdr_uint32_t(xdrs
, &objp
->i_attrs
))
93 if (!xdr_uint8_t(xdrs
, &len
))
96 if (!xdr_pointer(xdrs
, (char **)&objp
->i_sid
, len
,
97 (xdrproc_t
)smb_sid_xdr
))
100 if (!xdr_uint32_t(xdrs
, (uint32_t *)&objp
->i_id
))
107 smb_ids_xdr(XDR
*xdrs
, smb_ids_t
*objp
)
109 if (!xdr_array(xdrs
, (char **)&objp
->i_ids
, (uint32_t *)&objp
->i_cnt
,
110 ~0, sizeof (smb_id_t
), (xdrproc_t
)smb_id_xdr
))
117 smb_posix_grps_xdr(XDR
*xdrs
, smb_posix_grps_t
*objp
)
119 if (!xdr_uint32_t(xdrs
, &objp
->pg_ngrps
))
121 if (!xdr_vector(xdrs
, (char *)objp
->pg_grps
, objp
->pg_ngrps
,
122 sizeof (uint32_t), (xdrproc_t
)xdr_uint32_t
))
128 smb_posix_grps_helper_xdr(XDR
*xdrs
, char **identity
)
134 if (xdrs
->x_op
== XDR_DECODE
) {
135 pos
= xdr_getpos(xdrs
);
137 if (!xdr_bool(xdrs
, &rc
))
140 if (!xdr_uint32_t(xdrs
, &cnt
))
143 rc
= xdr_setpos(xdrs
, pos
);
147 if (*identity
== NULL
)
149 cnt
= ((smb_posix_grps_t
*)(uintptr_t)*identity
)->pg_ngrps
;
152 len
= SMB_POSIX_GRPS_SIZE(cnt
);
154 if (!xdr_pointer(xdrs
, identity
, len
, (xdrproc_t
)smb_posix_grps_xdr
))
160 smb_logon_xdr(XDR
*xdrs
, smb_logon_t
*objp
)
162 if (!xdr_uint16_t(xdrs
, &objp
->lg_level
))
164 if (!xdr_string(xdrs
, &objp
->lg_username
, ~0))
166 if (!xdr_string(xdrs
, &objp
->lg_domain
, ~0))
168 if (!xdr_string(xdrs
, &objp
->lg_e_username
, ~0))
170 if (!xdr_string(xdrs
, &objp
->lg_e_domain
, ~0))
172 if (!xdr_string(xdrs
, &objp
->lg_workstation
, ~0))
174 if (!smb_inaddr_xdr(xdrs
, &objp
->lg_clnt_ipaddr
))
176 if (!smb_inaddr_xdr(xdrs
, &objp
->lg_local_ipaddr
))
178 if (!xdr_uint16_t(xdrs
, &objp
->lg_local_port
))
180 if (!smb_buf32_xdr(xdrs
, &objp
->lg_challenge_key
))
182 if (!smb_buf32_xdr(xdrs
, &objp
->lg_nt_password
))
184 if (!smb_buf32_xdr(xdrs
, &objp
->lg_lm_password
))
186 if (!xdr_uint32_t(xdrs
, &objp
->lg_ntlm_flags
))
188 if (!xdr_int(xdrs
, &objp
->lg_native_os
))
190 if (!xdr_int(xdrs
, &objp
->lg_native_lm
))
192 if (!xdr_uint32_t(xdrs
, &objp
->lg_flags
))
194 if (!xdr_uint32_t(xdrs
, &objp
->lg_logon_id
))
196 if (!xdr_uint32_t(xdrs
, &objp
->lg_domain_type
))
198 if (!xdr_uint32_t(xdrs
, &objp
->lg_secmode
))
200 if (!xdr_uint32_t(xdrs
, &objp
->lg_status
))
206 smb_sid_xdr(XDR
*xdrs
, smb_sid_t
*objp
)
208 if (!xdr_uint8_t(xdrs
, &objp
->sid_revision
))
210 if (!xdr_uint8_t(xdrs
, &objp
->sid_subauthcnt
))
212 if (!xdr_vector(xdrs
, (char *)objp
->sid_authority
, NT_SID_AUTH_MAX
,
213 sizeof (uint8_t), (xdrproc_t
)xdr_uint8_t
))
215 if (!xdr_vector(xdrs
, (char *)objp
->sid_subauth
, objp
->sid_subauthcnt
,
216 sizeof (uint32_t), (xdrproc_t
)xdr_uint32_t
))
222 smb_luid_xdr(XDR
*xdrs
, smb_luid_t
*objp
)
224 if (!xdr_uint32_t(xdrs
, &objp
->lo_part
))
226 if (!xdr_uint32_t(xdrs
, &objp
->hi_part
))
232 smb_luid_attrs_xdr(XDR
*xdrs
, smb_luid_attrs_t
*objp
)
234 if (!smb_luid_xdr(xdrs
, &objp
->luid
))
236 if (!xdr_uint32_t(xdrs
, &objp
->attrs
))
242 smb_privset_xdr(XDR
*xdrs
, smb_privset_t
*objp
)
244 if (!xdr_uint32_t(xdrs
, &objp
->priv_cnt
))
246 if (!xdr_uint32_t(xdrs
, &objp
->control
))
248 if (!xdr_vector(xdrs
, (char *)objp
->priv
, objp
->priv_cnt
,
249 sizeof (smb_luid_attrs_t
),
250 (xdrproc_t
)smb_luid_attrs_xdr
))
256 smb_token_xdr(XDR
*xdrs
, smb_token_t
*objp
)
258 if (!smb_id_xdr(xdrs
, &objp
->tkn_user
))
260 if (!smb_id_xdr(xdrs
, &objp
->tkn_owner
))
262 if (!smb_id_xdr(xdrs
, &objp
->tkn_primary_grp
))
264 if (!smb_ids_xdr(xdrs
, &objp
->tkn_win_grps
))
266 if (!smb_privset_helper_xdr(xdrs
, (char **)&objp
->tkn_privileges
))
268 if (!xdr_string(xdrs
, &objp
->tkn_account_name
, ~0))
270 if (!xdr_string(xdrs
, &objp
->tkn_domain_name
, ~0))
272 if (!xdr_uint32_t(xdrs
, &objp
->tkn_flags
))
274 if (!xdr_uint32_t(xdrs
, &objp
->tkn_audit_sid
))
276 if (!smb_buf32_xdr(xdrs
, &objp
->tkn_ssnkey
))
278 if (!smb_posix_grps_helper_xdr(xdrs
, (char **)&objp
->tkn_posix_grps
))