make proto
[Samba/gbeck.git] / source / rpc_server / srv_srvsvc_nt.c
blob061c70454f709d861dc593c9d6014350df4d7e90
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 2001.
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 /* This is the implementation of the srvsvc pipe. */
27 #include "includes.h"
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)
38 int len_net_name;
39 pstring net_name;
40 pstring remark;
41 uint32 type;
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))
52 type = STYPE_PRINTQ;
53 if (strequal("IPC", lp_fstype(snum)))
54 type = STYPE_IPC;
55 if (net_name[len_net_name] == '$')
56 type |= STYPE_HIDDEN;
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)
68 int len_net_name;
69 pstring net_name;
70 pstring remark;
71 pstring path;
72 pstring passwd;
73 uint32 type;
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));
79 pstrcpy(passwd, "");
80 len_net_name = strlen(net_name);
82 /* work out the share type */
83 type = STYPE_DISKTREE;
85 if (lp_print_ok(snum))
86 type = STYPE_PRINTQ;
87 if (strequal("IPC", lp_fstype(snum)))
88 type = STYPE_IPC;
89 if (net_name[len_net_name] == '$')
90 type |= STYPE_HIDDEN;
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 level 1005 structure.
98 ***************************************************************************/
100 static void init_srv_share_info_1005(SRV_SHARE_INFO_1005* sh1005, int snum)
102 sh1005->dfs_root_flag = 0;
104 #ifdef WITH_MSDFS
105 if(lp_host_msdfs() && lp_msdfs_root(snum))
106 sh1005->dfs_root_flag = 3;
107 #endif
111 /*******************************************************************
112 Fill in a share info structure.
113 ********************************************************************/
115 static BOOL init_srv_share_info_ctr(TALLOC_CTX *ctx, SRV_SHARE_INFO_CTR *ctr,
116 uint32 info_level, uint32 *resume_hnd, uint32 *total_entries)
118 int num_entries = 0;
119 int num_services = lp_numservices();
120 int snum;
122 DEBUG(5,("init_srv_share_info_ctr\n"));
124 ZERO_STRUCTPN(ctr);
126 ctr->info_level = ctr->switch_value = info_level;
127 *resume_hnd = 0;
129 /* Count the number of entries. */
130 for (snum = 0; snum < num_services; snum++) {
131 if (lp_browseable(snum) && lp_snum_ok(snum))
132 num_entries++;
135 *total_entries = num_entries;
136 ctr->num_entries2 = ctr->num_entries = num_entries;
137 ctr->ptr_share_info = ctr->ptr_entries = 1;
139 if (!num_entries)
140 return True;
142 switch (info_level) {
143 case 1:
145 SRV_SHARE_INFO_1 *info1;
146 int i = 0;
148 info1 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_1));
150 for (snum = *resume_hnd; snum < num_services; snum++) {
151 if (lp_browseable(snum) && lp_snum_ok(snum)) {
152 init_srv_share_info_1(&info1[i++], snum);
156 ctr->share.info1 = info1;
157 break;
160 case 2:
162 SRV_SHARE_INFO_2 *info2;
163 int i = 0;
165 info2 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_2));
167 for (snum = *resume_hnd; snum < num_services; snum++) {
168 if (lp_browseable(snum) && lp_snum_ok(snum)) {
169 init_srv_share_info_2(&info2[i++], snum);
173 ctr->share.info2 = info2;
174 break;
177 default:
178 DEBUG(5,("init_srv_share_info_ctr: unsupported switch value %d\n", info_level));
179 return False;
182 return True;
185 /*******************************************************************
186 Inits a SRV_R_NET_SHARE_ENUM structure.
187 ********************************************************************/
189 static void init_srv_r_net_share_enum(TALLOC_CTX *ctx, SRV_R_NET_SHARE_ENUM *r_n,
190 uint32 info_level, uint32 resume_hnd)
192 DEBUG(5,("init_srv_r_net_share_enum: %d\n", __LINE__));
194 if (init_srv_share_info_ctr(ctx, &r_n->ctr, info_level,
195 &resume_hnd, &r_n->total_entries)) {
196 r_n->status = NT_STATUS_NOPROBLEMO;
197 } else {
198 r_n->status = NT_STATUS_INVALID_INFO_CLASS;
201 init_enum_hnd(&r_n->enum_hnd, resume_hnd);
204 /*******************************************************************
205 Inits a SRV_R_NET_SHARE_GET_INFO structure.
206 ********************************************************************/
208 static void init_srv_r_net_share_get_info(SRV_R_NET_SHARE_GET_INFO *r_n,
209 char *share_name, uint32 info_level)
211 uint32 status = NT_STATUS_NOPROBLEMO;
212 int snum;
214 DEBUG(5,("init_srv_r_net_share_get_info: %d\n", __LINE__));
216 r_n->switch_value = info_level;
218 snum = find_service(share_name);
220 if (snum >= 0) {
221 switch (info_level) {
222 case 1:
223 init_srv_share_info_1(&r_n->share.info1, snum);
224 break;
225 case 2:
226 init_srv_share_info_2(&r_n->share.info2, snum);
227 break;
228 case 1005:
229 init_srv_share_info_1005(&r_n->share.info1005, snum);
230 break;
231 default:
232 DEBUG(5,("init_srv_net_share_get_info: unsupported switch value %d\n", info_level));
233 status = NT_STATUS_INVALID_INFO_CLASS;
234 break;
236 } else {
237 status = NT_STATUS_BAD_NETWORK_NAME;
240 r_n->ptr_share_ctr = (status == NT_STATUS_NOPROBLEMO) ? 1 : 0;
241 r_n->status = status;
244 /*******************************************************************
245 fill in a sess info level 1 structure.
246 ********************************************************************/
248 static void init_srv_sess_0_info(SESS_INFO_0 *se0, SESS_INFO_0_STR *str0, char *name)
250 init_srv_sess_info0(se0, name);
251 init_srv_sess_info0_str(str0, name);
254 /*******************************************************************
255 fill in a sess info level 0 structure.
256 ********************************************************************/
258 static void init_srv_sess_info_0(SRV_SESS_INFO_0 *ss0, uint32 *snum, uint32 *stot)
260 uint32 num_entries = 0;
261 (*stot) = 1;
263 if (ss0 == NULL) {
264 (*snum) = 0;
265 return;
268 DEBUG(5,("init_srv_sess_0_ss0\n"));
270 if (snum) {
271 for (; (*snum) < (*stot) && num_entries < MAX_SESS_ENTRIES; (*snum)++) {
272 init_srv_sess_0_info(&ss0->info_0[num_entries],
273 &ss0->info_0_str[num_entries], "MACHINE");
275 /* move on to creating next session */
276 /* move on to creating next sess */
277 num_entries++;
280 ss0->num_entries_read = num_entries;
281 ss0->ptr_sess_info = num_entries > 0 ? 1 : 0;
282 ss0->num_entries_read2 = num_entries;
284 if ((*snum) >= (*stot)) {
285 (*snum) = 0;
288 } else {
289 ss0->num_entries_read = 0;
290 ss0->ptr_sess_info = 0;
291 ss0->num_entries_read2 = 0;
295 /*******************************************************************
296 fill in a sess info level 1 structure.
297 ********************************************************************/
299 static void init_srv_sess_1_info(SESS_INFO_1 *se1, SESS_INFO_1_STR *str1,
300 char *name, char *user,
301 uint32 num_opens,
302 uint32 open_time, uint32 idle_time,
303 uint32 usr_flgs)
305 init_srv_sess_info1(se1 , name, user, num_opens, open_time, idle_time, usr_flgs);
306 init_srv_sess_info1_str(str1, name, user);
309 /*******************************************************************
310 fill in a sess info level 1 structure.
311 ********************************************************************/
313 static void init_srv_sess_info_1(SRV_SESS_INFO_1 *ss1, uint32 *snum, uint32 *stot)
315 uint32 num_entries = 0;
316 (*stot) = 1;
318 if (ss1 == NULL) {
319 (*snum) = 0;
320 return;
323 DEBUG(5,("init_srv_sess_1_ss1\n"));
325 if (snum) {
326 for (; (*snum) < (*stot) && num_entries < MAX_SESS_ENTRIES; (*snum)++) {
327 init_srv_sess_1_info(&ss1->info_1[num_entries],
328 &ss1->info_1_str[num_entries],
329 "MACHINE", "dummy_user", 1, 10, 5, 0);
331 /* move on to creating next session */
332 /* move on to creating next sess */
333 num_entries++;
336 ss1->num_entries_read = num_entries;
337 ss1->ptr_sess_info = num_entries > 0 ? 1 : 0;
338 ss1->num_entries_read2 = num_entries;
340 if ((*snum) >= (*stot)) {
341 (*snum) = 0;
344 } else {
345 ss1->num_entries_read = 0;
346 ss1->ptr_sess_info = 0;
347 ss1->num_entries_read2 = 0;
349 (*stot) = 0;
353 /*******************************************************************
354 makes a SRV_R_NET_SESS_ENUM structure.
355 ********************************************************************/
357 static uint32 init_srv_sess_info_ctr(SRV_SESS_INFO_CTR *ctr,
358 int switch_value, uint32 *resume_hnd, uint32 *total_entries)
360 uint32 status = NT_STATUS_NOPROBLEMO;
361 DEBUG(5,("init_srv_sess_info_ctr: %d\n", __LINE__));
363 ctr->switch_value = switch_value;
365 switch (switch_value) {
366 case 0:
367 init_srv_sess_info_0(&(ctr->sess.info0), resume_hnd, total_entries);
368 ctr->ptr_sess_ctr = 1;
369 break;
370 case 1:
371 init_srv_sess_info_1(&(ctr->sess.info1), resume_hnd, total_entries);
372 ctr->ptr_sess_ctr = 1;
373 break;
374 default:
375 DEBUG(5,("init_srv_sess_info_ctr: unsupported switch value %d\n", switch_value));
376 (*resume_hnd) = 0;
377 (*total_entries) = 0;
378 ctr->ptr_sess_ctr = 0;
379 status = NT_STATUS_INVALID_INFO_CLASS;
380 break;
383 return status;
386 /*******************************************************************
387 makes a SRV_R_NET_SESS_ENUM structure.
388 ********************************************************************/
390 static void init_srv_r_net_sess_enum(SRV_R_NET_SESS_ENUM *r_n,
391 uint32 resume_hnd, int sess_level, int switch_value)
393 DEBUG(5,("init_srv_r_net_sess_enum: %d\n", __LINE__));
395 r_n->sess_level = sess_level;
397 if (sess_level == -1)
398 r_n->status = NT_STATUS_INVALID_INFO_CLASS;
399 else
400 r_n->status = init_srv_sess_info_ctr(r_n->ctr, switch_value, &resume_hnd, &r_n->total_entries);
402 if (r_n->status != NT_STATUS_NOPROBLEMO)
403 resume_hnd = 0;
405 init_enum_hnd(&r_n->enum_hnd, resume_hnd);
408 /*******************************************************************
409 fill in a conn info level 0 structure.
410 ********************************************************************/
412 static void init_srv_conn_info_0(SRV_CONN_INFO_0 *ss0, uint32 *snum, uint32 *stot)
414 uint32 num_entries = 0;
415 (*stot) = 1;
417 if (ss0 == NULL) {
418 (*snum) = 0;
419 return;
422 DEBUG(5,("init_srv_conn_0_ss0\n"));
424 if (snum) {
425 for (; (*snum) < (*stot) && num_entries < MAX_CONN_ENTRIES; (*snum)++) {
427 init_srv_conn_info0(&ss0->info_0[num_entries], (*stot));
429 /* move on to creating next connection */
430 /* move on to creating next conn */
431 num_entries++;
434 ss0->num_entries_read = num_entries;
435 ss0->ptr_conn_info = num_entries > 0 ? 1 : 0;
436 ss0->num_entries_read2 = num_entries;
438 if ((*snum) >= (*stot)) {
439 (*snum) = 0;
442 } else {
443 ss0->num_entries_read = 0;
444 ss0->ptr_conn_info = 0;
445 ss0->num_entries_read2 = 0;
447 (*stot) = 0;
451 /*******************************************************************
452 fill in a conn info level 1 structure.
453 ********************************************************************/
455 static void init_srv_conn_1_info(CONN_INFO_1 *se1, CONN_INFO_1_STR *str1,
456 uint32 id, uint32 type,
457 uint32 num_opens, uint32 num_users, uint32 open_time,
458 char *usr_name, char *net_name)
460 init_srv_conn_info1(se1 , id, type, num_opens, num_users, open_time, usr_name, net_name);
461 init_srv_conn_info1_str(str1, usr_name, net_name);
464 /*******************************************************************
465 fill in a conn info level 1 structure.
466 ********************************************************************/
468 static void init_srv_conn_info_1(SRV_CONN_INFO_1 *ss1, uint32 *snum, uint32 *stot)
470 uint32 num_entries = 0;
471 (*stot) = 1;
473 if (ss1 == NULL) {
474 (*snum) = 0;
475 return;
478 DEBUG(5,("init_srv_conn_1_ss1\n"));
480 if (snum) {
481 for (; (*snum) < (*stot) && num_entries < MAX_CONN_ENTRIES; (*snum)++) {
482 init_srv_conn_1_info(&ss1->info_1[num_entries],
483 &ss1->info_1_str[num_entries],
484 (*stot), 0x3, 1, 1, 3,"dummy_user", "IPC$");
486 /* move on to creating next connection */
487 /* move on to creating next conn */
488 num_entries++;
491 ss1->num_entries_read = num_entries;
492 ss1->ptr_conn_info = num_entries > 0 ? 1 : 0;
493 ss1->num_entries_read2 = num_entries;
496 if ((*snum) >= (*stot)) {
497 (*snum) = 0;
500 } else {
501 ss1->num_entries_read = 0;
502 ss1->ptr_conn_info = 0;
503 ss1->num_entries_read2 = 0;
505 (*stot) = 0;
509 /*******************************************************************
510 makes a SRV_R_NET_CONN_ENUM structure.
511 ********************************************************************/
513 static uint32 init_srv_conn_info_ctr(SRV_CONN_INFO_CTR *ctr,
514 int switch_value, uint32 *resume_hnd, uint32 *total_entries)
516 uint32 status = NT_STATUS_NOPROBLEMO;
517 DEBUG(5,("init_srv_conn_info_ctr: %d\n", __LINE__));
519 ctr->switch_value = switch_value;
521 switch (switch_value) {
522 case 0:
523 init_srv_conn_info_0(&ctr->conn.info0, resume_hnd, total_entries);
524 ctr->ptr_conn_ctr = 1;
525 break;
526 case 1:
527 init_srv_conn_info_1(&ctr->conn.info1, resume_hnd, total_entries);
528 ctr->ptr_conn_ctr = 1;
529 break;
530 default:
531 DEBUG(5,("init_srv_conn_info_ctr: unsupported switch value %d\n", switch_value));
532 (*resume_hnd = 0);
533 (*total_entries) = 0;
534 ctr->ptr_conn_ctr = 0;
535 status = NT_STATUS_INVALID_INFO_CLASS;
536 break;
539 return status;
542 /*******************************************************************
543 makes a SRV_R_NET_CONN_ENUM structure.
544 ********************************************************************/
546 static void init_srv_r_net_conn_enum(SRV_R_NET_CONN_ENUM *r_n,
547 uint32 resume_hnd, int conn_level, int switch_value)
549 DEBUG(5,("init_srv_r_net_conn_enum: %d\n", __LINE__));
551 r_n->conn_level = conn_level;
552 if (conn_level == -1)
553 r_n->status = NT_STATUS_INVALID_INFO_CLASS;
554 else
555 r_n->status = init_srv_conn_info_ctr(r_n->ctr, switch_value, &resume_hnd, &r_n->total_entries);
557 if (r_n->status != NT_STATUS_NOPROBLEMO)
558 resume_hnd = 0;
560 init_enum_hnd(&r_n->enum_hnd, resume_hnd);
563 /*******************************************************************
564 fill in a file info level 3 structure.
565 ********************************************************************/
567 static void init_srv_file_3_info(FILE_INFO_3 *fl3, FILE_INFO_3_STR *str3,
568 uint32 fnum, uint32 perms, uint32 num_locks,
569 char *path_name, char *user_name)
571 init_srv_file_info3(fl3 , fnum, perms, num_locks, path_name, user_name);
572 init_srv_file_info3_str(str3, path_name, user_name);
575 /*******************************************************************
576 fill in a file info level 3 structure.
577 ********************************************************************/
579 static void init_srv_file_info_3(SRV_FILE_INFO_3 *fl3, uint32 *fnum, uint32 *ftot)
581 uint32 num_entries = 0;
582 (*ftot) = 1;
584 if (fl3 == NULL) {
585 (*fnum) = 0;
586 return;
589 DEBUG(5,("init_srv_file_3_fl3\n"));
591 for (; (*fnum) < (*ftot) && num_entries < MAX_FILE_ENTRIES; (*fnum)++) {
592 init_srv_file_3_info(&fl3->info_3[num_entries],
593 &fl3->info_3_str[num_entries],
594 (*fnum), 0x35, 0, "\\PIPE\\samr", "dummy user");
596 /* move on to creating next file */
597 num_entries++;
600 fl3->num_entries_read = num_entries;
601 fl3->ptr_file_info = num_entries > 0 ? 1 : 0;
602 fl3->num_entries_read2 = num_entries;
604 if ((*fnum) >= (*ftot)) {
605 (*fnum) = 0;
609 /*******************************************************************
610 makes a SRV_R_NET_FILE_ENUM structure.
611 ********************************************************************/
613 static uint32 init_srv_file_info_ctr(SRV_FILE_INFO_CTR *ctr,
614 int switch_value, uint32 *resume_hnd, uint32 *total_entries)
616 uint32 status = NT_STATUS_NOPROBLEMO;
617 DEBUG(5,("init_srv_file_info_ctr: %d\n", __LINE__));
619 ctr->switch_value = switch_value;
621 switch (switch_value) {
622 case 3:
623 init_srv_file_info_3(&ctr->file.info3, resume_hnd, total_entries);
624 ctr->ptr_file_ctr = 1;
625 break;
626 default:
627 DEBUG(5,("init_srv_file_info_ctr: unsupported switch value %d\n", switch_value));
628 (*resume_hnd = 0);
629 (*total_entries) = 0;
630 ctr->ptr_file_ctr = 0;
631 status = NT_STATUS_INVALID_INFO_CLASS;
632 break;
635 return status;
638 /*******************************************************************
639 makes a SRV_R_NET_FILE_ENUM structure.
640 ********************************************************************/
642 static void init_srv_r_net_file_enum(SRV_R_NET_FILE_ENUM *r_n,
643 uint32 resume_hnd, int file_level, int switch_value)
645 DEBUG(5,("init_srv_r_net_file_enum: %d\n", __LINE__));
647 r_n->file_level = file_level;
648 if (file_level == 0)
649 r_n->status = NT_STATUS_INVALID_INFO_CLASS;
650 else
651 r_n->status = init_srv_file_info_ctr(r_n->ctr, switch_value, &resume_hnd, &(r_n->total_entries));
653 if (r_n->status != NT_STATUS_NOPROBLEMO)
654 resume_hnd = 0;
656 init_enum_hnd(&r_n->enum_hnd, resume_hnd);
659 /*******************************************************************
660 net server get info
661 ********************************************************************/
663 uint32 _srv_net_srv_get_info(pipes_struct *p, SRV_Q_NET_SRV_GET_INFO *q_u, SRV_R_NET_SRV_GET_INFO *r_u)
665 uint32 status = NT_STATUS_NOPROBLEMO;
666 SRV_INFO_CTR *ctr = (SRV_INFO_CTR *)talloc(p->mem_ctx, sizeof(SRV_INFO_CTR));
668 if (!ctr)
669 return NT_STATUS_NO_MEMORY;
671 ZERO_STRUCTP(ctr);
673 DEBUG(5,("srv_net_srv_get_info: %d\n", __LINE__));
675 switch (q_u->switch_value) {
676 case 102:
677 init_srv_info_102(&ctr->srv.sv102,
678 500, global_myname,
679 string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH),
680 lp_major_announce_version(), lp_minor_announce_version(),
681 lp_default_server_announce(),
682 0xffffffff, /* users */
683 0xf, /* disc */
684 0, /* hidden */
685 240, /* announce */
686 3000, /* announce delta */
687 100000, /* licenses */
688 "c:\\"); /* user path */
689 break;
690 case 101:
691 init_srv_info_101(&ctr->srv.sv101,
692 500, global_myname,
693 lp_major_announce_version(), lp_minor_announce_version(),
694 lp_default_server_announce(),
695 string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH));
696 break;
697 case 100:
698 init_srv_info_100(&ctr->srv.sv100, 500, global_myname);
699 break;
700 default:
701 status = NT_STATUS_INVALID_INFO_CLASS;
702 break;
705 /* set up the net server get info structure */
706 init_srv_r_net_srv_get_info(r_u, q_u->switch_value, ctr, status);
708 DEBUG(5,("srv_net_srv_get_info: %d\n", __LINE__));
710 return r_u->status;
713 /*******************************************************************
714 net file enum
715 ********************************************************************/
717 uint32 _srv_net_file_enum(pipes_struct *p, SRV_Q_NET_FILE_ENUM *q_u, SRV_R_NET_FILE_ENUM *r_u)
719 r_u->ctr = (SRV_FILE_INFO_CTR *)talloc(p->mem_ctx, sizeof(SRV_FILE_INFO_CTR));
720 if (!r_u->ctr)
721 return NT_STATUS_NO_MEMORY;
723 ZERO_STRUCTP(r_u->ctr);
725 DEBUG(5,("srv_net_file_enum: %d\n", __LINE__));
727 /* set up the */
728 init_srv_r_net_file_enum(r_u,
729 get_enum_hnd(&q_u->enum_hnd),
730 q_u->file_level,
731 q_u->ctr->switch_value);
733 DEBUG(5,("srv_net_file_enum: %d\n", __LINE__));
735 return r_u->status;
738 /*******************************************************************
739 net conn enum
740 ********************************************************************/
742 uint32 _srv_net_conn_enum(pipes_struct *p, SRV_Q_NET_CONN_ENUM *q_u, SRV_R_NET_CONN_ENUM *r_u)
744 DEBUG(5,("srv_net_conn_enum: %d\n", __LINE__));
746 r_u->ctr = (SRV_CONN_INFO_CTR *)talloc(p->mem_ctx, sizeof(SRV_CONN_INFO_CTR));
747 if (!r_u->ctr)
748 return NT_STATUS_NO_MEMORY;
750 ZERO_STRUCTP(r_u->ctr);
752 /* set up the */
753 init_srv_r_net_conn_enum(r_u,
754 get_enum_hnd(&q_u->enum_hnd),
755 q_u->conn_level,
756 q_u->ctr->switch_value);
758 DEBUG(5,("srv_net_conn_enum: %d\n", __LINE__));
760 return r_u->status;
763 /*******************************************************************
764 net sess enum
765 ********************************************************************/
767 uint32 _srv_net_sess_enum(pipes_struct *p, SRV_Q_NET_SESS_ENUM *q_u, SRV_R_NET_SESS_ENUM *r_u)
769 DEBUG(5,("_srv_net_sess_enum: %d\n", __LINE__));
771 r_u->ctr = (SRV_SESS_INFO_CTR *)talloc(p->mem_ctx, sizeof(SRV_SESS_INFO_CTR));
772 if (!r_u->ctr)
773 return NT_STATUS_NO_MEMORY;
775 ZERO_STRUCTP(r_u->ctr);
777 /* set up the */
778 init_srv_r_net_sess_enum(r_u,
779 get_enum_hnd(&q_u->enum_hnd),
780 q_u->sess_level,
781 q_u->ctr->switch_value);
783 DEBUG(5,("_srv_net_sess_enum: %d\n", __LINE__));
785 return r_u->status;
788 /*******************************************************************
789 Net share enum.
790 ********************************************************************/
792 uint32 _srv_net_share_enum(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R_NET_SHARE_ENUM *r_u)
794 DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__));
796 /* Create the list of shares for the response. */
797 init_srv_r_net_share_enum(p->mem_ctx, r_u,
798 q_u->ctr.info_level,
799 get_enum_hnd(&q_u->enum_hnd));
801 DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__));
803 return r_u->status;
806 /*******************************************************************
807 Net share get info.
808 ********************************************************************/
810 uint32 _srv_net_share_get_info(pipes_struct *p, SRV_Q_NET_SHARE_GET_INFO *q_u, SRV_R_NET_SHARE_GET_INFO *r_u)
812 char *share_name;
814 DEBUG(5,("_srv_net_share_get_info: %d\n", __LINE__));
816 /* Create the list of shares for the response. */
817 share_name = dos_unistr2_to_str(&q_u->uni_share_name);
818 init_srv_r_net_share_get_info(r_u, share_name, q_u->info_level);
820 DEBUG(5,("_srv_net_share_get_info: %d\n", __LINE__));
822 return r_u->status;
825 /*******************************************************************
826 time of day
827 ********************************************************************/
829 uint32 _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_NET_REMOTE_TOD *r_u)
831 TIME_OF_DAY_INFO *tod;
832 struct tm *t;
833 time_t unixdate = time(NULL);
835 tod = (TIME_OF_DAY_INFO *)talloc(p->mem_ctx, sizeof(TIME_OF_DAY_INFO));
836 if (!tod)
837 return NT_STATUS_NO_MEMORY;
839 ZERO_STRUCTP(tod);
841 r_u->tod = tod;
842 r_u->ptr_srv_tod = 0x1;
843 r_u->status = NT_STATUS_NOPROBLEMO;
845 DEBUG(5,("_srv_net_remote_tod: %d\n", __LINE__));
847 t = gmtime(&unixdate);
849 /* set up the */
850 init_time_of_day_info(tod,
851 unixdate,
853 t->tm_hour,
854 t->tm_min,
855 t->tm_sec,
857 TimeDiff(unixdate)/60,
858 10000,
859 t->tm_mday,
860 t->tm_mon + 1,
861 1900+t->tm_year,
862 t->tm_wday);
864 DEBUG(5,("_srv_net_remote_tod: %d\n", __LINE__));
866 return r_u->status;