summaryrefslogtreecommitdiffstats
path: root/libcli/named_pipe_auth/npa_tstream.h
blob: 1d85de7d911ecb3ece1bc0865cdd1a1b28dc8061 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
   Unix SMB/CIFS implementation.

   Copyright (C) Stefan Metzmacher 2009

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef NPA_TSTREAM_H
#define NPA_TSTREAM_H

struct tevent_req;
struct tevent_context;
struct auth_session_info_transport;
struct tsocket_address;

struct tevent_req *tstream_npa_connect_send(TALLOC_CTX *mem_ctx,
					    struct tevent_context *ev,
					    const char *directory,
					    const char *npipe,
					    const struct tsocket_address *client,
					    const char *client_name_in,
					    const struct tsocket_address *server,
					    const char *server_name,
					    const struct auth_session_info_transport *session_info);
int _tstream_npa_connect_recv(struct tevent_req *req,
			      int *perrno,
			      TALLOC_CTX *mem_ctx,
			      struct tstream_context **stream,
			      uint16_t *file_type,
			      uint16_t *device_state,
			      uint64_t *allocation_size,
			      const char *location);
#define tstream_npa_connect_recv(req, perrno, mem_ctx, stream, f, d, a) \
	_tstream_npa_connect_recv(req, perrno, mem_ctx, stream, f, d, a, \
				  __location__)

int _tstream_npa_existing_socket(TALLOC_CTX *mem_ctx,
				 int fd,
				 uint16_t file_type,
				 struct tstream_context **_stream,
				 const char *location);
#define tstream_npa_existing_socket(mem_ctx, fd, ft, stream) \
	_tstream_npa_existing_socket(mem_ctx, fd, ft, stream, \
				     __location__)


/**
 * @brief Accepts a connection for authenticated named pipes
 *
 * @param[in]  mem_ctx          The memory context for the operation
 * @param[in]  ev               The tevent_context for the operation
 * @param[in]  plain            The plain tstream_context of the bsd unix
 *                              domain socket.
 *                              This must be valid for the whole life of the
 *                              resulting npa tstream_context!
 * @param[in]  file_type        The file_type, message mode or byte mode
 * @param[in]  device_state     The reported device state
 * @param[in]  allocation_size  The reported allocation size
 *
 * @return the tevent_req handle
 */
struct tevent_req *tstream_npa_accept_existing_send(TALLOC_CTX *mem_ctx,
					struct tevent_context *ev,
					struct tstream_context *plain,
					uint16_t file_type,
					uint16_t device_state,
					uint64_t allocation_size);

/**
 * @brief The receive end of the previous async function
 *
 * @param[in]  req		The tevent_req handle
 * @param[out] perrno		Pointer to store the errno in case of error
 * @param[in]  mem_ctx		The memory context for the results
 * @param[out] stream		The resulting stream
 * @param[out] client		The resulting client address
 * @param[out] client_name	The resulting client name
 * @param[out] server		The resulting server address
 * @param[out] server_name	The resulting server name
 * @param[out] info3		The info3 auth for the connecting user.
 * @param[out] session_key	The resulting session key
 * @param[out] delegated_creds	Delegated credentials
 *
 * @return  0 if successful, -1 on failure with *perror filled.
 */
int _tstream_npa_accept_existing_recv(struct tevent_req *req,
				      int *perrno,
				      TALLOC_CTX *mem_ctx,
				      struct tstream_context **stream,
				      struct tsocket_address **client,
				      char **_client_name,
				      struct tsocket_address **server,
				      char **server_name,
				      struct auth_session_info_transport **session_info,
				      const char *location);
#define tstream_npa_accept_existing_recv(req, perrno, \
					 mem_ctx, stream, \
					 client, client_name, \
					 server, server_name, \
					 session_info) \
	_tstream_npa_accept_existing_recv(req, perrno, \
					  mem_ctx, stream, \
					  client, client_name, \
					  server, server_name, \
					  session_info, \
					  __location__)

#endif /* NPA_TSTREAM_H */