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