updated the 3.0 branch from the head branch - ready for alpha18
[jra/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 extern pstring global_myname;
35
36 /**********************************************************************
37  api_dfs_exist
38  **********************************************************************/
39
40 static BOOL api_dfs_exist(pipes_struct *p)
41 {
42         DFS_Q_DFS_EXIST q_u;
43         DFS_R_DFS_EXIST r_u;
44         prs_struct *data = &p->in_data.data;
45         prs_struct *rdata = &p->out_data.rdata;
46
47         if(!dfs_io_q_dfs_exist("", &q_u, data, 0))
48                 return False;
49         
50         r_u.status = _dfs_exist(p, &q_u, &r_u);
51         
52         if (!dfs_io_r_dfs_exist("", &r_u, rdata, 0))
53                 return False;
54
55         return True;
56 }
57
58 /*****************************************************************
59  api_dfs_add
60  *****************************************************************/
61
62 static BOOL api_dfs_add(pipes_struct *p)
63 {
64         DFS_Q_DFS_ADD q_u;
65         DFS_R_DFS_ADD r_u;
66         prs_struct *data = &p->in_data.data;
67         prs_struct *rdata = &p->out_data.rdata;
68
69         ZERO_STRUCT(q_u);
70         ZERO_STRUCT(r_u);
71         
72         if(!dfs_io_q_dfs_add("", &q_u, data, 0))
73                 return False;
74         
75         r_u.status = _dfs_add(p, &q_u, &r_u);
76         
77         if (!dfs_io_r_dfs_add("", &r_u, rdata, 0))
78                 return False;
79         
80         return True;
81 }
82
83 /*****************************************************************
84  api_dfs_remove
85  *****************************************************************/
86
87 static BOOL api_dfs_remove(pipes_struct *p)
88 {
89         DFS_Q_DFS_REMOVE q_u;
90         DFS_R_DFS_REMOVE r_u;
91         prs_struct *data = &p->in_data.data;
92         prs_struct *rdata = &p->out_data.rdata;
93         
94         ZERO_STRUCT(q_u);
95         ZERO_STRUCT(r_u);
96         
97         if(!dfs_io_q_dfs_remove("", &q_u, data, 0))
98                 return False;
99         
100         r_u.status = _dfs_remove(p, &q_u, &r_u);
101         
102         if (!dfs_io_r_dfs_remove("", &r_u, rdata, 0))
103                 return False;
104         
105         return True;
106 }
107
108 /*******************************************************************
109  api_dfs_get_info
110  *******************************************************************/
111
112 static BOOL api_dfs_get_info(pipes_struct *p)
113 {
114         DFS_Q_DFS_GET_INFO q_u;
115         DFS_R_DFS_GET_INFO r_u;
116         prs_struct *data = &p->in_data.data;
117         prs_struct *rdata = &p->out_data.rdata;
118
119         ZERO_STRUCT(q_u);
120         ZERO_STRUCT(r_u);
121         
122         if(!dfs_io_q_dfs_get_info("", &q_u, data, 0))
123                 return False;
124         
125         r_u.status = _dfs_get_info(p, &q_u, &r_u);
126         
127         if(!dfs_io_r_dfs_get_info("", &r_u, rdata, 0))
128                 return False;
129
130         return True;
131 }
132
133 /*******************************************************************
134  api_dfs_enum
135  *******************************************************************/
136
137 static BOOL api_dfs_enum(pipes_struct *p)
138 {
139         DFS_Q_DFS_ENUM q_u;
140         DFS_R_DFS_ENUM r_u;
141         prs_struct *data = &p->in_data.data;
142         prs_struct *rdata = &p->out_data.rdata;
143
144         ZERO_STRUCT(q_u);
145         ZERO_STRUCT(r_u);
146
147         if(!dfs_io_q_dfs_enum("", &q_u, data, 0))
148                 return False;
149         
150         r_u.status = _dfs_enum(p, &q_u, &r_u);
151         
152         if(!dfs_io_r_dfs_enum("", &r_u, rdata, 0))
153                 return False;
154
155         return True;
156 }
157
158 /*******************************************************************
159 \pipe\netdfs commands
160 ********************************************************************/
161
162 struct api_struct api_netdfs_cmds[] =
163 {
164         {"DFS_EXIST",        DFS_EXIST,               api_dfs_exist    },
165         {"DFS_ADD",          DFS_ADD,                 api_dfs_add      },
166         {"DFS_REMOVE",       DFS_REMOVE,              api_dfs_remove   },
167         {"DFS_GET_INFO",     DFS_GET_INFO,            api_dfs_get_info },
168         {"DFS_ENUM",         DFS_ENUM,                api_dfs_enum     },
169         {NULL,               0,                       NULL             }
170 };
171
172 /*******************************************************************
173 receives a netdfs pipe and responds.
174 ********************************************************************/
175
176 BOOL api_netdfs_rpc(pipes_struct *p)
177 {
178         return api_rpcTNP(p, "api_netdfs_rpc", api_netdfs_cmds);
179 }