Line data Source code
1 : /*
2 : Unix SMB/CIFS implementation.
3 :
4 : routines for marshalling/unmarshalling spoolss subcontext buffer structures
5 :
6 : Copyright (C) Stefan Metzmacher 2005
7 :
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.
12 :
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.
17 :
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/>.
20 : */
21 :
22 :
23 : #include "includes.h"
24 : #include "librpc/gen_ndr/ndr_krb5pac.h"
25 :
26 53111 : size_t _ndr_size_PAC_INFO(const union PAC_INFO *r, uint32_t level, libndr_flags flags)
27 : {
28 53111 : size_t s = ndr_size_PAC_INFO(r, level, flags);
29 53111 : switch (level) {
30 6620 : case PAC_TYPE_LOGON_INFO:
31 6620 : return NDR_ROUND(s,8);
32 6608 : case PAC_TYPE_UPN_DNS_INFO:
33 6608 : return NDR_ROUND(s,8);
34 39786 : default:
35 39786 : return s;
36 : }
37 : }
38 :
39 53111 : enum ndr_err_code ndr_push_PAC_BUFFER(struct ndr_push *ndr, ndr_flags_type ndr_flags, const struct PAC_BUFFER *r)
40 : {
41 53111 : if (ndr_flags & NDR_SCALARS) {
42 26556 : NDR_CHECK(ndr_push_align(ndr, 4));
43 26556 : NDR_CHECK(ndr_push_PAC_TYPE(ndr, NDR_SCALARS, r->type));
44 26556 : NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, _ndr_size_PAC_INFO(r->info,r->type,LIBNDR_FLAG_ALIGN8)));
45 : {
46 26556 : libndr_flags _flags_save_PAC_INFO = ndr->flags;
47 26556 : ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN8);
48 26556 : NDR_CHECK(ndr_push_relative_ptr1(ndr, r->info));
49 26556 : ndr->flags = _flags_save_PAC_INFO;
50 : }
51 26556 : NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
52 : }
53 53111 : if (ndr_flags & NDR_BUFFERS) {
54 : {
55 26556 : libndr_flags _flags_save_PAC_INFO = ndr->flags;
56 26556 : ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN8);
57 26556 : if (r->info) {
58 26555 : NDR_CHECK(ndr_push_relative_ptr2_start(ndr, r->info));
59 : {
60 70 : struct ndr_push *_ndr_info_pad;
61 70 : struct ndr_push *_ndr_info;
62 26555 : size_t _ndr_size = _ndr_size_PAC_INFO(r->info, r->type, LIBNDR_FLAG_ALIGN8);
63 26555 : NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_info_pad, 0, NDR_ROUND(_ndr_size, 8)));
64 26555 : NDR_CHECK(ndr_push_subcontext_start(_ndr_info_pad, &_ndr_info, 0, _ndr_size));
65 26555 : NDR_CHECK(ndr_push_set_switch_value(_ndr_info, r->info, r->type));
66 26555 : NDR_CHECK(ndr_push_PAC_INFO(_ndr_info, NDR_SCALARS|NDR_BUFFERS, r->info));
67 26555 : NDR_CHECK(ndr_push_subcontext_end(_ndr_info_pad, _ndr_info, 0, _ndr_size));
68 26555 : NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_info_pad, 0, NDR_ROUND(_ndr_size, 8)));
69 : }
70 26555 : NDR_CHECK(ndr_push_relative_ptr2_end(ndr, r->info));
71 : }
72 26556 : ndr->flags = _flags_save_PAC_INFO;
73 : }
74 : }
75 52970 : return NDR_ERR_SUCCESS;
76 : }
77 :
78 348136 : enum ndr_err_code ndr_pull_PAC_BUFFER(struct ndr_pull *ndr, ndr_flags_type ndr_flags, struct PAC_BUFFER *r)
79 : {
80 368 : uint32_t _ptr_info;
81 368 : TALLOC_CTX *_mem_save_info_0;
82 348136 : if (ndr_flags & NDR_SCALARS) {
83 174069 : NDR_CHECK(ndr_pull_align(ndr, 4));
84 174069 : NDR_CHECK(ndr_pull_PAC_TYPE(ndr, NDR_SCALARS, &r->type));
85 174069 : NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->_ndr_size));
86 : {
87 174069 : libndr_flags _flags_save_PAC_INFO = ndr->flags;
88 174069 : ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN8);
89 174069 : NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info));
90 174069 : if (_ptr_info) {
91 174067 : NDR_PULL_ALLOC(ndr, r->info);
92 174067 : NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->info, _ptr_info));
93 : } else {
94 2 : r->info = NULL;
95 : }
96 174069 : ndr->flags = _flags_save_PAC_INFO;
97 : }
98 174069 : NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->_pad));
99 : }
100 348136 : if (ndr_flags & NDR_BUFFERS) {
101 : {
102 174069 : libndr_flags _flags_save_PAC_INFO = ndr->flags;
103 174069 : ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN8);
104 174069 : if (r->info) {
105 183 : uint32_t _relative_save_offset;
106 174067 : _relative_save_offset = ndr->offset;
107 174067 : NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->info));
108 174067 : _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr);
109 174067 : NDR_PULL_SET_MEM_CTX(ndr, r->info, 0);
110 : {
111 183 : struct ndr_pull *_ndr_info_pad;
112 183 : struct ndr_pull *_ndr_info;
113 174067 : NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_info_pad, 0, NDR_ROUND(r->_ndr_size, 8)));
114 174067 : NDR_CHECK(ndr_pull_subcontext_start(_ndr_info_pad, &_ndr_info, 0, r->_ndr_size));
115 174067 : NDR_CHECK(ndr_pull_set_switch_value(_ndr_info, r->info, r->type));
116 174067 : NDR_CHECK(ndr_pull_PAC_INFO(_ndr_info, NDR_SCALARS|NDR_BUFFERS, r->info));
117 174067 : NDR_CHECK(ndr_pull_subcontext_end(_ndr_info_pad, _ndr_info, 0, r->_ndr_size));
118 174067 : NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_info_pad, 0, NDR_ROUND(r->_ndr_size, 8)));
119 : }
120 174067 : NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0);
121 174067 : if (ndr->offset > ndr->relative_highest_offset) {
122 152023 : ndr->relative_highest_offset = ndr->offset;
123 : }
124 174067 : ndr->offset = _relative_save_offset;
125 : }
126 174069 : ndr->flags = _flags_save_PAC_INFO;
127 : }
128 : }
129 347768 : return NDR_ERR_SUCCESS;
130 : }
|