r4231: commiting changes to 3.0.10
[Samba.git] / source / rpc_parse / parse_srv.c
blob8a5e17669a4ded4b1703722b3086fb82dfd6650a
1 /*
2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Andrew Tridgell 1992-1997,
5 * Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
6 * Copyright (C) Paul Ashton 1997,
7 * Copyright (C) Jeremy Allison 1999,
8 * Copyright (C) Nigel Williams 2001,
9 * Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2002.
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.
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.
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.
26 #include "includes.h"
28 #undef DBGC_CLASS
29 #define DBGC_CLASS DBGC_RPC_PARSE
31 /*******************************************************************
32 Inits a SH_INFO_0_STR structure
33 ********************************************************************/
35 void init_srv_share_info0_str(SH_INFO_0_STR *sh0, const char *net_name)
37 DEBUG(5,("init_srv_share_info0_str\n"));
39 init_unistr2(&sh0->uni_netname, net_name, UNI_STR_TERMINATE);
42 /*******************************************************************
43 Reads or writes a structure.
44 ********************************************************************/
46 static BOOL srv_io_share_info0_str(const char *desc, SH_INFO_0_STR *sh0, prs_struct *ps, int depth)
48 if (sh0 == NULL)
49 return False;
51 prs_debug(ps, depth, desc, "srv_io_share_info0_str");
52 depth++;
54 if(!prs_align(ps))
55 return False;
56 if(sh0->ptrs->ptr_netname)
57 if(!smb_io_unistr2("", &sh0->uni_netname, True, ps, depth))
58 return False;
60 return True;
63 /*******************************************************************
64 makes a SH_INFO_0 structure
65 ********************************************************************/
67 void init_srv_share_info0(SH_INFO_0 *sh0, const char *net_name)
69 DEBUG(5,("init_srv_share_info0: %s\n", net_name));
71 sh0->ptr_netname = (net_name != NULL) ? 1 : 0;
74 /*******************************************************************
75 Reads or writes a structure.
76 ********************************************************************/
78 static BOOL srv_io_share_info0(const char *desc, SH_INFO_0 *sh0, prs_struct *ps, int depth)
80 if (sh0 == NULL)
81 return False;
83 prs_debug(ps, depth, desc, "srv_io_share_info0");
84 depth++;
86 if(!prs_align(ps))
87 return False;
89 if(!prs_uint32("ptr_netname", ps, depth, &sh0->ptr_netname))
90 return False;
92 return True;
95 /*******************************************************************
96 Inits a SH_INFO_1_STR structure
97 ********************************************************************/
99 void init_srv_share_info1_str(SH_INFO_1_STR *sh1, const char *net_name, const char *remark)
101 DEBUG(5,("init_srv_share_info1_str\n"));
103 init_unistr2(&sh1->uni_netname, net_name, UNI_STR_TERMINATE);
104 init_unistr2(&sh1->uni_remark, remark, UNI_STR_TERMINATE);
107 /*******************************************************************
108 Reads or writes a structure.
109 ********************************************************************/
111 static BOOL srv_io_share_info1_str(const char *desc, SH_INFO_1_STR *sh1, prs_struct *ps, int depth)
113 if (sh1 == NULL)
114 return False;
116 prs_debug(ps, depth, desc, "srv_io_share_info1_str");
117 depth++;
119 if(!prs_align(ps))
120 return False;
122 if(sh1->ptrs->ptr_netname)
123 if(!smb_io_unistr2("", &sh1->uni_netname, True, ps, depth))
124 return False;
126 if(!prs_align(ps))
127 return False;
129 if(sh1->ptrs->ptr_remark)
130 if(!smb_io_unistr2("", &sh1->uni_remark, True, ps, depth))
131 return False;
133 return True;
136 /*******************************************************************
137 makes a SH_INFO_1 structure
138 ********************************************************************/
140 void init_srv_share_info1(SH_INFO_1 *sh1, const char *net_name, uint32 type, const char *remark)
142 DEBUG(5,("init_srv_share_info1: %s %8x %s\n", net_name, type, remark));
144 sh1->ptr_netname = (net_name != NULL) ? 1 : 0;
145 sh1->type = type;
146 sh1->ptr_remark = (remark != NULL) ? 1 : 0;
149 /*******************************************************************
150 Reads or writes a structure.
151 ********************************************************************/
153 static BOOL srv_io_share_info1(const char *desc, SH_INFO_1 *sh1, prs_struct *ps, int depth)
155 if (sh1 == NULL)
156 return False;
158 prs_debug(ps, depth, desc, "srv_io_share_info1");
159 depth++;
161 if(!prs_align(ps))
162 return False;
164 if(!prs_uint32("ptr_netname", ps, depth, &sh1->ptr_netname))
165 return False;
166 if(!prs_uint32("type ", ps, depth, &sh1->type))
167 return False;
168 if(!prs_uint32("ptr_remark ", ps, depth, &sh1->ptr_remark))
169 return False;
171 return True;
174 /*******************************************************************
175 Inits a SH_INFO_2_STR structure
176 ********************************************************************/
178 void init_srv_share_info2_str(SH_INFO_2_STR *sh2,
179 const char *net_name, const char *remark,
180 const char *path, const char *passwd)
182 DEBUG(5,("init_srv_share_info2_str\n"));
184 init_unistr2(&sh2->uni_netname, net_name, UNI_STR_TERMINATE);
185 init_unistr2(&sh2->uni_remark, remark, UNI_STR_TERMINATE);
186 init_unistr2(&sh2->uni_path, path, UNI_STR_TERMINATE);
187 init_unistr2(&sh2->uni_passwd, passwd, UNI_STR_TERMINATE);
190 /*******************************************************************
191 Reads or writes a structure.
192 ********************************************************************/
194 static BOOL srv_io_share_info2_str(const char *desc, SH_INFO_2 *sh, SH_INFO_2_STR *sh2, prs_struct *ps, int depth)
196 if (sh2 == NULL)
197 return False;
199 if (UNMARSHALLING(ps))
200 ZERO_STRUCTP(sh2);
202 prs_debug(ps, depth, desc, "srv_io_share_info2_str");
203 depth++;
205 if(!prs_align(ps))
206 return False;
208 if (sh->ptr_netname)
209 if(!smb_io_unistr2("", &sh2->uni_netname, True, ps, depth))
210 return False;
212 if (sh->ptr_remark)
213 if(!smb_io_unistr2("", &sh2->uni_remark, True, ps, depth))
214 return False;
216 if (sh->ptr_netname)
217 if(!smb_io_unistr2("", &sh2->uni_path, True, ps, depth))
218 return False;
220 if (sh->ptr_passwd)
221 if(!smb_io_unistr2("", &sh2->uni_passwd, True, ps, depth))
222 return False;
224 return True;
227 /*******************************************************************
228 Inits a SH_INFO_2 structure
229 ********************************************************************/
231 void init_srv_share_info2(SH_INFO_2 *sh2,
232 const char *net_name, uint32 type, const char *remark,
233 uint32 perms, uint32 max_uses, uint32 num_uses,
234 const char *path, const char *passwd)
236 DEBUG(5,("init_srv_share_info2: %s %8x %s\n", net_name, type, remark));
238 sh2->ptr_netname = (net_name != NULL) ? 1 : 0;
239 sh2->type = type;
240 sh2->ptr_remark = (remark != NULL) ? 1 : 0;
241 sh2->perms = perms;
242 sh2->max_uses = max_uses;
243 sh2->num_uses = num_uses;
244 sh2->ptr_path = (path != NULL) ? 1 : 0;
245 sh2->ptr_passwd = (passwd != NULL) ? 1 : 0;
248 /*******************************************************************
249 Reads or writes a structure.
250 ********************************************************************/
252 static BOOL srv_io_share_info2(const char *desc, SH_INFO_2 *sh2, prs_struct *ps, int depth)
254 if (sh2 == NULL)
255 return False;
257 prs_debug(ps, depth, desc, "srv_io_share_info2");
258 depth++;
260 if(!prs_align(ps))
261 return False;
263 if(!prs_uint32("ptr_netname", ps, depth, &sh2->ptr_netname))
264 return False;
265 if(!prs_uint32("type ", ps, depth, &sh2->type))
266 return False;
267 if(!prs_uint32("ptr_remark ", ps, depth, &sh2->ptr_remark))
268 return False;
269 if(!prs_uint32("perms ", ps, depth, &sh2->perms))
270 return False;
271 if(!prs_uint32("max_uses ", ps, depth, &sh2->max_uses))
272 return False;
273 if(!prs_uint32("num_uses ", ps, depth, &sh2->num_uses))
274 return False;
275 if(!prs_uint32("ptr_path ", ps, depth, &sh2->ptr_path))
276 return False;
277 if(!prs_uint32("ptr_passwd ", ps, depth, &sh2->ptr_passwd))
278 return False;
280 return True;
283 /*******************************************************************
284 Inits a SH_INFO_501_STR structure
285 ********************************************************************/
287 void init_srv_share_info501_str(SH_INFO_501_STR *sh501,
288 const char *net_name, const char *remark)
290 DEBUG(5,("init_srv_share_info501_str\n"));
292 init_unistr2(&sh501->uni_netname, net_name, UNI_STR_TERMINATE);
293 init_unistr2(&sh501->uni_remark, remark, UNI_STR_TERMINATE);
296 /*******************************************************************
297 Inits a SH_INFO_2 structure
298 *******************************************************************/
300 void init_srv_share_info501(SH_INFO_501 *sh501, const char *net_name, uint32 type, const char *remark, uint32 csc_policy)
302 DEBUG(5,("init_srv_share_info501: %s %8x %s %08x\n", net_name, type,
303 remark, csc_policy));
305 ZERO_STRUCTP(sh501);
307 sh501->ptr_netname = (net_name != NULL) ? 1 : 0;
308 sh501->type = type;
309 sh501->ptr_remark = (remark != NULL) ? 1 : 0;
310 sh501->csc_policy = csc_policy;
313 /*******************************************************************
314 Reads of writes a structure.
315 *******************************************************************/
317 static BOOL srv_io_share_info501(const char *desc, SH_INFO_501 *sh501, prs_struct *ps, int depth)
319 if (sh501 == NULL)
320 return False;
322 prs_debug(ps, depth, desc, "srv_io_share_info501");
323 depth++;
325 if (!prs_align(ps))
326 return False;
328 if (!prs_uint32("ptr_netname", ps, depth, &sh501->ptr_netname))
329 return False;
330 if (!prs_uint32("type ", ps, depth, &sh501->type))
331 return False;
332 if (!prs_uint32("ptr_remark ", ps, depth, &sh501->ptr_remark))
333 return False;
334 if (!prs_uint32("csc_policy ", ps, depth, &sh501->csc_policy))
335 return False;
337 return True;
340 /*******************************************************************
341 Reads or writes a structure.
342 ********************************************************************/
344 static BOOL srv_io_share_info501_str(const char *desc, SH_INFO_501_STR *sh501, prs_struct *ps, int depth)
346 if (sh501 == NULL)
347 return False;
349 prs_debug(ps, depth, desc, "srv_io_share_info501_str");
350 depth++;
352 if(!prs_align(ps))
353 return False;
354 if(!smb_io_unistr2("", &sh501->uni_netname, True, ps, depth))
355 return False;
357 if(!prs_align(ps))
358 return False;
359 if(!smb_io_unistr2("", &sh501->uni_remark, True, ps, depth))
360 return False;
362 return True;
365 /*******************************************************************
366 Inits a SH_INFO_502 structure
367 ********************************************************************/
369 void init_srv_share_info502(SH_INFO_502 *sh502,
370 const char *net_name, uint32 type, const char *remark,
371 uint32 perms, uint32 max_uses, uint32 num_uses,
372 const char *path, const char *passwd, SEC_DESC *psd, size_t sd_size)
374 DEBUG(5,("init_srv_share_info502: %s %8x %s\n", net_name, type, remark));
376 ZERO_STRUCTP(sh502);
378 sh502->ptr_netname = (net_name != NULL) ? 1 : 0;
379 sh502->type = type;
380 sh502->ptr_remark = (remark != NULL) ? 1 : 0;
381 sh502->perms = perms;
382 sh502->max_uses = max_uses;
383 sh502->num_uses = num_uses;
384 sh502->ptr_path = (path != NULL) ? 1 : 0;
385 sh502->ptr_passwd = (passwd != NULL) ? 1 : 0;
386 sh502->reserved = 0; /* actual size within rpc */
387 sh502->sd_size = (uint32)sd_size;
388 sh502->ptr_sd = (psd != NULL) ? 1 : 0;
391 /*******************************************************************
392 Reads or writes a structure.
393 ********************************************************************/
395 static BOOL srv_io_share_info502(const char *desc, SH_INFO_502 *sh502, prs_struct *ps, int depth)
397 if (sh502 == NULL)
398 return False;
400 prs_debug(ps, depth, desc, "srv_io_share_info502");
401 depth++;
403 if(!prs_align(ps))
404 return False;
406 if(!prs_uint32("ptr_netname", ps, depth, &sh502->ptr_netname))
407 return False;
408 if(!prs_uint32("type ", ps, depth, &sh502->type))
409 return False;
410 if(!prs_uint32("ptr_remark ", ps, depth, &sh502->ptr_remark))
411 return False;
412 if(!prs_uint32("perms ", ps, depth, &sh502->perms))
413 return False;
414 if(!prs_uint32("max_uses ", ps, depth, &sh502->max_uses))
415 return False;
416 if(!prs_uint32("num_uses ", ps, depth, &sh502->num_uses))
417 return False;
418 if(!prs_uint32("ptr_path ", ps, depth, &sh502->ptr_path))
419 return False;
420 if(!prs_uint32("ptr_passwd ", ps, depth, &sh502->ptr_passwd))
421 return False;
422 if(!prs_uint32_pre("reserved ", ps, depth, &sh502->reserved, &sh502->reserved_offset))
423 return False;
424 if(!prs_uint32("ptr_sd ", ps, depth, &sh502->ptr_sd))
425 return False;
427 return True;
430 /*******************************************************************
431 Inits a SH_INFO_502_STR structure
432 ********************************************************************/
434 void init_srv_share_info502_str(SH_INFO_502_STR *sh502str,
435 const char *net_name, const char *remark,
436 const char *path, const char *passwd, SEC_DESC *psd, size_t sd_size)
438 DEBUG(5,("init_srv_share_info502_str\n"));
440 init_unistr2(&sh502str->uni_netname, net_name, UNI_STR_TERMINATE);
441 init_unistr2(&sh502str->uni_remark, remark, UNI_STR_TERMINATE);
442 init_unistr2(&sh502str->uni_path, path, UNI_STR_TERMINATE);
443 init_unistr2(&sh502str->uni_passwd, passwd, UNI_STR_TERMINATE);
444 sh502str->sd = psd;
445 sh502str->reserved = 0;
446 sh502str->sd_size = sd_size;
449 /*******************************************************************
450 Reads or writes a structure.
451 ********************************************************************/
453 static BOOL srv_io_share_info502_str(const char *desc, SH_INFO_502_STR *sh502, prs_struct *ps, int depth)
455 if (sh502 == NULL)
456 return False;
458 prs_debug(ps, depth, desc, "srv_io_share_info502_str");
459 depth++;
461 if(!prs_align(ps))
462 return False;
464 if(sh502->ptrs->ptr_netname) {
465 if(!smb_io_unistr2("", &sh502->uni_netname, True, ps, depth))
466 return False;
469 if(!prs_align(ps))
470 return False;
472 if(sh502->ptrs->ptr_remark) {
473 if(!smb_io_unistr2("", &sh502->uni_remark, True, ps, depth))
474 return False;
477 if(!prs_align(ps))
478 return False;
480 if(sh502->ptrs->ptr_path) {
481 if(!smb_io_unistr2("", &sh502->uni_path, True, ps, depth))
482 return False;
485 if(!prs_align(ps))
486 return False;
488 if(sh502->ptrs->ptr_passwd) {
489 if(!smb_io_unistr2("", &sh502->uni_passwd, True, ps, depth))
490 return False;
493 if(!prs_align(ps))
494 return False;
496 if(sh502->ptrs->ptr_sd) {
497 uint32 old_offset;
498 uint32 reserved_offset;
500 if(!prs_uint32_pre("reserved ", ps, depth, &sh502->reserved, &reserved_offset))
501 return False;
503 old_offset = prs_offset(ps);
505 if (!sec_io_desc(desc, &sh502->sd, ps, depth))
506 return False;
508 if(UNMARSHALLING(ps)) {
510 sh502->ptrs->sd_size = sh502->sd_size = sec_desc_size(sh502->sd);
512 prs_set_offset(ps, old_offset + sh502->reserved);
515 prs_align(ps);
517 if(MARSHALLING(ps)) {
519 sh502->ptrs->reserved = sh502->reserved = prs_offset(ps) - old_offset;
522 if(!prs_uint32_post("reserved ", ps, depth,
523 &sh502->reserved, reserved_offset, sh502->reserved))
524 return False;
525 if(!prs_uint32_post("reserved ", ps, depth,
526 &sh502->ptrs->reserved, sh502->ptrs->reserved_offset, sh502->ptrs->reserved))
527 return False;
530 return True;
533 /*******************************************************************
534 Inits a SH_INFO_1004_STR structure
535 ********************************************************************/
537 void init_srv_share_info1004_str(SH_INFO_1004_STR *sh1004, const char *remark)
539 DEBUG(5,("init_srv_share_info1004_str\n"));
541 init_unistr2(&sh1004->uni_remark, remark, UNI_STR_TERMINATE);
544 /*******************************************************************
545 Reads or writes a structure.
546 ********************************************************************/
548 static BOOL srv_io_share_info1004_str(const char *desc, SH_INFO_1004_STR *sh1004, prs_struct *ps, int depth)
550 if (sh1004 == NULL)
551 return False;
553 prs_debug(ps, depth, desc, "srv_io_share_info1004_str");
554 depth++;
556 if(!prs_align(ps))
557 return False;
558 if(sh1004->ptrs->ptr_remark)
559 if(!smb_io_unistr2("", &sh1004->uni_remark, True, ps, depth))
560 return False;
562 return True;
565 /*******************************************************************
566 makes a SH_INFO_1004 structure
567 ********************************************************************/
569 void init_srv_share_info1004(SH_INFO_1004 *sh1004, const char *remark)
571 DEBUG(5,("init_srv_share_info1004: %s\n", remark));
573 sh1004->ptr_remark = (remark != NULL) ? 1 : 0;
576 /*******************************************************************
577 Reads or writes a structure.
578 ********************************************************************/
580 static BOOL srv_io_share_info1004(const char *desc, SH_INFO_1004 *sh1004, prs_struct *ps, int depth)
582 if (sh1004 == NULL)
583 return False;
585 prs_debug(ps, depth, desc, "srv_io_share_info1004");
586 depth++;
588 if(!prs_align(ps))
589 return False;
591 if(!prs_uint32("ptr_remark", ps, depth, &sh1004->ptr_remark))
592 return False;
594 return True;
597 /*******************************************************************
598 Reads or writes a structure.
599 ********************************************************************/
601 static BOOL srv_io_share_info1005(const char* desc, SRV_SHARE_INFO_1005* sh1005, prs_struct* ps, int depth)
603 if(sh1005 == NULL)
604 return False;
606 prs_debug(ps, depth, desc, "srv_io_share_info1005");
607 depth++;
609 if(!prs_align(ps))
610 return False;
612 if(!prs_uint32("share_info_flags", ps, depth,
613 &sh1005->share_info_flags))
614 return False;
616 return True;
619 /*******************************************************************
620 Reads or writes a structure.
621 ********************************************************************/
623 static BOOL srv_io_share_info1006(const char* desc, SRV_SHARE_INFO_1006* sh1006, prs_struct* ps, int depth)
625 if(sh1006 == NULL)
626 return False;
628 prs_debug(ps, depth, desc, "srv_io_share_info1006");
629 depth++;
631 if(!prs_align(ps))
632 return False;
634 if(!prs_uint32("max uses ", ps, depth, &sh1006->max_uses))
635 return False;
637 return True;
640 /*******************************************************************
641 Inits a SH_INFO_1007_STR structure
642 ********************************************************************/
644 void init_srv_share_info1007_str(SH_INFO_1007_STR *sh1007, const char *alternate_directory_name)
646 DEBUG(5,("init_srv_share_info1007_str\n"));
648 init_unistr2(&sh1007->uni_AlternateDirectoryName, alternate_directory_name, UNI_STR_TERMINATE);
651 /*******************************************************************
652 Reads or writes a structure.
653 ********************************************************************/
655 static BOOL srv_io_share_info1007_str(const char *desc, SH_INFO_1007_STR *sh1007, prs_struct *ps, int depth)
657 if (sh1007 == NULL)
658 return False;
660 prs_debug(ps, depth, desc, "srv_io_share_info1007_str");
661 depth++;
663 if(!prs_align(ps))
664 return False;
665 if(sh1007->ptrs->ptr_AlternateDirectoryName)
666 if(!smb_io_unistr2("", &sh1007->uni_AlternateDirectoryName, True, ps, depth))
667 return False;
669 return True;
672 /*******************************************************************
673 makes a SH_INFO_1007 structure
674 ********************************************************************/
676 void init_srv_share_info1007(SH_INFO_1007 *sh1007, uint32 flags, const char *alternate_directory_name)
678 DEBUG(5,("init_srv_share_info1007: %s\n", alternate_directory_name));
680 sh1007->flags = flags;
681 sh1007->ptr_AlternateDirectoryName = (alternate_directory_name != NULL) ? 1 : 0;
684 /*******************************************************************
685 Reads or writes a structure.
686 ********************************************************************/
688 static BOOL srv_io_share_info1007(const char *desc, SH_INFO_1007 *sh1007, prs_struct *ps, int depth)
690 if (sh1007 == NULL)
691 return False;
693 prs_debug(ps, depth, desc, "srv_io_share_info1007");
694 depth++;
696 if(!prs_align(ps))
697 return False;
699 if(!prs_uint32("flags ", ps, depth, &sh1007->flags))
700 return False;
701 if(!prs_uint32("ptr_Alter..", ps, depth, &sh1007->ptr_AlternateDirectoryName))
702 return False;
704 return True;
707 /*******************************************************************
708 Reads or writes a structure.
709 ********************************************************************/
711 static BOOL srv_io_share_info1501(const char* desc, SRV_SHARE_INFO_1501* sh1501,
712 prs_struct* ps, int depth)
714 if(sh1501 == NULL)
715 return False;
717 prs_debug(ps, depth, desc, "srv_io_share_info1501");
718 depth++;
720 if(!prs_align(ps))
721 return False;
723 if (!sec_io_desc_buf(desc, &sh1501->sdb, ps, depth))
724 return False;
726 return True;
729 /*******************************************************************
730 Reads or writes a structure.
731 ********************************************************************/
733 static BOOL srv_io_srv_share_ctr(const char *desc, SRV_SHARE_INFO_CTR *ctr, prs_struct *ps, int depth)
735 if (ctr == NULL)
736 return False;
738 prs_debug(ps, depth, desc, "srv_io_srv_share_ctr");
739 depth++;
741 if (UNMARSHALLING(ps)) {
742 memset(ctr, '\0', sizeof(SRV_SHARE_INFO_CTR));
745 if(!prs_align(ps))
746 return False;
748 if(!prs_uint32("info_level", ps, depth, &ctr->info_level))
749 return False;
751 if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
752 return False;
753 if(!prs_uint32("ptr_share_info", ps, depth, &ctr->ptr_share_info))
754 return False;
756 if (ctr->ptr_share_info == 0)
757 return True;
759 if(!prs_uint32("num_entries", ps, depth, &ctr->num_entries))
760 return False;
761 if(!prs_uint32("ptr_entries", ps, depth, &ctr->ptr_entries))
762 return False;
764 if (ctr->ptr_entries == 0) {
765 if (ctr->num_entries == 0)
766 return True;
767 else
768 return False;
771 if(!prs_uint32("num_entries2", ps, depth, &ctr->num_entries2))
772 return False;
774 if (ctr->num_entries2 != ctr->num_entries)
775 return False;
777 switch (ctr->switch_value) {
779 case 0:
781 SRV_SHARE_INFO_0 *info0 = ctr->share.info0;
782 int num_entries = ctr->num_entries;
783 int i;
785 if (UNMARSHALLING(ps)) {
786 if (!(info0 = PRS_ALLOC_MEM(ps, SRV_SHARE_INFO_0, num_entries)))
787 return False;
788 ctr->share.info0 = info0;
791 for (i = 0; i < num_entries; i++) {
792 if(!srv_io_share_info0("", &info0[i].info_0, ps, depth))
793 return False;
796 for (i = 0; i < num_entries; i++) {
797 info0[i].info_0_str.ptrs = &info0[i].info_0;
798 if(!srv_io_share_info0_str("", &info0[i].info_0_str, ps, depth))
799 return False;
802 break;
805 case 1:
807 SRV_SHARE_INFO_1 *info1 = ctr->share.info1;
808 int num_entries = ctr->num_entries;
809 int i;
811 if (UNMARSHALLING(ps)) {
812 if (!(info1 = PRS_ALLOC_MEM(ps, SRV_SHARE_INFO_1, num_entries)))
813 return False;
814 ctr->share.info1 = info1;
817 for (i = 0; i < num_entries; i++) {
818 if(!srv_io_share_info1("", &info1[i].info_1, ps, depth))
819 return False;
822 for (i = 0; i < num_entries; i++) {
823 info1[i].info_1_str.ptrs = &info1[i].info_1;
824 if(!srv_io_share_info1_str("", &info1[i].info_1_str, ps, depth))
825 return False;
828 break;
831 case 2:
833 SRV_SHARE_INFO_2 *info2 = ctr->share.info2;
834 int num_entries = ctr->num_entries;
835 int i;
837 if (UNMARSHALLING(ps)) {
838 if (!(info2 = PRS_ALLOC_MEM(ps,SRV_SHARE_INFO_2,num_entries)))
839 return False;
840 ctr->share.info2 = info2;
843 for (i = 0; i < num_entries; i++) {
844 if(!srv_io_share_info2("", &info2[i].info_2, ps, depth))
845 return False;
848 for (i = 0; i < num_entries; i++) {
849 if(!srv_io_share_info2_str("", &info2[i].info_2, &info2[i].info_2_str, ps, depth))
850 return False;
853 break;
856 case 501:
858 SRV_SHARE_INFO_501 *info501 = ctr->share.info501;
859 int num_entries = ctr->num_entries;
860 int i;
862 if (UNMARSHALLING(ps)) {
863 if (!(info501 = PRS_ALLOC_MEM(ps, SRV_SHARE_INFO_501, num_entries)))
864 return False;
865 ctr->share.info501 = info501;
868 for (i = 0; i < num_entries; i++) {
869 if (!srv_io_share_info501("", &info501[i].info_501, ps, depth))
870 return False;
873 for (i = 0; i < num_entries; i++) {
874 if (!srv_io_share_info501_str("", &info501[i].info_501_str, ps, depth))
875 return False;
878 break;
881 case 502:
883 SRV_SHARE_INFO_502 *info502 = ctr->share.info502;
884 int num_entries = ctr->num_entries;
885 int i;
887 if (UNMARSHALLING(ps)) {
888 if (!(info502 = PRS_ALLOC_MEM(ps,SRV_SHARE_INFO_502,num_entries)))
889 return False;
890 ctr->share.info502 = info502;
893 for (i = 0; i < num_entries; i++) {
894 if(!srv_io_share_info502("", &info502[i].info_502, ps, depth))
895 return False;
898 for (i = 0; i < num_entries; i++) {
899 info502[i].info_502_str.ptrs = &info502[i].info_502;
900 if(!srv_io_share_info502_str("", &info502[i].info_502_str, ps, depth))
901 return False;
904 break;
907 case 1004:
909 SRV_SHARE_INFO_1004 *info1004 = ctr->share.info1004;
910 int num_entries = ctr->num_entries;
911 int i;
913 if (UNMARSHALLING(ps)) {
914 if (!(info1004 = PRS_ALLOC_MEM(ps,SRV_SHARE_INFO_1004,num_entries)))
915 return False;
916 ctr->share.info1004 = info1004;
919 for (i = 0; i < num_entries; i++) {
920 if(!srv_io_share_info1004("", &info1004[i].info_1004, ps, depth))
921 return False;
924 for (i = 0; i < num_entries; i++) {
925 info1004[i].info_1004_str.ptrs = &info1004[i].info_1004;
926 if(!srv_io_share_info1004_str("", &info1004[i].info_1004_str, ps, depth))
927 return False;
930 break;
933 case 1005:
935 SRV_SHARE_INFO_1005 *info1005 = ctr->share.info1005;
936 int num_entries = ctr->num_entries;
937 int i;
939 if (UNMARSHALLING(ps)) {
940 if (!(info1005 = PRS_ALLOC_MEM(ps,SRV_SHARE_INFO_1005,num_entries)))
941 return False;
942 ctr->share.info1005 = info1005;
945 for (i = 0; i < num_entries; i++) {
946 if(!srv_io_share_info1005("", &info1005[i], ps, depth))
947 return False;
950 break;
953 case 1006:
955 SRV_SHARE_INFO_1006 *info1006 = ctr->share.info1006;
956 int num_entries = ctr->num_entries;
957 int i;
959 if (UNMARSHALLING(ps)) {
960 if (!(info1006 = PRS_ALLOC_MEM(ps,SRV_SHARE_INFO_1006,num_entries)))
961 return False;
962 ctr->share.info1006 = info1006;
965 for (i = 0; i < num_entries; i++) {
966 if(!srv_io_share_info1006("", &info1006[i], ps, depth))
967 return False;
970 break;
973 case 1007:
975 SRV_SHARE_INFO_1007 *info1007 = ctr->share.info1007;
976 int num_entries = ctr->num_entries;
977 int i;
979 if (UNMARSHALLING(ps)) {
980 if (!(info1007 = PRS_ALLOC_MEM(ps,SRV_SHARE_INFO_1007,num_entries)))
981 return False;
982 ctr->share.info1007 = info1007;
985 for (i = 0; i < num_entries; i++) {
986 if(!srv_io_share_info1007("", &info1007[i].info_1007, ps, depth))
987 return False;
990 for (i = 0; i < num_entries; i++) {
991 info1007[i].info_1007_str.ptrs = &info1007[i].info_1007;
992 if(!srv_io_share_info1007_str("", &info1007[i].info_1007_str, ps, depth))
993 return False;
996 break;
999 case 1501:
1001 SRV_SHARE_INFO_1501 *info1501 = ctr->share.info1501;
1002 int num_entries = ctr->num_entries;
1003 int i;
1005 if (UNMARSHALLING(ps)) {
1006 if (!(info1501 = PRS_ALLOC_MEM(ps,SRV_SHARE_INFO_1501,num_entries)))
1007 return False;
1008 ctr->share.info1501 = info1501;
1011 for (i = 0; i < num_entries; i++) {
1012 if(!srv_io_share_info1501("", &info1501[i], ps, depth))
1013 return False;
1016 break;
1019 default:
1020 DEBUG(5,("%s no share info at switch_value %d\n",
1021 tab_depth(depth), ctr->switch_value));
1022 break;
1025 return True;
1028 /*******************************************************************
1029 Inits a SRV_Q_NET_SHARE_ENUM structure.
1030 ********************************************************************/
1032 void init_srv_q_net_share_enum(SRV_Q_NET_SHARE_ENUM *q_n,
1033 const char *srv_name, uint32 info_level,
1034 uint32 preferred_len, ENUM_HND *hnd)
1037 DEBUG(5,("init_q_net_share_enum\n"));
1039 init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
1041 q_n->ctr.info_level = q_n->ctr.switch_value = info_level;
1042 q_n->ctr.ptr_share_info = 1;
1043 q_n->ctr.num_entries = 0;
1044 q_n->ctr.ptr_entries = 0;
1045 q_n->ctr.num_entries2 = 0;
1046 q_n->preferred_len = preferred_len;
1048 memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
1051 /*******************************************************************
1052 Reads or writes a structure.
1053 ********************************************************************/
1055 BOOL srv_io_q_net_share_enum(const char *desc, SRV_Q_NET_SHARE_ENUM *q_n, prs_struct *ps, int depth)
1057 if (q_n == NULL)
1058 return False;
1060 prs_debug(ps, depth, desc, "srv_io_q_net_share_enum");
1061 depth++;
1063 if(!prs_align(ps))
1064 return False;
1066 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
1067 return False;
1068 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1069 return False;
1071 if(!srv_io_srv_share_ctr("share_ctr", &q_n->ctr, ps, depth))
1072 return False;
1074 if(!prs_align(ps))
1075 return False;
1077 if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
1078 return False;
1080 if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
1081 return False;
1083 return True;
1086 /*******************************************************************
1087 Reads or writes a structure.
1088 ********************************************************************/
1090 BOOL srv_io_r_net_share_enum(const char *desc, SRV_R_NET_SHARE_ENUM *r_n, prs_struct *ps, int depth)
1092 if (r_n == NULL)
1093 return False;
1095 prs_debug(ps, depth, desc, "srv_io_r_net_share_enum");
1096 depth++;
1098 if(!srv_io_srv_share_ctr("share_ctr", &r_n->ctr, ps, depth))
1099 return False;
1101 if(!prs_align(ps))
1102 return False;
1104 if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
1105 return False;
1107 if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
1108 return False;
1110 if(!prs_werror("status", ps, depth, &r_n->status))
1111 return False;
1113 return True;
1116 /*******************************************************************
1117 initialises a structure.
1118 ********************************************************************/
1120 BOOL init_srv_q_net_share_get_info(SRV_Q_NET_SHARE_GET_INFO *q_n, const char *srv_name, const char *share_name, uint32 info_level)
1123 uint32 ptr_share_name;
1125 DEBUG(5,("init_srv_q_net_share_get_info\n"));
1127 init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
1128 init_buf_unistr2(&q_n->uni_share_name, &ptr_share_name, share_name);
1130 q_n->info_level = info_level;
1132 return True;
1135 /*******************************************************************
1136 Reads or writes a structure.
1137 ********************************************************************/
1139 BOOL srv_io_q_net_share_get_info(const char *desc, SRV_Q_NET_SHARE_GET_INFO *q_n, prs_struct *ps, int depth)
1141 if (q_n == NULL)
1142 return False;
1144 prs_debug(ps, depth, desc, "srv_io_q_net_share_get_info");
1145 depth++;
1147 if(!prs_align(ps))
1148 return False;
1150 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
1151 return False;
1152 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1153 return False;
1155 if(!smb_io_unistr2("", &q_n->uni_share_name, True, ps, depth))
1156 return False;
1158 if(!prs_align(ps))
1159 return False;
1161 if(!prs_uint32("info_level", ps, depth, &q_n->info_level))
1162 return False;
1164 return True;
1167 /*******************************************************************
1168 Reads or writes a structure.
1169 ********************************************************************/
1171 static BOOL srv_io_srv_share_info(const char *desc, prs_struct *ps, int depth, SRV_SHARE_INFO *r_n)
1173 if (r_n == NULL)
1174 return False;
1176 prs_debug(ps, depth, desc, "srv_io_srv_share_info");
1177 depth++;
1179 if(!prs_align(ps))
1180 return False;
1182 if(!prs_uint32("switch_value ", ps, depth, &r_n->switch_value ))
1183 return False;
1185 if(!prs_uint32("ptr_share_ctr", ps, depth, &r_n->ptr_share_ctr))
1186 return False;
1188 if (r_n->ptr_share_ctr != 0) {
1189 switch (r_n->switch_value) {
1190 case 0:
1191 if(!srv_io_share_info0("", &r_n->share.info0.info_0, ps, depth))
1192 return False;
1194 /* allow access to pointers in the str part. */
1195 r_n->share.info0.info_0_str.ptrs = &r_n->share.info0.info_0;
1197 if(!srv_io_share_info0_str("", &r_n->share.info0.info_0_str, ps, depth))
1198 return False;
1200 break;
1201 case 1:
1202 if(!srv_io_share_info1("", &r_n->share.info1.info_1, ps, depth))
1203 return False;
1205 /* allow access to pointers in the str part. */
1206 r_n->share.info1.info_1_str.ptrs = &r_n->share.info1.info_1;
1208 if(!srv_io_share_info1_str("", &r_n->share.info1.info_1_str, ps, depth))
1209 return False;
1211 break;
1212 case 2:
1213 if(!srv_io_share_info2("", &r_n->share.info2.info_2, ps, depth))
1214 return False;
1216 if(!srv_io_share_info2_str("", &r_n->share.info2.info_2, &r_n->share.info2.info_2_str, ps, depth))
1217 return False;
1219 break;
1220 case 501:
1221 if (!srv_io_share_info501("", &r_n->share.info501.info_501, ps, depth))
1222 return False;
1223 if (!srv_io_share_info501_str("", &r_n->share.info501.info_501_str, ps, depth))
1224 return False;
1225 break;
1227 case 502:
1228 if(!srv_io_share_info502("", &r_n->share.info502.info_502, ps, depth))
1229 return False;
1231 /* allow access to pointers in the str part. */
1232 r_n->share.info502.info_502_str.ptrs = &r_n->share.info502.info_502;
1234 if(!srv_io_share_info502_str("", &r_n->share.info502.info_502_str, ps, depth))
1235 return False;
1236 break;
1237 case 1004:
1238 if(!srv_io_share_info1004("", &r_n->share.info1004.info_1004, ps, depth))
1239 return False;
1241 /* allow access to pointers in the str part. */
1242 r_n->share.info1004.info_1004_str.ptrs = &r_n->share.info1004.info_1004;
1244 if(!srv_io_share_info1004_str("", &r_n->share.info1004.info_1004_str, ps, depth))
1245 return False;
1246 break;
1247 case 1005:
1248 if(!srv_io_share_info1005("", &r_n->share.info1005, ps, depth))
1249 return False;
1250 break;
1251 case 1006:
1252 if(!srv_io_share_info1006("", &r_n->share.info1006, ps, depth))
1253 return False;
1254 break;
1255 case 1007:
1256 if(!srv_io_share_info1007("", &r_n->share.info1007.info_1007, ps, depth))
1257 return False;
1259 /* allow access to pointers in the str part. */
1260 r_n->share.info1007.info_1007_str.ptrs = &r_n->share.info1007.info_1007;
1262 if(!srv_io_share_info1007_str("", &r_n->share.info1007.info_1007_str, ps, depth))
1263 return False;
1264 break;
1265 case 1501:
1266 if (!srv_io_share_info1501("", &r_n->share.info1501, ps, depth))
1267 return False;
1268 default:
1269 DEBUG(5,("%s no share info at switch_value %d\n",
1270 tab_depth(depth), r_n->switch_value));
1271 break;
1275 return True;
1278 /*******************************************************************
1279 Reads or writes a structure.
1280 ********************************************************************/
1282 BOOL srv_io_r_net_share_get_info(const char *desc, SRV_R_NET_SHARE_GET_INFO *r_n, prs_struct *ps, int depth)
1284 if (r_n == NULL)
1285 return False;
1287 prs_debug(ps, depth, desc, "srv_io_r_net_share_get_info");
1288 depth++;
1290 if(!prs_align(ps))
1291 return False;
1293 if(!srv_io_srv_share_info("info ", ps, depth, &r_n->info))
1294 return False;
1296 if(!prs_align(ps))
1297 return False;
1299 if(!prs_werror("status", ps, depth, &r_n->status))
1300 return False;
1302 return True;
1305 /*******************************************************************
1306 intialises a structure.
1307 ********************************************************************/
1309 BOOL init_srv_q_net_share_set_info(SRV_Q_NET_SHARE_SET_INFO *q_n,
1310 const char *srv_name,
1311 const char *share_name,
1312 uint32 info_level,
1313 const SRV_SHARE_INFO *info)
1316 uint32 ptr_share_name;
1318 DEBUG(5,("init_srv_q_net_share_set_info\n"));
1320 init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
1321 init_buf_unistr2(&q_n->uni_share_name, &ptr_share_name, share_name);
1323 q_n->info_level = info_level;
1325 q_n->info = *info;
1327 q_n->ptr_parm_error = 1;
1328 q_n->parm_error = 0;
1330 return True;
1333 /*******************************************************************
1334 Reads or writes a structure.
1335 ********************************************************************/
1337 BOOL srv_io_q_net_share_set_info(const char *desc, SRV_Q_NET_SHARE_SET_INFO *q_n, prs_struct *ps, int depth)
1339 if (q_n == NULL)
1340 return False;
1342 prs_debug(ps, depth, desc, "srv_io_q_net_share_set_info");
1343 depth++;
1345 if(!prs_align(ps))
1346 return False;
1348 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
1349 return False;
1350 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1351 return False;
1353 if(!smb_io_unistr2("", &q_n->uni_share_name, True, ps, depth))
1354 return False;
1356 if(!prs_align(ps))
1357 return False;
1359 if(!prs_uint32("info_level", ps, depth, &q_n->info_level))
1360 return False;
1362 if(!prs_align(ps))
1363 return False;
1365 if(!srv_io_srv_share_info("info ", ps, depth, &q_n->info))
1366 return False;
1368 if(!prs_align(ps))
1369 return False;
1370 if(!prs_uint32("ptr_parm_error", ps, depth, &q_n->ptr_parm_error))
1371 return False;
1372 if(q_n->ptr_parm_error!=0) {
1373 if(!prs_uint32("parm_error", ps, depth, &q_n->parm_error))
1374 return False;
1377 return True;
1380 /*******************************************************************
1381 Reads or writes a structure.
1382 ********************************************************************/
1384 BOOL srv_io_r_net_share_set_info(const char *desc, SRV_R_NET_SHARE_SET_INFO *r_n, prs_struct *ps, int depth)
1386 if (r_n == NULL)
1387 return False;
1389 prs_debug(ps, depth, desc, "srv_io_r_net_share_set_info");
1390 depth++;
1392 if(!prs_align(ps))
1393 return False;
1395 if(!prs_uint32("ptr_parm_error ", ps, depth, &r_n->ptr_parm_error))
1396 return False;
1398 if(r_n->ptr_parm_error) {
1400 if(!prs_uint32("parm_error ", ps, depth, &r_n->parm_error))
1401 return False;
1404 if(!prs_werror("status", ps, depth, &r_n->status))
1405 return False;
1407 return True;
1411 /*******************************************************************
1412 Reads or writes a structure.
1413 ********************************************************************/
1415 BOOL srv_io_q_net_share_add(const char *desc, SRV_Q_NET_SHARE_ADD *q_n, prs_struct *ps, int depth)
1417 if (q_n == NULL)
1418 return False;
1420 prs_debug(ps, depth, desc, "srv_io_q_net_share_add");
1421 depth++;
1423 if(!prs_align(ps))
1424 return False;
1426 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
1427 return False;
1428 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1429 return False;
1431 if(!prs_align(ps))
1432 return False;
1434 if(!prs_uint32("info_level", ps, depth, &q_n->info_level))
1435 return False;
1437 if(!prs_align(ps))
1438 return False;
1440 if(!srv_io_srv_share_info("info ", ps, depth, &q_n->info))
1441 return False;
1443 if(!prs_align(ps))
1444 return False;
1446 if(!prs_uint32("ptr_err_index", ps, depth, &q_n->ptr_err_index))
1447 return False;
1448 if (q_n->ptr_err_index)
1449 if (!prs_uint32("err_index", ps, depth, &q_n->err_index))
1450 return False;
1452 return True;
1455 void init_srv_q_net_share_add(SRV_Q_NET_SHARE_ADD *q, const char *srvname,
1456 const char *netname, uint32 type, const char *remark,
1457 uint32 perms, uint32 max_uses, uint32 num_uses,
1458 const char *path, const char *passwd,
1459 int level, SEC_DESC *sd)
1461 switch(level) {
1462 case 502: {
1463 size_t sd_size = sec_desc_size(sd);
1464 q->ptr_srv_name = 1;
1465 init_unistr2(&q->uni_srv_name, srvname, UNI_STR_TERMINATE);
1466 q->info.switch_value = q->info_level = level;
1467 q->info.ptr_share_ctr = 1;
1468 init_srv_share_info502(&q->info.share.info502.info_502, netname, type,
1469 remark, perms, max_uses, num_uses, path, passwd, sd, sd_size);
1470 init_srv_share_info502_str(&q->info.share.info502.info_502_str, netname,
1471 remark, path, passwd, sd, sd_size);
1472 q->ptr_err_index = 1;
1473 q->err_index = 0;
1475 break;
1476 case 2:
1477 default:
1478 q->ptr_srv_name = 1;
1479 init_unistr2(&q->uni_srv_name, srvname, UNI_STR_TERMINATE);
1480 q->info.switch_value = q->info_level = level;
1481 q->info.ptr_share_ctr = 1;
1482 init_srv_share_info2(&q->info.share.info2.info_2, netname, type,
1483 remark, perms, max_uses, num_uses, path, passwd);
1484 init_srv_share_info2_str(&q->info.share.info2.info_2_str, netname,
1485 remark, path, passwd);
1486 q->ptr_err_index = 1;
1487 q->err_index = 0;
1488 break;
1493 /*******************************************************************
1494 Reads or writes a structure.
1495 ********************************************************************/
1497 BOOL srv_io_r_net_share_add(const char *desc, SRV_R_NET_SHARE_ADD *r_n, prs_struct *ps, int depth)
1499 if (r_n == NULL)
1500 return False;
1502 prs_debug(ps, depth, desc, "srv_io_r_net_share_add");
1503 depth++;
1505 if(!prs_align(ps))
1506 return False;
1508 if(!prs_uint32("ptr_parm_error", ps, depth, &r_n->ptr_parm_error))
1509 return False;
1511 if(r_n->ptr_parm_error) {
1513 if(!prs_uint32("parm_error", ps, depth, &r_n->parm_error))
1514 return False;
1517 if(!prs_werror("status", ps, depth, &r_n->status))
1518 return False;
1520 return True;
1523 /*******************************************************************
1524 initialises a structure.
1525 ********************************************************************/
1527 void init_srv_q_net_share_del(SRV_Q_NET_SHARE_DEL *del, const char *srvname,
1528 const char *sharename)
1530 del->ptr_srv_name = 1;
1531 init_unistr2(&del->uni_srv_name, srvname, UNI_STR_TERMINATE);
1532 init_unistr2(&del->uni_share_name, sharename, UNI_STR_TERMINATE);
1535 /*******************************************************************
1536 Reads or writes a structure.
1537 ********************************************************************/
1539 BOOL srv_io_q_net_share_del(const char *desc, SRV_Q_NET_SHARE_DEL *q_n, prs_struct *ps, int depth)
1541 if (q_n == NULL)
1542 return False;
1544 prs_debug(ps, depth, desc, "srv_io_q_net_share_del");
1545 depth++;
1547 if(!prs_align(ps))
1548 return False;
1550 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
1551 return False;
1552 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1553 return False;
1555 if(!smb_io_unistr2("", &q_n->uni_share_name, True, ps, depth))
1556 return False;
1558 if(!prs_align(ps))
1559 return False;
1560 if(!prs_uint32("reserved", ps, depth, &q_n->reserved))
1561 return False;
1563 return True;
1566 /*******************************************************************
1567 Reads or writes a structure.
1568 ********************************************************************/
1570 BOOL srv_io_r_net_share_del(const char *desc, SRV_R_NET_SHARE_DEL *q_n, prs_struct *ps, int depth)
1572 if (q_n == NULL)
1573 return False;
1575 prs_debug(ps, depth, desc, "srv_io_r_net_share_del");
1576 depth++;
1578 if(!prs_align(ps))
1579 return False;
1581 if(!prs_werror("status", ps, depth, &q_n->status))
1582 return False;
1584 return True;
1587 /*******************************************************************
1588 Inits a SESS_INFO_0_STR structure
1589 ********************************************************************/
1591 void init_srv_sess_info0_str(SESS_INFO_0_STR *ss0, const char *name)
1593 DEBUG(5,("init_srv_sess_info0_str\n"));
1595 init_unistr2(&ss0->uni_name, name, UNI_STR_TERMINATE);
1598 /*******************************************************************
1599 Reads or writes a structure.
1600 ********************************************************************/
1602 static BOOL srv_io_sess_info0_str(const char *desc, SESS_INFO_0_STR *ss0, prs_struct *ps, int depth)
1604 if (ss0 == NULL)
1605 return False;
1607 prs_debug(ps, depth, desc, "srv_io_sess_info0_str");
1608 depth++;
1610 if(!prs_align(ps))
1611 return False;
1613 if(!smb_io_unistr2("", &ss0->uni_name, True, ps, depth))
1614 return False;
1616 return True;
1619 /*******************************************************************
1620 Inits a SESS_INFO_0 structure
1621 ********************************************************************/
1623 void init_srv_sess_info0(SESS_INFO_0 *ss0, const char *name)
1625 DEBUG(5,("init_srv_sess_info0: %s\n", name));
1627 ss0->ptr_name = (name != NULL) ? 1 : 0;
1630 /*******************************************************************
1631 Reads or writes a structure.
1632 ********************************************************************/
1634 static BOOL srv_io_sess_info0(const char *desc, SESS_INFO_0 *ss0, prs_struct *ps, int depth)
1636 if (ss0 == NULL)
1637 return False;
1639 prs_debug(ps, depth, desc, "srv_io_sess_info0");
1640 depth++;
1642 if(!prs_align(ps))
1643 return False;
1645 if(!prs_uint32("ptr_name", ps, depth, &ss0->ptr_name))
1646 return False;
1648 return True;
1651 /*******************************************************************
1652 Reads or writes a structure.
1653 ********************************************************************/
1655 static BOOL srv_io_srv_sess_info_0(const char *desc, SRV_SESS_INFO_0 *ss0, prs_struct *ps, int depth)
1657 if (ss0 == NULL)
1658 return False;
1660 prs_debug(ps, depth, desc, "srv_io_srv_sess_info_0");
1661 depth++;
1663 if(!prs_align(ps))
1664 return False;
1666 if(!prs_uint32("num_entries_read", ps, depth, &ss0->num_entries_read))
1667 return False;
1668 if(!prs_uint32("ptr_sess_info", ps, depth, &ss0->ptr_sess_info))
1669 return False;
1671 if (ss0->ptr_sess_info != 0) {
1672 uint32 i;
1673 uint32 num_entries = ss0->num_entries_read;
1675 if (num_entries > MAX_SESS_ENTRIES) {
1676 num_entries = MAX_SESS_ENTRIES; /* report this! */
1679 if(!prs_uint32("num_entries_read2", ps, depth, &ss0->num_entries_read2))
1680 return False;
1682 SMB_ASSERT_ARRAY(ss0->info_0, num_entries);
1684 for (i = 0; i < num_entries; i++) {
1685 if(!srv_io_sess_info0("", &ss0->info_0[i], ps, depth))
1686 return False;
1689 for (i = 0; i < num_entries; i++) {
1690 if(!srv_io_sess_info0_str("", &ss0->info_0_str[i], ps, depth))
1691 return False;
1694 if(!prs_align(ps))
1695 return False;
1698 return True;
1701 /*******************************************************************
1702 Inits a SESS_INFO_1_STR structure
1703 ********************************************************************/
1705 void init_srv_sess_info1_str(SESS_INFO_1_STR *ss1, const char *name, const char *user)
1707 DEBUG(5,("init_srv_sess_info1_str\n"));
1709 init_unistr2(&ss1->uni_name, name, UNI_STR_TERMINATE);
1710 init_unistr2(&ss1->uni_user, user, UNI_STR_TERMINATE);
1713 /*******************************************************************
1714 Reads or writes a structure.
1715 ********************************************************************/
1717 static BOOL srv_io_sess_info1_str(const char *desc, SESS_INFO_1_STR *ss1, prs_struct *ps, int depth)
1719 if (ss1 == NULL)
1720 return False;
1722 prs_debug(ps, depth, desc, "srv_io_sess_info1_str");
1723 depth++;
1725 if(!prs_align(ps))
1726 return False;
1728 if(!smb_io_unistr2("", &ss1->uni_name, True, ps, depth))
1729 return False;
1730 if(!smb_io_unistr2("", &(ss1->uni_user), True, ps, depth))
1731 return False;
1733 return True;
1736 /*******************************************************************
1737 Inits a SESS_INFO_1 structure
1738 ********************************************************************/
1740 void init_srv_sess_info1(SESS_INFO_1 *ss1,
1741 const char *name, const char *user,
1742 uint32 num_opens, uint32 open_time, uint32 idle_time,
1743 uint32 user_flags)
1745 DEBUG(5,("init_srv_sess_info1: %s\n", name));
1747 ss1->ptr_name = (name != NULL) ? 1 : 0;
1748 ss1->ptr_user = (user != NULL) ? 1 : 0;
1750 ss1->num_opens = num_opens;
1751 ss1->open_time = open_time;
1752 ss1->idle_time = idle_time;
1753 ss1->user_flags = user_flags;
1756 /*******************************************************************
1757 reads or writes a structure.
1758 ********************************************************************/
1760 static BOOL srv_io_sess_info1(const char *desc, SESS_INFO_1 *ss1, prs_struct *ps, int depth)
1762 if (ss1 == NULL)
1763 return False;
1765 prs_debug(ps, depth, desc, "srv_io_sess_info1");
1766 depth++;
1768 if(!prs_align(ps))
1769 return False;
1771 if(!prs_uint32("ptr_name ", ps, depth, &ss1->ptr_name))
1772 return False;
1773 if(!prs_uint32("ptr_user ", ps, depth, &ss1->ptr_user))
1774 return False;
1776 if(!prs_uint32("num_opens ", ps, depth, &ss1->num_opens))
1777 return False;
1778 if(!prs_uint32("open_time ", ps, depth, &ss1->open_time))
1779 return False;
1780 if(!prs_uint32("idle_time ", ps, depth, &ss1->idle_time))
1781 return False;
1782 if(!prs_uint32("user_flags", ps, depth, &ss1->user_flags))
1783 return False;
1785 return True;
1788 /*******************************************************************
1789 Reads or writes a structure.
1790 ********************************************************************/
1792 static BOOL srv_io_srv_sess_info_1(const char *desc, SRV_SESS_INFO_1 *ss1, prs_struct *ps, int depth)
1794 if (ss1 == NULL)
1795 return False;
1797 prs_debug(ps, depth, desc, "srv_io_srv_sess_info_1");
1798 depth++;
1800 if(!prs_align(ps))
1801 return False;
1803 if(!prs_uint32("num_entries_read", ps, depth, &ss1->num_entries_read))
1804 return False;
1805 if(!prs_uint32("ptr_sess_info", ps, depth, &ss1->ptr_sess_info))
1806 return False;
1808 if (ss1->ptr_sess_info != 0) {
1809 uint32 i;
1810 uint32 num_entries = ss1->num_entries_read;
1812 if (num_entries > MAX_SESS_ENTRIES) {
1813 num_entries = MAX_SESS_ENTRIES; /* report this! */
1816 if(!prs_uint32("num_entries_read2", ps, depth, &ss1->num_entries_read2))
1817 return False;
1819 SMB_ASSERT_ARRAY(ss1->info_1, num_entries);
1821 for (i = 0; i < num_entries; i++) {
1822 if(!srv_io_sess_info1("", &ss1->info_1[i], ps, depth))
1823 return False;
1826 for (i = 0; i < num_entries; i++) {
1827 if(!srv_io_sess_info1_str("", &ss1->info_1_str[i], ps, depth))
1828 return False;
1831 if(!prs_align(ps))
1832 return False;
1835 return True;
1838 /*******************************************************************
1839 Reads or writes a structure.
1840 ********************************************************************/
1842 static BOOL srv_io_srv_sess_ctr(const char *desc, SRV_SESS_INFO_CTR **pp_ctr, prs_struct *ps, int depth)
1844 SRV_SESS_INFO_CTR *ctr = *pp_ctr;
1846 prs_debug(ps, depth, desc, "srv_io_srv_sess_ctr");
1847 depth++;
1849 if(UNMARSHALLING(ps)) {
1850 ctr = *pp_ctr = PRS_ALLOC_MEM(ps, SRV_SESS_INFO_CTR, 1);
1851 if (ctr == NULL)
1852 return False;
1855 if (ctr == NULL)
1856 return False;
1858 if(!prs_align(ps))
1859 return False;
1861 if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
1862 return False;
1863 if(!prs_uint32("ptr_sess_ctr", ps, depth, &ctr->ptr_sess_ctr))
1864 return False;
1866 if (ctr->ptr_sess_ctr != 0) {
1867 switch (ctr->switch_value) {
1868 case 0:
1869 if(!srv_io_srv_sess_info_0("", &ctr->sess.info0, ps, depth))
1870 return False;
1871 break;
1872 case 1:
1873 if(!srv_io_srv_sess_info_1("", &ctr->sess.info1, ps, depth))
1874 return False;
1875 break;
1876 default:
1877 DEBUG(5,("%s no session info at switch_value %d\n",
1878 tab_depth(depth), ctr->switch_value));
1879 break;
1883 return True;
1886 /*******************************************************************
1887 Inits a SRV_Q_NET_SESS_ENUM structure.
1888 ********************************************************************/
1890 void init_srv_q_net_sess_enum(SRV_Q_NET_SESS_ENUM *q_n,
1891 const char *srv_name, const char *qual_name,
1892 const char *user_name, uint32 sess_level,
1893 SRV_SESS_INFO_CTR *ctr, uint32 preferred_len,
1894 ENUM_HND *hnd)
1896 q_n->ctr = ctr;
1898 DEBUG(5,("init_q_net_sess_enum\n"));
1900 init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
1901 init_buf_unistr2(&q_n->uni_qual_name, &q_n->ptr_qual_name, qual_name);
1902 init_buf_unistr2(&q_n->uni_user_name, &q_n->ptr_user_name, user_name);
1904 q_n->sess_level = sess_level;
1905 q_n->preferred_len = preferred_len;
1907 memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
1910 /*******************************************************************
1911 Reads or writes a structure.
1912 ********************************************************************/
1914 BOOL srv_io_q_net_sess_enum(const char *desc, SRV_Q_NET_SESS_ENUM *q_n, prs_struct *ps, int depth)
1916 if (q_n == NULL)
1917 return False;
1919 prs_debug(ps, depth, desc, "srv_io_q_net_sess_enum");
1920 depth++;
1922 if(!prs_align(ps))
1923 return False;
1925 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
1926 return False;
1927 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1928 return False;
1930 if(!prs_align(ps))
1931 return False;
1933 if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
1934 return False;
1935 if(!smb_io_unistr2("", &q_n->uni_qual_name, q_n->ptr_qual_name, ps, depth))
1936 return False;
1938 if(!prs_align(ps))
1939 return False;
1940 if(!prs_uint32("ptr_user_name", ps, depth, &q_n->ptr_user_name))
1941 return False;
1942 if(!smb_io_unistr2("", &q_n->uni_user_name, q_n->ptr_user_name, ps, depth))
1943 return False;
1945 if(!prs_align(ps))
1946 return False;
1948 if(!prs_uint32("sess_level", ps, depth, &q_n->sess_level))
1949 return False;
1951 if (q_n->sess_level != (uint32)-1) {
1952 if(!srv_io_srv_sess_ctr("sess_ctr", &q_n->ctr, ps, depth))
1953 return False;
1956 if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
1957 return False;
1959 if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
1960 return False;
1962 return True;
1965 /*******************************************************************
1966 Reads or writes a structure.
1967 ********************************************************************/
1969 BOOL srv_io_r_net_sess_enum(const char *desc, SRV_R_NET_SESS_ENUM *r_n, prs_struct *ps, int depth)
1971 if (r_n == NULL)
1972 return False;
1974 prs_debug(ps, depth, desc, "srv_io_r_net_sess_enum");
1975 depth++;
1977 if(!prs_align(ps))
1978 return False;
1980 if(!prs_uint32("sess_level", ps, depth, &r_n->sess_level))
1981 return False;
1983 if (r_n->sess_level != (uint32)-1) {
1984 if(!srv_io_srv_sess_ctr("sess_ctr", &r_n->ctr, ps, depth))
1985 return False;
1988 if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
1989 return False;
1990 if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
1991 return False;
1992 if(!prs_werror("status", ps, depth, &r_n->status))
1993 return False;
1995 return True;
1998 /*******************************************************************
1999 Inits a CONN_INFO_0 structure
2000 ********************************************************************/
2002 void init_srv_conn_info0(CONN_INFO_0 *ss0, uint32 id)
2004 DEBUG(5,("init_srv_conn_info0\n"));
2006 ss0->id = id;
2009 /*******************************************************************
2010 Reads or writes a structure.
2011 ********************************************************************/
2013 static BOOL srv_io_conn_info0(const char *desc, CONN_INFO_0 *ss0, prs_struct *ps, int depth)
2015 if (ss0 == NULL)
2016 return False;
2018 prs_debug(ps, depth, desc, "srv_io_conn_info0");
2019 depth++;
2021 if(!prs_align(ps))
2022 return False;
2024 if(!prs_uint32("id", ps, depth, &ss0->id))
2025 return False;
2027 return True;
2030 /*******************************************************************
2031 Reads or writes a structure.
2032 ********************************************************************/
2034 static BOOL srv_io_srv_conn_info_0(const char *desc, SRV_CONN_INFO_0 *ss0, prs_struct *ps, int depth)
2036 if (ss0 == NULL)
2037 return False;
2039 prs_debug(ps, depth, desc, "srv_io_srv_conn_info_0");
2040 depth++;
2042 if(!prs_align(ps))
2043 return False;
2045 if(!prs_uint32("num_entries_read", ps, depth, &ss0->num_entries_read))
2046 return False;
2047 if(!prs_uint32("ptr_conn_info", ps, depth, &ss0->ptr_conn_info))
2048 return False;
2050 if (ss0->ptr_conn_info != 0) {
2051 int i;
2052 int num_entries = ss0->num_entries_read;
2054 if (num_entries > MAX_CONN_ENTRIES) {
2055 num_entries = MAX_CONN_ENTRIES; /* report this! */
2058 if(!prs_uint32("num_entries_read2", ps, depth, &ss0->num_entries_read2))
2059 return False;
2061 for (i = 0; i < num_entries; i++) {
2062 if(!srv_io_conn_info0("", &ss0->info_0[i], ps, depth))
2063 return False;
2066 if(!prs_align(ps))
2067 return False;
2070 return True;
2073 /*******************************************************************
2074 Inits a CONN_INFO_1_STR structure
2075 ********************************************************************/
2077 void init_srv_conn_info1_str(CONN_INFO_1_STR *ss1, const char *usr_name, const char *net_name)
2079 DEBUG(5,("init_srv_conn_info1_str\n"));
2081 init_unistr2(&ss1->uni_usr_name, usr_name, UNI_STR_TERMINATE);
2082 init_unistr2(&ss1->uni_net_name, net_name, UNI_STR_TERMINATE);
2085 /*******************************************************************
2086 Reads or writes a structure.
2087 ********************************************************************/
2089 static BOOL srv_io_conn_info1_str(const char *desc, CONN_INFO_1_STR *ss1, prs_struct *ps, int depth)
2091 if (ss1 == NULL)
2092 return False;
2094 prs_debug(ps, depth, desc, "srv_io_conn_info1_str");
2095 depth++;
2097 if(!prs_align(ps))
2098 return False;
2100 if(!smb_io_unistr2("", &ss1->uni_usr_name, True, ps, depth))
2101 return False;
2102 if(!smb_io_unistr2("", &ss1->uni_net_name, True, ps, depth))
2103 return False;
2105 return True;
2108 /*******************************************************************
2109 Inits a CONN_INFO_1 structure
2110 ********************************************************************/
2112 void init_srv_conn_info1(CONN_INFO_1 *ss1,
2113 uint32 id, uint32 type,
2114 uint32 num_opens, uint32 num_users, uint32 open_time,
2115 const char *usr_name, const char *net_name)
2117 DEBUG(5,("init_srv_conn_info1: %s %s\n", usr_name, net_name));
2119 ss1->id = id ;
2120 ss1->type = type ;
2121 ss1->num_opens = num_opens ;
2122 ss1->num_users = num_users;
2123 ss1->open_time = open_time;
2125 ss1->ptr_usr_name = (usr_name != NULL) ? 1 : 0;
2126 ss1->ptr_net_name = (net_name != NULL) ? 1 : 0;
2129 /*******************************************************************
2130 Reads or writes a structure.
2131 ********************************************************************/
2133 static BOOL srv_io_conn_info1(const char *desc, CONN_INFO_1 *ss1, prs_struct *ps, int depth)
2135 if (ss1 == NULL)
2136 return False;
2138 prs_debug(ps, depth, desc, "srv_io_conn_info1");
2139 depth++;
2141 if(!prs_align(ps))
2142 return False;
2144 if(!prs_uint32("id ", ps, depth, &ss1->id))
2145 return False;
2146 if(!prs_uint32("type ", ps, depth, &ss1->type))
2147 return False;
2148 if(!prs_uint32("num_opens ", ps, depth, &ss1->num_opens))
2149 return False;
2150 if(!prs_uint32("num_users ", ps, depth, &ss1->num_users))
2151 return False;
2152 if(!prs_uint32("open_time ", ps, depth, &ss1->open_time))
2153 return False;
2155 if(!prs_uint32("ptr_usr_name", ps, depth, &ss1->ptr_usr_name))
2156 return False;
2157 if(!prs_uint32("ptr_net_name", ps, depth, &ss1->ptr_net_name))
2158 return False;
2160 return True;
2163 /*******************************************************************
2164 Reads or writes a structure.
2165 ********************************************************************/
2167 static BOOL srv_io_srv_conn_info_1(const char *desc, SRV_CONN_INFO_1 *ss1, prs_struct *ps, int depth)
2169 if (ss1 == NULL)
2170 return False;
2172 prs_debug(ps, depth, desc, "srv_io_srv_conn_info_1");
2173 depth++;
2175 if(!prs_align(ps))
2176 return False;
2178 if(!prs_uint32("num_entries_read", ps, depth, &ss1->num_entries_read))
2179 return False;
2180 if(!prs_uint32("ptr_conn_info", ps, depth, &ss1->ptr_conn_info))
2181 return False;
2183 if (ss1->ptr_conn_info != 0) {
2184 int i;
2185 int num_entries = ss1->num_entries_read;
2187 if (num_entries > MAX_CONN_ENTRIES) {
2188 num_entries = MAX_CONN_ENTRIES; /* report this! */
2191 if(!prs_uint32("num_entries_read2", ps, depth, &ss1->num_entries_read2))
2192 return False;
2194 for (i = 0; i < num_entries; i++) {
2195 if(!srv_io_conn_info1("", &ss1->info_1[i], ps, depth))
2196 return False;
2199 for (i = 0; i < num_entries; i++) {
2200 if(!srv_io_conn_info1_str("", &ss1->info_1_str[i], ps, depth))
2201 return False;
2204 if(!prs_align(ps))
2205 return False;
2208 return True;
2211 /*******************************************************************
2212 Reads or writes a structure.
2213 ********************************************************************/
2215 static BOOL srv_io_srv_conn_ctr(const char *desc, SRV_CONN_INFO_CTR **pp_ctr, prs_struct *ps, int depth)
2217 SRV_CONN_INFO_CTR *ctr = *pp_ctr;
2219 prs_debug(ps, depth, desc, "srv_io_srv_conn_ctr");
2220 depth++;
2222 if (UNMARSHALLING(ps)) {
2223 ctr = *pp_ctr = PRS_ALLOC_MEM(ps, SRV_CONN_INFO_CTR, 1);
2224 if (ctr == NULL)
2225 return False;
2228 if (ctr == NULL)
2229 return False;
2231 if(!prs_align(ps))
2232 return False;
2234 if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
2235 return False;
2236 if(!prs_uint32("ptr_conn_ctr", ps, depth, &ctr->ptr_conn_ctr))
2237 return False;
2239 if (ctr->ptr_conn_ctr != 0) {
2240 switch (ctr->switch_value) {
2241 case 0:
2242 if(!srv_io_srv_conn_info_0("", &ctr->conn.info0, ps, depth))
2243 return False;
2244 break;
2245 case 1:
2246 if(!srv_io_srv_conn_info_1("", &ctr->conn.info1, ps, depth))
2247 return False;
2248 break;
2249 default:
2250 DEBUG(5,("%s no connection info at switch_value %d\n",
2251 tab_depth(depth), ctr->switch_value));
2252 break;
2256 return True;
2259 /*******************************************************************
2260 Reads or writes a structure.
2261 ********************************************************************/
2263 void init_srv_q_net_conn_enum(SRV_Q_NET_CONN_ENUM *q_n,
2264 const char *srv_name, const char *qual_name,
2265 uint32 conn_level, SRV_CONN_INFO_CTR *ctr,
2266 uint32 preferred_len,
2267 ENUM_HND *hnd)
2269 DEBUG(5,("init_q_net_conn_enum\n"));
2271 q_n->ctr = ctr;
2273 init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name );
2274 init_buf_unistr2(&q_n->uni_qual_name, &q_n->ptr_qual_name, qual_name);
2276 q_n->conn_level = conn_level;
2277 q_n->preferred_len = preferred_len;
2279 memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
2282 /*******************************************************************
2283 Reads or writes a structure.
2284 ********************************************************************/
2286 BOOL srv_io_q_net_conn_enum(const char *desc, SRV_Q_NET_CONN_ENUM *q_n, prs_struct *ps, int depth)
2288 if (q_n == NULL)
2289 return False;
2291 prs_debug(ps, depth, desc, "srv_io_q_net_conn_enum");
2292 depth++;
2294 if(!prs_align(ps))
2295 return False;
2297 if(!prs_uint32("ptr_srv_name ", ps, depth, &q_n->ptr_srv_name))
2298 return False;
2299 if(!smb_io_unistr2("", &q_n->uni_srv_name, q_n->ptr_srv_name, ps, depth))
2300 return False;
2302 if(!prs_align(ps))
2303 return False;
2305 if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
2306 return False;
2307 if(!smb_io_unistr2("", &q_n->uni_qual_name, q_n->ptr_qual_name, ps, depth))
2308 return False;
2310 if(!prs_align(ps))
2311 return False;
2313 if(!prs_uint32("conn_level", ps, depth, &q_n->conn_level))
2314 return False;
2316 if (q_n->conn_level != (uint32)-1) {
2317 if(!srv_io_srv_conn_ctr("conn_ctr", &q_n->ctr, ps, depth))
2318 return False;
2321 if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
2322 return False;
2324 if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
2325 return False;
2327 return True;
2330 /*******************************************************************
2331 Reads or writes a structure.
2332 ********************************************************************/
2334 BOOL srv_io_r_net_conn_enum(const char *desc, SRV_R_NET_CONN_ENUM *r_n, prs_struct *ps, int depth)
2336 if (r_n == NULL)
2337 return False;
2339 prs_debug(ps, depth, desc, "srv_io_r_net_conn_enum");
2340 depth++;
2342 if(!prs_align(ps))
2343 return False;
2345 if(!prs_uint32("conn_level", ps, depth, &r_n->conn_level))
2346 return False;
2348 if (r_n->conn_level != (uint32)-1) {
2349 if(!srv_io_srv_conn_ctr("conn_ctr", &r_n->ctr, ps, depth))
2350 return False;
2353 if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
2354 return False;
2355 if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
2356 return False;
2357 if(!prs_werror("status", ps, depth, &r_n->status))
2358 return False;
2360 return True;
2363 /*******************************************************************
2364 Inits a FILE_INFO_3_STR structure
2365 ********************************************************************/
2367 void init_srv_file_info3_str(FILE_INFO_3_STR *fi3, const char *user_name, const char *path_name)
2369 DEBUG(5,("init_srv_file_info3_str\n"));
2371 init_unistr2(&fi3->uni_path_name, path_name, UNI_STR_TERMINATE);
2372 init_unistr2(&fi3->uni_user_name, user_name, UNI_STR_TERMINATE);
2375 /*******************************************************************
2376 Reads or writes a structure.
2377 ********************************************************************/
2379 static BOOL srv_io_file_info3_str(const char *desc, FILE_INFO_3_STR *sh1, prs_struct *ps, int depth)
2381 if (sh1 == NULL)
2382 return False;
2384 prs_debug(ps, depth, desc, "srv_io_file_info3_str");
2385 depth++;
2387 if(!prs_align(ps))
2388 return False;
2390 if(!smb_io_unistr2("", &sh1->uni_path_name, True, ps, depth))
2391 return False;
2392 if(!smb_io_unistr2("", &sh1->uni_user_name, True, ps, depth))
2393 return False;
2395 return True;
2398 /*******************************************************************
2399 Inits a FILE_INFO_3 structure
2400 ********************************************************************/
2402 void init_srv_file_info3(FILE_INFO_3 *fl3,
2403 uint32 id, uint32 perms, uint32 num_locks,
2404 const char *path_name, const char *user_name)
2406 DEBUG(5,("init_srv_file_info3: %s %s\n", path_name, user_name));
2408 fl3->id = id;
2409 fl3->perms = perms;
2410 fl3->num_locks = num_locks;
2412 fl3->ptr_path_name = (path_name != NULL) ? 1 : 0;
2413 fl3->ptr_user_name = (user_name != NULL) ? 1 : 0;
2416 /*******************************************************************
2417 Reads or writes a structure.
2418 ********************************************************************/
2420 static BOOL srv_io_file_info3(const char *desc, FILE_INFO_3 *fl3, prs_struct *ps, int depth)
2422 if (fl3 == NULL)
2423 return False;
2425 prs_debug(ps, depth, desc, "srv_io_file_info3");
2426 depth++;
2428 if(!prs_align(ps))
2429 return False;
2431 if(!prs_uint32("id ", ps, depth, &fl3->id))
2432 return False;
2433 if(!prs_uint32("perms ", ps, depth, &fl3->perms))
2434 return False;
2435 if(!prs_uint32("num_locks ", ps, depth, &fl3->num_locks))
2436 return False;
2437 if(!prs_uint32("ptr_path_name", ps, depth, &fl3->ptr_path_name))
2438 return False;
2439 if(!prs_uint32("ptr_user_name", ps, depth, &fl3->ptr_user_name))
2440 return False;
2442 return True;
2445 /*******************************************************************
2446 Reads or writes a structure.
2447 ********************************************************************/
2449 static BOOL srv_io_srv_file_ctr(const char *desc, SRV_FILE_INFO_CTR *ctr, prs_struct *ps, int depth)
2451 if (ctr == NULL)
2452 return False;
2454 prs_debug(ps, depth, desc, "srv_io_srv_file_ctr");
2455 depth++;
2457 if (UNMARSHALLING(ps)) {
2458 memset(ctr, '\0', sizeof(SRV_FILE_INFO_CTR));
2461 if(!prs_align(ps))
2462 return False;
2464 if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
2465 return False;
2466 if (ctr->switch_value != 3) {
2467 DEBUG(5,("%s File info %d level not supported\n",
2468 tab_depth(depth), ctr->switch_value));
2470 if(!prs_uint32("ptr_file_info", ps, depth, &ctr->ptr_file_info))
2471 return False;
2472 if(!prs_uint32("num_entries", ps, depth, &ctr->num_entries))
2473 return False;
2474 if(!prs_uint32("ptr_entries", ps, depth, &ctr->ptr_entries))
2475 return False;
2476 if (ctr->ptr_entries == 0)
2477 return True;
2478 if(!prs_uint32("num_entries2", ps, depth,
2479 &ctr->num_entries2))
2480 return False;
2482 switch (ctr->switch_value) {
2483 case 3: {
2484 SRV_FILE_INFO_3 *info3 = ctr->file.info3;
2485 int num_entries = ctr->num_entries;
2486 int i;
2488 if (UNMARSHALLING(ps)) {
2489 if (!(info3 = PRS_ALLOC_MEM(ps, SRV_FILE_INFO_3, num_entries)))
2490 return False;
2491 ctr->file.info3 = info3;
2494 for (i = 0; i < num_entries; i++) {
2495 if(!srv_io_file_info3("", &ctr->file.info3[i].info_3, ps, depth))
2496 return False;
2498 for (i = 0; i < num_entries; i++) {
2499 if(!srv_io_file_info3_str("", &ctr->file.info3[i].info_3_str, ps, depth))
2500 return False;
2502 break;
2504 default:
2505 DEBUG(5,("%s no file info at switch_value %d\n",
2506 tab_depth(depth), ctr->switch_value));
2507 break;
2510 return True;
2513 /*******************************************************************
2514 Inits a SRV_Q_NET_FILE_ENUM structure.
2515 ********************************************************************/
2517 void init_srv_q_net_file_enum(SRV_Q_NET_FILE_ENUM *q_n,
2518 const char *srv_name, const char *qual_name,
2519 const char *user_name,
2520 uint32 file_level, SRV_FILE_INFO_CTR *ctr,
2521 uint32 preferred_len,
2522 ENUM_HND *hnd)
2524 DEBUG(5,("init_q_net_file_enum\n"));
2526 init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
2527 init_buf_unistr2(&q_n->uni_qual_name, &q_n->ptr_qual_name, qual_name);
2528 init_buf_unistr2(&q_n->uni_user_name, &q_n->ptr_user_name, user_name);
2530 q_n->file_level = q_n->ctr.switch_value = file_level;
2531 q_n->preferred_len = preferred_len;
2532 q_n->ctr.ptr_file_info = 1;
2533 q_n->ctr.num_entries = 0;
2534 q_n->ctr.num_entries2 = 0;
2536 memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
2539 /*******************************************************************
2540 Reads or writes a structure.
2541 ********************************************************************/
2543 BOOL srv_io_q_net_file_enum(const char *desc, SRV_Q_NET_FILE_ENUM *q_n, prs_struct *ps, int depth)
2545 if (q_n == NULL)
2546 return False;
2548 prs_debug(ps, depth, desc, "srv_io_q_net_file_enum");
2549 depth++;
2551 if(!prs_align(ps))
2552 return False;
2554 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
2555 return False;
2556 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
2557 return False;
2559 if(!prs_align(ps))
2560 return False;
2562 if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
2563 return False;
2564 if(!smb_io_unistr2("", &q_n->uni_qual_name, q_n->ptr_qual_name, ps, depth))
2565 return False;
2567 if(!prs_align(ps))
2568 return False;
2570 if(!prs_uint32("ptr_user_name", ps, depth, &q_n->ptr_user_name))
2571 return False;
2572 if(!smb_io_unistr2("", &q_n->uni_user_name, q_n->ptr_user_name, ps, depth))
2573 return False;
2575 if(!prs_align(ps))
2576 return False;
2577 if(!prs_uint32("file_level", ps, depth, &q_n->file_level))
2578 return False;
2580 if (q_n->file_level != (uint32)-1) {
2581 if(!srv_io_srv_file_ctr("file_ctr", &q_n->ctr, ps, depth))
2582 return False;
2585 if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
2586 return False;
2588 if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
2589 return False;
2591 return True;
2594 /*******************************************************************
2595 Reads or writes a structure.
2596 ********************************************************************/
2598 BOOL srv_io_r_net_file_enum(const char *desc, SRV_R_NET_FILE_ENUM *r_n, prs_struct *ps, int depth)
2600 if (r_n == NULL)
2601 return False;
2603 prs_debug(ps, depth, desc, "srv_io_r_net_file_enum");
2604 depth++;
2606 if(!prs_align(ps))
2607 return False;
2609 if(!prs_uint32("file_level", ps, depth, &r_n->file_level))
2610 return False;
2612 if (r_n->file_level != 0) {
2613 if(!srv_io_srv_file_ctr("file_ctr", &r_n->ctr, ps, depth))
2614 return False;
2617 if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
2618 return False;
2619 if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
2620 return False;
2621 if(!prs_werror("status", ps, depth, &r_n->status))
2622 return False;
2624 return True;
2627 /*******************************************************************
2628 Initialize a net file close request
2629 ********************************************************************/
2630 void init_srv_q_net_file_close(SRV_Q_NET_FILE_CLOSE *q_n, const char *server,
2631 uint32 file_id)
2633 q_n->ptr_srv_name = 1;
2634 init_unistr2(&q_n->uni_srv_name, server, UNI_STR_TERMINATE);
2635 q_n->file_id = file_id;
2638 /*******************************************************************
2639 Reads or writes a structure.
2640 ********************************************************************/
2641 BOOL srv_io_q_net_file_close(const char *desc, SRV_Q_NET_FILE_CLOSE *q_n,
2642 prs_struct *ps, int depth)
2644 if (q_n == NULL)
2645 return False;
2647 prs_debug(ps, depth, desc, "srv_io_q_net_file_close");
2648 depth++;
2650 if(!prs_align(ps))
2651 return False;
2653 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
2654 return False;
2655 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
2656 return False;
2658 if(!prs_align(ps))
2659 return False;
2661 if(!prs_uint32("file_id", ps, depth, &q_n->file_id))
2662 return False;
2664 return True;
2667 /*******************************************************************
2668 Reads or writes a structure.
2669 ********************************************************************/
2671 BOOL srv_io_r_net_file_close(const char *desc, SRV_R_NET_FILE_CLOSE *q_n,
2672 prs_struct *ps, int depth)
2674 if (q_n == NULL)
2675 return False;
2677 prs_debug(ps, depth, desc, "srv_io_r_net_file_close");
2678 depth++;
2680 if(!prs_align(ps))
2681 return False;
2683 if(!prs_werror("status", ps, depth, &q_n->status))
2684 return False;
2686 return True;
2689 /*******************************************************************
2690 Inits a SRV_INFO_100 structure.
2691 ********************************************************************/
2693 void init_srv_info_100(SRV_INFO_100 *sv100, uint32 platform_id, const char *name)
2695 DEBUG(5,("init_srv_info_100\n"));
2697 sv100->platform_id = platform_id;
2698 init_buf_unistr2(&sv100->uni_name, &sv100->ptr_name, name);
2701 /*******************************************************************
2702 Reads or writes a SRV_INFO_101 structure.
2703 ********************************************************************/
2705 static BOOL srv_io_info_100(const char *desc, SRV_INFO_100 *sv100, prs_struct *ps, int depth)
2707 if (sv100 == NULL)
2708 return False;
2710 prs_debug(ps, depth, desc, "srv_io_info_100");
2711 depth++;
2713 if(!prs_align(ps))
2714 return False;
2716 if(!prs_uint32("platform_id ", ps, depth, &sv100->platform_id))
2717 return False;
2718 if(!prs_uint32("ptr_name ", ps, depth, &sv100->ptr_name))
2719 return False;
2721 if(!smb_io_unistr2("uni_name ", &sv100->uni_name, True, ps, depth))
2722 return False;
2724 return True;
2728 /*******************************************************************
2729 Inits a SRV_INFO_101 structure.
2730 ********************************************************************/
2732 void init_srv_info_101(SRV_INFO_101 *sv101, uint32 platform_id, const char *name,
2733 uint32 ver_major, uint32 ver_minor,
2734 uint32 srv_type, const char *comment)
2736 DEBUG(5,("init_srv_info_101\n"));
2738 sv101->platform_id = platform_id;
2739 init_buf_unistr2(&sv101->uni_name, &sv101->ptr_name, name);
2740 sv101->ver_major = ver_major;
2741 sv101->ver_minor = ver_minor;
2742 sv101->srv_type = srv_type;
2743 init_buf_unistr2(&sv101->uni_comment, &sv101->ptr_comment, comment);
2746 /*******************************************************************
2747 Reads or writes a SRV_INFO_101 structure.
2748 ********************************************************************/
2750 static BOOL srv_io_info_101(const char *desc, SRV_INFO_101 *sv101, prs_struct *ps, int depth)
2752 if (sv101 == NULL)
2753 return False;
2755 prs_debug(ps, depth, desc, "srv_io_info_101");
2756 depth++;
2758 if(!prs_align(ps))
2759 return False;
2761 if(!prs_uint32("platform_id ", ps, depth, &sv101->platform_id))
2762 return False;
2763 if(!prs_uint32("ptr_name ", ps, depth, &sv101->ptr_name))
2764 return False;
2765 if(!prs_uint32("ver_major ", ps, depth, &sv101->ver_major))
2766 return False;
2767 if(!prs_uint32("ver_minor ", ps, depth, &sv101->ver_minor))
2768 return False;
2769 if(!prs_uint32("srv_type ", ps, depth, &sv101->srv_type))
2770 return False;
2771 if(!prs_uint32("ptr_comment ", ps, depth, &sv101->ptr_comment))
2772 return False;
2774 if(!prs_align(ps))
2775 return False;
2777 if(!smb_io_unistr2("uni_name ", &sv101->uni_name, True, ps, depth))
2778 return False;
2779 if(!smb_io_unistr2("uni_comment ", &sv101->uni_comment, True, ps, depth))
2780 return False;
2782 return True;
2785 /*******************************************************************
2786 Inits a SRV_INFO_102 structure.
2787 ********************************************************************/
2789 void init_srv_info_102(SRV_INFO_102 *sv102, uint32 platform_id, const char *name,
2790 const char *comment, uint32 ver_major, uint32 ver_minor,
2791 uint32 srv_type, uint32 users, uint32 disc, uint32 hidden,
2792 uint32 announce, uint32 ann_delta, uint32 licenses,
2793 const char *usr_path)
2795 DEBUG(5,("init_srv_info_102\n"));
2797 sv102->platform_id = platform_id;
2798 init_buf_unistr2(&sv102->uni_name, &sv102->ptr_name, name);
2799 sv102->ver_major = ver_major;
2800 sv102->ver_minor = ver_minor;
2801 sv102->srv_type = srv_type;
2802 init_buf_unistr2(&sv102->uni_comment, &sv102->ptr_comment, comment);
2804 /* same as 101 up to here */
2806 sv102->users = users;
2807 sv102->disc = disc;
2808 sv102->hidden = hidden;
2809 sv102->announce = announce;
2810 sv102->ann_delta = ann_delta;
2811 sv102->licenses = licenses;
2812 init_buf_unistr2(&sv102->uni_usr_path, &sv102->ptr_usr_path, usr_path);
2816 /*******************************************************************
2817 Reads or writes a SRV_INFO_102 structure.
2818 ********************************************************************/
2820 static BOOL srv_io_info_102(const char *desc, SRV_INFO_102 *sv102, prs_struct *ps, int depth)
2822 if (sv102 == NULL)
2823 return False;
2825 prs_debug(ps, depth, desc, "srv_io_info102");
2826 depth++;
2828 if(!prs_align(ps))
2829 return False;
2831 if(!prs_uint32("platform_id ", ps, depth, &sv102->platform_id))
2832 return False;
2833 if(!prs_uint32("ptr_name ", ps, depth, &sv102->ptr_name))
2834 return False;
2835 if(!prs_uint32("ver_major ", ps, depth, &sv102->ver_major))
2836 return False;
2837 if(!prs_uint32("ver_minor ", ps, depth, &sv102->ver_minor))
2838 return False;
2839 if(!prs_uint32("srv_type ", ps, depth, &sv102->srv_type))
2840 return False;
2841 if(!prs_uint32("ptr_comment ", ps, depth, &sv102->ptr_comment))
2842 return False;
2844 /* same as 101 up to here */
2846 if(!prs_uint32("users ", ps, depth, &sv102->users))
2847 return False;
2848 if(!prs_uint32("disc ", ps, depth, &sv102->disc))
2849 return False;
2850 if(!prs_uint32("hidden ", ps, depth, &sv102->hidden))
2851 return False;
2852 if(!prs_uint32("announce ", ps, depth, &sv102->announce))
2853 return False;
2854 if(!prs_uint32("ann_delta ", ps, depth, &sv102->ann_delta))
2855 return False;
2856 if(!prs_uint32("licenses ", ps, depth, &sv102->licenses))
2857 return False;
2858 if(!prs_uint32("ptr_usr_path", ps, depth, &sv102->ptr_usr_path))
2859 return False;
2861 if(!smb_io_unistr2("uni_name ", &sv102->uni_name, True, ps, depth))
2862 return False;
2863 if(!prs_align(ps))
2864 return False;
2865 if(!smb_io_unistr2("uni_comment ", &sv102->uni_comment, True, ps, depth))
2866 return False;
2867 if(!prs_align(ps))
2868 return False;
2869 if(!smb_io_unistr2("uni_usr_path", &sv102->uni_usr_path, True, ps, depth))
2870 return False;
2872 return True;
2875 /*******************************************************************
2876 Reads or writes a SRV_INFO_102 structure.
2877 ********************************************************************/
2879 static BOOL srv_io_info_ctr(const char *desc, SRV_INFO_CTR *ctr, prs_struct *ps, int depth)
2881 if (ctr == NULL)
2882 return False;
2884 prs_debug(ps, depth, desc, "srv_io_info_ctr");
2885 depth++;
2887 if(!prs_align(ps))
2888 return False;
2890 if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
2891 return False;
2892 if(!prs_uint32("ptr_srv_ctr ", ps, depth, &ctr->ptr_srv_ctr))
2893 return False;
2895 if (ctr->ptr_srv_ctr != 0 && ctr->switch_value != 0 && ctr != NULL) {
2896 switch (ctr->switch_value) {
2897 case 100:
2898 if(!srv_io_info_100("sv100", &ctr->srv.sv100, ps, depth))
2899 return False;
2900 break;
2901 case 101:
2902 if(!srv_io_info_101("sv101", &ctr->srv.sv101, ps, depth))
2903 return False;
2904 break;
2905 case 102:
2906 if(!srv_io_info_102("sv102", &ctr->srv.sv102, ps, depth))
2907 return False;
2908 break;
2909 default:
2910 DEBUG(5,("%s no server info at switch_value %d\n",
2911 tab_depth(depth), ctr->switch_value));
2912 break;
2914 if(!prs_align(ps))
2915 return False;
2918 return True;
2921 /*******************************************************************
2922 Inits a SRV_Q_NET_SRV_GET_INFO structure.
2923 ********************************************************************/
2925 void init_srv_q_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *srv,
2926 const char *server_name, uint32 switch_value)
2928 DEBUG(5,("init_srv_q_net_srv_get_info\n"));
2930 init_buf_unistr2(&srv->uni_srv_name, &srv->ptr_srv_name, server_name);
2932 srv->switch_value = switch_value;
2935 /*******************************************************************
2936 Reads or writes a structure.
2937 ********************************************************************/
2939 BOOL srv_io_q_net_srv_get_info(const char *desc, SRV_Q_NET_SRV_GET_INFO *q_n, prs_struct *ps, int depth)
2941 if (q_n == NULL)
2942 return False;
2944 prs_debug(ps, depth, desc, "srv_io_q_net_srv_get_info");
2945 depth++;
2947 if(!prs_align(ps))
2948 return False;
2950 if(!prs_uint32("ptr_srv_name ", ps, depth, &q_n->ptr_srv_name))
2951 return False;
2952 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
2953 return False;
2955 if(!prs_align(ps))
2956 return False;
2958 if(!prs_uint32("switch_value ", ps, depth, &q_n->switch_value))
2959 return False;
2961 return True;
2964 /*******************************************************************
2965 Inits a SRV_R_NET_SRV_GET_INFO structure.
2966 ********************************************************************/
2968 void init_srv_r_net_srv_get_info(SRV_R_NET_SRV_GET_INFO *srv,
2969 uint32 switch_value, SRV_INFO_CTR *ctr, WERROR status)
2971 DEBUG(5,("init_srv_r_net_srv_get_info\n"));
2973 srv->ctr = ctr;
2975 if (W_ERROR_IS_OK(status)) {
2976 srv->ctr->switch_value = switch_value;
2977 srv->ctr->ptr_srv_ctr = 1;
2978 } else {
2979 srv->ctr->switch_value = 0;
2980 srv->ctr->ptr_srv_ctr = 0;
2983 srv->status = status;
2986 /*******************************************************************
2987 Inits a SRV_R_NET_SRV_SET_INFO structure.
2988 ********************************************************************/
2990 void init_srv_r_net_srv_set_info(SRV_R_NET_SRV_SET_INFO *srv,
2991 uint32 switch_value, WERROR status)
2993 DEBUG(5,("init_srv_r_net_srv_set_info\n"));
2995 srv->switch_value = switch_value;
2996 srv->status = status;
2999 /*******************************************************************
3000 Reads or writes a structure.
3001 ********************************************************************/
3003 BOOL srv_io_q_net_srv_set_info(const char *desc, SRV_Q_NET_SRV_SET_INFO *q_n,
3004 prs_struct *ps, int depth)
3006 prs_debug(ps, depth, desc, "srv_io_q_net_srv_set_info");
3007 depth++;
3009 if(!prs_align(ps))
3010 return False;
3012 if(!prs_uint32("ptr_srv_name ", ps, depth, &q_n->ptr_srv_name))
3013 return False;
3014 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
3015 return False;
3017 if(!prs_align(ps))
3018 return False;
3020 if(!prs_uint32("switch_value ", ps, depth, &q_n->switch_value))
3021 return False;
3023 if (UNMARSHALLING(ps)) {
3024 q_n->ctr = PRS_ALLOC_MEM(ps, SRV_INFO_CTR, 1);
3026 if (!q_n->ctr)
3027 return False;
3030 if(!srv_io_info_ctr("ctr", q_n->ctr, ps, depth))
3031 return False;
3033 return True;
3036 /*******************************************************************
3037 Reads or writes a structure.
3038 ********************************************************************/
3040 BOOL srv_io_r_net_srv_get_info(const char *desc, SRV_R_NET_SRV_GET_INFO *r_n, prs_struct *ps, int depth)
3042 if (r_n == NULL)
3043 return False;
3045 prs_debug(ps, depth, desc, "srv_io_r_net_srv_get_info");
3046 depth++;
3048 if(!prs_align(ps))
3049 return False;
3051 if(!srv_io_info_ctr("ctr", r_n->ctr, ps, depth))
3052 return False;
3054 if(!prs_werror("status", ps, depth, &r_n->status))
3055 return False;
3057 return True;
3060 /*******************************************************************
3061 Reads or writes a structure.
3062 ********************************************************************/
3064 BOOL srv_io_r_net_srv_set_info(const char *desc, SRV_R_NET_SRV_SET_INFO *r_n,
3065 prs_struct *ps, int depth)
3067 prs_debug(ps, depth, desc, "srv_io_r_net_srv_set_info");
3068 depth++;
3070 if(!prs_align(ps))
3071 return False;
3073 if(!prs_uint32("switch value ", ps, depth, &r_n->switch_value))
3074 return False;
3076 if(!prs_werror("status", ps, depth, &r_n->status))
3077 return False;
3079 return True;
3082 /*******************************************************************
3083 Reads or writes a structure.
3084 ********************************************************************/
3086 BOOL srv_io_q_net_remote_tod(const char *desc, SRV_Q_NET_REMOTE_TOD *q_n, prs_struct *ps, int depth)
3088 if (q_n == NULL)
3089 return False;
3091 prs_debug(ps, depth, desc, "srv_io_q_net_remote_tod");
3092 depth++;
3094 if(!prs_align(ps))
3095 return False;
3097 if(!prs_uint32("ptr_srv_name ", ps, depth, &q_n->ptr_srv_name))
3098 return False;
3099 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
3100 return False;
3102 return True;
3105 /*******************************************************************
3106 Reads or writes a TIME_OF_DAY_INFO structure.
3107 ********************************************************************/
3109 static BOOL srv_io_time_of_day_info(const char *desc, TIME_OF_DAY_INFO *tod, prs_struct *ps, int depth)
3111 if (tod == NULL)
3112 return False;
3114 prs_debug(ps, depth, desc, "srv_io_time_of_day_info");
3115 depth++;
3117 if(!prs_align(ps))
3118 return False;
3120 if(!prs_uint32("elapsedt ", ps, depth, &tod->elapsedt))
3121 return False;
3122 if(!prs_uint32("msecs ", ps, depth, &tod->msecs))
3123 return False;
3124 if(!prs_uint32("hours ", ps, depth, &tod->hours))
3125 return False;
3126 if(!prs_uint32("mins ", ps, depth, &tod->mins))
3127 return False;
3128 if(!prs_uint32("secs ", ps, depth, &tod->secs))
3129 return False;
3130 if(!prs_uint32("hunds ", ps, depth, &tod->hunds))
3131 return False;
3132 if(!prs_uint32("timezone ", ps, depth, &tod->zone))
3133 return False;
3134 if(!prs_uint32("tintervals ", ps, depth, &tod->tintervals))
3135 return False;
3136 if(!prs_uint32("day ", ps, depth, &tod->day))
3137 return False;
3138 if(!prs_uint32("month ", ps, depth, &tod->month))
3139 return False;
3140 if(!prs_uint32("year ", ps, depth, &tod->year))
3141 return False;
3142 if(!prs_uint32("weekday ", ps, depth, &tod->weekday))
3143 return False;
3145 return True;
3148 /*******************************************************************
3149 Inits a TIME_OF_DAY_INFO structure.
3150 ********************************************************************/
3152 void init_time_of_day_info(TIME_OF_DAY_INFO *tod, uint32 elapsedt, uint32 msecs,
3153 uint32 hours, uint32 mins, uint32 secs, uint32 hunds,
3154 uint32 zone, uint32 tintervals, uint32 day,
3155 uint32 month, uint32 year, uint32 weekday)
3157 DEBUG(5,("init_time_of_day_info\n"));
3159 tod->elapsedt = elapsedt;
3160 tod->msecs = msecs;
3161 tod->hours = hours;
3162 tod->mins = mins;
3163 tod->secs = secs;
3164 tod->hunds = hunds;
3165 tod->zone = zone;
3166 tod->tintervals = tintervals;
3167 tod->day = day;
3168 tod->month = month;
3169 tod->year = year;
3170 tod->weekday = weekday;
3174 /*******************************************************************
3175 Reads or writes a structure.
3176 ********************************************************************/
3178 BOOL srv_io_r_net_remote_tod(const char *desc, SRV_R_NET_REMOTE_TOD *r_n, prs_struct *ps, int depth)
3180 if (r_n == NULL)
3181 return False;
3183 prs_debug(ps, depth, desc, "srv_io_r_net_remote_tod");
3184 depth++;
3186 if(!prs_align(ps))
3187 return False;
3189 if(!prs_uint32("ptr_srv_tod ", ps, depth, &r_n->ptr_srv_tod))
3190 return False;
3192 if(!srv_io_time_of_day_info("tod", r_n->tod, ps, depth))
3193 return False;
3195 if(!prs_werror("status", ps, depth, &r_n->status))
3196 return False;
3198 return True;
3201 /*******************************************************************
3202 initialises a structure.
3203 ********************************************************************/
3205 BOOL init_srv_q_net_disk_enum(SRV_Q_NET_DISK_ENUM *q_n,
3206 const char *srv_name,
3207 uint32 preferred_len,
3208 ENUM_HND *enum_hnd
3213 DEBUG(5,("init_srv_q_net_srv_disk_enum\n"));
3215 init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
3217 q_n->disk_enum_ctr.level = 0;
3218 q_n->disk_enum_ctr.disk_info_ptr = 0;
3220 q_n->preferred_len = preferred_len;
3221 memcpy(&q_n->enum_hnd, enum_hnd, sizeof(*enum_hnd));
3223 return True;
3226 /*******************************************************************
3227 Reads or writes a structure.
3228 ********************************************************************/
3230 BOOL srv_io_q_net_disk_enum(const char *desc, SRV_Q_NET_DISK_ENUM *q_n, prs_struct *ps, int depth)
3232 if (q_n == NULL)
3233 return False;
3235 prs_debug(ps, depth, desc, "srv_io_q_net_disk_enum");
3236 depth++;
3238 if(!prs_align(ps))
3239 return False;
3241 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
3242 return False;
3244 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
3245 return False;
3247 if(!prs_align(ps))
3248 return False;
3250 if(!prs_uint32("level", ps, depth, &q_n->disk_enum_ctr.level))
3251 return False;
3253 if(!prs_uint32("entries_read", ps, depth, &q_n->disk_enum_ctr.entries_read))
3254 return False;
3256 if(!prs_uint32("buffer", ps, depth, &q_n->disk_enum_ctr.disk_info_ptr))
3257 return False;
3259 if(!prs_align(ps))
3260 return False;
3262 if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
3263 return False;
3264 if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
3265 return False;
3267 return True;
3270 /*******************************************************************
3271 Reads or writes a structure.
3272 ********************************************************************/
3274 BOOL srv_io_r_net_disk_enum(const char *desc, SRV_R_NET_DISK_ENUM *r_n, prs_struct *ps, int depth)
3277 unsigned int i;
3278 uint32 entries_read, entries_read2, entries_read3;
3280 if (r_n == NULL)
3281 return False;
3283 prs_debug(ps, depth, desc, "srv_io_r_net_disk_enum");
3284 depth++;
3286 entries_read = entries_read2 = entries_read3 = r_n->disk_enum_ctr.entries_read;
3288 if(!prs_align(ps))
3289 return False;
3291 if(!prs_uint32("entries_read", ps, depth, &entries_read))
3292 return False;
3293 if(!prs_uint32("ptr_disk_info", ps, depth, &r_n->disk_enum_ctr.disk_info_ptr))
3294 return False;
3296 /*this may be max, unknown, actual?*/
3298 if(!prs_uint32("max_elements", ps, depth, &entries_read2))
3299 return False;
3300 if(!prs_uint32("unknown", ps, depth, &r_n->disk_enum_ctr.unknown))
3301 return False;
3302 if(!prs_uint32("actual_elements", ps, depth, &entries_read3))
3303 return False;
3305 r_n->disk_enum_ctr.entries_read = entries_read3;
3307 if(UNMARSHALLING(ps)) {
3309 DISK_INFO *dinfo;
3311 if(!(dinfo = PRS_ALLOC_MEM(ps, DISK_INFO, entries_read3)))
3312 return False;
3313 r_n->disk_enum_ctr.disk_info = dinfo;
3316 for(i=0; i < r_n->disk_enum_ctr.entries_read; i++) {
3318 if(!prs_uint32("unknown", ps, depth, &r_n->disk_enum_ctr.disk_info[i].unknown))
3319 return False;
3321 if(!smb_io_unistr3("disk_name", &r_n->disk_enum_ctr.disk_info[i].disk_name, ps, depth))
3322 return False;
3324 if(!prs_align(ps))
3325 return False;
3328 if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
3329 return False;
3331 if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
3332 return False;
3334 if(!prs_werror("status", ps, depth, &r_n->status))
3335 return False;
3337 return True;
3340 /*******************************************************************
3341 initialises a structure.
3342 ********************************************************************/
3344 BOOL init_srv_q_net_name_validate(SRV_Q_NET_NAME_VALIDATE *q_n, const char *srv_name, const char *share_name, int type)
3346 uint32 ptr_share_name;
3348 DEBUG(5,("init_srv_q_net_name_validate\n"));
3350 init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
3351 init_buf_unistr2(&q_n->uni_name, &ptr_share_name, share_name);
3353 q_n->type = type;
3354 q_n->flags = 0;
3356 return True;
3359 /*******************************************************************
3360 Reads or writes a structure.
3361 ********************************************************************/
3363 BOOL srv_io_q_net_name_validate(const char *desc, SRV_Q_NET_NAME_VALIDATE *q_n, prs_struct *ps, int depth)
3365 if (q_n == NULL)
3366 return False;
3368 prs_debug(ps, depth, desc, "srv_io_q_net_name_validate");
3369 depth++;
3371 if(!prs_align(ps))
3372 return False;
3374 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
3375 return False;
3377 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
3378 return False;
3380 if(!prs_align(ps))
3381 return False;
3383 if(!smb_io_unistr2("", &q_n->uni_name, True, ps, depth))
3384 return False;
3386 if(!prs_align(ps))
3387 return False;
3389 if(!prs_uint32("type", ps, depth, &q_n->type))
3390 return False;
3392 if(!prs_uint32("flags", ps, depth, &q_n->flags))
3393 return False;
3395 return True;
3398 /*******************************************************************
3399 Reads or writes a structure.
3400 ********************************************************************/
3402 BOOL srv_io_r_net_name_validate(const char *desc, SRV_R_NET_NAME_VALIDATE *r_n, prs_struct *ps, int depth)
3404 if (r_n == NULL)
3405 return False;
3407 prs_debug(ps, depth, desc, "srv_io_r_net_name_validate");
3408 depth++;
3410 if(!prs_align(ps))
3411 return False;
3413 if(!prs_werror("status", ps, depth, &r_n->status))
3414 return False;
3416 return True;
3419 /*******************************************************************
3420 Reads or writes a structure.
3421 ********************************************************************/
3423 BOOL srv_io_q_net_file_query_secdesc(const char *desc, SRV_Q_NET_FILE_QUERY_SECDESC *q_n, prs_struct *ps, int depth)
3425 if (q_n == NULL)
3426 return False;
3428 prs_debug(ps, depth, desc, "srv_io_q_net_file_query_secdesc");
3429 depth++;
3431 if(!prs_align(ps))
3432 return False;
3434 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
3435 return False;
3437 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
3438 return False;
3440 if(!prs_align(ps))
3441 return False;
3443 if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
3444 return False;
3446 if(!smb_io_unistr2("", &q_n->uni_qual_name, True, ps, depth))
3447 return False;
3449 if(!prs_align(ps))
3450 return False;
3452 if(!smb_io_unistr2("", &q_n->uni_file_name, True, ps, depth))
3453 return False;
3455 if(!prs_uint32("unknown1", ps, depth, &q_n->unknown1))
3456 return False;
3458 if(!prs_uint32("unknown2", ps, depth, &q_n->unknown2))
3459 return False;
3461 if(!prs_uint32("unknown3", ps, depth, &q_n->unknown3))
3462 return False;
3464 return True;
3467 /*******************************************************************
3468 Reads or writes a structure.
3469 ********************************************************************/
3471 BOOL srv_io_r_net_file_query_secdesc(const char *desc, SRV_R_NET_FILE_QUERY_SECDESC *r_n, prs_struct *ps, int depth)
3473 if (r_n == NULL)
3474 return False;
3476 prs_debug(ps, depth, desc, "srv_io_r_net_file_query_secdesc");
3477 depth++;
3479 if(!prs_align(ps))
3480 return False;
3482 if(!prs_uint32("ptr_response", ps, depth, &r_n->ptr_response))
3483 return False;
3485 if(!prs_uint32("size_response", ps, depth, &r_n->size_response))
3486 return False;
3488 if(!prs_uint32("ptr_secdesc", ps, depth, &r_n->ptr_secdesc))
3489 return False;
3491 if(!prs_uint32("size_secdesc", ps, depth, &r_n->size_secdesc))
3492 return False;
3494 if(!sec_io_desc("sec_desc", &r_n->sec_desc, ps, depth))
3495 return False;
3497 if(!prs_align(ps))
3498 return False;
3500 if(!prs_werror("status", ps, depth, &r_n->status))
3501 return False;
3503 return True;
3506 /*******************************************************************
3507 Reads or writes a structure.
3508 ********************************************************************/
3510 BOOL srv_io_q_net_file_set_secdesc(const char *desc, SRV_Q_NET_FILE_SET_SECDESC *q_n, prs_struct *ps, int depth)
3512 if (q_n == NULL)
3513 return False;
3515 prs_debug(ps, depth, desc, "srv_io_q_net_file_set_secdesc");
3516 depth++;
3518 if(!prs_align(ps))
3519 return False;
3521 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
3522 return False;
3524 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
3525 return False;
3527 if(!prs_align(ps))
3528 return False;
3530 if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
3531 return False;
3533 if(!smb_io_unistr2("", &q_n->uni_qual_name, True, ps, depth))
3534 return False;
3536 if(!prs_align(ps))
3537 return False;
3539 if(!smb_io_unistr2("", &q_n->uni_file_name, True, ps, depth))
3540 return False;
3542 if(!prs_align(ps))
3543 return False;
3545 if(!prs_uint32("sec_info", ps, depth, &q_n->sec_info))
3546 return False;
3548 if(!prs_uint32("size_set", ps, depth, &q_n->size_set))
3549 return False;
3551 if(!prs_uint32("ptr_secdesc", ps, depth, &q_n->ptr_secdesc))
3552 return False;
3554 if(!prs_uint32("size_secdesc", ps, depth, &q_n->size_secdesc))
3555 return False;
3557 if(!sec_io_desc("sec_desc", &q_n->sec_desc, ps, depth))
3558 return False;
3560 return True;
3563 /*******************************************************************
3564 Reads or writes a structure.
3565 ********************************************************************/
3567 BOOL srv_io_r_net_file_set_secdesc(const char *desc, SRV_R_NET_FILE_SET_SECDESC *r_n, prs_struct *ps, int depth)
3569 if (r_n == NULL)
3570 return False;
3572 prs_debug(ps, depth, desc, "srv_io_r_net_file_set_secdesc");
3573 depth++;
3575 if(!prs_align(ps))
3576 return False;
3578 if(!prs_werror("status", ps, depth, &r_n->status))
3579 return False;
3581 return True;
3584 /*******************************************************************
3585 Inits a structure
3586 ********************************************************************/
3588 void init_srv_q_net_remote_tod(SRV_Q_NET_REMOTE_TOD *q_u, const char *server)
3590 q_u->ptr_srv_name = 1;
3591 init_unistr2(&q_u->uni_srv_name, server, UNI_STR_TERMINATE);