From e62c5c9a8dd1258b776d40918026a1be4b71fb72 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 17 Nov 2003 09:34:19 +0000 Subject: use [subcontext] to make GetPrinter a bit easier in smbtorture (This used to be commit a5140985d8f57695b4165c72af217092da6fae5f) --- source4/librpc/ndr/ndr.c | 6 ++ source4/librpc/ndr/ndr_echo.c | 167 +-------------------------------------- source4/librpc/ndr/ndr_echo.h | 20 +---- source4/librpc/ndr/ndr_spoolss.c | 71 +++-------------- source4/librpc/ndr/ndr_spoolss.h | 7 +- 5 files changed, 22 insertions(+), 249 deletions(-) (limited to 'source4/librpc/ndr') diff --git a/source4/librpc/ndr/ndr.c b/source4/librpc/ndr/ndr.c index 5f941c703d..6d2a6a99dd 100644 --- a/source4/librpc/ndr/ndr.c +++ b/source4/librpc/ndr/ndr.c @@ -399,6 +399,9 @@ NTSTATUS ndr_pull_subcontext_flags_fn(struct ndr_pull *ndr, struct ndr_pull ndr2; NDR_CHECK(ndr_pull_uint32(ndr, &size)); + if (size == 0) { + return NT_STATUS_OK; + } NDR_CHECK(ndr_pull_subcontext(ndr, &ndr2, size)); NDR_CHECK(fn(&ndr2, NDR_SCALARS|NDR_BUFFERS, base)); NDR_CHECK(ndr_pull_advance(ndr, size)); @@ -414,6 +417,9 @@ NTSTATUS ndr_pull_subcontext_union_fn(struct ndr_pull *ndr, struct ndr_pull ndr2; NDR_CHECK(ndr_pull_uint32(ndr, &size)); + if (size == 0) { + return NT_STATUS_OK; + } NDR_CHECK(ndr_pull_subcontext(ndr, &ndr2, size)); NDR_CHECK(fn(&ndr2, NDR_SCALARS|NDR_BUFFERS, level, base)); NDR_CHECK(ndr_pull_advance(ndr, size)); diff --git a/source4/librpc/ndr/ndr_echo.c b/source4/librpc/ndr/ndr_echo.c index 0067518f89..62a2428792 100644 --- a/source4/librpc/ndr/ndr_echo.c +++ b/source4/librpc/ndr/ndr_echo.c @@ -40,6 +40,10 @@ NTSTATUS ndr_push_echo_SourceData(struct ndr_push *ndr, struct echo_SourceData * NTSTATUS ndr_push_TestCall(struct ndr_push *ndr, struct TestCall *r) { + NDR_CHECK(ndr_push_ptr(ndr, r->in.s)); + if (r->in.s) { + NDR_CHECK(ndr_push_unistr(ndr, r->in.s)); + } return NT_STATUS_OK; } @@ -90,172 +94,9 @@ NTSTATUS ndr_pull_echo_SourceData(struct ndr_pull *ndr, struct echo_SourceData * return NT_STATUS_OK; } -NTSTATUS ndr_pull_echo_Enum1(struct ndr_pull *ndr, int ndr_flags, struct echo_Enum1 *r) -{ - uint32 _ptr_count; - NDR_CHECK(ndr_pull_struct_start(ndr)); - if (!(ndr_flags & NDR_SCALARS)) goto buffers; - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_uint32(ndr, &_ptr_count)); - if (_ptr_count) { - NDR_ALLOC(ndr, r->count); - } else { - r->count = NULL; - } - ndr_pull_struct_end(ndr); -buffers: - if (!(ndr_flags & NDR_BUFFERS)) goto done; - if (r->count) { - NDR_CHECK(ndr_pull_uint32(ndr, r->count)); - } -done: - return NT_STATUS_OK; -} - -NTSTATUS ndr_pull_echo_Enum3(struct ndr_pull *ndr, int ndr_flags, struct echo_Enum3 *r) -{ - uint32 _ptr_count; - NDR_CHECK(ndr_pull_struct_start(ndr)); - if (!(ndr_flags & NDR_SCALARS)) goto buffers; - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_uint32(ndr, &_ptr_count)); - if (_ptr_count) { - NDR_ALLOC(ndr, r->count); - } else { - r->count = NULL; - } - ndr_pull_struct_end(ndr); -buffers: - if (!(ndr_flags & NDR_BUFFERS)) goto done; - if (r->count) { - NDR_CHECK(ndr_pull_uint32(ndr, r->count)); - } -done: - return NT_STATUS_OK; -} - -NTSTATUS ndr_pull_echo_EnumInfo(struct ndr_pull *ndr, int ndr_flags, uint16 *level, union echo_EnumInfo *r) -{ - if (!(ndr_flags & NDR_SCALARS)) goto buffers; - NDR_CHECK(ndr_pull_struct_start(ndr)); - NDR_CHECK(ndr_pull_uint16(ndr, level)); - switch (*level) { - case 1: { - NDR_CHECK(ndr_pull_echo_Enum1(ndr, NDR_SCALARS, &r->enum1)); - break; } - - case 3: { - NDR_CHECK(ndr_pull_echo_Enum3(ndr, NDR_SCALARS, &r->enum3)); - break; } - - default: - return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", *level); - } - ndr_pull_struct_end(ndr); -buffers: - if (!(ndr_flags & NDR_BUFFERS)) goto done; - switch (*level) { - case 1: - NDR_CHECK(ndr_pull_echo_Enum1(ndr, NDR_BUFFERS, &r->enum1)); - break; - - case 3: - NDR_CHECK(ndr_pull_echo_Enum3(ndr, NDR_BUFFERS, &r->enum3)); - break; - - default: - return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", *level); - } -done: - return NT_STATUS_OK; -} - -NTSTATUS ndr_pull_Struct1(struct ndr_pull *ndr, int ndr_flags, struct Struct1 *r) -{ - NDR_CHECK(ndr_pull_struct_start(ndr)); - if (!(ndr_flags & NDR_SCALARS)) goto buffers; - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_uint32(ndr, &r->level)); - { uint16 _level = r->level; - NDR_CHECK(ndr_pull_echo_EnumInfo(ndr, NDR_SCALARS, &_level, &r->e)); - if (((NDR_SCALARS) & NDR_SCALARS) && (_level != r->level)) return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u in e"); - } - ndr_pull_struct_end(ndr); -buffers: - if (!(ndr_flags & NDR_BUFFERS)) goto done; - { uint16 _level = r->level; - NDR_CHECK(ndr_pull_echo_EnumInfo(ndr, NDR_BUFFERS, &_level, &r->e)); - if (((NDR_BUFFERS) & NDR_SCALARS) && (_level != r->level)) return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u in e"); - } -done: - return NT_STATUS_OK; -} - NTSTATUS ndr_pull_TestCall(struct ndr_pull *ndr, struct TestCall *r) { - uint32 _ptr_s1; - NDR_CHECK(ndr_pull_uint32(ndr, &_ptr_s1)); - if (_ptr_s1) { - NDR_ALLOC(ndr, r->out.s1); - } else { - r->out.s1 = NULL; - } - if (r->out.s1) { - NDR_CHECK(ndr_pull_Struct1(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.s1)); - } return NT_STATUS_OK; } -void ndr_print_echo_Enum1(struct ndr_print *ndr, const char *name, struct echo_Enum1 *r) -{ - ndr_print_struct(ndr, name, "echo_Enum1"); - ndr->depth++; - ndr_print_ptr(ndr, "count", r->count); - ndr->depth++; - if (r->count) { - ndr_print_uint32(ndr, "count", *r->count); - } - ndr->depth--; - ndr->depth--; -} - -void ndr_print_echo_Enum3(struct ndr_print *ndr, const char *name, struct echo_Enum3 *r) -{ - ndr_print_struct(ndr, name, "echo_Enum3"); - ndr->depth++; - ndr_print_ptr(ndr, "count", r->count); - ndr->depth++; - if (r->count) { - ndr_print_uint32(ndr, "count", *r->count); - } - ndr->depth--; - ndr->depth--; -} - -void ndr_print_echo_EnumInfo(struct ndr_print *ndr, const char *name, uint16 level, union echo_EnumInfo *r) -{ - ndr_print_union(ndr, name, level, "echo_EnumInfo"); - switch (level) { - case 1: - ndr_print_echo_Enum1(ndr, "enum1", &r->enum1); - break; - - case 3: - ndr_print_echo_Enum3(ndr, "enum3", &r->enum3); - break; - - default: - ndr_print_bad_level(ndr, name, level); - } -} - -void ndr_print_Struct1(struct ndr_print *ndr, const char *name, struct Struct1 *r) -{ - ndr_print_struct(ndr, name, "Struct1"); - ndr->depth++; - ndr_print_uint32(ndr, "level", r->level); - ndr_print_echo_EnumInfo(ndr, "e", r->level, &r->e); - ndr->depth--; -} - diff --git a/source4/librpc/ndr/ndr_echo.h b/source4/librpc/ndr/ndr_echo.h index 5edc4241a6..d6b6f0eb96 100644 --- a/source4/librpc/ndr/ndr_echo.h +++ b/source4/librpc/ndr/ndr_echo.h @@ -45,30 +45,12 @@ struct echo_SourceData { }; -struct echo_Enum1 { - uint32 *count; -}; - -struct echo_Enum3 { - uint32 *count; -}; - -union echo_EnumInfo { -/* [case(1)] */ struct echo_Enum1 enum1; -/* [case(3)] */ struct echo_Enum3 enum3; -}; - -struct Struct1 { - uint32 level; - union echo_EnumInfo e; -}; - struct TestCall { struct { + const char *s; } in; struct { - struct Struct1 *s1; } out; }; diff --git a/source4/librpc/ndr/ndr_spoolss.c b/source4/librpc/ndr/ndr_spoolss.c index 27227d1b90..4f31fa682b 100644 --- a/source4/librpc/ndr/ndr_spoolss.c +++ b/source4/librpc/ndr/ndr_spoolss.c @@ -172,19 +172,6 @@ done: return NT_STATUS_OK; } -NTSTATUS ndr_push_spoolss_PrinterInfo6(struct ndr_push *ndr, int ndr_flags, struct spoolss_PrinterInfo6 *r) -{ - if (!(ndr_flags & NDR_SCALARS)) goto buffers; - NDR_CHECK(ndr_push_struct_start(ndr)); - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_uint32(ndr, r->foo)); - ndr_push_struct_end(ndr); -buffers: - if (!(ndr_flags & NDR_BUFFERS)) goto done; -done: - return NT_STATUS_OK; -} - NTSTATUS ndr_push_spoolss_PrinterInfo7(struct ndr_push *ndr, int ndr_flags, struct spoolss_PrinterInfo7 *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; @@ -225,10 +212,6 @@ NTSTATUS ndr_push_spoolss_PrinterInfo(struct ndr_push *ndr, int ndr_flags, uint1 NDR_CHECK(ndr_push_spoolss_PrinterInfo5(ndr, NDR_SCALARS, &r->info5)); break; - case 6: - NDR_CHECK(ndr_push_spoolss_PrinterInfo6(ndr, NDR_SCALARS, &r->info6)); - break; - case 7: NDR_CHECK(ndr_push_spoolss_PrinterInfo7(ndr, NDR_SCALARS, &r->info7)); break; @@ -260,10 +243,6 @@ buffers: NDR_CHECK(ndr_push_spoolss_PrinterInfo5(ndr, ndr_flags, &r->info5)); break; - case 6: - NDR_CHECK(ndr_push_spoolss_PrinterInfo6(ndr, ndr_flags, &r->info6)); - break; - case 7: NDR_CHECK(ndr_push_spoolss_PrinterInfo7(ndr, ndr_flags, &r->info7)); break; @@ -1148,19 +1127,6 @@ done: return NT_STATUS_OK; } -NTSTATUS ndr_pull_spoolss_PrinterInfo6(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo6 *r) -{ - NDR_CHECK(ndr_pull_struct_start(ndr)); - if (!(ndr_flags & NDR_SCALARS)) goto buffers; - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_uint32(ndr, &r->foo)); - ndr_pull_struct_end(ndr); -buffers: - if (!(ndr_flags & NDR_BUFFERS)) goto done; -done: - return NT_STATUS_OK; -} - NTSTATUS ndr_pull_spoolss_PrinterInfo7(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo7 *r) { NDR_CHECK(ndr_pull_struct_start(ndr)); @@ -1200,10 +1166,6 @@ NTSTATUS ndr_pull_spoolss_PrinterInfo(struct ndr_pull *ndr, int ndr_flags, uint1 NDR_CHECK(ndr_pull_spoolss_PrinterInfo5(ndr, NDR_SCALARS, &r->info5)); break; } - case 6: { - NDR_CHECK(ndr_pull_spoolss_PrinterInfo6(ndr, NDR_SCALARS, &r->info6)); - break; } - case 7: { NDR_CHECK(ndr_pull_spoolss_PrinterInfo7(ndr, NDR_SCALARS, &r->info7)); break; } @@ -1235,10 +1197,6 @@ buffers: NDR_CHECK(ndr_pull_spoolss_PrinterInfo5(ndr, NDR_BUFFERS, &r->info5)); break; - case 6: - NDR_CHECK(ndr_pull_spoolss_PrinterInfo6(ndr, NDR_BUFFERS, &r->info6)); - break; - case 7: NDR_CHECK(ndr_pull_spoolss_PrinterInfo7(ndr, NDR_BUFFERS, &r->info7)); break; @@ -1333,15 +1291,18 @@ NTSTATUS ndr_pull_spoolss_07(struct ndr_pull *ndr, struct spoolss_07 *r) NTSTATUS ndr_pull_spoolss_GetPrinter(struct ndr_pull *ndr, struct spoolss_GetPrinter *r) { - uint32 _ptr_buffer; - NDR_CHECK(ndr_pull_uint32(ndr, &_ptr_buffer)); - if (_ptr_buffer) { - NDR_ALLOC(ndr, r->out.buffer); + uint32 _ptr_info; + NDR_CHECK(ndr_pull_uint32(ndr, &_ptr_info)); + if (_ptr_info) { + NDR_ALLOC(ndr, r->out.info); } else { - r->out.buffer = NULL; + r->out.info = NULL; + } + if (r->out.info) { + { uint16 _level = r->in.level; + NDR_CHECK(ndr_pull_subcontext_union_fn(ndr, &_level, r->out.info, (ndr_pull_union_fn_t) ndr_pull_spoolss_PrinterInfo)); + if (((NDR_SCALARS|NDR_BUFFERS) & NDR_SCALARS) && (_level != r->in.level)) return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u in info"); } - if (r->out.buffer) { - NDR_CHECK(ndr_pull_DATA_BLOB(ndr, r->out.buffer)); } NDR_CHECK(ndr_pull_uint32(ndr, r->out.buf_size)); NDR_CHECK(ndr_pull_WERROR(ndr, &r->out.result)); @@ -2109,14 +2070,6 @@ void ndr_print_spoolss_PrinterInfo5(struct ndr_print *ndr, const char *name, str ndr->depth--; } -void ndr_print_spoolss_PrinterInfo6(struct ndr_print *ndr, const char *name, struct spoolss_PrinterInfo6 *r) -{ - ndr_print_struct(ndr, name, "spoolss_PrinterInfo6"); - ndr->depth++; - ndr_print_uint32(ndr, "foo", r->foo); - ndr->depth--; -} - void ndr_print_spoolss_PrinterInfo7(struct ndr_print *ndr, const char *name, struct spoolss_PrinterInfo7 *r) { ndr_print_struct(ndr, name, "spoolss_PrinterInfo7"); @@ -2150,10 +2103,6 @@ void ndr_print_spoolss_PrinterInfo(struct ndr_print *ndr, const char *name, uint ndr_print_spoolss_PrinterInfo5(ndr, "info5", &r->info5); break; - case 6: - ndr_print_spoolss_PrinterInfo6(ndr, "info6", &r->info6); - break; - case 7: ndr_print_spoolss_PrinterInfo7(ndr, "info7", &r->info7); break; diff --git a/source4/librpc/ndr/ndr_spoolss.h b/source4/librpc/ndr/ndr_spoolss.h index 3f156b732d..33881ab41b 100644 --- a/source4/librpc/ndr/ndr_spoolss.h +++ b/source4/librpc/ndr/ndr_spoolss.h @@ -88,10 +88,6 @@ struct spoolss_PrinterInfo5 { uint32 transmission_retry_timeout; }; -struct spoolss_PrinterInfo6 { - uint32 foo; -}; - struct spoolss_PrinterInfo7 { const char * guid; uint32 action; @@ -103,7 +99,6 @@ union spoolss_PrinterInfo { /* [case(3)] */ struct spoolss_PrinterInfo3 info3; /* [case(4)] */ struct spoolss_PrinterInfo4 info4; /* [case(5)] */ struct spoolss_PrinterInfo5 info5; -/* [case(6)] */ struct spoolss_PrinterInfo6 info6; /* [case(7)] */ struct spoolss_PrinterInfo7 info7; }; @@ -218,7 +213,7 @@ struct spoolss_GetPrinter { } in; struct { - DATA_BLOB *buffer; + union spoolss_PrinterInfo *info; uint32 *buf_size; WERROR result; } out; -- cgit