r148: Ensure we do not dereference a null pointer when we return the user
[Samba/gebeck_regimport.git] / source3 / rpc_parse / parse_srv.c
blob6349fc1632575c25d5ed1706d2014a9bd69e9605
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 = (SRV_SHARE_INFO_0 *)prs_alloc_mem(ps, num_entries * sizeof(SRV_SHARE_INFO_0))))
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 = (SRV_SHARE_INFO_1 *)prs_alloc_mem(ps, num_entries * sizeof(SRV_SHARE_INFO_1))))
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 = (SRV_SHARE_INFO_2 *)prs_alloc_mem(ps,num_entries * sizeof(SRV_SHARE_INFO_2))))
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 = (SRV_SHARE_INFO_501 *) prs_alloc_mem(ps, num_entries *
864 sizeof (SRV_SHARE_INFO_501))))
865 return False;
866 ctr->share.info501 = info501;
869 for (i = 0; i < num_entries; i++) {
870 if (!srv_io_share_info501("", &info501[i].info_501, ps, depth))
871 return False;
874 for (i = 0; i < num_entries; i++) {
875 if (!srv_io_share_info501_str("", &info501[i].info_501_str, ps, depth))
876 return False;
879 break;
882 case 502:
884 SRV_SHARE_INFO_502 *info502 = ctr->share.info502;
885 int num_entries = ctr->num_entries;
886 int i;
888 if (UNMARSHALLING(ps)) {
889 if (!(info502 = (SRV_SHARE_INFO_502 *)prs_alloc_mem(ps,num_entries * sizeof(SRV_SHARE_INFO_502))))
890 return False;
891 ctr->share.info502 = info502;
894 for (i = 0; i < num_entries; i++) {
895 if(!srv_io_share_info502("", &info502[i].info_502, ps, depth))
896 return False;
899 for (i = 0; i < num_entries; i++) {
900 info502[i].info_502_str.ptrs = &info502[i].info_502;
901 if(!srv_io_share_info502_str("", &info502[i].info_502_str, ps, depth))
902 return False;
905 break;
908 case 1004:
910 SRV_SHARE_INFO_1004 *info1004 = ctr->share.info1004;
911 int num_entries = ctr->num_entries;
912 int i;
914 if (UNMARSHALLING(ps)) {
915 if (!(info1004 = (SRV_SHARE_INFO_1004 *)prs_alloc_mem(ps,num_entries * sizeof(SRV_SHARE_INFO_1004))))
916 return False;
917 ctr->share.info1004 = info1004;
920 for (i = 0; i < num_entries; i++) {
921 if(!srv_io_share_info1004("", &info1004[i].info_1004, ps, depth))
922 return False;
925 for (i = 0; i < num_entries; i++) {
926 info1004[i].info_1004_str.ptrs = &info1004[i].info_1004;
927 if(!srv_io_share_info1004_str("", &info1004[i].info_1004_str, ps, depth))
928 return False;
931 break;
934 case 1005:
936 SRV_SHARE_INFO_1005 *info1005 = ctr->share.info1005;
937 int num_entries = ctr->num_entries;
938 int i;
940 if (UNMARSHALLING(ps)) {
941 if (!(info1005 = (SRV_SHARE_INFO_1005 *)prs_alloc_mem(ps,num_entries * sizeof(SRV_SHARE_INFO_1005))))
942 return False;
943 ctr->share.info1005 = info1005;
946 for (i = 0; i < num_entries; i++) {
947 if(!srv_io_share_info1005("", &info1005[i], ps, depth))
948 return False;
951 break;
954 case 1006:
956 SRV_SHARE_INFO_1006 *info1006 = ctr->share.info1006;
957 int num_entries = ctr->num_entries;
958 int i;
960 if (UNMARSHALLING(ps)) {
961 if (!(info1006 = (SRV_SHARE_INFO_1006 *)prs_alloc_mem(ps,num_entries * sizeof(SRV_SHARE_INFO_1006))))
962 return False;
963 ctr->share.info1006 = info1006;
966 for (i = 0; i < num_entries; i++) {
967 if(!srv_io_share_info1006("", &info1006[i], ps, depth))
968 return False;
971 break;
974 case 1007:
976 SRV_SHARE_INFO_1007 *info1007 = ctr->share.info1007;
977 int num_entries = ctr->num_entries;
978 int i;
980 if (UNMARSHALLING(ps)) {
981 if (!(info1007 = (SRV_SHARE_INFO_1007 *)prs_alloc_mem(ps,num_entries * sizeof(SRV_SHARE_INFO_1007))))
982 return False;
983 ctr->share.info1007 = info1007;
986 for (i = 0; i < num_entries; i++) {
987 if(!srv_io_share_info1007("", &info1007[i].info_1007, ps, depth))
988 return False;
991 for (i = 0; i < num_entries; i++) {
992 info1007[i].info_1007_str.ptrs = &info1007[i].info_1007;
993 if(!srv_io_share_info1007_str("", &info1007[i].info_1007_str, ps, depth))
994 return False;
997 break;
1000 case 1501:
1002 SRV_SHARE_INFO_1501 *info1501 = ctr->share.info1501;
1003 int num_entries = ctr->num_entries;
1004 int i;
1006 if (UNMARSHALLING(ps)) {
1007 if (!(info1501 = (SRV_SHARE_INFO_1501 *)prs_alloc_mem(ps,num_entries * sizeof(SRV_SHARE_INFO_1501))))
1008 return False;
1009 ctr->share.info1501 = info1501;
1012 for (i = 0; i < num_entries; i++) {
1013 if(!srv_io_share_info1501("", &info1501[i], ps, depth))
1014 return False;
1017 break;
1020 default:
1021 DEBUG(5,("%s no share info at switch_value %d\n",
1022 tab_depth(depth), ctr->switch_value));
1023 break;
1026 return True;
1029 /*******************************************************************
1030 Inits a SRV_Q_NET_SHARE_ENUM structure.
1031 ********************************************************************/
1033 void init_srv_q_net_share_enum(SRV_Q_NET_SHARE_ENUM *q_n,
1034 const char *srv_name, uint32 info_level,
1035 uint32 preferred_len, ENUM_HND *hnd)
1038 DEBUG(5,("init_q_net_share_enum\n"));
1040 init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
1042 q_n->ctr.info_level = q_n->ctr.switch_value = info_level;
1043 q_n->ctr.ptr_share_info = 1;
1044 q_n->ctr.num_entries = 0;
1045 q_n->ctr.ptr_entries = 0;
1046 q_n->ctr.num_entries2 = 0;
1047 q_n->preferred_len = preferred_len;
1049 memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
1052 /*******************************************************************
1053 Reads or writes a structure.
1054 ********************************************************************/
1056 BOOL srv_io_q_net_share_enum(const char *desc, SRV_Q_NET_SHARE_ENUM *q_n, prs_struct *ps, int depth)
1058 if (q_n == NULL)
1059 return False;
1061 prs_debug(ps, depth, desc, "srv_io_q_net_share_enum");
1062 depth++;
1064 if(!prs_align(ps))
1065 return False;
1067 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
1068 return False;
1069 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1070 return False;
1072 if(!srv_io_srv_share_ctr("share_ctr", &q_n->ctr, ps, depth))
1073 return False;
1075 if(!prs_align(ps))
1076 return False;
1078 if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
1079 return False;
1081 if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
1082 return False;
1084 return True;
1087 /*******************************************************************
1088 Reads or writes a structure.
1089 ********************************************************************/
1091 BOOL srv_io_r_net_share_enum(const char *desc, SRV_R_NET_SHARE_ENUM *r_n, prs_struct *ps, int depth)
1093 if (r_n == NULL)
1094 return False;
1096 prs_debug(ps, depth, desc, "srv_io_r_net_share_enum");
1097 depth++;
1099 if(!srv_io_srv_share_ctr("share_ctr", &r_n->ctr, ps, depth))
1100 return False;
1102 if(!prs_align(ps))
1103 return False;
1105 if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
1106 return False;
1108 if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
1109 return False;
1111 if(!prs_werror("status", ps, depth, &r_n->status))
1112 return False;
1114 return True;
1117 /*******************************************************************
1118 initialises a structure.
1119 ********************************************************************/
1121 BOOL init_srv_q_net_share_get_info(SRV_Q_NET_SHARE_GET_INFO *q_n, const char *srv_name, const char *share_name, uint32 info_level)
1124 uint32 ptr_share_name;
1126 DEBUG(5,("init_srv_q_net_share_get_info\n"));
1128 init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
1129 init_buf_unistr2(&q_n->uni_share_name, &ptr_share_name, share_name);
1131 q_n->info_level = info_level;
1133 return True;
1136 /*******************************************************************
1137 Reads or writes a structure.
1138 ********************************************************************/
1140 BOOL srv_io_q_net_share_get_info(const char *desc, SRV_Q_NET_SHARE_GET_INFO *q_n, prs_struct *ps, int depth)
1142 if (q_n == NULL)
1143 return False;
1145 prs_debug(ps, depth, desc, "srv_io_q_net_share_get_info");
1146 depth++;
1148 if(!prs_align(ps))
1149 return False;
1151 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
1152 return False;
1153 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1154 return False;
1156 if(!smb_io_unistr2("", &q_n->uni_share_name, True, ps, depth))
1157 return False;
1159 if(!prs_align(ps))
1160 return False;
1162 if(!prs_uint32("info_level", ps, depth, &q_n->info_level))
1163 return False;
1165 return True;
1168 /*******************************************************************
1169 Reads or writes a structure.
1170 ********************************************************************/
1172 static BOOL srv_io_srv_share_info(const char *desc, prs_struct *ps, int depth, SRV_SHARE_INFO *r_n)
1174 if (r_n == NULL)
1175 return False;
1177 prs_debug(ps, depth, desc, "srv_io_srv_share_info");
1178 depth++;
1180 if(!prs_align(ps))
1181 return False;
1183 if(!prs_uint32("switch_value ", ps, depth, &r_n->switch_value ))
1184 return False;
1186 if(!prs_uint32("ptr_share_ctr", ps, depth, &r_n->ptr_share_ctr))
1187 return False;
1189 if (r_n->ptr_share_ctr != 0) {
1190 switch (r_n->switch_value) {
1191 case 0:
1192 if(!srv_io_share_info0("", &r_n->share.info0.info_0, ps, depth))
1193 return False;
1195 /* allow access to pointers in the str part. */
1196 r_n->share.info0.info_0_str.ptrs = &r_n->share.info0.info_0;
1198 if(!srv_io_share_info0_str("", &r_n->share.info0.info_0_str, ps, depth))
1199 return False;
1201 break;
1202 case 1:
1203 if(!srv_io_share_info1("", &r_n->share.info1.info_1, ps, depth))
1204 return False;
1206 /* allow access to pointers in the str part. */
1207 r_n->share.info1.info_1_str.ptrs = &r_n->share.info1.info_1;
1209 if(!srv_io_share_info1_str("", &r_n->share.info1.info_1_str, ps, depth))
1210 return False;
1212 break;
1213 case 2:
1214 if(!srv_io_share_info2("", &r_n->share.info2.info_2, ps, depth))
1215 return False;
1217 if(!srv_io_share_info2_str("", &r_n->share.info2.info_2, &r_n->share.info2.info_2_str, ps, depth))
1218 return False;
1220 break;
1221 case 501:
1222 if (!srv_io_share_info501("", &r_n->share.info501.info_501, ps, depth))
1223 return False;
1224 if (!srv_io_share_info501_str("", &r_n->share.info501.info_501_str, ps, depth))
1225 return False;
1226 break;
1228 case 502:
1229 if(!srv_io_share_info502("", &r_n->share.info502.info_502, ps, depth))
1230 return False;
1232 /* allow access to pointers in the str part. */
1233 r_n->share.info502.info_502_str.ptrs = &r_n->share.info502.info_502;
1235 if(!srv_io_share_info502_str("", &r_n->share.info502.info_502_str, ps, depth))
1236 return False;
1237 break;
1238 case 1004:
1239 if(!srv_io_share_info1004("", &r_n->share.info1004.info_1004, ps, depth))
1240 return False;
1242 /* allow access to pointers in the str part. */
1243 r_n->share.info1004.info_1004_str.ptrs = &r_n->share.info1004.info_1004;
1245 if(!srv_io_share_info1004_str("", &r_n->share.info1004.info_1004_str, ps, depth))
1246 return False;
1247 break;
1248 case 1005:
1249 if(!srv_io_share_info1005("", &r_n->share.info1005, ps, depth))
1250 return False;
1251 break;
1252 case 1006:
1253 if(!srv_io_share_info1006("", &r_n->share.info1006, ps, depth))
1254 return False;
1255 break;
1256 case 1007:
1257 if(!srv_io_share_info1007("", &r_n->share.info1007.info_1007, ps, depth))
1258 return False;
1260 /* allow access to pointers in the str part. */
1261 r_n->share.info1007.info_1007_str.ptrs = &r_n->share.info1007.info_1007;
1263 if(!srv_io_share_info1007_str("", &r_n->share.info1007.info_1007_str, ps, depth))
1264 return False;
1265 break;
1266 case 1501:
1267 if (!srv_io_share_info1501("", &r_n->share.info1501, ps, depth))
1268 return False;
1269 default:
1270 DEBUG(5,("%s no share info at switch_value %d\n",
1271 tab_depth(depth), r_n->switch_value));
1272 break;
1276 return True;
1279 /*******************************************************************
1280 Reads or writes a structure.
1281 ********************************************************************/
1283 BOOL srv_io_r_net_share_get_info(const char *desc, SRV_R_NET_SHARE_GET_INFO *r_n, prs_struct *ps, int depth)
1285 if (r_n == NULL)
1286 return False;
1288 prs_debug(ps, depth, desc, "srv_io_r_net_share_get_info");
1289 depth++;
1291 if(!prs_align(ps))
1292 return False;
1294 if(!srv_io_srv_share_info("info ", ps, depth, &r_n->info))
1295 return False;
1297 if(!prs_align(ps))
1298 return False;
1300 if(!prs_werror("status", ps, depth, &r_n->status))
1301 return False;
1303 return True;
1306 /*******************************************************************
1307 intialises a structure.
1308 ********************************************************************/
1310 BOOL init_srv_q_net_share_set_info(SRV_Q_NET_SHARE_SET_INFO *q_n,
1311 const char *srv_name,
1312 const char *share_name,
1313 uint32 info_level,
1314 const SRV_SHARE_INFO *info)
1317 uint32 ptr_share_name;
1319 DEBUG(5,("init_srv_q_net_share_set_info\n"));
1321 init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
1322 init_buf_unistr2(&q_n->uni_share_name, &ptr_share_name, share_name);
1324 q_n->info_level = info_level;
1326 q_n->info = *info;
1328 q_n->ptr_parm_error = 1;
1329 q_n->parm_error = 0;
1331 return True;
1334 /*******************************************************************
1335 Reads or writes a structure.
1336 ********************************************************************/
1338 BOOL srv_io_q_net_share_set_info(const char *desc, SRV_Q_NET_SHARE_SET_INFO *q_n, prs_struct *ps, int depth)
1340 if (q_n == NULL)
1341 return False;
1343 prs_debug(ps, depth, desc, "srv_io_q_net_share_set_info");
1344 depth++;
1346 if(!prs_align(ps))
1347 return False;
1349 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
1350 return False;
1351 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1352 return False;
1354 if(!smb_io_unistr2("", &q_n->uni_share_name, True, ps, depth))
1355 return False;
1357 if(!prs_align(ps))
1358 return False;
1360 if(!prs_uint32("info_level", ps, depth, &q_n->info_level))
1361 return False;
1363 if(!prs_align(ps))
1364 return False;
1366 if(!srv_io_srv_share_info("info ", ps, depth, &q_n->info))
1367 return False;
1369 if(!prs_align(ps))
1370 return False;
1371 if(!prs_uint32("ptr_parm_error", ps, depth, &q_n->ptr_parm_error))
1372 return False;
1373 if(q_n->ptr_parm_error!=0) {
1374 if(!prs_uint32("parm_error", ps, depth, &q_n->parm_error))
1375 return False;
1378 return True;
1381 /*******************************************************************
1382 Reads or writes a structure.
1383 ********************************************************************/
1385 BOOL srv_io_r_net_share_set_info(const char *desc, SRV_R_NET_SHARE_SET_INFO *r_n, prs_struct *ps, int depth)
1387 if (r_n == NULL)
1388 return False;
1390 prs_debug(ps, depth, desc, "srv_io_r_net_share_set_info");
1391 depth++;
1393 if(!prs_align(ps))
1394 return False;
1396 if(!prs_uint32("ptr_parm_error ", ps, depth, &r_n->ptr_parm_error))
1397 return False;
1399 if(r_n->ptr_parm_error) {
1401 if(!prs_uint32("parm_error ", ps, depth, &r_n->parm_error))
1402 return False;
1405 if(!prs_werror("status", ps, depth, &r_n->status))
1406 return False;
1408 return True;
1412 /*******************************************************************
1413 Reads or writes a structure.
1414 ********************************************************************/
1416 BOOL srv_io_q_net_share_add(const char *desc, SRV_Q_NET_SHARE_ADD *q_n, prs_struct *ps, int depth)
1418 if (q_n == NULL)
1419 return False;
1421 prs_debug(ps, depth, desc, "srv_io_q_net_share_add");
1422 depth++;
1424 if(!prs_align(ps))
1425 return False;
1427 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
1428 return False;
1429 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1430 return False;
1432 if(!prs_align(ps))
1433 return False;
1435 if(!prs_uint32("info_level", ps, depth, &q_n->info_level))
1436 return False;
1438 if(!prs_align(ps))
1439 return False;
1441 if(!srv_io_srv_share_info("info ", ps, depth, &q_n->info))
1442 return False;
1444 if(!prs_align(ps))
1445 return False;
1447 if(!prs_uint32("ptr_err_index", ps, depth, &q_n->ptr_err_index))
1448 return False;
1449 if (q_n->ptr_err_index)
1450 if (!prs_uint32("err_index", ps, depth, &q_n->err_index))
1451 return False;
1453 return True;
1456 void init_srv_q_net_share_add(SRV_Q_NET_SHARE_ADD *q, const char *srvname,
1457 const char *netname, uint32 type, const char *remark,
1458 uint32 perms, uint32 max_uses, uint32 num_uses,
1459 const char *path, const char *passwd)
1461 q->ptr_srv_name = 1;
1462 init_unistr2(&q->uni_srv_name, srvname, UNI_STR_TERMINATE);
1463 q->info.switch_value = q->info_level = 2;
1465 q->info.ptr_share_ctr = 1;
1466 init_srv_share_info2(&q->info.share.info2.info_2, netname, type,
1467 remark, perms, max_uses, num_uses, path, passwd);
1468 init_srv_share_info2_str(&q->info.share.info2.info_2_str, netname,
1469 remark, path, passwd);
1470 q->ptr_err_index = 1;
1471 q->err_index = 0;
1475 /*******************************************************************
1476 Reads or writes a structure.
1477 ********************************************************************/
1479 BOOL srv_io_r_net_share_add(const char *desc, SRV_R_NET_SHARE_ADD *r_n, prs_struct *ps, int depth)
1481 if (r_n == NULL)
1482 return False;
1484 prs_debug(ps, depth, desc, "srv_io_r_net_share_add");
1485 depth++;
1487 if(!prs_align(ps))
1488 return False;
1490 if(!prs_uint32("ptr_parm_error", ps, depth, &r_n->ptr_parm_error))
1491 return False;
1493 if(r_n->ptr_parm_error) {
1495 if(!prs_uint32("parm_error", ps, depth, &r_n->parm_error))
1496 return False;
1499 if(!prs_werror("status", ps, depth, &r_n->status))
1500 return False;
1502 return True;
1505 /*******************************************************************
1506 initialises a structure.
1507 ********************************************************************/
1509 void init_srv_q_net_share_del(SRV_Q_NET_SHARE_DEL *del, const char *srvname,
1510 const char *sharename)
1512 del->ptr_srv_name = 1;
1513 init_unistr2(&del->uni_srv_name, srvname, UNI_STR_TERMINATE);
1514 init_unistr2(&del->uni_share_name, sharename, UNI_STR_TERMINATE);
1517 /*******************************************************************
1518 Reads or writes a structure.
1519 ********************************************************************/
1521 BOOL srv_io_q_net_share_del(const char *desc, SRV_Q_NET_SHARE_DEL *q_n, prs_struct *ps, int depth)
1523 if (q_n == NULL)
1524 return False;
1526 prs_debug(ps, depth, desc, "srv_io_q_net_share_del");
1527 depth++;
1529 if(!prs_align(ps))
1530 return False;
1532 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
1533 return False;
1534 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1535 return False;
1537 if(!smb_io_unistr2("", &q_n->uni_share_name, True, ps, depth))
1538 return False;
1540 if(!prs_align(ps))
1541 return False;
1542 if(!prs_uint32("reserved", ps, depth, &q_n->reserved))
1543 return False;
1545 return True;
1548 /*******************************************************************
1549 Reads or writes a structure.
1550 ********************************************************************/
1552 BOOL srv_io_r_net_share_del(const char *desc, SRV_R_NET_SHARE_DEL *q_n, prs_struct *ps, int depth)
1554 if (q_n == NULL)
1555 return False;
1557 prs_debug(ps, depth, desc, "srv_io_r_net_share_del");
1558 depth++;
1560 if(!prs_align(ps))
1561 return False;
1563 if(!prs_werror("status", ps, depth, &q_n->status))
1564 return False;
1566 return True;
1569 /*******************************************************************
1570 Inits a SESS_INFO_0_STR structure
1571 ********************************************************************/
1573 void init_srv_sess_info0_str(SESS_INFO_0_STR *ss0, const char *name)
1575 DEBUG(5,("init_srv_sess_info0_str\n"));
1577 init_unistr2(&ss0->uni_name, name, UNI_STR_TERMINATE);
1580 /*******************************************************************
1581 Reads or writes a structure.
1582 ********************************************************************/
1584 static BOOL srv_io_sess_info0_str(const char *desc, SESS_INFO_0_STR *ss0, prs_struct *ps, int depth)
1586 if (ss0 == NULL)
1587 return False;
1589 prs_debug(ps, depth, desc, "srv_io_sess_info0_str");
1590 depth++;
1592 if(!prs_align(ps))
1593 return False;
1595 if(!smb_io_unistr2("", &ss0->uni_name, True, ps, depth))
1596 return False;
1598 return True;
1601 /*******************************************************************
1602 Inits a SESS_INFO_0 structure
1603 ********************************************************************/
1605 void init_srv_sess_info0(SESS_INFO_0 *ss0, const char *name)
1607 DEBUG(5,("init_srv_sess_info0: %s\n", name));
1609 ss0->ptr_name = (name != NULL) ? 1 : 0;
1612 /*******************************************************************
1613 Reads or writes a structure.
1614 ********************************************************************/
1616 static BOOL srv_io_sess_info0(const char *desc, SESS_INFO_0 *ss0, prs_struct *ps, int depth)
1618 if (ss0 == NULL)
1619 return False;
1621 prs_debug(ps, depth, desc, "srv_io_sess_info0");
1622 depth++;
1624 if(!prs_align(ps))
1625 return False;
1627 if(!prs_uint32("ptr_name", ps, depth, &ss0->ptr_name))
1628 return False;
1630 return True;
1633 /*******************************************************************
1634 Reads or writes a structure.
1635 ********************************************************************/
1637 static BOOL srv_io_srv_sess_info_0(const char *desc, SRV_SESS_INFO_0 *ss0, prs_struct *ps, int depth)
1639 if (ss0 == NULL)
1640 return False;
1642 prs_debug(ps, depth, desc, "srv_io_srv_sess_info_0");
1643 depth++;
1645 if(!prs_align(ps))
1646 return False;
1648 if(!prs_uint32("num_entries_read", ps, depth, &ss0->num_entries_read))
1649 return False;
1650 if(!prs_uint32("ptr_sess_info", ps, depth, &ss0->ptr_sess_info))
1651 return False;
1653 if (ss0->ptr_sess_info != 0) {
1654 uint32 i;
1655 uint32 num_entries = ss0->num_entries_read;
1657 if (num_entries > MAX_SESS_ENTRIES) {
1658 num_entries = MAX_SESS_ENTRIES; /* report this! */
1661 if(!prs_uint32("num_entries_read2", ps, depth, &ss0->num_entries_read2))
1662 return False;
1664 SMB_ASSERT_ARRAY(ss0->info_0, num_entries);
1666 for (i = 0; i < num_entries; i++) {
1667 if(!srv_io_sess_info0("", &ss0->info_0[i], ps, depth))
1668 return False;
1671 for (i = 0; i < num_entries; i++) {
1672 if(!srv_io_sess_info0_str("", &ss0->info_0_str[i], ps, depth))
1673 return False;
1676 if(!prs_align(ps))
1677 return False;
1680 return True;
1683 /*******************************************************************
1684 Inits a SESS_INFO_1_STR structure
1685 ********************************************************************/
1687 void init_srv_sess_info1_str(SESS_INFO_1_STR *ss1, const char *name, const char *user)
1689 DEBUG(5,("init_srv_sess_info1_str\n"));
1691 init_unistr2(&ss1->uni_name, name, UNI_STR_TERMINATE);
1692 init_unistr2(&ss1->uni_user, user, UNI_STR_TERMINATE);
1695 /*******************************************************************
1696 Reads or writes a structure.
1697 ********************************************************************/
1699 static BOOL srv_io_sess_info1_str(const char *desc, SESS_INFO_1_STR *ss1, prs_struct *ps, int depth)
1701 if (ss1 == NULL)
1702 return False;
1704 prs_debug(ps, depth, desc, "srv_io_sess_info1_str");
1705 depth++;
1707 if(!prs_align(ps))
1708 return False;
1710 if(!smb_io_unistr2("", &ss1->uni_name, True, ps, depth))
1711 return False;
1712 if(!smb_io_unistr2("", &(ss1->uni_user), True, ps, depth))
1713 return False;
1715 return True;
1718 /*******************************************************************
1719 Inits a SESS_INFO_1 structure
1720 ********************************************************************/
1722 void init_srv_sess_info1(SESS_INFO_1 *ss1,
1723 const char *name, const char *user,
1724 uint32 num_opens, uint32 open_time, uint32 idle_time,
1725 uint32 user_flags)
1727 DEBUG(5,("init_srv_sess_info1: %s\n", name));
1729 ss1->ptr_name = (name != NULL) ? 1 : 0;
1730 ss1->ptr_user = (user != NULL) ? 1 : 0;
1732 ss1->num_opens = num_opens;
1733 ss1->open_time = open_time;
1734 ss1->idle_time = idle_time;
1735 ss1->user_flags = user_flags;
1738 /*******************************************************************
1739 reads or writes a structure.
1740 ********************************************************************/
1742 static BOOL srv_io_sess_info1(const char *desc, SESS_INFO_1 *ss1, prs_struct *ps, int depth)
1744 if (ss1 == NULL)
1745 return False;
1747 prs_debug(ps, depth, desc, "srv_io_sess_info1");
1748 depth++;
1750 if(!prs_align(ps))
1751 return False;
1753 if(!prs_uint32("ptr_name ", ps, depth, &ss1->ptr_name))
1754 return False;
1755 if(!prs_uint32("ptr_user ", ps, depth, &ss1->ptr_user))
1756 return False;
1758 if(!prs_uint32("num_opens ", ps, depth, &ss1->num_opens))
1759 return False;
1760 if(!prs_uint32("open_time ", ps, depth, &ss1->open_time))
1761 return False;
1762 if(!prs_uint32("idle_time ", ps, depth, &ss1->idle_time))
1763 return False;
1764 if(!prs_uint32("user_flags", ps, depth, &ss1->user_flags))
1765 return False;
1767 return True;
1770 /*******************************************************************
1771 Reads or writes a structure.
1772 ********************************************************************/
1774 static BOOL srv_io_srv_sess_info_1(const char *desc, SRV_SESS_INFO_1 *ss1, prs_struct *ps, int depth)
1776 if (ss1 == NULL)
1777 return False;
1779 prs_debug(ps, depth, desc, "srv_io_srv_sess_info_1");
1780 depth++;
1782 if(!prs_align(ps))
1783 return False;
1785 if(!prs_uint32("num_entries_read", ps, depth, &ss1->num_entries_read))
1786 return False;
1787 if(!prs_uint32("ptr_sess_info", ps, depth, &ss1->ptr_sess_info))
1788 return False;
1790 if (ss1->ptr_sess_info != 0) {
1791 uint32 i;
1792 uint32 num_entries = ss1->num_entries_read;
1794 if (num_entries > MAX_SESS_ENTRIES) {
1795 num_entries = MAX_SESS_ENTRIES; /* report this! */
1798 if(!prs_uint32("num_entries_read2", ps, depth, &ss1->num_entries_read2))
1799 return False;
1801 SMB_ASSERT_ARRAY(ss1->info_1, num_entries);
1803 for (i = 0; i < num_entries; i++) {
1804 if(!srv_io_sess_info1("", &ss1->info_1[i], ps, depth))
1805 return False;
1808 for (i = 0; i < num_entries; i++) {
1809 if(!srv_io_sess_info1_str("", &ss1->info_1_str[i], ps, depth))
1810 return False;
1813 if(!prs_align(ps))
1814 return False;
1817 return True;
1820 /*******************************************************************
1821 Reads or writes a structure.
1822 ********************************************************************/
1824 static BOOL srv_io_srv_sess_ctr(const char *desc, SRV_SESS_INFO_CTR **pp_ctr, prs_struct *ps, int depth)
1826 SRV_SESS_INFO_CTR *ctr = *pp_ctr;
1828 prs_debug(ps, depth, desc, "srv_io_srv_sess_ctr");
1829 depth++;
1831 if(UNMARSHALLING(ps)) {
1832 ctr = *pp_ctr = (SRV_SESS_INFO_CTR *)prs_alloc_mem(ps, sizeof(SRV_SESS_INFO_CTR));
1833 if (ctr == NULL)
1834 return False;
1837 if (ctr == NULL)
1838 return False;
1840 if(!prs_align(ps))
1841 return False;
1843 if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
1844 return False;
1845 if(!prs_uint32("ptr_sess_ctr", ps, depth, &ctr->ptr_sess_ctr))
1846 return False;
1848 if (ctr->ptr_sess_ctr != 0) {
1849 switch (ctr->switch_value) {
1850 case 0:
1851 if(!srv_io_srv_sess_info_0("", &ctr->sess.info0, ps, depth))
1852 return False;
1853 break;
1854 case 1:
1855 if(!srv_io_srv_sess_info_1("", &ctr->sess.info1, ps, depth))
1856 return False;
1857 break;
1858 default:
1859 DEBUG(5,("%s no session info at switch_value %d\n",
1860 tab_depth(depth), ctr->switch_value));
1861 break;
1865 return True;
1868 /*******************************************************************
1869 Inits a SRV_Q_NET_SESS_ENUM structure.
1870 ********************************************************************/
1872 void init_srv_q_net_sess_enum(SRV_Q_NET_SESS_ENUM *q_n,
1873 const char *srv_name, const char *qual_name,
1874 const char *user_name, uint32 sess_level,
1875 SRV_SESS_INFO_CTR *ctr, uint32 preferred_len,
1876 ENUM_HND *hnd)
1878 q_n->ctr = ctr;
1880 DEBUG(5,("init_q_net_sess_enum\n"));
1882 init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
1883 init_buf_unistr2(&q_n->uni_qual_name, &q_n->ptr_qual_name, qual_name);
1884 init_buf_unistr2(&q_n->uni_user_name, &q_n->ptr_user_name, user_name);
1886 q_n->sess_level = sess_level;
1887 q_n->preferred_len = preferred_len;
1889 memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
1892 /*******************************************************************
1893 Reads or writes a structure.
1894 ********************************************************************/
1896 BOOL srv_io_q_net_sess_enum(const char *desc, SRV_Q_NET_SESS_ENUM *q_n, prs_struct *ps, int depth)
1898 if (q_n == NULL)
1899 return False;
1901 prs_debug(ps, depth, desc, "srv_io_q_net_sess_enum");
1902 depth++;
1904 if(!prs_align(ps))
1905 return False;
1907 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
1908 return False;
1909 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1910 return False;
1912 if(!prs_align(ps))
1913 return False;
1915 if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
1916 return False;
1917 if(!smb_io_unistr2("", &q_n->uni_qual_name, q_n->ptr_qual_name, ps, depth))
1918 return False;
1920 if(!prs_align(ps))
1921 return False;
1922 if(!prs_uint32("ptr_user_name", ps, depth, &q_n->ptr_user_name))
1923 return False;
1924 if(!smb_io_unistr2("", &q_n->uni_user_name, q_n->ptr_user_name, ps, depth))
1925 return False;
1927 if(!prs_align(ps))
1928 return False;
1930 if(!prs_uint32("sess_level", ps, depth, &q_n->sess_level))
1931 return False;
1933 if (q_n->sess_level != (uint32)-1) {
1934 if(!srv_io_srv_sess_ctr("sess_ctr", &q_n->ctr, ps, depth))
1935 return False;
1938 if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
1939 return False;
1941 if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
1942 return False;
1944 return True;
1947 /*******************************************************************
1948 Reads or writes a structure.
1949 ********************************************************************/
1951 BOOL srv_io_r_net_sess_enum(const char *desc, SRV_R_NET_SESS_ENUM *r_n, prs_struct *ps, int depth)
1953 if (r_n == NULL)
1954 return False;
1956 prs_debug(ps, depth, desc, "srv_io_r_net_sess_enum");
1957 depth++;
1959 if(!prs_align(ps))
1960 return False;
1962 if(!prs_uint32("sess_level", ps, depth, &r_n->sess_level))
1963 return False;
1965 if (r_n->sess_level != (uint32)-1) {
1966 if(!srv_io_srv_sess_ctr("sess_ctr", &r_n->ctr, ps, depth))
1967 return False;
1970 if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
1971 return False;
1972 if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
1973 return False;
1974 if(!prs_werror("status", ps, depth, &r_n->status))
1975 return False;
1977 return True;
1980 /*******************************************************************
1981 Inits a CONN_INFO_0 structure
1982 ********************************************************************/
1984 void init_srv_conn_info0(CONN_INFO_0 *ss0, uint32 id)
1986 DEBUG(5,("init_srv_conn_info0\n"));
1988 ss0->id = id;
1991 /*******************************************************************
1992 Reads or writes a structure.
1993 ********************************************************************/
1995 static BOOL srv_io_conn_info0(const char *desc, CONN_INFO_0 *ss0, prs_struct *ps, int depth)
1997 if (ss0 == NULL)
1998 return False;
2000 prs_debug(ps, depth, desc, "srv_io_conn_info0");
2001 depth++;
2003 if(!prs_align(ps))
2004 return False;
2006 if(!prs_uint32("id", ps, depth, &ss0->id))
2007 return False;
2009 return True;
2012 /*******************************************************************
2013 Reads or writes a structure.
2014 ********************************************************************/
2016 static BOOL srv_io_srv_conn_info_0(const char *desc, SRV_CONN_INFO_0 *ss0, prs_struct *ps, int depth)
2018 if (ss0 == NULL)
2019 return False;
2021 prs_debug(ps, depth, desc, "srv_io_srv_conn_info_0");
2022 depth++;
2024 if(!prs_align(ps))
2025 return False;
2027 if(!prs_uint32("num_entries_read", ps, depth, &ss0->num_entries_read))
2028 return False;
2029 if(!prs_uint32("ptr_conn_info", ps, depth, &ss0->ptr_conn_info))
2030 return False;
2032 if (ss0->ptr_conn_info != 0) {
2033 int i;
2034 int num_entries = ss0->num_entries_read;
2036 if (num_entries > MAX_CONN_ENTRIES) {
2037 num_entries = MAX_CONN_ENTRIES; /* report this! */
2040 if(!prs_uint32("num_entries_read2", ps, depth, &ss0->num_entries_read2))
2041 return False;
2043 for (i = 0; i < num_entries; i++) {
2044 if(!srv_io_conn_info0("", &ss0->info_0[i], ps, depth))
2045 return False;
2048 if(!prs_align(ps))
2049 return False;
2052 return True;
2055 /*******************************************************************
2056 Inits a CONN_INFO_1_STR structure
2057 ********************************************************************/
2059 void init_srv_conn_info1_str(CONN_INFO_1_STR *ss1, const char *usr_name, const char *net_name)
2061 DEBUG(5,("init_srv_conn_info1_str\n"));
2063 init_unistr2(&ss1->uni_usr_name, usr_name, UNI_STR_TERMINATE);
2064 init_unistr2(&ss1->uni_net_name, net_name, UNI_STR_TERMINATE);
2067 /*******************************************************************
2068 Reads or writes a structure.
2069 ********************************************************************/
2071 static BOOL srv_io_conn_info1_str(const char *desc, CONN_INFO_1_STR *ss1, prs_struct *ps, int depth)
2073 if (ss1 == NULL)
2074 return False;
2076 prs_debug(ps, depth, desc, "srv_io_conn_info1_str");
2077 depth++;
2079 if(!prs_align(ps))
2080 return False;
2082 if(!smb_io_unistr2("", &ss1->uni_usr_name, True, ps, depth))
2083 return False;
2084 if(!smb_io_unistr2("", &ss1->uni_net_name, True, ps, depth))
2085 return False;
2087 return True;
2090 /*******************************************************************
2091 Inits a CONN_INFO_1 structure
2092 ********************************************************************/
2094 void init_srv_conn_info1(CONN_INFO_1 *ss1,
2095 uint32 id, uint32 type,
2096 uint32 num_opens, uint32 num_users, uint32 open_time,
2097 const char *usr_name, const char *net_name)
2099 DEBUG(5,("init_srv_conn_info1: %s %s\n", usr_name, net_name));
2101 ss1->id = id ;
2102 ss1->type = type ;
2103 ss1->num_opens = num_opens ;
2104 ss1->num_users = num_users;
2105 ss1->open_time = open_time;
2107 ss1->ptr_usr_name = (usr_name != NULL) ? 1 : 0;
2108 ss1->ptr_net_name = (net_name != NULL) ? 1 : 0;
2111 /*******************************************************************
2112 Reads or writes a structure.
2113 ********************************************************************/
2115 static BOOL srv_io_conn_info1(const char *desc, CONN_INFO_1 *ss1, prs_struct *ps, int depth)
2117 if (ss1 == NULL)
2118 return False;
2120 prs_debug(ps, depth, desc, "srv_io_conn_info1");
2121 depth++;
2123 if(!prs_align(ps))
2124 return False;
2126 if(!prs_uint32("id ", ps, depth, &ss1->id))
2127 return False;
2128 if(!prs_uint32("type ", ps, depth, &ss1->type))
2129 return False;
2130 if(!prs_uint32("num_opens ", ps, depth, &ss1->num_opens))
2131 return False;
2132 if(!prs_uint32("num_users ", ps, depth, &ss1->num_users))
2133 return False;
2134 if(!prs_uint32("open_time ", ps, depth, &ss1->open_time))
2135 return False;
2137 if(!prs_uint32("ptr_usr_name", ps, depth, &ss1->ptr_usr_name))
2138 return False;
2139 if(!prs_uint32("ptr_net_name", ps, depth, &ss1->ptr_net_name))
2140 return False;
2142 return True;
2145 /*******************************************************************
2146 Reads or writes a structure.
2147 ********************************************************************/
2149 static BOOL srv_io_srv_conn_info_1(const char *desc, SRV_CONN_INFO_1 *ss1, prs_struct *ps, int depth)
2151 if (ss1 == NULL)
2152 return False;
2154 prs_debug(ps, depth, desc, "srv_io_srv_conn_info_1");
2155 depth++;
2157 if(!prs_align(ps))
2158 return False;
2160 if(!prs_uint32("num_entries_read", ps, depth, &ss1->num_entries_read))
2161 return False;
2162 if(!prs_uint32("ptr_conn_info", ps, depth, &ss1->ptr_conn_info))
2163 return False;
2165 if (ss1->ptr_conn_info != 0) {
2166 int i;
2167 int num_entries = ss1->num_entries_read;
2169 if (num_entries > MAX_CONN_ENTRIES) {
2170 num_entries = MAX_CONN_ENTRIES; /* report this! */
2173 if(!prs_uint32("num_entries_read2", ps, depth, &ss1->num_entries_read2))
2174 return False;
2176 for (i = 0; i < num_entries; i++) {
2177 if(!srv_io_conn_info1("", &ss1->info_1[i], ps, depth))
2178 return False;
2181 for (i = 0; i < num_entries; i++) {
2182 if(!srv_io_conn_info1_str("", &ss1->info_1_str[i], ps, depth))
2183 return False;
2186 if(!prs_align(ps))
2187 return False;
2190 return True;
2193 /*******************************************************************
2194 Reads or writes a structure.
2195 ********************************************************************/
2197 static BOOL srv_io_srv_conn_ctr(const char *desc, SRV_CONN_INFO_CTR **pp_ctr, prs_struct *ps, int depth)
2199 SRV_CONN_INFO_CTR *ctr = *pp_ctr;
2201 prs_debug(ps, depth, desc, "srv_io_srv_conn_ctr");
2202 depth++;
2204 if (UNMARSHALLING(ps)) {
2205 ctr = *pp_ctr = (SRV_CONN_INFO_CTR *)prs_alloc_mem(ps, sizeof(SRV_CONN_INFO_CTR));
2206 if (ctr == NULL)
2207 return False;
2210 if (ctr == NULL)
2211 return False;
2213 if(!prs_align(ps))
2214 return False;
2216 if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
2217 return False;
2218 if(!prs_uint32("ptr_conn_ctr", ps, depth, &ctr->ptr_conn_ctr))
2219 return False;
2221 if (ctr->ptr_conn_ctr != 0) {
2222 switch (ctr->switch_value) {
2223 case 0:
2224 if(!srv_io_srv_conn_info_0("", &ctr->conn.info0, ps, depth))
2225 return False;
2226 break;
2227 case 1:
2228 if(!srv_io_srv_conn_info_1("", &ctr->conn.info1, ps, depth))
2229 return False;
2230 break;
2231 default:
2232 DEBUG(5,("%s no connection info at switch_value %d\n",
2233 tab_depth(depth), ctr->switch_value));
2234 break;
2238 return True;
2241 /*******************************************************************
2242 Reads or writes a structure.
2243 ********************************************************************/
2245 void init_srv_q_net_conn_enum(SRV_Q_NET_CONN_ENUM *q_n,
2246 const char *srv_name, const char *qual_name,
2247 uint32 conn_level, SRV_CONN_INFO_CTR *ctr,
2248 uint32 preferred_len,
2249 ENUM_HND *hnd)
2251 DEBUG(5,("init_q_net_conn_enum\n"));
2253 q_n->ctr = ctr;
2255 init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name );
2256 init_buf_unistr2(&q_n->uni_qual_name, &q_n->ptr_qual_name, qual_name);
2258 q_n->conn_level = conn_level;
2259 q_n->preferred_len = preferred_len;
2261 memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
2264 /*******************************************************************
2265 Reads or writes a structure.
2266 ********************************************************************/
2268 BOOL srv_io_q_net_conn_enum(const char *desc, SRV_Q_NET_CONN_ENUM *q_n, prs_struct *ps, int depth)
2270 if (q_n == NULL)
2271 return False;
2273 prs_debug(ps, depth, desc, "srv_io_q_net_conn_enum");
2274 depth++;
2276 if(!prs_align(ps))
2277 return False;
2279 if(!prs_uint32("ptr_srv_name ", ps, depth, &q_n->ptr_srv_name))
2280 return False;
2281 if(!smb_io_unistr2("", &q_n->uni_srv_name, q_n->ptr_srv_name, ps, depth))
2282 return False;
2284 if(!prs_align(ps))
2285 return False;
2287 if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
2288 return False;
2289 if(!smb_io_unistr2("", &q_n->uni_qual_name, q_n->ptr_qual_name, ps, depth))
2290 return False;
2292 if(!prs_align(ps))
2293 return False;
2295 if(!prs_uint32("conn_level", ps, depth, &q_n->conn_level))
2296 return False;
2298 if (q_n->conn_level != (uint32)-1) {
2299 if(!srv_io_srv_conn_ctr("conn_ctr", &q_n->ctr, ps, depth))
2300 return False;
2303 if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
2304 return False;
2306 if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
2307 return False;
2309 return True;
2312 /*******************************************************************
2313 Reads or writes a structure.
2314 ********************************************************************/
2316 BOOL srv_io_r_net_conn_enum(const char *desc, SRV_R_NET_CONN_ENUM *r_n, prs_struct *ps, int depth)
2318 if (r_n == NULL)
2319 return False;
2321 prs_debug(ps, depth, desc, "srv_io_r_net_conn_enum");
2322 depth++;
2324 if(!prs_align(ps))
2325 return False;
2327 if(!prs_uint32("conn_level", ps, depth, &r_n->conn_level))
2328 return False;
2330 if (r_n->conn_level != (uint32)-1) {
2331 if(!srv_io_srv_conn_ctr("conn_ctr", &r_n->ctr, ps, depth))
2332 return False;
2335 if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
2336 return False;
2337 if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
2338 return False;
2339 if(!prs_werror("status", ps, depth, &r_n->status))
2340 return False;
2342 return True;
2345 /*******************************************************************
2346 Inits a FILE_INFO_3_STR structure
2347 ********************************************************************/
2349 void init_srv_file_info3_str(FILE_INFO_3_STR *fi3, const char *user_name, const char *path_name)
2351 DEBUG(5,("init_srv_file_info3_str\n"));
2353 init_unistr2(&fi3->uni_path_name, path_name, UNI_STR_TERMINATE);
2354 init_unistr2(&fi3->uni_user_name, user_name, UNI_STR_TERMINATE);
2357 /*******************************************************************
2358 Reads or writes a structure.
2359 ********************************************************************/
2361 static BOOL srv_io_file_info3_str(const char *desc, FILE_INFO_3_STR *sh1, prs_struct *ps, int depth)
2363 if (sh1 == NULL)
2364 return False;
2366 prs_debug(ps, depth, desc, "srv_io_file_info3_str");
2367 depth++;
2369 if(!prs_align(ps))
2370 return False;
2372 if(!smb_io_unistr2("", &sh1->uni_path_name, True, ps, depth))
2373 return False;
2374 if(!smb_io_unistr2("", &sh1->uni_user_name, True, ps, depth))
2375 return False;
2377 return True;
2380 /*******************************************************************
2381 Inits a FILE_INFO_3 structure
2382 ********************************************************************/
2384 void init_srv_file_info3(FILE_INFO_3 *fl3,
2385 uint32 id, uint32 perms, uint32 num_locks,
2386 const char *path_name, const char *user_name)
2388 DEBUG(5,("init_srv_file_info3: %s %s\n", path_name, user_name));
2390 fl3->id = id;
2391 fl3->perms = perms;
2392 fl3->num_locks = num_locks;
2394 fl3->ptr_path_name = (path_name != NULL) ? 1 : 0;
2395 fl3->ptr_user_name = (user_name != NULL) ? 1 : 0;
2398 /*******************************************************************
2399 Reads or writes a structure.
2400 ********************************************************************/
2402 static BOOL srv_io_file_info3(const char *desc, FILE_INFO_3 *fl3, prs_struct *ps, int depth)
2404 if (fl3 == NULL)
2405 return False;
2407 prs_debug(ps, depth, desc, "srv_io_file_info3");
2408 depth++;
2410 if(!prs_align(ps))
2411 return False;
2413 if(!prs_uint32("id ", ps, depth, &fl3->id))
2414 return False;
2415 if(!prs_uint32("perms ", ps, depth, &fl3->perms))
2416 return False;
2417 if(!prs_uint32("num_locks ", ps, depth, &fl3->num_locks))
2418 return False;
2419 if(!prs_uint32("ptr_path_name", ps, depth, &fl3->ptr_path_name))
2420 return False;
2421 if(!prs_uint32("ptr_user_name", ps, depth, &fl3->ptr_user_name))
2422 return False;
2424 return True;
2427 /*******************************************************************
2428 Reads or writes a structure.
2429 ********************************************************************/
2431 static BOOL srv_io_srv_file_ctr(const char *desc, SRV_FILE_INFO_CTR *ctr, prs_struct *ps, int depth)
2433 if (ctr == NULL)
2434 return False;
2436 prs_debug(ps, depth, desc, "srv_io_srv_file_ctr");
2437 depth++;
2439 if (UNMARSHALLING(ps)) {
2440 memset(ctr, '\0', sizeof(SRV_FILE_INFO_CTR));
2443 if(!prs_align(ps))
2444 return False;
2446 if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
2447 return False;
2448 if (ctr->switch_value != 3) {
2449 DEBUG(5,("%s File info %d level not supported\n",
2450 tab_depth(depth), ctr->switch_value));
2452 if(!prs_uint32("ptr_file_info", ps, depth, &ctr->ptr_file_info))
2453 return False;
2454 if(!prs_uint32("num_entries", ps, depth, &ctr->num_entries))
2455 return False;
2456 if(!prs_uint32("ptr_entries", ps, depth, &ctr->ptr_entries))
2457 return False;
2458 if (ctr->ptr_entries == 0)
2459 return True;
2460 if(!prs_uint32("num_entries2", ps, depth,
2461 &ctr->num_entries2))
2462 return False;
2464 switch (ctr->switch_value) {
2465 case 3: {
2466 SRV_FILE_INFO_3 *info3 = ctr->file.info3;
2467 int num_entries = ctr->num_entries;
2468 int i;
2470 if (UNMARSHALLING(ps)) {
2471 if (!(info3 = (SRV_FILE_INFO_3 *)prs_alloc_mem(ps, num_entries * sizeof(SRV_FILE_INFO_3))))
2472 return False;
2473 ctr->file.info3 = info3;
2476 for (i = 0; i < num_entries; i++) {
2477 if(!srv_io_file_info3("", &ctr->file.info3[i].info_3, ps, depth))
2478 return False;
2480 for (i = 0; i < num_entries; i++) {
2481 if(!srv_io_file_info3_str("", &ctr->file.info3[i].info_3_str, ps, depth))
2482 return False;
2484 break;
2486 default:
2487 DEBUG(5,("%s no file info at switch_value %d\n",
2488 tab_depth(depth), ctr->switch_value));
2489 break;
2492 return True;
2495 /*******************************************************************
2496 Inits a SRV_Q_NET_FILE_ENUM structure.
2497 ********************************************************************/
2499 void init_srv_q_net_file_enum(SRV_Q_NET_FILE_ENUM *q_n,
2500 const char *srv_name, const char *qual_name,
2501 const char *user_name,
2502 uint32 file_level, SRV_FILE_INFO_CTR *ctr,
2503 uint32 preferred_len,
2504 ENUM_HND *hnd)
2506 DEBUG(5,("init_q_net_file_enum\n"));
2508 init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
2509 init_buf_unistr2(&q_n->uni_qual_name, &q_n->ptr_qual_name, qual_name);
2510 init_buf_unistr2(&q_n->uni_user_name, &q_n->ptr_user_name, user_name);
2512 q_n->file_level = q_n->ctr.switch_value = file_level;
2513 q_n->preferred_len = preferred_len;
2514 q_n->ctr.ptr_file_info = 1;
2515 q_n->ctr.num_entries = 0;
2516 q_n->ctr.num_entries2 = 0;
2518 memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
2521 /*******************************************************************
2522 Reads or writes a structure.
2523 ********************************************************************/
2525 BOOL srv_io_q_net_file_enum(const char *desc, SRV_Q_NET_FILE_ENUM *q_n, prs_struct *ps, int depth)
2527 if (q_n == NULL)
2528 return False;
2530 prs_debug(ps, depth, desc, "srv_io_q_net_file_enum");
2531 depth++;
2533 if(!prs_align(ps))
2534 return False;
2536 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
2537 return False;
2538 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
2539 return False;
2541 if(!prs_align(ps))
2542 return False;
2544 if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
2545 return False;
2546 if(!smb_io_unistr2("", &q_n->uni_qual_name, q_n->ptr_qual_name, ps, depth))
2547 return False;
2549 if(!prs_align(ps))
2550 return False;
2552 if(!prs_uint32("ptr_user_name", ps, depth, &q_n->ptr_user_name))
2553 return False;
2554 if(!smb_io_unistr2("", &q_n->uni_user_name, q_n->ptr_user_name, ps, depth))
2555 return False;
2557 if(!prs_align(ps))
2558 return False;
2559 if(!prs_uint32("file_level", ps, depth, &q_n->file_level))
2560 return False;
2562 if (q_n->file_level != (uint32)-1) {
2563 if(!srv_io_srv_file_ctr("file_ctr", &q_n->ctr, ps, depth))
2564 return False;
2567 if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
2568 return False;
2570 if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
2571 return False;
2573 return True;
2576 /*******************************************************************
2577 Reads or writes a structure.
2578 ********************************************************************/
2580 BOOL srv_io_r_net_file_enum(const char *desc, SRV_R_NET_FILE_ENUM *r_n, prs_struct *ps, int depth)
2582 if (r_n == NULL)
2583 return False;
2585 prs_debug(ps, depth, desc, "srv_io_r_net_file_enum");
2586 depth++;
2588 if(!prs_align(ps))
2589 return False;
2591 if(!prs_uint32("file_level", ps, depth, &r_n->file_level))
2592 return False;
2594 if (r_n->file_level != 0) {
2595 if(!srv_io_srv_file_ctr("file_ctr", &r_n->ctr, ps, depth))
2596 return False;
2599 if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
2600 return False;
2601 if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
2602 return False;
2603 if(!prs_werror("status", ps, depth, &r_n->status))
2604 return False;
2606 return True;
2609 /*******************************************************************
2610 Initialize a net file close request
2611 ********************************************************************/
2612 void init_srv_q_net_file_close(SRV_Q_NET_FILE_CLOSE *q_n, const char *server,
2613 uint32 file_id)
2615 q_n->ptr_srv_name = 1;
2616 init_unistr2(&q_n->uni_srv_name, server, UNI_STR_TERMINATE);
2617 q_n->file_id = file_id;
2620 /*******************************************************************
2621 Reads or writes a structure.
2622 ********************************************************************/
2623 BOOL srv_io_q_net_file_close(const char *desc, SRV_Q_NET_FILE_CLOSE *q_n,
2624 prs_struct *ps, int depth)
2626 if (q_n == NULL)
2627 return False;
2629 prs_debug(ps, depth, desc, "srv_io_q_net_file_close");
2630 depth++;
2632 if(!prs_align(ps))
2633 return False;
2635 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
2636 return False;
2637 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
2638 return False;
2640 if(!prs_align(ps))
2641 return False;
2643 if(!prs_uint32("file_id", ps, depth, &q_n->file_id))
2644 return False;
2646 return True;
2649 /*******************************************************************
2650 Reads or writes a structure.
2651 ********************************************************************/
2653 BOOL srv_io_r_net_file_close(const char *desc, SRV_R_NET_FILE_CLOSE *q_n,
2654 prs_struct *ps, int depth)
2656 if (q_n == NULL)
2657 return False;
2659 prs_debug(ps, depth, desc, "srv_io_r_net_file_close");
2660 depth++;
2662 if(!prs_align(ps))
2663 return False;
2665 if(!prs_werror("status", ps, depth, &q_n->status))
2666 return False;
2668 return True;
2671 /*******************************************************************
2672 Inits a SRV_INFO_100 structure.
2673 ********************************************************************/
2675 void init_srv_info_100(SRV_INFO_100 *sv100, uint32 platform_id, const char *name)
2677 DEBUG(5,("init_srv_info_100\n"));
2679 sv100->platform_id = platform_id;
2680 init_buf_unistr2(&sv100->uni_name, &sv100->ptr_name, name);
2683 /*******************************************************************
2684 Reads or writes a SRV_INFO_101 structure.
2685 ********************************************************************/
2687 static BOOL srv_io_info_100(const char *desc, SRV_INFO_100 *sv100, prs_struct *ps, int depth)
2689 if (sv100 == NULL)
2690 return False;
2692 prs_debug(ps, depth, desc, "srv_io_info_100");
2693 depth++;
2695 if(!prs_align(ps))
2696 return False;
2698 if(!prs_uint32("platform_id ", ps, depth, &sv100->platform_id))
2699 return False;
2700 if(!prs_uint32("ptr_name ", ps, depth, &sv100->ptr_name))
2701 return False;
2703 if(!smb_io_unistr2("uni_name ", &sv100->uni_name, True, ps, depth))
2704 return False;
2706 return True;
2710 /*******************************************************************
2711 Inits a SRV_INFO_101 structure.
2712 ********************************************************************/
2714 void init_srv_info_101(SRV_INFO_101 *sv101, uint32 platform_id, const char *name,
2715 uint32 ver_major, uint32 ver_minor,
2716 uint32 srv_type, const char *comment)
2718 DEBUG(5,("init_srv_info_101\n"));
2720 sv101->platform_id = platform_id;
2721 init_buf_unistr2(&sv101->uni_name, &sv101->ptr_name, name);
2722 sv101->ver_major = ver_major;
2723 sv101->ver_minor = ver_minor;
2724 sv101->srv_type = srv_type;
2725 init_buf_unistr2(&sv101->uni_comment, &sv101->ptr_comment, comment);
2728 /*******************************************************************
2729 Reads or writes a SRV_INFO_101 structure.
2730 ********************************************************************/
2732 static BOOL srv_io_info_101(const char *desc, SRV_INFO_101 *sv101, prs_struct *ps, int depth)
2734 if (sv101 == NULL)
2735 return False;
2737 prs_debug(ps, depth, desc, "srv_io_info_101");
2738 depth++;
2740 if(!prs_align(ps))
2741 return False;
2743 if(!prs_uint32("platform_id ", ps, depth, &sv101->platform_id))
2744 return False;
2745 if(!prs_uint32("ptr_name ", ps, depth, &sv101->ptr_name))
2746 return False;
2747 if(!prs_uint32("ver_major ", ps, depth, &sv101->ver_major))
2748 return False;
2749 if(!prs_uint32("ver_minor ", ps, depth, &sv101->ver_minor))
2750 return False;
2751 if(!prs_uint32("srv_type ", ps, depth, &sv101->srv_type))
2752 return False;
2753 if(!prs_uint32("ptr_comment ", ps, depth, &sv101->ptr_comment))
2754 return False;
2756 if(!prs_align(ps))
2757 return False;
2759 if(!smb_io_unistr2("uni_name ", &sv101->uni_name, True, ps, depth))
2760 return False;
2761 if(!smb_io_unistr2("uni_comment ", &sv101->uni_comment, True, ps, depth))
2762 return False;
2764 return True;
2767 /*******************************************************************
2768 Inits a SRV_INFO_102 structure.
2769 ********************************************************************/
2771 void init_srv_info_102(SRV_INFO_102 *sv102, uint32 platform_id, const char *name,
2772 const char *comment, uint32 ver_major, uint32 ver_minor,
2773 uint32 srv_type, uint32 users, uint32 disc, uint32 hidden,
2774 uint32 announce, uint32 ann_delta, uint32 licenses,
2775 const char *usr_path)
2777 DEBUG(5,("init_srv_info_102\n"));
2779 sv102->platform_id = platform_id;
2780 init_buf_unistr2(&sv102->uni_name, &sv102->ptr_name, name);
2781 sv102->ver_major = ver_major;
2782 sv102->ver_minor = ver_minor;
2783 sv102->srv_type = srv_type;
2784 init_buf_unistr2(&sv102->uni_comment, &sv102->ptr_comment, comment);
2786 /* same as 101 up to here */
2788 sv102->users = users;
2789 sv102->disc = disc;
2790 sv102->hidden = hidden;
2791 sv102->announce = announce;
2792 sv102->ann_delta = ann_delta;
2793 sv102->licenses = licenses;
2794 init_buf_unistr2(&sv102->uni_usr_path, &sv102->ptr_usr_path, usr_path);
2798 /*******************************************************************
2799 Reads or writes a SRV_INFO_102 structure.
2800 ********************************************************************/
2802 static BOOL srv_io_info_102(const char *desc, SRV_INFO_102 *sv102, prs_struct *ps, int depth)
2804 if (sv102 == NULL)
2805 return False;
2807 prs_debug(ps, depth, desc, "srv_io_info102");
2808 depth++;
2810 if(!prs_align(ps))
2811 return False;
2813 if(!prs_uint32("platform_id ", ps, depth, &sv102->platform_id))
2814 return False;
2815 if(!prs_uint32("ptr_name ", ps, depth, &sv102->ptr_name))
2816 return False;
2817 if(!prs_uint32("ver_major ", ps, depth, &sv102->ver_major))
2818 return False;
2819 if(!prs_uint32("ver_minor ", ps, depth, &sv102->ver_minor))
2820 return False;
2821 if(!prs_uint32("srv_type ", ps, depth, &sv102->srv_type))
2822 return False;
2823 if(!prs_uint32("ptr_comment ", ps, depth, &sv102->ptr_comment))
2824 return False;
2826 /* same as 101 up to here */
2828 if(!prs_uint32("users ", ps, depth, &sv102->users))
2829 return False;
2830 if(!prs_uint32("disc ", ps, depth, &sv102->disc))
2831 return False;
2832 if(!prs_uint32("hidden ", ps, depth, &sv102->hidden))
2833 return False;
2834 if(!prs_uint32("announce ", ps, depth, &sv102->announce))
2835 return False;
2836 if(!prs_uint32("ann_delta ", ps, depth, &sv102->ann_delta))
2837 return False;
2838 if(!prs_uint32("licenses ", ps, depth, &sv102->licenses))
2839 return False;
2840 if(!prs_uint32("ptr_usr_path", ps, depth, &sv102->ptr_usr_path))
2841 return False;
2843 if(!smb_io_unistr2("uni_name ", &sv102->uni_name, True, ps, depth))
2844 return False;
2845 if(!prs_align(ps))
2846 return False;
2847 if(!smb_io_unistr2("uni_comment ", &sv102->uni_comment, True, ps, depth))
2848 return False;
2849 if(!prs_align(ps))
2850 return False;
2851 if(!smb_io_unistr2("uni_usr_path", &sv102->uni_usr_path, True, ps, depth))
2852 return False;
2854 return True;
2857 /*******************************************************************
2858 Reads or writes a SRV_INFO_102 structure.
2859 ********************************************************************/
2861 static BOOL srv_io_info_ctr(const char *desc, SRV_INFO_CTR *ctr, prs_struct *ps, int depth)
2863 if (ctr == NULL)
2864 return False;
2866 prs_debug(ps, depth, desc, "srv_io_info_ctr");
2867 depth++;
2869 if(!prs_align(ps))
2870 return False;
2872 if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
2873 return False;
2874 if(!prs_uint32("ptr_srv_ctr ", ps, depth, &ctr->ptr_srv_ctr))
2875 return False;
2877 if (ctr->ptr_srv_ctr != 0 && ctr->switch_value != 0 && ctr != NULL) {
2878 switch (ctr->switch_value) {
2879 case 100:
2880 if(!srv_io_info_100("sv100", &ctr->srv.sv100, ps, depth))
2881 return False;
2882 break;
2883 case 101:
2884 if(!srv_io_info_101("sv101", &ctr->srv.sv101, ps, depth))
2885 return False;
2886 break;
2887 case 102:
2888 if(!srv_io_info_102("sv102", &ctr->srv.sv102, ps, depth))
2889 return False;
2890 break;
2891 default:
2892 DEBUG(5,("%s no server info at switch_value %d\n",
2893 tab_depth(depth), ctr->switch_value));
2894 break;
2896 if(!prs_align(ps))
2897 return False;
2900 return True;
2903 /*******************************************************************
2904 Inits a SRV_Q_NET_SRV_GET_INFO structure.
2905 ********************************************************************/
2907 void init_srv_q_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *srv,
2908 const char *server_name, uint32 switch_value)
2910 DEBUG(5,("init_srv_q_net_srv_get_info\n"));
2912 init_buf_unistr2(&srv->uni_srv_name, &srv->ptr_srv_name, server_name);
2914 srv->switch_value = switch_value;
2917 /*******************************************************************
2918 Reads or writes a structure.
2919 ********************************************************************/
2921 BOOL srv_io_q_net_srv_get_info(const char *desc, SRV_Q_NET_SRV_GET_INFO *q_n, prs_struct *ps, int depth)
2923 if (q_n == NULL)
2924 return False;
2926 prs_debug(ps, depth, desc, "srv_io_q_net_srv_get_info");
2927 depth++;
2929 if(!prs_align(ps))
2930 return False;
2932 if(!prs_uint32("ptr_srv_name ", ps, depth, &q_n->ptr_srv_name))
2933 return False;
2934 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
2935 return False;
2937 if(!prs_align(ps))
2938 return False;
2940 if(!prs_uint32("switch_value ", ps, depth, &q_n->switch_value))
2941 return False;
2943 return True;
2946 /*******************************************************************
2947 Inits a SRV_R_NET_SRV_GET_INFO structure.
2948 ********************************************************************/
2950 void init_srv_r_net_srv_get_info(SRV_R_NET_SRV_GET_INFO *srv,
2951 uint32 switch_value, SRV_INFO_CTR *ctr, WERROR status)
2953 DEBUG(5,("init_srv_r_net_srv_get_info\n"));
2955 srv->ctr = ctr;
2957 if (W_ERROR_IS_OK(status)) {
2958 srv->ctr->switch_value = switch_value;
2959 srv->ctr->ptr_srv_ctr = 1;
2960 } else {
2961 srv->ctr->switch_value = 0;
2962 srv->ctr->ptr_srv_ctr = 0;
2965 srv->status = status;
2968 /*******************************************************************
2969 Inits a SRV_R_NET_SRV_SET_INFO structure.
2970 ********************************************************************/
2972 void init_srv_r_net_srv_set_info(SRV_R_NET_SRV_SET_INFO *srv,
2973 uint32 switch_value, WERROR status)
2975 DEBUG(5,("init_srv_r_net_srv_set_info\n"));
2977 srv->switch_value = switch_value;
2978 srv->status = status;
2981 /*******************************************************************
2982 Reads or writes a structure.
2983 ********************************************************************/
2985 BOOL srv_io_q_net_srv_set_info(const char *desc, SRV_Q_NET_SRV_SET_INFO *q_n,
2986 prs_struct *ps, int depth)
2988 prs_debug(ps, depth, desc, "srv_io_q_net_srv_set_info");
2989 depth++;
2991 if(!prs_align(ps))
2992 return False;
2994 if(!prs_uint32("ptr_srv_name ", ps, depth, &q_n->ptr_srv_name))
2995 return False;
2996 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
2997 return False;
2999 if(!prs_align(ps))
3000 return False;
3002 if(!prs_uint32("switch_value ", ps, depth, &q_n->switch_value))
3003 return False;
3005 if (UNMARSHALLING(ps)) {
3006 q_n->ctr = (SRV_INFO_CTR *)
3007 prs_alloc_mem(ps, sizeof(SRV_INFO_CTR));
3009 if (!q_n->ctr)
3010 return False;
3013 if(!srv_io_info_ctr("ctr", q_n->ctr, ps, depth))
3014 return False;
3016 return True;
3019 /*******************************************************************
3020 Reads or writes a structure.
3021 ********************************************************************/
3023 BOOL srv_io_r_net_srv_get_info(const char *desc, SRV_R_NET_SRV_GET_INFO *r_n, prs_struct *ps, int depth)
3025 if (r_n == NULL)
3026 return False;
3028 prs_debug(ps, depth, desc, "srv_io_r_net_srv_get_info");
3029 depth++;
3031 if(!prs_align(ps))
3032 return False;
3034 if(!srv_io_info_ctr("ctr", r_n->ctr, ps, depth))
3035 return False;
3037 if(!prs_werror("status", ps, depth, &r_n->status))
3038 return False;
3040 return True;
3043 /*******************************************************************
3044 Reads or writes a structure.
3045 ********************************************************************/
3047 BOOL srv_io_r_net_srv_set_info(const char *desc, SRV_R_NET_SRV_SET_INFO *r_n,
3048 prs_struct *ps, int depth)
3050 prs_debug(ps, depth, desc, "srv_io_r_net_srv_set_info");
3051 depth++;
3053 if(!prs_align(ps))
3054 return False;
3056 if(!prs_uint32("switch value ", ps, depth, &r_n->switch_value))
3057 return False;
3059 if(!prs_werror("status", ps, depth, &r_n->status))
3060 return False;
3062 return True;
3065 /*******************************************************************
3066 Reads or writes a structure.
3067 ********************************************************************/
3069 BOOL srv_io_q_net_remote_tod(const char *desc, SRV_Q_NET_REMOTE_TOD *q_n, prs_struct *ps, int depth)
3071 if (q_n == NULL)
3072 return False;
3074 prs_debug(ps, depth, desc, "srv_io_q_net_remote_tod");
3075 depth++;
3077 if(!prs_align(ps))
3078 return False;
3080 if(!prs_uint32("ptr_srv_name ", ps, depth, &q_n->ptr_srv_name))
3081 return False;
3082 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
3083 return False;
3085 return True;
3088 /*******************************************************************
3089 Reads or writes a TIME_OF_DAY_INFO structure.
3090 ********************************************************************/
3092 static BOOL srv_io_time_of_day_info(const char *desc, TIME_OF_DAY_INFO *tod, prs_struct *ps, int depth)
3094 if (tod == NULL)
3095 return False;
3097 prs_debug(ps, depth, desc, "srv_io_time_of_day_info");
3098 depth++;
3100 if(!prs_align(ps))
3101 return False;
3103 if(!prs_uint32("elapsedt ", ps, depth, &tod->elapsedt))
3104 return False;
3105 if(!prs_uint32("msecs ", ps, depth, &tod->msecs))
3106 return False;
3107 if(!prs_uint32("hours ", ps, depth, &tod->hours))
3108 return False;
3109 if(!prs_uint32("mins ", ps, depth, &tod->mins))
3110 return False;
3111 if(!prs_uint32("secs ", ps, depth, &tod->secs))
3112 return False;
3113 if(!prs_uint32("hunds ", ps, depth, &tod->hunds))
3114 return False;
3115 if(!prs_uint32("timezone ", ps, depth, &tod->zone))
3116 return False;
3117 if(!prs_uint32("tintervals ", ps, depth, &tod->tintervals))
3118 return False;
3119 if(!prs_uint32("day ", ps, depth, &tod->day))
3120 return False;
3121 if(!prs_uint32("month ", ps, depth, &tod->month))
3122 return False;
3123 if(!prs_uint32("year ", ps, depth, &tod->year))
3124 return False;
3125 if(!prs_uint32("weekday ", ps, depth, &tod->weekday))
3126 return False;
3128 return True;
3131 /*******************************************************************
3132 Inits a TIME_OF_DAY_INFO structure.
3133 ********************************************************************/
3135 void init_time_of_day_info(TIME_OF_DAY_INFO *tod, uint32 elapsedt, uint32 msecs,
3136 uint32 hours, uint32 mins, uint32 secs, uint32 hunds,
3137 uint32 zone, uint32 tintervals, uint32 day,
3138 uint32 month, uint32 year, uint32 weekday)
3140 DEBUG(5,("init_time_of_day_info\n"));
3142 tod->elapsedt = elapsedt;
3143 tod->msecs = msecs;
3144 tod->hours = hours;
3145 tod->mins = mins;
3146 tod->secs = secs;
3147 tod->hunds = hunds;
3148 tod->zone = zone;
3149 tod->tintervals = tintervals;
3150 tod->day = day;
3151 tod->month = month;
3152 tod->year = year;
3153 tod->weekday = weekday;
3157 /*******************************************************************
3158 Reads or writes a structure.
3159 ********************************************************************/
3161 BOOL srv_io_r_net_remote_tod(const char *desc, SRV_R_NET_REMOTE_TOD *r_n, prs_struct *ps, int depth)
3163 if (r_n == NULL)
3164 return False;
3166 prs_debug(ps, depth, desc, "srv_io_r_net_remote_tod");
3167 depth++;
3169 if(!prs_align(ps))
3170 return False;
3172 if(!prs_uint32("ptr_srv_tod ", ps, depth, &r_n->ptr_srv_tod))
3173 return False;
3175 if(!srv_io_time_of_day_info("tod", r_n->tod, ps, depth))
3176 return False;
3178 if(!prs_werror("status", ps, depth, &r_n->status))
3179 return False;
3181 return True;
3184 /*******************************************************************
3185 initialises a structure.
3186 ********************************************************************/
3188 BOOL init_srv_q_net_disk_enum(SRV_Q_NET_DISK_ENUM *q_n,
3189 const char *srv_name,
3190 uint32 preferred_len,
3191 ENUM_HND *enum_hnd
3196 DEBUG(5,("init_srv_q_net_srv_disk_enum\n"));
3198 init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
3200 q_n->disk_enum_ctr.level = 0;
3201 q_n->disk_enum_ctr.disk_info_ptr = 0;
3203 q_n->preferred_len = preferred_len;
3204 memcpy(&q_n->enum_hnd, enum_hnd, sizeof(*enum_hnd));
3206 return True;
3209 /*******************************************************************
3210 Reads or writes a structure.
3211 ********************************************************************/
3213 BOOL srv_io_q_net_disk_enum(const char *desc, SRV_Q_NET_DISK_ENUM *q_n, prs_struct *ps, int depth)
3215 if (q_n == NULL)
3216 return False;
3218 prs_debug(ps, depth, desc, "srv_io_q_net_disk_enum");
3219 depth++;
3221 if(!prs_align(ps))
3222 return False;
3224 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
3225 return False;
3227 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
3228 return False;
3230 if(!prs_align(ps))
3231 return False;
3233 if(!prs_uint32("level", ps, depth, &q_n->disk_enum_ctr.level))
3234 return False;
3236 if(!prs_uint32("entries_read", ps, depth, &q_n->disk_enum_ctr.entries_read))
3237 return False;
3239 if(!prs_uint32("buffer", ps, depth, &q_n->disk_enum_ctr.disk_info_ptr))
3240 return False;
3242 if(!prs_align(ps))
3243 return False;
3245 if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
3246 return False;
3247 if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
3248 return False;
3250 return True;
3253 /*******************************************************************
3254 Reads or writes a structure.
3255 ********************************************************************/
3257 BOOL srv_io_r_net_disk_enum(const char *desc, SRV_R_NET_DISK_ENUM *r_n, prs_struct *ps, int depth)
3260 unsigned int i;
3261 uint32 entries_read, entries_read2, entries_read3;
3263 if (r_n == NULL)
3264 return False;
3266 prs_debug(ps, depth, desc, "srv_io_r_net_disk_enum");
3267 depth++;
3269 entries_read = entries_read2 = entries_read3 = r_n->disk_enum_ctr.entries_read;
3271 if(!prs_align(ps))
3272 return False;
3274 if(!prs_uint32("entries_read", ps, depth, &entries_read))
3275 return False;
3276 if(!prs_uint32("ptr_disk_info", ps, depth, &r_n->disk_enum_ctr.disk_info_ptr))
3277 return False;
3279 /*this may be max, unknown, actual?*/
3281 if(!prs_uint32("max_elements", ps, depth, &entries_read2))
3282 return False;
3283 if(!prs_uint32("unknown", ps, depth, &r_n->disk_enum_ctr.unknown))
3284 return False;
3285 if(!prs_uint32("actual_elements", ps, depth, &entries_read3))
3286 return False;
3288 r_n->disk_enum_ctr.entries_read = entries_read3;
3290 if(UNMARSHALLING(ps)) {
3292 DISK_INFO *dinfo;
3294 if(!(dinfo = (DISK_INFO *)prs_alloc_mem(ps, sizeof(*dinfo) * entries_read3)))
3295 return False;
3296 r_n->disk_enum_ctr.disk_info = dinfo;
3299 for(i=0; i < r_n->disk_enum_ctr.entries_read; i++) {
3301 if(!prs_uint32("unknown", ps, depth, &r_n->disk_enum_ctr.disk_info[i].unknown))
3302 return False;
3304 if(!smb_io_unistr3("disk_name", &r_n->disk_enum_ctr.disk_info[i].disk_name, ps, depth))
3305 return False;
3307 if(!prs_align(ps))
3308 return False;
3311 if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
3312 return False;
3314 if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
3315 return False;
3317 if(!prs_werror("status", ps, depth, &r_n->status))
3318 return False;
3320 return True;
3323 /*******************************************************************
3324 initialises a structure.
3325 ********************************************************************/
3327 BOOL init_srv_q_net_name_validate(SRV_Q_NET_NAME_VALIDATE *q_n, const char *srv_name, const char *share_name, int type)
3329 uint32 ptr_share_name;
3331 DEBUG(5,("init_srv_q_net_name_validate\n"));
3333 init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
3334 init_buf_unistr2(&q_n->uni_name, &ptr_share_name, share_name);
3336 q_n->type = type;
3337 q_n->flags = 0;
3339 return True;
3342 /*******************************************************************
3343 Reads or writes a structure.
3344 ********************************************************************/
3346 BOOL srv_io_q_net_name_validate(const char *desc, SRV_Q_NET_NAME_VALIDATE *q_n, prs_struct *ps, int depth)
3348 if (q_n == NULL)
3349 return False;
3351 prs_debug(ps, depth, desc, "srv_io_q_net_name_validate");
3352 depth++;
3354 if(!prs_align(ps))
3355 return False;
3357 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
3358 return False;
3360 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
3361 return False;
3363 if(!prs_align(ps))
3364 return False;
3366 if(!smb_io_unistr2("", &q_n->uni_name, True, ps, depth))
3367 return False;
3369 if(!prs_align(ps))
3370 return False;
3372 if(!prs_uint32("type", ps, depth, &q_n->type))
3373 return False;
3375 if(!prs_uint32("flags", ps, depth, &q_n->flags))
3376 return False;
3378 return True;
3381 /*******************************************************************
3382 Reads or writes a structure.
3383 ********************************************************************/
3385 BOOL srv_io_r_net_name_validate(const char *desc, SRV_R_NET_NAME_VALIDATE *r_n, prs_struct *ps, int depth)
3387 if (r_n == NULL)
3388 return False;
3390 prs_debug(ps, depth, desc, "srv_io_r_net_name_validate");
3391 depth++;
3393 if(!prs_align(ps))
3394 return False;
3396 if(!prs_werror("status", ps, depth, &r_n->status))
3397 return False;
3399 return True;
3402 /*******************************************************************
3403 Reads or writes a structure.
3404 ********************************************************************/
3406 BOOL srv_io_q_net_file_query_secdesc(const char *desc, SRV_Q_NET_FILE_QUERY_SECDESC *q_n, prs_struct *ps, int depth)
3408 if (q_n == NULL)
3409 return False;
3411 prs_debug(ps, depth, desc, "srv_io_q_net_file_query_secdesc");
3412 depth++;
3414 if(!prs_align(ps))
3415 return False;
3417 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
3418 return False;
3420 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
3421 return False;
3423 if(!prs_align(ps))
3424 return False;
3426 if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
3427 return False;
3429 if(!smb_io_unistr2("", &q_n->uni_qual_name, True, ps, depth))
3430 return False;
3432 if(!prs_align(ps))
3433 return False;
3435 if(!smb_io_unistr2("", &q_n->uni_file_name, True, ps, depth))
3436 return False;
3438 if(!prs_uint32("unknown1", ps, depth, &q_n->unknown1))
3439 return False;
3441 if(!prs_uint32("unknown2", ps, depth, &q_n->unknown2))
3442 return False;
3444 if(!prs_uint32("unknown3", ps, depth, &q_n->unknown3))
3445 return False;
3447 return True;
3450 /*******************************************************************
3451 Reads or writes a structure.
3452 ********************************************************************/
3454 BOOL srv_io_r_net_file_query_secdesc(const char *desc, SRV_R_NET_FILE_QUERY_SECDESC *r_n, prs_struct *ps, int depth)
3456 if (r_n == NULL)
3457 return False;
3459 prs_debug(ps, depth, desc, "srv_io_r_net_file_query_secdesc");
3460 depth++;
3462 if(!prs_align(ps))
3463 return False;
3465 if(!prs_uint32("ptr_response", ps, depth, &r_n->ptr_response))
3466 return False;
3468 if(!prs_uint32("size_response", ps, depth, &r_n->size_response))
3469 return False;
3471 if(!prs_uint32("ptr_secdesc", ps, depth, &r_n->ptr_secdesc))
3472 return False;
3474 if(!prs_uint32("size_secdesc", ps, depth, &r_n->size_secdesc))
3475 return False;
3477 if(!sec_io_desc("sec_desc", &r_n->sec_desc, ps, depth))
3478 return False;
3480 if(!prs_align(ps))
3481 return False;
3483 if(!prs_werror("status", ps, depth, &r_n->status))
3484 return False;
3486 return True;
3489 /*******************************************************************
3490 Reads or writes a structure.
3491 ********************************************************************/
3493 BOOL srv_io_q_net_file_set_secdesc(const char *desc, SRV_Q_NET_FILE_SET_SECDESC *q_n, prs_struct *ps, int depth)
3495 if (q_n == NULL)
3496 return False;
3498 prs_debug(ps, depth, desc, "srv_io_q_net_file_set_secdesc");
3499 depth++;
3501 if(!prs_align(ps))
3502 return False;
3504 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
3505 return False;
3507 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
3508 return False;
3510 if(!prs_align(ps))
3511 return False;
3513 if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
3514 return False;
3516 if(!smb_io_unistr2("", &q_n->uni_qual_name, True, ps, depth))
3517 return False;
3519 if(!prs_align(ps))
3520 return False;
3522 if(!smb_io_unistr2("", &q_n->uni_file_name, True, ps, depth))
3523 return False;
3525 if(!prs_align(ps))
3526 return False;
3528 if(!prs_uint32("sec_info", ps, depth, &q_n->sec_info))
3529 return False;
3531 if(!prs_uint32("size_set", ps, depth, &q_n->size_set))
3532 return False;
3534 if(!prs_uint32("ptr_secdesc", ps, depth, &q_n->ptr_secdesc))
3535 return False;
3537 if(!prs_uint32("size_secdesc", ps, depth, &q_n->size_secdesc))
3538 return False;
3540 if(!sec_io_desc("sec_desc", &q_n->sec_desc, ps, depth))
3541 return False;
3543 return True;
3546 /*******************************************************************
3547 Reads or writes a structure.
3548 ********************************************************************/
3550 BOOL srv_io_r_net_file_set_secdesc(const char *desc, SRV_R_NET_FILE_SET_SECDESC *r_n, prs_struct *ps, int depth)
3552 if (r_n == NULL)
3553 return False;
3555 prs_debug(ps, depth, desc, "srv_io_r_net_file_set_secdesc");
3556 depth++;
3558 if(!prs_align(ps))
3559 return False;
3561 if(!prs_werror("status", ps, depth, &r_n->status))
3562 return False;
3564 return True;
3567 /*******************************************************************
3568 Inits a structure
3569 ********************************************************************/
3571 void init_srv_q_net_remote_tod(SRV_Q_NET_REMOTE_TOD *q_u, const char *server)
3573 q_u->ptr_srv_name = 1;
3574 init_unistr2(&q_u->uni_srv_name, server, UNI_STR_TERMINATE);