ekg2
Strona główna
Dodatkowe strony
Moduły
Struktury Danych
Pliki
Lista plików
Globalne
All
Struktury Danych
Pliki
Funkcje
Zmienne
Definicje typów
Wyliczenia
Wartości wyliczeń
Definicje
Grupay
Strony
remote
remote-ssl.h
Idź do dokumentacji tego pliku.
1
#ifndef __EKG_SSL_H
2
#define __EKG_SSL_H
/* <__EKG_SSL_H> */
3
4
#include <ekg2-config.h>
5
6
#ifdef REMOTE_WANT_GNUTLS
7
# define HAVE_SSL 1
8
#endif
9
10
#ifdef REMOTE_WANT_OPENSSL
11
# define HAVE_SSL 1
12
13
#endif
14
15
#ifdef HAVE_SSL
/* <HAVE_SSL> */
16
17
#ifdef REMOTE_WANT_GNUTLS
/* <WANT_GNUTLS> */
18
# include <gnutls/gnutls.h>
19
20
# define SSL_SESSION gnutls_session_t
21
22
static
int
__attribute__
((unused))
SSL_SET_FD
(
SSL_SESSION
session,
long
int
fd) {
23
gnutls_transport_set_ptr(session, (gnutls_transport_ptr)(fd));
24
return
1;
/* always success */
25
}
26
27
# define SSL_INIT(session) gnutls_init((&session), GNUTLS_CLIENT)
28
# define SSL_DEINIT(session) gnutls_deinit(session)
29
# define SSL_HELLO(session) gnutls_handshake(session)
30
# define SSL_BYE(session) gnutls_bye(session, GNUTLS_SHUT_RDWR)
31
# define SSL_GLOBAL_INIT() gnutls_global_init()
32
# define SSL_GLOBAL_DEINIT() gnutls_global_deinit()
33
# define SSL_ERROR(retcode) gnutls_strerror(retcode)
34
# define SSL_E_AGAIN(ret) ((ret == GNUTLS_E_INTERRUPTED) || (ret == GNUTLS_E_AGAIN))
35
36
# define SSL_SEND(session, str, len) gnutls_record_send(session, str, len)
37
# define SSL_RECV(session, buf, size) gnutls_record_recv(session, buf, size)
38
39
# define SSL_GET_FD(session, fd) (long int) gnutls_transport_get_ptr(session)
40
# define SSL_WRITE_DIRECTION(session, ret) gnutls_record_get_direction(session)
41
42
#endif
/* </WANT_GNUTLS> */
43
44
#ifdef REMOTE_WANT_OPENSSL
/* <WANT_OPENSSL> */
45
46
# include <openssl/ssl.h>
47
# include <openssl/err.h>
48
49
SSL_CTX *
jabberSslCtx
;
50
51
# define SSL_SESSION SSL *
52
53
# define SSL_INIT(session) !(session = SSL_new(jabberSslCtx))
54
55
# define SSL_HELLO(session) SSL_connect(session)
56
# define SSL_BYE(session) SSL_shutdown(session)
57
# define SSL_DEINIT(session) SSL_free(session)
58
# define SSL_GLOBAL_INIT() SSL_library_init(); jabberSslCtx = SSL_CTX_new(SSLv23_client_method())
59
# define SSL_GLOBAL_DEINIT() SSL_CTX_free(jabberSslCtx)
60
# define SSL_ERROR(retcode) ERR_error_string(retcode, NULL)
/* retcode need be value from SSL_get_error(session, res) */
61
# define SSL_E_AGAIN(ret) ((ret == SSL_ERROR_WANT_READ || ret == SSL_ERROR_WANT_WRITE))
62
63
# define SSL_SEND(session, str, len) SSL_write(session, str, len)
64
# define SSL_RECV(session, buf, size) SSL_read(session, buf, size)
65
66
# define SSL_SET_FD(session, fd) SSL_set_fd(session, fd)
67
# define SSL_GET_FD(session, fd) fd
68
# define SSL_WRITE_DIRECTION(session, ret) (ret != SSL_ERROR_WANT_READ)
69
70
#endif
/* </WANT_OPENSSL> */
71
72
#endif
/* </HAVE_SSL> */
73
74
#endif
/* </__EKG_SSL_H> */
75
Wygenerowano Pt, 21 mar 2014 17:50:26 dla ekg2 programem
1.8.1.2