merging for 2.2.6pre1
[Samba.git] / source / rpc_parse / parse_srv.c
blob3a1c13c7ea018a98e51b2fafda53ed6d24136d39
1 /*
2 * Unix SMB/Netbios implementation.
3 * Version 1.9.
4 * RPC Pipe client / server routines
5 * Copyright (C) Andrew Tridgell 1992-1997,
6 * Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
7 * Copyright (C) Paul Ashton 1997.
8 * Copyright (C) Jeremy Allison 1999.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #include "includes.h"
27 /*******************************************************************
28 Inits a SH_INFO_1_STR structure
29 ********************************************************************/
31 void init_srv_share_info1_str(SH_INFO_1_STR *sh1, char *net_name, char *remark)
33 DEBUG(5,("init_srv_share_info1_str\n"));
35 init_unistr2(&sh1->uni_netname, net_name, strlen(net_name)+1);
36 init_unistr2(&sh1->uni_remark, remark, strlen(remark)+1);
39 /*******************************************************************
40 Reads or writes a structure.
41 ********************************************************************/
43 static BOOL srv_io_share_info1_str(char *desc, SH_INFO_1_STR *sh1, prs_struct *ps, int depth)
45 if (sh1 == NULL)
46 return False;
48 prs_debug(ps, depth, desc, "srv_io_share_info1_str");
49 depth++;
51 if(!prs_align(ps))
52 return False;
53 if(!smb_io_unistr2("", &sh1->uni_netname, True, ps, depth))
54 return False;
56 if(!prs_align(ps))
57 return False;
58 if(!smb_io_unistr2("", &sh1->uni_remark, True, ps, depth))
59 return False;
61 return True;
64 /*******************************************************************
65 makes a SH_INFO_1 structure
66 ********************************************************************/
68 void init_srv_share_info1(SH_INFO_1 *sh1, char *net_name, uint32 type, char *remark)
70 DEBUG(5,("init_srv_share_info1: %s %8x %s\n", net_name, type, remark));
72 sh1->ptr_netname = (net_name != NULL) ? 1 : 0;
73 sh1->type = type;
74 sh1->ptr_remark = (remark != NULL) ? 1 : 0;
77 /*******************************************************************
78 Reads or writes a structure.
79 ********************************************************************/
81 static BOOL srv_io_share_info1(char *desc, SH_INFO_1 *sh1, prs_struct *ps, int depth)
83 if (sh1 == NULL)
84 return False;
86 prs_debug(ps, depth, desc, "srv_io_share_info1");
87 depth++;
89 if(!prs_align(ps))
90 return False;
92 if(!prs_uint32("ptr_netname", ps, depth, &sh1->ptr_netname))
93 return False;
94 if(!prs_uint32("type ", ps, depth, &sh1->type))
95 return False;
96 if(!prs_uint32("ptr_remark ", ps, depth, &sh1->ptr_remark))
97 return False;
99 return True;
102 /*******************************************************************
103 Inits a SH_INFO_2_STR structure
104 ********************************************************************/
106 void init_srv_share_info2_str(SH_INFO_2_STR *sh2,
107 char *net_name, char *remark,
108 char *path, char *passwd)
110 DEBUG(5,("init_srv_share_info2_str\n"));
112 init_unistr2(&sh2->uni_netname, net_name, strlen(net_name)+1);
113 init_unistr2(&sh2->uni_remark, remark, strlen(remark)+1);
114 init_unistr2(&sh2->uni_path, path, strlen(path)+1);
115 init_unistr2(&sh2->uni_passwd, passwd, strlen(passwd)+1);
118 /*******************************************************************
119 Reads or writes a structure.
120 ********************************************************************/
122 static BOOL srv_io_share_info2_str(char *desc, SH_INFO_2 *sh, SH_INFO_2_STR *sh2, prs_struct *ps, int depth)
124 if (sh2 == NULL)
125 return False;
127 if (UNMARSHALLING(ps))
128 ZERO_STRUCTP(sh2);
130 prs_debug(ps, depth, desc, "srv_io_share_info2_str");
131 depth++;
133 if(!prs_align(ps))
134 return False;
135 if (sh->ptr_netname)
136 if(!smb_io_unistr2("", &sh2->uni_netname, True, ps, depth))
137 return False;
139 if (sh->ptr_remark)
140 if(!smb_io_unistr2("", &sh2->uni_remark, True, ps, depth))
141 return False;
143 if (sh->ptr_netname)
144 if(!smb_io_unistr2("", &sh2->uni_path, True, ps, depth))
145 return False;
147 if (sh->ptr_passwd)
148 if(!smb_io_unistr2("", &sh2->uni_passwd, True, ps, depth))
149 return False;
151 return True;
154 /*******************************************************************
155 Inits a SH_INFO_2 structure
156 ********************************************************************/
158 void init_srv_share_info2(SH_INFO_2 *sh2,
159 char *net_name, uint32 type, char *remark,
160 uint32 perms, uint32 max_uses, uint32 num_uses,
161 char *path, char *passwd)
163 DEBUG(5,("init_srv_share_info2: %s %8x %s\n", net_name, type, remark));
165 sh2->ptr_netname = (net_name != NULL) ? 1 : 0;
166 sh2->type = type;
167 sh2->ptr_remark = (remark != NULL) ? 1 : 0;
168 sh2->perms = perms;
169 sh2->max_uses = max_uses;
170 sh2->num_uses = num_uses;
171 sh2->type = type;
172 sh2->ptr_path = (path != NULL) ? 1 : 0;
173 sh2->ptr_passwd = (passwd != NULL) ? 1 : 0;
176 /*******************************************************************
177 Reads or writes a structure.
178 ********************************************************************/
180 static BOOL srv_io_share_info2(char *desc, SH_INFO_2 *sh2, prs_struct *ps, int depth)
182 if (sh2 == NULL)
183 return False;
185 prs_debug(ps, depth, desc, "srv_io_share_info2");
186 depth++;
188 if(!prs_align(ps))
189 return False;
191 if(!prs_uint32("ptr_netname", ps, depth, &sh2->ptr_netname))
192 return False;
193 if(!prs_uint32("type ", ps, depth, &sh2->type))
194 return False;
195 if(!prs_uint32("ptr_remark ", ps, depth, &sh2->ptr_remark))
196 return False;
197 if(!prs_uint32("perms ", ps, depth, &sh2->perms))
198 return False;
199 if(!prs_uint32("max_uses ", ps, depth, &sh2->max_uses))
200 return False;
201 if(!prs_uint32("num_uses ", ps, depth, &sh2->num_uses))
202 return False;
203 if(!prs_uint32("ptr_path ", ps, depth, &sh2->ptr_path))
204 return False;
205 if(!prs_uint32("ptr_passwd ", ps, depth, &sh2->ptr_passwd))
206 return False;
208 return True;
211 /*******************************************************************
212 Inits a SH_INFO_2 structure
213 *******************************************************************/
215 void init_srv_share_info501(SH_INFO_501 *sh501, char *net_name, uint32 type, char *remark, uint32 csc_policy)
217 DEBUG(5,("init_srv_share_info501: %s %8x %s %08x\n", net_name, type,
218 remark, csc_policy));
220 ZERO_STRUCTP(sh501);
222 sh501->ptr_netname = (net_name != NULL) ? 1 : 0;
223 sh501->type = type;
224 sh501->ptr_remark = (remark != NULL) ? 1 : 0;
225 sh501->csc_policy = csc_policy;
228 /*******************************************************************
229 Reads of writes a structure.
230 *******************************************************************/
232 static BOOL srv_io_share_info501(char *desc, SH_INFO_501 *sh501, prs_struct *ps, int depth)
234 if (sh501 == NULL)
235 return False;
237 prs_debug(ps, depth, desc, "srv_io_share_info501");
238 depth++;
240 if (!prs_align(ps))
241 return False;
243 if (!prs_uint32("ptr_netname", ps, depth, &sh501->ptr_netname))
244 return False;
245 if (!prs_uint32("type ", ps, depth, &sh501->type))
246 return False;
247 if (!prs_uint32("ptr_remark ", ps, depth, &sh501->ptr_remark))
248 return False;
249 if (!prs_uint32("csc_policy ", ps, depth, &sh501->csc_policy))
250 return False;
252 return True;
255 /********************************************************************
256 Inits a SH_INFO_501_STR structure
257 ********************************************************************/
259 void init_srv_share_info501_str(SH_INFO_501_STR *sh501, char *net_name, char *remark)
261 DEBUG(5,("init_srv_share_info501_str\n"));
263 init_unistr2(&sh501->uni_netname, net_name, strlen(net_name)+1);
264 init_unistr2(&sh501->uni_remark, remark, strlen(remark)+1);
267 /*******************************************************************
268 Reads or writes a structure.
269 ********************************************************************/
271 static BOOL srv_io_share_info501_str(char *desc, SH_INFO_501_STR *sh501, prs_struct *ps, int depth)
273 if (sh501 == NULL)
274 return False;
276 prs_debug(ps, depth, desc, "srv_io_share_info501_str");
277 depth++;
279 if(!prs_align(ps))
280 return False;
281 if(!smb_io_unistr2("", &sh501->uni_netname, True, ps, depth))
282 return False;
284 if(!prs_align(ps))
285 return False;
286 if(!smb_io_unistr2("", &sh501->uni_remark, True, ps, depth))
287 return False;
289 return True;
292 /*******************************************************************
293 Inits a SH_INFO_502 structure
294 ********************************************************************/
296 void init_srv_share_info502(SH_INFO_502 *sh502,
297 char *net_name, uint32 type, char *remark,
298 uint32 perms, uint32 max_uses, uint32 num_uses,
299 char *path, char *passwd, SEC_DESC *psd, size_t sd_size)
301 DEBUG(5,("init_srv_share_info502: %s %8x %s\n", net_name, type, remark));
303 ZERO_STRUCTP(sh502);
305 sh502->ptr_netname = (net_name != NULL) ? 1 : 0;
306 sh502->type = type;
307 sh502->ptr_remark = (remark != NULL) ? 1 : 0;
308 sh502->perms = perms;
309 sh502->max_uses = max_uses;
310 sh502->num_uses = num_uses;
311 sh502->type = type;
312 sh502->ptr_path = (path != NULL) ? 1 : 0;
313 sh502->ptr_passwd = (passwd != NULL) ? 1 : 0;
314 sh502->sd_size = (uint32)sd_size;
315 sh502->ptr_sd = (psd != NULL) ? 1 : 0;
318 /*******************************************************************
319 Reads or writes a structure.
320 ********************************************************************/
322 static BOOL srv_io_share_info502(char *desc, SH_INFO_502 *sh502, prs_struct *ps, int depth)
324 if (sh502 == NULL)
325 return False;
327 prs_debug(ps, depth, desc, "srv_io_share_info502");
328 depth++;
330 if(!prs_align(ps))
331 return False;
333 if(!prs_uint32("ptr_netname", ps, depth, &sh502->ptr_netname))
334 return False;
335 if(!prs_uint32("type ", ps, depth, &sh502->type))
336 return False;
337 if(!prs_uint32("ptr_remark ", ps, depth, &sh502->ptr_remark))
338 return False;
339 if(!prs_uint32("perms ", ps, depth, &sh502->perms))
340 return False;
341 if(!prs_uint32("max_uses ", ps, depth, &sh502->max_uses))
342 return False;
343 if(!prs_uint32("num_uses ", ps, depth, &sh502->num_uses))
344 return False;
345 if(!prs_uint32("ptr_path ", ps, depth, &sh502->ptr_path))
346 return False;
347 if(!prs_uint32("ptr_passwd ", ps, depth, &sh502->ptr_passwd))
348 return False;
349 if(!prs_uint32("sd_size ", ps, depth, &sh502->sd_size))
350 return False;
351 if(!prs_uint32("ptr_sd ", ps, depth, &sh502->ptr_sd))
352 return False;
354 return True;
357 /*******************************************************************
358 Inits a SH_INFO_502_STR structure
359 ********************************************************************/
361 void init_srv_share_info502_str(SH_INFO_502_STR *sh502str,
362 SH_INFO_502 *ptrs,
363 char *net_name, char *remark,
364 char *path, char *passwd, SEC_DESC *psd, size_t sd_size)
366 DEBUG(5,("init_srv_share_info502_str\n"));
368 sh502str->ptrs = ptrs;
370 if(sh502str->ptrs->ptr_netname)
371 init_unistr2(&sh502str->uni_netname, net_name, strlen(net_name)+1);
372 if(sh502str->ptrs->ptr_remark)
373 init_unistr2(&sh502str->uni_remark, remark, strlen(remark)+1);
374 if(sh502str->ptrs->ptr_path)
375 init_unistr2(&sh502str->uni_path, path, strlen(path)+1);
376 if(sh502str->ptrs->ptr_passwd)
377 init_unistr2(&sh502str->uni_passwd, passwd, strlen(passwd)+1);
378 if(sh502str->ptrs->ptr_sd) {
379 sh502str->sd = psd;
380 sh502str->sd_size = sd_size;
384 /*******************************************************************
385 Reads or writes a structure.
386 ********************************************************************/
388 static BOOL srv_io_share_info502_str(char *desc, SH_INFO_502_STR *sh502, prs_struct *ps, int depth)
390 if (sh502 == NULL)
391 return False;
393 prs_debug(ps, depth, desc, "srv_io_share_info502_str");
394 depth++;
396 if(!prs_align(ps))
397 return False;
399 if(sh502->ptrs->ptr_netname) {
400 if(!smb_io_unistr2("", &sh502->uni_netname, True, ps, depth))
401 return False;
404 if(!prs_align(ps))
405 return False;
407 if(sh502->ptrs->ptr_remark) {
408 if(!smb_io_unistr2("", &sh502->uni_remark, True, ps, depth))
409 return False;
412 if(!prs_align(ps))
413 return False;
415 if(sh502->ptrs->ptr_path) {
416 if(!smb_io_unistr2("", &sh502->uni_path, True, ps, depth))
417 return False;
420 if(!prs_align(ps))
421 return False;
423 if(sh502->ptrs->ptr_passwd) {
424 if(!smb_io_unistr2("", &sh502->uni_passwd, True, ps, depth))
425 return False;
428 if(!prs_align(ps))
429 return False;
431 if(sh502->ptrs->ptr_sd) {
432 if(!prs_uint32("sd_size ", ps, depth, &sh502->sd_size))
433 return False;
434 if (!sec_io_desc(desc, &sh502->sd, ps, depth))
435 return False;
438 return True;
441 /*******************************************************************
442 Reads or writes a structure.
443 ********************************************************************/
445 static BOOL srv_io_share_info1005(char* desc, SRV_SHARE_INFO_1005* sh1005,
446 prs_struct* ps, int depth)
448 if(sh1005 == NULL)
449 return False;
451 prs_debug(ps, depth, desc, "srv_io_share_info1005");
452 depth++;
454 if(!prs_align(ps))
455 return False;
457 if(!prs_uint32("misc_flags", ps, depth, &sh1005->misc_flags))
458 return False;
460 return True;
463 /*******************************************************************
464 Reads or writes a structure.
465 ********************************************************************/
467 static BOOL srv_io_share_info1501(char* desc, SRV_SHARE_INFO_1501* sh1501,
468 prs_struct* ps, int depth)
470 if(sh1501 == NULL)
471 return False;
473 prs_debug(ps, depth, desc, "srv_io_share_info1501");
474 depth++;
476 if(!prs_align(ps))
477 return False;
479 if (!sec_io_desc_buf(desc, &sh1501->sdb, ps, depth))
480 return False;
482 return True;
485 /*******************************************************************
486 Reads or writes a structure.
487 ********************************************************************/
489 static BOOL srv_io_srv_share_ctr(char *desc, SRV_SHARE_INFO_CTR *ctr, prs_struct *ps, int depth)
491 if (ctr == NULL)
492 return False;
494 prs_debug(ps, depth, desc, "srv_io_srv_share_ctr");
495 depth++;
497 if (UNMARSHALLING(ps)) {
498 memset(ctr, '\0', sizeof(SRV_SHARE_INFO_CTR));
501 if(!prs_align(ps))
502 return False;
504 if(!prs_uint32("info_level", ps, depth, &ctr->info_level))
505 return False;
507 if (ctr->info_level == 0)
508 return True;
510 if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
511 return False;
512 if(!prs_uint32("ptr_share_info", ps, depth, &ctr->ptr_share_info))
513 return False;
515 if (ctr->ptr_share_info == 0)
516 return True;
518 if(!prs_uint32("num_entries", ps, depth, &ctr->num_entries))
519 return False;
520 if(!prs_uint32("ptr_entries", ps, depth, &ctr->ptr_entries))
521 return False;
523 if (ctr->ptr_entries == 0) {
524 if (ctr->num_entries == 0)
525 return True;
526 else
527 return False;
530 if(!prs_uint32("num_entries2", ps, depth, &ctr->num_entries2))
531 return False;
533 if (ctr->num_entries2 != ctr->num_entries)
534 return False;
536 switch (ctr->switch_value) {
537 case 1:
539 SRV_SHARE_INFO_1 *info1 = ctr->share.info1;
540 int num_entries = ctr->num_entries;
541 int i;
543 if (UNMARSHALLING(ps)) {
544 if (!(info1 = (SRV_SHARE_INFO_1 *)prs_alloc_mem(ps, num_entries * sizeof(SRV_SHARE_INFO_1))))
545 return False;
546 ctr->share.info1 = info1;
549 for (i = 0; i < num_entries; i++) {
550 if(!srv_io_share_info1("", &info1[i].info_1, ps, depth))
551 return False;
554 for (i = 0; i < num_entries; i++) {
555 if(!srv_io_share_info1_str("", &info1[i].info_1_str, ps, depth))
556 return False;
559 break;
562 case 2:
564 SRV_SHARE_INFO_2 *info2 = ctr->share.info2;
565 int num_entries = ctr->num_entries;
566 int i;
568 if (UNMARSHALLING(ps)) {
569 if (!(info2 = (SRV_SHARE_INFO_2 *)prs_alloc_mem(ps,num_entries * sizeof(SRV_SHARE_INFO_2))))
570 return False;
571 ctr->share.info2 = info2;
574 for (i = 0; i < num_entries; i++) {
575 if(!srv_io_share_info2("", &info2[i].info_2, ps, depth))
576 return False;
579 for (i = 0; i < num_entries; i++) {
580 if(!srv_io_share_info2_str("", &info2[i].info_2, &info2[i].info_2_str, ps, depth))
581 return False;
584 break;
587 case 501:
589 SRV_SHARE_INFO_501 *info501 = ctr->share.info501;
590 int num_entries = ctr->num_entries;
591 int i;
593 if (UNMARSHALLING(ps)) {
594 if (!(info501 = (SRV_SHARE_INFO_501 *) prs_alloc_mem(ps, num_entries *
595 sizeof (SRV_SHARE_INFO_501))))
596 return False;
597 ctr->share.info501 = info501;
600 for (i = 0; i < num_entries; i++) {
601 if (!srv_io_share_info501("", &info501[i].info_501, ps, depth))
602 return False;
605 for (i = 0; i < num_entries; i++) {
606 if (!srv_io_share_info501_str("", &info501[i].info_501_str, ps, depth))
607 return False;
610 break;
613 case 502:
615 SRV_SHARE_INFO_502 *info502 = ctr->share.info502;
616 int num_entries = ctr->num_entries;
617 int i;
619 if (UNMARSHALLING(ps)) {
620 if (!(info502 = (SRV_SHARE_INFO_502 *)prs_alloc_mem(ps,num_entries * sizeof(SRV_SHARE_INFO_502))))
621 return False;
622 ctr->share.info502 = info502;
625 for (i = 0; i < num_entries; i++) {
626 if(!srv_io_share_info502("", &info502[i].info_502, ps, depth))
627 return False;
630 for (i = 0; i < num_entries; i++) {
631 info502[i].info_502_str.ptrs = &info502[i].info_502;
632 if(!srv_io_share_info502_str("", &info502[i].info_502_str, ps, depth))
633 return False;
636 break;
639 default:
640 DEBUG(5,("%s no share info at switch_value %d\n",
641 tab_depth(depth), ctr->switch_value));
642 break;
645 return True;
648 /*******************************************************************
649 Inits a SRV_Q_NET_SHARE_ENUM structure.
650 ********************************************************************/
652 void init_srv_q_net_share_enum(SRV_Q_NET_SHARE_ENUM *q_n,
653 char *srv_name, uint32 info_level,
654 uint32 preferred_len, ENUM_HND *hnd)
657 DEBUG(5,("init_q_net_share_enum\n"));
659 init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
661 q_n->ctr.info_level = q_n->ctr.switch_value = info_level;
662 q_n->ctr.ptr_share_info = 0;
663 q_n->preferred_len = preferred_len;
665 memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
668 /*******************************************************************
669 Reads or writes a structure.
670 ********************************************************************/
672 BOOL srv_io_q_net_share_enum(char *desc, SRV_Q_NET_SHARE_ENUM *q_n, prs_struct *ps, int depth)
674 if (q_n == NULL)
675 return False;
677 prs_debug(ps, depth, desc, "srv_io_q_net_share_enum");
678 depth++;
680 if(!prs_align(ps))
681 return False;
683 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
684 return False;
685 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
686 return False;
688 if(!srv_io_srv_share_ctr("share_ctr", &q_n->ctr, ps, depth))
689 return False;
691 if(!prs_align(ps))
692 return False;
694 if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
695 return False;
697 if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
698 return False;
700 return True;
703 /*******************************************************************
704 Reads or writes a structure.
705 ********************************************************************/
707 BOOL srv_io_r_net_share_enum(char *desc, SRV_R_NET_SHARE_ENUM *r_n, prs_struct *ps, int depth)
709 if (r_n == NULL)
710 return False;
712 prs_debug(ps, depth, desc, "srv_io_r_net_share_enum");
713 depth++;
715 if(!srv_io_srv_share_ctr("share_ctr", &r_n->ctr, ps, depth))
716 return False;
718 if(!prs_align(ps))
719 return False;
721 if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
722 return False;
723 if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
724 return False;
725 if(!prs_werror("status ", ps, depth, &r_n->status))
726 return False;
728 return True;
731 /*******************************************************************
732 Reads or writes a structure.
733 ********************************************************************/
735 BOOL srv_io_q_net_share_get_info(char *desc, SRV_Q_NET_SHARE_GET_INFO *q_n, prs_struct *ps, int depth)
737 if (q_n == NULL)
738 return False;
740 prs_debug(ps, depth, desc, "srv_io_q_net_share_get_info");
741 depth++;
743 if(!prs_align(ps))
744 return False;
746 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
747 return False;
748 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
749 return False;
751 if(!smb_io_unistr2("", &q_n->uni_share_name, True, ps, depth))
752 return False;
754 if(!prs_align(ps))
755 return False;
757 if(!prs_uint32("info_level", ps, depth, &q_n->info_level))
758 return False;
760 return True;
763 /*******************************************************************
764 Reads or writes a structure.
765 ********************************************************************/
767 static BOOL srv_io_srv_share_info(char *desc, prs_struct *ps, int depth, SRV_SHARE_INFO *r_n)
769 if (r_n == NULL)
770 return False;
772 prs_debug(ps, depth, desc, "srv_io_srv_share_info");
773 depth++;
775 if(!prs_align(ps))
776 return False;
778 if(!prs_uint32("switch_value ", ps, depth, &r_n->switch_value ))
779 return False;
781 if(!prs_uint32("ptr_share_ctr", ps, depth, &r_n->ptr_share_ctr))
782 return False;
784 if (r_n->ptr_share_ctr != 0) {
785 switch (r_n->switch_value) {
786 case 1:
787 if(!srv_io_share_info1("", &r_n->share.info1.info_1, ps, depth))
788 return False;
790 if(!srv_io_share_info1_str("", &r_n->share.info1.info_1_str, ps, depth))
791 return False;
793 break;
794 case 2:
795 if(!srv_io_share_info2("", &r_n->share.info2.info_2, ps, depth))
796 return False;
798 if(!srv_io_share_info2_str("", &r_n->share.info2.info_2, &r_n->share.info2.info_2_str, ps, depth))
799 return False;
801 break;
802 case 501:
803 if (!srv_io_share_info501("", &r_n->share.info501.info_501, ps, depth))
804 return False;
805 if (!srv_io_share_info501_str("", &r_n->share.info501.info_501_str, ps, depth))
806 return False;
807 break;
809 case 502:
810 if(!srv_io_share_info502("", &r_n->share.info502.info_502, ps, depth))
811 return False;
813 /*allow access to pointers in the str part. */
814 r_n->share.info502.info_502_str.ptrs = &r_n->share.info502.info_502;
816 if(!srv_io_share_info502_str("", &r_n->share.info502.info_502_str, ps, depth))
817 return False;
818 break;
819 case 1005:
820 if(!srv_io_share_info1005("", &r_n->share.info1005, ps, depth))
821 return False;
822 break;
823 case 1501:
824 if (!srv_io_share_info1501("", &r_n->share.info1501, ps, depth))
825 return False;
826 default:
827 DEBUG(5,("%s no share info at switch_value %d\n",
828 tab_depth(depth), r_n->switch_value));
829 break;
833 return True;
836 /*******************************************************************
837 Reads or writes a structure.
838 ********************************************************************/
840 BOOL srv_io_r_net_share_get_info(char *desc, SRV_R_NET_SHARE_GET_INFO *r_n, prs_struct *ps, int depth)
842 if (r_n == NULL)
843 return False;
845 prs_debug(ps, depth, desc, "srv_io_r_net_share_get_info");
846 depth++;
848 if(!prs_align(ps))
849 return False;
851 if(!srv_io_srv_share_info("info ", ps, depth, &r_n->info))
852 return False;
854 if(!prs_align(ps))
855 return False;
857 if(!prs_werror("status", ps, depth, &r_n->status))
858 return False;
860 return True;
863 /*******************************************************************
864 Reads or writes a structure.
865 ********************************************************************/
867 BOOL srv_io_q_net_share_set_info(char *desc, SRV_Q_NET_SHARE_SET_INFO *q_n, prs_struct *ps, int depth)
869 if (q_n == NULL)
870 return False;
872 prs_debug(ps, depth, desc, "srv_io_q_net_share_set_info");
873 depth++;
875 if(!prs_align(ps))
876 return False;
878 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
879 return False;
880 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
881 return False;
883 if(!smb_io_unistr2("", &q_n->uni_share_name, True, ps, depth))
884 return False;
886 if(!prs_align(ps))
887 return False;
889 if(!prs_uint32("info_level", ps, depth, &q_n->info_level))
890 return False;
892 if(!prs_align(ps))
893 return False;
895 if(!srv_io_srv_share_info("info ", ps, depth, &q_n->info))
896 return False;
898 return True;
901 /*******************************************************************
902 Reads or writes a structure.
903 ********************************************************************/
905 BOOL srv_io_r_net_share_set_info(char *desc, SRV_R_NET_SHARE_SET_INFO *q_n, prs_struct *ps, int depth)
907 if (q_n == NULL)
908 return False;
910 prs_debug(ps, depth, desc, "srv_io_r_net_share_set_info");
911 depth++;
913 if(!prs_align(ps))
914 return False;
916 if(!prs_uint32("switch_value ", ps, depth, &q_n->switch_value))
917 return False;
918 if(!prs_werror("status ", ps, depth, &q_n->status))
919 return False;
921 return True;
924 /*******************************************************************
925 Reads or writes a structure.
926 ********************************************************************/
928 BOOL srv_io_q_net_share_add(char *desc, SRV_Q_NET_SHARE_ADD *q_n, prs_struct *ps, int depth)
930 if (q_n == NULL)
931 return False;
933 prs_debug(ps, depth, desc, "srv_io_q_net_share_add");
934 depth++;
936 if(!prs_align(ps))
937 return False;
939 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
940 return False;
941 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
942 return False;
944 if(!prs_align(ps))
945 return False;
947 if(!prs_uint32("info_level", ps, depth, &q_n->info_level))
948 return False;
950 if(!prs_align(ps))
951 return False;
953 if(!srv_io_srv_share_info("info ", ps, depth, &q_n->info))
954 return False;
956 return True;
959 /*******************************************************************
960 Reads or writes a structure.
961 ********************************************************************/
963 BOOL srv_io_r_net_share_add(char *desc, SRV_R_NET_SHARE_ADD *q_n, prs_struct *ps, int depth)
965 if (q_n == NULL)
966 return False;
968 prs_debug(ps, depth, desc, "srv_io_r_net_share_add");
969 depth++;
971 if(!prs_align(ps))
972 return False;
974 if(!prs_uint32("switch_value ", ps, depth, &q_n->switch_value))
975 return False;
976 if(!prs_werror("status ", ps, depth, &q_n->status))
977 return False;
979 return True;
982 /*******************************************************************
983 Reads or writes a structure.
984 ********************************************************************/
986 BOOL srv_io_q_net_share_del(char *desc, SRV_Q_NET_SHARE_DEL *q_n, prs_struct *ps, int depth)
988 if (q_n == NULL)
989 return False;
991 prs_debug(ps, depth, desc, "srv_io_q_net_share_del");
992 depth++;
994 if(!prs_align(ps))
995 return False;
997 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
998 return False;
999 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1000 return False;
1002 if(!smb_io_unistr2("", &q_n->uni_share_name, True, ps, depth))
1003 return False;
1005 return True;
1008 /*******************************************************************
1009 Reads or writes a structure.
1010 ********************************************************************/
1012 BOOL srv_io_r_net_share_del(char *desc, SRV_R_NET_SHARE_DEL *q_n, prs_struct *ps, int depth)
1014 if (q_n == NULL)
1015 return False;
1017 prs_debug(ps, depth, desc, "srv_io_r_net_share_del");
1018 depth++;
1020 if(!prs_align(ps))
1021 return False;
1023 if(!prs_werror("status ", ps, depth, &q_n->status))
1024 return False;
1026 return True;
1029 /*******************************************************************
1030 Inits a SESS_INFO_0_STR structure
1031 ********************************************************************/
1033 void init_srv_sess_info0_str(SESS_INFO_0_STR *ss0, char *name)
1035 DEBUG(5,("init_srv_sess_info0_str\n"));
1037 init_unistr2(&ss0->uni_name, name, strlen(name)+1);
1040 /*******************************************************************
1041 Reads or writes a structure.
1042 ********************************************************************/
1044 static BOOL srv_io_sess_info0_str(char *desc, SESS_INFO_0_STR *ss0, prs_struct *ps, int depth)
1046 if (ss0 == NULL)
1047 return False;
1049 prs_debug(ps, depth, desc, "srv_io_sess_info0_str");
1050 depth++;
1052 if(!prs_align(ps))
1053 return False;
1055 if(!smb_io_unistr2("", &ss0->uni_name, True, ps, depth))
1056 return False;
1058 return True;
1061 /*******************************************************************
1062 Inits a SESS_INFO_0 structure
1063 ********************************************************************/
1065 void init_srv_sess_info0(SESS_INFO_0 *ss0, char *name)
1067 DEBUG(5,("init_srv_sess_info0: %s\n", name));
1069 ss0->ptr_name = (name != NULL) ? 1 : 0;
1072 /*******************************************************************
1073 Reads or writes a structure.
1074 ********************************************************************/
1076 static BOOL srv_io_sess_info0(char *desc, SESS_INFO_0 *ss0, prs_struct *ps, int depth)
1078 if (ss0 == NULL)
1079 return False;
1081 prs_debug(ps, depth, desc, "srv_io_sess_info0");
1082 depth++;
1084 if(!prs_align(ps))
1085 return False;
1087 if(!prs_uint32("ptr_name", ps, depth, &ss0->ptr_name))
1088 return False;
1090 return True;
1093 /*******************************************************************
1094 Reads or writes a structure.
1095 ********************************************************************/
1097 static BOOL srv_io_srv_sess_info_0(char *desc, SRV_SESS_INFO_0 *ss0, prs_struct *ps, int depth)
1099 if (ss0 == NULL)
1100 return False;
1102 prs_debug(ps, depth, desc, "srv_io_srv_sess_info_0");
1103 depth++;
1105 if(!prs_align(ps))
1106 return False;
1108 if(!prs_uint32("num_entries_read", ps, depth, &ss0->num_entries_read))
1109 return False;
1110 if(!prs_uint32("ptr_sess_info", ps, depth, &ss0->ptr_sess_info))
1111 return False;
1113 if (ss0->ptr_sess_info != 0) {
1114 int i;
1115 int num_entries = ss0->num_entries_read;
1117 if (num_entries > MAX_SESS_ENTRIES) {
1118 num_entries = MAX_SESS_ENTRIES; /* report this! */
1121 if(!prs_uint32("num_entries_read2", ps, depth, &ss0->num_entries_read2))
1122 return False;
1124 SMB_ASSERT_ARRAY(ss0->info_0, num_entries);
1126 for (i = 0; i < num_entries; i++) {
1127 if(!srv_io_sess_info0("", &ss0->info_0[i], ps, depth))
1128 return False;
1131 for (i = 0; i < num_entries; i++) {
1132 if(!srv_io_sess_info0_str("", &ss0->info_0_str[i], ps, depth))
1133 return False;
1136 if(!prs_align(ps))
1137 return False;
1140 return True;
1143 /*******************************************************************
1144 Inits a SESS_INFO_1_STR structure
1145 ********************************************************************/
1147 void init_srv_sess_info1_str(SESS_INFO_1_STR *ss1, char *name, char *user)
1149 DEBUG(5,("init_srv_sess_info1_str\n"));
1151 init_unistr2(&ss1->uni_name, name, strlen(name)+1);
1152 init_unistr2(&ss1->uni_user, name, strlen(user)+1);
1155 /*******************************************************************
1156 Reads or writes a structure.
1157 ********************************************************************/
1159 static BOOL srv_io_sess_info1_str(char *desc, SESS_INFO_1_STR *ss1, prs_struct *ps, int depth)
1161 if (ss1 == NULL)
1162 return False;
1164 prs_debug(ps, depth, desc, "srv_io_sess_info1_str");
1165 depth++;
1167 if(!prs_align(ps))
1168 return False;
1170 if(!smb_io_unistr2("", &ss1->uni_name, True, ps, depth))
1171 return False;
1172 if(!smb_io_unistr2("", &(ss1->uni_user), True, ps, depth))
1173 return False;
1175 return True;
1178 /*******************************************************************
1179 Inits a SESS_INFO_1 structure
1180 ********************************************************************/
1182 void init_srv_sess_info1(SESS_INFO_1 *ss1,
1183 char *name, char *user,
1184 uint32 num_opens, uint32 open_time, uint32 idle_time,
1185 uint32 user_flags)
1187 DEBUG(5,("init_srv_sess_info1: %s\n", name));
1189 ss1->ptr_name = (name != NULL) ? 1 : 0;
1190 ss1->ptr_user = (user != NULL) ? 1 : 0;
1192 ss1->num_opens = num_opens;
1193 ss1->open_time = open_time;
1194 ss1->idle_time = idle_time;
1195 ss1->user_flags = user_flags;
1198 /*******************************************************************
1199 reads or writes a structure.
1200 ********************************************************************/
1202 static BOOL srv_io_sess_info1(char *desc, SESS_INFO_1 *ss1, prs_struct *ps, int depth)
1204 if (ss1 == NULL)
1205 return False;
1207 prs_debug(ps, depth, desc, "srv_io_sess_info1");
1208 depth++;
1210 if(!prs_align(ps))
1211 return False;
1213 if(!prs_uint32("ptr_name ", ps, depth, &ss1->ptr_name))
1214 return False;
1215 if(!prs_uint32("ptr_user ", ps, depth, &ss1->ptr_user))
1216 return False;
1218 if(!prs_uint32("num_opens ", ps, depth, &ss1->num_opens))
1219 return False;
1220 if(!prs_uint32("open_time ", ps, depth, &ss1->open_time))
1221 return False;
1222 if(!prs_uint32("idle_time ", ps, depth, &ss1->idle_time))
1223 return False;
1224 if(!prs_uint32("user_flags", ps, depth, &ss1->user_flags))
1225 return False;
1227 return True;
1230 /*******************************************************************
1231 Reads or writes a structure.
1232 ********************************************************************/
1234 static BOOL srv_io_srv_sess_info_1(char *desc, SRV_SESS_INFO_1 *ss1, prs_struct *ps, int depth)
1236 if (ss1 == NULL)
1237 return False;
1239 prs_debug(ps, depth, desc, "srv_io_srv_sess_info_1");
1240 depth++;
1242 if(!prs_align(ps))
1243 return False;
1245 if(!prs_uint32("num_entries_read", ps, depth, &ss1->num_entries_read))
1246 return False;
1247 if(!prs_uint32("ptr_sess_info", ps, depth, &ss1->ptr_sess_info))
1248 return False;
1250 if (ss1->ptr_sess_info != 0) {
1251 int i;
1252 int num_entries = ss1->num_entries_read;
1254 if (num_entries > MAX_SESS_ENTRIES) {
1255 num_entries = MAX_SESS_ENTRIES; /* report this! */
1258 if(!prs_uint32("num_entries_read2", ps, depth, &ss1->num_entries_read2))
1259 return False;
1261 SMB_ASSERT_ARRAY(ss1->info_1, num_entries);
1263 for (i = 0; i < num_entries; i++) {
1264 if(!srv_io_sess_info1("", &ss1->info_1[i], ps, depth))
1265 return False;
1268 for (i = 0; i < num_entries; i++) {
1269 if(!srv_io_sess_info1_str("", &ss1->info_1_str[i], ps, depth))
1270 return False;
1273 if(!prs_align(ps))
1274 return False;
1277 return True;
1280 /*******************************************************************
1281 Reads or writes a structure.
1282 ********************************************************************/
1284 static BOOL srv_io_srv_sess_ctr(char *desc, SRV_SESS_INFO_CTR **pp_ctr, prs_struct *ps, int depth)
1286 SRV_SESS_INFO_CTR *ctr = *pp_ctr;
1288 prs_debug(ps, depth, desc, "srv_io_srv_sess_ctr");
1289 depth++;
1291 if(UNMARSHALLING(ps)) {
1292 ctr = *pp_ctr = (SRV_SESS_INFO_CTR *)prs_alloc_mem(ps, sizeof(SRV_SESS_INFO_CTR));
1293 if (ctr == NULL)
1294 return False;
1297 if (ctr == NULL)
1298 return False;
1300 if(!prs_align(ps))
1301 return False;
1303 if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
1304 return False;
1305 if(!prs_uint32("ptr_sess_ctr", ps, depth, &ctr->ptr_sess_ctr))
1306 return False;
1308 if (ctr->ptr_sess_ctr != 0) {
1309 switch (ctr->switch_value) {
1310 case 0:
1311 if(!srv_io_srv_sess_info_0("", &ctr->sess.info0, ps, depth))
1312 return False;
1313 break;
1314 case 1:
1315 if(!srv_io_srv_sess_info_1("", &ctr->sess.info1, ps, depth))
1316 return False;
1317 break;
1318 default:
1319 DEBUG(5,("%s no session info at switch_value %d\n",
1320 tab_depth(depth), ctr->switch_value));
1321 break;
1325 return True;
1328 /*******************************************************************
1329 Inits a SRV_Q_NET_SESS_ENUM structure.
1330 ********************************************************************/
1332 void init_srv_q_net_sess_enum(SRV_Q_NET_SESS_ENUM *q_n,
1333 char *srv_name, char *qual_name,
1334 uint32 sess_level, SRV_SESS_INFO_CTR *ctr,
1335 uint32 preferred_len,
1336 ENUM_HND *hnd)
1338 q_n->ctr = ctr;
1340 DEBUG(5,("init_q_net_sess_enum\n"));
1342 init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
1343 init_buf_unistr2(&q_n->uni_qual_name, &q_n->ptr_qual_name, qual_name);
1345 q_n->sess_level = sess_level;
1346 q_n->preferred_len = preferred_len;
1348 memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
1351 /*******************************************************************
1352 Reads or writes a structure.
1353 ********************************************************************/
1355 BOOL srv_io_q_net_sess_enum(char *desc, SRV_Q_NET_SESS_ENUM *q_n, prs_struct *ps, int depth)
1357 if (q_n == NULL)
1358 return False;
1360 prs_debug(ps, depth, desc, "srv_io_q_net_sess_enum");
1361 depth++;
1363 if(!prs_align(ps))
1364 return False;
1366 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
1367 return False;
1368 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1369 return False;
1371 if(!prs_align(ps))
1372 return False;
1374 if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
1375 return False;
1376 if(!smb_io_unistr2("", &q_n->uni_qual_name, q_n->ptr_qual_name, ps, depth))
1377 return False;
1379 if(!prs_align(ps))
1380 return False;
1382 if(!prs_uint32("sess_level", ps, depth, &q_n->sess_level))
1383 return False;
1385 if (q_n->sess_level != -1) {
1386 if(!srv_io_srv_sess_ctr("sess_ctr", &q_n->ctr, ps, depth))
1387 return False;
1390 if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
1391 return False;
1393 if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
1394 return False;
1396 return True;
1399 /*******************************************************************
1400 Reads or writes a structure.
1401 ********************************************************************/
1403 BOOL srv_io_r_net_sess_enum(char *desc, SRV_R_NET_SESS_ENUM *r_n, prs_struct *ps, int depth)
1405 if (r_n == NULL)
1406 return False;
1408 prs_debug(ps, depth, desc, "srv_io_r_net_sess_enum");
1409 depth++;
1411 if(!prs_align(ps))
1412 return False;
1414 if(!prs_uint32("sess_level", ps, depth, &r_n->sess_level))
1415 return False;
1417 if (r_n->sess_level != -1) {
1418 if(!srv_io_srv_sess_ctr("sess_ctr", &r_n->ctr, ps, depth))
1419 return False;
1422 if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
1423 return False;
1424 if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
1425 return False;
1426 if(!prs_werror("status ", ps, depth, &r_n->status))
1427 return False;
1429 return True;
1432 /*******************************************************************
1433 Inits a CONN_INFO_0 structure
1434 ********************************************************************/
1436 void init_srv_conn_info0(CONN_INFO_0 *ss0, uint32 id)
1438 DEBUG(5,("init_srv_conn_info0\n"));
1440 ss0->id = id;
1443 /*******************************************************************
1444 Reads or writes a structure.
1445 ********************************************************************/
1447 static BOOL srv_io_conn_info0(char *desc, CONN_INFO_0 *ss0, prs_struct *ps, int depth)
1449 if (ss0 == NULL)
1450 return False;
1452 prs_debug(ps, depth, desc, "srv_io_conn_info0");
1453 depth++;
1455 if(!prs_align(ps))
1456 return False;
1458 if(!prs_uint32("id", ps, depth, &ss0->id))
1459 return False;
1461 return True;
1464 /*******************************************************************
1465 Reads or writes a structure.
1466 ********************************************************************/
1468 static BOOL srv_io_srv_conn_info_0(char *desc, SRV_CONN_INFO_0 *ss0, prs_struct *ps, int depth)
1470 if (ss0 == NULL)
1471 return False;
1473 prs_debug(ps, depth, desc, "srv_io_srv_conn_info_0");
1474 depth++;
1476 if(!prs_align(ps))
1477 return False;
1479 if(!prs_uint32("num_entries_read", ps, depth, &ss0->num_entries_read))
1480 return False;
1481 if(!prs_uint32("ptr_conn_info", ps, depth, &ss0->ptr_conn_info))
1482 return False;
1484 if (ss0->ptr_conn_info != 0) {
1485 int i;
1486 int num_entries = ss0->num_entries_read;
1488 if (num_entries > MAX_CONN_ENTRIES) {
1489 num_entries = MAX_CONN_ENTRIES; /* report this! */
1492 if(!prs_uint32("num_entries_read2", ps, depth, &ss0->num_entries_read2))
1493 return False;
1495 for (i = 0; i < num_entries; i++) {
1496 if(!srv_io_conn_info0("", &ss0->info_0[i], ps, depth))
1497 return False;
1500 if(!prs_align(ps))
1501 return False;
1504 return True;
1507 /*******************************************************************
1508 Inits a CONN_INFO_1_STR structure
1509 ********************************************************************/
1511 void init_srv_conn_info1_str(CONN_INFO_1_STR *ss1, char *usr_name, char *net_name)
1513 DEBUG(5,("init_srv_conn_info1_str\n"));
1515 init_unistr2(&ss1->uni_usr_name, usr_name, strlen(usr_name)+1);
1516 init_unistr2(&ss1->uni_net_name, net_name, strlen(net_name)+1);
1519 /*******************************************************************
1520 Reads or writes a structure.
1521 ********************************************************************/
1523 static BOOL srv_io_conn_info1_str(char *desc, CONN_INFO_1_STR *ss1, prs_struct *ps, int depth)
1525 if (ss1 == NULL)
1526 return False;
1528 prs_debug(ps, depth, desc, "srv_io_conn_info1_str");
1529 depth++;
1531 if(!prs_align(ps))
1532 return False;
1534 if(!smb_io_unistr2("", &ss1->uni_usr_name, True, ps, depth))
1535 return False;
1536 if(!smb_io_unistr2("", &ss1->uni_net_name, True, ps, depth))
1537 return False;
1539 return True;
1542 /*******************************************************************
1543 Inits a CONN_INFO_1 structure
1544 ********************************************************************/
1546 void init_srv_conn_info1(CONN_INFO_1 *ss1,
1547 uint32 id, uint32 type,
1548 uint32 num_opens, uint32 num_users, uint32 open_time,
1549 char *usr_name, char *net_name)
1551 DEBUG(5,("init_srv_conn_info1: %s %s\n", usr_name, net_name));
1553 ss1->id = id ;
1554 ss1->type = type ;
1555 ss1->num_opens = num_opens ;
1556 ss1->num_users = num_users;
1557 ss1->open_time = open_time;
1559 ss1->ptr_usr_name = (usr_name != NULL) ? 1 : 0;
1560 ss1->ptr_net_name = (net_name != NULL) ? 1 : 0;
1563 /*******************************************************************
1564 Reads or writes a structure.
1565 ********************************************************************/
1567 static BOOL srv_io_conn_info1(char *desc, CONN_INFO_1 *ss1, prs_struct *ps, int depth)
1569 if (ss1 == NULL)
1570 return False;
1572 prs_debug(ps, depth, desc, "srv_io_conn_info1");
1573 depth++;
1575 if(!prs_align(ps))
1576 return False;
1578 if(!prs_uint32("id ", ps, depth, &ss1->id))
1579 return False;
1580 if(!prs_uint32("type ", ps, depth, &ss1->type))
1581 return False;
1582 if(!prs_uint32("num_opens ", ps, depth, &ss1->num_opens))
1583 return False;
1584 if(!prs_uint32("num_users ", ps, depth, &ss1->num_users))
1585 return False;
1586 if(!prs_uint32("open_time ", ps, depth, &ss1->open_time))
1587 return False;
1589 if(!prs_uint32("ptr_usr_name", ps, depth, &ss1->ptr_usr_name))
1590 return False;
1591 if(!prs_uint32("ptr_net_name", ps, depth, &ss1->ptr_net_name))
1592 return False;
1594 return True;
1597 /*******************************************************************
1598 Reads or writes a structure.
1599 ********************************************************************/
1601 static BOOL srv_io_srv_conn_info_1(char *desc, SRV_CONN_INFO_1 *ss1, prs_struct *ps, int depth)
1603 if (ss1 == NULL)
1604 return False;
1606 prs_debug(ps, depth, desc, "srv_io_srv_conn_info_1");
1607 depth++;
1609 if(!prs_align(ps))
1610 return False;
1612 if(!prs_uint32("num_entries_read", ps, depth, &ss1->num_entries_read))
1613 return False;
1614 if(!prs_uint32("ptr_conn_info", ps, depth, &ss1->ptr_conn_info))
1615 return False;
1617 if (ss1->ptr_conn_info != 0) {
1618 int i;
1619 int num_entries = ss1->num_entries_read;
1621 if (num_entries > MAX_CONN_ENTRIES) {
1622 num_entries = MAX_CONN_ENTRIES; /* report this! */
1625 if(!prs_uint32("num_entries_read2", ps, depth, &ss1->num_entries_read2))
1626 return False;
1628 for (i = 0; i < num_entries; i++) {
1629 if(!srv_io_conn_info1("", &ss1->info_1[i], ps, depth))
1630 return False;
1633 for (i = 0; i < num_entries; i++) {
1634 if(!srv_io_conn_info1_str("", &ss1->info_1_str[i], ps, depth))
1635 return False;
1638 if(!prs_align(ps))
1639 return False;
1642 return True;
1645 /*******************************************************************
1646 Reads or writes a structure.
1647 ********************************************************************/
1649 static BOOL srv_io_srv_conn_ctr(char *desc, SRV_CONN_INFO_CTR **pp_ctr, prs_struct *ps, int depth)
1651 SRV_CONN_INFO_CTR *ctr = *pp_ctr;
1653 prs_debug(ps, depth, desc, "srv_io_srv_conn_ctr");
1654 depth++;
1656 if (UNMARSHALLING(ps)) {
1657 ctr = *pp_ctr = (SRV_CONN_INFO_CTR *)prs_alloc_mem(ps, sizeof(SRV_CONN_INFO_CTR));
1658 if (ctr == NULL)
1659 return False;
1662 if (ctr == NULL)
1663 return False;
1665 if(!prs_align(ps))
1666 return False;
1668 if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
1669 return False;
1670 if(!prs_uint32("ptr_conn_ctr", ps, depth, &ctr->ptr_conn_ctr))
1671 return False;
1673 if (ctr->ptr_conn_ctr != 0) {
1674 switch (ctr->switch_value) {
1675 case 0:
1676 if(!srv_io_srv_conn_info_0("", &ctr->conn.info0, ps, depth))
1677 return False;
1678 break;
1679 case 1:
1680 if(!srv_io_srv_conn_info_1("", &ctr->conn.info1, ps, depth))
1681 return False;
1682 break;
1683 default:
1684 DEBUG(5,("%s no connection info at switch_value %d\n",
1685 tab_depth(depth), ctr->switch_value));
1686 break;
1690 return True;
1693 /*******************************************************************
1694 Reads or writes a structure.
1695 ********************************************************************/
1697 void init_srv_q_net_conn_enum(SRV_Q_NET_CONN_ENUM *q_n,
1698 char *srv_name, char *qual_name,
1699 uint32 conn_level, SRV_CONN_INFO_CTR *ctr,
1700 uint32 preferred_len,
1701 ENUM_HND *hnd)
1703 DEBUG(5,("init_q_net_conn_enum\n"));
1705 q_n->ctr = ctr;
1707 init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name );
1708 init_buf_unistr2(&q_n->uni_qual_name, &q_n->ptr_qual_name, qual_name);
1710 q_n->conn_level = conn_level;
1711 q_n->preferred_len = preferred_len;
1713 memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
1716 /*******************************************************************
1717 Reads or writes a structure.
1718 ********************************************************************/
1720 BOOL srv_io_q_net_conn_enum(char *desc, SRV_Q_NET_CONN_ENUM *q_n, prs_struct *ps, int depth)
1722 if (q_n == NULL)
1723 return False;
1725 prs_debug(ps, depth, desc, "srv_io_q_net_conn_enum");
1726 depth++;
1728 if(!prs_align(ps))
1729 return False;
1731 if(!prs_uint32("ptr_srv_name ", ps, depth, &q_n->ptr_srv_name))
1732 return False;
1733 if(!smb_io_unistr2("", &q_n->uni_srv_name, q_n->ptr_srv_name, ps, depth))
1734 return False;
1736 if(!prs_align(ps))
1737 return False;
1739 if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
1740 return False;
1741 if(!smb_io_unistr2("", &q_n->uni_qual_name, q_n->ptr_qual_name, ps, depth))
1742 return False;
1744 if(!prs_align(ps))
1745 return False;
1747 if(!prs_uint32("conn_level", ps, depth, &q_n->conn_level))
1748 return False;
1750 if (q_n->conn_level != -1) {
1751 if(!srv_io_srv_conn_ctr("conn_ctr", &q_n->ctr, ps, depth))
1752 return False;
1755 if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
1756 return False;
1758 if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
1759 return False;
1761 return True;
1764 /*******************************************************************
1765 Reads or writes a structure.
1766 ********************************************************************/
1768 BOOL srv_io_r_net_conn_enum(char *desc, SRV_R_NET_CONN_ENUM *r_n, prs_struct *ps, int depth)
1770 if (r_n == NULL)
1771 return False;
1773 prs_debug(ps, depth, desc, "srv_io_r_net_conn_enum");
1774 depth++;
1776 if(!prs_align(ps))
1777 return False;
1779 if(!prs_uint32("conn_level", ps, depth, &r_n->conn_level))
1780 return False;
1782 if (r_n->conn_level != -1) {
1783 if(!srv_io_srv_conn_ctr("conn_ctr", &r_n->ctr, ps, depth))
1784 return False;
1787 if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
1788 return False;
1789 if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
1790 return False;
1791 if(!prs_werror("status ", ps, depth, &r_n->status))
1792 return False;
1794 return True;
1797 /*******************************************************************
1798 Inits a FILE_INFO_3_STR structure
1799 ********************************************************************/
1801 void init_srv_file_info3_str(FILE_INFO_3_STR *fi3, char *user_name, char *path_name)
1803 DEBUG(5,("init_srv_file_info3_str\n"));
1805 init_unistr2(&fi3->uni_path_name, path_name, strlen(path_name)+1);
1806 init_unistr2(&fi3->uni_user_name, user_name, strlen(user_name)+1);
1809 /*******************************************************************
1810 Reads or writes a structure.
1811 ********************************************************************/
1813 static BOOL srv_io_file_info3_str(char *desc, FILE_INFO_3_STR *sh1, prs_struct *ps, int depth)
1815 if (sh1 == NULL)
1816 return False;
1818 prs_debug(ps, depth, desc, "srv_io_file_info3_str");
1819 depth++;
1821 if(!prs_align(ps))
1822 return False;
1824 if(!smb_io_unistr2("", &sh1->uni_path_name, True, ps, depth))
1825 return False;
1826 if(!smb_io_unistr2("", &sh1->uni_user_name, True, ps, depth))
1827 return False;
1829 return True;
1832 /*******************************************************************
1833 Inits a FILE_INFO_3 structure
1834 ********************************************************************/
1836 void init_srv_file_info3(FILE_INFO_3 *fl3,
1837 uint32 id, uint32 perms, uint32 num_locks,
1838 char *path_name, char *user_name)
1840 DEBUG(5,("init_srv_file_info3: %s %s\n", path_name, user_name));
1842 fl3->id = id;
1843 fl3->perms = perms;
1844 fl3->num_locks = num_locks;
1846 fl3->ptr_path_name = (path_name != NULL) ? 1 : 0;
1847 fl3->ptr_user_name = (user_name != NULL) ? 1 : 0;
1850 /*******************************************************************
1851 Reads or writes a structure.
1852 ********************************************************************/
1854 static BOOL srv_io_file_info3(char *desc, FILE_INFO_3 *fl3, prs_struct *ps, int depth)
1856 if (fl3 == NULL)
1857 return False;
1859 prs_debug(ps, depth, desc, "srv_io_file_info3");
1860 depth++;
1862 if(!prs_align(ps))
1863 return False;
1865 if(!prs_uint32("id ", ps, depth, &fl3->id))
1866 return False;
1867 if(!prs_uint32("perms ", ps, depth, &fl3->perms))
1868 return False;
1869 if(!prs_uint32("num_locks ", ps, depth, &fl3->num_locks))
1870 return False;
1871 if(!prs_uint32("ptr_path_name", ps, depth, &fl3->ptr_path_name))
1872 return False;
1873 if(!prs_uint32("ptr_user_name", ps, depth, &fl3->ptr_user_name))
1874 return False;
1876 return True;
1879 /*******************************************************************
1880 Reads or writes a structure.
1881 ********************************************************************/
1883 static BOOL srv_io_srv_file_info_3(char *desc, SRV_FILE_INFO_3 *fl3, prs_struct *ps, int depth)
1885 if (fl3 == NULL)
1886 return False;
1888 prs_debug(ps, depth, desc, "srv_io_file_3_fl3");
1889 depth++;
1891 if(!prs_align(ps))
1892 return False;
1894 if(!prs_uint32("num_entries_read", ps, depth, &fl3->num_entries_read))
1895 return False;
1896 if(!prs_uint32("ptr_file_fl3", ps, depth, &fl3->ptr_file_info))
1897 return False;
1899 if (fl3->ptr_file_info != 0) {
1900 int i;
1901 int num_entries = fl3->num_entries_read;
1903 if (num_entries > MAX_FILE_ENTRIES) {
1904 num_entries = MAX_FILE_ENTRIES; /* report this! */
1907 if(!prs_uint32("num_entries_read2", ps, depth, &fl3->num_entries_read2))
1908 return False;
1910 for (i = 0; i < num_entries; i++) {
1911 if(!srv_io_file_info3("", &fl3->info_3[i], ps, depth))
1912 return False;
1915 for (i = 0; i < num_entries; i++) {
1916 if(!srv_io_file_info3_str("", &fl3->info_3_str[i], ps, depth))
1917 return False;
1920 if(!prs_align(ps))
1921 return False;
1924 return True;
1927 /*******************************************************************
1928 Reads or writes a structure.
1929 ********************************************************************/
1931 static BOOL srv_io_srv_file_ctr(char *desc, SRV_FILE_INFO_CTR **pp_ctr, prs_struct *ps, int depth)
1933 SRV_FILE_INFO_CTR *ctr = *pp_ctr;
1935 if (UNMARSHALLING(ps)) {
1936 ctr = *pp_ctr = (SRV_FILE_INFO_CTR *)prs_alloc_mem(ps, sizeof(SRV_FILE_INFO_CTR));
1937 if (ctr == NULL)
1938 return False;
1941 if (ctr == NULL)
1942 return False;
1944 prs_debug(ps, depth, desc, "srv_io_srv_file_ctr");
1945 depth++;
1947 if(!prs_align(ps))
1948 return False;
1950 if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
1951 return False;
1952 if(!prs_uint32("ptr_file_ctr", ps, depth, &ctr->ptr_file_ctr))
1953 return False;
1955 if (ctr->ptr_file_ctr != 0) {
1956 switch (ctr->switch_value) {
1957 case 3:
1958 if(!srv_io_srv_file_info_3("", &ctr->file.info3, ps, depth))
1959 return False;
1960 break;
1961 default:
1962 DEBUG(5,("%s no file info at switch_value %d\n",
1963 tab_depth(depth), ctr->switch_value));
1964 break;
1968 return True;
1971 /*******************************************************************
1972 Inits a SRV_Q_NET_FILE_ENUM structure.
1973 ********************************************************************/
1975 void init_srv_q_net_file_enum(SRV_Q_NET_FILE_ENUM *q_n,
1976 char *srv_name, char *qual_name,
1977 uint32 file_level, SRV_FILE_INFO_CTR *ctr,
1978 uint32 preferred_len,
1979 ENUM_HND *hnd)
1981 DEBUG(5,("init_q_net_file_enum\n"));
1983 q_n->ctr = ctr;
1985 init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
1986 init_buf_unistr2(&q_n->uni_qual_name, &q_n->ptr_qual_name, qual_name);
1988 q_n->file_level = file_level;
1989 q_n->preferred_len = preferred_len;
1991 memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
1994 /*******************************************************************
1995 Reads or writes a structure.
1996 ********************************************************************/
1998 BOOL srv_io_q_net_file_enum(char *desc, SRV_Q_NET_FILE_ENUM *q_n, prs_struct *ps, int depth)
2000 if (q_n == NULL)
2001 return False;
2003 prs_debug(ps, depth, desc, "srv_io_q_net_file_enum");
2004 depth++;
2006 if(!prs_align(ps))
2007 return False;
2009 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
2010 return False;
2011 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
2012 return False;
2014 if(!prs_align(ps))
2015 return False;
2017 if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
2018 return False;
2019 if(!smb_io_unistr2("", &q_n->uni_qual_name, q_n->ptr_qual_name, ps, depth))
2020 return False;
2022 if(!prs_align(ps))
2023 return False;
2025 if(!prs_uint32("file_level", ps, depth, &q_n->file_level))
2026 return False;
2028 if (q_n->file_level != -1) {
2029 if(!srv_io_srv_file_ctr("file_ctr", &q_n->ctr, ps, depth))
2030 return False;
2033 if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
2034 return False;
2036 if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
2037 return False;
2039 return True;
2042 /*******************************************************************
2043 Reads or writes a structure.
2044 ********************************************************************/
2046 BOOL srv_io_r_net_file_enum(char *desc, SRV_R_NET_FILE_ENUM *r_n, prs_struct *ps, int depth)
2048 if (r_n == NULL)
2049 return False;
2051 prs_debug(ps, depth, desc, "srv_io_r_net_file_enum");
2052 depth++;
2054 if(!prs_align(ps))
2055 return False;
2057 if(!prs_uint32("file_level", ps, depth, &r_n->file_level))
2058 return False;
2060 if (r_n->file_level != 0) {
2061 if(!srv_io_srv_file_ctr("file_ctr", &r_n->ctr, ps, depth))
2062 return False;
2065 if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
2066 return False;
2067 if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
2068 return False;
2069 if(!prs_werror("status ", ps, depth, &r_n->status))
2070 return False;
2072 return True;
2075 /*******************************************************************
2076 Inits a SRV_INFO_100 structure.
2077 ********************************************************************/
2079 void init_srv_info_100(SRV_INFO_100 *sv100, uint32 platform_id, char *name)
2081 DEBUG(5,("init_srv_info_100\n"));
2083 sv100->platform_id = platform_id;
2084 init_buf_unistr2(&sv100->uni_name, &sv100->ptr_name, name);
2087 /*******************************************************************
2088 Reads or writes a SRV_INFO_101 structure.
2089 ********************************************************************/
2091 static BOOL srv_io_info_100(char *desc, SRV_INFO_100 *sv100, prs_struct *ps, int depth)
2093 if (sv100 == NULL)
2094 return False;
2096 prs_debug(ps, depth, desc, "srv_io_info_100");
2097 depth++;
2099 if(!prs_align(ps))
2100 return False;
2102 if(!prs_uint32("platform_id ", ps, depth, &sv100->platform_id))
2103 return False;
2104 if(!prs_uint32("ptr_name ", ps, depth, &sv100->ptr_name))
2105 return False;
2107 if(!smb_io_unistr2("uni_name ", &sv100->uni_name, True, ps, depth))
2108 return False;
2110 return True;
2114 /*******************************************************************
2115 Inits a SRV_INFO_101 structure.
2116 ********************************************************************/
2118 void init_srv_info_101(SRV_INFO_101 *sv101, uint32 platform_id, char *name,
2119 uint32 ver_major, uint32 ver_minor,
2120 uint32 srv_type, char *comment)
2122 DEBUG(5,("init_srv_info_101\n"));
2124 sv101->platform_id = platform_id;
2125 init_buf_unistr2(&sv101->uni_name, &sv101->ptr_name, name);
2126 sv101->ver_major = ver_major;
2127 sv101->ver_minor = ver_minor;
2128 sv101->srv_type = srv_type;
2129 init_buf_unistr2(&sv101->uni_comment, &sv101->ptr_comment, comment);
2132 /*******************************************************************
2133 Reads or writes a SRV_INFO_101 structure.
2134 ********************************************************************/
2136 static BOOL srv_io_info_101(char *desc, SRV_INFO_101 *sv101, prs_struct *ps, int depth)
2138 if (sv101 == NULL)
2139 return False;
2141 prs_debug(ps, depth, desc, "srv_io_info_101");
2142 depth++;
2144 if(!prs_align(ps))
2145 return False;
2147 if(!prs_uint32("platform_id ", ps, depth, &sv101->platform_id))
2148 return False;
2149 if(!prs_uint32("ptr_name ", ps, depth, &sv101->ptr_name))
2150 return False;
2151 if(!prs_uint32("ver_major ", ps, depth, &sv101->ver_major))
2152 return False;
2153 if(!prs_uint32("ver_minor ", ps, depth, &sv101->ver_minor))
2154 return False;
2155 if(!prs_uint32("srv_type ", ps, depth, &sv101->srv_type))
2156 return False;
2157 if(!prs_uint32("ptr_comment ", ps, depth, &sv101->ptr_comment))
2158 return False;
2160 if(!prs_align(ps))
2161 return False;
2163 if(!smb_io_unistr2("uni_name ", &sv101->uni_name, True, ps, depth))
2164 return False;
2165 if(!smb_io_unistr2("uni_comment ", &sv101->uni_comment, True, ps, depth))
2166 return False;
2168 return True;
2171 /*******************************************************************
2172 Inits a SRV_INFO_102 structure.
2173 ********************************************************************/
2175 void init_srv_info_102(SRV_INFO_102 *sv102, uint32 platform_id, char *name,
2176 char *comment, uint32 ver_major, uint32 ver_minor,
2177 uint32 srv_type, uint32 users, uint32 disc, uint32 hidden,
2178 uint32 announce, uint32 ann_delta, uint32 licenses,
2179 char *usr_path)
2181 DEBUG(5,("init_srv_info_102\n"));
2183 sv102->platform_id = platform_id;
2184 init_buf_unistr2(&sv102->uni_name, &sv102->ptr_name, name);
2185 sv102->ver_major = ver_major;
2186 sv102->ver_minor = ver_minor;
2187 sv102->srv_type = srv_type;
2188 init_buf_unistr2(&sv102->uni_comment, &sv102->ptr_comment, comment);
2190 /* same as 101 up to here */
2192 sv102->users = users;
2193 sv102->disc = disc;
2194 sv102->hidden = hidden;
2195 sv102->announce = announce;
2196 sv102->ann_delta =ann_delta;
2197 sv102->licenses = licenses;
2198 init_buf_unistr2(&sv102->uni_usr_path, &sv102->ptr_usr_path, usr_path);
2202 /*******************************************************************
2203 Reads or writes a SRV_INFO_102 structure.
2204 ********************************************************************/
2206 static BOOL srv_io_info_102(char *desc, SRV_INFO_102 *sv102, prs_struct *ps, int depth)
2208 if (sv102 == NULL)
2209 return False;
2211 prs_debug(ps, depth, desc, "srv_io_info102");
2212 depth++;
2214 if(!prs_align(ps))
2215 return False;
2217 if(!prs_uint32("platform_id ", ps, depth, &sv102->platform_id))
2218 return False;
2219 if(!prs_uint32("ptr_name ", ps, depth, &sv102->ptr_name))
2220 return False;
2221 if(!prs_uint32("ver_major ", ps, depth, &sv102->ver_major))
2222 return False;
2223 if(!prs_uint32("ver_minor ", ps, depth, &sv102->ver_minor))
2224 return False;
2225 if(!prs_uint32("srv_type ", ps, depth, &sv102->srv_type))
2226 return False;
2227 if(!prs_uint32("ptr_comment ", ps, depth, &sv102->ptr_comment))
2228 return False;
2230 /* same as 101 up to here */
2232 if(!prs_uint32("users ", ps, depth, &sv102->users))
2233 return False;
2234 if(!prs_uint32("disc ", ps, depth, &sv102->disc))
2235 return False;
2236 if(!prs_uint32("hidden ", ps, depth, &sv102->hidden))
2237 return False;
2238 if(!prs_uint32("announce ", ps, depth, &sv102->announce))
2239 return False;
2240 if(!prs_uint32("ann_delta ", ps, depth, &sv102->ann_delta))
2241 return False;
2242 if(!prs_uint32("licenses ", ps, depth, &sv102->licenses))
2243 return False;
2244 if(!prs_uint32("ptr_usr_path", ps, depth, &sv102->ptr_usr_path))
2245 return False;
2247 if(!smb_io_unistr2("uni_name ", &sv102->uni_name, True, ps, depth))
2248 return False;
2249 if(!prs_align(ps))
2250 return False;
2251 if(!smb_io_unistr2("uni_comment ", &sv102->uni_comment, True, ps, depth))
2252 return False;
2253 if(!prs_align(ps))
2254 return False;
2255 if(!smb_io_unistr2("uni_usr_path", &sv102->uni_usr_path, True, ps, depth))
2256 return False;
2258 return True;
2261 /*******************************************************************
2262 Reads or writes a SRV_INFO_102 structure.
2263 ********************************************************************/
2265 static BOOL srv_io_info_ctr(char *desc, SRV_INFO_CTR *ctr, prs_struct *ps, int depth)
2267 if (ctr == NULL)
2268 return False;
2270 prs_debug(ps, depth, desc, "srv_io_info_ctr");
2271 depth++;
2273 if(!prs_align(ps))
2274 return False;
2276 if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
2277 return False;
2278 if(!prs_uint32("ptr_srv_ctr ", ps, depth, &ctr->ptr_srv_ctr))
2279 return False;
2281 if (ctr->ptr_srv_ctr != 0 && ctr->switch_value != 0 && ctr != NULL) {
2282 switch (ctr->switch_value) {
2283 case 100:
2284 if(!srv_io_info_100("sv100", &ctr->srv.sv100, ps, depth))
2285 return False;
2286 break;
2287 case 101:
2288 if(!srv_io_info_101("sv101", &ctr->srv.sv101, ps, depth))
2289 return False;
2290 break;
2291 case 102:
2292 if(!srv_io_info_102("sv102", &ctr->srv.sv102, ps, depth))
2293 return False;
2294 break;
2295 default:
2296 DEBUG(5,("%s no server info at switch_value %d\n",
2297 tab_depth(depth), ctr->switch_value));
2298 break;
2300 if(!prs_align(ps))
2301 return False;
2304 return True;
2307 /*******************************************************************
2308 Inits a SRV_Q_NET_SRV_GET_INFO structure.
2309 ********************************************************************/
2311 void init_srv_q_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *srv,
2312 char *server_name, uint32 switch_value)
2314 DEBUG(5,("init_srv_q_net_srv_get_info\n"));
2316 init_buf_unistr2(&srv->uni_srv_name, &srv->ptr_srv_name, server_name);
2318 srv->switch_value = switch_value;
2321 /*******************************************************************
2322 Reads or writes a structure.
2323 ********************************************************************/
2325 BOOL srv_io_q_net_srv_get_info(char *desc, SRV_Q_NET_SRV_GET_INFO *q_n, prs_struct *ps, int depth)
2327 if (q_n == NULL)
2328 return False;
2330 prs_debug(ps, depth, desc, "srv_io_q_net_srv_get_info");
2331 depth++;
2333 if(!prs_align(ps))
2334 return False;
2336 if(!prs_uint32("ptr_srv_name ", ps, depth, &q_n->ptr_srv_name))
2337 return False;
2338 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
2339 return False;
2341 if(!prs_align(ps))
2342 return False;
2344 if(!prs_uint32("switch_value ", ps, depth, &q_n->switch_value))
2345 return False;
2347 return True;
2350 /*******************************************************************
2351 Inits a SRV_R_NET_SRV_GET_INFO structure.
2352 ********************************************************************/
2354 void init_srv_r_net_srv_get_info(SRV_R_NET_SRV_GET_INFO *srv,
2355 uint32 switch_value, SRV_INFO_CTR *ctr, WERROR status)
2357 DEBUG(5,("init_srv_r_net_srv_get_info\n"));
2359 srv->ctr = ctr;
2361 if (W_ERROR_IS_OK(status)) {
2362 srv->ctr->switch_value = switch_value;
2363 srv->ctr->ptr_srv_ctr = 1;
2364 } else {
2365 srv->ctr->switch_value = 0;
2366 srv->ctr->ptr_srv_ctr = 0;
2369 srv->status = status;
2372 /*******************************************************************
2373 Inits a SRV_R_NET_SRV_SET_INFO structure.
2374 ********************************************************************/
2376 void init_srv_r_net_srv_set_info(SRV_R_NET_SRV_SET_INFO *srv,
2377 uint32 switch_value, WERROR status)
2379 DEBUG(5,("init_srv_r_net_srv_set_info\n"));
2381 srv->switch_value = switch_value;
2382 srv->status = status;
2385 /*******************************************************************
2386 Reads or writes a structure.
2387 ********************************************************************/
2389 BOOL srv_io_q_net_srv_set_info(char *desc, SRV_Q_NET_SRV_SET_INFO *q_n,
2390 prs_struct *ps, int depth)
2392 prs_debug(ps, depth, desc, "srv_io_q_net_srv_set_info");
2393 depth++;
2395 if(!prs_align(ps))
2396 return False;
2398 if(!prs_uint32("ptr_srv_name ", ps, depth, &q_n->ptr_srv_name))
2399 return False;
2400 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
2401 return False;
2403 if(!prs_align(ps))
2404 return False;
2406 if(!prs_uint32("switch_value ", ps, depth, &q_n->switch_value))
2407 return False;
2409 if (UNMARSHALLING(ps)) {
2410 q_n->ctr = (SRV_INFO_CTR *)
2411 prs_alloc_mem(ps, sizeof(SRV_INFO_CTR));
2413 if (!q_n->ctr)
2414 return False;
2417 if(!srv_io_info_ctr("ctr", q_n->ctr, ps, depth))
2418 return False;
2420 return True;
2423 /*******************************************************************
2424 Reads or writes a structure.
2425 ********************************************************************/
2427 BOOL srv_io_r_net_srv_get_info(char *desc, SRV_R_NET_SRV_GET_INFO *r_n, prs_struct *ps, int depth)
2429 if (r_n == NULL)
2430 return False;
2432 prs_debug(ps, depth, desc, "srv_io_r_net_srv_get_info");
2433 depth++;
2435 if(!prs_align(ps))
2436 return False;
2438 if(!srv_io_info_ctr("ctr", r_n->ctr, ps, depth))
2439 return False;
2441 if(!prs_werror("status ", ps, depth, &r_n->status))
2442 return False;
2444 return True;
2447 /*******************************************************************
2448 Reads or writes a structure.
2449 ********************************************************************/
2451 BOOL srv_io_r_net_srv_set_info(char *desc, SRV_R_NET_SRV_SET_INFO *r_n,
2452 prs_struct *ps, int depth)
2454 prs_debug(ps, depth, desc, "srv_io_r_net_srv_set_info");
2455 depth++;
2457 if(!prs_align(ps))
2458 return False;
2460 if(!prs_uint32("switch_value ", ps, depth, &r_n->switch_value))
2461 return False;
2463 if(!prs_werror("status ", ps, depth, &r_n->status))
2464 return False;
2466 return True;
2469 /*******************************************************************
2470 Reads or writes a structure.
2471 ********************************************************************/
2473 BOOL srv_io_q_net_remote_tod(char *desc, SRV_Q_NET_REMOTE_TOD *q_n, prs_struct *ps, int depth)
2475 if (q_n == NULL)
2476 return False;
2478 prs_debug(ps, depth, desc, "srv_io_q_net_remote_tod");
2479 depth++;
2481 if(!prs_align(ps))
2482 return False;
2484 if(!prs_uint32("ptr_srv_name ", ps, depth, &q_n->ptr_srv_name))
2485 return False;
2486 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
2487 return False;
2489 return True;
2492 /*******************************************************************
2493 Reads or writes a TIME_OF_DAY_INFO structure.
2494 ********************************************************************/
2496 static BOOL srv_io_time_of_day_info(char *desc, TIME_OF_DAY_INFO *tod, prs_struct *ps, int depth)
2498 if (tod == NULL)
2499 return False;
2501 prs_debug(ps, depth, desc, "srv_io_time_of_day_info");
2502 depth++;
2504 if(!prs_align(ps))
2505 return False;
2507 if(!prs_uint32("elapsedt ", ps, depth, &tod->elapsedt))
2508 return False;
2509 if(!prs_uint32("msecs ", ps, depth, &tod->msecs))
2510 return False;
2511 if(!prs_uint32("hours ", ps, depth, &tod->hours))
2512 return False;
2513 if(!prs_uint32("mins ", ps, depth, &tod->mins))
2514 return False;
2515 if(!prs_uint32("secs ", ps, depth, &tod->secs))
2516 return False;
2517 if(!prs_uint32("hunds ", ps, depth, &tod->hunds))
2518 return False;
2519 if(!prs_uint32("timezone ", ps, depth, &tod->zone))
2520 return False;
2521 if(!prs_uint32("tintervals ", ps, depth, &tod->tintervals))
2522 return False;
2523 if(!prs_uint32("day ", ps, depth, &tod->day))
2524 return False;
2525 if(!prs_uint32("month ", ps, depth, &tod->month))
2526 return False;
2527 if(!prs_uint32("year ", ps, depth, &tod->year))
2528 return False;
2529 if(!prs_uint32("weekday ", ps, depth, &tod->weekday))
2530 return False;
2532 return True;
2535 /*******************************************************************
2536 Inits a TIME_OF_DAY_INFO structure.
2537 ********************************************************************/
2539 void init_time_of_day_info(TIME_OF_DAY_INFO *tod, uint32 elapsedt, uint32 msecs,
2540 uint32 hours, uint32 mins, uint32 secs, uint32 hunds,
2541 uint32 zone, uint32 tintervals, uint32 day,
2542 uint32 month, uint32 year, uint32 weekday)
2544 DEBUG(5,("init_time_of_day_info\n"));
2546 tod->elapsedt = elapsedt;
2547 tod->msecs = msecs;
2548 tod->hours = hours;
2549 tod->mins = mins;
2550 tod->secs = secs;
2551 tod->hunds = hunds;
2552 tod->zone = zone;
2553 tod->tintervals = tintervals;
2554 tod->day = day;
2555 tod->month = month;
2556 tod->year = year;
2557 tod->weekday = weekday;
2561 /*******************************************************************
2562 Reads or writes a structure.
2563 ********************************************************************/
2565 BOOL srv_io_r_net_remote_tod(char *desc, SRV_R_NET_REMOTE_TOD *r_n, prs_struct *ps, int depth)
2567 if (r_n == NULL)
2568 return False;
2570 prs_debug(ps, depth, desc, "srv_io_r_net_remote_tod");
2571 depth++;
2573 if(!prs_align(ps))
2574 return False;
2576 if(!prs_uint32("ptr_srv_tod ", ps, depth, &r_n->ptr_srv_tod))
2577 return False;
2579 if(!srv_io_time_of_day_info("tod", r_n->tod, ps, depth))
2580 return False;
2582 if(!prs_werror("status ", ps, depth, &r_n->status))
2583 return False;
2585 return True;
2588 /*******************************************************************
2589 Reads or writes a structure.
2590 ********************************************************************/
2592 BOOL srv_io_q_net_disk_enum(char *desc, SRV_Q_NET_DISK_ENUM *q_n, prs_struct *ps, int depth)
2594 if (q_n == NULL)
2595 return False;
2597 prs_debug(ps, depth, desc, "srv_io_q_net_disk_enum");
2598 depth++;
2600 if(!prs_align(ps))
2601 return False;
2603 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
2604 return False;
2606 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
2607 return False;
2609 if(!prs_align(ps))
2610 return False;
2612 if(!prs_uint32("level", ps, depth, &q_n->disk_enum_ctr.level))
2613 return False;
2615 if(!prs_uint32("entries_read", ps, depth, &q_n->disk_enum_ctr.entries_read))
2616 return False;
2618 if(!prs_uint32("buffer", ps, depth, &q_n->disk_enum_ctr.disk_info_ptr))
2619 return False;
2621 if(!prs_align(ps))
2622 return False;
2624 if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
2625 return False;
2626 if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
2627 return False;
2629 return True;
2632 /*******************************************************************
2633 Reads or writes a structure.
2634 ********************************************************************/
2636 BOOL srv_io_r_net_disk_enum(char *desc, SRV_R_NET_DISK_ENUM *r_n, prs_struct *ps, int depth)
2638 int i;
2640 if (r_n == NULL)
2641 return False;
2643 prs_debug(ps, depth, desc, "srv_io_r_net_disk_enum");
2644 depth++;
2646 if(!prs_align(ps))
2647 return False;
2649 if(!prs_uint32("entries_read", ps, depth, &r_n->disk_enum_ctr.entries_read))
2650 return False;
2651 if(!prs_uint32("ptr_disk_info", ps, depth, &r_n->disk_enum_ctr.disk_info_ptr))
2652 return False;
2654 /*this may be max, unknown, actual?*/
2656 if(!prs_uint32("max_elements", ps, depth, &r_n->disk_enum_ctr.entries_read))
2657 return False;
2658 if(!prs_uint32("unknown", ps, depth, &r_n->disk_enum_ctr.unknown))
2659 return False;
2660 if(!prs_uint32("actual_elements", ps, depth, &r_n->disk_enum_ctr.entries_read))
2661 return False;
2663 for(i=0; i < r_n->disk_enum_ctr.entries_read; i++) {
2665 if(!prs_uint32("unknown", ps, depth, &r_n->disk_enum_ctr.disk_info[i].unknown))
2666 return False;
2668 if(!smb_io_unistr3("disk_name", &r_n->disk_enum_ctr.disk_info[i].disk_name, ps, depth))
2669 return False;
2671 if(!prs_align(ps))
2672 return False;
2675 if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
2676 return False;
2678 if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
2679 return False;
2681 if(!prs_werror("status", ps, depth, &r_n->status))
2682 return False;
2684 return True;
2687 /*******************************************************************
2688 Reads or writes a structure.
2689 ********************************************************************/
2691 BOOL srv_io_q_net_name_validate(char *desc, SRV_Q_NET_NAME_VALIDATE *q_n, prs_struct *ps, int depth)
2693 if (q_n == NULL)
2694 return False;
2696 prs_debug(ps, depth, desc, "srv_io_q_net_name_validate");
2697 depth++;
2699 if(!prs_align(ps))
2700 return False;
2702 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
2703 return False;
2705 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
2706 return False;
2708 if(!prs_align(ps))
2709 return False;
2711 if(!smb_io_unistr2("", &q_n->uni_name, True, ps, depth))
2712 return False;
2714 if(!prs_align(ps))
2715 return False;
2717 if(!prs_uint32("type", ps, depth, &q_n->type))
2718 return False;
2720 if(!prs_uint32("flags", ps, depth, &q_n->flags))
2721 return False;
2723 return True;
2726 /*******************************************************************
2727 Reads or writes a structure.
2728 ********************************************************************/
2730 BOOL srv_io_r_net_name_validate(char *desc, SRV_R_NET_NAME_VALIDATE *r_n, prs_struct *ps, int depth)
2732 if (r_n == NULL)
2733 return False;
2735 prs_debug(ps, depth, desc, "srv_io_r_net_name_validate");
2736 depth++;
2738 if(!prs_align(ps))
2739 return False;
2741 if(!prs_werror("status", ps, depth, &r_n->status))
2742 return False;
2744 return True;
2747 /*******************************************************************
2748 Reads or writes a structure.
2749 ********************************************************************/
2751 BOOL srv_io_q_net_file_query_secdesc(char *desc, SRV_Q_NET_FILE_QUERY_SECDESC *q_n, prs_struct *ps, int depth)
2753 if (q_n == NULL)
2754 return False;
2756 prs_debug(ps, depth, desc, "srv_io_q_net_file_query_secdesc");
2757 depth++;
2759 if(!prs_align(ps))
2760 return False;
2762 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
2763 return False;
2765 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
2766 return False;
2768 if(!prs_align(ps))
2769 return False;
2771 if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
2772 return False;
2774 if(!smb_io_unistr2("", &q_n->uni_qual_name, True, ps, depth))
2775 return False;
2777 if(!prs_align(ps))
2778 return False;
2780 if(!smb_io_unistr2("", &q_n->uni_file_name, True, ps, depth))
2781 return False;
2783 if(!prs_uint32("unknown1", ps, depth, &q_n->unknown1))
2784 return False;
2786 if(!prs_uint32("unknown2", ps, depth, &q_n->unknown2))
2787 return False;
2789 if(!prs_uint32("unknown3", ps, depth, &q_n->unknown3))
2790 return False;
2792 return True;
2795 /*******************************************************************
2796 Reads or writes a structure.
2797 ********************************************************************/
2799 BOOL srv_io_r_net_file_query_secdesc(char *desc, SRV_R_NET_FILE_QUERY_SECDESC *r_n, prs_struct *ps, int depth)
2801 if (r_n == NULL)
2802 return False;
2804 prs_debug(ps, depth, desc, "srv_io_r_net_file_query_secdesc");
2805 depth++;
2807 if(!prs_align(ps))
2808 return False;
2810 if(!prs_uint32("ptr_response", ps, depth, &r_n->ptr_response))
2811 return False;
2813 if(!prs_uint32("size_response", ps, depth, &r_n->size_response))
2814 return False;
2816 if(!prs_uint32("ptr_secdesc", ps, depth, &r_n->ptr_secdesc))
2817 return False;
2819 if(!prs_uint32("size_secdesc", ps, depth, &r_n->size_secdesc))
2820 return False;
2822 if(!sec_io_desc("sec_desc", &r_n->sec_desc, ps, depth))
2823 return False;
2825 if(!prs_align(ps))
2826 return False;
2828 if(!prs_werror("status", ps, depth, &r_n->status))
2829 return False;
2831 return True;
2834 /*******************************************************************
2835 Reads or writes a structure.
2836 ********************************************************************/
2838 BOOL srv_io_q_net_file_set_secdesc(char *desc, SRV_Q_NET_FILE_SET_SECDESC *q_n, prs_struct *ps, int depth)
2840 if (q_n == NULL)
2841 return False;
2843 prs_debug(ps, depth, desc, "srv_io_q_net_file_set_secdesc");
2844 depth++;
2846 if(!prs_align(ps))
2847 return False;
2849 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
2850 return False;
2852 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
2853 return False;
2855 if(!prs_align(ps))
2856 return False;
2858 if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
2859 return False;
2861 if(!smb_io_unistr2("", &q_n->uni_qual_name, True, ps, depth))
2862 return False;
2864 if(!prs_align(ps))
2865 return False;
2867 if(!smb_io_unistr2("", &q_n->uni_file_name, True, ps, depth))
2868 return False;
2870 if(!prs_align(ps))
2871 return False;
2873 if(!prs_uint32("sec_info", ps, depth, &q_n->sec_info))
2874 return False;
2876 if(!prs_uint32("size_set", ps, depth, &q_n->size_set))
2877 return False;
2879 if(!prs_uint32("ptr_secdesc", ps, depth, &q_n->ptr_secdesc))
2880 return False;
2882 if(!prs_uint32("size_secdesc", ps, depth, &q_n->size_secdesc))
2883 return False;
2885 if(!sec_io_desc("sec_desc", &q_n->sec_desc, ps, depth))
2886 return False;
2888 return True;
2891 /*******************************************************************
2892 Reads or writes a structure.
2893 ********************************************************************/
2895 BOOL srv_io_r_net_file_set_secdesc(char *desc, SRV_R_NET_FILE_SET_SECDESC *r_n, prs_struct *ps, int depth)
2897 if (r_n == NULL)
2898 return False;
2900 prs_debug(ps, depth, desc, "srv_io_r_net_file_set_secdesc");
2901 depth++;
2903 if(!prs_align(ps))
2904 return False;
2906 if(!prs_werror("status", ps, depth, &r_n->status))
2907 return False;
2909 return True;