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