2 * Unix SMB/Netbios implementation.
4 * MSDfs RPC Pipe client / server routines
5 * Copyright (C) Andrew Tridgell 1992-2000,
6 * Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
7 * Copyright (C) Shirish Kalele 2000.
8 * Copyright (C) Jeremy Allison 2001.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include "rpc_parse.h"
29 extern int DEBUGLEVEL
;
31 /*************************************************************
32 Read/write a DFS_Q_DFS_EXIST structure - dummy...
33 ************************************************************/
35 BOOL
dfs_io_q_dfs_exist(char *desc
, DFS_Q_DFS_EXIST
*q_d
, prs_struct
*ps
, int depth
)
40 prs_debug(ps
, depth
, desc
, "dfs_io_q_dfs_exist");
45 /*************************************************************
46 Read/write a DFS_R_DFS_EXIST structure
47 ************************************************************/
49 BOOL
dfs_io_r_dfs_exist(char *desc
, DFS_R_DFS_EXIST
*q_d
, prs_struct
*ps
, int depth
)
54 prs_debug(ps
, depth
, desc
, "dfs_io_r_dfs_exist");
60 if(!prs_uint32("exist flag", ps
, 0, &q_d
->status
))
66 /*******************************************************************
67 Make a DFS_Q_DFS_REMOVE structure
68 *******************************************************************/
70 BOOL
make_dfs_q_dfs_remove(DFS_Q_DFS_REMOVE
*q_d
, char *entrypath
,
71 char *servername
, char *sharename
)
73 DEBUG(5,("make_dfs_q_dfs_remove\n"));
74 init_unistr2(&q_d
->DfsEntryPath
, entrypath
, strlen(entrypath
)+1);
75 init_unistr2(&q_d
->ServerName
, servername
, strlen(servername
)+1);
76 init_unistr2(&q_d
->ShareName
, sharename
, strlen(sharename
)+1);
77 q_d
->ptr_ServerName
= q_d
->ptr_ShareName
= 1;
81 /*******************************************************************
82 Read/write a DFS_Q_DFS_REMOVE structure
83 *******************************************************************/
85 BOOL
dfs_io_q_dfs_remove(char *desc
, DFS_Q_DFS_REMOVE
*q_d
, prs_struct
*ps
, int depth
)
90 prs_debug(ps
, depth
, desc
, "dfs_io_q_dfs_remove");
96 if(!smb_io_unistr2("DfsEntryPath",&q_d
->DfsEntryPath
, 1, ps
, depth
))
102 if(!prs_uint32("ptr_ServerName", ps
, depth
, &q_d
->ptr_ServerName
))
104 if(q_d
->ptr_ServerName
)
105 if (!smb_io_unistr2("ServerName",&q_d
->ServerName
, q_d
->ptr_ServerName
, ps
, depth
))
110 if(!prs_uint32("ptr_ShareName", ps
, depth
, &q_d
->ptr_ShareName
))
112 if(q_d
->ptr_ShareName
)
113 if (!smb_io_unistr2("ShareName",&q_d
->ShareName
, q_d
->ptr_ShareName
, ps
, depth
))
121 /*******************************************************************
122 Read/write a DFS_R_DFS_REMOVE structure
123 *******************************************************************/
125 BOOL
dfs_io_r_dfs_remove(char *desc
, DFS_R_DFS_REMOVE
*r_d
, prs_struct
*ps
, int depth
)
130 prs_debug(ps
, depth
, desc
, "dfs_io_r_dfs_remove");
133 if(!prs_uint32("status", ps
, depth
, &r_d
->status
))
139 /*******************************************************************
140 Make a DFS_Q_DFS_ADD structure
141 *******************************************************************/
143 BOOL
make_dfs_q_dfs_add(DFS_Q_DFS_ADD
*q_d
, char *entrypath
, char *servername
,
144 char *sharename
, char *comment
, uint32 flags
)
146 DEBUG(5,("make_dfs_q_dfs_add\n"));
147 q_d
->ptr_DfsEntryPath
= q_d
->ptr_ServerName
= q_d
->ptr_ShareName
= 1;
148 init_unistr2(&q_d
->DfsEntryPath
, entrypath
, strlen(entrypath
)+1);
149 init_unistr2(&q_d
->ServerName
, servername
, strlen(servername
)+1);
150 init_unistr2(&q_d
->ShareName
, sharename
, strlen(sharename
)+1);
151 if(comment
!= NULL
) {
152 init_unistr2(&q_d
->Comment
, comment
, strlen(comment
)+1);
153 q_d
->ptr_Comment
= 1;
155 q_d
->ptr_Comment
= 0;
162 /************************************************************
163 Read/write a DFS_Q_DFS_ADD structure
164 ************************************************************/
166 BOOL
dfs_io_q_dfs_add(char *desc
, DFS_Q_DFS_ADD
*q_d
, prs_struct
*ps
, int depth
)
171 prs_debug(ps
, depth
, desc
, "dfs_io_q_dfs_add");
177 if(!smb_io_unistr2("DfsEntryPath",&q_d
->DfsEntryPath
, 1, ps
, depth
))
182 if(!smb_io_unistr2("ServerName",&q_d
->ServerName
, 1, ps
, depth
))
187 if(!prs_uint32("ptr_ShareName", ps
, depth
, &q_d
->ptr_ShareName
))
189 if(!smb_io_unistr2("ShareName",&q_d
->ShareName
, 1, ps
, depth
))
194 if(!prs_uint32("ptr_Comment", ps
, depth
, &q_d
->ptr_Comment
))
196 if(!smb_io_unistr2("",&q_d
->Comment
, q_d
->ptr_Comment
, ps
, depth
))
201 if(!prs_uint32("Flags", ps
, depth
, &q_d
->Flags
))
207 /************************************************************
208 Read/write a DFS_R_DFS_ADD structure
209 ************************************************************/
211 BOOL
dfs_io_r_dfs_add(char *desc
, DFS_R_DFS_ADD
*r_d
, prs_struct
*ps
, int depth
)
216 prs_debug(ps
, depth
, desc
, "dfs_io_r_dfs_add");
219 if(!prs_uint32("status", ps
, depth
, &r_d
->status
))
225 /************************************************************
226 Read/write a DFS_Q_GET_INFO structure
227 ************************************************************/
229 BOOL
dfs_io_q_dfs_get_info(char* desc
, DFS_Q_DFS_GET_INFO
* q_i
, prs_struct
* ps
, int depth
)
234 prs_debug(ps
, depth
, desc
, "dfs_io_q_dfs_get_info");
237 if(!smb_io_unistr2("",&q_i
->uni_path
, 1, ps
, depth
))
243 if(!prs_uint32("ptr_server", ps
, depth
, &q_i
->ptr_server
))
247 if (!smb_io_unistr2("",&q_i
->uni_server
, q_i
->ptr_server
, ps
, depth
))
252 if(!prs_uint32("ptr_share", ps
, depth
, &q_i
->ptr_share
))
255 if(!smb_io_unistr2("", &q_i
->uni_share
, q_i
->ptr_share
, ps
, depth
))
260 if(!prs_uint32("level", ps
, depth
, &q_i
->level
))
265 /************************************************************
266 Read/write a DFS_R_GET_INFO structure
267 ************************************************************/
269 BOOL
dfs_io_r_dfs_get_info(char* desc
, DFS_R_DFS_GET_INFO
* r_i
, prs_struct
* ps
, int depth
)
274 if(!prs_uint32("level", ps
, depth
, &r_i
->level
))
276 if(!prs_uint32("ptr_ctr", ps
, depth
, &r_i
->ptr_ctr
))
279 if(!dfs_io_dfs_info_ctr("", &r_i
->ctr
, 1, r_i
->level
, ps
, depth
))
281 if(!prs_uint32("status", ps
, depth
, &r_i
->status
))
286 /************************************************************
287 Make a DFS_Q_DFS_ENUM structure
288 ************************************************************/
289 BOOL
make_dfs_q_dfs_enum(DFS_Q_DFS_ENUM
*q_d
, uint32 level
, DFS_INFO_CTR
*ctr
)
292 q_d
->maxpreflen
= -1;
296 q_d
->ptr_num_entries
= 1;
297 q_d
->num_entries
= 0;
298 q_d
->num_entries2
= 0;
299 q_d
->reshnd
.ptr_hnd
= 1;
300 q_d
->reshnd
.handle
= 0;
304 /************************************************************
305 Read or write the DFS_Q_DFS_ENUM structure
306 ************************************************************/
308 BOOL
dfs_io_q_dfs_enum(char *desc
, DFS_Q_DFS_ENUM
*q_d
, prs_struct
*ps
, int depth
)
313 prs_debug(ps
, depth
, desc
, "dfs_io_q_dfs_enum");
319 if(!prs_uint32("level", ps
, depth
, &q_d
->level
))
321 if(!prs_uint32("maxpreflen", ps
, depth
, &q_d
->maxpreflen
))
323 if(!prs_uint32("ptr_buffer", ps
, depth
, &q_d
->ptr_buffer
))
325 if(!prs_uint32("level2", ps
, depth
, &q_d
->level2
))
327 if(!prs_uint32("level3", ps
, depth
, &q_d
->level2
))
330 if(!prs_uint32("ptr_num_entries", ps
, depth
, &q_d
->ptr_num_entries
))
332 if(!prs_uint32("num_entries", ps
, depth
, &q_d
->num_entries
))
334 if(!prs_uint32("num_entries2", ps
, depth
, &q_d
->num_entries2
))
336 if(!smb_io_enum_hnd("resume_hnd",&q_d
->reshnd
, ps
, depth
))
341 /************************************************************
342 Read/write a DFS_INFO_CTR structure
343 ************************************************************/
345 BOOL
dfs_io_dfs_info_ctr(char* desc
, DFS_INFO_CTR
* ctr
, uint32 num_entries
, uint32 level
, prs_struct
* ps
, int depth
)
352 /* should depend on whether marshalling or unmarshalling! */
353 if(UNMARSHALLING(ps
)) {
354 ctr
->dfs
.info1
= (DFS_INFO_1
*)prs_alloc_mem(ps
, sizeof(DFS_INFO_1
)*num_entries
);
359 for(i
=0;i
<num_entries
;i
++) {
360 if(!prs_uint32("ptr_entrypath",ps
, depth
, &ctr
->dfs
.info1
[i
].ptr_entrypath
))
363 for(i
=0;i
<num_entries
;i
++) {
364 if(!smb_io_unistr2("", &ctr
->dfs
.info1
[i
].entrypath
, ctr
->dfs
.info1
[i
].ptr_entrypath
, ps
, depth
))
373 if(UNMARSHALLING(ps
)) {
374 ctr
->dfs
.info2
= (DFS_INFO_2
*)prs_alloc_mem(ps
, num_entries
*sizeof(DFS_INFO_2
));
379 for(i
=0;i
<num_entries
;i
++) {
380 if(!prs_uint32("ptr_entrypath", ps
, depth
, &ctr
->dfs
.info2
[i
].ptr_entrypath
))
382 if(!prs_uint32("ptr_comment", ps
, depth
, &ctr
->dfs
.info2
[i
].ptr_comment
))
384 if(!prs_uint32("state", ps
, depth
, &ctr
->dfs
.info2
[i
].state
))
386 if(!prs_uint32("num_storages", ps
, depth
, &ctr
->dfs
.info2
[i
].num_storages
))
389 for(i
=0;i
<num_entries
;i
++) {
390 if(!smb_io_unistr2("", &ctr
->dfs
.info2
[i
].entrypath
, ctr
->dfs
.info2
[i
].ptr_entrypath
, ps
, depth
))
394 if(!smb_io_unistr2("",&ctr
->dfs
.info2
[i
].comment
, ctr
->dfs
.info2
[i
].ptr_comment
, ps
, depth
))
403 if(UNMARSHALLING(ps
)) {
404 ctr
->dfs
.info3
= (DFS_INFO_3
*)prs_alloc_mem(ps
, num_entries
*sizeof(DFS_INFO_3
));
409 for(i
=0;i
<num_entries
;i
++) {
410 if(!prs_uint32("ptr_entrypath", ps
, depth
, &ctr
->dfs
.info3
[i
].ptr_entrypath
))
412 if(!prs_uint32("ptr_comment", ps
, depth
, &ctr
->dfs
.info3
[i
].ptr_comment
))
414 if(!prs_uint32("state", ps
, depth
, &ctr
->dfs
.info3
[i
].state
))
416 if(!prs_uint32("num_storages", ps
, depth
, &ctr
->dfs
.info3
[i
].num_storages
))
418 if(!prs_uint32("ptr_storages", ps
, depth
, &ctr
->dfs
.info3
[i
].ptr_storages
))
421 for(i
=0;i
<num_entries
;i
++) {
422 if(!smb_io_unistr2("", &ctr
->dfs
.info3
[i
].entrypath
, ctr
->dfs
.info3
[i
].ptr_entrypath
, ps
, depth
))
426 if(!smb_io_unistr2("", &ctr
->dfs
.info3
[i
].comment
, ctr
->dfs
.info3
[i
].ptr_comment
, ps
, depth
))
430 if(!prs_uint32("num_storage_infos", ps
, depth
, &ctr
->dfs
.info3
[i
].num_storage_infos
))
433 if(!dfs_io_dfs_storage_info("storage_info", &ctr
->dfs
.info3
[i
], ps
, depth
))
441 /************************************************************
442 Read/write a DFS_R_DFS_ENUM structure
443 ************************************************************/
445 BOOL
dfs_io_r_dfs_enum(char *desc
, DFS_R_DFS_ENUM
*q_d
, prs_struct
*ps
, int depth
)
454 prs_debug(ps
, depth
, desc
, "dfs_io_r_dfs_enum");
460 if(!prs_uint32("ptr_buffer", ps
, depth
, &q_d
->ptr_buffer
))
462 if(!prs_uint32("level", ps
, depth
, &q_d
->level
))
464 if(!prs_uint32("level2", ps
, depth
, &ctr
->switch_value
))
466 if(!prs_uint32("ptr_num_entries", ps
, depth
, &q_d
->ptr_num_entries
))
468 if(q_d
->ptr_num_entries
)
469 if(!prs_uint32("num_entries", ps
, depth
, &q_d
->num_entries
))
471 if(!prs_uint32("ptr_num_entries2", ps
, depth
, &q_d
->ptr_num_entries2
))
473 if(q_d
->ptr_num_entries2
)
474 if(!prs_uint32("num_entries2", ps
, depth
, &ctr
->num_entries
))
477 if(!dfs_io_dfs_info_ctr("", ctr
, q_d
->num_entries
, q_d
->level
, ps
, depth
))
480 if(!smb_io_enum_hnd("resume_hnd", &q_d
->reshnd
, ps
, depth
))
482 if(!prs_uint32("status", ps
, depth
, &q_d
->status
))
487 BOOL
dfs_io_dfs_storage_info(char *desc
, DFS_INFO_3
* info3
, prs_struct
*ps
, int depth
)
493 prs_debug(ps
, depth
, desc
, "smb_io_dfs_storage_info");
496 if(UNMARSHALLING(ps
)) {
497 info3
->storages
= (DFS_STORAGE_INFO
*)prs_alloc_mem(ps
, info3
->num_storage_infos
*sizeof(DFS_STORAGE_INFO
));
498 if (!info3
->storages
)
502 for(i
=0;i
<info3
->num_storage_infos
;i
++) {
503 if(!prs_uint32("storage_state", ps
, depth
, &info3
->storages
[i
].state
))
505 if(!prs_uint32("ptr_servername", ps
, depth
, &info3
->storages
[i
].ptr_servername
))
507 if(!prs_uint32("ptr_sharename", ps
, depth
, &info3
->storages
[i
].ptr_sharename
))
511 for(i
=0;i
<info3
->num_storage_infos
;i
++) {
512 if(!smb_io_unistr2("servername", &info3
->storages
[i
].servername
, info3
->storages
[i
].ptr_servername
, ps
, depth
))
516 if(!smb_io_unistr2("sharename", &info3
->storages
[i
].sharename
, info3
->storages
[i
].ptr_sharename
, ps
, depth
))