rpc_parse/parse_ds.c

説明を見る。
00001 /* 
00002  *  Unix SMB/CIFS implementation.
00003  *  RPC Pipe client / server routines
00004  
00005  *  Copyright (C) Gerald Carter                         2002-2003
00006  *  
00007  *  This program is free software; you can redistribute it and/or modify
00008  *  it under the terms of the GNU General Public License as published by
00009  *  the Free Software Foundation; either version 2 of the License, or
00010  *  (at your option) any later version.
00011  *  
00012  *  This program is distributed in the hope that it will be useful,
00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *  GNU General Public License for more details.
00016  *  
00017  *  You should have received a copy of the GNU General Public License
00018  *  along with this program; if not, write to the Free Software
00019  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00020  */
00021 
00022 #include "includes.h"
00023 
00024 /************************************************************************
00025 ************************************************************************/
00026 
00027 static BOOL ds_io_dominfobasic(const char *desc, DSROLE_PRIMARY_DOMAIN_INFO_BASIC **basic, prs_struct *ps, int depth)
00028 {
00029         DSROLE_PRIMARY_DOMAIN_INFO_BASIC *p = *basic;
00030         
00031         if ( UNMARSHALLING(ps) ) {
00032                 p = *basic = PRS_ALLOC_MEM(ps, DSROLE_PRIMARY_DOMAIN_INFO_BASIC, 1);
00033         }
00034                 
00035         if ( !p )
00036                 return False;
00037                 
00038         if ( !prs_uint16("machine_role", ps, depth, &p->machine_role) )
00039                 return False;
00040         if ( !prs_align(ps) )
00041                 return False;
00042 
00043         if ( !prs_uint32("flags", ps, depth, &p->flags) )
00044                 return False;
00045 
00046         if ( !prs_uint32("netbios_ptr", ps, depth, &p->netbios_ptr) )
00047                 return False;
00048         if ( !prs_uint32("dnsname_ptr", ps, depth, &p->dnsname_ptr) )
00049                 return False;
00050         if ( !prs_uint32("forestname_ptr", ps, depth, &p->forestname_ptr) )
00051                 return False;
00052                 
00053         if ( !smb_io_uuid("domain_guid", &p->domain_guid, ps, depth) )
00054                 return False;
00055                 
00056         if ( !smb_io_unistr2( "netbios_domain", &p->netbios_domain, p->netbios_ptr, ps, depth) )
00057                 return False;
00058         if ( !prs_align(ps) )
00059                 return False;
00060         
00061         if ( !smb_io_unistr2( "dns_domain", &p->dns_domain, p->dnsname_ptr, ps, depth) )
00062                 return False;
00063         if ( !prs_align(ps) )
00064                 return False;
00065         
00066         if ( !smb_io_unistr2( "forest_domain", &p->forest_domain, p->forestname_ptr, ps, depth) )
00067                 return False;
00068         if ( !prs_align(ps) )
00069                 return False;
00070         
00071                 
00072         return True;
00073                 
00074 }
00075 
00076 /************************************************************************
00077 ************************************************************************/
00078 
00079 BOOL ds_io_q_getprimdominfo( const char *desc, DS_Q_GETPRIMDOMINFO *q_u, prs_struct *ps, int depth)
00080 {
00081         prs_debug(ps, depth, desc, "ds_io_q_getprimdominfo");
00082         depth++;
00083 
00084         if(!prs_align(ps))
00085                 return False;
00086 
00087         if ( !prs_uint16( "level", ps, depth, &q_u->level ) )
00088                 return False;
00089                 
00090         return True;
00091 }
00092 
00093 /************************************************************************
00094 ************************************************************************/
00095 
00096 BOOL ds_io_r_getprimdominfo( const char *desc, DS_R_GETPRIMDOMINFO *r_u, prs_struct *ps, int depth)
00097 {
00098         prs_debug(ps, depth, desc, "ds_io_r_getprimdominfo");
00099         depth++;
00100 
00101         if(!prs_align(ps))
00102                 return False;
00103 
00104         if ( !prs_uint32( "ptr", ps, depth, &r_u->ptr ) )
00105                 return False;
00106                 
00107         if ( r_u->ptr )
00108         {
00109                 if ( !prs_uint16( "level", ps, depth, &r_u->level ) )
00110                         return False;
00111         
00112                 if ( !prs_uint16( "unknown0", ps, depth, &r_u->unknown0 ) )
00113                         return False;
00114                 
00115                 switch ( r_u->level )
00116                 {
00117                         case DsRolePrimaryDomainInfoBasic:
00118                                 if ( !ds_io_dominfobasic( "dominfobasic", &r_u->info.basic, ps, depth) )
00119                                         return False;
00120                                 break;
00121                         default:
00122                                 return False;
00123                 }
00124         }
00125 
00126         if ( !prs_align(ps) )
00127                 return False;
00128         
00129         if ( !prs_ntstatus("status", ps, depth, &r_u->status ) )
00130                 return False;           
00131                 
00132         return True;
00133 }
00134 
00135 /************************************************************************
00136  initialize a DS_ENUM_DOM_TRUSTS structure
00137 ************************************************************************/
00138 
00139 BOOL init_q_ds_enum_domain_trusts( DS_Q_ENUM_DOM_TRUSTS *q, const char *server, uint32 flags )
00140 {
00141         q->flags = flags;
00142         
00143         if ( server && *server )
00144                 q->server_ptr = 1;
00145         else
00146                 q->server_ptr = 0;
00147 
00148         init_unistr2( &q->server, server, UNI_STR_TERMINATE);
00149                 
00150         return True;
00151 }
00152 
00153 /************************************************************************
00154 ************************************************************************/
00155 
00156 static BOOL ds_io_domain_trusts( const char *desc, DS_DOMAIN_TRUSTS *trust, prs_struct *ps, int depth)
00157 {
00158         prs_debug(ps, depth, desc, "ds_io_dom_trusts_ctr");
00159         depth++;
00160 
00161         if ( !prs_uint32( "netbios_ptr", ps, depth, &trust->netbios_ptr ) )
00162                 return False;
00163         
00164         if ( !prs_uint32( "dns_ptr", ps, depth, &trust->dns_ptr ) )
00165                 return False;
00166         
00167         if ( !prs_uint32( "flags", ps, depth, &trust->flags ) )
00168                 return False;
00169         
00170         if ( !prs_uint32( "parent_index", ps, depth, &trust->parent_index ) )
00171                 return False;
00172         
00173         if ( !prs_uint32( "trust_type", ps, depth, &trust->trust_type ) )
00174                 return False;
00175         
00176         if ( !prs_uint32( "trust_attributes", ps, depth, &trust->trust_attributes ) )
00177                 return False;
00178         
00179         if ( !prs_uint32( "sid_ptr", ps, depth, &trust->sid_ptr ) )
00180                 return False;
00181         
00182         if ( !smb_io_uuid("guid", &trust->guid, ps, depth) )
00183                 return False;
00184         
00185         return True;    
00186 }
00187 
00188 /************************************************************************
00189 ************************************************************************/
00190 
00191 static BOOL ds_io_dom_trusts_ctr( const char *desc, DS_DOMAIN_TRUSTS_CTR *ctr, prs_struct *ps, int depth)
00192 {
00193         int i;
00194 
00195         prs_debug(ps, depth, desc, "ds_io_dom_trusts_ctr");
00196         depth++;
00197         
00198         if ( !prs_uint32( "ptr", ps, depth, &ctr->ptr ) )
00199                 return False;
00200         
00201         if ( !prs_uint32( "max_count", ps, depth, &ctr->max_count ) )
00202                 return False;
00203         
00204         /* are we done? */
00205         
00206         if ( ctr->max_count == 0 )
00207                 return True;
00208         
00209         /* allocate the domain trusts array are parse it */
00210         
00211         ctr->trusts = TALLOC_ARRAY(ps->mem_ctx, DS_DOMAIN_TRUSTS, ctr->max_count);
00212         
00213         if ( !ctr->trusts )
00214                 return False;
00215         
00216         /* this stinks; the static portion o fthe structure is read here and then
00217            we need another loop to read the UNISTR2's and SID's */
00218            
00219         for ( i=0; i<ctr->max_count;i++ ) {
00220                 if ( !ds_io_domain_trusts("domain_trusts", &ctr->trusts[i], ps, depth) )
00221                         return False;
00222         }
00223 
00224         for ( i=0; i<ctr->max_count; i++ ) {
00225         
00226                 if ( !smb_io_unistr2("netbios_domain", &ctr->trusts[i].netbios_domain, ctr->trusts[i].netbios_ptr, ps, depth) )
00227                         return False;
00228 
00229                 if(!prs_align(ps))
00230                         return False;
00231                 
00232                 if ( !smb_io_unistr2("dns_domain", &ctr->trusts[i].dns_domain, ctr->trusts[i].dns_ptr, ps, depth) )
00233                         return False;
00234 
00235                 if(!prs_align(ps))
00236                         return False;
00237                         
00238                 if ( ctr->trusts[i].sid_ptr ) {
00239                         if ( !smb_io_dom_sid2("sid", &ctr->trusts[i].sid, ps, depth ) )
00240                                 return False;           
00241                 }
00242         }
00243         
00244         return True;
00245 }
00246 
00247 /************************************************************************
00248  initialize a DS_ENUM_DOM_TRUSTS request
00249 ************************************************************************/
00250 
00251 BOOL ds_io_q_enum_domain_trusts( const char *desc, DS_Q_ENUM_DOM_TRUSTS *q_u, prs_struct *ps, int depth)
00252 {
00253         prs_debug(ps, depth, desc, "ds_io_q_enum_domain_trusts");
00254         depth++;
00255 
00256         if ( !prs_align(ps) )
00257                 return False;
00258         
00259         if ( !prs_uint32( "server_ptr", ps, depth, &q_u->server_ptr ) )
00260                 return False;
00261         
00262         if ( !smb_io_unistr2("server", &q_u->server, q_u->server_ptr, ps, depth) )
00263                         return False;
00264         
00265         if ( !prs_align(ps) )
00266                 return False;
00267         
00268         if ( !prs_uint32( "flags", ps, depth, &q_u->flags ) )
00269                 return False;
00270         
00271         return True;
00272 }
00273 
00274 /************************************************************************
00275 ************************************************************************/
00276 
00277 BOOL ds_io_r_enum_domain_trusts( const char *desc, DS_R_ENUM_DOM_TRUSTS *r_u, prs_struct *ps, int depth)
00278 {
00279         prs_debug(ps, depth, desc, "ds_io_r_enum_domain_trusts");
00280         depth++;
00281 
00282         if(!prs_align(ps))
00283                 return False;
00284 
00285         if ( !prs_uint32( "num_domains", ps, depth, &r_u->num_domains ) )
00286                 return False;
00287                 
00288         if ( r_u->num_domains ) {
00289                 if ( !ds_io_dom_trusts_ctr("domains", &r_u->domains, ps, depth) )
00290                         return False;
00291         }
00292                 
00293         if(!prs_align(ps))
00294                 return False;
00295                         
00296         if ( !prs_ntstatus("status", ps, depth, &r_u->status ) )
00297                 return False;           
00298                 
00299         return True;
00300 }

Sambaに対してSat Aug 29 21:23:16 2009に生成されました。  doxygen 1.4.7