Changeset 920 for trunk/server/librpc/ndr/libndr.h
- Timestamp:
- Jun 9, 2016, 2:23:12 PM (9 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 919
- Property svn:mergeinfo changed
-
trunk/server/librpc/ndr/libndr.h
r918 r920 125 125 #define LIBNDR_STRING_FLAGS (0x7FFC) 126 126 127 /* 128 * don't debug NDR_ERR_BUFSIZE failures, 129 * as the available buffer might be incomplete. 130 * 131 * return NDR_ERR_INCOMPLETE_BUFFER instead. 132 */ 133 #define LIBNDR_FLAG_INCOMPLETE_BUFFER (1<<16) 134 135 /* 136 * This lets ndr_pull_subcontext_end() return 137 * NDR_ERR_UNREAD_BYTES. 138 */ 139 #define LIBNDR_FLAG_SUBCONTEXT_NO_UNREAD_BYTES (1<<17) 140 127 141 /* set if relative pointers should *not* be marshalled in reverse order */ 128 142 #define LIBNDR_FLAG_NO_RELATIVE_REVERSE (1<<18) … … 164 178 /* useful macro for debugging */ 165 179 #define NDR_PRINT_DEBUG(type, p) ndr_print_debug((ndr_print_fn_t)ndr_print_ ##type, #p, p) 180 #define NDR_PRINT_DEBUGC(dbgc_class, type, p) ndr_print_debugc(dbgc_class, (ndr_print_fn_t)ndr_print_ ##type, #p, p) 166 181 #define NDR_PRINT_UNION_DEBUG(type, level, p) ndr_print_union_debug((ndr_print_fn_t)ndr_print_ ##type, #p, level, p) 167 182 #define NDR_PRINT_FUNCTION_DEBUG(type, flags, p) ndr_print_function_debug((ndr_print_function_t)ndr_print_ ##type, #type, flags, p) … … 200 215 NDR_ERR_INVALID_POINTER, 201 216 NDR_ERR_UNREAD_BYTES, 202 NDR_ERR_NDR64 217 NDR_ERR_NDR64, 218 NDR_ERR_FLAGS, 219 NDR_ERR_INCOMPLETE_BUFFER 203 220 }; 204 221 … … 218 235 /* 219 236 flags passed to control parse flow 237 These are deliberately in a different range to the NDR_IN/NDR_OUT 238 flags to catch mixups 220 239 */ 221 #define NDR_SCALARS 1222 #define NDR_BUFFERS 2240 #define NDR_SCALARS 0x100 241 #define NDR_BUFFERS 0x200 223 242 224 243 /* 225 flags passed to ndr_print_*() 244 flags passed to ndr_print_*() and ndr pull/push for functions 245 These are deliberately in a different range to the NDR_SCALARS/NDR_BUFFERS 246 flags to catch mixups 226 247 */ 227 #define NDR_IN 1 228 #define NDR_OUT 2 229 #define NDR_BOTH 3 230 #define NDR_SET_VALUES 4 248 #define NDR_IN 0x10 249 #define NDR_OUT 0x20 250 #define NDR_BOTH 0x30 251 #define NDR_SET_VALUES 0x40 252 253 254 #define NDR_PULL_CHECK_FLAGS(ndr, ndr_flags) do { \ 255 if ((ndr_flags) & ~(NDR_SCALARS|NDR_BUFFERS)) { \ 256 return ndr_pull_error(ndr, NDR_ERR_FLAGS, "Invalid pull struct ndr_flags 0x%x", ndr_flags); \ 257 } \ 258 } while (0) 259 260 #define NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags) do { \ 261 if ((ndr_flags) & ~(NDR_SCALARS|NDR_BUFFERS)) \ 262 return ndr_push_error(ndr, NDR_ERR_FLAGS, "Invalid push struct ndr_flags 0x%x", ndr_flags); \ 263 } while (0) 264 265 #define NDR_PULL_CHECK_FN_FLAGS(ndr, flags) do { \ 266 if ((flags) & ~(NDR_BOTH|NDR_SET_VALUES)) { \ 267 return ndr_pull_error(ndr, NDR_ERR_FLAGS, "Invalid fn pull flags 0x%x", flags); \ 268 } \ 269 } while (0) 270 271 #define NDR_PUSH_CHECK_FN_FLAGS(ndr, flags) do { \ 272 if ((flags) & ~(NDR_BOTH|NDR_SET_VALUES)) \ 273 return ndr_push_error(ndr, NDR_ERR_FLAGS, "Invalid fn push flags 0x%x", flags); \ 274 } while (0) 231 275 232 276 #define NDR_PULL_NEED_BYTES(ndr, n) do { \ 233 277 if (unlikely((n) > ndr->data_size || ndr->offset + (n) > ndr->data_size)) { \ 278 if (ndr->flags & LIBNDR_FLAG_INCOMPLETE_BUFFER) { \ 279 uint32_t _available = ndr->data_size - ndr->offset; \ 280 uint32_t _missing = n - _available; \ 281 ndr->relative_highest_offset = _missing; \ 282 } \ 234 283 return ndr_pull_error(ndr, NDR_ERR_BUFSIZE, "Pull bytes %u (%s)", (unsigned)n, __location__); \ 235 284 } \ … … 248 297 } \ 249 298 if (unlikely(ndr->offset > ndr->data_size)) { \ 299 if (ndr->flags & LIBNDR_FLAG_INCOMPLETE_BUFFER) { \ 300 uint32_t _missing = ndr->offset - ndr->data_size; \ 301 ndr->relative_highest_offset = _missing; \ 302 } \ 250 303 return ndr_pull_error(ndr, NDR_ERR_BUFSIZE, "Pull align %u", (unsigned)n); \ 251 304 } \ … … 403 456 void ndr_print_GUID(struct ndr_print *ndr, const char *name, const struct GUID *guid); 404 457 bool ndr_syntax_id_equal(const struct ndr_syntax_id *i1, const struct ndr_syntax_id *i2); 458 char *ndr_syntax_id_to_string(TALLOC_CTX *mem_ctx, const struct ndr_syntax_id *id); 459 bool ndr_syntax_id_from_string(const char *s, struct ndr_syntax_id *id); 405 460 enum ndr_err_code ndr_push_struct_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, const void *p, ndr_push_flags_fn_t fn); 406 461 enum ndr_err_code ndr_push_union_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p, uint32_t level, ndr_push_flags_fn_t fn); … … 425 480 size_t ndr_align_size(uint32_t offset, size_t n); 426 481 struct ndr_pull *ndr_pull_init_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx); 482 enum ndr_err_code ndr_pull_append(struct ndr_pull *ndr, DATA_BLOB *blob); 483 enum ndr_err_code ndr_pull_pop(struct ndr_pull *ndr); 427 484 enum ndr_err_code ndr_pull_advance(struct ndr_pull *ndr, uint32_t size); 428 485 struct ndr_push *ndr_push_init_ctx(TALLOC_CTX *mem_ctx); … … 430 487 enum ndr_err_code ndr_push_expand(struct ndr_push *ndr, uint32_t extra_size); 431 488 void ndr_print_debug_helper(struct ndr_print *ndr, const char *format, ...) PRINTF_ATTRIBUTE(2,3); 489 void ndr_print_debugc_helper(struct ndr_print *ndr, const char *format, ...) PRINTF_ATTRIBUTE(2,3); 432 490 void ndr_print_printf_helper(struct ndr_print *ndr, const char *format, ...) PRINTF_ATTRIBUTE(2,3); 433 491 void ndr_print_string_helper(struct ndr_print *ndr, const char *format, ...) PRINTF_ATTRIBUTE(2,3); 434 492 void ndr_print_debug(ndr_print_fn_t fn, const char *name, void *ptr); 493 void ndr_print_debugc(int dbgc_class, ndr_print_fn_t fn, const char *name, void *ptr); 435 494 void ndr_print_union_debug(ndr_print_fn_t fn, const char *name, uint32_t level, void *ptr); 436 495 void ndr_print_function_debug(ndr_print_function_t fn, const char *name, int flags, void *ptr);
Note:
See TracChangeset
for help on using the changeset viewer.