I know we're supposed to be feature frozen, but I couldn't resist this... :-).
[bbaumbach/samba-autobuild/.git] / source / 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 *sh502,
284                                 char *net_name, char *remark,
285                                 char *path, char *passwd, SEC_DESC *psd, size_t sd_size)
286 {
287         DEBUG(5,("init_srv_share_info502_str\n"));
288
289         init_unistr2(&sh502->uni_netname, net_name, strlen(net_name)+1);
290         init_unistr2(&sh502->uni_remark, remark, strlen(remark)+1);
291         init_unistr2(&sh502->uni_path, path, strlen(path)+1);
292         init_unistr2(&sh502->uni_passwd, passwd, strlen(passwd)+1);
293         sh502->sd = psd;
294         sh502->sd_size = sd_size;
295 }
296
297 /*******************************************************************
298  Reads or writes a structure.
299 ********************************************************************/
300
301 static BOOL srv_io_share_info502_str(char *desc, SH_INFO_502_STR *sh502, prs_struct *ps, int depth)
302 {
303         if (sh502 == NULL)
304                 return False;
305
306         prs_debug(ps, depth, desc, "srv_io_share_info502_str");
307         depth++;
308
309         if(!prs_align(ps))
310                 return False;
311         if(!smb_io_unistr2("", &sh502->uni_netname, True, ps, depth))
312                 return False;
313
314         if(!prs_align(ps))
315                 return False;
316         if(!smb_io_unistr2("", &sh502->uni_remark, True, ps, depth))
317                 return False;
318
319         if(!prs_align(ps))
320                 return False;
321         if(!smb_io_unistr2("", &sh502->uni_path, True, ps, depth))
322                 return False;
323
324         if(!prs_align(ps))
325                 return False;
326         if(!smb_io_unistr2("", &sh502->uni_passwd, True, ps, depth))
327                 return False;
328
329         if(!prs_align(ps))
330                 return False;
331
332         if(!prs_uint32("sd_size   ", ps, depth, &sh502->sd_size))
333                 return False;
334         if (!sec_io_desc(desc, &sh502->sd, ps, depth))
335                 return False;
336
337         return True;
338 }
339
340 /*******************************************************************
341  Reads or writes a structure.
342 ********************************************************************/
343 static BOOL srv_io_share_info1005(char* desc, SRV_SHARE_INFO_1005* sh1005,
344                                   prs_struct* ps, int depth)
345 {
346   if(sh1005 == NULL)
347     return False;
348
349   prs_debug(ps, depth, desc, "srv_io_share_info1005");
350   depth++;
351
352   if(!prs_align(ps))
353     return False;
354
355   if(!prs_uint32("dfs_root_flag", ps, depth, &sh1005->dfs_root_flag))
356     return False;
357
358   return True;
359 }   
360
361 /*******************************************************************
362  Reads or writes a structure.
363 ********************************************************************/
364
365 static BOOL srv_io_srv_share_ctr(char *desc, SRV_SHARE_INFO_CTR *ctr, prs_struct *ps, int depth)
366 {
367         if (ctr == NULL)
368                 return False;
369
370         prs_debug(ps, depth, desc, "srv_io_srv_share_ctr");
371         depth++;
372
373         if (UNMARSHALLING(ps)) {
374                 memset(ctr, '\0', sizeof(SRV_SHARE_INFO_CTR));
375         }
376
377         if(!prs_align(ps))
378                 return False;
379
380         if(!prs_uint32("info_level", ps, depth, &ctr->info_level))
381                 return False;
382
383         if (ctr->info_level == 0)
384                 return True;
385
386         if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
387                 return False;
388         if(!prs_uint32("ptr_share_info", ps, depth, &ctr->ptr_share_info))
389                 return False;
390
391         if (ctr->ptr_share_info == 0)
392                 return True;
393
394         if(!prs_uint32("num_entries", ps, depth, &ctr->num_entries))
395                 return False;
396         if(!prs_uint32("ptr_entries", ps, depth, &ctr->ptr_entries))
397                 return False;
398
399         if (ctr->ptr_entries == 0) {
400                 if (ctr->num_entries == 0)
401                         return True;
402                 else
403                         return False;
404         }
405
406         if(!prs_uint32("num_entries2", ps, depth, &ctr->num_entries2))
407                 return False;
408
409         if (ctr->num_entries2 != ctr->num_entries)
410                 return False;
411
412         switch (ctr->switch_value) {
413         case 1:
414         {
415                 SRV_SHARE_INFO_1 *info1 = ctr->share.info1;
416                 int num_entries = ctr->num_entries;
417                 int i;
418
419                 if (UNMARSHALLING(ps)) {
420                         if (!(info1 = (SRV_SHARE_INFO_1 *)prs_alloc_mem(ps, num_entries * sizeof(SRV_SHARE_INFO_1))))
421                                 return False;
422                         ctr->share.info1 = info1;
423                 }
424
425                 for (i = 0; i < num_entries; i++) {
426                         if(!srv_io_share_info1("", &info1[i].info_1, ps, depth))
427                                 return False;
428                 }
429
430                 for (i = 0; i < num_entries; i++) {
431                         if(!srv_io_share_info1_str("", &info1[i].info_1_str, ps, depth))
432                                 return False;
433                 }
434
435                 break;
436         }
437
438         case 2:
439         {
440                 SRV_SHARE_INFO_2 *info2 = ctr->share.info2;
441                 int num_entries = ctr->num_entries;
442                 int i;
443
444                 if (UNMARSHALLING(ps)) {
445                         if (!(info2 = (SRV_SHARE_INFO_2 *)prs_alloc_mem(ps,num_entries * sizeof(SRV_SHARE_INFO_2))))
446                                 return False;
447                         ctr->share.info2 = info2;
448                 }
449
450                 for (i = 0; i < num_entries; i++) {
451                         if(!srv_io_share_info2("", &info2[i].info_2, ps, depth))
452                                 return False;
453                 }
454
455                 for (i = 0; i < num_entries; i++) {
456                         if(!srv_io_share_info2_str("", &info2[i].info_2_str, ps, depth))
457                                 return False;
458                 }
459
460                 break;
461         }
462
463         case 502:
464         {
465                 SRV_SHARE_INFO_502 *info502 = ctr->share.info502;
466                 int num_entries = ctr->num_entries;
467                 int i;
468
469                 if (UNMARSHALLING(ps)) {
470                         if (!(info502 = (SRV_SHARE_INFO_502 *)prs_alloc_mem(ps,num_entries * sizeof(SRV_SHARE_INFO_502))))
471                                 return False;
472                         ctr->share.info502 = info502;
473                 }
474
475                 for (i = 0; i < num_entries; i++) {
476                         if(!srv_io_share_info502("", &info502[i].info_502, ps, depth))
477                                 return False;
478                 }
479
480                 for (i = 0; i < num_entries; i++) {
481                         if(!srv_io_share_info502_str("", &info502[i].info_502_str, ps, depth))
482                                 return False;
483                 }
484
485                 break;
486         }
487
488         default:
489                 DEBUG(5,("%s no share info at switch_value %d\n",
490                          tab_depth(depth), ctr->switch_value));
491                 break;
492         }
493
494         return True;
495 }
496
497 /*******************************************************************
498  Inits a SRV_Q_NET_SHARE_ENUM structure.
499 ********************************************************************/
500
501 void init_srv_q_net_share_enum(SRV_Q_NET_SHARE_ENUM *q_n, 
502                                 char *srv_name, uint32 info_level,
503                                 uint32 preferred_len, ENUM_HND *hnd)
504 {
505
506         DEBUG(5,("init_q_net_share_enum\n"));
507
508         init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
509
510         q_n->ctr.info_level = q_n->ctr.switch_value = info_level;
511         q_n->ctr.ptr_share_info = 0;
512         q_n->preferred_len = preferred_len;
513
514         memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
515 }
516
517 /*******************************************************************
518  Reads or writes a structure.
519 ********************************************************************/
520
521 BOOL srv_io_q_net_share_enum(char *desc, SRV_Q_NET_SHARE_ENUM *q_n, prs_struct *ps, int depth)
522 {
523         if (q_n == NULL)
524                 return False;
525
526         prs_debug(ps, depth, desc, "srv_io_q_net_share_enum");
527         depth++;
528
529         if(!prs_align(ps))
530                 return False;
531
532         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
533                 return False;
534         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
535                 return False;
536
537         if(!srv_io_srv_share_ctr("share_ctr", &q_n->ctr, ps, depth))
538                 return False;
539
540         if(!prs_align(ps))
541                 return False;
542
543         if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
544                 return False;
545
546         if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
547                 return False;
548
549         return True;
550 }
551
552 /*******************************************************************
553  Reads or writes a structure.
554 ********************************************************************/
555
556 BOOL srv_io_r_net_share_enum(char *desc, SRV_R_NET_SHARE_ENUM *r_n, prs_struct *ps, int depth)
557 {
558         if (r_n == NULL)
559                 return False;
560
561         prs_debug(ps, depth, desc, "srv_io_r_net_share_enum");
562         depth++;
563
564         if(!srv_io_srv_share_ctr("share_ctr", &r_n->ctr, ps, depth))
565                 return False;
566
567         if(!prs_align(ps))
568                 return False;
569
570         if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
571                 return False;
572         if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
573                 return False;
574         if(!prs_uint32("status     ", ps, depth, &r_n->status))
575                 return False;
576
577         return True;
578 }
579
580 /*******************************************************************
581  Reads or writes a structure.
582 ********************************************************************/
583
584 BOOL srv_io_q_net_share_get_info(char *desc, SRV_Q_NET_SHARE_GET_INFO *q_n, prs_struct *ps, int depth)
585 {
586         if (q_n == NULL)
587                 return False;
588
589         prs_debug(ps, depth, desc, "srv_io_q_net_share_get_info");
590         depth++;
591
592         if(!prs_align(ps))
593                 return False;
594
595         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
596                 return False;
597         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
598                 return False;
599
600         if(!smb_io_unistr2("", &q_n->uni_share_name, True, ps, depth))
601                 return False;
602
603         if(!prs_align(ps))
604                 return False;
605
606         if(!prs_uint32("info_level", ps, depth, &q_n->info_level))
607                 return False;
608
609         return True;
610 }
611
612 /*******************************************************************
613  Reads or writes a structure.
614 ********************************************************************/
615
616 static BOOL srv_io_srv_share_info(char *desc, prs_struct *ps, int depth, SRV_SHARE_INFO *r_n)
617 {
618         if (r_n == NULL)
619                 return False;
620
621         prs_debug(ps, depth, desc, "srv_io_srv_share_info");
622         depth++;
623
624         if(!prs_align(ps))
625                 return False;
626
627         if(!prs_uint32("switch_value ", ps, depth, &r_n->switch_value ))
628                 return False;
629
630         if(!prs_uint32("ptr_share_ctr", ps, depth, &r_n->ptr_share_ctr))
631                 return False;
632
633         if (r_n->ptr_share_ctr != 0) {
634                 switch (r_n->switch_value) {
635                 case 1:
636                         if(!srv_io_share_info1("", &r_n->share.info1.info_1, ps, depth))
637                                 return False;
638
639                         if(!srv_io_share_info1_str("", &r_n->share.info1.info_1_str, ps, depth))
640                                 return False;
641
642                         break;
643                 case 2:
644                         if(!srv_io_share_info2("", &r_n->share.info2.info_2, ps, depth))
645                                 return False;
646
647                         if(!srv_io_share_info2_str("", &r_n->share.info2.info_2_str, ps, depth))
648                                 return False;
649
650                         break;
651                 case 502:
652                         if(!srv_io_share_info502("", &r_n->share.info502.info_502, ps, depth))
653                                 return False;
654
655                         if(!srv_io_share_info502_str("", &r_n->share.info502.info_502_str, ps, depth))
656                                 return False;
657                         break;
658                 case 1005:
659                         if(!srv_io_share_info1005("", &r_n->share.info1005, ps, depth))
660                                 return False;           
661                 default:
662                         DEBUG(5,("%s no share info at switch_value %d\n",
663                                  tab_depth(depth), r_n->switch_value));
664                         break;
665                 }
666         }
667
668         return True;
669 }
670
671 /*******************************************************************
672  Reads or writes a structure.
673 ********************************************************************/
674
675 BOOL srv_io_r_net_share_get_info(char *desc, SRV_R_NET_SHARE_GET_INFO *r_n, prs_struct *ps, int depth)
676 {
677         if (r_n == NULL)
678                 return False;
679
680         prs_debug(ps, depth, desc, "srv_io_r_net_share_get_info");
681         depth++;
682
683         if(!prs_align(ps))
684                 return False;
685
686         if(!srv_io_srv_share_info("info  ", ps, depth, &r_n->info))
687                 return False;
688
689         if(!prs_align(ps))
690                 return False;
691
692         if(!prs_uint32("status", ps, depth, &r_n->status))
693                 return False;
694
695         return True;
696 }
697
698 /*******************************************************************
699  Reads or writes a structure.
700 ********************************************************************/
701
702 BOOL srv_io_q_net_share_set_info(char *desc, SRV_Q_NET_SHARE_SET_INFO *q_n, prs_struct *ps, int depth)
703 {
704         if (q_n == NULL)
705                 return False;
706
707         prs_debug(ps, depth, desc, "srv_io_q_net_share_set_info");
708         depth++;
709
710         if(!prs_align(ps))
711                 return False;
712
713         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
714                 return False;
715         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
716                 return False;
717
718         if(!smb_io_unistr2("", &q_n->uni_share_name, True, ps, depth))
719                 return False;
720
721         if(!prs_align(ps))
722                 return False;
723
724         if(!prs_uint32("info_level", ps, depth, &q_n->info_level))
725                 return False;
726
727         if(!prs_align(ps))
728                 return False;
729
730         if(!srv_io_srv_share_info("info  ", ps, depth, &q_n->info))
731                 return False;
732
733         return True;
734 }
735
736 /*******************************************************************
737  Reads or writes a structure.
738 ********************************************************************/
739
740 BOOL srv_io_r_net_share_set_info(char *desc, SRV_R_NET_SHARE_SET_INFO *q_n, prs_struct *ps, int depth)
741 {
742         if (q_n == NULL)
743                 return False;
744
745         prs_debug(ps, depth, desc, "srv_io_r_net_share_set_info");
746         depth++;
747
748         if(!prs_align(ps))
749                 return False;
750
751         if(!prs_uint32("switch_value  ", ps, depth, &q_n->switch_value))
752                 return False;
753         if(!prs_uint32("status        ", ps, depth, &q_n->status))
754                 return False;
755
756         return True;
757 }       
758
759 /*******************************************************************
760  Inits a SESS_INFO_0_STR structure
761 ********************************************************************/
762
763 void init_srv_sess_info0_str(SESS_INFO_0_STR *ss0, char *name)
764 {
765         DEBUG(5,("init_srv_sess_info0_str\n"));
766
767         init_unistr2(&ss0->uni_name, name, strlen(name)+1);
768 }
769
770 /*******************************************************************
771  Reads or writes a structure.
772 ********************************************************************/
773
774 static BOOL srv_io_sess_info0_str(char *desc,  SESS_INFO_0_STR *ss0, prs_struct *ps, int depth)
775 {
776         if (ss0 == NULL)
777                 return False;
778
779         prs_debug(ps, depth, desc, "srv_io_sess_info0_str");
780         depth++;
781
782         if(!prs_align(ps))
783                 return False;
784
785         if(!smb_io_unistr2("", &ss0->uni_name, True, ps, depth))
786                 return False;
787
788         return True;
789 }
790
791 /*******************************************************************
792  Inits a SESS_INFO_0 structure
793 ********************************************************************/
794
795 void init_srv_sess_info0(SESS_INFO_0 *ss0, char *name)
796 {
797         DEBUG(5,("init_srv_sess_info0: %s\n", name));
798
799         ss0->ptr_name = (name != NULL) ? 1 : 0;
800 }
801
802 /*******************************************************************
803  Reads or writes a structure.
804 ********************************************************************/
805
806 static BOOL srv_io_sess_info0(char *desc, SESS_INFO_0 *ss0, prs_struct *ps, int depth)
807 {
808         if (ss0 == NULL)
809                 return False;
810
811         prs_debug(ps, depth, desc, "srv_io_sess_info0");
812         depth++;
813
814         if(!prs_align(ps))
815                 return False;
816
817         if(!prs_uint32("ptr_name", ps, depth, &ss0->ptr_name))
818                 return False;
819
820         return True;
821 }
822
823 /*******************************************************************
824  Reads or writes a structure.
825 ********************************************************************/
826
827 static BOOL srv_io_srv_sess_info_0(char *desc, SRV_SESS_INFO_0 *ss0, prs_struct *ps, int depth)
828 {
829         if (ss0 == NULL)
830                 return False;
831
832         prs_debug(ps, depth, desc, "srv_io_srv_sess_info_0");
833         depth++;
834
835         if(!prs_align(ps))
836                 return False;
837
838         if(!prs_uint32("num_entries_read", ps, depth, &ss0->num_entries_read))
839                 return False;
840         if(!prs_uint32("ptr_sess_info", ps, depth, &ss0->ptr_sess_info))
841                 return False;
842
843         if (ss0->ptr_sess_info != 0) {
844                 int i;
845                 int num_entries = ss0->num_entries_read;
846
847                 if (num_entries > MAX_SESS_ENTRIES) {
848                         num_entries = MAX_SESS_ENTRIES; /* report this! */
849                 }
850
851                 if(!prs_uint32("num_entries_read2", ps, depth, &ss0->num_entries_read2))
852                         return False;
853
854                 SMB_ASSERT_ARRAY(ss0->info_0, num_entries);
855
856                 for (i = 0; i < num_entries; i++) {
857                         if(!srv_io_sess_info0("", &ss0->info_0[i], ps, depth))
858                                 return False;
859                 }
860
861                 for (i = 0; i < num_entries; i++) {
862                         if(!srv_io_sess_info0_str("", &ss0->info_0_str[i], ps, depth))
863                                 return False;
864                 }
865
866                 if(!prs_align(ps))
867                         return False;
868         }
869
870         return True;
871 }
872
873 /*******************************************************************
874  Inits a SESS_INFO_1_STR structure
875 ********************************************************************/
876
877 void init_srv_sess_info1_str(SESS_INFO_1_STR *ss1, char *name, char *user)
878 {
879         DEBUG(5,("init_srv_sess_info1_str\n"));
880
881         init_unistr2(&ss1->uni_name, name, strlen(name)+1);
882         init_unistr2(&ss1->uni_user, name, strlen(user)+1);
883 }
884
885 /*******************************************************************
886  Reads or writes a structure.
887 ********************************************************************/
888
889 static BOOL srv_io_sess_info1_str(char *desc, SESS_INFO_1_STR *ss1, prs_struct *ps, int depth)
890 {
891         if (ss1 == NULL)
892                 return False;
893
894         prs_debug(ps, depth, desc, "srv_io_sess_info1_str");
895         depth++;
896
897         if(!prs_align(ps))
898                 return False;
899
900         if(!smb_io_unistr2("", &ss1->uni_name, True, ps, depth))
901                 return False;
902         if(!smb_io_unistr2("", &(ss1->uni_user), True, ps, depth))
903                 return False;
904
905         return True;
906 }
907
908 /*******************************************************************
909  Inits a SESS_INFO_1 structure
910 ********************************************************************/
911
912 void init_srv_sess_info1(SESS_INFO_1 *ss1, 
913                                 char *name, char *user,
914                                 uint32 num_opens, uint32 open_time, uint32 idle_time,
915                                 uint32 user_flags)
916 {
917         DEBUG(5,("init_srv_sess_info1: %s\n", name));
918
919         ss1->ptr_name = (name != NULL) ? 1 : 0;
920         ss1->ptr_user = (user != NULL) ? 1 : 0;
921
922         ss1->num_opens  = num_opens;
923         ss1->open_time  = open_time;
924         ss1->idle_time  = idle_time;
925         ss1->user_flags = user_flags;
926 }
927
928 /*******************************************************************
929 reads or writes a structure.
930 ********************************************************************/
931
932 static BOOL srv_io_sess_info1(char *desc, SESS_INFO_1 *ss1, prs_struct *ps, int depth)
933 {
934         if (ss1 == NULL)
935                 return False;
936
937         prs_debug(ps, depth, desc, "srv_io_sess_info1");
938         depth++;
939
940         if(!prs_align(ps))
941                 return False;
942
943         if(!prs_uint32("ptr_name  ", ps, depth, &ss1->ptr_name))
944                 return False;
945         if(!prs_uint32("ptr_user  ", ps, depth, &ss1->ptr_user))
946                 return False;
947
948         if(!prs_uint32("num_opens ", ps, depth, &ss1->num_opens))
949                 return False;
950         if(!prs_uint32("open_time ", ps, depth, &ss1->open_time))
951                 return False;
952         if(!prs_uint32("idle_time ", ps, depth, &ss1->idle_time))
953                 return False;
954         if(!prs_uint32("user_flags", ps, depth, &ss1->user_flags))
955                 return False;
956
957         return True;
958 }
959
960 /*******************************************************************
961  Reads or writes a structure.
962 ********************************************************************/
963
964 static BOOL srv_io_srv_sess_info_1(char *desc, SRV_SESS_INFO_1 *ss1, prs_struct *ps, int depth)
965 {
966         if (ss1 == NULL)
967                 return False;
968
969         prs_debug(ps, depth, desc, "srv_io_srv_sess_info_1");
970         depth++;
971
972         if(!prs_align(ps))
973                 return False;
974
975         if(!prs_uint32("num_entries_read", ps, depth, &ss1->num_entries_read))
976                 return False;
977         if(!prs_uint32("ptr_sess_info", ps, depth, &ss1->ptr_sess_info))
978                 return False;
979
980         if (ss1->ptr_sess_info != 0) {
981                 int i;
982                 int num_entries = ss1->num_entries_read;
983
984                 if (num_entries > MAX_SESS_ENTRIES) {
985                         num_entries = MAX_SESS_ENTRIES; /* report this! */
986                 }
987
988                 if(!prs_uint32("num_entries_read2", ps, depth, &ss1->num_entries_read2))
989                         return False;
990
991                 SMB_ASSERT_ARRAY(ss1->info_1, num_entries);
992
993                 for (i = 0; i < num_entries; i++) {
994                         if(!srv_io_sess_info1("", &ss1->info_1[i], ps, depth))
995                                 return False;
996                 }
997
998                 for (i = 0; i < num_entries; i++) {
999                         if(!srv_io_sess_info1_str("", &ss1->info_1_str[i], ps, depth))
1000                                 return False;
1001                 }
1002
1003                 if(!prs_align(ps))
1004                         return False;
1005         }
1006
1007         return True;
1008 }
1009
1010 /*******************************************************************
1011  Reads or writes a structure.
1012 ********************************************************************/
1013
1014 static BOOL srv_io_srv_sess_ctr(char *desc, SRV_SESS_INFO_CTR **pp_ctr, prs_struct *ps, int depth)
1015 {
1016         SRV_SESS_INFO_CTR *ctr = *pp_ctr;
1017
1018         prs_debug(ps, depth, desc, "srv_io_srv_sess_ctr");
1019         depth++;
1020
1021         if(UNMARSHALLING(ps)) {
1022                 ctr = *pp_ctr = (SRV_SESS_INFO_CTR *)prs_alloc_mem(ps, sizeof(SRV_SESS_INFO_CTR));
1023                 if (ctr == NULL)
1024                         return False;
1025         }
1026
1027         if (ctr == NULL)
1028                 return False;
1029
1030         if(!prs_align(ps))
1031                 return False;
1032
1033         if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
1034                 return False;
1035         if(!prs_uint32("ptr_sess_ctr", ps, depth, &ctr->ptr_sess_ctr))
1036                 return False;
1037
1038         if (ctr->ptr_sess_ctr != 0) {
1039                 switch (ctr->switch_value) {
1040                 case 0:
1041                         if(!srv_io_srv_sess_info_0("", &ctr->sess.info0, ps, depth))
1042                                 return False;
1043                         break;
1044                 case 1:
1045                         if(!srv_io_srv_sess_info_1("", &ctr->sess.info1, ps, depth))
1046                                 return False;
1047                         break;
1048                 default:
1049                         DEBUG(5,("%s no session info at switch_value %d\n",
1050                                  tab_depth(depth), ctr->switch_value));
1051                         break;
1052                 }
1053         }
1054
1055         return True;
1056 }
1057
1058 /*******************************************************************
1059  Inits a SRV_Q_NET_SESS_ENUM structure.
1060 ********************************************************************/
1061
1062 void init_srv_q_net_sess_enum(SRV_Q_NET_SESS_ENUM *q_n, 
1063                                 char *srv_name, char *qual_name,
1064                                 uint32 sess_level, SRV_SESS_INFO_CTR *ctr,
1065                                 uint32 preferred_len,
1066                                 ENUM_HND *hnd)
1067 {
1068         q_n->ctr = ctr;
1069
1070         DEBUG(5,("init_q_net_sess_enum\n"));
1071
1072         init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
1073         init_buf_unistr2(&q_n->uni_qual_name, &q_n->ptr_qual_name, qual_name);
1074
1075         q_n->sess_level    = sess_level;
1076         q_n->preferred_len = preferred_len;
1077
1078         memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
1079 }
1080
1081 /*******************************************************************
1082  Reads or writes a structure.
1083 ********************************************************************/
1084
1085 BOOL srv_io_q_net_sess_enum(char *desc, SRV_Q_NET_SESS_ENUM *q_n, prs_struct *ps, int depth)
1086 {
1087         if (q_n == NULL)
1088                 return False;
1089
1090         prs_debug(ps, depth, desc, "srv_io_q_net_sess_enum");
1091         depth++;
1092
1093         if(!prs_align(ps))
1094                 return False;
1095
1096         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
1097                 return False;
1098         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1099                 return False;
1100
1101         if(!prs_align(ps))
1102                 return False;
1103
1104         if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
1105                 return False;
1106         if(!smb_io_unistr2("", &q_n->uni_qual_name, q_n->ptr_qual_name, ps, depth))
1107                 return False;
1108
1109         if(!prs_align(ps))
1110                 return False;
1111
1112         if(!prs_uint32("sess_level", ps, depth, &q_n->sess_level))
1113                 return False;
1114         
1115         if (q_n->sess_level != -1) {
1116                 if(!srv_io_srv_sess_ctr("sess_ctr", &q_n->ctr, ps, depth))
1117                         return False;
1118         }
1119
1120         if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
1121                 return False;
1122
1123         if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
1124                 return False;
1125
1126         return True;
1127 }
1128
1129 /*******************************************************************
1130  Reads or writes a structure.
1131 ********************************************************************/
1132
1133 BOOL srv_io_r_net_sess_enum(char *desc, SRV_R_NET_SESS_ENUM *r_n, prs_struct *ps, int depth)
1134 {
1135         if (r_n == NULL)
1136                 return False;
1137
1138         prs_debug(ps, depth, desc, "srv_io_r_net_sess_enum");
1139         depth++;
1140
1141         if(!prs_align(ps))
1142                 return False;
1143
1144         if(!prs_uint32("sess_level", ps, depth, &r_n->sess_level))
1145                 return False;
1146
1147         if (r_n->sess_level != -1) {
1148                 if(!srv_io_srv_sess_ctr("sess_ctr", &r_n->ctr, ps, depth))
1149                         return False;
1150         }
1151
1152         if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
1153                 return False;
1154         if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
1155                 return False;
1156         if(!prs_uint32("status     ", ps, depth, &r_n->status))
1157                 return False;
1158
1159         return True;
1160 }
1161
1162 /*******************************************************************
1163  Inits a CONN_INFO_0 structure
1164 ********************************************************************/
1165
1166 void init_srv_conn_info0(CONN_INFO_0 *ss0, uint32 id)
1167 {
1168         DEBUG(5,("init_srv_conn_info0\n"));
1169
1170         ss0->id = id;
1171 }
1172
1173 /*******************************************************************
1174  Reads or writes a structure.
1175 ********************************************************************/
1176
1177 static BOOL srv_io_conn_info0(char *desc, CONN_INFO_0 *ss0, prs_struct *ps, int depth)
1178 {
1179         if (ss0 == NULL)
1180                 return False;
1181
1182         prs_debug(ps, depth, desc, "srv_io_conn_info0");
1183         depth++;
1184
1185         if(!prs_align(ps))
1186                 return False;
1187
1188         if(!prs_uint32("id", ps, depth, &ss0->id))
1189                 return False;
1190
1191         return True;
1192 }
1193
1194 /*******************************************************************
1195  Reads or writes a structure.
1196 ********************************************************************/
1197
1198 static BOOL srv_io_srv_conn_info_0(char *desc, SRV_CONN_INFO_0 *ss0, prs_struct *ps, int depth)
1199 {
1200         if (ss0 == NULL)
1201                 return False;
1202
1203         prs_debug(ps, depth, desc, "srv_io_srv_conn_info_0");
1204         depth++;
1205
1206         if(!prs_align(ps))
1207                 return False;
1208
1209         if(!prs_uint32("num_entries_read", ps, depth, &ss0->num_entries_read))
1210                 return False;
1211         if(!prs_uint32("ptr_conn_info", ps, depth, &ss0->ptr_conn_info))
1212                 return False;
1213
1214         if (ss0->ptr_conn_info != 0) {
1215                 int i;
1216                 int num_entries = ss0->num_entries_read;
1217
1218                 if (num_entries > MAX_CONN_ENTRIES) {
1219                         num_entries = MAX_CONN_ENTRIES; /* report this! */
1220                 }
1221
1222                 if(!prs_uint32("num_entries_read2", ps, depth, &ss0->num_entries_read2))
1223                         return False;
1224
1225                 for (i = 0; i < num_entries; i++) {
1226                         if(!srv_io_conn_info0("", &ss0->info_0[i], ps, depth))
1227                                 return False;
1228                 }
1229
1230                 if(!prs_align(ps))
1231                         return False;
1232         }
1233
1234         return True;
1235 }
1236
1237 /*******************************************************************
1238  Inits a CONN_INFO_1_STR structure
1239 ********************************************************************/
1240
1241 void init_srv_conn_info1_str(CONN_INFO_1_STR *ss1, char *usr_name, char *net_name)
1242 {
1243         DEBUG(5,("init_srv_conn_info1_str\n"));
1244
1245         init_unistr2(&ss1->uni_usr_name, usr_name, strlen(usr_name)+1);
1246         init_unistr2(&ss1->uni_net_name, net_name, strlen(net_name)+1);
1247 }
1248
1249 /*******************************************************************
1250  Reads or writes a structure.
1251 ********************************************************************/
1252
1253 static BOOL srv_io_conn_info1_str(char *desc, CONN_INFO_1_STR *ss1, prs_struct *ps, int depth)
1254 {
1255         if (ss1 == NULL)
1256                 return False;
1257
1258         prs_debug(ps, depth, desc, "srv_io_conn_info1_str");
1259         depth++;
1260
1261         if(!prs_align(ps))
1262                 return False;
1263
1264         if(!smb_io_unistr2("", &ss1->uni_usr_name, True, ps, depth))
1265                 return False;
1266         if(!smb_io_unistr2("", &ss1->uni_net_name, True, ps, depth))
1267                 return False;
1268
1269         return True;
1270 }
1271
1272 /*******************************************************************
1273  Inits a CONN_INFO_1 structure
1274 ********************************************************************/
1275
1276 void init_srv_conn_info1(CONN_INFO_1 *ss1, 
1277                                 uint32 id, uint32 type,
1278                                 uint32 num_opens, uint32 num_users, uint32 open_time,
1279                                 char *usr_name, char *net_name)
1280 {
1281         DEBUG(5,("init_srv_conn_info1: %s %s\n", usr_name, net_name));
1282
1283         ss1->id        = id       ;
1284         ss1->type      = type     ;
1285         ss1->num_opens = num_opens ;
1286         ss1->num_users = num_users;
1287         ss1->open_time = open_time;
1288
1289         ss1->ptr_usr_name = (usr_name != NULL) ? 1 : 0;
1290         ss1->ptr_net_name = (net_name != NULL) ? 1 : 0;
1291 }
1292
1293 /*******************************************************************
1294  Reads or writes a structure.
1295 ********************************************************************/
1296
1297 static BOOL srv_io_conn_info1(char *desc, CONN_INFO_1 *ss1, prs_struct *ps, int depth)
1298 {
1299         if (ss1 == NULL)
1300                 return False;
1301
1302         prs_debug(ps, depth, desc, "srv_io_conn_info1");
1303         depth++;
1304
1305         if(!prs_align(ps))
1306                 return False;
1307
1308         if(!prs_uint32("id          ", ps, depth, &ss1->id))
1309                 return False;
1310         if(!prs_uint32("type        ", ps, depth, &ss1->type))
1311                 return False;
1312         if(!prs_uint32("num_opens   ", ps, depth, &ss1->num_opens))
1313                 return False;
1314         if(!prs_uint32("num_users   ", ps, depth, &ss1->num_users))
1315                 return False;
1316         if(!prs_uint32("open_time   ", ps, depth, &ss1->open_time))
1317                 return False;
1318
1319         if(!prs_uint32("ptr_usr_name", ps, depth, &ss1->ptr_usr_name))
1320                 return False;
1321         if(!prs_uint32("ptr_net_name", ps, depth, &ss1->ptr_net_name))
1322                 return False;
1323
1324         return True;
1325 }
1326
1327 /*******************************************************************
1328  Reads or writes a structure.
1329 ********************************************************************/
1330
1331 static BOOL srv_io_srv_conn_info_1(char *desc, SRV_CONN_INFO_1 *ss1, prs_struct *ps, int depth)
1332 {
1333         if (ss1 == NULL)
1334                 return False;
1335
1336         prs_debug(ps, depth, desc, "srv_io_srv_conn_info_1");
1337         depth++;
1338
1339         if(!prs_align(ps))
1340                 return False;
1341
1342         if(!prs_uint32("num_entries_read", ps, depth, &ss1->num_entries_read))
1343                 return False;
1344         if(!prs_uint32("ptr_conn_info", ps, depth, &ss1->ptr_conn_info))
1345                 return False;
1346
1347         if (ss1->ptr_conn_info != 0) {
1348                 int i;
1349                 int num_entries = ss1->num_entries_read;
1350
1351                 if (num_entries > MAX_CONN_ENTRIES) {
1352                         num_entries = MAX_CONN_ENTRIES; /* report this! */
1353                 }
1354
1355                 if(!prs_uint32("num_entries_read2", ps, depth, &ss1->num_entries_read2))
1356                         return False;
1357
1358                 for (i = 0; i < num_entries; i++) {
1359                         if(!srv_io_conn_info1("", &ss1->info_1[i], ps, depth))
1360                                 return False;
1361                 }
1362
1363                 for (i = 0; i < num_entries; i++) {
1364                         if(!srv_io_conn_info1_str("", &ss1->info_1_str[i], ps, depth))
1365                                 return False;
1366                 }
1367
1368                 if(!prs_align(ps))
1369                         return False;
1370         }
1371
1372         return True;
1373 }
1374
1375 /*******************************************************************
1376  Reads or writes a structure.
1377 ********************************************************************/
1378
1379 static BOOL srv_io_srv_conn_ctr(char *desc, SRV_CONN_INFO_CTR **pp_ctr, prs_struct *ps, int depth)
1380 {
1381         SRV_CONN_INFO_CTR *ctr = *pp_ctr;
1382
1383         prs_debug(ps, depth, desc, "srv_io_srv_conn_ctr");
1384         depth++;
1385
1386         if (UNMARSHALLING(ps)) {
1387                 ctr = *pp_ctr = (SRV_CONN_INFO_CTR *)prs_alloc_mem(ps, sizeof(SRV_CONN_INFO_CTR));
1388                 if (ctr == NULL)
1389                         return False;
1390         }
1391                 
1392         if (ctr == NULL)
1393                 return False;
1394
1395         if(!prs_align(ps))
1396                 return False;
1397
1398         if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
1399                 return False;
1400         if(!prs_uint32("ptr_conn_ctr", ps, depth, &ctr->ptr_conn_ctr))
1401                 return False;
1402
1403         if (ctr->ptr_conn_ctr != 0) {
1404                 switch (ctr->switch_value) {
1405                 case 0:
1406                         if(!srv_io_srv_conn_info_0("", &ctr->conn.info0, ps, depth))
1407                                 return False;
1408                         break;
1409                 case 1:
1410                         if(!srv_io_srv_conn_info_1("", &ctr->conn.info1, ps, depth))
1411                                 return False;
1412                         break;
1413                 default:
1414                         DEBUG(5,("%s no connection info at switch_value %d\n",
1415                                  tab_depth(depth), ctr->switch_value));
1416                         break;
1417                 }
1418         }
1419
1420         return True;
1421 }
1422
1423 /*******************************************************************
1424   Reads or writes a structure.
1425 ********************************************************************/
1426
1427 void init_srv_q_net_conn_enum(SRV_Q_NET_CONN_ENUM *q_n, 
1428                                 char *srv_name, char *qual_name,
1429                                 uint32 conn_level, SRV_CONN_INFO_CTR *ctr,
1430                                 uint32 preferred_len,
1431                                 ENUM_HND *hnd)
1432 {
1433         DEBUG(5,("init_q_net_conn_enum\n"));
1434
1435         q_n->ctr = ctr;
1436
1437         init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name );
1438         init_buf_unistr2(&q_n->uni_qual_name, &q_n->ptr_qual_name, qual_name);
1439
1440         q_n->conn_level    = conn_level;
1441         q_n->preferred_len = preferred_len;
1442
1443         memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
1444 }
1445
1446 /*******************************************************************
1447  Reads or writes a structure.
1448 ********************************************************************/
1449
1450 BOOL srv_io_q_net_conn_enum(char *desc, SRV_Q_NET_CONN_ENUM *q_n, prs_struct *ps, int depth)
1451 {
1452         if (q_n == NULL)
1453                 return False;
1454
1455         prs_debug(ps, depth, desc, "srv_io_q_net_conn_enum");
1456         depth++;
1457
1458         if(!prs_align(ps))
1459                 return False;
1460
1461         if(!prs_uint32("ptr_srv_name ", ps, depth, &q_n->ptr_srv_name))
1462                 return False;
1463         if(!smb_io_unistr2("", &q_n->uni_srv_name, q_n->ptr_srv_name, ps, depth))
1464                 return False;
1465
1466         if(!prs_align(ps))
1467                 return False;
1468
1469         if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
1470                 return False;
1471         if(!smb_io_unistr2("", &q_n->uni_qual_name, q_n->ptr_qual_name, ps, depth))
1472                 return False;
1473
1474         if(!prs_align(ps))
1475                 return False;
1476
1477         if(!prs_uint32("conn_level", ps, depth, &q_n->conn_level))
1478                 return False;
1479         
1480         if (q_n->conn_level != -1) {
1481                 if(!srv_io_srv_conn_ctr("conn_ctr", &q_n->ctr, ps, depth))
1482                         return False;
1483         }
1484
1485         if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
1486                 return False;
1487
1488         if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
1489                 return False;
1490
1491         return True;
1492 }
1493
1494 /*******************************************************************
1495  Reads or writes a structure.
1496 ********************************************************************/
1497
1498 BOOL srv_io_r_net_conn_enum(char *desc,  SRV_R_NET_CONN_ENUM *r_n, prs_struct *ps, int depth)
1499 {
1500         if (r_n == NULL)
1501                 return False;
1502
1503         prs_debug(ps, depth, desc, "srv_io_r_net_conn_enum");
1504         depth++;
1505
1506         if(!prs_align(ps))
1507                 return False;
1508
1509         if(!prs_uint32("conn_level", ps, depth, &r_n->conn_level))
1510                 return False;
1511
1512         if (r_n->conn_level != -1) {
1513                 if(!srv_io_srv_conn_ctr("conn_ctr", &r_n->ctr, ps, depth))
1514                         return False;
1515         }
1516
1517         if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
1518                 return False;
1519         if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
1520                 return False;
1521         if(!prs_uint32("status     ", ps, depth, &r_n->status))
1522                 return False;
1523
1524         return True;
1525 }
1526
1527 /*******************************************************************
1528  Inits a FILE_INFO_3_STR structure
1529 ********************************************************************/
1530
1531 void init_srv_file_info3_str(FILE_INFO_3_STR *fi3, char *user_name, char *path_name)
1532 {
1533         DEBUG(5,("init_srv_file_info3_str\n"));
1534
1535         init_unistr2(&fi3->uni_path_name, path_name, strlen(path_name)+1);
1536         init_unistr2(&fi3->uni_user_name, user_name, strlen(user_name)+1);
1537 }
1538
1539 /*******************************************************************
1540  Reads or writes a structure.
1541 ********************************************************************/
1542
1543 static BOOL srv_io_file_info3_str(char *desc, FILE_INFO_3_STR *sh1, prs_struct *ps, int depth)
1544 {
1545         if (sh1 == NULL)
1546                 return False;
1547
1548         prs_debug(ps, depth, desc, "srv_io_file_info3_str");
1549         depth++;
1550
1551         if(!prs_align(ps))
1552                 return False;
1553
1554         if(!smb_io_unistr2("", &sh1->uni_path_name, True, ps, depth))
1555                 return False;
1556         if(!smb_io_unistr2("", &sh1->uni_user_name, True, ps, depth))
1557                 return False;
1558
1559         return True;
1560 }
1561
1562 /*******************************************************************
1563  Inits a FILE_INFO_3 structure
1564 ********************************************************************/
1565
1566 void init_srv_file_info3(FILE_INFO_3 *fl3,
1567                                 uint32 id, uint32 perms, uint32 num_locks,
1568                                 char *path_name, char *user_name)
1569 {
1570         DEBUG(5,("init_srv_file_info3: %s %s\n", path_name, user_name));
1571
1572         fl3->id        = id;    
1573         fl3->perms     = perms;
1574         fl3->num_locks = num_locks;
1575
1576         fl3->ptr_path_name = (path_name != NULL) ? 1 : 0;
1577         fl3->ptr_user_name = (user_name != NULL) ? 1 : 0;
1578 }
1579
1580 /*******************************************************************
1581  Reads or writes a structure.
1582 ********************************************************************/
1583
1584 static BOOL srv_io_file_info3(char *desc, FILE_INFO_3 *fl3, prs_struct *ps, int depth)
1585 {
1586         if (fl3 == NULL)
1587                 return False;
1588
1589         prs_debug(ps, depth, desc, "srv_io_file_info3");
1590         depth++;
1591
1592         if(!prs_align(ps))
1593                 return False;
1594
1595         if(!prs_uint32("id           ", ps, depth, &fl3->id))
1596                 return False;
1597         if(!prs_uint32("perms        ", ps, depth, &fl3->perms))
1598                 return False;
1599         if(!prs_uint32("num_locks    ", ps, depth, &fl3->num_locks))
1600                 return False;
1601         if(!prs_uint32("ptr_path_name", ps, depth, &fl3->ptr_path_name))
1602                 return False;
1603         if(!prs_uint32("ptr_user_name", ps, depth, &fl3->ptr_user_name))
1604                 return False;
1605
1606         return True;
1607 }
1608
1609 /*******************************************************************
1610  Reads or writes a structure.
1611 ********************************************************************/
1612
1613 static BOOL srv_io_srv_file_info_3(char *desc, SRV_FILE_INFO_3 *fl3, prs_struct *ps, int depth)
1614 {
1615         if (fl3 == NULL)
1616                 return False;
1617
1618         prs_debug(ps, depth, desc, "srv_io_file_3_fl3");
1619         depth++;
1620
1621         if(!prs_align(ps))
1622                 return False;
1623
1624         if(!prs_uint32("num_entries_read", ps, depth, &fl3->num_entries_read))
1625                 return False;
1626         if(!prs_uint32("ptr_file_fl3", ps, depth, &fl3->ptr_file_info))
1627                 return False;
1628
1629         if (fl3->ptr_file_info != 0) {
1630                 int i;
1631                 int num_entries = fl3->num_entries_read;
1632
1633                 if (num_entries > MAX_FILE_ENTRIES) {
1634                         num_entries = MAX_FILE_ENTRIES; /* report this! */
1635                 }
1636
1637                 if(!prs_uint32("num_entries_read2", ps, depth, &fl3->num_entries_read2))
1638                         return False;
1639
1640                 for (i = 0; i < num_entries; i++) {
1641                         if(!srv_io_file_info3("", &fl3->info_3[i], ps, depth))
1642                                 return False;
1643                 }
1644
1645                 for (i = 0; i < num_entries; i++) {
1646                         if(!srv_io_file_info3_str("", &fl3->info_3_str[i], ps, depth))
1647                                 return False;
1648                 }
1649
1650                 if(!prs_align(ps))
1651                         return False;
1652         }
1653
1654         return True;
1655 }
1656
1657 /*******************************************************************
1658  Reads or writes a structure.
1659 ********************************************************************/
1660
1661 static BOOL srv_io_srv_file_ctr(char *desc, SRV_FILE_INFO_CTR **pp_ctr, prs_struct *ps, int depth)
1662 {
1663         SRV_FILE_INFO_CTR *ctr = *pp_ctr;
1664
1665         if (UNMARSHALLING(ps)) {
1666                 ctr = *pp_ctr = (SRV_FILE_INFO_CTR *)prs_alloc_mem(ps, sizeof(SRV_FILE_INFO_CTR));
1667                 if (ctr == NULL)
1668                         return False;
1669         }
1670
1671         if (ctr == NULL)
1672                 return False;
1673
1674         prs_debug(ps, depth, desc, "srv_io_srv_file_ctr");
1675         depth++;
1676
1677         if(!prs_align(ps))
1678                 return False;
1679
1680         if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
1681                 return False;
1682         if(!prs_uint32("ptr_file_ctr", ps, depth, &ctr->ptr_file_ctr))
1683                 return False;
1684
1685         if (ctr->ptr_file_ctr != 0) {
1686                 switch (ctr->switch_value) {
1687                 case 3:
1688                         if(!srv_io_srv_file_info_3("", &ctr->file.info3, ps, depth))
1689                                 return False;
1690                         break;
1691                 default:
1692                         DEBUG(5,("%s no file info at switch_value %d\n",
1693                                  tab_depth(depth), ctr->switch_value));
1694                         break;
1695                 }
1696         }
1697
1698         return True;
1699 }
1700
1701 /*******************************************************************
1702  Inits a SRV_Q_NET_FILE_ENUM structure.
1703 ********************************************************************/
1704
1705 void init_srv_q_net_file_enum(SRV_Q_NET_FILE_ENUM *q_n, 
1706                                 char *srv_name, char *qual_name,
1707                                 uint32 file_level, SRV_FILE_INFO_CTR *ctr,
1708                                 uint32 preferred_len,
1709                                 ENUM_HND *hnd)
1710 {
1711         DEBUG(5,("init_q_net_file_enum\n"));
1712
1713         q_n->ctr = ctr;
1714
1715         init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
1716         init_buf_unistr2(&q_n->uni_qual_name, &q_n->ptr_qual_name, qual_name);
1717
1718         q_n->file_level    = file_level;
1719         q_n->preferred_len = preferred_len;
1720
1721         memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
1722 }
1723
1724 /*******************************************************************
1725  Reads or writes a structure.
1726 ********************************************************************/
1727
1728 BOOL srv_io_q_net_file_enum(char *desc, SRV_Q_NET_FILE_ENUM *q_n, prs_struct *ps, int depth)
1729 {
1730         if (q_n == NULL)
1731                 return False;
1732
1733         prs_debug(ps, depth, desc, "srv_io_q_net_file_enum");
1734         depth++;
1735
1736         if(!prs_align(ps))
1737                 return False;
1738
1739         if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
1740                 return False;
1741         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1742                 return False;
1743
1744         if(!prs_align(ps))
1745                 return False;
1746
1747         if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
1748                 return False;
1749         if(!smb_io_unistr2("", &q_n->uni_qual_name, q_n->ptr_qual_name, ps, depth))
1750                 return False;
1751
1752         if(!prs_align(ps))
1753                 return False;
1754
1755         if(!prs_uint32("file_level", ps, depth, &q_n->file_level))
1756                 return False;
1757
1758         if (q_n->file_level != -1) {
1759                 if(!srv_io_srv_file_ctr("file_ctr", &q_n->ctr, ps, depth))
1760                         return False;
1761         }
1762
1763         if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
1764                 return False;
1765
1766         if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
1767                 return False;
1768
1769         return True;
1770 }
1771
1772 /*******************************************************************
1773  Reads or writes a structure.
1774 ********************************************************************/
1775
1776 BOOL srv_io_r_net_file_enum(char *desc, SRV_R_NET_FILE_ENUM *r_n, prs_struct *ps, int depth)
1777 {
1778         if (r_n == NULL)
1779                 return False;
1780
1781         prs_debug(ps, depth, desc, "srv_io_r_net_file_enum");
1782         depth++;
1783
1784         if(!prs_align(ps))
1785                 return False;
1786
1787         if(!prs_uint32("file_level", ps, depth, &r_n->file_level))
1788                 return False;
1789
1790         if (r_n->file_level != 0) {
1791                 if(!srv_io_srv_file_ctr("file_ctr", &r_n->ctr, ps, depth))
1792                         return False;
1793         }
1794
1795         if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
1796                 return False;
1797         if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
1798                 return False;
1799         if(!prs_uint32("status     ", ps, depth, &r_n->status))
1800                 return False;
1801
1802         return True;
1803 }
1804
1805 /*******************************************************************
1806  Inits a SRV_INFO_100 structure.
1807  ********************************************************************/
1808
1809 void init_srv_info_100(SRV_INFO_100 *sv100, uint32 platform_id, char *name)
1810 {
1811         DEBUG(5,("init_srv_info_100\n"));
1812
1813         sv100->platform_id  = platform_id;
1814         init_buf_unistr2(&sv100->uni_name, &sv100->ptr_name, name);
1815 }
1816
1817 /*******************************************************************
1818  Reads or writes a SRV_INFO_101 structure.
1819  ********************************************************************/
1820
1821 static BOOL srv_io_info_100(char *desc, SRV_INFO_100 *sv100, prs_struct *ps, int depth)
1822 {
1823         if (sv100 == NULL)
1824                 return False;
1825
1826         prs_debug(ps, depth, desc, "srv_io_info_100");
1827         depth++;
1828
1829         if(!prs_align(ps))
1830                 return False;
1831
1832         if(!prs_uint32("platform_id ", ps, depth, &sv100->platform_id))
1833                 return False;
1834         if(!prs_uint32("ptr_name    ", ps, depth, &sv100->ptr_name))
1835                 return False;
1836
1837         if(!smb_io_unistr2("uni_name    ", &sv100->uni_name, True, ps, depth))
1838                 return False;
1839
1840         return True;
1841 }
1842
1843
1844 /*******************************************************************
1845  Inits a SRV_INFO_101 structure.
1846  ********************************************************************/
1847
1848 void init_srv_info_101(SRV_INFO_101 *sv101, uint32 platform_id, char *name,
1849                                 uint32 ver_major, uint32 ver_minor,
1850                                 uint32 srv_type, char *comment)
1851 {
1852         DEBUG(5,("init_srv_info_101\n"));
1853
1854         sv101->platform_id  = platform_id;
1855         init_buf_unistr2(&sv101->uni_name, &sv101->ptr_name, name);
1856         sv101->ver_major    = ver_major;
1857         sv101->ver_minor    = ver_minor;
1858         sv101->srv_type     = srv_type;
1859         init_buf_unistr2(&sv101->uni_comment, &sv101->ptr_comment, comment);
1860 }
1861
1862 /*******************************************************************
1863  Reads or writes a SRV_INFO_101 structure.
1864  ********************************************************************/
1865
1866 static BOOL srv_io_info_101(char *desc, SRV_INFO_101 *sv101, prs_struct *ps, int depth)
1867 {
1868         if (sv101 == NULL)
1869                 return False;
1870
1871         prs_debug(ps, depth, desc, "srv_io_info_101");
1872         depth++;
1873
1874         if(!prs_align(ps))
1875                 return False;
1876
1877         if(!prs_uint32("platform_id ", ps, depth, &sv101->platform_id))
1878                 return False;
1879         if(!prs_uint32("ptr_name    ", ps, depth, &sv101->ptr_name))
1880                 return False;
1881         if(!prs_uint32("ver_major   ", ps, depth, &sv101->ver_major))
1882                 return False;
1883         if(!prs_uint32("ver_minor   ", ps, depth, &sv101->ver_minor))
1884                 return False;
1885         if(!prs_uint32("srv_type    ", ps, depth, &sv101->srv_type))
1886                 return False;
1887         if(!prs_uint32("ptr_comment ", ps, depth, &sv101->ptr_comment))
1888                 return False;
1889
1890         if(!prs_align(ps))
1891                 return False;
1892
1893         if(!smb_io_unistr2("uni_name    ", &sv101->uni_name, True, ps, depth))
1894                 return False;
1895         if(!smb_io_unistr2("uni_comment ", &sv101->uni_comment, True, ps, depth))
1896                 return False;
1897
1898         return True;
1899 }
1900
1901 /*******************************************************************
1902  Inits a SRV_INFO_102 structure.
1903  ********************************************************************/
1904
1905 void init_srv_info_102(SRV_INFO_102 *sv102, uint32 platform_id, char *name,
1906                                 char *comment, uint32 ver_major, uint32 ver_minor,
1907                                 uint32 srv_type, uint32 users, uint32 disc, uint32 hidden,
1908                                 uint32 announce, uint32 ann_delta, uint32 licenses,
1909                                 char *usr_path)
1910 {
1911         DEBUG(5,("init_srv_info_102\n"));
1912
1913         sv102->platform_id  = platform_id;
1914         init_buf_unistr2(&sv102->uni_name, &sv102->ptr_name, name);
1915         sv102->ver_major    = ver_major;
1916         sv102->ver_minor    = ver_minor;
1917         sv102->srv_type     = srv_type;
1918         init_buf_unistr2(&sv102->uni_comment, &sv102->ptr_comment, comment);
1919
1920         /* same as 101 up to here */
1921
1922         sv102->users        = users;
1923         sv102->disc         = disc;
1924         sv102->hidden       = hidden;
1925         sv102->announce     = announce;
1926         sv102->ann_delta    =ann_delta;
1927         sv102->licenses     = licenses;
1928         init_buf_unistr2(&sv102->uni_usr_path, &sv102->ptr_usr_path, usr_path);
1929 }
1930
1931
1932 /*******************************************************************
1933  Reads or writes a SRV_INFO_102 structure.
1934  ********************************************************************/
1935
1936 static BOOL srv_io_info_102(char *desc, SRV_INFO_102 *sv102, prs_struct *ps, int depth)
1937 {
1938         if (sv102 == NULL)
1939                 return False;
1940
1941         prs_debug(ps, depth, desc, "srv_io_info102");
1942         depth++;
1943
1944         if(!prs_align(ps))
1945                 return False;
1946
1947         if(!prs_uint32("platform_id ", ps, depth, &sv102->platform_id))
1948                 return False;
1949         if(!prs_uint32("ptr_name    ", ps, depth, &sv102->ptr_name))
1950                 return False;
1951         if(!prs_uint32("ver_major   ", ps, depth, &sv102->ver_major))
1952                 return False;
1953         if(!prs_uint32("ver_minor   ", ps, depth, &sv102->ver_minor))
1954                 return False;
1955         if(!prs_uint32("srv_type    ", ps, depth, &sv102->srv_type))
1956                 return False;
1957         if(!prs_uint32("ptr_comment ", ps, depth, &sv102->ptr_comment))
1958                 return False;
1959
1960         /* same as 101 up to here */
1961
1962         if(!prs_uint32("users       ", ps, depth, &sv102->users))
1963                 return False;
1964         if(!prs_uint32("disc        ", ps, depth, &sv102->disc))
1965                 return False;
1966         if(!prs_uint32("hidden      ", ps, depth, &sv102->hidden))
1967                 return False;
1968         if(!prs_uint32("announce    ", ps, depth, &sv102->announce))
1969                 return False;
1970         if(!prs_uint32("ann_delta   ", ps, depth, &sv102->ann_delta))
1971                 return False;
1972         if(!prs_uint32("licenses    ", ps, depth, &sv102->licenses))
1973                 return False;
1974         if(!prs_uint32("ptr_usr_path", ps, depth, &sv102->ptr_usr_path))
1975                 return False;
1976
1977         if(!smb_io_unistr2("uni_name    ", &sv102->uni_name, True, ps, depth))
1978                 return False;
1979         if(!prs_align(ps))
1980                 return False;
1981         if(!smb_io_unistr2("uni_comment ", &sv102->uni_comment, True, ps, depth))
1982                 return False;
1983         if(!prs_align(ps))
1984                 return False;
1985         if(!smb_io_unistr2("uni_usr_path", &sv102->uni_usr_path, True, ps, depth))
1986                 return False;
1987
1988         return True;
1989 }
1990
1991 /*******************************************************************
1992  Reads or writes a SRV_INFO_102 structure.
1993  ********************************************************************/
1994
1995 static BOOL srv_io_info_ctr(char *desc, SRV_INFO_CTR *ctr, prs_struct *ps, int depth)
1996 {
1997         if (ctr == NULL)
1998                 return False;
1999
2000         prs_debug(ps, depth, desc, "srv_io_info_ctr");
2001         depth++;
2002
2003         if(!prs_align(ps))
2004                 return False;
2005
2006         if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
2007                 return False;
2008         if(!prs_uint32("ptr_srv_ctr ", ps, depth, &ctr->ptr_srv_ctr))
2009                 return False;
2010
2011         if (ctr->ptr_srv_ctr != 0 && ctr->switch_value != 0 && ctr != NULL) {
2012                 switch (ctr->switch_value) {
2013                 case 100:
2014                         if(!srv_io_info_100("sv100", &ctr->srv.sv100, ps, depth))
2015                                 return False;
2016                         break;
2017                 case 101:
2018                         if(!srv_io_info_101("sv101", &ctr->srv.sv101, ps, depth))
2019                                 return False;
2020                         break;
2021                 case 102:
2022                         if(!srv_io_info_102("sv102", &ctr->srv.sv102, ps, depth))
2023                                 return False;
2024                         break;
2025                 default:
2026                         DEBUG(5,("%s no server info at switch_value %d\n",
2027                                          tab_depth(depth), ctr->switch_value));
2028                         break;
2029                 }
2030                 if(!prs_align(ps))
2031                         return False;
2032         }
2033
2034         return True;
2035 }
2036
2037 /*******************************************************************
2038  Inits a SRV_Q_NET_SRV_GET_INFO structure.
2039  ********************************************************************/
2040
2041 void init_srv_q_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *srv,
2042                                 char *server_name, uint32 switch_value)
2043 {
2044         DEBUG(5,("init_srv_q_net_srv_get_info\n"));
2045
2046         init_buf_unistr2(&srv->uni_srv_name, &srv->ptr_srv_name, server_name);
2047
2048         srv->switch_value = switch_value;
2049 }
2050
2051 /*******************************************************************
2052  Reads or writes a structure.
2053 ********************************************************************/
2054
2055 BOOL srv_io_q_net_srv_get_info(char *desc, SRV_Q_NET_SRV_GET_INFO *q_n, prs_struct *ps, int depth)
2056 {
2057         if (q_n == NULL)
2058                 return False;
2059
2060         prs_debug(ps, depth, desc, "srv_io_q_net_srv_get_info");
2061         depth++;
2062
2063         if(!prs_align(ps))
2064                 return False;
2065
2066         if(!prs_uint32("ptr_srv_name  ", ps, depth, &q_n->ptr_srv_name))
2067                 return False;
2068         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
2069                 return False;
2070
2071         if(!prs_align(ps))
2072                 return False;
2073
2074         if(!prs_uint32("switch_value  ", ps, depth, &q_n->switch_value))
2075                 return False;
2076
2077         return True;
2078 }
2079
2080 /*******************************************************************
2081  Inits a SRV_R_NET_SRV_GET_INFO structure.
2082  ********************************************************************/
2083
2084 void init_srv_r_net_srv_get_info(SRV_R_NET_SRV_GET_INFO *srv,
2085                                 uint32 switch_value, SRV_INFO_CTR *ctr, uint32 status)
2086 {
2087         DEBUG(5,("init_srv_r_net_srv_get_info\n"));
2088
2089         srv->ctr = ctr;
2090
2091         if (status == 0x0) {
2092                 srv->ctr->switch_value = switch_value;
2093                 srv->ctr->ptr_srv_ctr  = 1;
2094         } else {
2095                 srv->ctr->switch_value = 0;
2096                 srv->ctr->ptr_srv_ctr  = 0;
2097         }
2098
2099         srv->status = status;
2100 }
2101
2102 /*******************************************************************
2103  Reads or writes a structure.
2104  ********************************************************************/
2105
2106 BOOL srv_io_r_net_srv_get_info(char *desc, SRV_R_NET_SRV_GET_INFO *r_n, prs_struct *ps, int depth)
2107 {
2108         if (r_n == NULL)
2109                 return False;
2110
2111         prs_debug(ps, depth, desc, "srv_io_r_net_srv_get_info");
2112         depth++;
2113
2114         if(!prs_align(ps))
2115                 return False;
2116
2117         if(!srv_io_info_ctr("ctr", r_n->ctr, ps, depth))
2118                 return False;
2119
2120         if(!prs_uint32("status      ", ps, depth, &r_n->status))
2121                 return False;
2122
2123         return True;
2124 }
2125
2126
2127 /*******************************************************************
2128  Reads or writes a structure.
2129  ********************************************************************/
2130
2131 BOOL srv_io_q_net_remote_tod(char *desc, SRV_Q_NET_REMOTE_TOD *q_n, prs_struct *ps, int depth)
2132 {
2133         if (q_n == NULL)
2134                 return False;
2135
2136         prs_debug(ps, depth, desc, "srv_io_q_net_remote_tod");
2137         depth++;
2138
2139         if(!prs_align(ps))
2140                 return False;
2141
2142         if(!prs_uint32("ptr_srv_name  ", ps, depth, &q_n->ptr_srv_name))
2143                 return False;
2144         if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
2145                 return False;
2146
2147         return True;
2148 }
2149
2150 /*******************************************************************
2151  Reads or writes a TIME_OF_DAY_INFO structure.
2152  ********************************************************************/
2153
2154 static BOOL srv_io_time_of_day_info(char *desc, TIME_OF_DAY_INFO *tod, prs_struct *ps, int depth)
2155 {
2156         if (tod == NULL)
2157                 return False;
2158
2159         prs_debug(ps, depth, desc, "srv_io_time_of_day_info");
2160         depth++;
2161
2162         if(!prs_align(ps))
2163                 return False;
2164         
2165         if(!prs_uint32("elapsedt   ", ps, depth, &tod->elapsedt))
2166                 return False;
2167         if(!prs_uint32("msecs      ", ps, depth, &tod->msecs))
2168                 return False;
2169         if(!prs_uint32("hours      ", ps, depth, &tod->hours))
2170                 return False;
2171         if(!prs_uint32("mins       ", ps, depth, &tod->mins))
2172                 return False;
2173         if(!prs_uint32("secs       ", ps, depth, &tod->secs))
2174                 return False;
2175         if(!prs_uint32("hunds      ", ps, depth, &tod->hunds))
2176                 return False;
2177         if(!prs_uint32("timezone   ", ps, depth, &tod->zone))
2178                 return False;
2179         if(!prs_uint32("tintervals ", ps, depth, &tod->tintervals))
2180                 return False;
2181         if(!prs_uint32("day        ", ps, depth, &tod->day))
2182                 return False;
2183         if(!prs_uint32("month      ", ps, depth, &tod->month))
2184                 return False;
2185         if(!prs_uint32("year       ", ps, depth, &tod->year))
2186                 return False;
2187         if(!prs_uint32("weekday    ", ps, depth, &tod->weekday))
2188                 return False;
2189
2190         return True;
2191 }
2192
2193 /*******************************************************************
2194  Inits a TIME_OF_DAY_INFO structure.
2195  ********************************************************************/
2196
2197 void init_time_of_day_info(TIME_OF_DAY_INFO *tod, uint32 elapsedt, uint32 msecs,
2198                            uint32 hours, uint32 mins, uint32 secs, uint32 hunds,
2199                            uint32 zone, uint32 tintervals, uint32 day,
2200                            uint32 month, uint32 year, uint32 weekday)
2201 {
2202         DEBUG(5,("init_time_of_day_info\n"));
2203
2204         tod->elapsedt   = elapsedt;
2205         tod->msecs      = msecs;
2206         tod->hours      = hours;
2207         tod->mins       = mins;
2208         tod->secs       = secs;
2209         tod->hunds      = hunds;
2210         tod->zone       = zone;
2211         tod->tintervals = tintervals;
2212         tod->day        = day;
2213         tod->month      = month;
2214         tod->year       = year;
2215         tod->weekday    = weekday;
2216 }
2217
2218
2219 /*******************************************************************
2220  Reads or writes a structure.
2221  ********************************************************************/
2222
2223 BOOL srv_io_r_net_remote_tod(char *desc, SRV_R_NET_REMOTE_TOD *r_n, prs_struct *ps, int depth)
2224 {
2225         if (r_n == NULL)
2226                 return False;
2227
2228         prs_debug(ps, depth, desc, "srv_io_r_net_remote_tod");
2229         depth++;
2230
2231         if(!prs_align(ps))
2232                 return False;
2233         
2234         if(!prs_uint32("ptr_srv_tod ", ps, depth, &r_n->ptr_srv_tod))
2235                 return False;
2236
2237         if(!srv_io_time_of_day_info("tod", r_n->tod, ps, depth))
2238                 return False;
2239
2240         if(!prs_uint32("status      ", ps, depth, &r_n->status))
2241                 return False;
2242
2243         return True;
2244 }