9 #include <sys/socket.h>
10 #include <sys/types.h>
11 #include <netinet/in.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
27 extern __thread
int ssl_errno
;
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
;
48 } __attribute__ ((aligned(64)));
49 int ssl_free_ev (int fd
, net_srv_t
*srv
);
56 #define SSLSRV_SIZE sizeof(ssl_srv_t)
57 #define SSLEV_SIZE sizeof(ssl_ev_t)
58 net_srv_t
*sslws_srv_init_ex (const char *svc
, size_t srv_size
, size_t ev_size
, const char *cert_file
, const char *key_file
);
59 static inline net_srv_t
*sslws_srv_init (const char *svc
, const char *cert_file
, const char *key_file
) {
60 return sslws_srv_init_ex(svc
, sizeof(ssl_srv_t
), sizeof(ssl_ev_t
), cert_file
, key_file
);
62 void sslws_srv_done (net_srv_t
*srv
);
64 net_srv_t
*sslws_jsonrpc_srv_init_ex (const char *svc
, size_t srv_size
, size_t ev_size
, const char *cert_file
, const char *key_file
);
65 static inline net_srv_t
*sslws_jsonrpc_srv_init (const char *svc
, const char *cert_file
, const char *key_file
) {
66 return sslws_jsonrpc_srv_init_ex(svc
, sizeof(ssl_srv_t
), sizeof(ssl_ev_t
), cert_file
, key_file
);