libwbclient: Make wbcDomainInfo not use talloc
[amitay/samba.git] / nsswitch / libwbclient / wbc_async.h
1 /*
2    Unix SMB/CIFS implementation.
3    Headers for the async winbind client library
4    Copyright (C) Volker Lendecke 2008
5
6      ** NOTE! The following LGPL license applies to the wbclient
7      ** library. This does NOT imply that all of Samba is released
8      ** under the LGPL
9
10    This library is free software; you can redistribute it and/or
11    modify it under the terms of the GNU Lesser General Public
12    License as published by the Free Software Foundation; either
13    version 3 of the License, or (at your option) any later version.
14
15    This library 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 GNU
18    Library General Public License for more details.
19
20    You should have received a copy of the GNU Lesser General Public License
21    along with this program.  If not, see <http://www.gnu.org/licenses/>.
22 */
23
24 #ifndef _WBC_ASYNC_H_
25 #define _WBC_ASYNC_H_
26
27 #include <talloc.h>
28 #include <tevent.h>
29 #include "nsswitch/libwbclient/wbclient.h"
30
31 struct wb_context;
32 struct winbindd_request;
33 struct winbindd_response;
34
35 enum wbcDebugLevel {
36         WBC_DEBUG_FATAL,
37         WBC_DEBUG_ERROR,
38         WBC_DEBUG_WARNING,
39         WBC_DEBUG_TRACE
40 };
41
42 struct tevent_req *wb_trans_send(TALLOC_CTX *mem_ctx,
43                                  struct tevent_context *ev,
44                                  struct wb_context *wb_ctx, bool need_priv,
45                                  struct winbindd_request *wb_req);
46 wbcErr wb_trans_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
47                      struct winbindd_response **presponse);
48 struct wb_context *wb_context_init(TALLOC_CTX *mem_ctx, const char* dir);
49 int wbcSetDebug(struct wb_context *wb_ctx,
50                 void (*debug)(void *context,
51                               enum wbcDebugLevel level,
52                               const char *fmt,
53                               va_list ap) PRINTF_ATTRIBUTE(3,0),
54                 void *context);
55 int wbcSetDebugStderr(struct wb_context *wb_ctx);
56 void wbcDebug(struct wb_context *wb_ctx, enum wbcDebugLevel level,
57               const char *fmt, ...) PRINTF_ATTRIBUTE(3,0);
58
59 /* Definitions from wb_reqtrans.c */
60 wbcErr map_wbc_err_from_errno(int error);
61
62 bool tevent_req_is_wbcerr(struct tevent_req *req, wbcErr *pwbc_err);
63 wbcErr tevent_req_simple_recv_wbcerr(struct tevent_req *req);
64
65 struct tevent_req *wb_req_read_send(TALLOC_CTX *mem_ctx,
66                                     struct tevent_context *ev,
67                                     int fd, size_t max_extra_data);
68 ssize_t wb_req_read_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
69                          struct winbindd_request **preq, int *err);
70
71 struct tevent_req *wb_req_write_send(TALLOC_CTX *mem_ctx,
72                                      struct tevent_context *ev,
73                                      struct tevent_queue *queue, int fd,
74                                      struct winbindd_request *wb_req);
75 ssize_t wb_req_write_recv(struct tevent_req *req, int *err);
76
77 struct tevent_req *wb_resp_read_send(TALLOC_CTX *mem_ctx,
78                                      struct tevent_context *ev, int fd);
79 ssize_t wb_resp_read_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
80                           struct winbindd_response **presp, int *err);
81
82 struct tevent_req *wb_resp_write_send(TALLOC_CTX *mem_ctx,
83                                       struct tevent_context *ev,
84                                       struct tevent_queue *queue, int fd,
85                                       struct winbindd_response *wb_resp);
86 ssize_t wb_resp_write_recv(struct tevent_req *req, int *err);
87
88 struct tevent_req *wb_simple_trans_send(TALLOC_CTX *mem_ctx,
89                                         struct tevent_context *ev,
90                                         struct tevent_queue *queue, int fd,
91                                         struct winbindd_request *wb_req);
92 int wb_simple_trans_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
93                          struct winbindd_response **presponse, int *err);
94
95 /* Async functions from wbc_idmap.c */
96
97 struct tevent_req *wbcSidToUid_send(TALLOC_CTX *mem_ctx,
98                                     struct tevent_context *ev,
99                                     struct wb_context *wb_ctx,
100                                     const struct wbcDomainSid *sid);
101 wbcErr wbcSidToUid_recv(struct tevent_req *req, uid_t *puid);
102
103 struct tevent_req *wbcUidToSid_send(TALLOC_CTX *mem_ctx,
104                                     struct tevent_context *ev,
105                                     struct wb_context *wb_ctx,
106                                     uid_t uid);
107 wbcErr wbcUidToSid_recv(struct tevent_req *req, struct wbcDomainSid *psid);
108
109 struct tevent_req *wbcSidToGid_send(TALLOC_CTX *mem_ctx,
110                                     struct tevent_context *ev,
111                                     struct wb_context *wb_ctx,
112                                     const struct wbcDomainSid *sid);
113 wbcErr wbcSidToGid_recv(struct tevent_req *req, gid_t *pgid);
114
115 struct tevent_req *wbcGidToSid_send(TALLOC_CTX *mem_ctx,
116                                     struct tevent_context *ev,
117                                     struct wb_context *wb_ctx,
118                                     gid_t gid);
119 wbcErr wbcGidToSid_recv(struct tevent_req *req, struct wbcDomainSid *psid);
120
121 /* Async functions from wbc_pam.c */
122 struct tevent_req *wbcAuthenticateUserEx_send(TALLOC_CTX *mem_ctx,
123                                         struct tevent_context *ev,
124                                         struct wb_context *wb_ctx,
125                                         const struct wbcAuthUserParams *params);
126 wbcErr wbcAuthenticateUserEx_recv(struct tevent_req *req,
127                                   TALLOC_CTX *mem_ctx,
128                                   struct wbcAuthUserInfo **info,
129                                   struct wbcAuthErrorInfo **error);
130
131 /* Async functions from wbc_sid.c */
132 struct tevent_req *wbcLookupName_send(TALLOC_CTX *mem_ctx,
133                                       struct tevent_context *ev,
134                                       struct wb_context *wb_ctx,
135                                       const char *domain,
136                                       const char *name);
137 wbcErr wbcLookupName_recv(struct tevent_req *req,
138                           struct wbcDomainSid *sid,
139                           enum wbcSidType *name_type);
140 struct tevent_req *wbcLookupSid_send(TALLOC_CTX *mem_ctx,
141                                      struct tevent_context *ev,
142                                      struct wb_context *wb_ctx,
143                                      const struct wbcDomainSid *sid);
144 wbcErr wbcLookupSid_recv(struct tevent_req *req,
145                          TALLOC_CTX *mem_ctx,
146                          char **pdomain,
147                          char **pname,
148                          enum wbcSidType *pname_type);
149
150 /* Async functions from wbc_util.c */
151
152 struct tevent_req *wbcPing_send(TALLOC_CTX *mem_ctx,
153                                struct tevent_context *ev,
154                                struct wb_context *wb_ctx);
155 wbcErr wbcPing_recv(struct tevent_req *req);
156
157 struct tevent_req *wbcInterfaceVersion_send(TALLOC_CTX *mem_ctx,
158                                             struct tevent_context *ev,
159                                             struct wb_context *wb_ctx);
160 wbcErr wbcInterfaceVersion_recv(struct tevent_req *req,
161                                 uint32_t *interface_version);
162
163 struct tevent_req *wbcInfo_send(TALLOC_CTX *mem_ctx,
164                                 struct tevent_context *ev,
165                                 struct wb_context *wb_ctx);
166 wbcErr wbcInfo_recv(struct tevent_req *req,
167                     TALLOC_CTX *mem_ctx,
168                     char *winbind_separator,
169                     char **version_string);
170
171 struct tevent_req *wbcNetbiosName_send(TALLOC_CTX *mem_ctx,
172                                        struct tevent_context *ev,
173                                        struct wb_context *wb_ctx);
174 wbcErr wbcNetbiosName_recv(struct tevent_req *req,
175                            TALLOC_CTX *mem_ctx,
176                            char **netbios_name);
177
178 struct tevent_req *wbcDomainName_send(TALLOC_CTX *mem_ctx,
179                                       struct tevent_context *ev,
180                                       struct wb_context *wb_ctx);
181 wbcErr wbcDomainName_recv(struct tevent_req *req,
182                           TALLOC_CTX *mem_ctx,
183                           char **netbios_name);
184
185 struct tevent_req *wbcInterfaceDetails_send(TALLOC_CTX *mem_ctx,
186                                             struct tevent_context *ev,
187                                             struct wb_context *wb_ctx);
188 wbcErr wbcInterfaceDetails_recv(struct tevent_req *req,
189                                 TALLOC_CTX *mem_ctx,
190                                 struct wbcInterfaceDetails **details);
191
192 struct tevent_req *wbcDomainInfo_send(TALLOC_CTX *mem_ctx,
193                                       struct tevent_context *ev,
194                                       struct wb_context *wb_ctx,
195                                       const char *domain);
196 wbcErr wbcDomainInfo_recv(struct tevent_req *req,
197                           TALLOC_CTX *mem_ctx,
198                           struct wbcDomainInfo **dinfo);
199
200 #endif /*_WBC_ASYNC_H_*/