Changes in lib/ssl_gnutls.c [c1ed6527:df1694b]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/ssl_gnutls.c
rc1ed6527 rdf1694b 49 49 50 50 static gboolean ssl_connected( gpointer data, gint source, b_input_condition cond ); 51 static gboolean ssl_starttls_real( gpointer data, gint source, b_input_condition cond );52 static gboolean ssl_handshake( gpointer data, gint source, b_input_condition cond );53 51 54 52 … … 65 63 { 66 64 g_free( conn ); 67 return NULL; 68 } 69 70 return conn; 71 } 72 73 void *ssl_starttls( int fd, ssl_input_function func, gpointer data ) 74 { 75 struct scd *conn = g_new0( struct scd, 1 ); 76 77 conn->fd = fd; 78 conn->func = func; 79 conn->data = data; 80 conn->inpa = -1; 81 82 /* This function should be called via a (short) timeout instead of 83 directly from here, because these SSL calls are *supposed* to be 84 *completely* asynchronous and not ready yet when this function 85 (or *_connect, for examle) returns. Also, errors are reported via 86 the callback function, not via this function's return value. 87 88 In short, doing things like this makes the rest of the code a lot 89 simpler. */ 90 91 b_timeout_add( 1, ssl_starttls_real, conn ); 92 93 return conn; 94 } 95 96 static gboolean ssl_starttls_real( gpointer data, gint source, b_input_condition cond ) 97 { 98 struct scd *conn = data; 99 100 return ssl_connected( conn, conn->fd, GAIM_INPUT_WRITE ); 101 } 102 103 static gboolean ssl_connected( gpointer data, gint source, b_input_condition cond ) 104 { 105 struct scd *conn = data; 106 107 if( source == -1 ) 108 { 109 conn->func( conn->data, NULL, cond ); 110 111 g_free( conn ); 112 113 return FALSE; 65 return( NULL ); 114 66 } 115 67 … … 125 77 gnutls_set_default_priority( conn->session ); 126 78 gnutls_credentials_set( conn->session, GNUTLS_CRD_CERTIFICATE, conn->xcred ); 79 80 return( conn ); 81 } 82 83 static gboolean ssl_handshake( gpointer data, gint source, b_input_condition cond ); 84 85 static gboolean ssl_connected( gpointer data, gint source, b_input_condition cond ) 86 { 87 struct scd *conn = data; 88 89 if( source == -1 ) 90 { 91 conn->func( conn->data, NULL, cond ); 92 93 gnutls_deinit( conn->session ); 94 gnutls_certificate_free_credentials( conn->xcred ); 95 96 g_free( conn ); 97 98 return FALSE; 99 } 127 100 128 101 sock_make_nonblocking( conn->fd );
Note: See TracChangeset
for help on using the changeset viewer.