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