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 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #ifndef _NDR_TYPES_NDL_
27 #define _NDR_TYPES_NDL_
28
29 #define TYPEINFO(TYPE) ndt__##TYPE
30
31 #ifdef NDRGEN
32
33 #define ALIGN(X) [align(X)]
34 #define OPERATION(X) [operation(X)]
35 #define IN [in]
36 #define OUT [out]
37 #define INOUT [in out]
38
39 #define STRING [string]
40 #define SIZE_IS(X) [size_is(X)]
41
42 #define SWITCH(X) [switch_is(X)]
43 #define CASE(X) [case(X)]
44 #define DEFAULT [default]
45
46 #define INTERFACE(X) [interface(X)]
47 #define UUID(X) [uuid(X)]
48
49 #define ARG_IS(X) [arg_is(X)]
50
51 #define REFERENCE [reference]
52 #define REF [reference]
53 #define UNIQUE [unique]
54 #define PTR [ptr]
55 #define POINTER_DEFAULT(X) [pointer_default(X)]
56
57 #define ANY_SIZE_ARRAY *
58
59 #define IMPORT_EXTERN [extern]
60
61 #define BYTE uchar
62 #define WORD ushort
63 #define DWORD ulong
64 #define ntstatus_t ulong
65
66 #define LPTSTR STRING wchar *
67
68 #define LPBYTE uchar *
69 #define LPWORD ushort *
70 #define LPDWORD ulong *
71
72 /*
73 * Opaque context handle.
74 */
75 #ifndef CONTEXT_HANDLE
76 #define CONTEXT_HANDLE(NAME) \
77 struct NAME { \
78 DWORD data1; \
79 DWORD data2; \
80 WORD data3[2]; \
81 BYTE data4[8]; \
82 }; \
83 typedef struct NAME
84 #endif /* CONTEXT_HANDLE */
85
86 #define EXTERNTYPEINFO(TYPE)
87
88 #else /* NDRGEN */
89
90 #define ALIGN(X)
91 #define OPERATION(X)
92 #define IN
93 #define OUT
94 #define INOUT
95
96 #define STRING
97 #define SIZE_IS(X)
98
99 #define SWITCH(X)
100 #define CASE(X)
101 #define DEFAULT
102
103 #define INTERFACE(X)
104 #define UUID(X)
105
106 #define ARG_IS(X)
107
108 #define REFERENCE
109 #define REF
110 #define UNIQUE
111 #define PTR
112 #define POINTER_DEFAULT(X)
113
114 #define IMPORT_EXTERN
115
116 /*
117 * When not using ndrgen, get BYTE, WORD, DWORD definitions from wintypes.h.
118 */
119 #include <smbsrv/wintypes.h>
120
121 #define EXTERNTYPEINFO(TYPE) extern struct ndr_typeinfo TYPEINFO(TYPE);
122
123
124 /*
125 ***********************************************************************
126 * There is a bug in the way that midl and the marshalling code handles
127 * unions so we need to fix some of the data offsets at runtime. The
128 * following macros and the fixup function handle the correction.
129 ***********************************************************************
130 */
131
132 /*
133 * DECL_FIXUP_STRUCT allows us to declare external references to data
134 * structures generated by ndrgen in the _ndr.c file.
135 */
136 #define DECL_FIXUP_STRUCT(NAME) extern struct ndr_typeinfo ndt__##NAME
137
138 /*
139 * CASE_INFO_ENT is intended to simplify the declaration of the case
140 * statement in the fixup function. Assuming you have followed the
141 * convention for naming the individual structures all you have to do
142 * is add a single line to the fixup function for each new case.
143 */
144 #define CASE_INFO_ENT(NAME,N) \
145 case N: size1 = sizeof (struct NAME##N); \
146 break
147
148 /*
149 * FIXUP_PDU_SIZE is used to patch the appropriate structures (identified
150 * by DECL_FIXUP_STRUCT) at runtime. The values are based on the
151 * switch_index.
152 */
153 #define FIXUP_PDU_SIZE(NAME,SIZE) { \
154 ndt__##NAME.pdu_size_fixed_part = SIZE; \
155 ndt__##NAME.c_size_fixed_part = SIZE; \
156 }
157
158
159 #endif /* NDRGEN */
160
161 /*
162 * UNION_INFO_ENT is intended to simplify adding new entries to a union.
163 * If the entry structures are named using the form FunctionNameX,
164 * where X is the sitch_value, you can just add a single line. Note
165 * that you must also update the fixup function in mlsvc_xxx.c.
166 */
167 #define UNION_INFO_ENT(N,NAME) CASE(N) struct NAME##N info##N
168 #define UNION_INFO_PTR(N,NAME) CASE(N) struct NAME##N *info##N
169
170 #endif /* _NDR_TYPES_NDL_ */