#include "glob.h"
#include "ndr.h"
-#define PAYLOAD_HEAD(d) ((d)->data + (d)->offset)
+static inline char *ndr_get_field(struct ndr *n)
+{
+ return n->data + n->offset;
+}
static int try_to_realloc_ndr_blob(struct ndr *n, size_t sz)
{
if (n->length <= n->offset + sizeof(value))
try_to_realloc_ndr_blob(n, sizeof(value));
- *(__le16 *)PAYLOAD_HEAD(n) = cpu_to_le16(value);
+ *(__le16 *)ndr_get_field(n) = cpu_to_le16(value);
n->offset += sizeof(value);
}
if (n->length <= n->offset + sizeof(value))
try_to_realloc_ndr_blob(n, sizeof(value));
- *(__le32 *)PAYLOAD_HEAD(n) = cpu_to_le32(value);
+ *(__le32 *)ndr_get_field(n) = cpu_to_le32(value);
n->offset += sizeof(value);
}
if (n->length <= n->offset + sizeof(value))
try_to_realloc_ndr_blob(n, sizeof(value));
- *(__le64 *)PAYLOAD_HEAD(n) = cpu_to_le64(value);
+ *(__le64 *)ndr_get_field(n) = cpu_to_le64(value);
n->offset += sizeof(value);
}
if (n->length <= n->offset + sz)
try_to_realloc_ndr_blob(n, sz);
- memcpy(PAYLOAD_HEAD(n), value, sz);
+ memcpy(ndr_get_field(n), value, sz);
n->offset += sz;
return 0;
}
if (n->length <= n->offset + sz)
try_to_realloc_ndr_blob(n, sz);
- strncpy(PAYLOAD_HEAD(n), value, sz);
+ strncpy(ndr_get_field(n), value, sz);
sz++;
n->offset += sz;
n->offset = ALIGN(n->offset, 2);
static int ndr_read_string(struct ndr *n, void *value, size_t sz)
{
- int len = strnlen(PAYLOAD_HEAD(n), sz);
+ int len = strnlen(ndr_get_field(n), sz);
- memcpy(value, PAYLOAD_HEAD(n), len);
+ memcpy(value, ndr_get_field(n), len);
len++;
n->offset += len;
n->offset = ALIGN(n->offset, 2);
static int ndr_read_bytes(struct ndr *n, void *value, size_t sz)
{
- memcpy(value, PAYLOAD_HEAD(n), sz);
+ memcpy(value, ndr_get_field(n), sz);
n->offset += sz;
return 0;
}
{
__u16 ret;
- ret = le16_to_cpu(*(__le16 *)PAYLOAD_HEAD(n));
+ ret = le16_to_cpu(*(__le16 *)ndr_get_field(n));
n->offset += sizeof(__u16);
return ret;
}
{
__u32 ret;
- ret = le32_to_cpu(*(__le32 *)PAYLOAD_HEAD(n));
+ ret = le32_to_cpu(*(__le32 *)ndr_get_field(n));
n->offset += sizeof(__u32);
return ret;
}
{
__u64 ret;
- ret = le64_to_cpu(*(__le64 *)PAYLOAD_HEAD(n));
+ ret = le64_to_cpu(*(__le64 *)ndr_get_field(n));
n->offset += sizeof(__u64);
return ret;
}