lib:util: Move debug message for mkdir failing to log level 1
[Samba.git] / librpc / ndr / ndr_krb5pac.c
bloba9ae2c4a789c1b02920a6b16817550597880713f
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 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 case PAC_TYPE_UPN_DNS_INFO:
33 return NDR_ROUND(s,8);
34 default:
35 return s;
39 enum ndr_err_code ndr_push_PAC_BUFFER(struct ndr_push *ndr, int ndr_flags, const struct PAC_BUFFER *r)
41 if (ndr_flags & NDR_SCALARS) {
42 NDR_CHECK(ndr_push_align(ndr, 4));
43 NDR_CHECK(ndr_push_PAC_TYPE(ndr, NDR_SCALARS, r->type));
44 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, _ndr_size_PAC_INFO(r->info,r->type,0)));
46 uint32_t _flags_save_PAC_INFO = ndr->flags;
47 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN8);
48 NDR_CHECK(ndr_push_relative_ptr1(ndr, r->info));
49 ndr->flags = _flags_save_PAC_INFO;
51 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
53 if (ndr_flags & NDR_BUFFERS) {
55 uint32_t _flags_save_PAC_INFO = ndr->flags;
56 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN8);
57 if (r->info) {
58 NDR_CHECK(ndr_push_relative_ptr2_start(ndr, r->info));
60 struct ndr_push *_ndr_info_pad;
61 struct ndr_push *_ndr_info;
62 size_t _ndr_size = _ndr_size_PAC_INFO(r->info, r->type, 0);
63 NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_info_pad, 0, NDR_ROUND(_ndr_size, 8)));
64 NDR_CHECK(ndr_push_subcontext_start(_ndr_info_pad, &_ndr_info, 0, _ndr_size));
65 NDR_CHECK(ndr_push_set_switch_value(_ndr_info, r->info, r->type));
66 NDR_CHECK(ndr_push_PAC_INFO(_ndr_info, NDR_SCALARS|NDR_BUFFERS, r->info));
67 NDR_CHECK(ndr_push_subcontext_end(_ndr_info_pad, _ndr_info, 0, _ndr_size));
68 NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_info_pad, 0, NDR_ROUND(_ndr_size, 8)));
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_pad;
112 struct ndr_pull *_ndr_info;
113 NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_info_pad, 0, NDR_ROUND(r->_ndr_size, 8)));
114 NDR_CHECK(ndr_pull_subcontext_start(_ndr_info_pad, &_ndr_info, 0, r->_ndr_size));
115 NDR_CHECK(ndr_pull_set_switch_value(_ndr_info, r->info, r->type));
116 NDR_CHECK(ndr_pull_PAC_INFO(_ndr_info, NDR_SCALARS|NDR_BUFFERS, r->info));
117 NDR_CHECK(ndr_pull_subcontext_end(_ndr_info_pad, _ndr_info, 0, r->_ndr_size));
118 NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_info_pad, 0, NDR_ROUND(r->_ndr_size, 8)));
120 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0);
121 if (ndr->offset > ndr->relative_highest_offset) {
122 ndr->relative_highest_offset = ndr->offset;
124 ndr->offset = _relative_save_offset;
126 ndr->flags = _flags_save_PAC_INFO;
129 return NDR_ERR_SUCCESS;