LCOV - code coverage report
Current view: top level - librpc/ndr - ndr_negoex.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 218 329 66.3 %
Date: 2024-04-21 15:09:00 Functions: 11 13 84.6 %

          Line data    Source code
       1             : /*
       2             :    Unix SMB/CIFS implementation.
       3             : 
       4             :    routines for marshalling/unmarshalling special NEGOEX structures
       5             : 
       6             :    Copyright (C) Stefan Metzmacher 2015
       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             : #include "includes.h"
      22             : #include "librpc/gen_ndr/ndr_negoex.h"
      23             : #include "librpc/gen_ndr/ndr_misc.h"
      24             : #include "librpc/ndr/ndr_negoex.h"
      25             : 
      26           2 : void ndr_print_negoex_BYTE_VECTOR(struct ndr_print *ndr, const char *name, const struct negoex_BYTE_VECTOR *r)
      27             : {
      28           2 :         ndr_print_struct(ndr, name, "negoex_BYTE_VECTOR");
      29           2 :         if (r == NULL) { ndr_print_null(ndr); return; }
      30           2 :         ndr->depth++;
      31           2 :         ndr_print_DATA_BLOB(ndr, "blob", r->blob);
      32           2 :         ndr->depth--;
      33             : }
      34             : 
      35           8 : enum ndr_err_code ndr_push_negoex_BYTE_VECTOR(struct ndr_push *ndr, ndr_flags_type ndr_flags, const struct negoex_BYTE_VECTOR *r)
      36             : {
      37           8 :         NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
      38           8 :         if (ndr_flags & NDR_SCALARS) {
      39           4 :                 NDR_CHECK(ndr_push_align(ndr, 5));
      40           4 :                 NDR_CHECK(ndr_push_relative_ptr1(ndr, r->blob.data));
      41           4 :                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->blob.length));
      42           4 :                 NDR_CHECK(ndr_push_trailer_align(ndr, 5));
      43             :         }
      44           8 :         if (ndr_flags & NDR_BUFFERS) {
      45           4 :                 if (r->blob.data) {
      46           4 :                         NDR_CHECK(ndr_push_relative_ptr2_start(ndr, r->blob.data));
      47             : #if 0
      48             :                         NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, r->blob.length));
      49             : #endif
      50           4 :                         NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->blob.data, r->blob.length));
      51           4 :                         NDR_CHECK(ndr_push_relative_ptr2_end(ndr, r->blob.data));
      52             :                 }
      53             :         }
      54           0 :         return NDR_ERR_SUCCESS;
      55             : }
      56             : 
      57           4 : enum ndr_err_code ndr_pull_negoex_BYTE_VECTOR(struct ndr_pull *ndr, ndr_flags_type ndr_flags, struct negoex_BYTE_VECTOR *r)
      58             : {
      59           4 :         uint32_t _ptr_data;
      60           4 :         uint32_t size_data_1 = 0;
      61           4 :         TALLOC_CTX *_mem_save_data_0 = NULL;
      62           4 :         NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
      63           4 :         r->_dummy = NULL;
      64           4 :         if (ndr_flags & NDR_SCALARS) {
      65           2 :                 NDR_CHECK(ndr_pull_align(ndr, 5));
      66           2 :                 NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_data));
      67           2 :                 if (_ptr_data) {
      68           2 :                         NDR_PULL_ALLOC(ndr, r->blob.data);
      69           2 :                         NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->blob.data, _ptr_data));
      70             :                 } else {
      71           0 :                         r->blob.data = NULL;
      72             :                 }
      73           2 :                 r->blob.length = 0;
      74           2 :                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &size_data_1));
      75           2 :                 r->_length = size_data_1;
      76           2 :                 NDR_CHECK(ndr_pull_trailer_align(ndr, 5));
      77             :         }
      78           4 :         if (ndr_flags & NDR_BUFFERS) {
      79           2 :                 if (r->blob.data) {
      80           2 :                         uint32_t _relative_save_offset;
      81           2 :                         _relative_save_offset = ndr->offset;
      82           2 :                         NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->blob.data));
      83           2 :                         _mem_save_data_0 = NDR_PULL_GET_MEM_CTX(ndr);
      84           2 :                         NDR_PULL_SET_MEM_CTX(ndr, r->blob.data, 0);
      85             : #if 0
      86             :                         NDR_CHECK(ndr_pull_array_size(ndr, &r->blob.data));
      87             :                         size_data_1 = ndr_get_array_size(ndr, &r->blob.data);
      88             : #else
      89           2 :                         size_data_1 = r->_length;
      90             : #endif
      91           2 :                         NDR_PULL_ALLOC_N(ndr, r->blob.data, size_data_1);
      92           2 :                         NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->blob.data, size_data_1));
      93           2 :                         r->blob.length = size_data_1;
      94           2 :                         NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_0, 0);
      95           2 :                         if (ndr->offset > ndr->relative_highest_offset) {
      96           2 :                                 ndr->relative_highest_offset = ndr->offset;
      97             :                         }
      98           2 :                         ndr->offset = _relative_save_offset;
      99             :                 }
     100             : #if 0
     101             :                 if (r->blob.data) {
     102             :                         NDR_CHECK(ndr_check_steal_array_size(ndr, (void*)&r->blob.data, r->blob.length));
     103             :                 }
     104             : #endif
     105             :         }
     106           0 :         return NDR_ERR_SUCCESS;
     107             : }
     108             : 
     109           8 : enum ndr_err_code ndr_push_negoex_AUTH_SCHEME_VECTOR(struct ndr_push *ndr, ndr_flags_type ndr_flags, const struct negoex_AUTH_SCHEME_VECTOR *r)
     110             : {
     111           8 :         uint32_t cntr_array_1;
     112           8 :         NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
     113           8 :         if (ndr_flags & NDR_SCALARS) {
     114           4 :                 NDR_CHECK(ndr_push_align(ndr, 5));
     115           4 :                 NDR_CHECK(ndr_push_relative_ptr1(ndr, r->array));
     116           4 :                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->count));
     117           4 :                 NDR_CHECK(ndr_push_trailer_align(ndr, 5));
     118             :         }
     119           8 :         if (ndr_flags & NDR_BUFFERS) {
     120           4 :                 if (r->array) {
     121           4 :                         NDR_CHECK(ndr_push_relative_ptr2_start(ndr, r->array));
     122             : #if 0
     123             :                         NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, r->count));
     124             : #endif
     125           8 :                         for (cntr_array_1 = 0; cntr_array_1 < (r->count); cntr_array_1++) {
     126           4 :                                 NDR_CHECK(ndr_push_negoex_AUTH_SCHEME(ndr, NDR_SCALARS, &r->array[cntr_array_1]));
     127             :                         }
     128           4 :                         NDR_CHECK(ndr_push_relative_ptr2_end(ndr, r->array));
     129             :                 }
     130             :         }
     131           0 :         return NDR_ERR_SUCCESS;
     132             : }
     133             : 
     134           4 : enum ndr_err_code ndr_pull_negoex_AUTH_SCHEME_VECTOR(struct ndr_pull *ndr, ndr_flags_type ndr_flags, struct negoex_AUTH_SCHEME_VECTOR *r)
     135             : {
     136           4 :         uint32_t _ptr_array;
     137           4 :         uint32_t size_array_1 = 0;
     138           4 :         uint32_t cntr_array_1;
     139           4 :         TALLOC_CTX *_mem_save_array_0 = NULL;
     140           4 :         TALLOC_CTX *_mem_save_array_1 = NULL;
     141           4 :         NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
     142           4 :         if (ndr_flags & NDR_SCALARS) {
     143           2 :                 NDR_CHECK(ndr_pull_align(ndr, 5));
     144           2 :                 NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_array));
     145           2 :                 if (_ptr_array) {
     146           2 :                         NDR_PULL_ALLOC(ndr, r->array);
     147           2 :                         NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->array, _ptr_array));
     148             :                 } else {
     149           0 :                         r->array = NULL;
     150             :                 }
     151           2 :                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->count));
     152           2 :                 NDR_CHECK(ndr_pull_trailer_align(ndr, 5));
     153             :         }
     154           4 :         if (ndr_flags & NDR_BUFFERS) {
     155           2 :                 if (r->array) {
     156           2 :                         uint32_t _relative_save_offset;
     157           2 :                         _relative_save_offset = ndr->offset;
     158           2 :                         NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->array));
     159           2 :                         _mem_save_array_0 = NDR_PULL_GET_MEM_CTX(ndr);
     160           2 :                         NDR_PULL_SET_MEM_CTX(ndr, r->array, 0);
     161             : #if 0
     162             :                         NDR_CHECK(ndr_pull_array_size(ndr, &r->array));
     163             :                         size_array_1 = ndr_get_array_size(ndr, &r->array);
     164             : #else
     165           2 :                         size_array_1 = r->count;
     166             : #endif
     167           2 :                         NDR_PULL_ALLOC_N(ndr, r->array, size_array_1);
     168           2 :                         _mem_save_array_1 = NDR_PULL_GET_MEM_CTX(ndr);
     169           2 :                         NDR_PULL_SET_MEM_CTX(ndr, r->array, 0);
     170           4 :                         for (cntr_array_1 = 0; cntr_array_1 < (size_array_1); cntr_array_1++) {
     171           2 :                                 NDR_CHECK(ndr_pull_negoex_AUTH_SCHEME(ndr, NDR_SCALARS, &r->array[cntr_array_1]));
     172             :                         }
     173           2 :                         NDR_PULL_SET_MEM_CTX(ndr, _mem_save_array_1, 0);
     174           2 :                         NDR_PULL_SET_MEM_CTX(ndr, _mem_save_array_0, 0);
     175           2 :                         if (ndr->offset > ndr->relative_highest_offset) {
     176           2 :                                 ndr->relative_highest_offset = ndr->offset;
     177             :                         }
     178           2 :                         ndr->offset = _relative_save_offset;
     179             :                 }
     180             : #if 0
     181             :                 if (r->array) {
     182             :                         NDR_CHECK(ndr_check_steal_array_size(ndr, (void*)&r->array, r->count));
     183             :                 }
     184             : #endif
     185             :         }
     186           0 :         return NDR_ERR_SUCCESS;
     187             : }
     188             : 
     189           8 : enum ndr_err_code ndr_push_negoex_EXTENSION_VECTOR(struct ndr_push *ndr, ndr_flags_type ndr_flags, const struct negoex_EXTENSION_VECTOR *r)
     190             : {
     191           8 :         uint32_t cntr_array_1;
     192           8 :         NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
     193           8 :         if (ndr_flags & NDR_SCALARS) {
     194           4 :                 NDR_CHECK(ndr_push_align(ndr, 5));
     195           4 :                 NDR_CHECK(ndr_push_relative_ptr1(ndr, r->array));
     196           4 :                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->count));
     197           4 :                 NDR_CHECK(ndr_push_trailer_align(ndr, 5));
     198             :         }
     199           8 :         if (ndr_flags & NDR_BUFFERS) {
     200           4 :                 if (r->array) {
     201           0 :                         NDR_CHECK(ndr_push_relative_ptr2_start(ndr, r->array));
     202             : #if 0
     203             :                         NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, r->count));
     204             : #endif
     205           0 :                         for (cntr_array_1 = 0; cntr_array_1 < (r->count); cntr_array_1++) {
     206           0 :                                 NDR_CHECK(ndr_push_negoex_EXTENSION(ndr, NDR_SCALARS, &r->array[cntr_array_1]));
     207             :                         }
     208           0 :                         for (cntr_array_1 = 0; cntr_array_1 < (r->count); cntr_array_1++) {
     209           0 :                                 NDR_CHECK(ndr_push_negoex_EXTENSION(ndr, NDR_BUFFERS, &r->array[cntr_array_1]));
     210             :                         }
     211           0 :                         NDR_CHECK(ndr_push_relative_ptr2_end(ndr, r->array));
     212             :                 }
     213             :         }
     214           0 :         return NDR_ERR_SUCCESS;
     215             : }
     216             : 
     217           4 : enum ndr_err_code ndr_pull_negoex_EXTENSION_VECTOR(struct ndr_pull *ndr, ndr_flags_type ndr_flags, struct negoex_EXTENSION_VECTOR *r)
     218             : {
     219           4 :         uint32_t _ptr_array;
     220           4 :         uint32_t size_array_1 = 0;
     221           4 :         uint32_t cntr_array_1;
     222           4 :         TALLOC_CTX *_mem_save_array_0 = NULL;
     223           4 :         TALLOC_CTX *_mem_save_array_1 = NULL;
     224           4 :         NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
     225           4 :         if (ndr_flags & NDR_SCALARS) {
     226           2 :                 NDR_CHECK(ndr_pull_align(ndr, 5));
     227           2 :                 NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_array));
     228           2 :                 if (_ptr_array) {
     229           0 :                         NDR_PULL_ALLOC(ndr, r->array);
     230           0 :                         NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->array, _ptr_array));
     231             :                 } else {
     232           2 :                         r->array = NULL;
     233             :                 }
     234           2 :                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->count));
     235           2 :                 NDR_CHECK(ndr_pull_trailer_align(ndr, 5));
     236             :         }
     237           4 :         if (ndr_flags & NDR_BUFFERS) {
     238           2 :                 if (r->array) {
     239           0 :                         uint32_t _relative_save_offset;
     240           0 :                         _relative_save_offset = ndr->offset;
     241           0 :                         NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->array));
     242           0 :                         _mem_save_array_0 = NDR_PULL_GET_MEM_CTX(ndr);
     243           0 :                         NDR_PULL_SET_MEM_CTX(ndr, r->array, 0);
     244             : #if 0
     245             :                         NDR_CHECK(ndr_pull_array_size(ndr, &r->array));
     246             :                         size_array_1 = ndr_get_array_size(ndr, &r->array);
     247             : #else
     248           0 :                         size_array_1 = r->count;
     249             : #endif
     250           0 :                         NDR_PULL_ALLOC_N(ndr, r->array, size_array_1);
     251           0 :                         _mem_save_array_1 = NDR_PULL_GET_MEM_CTX(ndr);
     252           0 :                         NDR_PULL_SET_MEM_CTX(ndr, r->array, 0);
     253           0 :                         for (cntr_array_1 = 0; cntr_array_1 < (size_array_1); cntr_array_1++) {
     254           0 :                                 NDR_CHECK(ndr_pull_negoex_EXTENSION(ndr, NDR_SCALARS, &r->array[cntr_array_1]));
     255             :                         }
     256           0 :                         for (cntr_array_1 = 0; cntr_array_1 < (size_array_1); cntr_array_1++) {
     257           0 :                                 NDR_CHECK(ndr_pull_negoex_EXTENSION(ndr, NDR_BUFFERS, &r->array[cntr_array_1]));
     258             :                         }
     259           0 :                         NDR_PULL_SET_MEM_CTX(ndr, _mem_save_array_1, 0);
     260           0 :                         NDR_PULL_SET_MEM_CTX(ndr, _mem_save_array_0, 0);
     261           0 :                         if (ndr->offset > ndr->relative_highest_offset) {
     262           0 :                                 ndr->relative_highest_offset = ndr->offset;
     263             :                         }
     264           0 :                         ndr->offset = _relative_save_offset;
     265             :                 }
     266             : #if 0
     267             :                 if (r->array) {
     268             :                         NDR_CHECK(ndr_check_steal_array_size(ndr, (void*)&r->array, r->count));
     269             :                 }
     270             : #endif
     271             :         }
     272           0 :         return NDR_ERR_SUCCESS;
     273             : }
     274             : 
     275           0 : enum ndr_err_code ndr_push_negoex_ALERT_VECTOR(struct ndr_push *ndr, ndr_flags_type ndr_flags, const struct negoex_ALERT_VECTOR *r)
     276             : {
     277           0 :         uint32_t cntr_array_1;
     278           0 :         NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
     279           0 :         if (ndr_flags & NDR_SCALARS) {
     280           0 :                 NDR_CHECK(ndr_push_align(ndr, 5));
     281           0 :                 NDR_CHECK(ndr_push_relative_ptr1(ndr, r->array));
     282           0 :                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->count));
     283           0 :                 NDR_CHECK(ndr_push_trailer_align(ndr, 5));
     284             :         }
     285           0 :         if (ndr_flags & NDR_BUFFERS) {
     286           0 :                 if (r->array) {
     287           0 :                         NDR_CHECK(ndr_push_relative_ptr2_start(ndr, r->array));
     288             : #if 0
     289             :                         NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, r->count));
     290             : #endif
     291           0 :                         for (cntr_array_1 = 0; cntr_array_1 < (r->count); cntr_array_1++) {
     292           0 :                                 NDR_CHECK(ndr_push_negoex_ALERT(ndr, NDR_SCALARS, &r->array[cntr_array_1]));
     293             :                         }
     294           0 :                         for (cntr_array_1 = 0; cntr_array_1 < (r->count); cntr_array_1++) {
     295           0 :                                 NDR_CHECK(ndr_push_negoex_ALERT(ndr, NDR_BUFFERS, &r->array[cntr_array_1]));
     296             :                         }
     297           0 :                         NDR_CHECK(ndr_push_relative_ptr2_end(ndr, r->array));
     298             :                 }
     299             :         }
     300           0 :         return NDR_ERR_SUCCESS;
     301             : }
     302             : 
     303           0 : enum ndr_err_code ndr_pull_negoex_ALERT_VECTOR(struct ndr_pull *ndr, ndr_flags_type ndr_flags, struct negoex_ALERT_VECTOR *r)
     304             : {
     305           0 :         uint32_t _ptr_array;
     306           0 :         uint32_t size_array_1 = 0;
     307           0 :         uint32_t cntr_array_1;
     308           0 :         TALLOC_CTX *_mem_save_array_0 = NULL;
     309           0 :         TALLOC_CTX *_mem_save_array_1 = NULL;
     310           0 :         NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
     311           0 :         if (ndr_flags & NDR_SCALARS) {
     312           0 :                 NDR_CHECK(ndr_pull_align(ndr, 5));
     313           0 :                 NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_array));
     314           0 :                 if (_ptr_array) {
     315           0 :                         NDR_PULL_ALLOC(ndr, r->array);
     316           0 :                         NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->array, _ptr_array));
     317             :                 } else {
     318           0 :                         r->array = NULL;
     319             :                 }
     320           0 :                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->count));
     321           0 :                 NDR_CHECK(ndr_pull_trailer_align(ndr, 5));
     322             :         }
     323           0 :         if (ndr_flags & NDR_BUFFERS) {
     324           0 :                 if (r->array) {
     325           0 :                         uint32_t _relative_save_offset;
     326           0 :                         _relative_save_offset = ndr->offset;
     327           0 :                         NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->array));
     328           0 :                         _mem_save_array_0 = NDR_PULL_GET_MEM_CTX(ndr);
     329           0 :                         NDR_PULL_SET_MEM_CTX(ndr, r->array, 0);
     330             : #if 0
     331             :                         NDR_CHECK(ndr_pull_array_size(ndr, &r->array));
     332             :                         size_array_1 = ndr_get_array_size(ndr, &r->array);
     333             : #else
     334           0 :                         size_array_1 = r->count;
     335             : #endif
     336           0 :                         NDR_PULL_ALLOC_N(ndr, r->array, size_array_1);
     337           0 :                         _mem_save_array_1 = NDR_PULL_GET_MEM_CTX(ndr);
     338           0 :                         NDR_PULL_SET_MEM_CTX(ndr, r->array, 0);
     339           0 :                         for (cntr_array_1 = 0; cntr_array_1 < (size_array_1); cntr_array_1++) {
     340           0 :                                 NDR_CHECK(ndr_pull_negoex_ALERT(ndr, NDR_SCALARS, &r->array[cntr_array_1]));
     341             :                         }
     342           0 :                         for (cntr_array_1 = 0; cntr_array_1 < (size_array_1); cntr_array_1++) {
     343           0 :                                 NDR_CHECK(ndr_pull_negoex_ALERT(ndr, NDR_BUFFERS, &r->array[cntr_array_1]));
     344             :                         }
     345           0 :                         NDR_PULL_SET_MEM_CTX(ndr, _mem_save_array_1, 0);
     346           0 :                         NDR_PULL_SET_MEM_CTX(ndr, _mem_save_array_0, 0);
     347           0 :                         if (ndr->offset > ndr->relative_highest_offset) {
     348           0 :                                 ndr->relative_highest_offset = ndr->offset;
     349             :                         }
     350           0 :                         ndr->offset = _relative_save_offset;
     351             :                 }
     352             : #if 0
     353             :                 if (r->array) {
     354             :                         NDR_CHECK(ndr_check_steal_array_size(ndr, (void*)&r->array, r->count));
     355             :                 }
     356             : #endif
     357             :         }
     358           0 :         return NDR_ERR_SUCCESS;
     359             : }
     360             : 
     361           8 : size_t ndr_negoex_MESSAGE_header_length(const struct negoex_MESSAGE *r)
     362             : {
     363           8 :         size_t size = 0;
     364             : 
     365           8 :         size += 8;  /* signature */
     366           8 :         size += 4;  /* type */
     367           8 :         size += 4;  /* sequence_number */
     368           8 :         size += 4;  /* header_length */
     369           8 :         size += 4;  /* message_length */
     370           8 :         size += 16; /* conversation_id */
     371             : 
     372           8 :         switch (r->type) {
     373           0 :         case NEGOEX_MESSAGE_TYPE_INITIATOR_NEGO:
     374             :         case NEGOEX_MESSAGE_TYPE_ACCEPTOR_NEGO:
     375           0 :                 size += 32; /* random */
     376           0 :                 size += 8;  /* protocol_version */
     377           0 :                 size += 8;  /* auth_schemes */
     378           0 :                 size += 8;  /* extensions */
     379           0 :                 break;
     380             : 
     381           0 :         case NEGOEX_MESSAGE_TYPE_INITIATOR_META_DATA:
     382             :         case NEGOEX_MESSAGE_TYPE_ACCEPTOR_META_DATA:
     383             :         case NEGOEX_MESSAGE_TYPE_CHALLENGE:
     384             :         case NEGOEX_MESSAGE_TYPE_AP_REQUEST:
     385           0 :                 size += 16; /* auth_scheme */
     386           0 :                 size += 8;  /* exchange */
     387           0 :                 break;
     388             : 
     389           0 :         case NEGOEX_MESSAGE_TYPE_VERIFY:
     390           0 :                 size += 16; /* auth_scheme */
     391           0 :                 size += 4;  /* checksum.header_length */
     392           0 :                 size += 4;  /* checksum.scheme */
     393           0 :                 size += 4;  /* checksum.type */
     394           0 :                 size += 8;  /* checksum.value */
     395           0 :                 break;
     396             : 
     397           0 :         case NEGOEX_MESSAGE_TYPE_ALERT:
     398           0 :                 size += 16; /* auth_scheme */
     399           0 :                 size += 4;  /* status */
     400           0 :                 size += 8;  /* alerts */
     401           0 :                 break;
     402             :         }
     403             : 
     404           8 :         return size;
     405             : }
     406             : 
     407           4 : enum ndr_err_code ndr_pull_negoex_MESSAGE(struct ndr_pull *ndr, ndr_flags_type ndr_flags, struct negoex_MESSAGE *r)
     408             : {
     409           4 :         uint32_t _save_relative_base_offset = ndr_pull_get_relative_base_offset(ndr);
     410           4 :         uint32_t size_signature_0 = 0;
     411           4 :         uint32_t start_data_size = ndr->data_size;
     412           4 :         uint32_t saved_offset = 0;
     413           4 :         NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
     414           4 :         if (ndr_flags & NDR_SCALARS) {
     415           4 :                 NDR_CHECK(ndr_pull_align(ndr, 5));
     416           4 :                 NDR_CHECK(ndr_pull_setup_relative_base_offset1(ndr, r, ndr->offset));
     417           4 :                 size_signature_0 = 8;
     418           4 :                 NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->signature, size_signature_0, sizeof(uint8_t), CH_DOS));
     419           4 :                 NDR_CHECK(ndr_pull_negoex_MESSAGE_TYPE(ndr, NDR_SCALARS, &r->type));
     420           4 :                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->sequence_number));
     421           4 :                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->header_length));
     422           4 :                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->message_length));
     423           4 :                 saved_offset = ndr->offset;
     424           4 :                 ndr->offset = ndr->relative_base_offset;
     425           4 :                 NDR_PULL_NEED_BYTES(ndr, r->message_length);
     426           4 :                 ndr->data_size = ndr->offset + r->message_length;
     427           4 :                 ndr->offset = saved_offset;
     428           4 :                 NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, &r->conversation_id));
     429           4 :                 NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->p, r->type));
     430           4 :                 NDR_CHECK(ndr_pull_negoex_PAYLOAD(ndr, NDR_SCALARS, &r->p));
     431           4 :                 NDR_CHECK(ndr_pull_trailer_align(ndr, 5));
     432           4 :                 ndr->offset = ndr->data_size;
     433           4 :                 ndr->data_size = start_data_size;
     434             :         }
     435           4 :         if (ndr_flags & NDR_BUFFERS) {
     436           4 :                 NDR_CHECK(ndr_pull_setup_relative_base_offset2(ndr, r));
     437           4 :                 saved_offset = ndr->offset;
     438           4 :                 ndr->offset = ndr->relative_base_offset;
     439           4 :                 NDR_PULL_NEED_BYTES(ndr, r->message_length);
     440           4 :                 ndr->data_size = ndr->offset + r->message_length;
     441           4 :                 ndr->offset = saved_offset;
     442           4 :                 NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->p, r->type));
     443           4 :                 NDR_CHECK(ndr_pull_negoex_PAYLOAD(ndr, NDR_BUFFERS, &r->p));
     444           4 :                 ndr->offset = ndr->data_size;
     445           4 :                 ndr->data_size = start_data_size;
     446             :         }
     447           4 :         ndr_pull_restore_relative_base_offset(ndr, _save_relative_base_offset);
     448           4 :         return NDR_ERR_SUCCESS;
     449             : }
     450             : 
     451           2 : enum ndr_err_code ndr_push_negoex_MESSAGE_ARRAY(struct ndr_push *ndr, ndr_flags_type ndr_flags, const struct negoex_MESSAGE_ARRAY *r)
     452             : {
     453           2 :         uint32_t cntr_messages_0;
     454             :         {
     455           2 :                 libndr_flags _flags_save_STRUCT = ndr->flags;
     456           2 :                 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
     457           2 :                 NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
     458           2 :                 if (ndr_flags & NDR_SCALARS) {
     459           2 :                         NDR_CHECK(ndr_push_align(ndr, 5));
     460           6 :                         for (cntr_messages_0 = 0; cntr_messages_0 < (r->count); cntr_messages_0++) {
     461           4 :                                 NDR_CHECK(ndr_push_negoex_MESSAGE(ndr, NDR_SCALARS|NDR_BUFFERS, &r->messages[cntr_messages_0]));
     462             :                         }
     463           2 :                         NDR_CHECK(ndr_push_trailer_align(ndr, 5));
     464             :                 }
     465           2 :                 ndr->flags = _flags_save_STRUCT;
     466             :         }
     467           2 :         return NDR_ERR_SUCCESS;
     468             : }
     469             : 
     470           2 : enum ndr_err_code ndr_pull_negoex_MESSAGE_ARRAY(struct ndr_pull *ndr, ndr_flags_type ndr_flags, struct negoex_MESSAGE_ARRAY *r)
     471             : {
     472           2 :         uint32_t size_messages_0 = 0;
     473           2 :         uint32_t cntr_messages_0;
     474           2 :         TALLOC_CTX *_mem_save_messages_0 = NULL;
     475             :         {
     476           2 :                 libndr_flags _flags_save_STRUCT = ndr->flags;
     477           2 :                 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
     478           2 :                 NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
     479           2 :                 if (ndr_flags & NDR_SCALARS) {
     480           2 :                         uint32_t saved_offset = ndr->offset;
     481           2 :                         uint32_t available = 0;
     482           2 :                         NDR_CHECK(ndr_pull_align(ndr, 5));
     483           2 :                         r->count = 0;
     484           2 :                         available = ndr->data_size - ndr->offset;
     485           6 :                         while (available > 0) {
     486           4 :                                 uint32_t length;
     487             : 
     488             :                                 /*
     489             :                                  * The common header is 40 bytes
     490             :                                  * and message_length is at offset 20
     491             :                                  */
     492           4 :                                 NDR_PULL_NEED_BYTES(ndr, 40);
     493           4 :                                 ndr->offset += 20;
     494           4 :                                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &length));
     495           4 :                                 ndr->offset -= 24;
     496           4 :                                 if (length < 40) {
     497             :                                         /*
     498             :                                          * let the pull function catch the error
     499             :                                          */
     500           0 :                                         length = 40;
     501             :                                 }
     502           4 :                                 NDR_PULL_NEED_BYTES(ndr, length);
     503           4 :                                 ndr->offset += length;
     504           4 :                                 available -= length;
     505           4 :                                 r->count++;
     506             :                         }
     507           2 :                         ndr->offset = saved_offset;
     508           2 :                         size_messages_0 = r->count;
     509           2 :                         NDR_PULL_ALLOC_N(ndr, r->messages, size_messages_0);
     510           2 :                         _mem_save_messages_0 = NDR_PULL_GET_MEM_CTX(ndr);
     511           2 :                         NDR_PULL_SET_MEM_CTX(ndr, r->messages, 0);
     512           6 :                         for (cntr_messages_0 = 0; cntr_messages_0 < (size_messages_0); cntr_messages_0++) {
     513           4 :                                 NDR_CHECK(ndr_pull_negoex_MESSAGE(ndr, NDR_SCALARS|NDR_BUFFERS, &r->messages[cntr_messages_0]));
     514             :                         }
     515           2 :                         NDR_PULL_SET_MEM_CTX(ndr, _mem_save_messages_0, 0);
     516           2 :                         NDR_CHECK(ndr_pull_trailer_align(ndr, 5));
     517             :                 }
     518           2 :                 ndr->flags = _flags_save_STRUCT;
     519             :         }
     520           2 :         return NDR_ERR_SUCCESS;
     521             : }

Generated by: LCOV version 1.14