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"
28 /*******************************************************************
29 Make a DFS_Q_DFS_QUERY structure
30 *******************************************************************/
32 void init_dfs_q_dfs_exist(DFS_Q_DFS_EXIST *q_d)
37 /*************************************************************
38 Read/write a DFS_Q_DFS_EXIST structure - dummy...
39 ************************************************************/
41 BOOL dfs_io_q_dfs_exist(char *desc, DFS_Q_DFS_EXIST *q_d, prs_struct *ps, int depth)
46 prs_debug(ps, depth, desc, "dfs_io_q_dfs_exist");
51 /*************************************************************
52 Read/write a DFS_R_DFS_EXIST structure
53 ************************************************************/
55 BOOL dfs_io_r_dfs_exist(char *desc, DFS_R_DFS_EXIST *q_d, prs_struct *ps, int depth)
60 prs_debug(ps, depth, desc, "dfs_io_r_dfs_exist");
66 if(!prs_uint32("exist flag", ps, 0, &q_d->status))
72 /*******************************************************************
73 Make a DFS_Q_DFS_REMOVE structure
74 *******************************************************************/
76 BOOL init_dfs_q_dfs_remove(DFS_Q_DFS_REMOVE *q_d, char *entrypath,
77 char *servername, char *sharename)
79 DEBUG(5,("init_dfs_q_dfs_remove\n"));
80 init_unistr2(&q_d->DfsEntryPath, entrypath, strlen(entrypath)+1);
81 init_unistr2(&q_d->ServerName, servername, strlen(servername)+1);
82 init_unistr2(&q_d->ShareName, sharename, strlen(sharename)+1);
83 q_d->ptr_ServerName = q_d->ptr_ShareName = 1;
87 /*******************************************************************
88 Read/write a DFS_Q_DFS_REMOVE structure
89 *******************************************************************/
91 BOOL dfs_io_q_dfs_remove(char *desc, DFS_Q_DFS_REMOVE *q_d, prs_struct *ps, int depth)
96 prs_debug(ps, depth, desc, "dfs_io_q_dfs_remove");
102 if(!smb_io_unistr2("DfsEntryPath",&q_d->DfsEntryPath, 1, ps, depth))
108 if(!prs_uint32("ptr_ServerName", ps, depth, &q_d->ptr_ServerName))
110 if(q_d->ptr_ServerName)
111 if (!smb_io_unistr2("ServerName",&q_d->ServerName, q_d->ptr_ServerName, ps, depth))
116 if(!prs_uint32("ptr_ShareName", ps, depth, &q_d->ptr_ShareName))
118 if(q_d->ptr_ShareName)
119 if (!smb_io_unistr2("ShareName",&q_d->ShareName, q_d->ptr_ShareName, ps, depth))
127 /*******************************************************************
128 Read/write a DFS_R_DFS_REMOVE structure
129 *******************************************************************/
131 BOOL dfs_io_r_dfs_remove(char *desc, DFS_R_DFS_REMOVE *r_d, prs_struct *ps, int depth)
136 prs_debug(ps, depth, desc, "dfs_io_r_dfs_remove");
139 if(!prs_werror("status", ps, depth, &r_d->status))
145 /*******************************************************************
146 Make a DFS_Q_DFS_ADD structure
147 *******************************************************************/
149 BOOL init_dfs_q_dfs_add(DFS_Q_DFS_ADD *q_d, char *entrypath, char *servername,
150 char *sharename, char *comment, uint32 flags)
152 DEBUG(5,("init_dfs_q_dfs_add\n"));
153 q_d->ptr_DfsEntryPath = q_d->ptr_ServerName = q_d->ptr_ShareName = 1;
154 init_unistr2(&q_d->DfsEntryPath, entrypath, strlen(entrypath)+1);
155 init_unistr2(&q_d->ServerName, servername, strlen(servername)+1);
156 init_unistr2(&q_d->ShareName, sharename, strlen(sharename)+1);
157 if(comment != NULL) {
158 init_unistr2(&q_d->Comment, comment, strlen(comment)+1);
159 q_d->ptr_Comment = 1;
161 q_d->ptr_Comment = 0;
168 /************************************************************
169 Read/write a DFS_Q_DFS_ADD structure
170 ************************************************************/
172 BOOL dfs_io_q_dfs_add(char *desc, DFS_Q_DFS_ADD *q_d, prs_struct *ps, int depth)
177 prs_debug(ps, depth, desc, "dfs_io_q_dfs_add");
183 if(!smb_io_unistr2("DfsEntryPath",&q_d->DfsEntryPath, 1, ps, depth))
188 if(!smb_io_unistr2("ServerName",&q_d->ServerName, 1, ps, depth))
193 if(!prs_uint32("ptr_ShareName", ps, depth, &q_d->ptr_ShareName))
195 if(!smb_io_unistr2("ShareName",&q_d->ShareName, 1, ps, depth))
200 if(!prs_uint32("ptr_Comment", ps, depth, &q_d->ptr_Comment))
202 if(!smb_io_unistr2("",&q_d->Comment, q_d->ptr_Comment , ps, depth))
207 if(!prs_uint32("Flags", ps, depth, &q_d->Flags))
213 /************************************************************
214 Read/write a DFS_R_DFS_ADD structure
215 ************************************************************/
217 BOOL dfs_io_r_dfs_add(char *desc, DFS_R_DFS_ADD *r_d, prs_struct *ps, int depth)
222 prs_debug(ps, depth, desc, "dfs_io_r_dfs_add");
225 if(!prs_werror("status", ps, depth, &r_d->status))
231 BOOL init_dfs_q_dfs_get_info(DFS_Q_DFS_GET_INFO *q_d, char *entrypath,
232 char *servername, char *sharename,
235 DEBUG(5,("init_dfs_q2_get_info\n"));
236 init_unistr2(&q_d->uni_path, entrypath, strlen(entrypath)+1);
237 init_unistr2(&q_d->uni_server, servername, strlen(servername)+1);
238 init_unistr2(&q_d->uni_share, sharename, strlen(sharename)+1);
239 q_d->level = info_level;
240 q_d->ptr_server = q_d->ptr_share = 1;
244 /************************************************************
245 Read/write a DFS_Q_GET_INFO structure
246 ************************************************************/
248 BOOL dfs_io_q_dfs_get_info(char* desc, DFS_Q_DFS_GET_INFO* q_i, prs_struct* ps, int depth)
253 prs_debug(ps, depth, desc, "dfs_io_q_dfs_get_info");
256 if(!smb_io_unistr2("",&q_i->uni_path, 1, ps, depth))
262 if(!prs_uint32("ptr_server", ps, depth, &q_i->ptr_server))
266 if (!smb_io_unistr2("",&q_i->uni_server, q_i->ptr_server, ps, depth))
271 if(!prs_uint32("ptr_share", ps, depth, &q_i->ptr_share))
274 if(!smb_io_unistr2("", &q_i->uni_share, q_i->ptr_share, ps, depth))
279 if(!prs_uint32("level", ps, depth, &q_i->level))
284 /************************************************************
285 Read/write a DFS_R_GET_INFO structure
286 ************************************************************/
288 BOOL dfs_io_r_dfs_get_info(char* desc, DFS_R_DFS_GET_INFO* r_i, prs_struct* ps, int depth)
293 if(!prs_uint32("level", ps, depth, &r_i->level))
295 if(!prs_uint32("ptr_ctr", ps, depth, &r_i->ptr_ctr))
298 if(!dfs_io_dfs_info_ctr("", &r_i->ctr, 1, r_i->level, ps, depth))
300 if(!prs_werror("status", ps, depth, &r_i->status))
305 /************************************************************
306 Make a DFS_Q_DFS_ENUM structure
307 ************************************************************/
308 BOOL init_dfs_q_dfs_enum(DFS_Q_DFS_ENUM *q_d, uint32 level, DFS_INFO_CTR *ctr)
311 q_d->maxpreflen = -1;
315 q_d->ptr_num_entries = 1;
316 q_d->num_entries = 0;
317 q_d->num_entries2 = 0;
318 q_d->reshnd.ptr_hnd = 1;
319 q_d->reshnd.handle = 0;
323 /************************************************************
324 Read or write the DFS_Q_DFS_ENUM structure
325 ************************************************************/
327 BOOL dfs_io_q_dfs_enum(char *desc, DFS_Q_DFS_ENUM *q_d, prs_struct *ps, int depth)
332 prs_debug(ps, depth, desc, "dfs_io_q_dfs_enum");
338 if(!prs_uint32("level", ps, depth, &q_d->level))
340 if(!prs_uint32("maxpreflen", ps, depth, &q_d->maxpreflen))
342 if(!prs_uint32("ptr_buffer", ps, depth, &q_d->ptr_buffer))
344 if(!prs_uint32("level2", ps, depth, &q_d->level2))
346 if(!prs_uint32("level3", ps, depth, &q_d->level2))
349 if(!prs_uint32("ptr_num_entries", ps, depth, &q_d->ptr_num_entries))
351 if(!prs_uint32("num_entries", ps, depth, &q_d->num_entries))
353 if(!prs_uint32("num_entries2", ps, depth, &q_d->num_entries2))
355 if(!smb_io_enum_hnd("resume_hnd",&q_d->reshnd, ps, depth))
360 /************************************************************
361 Read/write a DFS_INFO_CTR structure
362 ************************************************************/
364 BOOL dfs_io_dfs_info_ctr(char* desc, DFS_INFO_CTR* ctr, uint32 num_entries, uint32 level, prs_struct* ps, int depth)
371 /* should depend on whether marshalling or unmarshalling! */
372 if(UNMARSHALLING(ps)) {
373 ctr->dfs.info1 = (DFS_INFO_1 *)prs_alloc_mem(ps, sizeof(DFS_INFO_1)*num_entries);
378 for(i=0;i<num_entries;i++) {
379 if(!prs_uint32("ptr_entrypath",ps, depth, &ctr->dfs.info1[i].ptr_entrypath))
382 for(i=0;i<num_entries;i++) {
383 if(!smb_io_unistr2("", &ctr->dfs.info1[i].entrypath, ctr->dfs.info1[i].ptr_entrypath, ps, depth))
392 if(UNMARSHALLING(ps)) {
393 ctr->dfs.info2 = (DFS_INFO_2 *)prs_alloc_mem(ps, num_entries*sizeof(DFS_INFO_2));
398 for(i=0;i<num_entries;i++) {
399 if(!prs_uint32("ptr_entrypath", ps, depth, &ctr->dfs.info2[i].ptr_entrypath))
401 if(!prs_uint32("ptr_comment", ps, depth, &ctr->dfs.info2[i].ptr_comment))
403 if(!prs_uint32("state", ps, depth, &ctr->dfs.info2[i].state))
405 if(!prs_uint32("num_storages", ps, depth, &ctr->dfs.info2[i].num_storages))
408 for(i=0;i<num_entries;i++) {
409 if(!smb_io_unistr2("", &ctr->dfs.info2[i].entrypath, ctr->dfs.info2[i].ptr_entrypath, ps, depth))
413 if(!smb_io_unistr2("",&ctr->dfs.info2[i].comment, ctr->dfs.info2[i].ptr_comment, ps, depth))
422 if(UNMARSHALLING(ps)) {
423 ctr->dfs.info3 = (DFS_INFO_3 *)prs_alloc_mem(ps, num_entries*sizeof(DFS_INFO_3));
428 for(i=0;i<num_entries;i++) {
429 if(!prs_uint32("ptr_entrypath", ps, depth, &ctr->dfs.info3[i].ptr_entrypath))
431 if(!prs_uint32("ptr_comment", ps, depth, &ctr->dfs.info3[i].ptr_comment))
433 if(!prs_uint32("state", ps, depth, &ctr->dfs.info3[i].state))
435 if(!prs_uint32("num_storages", ps, depth, &ctr->dfs.info3[i].num_storages))
437 if(!prs_uint32("ptr_storages", ps, depth, &ctr->dfs.info3[i].ptr_storages))
440 for(i=0;i<num_entries;i++) {
441 if(!smb_io_unistr2("", &ctr->dfs.info3[i].entrypath, ctr->dfs.info3[i].ptr_entrypath, ps, depth))
445 if(!smb_io_unistr2("", &ctr->dfs.info3[i].comment, ctr->dfs.info3[i].ptr_comment, ps, depth))
449 if(!prs_uint32("num_storage_infos", ps, depth, &ctr->dfs.info3[i].num_storage_infos))
452 if(!dfs_io_dfs_storage_info("storage_info", &ctr->dfs.info3[i], ps, depth))
460 /************************************************************
461 Read/write a DFS_R_DFS_ENUM structure
462 ************************************************************/
464 BOOL dfs_io_r_dfs_enum(char *desc, DFS_R_DFS_ENUM *q_d, prs_struct *ps, int depth)
473 prs_debug(ps, depth, desc, "dfs_io_r_dfs_enum");
479 if(!prs_uint32("ptr_buffer", ps, depth, &q_d->ptr_buffer))
481 if(!prs_uint32("level", ps, depth, &q_d->level))
483 if(!prs_uint32("level2", ps, depth, &ctr->switch_value))
485 if(!prs_uint32("ptr_num_entries", ps, depth, &q_d->ptr_num_entries))
487 if(q_d->ptr_num_entries)
488 if(!prs_uint32("num_entries", ps, depth, &q_d->num_entries))
490 if(!prs_uint32("ptr_num_entries2", ps, depth, &q_d->ptr_num_entries2))
492 if(q_d->ptr_num_entries2)
493 if(!prs_uint32("num_entries2", ps, depth, &ctr->num_entries))
496 if(!dfs_io_dfs_info_ctr("", ctr, q_d->num_entries, q_d->level, ps, depth))
499 if(!smb_io_enum_hnd("resume_hnd", &q_d->reshnd, ps, depth))
501 if(!prs_werror("status", ps, depth, &q_d->status))
506 BOOL dfs_io_dfs_storage_info(char *desc, DFS_INFO_3* info3, prs_struct *ps, int depth)
512 prs_debug(ps, depth, desc, "smb_io_dfs_storage_info");
515 if(UNMARSHALLING(ps)) {
516 info3->storages = (DFS_STORAGE_INFO *)prs_alloc_mem(ps, info3->num_storage_infos*sizeof(DFS_STORAGE_INFO));
517 if (!info3->storages)
521 for(i=0;i<info3->num_storage_infos;i++) {
522 if(!prs_uint32("storage_state", ps, depth, &info3->storages[i].state))
524 if(!prs_uint32("ptr_servername", ps, depth, &info3->storages[i].ptr_servername))
526 if(!prs_uint32("ptr_sharename", ps, depth, &info3->storages[i].ptr_sharename))
530 for(i=0;i<info3->num_storage_infos;i++) {
531 if(!smb_io_unistr2("servername", &info3->storages[i].servername, info3->storages[i].ptr_servername, ps, depth))
535 if(!smb_io_unistr2("sharename", &info3->storages[i].sharename, info3->storages[i].ptr_sharename, ps, depth))