Mercurial > pidgin
annotate src/sslconn.h @ 6738:6c95f01aaf49
[gaim-migrate @ 7270]
Added optional GNUTLS support, which will also be used as a fallback if
Mozilla NSS is not installed.
committer: Tailor Script <tailor@pidgin.im>
| author | Christian Hammond <chipx86@chipx86.com> |
|---|---|
| date | Thu, 04 Sep 2003 06:19:25 +0000 |
| parents | 41120df7ed94 |
| children | 818ce550d2ce |
| rev | line source |
|---|---|
| 6703 | 1 /** |
| 2 * @file sslconn.h SSL API | |
| 3 * @ingroup core | |
| 4 * | |
| 5 * gaim | |
| 6 * | |
| 7 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org> | |
| 8 * | |
| 9 * This program is free software; you can redistribute it and/or modify | |
| 10 * it under the terms of the GNU General Public License as published by | |
| 11 * the Free Software Foundation; either version 2 of the License, or | |
| 12 * (at your option) any later version. | |
| 13 * | |
| 14 * This program is distributed in the hope that it will be useful, | |
| 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 17 * GNU General Public License for more details. | |
| 18 * | |
| 19 * You should have received a copy of the GNU General Public License | |
| 20 * along with this program; if not, write to the Free Software | |
| 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 22 */ | |
| 23 #ifndef _GAIM_SSL_H_ | |
| 24 #define _GAIM_SSL_H_ | |
| 25 | |
| 26 #include "proxy.h" | |
| 27 | |
|
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
28 #define GAIM_SSL_DEFAULT_PORT 443 |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
29 |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
30 typedef struct _GaimSslConnection GaimSslConnection; |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
31 |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
32 typedef void (*GaimSslInputFunction)(gpointer, GaimSslConnection *, |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
33 GaimInputCondition); |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
34 |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
35 struct _GaimSslConnection |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
36 { |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
37 char *host; |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
38 int port; |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
39 void *user_data; |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
40 GaimSslInputFunction input_func; |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
41 |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
42 int fd; |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
43 int inpa; |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
44 |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
45 void *private_data; |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
46 }; |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
47 |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
48 /** |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
49 * SSL implementation operations structure. |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
50 * |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
51 * Every SSL implementation must provide one of these and register it. |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
52 */ |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
53 typedef struct |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
54 { |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
55 gboolean (*init)(void); |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
56 void (*uninit)(void); |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
57 GaimInputFunction connect_cb; |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
58 void (*close)(GaimSslConnection *gsc); |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
59 size_t (*read)(GaimSslConnection *gsc, void *data, size_t len); |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
60 size_t (*write)(GaimSslConnection *gsc, const void *data, size_t len); |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
61 |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
62 } GaimSslOps; |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
63 |
| 6703 | 64 #ifdef __cplusplus |
| 65 extern "C" { | |
| 66 #endif | |
| 67 | |
| 68 /**************************************************************************/ | |
| 69 /** @name SSL API */ | |
| 70 /**************************************************************************/ | |
| 71 /*@{*/ | |
| 72 | |
| 73 /** | |
| 74 * Returns whether or not SSL is currently supported. | |
| 75 * | |
| 76 * @return TRUE if SSL is supported, or FALSE otherwise. | |
| 77 */ | |
| 78 gboolean gaim_ssl_is_supported(void); | |
| 79 | |
| 80 /** | |
| 81 * Makes a SSL connection to the specified host and port. | |
| 82 * | |
| 83 * @param account The account making the connection. | |
| 84 * @param host The destination host. | |
| 85 * @param port The destination port. | |
| 86 * @param func The SSL input handler function. | |
| 87 * @param data User-defined data. | |
| 88 * | |
| 89 * @return The SSL connection handle. | |
| 90 */ | |
| 91 GaimSslConnection *gaim_ssl_connect(GaimAccount *account, const char *host, | |
| 92 int port, GaimSslInputFunction func, | |
| 93 void *data); | |
| 94 | |
| 95 /** | |
| 96 * Closes a SSL connection. | |
| 97 * | |
| 98 * @param gsc The SSL connection to close. | |
| 99 */ | |
| 100 void gaim_ssl_close(GaimSslConnection *gsc); | |
| 101 | |
| 102 /** | |
| 103 * Reads data from an SSL connection. | |
| 104 * | |
| 105 * @param gsc The SSL connection handle. | |
| 106 * @param buffer The destination buffer. | |
| 107 * @param len The maximum number of bytes to read. | |
| 108 * | |
| 109 * @return The number of bytes read. | |
| 110 */ | |
|
6720
41120df7ed94
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6703
diff
changeset
|
111 size_t gaim_ssl_read(GaimSslConnection *gsc, void *buffer, size_t len); |
| 6703 | 112 |
| 113 /** | |
| 114 * Writes data to an SSL connection. | |
| 115 * | |
|
6720
41120df7ed94
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6703
diff
changeset
|
116 * @param gsc The SSL connection handle. |
|
41120df7ed94
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6703
diff
changeset
|
117 * @param buffer The buffer to write. |
|
41120df7ed94
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6703
diff
changeset
|
118 * @param len The length of the data to write. |
| 6703 | 119 * |
| 120 * @return The number of bytes written. | |
| 121 */ | |
|
6720
41120df7ed94
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6703
diff
changeset
|
122 size_t gaim_ssl_write(GaimSslConnection *gsc, const void *buffer, size_t len); |
| 6703 | 123 |
| 124 /*@}*/ | |
| 125 | |
| 126 /**************************************************************************/ | |
| 127 /** @name Subsystem API */ | |
| 128 /**************************************************************************/ | |
| 129 /*@{*/ | |
| 130 | |
| 131 /** | |
|
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
132 * Sets the current SSL operations structure. |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
133 * |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
134 * @param ops The SSL operations structure to assign. |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
135 */ |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
136 void gaim_ssl_set_ops(GaimSslOps *ops); |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
137 |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
138 /** |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
139 * Returns the current SSL operations structure. |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
140 * |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
141 * @return The SSL operations structure. |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
142 */ |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
143 GaimSslOps *gaim_ssl_get_ops(void); |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
144 |
|
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
145 /** |
| 6703 | 146 * Initializes the SSL subsystem. |
| 147 */ | |
| 148 void gaim_ssl_init(void); | |
| 149 | |
| 150 /** | |
| 151 * Uninitializes the SSL subsystem. | |
| 152 */ | |
| 153 void gaim_ssl_uninit(void); | |
| 154 | |
| 155 /*@}*/ | |
| 156 | |
| 157 #ifdef __cplusplus | |
| 158 } | |
| 159 #endif | |
| 160 | |
| 161 #endif /* _GAIM_SSL_H_ */ |
