ebb6d16e428c93357dcee72bb7f8c1de8e0d197c
[metze/samba-autobuild/.git] / libcli / named_pipe_auth / npa_tstream.h
1 /*
2    Unix SMB/CIFS implementation.
3
4    Copyright (C) Stefan Metzmacher 2009
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef NPA_TSTREAM_H
21 #define NPA_TSTREAM_H
22
23 #include <replace.h>
24 #include "librpc/rpc/rpc_common.h"
25
26 struct tevent_req;
27 struct tevent_context;
28 struct auth_session_info_transport;
29 struct tsocket_address;
30 struct named_pipe_auth_req_info7;
31
32 struct tevent_req *tstream_npa_connect_send(TALLOC_CTX *mem_ctx,
33                                             struct tevent_context *ev,
34                                             const char *directory,
35                                             const char *npipe,
36                                             enum dcerpc_transport_t transport,
37                                             const struct tsocket_address *remote_client_addr,
38                                             const char *remote_client_name_in,
39                                             const struct tsocket_address *local_server_addr,
40                                             const char *local_server_name_in,
41                                             const struct auth_session_info_transport *session_info);
42 int _tstream_npa_connect_recv(struct tevent_req *req,
43                               int *perrno,
44                               TALLOC_CTX *mem_ctx,
45                               struct tstream_context **stream,
46                               uint16_t *file_type,
47                               uint16_t *device_state,
48                               uint64_t *allocation_size,
49                               const char *location);
50 #define tstream_npa_connect_recv(req, perrno, mem_ctx, stream, f, d, a) \
51         _tstream_npa_connect_recv(req, perrno, mem_ctx, stream, f, d, a, \
52                                   __location__)
53
54 int _tstream_npa_existing_stream(TALLOC_CTX *mem_ctx,
55                                  struct tstream_context **transport,
56                                  uint16_t file_type,
57                                  struct tstream_context **_stream,
58                                  const char *location);
59 #define tstream_npa_existing_stream(mem_ctx, transport, ft, stream) \
60         _tstream_npa_existing_stream(mem_ctx, transport, ft, stream, \
61                                      __location__)
62
63 int _tstream_npa_existing_socket(TALLOC_CTX *mem_ctx,
64                                  int fd,
65                                  uint16_t file_type,
66                                  struct tstream_context **_stream,
67                                  const char *location);
68 #define tstream_npa_existing_socket(mem_ctx, fd, ft, stream) \
69         _tstream_npa_existing_socket(mem_ctx, fd, ft, stream, \
70                                      __location__)
71
72
73 /**
74  * @brief Accepts a connection for authenticated named pipes
75  *
76  * @param[in]  mem_ctx          The memory context for the operation
77  * @param[in]  ev               The tevent_context for the operation
78  * @param[in]  plain            The plain tstream_context of the bsd unix
79  *                              domain socket.
80  *                              This must be valid for the whole life of the
81  *                              resulting npa tstream_context!
82  * @param[in]  file_type        The file_type, message mode or byte mode
83  * @param[in]  device_state     The reported device state
84  * @param[in]  allocation_size  The reported allocation size
85  *
86  * @return the tevent_req handle
87  */
88 struct tevent_req *tstream_npa_accept_existing_send(TALLOC_CTX *mem_ctx,
89                                         struct tevent_context *ev,
90                                         struct tstream_context *plain,
91                                         uint16_t file_type,
92                                         uint16_t device_state,
93                                         uint64_t allocation_size);
94
95 /**
96  * @brief The receive end of the previous async function
97  *
98  * @param[in]  req              The tevent_req handle
99  * @param[out] perrno           Pointer to store the errno in case of error
100  * @param[in]  mem_ctx          The memory context for the results
101  * @param[out] stream           The resulting stream
102  * @param[out] client           The resulting client address
103  * @param[out] client_name      The resulting client name
104  * @param[out] server           The resulting server address
105  * @param[out] server_name      The resulting server name
106  * @param[out] info3            The info3 auth for the connecting user.
107  * @param[out] session_key      The resulting session key
108  * @param[out] delegated_creds  Delegated credentials
109  *
110  * @return  0 if successful, -1 on failure with *perror filled.
111  */
112 int _tstream_npa_accept_existing_recv(
113         struct tevent_req *req,
114         int *perrno,
115         TALLOC_CTX *mem_ctx,
116         struct tstream_context **stream,
117         struct named_pipe_auth_req_info7 **info7,
118         enum dcerpc_transport_t *transport,
119         struct tsocket_address **remote_client_addr,
120         char **_remote_client_name,
121         struct tsocket_address **local_server_addr,
122         char **local_server_name,
123         struct auth_session_info_transport **session_info,
124         const char *location);
125 #define tstream_npa_accept_existing_recv(req, perrno, \
126                                          mem_ctx, stream, \
127                                          info4, \
128                                          transport, \
129                                          remote_client_addr, \
130                                          remote_client_name,  \
131                                          local_server_addr, \
132                                          local_server_name, \
133                                          session_info) \
134         _tstream_npa_accept_existing_recv(req, perrno, \
135                                           mem_ctx, stream, \
136                                           info4, \
137                                           transport, \
138                                           remote_client_addr, \
139                                           remote_client_name,  \
140                                           local_server_addr, \
141                                           local_server_name, \
142                                           session_info, \
143                                           __location__)
144
145 #endif /* NPA_TSTREAM_H */