3 * Unix SMB/Netbios implementation.
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.
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.
29 extern int DEBUGLEVEL;
30 extern pstring global_myname;
32 /*******************************************************************
33 Fill in a share info level 1 structure.
34 ********************************************************************/
36 static void init_srv_share_info_1(SRV_SHARE_INFO_1 *sh1, int snum)
43 pstrcpy(net_name, lp_servicename(snum));
44 pstrcpy(remark, lp_comment(snum));
45 pstring_sub(remark,"%S",lp_servicename(snum));
46 len_net_name = strlen(net_name);
48 /* work out the share type */
49 type = STYPE_DISKTREE;
51 if (lp_print_ok(snum))
53 if (strequal("IPC$", net_name))
55 if (net_name[len_net_name] == '$')
58 init_srv_share_info1(&sh1->info_1, net_name, type, remark);
59 init_srv_share_info1_str(&sh1->info_1_str, net_name, remark);
62 /*******************************************************************
63 Fill in a share info level 2 structure.
64 ********************************************************************/
66 static void init_srv_share_info_2(SRV_SHARE_INFO_2 *sh2, int snum)
75 pstrcpy(net_name, lp_servicename(snum));
76 pstrcpy(remark, lp_comment(snum));
77 pstring_sub(remark,"%S",lp_servicename(snum));
78 pstrcpy(path, lp_pathname(snum));
80 len_net_name = strlen(net_name);
82 /* work out the share type */
83 type = STYPE_DISKTREE;
85 if (lp_print_ok(snum))
87 if (strequal("IPC$", net_name))
89 if (net_name[len_net_name] == '$')
92 init_srv_share_info2(&sh2->info_2, net_name, type, remark, 0, 0xffffffff, 1, path, passwd);
93 init_srv_share_info2_str(&sh2->info_2_str, net_name, remark, path, passwd);
96 /*******************************************************************
97 Fill in a share info structure.
98 ********************************************************************/
100 static BOOL init_srv_share_info_ctr(SRV_SHARE_INFO_CTR *ctr,
101 uint32 info_level, uint32 *resume_hnd, uint32 *total_entries)
104 int num_services = lp_numservices();
107 DEBUG(5,("init_srv_share_info_ctr\n"));
111 ctr->info_level = ctr->switch_value = info_level;
114 /* Count the number of entries. */
115 for (snum = 0; snum < num_services; snum++) {
116 if (lp_browseable(snum) && lp_snum_ok(snum))
120 *total_entries = num_entries;
121 ctr->num_entries2 = ctr->num_entries = num_entries;
122 ctr->ptr_share_info = ctr->ptr_entries = 1;
127 switch (info_level) {
130 SRV_SHARE_INFO_1 *info1;
133 info1 = malloc(num_entries * sizeof(SRV_SHARE_INFO_1));
135 for (snum = *resume_hnd; snum < num_services; snum++) {
136 if (lp_browseable(snum) && lp_snum_ok(snum)) {
137 init_srv_share_info_1(&info1[i++], snum);
141 ctr->share.info1 = info1;
147 SRV_SHARE_INFO_2 *info2;
150 info2 = malloc(num_entries * sizeof(SRV_SHARE_INFO_2));
152 for (snum = *resume_hnd; snum < num_services; snum++) {
153 if (lp_browseable(snum) && lp_snum_ok(snum)) {
154 init_srv_share_info_2(&info2[i++], snum);
158 ctr->share.info2 = info2;
163 DEBUG(5,("init_srv_share_info_ctr: unsupported switch value %d\n", info_level));
170 /*******************************************************************
171 Inits a SRV_R_NET_SHARE_ENUM structure.
172 ********************************************************************/
174 static void init_srv_r_net_share_enum(SRV_R_NET_SHARE_ENUM *r_n,
175 uint32 info_level, uint32 resume_hnd)
177 DEBUG(5,("init_srv_r_net_share_enum: %d\n", __LINE__));
179 if (init_srv_share_info_ctr(&r_n->ctr, info_level,
180 &resume_hnd, &r_n->total_entries)) {
183 r_n->status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS;
186 init_enum_hnd(&r_n->enum_hnd, resume_hnd);
189 /*******************************************************************
191 ********************************************************************/
193 static BOOL srv_reply_net_share_enum(SRV_Q_NET_SHARE_ENUM *q_n,
196 SRV_R_NET_SHARE_ENUM r_n;
199 DEBUG(5,("srv_net_share_enum: %d\n", __LINE__));
201 /* Create the list of shares for the response. */
202 init_srv_r_net_share_enum(&r_n,
204 get_enum_hnd(&q_n->enum_hnd));
206 /* store the response in the SMB stream */
207 ret = srv_io_r_net_share_enum("", &r_n, rdata, 0);
209 /* Free the memory used by the response. */
210 free_srv_r_net_share_enum(&r_n);
212 DEBUG(5,("srv_net_share_enum: %d\n", __LINE__));
217 /*******************************************************************
218 Inits a SRV_R_NET_SHARE_GET_INFO structure.
219 ********************************************************************/
221 static void init_srv_r_net_share_get_info(SRV_R_NET_SHARE_GET_INFO *r_n,
222 char *share_name, uint32 info_level)
227 DEBUG(5,("init_srv_r_net_share_get_info: %d\n", __LINE__));
229 r_n->switch_value = info_level;
231 snum = find_service(share_name);
234 switch (info_level) {
236 init_srv_share_info_1(&r_n->share.info1, snum);
239 init_srv_share_info_2(&r_n->share.info2, snum);
242 DEBUG(5,("init_srv_net_share_get_info: unsupported switch value %d\n", info_level));
243 status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS;
247 status = 0xC0000000 | NT_STATUS_BAD_NETWORK_NAME;
250 r_n->ptr_share_ctr = (status == 0x0) ? 1 : 0;
251 r_n->status = status;
254 /*******************************************************************
256 ********************************************************************/
258 static BOOL srv_reply_net_share_get_info(SRV_Q_NET_SHARE_GET_INFO *q_n,
261 SRV_R_NET_SHARE_GET_INFO r_n;
265 DEBUG(5,("srv_net_share_get_info: %d\n", __LINE__));
267 /* Create the list of shares for the response. */
268 share_name = dos_unistr2_to_str(&q_n->uni_share_name);
269 init_srv_r_net_share_get_info(&r_n, share_name, q_n->info_level);
271 /* store the response in the SMB stream */
272 ret = srv_io_r_net_share_get_info("", &r_n, rdata, 0);
274 /* Free the memory used by the response. */
275 free_srv_r_net_share_get_info(&r_n);
277 DEBUG(5,("srv_net_share_get_info: %d\n", __LINE__));
282 /*******************************************************************
283 fill in a sess info level 1 structure.
285 this function breaks the rule that i'd like to be in place, namely
286 it doesn't receive its data as arguments: it has to call lp_xxxx()
287 functions itself. yuck.
289 ********************************************************************/
290 static void init_srv_sess_0_info(SESS_INFO_0 *se0, SESS_INFO_0_STR *str0,
293 init_srv_sess_info0 (se0 , name);
294 init_srv_sess_info0_str(str0, name);
297 /*******************************************************************
298 fill in a sess info level 0 structure.
300 this function breaks the rule that i'd like to be in place, namely
301 it doesn't receive its data as arguments: it has to call lp_xxxx()
302 functions itself. yuck.
304 ********************************************************************/
305 static void init_srv_sess_info_0(SRV_SESS_INFO_0 *ss0, uint32 *snum, uint32 *stot)
307 uint32 num_entries = 0;
316 DEBUG(5,("init_srv_sess_0_ss0\n"));
320 for (; (*snum) < (*stot) && num_entries < MAX_SESS_ENTRIES; (*snum)++)
322 init_srv_sess_0_info(&(ss0->info_0 [num_entries]),
323 &(ss0->info_0_str[num_entries]), "MACHINE");
325 /* move on to creating next session */
326 /* move on to creating next sess */
330 ss0->num_entries_read = num_entries;
331 ss0->ptr_sess_info = num_entries > 0 ? 1 : 0;
332 ss0->num_entries_read2 = num_entries;
334 if ((*snum) >= (*stot))
341 ss0->num_entries_read = 0;
342 ss0->ptr_sess_info = 0;
343 ss0->num_entries_read2 = 0;
347 /*******************************************************************
348 fill in a sess info level 1 structure.
350 this function breaks the rule that i'd like to be in place, namely
351 it doesn't receive its data as arguments: it has to call lp_xxxx()
352 functions itself. yuck.
354 ********************************************************************/
355 static void init_srv_sess_1_info(SESS_INFO_1 *se1, SESS_INFO_1_STR *str1,
356 char *name, char *user,
358 uint32 open_time, uint32 idle_time,
361 init_srv_sess_info1 (se1 , name, user, num_opens, open_time, idle_time, usr_flgs);
362 init_srv_sess_info1_str(str1, name, user);
365 /*******************************************************************
366 fill in a sess info level 1 structure.
368 this function breaks the rule that i'd like to be in place, namely
369 it doesn't receive its data as arguments: it has to call lp_xxxx()
370 functions itself. yuck.
372 ********************************************************************/
373 static void init_srv_sess_info_1(SRV_SESS_INFO_1 *ss1, uint32 *snum, uint32 *stot)
375 uint32 num_entries = 0;
384 DEBUG(5,("init_srv_sess_1_ss1\n"));
388 for (; (*snum) < (*stot) && num_entries < MAX_SESS_ENTRIES; (*snum)++)
390 init_srv_sess_1_info(&(ss1->info_1 [num_entries]),
391 &(ss1->info_1_str[num_entries]),
392 "MACHINE", "dummy_user", 1, 10, 5, 0);
394 /* move on to creating next session */
395 /* move on to creating next sess */
399 ss1->num_entries_read = num_entries;
400 ss1->ptr_sess_info = num_entries > 0 ? 1 : 0;
401 ss1->num_entries_read2 = num_entries;
403 if ((*snum) >= (*stot))
410 ss1->num_entries_read = 0;
411 ss1->ptr_sess_info = 0;
412 ss1->num_entries_read2 = 0;
418 /*******************************************************************
419 makes a SRV_R_NET_SESS_ENUM structure.
420 ********************************************************************/
421 static uint32 init_srv_sess_info_ctr(SRV_SESS_INFO_CTR *ctr,
422 int switch_value, uint32 *resume_hnd, uint32 *total_entries)
425 DEBUG(5,("init_srv_sess_info_ctr: %d\n", __LINE__));
427 ctr->switch_value = switch_value;
429 switch (switch_value)
433 init_srv_sess_info_0(&(ctr->sess.info0), resume_hnd, total_entries);
434 ctr->ptr_sess_ctr = 1;
439 init_srv_sess_info_1(&(ctr->sess.info1), resume_hnd, total_entries);
440 ctr->ptr_sess_ctr = 1;
445 DEBUG(5,("init_srv_sess_info_ctr: unsupported switch value %d\n",
448 (*total_entries) = 0;
449 ctr->ptr_sess_ctr = 0;
450 status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS;
458 /*******************************************************************
459 makes a SRV_R_NET_SESS_ENUM structure.
460 ********************************************************************/
461 static void init_srv_r_net_sess_enum(SRV_R_NET_SESS_ENUM *r_n,
462 uint32 resume_hnd, int sess_level, int switch_value)
464 DEBUG(5,("init_srv_r_net_sess_enum: %d\n", __LINE__));
466 r_n->sess_level = sess_level;
467 if (sess_level == -1)
469 r_n->status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS;
473 r_n->status = init_srv_sess_info_ctr(r_n->ctr, switch_value, &resume_hnd, &r_n->total_entries);
475 if (r_n->status != 0x0)
479 init_enum_hnd(&(r_n->enum_hnd), resume_hnd);
482 /*******************************************************************
484 ********************************************************************/
485 static void srv_reply_net_sess_enum(SRV_Q_NET_SESS_ENUM *q_n,
488 SRV_R_NET_SESS_ENUM r_n;
489 SRV_SESS_INFO_CTR ctr;
493 DEBUG(5,("srv_net_sess_enum: %d\n", __LINE__));
496 init_srv_r_net_sess_enum(&r_n,
497 get_enum_hnd(&q_n->enum_hnd),
499 q_n->ctr->switch_value);
501 /* store the response in the SMB stream */
502 srv_io_r_net_sess_enum("", &r_n, rdata, 0);
504 DEBUG(5,("srv_net_sess_enum: %d\n", __LINE__));
507 /*******************************************************************
508 fill in a conn info level 0 structure.
510 this function breaks the rule that i'd like to be in place, namely
511 it doesn't receive its data as arguments: it has to call lp_xxxx()
512 functions itself. yuck.
514 ********************************************************************/
515 static void init_srv_conn_info_0(SRV_CONN_INFO_0 *ss0, uint32 *snum, uint32 *stot)
517 uint32 num_entries = 0;
526 DEBUG(5,("init_srv_conn_0_ss0\n"));
530 for (; (*snum) < (*stot) && num_entries < MAX_CONN_ENTRIES; (*snum)++)
532 init_srv_conn_info0(&(ss0->info_0 [num_entries]), (*stot));
534 /* move on to creating next connection */
535 /* move on to creating next conn */
539 ss0->num_entries_read = num_entries;
540 ss0->ptr_conn_info = num_entries > 0 ? 1 : 0;
541 ss0->num_entries_read2 = num_entries;
545 if ((*snum) >= (*stot))
552 ss0->num_entries_read = 0;
553 ss0->ptr_conn_info = 0;
554 ss0->num_entries_read2 = 0;
560 /*******************************************************************
561 fill in a conn info level 1 structure.
563 this function breaks the rule that i'd like to be in place, namely
564 it doesn't receive its data as arguments: it has to call lp_xxxx()
565 functions itself. yuck.
567 ********************************************************************/
568 static void init_srv_conn_1_info(CONN_INFO_1 *se1, CONN_INFO_1_STR *str1,
569 uint32 id, uint32 type,
570 uint32 num_opens, uint32 num_users, uint32 open_time,
571 char *usr_name, char *net_name)
573 init_srv_conn_info1 (se1 , id, type, num_opens, num_users, open_time, usr_name, net_name);
574 init_srv_conn_info1_str(str1, usr_name, net_name);
577 /*******************************************************************
578 fill in a conn info level 1 structure.
580 this function breaks the rule that i'd like to be in place, namely
581 it doesn't receive its data as arguments: it has to call lp_xxxx()
582 functions itself. yuck.
584 ********************************************************************/
585 static void init_srv_conn_info_1(SRV_CONN_INFO_1 *ss1, uint32 *snum, uint32 *stot)
587 uint32 num_entries = 0;
596 DEBUG(5,("init_srv_conn_1_ss1\n"));
600 for (; (*snum) < (*stot) && num_entries < MAX_CONN_ENTRIES; (*snum)++)
602 init_srv_conn_1_info(&(ss1->info_1 [num_entries]),
603 &(ss1->info_1_str[num_entries]),
604 (*stot), 0x3, 1, 1, 3,"dummy_user", "IPC$");
606 /* move on to creating next connection */
607 /* move on to creating next conn */
611 ss1->num_entries_read = num_entries;
612 ss1->ptr_conn_info = num_entries > 0 ? 1 : 0;
613 ss1->num_entries_read2 = num_entries;
616 if ((*snum) >= (*stot))
623 ss1->num_entries_read = 0;
624 ss1->ptr_conn_info = 0;
625 ss1->num_entries_read2 = 0;
631 /*******************************************************************
632 makes a SRV_R_NET_CONN_ENUM structure.
633 ********************************************************************/
634 static uint32 init_srv_conn_info_ctr(SRV_CONN_INFO_CTR *ctr,
635 int switch_value, uint32 *resume_hnd, uint32 *total_entries)
638 DEBUG(5,("init_srv_conn_info_ctr: %d\n", __LINE__));
640 ctr->switch_value = switch_value;
642 switch (switch_value)
646 init_srv_conn_info_0(&(ctr->conn.info0), resume_hnd, total_entries);
647 ctr->ptr_conn_ctr = 1;
652 init_srv_conn_info_1(&(ctr->conn.info1), resume_hnd, total_entries);
653 ctr->ptr_conn_ctr = 1;
658 DEBUG(5,("init_srv_conn_info_ctr: unsupported switch value %d\n",
661 (*total_entries) = 0;
662 ctr->ptr_conn_ctr = 0;
663 status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS;
671 /*******************************************************************
672 makes a SRV_R_NET_CONN_ENUM structure.
673 ********************************************************************/
674 static void init_srv_r_net_conn_enum(SRV_R_NET_CONN_ENUM *r_n,
675 uint32 resume_hnd, int conn_level, int switch_value)
677 DEBUG(5,("init_srv_r_net_conn_enum: %d\n", __LINE__));
679 r_n->conn_level = conn_level;
680 if (conn_level == -1)
682 r_n->status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS;
686 r_n->status = init_srv_conn_info_ctr(r_n->ctr, switch_value, &resume_hnd, &r_n->total_entries);
688 if (r_n->status != 0x0)
692 init_enum_hnd(&(r_n->enum_hnd), resume_hnd);
695 /*******************************************************************
697 ********************************************************************/
698 static void srv_reply_net_conn_enum(SRV_Q_NET_CONN_ENUM *q_n,
701 SRV_R_NET_CONN_ENUM r_n;
702 SRV_CONN_INFO_CTR ctr;
706 DEBUG(5,("srv_net_conn_enum: %d\n", __LINE__));
709 init_srv_r_net_conn_enum(&r_n,
710 get_enum_hnd(&q_n->enum_hnd),
712 q_n->ctr->switch_value);
714 /* store the response in the SMB stream */
715 srv_io_r_net_conn_enum("", &r_n, rdata, 0);
717 DEBUG(5,("srv_net_conn_enum: %d\n", __LINE__));
720 /*******************************************************************
721 fill in a file info level 3 structure.
722 ********************************************************************/
723 static void init_srv_file_3_info(FILE_INFO_3 *fl3, FILE_INFO_3_STR *str3,
724 uint32 fnum, uint32 perms, uint32 num_locks,
725 char *path_name, char *user_name)
727 init_srv_file_info3 (fl3 , fnum, perms, num_locks, path_name, user_name);
728 init_srv_file_info3_str(str3, path_name, user_name);
731 /*******************************************************************
732 fill in a file info level 3 structure.
734 this function breaks the rule that i'd like to be in place, namely
735 it doesn't receive its data as arguments: it has to call lp_xxxx()
736 functions itself. yuck.
738 ********************************************************************/
739 static void init_srv_file_info_3(SRV_FILE_INFO_3 *fl3, uint32 *fnum, uint32 *ftot)
741 uint32 num_entries = 0;
750 DEBUG(5,("init_srv_file_3_fl3\n"));
752 for (; (*fnum) < (*ftot) && num_entries < MAX_FILE_ENTRIES; (*fnum)++)
754 init_srv_file_3_info(&(fl3->info_3 [num_entries]),
755 &(fl3->info_3_str[num_entries]),
756 (*fnum), 0x35, 0, "\\PIPE\\samr", "dummy user");
758 /* move on to creating next file */
762 fl3->num_entries_read = num_entries;
763 fl3->ptr_file_info = num_entries > 0 ? 1 : 0;
764 fl3->num_entries_read2 = num_entries;
766 if ((*fnum) >= (*ftot))
772 /*******************************************************************
773 makes a SRV_R_NET_FILE_ENUM structure.
774 ********************************************************************/
775 static uint32 init_srv_file_info_ctr(SRV_FILE_INFO_CTR *ctr,
776 int switch_value, uint32 *resume_hnd, uint32 *total_entries)
779 DEBUG(5,("init_srv_file_info_ctr: %d\n", __LINE__));
781 ctr->switch_value = switch_value;
783 switch (switch_value)
787 init_srv_file_info_3(&(ctr->file.info3), resume_hnd, total_entries);
788 ctr->ptr_file_ctr = 1;
793 DEBUG(5,("init_srv_file_info_ctr: unsupported switch value %d\n",
796 (*total_entries) = 0;
797 ctr->ptr_file_ctr = 0;
798 status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS;
806 /*******************************************************************
807 makes a SRV_R_NET_FILE_ENUM structure.
808 ********************************************************************/
809 static void init_srv_r_net_file_enum(SRV_R_NET_FILE_ENUM *r_n,
810 uint32 resume_hnd, int file_level, int switch_value)
812 DEBUG(5,("init_srv_r_net_file_enum: %d\n", __LINE__));
814 r_n->file_level = file_level;
817 r_n->status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS;
821 r_n->status = init_srv_file_info_ctr(r_n->ctr, switch_value, &resume_hnd, &(r_n->total_entries));
823 if (r_n->status != 0x0)
827 init_enum_hnd(&(r_n->enum_hnd), resume_hnd);
830 /*******************************************************************
832 ********************************************************************/
833 static void srv_reply_net_file_enum(SRV_Q_NET_FILE_ENUM *q_n,
836 SRV_R_NET_FILE_ENUM r_n;
837 SRV_FILE_INFO_CTR ctr;
841 DEBUG(5,("srv_net_file_enum: %d\n", __LINE__));
844 init_srv_r_net_file_enum(&r_n,
845 get_enum_hnd(&q_n->enum_hnd),
847 q_n->ctr->switch_value);
849 /* store the response in the SMB stream */
850 srv_io_r_net_file_enum("", &r_n, rdata, 0);
852 DEBUG(5,("srv_net_file_enum: %d\n", __LINE__));
855 /*******************************************************************
857 ********************************************************************/
859 static void srv_reply_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *q_n,
862 SRV_R_NET_SRV_GET_INFO r_n;
867 DEBUG(5,("srv_net_srv_get_info: %d\n", __LINE__));
869 switch (q_n->switch_value)
873 init_srv_info_102(&ctr.srv.sv102,
875 string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH),
876 lp_major_announce_version(), lp_minor_announce_version(),
877 lp_default_server_announce(),
878 0xffffffff, /* users */
882 3000, /* announce delta */
883 100000, /* licenses */
884 "c:\\"); /* user path */
889 init_srv_info_101(&ctr.srv.sv101,
891 lp_major_announce_version(), lp_minor_announce_version(),
892 lp_default_server_announce(),
893 string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH));
898 status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS;
903 /* set up the net server get info structure */
904 init_srv_r_net_srv_get_info(&r_n, q_n->switch_value, &ctr, status);
906 /* store the response in the SMB stream */
907 srv_io_r_net_srv_get_info("", &r_n, rdata, 0);
909 DEBUG(5,("srv_net_srv_get_info: %d\n", __LINE__));
912 /*******************************************************************
913 ********************************************************************/
914 static BOOL api_srv_net_srv_get_info( uint16 vuid, prs_struct *data,
917 SRV_Q_NET_SRV_GET_INFO q_n;
919 /* grab the net server get info */
920 srv_io_q_net_srv_get_info("", &q_n, data, 0);
922 /* construct reply. always indicate success */
923 srv_reply_net_srv_get_info(&q_n, rdata);
929 /*******************************************************************
930 ********************************************************************/
931 static BOOL api_srv_net_file_enum( uint16 vuid, prs_struct *data,
934 SRV_Q_NET_FILE_ENUM q_n;
935 SRV_FILE_INFO_CTR ctr;
939 /* grab the net file enum */
940 srv_io_q_net_file_enum("", &q_n, data, 0);
942 /* construct reply. always indicate success */
943 srv_reply_net_file_enum(&q_n, rdata);
949 /*******************************************************************
950 ********************************************************************/
951 static BOOL api_srv_net_conn_enum( uint16 vuid, prs_struct *data,
954 SRV_Q_NET_CONN_ENUM q_n;
955 SRV_CONN_INFO_CTR ctr;
959 /* grab the net server get enum */
960 srv_io_q_net_conn_enum("", &q_n, data, 0);
962 /* construct reply. always indicate success */
963 srv_reply_net_conn_enum(&q_n, rdata);
969 /*******************************************************************
970 ********************************************************************/
971 static BOOL api_srv_net_sess_enum( uint16 vuid, prs_struct *data,
974 SRV_Q_NET_SESS_ENUM q_n;
975 SRV_SESS_INFO_CTR ctr;
979 /* grab the net server get enum */
980 srv_io_q_net_sess_enum("", &q_n, data, 0);
982 /* construct reply. always indicate success */
983 srv_reply_net_sess_enum(&q_n, rdata);
989 /*******************************************************************
990 RPC to enumerate shares.
991 ********************************************************************/
993 static BOOL api_srv_net_share_enum( uint16 vuid, prs_struct *data,
996 SRV_Q_NET_SHARE_ENUM q_n;
999 /* Unmarshall the net server get enum. */
1000 if(!srv_io_q_net_share_enum("", &q_n, data, 0)) {
1001 DEBUG(0,("api_srv_net_share_enum: Failed to unmarshall SRV_Q_NET_SHARE_ENUM.\n"));
1005 ret = srv_reply_net_share_enum(&q_n, rdata);
1007 /* Free any data allocated in the unmarshalling. */
1008 free_srv_q_net_share_enum(&q_n);
1013 /*******************************************************************
1014 RPC to return share information.
1015 ********************************************************************/
1017 static BOOL api_srv_net_share_get_info( uint16 vuid, prs_struct *data,
1020 SRV_Q_NET_SHARE_GET_INFO q_n;
1023 /* Unmarshall the net server get info. */
1024 if(!srv_io_q_net_share_get_info("", &q_n, data, 0)) {
1025 DEBUG(0,("api_srv_net_share_get_info: Failed to unmarshall SRV_Q_NET_SHARE_GET_INFO.\n"));
1029 ret = srv_reply_net_share_get_info(&q_n, rdata);
1031 /* Free any data allocated in the unmarshalling. */
1032 free_srv_q_net_share_get_info(&q_n);
1037 /*******************************************************************
1039 ********************************************************************/
1040 static BOOL srv_reply_net_remote_tod(SRV_Q_NET_REMOTE_TOD *q_n,
1043 SRV_R_NET_REMOTE_TOD r_n;
1044 TIME_OF_DAY_INFO tod;
1046 time_t unixdate = time(NULL);
1049 r_n.ptr_srv_tod = 0x1;
1052 DEBUG(5,("srv_reply_net_remote_tod: %d\n", __LINE__));
1054 t = gmtime(&unixdate);
1057 init_time_of_day_info(&tod,
1064 TimeDiff(unixdate)/60,
1071 /* store the response in the SMB stream */
1072 srv_io_r_net_remote_tod("", &r_n, rdata, 0);
1074 DEBUG(5,("srv_reply_net_remote_tod: %d\n", __LINE__));
1078 /*******************************************************************
1079 ********************************************************************/
1080 static BOOL api_srv_net_remote_tod( uint16 vuid, prs_struct *data,
1083 SRV_Q_NET_REMOTE_TOD q_n;
1085 /* grab the net server get enum */
1086 srv_io_q_net_remote_tod("", &q_n, data, 0);
1088 /* construct reply. always indicate success */
1089 srv_reply_net_remote_tod(&q_n, rdata);
1095 /*******************************************************************
1096 \PIPE\srvsvc commands
1097 ********************************************************************/
1098 struct api_struct api_srv_cmds[] =
1100 { "SRV_NETCONNENUM" , SRV_NETCONNENUM , api_srv_net_conn_enum },
1101 { "SRV_NETSESSENUM" , SRV_NETSESSENUM , api_srv_net_sess_enum },
1102 { "SRV_NETSHAREENUM" , SRV_NETSHAREENUM , api_srv_net_share_enum },
1103 { "SRV_NET_SHARE_GET_INFO", SRV_NET_SHARE_GET_INFO, api_srv_net_share_get_info },
1104 { "SRV_NETFILEENUM" , SRV_NETFILEENUM , api_srv_net_file_enum },
1105 { "SRV_NET_SRV_GET_INFO" , SRV_NET_SRV_GET_INFO , api_srv_net_srv_get_info },
1106 { "SRV_NET_REMOTE_TOD" , SRV_NET_REMOTE_TOD , api_srv_net_remote_tod },
1110 /*******************************************************************
1111 receives a srvsvc pipe and responds.
1112 ********************************************************************/
1113 BOOL api_srvsvc_rpc(pipes_struct *p, prs_struct *data)
1115 return api_rpcTNP(p, "api_srvsvc_rpc", api_srv_cmds, data);