fix
[libexssl.git] / include / libexssl / sslnet.h
blob8b7412ec0cb9b0196241dc8b7923a0af24528110
1 #ifndef __SSLWNET_H__
2 #define __SSLWNET_H__
4 #include <errno.h>
5 #include <unistd.h>
6 #include <malloc.h>
7 #include <string.h>
8 #include <arpa/inet.h>
9 #include <sys/socket.h>
10 #include <sys/types.h>
11 #include <netinet/in.h>
12 #include <resolv.h>
13 #include <openssl/ssl.h>
14 #include <openssl/err.h>
15 #include <libex/str.h>
16 #include <libex/net.h>
17 #include <libex/wsnet.h>
19 #define FL_WSLOADEDHDR 0x00000002
20 #define FL_WSLOADEDLEN 0x00000004
21 #define FL_WSLOADEDMASK 0x00000008
22 #define FL_WSLOADED 0x00000010
24 #define SSL_CLIENT 0
25 #define SSL_SERVER 1
27 extern __thread int ssl_errno;
28 cstr_t *ssl_error ();
30 SSL_CTX *ssl_create (int kind);
31 int ssl_config (SSL_CTX *ctx, const char *cert_file, const char *key_file);
33 int ssl_accept (SSL_CTX *ctx, int fd, SSL **ssl);
34 int ssl_connect (SSL_CTX *ctx, int fd, SSL **ssl);
35 ssize_t ssl_recv (SSL *ssl, strbuf_t *buf);
36 ssize_t ssl_send (SSL *ssl, const void *buf, size_t size);
38 int sslws_handshake (SSL *ssl, strbuf_t *buf, strptr_t *url);
39 int sslws_recv (SSL *ssl, netbuf_t *nbuf, ws_t *result);
41 #define NF_SSLACCEPTED 0x80000000
42 typedef struct ssl_ev ssl_ev_t;
43 typedef struct ssl_srv ssl_srv_t;
45 struct ssl_ev {
46 DECLARE_EV;
47 SSL *ssl;
50 struct ssl_srv {
51 DECLARE_NET_SRV
52 SSL_CTX *ctx_cli;
53 SSL_CTX *ctx_srv;
55 net_srv_t *sslws_srv_init (const char *svc, const char *cert_file, const char *key_file);
56 void sslws_srv_done (net_srv_t *srv);
58 net_srv_t *sslws_jsonrpc_srv_init (const char *svc, const char *cert_file, const char *key_file);
60 #endif