first public release of samba4 code
[samba.git] / source / rpc_parse / parse_ds.c
1 /* 
2  *  Unix SMB/CIFS implementation.
3  *  RPC Pipe client / server routines
4  *  Copyright (C) Gerald Carter                         2002
5  *  
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *  
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *  
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  */
20
21 #include "includes.h"
22
23 static BOOL ds_io_dominfobasic( const char *desc, prs_struct *ps, int depth, DSROLE_PRIMARY_DOMAIN_INFO_BASIC **basic)
24 {
25         DSROLE_PRIMARY_DOMAIN_INFO_BASIC *p = *basic;
26         
27         if ( UNMARSHALLING(ps) )
28                 p = *basic = (DSROLE_PRIMARY_DOMAIN_INFO_BASIC *)prs_alloc_mem(ps, sizeof(DSROLE_PRIMARY_DOMAIN_INFO_BASIC));
29                 
30         if ( !p )
31                 return False;
32                 
33         if ( !prs_uint16("machine_role", ps, depth, &p->machine_role) )
34                 return False;
35         if ( !prs_uint16("unknown", ps, depth, &p->unknown) )
36                 return False;
37
38         if ( !prs_uint32("flags", ps, depth, &p->flags) )
39                 return False;
40
41         if ( !prs_uint32("netbios_ptr", ps, depth, &p->netbios_ptr) )
42                 return False;
43         if ( !prs_uint32("dnsname_ptr", ps, depth, &p->dnsname_ptr) )
44                 return False;
45         if ( !prs_uint32("forestname_ptr", ps, depth, &p->forestname_ptr) )
46                 return False;
47                 
48         if ( !prs_uint8s(False, "domain_guid", ps, depth, p->domain_guid.info, GUID_SIZE) )
49                 return False;
50                 
51         if ( !smb_io_unistr2( "netbios_domain", &p->netbios_domain, p->netbios_ptr, ps, depth) )
52                 return False;
53         if ( !prs_align(ps) )
54                 return False;
55         
56         if ( !smb_io_unistr2( "dns_domain", &p->dns_domain, p->dnsname_ptr, ps, depth) )
57                 return False;
58         if ( !prs_align(ps) )
59                 return False;
60         
61         if ( !smb_io_unistr2( "forest_domain", &p->forest_domain, p->forestname_ptr, ps, depth) )
62                 return False;
63         if ( !prs_align(ps) )
64                 return False;
65         
66                 
67         return True;
68                 
69 }
70
71 BOOL ds_io_q_getprimdominfo( const char *desc, DS_Q_GETPRIMDOMINFO *q_u, prs_struct *ps, int depth)
72 {
73         prs_debug(ps, depth, desc, "ds_io_q_getprimdominfo");
74         depth++;
75
76         if(!prs_align(ps))
77                 return False;
78
79         if ( !prs_uint16( "level", ps, depth, &q_u->level ) )
80                 return False;
81                 
82         return True;
83 }
84
85 BOOL ds_io_r_getprimdominfo( const char *desc, DS_R_GETPRIMDOMINFO *r_u, prs_struct *ps, int depth)
86 {
87         prs_debug(ps, depth, desc, "ds_io_r_getprimdominfo");
88         depth++;
89
90         if(!prs_align(ps))
91                 return False;
92
93         if ( !prs_uint32( "ptr", ps, depth, &r_u->ptr ) )
94                 return False;
95                 
96         if ( r_u->ptr )
97         {
98                 if ( !prs_uint16( "level", ps, depth, &r_u->level ) )
99                         return False;
100         
101                 if ( !prs_uint16( "unknown0", ps, depth, &r_u->unknown0 ) )
102                         return False;
103                 
104                 switch ( r_u->level )
105                 {
106                         case DsRolePrimaryDomainInfoBasic:
107                                 if ( !ds_io_dominfobasic( "dominfobasic", ps, depth, &r_u->info.basic ) )
108                                         return False;
109                                 break;
110                         default:
111                                 return False;
112                 }
113         }
114
115         if ( !prs_align(ps) )
116                 return False;
117         
118         if ( !prs_ntstatus("status", ps, depth, &r_u->status ) )
119                 return False;           
120                 
121         return True;
122 }