Correct PPTP server firewall rules chain.
[tomato/davidwu.git] / release / src / router / samba / source / rpc_parse / parse_srv.c
blob8997b05e0b75a2713275eac56cf7a74bf3d7a3c5
2 /*
3 * Unix SMB/Netbios implementation.
4 * Version 1.9.
5 * RPC Pipe client / server routines
6 * Copyright (C) Andrew Tridgell 1992-1997,
7 * Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
8 * Copyright (C) Paul Ashton 1997.
9 * Copyright (C) Jeremy Allison 1999.
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.
27 #include "includes.h"
29 extern int DEBUGLEVEL;
31 /*******************************************************************
32 Inits a SH_INFO_1_STR structure
33 ********************************************************************/
35 void init_srv_share_info1_str(SH_INFO_1_STR *sh1, char *net_name, char *remark)
37 DEBUG(5,("init_srv_share_info1_str\n"));
39 init_unistr2(&sh1->uni_netname, net_name, strlen(net_name)+1);
40 init_unistr2(&sh1->uni_remark, remark, strlen(remark)+1);
43 /*******************************************************************
44 Reads or writes a structure.
45 ********************************************************************/
47 static BOOL srv_io_share_info1_str(char *desc, SH_INFO_1_STR *sh1, prs_struct *ps, int depth)
49 if (sh1 == NULL)
50 return False;
52 prs_debug(ps, depth, desc, "srv_io_share_info1_str");
53 depth++;
55 if(!prs_align(ps))
56 return False;
58 if(!smb_io_unistr2("", &sh1->uni_netname, True, ps, depth))
59 return False;
60 if(!smb_io_unistr2("", &sh1->uni_remark, True, ps, depth))
61 return False;
63 return True;
66 /*******************************************************************
67 makes a SH_INFO_1 structure
68 ********************************************************************/
70 void init_srv_share_info1(SH_INFO_1 *sh1, char *net_name, uint32 type, char *remark)
72 DEBUG(5,("init_srv_share_info1: %s %8x %s\n", net_name, type, remark));
74 sh1->ptr_netname = (net_name != NULL) ? 1 : 0;
75 sh1->type = type;
76 sh1->ptr_remark = (remark != NULL) ? 1 : 0;
79 /*******************************************************************
80 Reads or writes a structure.
81 ********************************************************************/
83 static BOOL srv_io_share_info1(char *desc, SH_INFO_1 *sh1, prs_struct *ps, int depth)
85 if (sh1 == NULL)
86 return False;
88 prs_debug(ps, depth, desc, "srv_io_share_info1");
89 depth++;
91 if(!prs_align(ps))
92 return False;
94 if(!prs_uint32("ptr_netname", ps, depth, &sh1->ptr_netname))
95 return False;
96 if(!prs_uint32("type ", ps, depth, &sh1->type))
97 return False;
98 if(!prs_uint32("ptr_remark ", ps, depth, &sh1->ptr_remark))
99 return False;
101 return True;
104 /*******************************************************************
105 Inits a SH_INFO_2_STR structure
106 ********************************************************************/
108 void init_srv_share_info2_str(SH_INFO_2_STR *sh2,
109 char *net_name, char *remark,
110 char *path, char *passwd)
112 DEBUG(5,("init_srv_share_info2_str\n"));
114 init_unistr2(&sh2->uni_netname, net_name, strlen(net_name)+1);
115 init_unistr2(&sh2->uni_remark, remark, strlen(remark)+1);
116 init_unistr2(&sh2->uni_path, path, strlen(path)+1);
117 init_unistr2(&sh2->uni_passwd, passwd, strlen(passwd)+1);
120 /*******************************************************************
121 Reads or writes a structure.
122 ********************************************************************/
124 static BOOL srv_io_share_info2_str(char *desc, SH_INFO_2_STR *sh2, prs_struct *ps, int depth)
126 if (sh2 == NULL)
127 return False;
129 prs_debug(ps, depth, desc, "srv_io_share_info2_str");
130 depth++;
132 if(!prs_align(ps))
133 return False;
135 if(!smb_io_unistr2("", &sh2->uni_netname, True, ps, depth))
136 return False;
137 if(!smb_io_unistr2("", &sh2->uni_remark, True, ps, depth))
138 return False;
139 if(!smb_io_unistr2("", &sh2->uni_path, True, ps, depth))
140 return False;
141 if(!smb_io_unistr2("", &sh2->uni_passwd, True, ps, depth))
142 return False;
144 return True;
147 /*******************************************************************
148 Inits a SH_INFO_2 structure
149 ********************************************************************/
151 void init_srv_share_info2(SH_INFO_2 *sh2,
152 char *net_name, uint32 type, char *remark,
153 uint32 perms, uint32 max_uses, uint32 num_uses,
154 char *path, char *passwd)
156 DEBUG(5,("init_srv_share_info2: %s %8x %s\n", net_name, type, remark));
158 sh2->ptr_netname = (net_name != NULL) ? 1 : 0;
159 sh2->type = type;
160 sh2->ptr_remark = (remark != NULL) ? 1 : 0;
161 sh2->perms = perms;
162 sh2->max_uses = max_uses;
163 sh2->num_uses = num_uses;
164 sh2->type = type;
165 sh2->ptr_path = (path != NULL) ? 1 : 0;
166 sh2->ptr_passwd = (passwd != NULL) ? 1 : 0;
169 /*******************************************************************
170 Reads or writes a structure.
171 ********************************************************************/
173 static BOOL srv_io_share_info2(char *desc, SH_INFO_2 *sh2, prs_struct *ps, int depth)
175 if (sh2 == NULL)
176 return False;
178 prs_debug(ps, depth, desc, "srv_io_share_info2");
179 depth++;
181 if(!prs_align(ps))
182 return False;
184 if(!prs_uint32("ptr_netname", ps, depth, &sh2->ptr_netname))
185 return False;
186 if(!prs_uint32("type ", ps, depth, &sh2->type))
187 return False;
188 if(!prs_uint32("ptr_remark ", ps, depth, &sh2->ptr_remark))
189 return False;
190 if(!prs_uint32("perms ", ps, depth, &sh2->perms))
191 return False;
192 if(!prs_uint32("max_uses ", ps, depth, &sh2->max_uses))
193 return False;
194 if(!prs_uint32("num_uses ", ps, depth, &sh2->num_uses))
195 return False;
196 if(!prs_uint32("ptr_path ", ps, depth, &sh2->ptr_path))
197 return False;
198 if(!prs_uint32("ptr_passwd ", ps, depth, &sh2->ptr_passwd))
199 return False;
201 return True;
204 /*******************************************************************
205 Reads or writes a structure.
206 ********************************************************************/
208 static BOOL srv_io_srv_share_ctr(char *desc, SRV_SHARE_INFO_CTR *ctr, prs_struct *ps, int depth)
210 if (ctr == NULL)
211 return False;
213 prs_debug(ps, depth, desc, "srv_io_srv_share_ctr");
214 depth++;
216 if (UNMARSHALLING(ps)) {
217 memset(ctr, '\0', sizeof(SRV_SHARE_INFO_CTR));
220 if(!prs_align(ps))
221 return False;
223 if(!prs_uint32("info_level", ps, depth, &ctr->info_level))
224 return False;
226 if (ctr->info_level == 0)
227 return True;
229 if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
230 return False;
231 if(!prs_uint32("ptr_share_info", ps, depth, &ctr->ptr_share_info))
232 return False;
234 if (ctr->ptr_share_info == 0)
235 return True;
237 if(!prs_uint32("num_entries", ps, depth, &ctr->num_entries))
238 return False;
239 if(!prs_uint32("ptr_entries", ps, depth, &ctr->ptr_entries))
240 return False;
242 if (ctr->ptr_entries == 0) {
243 if (ctr->num_entries == 0)
244 return True;
245 else
246 return False;
249 if(!prs_uint32("num_entries2", ps, depth, &ctr->num_entries2))
250 return False;
252 if (ctr->num_entries2 != ctr->num_entries)
253 return False;
255 switch (ctr->switch_value) {
256 case 1:
258 SRV_SHARE_INFO_1 *info1 = ctr->share.info1;
259 int num_entries = ctr->num_entries;
260 int i;
262 if (UNMARSHALLING(ps)) {
263 if (!(info1 = malloc(num_entries * sizeof(SRV_SHARE_INFO_1))))
264 return False;
265 memset(info1, '\0', num_entries * sizeof(SRV_SHARE_INFO_1));
266 ctr->share.info1 = info1;
269 for (i = 0; i < num_entries; i++) {
270 if(!srv_io_share_info1("", &info1[i].info_1, ps, depth))
271 return False;
274 for (i = 0; i < num_entries; i++) {
275 if(!srv_io_share_info1_str("", &info1[i].info_1_str, ps, depth))
276 return False;
279 break;
282 case 2:
284 SRV_SHARE_INFO_2 *info2 = ctr->share.info2;
285 int num_entries = ctr->num_entries;
286 int i;
288 if (UNMARSHALLING(ps)) {
289 if (!(info2 = malloc(num_entries * sizeof(SRV_SHARE_INFO_2))))
290 return False;
291 memset(info2, '\0', num_entries * sizeof(SRV_SHARE_INFO_2));
292 ctr->share.info2 = info2;
295 for (i = 0; i < num_entries; i++) {
296 if(!srv_io_share_info2("", &info2[i].info_2, ps, depth))
297 return False;
300 for (i = 0; i < num_entries; i++) {
301 if(!srv_io_share_info2_str("", &info2[i].info_2_str, ps, depth))
302 return False;
305 break;
308 default:
309 DEBUG(5,("%s no share info at switch_value %d\n",
310 tab_depth(depth), ctr->switch_value));
311 break;
314 return True;
317 /*******************************************************************
318 Frees a SRV_SHARE_INFO_CTR structure.
319 ********************************************************************/
321 void free_srv_share_info_ctr(SRV_SHARE_INFO_CTR *ctr)
323 if(!ctr)
324 return;
325 if(ctr->share.info)
326 free(ctr->share.info);
327 memset(ctr, '\0', sizeof(SRV_SHARE_INFO_CTR));
330 /*******************************************************************
331 Frees a SRV_Q_NET_SHARE_ENUM structure.
332 ********************************************************************/
334 void free_srv_q_net_share_enum(SRV_Q_NET_SHARE_ENUM *q_n)
336 if(!q_n)
337 return;
338 free_srv_share_info_ctr(&q_n->ctr);
339 memset(q_n, '\0', sizeof(SRV_Q_NET_SHARE_ENUM));
342 /*******************************************************************
343 Frees a SRV_R_NET_SHARE_ENUM structure.
344 ********************************************************************/
346 void free_srv_r_net_share_enum(SRV_R_NET_SHARE_ENUM *r_n)
348 if(!r_n)
349 return;
350 free_srv_share_info_ctr(&r_n->ctr);
351 memset(r_n, '\0', sizeof(SRV_R_NET_SHARE_ENUM));
354 /*******************************************************************
355 Inits a SRV_Q_NET_SHARE_ENUM structure.
356 ********************************************************************/
358 void init_srv_q_net_share_enum(SRV_Q_NET_SHARE_ENUM *q_n,
359 char *srv_name, uint32 info_level,
360 uint32 preferred_len, ENUM_HND *hnd)
363 DEBUG(5,("init_q_net_share_enum\n"));
365 init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
367 q_n->ctr.info_level = q_n->ctr.switch_value = info_level;
368 q_n->ctr.ptr_share_info = 0;
369 q_n->preferred_len = preferred_len;
371 memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
374 /*******************************************************************
375 Reads or writes a structure.
376 ********************************************************************/
378 BOOL srv_io_q_net_share_enum(char *desc, SRV_Q_NET_SHARE_ENUM *q_n, prs_struct *ps, int depth)
380 if (q_n == NULL)
381 return False;
383 prs_debug(ps, depth, desc, "srv_io_q_net_share_enum");
384 depth++;
386 if(!prs_align(ps))
387 return False;
389 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
390 return False;
391 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
392 return False;
394 if(!srv_io_srv_share_ctr("share_ctr", &q_n->ctr, ps, depth))
395 return False;
397 if(!prs_align(ps))
398 return False;
400 if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
401 return False;
403 if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
404 return False;
406 return True;
409 /*******************************************************************
410 Reads or writes a structure.
411 ********************************************************************/
413 BOOL srv_io_r_net_share_enum(char *desc, SRV_R_NET_SHARE_ENUM *r_n, prs_struct *ps, int depth)
415 if (r_n == NULL)
416 return False;
418 prs_debug(ps, depth, desc, "srv_io_r_net_share_enum");
419 depth++;
421 if(!srv_io_srv_share_ctr("share_ctr", &r_n->ctr, ps, depth))
422 return False;
424 if(!prs_align(ps))
425 return False;
427 if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
428 return False;
429 if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
430 return False;
431 if(!prs_uint32("status ", ps, depth, &r_n->status))
432 return False;
434 return True;
437 /*******************************************************************
438 Frees a SRV_Q_NET_SHARE_GET_INFO structure.
439 ********************************************************************/
441 void free_srv_q_net_share_get_info(SRV_Q_NET_SHARE_GET_INFO *q_n)
443 if(!q_n)
444 return;
445 memset(q_n, '\0', sizeof(SRV_Q_NET_SHARE_GET_INFO));
448 /*******************************************************************
449 Frees a SRV_R_NET_SHARE_GET_INFO structure.
450 ********************************************************************/
452 void free_srv_r_net_share_get_info(SRV_R_NET_SHARE_GET_INFO *r_n)
454 if(!r_n)
455 return;
456 memset(r_n, '\0', sizeof(SRV_R_NET_SHARE_GET_INFO));
459 /*******************************************************************
460 Reads or writes a structure.
461 ********************************************************************/
463 BOOL srv_io_q_net_share_get_info(char *desc, SRV_Q_NET_SHARE_GET_INFO *q_n, prs_struct *ps, int depth)
465 if (q_n == NULL)
466 return False;
468 prs_debug(ps, depth, desc, "srv_io_q_net_share_get_info");
469 depth++;
471 if(!prs_align(ps))
472 return False;
474 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
475 return False;
476 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
477 return False;
479 if(!smb_io_unistr2("", &q_n->uni_share_name, True, ps, depth))
480 return False;
482 if(!prs_align(ps))
483 return False;
485 if(!prs_uint32("info_level", ps, depth, &q_n->info_level))
486 return False;
488 return True;
491 /*******************************************************************
492 Reads or writes a structure.
493 ********************************************************************/
495 BOOL srv_io_r_net_share_get_info(char *desc, SRV_R_NET_SHARE_GET_INFO *r_n, prs_struct *ps, int depth)
497 if (r_n == NULL)
498 return False;
500 prs_debug(ps, depth, desc, "srv_io_r_net_share_get_info");
501 depth++;
503 if(!prs_align(ps))
504 return False;
506 if(!prs_uint32("switch_value ", ps, depth, &r_n->switch_value ))
507 return False;
509 if(!prs_uint32("ptr_share_ctr", ps, depth, &r_n->ptr_share_ctr))
510 return False;
512 if (r_n->ptr_share_ctr != 0) {
513 switch (r_n->switch_value) {
514 case 1:
515 if(!srv_io_share_info1("", &r_n->share.info1.info_1, ps, depth))
516 return False;
518 if(!srv_io_share_info1_str("", &r_n->share.info1.info_1_str, ps, depth))
519 return False;
521 break;
522 case 2:
523 if(!srv_io_share_info2("", &r_n->share.info2.info_2, ps, depth))
524 return False;
526 if(!srv_io_share_info2_str("", &r_n->share.info2.info_2_str, ps, depth))
527 return False;
529 break;
530 default:
531 DEBUG(5,("%s no share info at switch_value %d\n",
532 tab_depth(depth), r_n->switch_value));
533 break;
537 if(!prs_align(ps))
538 return False;
540 if(!prs_uint32("status", ps, depth, &r_n->status))
541 return False;
543 return True;
546 /*******************************************************************
547 Inits a SESS_INFO_0_STR structure
548 ********************************************************************/
550 void init_srv_sess_info0_str(SESS_INFO_0_STR *ss0, char *name)
552 DEBUG(5,("init_srv_sess_info0_str\n"));
554 init_unistr2(&ss0->uni_name, name, strlen(name)+1);
557 /*******************************************************************
558 Reads or writes a structure.
559 ********************************************************************/
561 static BOOL srv_io_sess_info0_str(char *desc, SESS_INFO_0_STR *ss0, prs_struct *ps, int depth)
563 if (ss0 == NULL)
564 return False;
566 prs_debug(ps, depth, desc, "srv_io_sess_info0_str");
567 depth++;
569 if(!prs_align(ps))
570 return False;
572 if(!smb_io_unistr2("", &ss0->uni_name, True, ps, depth))
573 return False;
575 return True;
578 /*******************************************************************
579 Inits a SESS_INFO_0 structure
580 ********************************************************************/
582 void init_srv_sess_info0(SESS_INFO_0 *ss0, char *name)
584 DEBUG(5,("init_srv_sess_info0: %s\n", name));
586 ss0->ptr_name = (name != NULL) ? 1 : 0;
589 /*******************************************************************
590 Reads or writes a structure.
591 ********************************************************************/
593 static BOOL srv_io_sess_info0(char *desc, SESS_INFO_0 *ss0, prs_struct *ps, int depth)
595 if (ss0 == NULL)
596 return False;
598 prs_debug(ps, depth, desc, "srv_io_sess_info0");
599 depth++;
601 if(!prs_align(ps))
602 return False;
604 if(!prs_uint32("ptr_name", ps, depth, &ss0->ptr_name))
605 return False;
607 return True;
610 /*******************************************************************
611 Reads or writes a structure.
612 ********************************************************************/
614 static BOOL srv_io_srv_sess_info_0(char *desc, SRV_SESS_INFO_0 *ss0, prs_struct *ps, int depth)
616 if (ss0 == NULL)
617 return False;
619 prs_debug(ps, depth, desc, "srv_io_srv_sess_info_0");
620 depth++;
622 if(!prs_align(ps))
623 return False;
625 if(!prs_uint32("num_entries_read", ps, depth, &ss0->num_entries_read))
626 return False;
627 if(!prs_uint32("ptr_sess_info", ps, depth, &ss0->ptr_sess_info))
628 return False;
630 if (ss0->ptr_sess_info != 0) {
631 int i;
632 int num_entries = ss0->num_entries_read;
634 if (num_entries > MAX_SESS_ENTRIES) {
635 num_entries = MAX_SESS_ENTRIES; /* report this! */
638 if(!prs_uint32("num_entries_read2", ps, depth, &ss0->num_entries_read2))
639 return False;
641 SMB_ASSERT_ARRAY(ss0->info_0, num_entries);
643 for (i = 0; i < num_entries; i++) {
644 if(!srv_io_sess_info0("", &ss0->info_0[i], ps, depth))
645 return False;
648 for (i = 0; i < num_entries; i++) {
649 if(!srv_io_sess_info0_str("", &ss0->info_0_str[i], ps, depth))
650 return False;
653 if(!prs_align(ps))
654 return False;
657 return True;
660 /*******************************************************************
661 Inits a SESS_INFO_1_STR structure
662 ********************************************************************/
664 void init_srv_sess_info1_str(SESS_INFO_1_STR *ss1, char *name, char *user)
666 DEBUG(5,("init_srv_sess_info1_str\n"));
668 init_unistr2(&ss1->uni_name, name, strlen(name)+1);
669 init_unistr2(&ss1->uni_user, name, strlen(user)+1);
672 /*******************************************************************
673 Reads or writes a structure.
674 ********************************************************************/
676 static BOOL srv_io_sess_info1_str(char *desc, SESS_INFO_1_STR *ss1, prs_struct *ps, int depth)
678 if (ss1 == NULL)
679 return False;
681 prs_debug(ps, depth, desc, "srv_io_sess_info1_str");
682 depth++;
684 if(!prs_align(ps))
685 return False;
687 if(!smb_io_unistr2("", &ss1->uni_name, True, ps, depth))
688 return False;
689 if(!smb_io_unistr2("", &(ss1->uni_user), True, ps, depth))
690 return False;
692 return True;
695 /*******************************************************************
696 Inits a SESS_INFO_1 structure
697 ********************************************************************/
699 void init_srv_sess_info1(SESS_INFO_1 *ss1,
700 char *name, char *user,
701 uint32 num_opens, uint32 open_time, uint32 idle_time,
702 uint32 user_flags)
704 DEBUG(5,("init_srv_sess_info1: %s\n", name));
706 ss1->ptr_name = (name != NULL) ? 1 : 0;
707 ss1->ptr_user = (user != NULL) ? 1 : 0;
709 ss1->num_opens = num_opens;
710 ss1->open_time = open_time;
711 ss1->idle_time = idle_time;
712 ss1->user_flags = user_flags;
715 /*******************************************************************
716 reads or writes a structure.
717 ********************************************************************/
719 static BOOL srv_io_sess_info1(char *desc, SESS_INFO_1 *ss1, prs_struct *ps, int depth)
721 if (ss1 == NULL)
722 return False;
724 prs_debug(ps, depth, desc, "srv_io_sess_info1");
725 depth++;
727 if(!prs_align(ps))
728 return False;
730 if(!prs_uint32("ptr_name ", ps, depth, &ss1->ptr_name))
731 return False;
732 if(!prs_uint32("ptr_user ", ps, depth, &ss1->ptr_user))
733 return False;
735 if(!prs_uint32("num_opens ", ps, depth, &ss1->num_opens))
736 return False;
737 if(!prs_uint32("open_time ", ps, depth, &ss1->open_time))
738 return False;
739 if(!prs_uint32("idle_time ", ps, depth, &ss1->idle_time))
740 return False;
741 if(!prs_uint32("user_flags", ps, depth, &ss1->user_flags))
742 return False;
744 return True;
747 /*******************************************************************
748 Reads or writes a structure.
749 ********************************************************************/
751 static BOOL srv_io_srv_sess_info_1(char *desc, SRV_SESS_INFO_1 *ss1, prs_struct *ps, int depth)
753 if (ss1 == NULL)
754 return False;
756 prs_debug(ps, depth, desc, "srv_io_srv_sess_info_1");
757 depth++;
759 if(!prs_align(ps))
760 return False;
762 if(!prs_uint32("num_entries_read", ps, depth, &ss1->num_entries_read))
763 return False;
764 if(!prs_uint32("ptr_sess_info", ps, depth, &ss1->ptr_sess_info))
765 return False;
767 if (ss1->ptr_sess_info != 0) {
768 int i;
769 int num_entries = ss1->num_entries_read;
771 if (num_entries > MAX_SESS_ENTRIES) {
772 num_entries = MAX_SESS_ENTRIES; /* report this! */
775 if(!prs_uint32("num_entries_read2", ps, depth, &ss1->num_entries_read2))
776 return False;
778 SMB_ASSERT_ARRAY(ss1->info_1, num_entries);
780 for (i = 0; i < num_entries; i++) {
781 if(!srv_io_sess_info1("", &ss1->info_1[i], ps, depth))
782 return False;
785 for (i = 0; i < num_entries; i++) {
786 if(!srv_io_sess_info1_str("", &ss1->info_1_str[i], ps, depth))
787 return False;
790 if(!prs_align(ps))
791 return False;
794 return True;
797 /*******************************************************************
798 Reads or writes a structure.
799 ********************************************************************/
801 static BOOL srv_io_srv_sess_ctr(char *desc, SRV_SESS_INFO_CTR *ctr, prs_struct *ps, int depth)
803 if (ctr == NULL)
804 return False;
806 prs_debug(ps, depth, desc, "srv_io_srv_sess_ctr");
807 depth++;
809 if(!prs_align(ps))
810 return False;
812 if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
813 return False;
814 if(!prs_uint32("ptr_sess_ctr", ps, depth, &ctr->ptr_sess_ctr))
815 return False;
817 if (ctr->ptr_sess_ctr != 0) {
818 switch (ctr->switch_value) {
819 case 0:
820 if(!srv_io_srv_sess_info_0("", &ctr->sess.info0, ps, depth))
821 return False;
822 break;
823 case 1:
824 if(!srv_io_srv_sess_info_1("", &ctr->sess.info1, ps, depth))
825 return False;
826 break;
827 default:
828 DEBUG(5,("%s no session info at switch_value %d\n",
829 tab_depth(depth), ctr->switch_value));
830 break;
834 return True;
837 /*******************************************************************
838 Inits a SRV_Q_NET_SESS_ENUM structure.
839 ********************************************************************/
841 void init_srv_q_net_sess_enum(SRV_Q_NET_SESS_ENUM *q_n,
842 char *srv_name, char *qual_name,
843 uint32 sess_level, SRV_SESS_INFO_CTR *ctr,
844 uint32 preferred_len,
845 ENUM_HND *hnd)
847 q_n->ctr = ctr;
849 DEBUG(5,("init_q_net_sess_enum\n"));
851 init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
852 init_buf_unistr2(&q_n->uni_qual_name, &q_n->ptr_qual_name, qual_name);
854 q_n->sess_level = sess_level;
855 q_n->preferred_len = preferred_len;
857 memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
860 /*******************************************************************
861 Reads or writes a structure.
862 ********************************************************************/
864 BOOL srv_io_q_net_sess_enum(char *desc, SRV_Q_NET_SESS_ENUM *q_n, prs_struct *ps, int depth)
866 if (q_n == NULL)
867 return False;
869 prs_debug(ps, depth, desc, "srv_io_q_net_sess_enum");
870 depth++;
872 if(!prs_align(ps))
873 return False;
875 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
876 return False;
877 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
878 return False;
880 if(!prs_align(ps))
881 return False;
883 if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
884 return False;
885 if(!smb_io_unistr2("", &q_n->uni_qual_name, q_n->ptr_qual_name, ps, depth))
886 return False;
888 if(!prs_align(ps))
889 return False;
891 if(!prs_uint32("sess_level", ps, depth, &q_n->sess_level))
892 return False;
894 if (q_n->sess_level != -1) {
895 if(!srv_io_srv_sess_ctr("sess_ctr", q_n->ctr, ps, depth))
896 return False;
899 if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
900 return False;
902 if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
903 return False;
905 return True;
908 /*******************************************************************
909 Reads or writes a structure.
910 ********************************************************************/
912 BOOL srv_io_r_net_sess_enum(char *desc, SRV_R_NET_SESS_ENUM *r_n, prs_struct *ps, int depth)
914 if (r_n == NULL)
915 return False;
917 prs_debug(ps, depth, desc, "srv_io_r_net_sess_enum");
918 depth++;
920 if(!prs_align(ps))
921 return False;
923 if(!prs_uint32("sess_level", ps, depth, &r_n->sess_level))
924 return False;
926 if (r_n->sess_level != -1) {
927 if(!srv_io_srv_sess_ctr("sess_ctr", r_n->ctr, ps, depth))
928 return False;
931 if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
932 return False;
933 if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
934 return False;
935 if(!prs_uint32("status ", ps, depth, &r_n->status))
936 return False;
938 return True;
941 /*******************************************************************
942 Inits a CONN_INFO_0 structure
943 ********************************************************************/
945 void init_srv_conn_info0(CONN_INFO_0 *ss0, uint32 id)
947 DEBUG(5,("init_srv_conn_info0\n"));
949 ss0->id = id;
952 /*******************************************************************
953 Reads or writes a structure.
954 ********************************************************************/
956 static BOOL srv_io_conn_info0(char *desc, CONN_INFO_0 *ss0, prs_struct *ps, int depth)
958 if (ss0 == NULL)
959 return False;
961 prs_debug(ps, depth, desc, "srv_io_conn_info0");
962 depth++;
964 if(!prs_align(ps))
965 return False;
967 if(!prs_uint32("id", ps, depth, &ss0->id))
968 return False;
970 return True;
973 /*******************************************************************
974 Reads or writes a structure.
975 ********************************************************************/
977 static BOOL srv_io_srv_conn_info_0(char *desc, SRV_CONN_INFO_0 *ss0, prs_struct *ps, int depth)
979 if (ss0 == NULL)
980 return False;
982 prs_debug(ps, depth, desc, "srv_io_srv_conn_info_0");
983 depth++;
985 if(!prs_align(ps))
986 return False;
988 if(!prs_uint32("num_entries_read", ps, depth, &ss0->num_entries_read))
989 return False;
990 if(!prs_uint32("ptr_conn_info", ps, depth, &ss0->ptr_conn_info))
991 return False;
993 if (ss0->ptr_conn_info != 0) {
994 int i;
995 int num_entries = ss0->num_entries_read;
997 if (num_entries > MAX_CONN_ENTRIES) {
998 num_entries = MAX_CONN_ENTRIES; /* report this! */
1001 if(!prs_uint32("num_entries_read2", ps, depth, &ss0->num_entries_read2))
1002 return False;
1004 for (i = 0; i < num_entries; i++) {
1005 if(!srv_io_conn_info0("", &ss0->info_0[i], ps, depth))
1006 return False;
1009 if(!prs_align(ps))
1010 return False;
1013 return True;
1016 /*******************************************************************
1017 Inits a CONN_INFO_1_STR structure
1018 ********************************************************************/
1020 void init_srv_conn_info1_str(CONN_INFO_1_STR *ss1, char *usr_name, char *net_name)
1022 DEBUG(5,("init_srv_conn_info1_str\n"));
1024 init_unistr2(&ss1->uni_usr_name, usr_name, strlen(usr_name)+1);
1025 init_unistr2(&ss1->uni_net_name, net_name, strlen(net_name)+1);
1028 /*******************************************************************
1029 Reads or writes a structure.
1030 ********************************************************************/
1032 static BOOL srv_io_conn_info1_str(char *desc, CONN_INFO_1_STR *ss1, prs_struct *ps, int depth)
1034 if (ss1 == NULL)
1035 return False;
1037 prs_debug(ps, depth, desc, "srv_io_conn_info1_str");
1038 depth++;
1040 if(!prs_align(ps))
1041 return False;
1043 if(!smb_io_unistr2("", &ss1->uni_usr_name, True, ps, depth))
1044 return False;
1045 if(!smb_io_unistr2("", &ss1->uni_net_name, True, ps, depth))
1046 return False;
1048 return True;
1051 /*******************************************************************
1052 Inits a CONN_INFO_1 structure
1053 ********************************************************************/
1055 void init_srv_conn_info1(CONN_INFO_1 *ss1,
1056 uint32 id, uint32 type,
1057 uint32 num_opens, uint32 num_users, uint32 open_time,
1058 char *usr_name, char *net_name)
1060 DEBUG(5,("init_srv_conn_info1: %s %s\n", usr_name, net_name));
1062 ss1->id = id ;
1063 ss1->type = type ;
1064 ss1->num_opens = num_opens ;
1065 ss1->num_users = num_users;
1066 ss1->open_time = open_time;
1068 ss1->ptr_usr_name = (usr_name != NULL) ? 1 : 0;
1069 ss1->ptr_net_name = (net_name != NULL) ? 1 : 0;
1072 /*******************************************************************
1073 Reads or writes a structure.
1074 ********************************************************************/
1076 static BOOL srv_io_conn_info1(char *desc, CONN_INFO_1 *ss1, prs_struct *ps, int depth)
1078 if (ss1 == NULL)
1079 return False;
1081 prs_debug(ps, depth, desc, "srv_io_conn_info1");
1082 depth++;
1084 if(!prs_align(ps))
1085 return False;
1087 if(!prs_uint32("id ", ps, depth, &ss1->id))
1088 return False;
1089 if(!prs_uint32("type ", ps, depth, &ss1->type))
1090 return False;
1091 if(!prs_uint32("num_opens ", ps, depth, &ss1->num_opens))
1092 return False;
1093 if(!prs_uint32("num_users ", ps, depth, &ss1->num_users))
1094 return False;
1095 if(!prs_uint32("open_time ", ps, depth, &ss1->open_time))
1096 return False;
1098 if(!prs_uint32("ptr_usr_name", ps, depth, &ss1->ptr_usr_name))
1099 return False;
1100 if(!prs_uint32("ptr_net_name", ps, depth, &ss1->ptr_net_name))
1101 return False;
1103 return True;
1106 /*******************************************************************
1107 Reads or writes a structure.
1108 ********************************************************************/
1110 static BOOL srv_io_srv_conn_info_1(char *desc, SRV_CONN_INFO_1 *ss1, prs_struct *ps, int depth)
1112 if (ss1 == NULL)
1113 return False;
1115 prs_debug(ps, depth, desc, "srv_io_srv_conn_info_1");
1116 depth++;
1118 if(!prs_align(ps))
1119 return False;
1121 if(!prs_uint32("num_entries_read", ps, depth, &ss1->num_entries_read))
1122 return False;
1123 if(!prs_uint32("ptr_conn_info", ps, depth, &ss1->ptr_conn_info))
1124 return False;
1126 if (ss1->ptr_conn_info != 0) {
1127 int i;
1128 int num_entries = ss1->num_entries_read;
1130 if (num_entries > MAX_CONN_ENTRIES) {
1131 num_entries = MAX_CONN_ENTRIES; /* report this! */
1134 if(!prs_uint32("num_entries_read2", ps, depth, &ss1->num_entries_read2))
1135 return False;
1137 for (i = 0; i < num_entries; i++) {
1138 if(!srv_io_conn_info1("", &ss1->info_1[i], ps, depth))
1139 return False;
1142 for (i = 0; i < num_entries; i++) {
1143 if(!srv_io_conn_info1_str("", &ss1->info_1_str[i], ps, depth))
1144 return False;
1147 if(!prs_align(ps))
1148 return False;
1151 return True;
1154 /*******************************************************************
1155 Reads or writes a structure.
1156 ********************************************************************/
1158 static BOOL srv_io_srv_conn_ctr(char *desc, SRV_CONN_INFO_CTR *ctr, prs_struct *ps, int depth)
1160 if (ctr == NULL)
1161 return False;
1163 prs_debug(ps, depth, desc, "srv_io_srv_conn_ctr");
1164 depth++;
1166 if(!prs_align(ps))
1167 return False;
1169 if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
1170 return False;
1171 if(!prs_uint32("ptr_conn_ctr", ps, depth, &ctr->ptr_conn_ctr))
1172 return False;
1174 if (ctr->ptr_conn_ctr != 0) {
1175 switch (ctr->switch_value) {
1176 case 0:
1177 if(!srv_io_srv_conn_info_0("", &ctr->conn.info0, ps, depth))
1178 return False;
1179 break;
1180 case 1:
1181 if(!srv_io_srv_conn_info_1("", &ctr->conn.info1, ps, depth))
1182 return False;
1183 break;
1184 default:
1185 DEBUG(5,("%s no connection info at switch_value %d\n",
1186 tab_depth(depth), ctr->switch_value));
1187 break;
1191 return True;
1194 /*******************************************************************
1195 Reads or writes a structure.
1196 ********************************************************************/
1198 void init_srv_q_net_conn_enum(SRV_Q_NET_CONN_ENUM *q_n,
1199 char *srv_name, char *qual_name,
1200 uint32 conn_level, SRV_CONN_INFO_CTR *ctr,
1201 uint32 preferred_len,
1202 ENUM_HND *hnd)
1204 DEBUG(5,("init_q_net_conn_enum\n"));
1206 q_n->ctr = ctr;
1208 init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name );
1209 init_buf_unistr2(&q_n->uni_qual_name, &q_n->ptr_qual_name, qual_name);
1211 q_n->conn_level = conn_level;
1212 q_n->preferred_len = preferred_len;
1214 memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
1217 /*******************************************************************
1218 Reads or writes a structure.
1219 ********************************************************************/
1221 BOOL srv_io_q_net_conn_enum(char *desc, SRV_Q_NET_CONN_ENUM *q_n, prs_struct *ps, int depth)
1223 if (q_n == NULL)
1224 return False;
1226 prs_debug(ps, depth, desc, "srv_io_q_net_conn_enum");
1227 depth++;
1229 if(!prs_align(ps))
1230 return False;
1232 if(!prs_uint32("ptr_srv_name ", ps, depth, &q_n->ptr_srv_name))
1233 return False;
1234 if(!smb_io_unistr2("", &q_n->uni_srv_name, q_n->ptr_srv_name, ps, depth))
1235 return False;
1237 if(!prs_align(ps))
1238 return False;
1240 if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
1241 return False;
1242 if(!smb_io_unistr2("", &q_n->uni_qual_name, q_n->ptr_qual_name, ps, depth))
1243 return False;
1245 if(!prs_align(ps))
1246 return False;
1248 if(!prs_uint32("conn_level", ps, depth, &q_n->conn_level))
1249 return False;
1251 if (q_n->conn_level != -1) {
1252 if(!srv_io_srv_conn_ctr("conn_ctr", q_n->ctr, ps, depth))
1253 return False;
1256 if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
1257 return False;
1259 if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
1260 return False;
1262 return True;
1265 /*******************************************************************
1266 Reads or writes a structure.
1267 ********************************************************************/
1269 BOOL srv_io_r_net_conn_enum(char *desc, SRV_R_NET_CONN_ENUM *r_n, prs_struct *ps, int depth)
1271 if (r_n == NULL)
1272 return False;
1274 prs_debug(ps, depth, desc, "srv_io_r_net_conn_enum");
1275 depth++;
1277 if(!prs_align(ps))
1278 return False;
1280 if(!prs_uint32("conn_level", ps, depth, &r_n->conn_level))
1281 return False;
1283 if (r_n->conn_level != -1) {
1284 if(!srv_io_srv_conn_ctr("conn_ctr", r_n->ctr, ps, depth))
1285 return False;
1288 if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
1289 return False;
1290 if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
1291 return False;
1292 if(!prs_uint32("status ", ps, depth, &r_n->status))
1293 return False;
1295 return True;
1298 /*******************************************************************
1299 Inits a FILE_INFO_3_STR structure
1300 ********************************************************************/
1302 void init_srv_file_info3_str(FILE_INFO_3_STR *fi3, char *user_name, char *path_name)
1304 DEBUG(5,("init_srv_file_info3_str\n"));
1306 init_unistr2(&fi3->uni_path_name, path_name, strlen(path_name)+1);
1307 init_unistr2(&fi3->uni_user_name, user_name, strlen(user_name)+1);
1310 /*******************************************************************
1311 Reads or writes a structure.
1312 ********************************************************************/
1314 static BOOL srv_io_file_info3_str(char *desc, FILE_INFO_3_STR *sh1, prs_struct *ps, int depth)
1316 if (sh1 == NULL)
1317 return False;
1319 prs_debug(ps, depth, desc, "srv_io_file_info3_str");
1320 depth++;
1322 if(!prs_align(ps))
1323 return False;
1325 if(!smb_io_unistr2("", &sh1->uni_path_name, True, ps, depth))
1326 return False;
1327 if(!smb_io_unistr2("", &sh1->uni_user_name, True, ps, depth))
1328 return False;
1330 return True;
1333 /*******************************************************************
1334 Inits a FILE_INFO_3 structure
1335 ********************************************************************/
1337 void init_srv_file_info3(FILE_INFO_3 *fl3,
1338 uint32 id, uint32 perms, uint32 num_locks,
1339 char *path_name, char *user_name)
1341 DEBUG(5,("init_srv_file_info3: %s %s\n", path_name, user_name));
1343 fl3->id = id;
1344 fl3->perms = perms;
1345 fl3->num_locks = num_locks;
1347 fl3->ptr_path_name = (path_name != NULL) ? 1 : 0;
1348 fl3->ptr_user_name = (user_name != NULL) ? 1 : 0;
1351 /*******************************************************************
1352 Reads or writes a structure.
1353 ********************************************************************/
1355 static BOOL srv_io_file_info3(char *desc, FILE_INFO_3 *fl3, prs_struct *ps, int depth)
1357 if (fl3 == NULL)
1358 return False;
1360 prs_debug(ps, depth, desc, "srv_io_file_info3");
1361 depth++;
1363 if(!prs_align(ps))
1364 return False;
1366 if(!prs_uint32("id ", ps, depth, &fl3->id))
1367 return False;
1368 if(!prs_uint32("perms ", ps, depth, &fl3->perms))
1369 return False;
1370 if(!prs_uint32("num_locks ", ps, depth, &fl3->num_locks))
1371 return False;
1372 if(!prs_uint32("ptr_path_name", ps, depth, &fl3->ptr_path_name))
1373 return False;
1374 if(!prs_uint32("ptr_user_name", ps, depth, &fl3->ptr_user_name))
1375 return False;
1377 return True;
1380 /*******************************************************************
1381 Reads or writes a structure.
1382 ********************************************************************/
1384 static BOOL srv_io_srv_file_info_3(char *desc, SRV_FILE_INFO_3 *fl3, prs_struct *ps, int depth)
1386 if (fl3 == NULL)
1387 return False;
1389 prs_debug(ps, depth, desc, "srv_io_file_3_fl3");
1390 depth++;
1392 if(!prs_align(ps))
1393 return False;
1395 if(!prs_uint32("num_entries_read", ps, depth, &fl3->num_entries_read))
1396 return False;
1397 if(!prs_uint32("ptr_file_fl3", ps, depth, &fl3->ptr_file_info))
1398 return False;
1400 if (fl3->ptr_file_info != 0) {
1401 int i;
1402 int num_entries = fl3->num_entries_read;
1404 if (num_entries > MAX_FILE_ENTRIES) {
1405 num_entries = MAX_FILE_ENTRIES; /* report this! */
1408 if(!prs_uint32("num_entries_read2", ps, depth, &fl3->num_entries_read2))
1409 return False;
1411 for (i = 0; i < num_entries; i++) {
1412 if(!srv_io_file_info3("", &fl3->info_3[i], ps, depth))
1413 return False;
1416 for (i = 0; i < num_entries; i++) {
1417 if(!srv_io_file_info3_str("", &fl3->info_3_str[i], ps, depth))
1418 return False;
1421 if(!prs_align(ps))
1422 return False;
1425 return True;
1428 /*******************************************************************
1429 Reads or writes a structure.
1430 ********************************************************************/
1432 static BOOL srv_io_srv_file_ctr(char *desc, SRV_FILE_INFO_CTR *ctr, prs_struct *ps, int depth)
1434 if (ctr == NULL)
1435 return False;
1437 prs_debug(ps, depth, desc, "srv_io_srv_file_ctr");
1438 depth++;
1440 if(!prs_align(ps))
1441 return False;
1443 if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
1444 return False;
1445 if(!prs_uint32("ptr_file_ctr", ps, depth, &ctr->ptr_file_ctr))
1446 return False;
1448 if (ctr->ptr_file_ctr != 0) {
1449 switch (ctr->switch_value) {
1450 case 3:
1451 if(!srv_io_srv_file_info_3("", &ctr->file.info3, ps, depth))
1452 return False;
1453 break;
1454 default:
1455 DEBUG(5,("%s no file info at switch_value %d\n",
1456 tab_depth(depth), ctr->switch_value));
1457 break;
1461 return True;
1464 /*******************************************************************
1465 Inits a SRV_Q_NET_FILE_ENUM structure.
1466 ********************************************************************/
1468 void init_srv_q_net_file_enum(SRV_Q_NET_FILE_ENUM *q_n,
1469 char *srv_name, char *qual_name,
1470 uint32 file_level, SRV_FILE_INFO_CTR *ctr,
1471 uint32 preferred_len,
1472 ENUM_HND *hnd)
1474 DEBUG(5,("init_q_net_file_enum\n"));
1476 q_n->ctr = ctr;
1478 init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);
1479 init_buf_unistr2(&q_n->uni_qual_name, &q_n->ptr_qual_name, qual_name);
1481 q_n->file_level = file_level;
1482 q_n->preferred_len = preferred_len;
1484 memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));
1487 /*******************************************************************
1488 Reads or writes a structure.
1489 ********************************************************************/
1491 BOOL srv_io_q_net_file_enum(char *desc, SRV_Q_NET_FILE_ENUM *q_n, prs_struct *ps, int depth)
1493 if (q_n == NULL)
1494 return False;
1496 prs_debug(ps, depth, desc, "srv_io_q_net_file_enum");
1497 depth++;
1499 if(!prs_align(ps))
1500 return False;
1502 if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
1503 return False;
1504 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1505 return False;
1507 if(!prs_align(ps))
1508 return False;
1510 if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
1511 return False;
1512 if(!smb_io_unistr2("", &q_n->uni_qual_name, q_n->ptr_qual_name, ps, depth))
1513 return False;
1515 if(!prs_align(ps))
1516 return False;
1518 if(!prs_uint32("file_level", ps, depth, &q_n->file_level))
1519 return False;
1521 if (q_n->file_level != -1) {
1522 if(!srv_io_srv_file_ctr("file_ctr", q_n->ctr, ps, depth))
1523 return False;
1526 if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))
1527 return False;
1529 if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))
1530 return False;
1532 return True;
1535 /*******************************************************************
1536 Reads or writes a structure.
1537 ********************************************************************/
1539 BOOL srv_io_r_net_file_enum(char *desc, SRV_R_NET_FILE_ENUM *r_n, prs_struct *ps, int depth)
1541 if (r_n == NULL)
1542 return False;
1544 prs_debug(ps, depth, desc, "srv_io_r_net_file_enum");
1545 depth++;
1547 if(!prs_align(ps))
1548 return False;
1550 if(!prs_uint32("file_level", ps, depth, &r_n->file_level))
1551 return False;
1553 if (r_n->file_level != 0) {
1554 if(!srv_io_srv_file_ctr("file_ctr", r_n->ctr, ps, depth))
1555 return False;
1558 if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))
1559 return False;
1560 if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))
1561 return False;
1562 if(!prs_uint32("status ", ps, depth, &r_n->status))
1563 return False;
1565 return True;
1568 /*******************************************************************
1569 Inits a SRV_INFO_101 structure.
1570 ********************************************************************/
1572 void init_srv_info_101(SRV_INFO_101 *sv101, uint32 platform_id, char *name,
1573 uint32 ver_major, uint32 ver_minor,
1574 uint32 srv_type, char *comment)
1576 DEBUG(5,("init_srv_info_101\n"));
1578 sv101->platform_id = platform_id;
1579 init_buf_unistr2(&sv101->uni_name, &sv101->ptr_name, name);
1580 sv101->ver_major = ver_major;
1581 sv101->ver_minor = ver_minor;
1582 sv101->srv_type = srv_type;
1583 init_buf_unistr2(&sv101->uni_comment, &sv101->ptr_comment, comment);
1586 /*******************************************************************
1587 Reads or writes a SRV_INFO_101 structure.
1588 ********************************************************************/
1590 static BOOL srv_io_info_101(char *desc, SRV_INFO_101 *sv101, prs_struct *ps, int depth)
1592 if (sv101 == NULL)
1593 return False;
1595 prs_debug(ps, depth, desc, "srv_io_info_101");
1596 depth++;
1598 if(!prs_align(ps))
1599 return False;
1601 if(!prs_uint32("platform_id ", ps, depth, &sv101->platform_id))
1602 return False;
1603 if(!prs_uint32("ptr_name ", ps, depth, &sv101->ptr_name))
1604 return False;
1605 if(!prs_uint32("ver_major ", ps, depth, &sv101->ver_major))
1606 return False;
1607 if(!prs_uint32("ver_minor ", ps, depth, &sv101->ver_minor))
1608 return False;
1609 if(!prs_uint32("srv_type ", ps, depth, &sv101->srv_type))
1610 return False;
1611 if(!prs_uint32("ptr_comment ", ps, depth, &sv101->ptr_comment))
1612 return False;
1614 if(!prs_align(ps))
1615 return False;
1617 if(!smb_io_unistr2("uni_name ", &sv101->uni_name, True, ps, depth))
1618 return False;
1619 if(!smb_io_unistr2("uni_comment ", &sv101->uni_comment, True, ps, depth))
1620 return False;
1622 return True;
1625 /*******************************************************************
1626 Inits a SRV_INFO_102 structure.
1627 ********************************************************************/
1629 void init_srv_info_102(SRV_INFO_102 *sv102, uint32 platform_id, char *name,
1630 char *comment, uint32 ver_major, uint32 ver_minor,
1631 uint32 srv_type, uint32 users, uint32 disc, uint32 hidden,
1632 uint32 announce, uint32 ann_delta, uint32 licenses,
1633 char *usr_path)
1635 DEBUG(5,("init_srv_info_102\n"));
1637 sv102->platform_id = platform_id;
1638 init_buf_unistr2(&sv102->uni_name, &sv102->ptr_name, name);
1639 sv102->ver_major = ver_major;
1640 sv102->ver_minor = ver_minor;
1641 sv102->srv_type = srv_type;
1642 init_buf_unistr2(&sv102->uni_comment, &sv102->ptr_comment, comment);
1644 /* same as 101 up to here */
1646 sv102->users = users;
1647 sv102->disc = disc;
1648 sv102->hidden = hidden;
1649 sv102->announce = announce;
1650 sv102->ann_delta =ann_delta;
1651 sv102->licenses = licenses;
1652 init_buf_unistr2(&sv102->uni_usr_path, &sv102->ptr_usr_path, usr_path);
1656 /*******************************************************************
1657 Reads or writes a SRV_INFO_102 structure.
1658 ********************************************************************/
1660 static BOOL srv_io_info_102(char *desc, SRV_INFO_102 *sv102, prs_struct *ps, int depth)
1662 if (sv102 == NULL)
1663 return False;
1665 prs_debug(ps, depth, desc, "srv_io_info102");
1666 depth++;
1668 if(!prs_align(ps))
1669 return False;
1671 if(!prs_uint32("platform_id ", ps, depth, &sv102->platform_id))
1672 return False;
1673 if(!prs_uint32("ptr_name ", ps, depth, &sv102->ptr_name))
1674 return False;
1675 if(!prs_uint32("ver_major ", ps, depth, &sv102->ver_major))
1676 return False;
1677 if(!prs_uint32("ver_minor ", ps, depth, &sv102->ver_minor))
1678 return False;
1679 if(!prs_uint32("srv_type ", ps, depth, &sv102->srv_type))
1680 return False;
1681 if(!prs_uint32("ptr_comment ", ps, depth, &sv102->ptr_comment))
1682 return False;
1684 /* same as 101 up to here */
1686 if(!prs_uint32("users ", ps, depth, &sv102->users))
1687 return False;
1688 if(!prs_uint32("disc ", ps, depth, &sv102->disc))
1689 return False;
1690 if(!prs_uint32("hidden ", ps, depth, &sv102->hidden))
1691 return False;
1692 if(!prs_uint32("announce ", ps, depth, &sv102->announce))
1693 return False;
1694 if(!prs_uint32("ann_delta ", ps, depth, &sv102->ann_delta))
1695 return False;
1696 if(!prs_uint32("licenses ", ps, depth, &sv102->licenses))
1697 return False;
1698 if(!prs_uint32("ptr_usr_path", ps, depth, &sv102->ptr_usr_path))
1699 return False;
1701 if(!smb_io_unistr2("uni_name ", &sv102->uni_name, True, ps, depth))
1702 return False;
1703 if(!prs_align(ps))
1704 return False;
1705 if(!smb_io_unistr2("uni_comment ", &sv102->uni_comment, True, ps, depth))
1706 return False;
1707 if(!prs_align(ps))
1708 return False;
1709 if(!smb_io_unistr2("uni_usr_path", &sv102->uni_usr_path, True, ps, depth))
1710 return False;
1712 return True;
1715 /*******************************************************************
1716 Reads or writes a SRV_INFO_102 structure.
1717 ********************************************************************/
1719 static BOOL srv_io_info_ctr(char *desc, SRV_INFO_CTR *ctr, prs_struct *ps, int depth)
1721 if (ctr == NULL)
1722 return False;
1724 prs_debug(ps, depth, desc, "srv_io_info_ctr");
1725 depth++;
1727 if(!prs_align(ps))
1728 return False;
1730 if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))
1731 return False;
1732 if(!prs_uint32("ptr_srv_ctr ", ps, depth, &ctr->ptr_srv_ctr))
1733 return False;
1735 if (ctr->ptr_srv_ctr != 0 && ctr->switch_value != 0 && ctr != NULL) {
1736 switch (ctr->switch_value) {
1737 case 101:
1738 if(!srv_io_info_101("sv101", &ctr->srv.sv101, ps, depth))
1739 return False;
1740 break;
1741 case 102:
1742 if(!srv_io_info_102("sv102", &ctr->srv.sv102, ps, depth))
1743 return False;
1744 break;
1745 default:
1746 DEBUG(5,("%s no server info at switch_value %d\n",
1747 tab_depth(depth), ctr->switch_value));
1748 break;
1750 if(!prs_align(ps))
1751 return False;
1754 return True;
1757 /*******************************************************************
1758 Inits a SRV_Q_NET_SRV_GET_INFO structure.
1759 ********************************************************************/
1761 void init_srv_q_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *srv,
1762 char *server_name, uint32 switch_value)
1764 DEBUG(5,("init_srv_q_net_srv_get_info\n"));
1766 init_buf_unistr2(&srv->uni_srv_name, &srv->ptr_srv_name, server_name);
1768 srv->switch_value = switch_value;
1771 /*******************************************************************
1772 Reads or writes a structure.
1773 ********************************************************************/
1775 BOOL srv_io_q_net_srv_get_info(char *desc, SRV_Q_NET_SRV_GET_INFO *q_n, prs_struct *ps, int depth)
1777 if (q_n == NULL)
1778 return False;
1780 prs_debug(ps, depth, desc, "srv_io_q_net_srv_get_info");
1781 depth++;
1783 if(!prs_align(ps))
1784 return False;
1786 if(!prs_uint32("ptr_srv_name ", ps, depth, &q_n->ptr_srv_name))
1787 return False;
1788 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1789 return False;
1791 if(!prs_align(ps))
1792 return False;
1794 if(!prs_uint32("switch_value ", ps, depth, &q_n->switch_value))
1795 return False;
1797 return True;
1800 /*******************************************************************
1801 Inits a SRV_R_NET_SRV_GET_INFO structure.
1802 ********************************************************************/
1804 void init_srv_r_net_srv_get_info(SRV_R_NET_SRV_GET_INFO *srv,
1805 uint32 switch_value, SRV_INFO_CTR *ctr, uint32 status)
1807 DEBUG(5,("init_srv_r_net_srv_get_info\n"));
1809 srv->ctr = ctr;
1811 if (status == 0x0) {
1812 srv->ctr->switch_value = switch_value;
1813 srv->ctr->ptr_srv_ctr = 1;
1814 } else {
1815 srv->ctr->switch_value = 0;
1816 srv->ctr->ptr_srv_ctr = 0;
1819 srv->status = status;
1822 /*******************************************************************
1823 Reads or writes a structure.
1824 ********************************************************************/
1826 BOOL srv_io_r_net_srv_get_info(char *desc, SRV_R_NET_SRV_GET_INFO *r_n, prs_struct *ps, int depth)
1828 if (r_n == NULL)
1829 return False;
1831 prs_debug(ps, depth, desc, "srv_io_r_net_srv_get_info");
1832 depth++;
1834 if(!prs_align(ps))
1835 return False;
1837 if(!srv_io_info_ctr("ctr", r_n->ctr, ps, depth))
1838 return False;
1840 if(!prs_uint32("status ", ps, depth, &r_n->status))
1841 return False;
1843 return True;
1847 /*******************************************************************
1848 Reads or writes a structure.
1849 ********************************************************************/
1851 BOOL srv_io_q_net_remote_tod(char *desc, SRV_Q_NET_REMOTE_TOD *q_n, prs_struct *ps, int depth)
1853 if (q_n == NULL)
1854 return False;
1856 prs_debug(ps, depth, desc, "srv_io_q_net_remote_tod");
1857 depth++;
1859 if(!prs_align(ps))
1860 return False;
1862 if(!prs_uint32("ptr_srv_name ", ps, depth, &q_n->ptr_srv_name))
1863 return False;
1864 if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
1865 return False;
1867 return True;
1870 /*******************************************************************
1871 Reads or writes a TIME_OF_DAY_INFO structure.
1872 ********************************************************************/
1874 static BOOL srv_io_time_of_day_info(char *desc, TIME_OF_DAY_INFO *tod, prs_struct *ps, int depth)
1876 if (tod == NULL)
1877 return False;
1879 prs_debug(ps, depth, desc, "srv_io_time_of_day_info");
1880 depth++;
1882 if(!prs_align(ps))
1883 return False;
1885 if(!prs_uint32("elapsedt ", ps, depth, &tod->elapsedt))
1886 return False;
1887 if(!prs_uint32("msecs ", ps, depth, &tod->msecs))
1888 return False;
1889 if(!prs_uint32("hours ", ps, depth, &tod->hours))
1890 return False;
1891 if(!prs_uint32("mins ", ps, depth, &tod->mins))
1892 return False;
1893 if(!prs_uint32("secs ", ps, depth, &tod->secs))
1894 return False;
1895 if(!prs_uint32("hunds ", ps, depth, &tod->hunds))
1896 return False;
1897 if(!prs_uint32("timezone ", ps, depth, &tod->zone))
1898 return False;
1899 if(!prs_uint32("tintervals ", ps, depth, &tod->tintervals))
1900 return False;
1901 if(!prs_uint32("day ", ps, depth, &tod->day))
1902 return False;
1903 if(!prs_uint32("month ", ps, depth, &tod->month))
1904 return False;
1905 if(!prs_uint32("year ", ps, depth, &tod->year))
1906 return False;
1907 if(!prs_uint32("weekday ", ps, depth, &tod->weekday))
1908 return False;
1910 return True;
1913 /*******************************************************************
1914 Inits a TIME_OF_DAY_INFO structure.
1915 ********************************************************************/
1917 void init_time_of_day_info(TIME_OF_DAY_INFO *tod, uint32 elapsedt, uint32 msecs,
1918 uint32 hours, uint32 mins, uint32 secs, uint32 hunds,
1919 uint32 zone, uint32 tintervals, uint32 day,
1920 uint32 month, uint32 year, uint32 weekday)
1922 DEBUG(5,("init_time_of_day_info\n"));
1924 tod->elapsedt = elapsedt;
1925 tod->msecs = msecs;
1926 tod->hours = hours;
1927 tod->mins = mins;
1928 tod->secs = secs;
1929 tod->hunds = hunds;
1930 tod->zone = zone;
1931 tod->tintervals = tintervals;
1932 tod->day = day;
1933 tod->month = month;
1934 tod->year = year;
1935 tod->weekday = weekday;
1939 /*******************************************************************
1940 Reads or writes a structure.
1941 ********************************************************************/
1943 BOOL srv_io_r_net_remote_tod(char *desc, SRV_R_NET_REMOTE_TOD *r_n, prs_struct *ps, int depth)
1945 if (r_n == NULL)
1946 return False;
1948 prs_debug(ps, depth, desc, "srv_io_r_net_remote_tod");
1949 depth++;
1951 if(!prs_align(ps))
1952 return False;
1954 if(!prs_uint32("ptr_srv_tod ", ps, depth, &r_n->ptr_srv_tod))
1955 return False;
1957 if(!srv_io_time_of_day_info("tod", r_n->tod, ps, depth))
1958 return False;
1960 if(!prs_uint32("status ", ps, depth, &r_n->status))
1961 return False;
1963 return True;