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 4558 : size_t _ndr_size_PAC_INFO(const union PAC_INFO *r, uint32_t level, int flags)
27 : {
28 4558 : size_t s = ndr_size_PAC_INFO(r, level, flags);
29 4558 : switch (level) {
30 650 : case PAC_TYPE_LOGON_INFO:
31 650 : return NDR_ROUND(s,8);
32 650 : case PAC_TYPE_UPN_DNS_INFO:
33 650 : return NDR_ROUND(s,8);
34 3258 : default:
35 3258 : return s;
36 : }
37 : }
38 :
39 4558 : enum ndr_err_code ndr_push_PAC_BUFFER(struct ndr_push *ndr, int ndr_flags, const struct PAC_BUFFER *r)
40 : {
41 4558 : if (ndr_flags & NDR_SCALARS) {
42 2279 : NDR_CHECK(ndr_push_align(ndr, 4));
43 2279 : NDR_CHECK(ndr_push_PAC_TYPE(ndr, NDR_SCALARS, r->type));
44 2279 : NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, _ndr_size_PAC_INFO(r->info,r->type,LIBNDR_FLAG_ALIGN8)));
45 : {
46 2279 : uint32_t _flags_save_PAC_INFO = ndr->flags;
47 2279 : ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN8);
48 2279 : NDR_CHECK(ndr_push_relative_ptr1(ndr, r->info));
49 2279 : ndr->flags = _flags_save_PAC_INFO;
50 : }
51 2279 : NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
52 : }
53 4558 : if (ndr_flags & NDR_BUFFERS) {
54 : {
55 2279 : uint32_t _flags_save_PAC_INFO = ndr->flags;
56 2279 : ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN8);
57 2279 : if (r->info) {
58 2279 : NDR_CHECK(ndr_push_relative_ptr2_start(ndr, r->info));
59 : {
60 : struct ndr_push *_ndr_info_pad;
61 : struct ndr_push *_ndr_info;
62 2279 : size_t _ndr_size = _ndr_size_PAC_INFO(r->info, r->type, LIBNDR_FLAG_ALIGN8);
63 2279 : NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_info_pad, 0, NDR_ROUND(_ndr_size, 8)));
64 2279 : NDR_CHECK(ndr_push_subcontext_start(_ndr_info_pad, &_ndr_info, 0, _ndr_size));
65 2279 : NDR_CHECK(ndr_push_set_switch_value(_ndr_info, r->info, r->type));
66 2279 : NDR_CHECK(ndr_push_PAC_INFO(_ndr_info, NDR_SCALARS|NDR_BUFFERS, r->info));
67 2279 : NDR_CHECK(ndr_push_subcontext_end(_ndr_info_pad, _ndr_info, 0, _ndr_size));
68 2279 : NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_info_pad, 0, NDR_ROUND(_ndr_size, 8)));
69 : }
70 2279 : NDR_CHECK(ndr_push_relative_ptr2_end(ndr, r->info));
71 : }
72 2279 : ndr->flags = _flags_save_PAC_INFO;
73 : }
74 : }
75 4558 : return NDR_ERR_SUCCESS;
76 : }
77 :
78 105922 : enum ndr_err_code ndr_pull_PAC_BUFFER(struct ndr_pull *ndr, int ndr_flags, struct PAC_BUFFER *r)
79 : {
80 : uint32_t _ptr_info;
81 : TALLOC_CTX *_mem_save_info_0;
82 105922 : if (ndr_flags & NDR_SCALARS) {
83 52961 : NDR_CHECK(ndr_pull_align(ndr, 4));
84 52961 : NDR_CHECK(ndr_pull_PAC_TYPE(ndr, NDR_SCALARS, &r->type));
85 52961 : NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->_ndr_size));
86 : {
87 52961 : uint32_t _flags_save_PAC_INFO = ndr->flags;
88 52961 : ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN8);
89 52961 : NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info));
90 52961 : if (_ptr_info) {
91 52961 : NDR_PULL_ALLOC(ndr, r->info);
92 52961 : NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->info, _ptr_info));
93 : } else {
94 0 : r->info = NULL;
95 : }
96 52961 : ndr->flags = _flags_save_PAC_INFO;
97 : }
98 52961 : NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->_pad));
99 : }
100 105922 : if (ndr_flags & NDR_BUFFERS) {
101 : {
102 52961 : uint32_t _flags_save_PAC_INFO = ndr->flags;
103 52961 : ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN8);
104 52961 : if (r->info) {
105 : uint32_t _relative_save_offset;
106 52961 : _relative_save_offset = ndr->offset;
107 52961 : NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->info));
108 52961 : _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr);
109 52961 : NDR_PULL_SET_MEM_CTX(ndr, r->info, 0);
110 : {
111 : struct ndr_pull *_ndr_info_pad;
112 : struct ndr_pull *_ndr_info;
113 52961 : NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_info_pad, 0, NDR_ROUND(r->_ndr_size, 8)));
114 52961 : NDR_CHECK(ndr_pull_subcontext_start(_ndr_info_pad, &_ndr_info, 0, r->_ndr_size));
115 52961 : NDR_CHECK(ndr_pull_set_switch_value(_ndr_info, r->info, r->type));
116 52961 : NDR_CHECK(ndr_pull_PAC_INFO(_ndr_info, NDR_SCALARS|NDR_BUFFERS, r->info));
117 52961 : NDR_CHECK(ndr_pull_subcontext_end(_ndr_info_pad, _ndr_info, 0, r->_ndr_size));
118 52961 : NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_info_pad, 0, NDR_ROUND(r->_ndr_size, 8)));
119 : }
120 52961 : NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0);
121 52961 : if (ndr->offset > ndr->relative_highest_offset) {
122 52961 : ndr->relative_highest_offset = ndr->offset;
123 : }
124 52961 : ndr->offset = _relative_save_offset;
125 : }
126 52961 : ndr->flags = _flags_save_PAC_INFO;
127 : }
128 : }
129 105922 : return NDR_ERR_SUCCESS;
130 : }
|