/* push some bytes */ _PUBLIC_ enum ndr_err_code ndr_push_bytes(struct ndr_push *ndr, const uint8_t *data, uint32_t n) { NDR_PUSH_NEED_BYTES(ndr, n); memcpy(ndr->data + ndr->offset, data, n); ndr->offset += n; return NDR_ERR_SUCCESS; }
/* push some zero bytes */ _PUBLIC_ enum ndr_err_code ndr_push_zero(struct ndr_push *ndr, uint32_t n) { NDR_PUSH_NEED_BYTES(ndr, n); memset(ndr->data + ndr->offset, 0, n); ndr->offset += n; return NDR_ERR_SUCCESS; }
/* push a uint8_t */ _PUBLIC_ enum ndr_err_code ndr_push_uint8(struct ndr_push *ndr, int ndr_flags, uint8_t v) { NDR_PUSH_NEED_BYTES(ndr, 1); SCVAL(ndr->data, ndr->offset, v); ndr->offset += 1; return NDR_ERR_SUCCESS; }
NTSTATUS ndr_push_charset(struct ndr_push *ndr, int ndr_flags, const char *var, uint32_t length, uint8_t byte_mul, charset_t chset) { ssize_t ret, required; if (NDR_BE(ndr) && chset == CH_UTF16) { chset = CH_UTF16BE; } required = byte_mul * length; NDR_PUSH_NEED_BYTES(ndr, required); ret = convert_string(CH_UNIX, chset, var, strlen(var), ndr->data+ndr->offset, required, False); if (ret == -1) { return ndr_push_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); } /* Make sure the remaining part of the string is filled with zeroes */ if (ret < required) { memset(ndr->data+ndr->offset+ret, 0, required-ret); } ndr->offset += required; return NT_STATUS_OK; }
/* push a uint32_t */ _PUBLIC_ enum ndr_err_code ndr_push_uint32(struct ndr_push *ndr, int ndr_flags, uint32_t v) { NDR_PUSH_ALIGN(ndr, 4); NDR_PUSH_NEED_BYTES(ndr, 4); NDR_SIVAL(ndr, ndr->offset, v); ndr->offset += 4; return NDR_ERR_SUCCESS; }
/* push a int16_t */ _PUBLIC_ enum ndr_err_code ndr_push_int16(struct ndr_push *ndr, int ndr_flags, int16_t v) { NDR_PUSH_ALIGN(ndr, 2); NDR_PUSH_NEED_BYTES(ndr, 2); NDR_SSVAL(ndr, ndr->offset, (uint16_t)v); ndr->offset += 2; return NDR_ERR_SUCCESS; }
/* push a double */ _PUBLIC_ enum ndr_err_code ndr_push_double(struct ndr_push *ndr, int ndr_flags, double v) { NDR_PUSH_ALIGN(ndr, 8); NDR_PUSH_NEED_BYTES(ndr, 8); memcpy(ndr->data+ndr->offset, &v, 8); ndr->offset += 8; return NDR_ERR_SUCCESS; }
/* push a pointer */ _PUBLIC_ enum ndr_err_code ndr_push_pointer(struct ndr_push *ndr, int ndr_flags, void* v) { uintptr_t h = (intptr_t)v; NDR_PUSH_ALIGN(ndr, sizeof(h)); NDR_PUSH_NEED_BYTES(ndr, sizeof(h)); memcpy(ndr->data+ndr->offset, &h, sizeof(h)); ndr->offset += sizeof(h); return NDR_ERR_SUCCESS; }
/* push a udlongr */ _PUBLIC_ enum ndr_err_code ndr_push_udlongr(struct ndr_push *ndr, int ndr_flags, uint64_t v) { NDR_PUSH_ALIGN(ndr, 4); NDR_PUSH_NEED_BYTES(ndr, 8); NDR_SIVAL(ndr, ndr->offset, (v>>32)); NDR_SIVAL(ndr, ndr->offset+4, (v & 0xFFFFFFFF)); ndr->offset += 8; return NDR_ERR_SUCCESS; }