2 * Unix SMB/CIFS implementation.
3 * MSDfs RPC Pipe client / server routines
4 * Copyright (C) Andrew Tridgell 1992-2000,
5 * Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
6 * Copyright (C) Shirish Kalele 2000.
7 * Copyright (C) Jeremy Allison 2001.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #include "rpc_parse.h"
29 #define DBGC_CLASS DBGC_RPC_PARSE
31 /*******************************************************************
32 Make a DFS_Q_DFS_QUERY structure
33 *******************************************************************/
35 void init_dfs_q_dfs_exist(DFS_Q_DFS_EXIST
*q_d
)
40 /*************************************************************
41 Read/write a DFS_Q_DFS_EXIST structure - dummy...
42 ************************************************************/
44 BOOL
dfs_io_q_dfs_exist(const char *desc
, DFS_Q_DFS_EXIST
*q_d
, prs_struct
*ps
, int depth
)
49 prs_debug(ps
, depth
, desc
, "dfs_io_q_dfs_exist");
54 /*************************************************************
55 Read/write a DFS_R_DFS_EXIST structure
56 ************************************************************/
58 BOOL
dfs_io_r_dfs_exist(const char *desc
, DFS_R_DFS_EXIST
*q_d
, prs_struct
*ps
, int depth
)
63 prs_debug(ps
, depth
, desc
, "dfs_io_r_dfs_exist");
69 if(!prs_uint32("exist flag", ps
, 0, &q_d
->status
))
75 /*******************************************************************
76 Make a DFS_Q_DFS_REMOVE structure
77 *******************************************************************/
79 BOOL
init_dfs_q_dfs_remove(DFS_Q_DFS_REMOVE
*q_d
, const char *entrypath
,
80 const char *servername
, const char *sharename
)
82 DEBUG(5,("init_dfs_q_dfs_remove\n"));
83 init_unistr2(&q_d
->DfsEntryPath
, entrypath
, strlen(entrypath
)+1);
84 init_unistr2(&q_d
->ServerName
, servername
, strlen(servername
)+1);
85 init_unistr2(&q_d
->ShareName
, sharename
, strlen(sharename
)+1);
86 q_d
->ptr_ServerName
= q_d
->ptr_ShareName
= 1;
90 /*******************************************************************
91 Read/write a DFS_Q_DFS_REMOVE structure
92 *******************************************************************/
94 BOOL
dfs_io_q_dfs_remove(const char *desc
, DFS_Q_DFS_REMOVE
*q_d
, prs_struct
*ps
, int depth
)
99 prs_debug(ps
, depth
, desc
, "dfs_io_q_dfs_remove");
105 if(!smb_io_unistr2("DfsEntryPath",&q_d
->DfsEntryPath
, 1, ps
, depth
))
111 if(!prs_uint32("ptr_ServerName", ps
, depth
, &q_d
->ptr_ServerName
))
113 if(q_d
->ptr_ServerName
)
114 if (!smb_io_unistr2("ServerName",&q_d
->ServerName
, q_d
->ptr_ServerName
, ps
, depth
))
119 if(!prs_uint32("ptr_ShareName", ps
, depth
, &q_d
->ptr_ShareName
))
121 if(q_d
->ptr_ShareName
)
122 if (!smb_io_unistr2("ShareName",&q_d
->ShareName
, q_d
->ptr_ShareName
, ps
, depth
))
130 /*******************************************************************
131 Read/write a DFS_R_DFS_REMOVE structure
132 *******************************************************************/
134 BOOL
dfs_io_r_dfs_remove(const char *desc
, DFS_R_DFS_REMOVE
*r_d
, prs_struct
*ps
, int depth
)
139 prs_debug(ps
, depth
, desc
, "dfs_io_r_dfs_remove");
142 if(!prs_werror("status", ps
, depth
, &r_d
->status
))
148 /*******************************************************************
149 Make a DFS_Q_DFS_ADD structure
150 *******************************************************************/
152 BOOL
init_dfs_q_dfs_add(DFS_Q_DFS_ADD
*q_d
, const char *entrypath
,
153 const char *servername
, const char *sharename
,
154 const char *comment
, uint32 flags
)
156 DEBUG(5,("init_dfs_q_dfs_add\n"));
157 q_d
->ptr_DfsEntryPath
= q_d
->ptr_ServerName
= q_d
->ptr_ShareName
= 1;
158 init_unistr2(&q_d
->DfsEntryPath
, entrypath
, strlen(entrypath
)+1);
159 init_unistr2(&q_d
->ServerName
, servername
, strlen(servername
)+1);
160 init_unistr2(&q_d
->ShareName
, sharename
, strlen(sharename
)+1);
161 if(comment
!= NULL
) {
162 init_unistr2(&q_d
->Comment
, comment
, strlen(comment
)+1);
163 q_d
->ptr_Comment
= 1;
165 q_d
->ptr_Comment
= 0;
172 /************************************************************
173 Read/write a DFS_Q_DFS_ADD structure
174 ************************************************************/
176 BOOL
dfs_io_q_dfs_add(const char *desc
, DFS_Q_DFS_ADD
*q_d
, prs_struct
*ps
, int depth
)
181 prs_debug(ps
, depth
, desc
, "dfs_io_q_dfs_add");
187 if(!smb_io_unistr2("DfsEntryPath",&q_d
->DfsEntryPath
, 1, ps
, depth
))
192 if(!smb_io_unistr2("ServerName",&q_d
->ServerName
, 1, ps
, depth
))
197 if(!prs_uint32("ptr_ShareName", ps
, depth
, &q_d
->ptr_ShareName
))
199 if(!smb_io_unistr2("ShareName",&q_d
->ShareName
, 1, ps
, depth
))
204 if(!prs_uint32("ptr_Comment", ps
, depth
, &q_d
->ptr_Comment
))
206 if(!smb_io_unistr2("",&q_d
->Comment
, q_d
->ptr_Comment
, ps
, depth
))
211 if(!prs_uint32("Flags", ps
, depth
, &q_d
->Flags
))
217 /************************************************************
218 Read/write a DFS_R_DFS_ADD structure
219 ************************************************************/
221 BOOL
dfs_io_r_dfs_add(const char *desc
, DFS_R_DFS_ADD
*r_d
, prs_struct
*ps
, int depth
)
226 prs_debug(ps
, depth
, desc
, "dfs_io_r_dfs_add");
229 if(!prs_werror("status", ps
, depth
, &r_d
->status
))
235 BOOL
init_dfs_q_dfs_get_info(DFS_Q_DFS_GET_INFO
*q_d
, const char *entrypath
,
236 const char *servername
, const char *sharename
,
239 DEBUG(5,("init_dfs_q2_get_info\n"));
240 init_unistr2(&q_d
->uni_path
, entrypath
, strlen(entrypath
)+1);
241 init_unistr2(&q_d
->uni_server
, servername
, strlen(servername
)+1);
242 init_unistr2(&q_d
->uni_share
, sharename
, strlen(sharename
)+1);
243 q_d
->level
= info_level
;
244 q_d
->ptr_server
= q_d
->ptr_share
= 1;
248 /************************************************************
249 Read/write a DFS_Q_GET_INFO structure
250 ************************************************************/
252 BOOL
dfs_io_q_dfs_get_info(const char *desc
, DFS_Q_DFS_GET_INFO
* q_i
, prs_struct
* ps
, int depth
)
257 prs_debug(ps
, depth
, desc
, "dfs_io_q_dfs_get_info");
260 if(!smb_io_unistr2("",&q_i
->uni_path
, 1, ps
, depth
))
266 if(!prs_uint32("ptr_server", ps
, depth
, &q_i
->ptr_server
))
270 if (!smb_io_unistr2("",&q_i
->uni_server
, q_i
->ptr_server
, ps
, depth
))
275 if(!prs_uint32("ptr_share", ps
, depth
, &q_i
->ptr_share
))
278 if(!smb_io_unistr2("", &q_i
->uni_share
, q_i
->ptr_share
, ps
, depth
))
283 if(!prs_uint32("level", ps
, depth
, &q_i
->level
))
288 /************************************************************
289 Read/write a DFS_R_GET_INFO structure
290 ************************************************************/
292 BOOL
dfs_io_r_dfs_get_info(const char *desc
, DFS_R_DFS_GET_INFO
* r_i
, prs_struct
* ps
, int depth
)
297 if(!prs_uint32("level", ps
, depth
, &r_i
->level
))
299 if(!prs_uint32("ptr_ctr", ps
, depth
, &r_i
->ptr_ctr
))
302 if(!dfs_io_dfs_info_ctr("", &r_i
->ctr
, 1, r_i
->level
, ps
, depth
))
304 if(!prs_werror("status", ps
, depth
, &r_i
->status
))
309 /************************************************************
310 Make a DFS_Q_DFS_ENUM structure
311 ************************************************************/
312 BOOL
init_dfs_q_dfs_enum(DFS_Q_DFS_ENUM
*q_d
, uint32 level
, DFS_INFO_CTR
*ctr
)
315 q_d
->maxpreflen
= -1;
319 q_d
->ptr_num_entries
= 1;
320 q_d
->num_entries
= 0;
321 q_d
->num_entries2
= 0;
322 q_d
->reshnd
.ptr_hnd
= 1;
323 q_d
->reshnd
.handle
= 0;
327 /************************************************************
328 Read or write the DFS_Q_DFS_ENUM structure
329 ************************************************************/
331 BOOL
dfs_io_q_dfs_enum(const char *desc
, DFS_Q_DFS_ENUM
*q_d
, prs_struct
*ps
, int depth
)
336 prs_debug(ps
, depth
, desc
, "dfs_io_q_dfs_enum");
342 if(!prs_uint32("level", ps
, depth
, &q_d
->level
))
344 if(!prs_uint32("maxpreflen", ps
, depth
, &q_d
->maxpreflen
))
346 if(!prs_uint32("ptr_buffer", ps
, depth
, &q_d
->ptr_buffer
))
348 if(!prs_uint32("level2", ps
, depth
, &q_d
->level2
))
350 if(!prs_uint32("level3", ps
, depth
, &q_d
->level2
))
353 if(!prs_uint32("ptr_num_entries", ps
, depth
, &q_d
->ptr_num_entries
))
355 if(!prs_uint32("num_entries", ps
, depth
, &q_d
->num_entries
))
357 if(!prs_uint32("num_entries2", ps
, depth
, &q_d
->num_entries2
))
359 if(!smb_io_enum_hnd("resume_hnd",&q_d
->reshnd
, ps
, depth
))
364 /************************************************************
365 Read/write a DFS_INFO_CTR structure
366 ************************************************************/
368 BOOL
dfs_io_dfs_info_ctr(const char *desc
, DFS_INFO_CTR
* ctr
, uint32 num_entries
, uint32 level
, prs_struct
* ps
, int depth
)
375 /* should depend on whether marshalling or unmarshalling! */
376 if(UNMARSHALLING(ps
)) {
377 ctr
->dfs
.info1
= (DFS_INFO_1
*)prs_alloc_mem(ps
, sizeof(DFS_INFO_1
)*num_entries
);
382 for(i
=0;i
<num_entries
;i
++) {
383 if(!prs_uint32("ptr_entrypath",ps
, depth
, &ctr
->dfs
.info1
[i
].ptr_entrypath
))
386 for(i
=0;i
<num_entries
;i
++) {
387 if(!smb_io_unistr2("", &ctr
->dfs
.info1
[i
].entrypath
, ctr
->dfs
.info1
[i
].ptr_entrypath
, ps
, depth
))
396 if(UNMARSHALLING(ps
)) {
397 ctr
->dfs
.info2
= (DFS_INFO_2
*)prs_alloc_mem(ps
, num_entries
*sizeof(DFS_INFO_2
));
402 for(i
=0;i
<num_entries
;i
++) {
403 if(!prs_uint32("ptr_entrypath", ps
, depth
, &ctr
->dfs
.info2
[i
].ptr_entrypath
))
405 if(!prs_uint32("ptr_comment", ps
, depth
, &ctr
->dfs
.info2
[i
].ptr_comment
))
407 if(!prs_uint32("state", ps
, depth
, &ctr
->dfs
.info2
[i
].state
))
409 if(!prs_uint32("num_storages", ps
, depth
, &ctr
->dfs
.info2
[i
].num_storages
))
412 for(i
=0;i
<num_entries
;i
++) {
413 if(!smb_io_unistr2("", &ctr
->dfs
.info2
[i
].entrypath
, ctr
->dfs
.info2
[i
].ptr_entrypath
, ps
, depth
))
417 if(!smb_io_unistr2("",&ctr
->dfs
.info2
[i
].comment
, ctr
->dfs
.info2
[i
].ptr_comment
, ps
, depth
))
426 if(UNMARSHALLING(ps
)) {
427 ctr
->dfs
.info3
= (DFS_INFO_3
*)prs_alloc_mem(ps
, num_entries
*sizeof(DFS_INFO_3
));
432 for(i
=0;i
<num_entries
;i
++) {
433 if(!prs_uint32("ptr_entrypath", ps
, depth
, &ctr
->dfs
.info3
[i
].ptr_entrypath
))
435 if(!prs_uint32("ptr_comment", ps
, depth
, &ctr
->dfs
.info3
[i
].ptr_comment
))
437 if(!prs_uint32("state", ps
, depth
, &ctr
->dfs
.info3
[i
].state
))
439 if(!prs_uint32("num_storages", ps
, depth
, &ctr
->dfs
.info3
[i
].num_storages
))
441 if(!prs_uint32("ptr_storages", ps
, depth
, &ctr
->dfs
.info3
[i
].ptr_storages
))
444 for(i
=0;i
<num_entries
;i
++) {
445 if(!smb_io_unistr2("", &ctr
->dfs
.info3
[i
].entrypath
, ctr
->dfs
.info3
[i
].ptr_entrypath
, ps
, depth
))
449 if(!smb_io_unistr2("", &ctr
->dfs
.info3
[i
].comment
, ctr
->dfs
.info3
[i
].ptr_comment
, ps
, depth
))
453 if(!prs_uint32("num_storage_infos", ps
, depth
, &ctr
->dfs
.info3
[i
].num_storage_infos
))
456 if(!dfs_io_dfs_storage_info("storage_info", &ctr
->dfs
.info3
[i
], ps
, depth
))
464 /************************************************************
465 Read/write a DFS_R_DFS_ENUM structure
466 ************************************************************/
468 BOOL
dfs_io_r_dfs_enum(const char *desc
, DFS_R_DFS_ENUM
*q_d
, prs_struct
*ps
, int depth
)
477 prs_debug(ps
, depth
, desc
, "dfs_io_r_dfs_enum");
483 if(!prs_uint32("ptr_buffer", ps
, depth
, &q_d
->ptr_buffer
))
485 if(!prs_uint32("level", ps
, depth
, &q_d
->level
))
487 if(!prs_uint32("level2", ps
, depth
, &ctr
->switch_value
))
489 if(!prs_uint32("ptr_num_entries", ps
, depth
, &q_d
->ptr_num_entries
))
491 if(q_d
->ptr_num_entries
)
492 if(!prs_uint32("num_entries", ps
, depth
, &q_d
->num_entries
))
494 if(!prs_uint32("ptr_num_entries2", ps
, depth
, &q_d
->ptr_num_entries2
))
496 if(q_d
->ptr_num_entries2
)
497 if(!prs_uint32("num_entries2", ps
, depth
, &ctr
->num_entries
))
500 if(!dfs_io_dfs_info_ctr("", ctr
, q_d
->num_entries
, q_d
->level
, ps
, depth
))
503 if(!smb_io_enum_hnd("resume_hnd", &q_d
->reshnd
, ps
, depth
))
505 if(!prs_werror("status", ps
, depth
, &q_d
->status
))
510 BOOL
dfs_io_dfs_storage_info(const char *desc
, DFS_INFO_3
* info3
, prs_struct
*ps
, int depth
)
516 prs_debug(ps
, depth
, desc
, "smb_io_dfs_storage_info");
519 if(UNMARSHALLING(ps
)) {
520 info3
->storages
= (DFS_STORAGE_INFO
*)prs_alloc_mem(ps
, info3
->num_storage_infos
*sizeof(DFS_STORAGE_INFO
));
521 if (!info3
->storages
)
525 for(i
=0;i
<info3
->num_storage_infos
;i
++) {
526 if(!prs_uint32("storage_state", ps
, depth
, &info3
->storages
[i
].state
))
528 if(!prs_uint32("ptr_servername", ps
, depth
, &info3
->storages
[i
].ptr_servername
))
530 if(!prs_uint32("ptr_sharename", ps
, depth
, &info3
->storages
[i
].ptr_sharename
))
534 for(i
=0;i
<info3
->num_storage_infos
;i
++) {
535 if(!smb_io_unistr2("servername", &info3
->storages
[i
].servername
, info3
->storages
[i
].ptr_servername
, ps
, depth
))
539 if(!smb_io_unistr2("sharename", &info3
->storages
[i
].sharename
, info3
->storages
[i
].ptr_sharename
, ps
, depth
))