libwbclient: Actually implement wbcCredentialCache()
[Samba/nascimento.git] / librpc / ndr / ndr_krb5pac.c
blobf6654f7380526ce1132e58f70b0d26a5cee907e7
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, struct smb_iconv_convenience *ic, int flags)
28 size_t s = ndr_size_PAC_INFO(r, level, ic, 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, struct smb_iconv_convenience *ic, int flags)
39 size_t s = ndr_size_PAC_INFO(r, level, ic, 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,ndr->iconv_convenience,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(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,ndr->iconv_convenience, 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,ndr->iconv_convenience,0)));
71 ndr->flags = _flags_save_PAC_INFO;
74 return NDR_ERR_SUCCESS;
77 enum ndr_err_code ndr_pull_PAC_BUFFER(struct ndr_pull *ndr, int ndr_flags, struct PAC_BUFFER *r)
79 uint32_t _ptr_info;
80 TALLOC_CTX *_mem_save_info_0;
81 if (ndr_flags & NDR_SCALARS) {
82 NDR_CHECK(ndr_pull_align(ndr, 4));
83 NDR_CHECK(ndr_pull_PAC_TYPE(ndr, NDR_SCALARS, &r->type));
84 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->_ndr_size));
86 uint32_t _flags_save_PAC_INFO = ndr->flags;
87 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN8);
88 NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info));
89 if (_ptr_info) {
90 NDR_PULL_ALLOC(ndr, r->info);
91 NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->info, _ptr_info));
92 } else {
93 r->info = NULL;
95 ndr->flags = _flags_save_PAC_INFO;
97 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->_pad));
99 if (ndr_flags & NDR_BUFFERS) {
101 uint32_t _flags_save_PAC_INFO = ndr->flags;
102 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN8);
103 if (r->info) {
104 uint32_t _relative_save_offset;
105 _relative_save_offset = ndr->offset;
106 NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->info));
107 _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr);
108 NDR_PULL_SET_MEM_CTX(ndr, r->info, 0);
110 struct ndr_pull *_ndr_info;
111 NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_info, 0, r->_ndr_size));
112 NDR_CHECK(ndr_pull_set_switch_value(_ndr_info, r->info, r->type));
113 NDR_CHECK(ndr_pull_PAC_INFO(_ndr_info, NDR_SCALARS|NDR_BUFFERS, r->info));
114 NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_info, 0, r->_ndr_size));
116 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0);
117 ndr->offset = _relative_save_offset;
119 ndr->flags = _flags_save_PAC_INFO;
122 return NDR_ERR_SUCCESS;
125 void ndr_print_PAC_BUFFER(struct ndr_print *ndr, const char *name, const struct PAC_BUFFER *r)
127 ndr_print_struct(ndr, name, "PAC_BUFFER");
128 ndr->depth++;
129 ndr_print_PAC_TYPE(ndr, "type", r->type);
130 ndr_print_uint32(ndr, "_ndr_size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?_ndr_size_PAC_INFO(r->info,r->type,ndr->iconv_convenience,0):r->_ndr_size);
131 ndr_print_ptr(ndr, "info", r->info);
132 ndr->depth++;
133 if (r->info) {
134 ndr_print_set_switch_value(ndr, r->info, r->type);
135 ndr_print_PAC_INFO(ndr, "info", r->info);
137 ndr->depth--;
138 ndr_print_uint32(ndr, "_pad", r->_pad);
139 ndr->depth--;