/* pull a relative object - stage1 called during SCALARS processing */ _PUBLIC_ enum ndr_err_code ndr_pull_relative_ptr1(struct ndr_pull *ndr, const void *p, uint32_t rel_offset) { rel_offset += ndr->relative_base_offset; if (rel_offset > ndr->data_size) { return ndr_pull_error(ndr, NDR_ERR_BUFSIZE, "ndr_pull_relative_ptr1 rel_offset(%u) > ndr->data_size(%u)", rel_offset, ndr->data_size); } return ndr_token_store(ndr, &ndr->relative_list, p, rel_offset); }
/* push a relative object - stage1 this is called during SCALARS processing */ _PUBLIC_ enum ndr_err_code ndr_push_relative_ptr1(struct ndr_push *ndr, const void *p) { if (p == NULL) { NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); return NDR_ERR_SUCCESS; } NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_token_store(ndr, &ndr->relative_list, p, ndr->offset)); return ndr_push_uint32(ndr, NDR_SCALARS, 0xFFFFFFFF); }
/* pull an array length field and add it to the array_length_list token list */ _PUBLIC_ enum ndr_err_code ndr_pull_array_length(struct ndr_pull *ndr, const void *p) { uint32_t length, offset; NDR_CHECK(ndr_pull_uint3264(ndr, NDR_SCALARS, &offset)); if (offset != 0) { return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "non-zero array offset %u\n", offset); } NDR_CHECK(ndr_pull_uint3264(ndr, NDR_SCALARS, &length)); return ndr_token_store(ndr, &ndr->array_length_list, p, length); }
/* push a 'simple' full non-zero value if a pointer is non-NULL, otherwise 0 */ _PUBLIC_ enum ndr_err_code ndr_push_full_ptr(struct ndr_push *ndr, const void *p) { uint32_t ptr = 0; if (p) { /* Check if the pointer already exists and has an id */ ptr = ndr_token_peek(&ndr->full_ptr_list, p); if (ptr == 0) { ndr->ptr_count++; ptr = ndr->ptr_count; ndr_token_store(ndr, &ndr->full_ptr_list, p, ptr); } } return ndr_push_uint32(ndr, NDR_SCALARS, ptr); }
/* push a relative object - stage2 start this is called during buffers processing */ _PUBLIC_ enum ndr_err_code ndr_push_relative_ptr2_start(struct ndr_push *ndr, const void *p) { if (p == NULL) { return NDR_ERR_SUCCESS; } if (!(ndr->flags & LIBNDR_FLAG_RELATIVE_REVERSE)) { return ndr_push_relative_ptr2(ndr, p); } if (ndr->relative_end_offset == -1) { return ndr_push_error(ndr, NDR_ERR_RELATIVE, "ndr_push_relative_ptr2_start RELATIVE_REVERSE flag set and relative_end_offset %d", ndr->relative_end_offset); } NDR_CHECK(ndr_token_store(ndr, &ndr->relative_begin_list, p, ndr->offset)); return NDR_ERR_SUCCESS; }
/* push a relative object - stage2 start this is called during buffers processing */ _PUBLIC_ enum ndr_err_code ndr_push_relative_ptr2_start(struct ndr_push *ndr, const void *p) { if (p == NULL) { return NDR_ERR_SUCCESS; } if (!(ndr->flags & LIBNDR_FLAG_RELATIVE_REVERSE)) { uint32_t relative_offset; size_t pad; size_t align = 1; if (ndr->offset < ndr->relative_base_offset) { return ndr_push_error(ndr, NDR_ERR_BUFSIZE, "ndr_push_relative_ptr2_start ndr->offset(%u) < ndr->relative_base_offset(%u)", ndr->offset, ndr->relative_base_offset); } relative_offset = ndr->offset - ndr->relative_base_offset; if (ndr->flags & LIBNDR_FLAG_NOALIGN) { align = 1; } else if (ndr->flags & LIBNDR_FLAG_ALIGN2) { align = 2; } else if (ndr->flags & LIBNDR_FLAG_ALIGN4) { align = 4; } else if (ndr->flags & LIBNDR_FLAG_ALIGN8) { align = 8; } pad = ndr_align_size(relative_offset, align); if (pad) { NDR_CHECK(ndr_push_zero(ndr, pad)); } return ndr_push_relative_ptr2(ndr, p); } if (ndr->relative_end_offset == -1) { return ndr_push_error(ndr, NDR_ERR_RELATIVE, "ndr_push_relative_ptr2_start RELATIVE_REVERSE flag set and relative_end_offset %d", ndr->relative_end_offset); } NDR_CHECK(ndr_token_store(ndr, &ndr->relative_begin_list, p, ndr->offset)); return NDR_ERR_SUCCESS; }
_PUBLIC_ enum ndr_err_code ndr_print_set_switch_value(struct ndr_print *ndr, const void *p, uint32_t val) { return ndr_token_store(ndr, &ndr->switch_list, p, val); }
/* pull an array size field and add it to the array_size_list token list */ _PUBLIC_ enum ndr_err_code ndr_pull_array_size(struct ndr_pull *ndr, const void *p) { uint32_t size; NDR_CHECK(ndr_pull_uint3264(ndr, NDR_SCALARS, &size)); return ndr_token_store(ndr, &ndr->array_size_list, p, size); }
/* setup the current base for relative pointers for the pull called in the NDR_SCALAR stage */ _PUBLIC_ enum ndr_err_code ndr_pull_setup_relative_base_offset1(struct ndr_pull *ndr, const void *p, uint32_t offset) { ndr->relative_base_offset = offset; return ndr_token_store(ndr, &ndr->relative_base_list, p, offset); }