Separated dfs pipe into implementation and interface modules.
[tprouty/samba.git] / source3 / rpc_server / srv_dfs.c
1 /* 
2  *  Unix SMB/Netbios implementation.
3  *  Version 1.9.
4  *  RPC Pipe client / server routines for Dfs
5  *  Copyright (C) Andrew Tridgell              1992-1997,
6  *  Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
7  *  Copyright (C) Shirish Kalele               2000.
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.
14  *  
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.
19  *  
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.
23  */
24
25 /* This is the interface to the dfs pipe. */
26
27 #include "includes.h"
28 #include "nterr.h"
29
30 #define MAX_MSDFS_JUNCTIONS 256
31
32 extern int DEBUGLEVEL;
33 extern pstring global_myname;
34
35 #ifdef WITH_MSDFS
36
37 /**********************************************************************
38  api_dfs_exist
39  **********************************************************************/
40
41 static BOOL api_dfs_exist(pipes_struct *p)
42 {
43         DFS_Q_DFS_EXIST q_u;
44         DFS_R_DFS_EXIST r_u;
45         prs_struct *data = &p->in_data.data;
46         prs_struct *rdata = &p->out_data.rdata;
47
48         if(!dfs_io_q_dfs_exist("", &q_u, data, 0))
49                 return False;
50         
51         r_u.status = _dfs_exist(p, &q_u, &r_u);
52         
53         if (!dfs_io_r_dfs_exist("", &r_u, rdata, 0))
54                 return False;
55
56         return True;
57 }
58
59 /*****************************************************************
60  api_dfs_add
61  *****************************************************************/
62
63 static BOOL api_dfs_add(pipes_struct *p)
64 {
65         DFS_Q_DFS_ADD q_u;
66         DFS_R_DFS_ADD r_u;
67         prs_struct *data = &p->in_data.data;
68         prs_struct *rdata = &p->out_data.rdata;
69
70         ZERO_STRUCT(q_u);
71         ZERO_STRUCT(r_u);
72         
73         if(!dfs_io_q_dfs_add("", &q_u, data, 0))
74                 return False;
75         
76         r_u.status = _dfs_add(p, &q_u, &r_u);
77         
78         if (!dfs_io_r_dfs_add("", &r_u, rdata, 0))
79                 return False;
80         
81         return True;
82 }
83
84 /*****************************************************************
85  api_dfs_remove
86  *****************************************************************/
87
88 static BOOL api_dfs_remove(pipes_struct *p)
89 {
90         DFS_Q_DFS_REMOVE q_u;
91         DFS_R_DFS_REMOVE r_u;
92         prs_struct *data = &p->in_data.data;
93         prs_struct *rdata = &p->out_data.rdata;
94         
95         ZERO_STRUCT(q_u);
96         ZERO_STRUCT(r_u);
97         
98         if(!dfs_io_q_dfs_remove("", &q_u, data, 0))
99                 return False;
100         
101         r_u.status = _dfs_remove(p, &q_u, &r_u);
102         
103         if (!dfs_io_r_dfs_remove("", &r_u, rdata, 0))
104                 return False;
105         
106         return True;
107 }
108
109 /*******************************************************************
110  api_dfs_get_info
111  *******************************************************************/
112
113 static BOOL api_dfs_get_info(pipes_struct *p)
114 {
115         DFS_Q_DFS_GET_INFO q_u;
116         DFS_R_DFS_GET_INFO r_u;
117         prs_struct *data = &p->in_data.data;
118         prs_struct *rdata = &p->out_data.rdata;
119
120         ZERO_STRUCT(q_u);
121         ZERO_STRUCT(r_u);
122         
123         if(!dfs_io_q_dfs_get_info("", &q_u, data, 0))
124                 return False;
125         
126         r_u.status = _dfs_get_info(p, &q_u, &r_u);
127         
128         if(!dfs_io_r_dfs_get_info("", &r_u, rdata, 0))
129                 return False;
130
131         return True;
132 }
133
134 /*******************************************************************
135  api_dfs_enum
136  *******************************************************************/
137
138 static BOOL api_dfs_enum(pipes_struct *p)
139 {
140         DFS_Q_DFS_ENUM q_u;
141         DFS_R_DFS_ENUM r_u;
142         prs_struct *data = &p->in_data.data;
143         prs_struct *rdata = &p->out_data.rdata;
144
145         ZERO_STRUCT(q_u);
146         ZERO_STRUCT(r_u);
147
148         if(!dfs_io_q_dfs_enum("", &q_u, data, 0))
149                 return False;
150         
151         r_u.status = _dfs_enum(p, &q_u, &r_u);
152         
153         if(!dfs_io_r_dfs_enum("", &r_u, rdata, 0))
154                 return False;
155
156         return True;
157 }
158
159 /*******************************************************************
160 \pipe\netdfs commands
161 ********************************************************************/
162
163 struct api_struct api_netdfs_cmds[] =
164 {
165         {"DFS_EXIST",        DFS_EXIST,               api_dfs_exist    },
166         {"DFS_ADD",          DFS_ADD,                 api_dfs_add      },
167         {"DFS_REMOVE",       DFS_REMOVE,              api_dfs_remove   },
168         {"DFS_GET_INFO",     DFS_GET_INFO,            api_dfs_get_info },
169         {"DFS_ENUM",         DFS_ENUM,                api_dfs_enum     },
170         {NULL,               0,                       NULL             }
171 };
172
173 /*******************************************************************
174 receives a netdfs pipe and responds.
175 ********************************************************************/
176
177 BOOL api_netdfs_rpc(pipes_struct *p)
178 {
179         return api_rpcTNP(p, "api_netdfs_rpc", api_netdfs_cmds);
180 }
181
182 #else
183
184  void dfs_dummy(void) {;} /* So some compilers don't complain. */
185
186 #endif