2004-11-08 00:30:59 +03:00
/*
Unix SMB / CIFS implementation .
routines for marshalling / unmarshalling DCOM string arrays
Copyright ( C ) Jelmer Vernooij 2004
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
2007-07-10 06:07:03 +04:00
the Free Software Foundation ; either version 3 of the License , or
2004-11-08 00:30:59 +03:00
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
2007-07-10 06:07:03 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2004-11-08 00:30:59 +03:00
*/
# include "includes.h"
2005-02-21 17:30:49 +03:00
# include "librpc/gen_ndr/ndr_orpc.h"
2004-11-08 00:30:59 +03:00
2007-11-09 21:24:10 +03:00
enum ndr_err_code ndr_pull_DUALSTRINGARRAY ( struct ndr_pull * ndr , int ndr_flags , struct DUALSTRINGARRAY * ar )
2004-11-08 00:30:59 +03:00
{
uint16_t num_entries , security_offset ;
uint16_t towerid ;
uint32_t towernum = 0 , conformant_size ;
if ( ! ( ndr_flags & NDR_SCALARS ) ) {
2007-11-09 21:24:10 +03:00
return NDR_ERR_SUCCESS ;
2004-11-08 00:30:59 +03:00
}
2005-02-10 00:10:23 +03:00
NDR_CHECK ( ndr_pull_uint32 ( ndr , NDR_SCALARS , & conformant_size ) ) ;
NDR_CHECK ( ndr_pull_uint16 ( ndr , NDR_SCALARS , & num_entries ) ) ;
NDR_CHECK ( ndr_pull_uint16 ( ndr , NDR_SCALARS , & security_offset ) ) ;
2004-11-08 00:30:59 +03:00
2005-01-27 10:08:20 +03:00
ar - > stringbindings = talloc_array ( ndr , struct STRINGBINDING * , num_entries ) ;
2004-11-08 00:30:59 +03:00
ar - > stringbindings [ 0 ] = NULL ;
do {
/* 'Peek' */
2005-02-10 00:10:23 +03:00
NDR_CHECK ( ndr_pull_uint16 ( ndr , NDR_SCALARS , & towerid ) ) ;
2004-11-08 00:30:59 +03:00
if ( towerid > 0 ) {
ndr - > offset - = 2 ;
2005-01-27 10:08:20 +03:00
ar - > stringbindings = talloc_realloc ( ndr , ar - > stringbindings , struct STRINGBINDING * , towernum + 2 ) ;
ar - > stringbindings [ towernum ] = talloc ( ndr , struct STRINGBINDING ) ;
2004-11-08 00:30:59 +03:00
NDR_CHECK ( ndr_pull_STRINGBINDING ( ndr , ndr_flags , ar - > stringbindings [ towernum ] ) ) ;
towernum + + ;
}
} while ( towerid ! = 0 ) ;
ar - > stringbindings [ towernum ] = NULL ;
towernum = 0 ;
2005-01-27 10:08:20 +03:00
ar - > securitybindings = talloc_array ( ndr , struct SECURITYBINDING * , num_entries ) ;
2004-11-08 00:30:59 +03:00
ar - > securitybindings [ 0 ] = NULL ;
do {
/* 'Peek' */
2005-02-10 00:10:23 +03:00
NDR_CHECK ( ndr_pull_uint16 ( ndr , NDR_SCALARS , & towerid ) ) ;
2004-11-08 00:30:59 +03:00
if ( towerid > 0 ) {
ndr - > offset - = 2 ;
2005-01-27 10:08:20 +03:00
ar - > securitybindings = talloc_realloc ( ndr , ar - > securitybindings , struct SECURITYBINDING * , towernum + 2 ) ;
ar - > securitybindings [ towernum ] = talloc ( ndr , struct SECURITYBINDING ) ;
2004-11-08 00:30:59 +03:00
NDR_CHECK ( ndr_pull_SECURITYBINDING ( ndr , ndr_flags , ar - > securitybindings [ towernum ] ) ) ;
towernum + + ;
}
} while ( towerid ! = 0 ) ;
ar - > securitybindings [ towernum ] = NULL ;
2007-11-09 21:24:10 +03:00
return NDR_ERR_SUCCESS ;
2004-11-08 00:30:59 +03:00
}
2007-11-09 21:24:10 +03:00
enum ndr_err_code ndr_push_DUALSTRINGARRAY ( struct ndr_push * ndr , int ndr_flags , const struct DUALSTRINGARRAY * ar )
2004-11-08 00:30:59 +03:00
{
2007-11-09 21:24:10 +03:00
return ndr_push_error ( ndr , NDR_ERR_STRING , " ndr_push_DUALSTRINGARRAY not implemented " ) ;
2004-11-08 00:30:59 +03:00
}
/*
print a dom_sid
*/
2005-06-24 05:18:56 +04:00
void ndr_print_DUALSTRINGARRAY ( struct ndr_print * ndr , const char * name , const struct DUALSTRINGARRAY * ar )
2004-11-08 00:30:59 +03:00
{
int i ;
ndr - > print ( ndr , " %-25s: DUALSTRINGARRAY " , name ) ;
ndr - > depth + + ;
ndr - > print ( ndr , " STRING BINDINGS " ) ;
ndr - > depth + + ;
for ( i = 0 ; ar - > stringbindings [ i ] ; i + + ) {
char * idx = NULL ;
asprintf ( & idx , " [%d] " , i ) ;
if ( idx ) {
ndr_print_STRINGBINDING ( ndr , idx , ar - > stringbindings [ i ] ) ;
free ( idx ) ;
}
}
ndr - > depth - - ;
ndr - > print ( ndr , " SECURITY BINDINGS " ) ;
ndr - > depth + + ;
for ( i = 0 ; ar - > securitybindings [ i ] ; i + + ) {
char * idx = NULL ;
asprintf ( & idx , " [%d] " , i ) ;
if ( idx ) {
ndr_print_SECURITYBINDING ( ndr , idx , ar - > securitybindings [ i ] ) ;
free ( idx ) ;
}
}
ndr - > depth - - ;
}
2007-11-09 21:24:10 +03:00
enum ndr_err_code ndr_pull_STRINGARRAY ( struct ndr_pull * ndr , int ndr_flags , struct STRINGARRAY * ar )
2004-11-08 00:30:59 +03:00
{
uint16_t towerid ;
uint32_t towernum = 0 ;
uint16_t num_entries ;
if ( ! ( ndr_flags & NDR_SCALARS ) ) {
2007-11-09 21:24:10 +03:00
return NDR_ERR_SUCCESS ;
2004-11-08 00:30:59 +03:00
}
2005-02-10 00:10:23 +03:00
NDR_CHECK ( ndr_pull_uint16 ( ndr , NDR_SCALARS , & num_entries ) ) ;
2004-11-08 00:30:59 +03:00
2005-01-27 10:08:20 +03:00
ar - > stringbindings = talloc_array ( ndr , struct STRINGBINDING * , 1 ) ;
2004-11-08 00:30:59 +03:00
ar - > stringbindings [ 0 ] = NULL ;
do {
/* 'Peek' */
2005-02-10 00:10:23 +03:00
NDR_CHECK ( ndr_pull_uint16 ( ndr , NDR_SCALARS , & towerid ) ) ;
2004-11-08 00:30:59 +03:00
if ( towerid > 0 ) {
ndr - > offset - = 2 ;
2005-01-27 10:08:20 +03:00
ar - > stringbindings = talloc_realloc ( ndr , ar - > stringbindings , struct STRINGBINDING * , towernum + 2 ) ;
ar - > stringbindings [ towernum ] = talloc ( ndr , struct STRINGBINDING ) ;
2004-11-08 00:30:59 +03:00
NDR_CHECK ( ndr_pull_STRINGBINDING ( ndr , ndr_flags , ar - > stringbindings [ towernum ] ) ) ;
towernum + + ;
}
} while ( towerid ! = 0 ) ;
ar - > stringbindings [ towernum ] = NULL ;
towernum = 0 ;
2007-11-09 21:24:10 +03:00
return NDR_ERR_SUCCESS ;
2004-11-08 00:30:59 +03:00
}
2007-11-09 21:24:10 +03:00
enum ndr_err_code ndr_push_STRINGARRAY ( struct ndr_push * ndr , int ndr_flags , const struct STRINGARRAY * ar )
2004-11-08 00:30:59 +03:00
{
2007-11-09 21:24:10 +03:00
return ndr_push_error ( ndr , NDR_ERR_STRING , " ndr_push_STRINGARRAY not implemented " ) ;
2004-11-08 00:30:59 +03:00
}
/*
print a dom_sid
*/
2005-06-24 05:18:56 +04:00
void ndr_print_STRINGARRAY ( struct ndr_print * ndr , const char * name , const struct STRINGARRAY * ar )
2004-11-08 00:30:59 +03:00
{
int i ;
ndr - > print ( ndr , " %-25s: STRINGARRAY " , name ) ;
ndr - > depth + + ;
for ( i = 0 ; ar - > stringbindings [ i ] ; i + + ) {
char * idx = NULL ;
asprintf ( & idx , " [%d] " , i ) ;
if ( idx ) {
ndr_print_STRINGBINDING ( ndr , idx , ar - > stringbindings [ i ] ) ;
free ( idx ) ;
}
}
ndr - > depth - - ;
}