tstream: make npa_tstream a private library
[samba.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 struct tevent_req;
24 struct tevent_context;
25 struct auth_session_info_transport;
26
27 struct tevent_req *tstream_npa_connect_send(TALLOC_CTX *mem_ctx,
28                                             struct tevent_context *ev,
29                                             const char *directory,
30                                             const char *npipe,
31                                             const struct tsocket_address *client,
32                                             const char *client_name_in,
33                                             const struct tsocket_address *server,
34                                             const char *server_name,
35                                             const struct auth_session_info_transport *session_info);
36 int _tstream_npa_connect_recv(struct tevent_req *req,
37                               int *perrno,
38                               TALLOC_CTX *mem_ctx,
39                               struct tstream_context **stream,
40                               uint16_t *file_type,
41                               uint16_t *device_state,
42                               uint64_t *allocation_size,
43                               const char *location);
44 #define tstream_npa_connect_recv(req, perrno, mem_ctx, stream, f, d, a) \
45         _tstream_npa_connect_recv(req, perrno, mem_ctx, stream, f, d, a, \
46                                   __location__)
47
48 int _tstream_npa_existing_socket(TALLOC_CTX *mem_ctx,
49                                  int fd,
50                                  uint16_t file_type,
51                                  struct tstream_context **_stream,
52                                  const char *location);
53 #define tstream_npa_existing_socket(mem_ctx, fd, ft, stream) \
54         _tstream_npa_existing_socket(mem_ctx, fd, ft, stream, \
55                                      __location__)
56
57
58 /**
59  * @brief Accepts a connection for authenticated named pipes
60  *
61  * @param[in]  mem_ctx          The memory context for the operation
62  * @param[in]  ev               The tevent_context for the operation
63  * @param[in]  plain            The plain tstream_context of the bsd unix
64  *                              domain socket.
65  *                              This must be valid for the whole life of the
66  *                              resulting npa tstream_context!
67  * @param[in]  file_type        The file_type, message mode or byte mode
68  * @param[in]  device_state     The reported device state
69  * @param[in]  allocation_size  The reported allocation size
70  *
71  * @return the tevent_req handle
72  */
73 struct tevent_req *tstream_npa_accept_existing_send(TALLOC_CTX *mem_ctx,
74                                         struct tevent_context *ev,
75                                         struct tstream_context *plain,
76                                         uint16_t file_type,
77                                         uint16_t device_state,
78                                         uint64_t allocation_size);
79
80 /**
81  * @brief The receive end of the previous async function
82  *
83  * @param[in]  req              The tevent_req handle
84  * @param[out] perrno           Pointer to store the errno in case of error
85  * @param[in]  mem_ctx          The memory context for the results
86  * @param[out] stream           The resulting stream
87  * @param[out] client           The resulting client address
88  * @param[out] client_name      The resulting client name
89  * @param[out] server           The resulting server address
90  * @param[out] server_name      The resulting server name
91  * @param[out] info3            The info3 auth for the connecting user.
92  * @param[out] session_key      The resulting session key
93  * @param[out] delegated_creds  Delegated credentials
94  *
95  * @return  0 if successful, -1 on failure with *perror filled.
96  */
97 int _tstream_npa_accept_existing_recv(struct tevent_req *req,
98                                       int *perrno,
99                                       TALLOC_CTX *mem_ctx,
100                                       struct tstream_context **stream,
101                                       struct tsocket_address **client,
102                                       char **_client_name,
103                                       struct tsocket_address **server,
104                                       char **server_name,
105                                       struct auth_session_info_transport **session_info,
106                                       const char *location);
107 #define tstream_npa_accept_existing_recv(req, perrno, \
108                                          mem_ctx, stream, \
109                                          client, client_name, \
110                                          server, server_name, \
111                                          session_info) \
112         _tstream_npa_accept_existing_recv(req, perrno, \
113                                           mem_ctx, stream, \
114                                           client, client_name, \
115                                           server, server_name, \
116                                           session_info, \
117                                           __location__)
118
119 #endif /* NPA_TSTREAM_H */