Mercurial > pidgin
annotate src/protocols/novell/nmconn.h @ 8874:a2affcdf8e01
[gaim-migrate @ 9643]
"This patch fixes the Novell protocol plugin on big
endian platforms (Bug #947017). It also includes a fix
for disconnects when sending large messages." --Mike Stoddard (novell)
committer: Tailor Script <tailor@pidgin.im>
| author | Luke Schierer <lschiere@pidgin.im> |
|---|---|
| date | Wed, 05 May 2004 20:29:21 +0000 |
| parents | 046dd8ef2920 |
| children | 6663ad2386d9 |
| rev | line source |
|---|---|
| 8675 | 1 /* |
| 2 * nmconn.h | |
| 3 * | |
| 4 * Copyright © 2004 Unpublished Work of Novell, Inc. All Rights Reserved. | |
| 5 * | |
| 6 * THIS WORK IS AN UNPUBLISHED WORK OF NOVELL, INC. NO PART OF THIS WORK MAY BE | |
| 7 * USED, PRACTICED, PERFORMED, COPIED, DISTRIBUTED, REVISED, MODIFIED, | |
| 8 * TRANSLATED, ABRIDGED, CONDENSED, EXPANDED, COLLECTED, COMPILED, LINKED, | |
| 9 * RECAST, TRANSFORMED OR ADAPTED WITHOUT THE PRIOR WRITTEN CONSENT OF NOVELL, | |
| 10 * INC. ANY USE OR EXPLOITATION OF THIS WORK WITHOUT AUTHORIZATION COULD SUBJECT | |
| 11 * THE PERPETRATOR TO CRIMINAL AND CIVIL LIABILITY. | |
|
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8675
diff
changeset
|
12 * |
| 8675 | 13 * AS BETWEEN [GAIM] AND NOVELL, NOVELL GRANTS [GAIM] THE RIGHT TO REPUBLISH |
| 14 * THIS WORK UNDER THE GPL (GNU GENERAL PUBLIC LICENSE) WITH ALL RIGHTS AND | |
| 15 * LICENSES THEREUNDER. IF YOU HAVE RECEIVED THIS WORK DIRECTLY OR INDIRECTLY | |
| 16 * FROM [GAIM] AS PART OF SUCH A REPUBLICATION, YOU HAVE ALL RIGHTS AND LICENSES | |
| 17 * GRANTED BY [GAIM] UNDER THE GPL. IN CONNECTION WITH SUCH A REPUBLICATION, IF | |
| 18 * ANYTHING IN THIS NOTICE CONFLICTS WITH THE TERMS OF THE GPL, SUCH TERMS | |
| 19 * PREVAIL. | |
| 20 * | |
| 21 */ | |
| 22 | |
| 23 #ifndef __NM_CONN_H__ | |
| 24 #define __NM_CONN_H__ | |
| 25 | |
| 26 typedef struct _NMConn NMConn; | |
| 27 typedef struct _NMSSLConn NMSSLConn; | |
| 28 | |
| 29 #include "nmfield.h" | |
| 30 #include "nmuser.h" | |
| 31 | |
| 32 typedef int (*nm_ssl_read_cb) (gpointer ssl_data, void *buff, int len); | |
| 33 typedef int (*nm_ssl_write_cb) (gpointer ssl_data, const void *buff, int len); | |
| 34 | |
| 35 struct _NMConn | |
| 36 { | |
| 37 | |
| 38 /* The address of the server that we are connecting to. */ | |
| 39 char *addr; | |
| 40 | |
| 41 /* The port that we are connecting to. */ | |
| 42 int port; | |
| 43 | |
| 44 /* The file descriptor of the socket for the connection. */ | |
| 45 int fd; | |
| 46 | |
| 47 /* The transaction counter. */ | |
| 48 int trans_id; | |
| 49 | |
| 50 /* A list of requests currently awaiting a response. */ | |
| 51 GSList *requests; | |
| 52 | |
| 53 /* Are we connected? TRUE if so, FALSE if not. */ | |
| 54 gboolean connected; | |
| 55 | |
| 56 /* Are we running in secure mode? */ | |
| 57 gboolean use_ssl; | |
| 58 | |
| 59 /* Have we been redirected? */ | |
| 60 gboolean redirect; | |
| 61 | |
| 62 /* SSL connection */ | |
| 63 NMSSLConn *ssl_conn; | |
| 64 | |
| 65 }; | |
| 66 | |
| 67 struct _NMSSLConn | |
| 68 { | |
| 69 | |
| 70 /* Data to pass to the callbacks */ | |
| 71 gpointer data; | |
| 72 | |
| 73 /* Callbacks for reading/writing */ | |
| 74 nm_ssl_read_cb read; | |
| 75 nm_ssl_write_cb write; | |
| 76 | |
| 77 }; | |
| 78 | |
| 79 /** | |
| 80 * Write len bytes from the given buffer. | |
| 81 * | |
| 82 * @param conn The connection to write to. | |
| 83 * @param buff The buffer to write from. | |
| 84 * @param len The number of bytes to write. | |
| 85 * | |
| 86 * @return The number of bytes written. | |
| 87 */ | |
| 88 int nm_tcp_write(NMConn * conn, const void *buff, int len); | |
| 89 | |
| 90 /** | |
| 91 * Read at most len bytes into the given buffer. | |
| 92 * | |
| 93 * @param conn The connection to read from. | |
| 94 * @param buff The buffer to write to. | |
| 95 * @param len The maximum number of bytes to read. | |
| 96 * | |
| 97 * @return The number of bytes read. | |
| 98 */ | |
| 99 int nm_tcp_read(NMConn * conn, void *buff, int len); | |
| 100 | |
| 101 /** | |
| 102 * Read exactly len bytes into the given buffer. | |
| 103 * | |
| 104 * @param conn The connection to read from. | |
| 105 * @param buff The buffer to write to. | |
| 106 * @param len The number of bytes to read. | |
| 107 * | |
| 108 * @return NM_OK on success, NMERR_TCP_READ if read fails. | |
| 109 */ | |
| 110 NMERR_T nm_read_all(NMConn * conn, char *buf, int len); | |
| 111 | |
| 112 /** | |
| 8874 | 113 * Read a 32 bit value and convert it to the host byte order. |
| 114 * | |
| 115 * @param conn The connection to read from. | |
| 116 * @param val A pointer to unsigned 32 bit integer | |
| 117 * | |
| 118 * @return NM_OK on success, NMERR_TCP_READ if read fails. | |
| 119 */ | |
| 120 NMERR_T | |
| 121 nm_read_uint32(NMConn *conn, guint32 *val); | |
| 122 | |
| 123 /** | |
| 124 * Read a 16 bit value and convert it to the host byte order. | |
| 125 * | |
| 126 * @param conn The connection to read from. | |
| 127 * @param val A pointer to unsigned 16 bit integer | |
| 128 * | |
| 129 * @return NM_OK on success, NMERR_TCP_READ if read fails. | |
| 130 */ | |
| 131 NMERR_T | |
| 132 nm_read_uint16(NMConn *conn, guint16 *val); | |
| 133 | |
| 134 /** | |
| 8675 | 135 * Dispatch a request to the server. |
| 136 * | |
| 137 * @param conn The connection. | |
| 138 * @param cmd The request to dispatch. | |
| 139 * @param fields The field list for the request. | |
| 140 * @param req The request. Should be freed with nm_release_request. | |
| 141 * | |
| 142 * @return NM_OK on success. | |
| 143 */ | |
| 144 NMERR_T nm_send_request(NMConn * conn, char *cmd, NMField * fields, | |
| 145 NMRequest ** req); | |
| 146 | |
| 147 /** | |
| 148 * Write out the given field list. | |
| 149 * | |
| 150 * @param conn The connection to write to. | |
| 151 * @param fields The field list to write. | |
| 152 * | |
| 153 * @return NM_OK on success. | |
| 154 */ | |
| 155 NMERR_T nm_write_fields(NMConn * conn, NMField * fields); | |
| 156 | |
| 157 /** | |
| 158 * Read the headers for a response. | |
| 159 * | |
| 160 * @param conn The connection to read from. | |
| 161 * | |
| 162 * @return NM_OK on success. | |
| 163 */ | |
| 164 NMERR_T nm_read_header(NMConn * conn); | |
| 165 | |
| 166 /** | |
| 167 * Read a field list from the connection. | |
| 168 * | |
| 169 * @param conn The connection to read from. | |
| 170 * @param count The maximum number of fields to read (or -1 for no max). | |
| 171 * @param fields The field list. This is an out param. It | |
| 172 * should be freed by calling nm_free_fields | |
| 173 * when finished. | |
| 174 * | |
| 175 * @return NM_OK on success. | |
| 176 */ | |
| 177 NMERR_T nm_read_fields(NMConn * conn, int count, NMField ** fields); | |
| 178 | |
| 179 /** | |
| 180 * Add a request to the connections request list. | |
| 181 * | |
| 182 * @param conn The connection. | |
| 183 * @param request The request to add to the list. | |
| 184 */ | |
| 185 void nm_conn_add_request_item(NMConn * conn, NMRequest * request); | |
| 186 | |
| 187 /** | |
| 188 * Remove a request from the connections list. | |
| 189 * | |
| 190 * @param conn The connection. | |
| 191 * @param request The request to remove from the list. | |
| 192 */ | |
| 193 void nm_conn_remove_request_item(NMConn * conn, NMRequest * request); | |
| 194 | |
| 195 /** | |
| 196 * Find the request with the given transaction id in the connections | |
| 197 * request list. | |
| 198 * | |
| 199 * @param conn The connection. | |
| 200 * @param trans_id The transaction id of the request to return. | |
| 201 * | |
| 202 * @return The request, or NULL if a matching request is not | |
| 203 * found. | |
| 204 */ | |
| 205 NMRequest *nm_conn_find_request(NMConn * conn, int trans_id); | |
| 206 | |
| 207 /** | |
| 208 * Get the server address for the connection. | |
| 209 * | |
| 210 * @param conn The connection. | |
| 211 * | |
| 212 * @return The server address for the connection. | |
| 213 * | |
| 214 */ | |
| 215 const char *nm_conn_get_addr(NMConn * conn); | |
| 216 | |
| 217 /** | |
| 218 * Get the port for the connection. | |
| 219 * | |
| 220 * @param conn The connection. | |
| 221 * | |
| 222 * @return The port that we are connected to. | |
| 223 */ | |
| 224 int nm_conn_get_port(NMConn * conn); | |
| 225 | |
| 226 #endif |
