xref: /titanic_41/usr/src/uts/common/smbsrv/ndr.h (revision 391647d5ee9b25dc5307abb55f583388e08b2dd7)
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 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SMBSRV_NDR_H
27 #define	_SMBSRV_NDR_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 /*
32  * Network Data Representation (NDR) is a compatible subset of DCE RPC
33  * and MSRPC NDR.  NDR is used to move parameters consisting of
34  * complicated trees of data constructs between an RPC client and server.
35  *
36  * CAE Specification (1997)
37  * DCE 1.1: Remote Procedure Call
38  * Document Number: C706
39  * The Open Group
40  * ogspecs@opengroup.org
41  */
42 
43 #ifndef _KERNEL
44 #include <sys/types.h>
45 #include <sys/uio.h>
46 #include <syslog.h>
47 #include <stdlib.h>
48 #include <string.h>
49 #include <smbsrv/smb_i18n.h>
50 #endif
51 
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
56 /*
57  * Normal sequence:
58  *	- Application calls client-side stub w/ TOP-MOST arg structure
59  *	- client stub performs NDR_M_OP_MARSHALL+NDR_DIR_IN
60  *	- PDU conveyed (request, aka call, aka query)
61  *	- server stub performs NDR_M_OP_UNMARSHALL+NDR_DIR_IN
62  *	- server function called w/ TOP-MOST arg structure
63  *	- server function returns w/ TOP-MOST arg structure modified
64  *	- server stub performs NDR_M_OP_MARSHALL+NDR_DIR_OUT
65  *	- PDU conveyed (reply, aka result, aka response)
66  *	- client stub performs NDR_M_OP_UNMARSHALL+NDR_DIR_OUT
67  *	- return to Application w/ TOP-MOST arg structure modified
68  *
69  * An interface is a sequence of top-most constructs.  Each top-most
70  * construct corresponds to one parameter, either argument or return
71  * value.
72  *
73  * A top-most construct is a sequence of outer constructs.  The first
74  * outer construct is the referent of the argument, and the subsequent
75  * outer constructs are descendents referenced by pointers from prior
76  * constructs.
77  *
78  * An outer construct is a sequence of variable-sized info, fixed-sized
79  * data, and variable-sized data.
80  */
81 
82 /*
83  * Terminology
84  *
85  * The ALL UPPER CASE terms recur in the DCE/RPC documentation.
86  * The mixed-case names have been introduced as a reading aid.
87  *
88  * Size		The size of an array in elements. Think of this
89  *		as the amount to malloc().
90  *
91  * Length	The number of elements of an array which are significant
92  *		Think of this as the amount to bcopy().
93  *
94  * Known	Size/length is known at build time.
95  *
96  * Determined	Size/length is determined at run time.
97  *
98  * FIXED	The Size and Length are Known.
99  *		Think of this as a string constant or a DOS 8.3 file name.
100  *		char array[] = "A Constant Size/Length";
101  *
102  * CONFORMANT	The Size is Determined. Length is the same as Size.
103  *		Think of this as strdup().
104  *		char *array = strdup("Something");
105  *
106  * VARYING	The Size is Known. The Length is determined.
107  *		Think of this as a strcpy() of a variable length string
108  *		into a fixed length buffer:
109  *		char array[100];
110  *		strcpy(array, "very short string");
111  *
112  * VARYING/CONFORMANT
113  *		The Size is Determined. The Length is separately Determined.
114  *		Think of this like:
115  *		char *array = malloc(size);
116  *		strcpy(array, "short string");
117  *
118  * STRING	Strings can be CONFORMANT, VARYING, or CONFORMANT/VARYING.
119  *		A string is fundamentally an array with the last
120  *		significant element some sort of NULL.
121  */
122 
123 #define	NDR_F_NONE		0x0000	/* no flags */
124 #define	NDR_F_PARAMS_MASK	0x00FF
125 #define	NDR_F_SIZE_IS		0x0001	/* [size_is(X)] required/given */
126 #define	NDR_F_LENGTH_IS		0x0002	/* not implemented */
127 #define	NDR_F_SWITCH_IS		0x0004	/* [switch_is(X)] req./given */
128 #define	NDR_F_IS_STRING		0x0008	/* [string] req./given */
129 #define	NDR_F_IS_POINTER	0x0010	/* TYPE * ... req./given */
130 #define	NDR_F_IS_REFERENCE	0x0020	/* TYPE & ... req./given */
131 #define	NDR_F_DIMENSION_IS	0x0040	/* TYPE [N] req./given */
132 
133 #define	NDR_F_WHENCE_MASK	0x00F0
134 #define	NDR_F_BACKPTR		0x0010	/* ref cause by pointer */
135 #define	NDR_F_OUTER		0x0020	/* ref caused by outer */
136 #define	NDR_F_TOPMOST		0x0040	/* ref caused by topmost */
137 
138 #define	NDR_F_TYPEOP_MASK	0x0F00
139 #define	NDR_F_ARRAY		0x0100	/* type is array of somethings */
140 #define	NDR_F_POINTER		0x0200	/* type is pointer to something(s) */
141 #define	NDR_F_STRING		0x0300	/* type is string of somethings */
142 #define	NDR_F_UNION		0x0400	/* type is a union */
143 #define	NDR_F_STRUCT		0x0500	/* type is a structure */
144 #define	NDR_F_OPERATION		0x0600	/* type is a structure, special */
145 #define	NDR_F_INTERFACE		0x0700	/* type is a union, special */
146 #define	NDR_F_CONFORMANT	0x1000	/* struct conforming (var-size tail) */
147 #define	NDR_F_VARYING		0x2000	/* not implemented */
148 
149 struct mlrpc_heap;
150 struct mlndr_stream;
151 struct ndr_reference;
152 struct ndr_typeinfo;
153 
154 struct ndr_typeinfo {
155 	unsigned char		version;	/* sanity check */
156 	unsigned char		alignment;	/* mask */
157 	unsigned short		type_flags;	/* NDR_F_... */
158 	int			(*ndr_func)(struct ndr_reference *encl_ref);
159 	unsigned short		pdu_size_fixed_part;
160 	unsigned short		pdu_size_variable_part;
161 	unsigned short		c_size_fixed_part;
162 	unsigned short		c_size_variable_part;
163 };
164 
165 struct ndr_reference {
166 	struct ndr_reference	*next;		/* queue list (outer only) */
167 	struct ndr_reference	*enclosing;	/* e.g. struct for this memb */
168 	struct mlndr_stream	*stream;	/* root of NDR */
169 	struct ndr_typeinfo	*ti;		/* type of data referenced */
170 	char			*name;		/* name of this member */
171 	unsigned long		pdu_offset;	/* referent in stub data */
172 	char			*datum;		/* referent in local memory */
173 	char			**backptr;	/* referer to set */
174 	unsigned short		outer_flags;	/* XXX_is() from top level */
175 	unsigned short		inner_flags;	/* XXX_is() in encapsulated */
176 	unsigned short		type_flags;	/* "requires" */
177 	unsigned short		packed_alignment;
178 	unsigned long		size_is;	/* conforming constructs */
179 	unsigned long		strlen_is;	/* strings */
180 	unsigned long		switch_is;	/* union arg selector */
181 	unsigned long		dimension_is;	/* fixed-len array size */
182 	unsigned long		pdu_end_offset;	/* offset for limit of PDU */
183 };
184 
185 /*
186  * For all operations, the mlndr_stream, which is the root of NDR processing,
187  * is the primary object.  When available, the appropriate ndr_reference
188  * is passed, NULL otherwise.  Functions that return 'int' should return
189  * TRUE (!0) or FALSE (0).  When functions return FALSE, including
190  * mlndo_malloc() returning NULL, they should set the stream->error to an
191  * appropriate indicator of what went wrong.
192  *
193  * Functions mlndo_get_pdu(), mlndo_put_pdu(), and mlndo_pad_pdu() must
194  * never grow the PDU data.  A request for out-of-bounds data is an error.
195  * The swap_bytes flag is 1 if NDR knows that the byte-order in the PDU
196  * is different from the local system.  mlndo_pad_pdu() advised that the
197  * affected bytes should be zero filled.
198  */
199 struct mlndr_stream_ops {
200 	char *(*mlndo_malloc)(struct mlndr_stream *, unsigned,
201 	    struct ndr_reference *);
202 
203 	int (*mlndo_free)(struct mlndr_stream *, char *,
204 	    struct ndr_reference *);
205 
206 	int (*mlndo_grow_pdu)(struct mlndr_stream *, unsigned long,
207 	    struct ndr_reference *);
208 
209 	int (*mlndo_pad_pdu)(struct mlndr_stream *, unsigned long,
210 	    unsigned long, struct ndr_reference *);
211 
212 	int (*mlndo_get_pdu)(struct mlndr_stream *, unsigned long,
213 	    unsigned long, char *, int, struct ndr_reference *);
214 
215 	int (*mlndo_put_pdu)(struct mlndr_stream *, unsigned long,
216 	    unsigned long, char *, int, struct ndr_reference *);
217 
218 	void (*mlndo_tattle)(struct mlndr_stream *, char *,
219 	    struct ndr_reference *);
220 
221 	void (*mlndo_tattle_error)(struct mlndr_stream *,
222 	    struct ndr_reference *);
223 
224 	int (*mlndo_reset)(struct mlndr_stream *);
225 	void (*mlndo_destruct)(struct mlndr_stream *);
226 };
227 
228 #define	MLNDS_MALLOC(MLNDS, LEN, REF) \
229 	(*(MLNDS)->mlndo->mlndo_malloc)(MLNDS, LEN, REF)
230 
231 #define	MLNDS_GROW_PDU(MLNDS, WANT_END_OFF, REF) \
232 	(*(MLNDS)->mlndo->mlndo_grow_pdu)(MLNDS, WANT_END_OFF, REF)
233 #define	MLNDS_PAD_PDU(MLNDS, PDU_OFFSET, N_BYTES, REF) \
234 	(*(MLNDS)->mlndo->mlndo_pad_pdu)(MLNDS, PDU_OFFSET, N_BYTES, REF)
235 #define	MLNDS_GET_PDU(MLNDS, PDU_OFFSET, N_BYTES, BUF, SWAP, REF) \
236 	(*(MLNDS)->mlndo->mlndo_get_pdu)(MLNDS, PDU_OFFSET, N_BYTES, BUF, \
237 	SWAP, REF)
238 #define	MLNDS_PUT_PDU(MLNDS, PDU_OFFSET, N_BYTES, BUF, SWAP, REF) \
239 	(*(MLNDS)->mlndo->mlndo_put_pdu)(MLNDS, PDU_OFFSET, N_BYTES, BUF, \
240 	SWAP, REF)
241 
242 #define	MLNDS_TATTLE(MLNDS, WHAT, REF) \
243 	(*(MLNDS)->mlndo->mlndo_tattle)(MLNDS, WHAT, REF)
244 #define	MLNDS_TATTLE_ERROR(MLNDS, WHAT, REF) \
245 	(*(MLNDS)->mlndo->mlndo_tattle_error)(MLNDS, REF)
246 #define	MLNDS_RESET(MLNDS) \
247 	(*(MLNDS)->mlndo->mlndo_reset)(MLNDS)
248 #define	MLNDS_DESTRUCT(MLNDS) \
249 	(*(MLNDS)->mlndo->mlndo_destruct)(MLNDS)
250 
251 typedef struct ndr_frag {
252 	struct ndr_frag *next;
253 	uint8_t *buf;
254 	uint32_t len;
255 } ndr_frag_t;
256 
257 typedef struct ndr_fraglist {
258 	struct uio	uio;
259 	iovec_t		*iov;
260 	ndr_frag_t	*head;
261 	ndr_frag_t	*tail;
262 	uint32_t	nfrag;
263 } ndr_fraglist_t;
264 
265 struct mlndr_stream {
266 	unsigned long		pdu_size;
267 	unsigned long		pdu_max_size;
268 	unsigned long		pdu_base_offset;
269 	unsigned long		pdu_scan_offset;
270 	unsigned char		*pdu_base_addr;
271 
272 	ndr_fraglist_t		frags;
273 	struct mlndr_stream_ops *mlndo;
274 
275 	unsigned char		m_op;
276 	unsigned char		dir;
277 	unsigned char		swap;		/* native/net endian swap */
278 	unsigned char		flags;
279 	short			error;
280 	short			error_ref;
281 
282 	struct ndr_reference *outer_queue_head;
283 	struct ndr_reference **outer_queue_tailp;
284 	struct ndr_reference *outer_current;
285 	struct mlrpc_heap *heap;
286 };
287 
288 
289 #define	NDR_M_OP_NONE		0x00
290 #define	NDR_M_OP_MARSHALL	0x01	/* data moving from datum to PDU */
291 #define	NDR_M_OP_UNMARSHALL	0x02	/* data moving from PDU to datum */
292 
293 #define	NDR_DIR_NONE		0x00
294 #define	NDR_DIR_IN		0x10	/* data moving from caller to callee */
295 #define	NDR_DIR_OUT		0x20	/* data moving from callee to caller */
296 
297 #define	NDR_MODE_CALL_SEND	(NDR_M_OP_MARSHALL + NDR_DIR_IN)
298 #define	NDR_MODE_CALL_RECV	(NDR_M_OP_UNMARSHALL + NDR_DIR_IN)
299 #define	NDR_MODE_RETURN_SEND	(NDR_M_OP_MARSHALL + NDR_DIR_OUT)
300 #define	NDR_MODE_RETURN_RECV	(NDR_M_OP_UNMARSHALL + NDR_DIR_OUT)
301 
302 #define	NDR_MODE_TO_M_OP(MODE)	((MODE)&0x0F)
303 #define	NDR_MODE_TO_DIR(MODE)	((MODE)&0xF0)
304 #define	NDR_M_OP_AND_DIR_TO_MODE(M_OP, DIR)	((M_OP)|(DIR))
305 
306 #define	NDR_MODE_MATCH(MLNDS, MODE) \
307 	(NDR_M_OP_AND_DIR_TO_MODE((MLNDS)->m_op, (MLNDS)->dir) == (MODE))
308 
309 #define	MLNDS_F_NONE		0x00
310 #define	MLNDS_F_NOTERM		0x01	/* strings are not null terminated */
311 #define	MLNDS_SETF(S, F)	((S)->flags |= (F))
312 #define	MLNDS_CLEARF(S, F)	((S)->flags &= ~(F))
313 
314 #define	NDR_ERR_MALLOC_FAILED		-1
315 #define	NDR_ERR_M_OP_INVALID		-2
316 #define	NDR_ERR_UNDERFLOW		-3
317 #define	NDR_ERR_GROW_FAILED		-4	/* overflow */
318 #define	NDR_ERR_PAD_FAILED		-5	/* couldn't possibly happen */
319 #define	NDR_ERR_OUTER_HEADER_BAD	-6
320 #define	NDR_ERR_SWITCH_VALUE_ILLEGAL	-7
321 #define	NDR_ERR_SWITCH_VALUE_INVALID	-8
322 #define	NDR_ERR_SWITCH_VALUE_MISSING	-9
323 #define	NDR_ERR_SIZE_IS_MISMATCH_PDU	-10
324 #define	NDR_ERR_SIZE_IS_MISMATCH_AFTER	-11
325 #define	NDR_ERR_SIZE_IS_UNEXPECTED	-12
326 #define	NDR_ERR_SIZE_IS_DUPLICATED	-13
327 #define	NDR_ERR_OUTER_PARAMS_MISMATCH	-14
328 #define	NDR_ERR_ARRAY_VARLEN_ILLEGAL	-15
329 #define	NDR_ERR_ARRAY_UNION_ILLEGAL	-16
330 #define	NDR_ERR_OUTER_PARAMS_BAD	-17
331 #define	NDR_ERR_OUTER_UNION_ILLEGAL	-18
332 #define	NDR_ERR_TOPMOST_UNION_ILLEGAL	-19
333 #define	NDR_ERR_TOPMOST_VARLEN_ILLEGAL	-20
334 #define	NDR_ERR_INNER_PARAMS_BAD	-21
335 #define	NDR_ERR_UNIMPLEMENTED		-22
336 #define	NDR_ERR_NOT_AN_INTERFACE	-23
337 #define	NDR_ERR_STRLEN			-24
338 #define	NDR_ERR_STRING_SIZING		-25
339 #define	NDR_ERR_BOUNDS_CHECK		-26
340 
341 #define	NDR_SET_ERROR(REF, ERROR)			\
342 	((REF)->stream->error = (ERROR),		\
343 	(REF)->stream->error_ref = __LINE__,		\
344 	MLNDS_TATTLE_ERROR((REF)->stream, 0, REF))
345 
346 #define	NDR_TATTLE(REF, WHAT) \
347 	(*(REF)->stream->mlndo->mlndo_tattle)((REF)->stream, WHAT, REF)
348 
349 #define	MEMBER_STR(MEMBER) #MEMBER
350 
351 #define	NDR_DIR_IS_IN  (encl_ref->stream->dir == NDR_DIR_IN)
352 #define	NDR_DIR_IS_OUT (encl_ref->stream->dir == NDR_DIR_OUT)
353 
354 #define	NDR_MEMBER_WITH_ARG(TYPE, MEMBER, OFFSET, \
355 		ARGFLAGS, ARGMEM, ARGVAL) { \
356 		myref.pdu_offset = encl_ref->pdu_offset + (OFFSET);	\
357 		myref.name = MEMBER_STR(MEMBER);			\
358 		myref.datum = (char *)&val->MEMBER;			\
359 		myref.inner_flags = ARGFLAGS;				\
360 		myref.ti = &ndt_##TYPE;					\
361 		myref.ARGMEM = ARGVAL;					\
362 		if (!mlndr_inner(&myref))				\
363 			return (0);					\
364 	}
365 
366 #define	NDR_MEMBER(TYPE, MEMBER, OFFSET) \
367 	NDR_MEMBER_WITH_ARG(TYPE, MEMBER, OFFSET, \
368 		NDR_F_NONE, size_is, 0)
369 
370 #define	NDR_MEMBER_ARR_WITH_SIZE_IS(TYPE, MEMBER, OFFSET, SIZE_IS) \
371 	NDR_MEMBER_WITH_ARG(TYPE, MEMBER, OFFSET, \
372 		NDR_F_SIZE_IS, size_is, SIZE_IS)
373 
374 #define	NDR_MEMBER_ARR_WITH_DIMENSION(TYPE, MEMBER, OFFSET, SIZE_IS) \
375 	NDR_MEMBER_WITH_ARG(TYPE, MEMBER, OFFSET, \
376 		NDR_F_DIMENSION_IS, dimension_is, SIZE_IS)
377 
378 #define	NDR_MEMBER_PTR_WITH_SIZE_IS(TYPE, MEMBER, OFFSET, SIZE_IS) \
379 	NDR_MEMBER_WITH_ARG(TYPE, MEMBER, OFFSET, \
380 		NDR_F_SIZE_IS+NDR_F_IS_POINTER, size_is, SIZE_IS)
381 
382 #define	NDR_MEMBER_PTR(TYPE, MEMBER, OFFSET)		\
383 	NDR_MEMBER_WITH_ARG(TYPE, MEMBER, OFFSET,	\
384 		NDR_F_IS_POINTER, size_is, 0)
385 
386 #define	NDR_MEMBER_WITH_SWITCH_IS(TYPE, MEMBER, OFFSET, SWITCH_IS)	\
387 	NDR_MEMBER_WITH_ARG(TYPE, MEMBER, OFFSET,			\
388 		NDR_F_SWITCH_IS, switch_is, SWITCH_IS)
389 
390 
391 #define	NDR_TOPMOST_MEMBER_WITH_ARG(TYPE, MEMBER, \
392 		ARGFLAGS, ARGMEM, ARGVAL) { \
393 		myref.pdu_offset = -1;					\
394 		myref.name = MEMBER_STR(MEMBER);			\
395 		myref.datum = (char *)&val->MEMBER;			\
396 		myref.inner_flags = ARGFLAGS;				\
397 		myref.ti = &ndt_##TYPE;					\
398 		myref.ARGMEM = ARGVAL;					\
399 		if (!mlndr_topmost(&myref))				\
400 			return (0);					\
401 	}
402 
403 #define	NDR_TOPMOST_MEMBER(TYPE, MEMBER)	   			\
404 	NDR_TOPMOST_MEMBER_WITH_ARG(TYPE, MEMBER,			\
405 		NDR_F_NONE, size_is, 0)
406 
407 #define	NDR_TOPMOST_MEMBER_ARR_WITH_SIZE_IS(TYPE, MEMBER, SIZE_IS)	\
408 	NDR_TOPMOST_MEMBER_WITH_ARG(TYPE, MEMBER,		    	\
409 		NDR_F_SIZE_IS, size_is, SIZE_IS)
410 
411 #define	NDR_TOPMOST_MEMBER_ARR_WITH_DIMENSION(TYPE, MEMBER, SIZE_IS)	\
412 	NDR_TOPMOST_MEMBER_WITH_ARG(TYPE, MEMBER,		      	\
413 		NDR_F_DIMENSION_IS, dimension_is, SIZE_IS)
414 
415 #define	NDR_TOPMOST_MEMBER_PTR_WITH_SIZE_IS(TYPE, MEMBER, SIZE_IS)	\
416 	NDR_TOPMOST_MEMBER_WITH_ARG(TYPE, MEMBER,			\
417 		NDR_F_SIZE_IS+NDR_F_IS_POINTER, size_is, SIZE_IS)
418 
419 #define	NDR_TOPMOST_MEMBER_PTR(TYPE, MEMBER)		\
420 	NDR_TOPMOST_MEMBER_WITH_ARG(TYPE, MEMBER,	\
421 		NDR_F_IS_POINTER, size_is, 0)
422 
423 #define	NDR_TOPMOST_MEMBER_REF(TYPE, MEMBER)		\
424 	NDR_TOPMOST_MEMBER_WITH_ARG(TYPE, MEMBER,	\
425 		NDR_F_IS_REFERENCE, size_is, 0)
426 
427 #define	NDR_TOPMOST_MEMBER_REF_WITH_SIZE_IS(TYPE, MEMBER, SIZE_IS)	\
428 	NDR_TOPMOST_MEMBER_WITH_ARG(TYPE, MEMBER,			\
429 		NDR_F_SIZE_IS+NDR_F_IS_REFERENCE, size_is, SIZE_IS)
430 
431 #define	NDR_TOPMOST_MEMBER_WITH_SWITCH_IS(TYPE, MEMBER, SWITCH_IS)	\
432 	NDR_TOPMOST_MEMBER_WITH_ARG(TYPE, MEMBER,			\
433 		NDR_F_SWITCH_IS, switch_is, SWITCH_IS)
434 
435 /* this is assuming offset+0 */
436 #define	NDR_PARAMS_MEMBER_WITH_ARG(TYPE, MEMBER, ARGFLAGS, \
437 	ARGMEM, ARGVAL) { \
438 		myref.pdu_offset = encl_ref->pdu_offset;		\
439 		myref.name = MEMBER_STR(MEMBER);			\
440 		myref.datum = (char *)&val->MEMBER;			\
441 		myref.inner_flags = ARGFLAGS;				\
442 		myref.ti = &ndt_##TYPE;					\
443 		myref.ARGMEM = ARGVAL;					\
444 		if (!mlndr_params(&myref))				\
445 			return (0);					\
446 	}
447 
448 #define	NDR_PARAMS_MEMBER(TYPE, MEMBER)			\
449 	NDR_PARAMS_MEMBER_WITH_ARG(TYPE, MEMBER,	\
450 	NDR_F_NONE, size_is, 0)
451 
452 #define	NDR_STRING_DIM		1
453 #define	NDR_ANYSIZE_DIM		1
454 
455 int mlndo_process(struct mlndr_stream *, struct ndr_typeinfo *, char *);
456 int mlndo_operation(struct mlndr_stream *, struct ndr_typeinfo *,
457     int opnum, char *);
458 void mlndo_printf(struct mlndr_stream *, struct ndr_reference *,
459     const char *, ...);
460 void mlndo_trace(const char *);
461 void mlndo_fmt(struct mlndr_stream *, struct ndr_reference *, char *);
462 
463 int mlndr_params(struct ndr_reference *);
464 int mlndr_topmost(struct ndr_reference *);
465 int mlndr_run_outer_queue(struct mlndr_stream *);
466 int mlndr_outer(struct ndr_reference *);
467 int mlndr_outer_fixed(struct ndr_reference *);
468 int mlndr_outer_fixed_array(struct ndr_reference *);
469 int mlndr_outer_conformant_array(struct ndr_reference *);
470 int mlndr_outer_conformant_construct(struct ndr_reference *);
471 int mlndr_size_is(struct ndr_reference *);
472 int mlndr_outer_string(struct ndr_reference *);
473 int mlndr_outer_peek_sizing(struct ndr_reference *, unsigned,
474     unsigned long *);
475 int mlndr_outer_poke_sizing(struct ndr_reference *, unsigned,
476     unsigned long *);
477 int mlndr_outer_align(struct ndr_reference *);
478 int mlndr_outer_grow(struct ndr_reference *, unsigned);
479 int mlndr_inner(struct ndr_reference *);
480 int mlndr_inner_pointer(struct ndr_reference *);
481 int mlndr_inner_reference(struct ndr_reference *);
482 int mlndr_inner_array(struct ndr_reference *);
483 
484 size_t ndr_mbstowcs(struct mlndr_stream *, mts_wchar_t *, const char *, size_t);
485 int ndr_mbtowc(struct mlndr_stream *, mts_wchar_t *, const char *, size_t);
486 
487 void mlnds_bswap(void *src, void *dst, size_t len);
488 
489 #ifdef __cplusplus
490 }
491 #endif
492 
493 #endif /* _SMBSRV_NDR_H */
494