xref: /titanic_51/usr/src/common/smbsrv/smb_xdr.c (revision 05ead181677a01a3a118f8b89ce79361113e34cf)
1 /*
2  * CDDL HEADER START
3  *
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.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
23  */
24 
25 #include <sys/sunddi.h>
26 #ifndef _KERNEL
27 #include <string.h>
28 #include <strings.h>
29 #include <stddef.h>
30 #endif /* _KERNEL */
31 #include <smbsrv/smb_door.h>
32 #include <smbsrv/alloc.h>
33 #include <sys/socket.h>
34 #include <sys/sysmacros.h>
35 
36 #define	SMB_XDRMAX32_SZ		0xFFFFFFFF
37 
38 bool_t smb_list_xdr(XDR *, list_t *,  const size_t, const size_t,
39     const xdrproc_t);
40 
41 bool_t
42 smb_buf32_xdr(XDR *xdrs, smb_buf32_t *objp)
43 {
44 	uint_t	maxsize = SMB_XDRMAX32_SZ;
45 	uint_t	size;
46 
47 	if (xdrs->x_op != XDR_DECODE)
48 		maxsize = size = (uint_t)objp->len;
49 
50 	if (xdr_bytes(xdrs, (char **)&objp->val, &size, maxsize)) {
51 		if (xdrs->x_op == XDR_DECODE)
52 			objp->len = (uint32_t)size;
53 		return (TRUE);
54 	}
55 
56 	return (FALSE);
57 }
58 
59 /*
60  * When decoding into a string, ensure that objp->buf is NULL or
61  * is pointing at a buffer large enough to receive the string.
62  * Don't leave it as an uninitialized pointer.
63  *
64  * If objp->buf is NULL, xdr_string will allocate memory for the
65  * string.  Otherwise it will copy into the available buffer.
66  */
67 bool_t
68 smb_string_xdr(XDR *xdrs, smb_string_t *objp)
69 {
70 	if (!xdr_string(xdrs, &objp->buf, ~0))
71 		return (FALSE);
72 	return (TRUE);
73 }
74 
75 const char *
76 smb_doorhdr_opname(uint32_t op)
77 {
78 	struct {
79 		uint32_t	op;
80 		const char	*name;
81 	} ops[] = {
82 		{ SMB_DR_NULL,			"null" },
83 		{ SMB_DR_ASYNC_RESPONSE,	"async_response" },
84 		{ SMB_DR_USER_AUTH_LOGON,	"user_auth_logon" },
85 		{ SMB_DR_USER_NONAUTH_LOGON,	"user_nonauth_logon" },
86 		{ SMB_DR_USER_AUTH_LOGOFF,	"user_auth_logoff" },
87 		{ SMB_DR_LOOKUP_SID,		"lookup_sid" },
88 		{ SMB_DR_LOOKUP_NAME,		"lookup_name" },
89 		{ SMB_DR_JOIN,			"join" },
90 		{ SMB_DR_GET_DCINFO,		"get_dcinfo" },
91 		{ SMB_DR_VSS_GET_COUNT,		"vss_get_count" },
92 		{ SMB_DR_VSS_GET_SNAPSHOTS,	"vss_get_snapshots" },
93 		{ SMB_DR_VSS_MAP_GMTTOKEN,	"vss_map_gmttoken" },
94 		{ SMB_DR_ADS_FIND_HOST,		"ads_find_host" },
95 		{ SMB_DR_QUOTA_QUERY,		"quota_query" },
96 		{ SMB_DR_QUOTA_SET,		"quota_set" },
97 		{ SMB_DR_DFS_GET_REFERRALS,	"dfs_get_referrals" },
98 		{ SMB_DR_SHR_HOSTACCESS,	"share_hostaccess" },
99 		{ SMB_DR_SHR_EXEC,		"share_exec" }
100 	};
101 	int	i;
102 
103 	for (i = 0; i < (sizeof (ops) / sizeof (ops[0])); ++i) {
104 		if (ops[i].op == op)
105 			return (ops[i].name);
106 	}
107 
108 	return ("unknown");
109 }
110 
111 /*
112  * Encode a door header structure into an XDR buffer.
113  */
114 int
115 smb_doorhdr_encode(smb_doorhdr_t *hdr, uint8_t *buf, uint32_t buflen)
116 {
117 	XDR xdrs;
118 	int rc = 0;
119 
120 	xdrmem_create(&xdrs, (const caddr_t)buf, buflen, XDR_ENCODE);
121 
122 	if (!smb_doorhdr_xdr(&xdrs, hdr))
123 		rc = -1;
124 
125 	xdr_destroy(&xdrs);
126 	return (rc);
127 }
128 
129 /*
130  * Decode an XDR buffer into a door header structure.
131  */
132 int
133 smb_doorhdr_decode(smb_doorhdr_t *hdr, uint8_t *buf, uint32_t buflen)
134 {
135 	XDR xdrs;
136 	int rc = 0;
137 
138 	bzero(hdr, sizeof (smb_doorhdr_t));
139 	xdrmem_create(&xdrs, (const caddr_t)buf, buflen, XDR_DECODE);
140 
141 	if (!smb_doorhdr_xdr(&xdrs, hdr))
142 		rc = -1;
143 
144 	xdr_destroy(&xdrs);
145 	return (rc);
146 }
147 
148 bool_t
149 smb_doorhdr_xdr(XDR *xdrs, smb_doorhdr_t *objp)
150 {
151 	if (!xdr_uint32_t(xdrs, &objp->dh_magic))
152 		return (FALSE);
153 	if (!xdr_uint32_t(xdrs, &objp->dh_flags))
154 		return (FALSE);
155 	if (!xdr_uint32_t(xdrs, &objp->dh_fid))
156 		return (FALSE);
157 	if (!xdr_uint32_t(xdrs, &objp->dh_op))
158 		return (FALSE);
159 	if (!xdr_uint32_t(xdrs, &objp->dh_txid))
160 		return (FALSE);
161 	if (!xdr_uint32_t(xdrs, &objp->dh_datalen))
162 		return (FALSE);
163 	if (!xdr_uint32_t(xdrs, &objp->dh_resid))
164 		return (FALSE);
165 	if (!xdr_uint32_t(xdrs, &objp->dh_door_rc))
166 		return (FALSE);
167 	if (!xdr_uint32_t(xdrs, &objp->dh_status))
168 		return (FALSE);
169 	return (TRUE);
170 }
171 
172 /*
173  * Encode an smb_netuserinfo_t into a buffer.
174  */
175 int
176 smb_netuserinfo_encode(smb_netuserinfo_t *info, uint8_t *buf,
177     uint32_t buflen, uint_t *nbytes)
178 {
179 	XDR xdrs;
180 	int rc = 0;
181 
182 	xdrmem_create(&xdrs, (const caddr_t)buf, buflen, XDR_ENCODE);
183 
184 	if (!smb_netuserinfo_xdr(&xdrs, info))
185 		rc = -1;
186 
187 	if (nbytes != NULL)
188 		*nbytes = xdr_getpos(&xdrs);
189 	xdr_destroy(&xdrs);
190 	return (rc);
191 }
192 
193 /*
194  * Decode an XDR buffer into an smb_netuserinfo_t.
195  */
196 int
197 smb_netuserinfo_decode(smb_netuserinfo_t *info, uint8_t *buf,
198     uint32_t buflen, uint_t *nbytes)
199 {
200 	XDR xdrs;
201 	int rc = 0;
202 
203 	xdrmem_create(&xdrs, (const caddr_t)buf, buflen, XDR_DECODE);
204 
205 	bzero(info, sizeof (smb_netuserinfo_t));
206 	if (!smb_netuserinfo_xdr(&xdrs, info))
207 		rc = -1;
208 
209 	if (nbytes != NULL)
210 		*nbytes = xdr_getpos(&xdrs);
211 	xdr_destroy(&xdrs);
212 	return (rc);
213 }
214 
215 bool_t
216 smb_inaddr_xdr(XDR *xdrs, smb_inaddr_t *objp)
217 {
218 	if (!xdr_int32_t(xdrs, &objp->a_family))
219 		return (FALSE);
220 	if (objp->a_family == AF_INET) {
221 		if (!xdr_uint32_t(xdrs, (in_addr_t *)&objp->a_ipv4))
222 			return (FALSE);
223 	} else {
224 		if (!xdr_vector(xdrs, (char *)&objp->a_ipv6,
225 		    sizeof (objp->a_ipv6), sizeof (char), (xdrproc_t)xdr_char))
226 			return (FALSE);
227 	}
228 	return (TRUE);
229 }
230 
231 /*
232  * XDR encode/decode for smb_netuserinfo_t.
233  */
234 bool_t
235 smb_netuserinfo_xdr(XDR *xdrs, smb_netuserinfo_t *objp)
236 {
237 	if (!xdr_uint64_t(xdrs, &objp->ui_session_id))
238 		return (FALSE);
239 	if (!xdr_uint16_t(xdrs, &objp->ui_smb_uid))
240 		return (FALSE);
241 	if (!xdr_uint16_t(xdrs, &objp->ui_domain_len))
242 		return (FALSE);
243 	if (!xdr_string(xdrs, &objp->ui_domain, ~0))
244 		return (FALSE);
245 	if (!xdr_uint16_t(xdrs, &objp->ui_account_len))
246 		return (FALSE);
247 	if (!xdr_string(xdrs, &objp->ui_account, ~0))
248 		return (FALSE);
249 	if (!xdr_uint32_t(xdrs, &objp->ui_posix_uid))
250 		return (FALSE);
251 	if (!xdr_uint16_t(xdrs, &objp->ui_workstation_len))
252 		return (FALSE);
253 	if (!xdr_string(xdrs, &objp->ui_workstation, ~0))
254 		return (FALSE);
255 	if (!smb_inaddr_xdr(xdrs, &objp->ui_ipaddr))
256 		return (FALSE);
257 	if (!xdr_int32_t(xdrs, &objp->ui_native_os))
258 		return (FALSE);
259 	if (!xdr_int64_t(xdrs, &objp->ui_logon_time))
260 		return (FALSE);
261 	if (!xdr_uint32_t(xdrs, &objp->ui_numopens))
262 		return (FALSE);
263 	if (!xdr_uint32_t(xdrs, &objp->ui_flags))
264 		return (FALSE);
265 	return (TRUE);
266 }
267 
268 /*
269  * Encode an smb_netconnectinfo_t into a buffer.
270  */
271 int
272 smb_netconnectinfo_encode(smb_netconnectinfo_t *info, uint8_t *buf,
273     uint32_t buflen, uint_t *nbytes)
274 {
275 	XDR xdrs;
276 	int rc = 0;
277 
278 	xdrmem_create(&xdrs, (const caddr_t)buf, buflen, XDR_ENCODE);
279 
280 	if (!smb_netconnectinfo_xdr(&xdrs, info))
281 		rc = -1;
282 
283 	if (nbytes != NULL)
284 		*nbytes = xdr_getpos(&xdrs);
285 	xdr_destroy(&xdrs);
286 	return (rc);
287 }
288 
289 /*
290  * Decode an XDR buffer into an smb_netconnectinfo_t.
291  */
292 int
293 smb_netconnectinfo_decode(smb_netconnectinfo_t *info, uint8_t *buf,
294     uint32_t buflen, uint_t *nbytes)
295 {
296 	XDR xdrs;
297 	int rc = 0;
298 
299 	xdrmem_create(&xdrs, (const caddr_t)buf, buflen, XDR_DECODE);
300 
301 	bzero(info, sizeof (smb_netconnectinfo_t));
302 	if (!smb_netconnectinfo_xdr(&xdrs, info))
303 		rc = -1;
304 
305 	if (nbytes != NULL)
306 		*nbytes = xdr_getpos(&xdrs);
307 	xdr_destroy(&xdrs);
308 	return (rc);
309 }
310 
311 /*
312  * XDR encode/decode for smb_netconnectinfo_t.
313  */
314 bool_t
315 smb_netconnectinfo_xdr(XDR *xdrs, smb_netconnectinfo_t *objp)
316 {
317 	if (!xdr_uint32_t(xdrs, &objp->ci_id))
318 		return (FALSE);
319 	if (!xdr_uint32_t(xdrs, &objp->ci_type))
320 		return (FALSE);
321 	if (!xdr_uint32_t(xdrs, &objp->ci_numopens))
322 		return (FALSE);
323 	if (!xdr_uint32_t(xdrs, &objp->ci_numusers))
324 		return (FALSE);
325 	if (!xdr_uint32_t(xdrs, &objp->ci_time))
326 		return (FALSE);
327 	if (!xdr_uint32_t(xdrs, &objp->ci_namelen))
328 		return (FALSE);
329 	if (!xdr_uint32_t(xdrs, &objp->ci_sharelen))
330 		return (FALSE);
331 	if (!xdr_string(xdrs, &objp->ci_username, MAXNAMELEN))
332 		return (FALSE);
333 	if (!xdr_string(xdrs, &objp->ci_share, MAXNAMELEN))
334 		return (FALSE);
335 	return (TRUE);
336 }
337 
338 /*
339  * Encode an smb_netfileinfo_t into a buffer.
340  */
341 int
342 smb_netfileinfo_encode(smb_netfileinfo_t *info, uint8_t *buf,
343     uint32_t buflen, uint_t *nbytes)
344 {
345 	XDR xdrs;
346 	int rc = 0;
347 
348 	xdrmem_create(&xdrs, (const caddr_t)buf, buflen, XDR_ENCODE);
349 
350 	if (!smb_netfileinfo_xdr(&xdrs, info))
351 		rc = -1;
352 
353 	if (nbytes != NULL)
354 		*nbytes = xdr_getpos(&xdrs);
355 	xdr_destroy(&xdrs);
356 	return (rc);
357 }
358 
359 /*
360  * Decode an XDR buffer into an smb_netfileinfo_t.
361  */
362 int
363 smb_netfileinfo_decode(smb_netfileinfo_t *info, uint8_t *buf,
364     uint32_t buflen, uint_t *nbytes)
365 {
366 	XDR xdrs;
367 	int rc = 0;
368 
369 	xdrmem_create(&xdrs, (const caddr_t)buf, buflen, XDR_DECODE);
370 
371 	bzero(info, sizeof (smb_netfileinfo_t));
372 	if (!smb_netfileinfo_xdr(&xdrs, info))
373 		rc = -1;
374 
375 	if (nbytes != NULL)
376 		*nbytes = xdr_getpos(&xdrs);
377 	xdr_destroy(&xdrs);
378 	return (rc);
379 }
380 
381 /*
382  * XDR encode/decode for smb_netfileinfo_t.
383  */
384 bool_t
385 smb_netfileinfo_xdr(XDR *xdrs, smb_netfileinfo_t *objp)
386 {
387 	if (!xdr_uint16_t(xdrs, &objp->fi_fid))
388 		return (FALSE);
389 	if (!xdr_uint32_t(xdrs, &objp->fi_uniqid))
390 		return (FALSE);
391 	if (!xdr_uint32_t(xdrs, &objp->fi_permissions))
392 		return (FALSE);
393 	if (!xdr_uint32_t(xdrs, &objp->fi_numlocks))
394 		return (FALSE);
395 	if (!xdr_uint32_t(xdrs, &objp->fi_pathlen))
396 		return (FALSE);
397 	if (!xdr_uint32_t(xdrs, &objp->fi_namelen))
398 		return (FALSE);
399 	if (!xdr_string(xdrs, &objp->fi_path, MAXPATHLEN))
400 		return (FALSE);
401 	if (!xdr_string(xdrs, &objp->fi_username, MAXNAMELEN))
402 		return (FALSE);
403 	return (TRUE);
404 }
405 
406 bool_t
407 smb_gmttoken_query_xdr(XDR *xdrs, smb_gmttoken_query_t *objp)
408 {
409 	if (!xdr_uint32_t(xdrs, &objp->gtq_count)) {
410 		return (FALSE);
411 	}
412 	if (!xdr_string(xdrs, &objp->gtq_path, ~0)) {
413 		return (FALSE);
414 	}
415 	return (TRUE);
416 }
417 
418 static bool_t
419 smb_gmttoken_xdr(XDR *xdrs, smb_gmttoken_t *objp)
420 {
421 	if (!xdr_string(xdrs, objp, SMB_VSS_GMT_SIZE)) {
422 		return (FALSE);
423 	}
424 	return (TRUE);
425 }
426 
427 bool_t
428 smb_gmttoken_response_xdr(XDR *xdrs, smb_gmttoken_response_t *objp)
429 {
430 	if (!xdr_uint32_t(xdrs, &objp->gtr_count)) {
431 		return (FALSE);
432 	}
433 	if (!xdr_array(xdrs, (char **)&objp->gtr_gmttokens.gtr_gmttokens_val,
434 	    (uint_t *)&objp->gtr_gmttokens.gtr_gmttokens_len, ~0,
435 	    sizeof (smb_gmttoken_t), (xdrproc_t)smb_gmttoken_xdr)) {
436 		return (FALSE);
437 	}
438 	return (TRUE);
439 }
440 
441 bool_t
442 smb_gmttoken_snapname_xdr(XDR *xdrs, smb_gmttoken_snapname_t *objp)
443 {
444 	if (!xdr_string(xdrs, &objp->gts_path, MAXPATHLEN)) {
445 		return (FALSE);
446 	}
447 	if (!xdr_string(xdrs, &objp->gts_gmttoken, SMB_VSS_GMT_SIZE)) {
448 		return (FALSE);
449 	}
450 	return (TRUE);
451 }
452 
453 bool_t
454 smb_quota_xdr(XDR *xdrs, smb_quota_t *objp)
455 {
456 	if (!xdr_vector(xdrs, (char *)objp->q_sidstr, SMB_SID_STRSZ,
457 	    sizeof (char), (xdrproc_t)xdr_char))
458 		return (FALSE);
459 	if (!xdr_uint32_t(xdrs, &objp->q_sidtype))
460 		return (FALSE);
461 	if (!xdr_uint64_t(xdrs, &objp->q_used))
462 		return (FALSE);
463 	if (!xdr_uint64_t(xdrs, &objp->q_thresh))
464 		return (FALSE);
465 	if (!xdr_uint64_t(xdrs, &objp->q_limit))
466 		return (FALSE);
467 
468 	return (TRUE);
469 }
470 
471 bool_t
472 smb_quota_sid_xdr(XDR *xdrs, smb_quota_sid_t *objp)
473 {
474 	if (!xdr_vector(xdrs, (char *)objp->qs_sidstr, SMB_SID_STRSZ,
475 	    sizeof (char), (xdrproc_t)xdr_char))
476 		return (FALSE);
477 	return (TRUE);
478 }
479 
480 bool_t
481 smb_quota_query_xdr(XDR *xdrs, smb_quota_query_t *objp)
482 {
483 	if (!xdr_string(xdrs, &objp->qq_root_path, ~0))
484 		return (FALSE);
485 	if (!xdr_uint32_t(xdrs, &objp->qq_query_op))
486 		return (FALSE);
487 	if (!xdr_bool(xdrs, &objp->qq_single))
488 		return (FALSE);
489 	if (!xdr_bool(xdrs, &objp->qq_restart))
490 		return (FALSE);
491 	if (!xdr_uint32_t(xdrs, &objp->qq_max_quota))
492 		return (FALSE);
493 	if (!smb_list_xdr(xdrs, &objp->qq_sid_list,
494 	    offsetof(smb_quota_sid_t, qs_list_node),
495 	    sizeof (smb_quota_sid_t), (xdrproc_t)smb_quota_sid_xdr))
496 		return (FALSE);
497 
498 	return (TRUE);
499 }
500 
501 bool_t
502 smb_quota_response_xdr(XDR *xdrs, smb_quota_response_t *objp)
503 {
504 	if (!xdr_uint32_t(xdrs, &objp->qr_status))
505 		return (FALSE);
506 	if (!smb_list_xdr(xdrs, &objp->qr_quota_list,
507 	    offsetof(smb_quota_t, q_list_node),
508 	    sizeof (smb_quota_t), (xdrproc_t)smb_quota_xdr))
509 		return (FALSE);
510 	return (TRUE);
511 }
512 
513 bool_t
514 smb_quota_set_xdr(XDR *xdrs, smb_quota_set_t *objp)
515 {
516 	if (!xdr_string(xdrs, &objp->qs_root_path, ~0))
517 		return (FALSE);
518 	if (!smb_list_xdr(xdrs, &objp->qs_quota_list,
519 	    offsetof(smb_quota_t, q_list_node),
520 	    sizeof (smb_quota_t), (xdrproc_t)smb_quota_xdr))
521 		return (FALSE);
522 	return (TRUE);
523 }
524 
525 /*
526  * XDR a list_t list of elements
527  * offset - offset of list_node_t in list element
528  * elsize - size of list element
529  * elproc - XDR function for the list element
530  */
531 bool_t
532 smb_list_xdr(XDR *xdrs, list_t *list,  const size_t offset,
533     const size_t elsize, const xdrproc_t elproc)
534 {
535 	void *node;
536 	uint32_t count = 0;
537 
538 	switch (xdrs->x_op) {
539 	case XDR_ENCODE:
540 		node = list_head(list);
541 		while (node) {
542 			++count;
543 			node = list_next(list, node);
544 		}
545 		if (!xdr_uint32_t(xdrs, &count))
546 			return (FALSE);
547 
548 		node = list_head(list);
549 		while (node) {
550 			if (!elproc(xdrs, node))
551 				return (FALSE);
552 			node = list_next(list, node);
553 		}
554 		return (TRUE);
555 
556 	case XDR_DECODE:
557 		if (!xdr_uint32_t(xdrs, &count))
558 			return (FALSE);
559 		list_create(list, elsize, offset);
560 		while (count) {
561 			node = MEM_MALLOC("xdr", elsize);
562 			if (node == NULL)
563 				return (FALSE);
564 			if (!elproc(xdrs, node))
565 				return (FALSE);
566 			list_insert_tail(list, node);
567 			--count;
568 		}
569 		return (TRUE);
570 
571 	case XDR_FREE:
572 		while ((node = list_head(list)) != NULL) {
573 			list_remove(list, node);
574 			(void) elproc(xdrs, node);
575 			MEM_FREE("xdr", node);
576 		}
577 		list_destroy(list);
578 		return (TRUE);
579 	}
580 
581 	return (FALSE);
582 }
583 
584 bool_t
585 dfs_target_pclass_xdr(XDR *xdrs, dfs_target_pclass_t *objp)
586 {
587 	return (xdr_enum(xdrs, (enum_t *)objp));
588 }
589 
590 bool_t
591 dfs_target_priority_xdr(XDR *xdrs, dfs_target_priority_t *objp)
592 {
593 	if (!dfs_target_pclass_xdr(xdrs, &objp->p_class))
594 		return (FALSE);
595 
596 	if (!xdr_uint16_t(xdrs, &objp->p_rank))
597 		return (FALSE);
598 
599 	return (TRUE);
600 }
601 
602 bool_t
603 dfs_target_xdr(XDR *xdrs, dfs_target_t *objp)
604 {
605 	if (!xdr_vector(xdrs, (char *)objp->t_server, DFS_SRVNAME_MAX,
606 	    sizeof (char), (xdrproc_t)xdr_char))
607 		return (FALSE);
608 
609 	if (!xdr_vector(xdrs, (char *)objp->t_share, DFS_NAME_MAX,
610 	    sizeof (char), (xdrproc_t)xdr_char))
611 		return (FALSE);
612 
613 	if (!xdr_uint32_t(xdrs, &objp->t_state))
614 		return (FALSE);
615 
616 	if (!dfs_target_priority_xdr(xdrs, &objp->t_priority))
617 		return (FALSE);
618 
619 	return (TRUE);
620 }
621 
622 bool_t
623 dfs_reftype_xdr(XDR *xdrs, dfs_reftype_t *objp)
624 {
625 	return (xdr_enum(xdrs, (enum_t *)objp));
626 }
627 
628 bool_t
629 dfs_info_xdr(XDR *xdrs, dfs_info_t *objp)
630 {
631 	if (!xdr_vector(xdrs, (char *)objp->i_uncpath, DFS_PATH_MAX,
632 	    sizeof (char), (xdrproc_t)xdr_char))
633 		return (FALSE);
634 
635 	if (!xdr_vector(xdrs, (char *)objp->i_comment, DFS_COMMENT_MAX,
636 	    sizeof (char), (xdrproc_t)xdr_char))
637 		return (FALSE);
638 
639 	if (!xdr_vector(xdrs, (char *)objp->i_guid,
640 	    UUID_PRINTABLE_STRING_LENGTH, sizeof (char), (xdrproc_t)xdr_char))
641 		return (FALSE);
642 
643 	if (!xdr_uint32_t(xdrs, &objp->i_state))
644 		return (FALSE);
645 
646 	if (!xdr_uint32_t(xdrs, &objp->i_timeout))
647 		return (FALSE);
648 
649 	if (!xdr_uint32_t(xdrs, &objp->i_propflags))
650 		return (FALSE);
651 
652 	if (!xdr_uint32_t(xdrs, &objp->i_type))
653 		return (FALSE);
654 
655 	if (!xdr_array(xdrs, (char **)&objp->i_targets,
656 	    (uint32_t *)&objp->i_ntargets, ~0, sizeof (dfs_target_t),
657 	    (xdrproc_t)dfs_target_xdr))
658 		return (FALSE);
659 
660 	return (TRUE);
661 }
662 
663 bool_t
664 dfs_referral_query_xdr(XDR *xdrs, dfs_referral_query_t *objp)
665 {
666 	if (!dfs_reftype_xdr(xdrs, &objp->rq_type))
667 		return (FALSE);
668 
669 	if (!xdr_string(xdrs, &objp->rq_path, ~0))
670 		return (FALSE);
671 
672 	return (TRUE);
673 }
674 
675 bool_t
676 dfs_referral_response_xdr(XDR *xdrs, dfs_referral_response_t *objp)
677 {
678 	if (!dfs_info_xdr(xdrs, &objp->rp_referrals))
679 		return (FALSE);
680 
681 	if (!xdr_uint32_t(xdrs, &objp->rp_status))
682 		return (FALSE);
683 
684 	return (TRUE);
685 }
686 
687 bool_t
688 smb_shr_hostaccess_query_xdr(XDR *xdrs, smb_shr_hostaccess_query_t *objp)
689 {
690 	if (!xdr_string(xdrs, &objp->shq_none, ~0))
691 		return (FALSE);
692 
693 	if (!xdr_string(xdrs, &objp->shq_ro, ~0))
694 		return (FALSE);
695 
696 	if (!xdr_string(xdrs, &objp->shq_rw, ~0))
697 		return (FALSE);
698 
699 	if (!xdr_uint32_t(xdrs, &objp->shq_flag))
700 		return (FALSE);
701 
702 	if (!smb_inaddr_xdr(xdrs, &objp->shq_ipaddr))
703 		return (FALSE);
704 
705 	return (TRUE);
706 }
707 
708 bool_t
709 smb_shr_execinfo_xdr(XDR *xdrs, smb_shr_execinfo_t *objp)
710 {
711 	if (!xdr_string(xdrs, &objp->e_sharename, ~0))
712 		return (FALSE);
713 
714 	if (!xdr_string(xdrs, &objp->e_winname, ~0))
715 		return (FALSE);
716 
717 	if (!xdr_string(xdrs, &objp->e_userdom, ~0))
718 		return (FALSE);
719 
720 	if (!smb_inaddr_xdr(xdrs, &objp->e_srv_ipaddr))
721 		return (FALSE);
722 
723 	if (!smb_inaddr_xdr(xdrs, &objp->e_cli_ipaddr))
724 		return (FALSE);
725 
726 	if (!xdr_string(xdrs, &objp->e_cli_netbiosname, ~0))
727 		return (FALSE);
728 
729 	if (!xdr_u_int(xdrs, &objp->e_uid))
730 		return (FALSE);
731 
732 	if (!xdr_int(xdrs, &objp->e_type))
733 		return (FALSE);
734 
735 	return (TRUE);
736 }
737