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