root/librpc/ndr/ndr_krb5pac.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. _ndr_size_PAC_INFO
  2. _subcontext_size_PAC_INFO
  3. ndr_push_PAC_BUFFER
  4. ndr_pull_PAC_BUFFER
  5. ndr_print_PAC_BUFFER

   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 static size_t _ndr_size_PAC_INFO(const union PAC_INFO *r, uint32_t level, struct smb_iconv_convenience *ic, int flags)
     /* [<][>][^][v][top][bottom][index][help] */
  27 {
  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;
  34         }
  35 }
  36 
  37 static size_t _subcontext_size_PAC_INFO(const union PAC_INFO *r, uint32_t level, struct smb_iconv_convenience *ic, int flags)
     /* [<][>][^][v][top][bottom][index][help] */
  38 {
  39         size_t s = ndr_size_PAC_INFO(r, level, ic, flags);
  40         return NDR_ROUND(s,8);
  41 }
  42 
  43 enum ndr_err_code ndr_push_PAC_BUFFER(struct ndr_push *ndr, int ndr_flags, const struct PAC_BUFFER *r)
     /* [<][>][^][v][top][bottom][index][help] */
  44 {
  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)));
  49                 {
  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;
  54                 }
  55                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
  56         }
  57         if (ndr_flags & NDR_BUFFERS) {
  58                 {
  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));
  63                                 {
  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)));
  69                                 }
  70                         }
  71                         ndr->flags = _flags_save_PAC_INFO;
  72                 }
  73         }
  74         return NDR_ERR_SUCCESS;
  75 }
  76 
  77 enum ndr_err_code ndr_pull_PAC_BUFFER(struct ndr_pull *ndr, int ndr_flags, struct PAC_BUFFER *r)
     /* [<][>][^][v][top][bottom][index][help] */
  78 {
  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));
  85                 {
  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;
  94                         }
  95                         ndr->flags = _flags_save_PAC_INFO;
  96                 }
  97                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->_pad));
  98         }
  99         if (ndr_flags & NDR_BUFFERS) {
 100                 {
 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);
 109                                 {
 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));
 115                                 }
 116                                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0);
 117                                 ndr->offset = _relative_save_offset;
 118                         }
 119                         ndr->flags = _flags_save_PAC_INFO;
 120                 }
 121         }
 122         return NDR_ERR_SUCCESS;
 123 }
 124 
 125 void ndr_print_PAC_BUFFER(struct ndr_print *ndr, const char *name, const struct PAC_BUFFER *r)
     /* [<][>][^][v][top][bottom][index][help] */
 126 {
 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);
 136         }
 137         ndr->depth--;
 138         ndr_print_uint32(ndr, "_pad", r->_pad);
 139         ndr->depth--;
 140 }

/* [<][>][^][v][top][bottom][index][help] */