2 Unix SMB/CIFS implementation.
3 rpc interface definitions
4 Copyright (C) Andrew Tridgell 2003
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 this provides definitions for the libcli/rpc/ MSRPC library
26 /* this is the base structure passed to routines that
27 parse MSRPC formatted data
29 note that in Samba4 we use separate routines and structures for
30 MSRPC marshalling and unmarshalling. Also note that these routines
31 are being kept deliberately very simple, and are not tied to a
35 uint32 flags; /* LIBNDR_FLAG_* */
42 struct ndr_pull_save {
48 /* structure passed to functions that generate NDR formatted data */
50 uint32 flags; /* LIBNDR_FLAG_* */
56 /* this list is used by the relstr code to find the offsets */
57 struct ndr_push_save *relstr_list;
60 struct ndr_push_save {
62 struct ndr_push_save *next;
66 /* structure passed to functions that print IDL structures */
68 uint32 flags; /* LIBNDR_FLAG_* */
71 void (*print)(struct ndr_print *, const char *, ...);
75 #define LIBNDR_FLAG_BIGENDIAN 1
78 /* useful macro for debugging */
79 #define NDR_PRINT_DEBUG(type, p) ndr_print_debug((ndr_print_fn_t)ndr_print_ ##type, #p, p)
80 #define NDR_PRINT_UNION_DEBUG(type, level, p) ndr_print_union_debug((ndr_print_union_fn_t)ndr_print_ ##type, #p, level, p)
84 NDR_ERR_CONFORMANT_SIZE,
94 flags passed to control parse flow
99 #define NDR_PULL_NEED_BYTES(ndr, n) do { \
100 if ((n) > ndr->data_size || ndr->offset + (n) > ndr->data_size) { \
101 return NT_STATUS_BUFFER_TOO_SMALL; \
105 #define NDR_PULL_ALIGN(ndr, n) do { \
106 ndr->offset = (ndr->offset + (n-1)) & ~(n-1); \
107 if (ndr->offset >= ndr->data_size) { \
108 return NT_STATUS_BUFFER_TOO_SMALL; \
112 #define NDR_PUSH_NEED_BYTES(ndr, n) NDR_CHECK(ndr_push_expand(ndr, ndr->offset+(n)))
114 #define NDR_PUSH_ALIGN(ndr, n) do { \
115 uint32 _pad = (ndr->offset & (n-1)); \
116 while (_pad--) NDR_CHECK(ndr_push_uint8(ndr, 0)); \
120 /* these are used to make the error checking on each element in libndr
121 less tedious, hopefully making the code more readable */
122 #define NDR_CHECK(call) do { NTSTATUS _status; \
124 if (!NT_STATUS_IS_OK(_status)) \
129 #define NDR_ALLOC_SIZE(ndr, s, size) do { \
130 (s) = talloc(ndr->mem_ctx, size); \
131 if (!(s)) return NT_STATUS_NO_MEMORY; \
134 #define NDR_ALLOC(ndr, s) NDR_ALLOC_SIZE(ndr, s, sizeof(*(s)))
137 #define NDR_ALLOC_N_SIZE(ndr, s, n, elsize) do { \
141 (s) = talloc(ndr->mem_ctx, (n) * elsize); \
142 if (!(s)) return NT_STATUS_NO_MEMORY; \
146 #define NDR_ALLOC_N(ndr, s, n) NDR_ALLOC_N_SIZE(ndr, s, n, sizeof(*(s)))
148 /* these are used when generic fn pointers are needed for ndr push/pull fns */
149 typedef NTSTATUS (*ndr_push_fn_t)(struct ndr_push *, void *);
150 typedef NTSTATUS (*ndr_pull_fn_t)(struct ndr_pull *, void *);
152 typedef NTSTATUS (*ndr_push_flags_fn_t)(struct ndr_push *, int ndr_flags, void *);
153 typedef NTSTATUS (*ndr_pull_flags_fn_t)(struct ndr_pull *, int ndr_flags, void *);
154 typedef NTSTATUS (*ndr_push_union_fn_t)(struct ndr_push *, int ndr_flags, uint16, void *);
155 typedef NTSTATUS (*ndr_pull_union_fn_t)(struct ndr_pull *, int ndr_flags, uint16 *, void *);
156 typedef void (*ndr_print_fn_t)(struct ndr_print *, const char *, void *);
157 typedef void (*ndr_print_union_fn_t)(struct ndr_print *, const char *, uint16, void *);
159 /* now pull in the individual parsers */
160 #include "librpc/ndr/ndr_sec.h"
161 #include "librpc/ndr/ndr_misc.h"
162 #include "librpc/ndr/ndr_echo.h"
163 #include "librpc/ndr/ndr_lsa.h"
164 #include "librpc/ndr/ndr_dfs.h"
165 #include "librpc/ndr/ndr_spoolss.h"
166 #include "librpc/ndr/ndr_spoolss_buf.h"
167 #include "librpc/ndr/ndr_samr.h"