source: protocols/oscar/aim.h @ a39ede7

Last change on this file since a39ede7 was a39ede7, checked in by dequis <dx@…>, at 2018-03-31T02:04:45Z

oscar: remove old_icq_auth (XOR login, default off since 2010)

Holy crap this login method is *bad*

  • Property mode set to 100644
File size: 27.2 KB
Line 
1/*
2 * Main libfaim header.  Must be included in client for prototypes/macros.
3 *
4 * "come on, i turned a chick lesbian; i think this is the hackish equivalent"
5 *                                                -- Josh Meyer
6 *
7 */
8
9#ifndef __AIM_H__
10#define __AIM_H__
11
12#include <stdio.h>
13#include <string.h>
14#include <fcntl.h>
15#include <sys/types.h>
16#include <stdlib.h>
17#include <stdarg.h>
18#include <errno.h>
19#include <time.h>
20#include <gmodule.h>
21
22#include "bitlbee.h"
23
24#ifdef WITH_PURPLE
25/* For compatibility with builds that include both purple and this oscar module */
26#include "aim_prefixes.h"
27#endif
28
29/* XXX adjust these based on autoconf-detected platform */
30typedef guint32 aim_snacid_t;
31typedef guint16 flap_seqnum_t;
32
33/* Portability stuff (DMP) */
34
35#if defined(mach) && defined(__APPLE__)
36#define gethostbyname(x) gethostbyname2(x, AF_INET)
37#endif
38
39/*
40 * Current Maximum Length for Screen Names (not including NULL)
41 *
42 * Currently only names up to 16 characters can be registered
43 * however it is aparently legal for them to be larger.
44 */
45#define MAXSNLEN 32
46
47/*
48 * Current Maximum Length for Instant Messages
49 *
50 * This was found basically by experiment, but not wholly
51 * accurate experiment.  It should not be regarded
52 * as completely correct.  But its a decent approximation.
53 *
54 * Note that although we can send this much, its impossible
55 * for WinAIM clients (up through the latest (4.0.1957)) to
56 * send any more than 1kb.  Amaze all your windows friends
57 * with utterly oversized instant messages!
58 *
59 * XXX: the real limit is the total SNAC size at 8192. Fix this.
60 *
61 */
62#define MAXMSGLEN 7987
63
64/*
65 * Maximum size of a Buddy Icon.
66 */
67#define MAXICONLEN 7168
68#define AIM_ICONIDENT "AVT1picture.id"
69
70/*
71 * Current Maximum Length for Chat Room Messages
72 *
73 * This is actually defined by the protocol to be
74 * dynamic, but I have yet to see due cause to
75 * define it dynamically here.  Maybe later.
76 *
77 */
78#define MAXCHATMSGLEN 512
79
80/*
81 * Standard size of an AIM authorization cookie
82 */
83#define AIM_COOKIELEN            0x100
84
85#define AIM_MD5_STRING "AOL Instant Messenger (SM)"
86
87/*
88 * Default Authorizer server name and TCP port for the OSCAR farm.
89 *
90 * You shouldn't need to change this unless you're writing
91 * your own server.
92 *
93 * Note that only one server is needed to start the whole
94 * AIM process.  The later server addresses come from
95 * the authorizer service.
96 *
97 * This is only here for convenience.  Its still up to
98 * the client to connect to it.
99 *
100 */
101#define AIM_DEFAULT_LOGIN_SERVER_AIM "login.messaging.aol.com"
102#define AIM_DEFAULT_LOGIN_SERVER_ICQ "login.icq.com"
103#define AIM_LOGIN_PORT 5190
104
105/*
106 * Size of the SNAC caching hash.
107 *
108 * Default: 16
109 *
110 */
111#define AIM_SNAC_HASH_SIZE 16
112
113/*
114 * Client info.  Filled in by the client and passed in to
115 * aim_send_login().  The information ends up getting passed to OSCAR
116 * through the initial login command.
117 *
118 */
119struct client_info_s {
120        const char *clientstring;
121        guint16 clientid;
122        int major;
123        int minor;
124        int point;
125        int build;
126        const char *country; /* two-letter abbrev */
127        const char *lang; /* two-letter abbrev */
128};
129
130#define AIM_CLIENTINFO_KNOWNGOOD_3_5_1670 { \
131                "AOL Instant Messenger (SM), version 3.5.1670/WIN32", \
132                0x0004, \
133                0x0003, \
134                0x0005, \
135                0x0000, \
136                0x0686, \
137                "us", \
138                "en", \
139}
140
141#define AIM_CLIENTINFO_KNOWNGOOD_4_1_2010 { \
142                "AOL Instant Messenger (SM), version 4.1.2010/WIN32", \
143                0x0004, \
144                0x0004, \
145                0x0001, \
146                0x0000, \
147                0x07da, \
148                "us", \
149                "en", \
150}
151
152#define AIM_CLIENTINFO_KNOWNGOOD_5_1_3036 { \
153                "AOL Instant Messenger, version 5.1.3036/WIN32", \
154                0x0109, \
155                0x0005, \
156                0x0001, \
157                0x0000, \
158                0x0bdc, \
159                "us", \
160                "en", \
161}
162
163/*
164 * I would make 4.1.2010 the default, but they seem to have found
165 * an alternate way of breaking that one.
166 *
167 * 3.5.1670 should work fine, however, you will be subjected to the
168 * memory test, which may require you to have a WinAIM binary laying
169 * around. (see login.c::memrequest())
170 */
171#define AIM_CLIENTINFO_KNOWNGOOD AIM_CLIENTINFO_KNOWNGOOD_5_1_3036
172
173#ifndef TRUE
174#define TRUE 1
175#define FALSE 0
176#endif
177
178/*
179 * These could be arbitrary, but its easier to use the actual AIM values
180 */
181#define AIM_CONN_TYPE_AUTH          0x0007
182#define AIM_CONN_TYPE_ADS           0x0005
183#define AIM_CONN_TYPE_BOS           0x0002
184#define AIM_CONN_TYPE_CHAT          0x000e
185#define AIM_CONN_TYPE_CHATNAV       0x000d
186
187/*
188 * Status values returned from aim_conn_new().  ORed together.
189 */
190#define AIM_CONN_STATUS_READY       0x0001
191#define AIM_CONN_STATUS_INTERNALERR 0x0002
192#define AIM_CONN_STATUS_RESOLVERR   0x0040
193#define AIM_CONN_STATUS_CONNERR     0x0080
194#define AIM_CONN_STATUS_INPROGRESS  0x0100
195
196#define AIM_FRAMETYPE_FLAP 0x0000
197
198/*
199 * message type flags
200 */
201#define AIM_MTYPE_PLAIN     0x01
202#define AIM_MTYPE_CHAT      0x02
203#define AIM_MTYPE_FILEREQ   0x03
204#define AIM_MTYPE_URL       0x04
205#define AIM_MTYPE_AUTHREQ   0x06
206#define AIM_MTYPE_AUTHDENY  0x07
207#define AIM_MTYPE_AUTHOK    0x08
208#define AIM_MTYPE_SERVER    0x09
209#define AIM_MTYPE_ADDED     0x0C
210#define AIM_MTYPE_WWP       0x0D
211#define AIM_MTYPE_EEXPRESS  0x0E
212#define AIM_MTYPE_CONTACTS  0x13
213#define AIM_MTYPE_PLUGIN    0x1A
214#define AIM_MTYPE_AUTOAWAY      0xE8
215#define AIM_MTYPE_AUTOBUSY      0xE9
216#define AIM_MTYPE_AUTONA        0xEA
217#define AIM_MTYPE_AUTODND       0xEB
218#define AIM_MTYPE_AUTOFFC       0xEC
219
220typedef struct aim_conn_s {
221        int fd;
222        guint16 type;
223        guint16 subtype;
224        flap_seqnum_t seqnum;
225        guint32 status;
226        void *priv; /* misc data the client may want to store */
227        void *internal; /* internal conn-specific libfaim data */
228        time_t lastactivity; /* time of last transmit */
229        int forcedlatency;
230        void *handlerlist;
231        void *sessv; /* pointer to parent session */
232        void *inside; /* only accessible from inside libfaim */
233        struct aim_conn_s *next;
234} aim_conn_t;
235
236/*
237 * Byte Stream type. Sort of.
238 *
239 * Use of this type serves a couple purposes:
240 *   - Buffer/buflen pairs are passed all around everywhere. This turns
241 *     that into one value, as well as abstracting it slightly.
242 *   - Through the abstraction, it is possible to enable bounds checking
243 *     for robustness at the cost of performance.  But a clean failure on
244 *     weird packets is much better than a segfault.
245 *   - I like having variables named "bs".
246 *
247 * Don't touch the insides of this struct.  Or I'll have to kill you.
248 *
249 */
250typedef struct aim_bstream_s {
251        guint8 *data;
252        guint32 len;
253        guint32 offset;
254} aim_bstream_t;
255
256typedef struct aim_frame_s {
257        guint8 hdrtype; /* defines which piece of the union to use */
258        union {
259                struct {
260                        guint8 type;
261                        flap_seqnum_t seqnum;
262                } flap;
263        } hdr;
264        aim_bstream_t data;     /* payload stream */
265        guint8 handled;         /* 0 = new, !0 = been handled */
266        guint8 nofree;          /* 0 = free data on purge, 1 = only unlink */
267        aim_conn_t *conn;  /* the connection it came in on... */
268        struct aim_frame_s *next;
269} aim_frame_t;
270
271typedef struct aim_msgcookie_s {
272        unsigned char cookie[8];
273        int type;
274        void *data;
275        time_t addtime;
276        struct aim_msgcookie_s *next;
277} aim_msgcookie_t;
278
279/*
280 * AIM Session: The main client-data interface.
281 *
282 */
283typedef struct aim_session_s {
284
285        /* ---- Client Accessible ------------------------ */
286
287        /* Our screen name. */
288        char sn[MAXSNLEN + 1];
289
290        /*
291         * Pointer to anything the client wants to
292         * explicitly associate with this session.
293         *
294         * This is for use in the callbacks mainly. In any
295         * callback, you can access this with sess->aux_data.
296         *
297         */
298        void *aux_data;
299
300        /* ---- Internal Use Only ------------------------ */
301
302        /* Server-stored information (ssi) */
303        struct {
304                int received_data;
305                guint16 revision;
306                struct aim_ssi_item *items;
307                time_t timestamp;
308                int waiting_for_ack;
309                aim_frame_t *holding_queue;
310        } ssi;
311
312        /* Connection information */
313        aim_conn_t *connlist;
314
315        /*
316         * Transmit/receive queues.
317         *
318         * These are only used when you don't use your own lowlevel
319         * I/O.  I don't suggest that you use libfaim's internal I/O.
320         * Its really bad and the API/event model is quirky at best.
321         *
322         */
323        aim_frame_t *queue_outgoing;
324        aim_frame_t *queue_incoming;
325
326        /*
327         * Tx Enqueuing function.
328         *
329         * This is how you override the transmit direction of libfaim's
330         * internal I/O.  This function will be called whenever it needs
331         * to send something.
332         *
333         */
334        int (*tx_enqueue)(struct aim_session_s *, aim_frame_t *);
335
336        /*
337         * Outstanding snac handling
338         *
339         * XXX: Should these be per-connection? -mid
340         */
341        void *snac_hash[AIM_SNAC_HASH_SIZE];
342        aim_snacid_t snacid_next;
343
344        struct aim_icq_info *icq_info;
345        struct aim_oft_info *oft_info;
346        struct aim_authresp_info *authinfo;
347        struct aim_emailinfo *emailinfo;
348
349        struct {
350                struct aim_userinfo_s *userinfo;
351                struct userinfo_node *torequest;
352                struct userinfo_node *requested;
353                int waiting_for_response;
354        } locate;
355
356        guint32 flags; /* AIM_SESS_FLAGS_ */
357
358        aim_msgcookie_t *msgcookies;
359
360        void *modlistv;
361
362        guint8 aim_icq_state;  /* ICQ representation of away state */
363} aim_session_t;
364
365/* Values for sess->flags */
366#define AIM_SESS_FLAGS_SNACLOGIN         0x00000001
367#define AIM_SESS_FLAGS_NONBLOCKCONNECT   0x00000004
368#define AIM_SESS_FLAGS_DONTTIMEOUTONICBM 0x00000008
369
370/* Valid for calling aim_icq_setstatus() and for aim_userinfo_t->icqinfo.status */
371#define AIM_ICQ_STATE_NORMAL    0x00000000
372#define AIM_ICQ_STATE_AWAY      0x00000001
373#define AIM_ICQ_STATE_DND       0x00000002
374#define AIM_ICQ_STATE_OUT       0x00000004
375#define AIM_ICQ_STATE_BUSY      0x00000010
376#define AIM_ICQ_STATE_CHAT      0x00000020
377#define AIM_ICQ_STATE_INVISIBLE 0x00000100
378#define AIM_ICQ_STATE_WEBAWARE  0x00010000
379#define AIM_ICQ_STATE_HIDEIP            0x00020000
380#define AIM_ICQ_STATE_BIRTHDAY          0x00080000
381#define AIM_ICQ_STATE_DIRECTDISABLED    0x00100000
382#define AIM_ICQ_STATE_ICQHOMEPAGE       0x00200000
383#define AIM_ICQ_STATE_DIRECTREQUIREAUTH 0x10000000
384#define AIM_ICQ_STATE_DIRECTCONTACTLIST 0x20000000
385
386/*
387 * AIM User Info, Standard Form.
388 */
389typedef struct {
390        char sn[MAXSNLEN + 1];
391        guint16 warnlevel;
392        guint16 idletime;
393        guint16 flags;
394        guint32 membersince;
395        guint32 onlinesince;
396        guint32 sessionlen;
397        guint32 capabilities;
398        struct {
399                guint32 status;
400                guint32 ipaddr;
401                guint8 crap[0x25]; /* until we figure it out... */
402        } icqinfo;
403        guint32 present;
404} aim_userinfo_t;
405
406#define AIM_USERINFO_PRESENT_FLAGS        0x00000001
407#define AIM_USERINFO_PRESENT_MEMBERSINCE  0x00000002
408#define AIM_USERINFO_PRESENT_ONLINESINCE  0x00000004
409#define AIM_USERINFO_PRESENT_IDLE         0x00000008
410#define AIM_USERINFO_PRESENT_ICQEXTSTATUS 0x00000010
411#define AIM_USERINFO_PRESENT_ICQIPADDR    0x00000020
412#define AIM_USERINFO_PRESENT_ICQDATA      0x00000040
413#define AIM_USERINFO_PRESENT_CAPABILITIES 0x00000080
414#define AIM_USERINFO_PRESENT_SESSIONLEN   0x00000100
415
416#define AIM_FLAG_UNCONFIRMED    0x0001 /* "damned transients" */
417#define AIM_FLAG_ADMINISTRATOR  0x0002
418#define AIM_FLAG_AOL            0x0004
419#define AIM_FLAG_OSCAR_PAY      0x0008
420#define AIM_FLAG_FREE           0x0010
421#define AIM_FLAG_AWAY           0x0020
422#define AIM_FLAG_ICQ            0x0040
423#define AIM_FLAG_WIRELESS       0x0080
424#define AIM_FLAG_UNKNOWN100     0x0100
425#define AIM_FLAG_UNKNOWN200     0x0200
426#define AIM_FLAG_ACTIVEBUDDY    0x0400
427#define AIM_FLAG_UNKNOWN800     0x0800
428#define AIM_FLAG_ABINTERNAL     0x1000
429
430#define AIM_FLAG_ALLUSERS       0x001f
431
432/*
433 * TLV handling
434 */
435
436/* Generic TLV structure. */
437typedef struct aim_tlv_s {
438        guint16 type;
439        guint16 length;
440        guint8 *value;
441} aim_tlv_t;
442
443/* List of above. */
444typedef struct aim_tlvlist_s {
445        aim_tlv_t *tlv;
446        struct aim_tlvlist_s *next;
447} aim_tlvlist_t;
448
449/* TLV-handling functions */
450
451#if 0
452/* Very, very raw TLV handling. */
453int aim_puttlv_8(guint8 *buf, const guint16 t, const guint8 v);
454int aim_puttlv_16(guint8 *buf, const guint16 t, const guint16 v);
455int aim_puttlv_32(guint8 *buf, const guint16 t, const guint32 v);
456int aim_puttlv_raw(guint8 *buf, const guint16 t, const guint16 l, const guint8 *v);
457#endif
458
459/* TLV list handling. */
460aim_tlvlist_t *aim_readtlvchain(aim_bstream_t *bs);
461void aim_freetlvchain(aim_tlvlist_t **list);
462aim_tlv_t *aim_gettlv(aim_tlvlist_t *list, guint16 t, const int n);
463char *aim_gettlv_str(aim_tlvlist_t *list, const guint16 t, const int n);
464guint8 aim_gettlv8(aim_tlvlist_t *list, const guint16 type, const int num);
465guint16 aim_gettlv16(aim_tlvlist_t *list, const guint16 t, const int n);
466guint32 aim_gettlv32(aim_tlvlist_t *list, const guint16 t, const int n);
467int aim_writetlvchain(aim_bstream_t *bs, aim_tlvlist_t **list);
468int aim_addtlvtochain8(aim_tlvlist_t **list, const guint16 t, const guint8 v);
469int aim_addtlvtochain16(aim_tlvlist_t **list, const guint16 t, const guint16 v);
470int aim_addtlvtochain32(aim_tlvlist_t **list, const guint16 type, const guint32 v);
471int aim_addtlvtochain_raw(aim_tlvlist_t **list, const guint16 t, const guint16 l, const guint8 *v);
472int aim_addtlvtochain_caps(aim_tlvlist_t **list, const guint16 t, const guint32 caps);
473int aim_addtlvtochain_noval(aim_tlvlist_t **list, const guint16 type);
474int aim_addtlvtochain_chatroom(aim_tlvlist_t **list, guint16 type, guint16 exchange, const char *roomname,
475                               guint16 instance);
476int aim_addtlvtochain_userinfo(aim_tlvlist_t **list, guint16 type, aim_userinfo_t *ui);
477int aim_addtlvtochain_frozentlvlist(aim_tlvlist_t **list, guint16 type, aim_tlvlist_t **tl);
478int aim_counttlvchain(aim_tlvlist_t **list);
479int aim_sizetlvchain(aim_tlvlist_t **list);
480
481
482/*
483 * Get command from connections
484 *
485 * aim_get_commmand() is the libfaim lowlevel I/O in the receive direction.
486 * XXX Make this easily overridable.
487 *
488 */
489int aim_get_command(aim_session_t *, aim_conn_t *);
490
491/*
492 * Dispatch commands that are in the rx queue.
493 */
494void aim_rxdispatch(aim_session_t *);
495
496int aim_debugconn_sendconnect(aim_session_t *sess, aim_conn_t *conn);
497
498typedef int (*aim_rxcallback_t)(aim_session_t *, aim_frame_t *, ...);
499
500struct aim_clientrelease {
501        char *name;
502        guint32 build;
503        char *url;
504        char *info;
505};
506
507struct aim_authresp_info {
508        char *sn;
509        guint16 errorcode;
510        char *errorurl;
511        guint16 regstatus;
512        char *email;
513        char *bosip;
514        guint8 *cookie;
515        struct aim_clientrelease latestrelease;
516        struct aim_clientrelease latestbeta;
517};
518
519/* Callback data for redirect. */
520struct aim_redirect_data {
521        guint16 group;
522        const char *ip;
523        const guint8 *cookie;
524        struct { /* group == AIM_CONN_TYPE_CHAT */
525                guint16 exchange;
526                const char *room;
527                guint16 instance;
528        } chat;
529};
530
531int aim_clientready(aim_session_t *sess, aim_conn_t *conn);
532int aim_sendflapver(aim_session_t *sess, aim_conn_t *conn);
533int aim_request_login(aim_session_t *sess, aim_conn_t *conn, const char *sn);
534int aim_send_login(aim_session_t *, aim_conn_t *, const char *, const char *, struct client_info_s *, const char *key);
535int aim_encode_password_md5(const char *password, const char *key, unsigned char *digest);
536void aim_purge_rxqueue(aim_session_t *);
537
538#define AIM_TX_QUEUED    0 /* default */
539#define AIM_TX_IMMEDIATE 1
540#define AIM_TX_USER      2
541int aim_tx_setenqueue(aim_session_t *sess, int what, int (*func)(aim_session_t *, aim_frame_t *));
542
543int aim_tx_flushqueue(aim_session_t *);
544void aim_tx_purgequeue(aim_session_t *);
545
546int aim_conn_setlatency(aim_conn_t *conn, int newval);
547
548void aim_conn_kill(aim_session_t *sess, aim_conn_t **deadconn);
549
550int aim_conn_addhandler(aim_session_t *, aim_conn_t *conn, u_short family, u_short type, aim_rxcallback_t newhandler,
551                        u_short flags);
552int aim_clearhandlers(aim_conn_t *conn);
553
554aim_conn_t *aim_conn_findbygroup(aim_session_t *sess, guint16 group);
555aim_session_t *aim_conn_getsess(aim_conn_t *conn);
556void aim_conn_close(aim_conn_t *deadconn);
557aim_conn_t *aim_newconn(aim_session_t *, int type, const char *dest);
558int aim_conngetmaxfd(aim_session_t *);
559aim_conn_t *aim_select(aim_session_t *, struct timeval *, int *);
560int aim_conn_isready(aim_conn_t *);
561int aim_conn_setstatus(aim_conn_t *, int);
562int aim_conn_completeconnect(aim_session_t *sess, aim_conn_t *conn);
563int aim_conn_isconnecting(aim_conn_t *conn);
564
565typedef void (*faim_debugging_callback_t)(aim_session_t *sess, int level, const char *format, va_list va);
566int aim_setdebuggingcb(aim_session_t * sess, faim_debugging_callback_t);
567void aim_session_init(aim_session_t *, guint32 flags, int debuglevel);
568void aim_session_kill(aim_session_t *);
569void aim_setupproxy(aim_session_t *sess, const char *server, const char *username, const char *password);
570aim_conn_t *aim_getconn_type(aim_session_t *, int type);
571aim_conn_t *aim_getconn_type_all(aim_session_t *, int type);
572aim_conn_t *aim_getconn_fd(aim_session_t *, int fd);
573
574/* aim_misc.c */
575
576
577struct aim_chat_roominfo {
578        unsigned short exchange;
579        char *name;
580        unsigned short instance;
581};
582
583struct aim_chat_invitation {
584        struct im_connection * ic;
585        char * name;
586        guint8 exchange;
587};
588
589#define AIM_VISIBILITYCHANGE_PERMITADD    0x05
590#define AIM_VISIBILITYCHANGE_PERMITREMOVE 0x06
591#define AIM_VISIBILITYCHANGE_DENYADD      0x07
592#define AIM_VISIBILITYCHANGE_DENYREMOVE   0x08
593
594#define AIM_PRIVFLAGS_ALLOWIDLE           0x01
595#define AIM_PRIVFLAGS_ALLOWMEMBERSINCE    0x02
596
597#define AIM_WARN_ANON                     0x01
598
599int aim_flap_nop(aim_session_t *sess, aim_conn_t *conn);
600int aim_bos_setprofile(aim_session_t *sess, aim_conn_t *conn, const char *profile, const char *awaymsg, guint32 caps);
601int aim_bos_setgroupperm(aim_session_t *, aim_conn_t *, guint32 mask);
602int aim_bos_setprivacyflags(aim_session_t *, aim_conn_t *, guint32);
603int aim_reqpersonalinfo(aim_session_t *, aim_conn_t *);
604int aim_reqservice(aim_session_t *, aim_conn_t *, guint16);
605int aim_bos_reqrights(aim_session_t *, aim_conn_t *);
606int aim_bos_reqbuddyrights(aim_session_t *, aim_conn_t *);
607int aim_bos_reqlocaterights(aim_session_t *, aim_conn_t *);
608int aim_setextstatus(aim_session_t *sess, aim_conn_t *conn, guint32 status);
609
610struct aim_fileheader_t *aim_getlisting(aim_session_t *sess, FILE *);
611
612#define AIM_CLIENTTYPE_UNKNOWN  0x0000
613#define AIM_CLIENTTYPE_MC       0x0001
614#define AIM_CLIENTTYPE_WINAIM   0x0002
615#define AIM_CLIENTTYPE_WINAIM41 0x0003
616#define AIM_CLIENTTYPE_AOL_TOC  0x0004
617
618#define AIM_RATE_CODE_CHANGE     0x0001
619#define AIM_RATE_CODE_WARNING    0x0002
620#define AIM_RATE_CODE_LIMIT      0x0003
621#define AIM_RATE_CODE_CLEARLIMIT 0x0004
622int aim_ads_requestads(aim_session_t *sess, aim_conn_t *conn);
623
624/* aim_im.c */
625
626aim_conn_t *aim_sendfile_initiate(aim_session_t *, const char *destsn, const char *filename, guint16 numfiles,
627                                  guint32 totsize);
628
629aim_conn_t *aim_getfile_initiate(aim_session_t *sess, aim_conn_t *conn, const char *destsn);
630int aim_oft_getfile_request(aim_session_t *sess, aim_conn_t *conn, const char *name, int size);
631int aim_oft_getfile_ack(aim_session_t *sess, aim_conn_t *conn);
632int aim_oft_getfile_end(aim_session_t *sess, aim_conn_t *conn);
633
634#define AIM_SENDMEMBLOCK_FLAG_ISREQUEST  0
635#define AIM_SENDMEMBLOCK_FLAG_ISHASH     1
636
637#define AIM_GETINFO_GENERALINFO 0x00001
638#define AIM_GETINFO_AWAYMESSAGE 0x00003
639#define AIM_GETINFO_CAPABILITIES 0x0004
640
641struct aim_invite_priv {
642        char *sn;
643        char *roomname;
644        guint16 exchange;
645        guint16 instance;
646};
647
648#define AIM_COOKIETYPE_UNKNOWN  0x00
649#define AIM_COOKIETYPE_ICBM     0x01
650#define AIM_COOKIETYPE_ADS      0x02
651#define AIM_COOKIETYPE_BOS      0x03
652#define AIM_COOKIETYPE_IM       0x04
653#define AIM_COOKIETYPE_CHAT     0x05
654#define AIM_COOKIETYPE_CHATNAV  0x06
655#define AIM_COOKIETYPE_INVITE   0x07
656
657int aim_handlerendconnect(aim_session_t *sess, aim_conn_t *cur);
658
659#define AIM_TRANSFER_DENY_NOTSUPPORTED 0x0000
660#define AIM_TRANSFER_DENY_DECLINE 0x0001
661#define AIM_TRANSFER_DENY_NOTACCEPTING 0x0002
662aim_conn_t *aim_accepttransfer(aim_session_t *sess, aim_conn_t *conn, const char *sn, const guint8 *cookie,
663                               const guint8 *ip, guint16 listingfiles, guint16 listingtotsize, guint16 listingsize,
664                               guint32 listingchecksum, guint16 rendid);
665
666int aim_getinfo(aim_session_t *, aim_conn_t *, const char *, unsigned short);
667
668#define AIM_IMPARAM_FLAG_CHANMSGS_ALLOWED       0x00000001
669#define AIM_IMPARAM_FLAG_MISSEDCALLS_ENABLED    0x00000002
670
671/* This is what the server will give you if you don't set them yourself. */
672#define AIM_IMPARAM_DEFAULTS { \
673                0, \
674                AIM_IMPARAM_FLAG_CHANMSGS_ALLOWED | AIM_IMPARAM_FLAG_MISSEDCALLS_ENABLED, \
675                512, /* !! Note how small this is. */ \
676                (99.9) * 10, (99.9) * 10, \
677                1000 /* !! And how large this is. */ \
678}
679
680/* This is what most AIM versions use. */
681#define AIM_IMPARAM_REASONABLE { \
682                0, \
683                AIM_IMPARAM_FLAG_CHANMSGS_ALLOWED | AIM_IMPARAM_FLAG_MISSEDCALLS_ENABLED, \
684                8000, \
685                (99.9) * 10, (99.9) * 10, \
686                0 \
687}
688
689
690struct aim_icbmparameters {
691        guint16 maxchan;
692        guint32 flags; /* AIM_IMPARAM_FLAG_ */
693        guint16 maxmsglen; /* message size that you will accept */
694        guint16 maxsenderwarn; /* this and below are *10 (999=99.9%) */
695        guint16 maxrecverwarn;
696        guint32 minmsginterval; /* in milliseconds? */
697};
698
699int aim_reqicbmparams(aim_session_t *sess);
700int aim_seticbmparam(aim_session_t *sess, struct aim_icbmparameters *params);
701
702/* auth.c */
703int aim_sendcookie(aim_session_t *, aim_conn_t *, const guint8 *);
704
705int aim_admin_changepasswd(aim_session_t *, aim_conn_t *, const char *newpw, const char *curpw);
706int aim_admin_reqconfirm(aim_session_t *sess, aim_conn_t *conn);
707int aim_admin_getinfo(aim_session_t *sess, aim_conn_t *conn, guint16 info);
708int aim_admin_setemail(aim_session_t *sess, aim_conn_t *conn, const char *newemail);
709int aim_admin_setnick(aim_session_t *sess, aim_conn_t *conn, const char *newnick);
710
711/* These apply to exchanges as well. */
712#define AIM_CHATROOM_FLAG_EVILABLE 0x0001
713#define AIM_CHATROOM_FLAG_NAV_ONLY 0x0002
714#define AIM_CHATROOM_FLAG_INSTANCING_ALLOWED 0x0004
715#define AIM_CHATROOM_FLAG_OCCUPANT_PEEK_ALLOWED 0x0008
716
717struct aim_chat_exchangeinfo {
718        guint16 number;
719        guint16 flags;
720        char *name;
721        char *charset1;
722        char *lang1;
723        char *charset2;
724        char *lang2;
725};
726
727#define AIM_CHATFLAGS_NOREFLECT         0x0001
728#define AIM_CHATFLAGS_AWAY              0x0002
729#define AIM_CHATFLAGS_UNICODE           0x0004
730#define AIM_CHATFLAGS_ISO_8859_1        0x0008
731
732int aim_chat_send_im(aim_session_t *sess, aim_conn_t *conn, guint16 flags, const char *msg, int msglen);
733int aim_chat_join(aim_session_t *sess, aim_conn_t *conn, guint16 exchange, const char *roomname, guint16 instance);
734
735int aim_chatnav_reqrights(aim_session_t *sess, aim_conn_t *conn);
736
737int aim_chat_invite(aim_session_t *sess, aim_conn_t *conn, const char *sn, const char *msg, guint16 exchange,
738                    const char *roomname, guint16 instance);
739
740int aim_chatnav_createroom(aim_session_t *sess, aim_conn_t *conn, const char *name, guint16 exchange);
741
742/* aim_util.c */
743/*
744 * These are really ugly.  You'd think this was LISP.  I wish it was.
745 *
746 * XXX With the advent of bstream's, these should be removed to enforce
747 * their use.
748 *
749 */
750#define aimutil_put8(buf, data) ((*(buf) = (u_char) (data) & 0xff), 1)
751#define aimutil_get8(buf) ((*(buf)) & 0xff)
752#define aimutil_put16(buf, data) ( \
753                (*(buf) = (u_char) ((data) >> 8) & 0xff), \
754                (*((buf) + 1) = (u_char) (data) & 0xff),  \
755                2)
756#define aimutil_get16(buf) ((((*(buf)) << 8) & 0xff00) + ((*((buf) + 1)) & 0xff))
757#define aimutil_put32(buf, data) ( \
758                (*((buf)) = (u_char) ((data) >> 24) & 0xff), \
759                (*((buf) + 1) = (u_char) ((data) >> 16) & 0xff), \
760                (*((buf) + 2) = (u_char) ((data) >> 8) & 0xff), \
761                (*((buf) + 3) = (u_char) (data) & 0xff), \
762                4)
763#define aimutil_get32(buf) ((((*(buf)) << 24) & 0xff000000) + \
764                            (((*((buf) + 1)) << 16) & 0x00ff0000) + \
765                            (((*((buf) + 2)) << 8) & 0x0000ff00) + \
766                            (((*((buf) + 3)) & 0x000000ff)))
767
768/* Little-endian versions (damn ICQ) */
769#define aimutil_putle8(buf, data) ( \
770                (*(buf) = (unsigned char) (data) & 0xff), \
771                1)
772#define aimutil_getle8(buf) ( \
773                (*(buf)) & 0xff \
774                )
775#define aimutil_putle16(buf, data) ( \
776                (*((buf) + 0) = (unsigned char) ((data) >> 0) & 0xff),  \
777                (*((buf) + 1) = (unsigned char) ((data) >> 8) & 0xff), \
778                2)
779#define aimutil_getle16(buf) ( \
780                (((*((buf) + 0)) << 0) & 0x00ff) + \
781                (((*((buf) + 1)) << 8) & 0xff00) \
782                )
783#define aimutil_putle32(buf, data) ( \
784                (*((buf) + 0) = (unsigned char) ((data) >>  0) & 0xff), \
785                (*((buf) + 1) = (unsigned char) ((data) >>  8) & 0xff), \
786                (*((buf) + 2) = (unsigned char) ((data) >> 16) & 0xff), \
787                (*((buf) + 3) = (unsigned char) ((data) >> 24) & 0xff), \
788                4)
789#define aimutil_getle32(buf) ( \
790                (((*((buf) + 0)) <<  0) & 0x000000ff) + \
791                (((*((buf) + 1)) <<  8) & 0x0000ff00) + \
792                (((*((buf) + 2)) << 16) & 0x00ff0000) + \
793                (((*((buf) + 3)) << 24) & 0xff000000))
794
795
796int aim_sncmp(const char *a, const char *b);
797
798#include <aim_internal.h>
799
800/*
801 * SNAC Families.
802 */
803#define AIM_CB_FAM_ACK 0x0000
804#define AIM_CB_FAM_GEN 0x0001
805#define AIM_CB_FAM_SPECIAL 0xffff /* Internal libfaim use */
806
807/*
808 * SNAC Family: Ack.
809 *
810 * Not really a family, but treating it as one really
811 * helps it fit into the libfaim callback structure better.
812 *
813 */
814#define AIM_CB_ACK_ACK 0x0001
815
816/*
817 * SNAC Family: General.
818 */
819#define AIM_CB_GEN_ERROR 0x0001
820#define AIM_CB_GEN_CLIENTREADY 0x0002
821#define AIM_CB_GEN_SERVERREADY 0x0003
822#define AIM_CB_GEN_SERVICEREQ 0x0004
823#define AIM_CB_GEN_REDIRECT 0x0005
824#define AIM_CB_GEN_RATEINFOREQ 0x0006
825#define AIM_CB_GEN_RATEINFO 0x0007
826#define AIM_CB_GEN_RATEINFOACK 0x0008
827#define AIM_CB_GEN_RATECHANGE 0x000a
828#define AIM_CB_GEN_SERVERPAUSE 0x000b
829#define AIM_CB_GEN_SERVERRESUME 0x000d
830#define AIM_CB_GEN_REQSELFINFO 0x000e
831#define AIM_CB_GEN_SELFINFO 0x000f
832#define AIM_CB_GEN_EVIL 0x0010
833#define AIM_CB_GEN_SETIDLE 0x0011
834#define AIM_CB_GEN_MIGRATIONREQ 0x0012
835#define AIM_CB_GEN_MOTD 0x0013
836#define AIM_CB_GEN_SETPRIVFLAGS 0x0014
837#define AIM_CB_GEN_WELLKNOWNURL 0x0015
838#define AIM_CB_GEN_NOP 0x0016
839#define AIM_CB_GEN_DEFAULT 0xffff
840
841/*
842 * SNAC Family: Advertisement Services
843 */
844#define AIM_CB_ADS_ERROR 0x0001
845#define AIM_CB_ADS_DEFAULT 0xffff
846
847/*
848 * OFT Services
849 *
850 * See non-SNAC note below.
851 */
852#define AIM_CB_OFT_DIRECTIMCONNECTREQ 0x0001 /* connect request -- actually an OSCAR CAP*/
853#define AIM_CB_OFT_DIRECTIMINCOMING 0x0002
854#define AIM_CB_OFT_DIRECTIMDISCONNECT 0x0003
855#define AIM_CB_OFT_DIRECTIMTYPING 0x0004
856#define AIM_CB_OFT_DIRECTIMINITIATE 0x0005
857
858#define AIM_CB_OFT_GETFILECONNECTREQ 0x0006 /* connect request -- actually an OSCAR CAP*/
859#define AIM_CB_OFT_GETFILELISTINGREQ 0x0007 /* OFT listing.txt request */
860#define AIM_CB_OFT_GETFILEFILEREQ 0x0008    /* received file request */
861#define AIM_CB_OFT_GETFILEFILESEND 0x0009   /* received file request confirm -- send data */
862#define AIM_CB_OFT_GETFILECOMPLETE 0x000a   /* received file send complete*/
863#define AIM_CB_OFT_GETFILEINITIATE 0x000b   /* request for file get acknowledge */
864#define AIM_CB_OFT_GETFILEDISCONNECT 0x000c   /* OFT connection disconnected.*/
865#define AIM_CB_OFT_GETFILELISTING 0x000d   /* OFT listing.txt received.*/
866#define AIM_CB_OFT_GETFILERECEIVE 0x000e   /* OFT file incoming.*/
867#define AIM_CB_OFT_GETFILELISTINGRXCONFIRM 0x000f
868#define AIM_CB_OFT_GETFILESTATE4 0x0010
869
870#define AIM_CB_OFT_SENDFILEDISCONNECT 0x0020   /* OFT connection disconnected.*/
871
872
873
874/*
875 * SNAC Family: Internal Messages
876 *
877 * This isn't truly a SNAC family either, but using
878 * these, we can integrated non-SNAC services into
879 * the SNAC-centered libfaim callback structure.
880 *
881 */
882#define AIM_CB_SPECIAL_AUTHSUCCESS 0x0001
883#define AIM_CB_SPECIAL_AUTHOTHER 0x0002
884#define AIM_CB_SPECIAL_CONNERR 0x0003
885#define AIM_CB_SPECIAL_CONNCOMPLETE 0x0004
886#define AIM_CB_SPECIAL_FLAPVER 0x0005
887#define AIM_CB_SPECIAL_CONNINITDONE 0x0006
888#define AIM_CB_SPECIAL_IMAGETRANSFER 0x007
889#define AIM_CB_SPECIAL_UNKNOWN 0xffff
890#define AIM_CB_SPECIAL_DEFAULT AIM_CB_SPECIAL_UNKNOWN
891
892#endif /* __AIM_H__ */
Note: See TracBrowser for help on using the repository browser.