| |
1 /* |
| |
2 * Main libfaim header. Must be included in client for prototypes/macros. |
| |
3 * |
| |
4 */ |
| |
5 |
| 1 #ifndef __AIM_H__ |
6 #ifndef __AIM_H__ |
| 2 #define __AIM_H__ |
7 #define __AIM_H__ |
| 3 |
8 |
| 4 #include <faimconfig.h> |
9 #include <faimconfig.h> |
| 5 |
10 #include <aim_cbtypes.h> |
| 6 /* some global includes */ |
11 |
| 7 #include <stdio.h> |
12 #include <stdio.h> |
| 8 #include <string.h> |
13 #include <string.h> |
| 9 #include <fcntl.h> |
14 #include <fcntl.h> |
| |
15 #include <sys/types.h> |
| |
16 #include <stdlib.h> |
| |
17 #include <stdarg.h> |
| |
18 #include <errno.h> |
| |
19 |
| |
20 #ifdef _WIN32 |
| |
21 #include <windows.h> |
| |
22 #include <time.h> |
| |
23 #include <io.h> |
| |
24 #else |
| 10 #include <netdb.h> |
25 #include <netdb.h> |
| 11 #include <sys/types.h> |
|
| 12 #include <sys/socket.h> |
26 #include <sys/socket.h> |
| 13 #include <netinet/in.h> |
27 #include <netinet/in.h> |
| 14 #include <sys/time.h> |
28 #include <sys/time.h> |
| 15 #include <unistd.h> |
29 #include <unistd.h> |
| 16 #include <stdlib.h> |
30 #endif |
| 17 #include <stdarg.h> |
31 |
| 18 #include <errno.h> |
32 /* Portability stuff (DMP) */ |
| 19 |
33 |
| 20 #define CONNECT_SIG_LEN 10 /* not used anymore, hopefully */ |
34 #ifdef _WIN32 |
| 21 #define LOGIN_RESP_LEN 512 /* should only be 334b but no segfault for us! */ |
35 #define sleep Sleep |
| 22 |
36 #define strlen(x) (int)strlen(x) /* win32 has a unsigned size_t */ |
| 23 |
37 #endif |
| 24 /* |
38 |
| 25 * Error codes |
39 #if defined(_WIN32) || (defined(mach) && defined(__APPLE__)) |
| 26 */ |
40 #define gethostbyname2(x,y) gethostbyname(x) /* revert to IPv4 */ |
| 27 #define AIM_CONNECT_ERROR -0x1 |
41 #endif |
| 28 #define AIM_SIGNON_TOO_SOON -0x4 |
42 |
| 29 #define AIM_SERVICE_FULL -0x6f |
43 /* |
| 30 |
44 * Current Maximum Length for Screen Names (not including NULL) |
| 31 |
45 */ |
| 32 struct login_phase1_struct { |
46 #define MAXSNLEN 16 |
| 33 char *screen_name; |
47 |
| |
48 /* |
| |
49 * Standard size of an AIM authorization cookie |
| |
50 */ |
| |
51 #define AIM_COOKIELEN 0x100 |
| |
52 |
| |
53 #if debug > 0 |
| |
54 #define faimdprintf(l, x...) {if (l >= debug) printf(x); } |
| |
55 #else |
| |
56 #define faimdprintf(l, x...) |
| |
57 #endif |
| |
58 |
| |
59 /* |
| |
60 * Login info. Passes information from the Authorization |
| |
61 * stage of login to the service (BOS, etc) connection |
| |
62 * phase. |
| |
63 * |
| |
64 */ |
| |
65 struct aim_login_struct { |
| |
66 char screen_name[MAXSNLEN+1]; |
| 34 char *BOSIP; |
67 char *BOSIP; |
| 35 char *cookie; |
68 char cookie[AIM_COOKIELEN]; |
| 36 char *email; |
69 char *email; |
| 37 ushort regstatus; |
70 u_short regstatus; |
| 38 }; |
71 char *errorurl; |
| 39 |
72 u_short errorcode; |
| 40 extern struct login_phase1_struct aim_logininfo; |
73 }; |
| 41 |
74 |
| |
75 /* |
| |
76 * Client info. Filled in by the client and passed |
| |
77 * in to aim_login(). The information ends up |
| |
78 * getting passed to OSCAR through the initial |
| |
79 * login command. |
| |
80 * |
| |
81 * XXX: Should this be per-session? -mid |
| |
82 * |
| |
83 */ |
| 42 struct client_info_s { |
84 struct client_info_s { |
| 43 char clientstring[100]; /* arbitrary number */ |
85 char clientstring[100]; /* arbitrary size */ |
| 44 int major; |
86 int major; |
| 45 int minor; |
87 int minor; |
| 46 int build; |
88 int build; |
| 47 char country[3]; |
89 char country[3]; |
| 48 char lang[3]; |
90 char lang[3]; |
| 49 }; |
91 }; |
| 50 |
92 |
| 51 struct connection_info_struct { |
|
| 52 unsigned int local_seq_num_origin; /* our first seq num */ |
|
| 53 int local_command_count; |
|
| 54 |
|
| 55 unsigned int remote_seq_num_origin; /* oscar's first seqnum */ |
|
| 56 int remote_command_count; /* command_count + seq_num_origin = cur_seq_num */ |
|
| 57 |
|
| 58 char *sn; /* our screen name */ |
|
| 59 |
|
| 60 int fd; /* socket descriptor */ |
|
| 61 }; |
|
| 62 |
|
| 63 #ifndef TRUE |
93 #ifndef TRUE |
| 64 #define TRUE 1 |
94 #define TRUE 1 |
| 65 #define FALSE 0 |
95 #define FALSE 0 |
| 66 #endif |
96 #endif |
| 67 |
97 |
| 68 #define AIM_CONN_MAX 5 |
98 /* |
| 69 /* these could be arbitrary, but its easier to use the actual AIM values */ |
99 * These could be arbitrary, but its easier to use the actual AIM values |
| 70 #define AIM_CONN_TYPE_AUTH 0x0007 |
100 */ |
| 71 #define AIM_CONN_TYPE_ADS 0x0005 |
101 #define AIM_CONN_TYPE_AUTH 0x0007 |
| 72 #define AIM_CONN_TYPE_BOS 2 |
102 #define AIM_CONN_TYPE_ADS 0x0005 |
| 73 #define AIM_CONN_TYPE_CHAT 0x000e |
103 #define AIM_CONN_TYPE_BOS 0x0002 |
| 74 #define AIM_CONN_TYPE_CHATNAV 0x000d |
104 #define AIM_CONN_TYPE_CHAT 0x000e |
| 75 |
105 #define AIM_CONN_TYPE_CHATNAV 0x000d |
| 76 #define AIM_CONN_STATUS_READY 0x0001 |
106 |
| |
107 /* |
| |
108 * Status values returned from aim_conn_new(). ORed together. |
| |
109 */ |
| |
110 #define AIM_CONN_STATUS_READY 0x0001 |
| 77 #define AIM_CONN_STATUS_INTERNALERR 0x0002 |
111 #define AIM_CONN_STATUS_INTERNALERR 0x0002 |
| 78 #define AIM_CONN_STATUS_RESOLVERR 0x80 |
112 #define AIM_CONN_STATUS_RESOLVERR 0x0080 |
| 79 #define AIM_CONN_STATUS_CONNERR 0x40 |
113 #define AIM_CONN_STATUS_CONNERR 0x0040 |
| 80 |
|
| 81 |
114 |
| 82 struct aim_conn_t { |
115 struct aim_conn_t { |
| 83 int fd; |
116 int fd; |
| 84 int type; |
117 int type; |
| 85 int seqnum; |
118 int seqnum; |
| 86 int status; |
119 int status; |
| 87 }; |
120 void *priv; /* misc data the client may want to store */ |
| 88 struct aim_conn_t aim_conns[AIM_CONN_MAX]; |
121 time_t lastactivity; /* time of last transmit */ |
| 89 |
122 int forcedlatency; |
| |
123 struct aim_rxcblist_t *handlerlist; |
| |
124 }; |
| 90 |
125 |
| 91 /* struct for incoming commands */ |
126 /* struct for incoming commands */ |
| 92 struct command_rx_struct { |
127 struct command_rx_struct { |
| 93 /* byte 1 assumed to always be 0x2a */ |
128 /* byte 1 assumed to always be 0x2a */ |
| 94 char type; /* type code (byte 2) */ |
129 char type; /* type code (byte 2) */ |
| 95 unsigned int seqnum; /* sequence number (bytes 3 and 4) */ |
130 u_int seqnum; /* sequence number (bytes 3 and 4) */ |
| 96 unsigned int commandlen; /* total packet len - 6 (bytes 5 and 6) */ |
131 u_int commandlen; /* total packet len - 6 (bytes 5 and 6) */ |
| 97 char *data; /* packet data (from 7 byte on) */ |
132 u_char *data; /* packet data (from 7 byte on) */ |
| 98 unsigned int lock; /* 1 = locked, 0 = open */ |
133 u_int lock; /* 0 = open, !0 = locked */ |
| 99 unsigned int handled; /* 1 = been handled, 0 = new */ |
134 u_int handled; /* 0 = new, !0 = been handled */ |
| |
135 u_int nofree; /* 0 = free data on purge, 1 = only unlink */ |
| 100 struct aim_conn_t *conn; /* the connection it came in on... */ |
136 struct aim_conn_t *conn; /* the connection it came in on... */ |
| 101 struct command_rx_struct *next; /* ptr to next struct in list */ |
137 struct command_rx_struct *next; /* ptr to next struct in list */ |
| 102 }; |
138 }; |
| 103 |
139 |
| 104 /* struct for outgoing commands */ |
140 /* struct for outgoing commands */ |
| 105 struct command_tx_struct { |
141 struct command_tx_struct { |
| 106 /* byte 1 assumed to be 0x2a */ |
142 /* byte 1 assumed to be 0x2a */ |
| 107 char type; /* type/family code */ |
143 char type; /* type/family code */ |
| 108 unsigned int seqnum; /* seqnum dynamically assigned on tx */ |
144 u_int seqnum; /* seqnum dynamically assigned on tx */ |
| 109 unsigned int commandlen; /* SNAC length */ |
145 u_int commandlen; /* SNAC length */ |
| 110 char *data; /* packet data */ |
146 u_char *data; /* packet data */ |
| 111 unsigned int lock; /* 1 = locked, 0 = open */ |
147 u_int lock; /* 0 = open, !0 = locked */ |
| 112 unsigned int sent; /* 1 = has been sent, 0 = new */ |
148 u_int sent; /* 0 = pending, !0 = has been sent */ |
| 113 struct aim_conn_t *conn; |
149 struct aim_conn_t *conn; |
| 114 struct command_tx_struct *next; /* ptr to next struct in list */ |
150 struct command_tx_struct *next; /* ptr to next struct in list */ |
| 115 }; |
151 }; |
| 116 |
152 |
| 117 /* TLV-related tidbits */ |
153 |
| |
154 /* |
| |
155 * AIM Session: The main client-data interface. |
| |
156 * |
| |
157 */ |
| |
158 struct aim_session_t { |
| |
159 |
| |
160 /* ---- Client Accessible ------------------------ */ |
| |
161 /* |
| |
162 * Login information. See definition above. |
| |
163 * |
| |
164 */ |
| |
165 struct aim_login_struct logininfo; |
| |
166 |
| |
167 /* |
| |
168 * Pointer to anything the client wants to |
| |
169 * explicitly associate with this session. |
| |
170 */ |
| |
171 void *aux_data; |
| |
172 |
| |
173 |
| |
174 /* ---- Internal Use Only ------------------------ */ |
| |
175 /* |
| |
176 * Connection information |
| |
177 */ |
| |
178 struct aim_conn_t conns[AIM_CONN_MAX]; |
| |
179 |
| |
180 /* |
| |
181 * TX/RX queues |
| |
182 */ |
| |
183 struct command_tx_struct *queue_outgoing; |
| |
184 struct command_rx_struct *queue_incoming; |
| |
185 |
| |
186 /* |
| |
187 * This is a dreadful solution to the what-room-are-we-joining |
| |
188 * problem. (There's no connection between the service |
| |
189 * request and the resulting redirect.) |
| |
190 */ |
| |
191 char *pendingjoin; |
| |
192 |
| |
193 /* |
| |
194 * Outstanding snac handling |
| |
195 * |
| |
196 * XXX: Should these be per-connection? -mid |
| |
197 **/ |
| |
198 struct aim_snac_t *outstanding_snacs; |
| |
199 u_long snac_nextid; |
| |
200 }; |
| |
201 |
| |
202 |
| |
203 /* |
| |
204 * AIM User Info, Standard Form. |
| |
205 */ |
| |
206 struct aim_userinfo_s { |
| |
207 char sn[MAXSNLEN+1]; |
| |
208 u_short warnlevel; |
| |
209 u_short idletime; |
| |
210 u_short class; |
| |
211 u_long membersince; |
| |
212 u_long onlinesince; |
| |
213 u_long sessionlen; |
| |
214 u_short capabilities; |
| |
215 }; |
| |
216 |
| |
217 #define AIM_CLASS_TRIAL 0x0001 |
| |
218 #define AIM_CLASS_UNKNOWN2 0x0002 |
| |
219 #define AIM_CLASS_AOL 0x0004 |
| |
220 #define AIM_CLASS_UNKNOWN4 0x0008 |
| |
221 #define AIM_CLASS_FREE 0x0010 |
| |
222 #define AIM_CLASS_AWAY 0x0020 |
| |
223 #define AIM_CLASS_UNKNOWN40 0x0040 |
| |
224 #define AIM_CLASS_UNKNOWN80 0x0080 |
| |
225 |
| |
226 /* |
| |
227 * TLV handling |
| |
228 */ |
| |
229 |
| |
230 /* Generic TLV structure. */ |
| 118 struct aim_tlv_t { |
231 struct aim_tlv_t { |
| 119 u_short type; |
232 u_short type; |
| 120 u_short length; |
233 u_short length; |
| 121 u_char *value; |
234 u_char *value; |
| 122 }; |
235 }; |
| 123 |
236 |
| |
237 /* List of above. */ |
| |
238 struct aim_tlvlist_t { |
| |
239 struct aim_tlv_t *tlv; |
| |
240 struct aim_tlvlist_t *next; |
| |
241 }; |
| |
242 |
| |
243 /* TLV-handling functions */ |
| |
244 struct aim_tlvlist_t *aim_readtlvchain(u_char *buf, int maxlen); |
| |
245 void aim_freetlvchain(struct aim_tlvlist_t **list); |
| 124 struct aim_tlv_t *aim_grabtlv(u_char *src); |
246 struct aim_tlv_t *aim_grabtlv(u_char *src); |
| 125 struct aim_tlv_t *aim_grabtlvstr(u_char *src); |
247 struct aim_tlv_t *aim_grabtlvstr(u_char *src); |
| |
248 struct aim_tlv_t *aim_gettlv(struct aim_tlvlist_t *, u_short, int); |
| |
249 char *aim_gettlv_str(struct aim_tlvlist_t *, u_short, int); |
| 126 int aim_puttlv (u_char *dest, struct aim_tlv_t *newtlv); |
250 int aim_puttlv (u_char *dest, struct aim_tlv_t *newtlv); |
| 127 struct aim_tlv_t *aim_createtlv(void); |
251 struct aim_tlv_t *aim_createtlv(void); |
| 128 int aim_freetlv(struct aim_tlv_t **oldtlv); |
252 int aim_freetlv(struct aim_tlv_t **oldtlv); |
| 129 int aim_puttlv_16(u_char *, u_short, u_short); |
253 int aim_puttlv_16(u_char *, u_short, u_short); |
| 130 |
254 int aim_puttlv_32(u_char *, u_short, u_long); |
| 131 /* some prototypes... */ |
255 int aim_puttlv_str(u_char *buf, u_short t, u_short l, u_char *v); |
| 132 |
256 int aim_writetlvchain(u_char *buf, int buflen, struct aim_tlvlist_t **list); |
| 133 /* implicitly or explicitly called */ |
257 int aim_addtlvtochain16(struct aim_tlvlist_t **list, unsigned short type, unsigned short val); |
| 134 int aim_get_command(void); |
258 int aim_addtlvtochain32(struct aim_tlvlist_t **list, unsigned short type, unsigned long val); |
| 135 int aim_rxdispatch(void); |
259 int aim_addtlvtochain_str(struct aim_tlvlist_t **list, unsigned short type, char *str, int len); |
| 136 int aim_logoff(void); |
260 int aim_counttlvchain(struct aim_tlvlist_t **list); |
| 137 |
261 |
| 138 typedef int (*rxcallback_t)(struct command_rx_struct *, ...); |
262 /* |
| |
263 * Get command from connections / Dispatch commands |
| |
264 * already in queue. |
| |
265 */ |
| |
266 int aim_get_command(struct aim_session_t *, struct aim_conn_t *); |
| |
267 int aim_rxdispatch(struct aim_session_t *); |
| |
268 |
| |
269 int aim_logoff(struct aim_session_t *); |
| |
270 |
| |
271 |
| |
272 typedef int (*rxcallback_t)(struct aim_session_t *, struct command_rx_struct *, ...); |
| 139 int aim_register_callbacks(rxcallback_t *); |
273 int aim_register_callbacks(rxcallback_t *); |
| 140 |
274 |
| 141 u_long aim_genericreq_n(struct aim_conn_t *conn, u_short family, u_short subtype); |
275 u_long aim_genericreq_n(struct aim_session_t *, struct aim_conn_t *conn, u_short family, u_short subtype); |
| 142 u_long aim_genericreq_l(struct aim_conn_t *conn, u_short family, u_short subtype, u_long *); |
276 u_long aim_genericreq_l(struct aim_session_t *, struct aim_conn_t *conn, u_short family, u_short subtype, u_long *); |
| 143 u_long aim_genericreq_s(struct aim_conn_t *conn, u_short family, u_short subtype, u_short *); |
277 u_long aim_genericreq_s(struct aim_session_t *, struct aim_conn_t *conn, u_short family, u_short subtype, u_short *); |
| 144 |
278 |
| 145 /* aim_login.c */ |
279 /* aim_login.c */ |
| 146 int aim_send_login (struct aim_conn_t *, char *, char *, struct client_info_s *); |
280 int aim_sendconnack(struct aim_session_t *sess, struct aim_conn_t *conn); |
| 147 int aim_encode_password(const char *, char *); |
281 int aim_request_login (struct aim_session_t *sess, struct aim_conn_t *conn, char *sn); |
| 148 |
282 int aim_send_login (struct aim_session_t *, struct aim_conn_t *, char *, char *, struct client_info_s *); |
| 149 |
283 int aim_encode_password(const char *, u_char *); |
| 150 struct command_rx_struct *aim_purge_rxqueue(struct command_rx_struct *queue); |
284 unsigned long aim_sendauthresp(struct aim_session_t *sess, |
| 151 |
285 struct aim_conn_t *conn, |
| 152 |
286 char *sn, char *bosip, |
| 153 int aim_parse_unknown(struct command_rx_struct *command, ...); |
287 char *cookie, char *email, |
| 154 int aim_parse_missed_im(struct command_rx_struct *, ...); |
288 int regstatus); |
| 155 int aim_parse_last_bad(struct command_rx_struct *, ...); |
289 int aim_gencookie(unsigned char *buf); |
| 156 |
290 int aim_sendserverready(struct aim_session_t *sess, struct aim_conn_t *conn); |
| 157 int aim_tx_enqueue(struct command_tx_struct *); |
291 unsigned long aim_sendredirect(struct aim_session_t *sess, |
| 158 unsigned int aim_get_next_txseqnum(struct aim_conn_t *); |
292 struct aim_conn_t *conn, |
| 159 int aim_tx_flushqueue(void); |
293 unsigned short servid, |
| 160 int aim_tx_printqueue(void); |
294 char *ip, |
| 161 int aim_tx_purgequeue(void); |
295 char *cookie); |
| 162 |
296 void aim_purge_rxqueue(struct aim_session_t *); |
| 163 /* queue (linked list) pointers */ |
297 |
| 164 extern struct command_tx_struct *aim_queue_outgoing; /* incoming commands */ |
298 |
| 165 extern struct command_rx_struct *aim_queue_incoming; /* outgoing commands */ |
299 int aim_parse_unknown(struct aim_session_t *, struct command_rx_struct *command, ...); |
| 166 |
300 int aim_parse_missed_im(struct aim_session_t *, struct command_rx_struct *, ...); |
| 167 /* The default callback handler array */ |
301 int aim_parse_last_bad(struct aim_session_t *, struct command_rx_struct *, ...); |
| 168 extern rxcallback_t aim_callbacks[]; |
302 |
| 169 |
303 struct command_tx_struct *aim_tx_new(int, struct aim_conn_t *, int); |
| 170 extern struct aim_snac_t *aim_outstanding_snacs; |
304 int aim_tx_enqueue(struct aim_session_t *, struct command_tx_struct *); |
| 171 extern u_long aim_snac_nextid; |
305 u_int aim_get_next_txseqnum(struct aim_conn_t *); |
| 172 |
306 int aim_tx_flushqueue(struct aim_session_t *); |
| 173 #define AIM_CB_INCOMING_IM 0 |
307 int aim_tx_printqueue(struct aim_session_t *); |
| 174 #define AIM_CB_ONCOMING_BUDDY 1 |
308 void aim_tx_purgequeue(struct aim_session_t *); |
| 175 #define AIM_CB_OFFGOING_BUDDY 2 |
309 |
| 176 #define AIM_CB_MISSED_IM 3 |
310 struct aim_rxcblist_t { |
| 177 #define AIM_CB_MISSED_CALL 4 |
311 u_short family; |
| 178 #define AIM_CB_LOGIN_P4_C1 5 |
312 u_short type; |
| 179 #define AIM_CB_LOGIN_P4_C2 6 |
313 rxcallback_t handler; |
| 180 #define AIM_CB_LOGIN_P2_1 7 |
314 u_short flags; |
| 181 #define AIM_CB_LOGIN_P2_2 8 |
315 struct aim_rxcblist_t *next; |
| 182 #define AIM_CB_LOGIN_P3_B 9 |
316 }; |
| 183 #define AIM_CB_LOGIN_P3D_A 10 |
317 |
| 184 #define AIM_CB_LOGIN_P3D_B 11 |
318 int aim_conn_setlatency(struct aim_conn_t *conn, int newval); |
| 185 #define AIM_CB_LOGIN_P3D_C 12 |
319 |
| 186 #define AIM_CB_LOGIN_P3D_D 13 |
320 int aim_conn_addhandler(struct aim_session_t *, struct aim_conn_t *conn, u_short family, u_short type, rxcallback_t newhandler, u_short flags); |
| 187 #define AIM_CB_LOGIN_P3D_E 14 |
321 rxcallback_t aim_callhandler(struct aim_conn_t *conn, u_short family, u_short type); |
| 188 #define AIM_CB_LOGIN_P3D_F 15 |
322 int aim_clearhandlers(struct aim_conn_t *conn); |
| 189 #define AIM_CB_RATECHANGE 16 |
323 |
| 190 #define AIM_CB_USERERROR 17 |
324 /* |
| 191 #define AIM_CB_UNKNOWN 18 |
325 * Generic SNAC structure. Rarely if ever used. |
| 192 #define AIM_CB_USERINFO 19 |
326 */ |
| 193 #define AIM_CB_SEARCH_ADDRESS 20 |
|
| 194 #define AIM_CB_SEARCH_NAME 21 |
|
| 195 #define AIM_CB_SEARCH_FAIL 22 |
|
| 196 #define AIM_CB_AUTH_ERROR 23 |
|
| 197 #define AIM_CB_AUTH_SUCCESS 24 |
|
| 198 #define AIM_CB_AUTH_SVRREADY 25 |
|
| 199 #define AIM_CB_AUTH_OTHER 26 |
|
| 200 #define AIM_CB_AUTH_INFOCHNG_REPLY 27 |
|
| 201 #define AIM_CB_CHATNAV_SVRREADY 28 |
|
| 202 |
|
| 203 int Read(int, u_char *, int); |
|
| 204 |
|
| 205 struct aim_snac_t { |
327 struct aim_snac_t { |
| 206 u_long id; |
328 u_long id; |
| 207 u_short family; |
329 u_short family; |
| 208 u_short type; |
330 u_short type; |
| 209 u_short flags; |
331 u_short flags; |
| 210 void *data; |
332 void *data; |
| 211 time_t issuetime; |
333 time_t issuetime; |
| 212 struct aim_snac_t *next; |
334 struct aim_snac_t *next; |
| 213 }; |
335 }; |
| 214 u_long aim_newsnac(struct aim_snac_t *newsnac); |
336 u_long aim_newsnac(struct aim_session_t *, struct aim_snac_t *newsnac); |
| 215 struct aim_snac_t *aim_remsnac(u_long id); |
337 struct aim_snac_t *aim_remsnac(struct aim_session_t *, u_long id); |
| 216 int aim_cleansnacs(int maxage); |
338 int aim_cleansnacs(struct aim_session_t *, int maxage); |
| 217 int aim_putsnac(u_char *, int, int, int, u_long); |
339 int aim_putsnac(u_char *, int, int, int, u_long); |
| 218 |
340 |
| 219 void aim_connrst(void); |
341 |
| 220 struct aim_conn_t *aim_conn_getnext(void); |
342 void aim_connrst(struct aim_session_t *); |
| |
343 struct aim_conn_t *aim_conn_getnext(struct aim_session_t *); |
| 221 void aim_conn_close(struct aim_conn_t *deadconn); |
344 void aim_conn_close(struct aim_conn_t *deadconn); |
| 222 struct aim_conn_t *aim_getconn_type(int type); |
345 struct aim_conn_t *aim_getconn_type(struct aim_session_t *, int type); |
| 223 struct aim_conn_t *aim_newconn(int type, char *dest); |
346 struct aim_conn_t *aim_newconn(struct aim_session_t *, int type, char *dest); |
| 224 int aim_conngetmaxfd(void); |
347 int aim_conngetmaxfd(struct aim_session_t *); |
| 225 struct aim_conn_t *aim_select(struct timeval *); |
348 struct aim_conn_t *aim_select(struct aim_session_t *, struct timeval *, int *); |
| 226 int aim_conn_isready(struct aim_conn_t *); |
349 int aim_conn_isready(struct aim_conn_t *); |
| 227 int aim_conn_setstatus(struct aim_conn_t *, int); |
350 int aim_conn_setstatus(struct aim_conn_t *, int); |
| |
351 void aim_session_init(struct aim_session_t *); |
| 228 |
352 |
| 229 /* aim_misc.c */ |
353 /* aim_misc.c */ |
| 230 |
354 |
| 231 #define AIM_VISIBILITYCHANGE_PERMITADD 0x05 |
355 #define AIM_VISIBILITYCHANGE_PERMITADD 0x05 |
| 232 #define AIM_VISIBILITYCHANGE_PERMITREMOVE 0x06 |
356 #define AIM_VISIBILITYCHANGE_PERMITREMOVE 0x06 |
| 233 #define AIM_VISIBILITYCHANGE_DENYADD 0x07 |
357 #define AIM_VISIBILITYCHANGE_DENYADD 0x07 |
| 234 #define AIM_VISIBILITYCHANGE_DENYREMOVE 0x08 |
358 #define AIM_VISIBILITYCHANGE_DENYREMOVE 0x08 |
| 235 |
359 |
| 236 u_long aim_bos_setidle(struct aim_conn_t *, u_long); |
360 u_long aim_bos_setidle(struct aim_session_t *, struct aim_conn_t *, u_long); |
| 237 u_long aim_bos_changevisibility(struct aim_conn_t *, int, char *); |
361 u_long aim_bos_changevisibility(struct aim_session_t *, struct aim_conn_t *, int, char *); |
| 238 u_long aim_bos_setbuddylist(struct aim_conn_t *, char *); |
362 u_long aim_bos_setbuddylist(struct aim_session_t *, struct aim_conn_t *, char *); |
| 239 u_long aim_bos_setprofile(struct aim_conn_t *, char *); |
363 u_long aim_bos_setprofile(struct aim_session_t *, struct aim_conn_t *, char *, char *, unsigned int); |
| 240 u_long aim_bos_setgroupperm(struct aim_conn_t *, u_long); |
364 u_long aim_bos_setgroupperm(struct aim_session_t *, struct aim_conn_t *, u_long); |
| 241 u_long aim_bos_clientready(struct aim_conn_t *); |
365 u_long aim_bos_clientready(struct aim_session_t *, struct aim_conn_t *); |
| 242 u_long aim_bos_reqrate(struct aim_conn_t *); |
366 u_long aim_bos_reqrate(struct aim_session_t *, struct aim_conn_t *); |
| 243 u_long aim_bos_ackrateresp(struct aim_conn_t *); |
367 u_long aim_bos_ackrateresp(struct aim_session_t *, struct aim_conn_t *); |
| 244 u_long aim_bos_setprivacyflags(struct aim_conn_t *, u_long); |
368 u_long aim_bos_setprivacyflags(struct aim_session_t *, struct aim_conn_t *, u_long); |
| 245 u_long aim_bos_reqpersonalinfo(struct aim_conn_t *); |
369 u_long aim_bos_reqpersonalinfo(struct aim_session_t *, struct aim_conn_t *); |
| 246 u_long aim_bos_reqservice(struct aim_conn_t *, u_short); |
370 u_long aim_bos_reqservice(struct aim_session_t *, struct aim_conn_t *, u_short); |
| 247 u_long aim_bos_reqrights(struct aim_conn_t *); |
371 u_long aim_bos_reqrights(struct aim_session_t *, struct aim_conn_t *); |
| 248 u_long aim_bos_reqbuddyrights(struct aim_conn_t *); |
372 u_long aim_bos_reqbuddyrights(struct aim_session_t *, struct aim_conn_t *); |
| 249 u_long aim_bos_reqlocaterights(struct aim_conn_t *); |
373 u_long aim_bos_reqlocaterights(struct aim_session_t *, struct aim_conn_t *); |
| 250 u_long aim_bos_reqicbmparaminfo(struct aim_conn_t *); |
374 u_long aim_bos_reqicbmparaminfo(struct aim_session_t *, struct aim_conn_t *); |
| |
375 u_long aim_setversions(struct aim_session_t *sess, struct aim_conn_t *conn); |
| 251 |
376 |
| 252 /* aim_rxhandlers.c */ |
377 /* aim_rxhandlers.c */ |
| 253 int aim_register_callbacks(rxcallback_t *); |
378 int aim_rxdispatch(struct aim_session_t *); |
| 254 int aim_rxdispatch(void); |
379 int aim_authparse(struct aim_session_t *, struct command_rx_struct *); |
| 255 int aim_authparse(struct command_rx_struct *); |
380 int aim_handleredirect_middle(struct aim_session_t *, struct command_rx_struct *, ...); |
| 256 int aim_handleredirect_middle(struct command_rx_struct *, ...); |
381 int aim_parse_unknown(struct aim_session_t *, struct command_rx_struct *, ...); |
| 257 int aim_parse_unknown(struct command_rx_struct *, ...); |
382 int aim_parse_last_bad(struct aim_session_t *, struct command_rx_struct *, ...); |
| 258 int aim_parse_missed_im(struct command_rx_struct *, ...); |
383 int aim_parse_generalerrs(struct aim_session_t *, struct command_rx_struct *command, ...); |
| 259 int aim_parse_last_bad(struct command_rx_struct *, ...); |
384 int aim_parsemotd_middle(struct aim_session_t *sess, struct command_rx_struct *command, ...); |
| 260 int aim_parse_generalerrs(struct command_rx_struct *command, ...); |
|
| 261 |
385 |
| 262 /* aim_im.c */ |
386 /* aim_im.c */ |
| 263 #define AIM_IMFLAGS_AWAY 0x01 /* mark as an autoreply */ |
387 #define AIM_IMFLAGS_AWAY 0x01 /* mark as an autoreply */ |
| 264 #define AIM_IMFLAGS_ACK 0x02 /* request a receipt notice */ |
388 #define AIM_IMFLAGS_ACK 0x02 /* request a receipt notice */ |
| 265 u_long aim_send_im(struct aim_conn_t *, char *, int, char *); |
389 |
| 266 int aim_parse_incoming_im_middle(struct command_rx_struct *); |
390 u_long aim_send_im(struct aim_session_t *, struct aim_conn_t *, char *, u_int, char *); |
| |
391 int aim_parse_incoming_im_middle(struct aim_session_t *, struct command_rx_struct *); |
| |
392 u_long aim_seticbmparam(struct aim_session_t *, struct aim_conn_t *conn); |
| |
393 int aim_parse_msgerror_middle(struct aim_session_t *, struct command_rx_struct *); |
| 267 |
394 |
| 268 /* aim_info.c */ |
395 /* aim_info.c */ |
| 269 u_long aim_getinfo(struct aim_conn_t *, const char *); |
396 #define AIM_CAPS_BUDDYICON 0x01 |
| 270 int aim_parse_userinfo_middle(struct command_rx_struct *); |
397 #define AIM_CAPS_VOICE 0x02 |
| |
398 #define AIM_CAPS_IMIMAGE 0x04 |
| |
399 #define AIM_CAPS_CHAT 0x08 |
| |
400 #define AIM_CAPS_GETFILE 0x10 |
| |
401 #define AIM_CAPS_SENDFILE 0x20 |
| |
402 extern u_char aim_caps[6][16]; |
| |
403 u_long aim_getinfo(struct aim_session_t *, struct aim_conn_t *, const char *); |
| |
404 int aim_extractuserinfo(u_char *, struct aim_userinfo_s *); |
| |
405 int aim_parse_userinfo_middle(struct aim_session_t *, struct command_rx_struct *); |
| |
406 int aim_parse_oncoming_middle(struct aim_session_t *, struct command_rx_struct *); |
| |
407 int aim_parse_offgoing_middle(struct aim_session_t *, struct command_rx_struct *); |
| |
408 int aim_putuserinfo(u_char *buf, int buflen, struct aim_userinfo_s *info); |
| |
409 int aim_sendbuddyoncoming(struct aim_session_t *sess, struct aim_conn_t *conn, struct aim_userinfo_s *info); |
| |
410 int aim_sendbuddyoffgoing(struct aim_session_t *sess, struct aim_conn_t *conn, char *sn); |
| |
411 |
| 271 |
412 |
| 272 /* aim_auth.c */ |
413 /* aim_auth.c */ |
| 273 int aim_auth_sendcookie(struct aim_conn_t *, char *); |
414 int aim_auth_sendcookie(struct aim_session_t *, struct aim_conn_t *, u_char *); |
| 274 u_long aim_auth_clientready(struct aim_conn_t *); |
415 u_long aim_auth_clientready(struct aim_session_t *, struct aim_conn_t *); |
| 275 u_long aim_auth_changepasswd(struct aim_conn_t *, char *, char *); |
416 u_long aim_auth_changepasswd(struct aim_session_t *, struct aim_conn_t *, char *, char *); |
| 276 |
417 |
| 277 /* aim_buddylist.c */ |
418 /* aim_buddylist.c */ |
| 278 u_long aim_add_buddy(struct aim_conn_t *, char *); |
419 u_long aim_add_buddy(struct aim_session_t *, struct aim_conn_t *, char *); |
| 279 u_long aim_remove_buddy(struct aim_conn_t *, char *); |
420 u_long aim_remove_buddy(struct aim_session_t *, struct aim_conn_t *, char *); |
| 280 |
421 |
| 281 /* aim_search.c */ |
422 /* aim_search.c */ |
| 282 u_long aim_usersearch_address(struct aim_conn_t *, char *); |
423 u_long aim_usersearch_address(struct aim_session_t *, struct aim_conn_t *, char *); |
| 283 /* u_long aim_usersearch_name(struct aim_conn_t *, char *); */ |
424 /* u_long aim_usersearch_name(struct aim_session_t *, struct aim_conn_t *, char *); */ |
| |
425 |
| |
426 |
| |
427 struct aim_chat_roominfo { |
| |
428 u_short exchange; |
| |
429 char *name; |
| |
430 u_short instance; |
| |
431 }; |
| |
432 int aim_chat_readroominfo(u_char *buf, struct aim_chat_roominfo *outinfo); |
| |
433 int aim_chat_parse_infoupdate(struct aim_session_t *sess, struct command_rx_struct *command); |
| |
434 int aim_chat_parse_joined(struct aim_session_t *sess, struct command_rx_struct *command); |
| |
435 int aim_chat_parse_leave(struct aim_session_t *sess, struct command_rx_struct *command); |
| |
436 int aim_chat_parse_incoming(struct aim_session_t *sess, struct command_rx_struct *command); |
| |
437 u_long aim_chat_send_im(struct aim_session_t *sess, struct aim_conn_t *conn, char *msg); |
| |
438 u_long aim_chat_join(struct aim_session_t *sess, struct aim_conn_t *conn, u_short exchange, const char *roomname); |
| |
439 u_long aim_chat_clientready(struct aim_session_t *sess, struct aim_conn_t *conn); |
| |
440 int aim_chat_attachname(struct aim_conn_t *conn, char *roomname); |
| |
441 char *aim_chat_getname(struct aim_conn_t *conn); |
| |
442 struct aim_conn_t *aim_chat_getconn(struct aim_session_t *, char *name); |
| |
443 |
| |
444 u_long aim_chatnav_reqrights(struct aim_session_t *sess, struct aim_conn_t *conn); |
| |
445 u_long aim_chatnav_clientready(struct aim_session_t *sess, struct aim_conn_t *conn); |
| |
446 |
| |
447 u_long aim_chat_invite(struct aim_session_t *sess, struct aim_conn_t *conn, char *sn, char *msg, u_short exchange, char *roomname, u_short instance); |
| |
448 |
| |
449 struct aim_chat_exchangeinfo { |
| |
450 u_short number; |
| |
451 char *name; |
| |
452 char *charset1; |
| |
453 char *lang1; |
| |
454 char *charset2; |
| |
455 char *lang2; |
| |
456 }; |
| |
457 int aim_chatnav_parse_info(struct aim_session_t *sess, struct command_rx_struct *command); |
| |
458 u_long aim_chatnav_createroom(struct aim_session_t *sess, struct aim_conn_t *conn, char *name, u_short exchange); |
| |
459 int aim_chat_leaveroom(struct aim_session_t *sess, char *name); |
| 284 |
460 |
| 285 /* aim_util.c */ |
461 /* aim_util.c */ |
| 286 int aimutil_put8(u_char *, u_short); |
462 #ifdef AIMUTIL_USEMACROS |
| |
463 /* |
| |
464 * These are really ugly. You'd think this was LISP. I wish it was. |
| |
465 */ |
| |
466 #define aimutil_put8(buf, data) ((*(buf) = (u_char)(data)&0xff),1) |
| |
467 #define aimutil_get8(buf) ((*(buf))&0xff) |
| |
468 #define aimutil_put16(buf, data) ( \ |
| |
469 (*(buf) = (u_char)((data)>>8)&0xff), \ |
| |
470 (*((buf)+1) = (u_char)(data)&0xff), \ |
| |
471 2) |
| |
472 #define aimutil_get16(buf) ((((*(buf))<<8)&0xff00) + ((*((buf)+1)) & 0xff)) |
| |
473 #define aimutil_put32(buf, data) ( \ |
| |
474 (*((buf)) = (u_char)((data)>>24)&0xff), \ |
| |
475 (*((buf)+1) = (u_char)((data)>>16)&0xff), \ |
| |
476 (*((buf)+2) = (u_char)((data)>>8)&0xff), \ |
| |
477 (*((buf)+3) = (u_char)(data)&0xff), \ |
| |
478 4) |
| |
479 #define aimutil_get32(buf) ((((*(buf))<<24)&0xff000000) + \ |
| |
480 (((*((buf)+1))<<16)&0x00ff0000) + \ |
| |
481 (((*((buf)+2))<< 8)&0x0000ff00) + \ |
| |
482 (((*((buf)+3) )&0x000000ff))) |
| |
483 #else |
| |
484 #warning Not using aimutil macros. May have performance problems. |
| |
485 int aimutil_put8(u_char *, u_char); |
| |
486 u_char aimutil_get8(u_char *buf); |
| 287 int aimutil_put16(u_char *, u_short); |
487 int aimutil_put16(u_char *, u_short); |
| |
488 u_short aimutil_get16(u_char *); |
| 288 int aimutil_put32(u_char *, u_long); |
489 int aimutil_put32(u_char *, u_long); |
| 289 int aimutil_putstr(u_char *, u_char *, int); |
490 u_long aimutil_get32(u_char *); |
| 290 |
|
| 291 /* proxy support */ |
|
| 292 #ifdef ENABLE_PROXY_SUPPORT |
|
| 293 #include "proxy.h" |
|
| 294 #endif |
491 #endif |
| 295 |
492 |
| |
493 int aimutil_putstr(u_char *, const u_char *, int); |
| |
494 int aimutil_tokslen(char *toSearch, int index, char dl); |
| |
495 int aimutil_itemcnt(char *toSearch, char dl); |
| |
496 char *aimutil_itemidx(char *toSearch, int index, char dl); |
| |
497 |
| |
498 int aim_snlen(const char *sn); |
| |
499 int aim_sncmp(const char *sn1, const char *sn2); |
| |
500 |
| 296 #endif /* __AIM_H__ */ |
501 #endif /* __AIM_H__ */ |
| 297 |
502 |