This commit was manufactured by cvs2svn to create branch 'SAMBA_3_0'.(This used to...
[kai/samba.git] / source3 / rpc_server / srv_dfs.c
1 /* 
2  *  Unix SMB/CIFS implementation.
3  *  RPC Pipe client / server routines for Dfs
4  *  Copyright (C) Andrew Tridgell              1992-1997,
5  *  Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
6  *  Copyright (C) Shirish Kalele               2000.
7  *  Copyright (C) Jeremy Allison                                2001.
8  *  
9  *  This program is free software; you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License as published by
11  *  the Free Software Foundation; either version 2 of the License, or
12  *  (at your option) any later version.
13  *  
14  *  This program is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  *  
19  *  You should have received a copy of the GNU General Public License
20  *  along with this program; if not, write to the Free Software
21  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22  */
23
24 /* This is the interface to the dfs pipe. */
25
26 #include "includes.h"
27 #include "nterr.h"
28
29 #define MAX_MSDFS_JUNCTIONS 256
30
31 #undef DBGC_CLASS
32 #define DBGC_CLASS DBGC_RPC_SRV
33
34 /**********************************************************************
35  api_dfs_exist
36  **********************************************************************/
37
38 static BOOL api_dfs_exist(pipes_struct *p)
39 {
40         DFS_Q_DFS_EXIST q_u;
41         DFS_R_DFS_EXIST r_u;
42         prs_struct *data = &p->in_data.data;
43         prs_struct *rdata = &p->out_data.rdata;
44
45         if(!dfs_io_q_dfs_exist("", &q_u, data, 0))
46                 return False;
47         
48         r_u.status = _dfs_exist(p, &q_u, &r_u);
49         
50         if (!dfs_io_r_dfs_exist("", &r_u, rdata, 0))
51                 return False;
52
53         return True;
54 }
55
56 /*****************************************************************
57  api_dfs_add
58  *****************************************************************/
59
60 static BOOL api_dfs_add(pipes_struct *p)
61 {
62         DFS_Q_DFS_ADD q_u;
63         DFS_R_DFS_ADD r_u;
64         prs_struct *data = &p->in_data.data;
65         prs_struct *rdata = &p->out_data.rdata;
66
67         ZERO_STRUCT(q_u);
68         ZERO_STRUCT(r_u);
69         
70         if(!dfs_io_q_dfs_add("", &q_u, data, 0))
71                 return False;
72         
73         r_u.status = _dfs_add(p, &q_u, &r_u);
74         
75         if (!dfs_io_r_dfs_add("", &r_u, rdata, 0))
76                 return False;
77         
78         return True;
79 }
80
81 /*****************************************************************
82  api_dfs_remove
83  *****************************************************************/
84
85 static BOOL api_dfs_remove(pipes_struct *p)
86 {
87         DFS_Q_DFS_REMOVE q_u;
88         DFS_R_DFS_REMOVE r_u;
89         prs_struct *data = &p->in_data.data;
90         prs_struct *rdata = &p->out_data.rdata;
91         
92         ZERO_STRUCT(q_u);
93         ZERO_STRUCT(r_u);
94         
95         if(!dfs_io_q_dfs_remove("", &q_u, data, 0))
96                 return False;
97         
98         r_u.status = _dfs_remove(p, &q_u, &r_u);
99         
100         if (!dfs_io_r_dfs_remove("", &r_u, rdata, 0))
101                 return False;
102         
103         return True;
104 }
105
106 /*******************************************************************
107  api_dfs_get_info
108  *******************************************************************/
109
110 static BOOL api_dfs_get_info(pipes_struct *p)
111 {
112         DFS_Q_DFS_GET_INFO q_u;
113         DFS_R_DFS_GET_INFO r_u;
114         prs_struct *data = &p->in_data.data;
115         prs_struct *rdata = &p->out_data.rdata;
116
117         ZERO_STRUCT(q_u);
118         ZERO_STRUCT(r_u);
119         
120         if(!dfs_io_q_dfs_get_info("", &q_u, data, 0))
121                 return False;
122         
123         r_u.status = _dfs_get_info(p, &q_u, &r_u);
124         
125         if(!dfs_io_r_dfs_get_info("", &r_u, rdata, 0))
126                 return False;
127
128         return True;
129 }
130
131 /*******************************************************************
132  api_dfs_enum
133  *******************************************************************/
134
135 static BOOL api_dfs_enum(pipes_struct *p)
136 {
137         DFS_Q_DFS_ENUM q_u;
138         DFS_R_DFS_ENUM r_u;
139         prs_struct *data = &p->in_data.data;
140         prs_struct *rdata = &p->out_data.rdata;
141
142         ZERO_STRUCT(q_u);
143         ZERO_STRUCT(r_u);
144
145         if(!dfs_io_q_dfs_enum("", &q_u, data, 0))
146                 return False;
147         
148         r_u.status = _dfs_enum(p, &q_u, &r_u);
149         
150         if(!dfs_io_r_dfs_enum("", &r_u, rdata, 0))
151                 return False;
152
153         return True;
154 }
155
156 /*******************************************************************
157 \pipe\netdfs commands
158 ********************************************************************/
159
160 struct api_struct api_netdfs_cmds[] =
161 {
162         {"DFS_EXIST",        DFS_EXIST,               api_dfs_exist    },
163         {"DFS_ADD",          DFS_ADD,                 api_dfs_add      },
164         {"DFS_REMOVE",       DFS_REMOVE,              api_dfs_remove   },
165         {"DFS_GET_INFO",     DFS_GET_INFO,            api_dfs_get_info },
166         {"DFS_ENUM",         DFS_ENUM,                api_dfs_enum     },
167         {NULL,               0,                       NULL             }
168 };
169
170 /*******************************************************************
171 receives a netdfs pipe and responds.
172 ********************************************************************/
173
174 BOOL api_netdfs_rpc(pipes_struct *p)
175 {
176         return api_rpcTNP(p, "api_netdfs_rpc", api_netdfs_cmds);
177 }