r7747: - simplified the ldap server buffer handling
[metze/samba/wip.git] / source4 / lib / tls / tls.h
1 /* 
2    Unix SMB/CIFS implementation.
3
4    transport layer security handling code
5
6    Copyright (C) Andrew Tridgell 2005
7    
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 2 of the License, or
11    (at your option) any later version.
12    
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17    
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 /*
24   call tls_initialise() once per task to startup the tls subsystem
25 */
26 struct tls_params *tls_initialise(TALLOC_CTX *mem_ctx);
27
28 /*
29   call tls_init_server() on each new server connection
30
31   the 'plain_chars' parameter is a list of chars that when they occur
32   as the first character from the client on the connection tell the
33   tls code that this is a non-tls connection. This can be used to have
34   tls and non-tls servers on the same port. If this is NULL then only
35   tls connections will be allowed
36 */
37 struct tls_context *tls_init_server(struct tls_params *parms,
38                                     struct socket_context *sock, 
39                                     struct fd_event *fde,
40                                     const char *plain_chars);
41
42 /*
43   call these to send and receive data. They behave like socket_send() and socket_recv()
44  */
45 NTSTATUS tls_socket_recv(struct tls_context *tls, void *buf, size_t wantlen, 
46                          size_t *nread);
47 NTSTATUS tls_socket_send(struct tls_context *tls, const DATA_BLOB *blob, 
48                          size_t *sendlen);
49
50 /*
51   return True if a connection used tls
52 */
53 BOOL tls_enabled(struct tls_context *tls);
54
55
56 /*
57   true if tls support is compiled in
58 */
59 BOOL tls_support(struct tls_params *parms);
60
61
62 /*
63   ask for the number of bytes in a pending incoming packet
64 */
65 NTSTATUS tls_socket_pending(struct tls_context *tls, size_t *npending);
66