samr: don't block the sam sid or the builtin domain sid in sid_to_name
[Samba.git] / librpc / ndr / ndr_krb5pac.c
blobf7db79110762416cc4c72b8c77f75f4245211fbd
1 /*
2 Unix SMB/CIFS implementation.
4 routines for marshalling/unmarshalling spoolss subcontext buffer structures
6 Copyright (C) Stefan Metzmacher 2005
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "includes.h"
24 #include "librpc/gen_ndr/ndr_krb5pac.h"
26 static size_t _ndr_size_PAC_INFO(const union PAC_INFO *r, uint32_t level, int flags)
28 size_t s = ndr_size_PAC_INFO(r, level, flags);
29 switch (level) {
30 case PAC_TYPE_LOGON_INFO:
31 return NDR_ROUND(s,8);
32 default:
33 return s;
37 static size_t _subcontext_size_PAC_INFO(const union PAC_INFO *r, uint32_t level, int flags)
39 size_t s = ndr_size_PAC_INFO(r, level, flags);
40 return NDR_ROUND(s,8);
43 enum ndr_err_code ndr_push_PAC_BUFFER(struct ndr_push *ndr, int ndr_flags, const struct PAC_BUFFER *r)
45 if (ndr_flags & NDR_SCALARS) {
46 NDR_CHECK(ndr_push_align(ndr, 4));
47 NDR_CHECK(ndr_push_PAC_TYPE(ndr, NDR_SCALARS, r->type));
48 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, _ndr_size_PAC_INFO(r->info,r->type,0)));
50 uint32_t _flags_save_PAC_INFO = ndr->flags;
51 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN8);
52 NDR_CHECK(ndr_push_relative_ptr1(ndr, r->info));
53 ndr->flags = _flags_save_PAC_INFO;
55 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
57 if (ndr_flags & NDR_BUFFERS) {
59 uint32_t _flags_save_PAC_INFO = ndr->flags;
60 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN8);
61 if (r->info) {
62 NDR_CHECK(ndr_push_relative_ptr2_start(ndr, r->info));
64 struct ndr_push *_ndr_info;
65 NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_info, 0, _subcontext_size_PAC_INFO(r->info,r->type,0)));
66 NDR_CHECK(ndr_push_set_switch_value(_ndr_info, r->info, r->type));
67 NDR_CHECK(ndr_push_PAC_INFO(_ndr_info, NDR_SCALARS|NDR_BUFFERS, r->info));
68 NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_info, 0, _subcontext_size_PAC_INFO(r->info,r->type,0)));
70 NDR_CHECK(ndr_push_relative_ptr2_end(ndr, r->info));
72 ndr->flags = _flags_save_PAC_INFO;
75 return NDR_ERR_SUCCESS;
78 enum ndr_err_code ndr_pull_PAC_BUFFER(struct ndr_pull *ndr, int ndr_flags, struct PAC_BUFFER *r)
80 uint32_t _ptr_info;
81 TALLOC_CTX *_mem_save_info_0;
82 if (ndr_flags & NDR_SCALARS) {
83 NDR_CHECK(ndr_pull_align(ndr, 4));
84 NDR_CHECK(ndr_pull_PAC_TYPE(ndr, NDR_SCALARS, &r->type));
85 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->_ndr_size));
87 uint32_t _flags_save_PAC_INFO = ndr->flags;
88 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN8);
89 NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info));
90 if (_ptr_info) {
91 NDR_PULL_ALLOC(ndr, r->info);
92 NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->info, _ptr_info));
93 } else {
94 r->info = NULL;
96 ndr->flags = _flags_save_PAC_INFO;
98 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->_pad));
100 if (ndr_flags & NDR_BUFFERS) {
102 uint32_t _flags_save_PAC_INFO = ndr->flags;
103 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN8);
104 if (r->info) {
105 uint32_t _relative_save_offset;
106 _relative_save_offset = ndr->offset;
107 NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->info));
108 _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr);
109 NDR_PULL_SET_MEM_CTX(ndr, r->info, 0);
111 struct ndr_pull *_ndr_info;
112 NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_info, 0, r->_ndr_size));
113 NDR_CHECK(ndr_pull_set_switch_value(_ndr_info, r->info, r->type));
114 NDR_CHECK(ndr_pull_PAC_INFO(_ndr_info, NDR_SCALARS|NDR_BUFFERS, r->info));
115 NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_info, 0, r->_ndr_size));
117 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0);
118 if (ndr->offset > ndr->relative_highest_offset) {
119 ndr->relative_highest_offset = ndr->offset;
121 ndr->offset = _relative_save_offset;
123 ndr->flags = _flags_save_PAC_INFO;
126 return NDR_ERR_SUCCESS;
129 void ndr_print_PAC_BUFFER(struct ndr_print *ndr, const char *name, const struct PAC_BUFFER *r)
131 ndr_print_struct(ndr, name, "PAC_BUFFER");
132 ndr->depth++;
133 ndr_print_PAC_TYPE(ndr, "type", r->type);
134 ndr_print_uint32(ndr, "_ndr_size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?_ndr_size_PAC_INFO(r->info,r->type,0):r->_ndr_size);
135 ndr_print_ptr(ndr, "info", r->info);
136 ndr->depth++;
137 if (r->info) {
138 ndr_print_set_switch_value(ndr, r->info, r->type);
139 ndr_print_PAC_INFO(ndr, "info", r->info);
141 ndr->depth--;
142 ndr_print_uint32(ndr, "_pad", r->_pad);
143 ndr->depth--;