ekg2
GIT master
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
plugins
jabber
jabber-ssl.h
Idź do dokumentacji tego pliku.
1
#ifndef __EKG_JABBER_SSL_H
2
#define __EKG_JABBER_SSL_H
3
4
#ifdef HAVE_LIBGNUTLS
5
# define JABBER_HAVE_SSL 1
6
# undef HAVE_LIBSSL
/* na wszelki wypadek */
7
#else
8
#ifdef HAVE_LIBSSL
9
# define JABBER_HAVE_SSL 1
10
# warning "You want to use OpenSSL library as ssl transport layer for jabber, it have bugs and is not well tested.. It's better if you use gnutls"
11
#endif
12
#endif
13
14
#ifdef JABBER_HAVE_SSL
15
16
#ifdef HAVE_LIBGNUTLS
/* HAVE_GNUTLS */
17
# include <gnutls/gnutls.h>
18
19
20
# define SSL_SESSION gnutls_session
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
#else
/* HAVE_OPENSSL */
43
# include <openssl/ssl.h>
44
# include <openssl/err.h>
45
46
extern
SSL_CTX *
jabberSslCtx
;
/* jabber.c */
47
48
# define SSL_SESSION SSL *
49
50
# define SSL_INIT(session) !(session = SSL_new(jabberSslCtx))
51
52
# define SSL_HELLO(session) SSL_connect(session)
53
# define SSL_BYE(session) SSL_shutdown(session)
54
# define SSL_DEINIT(session) SSL_free(session)
55
# define SSL_GLOBAL_INIT() SSL_library_init(); jabberSslCtx = SSL_CTX_new(SSLv23_client_method())
56
# define SSL_GLOBAL_DEINIT() SSL_CTX_free(jabberSslCtx)
57
# define SSL_ERROR(retcode) ERR_error_string(retcode, NULL)
/* retcode need be value from SSL_get_error(session, res) */
58
# define SSL_E_AGAIN(ret) ((ret == SSL_ERROR_WANT_READ || ret == SSL_ERROR_WANT_WRITE))
59
60
# define SSL_SEND(session, str, len) SSL_write(session, str, len)
61
# define SSL_RECV(session, buf, size) SSL_read(session, buf, size)
62
63
# define SSL_SET_FD(session, fd) SSL_set_fd(session, fd)
64
# define SSL_GET_FD(session, fd) fd
65
# define SSL_WRITE_DIRECTION(session, ret) (ret != SSL_ERROR_WANT_READ)
66
67
#endif
/* ... */
68
69
#endif
/* JABBER_HAVE_SSL */
70
#endif
/* __EKG_JABBER_SSL_H */
71
Wygenerowano Wt, 29 paź 2013 20:17:04 dla ekg2 programem
1.8.4