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