Add fns for netshareadd and netsharedel rpcs
[ira/wip.git] / source3 / rpc_parse / parse_srv.c
1 /* 
2  *  Unix SMB/CIFS implementation.
3  *  RPC Pipe client / server routines
4  *  Copyright (C) Andrew Tridgell              1992-1997,
5  *  Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
6  *  Copyright (C) Paul Ashton                       1997.
7  *  Copyright (C) Jeremy Allison                    1999.
8  *  Copyright (C) Jim McDonough (jmcd@us.ibm.com)   2002
9  *  
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.
14  *  
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.
19  *  
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.
23  */
24
25 #include "includes.h"
26
27 /*******************************************************************
28  Inits a SH_INFO_1_STR structure
29 ********************************************************************/
30
31 void init_srv_share_info1_str(SH_INFO_1_STR *sh1, char *net_name, char *remark)
32 {
33         DEBUG(5,("init_srv_share_info1_str\n"));
34
35         init_unistr2(&sh1->uni_netname, net_name, strlen(net_name)+1);
36         init_unistr2(&sh1->uni_remark, remark, strlen(remark)+1);
37 }
38
39 /*******************************************************************
40  Reads or writes a structure.
41 ********************************************************************/
42
43 static BOOL srv_io_share_info1_str(char *desc, SH_INFO_1_STR *sh1, prs_struct *ps, int depth)
44 {
45         if (sh1 == NULL)
46                 return False;
47
48         prs_debug(ps, depth, desc, "srv_io_share_info1_str");
49         depth++;
50
51         if(!prs_align(ps))
52                 return False;
53         if(!smb_io_unistr2("", &sh1->uni_netname, True, ps, depth))
54                 return False;
55
56         if(!prs_align(ps))
57                 return False;
58         if(!smb_io_unistr2("", &sh1->uni_remark, True, ps, depth))
59                 return False;
60
61         return True;
62 }
63
64 /*******************************************************************
65  makes a SH_INFO_1 structure
66 ********************************************************************/
67
68 void init_srv_share_info1(SH_INFO_1 *sh1, char *net_name, uint32 type, char *remark)
69 {
70         DEBUG(5,("init_srv_share_info1: %s %8x %s\n", net_name, type, remark));
71
72         sh1->ptr_netname = (net_name != NULL) ? 1 : 0;
73         sh1->type        = type;
74         sh1->ptr_remark  = (remark != NULL) ? 1 : 0;
75 }
76
77 /*******************************************************************
78  Reads or writes a structure.
79 ********************************************************************/
80
81 static BOOL srv_io_share_info1(char *desc, SH_INFO_1 *sh1, prs_struct *ps, int depth)
82 {
83         if (sh1 == NULL)
84                 return False;
85
86         prs_debug(ps, depth, desc, "srv_io_share_info1");
87         depth++;
88
89         if(!prs_align(ps))
90                 return False;
91
92         if(!prs_uint32("ptr_netname", ps, depth, &sh1->ptr_netname))
93                 return False;
94         if(!prs_uint32("type       ", ps, depth, &sh1->type))
95                 return False;
96         if(!prs_uint32("ptr_remark ", ps, depth, &sh1->ptr_remark))
97                 return False;
98
99         return True;
100 }
101
102 /*******************************************************************
103  Inits a SH_INFO_2_STR structure
104 ********************************************************************/
105
106 void init_srv_share_info2_str(SH_INFO_2_STR *sh2,
107                                 char *net_name, char *remark,
108                                 char *path, char *passwd)
109 {
110         DEBUG(5,("init_srv_share_info2_str\n"));
111
112         if (net_name)
113                 init_unistr2(&sh2->uni_netname, net_name, strlen(net_name)+1);
114         if (remark)
115                 init_unistr2(&sh2->uni_remark, remark, strlen(remark)+1);
116         if (path)
117                 init_unistr2(&sh2->uni_path, path, strlen(path)+1);
118         if (passwd)
119                 init_unistr2(&sh2->uni_passwd, passwd, strlen(passwd)+1);
120 }
121
122 /*******************************************************************
123  Reads or writes a structure.
124 ********************************************************************/
125
126 static BOOL srv_io_share_info2_str(char *desc, SH_INFO_2 *sh, SH_INFO_2_STR *sh2, prs_struct *ps, int depth)
127 {
128         if (sh2 == NULL)
129                 return False;
130
131         if (UNMARSHALLING(ps))
132                 ZERO_STRUCTP(sh2);
133
134         prs_debug(ps, depth, desc, "srv_io_share_info2_str");
135         depth++;
136
137         if(!prs_align(ps))
138                 return False;
139         if (sh->ptr_netname)
140                 if(!smb_io_unistr2("", &sh2->uni_netname, True, ps, depth))
141                         return False;
142
143         if (sh->ptr_remark)
144                 if(!smb_io_unistr2("", &sh2->uni_remark, True, ps, depth))
145                         return False;
146
147         if (sh->ptr_netname)
148                 if(!smb_io_unistr2("", &sh2->uni_path, True, ps, depth))
149                         return False;
150
151         if (sh->ptr_passwd)
152                 if(!smb_io_unistr2("", &sh2->uni_passwd, True, ps, depth))
153                         return False;
154
155         return True;
156 }
157
158 /*******************************************************************
159  Inits a SH_INFO_2 structure
160 ********************************************************************/
161
162 void init_srv_share_info2(SH_INFO_2 *sh2,
163                                 char *net_name, uint32 type, char *remark,
164                                 uint32 perms, uint32 max_uses, uint32 num_uses,
165                                 char *path, char *passwd)
166 {
167         DEBUG(5,("init_srv_share_info2: %s %8x %s\n", net_name, type, remark));
168
169         sh2->ptr_netname = (net_name != NULL) ? 1 : 0;
170         sh2->type        = type;
171         sh2->ptr_remark  = (remark != NULL) ? 1 : 0;
172         sh2->perms       = perms;
173         sh2->max_uses    = max_uses;
174         sh2->num_uses    = num_uses;
175         sh2->type        = type;
176         sh2->ptr_path    = (path != NULL) ? 1 : 0;
177         sh2->ptr_passwd  = (passwd != NULL) ? 1 : 0;
178 }
179
180 /*******************************************************************
181  Reads or writes a structure.
182 ********************************************************************/
183
184 static BOOL srv_io_share_info2(char *desc, SH_INFO_2 *sh2, prs_struct *ps, int depth)
185 {
186         if (sh2 == NULL)
187                 return False;
188
189         prs_debug(ps, depth, desc, "srv_io_share_info2");
190         depth++;
191
192         if(!prs_align(ps))
193                 return False;
194
195         if(!prs_uint32("ptr_netname", ps, depth, &sh2->ptr_netname))
196                 return False;
197         if(!prs_uint32("type       ", ps, depth, &sh2->type))
198                 return False;
199         if(!prs_uint32("ptr_remark ", ps, depth, &sh2->ptr_remark))
200                 return False;
201         if(!prs_uint32("perms      ", ps, depth, &sh2->perms))
202                 return False;
203         if(!prs_uint32("max_uses   ", ps, depth, &sh2->max_uses))
204                 return False;
205         if(!prs_uint32("num_uses   ", ps, depth, &sh2->num_uses))
206                 return False;
207         if(!prs_uint32("ptr_path   ", ps, depth, &sh2->ptr_path))
208                 return False;
209         if(!prs_uint32("ptr_passwd ", ps, depth, &sh2->ptr_passwd))
210                 return False;
211
212         return True;
213 }
214
215 /*******************************************************************
216  Inits a SH_INFO_2 structure
217 *******************************************************************/
218
219 void init_srv_share_info501(SH_INFO_501 *sh501, char *net_name, uint32 type, char *remark, uint32 csc_policy)
220 {
221         DEBUG(5,("init_srv_share_info501: %s %8x %s %08x\n", net_name, type,
222                 remark, csc_policy));
223
224         ZERO_STRUCTP(sh501);
225
226         sh501->ptr_netname = (net_name != NULL) ? 1 : 0;
227         sh501->type = type;
228         sh501->ptr_remark = (remark != NULL) ? 1 : 0;
229         sh501->csc_policy = csc_policy;
230 }
231
232 /*******************************************************************
233  Reads of writes a structure.
234 *******************************************************************/
235
236 static BOOL srv_io_share_info501(char *desc, SH_INFO_501 *sh501, prs_struct *ps, int depth)
237 {
238         if (sh501 == NULL)
239                 return False;
240
241         prs_debug(ps, depth, desc, "srv_io_share_info501");
242         depth++;
243
244         if (!prs_align(ps))
245                 return False;
246
247         if (!prs_uint32("ptr_netname", ps, depth, &sh501->ptr_netname))
248                 return False;
249         if (!prs_uint32("type     ", ps, depth, &sh501->type))
250                 return False;
251         if (!prs_uint32("ptr_remark ", ps, depth, &sh501->ptr_remark))
252                 return False;
253         if (!prs_uint32("csc_policy ", ps, depth, &sh501->csc_policy))
254                 return False;
255
256         return True;
257 }
258
259 /********************************************************************
260  Inits a SH_INFO_501_STR structure
261 ********************************************************************/
262
263 void init_srv_share_info501_str(SH_INFO_501_STR *sh501, char *net_name, char *remark)
264 {
265         DEBUG(5,("init_srv_share_info501_str\n"));
266
267         init_unistr2(&sh501->uni_netname, net_name, strlen(net_name)+1);
268         init_unistr2(&sh501->uni_remark, remark, strlen(remark)+1);
269 }
270
271 /*******************************************************************
272  Reads or writes a structure.
273 ********************************************************************/
274
275 static BOOL srv_io_share_info501_str(char *desc, SH_INFO_501_STR *sh501, prs_struct *ps, int depth)
276 {
277         if (sh501 == NULL)
278                 return False;
279
280         prs_debug(ps, depth, desc, "srv_io_share_info501_str");
281         depth++;
282
283         if(!prs_align(ps))
284                 return False;
285         if(!smb_io_unistr2("", &sh501->uni_netname, True, ps, depth))
286                 return False;
287
288         if(!prs_align(ps))
289                 return False;
290         if(!smb_io_unistr2("", &sh501->uni_remark, True, ps, depth))
291                 return False;
292
293         return True;
294 }
295
296 /*******************************************************************
297  Inits a SH_INFO_502 structure
298 ********************************************************************/
299
300 void init_srv_share_info502(SH_INFO_502 *sh502,
301                                 char *net_name, uint32 type, char *remark,
302                                 uint32 perms, uint32 max_uses, uint32 num_uses,
303                                 char *path, char *passwd, SEC_DESC *psd, size_t sd_size)
304 {
305         DEBUG(5,("init_srv_share_info502: %s %8x %s\n", net_name, type, remark));
306
307         ZERO_STRUCTP(sh502);
308
309         sh502->ptr_netname = (net_name != NULL) ? 1 : 0;
310         sh502->type        = type;
311         sh502->ptr_remark  = (remark != NULL) ? 1 : 0;
312         sh502->perms       = perms;
313         sh502->max_uses    = max_uses;
314         sh502->num_uses    = num_uses;
315         sh502->type        = type;
316         sh502->ptr_path    = (path != NULL) ? 1 : 0;
317         sh502->ptr_passwd  = (passwd != NULL) ? 1 : 0;
318         sh502->sd_size     = (uint32)sd_size;
319         sh502->ptr_sd      = (psd != NULL) ? 1 : 0;
320 }
321
322 /*******************************************************************
323  Reads or writes a structure.
324 ********************************************************************/
325
326 static BOOL srv_io_share_info502(char *desc, SH_INFO_502 *sh502, prs_struct *ps, int depth)
327 {
328         if (sh502 == NULL)
329                 return False;
330
331         prs_debug(ps, depth, desc, "srv_io_share_info502");
332         depth++;
333
334         if(!prs_align(ps))
335                 return False;
336
337         if(!prs_uint32("ptr_netname", ps, depth, &sh502->ptr_netname))
338                 return False;
339         if(!prs_uint32("type       ", ps, depth, &sh502->type))
340                 return False;
341         if(!prs_uint32("ptr_remark ", ps, depth, &sh502->ptr_remark))
342                 return False;
343         if(!prs_uint32("perms      ", ps, depth, &sh502->perms))
344                 return False;
345         if(!prs_uint32("max_uses   ", ps, depth, &sh502->max_uses))
346                 return False;
347         if(!prs_uint32("num_uses   ", ps, depth, &sh502->num_uses))
348                 return False;
349         if(!prs_uint32("ptr_path   ", ps, depth, &sh502->ptr_path))
350                 return False;
351         if(!prs_uint32("ptr_passwd ", ps, depth, &sh502->ptr_passwd))
352                 return False;
353         if(!prs_uint32("sd_size    ", ps, depth, &sh502->sd_size))
354                 return False;
355         if(!prs_uint32("ptr_sd     ", ps, depth, &sh502->ptr_sd))
356                 return False;
357
358         return True;
359 }
360
361 /*******************************************************************
362  Inits a SH_INFO_502_STR structure
363 ********************************************************************/
364
365 void init_srv_share_info502_str(SH_INFO_502_STR *sh502str,
366                                 SH_INFO_502 *ptrs,
367                                 char *net_name, char *remark,
368                                 char *path, char *passwd, SEC_DESC *psd, size_t sd_size)
369 {
370         DEBUG(5,("init_srv_share_info502_str\n"));
371
372         sh502str->ptrs = ptrs;
373
374         if(sh502str->ptrs->ptr_netname)
375                 init_unistr2(&sh502str->uni_netname, net_name, strlen(net_name)+1);
376         if(sh502str->ptrs->ptr_remark)
377                 init_unistr2(&sh502str->uni_remark, remark, strlen(remark)+1);
378         if(sh502str->ptrs->ptr_path)
379                 init_unistr2(&sh502str->uni_path, path, strlen(path)+1);
380         if(sh502str->ptrs->ptr_passwd)
381                 init_unistr2(&sh502str->uni_passwd, passwd, strlen(passwd)+1);
382         if(sh502str->ptrs->ptr_sd) {
383                 sh502str->sd = psd;
384                 sh502str->sd_size = sd_size;
385         }
386 }
387
388 /*******************************************************************
389  Reads or writes a structure.
390 ********************************************************************/
391
392 static BOOL srv_io_share_info502_str(char *desc, SH_INFO_502_STR *sh502, prs_struct *ps, int depth)
393 {
394         if (sh502 == NULL)
395                 return False;
396
397         prs_debug(ps, depth, desc, "srv_io_share_info502_str");
398         depth++;
399
400         if(!prs_align(ps))
401                 return False;
402
403         if(sh502->ptrs->ptr_netname) {
404                 if(!smb_io_unistr2("", &sh502->uni_netname, True, ps, depth))
405                         return False;
406         }
407
408         if(!prs_align(ps))
409                 return False;
410
411         if(sh502->ptrs->ptr_remark) {
412                 if(!smb_io_unistr2("", &sh502->uni_remark, True, ps, depth))
413                         return False;
414         }
415
416         if(!prs_align(ps))
417                 return False;
418
419         if(sh502->ptrs->ptr_path) {
420                 if(!smb_io_unistr2("", &sh502->uni_path, True, ps, depth))
421                         return False;
422         }
423
424         if(!prs_align(ps))
425                 return False;
426
427         if(sh502->ptrs->ptr_passwd) {
428                 if(!smb_io_unistr2("", &sh502->uni_passwd, True, ps, depth))
429                         return False;
430         }
431
432         if(!prs_align(ps))
433                 return False;
434
435         if(sh502->ptrs->ptr_sd) {
436                 if(!prs_uint32("sd_size   ", ps, depth, &sh502->sd_size))
437                         return False;
438                 if (!sec_io_desc(desc, &sh502->sd, ps, depth))
439                         return False;
440         }
441
442         return True;
443 }
444
445 /*******************************************************************
446  Reads or writes a structure.
447 ********************************************************************/
448
449 static BOOL srv_io_share_info1005(char* desc, SRV_SHARE_INFO_1005* sh1005,
450                                   prs_struct* ps, int depth)
451 {
452         if(sh1005 == NULL)
453                 return False;
454
455         prs_debug(ps, depth, desc, "srv_io_share_info1005");
456                 depth++;
457
458         if(!prs_align(ps))
459                 return False;
460
461         if(!prs_uint32("dfs_root_flag", ps, depth, &sh1005->dfs_root_flag))
462                 return False;
463
464         return True;
465 }   
466
467 /*******************************************************************
468  Reads or writes a structure.
469 ********************************************************************/
470
471 static BOOL srv_io_share_info1501(char* desc, SRV_SHARE_INFO_1501* sh1501,
472                                   prs_struct* ps, int depth)
473 {
474         if(sh1501 == NULL)
475                 return False;
476
477         prs_debug(ps, depth, desc, "srv_io_share_info1501");
478         depth++;
479
480         if(!prs_align(ps))
481                 return False;
482
483         if (!sec_io_desc_buf(desc, &sh1501->sdb, ps, depth))
484                 return False;
485
486         return True;
487 }   
488
489 /*******************************************************************
490  Reads or writes a structure.
491 ********************************************************************/
492
493 static BOOL srv_io_srv_share_ctr(char *desc, SRV_SHARE_INFO_CTR *ctr, prs_struct *ps, int depth)
494 {
495         if (ctr == NULL)
496                 return False;
497
498         prs_debug(ps, depth, desc, "srv_io_srv_share_ctr");
499         depth++;
500
501         if (UNMARSHALLING(ps)) {
502                 memset(ctr, '\0', sizeof(SRV_SHARE_INFO_CTR));
503         }
504
505         if(!prs_align(ps))
506                 return False;
507
508         if(!prs_uint32("info_level", ps, depth, &ctr->info_level))
509                 return False;
510
511         if (ctr->info_level == 0)
512                 return True;
513
514         if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
515                 return False;
516         if(!prs_uint32("ptr_share_info", ps, depth, &ctr->ptr_share_info))
517                 return False;
518
519         if (ctr->ptr_share_info == 0)
520                 return True;
521
522         if(!prs_uint32("num_entries", ps, depth, &ctr->num_entries))
523                 return False;
524         if(!prs_uint32("ptr_entries", ps, depth, &ctr->ptr_entries))
525                 return False;
526
527         if (ctr->ptr_entries == 0) {
528                 if (ctr->num_entries == 0)
529                         return True;
530                 else
531                         return False;
532         }
533
534         if(!prs_uint32("num_entries2", ps, depth, &ctr->num_entries2))
535                 return False;
536
537         if (ctr->num_entries2 != ctr->num_entries)
538                 return False;
539
540         switch (ctr->switch_value) {
541         case 1:
542         {
543                 SRV_SHARE_INFO_1 *info1 = ctr->share.info1;
544                 int num_entries = ctr->num_entries;
545                 int i;
546
547                 if (UNMARSHALLING(ps)) {
548                         if (!(info1 = (SRV_SHARE_INFO_1 *)prs_alloc_mem(ps, num_entries * sizeof(SRV_SHARE_INFO_1))))
549                                 return False;
550                         ctr->share.info1 = info1;
551                 }
552
553                 for (i = 0; i < num_entries; i++) {
554                         if(!srv_io_share_info1("", &info1[i].info_1, ps, depth))
555                                 return False;
556                 }
557
558                 for (i = 0; i < num_entries; i++) {
559                         if(!srv_io_share_info1_str("", &info1[i].info_1_str, ps, depth))
560                                 return False;
561                 }
562
563                 break;
564         }
565
566         case 2:
567         {
568                 SRV_SHARE_INFO_2 *info2 = ctr->share.info2;
569                 int num_entries = ctr->num_entries;
570                 int i;
571
572                 if (UNMARSHALLING(ps)) {
573                         if (!(info2 = (SRV_SHARE_INFO_2 *)prs_alloc_mem(ps,num_entries * sizeof(SRV_SHARE_INFO_2))))
574                                 return False;
575                         ctr->share.info2 = info2;
576                 }
577
578                 for (i = 0; i < num_entries; i++) {
579                         if(!srv_io_share_info2("", &info2[i].info_2, ps, depth))
580                                 return False;
581                 }
582
583                 for (i = 0; i < num_entries; i++) {
584                         if(!srv_io_share_info2_str("", &info2[i].info_2, &info2[i].info_2_str, ps, depth))
585                                 return False;
586                 }
587
588                 break;
589         }
590
591         case 501:
592         {
593                 SRV_SHARE_INFO_501 *info501 = ctr->share.info501;
594                 int num_entries = ctr->num_entries;
595                 int i;
596
597                 if (UNMARSHALLING(ps)) {
598                         if (!(info501 = (SRV_SHARE_INFO_501 *) prs_alloc_mem(ps, num_entries *
599                                         sizeof (SRV_SHARE_INFO_501))))
600                                 return False;
601                         ctr->share.info501 = info501;
602                 }
603
604                 for (i = 0; i < num_entries; i++) {
605                         if (!srv_io_share_info501("", &info501[i].info_501, ps, depth))
606                                 return False;
607                 }
608
609                 for (i = 0; i < num_entries; i++) {
610                         if (!srv_io_share_info501_str("", &info501[i].info_501_str, ps, depth))
611                                 return False;
612                 }
613
614                 break;
615         }
616
617         case 502:
618         {
619                 SRV_SHARE_INFO_502 *info502 = ctr->share.info502;
620                 int num_entries = ctr->num_entries;
621                 int i;
622
623                 if (UNMARSHALLING(ps)) {
624                         if (!(info502 = (SRV_SHARE_INFO_502 *)prs_alloc_mem(ps,num_entries * sizeof(SRV_SHARE_INFO_502))))
625                                 return False;
626                         ctr->share.info502 = info502;
627                 }
628
629                 for (i = 0; i < num_entries; i++) {
630                         if(!srv_io_share_info502("", &info502[i].info_502, ps, depth))
631                                 return False;
632                 }
633
634                 for (i = 0; i < num_entries; i++) {
635                         info502[i].info_502_str.ptrs = &info502[i].info_502;
636                         if(!srv_io_share_info502_str("", &info502[i].info_502_str, ps, depth))
637                                 return False;
638                 }
639
640                 break;
641         }
642
643         default:
644                 DEBUG(5,("%s no share info at switch_value %d\n",
645                          tab_depth(depth), ctr->switch_value));
646                 break;
647         }
648
649         return True;
650 }
651
652 /*******************************************************************
653  Inits a SRV_Q_NET_SHARE_ENUM structure.
654 ********************************************************************/
655
656 void init_srv_q_net_share_enum(SRV_Q_NET_SHARE_ENUM *q_n, 
657                                 char *srv_name, uint32 info_level,
658                                 uint32 preferred_len, ENUM_HND *hnd)
659 {
660
661         DEBUG(5,("init_q_net_share_enum\n"));
662
663         init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
664
665         q_n->ctr.info_level = q_n->ctr.switch_value = info_level;
666         q_n->ctr.ptr_share_info = 1;
667         q_n->ctr.num_entries = 0;
668         q_n->ctr.ptr_entries = 0;
669         q_n->preferred_len = preferred_len;
670
671         memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
672 }
673
674 /*******************************************************************
675  Reads or writes a structure.
676 ********************************************************************/
677
678 BOOL srv_io_q_net_share_enum(char *desc, SRV_Q_NET_SHARE_ENUM *q_n, prs_struct *ps, int depth)
679 {
680         if (q_n == NULL)
681                 return False;
682
683         prs_debug(ps, depth, desc, "srv_io_q_net_share_enum");
684         depth++;
685
686         if(!prs_align(ps))
687                 return False;
688
689         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
690                 return False;
691         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
692                 return False;
693
694         if(!srv_io_srv_share_ctr("share_ctr", &q_n->ctr, ps, depth))
695                 return False;
696
697         if(!prs_align(ps))
698                 return False;
699
700         if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
701                 return False;
702
703         if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
704                 return False;
705
706         return True;
707 }
708
709 /*******************************************************************
710  Reads or writes a structure.
711 ********************************************************************/
712
713 BOOL srv_io_r_net_share_enum(char *desc, SRV_R_NET_SHARE_ENUM *r_n, prs_struct *ps, int depth)
714 {
715         if (r_n == NULL)
716                 return False;
717
718         prs_debug(ps, depth, desc, "srv_io_r_net_share_enum");
719         depth++;
720
721         if(!srv_io_srv_share_ctr("share_ctr", &r_n->ctr, ps, depth))
722                 return False;
723
724         if(!prs_align(ps))
725                 return False;
726
727         if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
728                 return False;
729         if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
730                 return False;
731         if(!prs_werror("status", ps, depth, &r_n->status))
732                 return False;
733
734         return True;
735 }
736
737 /*******************************************************************
738  Reads or writes a structure.
739 ********************************************************************/
740
741 BOOL srv_io_q_net_share_get_info(char *desc, SRV_Q_NET_SHARE_GET_INFO *q_n, prs_struct *ps, int depth)
742 {
743         if (q_n == NULL)
744                 return False;
745
746         prs_debug(ps, depth, desc, "srv_io_q_net_share_get_info");
747         depth++;
748
749         if(!prs_align(ps))
750                 return False;
751
752         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
753                 return False;
754         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
755                 return False;
756
757         if(!smb_io_unistr2("", &q_n->uni_share_name, True, ps, depth))
758                 return False;
759
760         if(!prs_align(ps))
761                 return False;
762
763         if(!prs_uint32("info_level", ps, depth, &q_n->info_level))
764                 return False;
765
766         return True;
767 }
768
769 /*******************************************************************
770  Reads or writes a structure.
771 ********************************************************************/
772
773 static BOOL srv_io_srv_share_info(char *desc, prs_struct *ps, int depth, SRV_SHARE_INFO *r_n)
774 {
775         if (r_n == NULL)
776                 return False;
777
778         prs_debug(ps, depth, desc, "srv_io_srv_share_info");
779         depth++;
780
781         if(!prs_align(ps))
782                 return False;
783
784         if(!prs_uint32("switch_value ", ps, depth, &r_n->switch_value ))
785                 return False;
786
787         if(!prs_uint32("ptr_share_ctr", ps, depth, &r_n->ptr_share_ctr))
788                 return False;
789
790         if (r_n->ptr_share_ctr != 0) {
791                 switch (r_n->switch_value) {
792                 case 1:
793                         if(!srv_io_share_info1("", &r_n->share.info1.info_1, ps, depth))
794                                 return False;
795
796                         if(!srv_io_share_info1_str("", &r_n->share.info1.info_1_str, ps, depth))
797                                 return False;
798
799                         break;
800                 case 2:
801                         if(!srv_io_share_info2("", &r_n->share.info2.info_2, ps, depth))
802                                 return False;
803
804                         if(!srv_io_share_info2_str("", &r_n->share.info2.info_2, &r_n->share.info2.info_2_str, ps, depth))
805                                 return False;
806
807                         break;
808                 case 501:
809                         if (!srv_io_share_info501("", &r_n->share.info501.info_501, ps, depth))
810                                 return False;
811                         if (!srv_io_share_info501_str("", &r_n->share.info501.info_501_str, ps, depth))
812                                 return False;
813                         break;
814
815                 case 502:
816                         if(!srv_io_share_info502("", &r_n->share.info502.info_502, ps, depth))
817                                 return False;
818
819                         /*allow access to pointers in the str part. */
820                         r_n->share.info502.info_502_str.ptrs = &r_n->share.info502.info_502;
821
822                         if(!srv_io_share_info502_str("", &r_n->share.info502.info_502_str, ps, depth))
823                                 return False;
824                         break;
825                 case 1005:
826                         if(!srv_io_share_info1005("", &r_n->share.info1005, ps, depth))
827                                 return False;           
828                         break;
829                 case 1501:
830                         if (!srv_io_share_info1501("", &r_n->share.info1501, ps, depth))
831                                 return False;
832                 default:
833                         DEBUG(5,("%s no share info at switch_value %d\n",
834                                  tab_depth(depth), r_n->switch_value));
835                         break;
836                 }
837         }
838
839         return True;
840 }
841
842 /*******************************************************************
843  Reads or writes a structure.
844 ********************************************************************/
845
846 BOOL srv_io_r_net_share_get_info(char *desc, SRV_R_NET_SHARE_GET_INFO *r_n, prs_struct *ps, int depth)
847 {
848         if (r_n == NULL)
849                 return False;
850
851         prs_debug(ps, depth, desc, "srv_io_r_net_share_get_info");
852         depth++;
853
854         if(!prs_align(ps))
855                 return False;
856
857         if(!srv_io_srv_share_info("info  ", ps, depth, &r_n->info))
858                 return False;
859
860         if(!prs_align(ps))
861                 return False;
862
863         if(!prs_werror("status", ps, depth, &r_n->status))
864                 return False;
865
866         return True;
867 }
868
869 /*******************************************************************
870  Reads or writes a structure.
871 ********************************************************************/
872
873 BOOL srv_io_q_net_share_set_info(char *desc, SRV_Q_NET_SHARE_SET_INFO *q_n, prs_struct *ps, int depth)
874 {
875         if (q_n == NULL)
876                 return False;
877
878         prs_debug(ps, depth, desc, "srv_io_q_net_share_set_info");
879         depth++;
880
881         if(!prs_align(ps))
882                 return False;
883
884         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
885                 return False;
886         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
887                 return False;
888
889         if(!smb_io_unistr2("", &q_n->uni_share_name, True, ps, depth))
890                 return False;
891
892         if(!prs_align(ps))
893                 return False;
894
895         if(!prs_uint32("info_level", ps, depth, &q_n->info_level))
896                 return False;
897
898         if(!prs_align(ps))
899                 return False;
900
901         if(!srv_io_srv_share_info("info  ", ps, depth, &q_n->info))
902                 return False;
903
904         return True;
905 }
906
907 /*******************************************************************
908  Reads or writes a structure.
909 ********************************************************************/
910
911 BOOL srv_io_r_net_share_set_info(char *desc, SRV_R_NET_SHARE_SET_INFO *q_n, prs_struct *ps, int depth)
912 {
913         if (q_n == NULL)
914                 return False;
915
916         prs_debug(ps, depth, desc, "srv_io_r_net_share_set_info");
917         depth++;
918
919         if(!prs_align(ps))
920                 return False;
921
922         if(!prs_uint32("switch_value  ", ps, depth, &q_n->switch_value))
923                 return False;
924         if(!prs_werror("status", ps, depth, &q_n->status))
925                 return False;
926
927         return True;
928 }       
929
930 /*******************************************************************
931  Reads or writes a structure.
932 ********************************************************************/
933
934 BOOL srv_io_q_net_share_add(char *desc, SRV_Q_NET_SHARE_ADD *q_n, prs_struct *ps, int depth)
935 {
936         if (q_n == NULL)
937                 return False;
938
939         prs_debug(ps, depth, desc, "srv_io_q_net_share_add");
940         depth++;
941
942         if(!prs_align(ps))
943                 return False;
944
945         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
946                 return False;
947         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
948                 return False;
949
950         if(!prs_align(ps))
951                 return False;
952
953         if(!prs_uint32("info_level", ps, depth, &q_n->info_level))
954                 return False;
955
956         if(!prs_align(ps))
957                 return False;
958
959         if(!srv_io_srv_share_info("info  ", ps, depth, &q_n->info))
960                 return False;
961
962         if(!prs_uint32("ptr_err_index", ps, depth, &q_n->ptr_err_index))
963                 return False;
964         if (q_n->ptr_err_index)
965                 if (!prs_uint32("err_index", ps, depth, &q_n->err_index))
966                         return False;
967
968         return True;
969 }
970
971 void init_srv_q_net_share_add(SRV_Q_NET_SHARE_ADD *q, char *srvname,
972                               char *netname, uint32 type, char *remark, 
973                               uint32 perms, uint32 max_uses, uint32 num_uses,
974                               char *path, char *passwd)
975 {
976         q->ptr_srv_name = 1;
977         init_unistr2(&q->uni_srv_name, srvname, strlen(srvname) +1);
978         q->info.switch_value = q->info_level = 2;
979
980         q->info.ptr_share_ctr = 1;
981         init_srv_share_info2(&q->info.share.info2.info_2, netname, type,
982                              remark, perms, max_uses, num_uses, path, passwd);
983         init_srv_share_info2_str(&q->info.share.info2.info_2_str, netname,
984                                  remark, path, passwd);
985         q->ptr_err_index = 1;
986         q->err_index = 0;
987 }
988
989
990 /*******************************************************************
991  Reads or writes a structure.
992 ********************************************************************/
993
994 BOOL srv_io_r_net_share_add(char *desc, SRV_R_NET_SHARE_ADD *q_n, prs_struct *ps, int depth)
995 {
996         if (q_n == NULL)
997                 return False;
998
999         prs_debug(ps, depth, desc, "srv_io_r_net_share_add");
1000         depth++;
1001
1002         if(!prs_align(ps))
1003                 return False;
1004
1005         if(!prs_uint32("switch_value  ", ps, depth, &q_n->switch_value))
1006                 return False;
1007         if(!prs_werror("status", ps, depth, &q_n->status))
1008                 return False;
1009
1010         return True;
1011 }       
1012
1013 void init_srv_q_net_share_del(SRV_Q_NET_SHARE_DEL *del, const char *srvname,
1014                               const char *sharename)
1015 {
1016         del->ptr_srv_name = 1;
1017         init_unistr2(&del->uni_srv_name, srvname, strlen(srvname) +1 );
1018         init_unistr2(&del->uni_share_name, sharename, strlen(sharename) + 1);
1019 }
1020
1021 /*******************************************************************
1022  Reads or writes a structure.
1023 ********************************************************************/
1024
1025 BOOL srv_io_q_net_share_del(char *desc, SRV_Q_NET_SHARE_DEL *q_n, prs_struct *ps, int depth)
1026 {
1027         if (q_n == NULL)
1028                 return False;
1029
1030         prs_debug(ps, depth, desc, "srv_io_q_net_share_del");
1031         depth++;
1032
1033         if(!prs_align(ps))
1034                 return False;
1035
1036         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
1037                 return False;
1038         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1039                 return False;
1040
1041         if(!smb_io_unistr2("", &q_n->uni_share_name, True, ps, depth))
1042                 return False;
1043
1044         if(!prs_align(ps))
1045                 return False;
1046         if(!prs_uint32("reserved", ps, depth, &q_n->reserved))
1047                 return False;
1048
1049         return True;
1050 }
1051
1052 /*******************************************************************
1053  Reads or writes a structure.
1054 ********************************************************************/
1055
1056 BOOL srv_io_r_net_share_del(char *desc, SRV_R_NET_SHARE_DEL *q_n, prs_struct *ps, int depth)
1057 {
1058         if (q_n == NULL)
1059                 return False;
1060
1061         prs_debug(ps, depth, desc, "srv_io_r_net_share_del");
1062         depth++;
1063
1064         if(!prs_align(ps))
1065                 return False;
1066
1067         if(!prs_werror("status", ps, depth, &q_n->status))
1068                 return False;
1069
1070         return True;
1071 }       
1072
1073 /*******************************************************************
1074  Inits a SESS_INFO_0_STR structure
1075 ********************************************************************/
1076
1077 void init_srv_sess_info0_str(SESS_INFO_0_STR *ss0, char *name)
1078 {
1079         DEBUG(5,("init_srv_sess_info0_str\n"));
1080
1081         init_unistr2(&ss0->uni_name, name, strlen(name)+1);
1082 }
1083
1084 /*******************************************************************
1085  Reads or writes a structure.
1086 ********************************************************************/
1087
1088 static BOOL srv_io_sess_info0_str(char *desc,  SESS_INFO_0_STR *ss0, prs_struct *ps, int depth)
1089 {
1090         if (ss0 == NULL)
1091                 return False;
1092
1093         prs_debug(ps, depth, desc, "srv_io_sess_info0_str");
1094         depth++;
1095
1096         if(!prs_align(ps))
1097                 return False;
1098
1099         if(!smb_io_unistr2("", &ss0->uni_name, True, ps, depth))
1100                 return False;
1101
1102         return True;
1103 }
1104
1105 /*******************************************************************
1106  Inits a SESS_INFO_0 structure
1107 ********************************************************************/
1108
1109 void init_srv_sess_info0(SESS_INFO_0 *ss0, char *name)
1110 {
1111         DEBUG(5,("init_srv_sess_info0: %s\n", name));
1112
1113         ss0->ptr_name = (name != NULL) ? 1 : 0;
1114 }
1115
1116 /*******************************************************************
1117  Reads or writes a structure.
1118 ********************************************************************/
1119
1120 static BOOL srv_io_sess_info0(char *desc, SESS_INFO_0 *ss0, prs_struct *ps, int depth)
1121 {
1122         if (ss0 == NULL)
1123                 return False;
1124
1125         prs_debug(ps, depth, desc, "srv_io_sess_info0");
1126         depth++;
1127
1128         if(!prs_align(ps))
1129                 return False;
1130
1131         if(!prs_uint32("ptr_name", ps, depth, &ss0->ptr_name))
1132                 return False;
1133
1134         return True;
1135 }
1136
1137 /*******************************************************************
1138  Reads or writes a structure.
1139 ********************************************************************/
1140
1141 static BOOL srv_io_srv_sess_info_0(char *desc, SRV_SESS_INFO_0 *ss0, prs_struct *ps, int depth)
1142 {
1143         if (ss0 == NULL)
1144                 return False;
1145
1146         prs_debug(ps, depth, desc, "srv_io_srv_sess_info_0");
1147         depth++;
1148
1149         if(!prs_align(ps))
1150                 return False;
1151
1152         if(!prs_uint32("num_entries_read", ps, depth, &ss0->num_entries_read))
1153                 return False;
1154         if(!prs_uint32("ptr_sess_info", ps, depth, &ss0->ptr_sess_info))
1155                 return False;
1156
1157         if (ss0->ptr_sess_info != 0) {
1158                 int i;
1159                 int num_entries = ss0->num_entries_read;
1160
1161                 if (num_entries > MAX_SESS_ENTRIES) {
1162                         num_entries = MAX_SESS_ENTRIES; /* report this! */
1163                 }
1164
1165                 if(!prs_uint32("num_entries_read2", ps, depth, &ss0->num_entries_read2))
1166                         return False;
1167
1168                 SMB_ASSERT_ARRAY(ss0->info_0, num_entries);
1169
1170                 for (i = 0; i < num_entries; i++) {
1171                         if(!srv_io_sess_info0("", &ss0->info_0[i], ps, depth))
1172                                 return False;
1173                 }
1174
1175                 for (i = 0; i < num_entries; i++) {
1176                         if(!srv_io_sess_info0_str("", &ss0->info_0_str[i], ps, depth))
1177                                 return False;
1178                 }
1179
1180                 if(!prs_align(ps))
1181                         return False;
1182         }
1183
1184         return True;
1185 }
1186
1187 /*******************************************************************
1188  Inits a SESS_INFO_1_STR structure
1189 ********************************************************************/
1190
1191 void init_srv_sess_info1_str(SESS_INFO_1_STR *ss1, char *name, char *user)
1192 {
1193         DEBUG(5,("init_srv_sess_info1_str\n"));
1194
1195         init_unistr2(&ss1->uni_name, name, strlen(name)+1);
1196         init_unistr2(&ss1->uni_user, name, strlen(user)+1);
1197 }
1198
1199 /*******************************************************************
1200  Reads or writes a structure.
1201 ********************************************************************/
1202
1203 static BOOL srv_io_sess_info1_str(char *desc, SESS_INFO_1_STR *ss1, prs_struct *ps, int depth)
1204 {
1205         if (ss1 == NULL)
1206                 return False;
1207
1208         prs_debug(ps, depth, desc, "srv_io_sess_info1_str");
1209         depth++;
1210
1211         if(!prs_align(ps))
1212                 return False;
1213
1214         if(!smb_io_unistr2("", &ss1->uni_name, True, ps, depth))
1215                 return False;
1216         if(!smb_io_unistr2("", &(ss1->uni_user), True, ps, depth))
1217                 return False;
1218
1219         return True;
1220 }
1221
1222 /*******************************************************************
1223  Inits a SESS_INFO_1 structure
1224 ********************************************************************/
1225
1226 void init_srv_sess_info1(SESS_INFO_1 *ss1, 
1227                                 char *name, char *user,
1228                                 uint32 num_opens, uint32 open_time, uint32 idle_time,
1229                                 uint32 user_flags)
1230 {
1231         DEBUG(5,("init_srv_sess_info1: %s\n", name));
1232
1233         ss1->ptr_name = (name != NULL) ? 1 : 0;
1234         ss1->ptr_user = (user != NULL) ? 1 : 0;
1235
1236         ss1->num_opens  = num_opens;
1237         ss1->open_time  = open_time;
1238         ss1->idle_time  = idle_time;
1239         ss1->user_flags = user_flags;
1240 }
1241
1242 /*******************************************************************
1243 reads or writes a structure.
1244 ********************************************************************/
1245
1246 static BOOL srv_io_sess_info1(char *desc, SESS_INFO_1 *ss1, prs_struct *ps, int depth)
1247 {
1248         if (ss1 == NULL)
1249                 return False;
1250
1251         prs_debug(ps, depth, desc, "srv_io_sess_info1");
1252         depth++;
1253
1254         if(!prs_align(ps))
1255                 return False;
1256
1257         if(!prs_uint32("ptr_name  ", ps, depth, &ss1->ptr_name))
1258                 return False;
1259         if(!prs_uint32("ptr_user  ", ps, depth, &ss1->ptr_user))
1260                 return False;
1261
1262         if(!prs_uint32("num_opens ", ps, depth, &ss1->num_opens))
1263                 return False;
1264         if(!prs_uint32("open_time ", ps, depth, &ss1->open_time))
1265                 return False;
1266         if(!prs_uint32("idle_time ", ps, depth, &ss1->idle_time))
1267                 return False;
1268         if(!prs_uint32("user_flags", ps, depth, &ss1->user_flags))
1269                 return False;
1270
1271         return True;
1272 }
1273
1274 /*******************************************************************
1275  Reads or writes a structure.
1276 ********************************************************************/
1277
1278 static BOOL srv_io_srv_sess_info_1(char *desc, SRV_SESS_INFO_1 *ss1, prs_struct *ps, int depth)
1279 {
1280         if (ss1 == NULL)
1281                 return False;
1282
1283         prs_debug(ps, depth, desc, "srv_io_srv_sess_info_1");
1284         depth++;
1285
1286         if(!prs_align(ps))
1287                 return False;
1288
1289         if(!prs_uint32("num_entries_read", ps, depth, &ss1->num_entries_read))
1290                 return False;
1291         if(!prs_uint32("ptr_sess_info", ps, depth, &ss1->ptr_sess_info))
1292                 return False;
1293
1294         if (ss1->ptr_sess_info != 0) {
1295                 int i;
1296                 int num_entries = ss1->num_entries_read;
1297
1298                 if (num_entries > MAX_SESS_ENTRIES) {
1299                         num_entries = MAX_SESS_ENTRIES; /* report this! */
1300                 }
1301
1302                 if(!prs_uint32("num_entries_read2", ps, depth, &ss1->num_entries_read2))
1303                         return False;
1304
1305                 SMB_ASSERT_ARRAY(ss1->info_1, num_entries);
1306
1307                 for (i = 0; i < num_entries; i++) {
1308                         if(!srv_io_sess_info1("", &ss1->info_1[i], ps, depth))
1309                                 return False;
1310                 }
1311
1312                 for (i = 0; i < num_entries; i++) {
1313                         if(!srv_io_sess_info1_str("", &ss1->info_1_str[i], ps, depth))
1314                                 return False;
1315                 }
1316
1317                 if(!prs_align(ps))
1318                         return False;
1319         }
1320
1321         return True;
1322 }
1323
1324 /*******************************************************************
1325  Reads or writes a structure.
1326 ********************************************************************/
1327
1328 static BOOL srv_io_srv_sess_ctr(char *desc, SRV_SESS_INFO_CTR **pp_ctr, prs_struct *ps, int depth)
1329 {
1330         SRV_SESS_INFO_CTR *ctr = *pp_ctr;
1331
1332         prs_debug(ps, depth, desc, "srv_io_srv_sess_ctr");
1333         depth++;
1334
1335         if(UNMARSHALLING(ps)) {
1336                 ctr = *pp_ctr = (SRV_SESS_INFO_CTR *)prs_alloc_mem(ps, sizeof(SRV_SESS_INFO_CTR));
1337                 if (ctr == NULL)
1338                         return False;
1339         }
1340
1341         if (ctr == NULL)
1342                 return False;
1343
1344         if(!prs_align(ps))
1345                 return False;
1346
1347         if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
1348                 return False;
1349         if(!prs_uint32("ptr_sess_ctr", ps, depth, &ctr->ptr_sess_ctr))
1350                 return False;
1351
1352         if (ctr->ptr_sess_ctr != 0) {
1353                 switch (ctr->switch_value) {
1354                 case 0:
1355                         if(!srv_io_srv_sess_info_0("", &ctr->sess.info0, ps, depth))
1356                                 return False;
1357                         break;
1358                 case 1:
1359                         if(!srv_io_srv_sess_info_1("", &ctr->sess.info1, ps, depth))
1360                                 return False;
1361                         break;
1362                 default:
1363                         DEBUG(5,("%s no session info at switch_value %d\n",
1364                                  tab_depth(depth), ctr->switch_value));
1365                         break;
1366                 }
1367         }
1368
1369         return True;
1370 }
1371
1372 /*******************************************************************
1373  Inits a SRV_Q_NET_SESS_ENUM structure.
1374 ********************************************************************/
1375
1376 void init_srv_q_net_sess_enum(SRV_Q_NET_SESS_ENUM *q_n, 
1377                                 char *srv_name, char *qual_name,
1378                                 uint32 sess_level, SRV_SESS_INFO_CTR *ctr,
1379                                 uint32 preferred_len,
1380                                 ENUM_HND *hnd)
1381 {
1382         q_n->ctr = ctr;
1383
1384         DEBUG(5,("init_q_net_sess_enum\n"));
1385
1386         init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
1387         init_buf_unistr2(&q_n->uni_qual_name, &q_n->ptr_qual_name, qual_name);
1388
1389         q_n->sess_level    = sess_level;
1390         q_n->preferred_len = preferred_len;
1391
1392         memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
1393 }
1394
1395 /*******************************************************************
1396  Reads or writes a structure.
1397 ********************************************************************/
1398
1399 BOOL srv_io_q_net_sess_enum(char *desc, SRV_Q_NET_SESS_ENUM *q_n, prs_struct *ps, int depth)
1400 {
1401         if (q_n == NULL)
1402                 return False;
1403
1404         prs_debug(ps, depth, desc, "srv_io_q_net_sess_enum");
1405         depth++;
1406
1407         if(!prs_align(ps))
1408                 return False;
1409
1410         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
1411                 return False;
1412         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1413                 return False;
1414
1415         if(!prs_align(ps))
1416                 return False;
1417
1418         if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
1419                 return False;
1420         if(!smb_io_unistr2("", &q_n->uni_qual_name, q_n->ptr_qual_name, ps, depth))
1421                 return False;
1422
1423         if(!prs_align(ps))
1424                 return False;
1425
1426         if(!prs_uint32("sess_level", ps, depth, &q_n->sess_level))
1427                 return False;
1428         
1429         if (q_n->sess_level != -1) {
1430                 if(!srv_io_srv_sess_ctr("sess_ctr", &q_n->ctr, ps, depth))
1431                         return False;
1432         }
1433
1434         if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
1435                 return False;
1436
1437         if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
1438                 return False;
1439
1440         return True;
1441 }
1442
1443 /*******************************************************************
1444  Reads or writes a structure.
1445 ********************************************************************/
1446
1447 BOOL srv_io_r_net_sess_enum(char *desc, SRV_R_NET_SESS_ENUM *r_n, prs_struct *ps, int depth)
1448 {
1449         if (r_n == NULL)
1450                 return False;
1451
1452         prs_debug(ps, depth, desc, "srv_io_r_net_sess_enum");
1453         depth++;
1454
1455         if(!prs_align(ps))
1456                 return False;
1457
1458         if(!prs_uint32("sess_level", ps, depth, &r_n->sess_level))
1459                 return False;
1460
1461         if (r_n->sess_level != -1) {
1462                 if(!srv_io_srv_sess_ctr("sess_ctr", &r_n->ctr, ps, depth))
1463                         return False;
1464         }
1465
1466         if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
1467                 return False;
1468         if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
1469                 return False;
1470         if(!prs_werror("status", ps, depth, &r_n->status))
1471                 return False;
1472
1473         return True;
1474 }
1475
1476 /*******************************************************************
1477  Inits a CONN_INFO_0 structure
1478 ********************************************************************/
1479
1480 void init_srv_conn_info0(CONN_INFO_0 *ss0, uint32 id)
1481 {
1482         DEBUG(5,("init_srv_conn_info0\n"));
1483
1484         ss0->id = id;
1485 }
1486
1487 /*******************************************************************
1488  Reads or writes a structure.
1489 ********************************************************************/
1490
1491 static BOOL srv_io_conn_info0(char *desc, CONN_INFO_0 *ss0, prs_struct *ps, int depth)
1492 {
1493         if (ss0 == NULL)
1494                 return False;
1495
1496         prs_debug(ps, depth, desc, "srv_io_conn_info0");
1497         depth++;
1498
1499         if(!prs_align(ps))
1500                 return False;
1501
1502         if(!prs_uint32("id", ps, depth, &ss0->id))
1503                 return False;
1504
1505         return True;
1506 }
1507
1508 /*******************************************************************
1509  Reads or writes a structure.
1510 ********************************************************************/
1511
1512 static BOOL srv_io_srv_conn_info_0(char *desc, SRV_CONN_INFO_0 *ss0, prs_struct *ps, int depth)
1513 {
1514         if (ss0 == NULL)
1515                 return False;
1516
1517         prs_debug(ps, depth, desc, "srv_io_srv_conn_info_0");
1518         depth++;
1519
1520         if(!prs_align(ps))
1521                 return False;
1522
1523         if(!prs_uint32("num_entries_read", ps, depth, &ss0->num_entries_read))
1524                 return False;
1525         if(!prs_uint32("ptr_conn_info", ps, depth, &ss0->ptr_conn_info))
1526                 return False;
1527
1528         if (ss0->ptr_conn_info != 0) {
1529                 int i;
1530                 int num_entries = ss0->num_entries_read;
1531
1532                 if (num_entries > MAX_CONN_ENTRIES) {
1533                         num_entries = MAX_CONN_ENTRIES; /* report this! */
1534                 }
1535
1536                 if(!prs_uint32("num_entries_read2", ps, depth, &ss0->num_entries_read2))
1537                         return False;
1538
1539                 for (i = 0; i < num_entries; i++) {
1540                         if(!srv_io_conn_info0("", &ss0->info_0[i], ps, depth))
1541                                 return False;
1542                 }
1543
1544                 if(!prs_align(ps))
1545                         return False;
1546         }
1547
1548         return True;
1549 }
1550
1551 /*******************************************************************
1552  Inits a CONN_INFO_1_STR structure
1553 ********************************************************************/
1554
1555 void init_srv_conn_info1_str(CONN_INFO_1_STR *ss1, char *usr_name, char *net_name)
1556 {
1557         DEBUG(5,("init_srv_conn_info1_str\n"));
1558
1559         init_unistr2(&ss1->uni_usr_name, usr_name, strlen(usr_name)+1);
1560         init_unistr2(&ss1->uni_net_name, net_name, strlen(net_name)+1);
1561 }
1562
1563 /*******************************************************************
1564  Reads or writes a structure.
1565 ********************************************************************/
1566
1567 static BOOL srv_io_conn_info1_str(char *desc, CONN_INFO_1_STR *ss1, prs_struct *ps, int depth)
1568 {
1569         if (ss1 == NULL)
1570                 return False;
1571
1572         prs_debug(ps, depth, desc, "srv_io_conn_info1_str");
1573         depth++;
1574
1575         if(!prs_align(ps))
1576                 return False;
1577
1578         if(!smb_io_unistr2("", &ss1->uni_usr_name, True, ps, depth))
1579                 return False;
1580         if(!smb_io_unistr2("", &ss1->uni_net_name, True, ps, depth))
1581                 return False;
1582
1583         return True;
1584 }
1585
1586 /*******************************************************************
1587  Inits a CONN_INFO_1 structure
1588 ********************************************************************/
1589
1590 void init_srv_conn_info1(CONN_INFO_1 *ss1, 
1591                                 uint32 id, uint32 type,
1592                                 uint32 num_opens, uint32 num_users, uint32 open_time,
1593                                 char *usr_name, char *net_name)
1594 {
1595         DEBUG(5,("init_srv_conn_info1: %s %s\n", usr_name, net_name));
1596
1597         ss1->id        = id       ;
1598         ss1->type      = type     ;
1599         ss1->num_opens = num_opens ;
1600         ss1->num_users = num_users;
1601         ss1->open_time = open_time;
1602
1603         ss1->ptr_usr_name = (usr_name != NULL) ? 1 : 0;
1604         ss1->ptr_net_name = (net_name != NULL) ? 1 : 0;
1605 }
1606
1607 /*******************************************************************
1608  Reads or writes a structure.
1609 ********************************************************************/
1610
1611 static BOOL srv_io_conn_info1(char *desc, CONN_INFO_1 *ss1, prs_struct *ps, int depth)
1612 {
1613         if (ss1 == NULL)
1614                 return False;
1615
1616         prs_debug(ps, depth, desc, "srv_io_conn_info1");
1617         depth++;
1618
1619         if(!prs_align(ps))
1620                 return False;
1621
1622         if(!prs_uint32("id          ", ps, depth, &ss1->id))
1623                 return False;
1624         if(!prs_uint32("type        ", ps, depth, &ss1->type))
1625                 return False;
1626         if(!prs_uint32("num_opens   ", ps, depth, &ss1->num_opens))
1627                 return False;
1628         if(!prs_uint32("num_users   ", ps, depth, &ss1->num_users))
1629                 return False;
1630         if(!prs_uint32("open_time   ", ps, depth, &ss1->open_time))
1631                 return False;
1632
1633         if(!prs_uint32("ptr_usr_name", ps, depth, &ss1->ptr_usr_name))
1634                 return False;
1635         if(!prs_uint32("ptr_net_name", ps, depth, &ss1->ptr_net_name))
1636                 return False;
1637
1638         return True;
1639 }
1640
1641 /*******************************************************************
1642  Reads or writes a structure.
1643 ********************************************************************/
1644
1645 static BOOL srv_io_srv_conn_info_1(char *desc, SRV_CONN_INFO_1 *ss1, prs_struct *ps, int depth)
1646 {
1647         if (ss1 == NULL)
1648                 return False;
1649
1650         prs_debug(ps, depth, desc, "srv_io_srv_conn_info_1");
1651         depth++;
1652
1653         if(!prs_align(ps))
1654                 return False;
1655
1656         if(!prs_uint32("num_entries_read", ps, depth, &ss1->num_entries_read))
1657                 return False;
1658         if(!prs_uint32("ptr_conn_info", ps, depth, &ss1->ptr_conn_info))
1659                 return False;
1660
1661         if (ss1->ptr_conn_info != 0) {
1662                 int i;
1663                 int num_entries = ss1->num_entries_read;
1664
1665                 if (num_entries > MAX_CONN_ENTRIES) {
1666                         num_entries = MAX_CONN_ENTRIES; /* report this! */
1667                 }
1668
1669                 if(!prs_uint32("num_entries_read2", ps, depth, &ss1->num_entries_read2))
1670                         return False;
1671
1672                 for (i = 0; i < num_entries; i++) {
1673                         if(!srv_io_conn_info1("", &ss1->info_1[i], ps, depth))
1674                                 return False;
1675                 }
1676
1677                 for (i = 0; i < num_entries; i++) {
1678                         if(!srv_io_conn_info1_str("", &ss1->info_1_str[i], ps, depth))
1679                                 return False;
1680                 }
1681
1682                 if(!prs_align(ps))
1683                         return False;
1684         }
1685
1686         return True;
1687 }
1688
1689 /*******************************************************************
1690  Reads or writes a structure.
1691 ********************************************************************/
1692
1693 static BOOL srv_io_srv_conn_ctr(char *desc, SRV_CONN_INFO_CTR **pp_ctr, prs_struct *ps, int depth)
1694 {
1695         SRV_CONN_INFO_CTR *ctr = *pp_ctr;
1696
1697         prs_debug(ps, depth, desc, "srv_io_srv_conn_ctr");
1698         depth++;
1699
1700         if (UNMARSHALLING(ps)) {
1701                 ctr = *pp_ctr = (SRV_CONN_INFO_CTR *)prs_alloc_mem(ps, sizeof(SRV_CONN_INFO_CTR));
1702                 if (ctr == NULL)
1703                         return False;
1704         }
1705                 
1706         if (ctr == NULL)
1707                 return False;
1708
1709         if(!prs_align(ps))
1710                 return False;
1711
1712         if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
1713                 return False;
1714         if(!prs_uint32("ptr_conn_ctr", ps, depth, &ctr->ptr_conn_ctr))
1715                 return False;
1716
1717         if (ctr->ptr_conn_ctr != 0) {
1718                 switch (ctr->switch_value) {
1719                 case 0:
1720                         if(!srv_io_srv_conn_info_0("", &ctr->conn.info0, ps, depth))
1721                                 return False;
1722                         break;
1723                 case 1:
1724                         if(!srv_io_srv_conn_info_1("", &ctr->conn.info1, ps, depth))
1725                                 return False;
1726                         break;
1727                 default:
1728                         DEBUG(5,("%s no connection info at switch_value %d\n",
1729                                  tab_depth(depth), ctr->switch_value));
1730                         break;
1731                 }
1732         }
1733
1734         return True;
1735 }
1736
1737 /*******************************************************************
1738   Reads or writes a structure.
1739 ********************************************************************/
1740
1741 void init_srv_q_net_conn_enum(SRV_Q_NET_CONN_ENUM *q_n, 
1742                                 char *srv_name, char *qual_name,
1743                                 uint32 conn_level, SRV_CONN_INFO_CTR *ctr,
1744                                 uint32 preferred_len,
1745                                 ENUM_HND *hnd)
1746 {
1747         DEBUG(5,("init_q_net_conn_enum\n"));
1748
1749         q_n->ctr = ctr;
1750
1751         init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name );
1752         init_buf_unistr2(&q_n->uni_qual_name, &q_n->ptr_qual_name, qual_name);
1753
1754         q_n->conn_level    = conn_level;
1755         q_n->preferred_len = preferred_len;
1756
1757         memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
1758 }
1759
1760 /*******************************************************************
1761  Reads or writes a structure.
1762 ********************************************************************/
1763
1764 BOOL srv_io_q_net_conn_enum(char *desc, SRV_Q_NET_CONN_ENUM *q_n, prs_struct *ps, int depth)
1765 {
1766         if (q_n == NULL)
1767                 return False;
1768
1769         prs_debug(ps, depth, desc, "srv_io_q_net_conn_enum");
1770         depth++;
1771
1772         if(!prs_align(ps))
1773                 return False;
1774
1775         if(!prs_uint32("ptr_srv_name ", ps, depth, &q_n->ptr_srv_name))
1776                 return False;
1777         if(!smb_io_unistr2("", &q_n->uni_srv_name, q_n->ptr_srv_name, ps, depth))
1778                 return False;
1779
1780         if(!prs_align(ps))
1781                 return False;
1782
1783         if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
1784                 return False;
1785         if(!smb_io_unistr2("", &q_n->uni_qual_name, q_n->ptr_qual_name, ps, depth))
1786                 return False;
1787
1788         if(!prs_align(ps))
1789                 return False;
1790
1791         if(!prs_uint32("conn_level", ps, depth, &q_n->conn_level))
1792                 return False;
1793         
1794         if (q_n->conn_level != -1) {
1795                 if(!srv_io_srv_conn_ctr("conn_ctr", &q_n->ctr, ps, depth))
1796                         return False;
1797         }
1798
1799         if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
1800                 return False;
1801
1802         if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
1803                 return False;
1804
1805         return True;
1806 }
1807
1808 /*******************************************************************
1809  Reads or writes a structure.
1810 ********************************************************************/
1811
1812 BOOL srv_io_r_net_conn_enum(char *desc,  SRV_R_NET_CONN_ENUM *r_n, prs_struct *ps, int depth)
1813 {
1814         if (r_n == NULL)
1815                 return False;
1816
1817         prs_debug(ps, depth, desc, "srv_io_r_net_conn_enum");
1818         depth++;
1819
1820         if(!prs_align(ps))
1821                 return False;
1822
1823         if(!prs_uint32("conn_level", ps, depth, &r_n->conn_level))
1824                 return False;
1825
1826         if (r_n->conn_level != -1) {
1827                 if(!srv_io_srv_conn_ctr("conn_ctr", &r_n->ctr, ps, depth))
1828                         return False;
1829         }
1830
1831         if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
1832                 return False;
1833         if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
1834                 return False;
1835         if(!prs_werror("status", ps, depth, &r_n->status))
1836                 return False;
1837
1838         return True;
1839 }
1840
1841 /*******************************************************************
1842  Inits a FILE_INFO_3_STR structure
1843 ********************************************************************/
1844
1845 void init_srv_file_info3_str(FILE_INFO_3_STR *fi3, char *user_name, char *path_name)
1846 {
1847         DEBUG(5,("init_srv_file_info3_str\n"));
1848
1849         init_unistr2(&fi3->uni_path_name, path_name, strlen(path_name)+1);
1850         init_unistr2(&fi3->uni_user_name, user_name, strlen(user_name)+1);
1851 }
1852
1853 /*******************************************************************
1854  Reads or writes a structure.
1855 ********************************************************************/
1856
1857 static BOOL srv_io_file_info3_str(char *desc, FILE_INFO_3_STR *sh1, prs_struct *ps, int depth)
1858 {
1859         if (sh1 == NULL)
1860                 return False;
1861
1862         prs_debug(ps, depth, desc, "srv_io_file_info3_str");
1863         depth++;
1864
1865         if(!prs_align(ps))
1866                 return False;
1867
1868         if(!smb_io_unistr2("", &sh1->uni_path_name, True, ps, depth))
1869                 return False;
1870         if(!smb_io_unistr2("", &sh1->uni_user_name, True, ps, depth))
1871                 return False;
1872
1873         return True;
1874 }
1875
1876 /*******************************************************************
1877  Inits a FILE_INFO_3 structure
1878 ********************************************************************/
1879
1880 void init_srv_file_info3(FILE_INFO_3 *fl3,
1881                                 uint32 id, uint32 perms, uint32 num_locks,
1882                                 char *path_name, char *user_name)
1883 {
1884         DEBUG(5,("init_srv_file_info3: %s %s\n", path_name, user_name));
1885
1886         fl3->id        = id;    
1887         fl3->perms     = perms;
1888         fl3->num_locks = num_locks;
1889
1890         fl3->ptr_path_name = (path_name != NULL) ? 1 : 0;
1891         fl3->ptr_user_name = (user_name != NULL) ? 1 : 0;
1892 }
1893
1894 /*******************************************************************
1895  Reads or writes a structure.
1896 ********************************************************************/
1897
1898 static BOOL srv_io_file_info3(char *desc, FILE_INFO_3 *fl3, prs_struct *ps, int depth)
1899 {
1900         if (fl3 == NULL)
1901                 return False;
1902
1903         prs_debug(ps, depth, desc, "srv_io_file_info3");
1904         depth++;
1905
1906         if(!prs_align(ps))
1907                 return False;
1908
1909         if(!prs_uint32("id           ", ps, depth, &fl3->id))
1910                 return False;
1911         if(!prs_uint32("perms        ", ps, depth, &fl3->perms))
1912                 return False;
1913         if(!prs_uint32("num_locks    ", ps, depth, &fl3->num_locks))
1914                 return False;
1915         if(!prs_uint32("ptr_path_name", ps, depth, &fl3->ptr_path_name))
1916                 return False;
1917         if(!prs_uint32("ptr_user_name", ps, depth, &fl3->ptr_user_name))
1918                 return False;
1919
1920         return True;
1921 }
1922
1923 /*******************************************************************
1924  Reads or writes a structure.
1925 ********************************************************************/
1926
1927 static BOOL srv_io_srv_file_ctr(char *desc, SRV_FILE_INFO_CTR *ctr, prs_struct *ps, int depth)
1928 {
1929         if (ctr == NULL)
1930                 return False;
1931
1932         prs_debug(ps, depth, desc, "srv_io_srv_file_ctr");
1933         depth++;
1934
1935         if (UNMARSHALLING(ps)) {
1936                 memset(ctr, '\0', sizeof(SRV_FILE_INFO_CTR));
1937         }
1938
1939         if(!prs_align(ps))
1940                 return False;
1941
1942         if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
1943                 return False;
1944         if (ctr->switch_value != 3) {
1945                 DEBUG(5,("%s File info %d level not supported\n",
1946                          tab_depth(depth), ctr->switch_value));
1947         }
1948         if(!prs_uint32("ptr_file_info", ps, depth, &ctr->ptr_file_info))
1949                 return False;
1950         if(!prs_uint32("num_entries", ps, depth, &ctr->num_entries))
1951                 return False;
1952         if(!prs_uint32("ptr_entries", ps, depth, &ctr->ptr_entries))
1953                 return False;
1954         if (ctr->ptr_entries == 0)
1955                 return True;
1956         if(!prs_uint32("num_entries2", ps, depth, 
1957                        &ctr->num_entries2))
1958                 return False;
1959
1960         switch (ctr->switch_value) {
1961         case 3: {
1962                 SRV_FILE_INFO_3 *info3 = ctr->file.info3;
1963                 int num_entries = ctr->num_entries;
1964                 int i;
1965
1966                 if (UNMARSHALLING(ps)) {
1967                         if (!(info3 = (SRV_FILE_INFO_3 *)prs_alloc_mem(ps, num_entries * sizeof(SRV_FILE_INFO_3))))
1968                                 return False;
1969                         ctr->file.info3 = info3;
1970                 }
1971
1972                 for (i = 0; i < num_entries; i++) {
1973                         if(!srv_io_file_info3("", &ctr->file.info3[i].info_3, ps, depth))
1974                                 return False;
1975                 }
1976                 for (i = 0; i < num_entries; i++) {
1977                         if(!srv_io_file_info3_str("", &ctr->file.info3[i].info_3_str, ps, depth))
1978                                 return False;
1979                 }
1980                 break;
1981         }
1982         default:
1983                 DEBUG(5,("%s no file info at switch_value %d\n",
1984                          tab_depth(depth), ctr->switch_value));
1985                 break;
1986         }
1987                         
1988         return True;
1989 }
1990
1991 /*******************************************************************
1992  Inits a SRV_Q_NET_FILE_ENUM structure.
1993 ********************************************************************/
1994
1995 void init_srv_q_net_file_enum(SRV_Q_NET_FILE_ENUM *q_n, 
1996                                 char *srv_name, char *qual_name,
1997                                 uint32 file_level, SRV_FILE_INFO_CTR *ctr,
1998                                 uint32 preferred_len,
1999                                 ENUM_HND *hnd)
2000 {
2001         DEBUG(5,("init_q_net_file_enum\n"));
2002
2003         init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
2004         init_buf_unistr2(&q_n->uni_qual_name, &q_n->ptr_qual_name, qual_name);
2005
2006         q_n->file_level    = q_n->ctr.switch_value = file_level;
2007         q_n->preferred_len = preferred_len;
2008         q_n->ctr.ptr_file_info = 1;
2009         q_n->ctr.num_entries = 0;
2010         q_n->ctr.num_entries2 = 0;
2011
2012         memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
2013 }
2014
2015 /*******************************************************************
2016  Reads or writes a structure.
2017 ********************************************************************/
2018
2019 BOOL srv_io_q_net_file_enum(char *desc, SRV_Q_NET_FILE_ENUM *q_n, prs_struct *ps, int depth)
2020 {
2021         if (q_n == NULL)
2022                 return False;
2023
2024         prs_debug(ps, depth, desc, "srv_io_q_net_file_enum");
2025         depth++;
2026
2027         if(!prs_align(ps))
2028                 return False;
2029
2030         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
2031                 return False;
2032         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
2033                 return False;
2034
2035         if(!prs_align(ps))
2036                 return False;
2037
2038         if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
2039                 return False;
2040         if(!smb_io_unistr2("", &q_n->uni_qual_name, q_n->ptr_qual_name, ps, depth))
2041                 return False;
2042
2043         if(!prs_align(ps))
2044                 return False;
2045
2046         if(!prs_uint32("ptr_user_name", ps, depth, &q_n->ptr_user_name))
2047                 return False;
2048         if(!smb_io_unistr2("", &q_n->uni_user_name, q_n->ptr_user_name, ps, depth))
2049                 return False;
2050
2051         if(!prs_align(ps))
2052                 return False;
2053         if(!prs_uint32("file_level", ps, depth, &q_n->file_level))
2054                 return False;
2055
2056         if (q_n->file_level != -1) {
2057                 if(!srv_io_srv_file_ctr("file_ctr", &q_n->ctr, ps, depth))
2058                         return False;
2059         }
2060
2061         if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
2062                 return False;
2063
2064         if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
2065                 return False;
2066
2067         return True;
2068 }
2069
2070 /*******************************************************************
2071  Reads or writes a structure.
2072 ********************************************************************/
2073
2074 BOOL srv_io_r_net_file_enum(char *desc, SRV_R_NET_FILE_ENUM *r_n, prs_struct *ps, int depth)
2075 {
2076         if (r_n == NULL)
2077                 return False;
2078
2079         prs_debug(ps, depth, desc, "srv_io_r_net_file_enum");
2080         depth++;
2081
2082         if(!prs_align(ps))
2083                 return False;
2084
2085         if(!prs_uint32("file_level", ps, depth, &r_n->file_level))
2086                 return False;
2087
2088         if (r_n->file_level != 0) {
2089                 if(!srv_io_srv_file_ctr("file_ctr", &r_n->ctr, ps, depth))
2090                         return False;
2091         }
2092
2093         if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
2094                 return False;
2095         if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
2096                 return False;
2097         if(!prs_werror("status", ps, depth, &r_n->status))
2098                 return False;
2099
2100         return True;
2101 }
2102
2103 /*******************************************************************
2104  Inits a SRV_INFO_100 structure.
2105  ********************************************************************/
2106
2107 void init_srv_info_100(SRV_INFO_100 *sv100, uint32 platform_id, char *name)
2108 {
2109         DEBUG(5,("init_srv_info_100\n"));
2110
2111         sv100->platform_id  = platform_id;
2112         init_buf_unistr2(&sv100->uni_name, &sv100->ptr_name, name);
2113 }
2114
2115 /*******************************************************************
2116  Reads or writes a SRV_INFO_101 structure.
2117  ********************************************************************/
2118
2119 static BOOL srv_io_info_100(char *desc, SRV_INFO_100 *sv100, prs_struct *ps, int depth)
2120 {
2121         if (sv100 == NULL)
2122                 return False;
2123
2124         prs_debug(ps, depth, desc, "srv_io_info_100");
2125         depth++;
2126
2127         if(!prs_align(ps))
2128                 return False;
2129
2130         if(!prs_uint32("platform_id ", ps, depth, &sv100->platform_id))
2131                 return False;
2132         if(!prs_uint32("ptr_name    ", ps, depth, &sv100->ptr_name))
2133                 return False;
2134
2135         if(!smb_io_unistr2("uni_name    ", &sv100->uni_name, True, ps, depth))
2136                 return False;
2137
2138         return True;
2139 }
2140
2141
2142 /*******************************************************************
2143  Inits a SRV_INFO_101 structure.
2144  ********************************************************************/
2145
2146 void init_srv_info_101(SRV_INFO_101 *sv101, uint32 platform_id, char *name,
2147                                 uint32 ver_major, uint32 ver_minor,
2148                                 uint32 srv_type, char *comment)
2149 {
2150         DEBUG(5,("init_srv_info_101\n"));
2151
2152         sv101->platform_id  = platform_id;
2153         init_buf_unistr2(&sv101->uni_name, &sv101->ptr_name, name);
2154         sv101->ver_major    = ver_major;
2155         sv101->ver_minor    = ver_minor;
2156         sv101->srv_type     = srv_type;
2157         init_buf_unistr2(&sv101->uni_comment, &sv101->ptr_comment, comment);
2158 }
2159
2160 /*******************************************************************
2161  Reads or writes a SRV_INFO_101 structure.
2162  ********************************************************************/
2163
2164 static BOOL srv_io_info_101(char *desc, SRV_INFO_101 *sv101, prs_struct *ps, int depth)
2165 {
2166         if (sv101 == NULL)
2167                 return False;
2168
2169         prs_debug(ps, depth, desc, "srv_io_info_101");
2170         depth++;
2171
2172         if(!prs_align(ps))
2173                 return False;
2174
2175         if(!prs_uint32("platform_id ", ps, depth, &sv101->platform_id))
2176                 return False;
2177         if(!prs_uint32("ptr_name    ", ps, depth, &sv101->ptr_name))
2178                 return False;
2179         if(!prs_uint32("ver_major   ", ps, depth, &sv101->ver_major))
2180                 return False;
2181         if(!prs_uint32("ver_minor   ", ps, depth, &sv101->ver_minor))
2182                 return False;
2183         if(!prs_uint32("srv_type    ", ps, depth, &sv101->srv_type))
2184                 return False;
2185         if(!prs_uint32("ptr_comment ", ps, depth, &sv101->ptr_comment))
2186                 return False;
2187
2188         if(!prs_align(ps))
2189                 return False;
2190
2191         if(!smb_io_unistr2("uni_name    ", &sv101->uni_name, True, ps, depth))
2192                 return False;
2193         if(!smb_io_unistr2("uni_comment ", &sv101->uni_comment, True, ps, depth))
2194                 return False;
2195
2196         return True;
2197 }
2198
2199 /*******************************************************************
2200  Inits a SRV_INFO_102 structure.
2201  ********************************************************************/
2202
2203 void init_srv_info_102(SRV_INFO_102 *sv102, uint32 platform_id, char *name,
2204                                 char *comment, uint32 ver_major, uint32 ver_minor,
2205                                 uint32 srv_type, uint32 users, uint32 disc, uint32 hidden,
2206                                 uint32 announce, uint32 ann_delta, uint32 licenses,
2207                                 char *usr_path)
2208 {
2209         DEBUG(5,("init_srv_info_102\n"));
2210
2211         sv102->platform_id  = platform_id;
2212         init_buf_unistr2(&sv102->uni_name, &sv102->ptr_name, name);
2213         sv102->ver_major    = ver_major;
2214         sv102->ver_minor    = ver_minor;
2215         sv102->srv_type     = srv_type;
2216         init_buf_unistr2(&sv102->uni_comment, &sv102->ptr_comment, comment);
2217
2218         /* same as 101 up to here */
2219
2220         sv102->users        = users;
2221         sv102->disc         = disc;
2222         sv102->hidden       = hidden;
2223         sv102->announce     = announce;
2224         sv102->ann_delta    =ann_delta;
2225         sv102->licenses     = licenses;
2226         init_buf_unistr2(&sv102->uni_usr_path, &sv102->ptr_usr_path, usr_path);
2227 }
2228
2229
2230 /*******************************************************************
2231  Reads or writes a SRV_INFO_102 structure.
2232  ********************************************************************/
2233
2234 static BOOL srv_io_info_102(char *desc, SRV_INFO_102 *sv102, prs_struct *ps, int depth)
2235 {
2236         if (sv102 == NULL)
2237                 return False;
2238
2239         prs_debug(ps, depth, desc, "srv_io_info102");
2240         depth++;
2241
2242         if(!prs_align(ps))
2243                 return False;
2244
2245         if(!prs_uint32("platform_id ", ps, depth, &sv102->platform_id))
2246                 return False;
2247         if(!prs_uint32("ptr_name    ", ps, depth, &sv102->ptr_name))
2248                 return False;
2249         if(!prs_uint32("ver_major   ", ps, depth, &sv102->ver_major))
2250                 return False;
2251         if(!prs_uint32("ver_minor   ", ps, depth, &sv102->ver_minor))
2252                 return False;
2253         if(!prs_uint32("srv_type    ", ps, depth, &sv102->srv_type))
2254                 return False;
2255         if(!prs_uint32("ptr_comment ", ps, depth, &sv102->ptr_comment))
2256                 return False;
2257
2258         /* same as 101 up to here */
2259
2260         if(!prs_uint32("users       ", ps, depth, &sv102->users))
2261                 return False;
2262         if(!prs_uint32("disc        ", ps, depth, &sv102->disc))
2263                 return False;
2264         if(!prs_uint32("hidden      ", ps, depth, &sv102->hidden))
2265                 return False;
2266         if(!prs_uint32("announce    ", ps, depth, &sv102->announce))
2267                 return False;
2268         if(!prs_uint32("ann_delta   ", ps, depth, &sv102->ann_delta))
2269                 return False;
2270         if(!prs_uint32("licenses    ", ps, depth, &sv102->licenses))
2271                 return False;
2272         if(!prs_uint32("ptr_usr_path", ps, depth, &sv102->ptr_usr_path))
2273                 return False;
2274
2275         if(!smb_io_unistr2("uni_name    ", &sv102->uni_name, True, ps, depth))
2276                 return False;
2277         if(!prs_align(ps))
2278                 return False;
2279         if(!smb_io_unistr2("uni_comment ", &sv102->uni_comment, True, ps, depth))
2280                 return False;
2281         if(!prs_align(ps))
2282                 return False;
2283         if(!smb_io_unistr2("uni_usr_path", &sv102->uni_usr_path, True, ps, depth))
2284                 return False;
2285
2286         return True;
2287 }
2288
2289 /*******************************************************************
2290  Reads or writes a SRV_INFO_102 structure.
2291  ********************************************************************/
2292
2293 static BOOL srv_io_info_ctr(char *desc, SRV_INFO_CTR *ctr, prs_struct *ps, int depth)
2294 {
2295         if (ctr == NULL)
2296                 return False;
2297
2298         prs_debug(ps, depth, desc, "srv_io_info_ctr");
2299         depth++;
2300
2301         if(!prs_align(ps))
2302                 return False;
2303
2304         if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
2305                 return False;
2306         if(!prs_uint32("ptr_srv_ctr ", ps, depth, &ctr->ptr_srv_ctr))
2307                 return False;
2308
2309         if (ctr->ptr_srv_ctr != 0 && ctr->switch_value != 0 && ctr != NULL) {
2310                 switch (ctr->switch_value) {
2311                 case 100:
2312                         if(!srv_io_info_100("sv100", &ctr->srv.sv100, ps, depth))
2313                                 return False;
2314                         break;
2315                 case 101:
2316                         if(!srv_io_info_101("sv101", &ctr->srv.sv101, ps, depth))
2317                                 return False;
2318                         break;
2319                 case 102:
2320                         if(!srv_io_info_102("sv102", &ctr->srv.sv102, ps, depth))
2321                                 return False;
2322                         break;
2323                 default:
2324                         DEBUG(5,("%s no server info at switch_value %d\n",
2325                                          tab_depth(depth), ctr->switch_value));
2326                         break;
2327                 }
2328                 if(!prs_align(ps))
2329                         return False;
2330         }
2331
2332         return True;
2333 }
2334
2335 /*******************************************************************
2336  Inits a SRV_Q_NET_SRV_GET_INFO structure.
2337  ********************************************************************/
2338
2339 void init_srv_q_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *srv,
2340                                 char *server_name, uint32 switch_value)
2341 {
2342         DEBUG(5,("init_srv_q_net_srv_get_info\n"));
2343
2344         init_buf_unistr2(&srv->uni_srv_name, &srv->ptr_srv_name, server_name);
2345
2346         srv->switch_value = switch_value;
2347 }
2348
2349 /*******************************************************************
2350  Reads or writes a structure.
2351 ********************************************************************/
2352
2353 BOOL srv_io_q_net_srv_get_info(char *desc, SRV_Q_NET_SRV_GET_INFO *q_n, prs_struct *ps, int depth)
2354 {
2355         if (q_n == NULL)
2356                 return False;
2357
2358         prs_debug(ps, depth, desc, "srv_io_q_net_srv_get_info");
2359         depth++;
2360
2361         if(!prs_align(ps))
2362                 return False;
2363
2364         if(!prs_uint32("ptr_srv_name  ", ps, depth, &q_n->ptr_srv_name))
2365                 return False;
2366         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
2367                 return False;
2368
2369         if(!prs_align(ps))
2370                 return False;
2371
2372         if(!prs_uint32("switch_value  ", ps, depth, &q_n->switch_value))
2373                 return False;
2374
2375         return True;
2376 }
2377
2378 /*******************************************************************
2379  Inits a SRV_R_NET_SRV_GET_INFO structure.
2380  ********************************************************************/
2381
2382 void init_srv_r_net_srv_get_info(SRV_R_NET_SRV_GET_INFO *srv,
2383                                 uint32 switch_value, SRV_INFO_CTR *ctr, WERROR status)
2384 {
2385         DEBUG(5,("init_srv_r_net_srv_get_info\n"));
2386
2387         srv->ctr = ctr;
2388
2389         if (W_ERROR_IS_OK(status)) {
2390                 srv->ctr->switch_value = switch_value;
2391                 srv->ctr->ptr_srv_ctr  = 1;
2392         } else {
2393                 srv->ctr->switch_value = 0;
2394                 srv->ctr->ptr_srv_ctr  = 0;
2395         }
2396
2397         srv->status = status;
2398 }
2399
2400 /*******************************************************************
2401  Inits a SRV_R_NET_SRV_SET_INFO structure.
2402  ********************************************************************/
2403
2404 void init_srv_r_net_srv_set_info(SRV_R_NET_SRV_SET_INFO *srv,
2405                                  uint32 switch_value, WERROR status)
2406 {
2407         DEBUG(5,("init_srv_r_net_srv_set_info\n"));
2408
2409         srv->switch_value = switch_value;
2410         srv->status = status;
2411 }
2412
2413 /*******************************************************************
2414  Reads or writes a structure.
2415 ********************************************************************/
2416
2417 BOOL srv_io_q_net_srv_set_info(char *desc, SRV_Q_NET_SRV_SET_INFO *q_n, 
2418                                prs_struct *ps, int depth)
2419 {
2420         prs_debug(ps, depth, desc, "srv_io_q_net_srv_set_info");
2421         depth++;
2422
2423         if(!prs_align(ps))
2424                 return False;
2425
2426         if(!prs_uint32("ptr_srv_name  ", ps, depth, &q_n->ptr_srv_name))
2427                 return False;
2428         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
2429                 return False;
2430
2431         if(!prs_align(ps))
2432                 return False;
2433
2434         if(!prs_uint32("switch_value  ", ps, depth, &q_n->switch_value))
2435                 return False;
2436
2437         if (UNMARSHALLING(ps)) {
2438                 q_n->ctr = (SRV_INFO_CTR *)
2439                         prs_alloc_mem(ps, sizeof(SRV_INFO_CTR));
2440
2441                 if (!q_n->ctr)
2442                         return False;
2443         }
2444
2445         if(!srv_io_info_ctr("ctr", q_n->ctr, ps, depth))
2446                 return False;
2447
2448         return True;
2449 }
2450
2451 /*******************************************************************
2452  Reads or writes a structure.
2453  ********************************************************************/
2454
2455 BOOL srv_io_r_net_srv_get_info(char *desc, SRV_R_NET_SRV_GET_INFO *r_n, prs_struct *ps, int depth)
2456 {
2457         if (r_n == NULL)
2458                 return False;
2459
2460         prs_debug(ps, depth, desc, "srv_io_r_net_srv_get_info");
2461         depth++;
2462
2463         if(!prs_align(ps))
2464                 return False;
2465
2466         if(!srv_io_info_ctr("ctr", r_n->ctr, ps, depth))
2467                 return False;
2468
2469         if(!prs_werror("status", ps, depth, &r_n->status))
2470                 return False;
2471
2472         return True;
2473 }
2474
2475 /*******************************************************************
2476  Reads or writes a structure.
2477  ********************************************************************/
2478
2479 BOOL srv_io_r_net_srv_set_info(char *desc, SRV_R_NET_SRV_SET_INFO *r_n, 
2480                                prs_struct *ps, int depth)
2481 {
2482         prs_debug(ps, depth, desc, "srv_io_r_net_srv_set_info");
2483         depth++;
2484
2485         if(!prs_align(ps))
2486                 return False;
2487
2488         if(!prs_uint32("switch_value  ", ps, depth, &r_n->switch_value))
2489                 return False;
2490
2491         if(!prs_werror("status", ps, depth, &r_n->status))
2492                 return False;
2493
2494         return True;
2495 }
2496
2497 /*******************************************************************
2498  Reads or writes a structure.
2499  ********************************************************************/
2500
2501 BOOL srv_io_q_net_remote_tod(char *desc, SRV_Q_NET_REMOTE_TOD *q_n, prs_struct *ps, int depth)
2502 {
2503         if (q_n == NULL)
2504                 return False;
2505
2506         prs_debug(ps, depth, desc, "srv_io_q_net_remote_tod");
2507         depth++;
2508
2509         if(!prs_align(ps))
2510                 return False;
2511
2512         if(!prs_uint32("ptr_srv_name  ", ps, depth, &q_n->ptr_srv_name))
2513                 return False;
2514         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
2515                 return False;
2516
2517         return True;
2518 }
2519
2520 /*******************************************************************
2521  Reads or writes a TIME_OF_DAY_INFO structure.
2522  ********************************************************************/
2523
2524 static BOOL srv_io_time_of_day_info(char *desc, TIME_OF_DAY_INFO *tod, prs_struct *ps, int depth)
2525 {
2526         if (tod == NULL)
2527                 return False;
2528
2529         prs_debug(ps, depth, desc, "srv_io_time_of_day_info");
2530         depth++;
2531
2532         if(!prs_align(ps))
2533                 return False;
2534         
2535         if(!prs_uint32("elapsedt   ", ps, depth, &tod->elapsedt))
2536                 return False;
2537         if(!prs_uint32("msecs      ", ps, depth, &tod->msecs))
2538                 return False;
2539         if(!prs_uint32("hours      ", ps, depth, &tod->hours))
2540                 return False;
2541         if(!prs_uint32("mins       ", ps, depth, &tod->mins))
2542                 return False;
2543         if(!prs_uint32("secs       ", ps, depth, &tod->secs))
2544                 return False;
2545         if(!prs_uint32("hunds      ", ps, depth, &tod->hunds))
2546                 return False;
2547         if(!prs_uint32("timezone   ", ps, depth, &tod->zone))
2548                 return False;
2549         if(!prs_uint32("tintervals ", ps, depth, &tod->tintervals))
2550                 return False;
2551         if(!prs_uint32("day        ", ps, depth, &tod->day))
2552                 return False;
2553         if(!prs_uint32("month      ", ps, depth, &tod->month))
2554                 return False;
2555         if(!prs_uint32("year       ", ps, depth, &tod->year))
2556                 return False;
2557         if(!prs_uint32("weekday    ", ps, depth, &tod->weekday))
2558                 return False;
2559
2560         return True;
2561 }
2562
2563 /*******************************************************************
2564  Inits a TIME_OF_DAY_INFO structure.
2565  ********************************************************************/
2566
2567 void init_time_of_day_info(TIME_OF_DAY_INFO *tod, uint32 elapsedt, uint32 msecs,
2568                            uint32 hours, uint32 mins, uint32 secs, uint32 hunds,
2569                            uint32 zone, uint32 tintervals, uint32 day,
2570                            uint32 month, uint32 year, uint32 weekday)
2571 {
2572         DEBUG(5,("init_time_of_day_info\n"));
2573
2574         tod->elapsedt   = elapsedt;
2575         tod->msecs      = msecs;
2576         tod->hours      = hours;
2577         tod->mins       = mins;
2578         tod->secs       = secs;
2579         tod->hunds      = hunds;
2580         tod->zone       = zone;
2581         tod->tintervals = tintervals;
2582         tod->day        = day;
2583         tod->month      = month;
2584         tod->year       = year;
2585         tod->weekday    = weekday;
2586 }
2587
2588
2589 /*******************************************************************
2590  Reads or writes a structure.
2591  ********************************************************************/
2592
2593 BOOL srv_io_r_net_remote_tod(char *desc, SRV_R_NET_REMOTE_TOD *r_n, prs_struct *ps, int depth)
2594 {
2595         if (r_n == NULL)
2596                 return False;
2597
2598         prs_debug(ps, depth, desc, "srv_io_r_net_remote_tod");
2599         depth++;
2600
2601         if(!prs_align(ps))
2602                 return False;
2603         
2604         if(!prs_uint32("ptr_srv_tod ", ps, depth, &r_n->ptr_srv_tod))
2605                 return False;
2606
2607         if(!srv_io_time_of_day_info("tod", r_n->tod, ps, depth))
2608                 return False;
2609
2610         if(!prs_werror("status", ps, depth, &r_n->status))
2611                 return False;
2612
2613         return True;
2614 }
2615
2616 /*******************************************************************
2617  Reads or writes a structure.
2618  ********************************************************************/
2619
2620 BOOL srv_io_q_net_disk_enum(char *desc, SRV_Q_NET_DISK_ENUM *q_n, prs_struct *ps, int depth)
2621 {
2622         if (q_n == NULL)
2623                 return False;
2624
2625         prs_debug(ps, depth, desc, "srv_io_q_net_disk_enum");
2626         depth++;
2627
2628         if(!prs_align(ps))
2629                 return False;
2630
2631         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
2632                 return False;
2633
2634         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
2635                 return False;
2636
2637         if(!prs_align(ps))
2638                 return False;
2639
2640         if(!prs_uint32("level", ps, depth, &q_n->disk_enum_ctr.level))
2641                 return False;
2642
2643         if(!prs_uint32("entries_read", ps, depth, &q_n->disk_enum_ctr.entries_read))
2644                 return False;
2645
2646         if(!prs_uint32("buffer", ps, depth, &q_n->disk_enum_ctr.disk_info_ptr))
2647                 return False;
2648
2649         if(!prs_align(ps))
2650                 return False;
2651
2652         if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
2653                 return False;
2654         if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
2655                 return False;
2656
2657         return True;
2658 }
2659
2660 /*******************************************************************
2661  Reads or writes a structure.
2662  ********************************************************************/
2663
2664 BOOL srv_io_r_net_disk_enum(char *desc, SRV_R_NET_DISK_ENUM *r_n, prs_struct *ps, int depth)
2665 {
2666         int i;
2667
2668         if (r_n == NULL)
2669                 return False;
2670
2671         prs_debug(ps, depth, desc, "srv_io_r_net_disk_enum");
2672         depth++;
2673
2674         if(!prs_align(ps))
2675                 return False;
2676
2677         if(!prs_uint32("entries_read", ps, depth, &r_n->disk_enum_ctr.entries_read))
2678                 return False;
2679         if(!prs_uint32("ptr_disk_info", ps, depth, &r_n->disk_enum_ctr.disk_info_ptr))
2680                 return False;
2681
2682         /*this may be max, unknown, actual?*/
2683
2684         if(!prs_uint32("max_elements", ps, depth, &r_n->disk_enum_ctr.entries_read))
2685                 return False;
2686         if(!prs_uint32("unknown", ps, depth, &r_n->disk_enum_ctr.unknown))
2687                 return False;
2688         if(!prs_uint32("actual_elements", ps, depth, &r_n->disk_enum_ctr.entries_read))
2689                 return False;
2690
2691         for(i=0; i < r_n->disk_enum_ctr.entries_read; i++) {
2692
2693                 if(!prs_uint32("unknown", ps, depth, &r_n->disk_enum_ctr.disk_info[i].unknown))
2694                         return False;
2695    
2696                 if(!smb_io_unistr3("disk_name", &r_n->disk_enum_ctr.disk_info[i].disk_name, ps, depth))
2697                         return False;
2698
2699                 if(!prs_align(ps))
2700                         return False;
2701         }
2702
2703         if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
2704                 return False;
2705
2706         if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
2707                 return False;
2708
2709         if(!prs_werror("status", ps, depth, &r_n->status))
2710                 return False;
2711
2712         return True;
2713 }
2714
2715 /*******************************************************************
2716  Reads or writes a structure.
2717  ********************************************************************/
2718
2719 BOOL srv_io_q_net_name_validate(char *desc, SRV_Q_NET_NAME_VALIDATE *q_n, prs_struct *ps, int depth)
2720 {
2721         if (q_n == NULL)
2722                 return False;
2723
2724         prs_debug(ps, depth, desc, "srv_io_q_net_name_validate");
2725         depth++;
2726
2727         if(!prs_align(ps))
2728                 return False;
2729
2730         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
2731                 return False;
2732
2733         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
2734                 return False;
2735
2736         if(!prs_align(ps))
2737                 return False;
2738
2739         if(!smb_io_unistr2("", &q_n->uni_name, True, ps, depth))
2740                 return False;
2741
2742         if(!prs_align(ps))
2743                 return False;
2744
2745         if(!prs_uint32("type", ps, depth, &q_n->type))
2746                 return False;
2747
2748         if(!prs_uint32("flags", ps, depth, &q_n->flags))
2749                 return False;
2750
2751         return True;
2752 }
2753
2754 /*******************************************************************
2755  Reads or writes a structure.
2756  ********************************************************************/
2757
2758 BOOL srv_io_r_net_name_validate(char *desc, SRV_R_NET_NAME_VALIDATE *r_n, prs_struct *ps, int depth)
2759 {
2760         if (r_n == NULL)
2761                 return False;
2762
2763         prs_debug(ps, depth, desc, "srv_io_r_net_name_validate");
2764         depth++;
2765
2766         if(!prs_align(ps))
2767                 return False;
2768
2769         if(!prs_werror("status", ps, depth, &r_n->status))
2770                 return False;
2771
2772         return True;
2773 }
2774
2775 /*******************************************************************
2776  Reads or writes a structure.
2777 ********************************************************************/
2778
2779 BOOL srv_io_q_net_file_query_secdesc(char *desc, SRV_Q_NET_FILE_QUERY_SECDESC *q_n, prs_struct *ps, int depth)
2780 {
2781         if (q_n == NULL)
2782                 return False;
2783
2784         prs_debug(ps, depth, desc, "srv_io_q_net_file_query_secdesc");
2785         depth++;
2786
2787         if(!prs_align(ps))
2788                 return False;
2789
2790         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
2791                 return False;
2792
2793         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
2794                 return False;
2795
2796         if(!prs_align(ps))
2797                 return False;
2798
2799         if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
2800                 return False;
2801
2802         if(!smb_io_unistr2("", &q_n->uni_qual_name, True, ps, depth))
2803                 return False;
2804
2805         if(!prs_align(ps))
2806                 return False;
2807
2808         if(!smb_io_unistr2("", &q_n->uni_file_name, True, ps, depth))
2809                 return False;
2810
2811         if(!prs_uint32("unknown1", ps, depth, &q_n->unknown1))
2812                 return False;
2813
2814         if(!prs_uint32("unknown2", ps, depth, &q_n->unknown2))
2815                 return False;
2816
2817         if(!prs_uint32("unknown3", ps, depth, &q_n->unknown3))
2818                 return False;
2819
2820         return True;
2821 }
2822
2823 /*******************************************************************
2824  Reads or writes a structure.
2825 ********************************************************************/
2826
2827 BOOL srv_io_r_net_file_query_secdesc(char *desc, SRV_R_NET_FILE_QUERY_SECDESC *r_n, prs_struct *ps, int depth)
2828 {
2829         if (r_n == NULL)
2830                 return False;
2831
2832         prs_debug(ps, depth, desc, "srv_io_r_net_file_query_secdesc");
2833         depth++;
2834
2835         if(!prs_align(ps))
2836                 return False;
2837
2838         if(!prs_uint32("ptr_response", ps, depth, &r_n->ptr_response))
2839                 return False;
2840
2841         if(!prs_uint32("size_response", ps, depth, &r_n->size_response))
2842                 return False;
2843
2844         if(!prs_uint32("ptr_secdesc", ps, depth, &r_n->ptr_secdesc))
2845                 return False;
2846
2847         if(!prs_uint32("size_secdesc", ps, depth, &r_n->size_secdesc))
2848                 return False;
2849
2850         if(!sec_io_desc("sec_desc", &r_n->sec_desc, ps, depth))
2851                 return False;
2852
2853         if(!prs_align(ps))
2854                 return False;
2855
2856         if(!prs_werror("status", ps, depth, &r_n->status))
2857                 return False;
2858
2859         return True;
2860 }
2861
2862 /*******************************************************************
2863  Reads or writes a structure.
2864 ********************************************************************/
2865
2866 BOOL srv_io_q_net_file_set_secdesc(char *desc, SRV_Q_NET_FILE_SET_SECDESC *q_n, prs_struct *ps, int depth)
2867 {
2868         if (q_n == NULL)
2869                 return False;
2870
2871         prs_debug(ps, depth, desc, "srv_io_q_net_file_set_secdesc");
2872         depth++;
2873
2874         if(!prs_align(ps))
2875                 return False;
2876
2877         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
2878                 return False;
2879
2880         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
2881                 return False;
2882
2883         if(!prs_align(ps))
2884                 return False;
2885
2886         if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
2887                 return False;
2888
2889         if(!smb_io_unistr2("", &q_n->uni_qual_name, True, ps, depth))
2890                 return False;
2891
2892         if(!prs_align(ps))
2893                 return False;
2894
2895         if(!smb_io_unistr2("", &q_n->uni_file_name, True, ps, depth))
2896                 return False;
2897
2898         if(!prs_align(ps))
2899                 return False;
2900
2901         if(!prs_uint32("sec_info", ps, depth, &q_n->sec_info))
2902                 return False;
2903
2904         if(!prs_uint32("size_set", ps, depth, &q_n->size_set))
2905                 return False;
2906
2907         if(!prs_uint32("ptr_secdesc", ps, depth, &q_n->ptr_secdesc))
2908                 return False;
2909
2910         if(!prs_uint32("size_secdesc", ps, depth, &q_n->size_secdesc))
2911                 return False;
2912
2913         if(!sec_io_desc("sec_desc", &q_n->sec_desc, ps, depth))
2914                 return False;
2915
2916         return True;
2917 }
2918
2919 /*******************************************************************
2920  Reads or writes a structure.
2921 ********************************************************************/
2922
2923 BOOL srv_io_r_net_file_set_secdesc(char *desc, SRV_R_NET_FILE_SET_SECDESC *r_n, prs_struct *ps, int depth)
2924 {
2925         if (r_n == NULL)
2926                 return False;
2927
2928         prs_debug(ps, depth, desc, "srv_io_r_net_file_set_secdesc");
2929         depth++;
2930
2931         if(!prs_align(ps))
2932                 return False;
2933
2934         if(!prs_werror("status", ps, depth, &r_n->status))
2935                 return False;
2936
2937         return True;
2938 }
2939
2940 /*******************************************************************
2941  Inits a structure
2942 ********************************************************************/
2943
2944 void init_srv_q_net_remote_tod(SRV_Q_NET_REMOTE_TOD *q_u, char *server)
2945 {
2946         q_u->ptr_srv_name = 1;
2947         init_unistr2(&q_u->uni_srv_name, server, strlen(server) + 1);
2948 }
2949