libndr: implement LIBNDR_RELATIVE_REVERSE handling
[ira/wip.git] / librpc / ndr / libndr.h
index f6f517064616d43904a442f874d3b4d16727e8db..72e8d21ba40a40836ef4ff1eabcf431a4c275ed6 100644 (file)
@@ -62,6 +62,7 @@ struct ndr_pull {
 
        struct smb_iconv_convenience *iconv_convenience;
 
+       uint32_t relative_highest_offset;
        uint32_t relative_base_offset;
        struct ndr_token_list *relative_base_list;
 
@@ -85,10 +86,12 @@ struct ndr_push {
        uint32_t offset;
 
        uint32_t relative_base_offset;
+       uint32_t relative_end_offset;
        struct ndr_token_list *relative_base_list;
 
        struct ndr_token_list *switch_list;
        struct ndr_token_list *relative_list;
+       struct ndr_token_list *relative_begin_list;
        struct ndr_token_list *nbt_string_list;
        struct ndr_token_list *full_ptr_list;
 
@@ -123,6 +126,11 @@ struct ndr_print {
 #define LIBNDR_FLAG_STR_UTF8           (1<<12)
 #define LIBNDR_STRING_FLAGS            (0x7FFC)
 
+/* set if relative pointers should *not* be marshalled in reverse order */
+#define LIBNDR_FLAG_NO_RELATIVE_REVERSE        (1<<18)
+
+/* set if relative pointers are marshalled in reverse order */
+#define LIBNDR_FLAG_RELATIVE_REVERSE   (1<<19)
 
 #define LIBNDR_FLAG_REF_ALLOC    (1<<20)
 #define LIBNDR_FLAG_REMAINING    (1<<21)
@@ -382,13 +390,17 @@ void ndr_push_restore_relative_base_offset(struct ndr_push *ndr, uint32_t offset
 enum ndr_err_code ndr_push_setup_relative_base_offset1(struct ndr_push *ndr, const void *p, uint32_t offset);
 enum ndr_err_code ndr_push_setup_relative_base_offset2(struct ndr_push *ndr, const void *p);
 enum ndr_err_code ndr_push_relative_ptr1(struct ndr_push *ndr, const void *p);
-enum ndr_err_code ndr_push_relative_ptr2(struct ndr_push *ndr, const void *p);
+enum ndr_err_code ndr_push_short_relative_ptr1(struct ndr_push *ndr, const void *p);
+enum ndr_err_code ndr_push_relative_ptr2_start(struct ndr_push *ndr, const void *p);
+enum ndr_err_code ndr_push_relative_ptr2_end(struct ndr_push *ndr, const void *p);
+enum ndr_err_code ndr_push_short_relative_ptr2(struct ndr_push *ndr, const void *p);
 uint32_t ndr_pull_get_relative_base_offset(struct ndr_pull *ndr);
 void ndr_pull_restore_relative_base_offset(struct ndr_pull *ndr, uint32_t offset);
 enum ndr_err_code ndr_pull_setup_relative_base_offset1(struct ndr_pull *ndr, const void *p, uint32_t offset);
 enum ndr_err_code ndr_pull_setup_relative_base_offset2(struct ndr_pull *ndr, const void *p);
 enum ndr_err_code ndr_pull_relative_ptr1(struct ndr_pull *ndr, const void *p, uint32_t rel_offset);
 enum ndr_err_code ndr_pull_relative_ptr2(struct ndr_pull *ndr, const void *p);
+enum ndr_err_code ndr_pull_relative_ptr_short(struct ndr_pull *ndr, uint16_t *v);
 size_t ndr_align_size(uint32_t offset, size_t n);
 struct ndr_pull *ndr_pull_init_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience);
 enum ndr_err_code ndr_pull_advance(struct ndr_pull *ndr, uint32_t size);
@@ -432,7 +444,7 @@ enum ndr_err_code ndr_token_store(TALLOC_CTX *mem_ctx,
                         struct ndr_token_list **list, 
                         const void *key, 
                         uint32_t value);
-enum ndr_err_code ndr_token_retrieve_cmp_fn(struct ndr_token_list **list, const void *key, uint32_t *v, comparison_fn_t _cmp_fn, bool _remove_tok);
+enum ndr_err_code ndr_token_retrieve_cmp_fn(struct ndr_token_list **list, const void *key, uint32_t *v, int(*_cmp_fn)(const void*,const void*), bool _remove_tok);
 enum ndr_err_code ndr_token_retrieve(struct ndr_token_list **list, const void *key, uint32_t *v);
 uint32_t ndr_token_peek(struct ndr_token_list **list, const void *key);
 enum ndr_err_code ndr_pull_array_size(struct ndr_pull *ndr, const void *p);
@@ -467,9 +479,11 @@ NDR_SCALAR_PROTO(uint8, uint8_t)
 NDR_SCALAR_PROTO(int8, int8_t)
 NDR_SCALAR_PROTO(uint16, uint16_t)
 NDR_SCALAR_PROTO(int16, int16_t)
+NDR_SCALAR_PROTO(uint1632, uint16_t)
 NDR_SCALAR_PROTO(uint32, uint32_t)
 NDR_SCALAR_PROTO(uint3264, uint32_t)
 NDR_SCALAR_PROTO(int32, int32_t)
+NDR_SCALAR_PROTO(int3264, int32_t)
 NDR_SCALAR_PROTO(udlong, uint64_t)
 NDR_SCALAR_PROTO(udlongr, uint64_t)
 NDR_SCALAR_PROTO(dlong, int64_t)
@@ -500,6 +514,8 @@ enum ndr_err_code ndr_push_align(struct ndr_push *ndr, size_t size);
 enum ndr_err_code ndr_pull_align(struct ndr_pull *ndr, size_t size);
 enum ndr_err_code ndr_push_union_align(struct ndr_push *ndr, size_t size);
 enum ndr_err_code ndr_pull_union_align(struct ndr_pull *ndr, size_t size);
+enum ndr_err_code ndr_push_trailer_align(struct ndr_push *ndr, size_t size);
+enum ndr_err_code ndr_pull_trailer_align(struct ndr_pull *ndr, size_t size);
 enum ndr_err_code ndr_push_bytes(struct ndr_push *ndr, const uint8_t *data, uint32_t n);
 enum ndr_err_code ndr_push_zero(struct ndr_push *ndr, uint32_t n);
 enum ndr_err_code ndr_push_array_uint8(struct ndr_push *ndr, int ndr_flags, const uint8_t *data, uint32_t n);
@@ -531,6 +547,8 @@ enum ndr_err_code ndr_push_charset(struct ndr_push *ndr, int ndr_flags, const ch
 
 /* GUIDs */
 bool GUID_equal(const struct GUID *u1, const struct GUID *u2);
+NTSTATUS GUID_to_ndr_blob(const struct GUID *guid, TALLOC_CTX *mem_ctx, DATA_BLOB *b);
+NTSTATUS GUID_from_ndr_blob(const DATA_BLOB *b, struct GUID *guid);
 NTSTATUS GUID_from_data_blob(const DATA_BLOB *s, struct GUID *guid);
 NTSTATUS GUID_from_string(const char *s, struct GUID *guid);
 NTSTATUS NS_GUID_from_string(const char *s, struct GUID *guid);
@@ -546,8 +564,10 @@ struct GUID GUID_random(void);
 _PUBLIC_ enum ndr_err_code ndr_pull_enum_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *v);
 _PUBLIC_ enum ndr_err_code ndr_pull_enum_uint16(struct ndr_pull *ndr, int ndr_flags, uint16_t *v);
 _PUBLIC_ enum ndr_err_code ndr_pull_enum_uint32(struct ndr_pull *ndr, int ndr_flags, uint32_t *v);
+_PUBLIC_ enum ndr_err_code ndr_pull_enum_uint1632(struct ndr_pull *ndr, int ndr_flags, uint16_t *v);
 _PUBLIC_ enum ndr_err_code ndr_push_enum_uint8(struct ndr_push *ndr, int ndr_flags, uint8_t v);
 _PUBLIC_ enum ndr_err_code ndr_push_enum_uint16(struct ndr_push *ndr, int ndr_flags, uint16_t v);
 _PUBLIC_ enum ndr_err_code ndr_push_enum_uint32(struct ndr_push *ndr, int ndr_flags, uint32_t v);
+_PUBLIC_ enum ndr_err_code ndr_push_enum_uint1632(struct ndr_push *ndr, int ndr_flags, uint16_t v);
 
 #endif /* __LIBNDR_H__ */