1 | /* |
---|
2 | * aim_internal.h -- prototypes/structs for the guts of libfaim |
---|
3 | * |
---|
4 | */ |
---|
5 | |
---|
6 | #ifndef __AIM_INTERNAL_H__ |
---|
7 | #define __AIM_INTERNAL_H__ 1 |
---|
8 | |
---|
9 | typedef struct { |
---|
10 | guint16 family; |
---|
11 | guint16 subtype; |
---|
12 | guint16 flags; |
---|
13 | guint32 id; |
---|
14 | } aim_modsnac_t; |
---|
15 | |
---|
16 | #define AIM_MODULENAME_MAXLEN 16 |
---|
17 | #define AIM_MODFLAG_MULTIFAMILY 0x0001 |
---|
18 | typedef struct aim_module_s { |
---|
19 | guint16 family; |
---|
20 | guint16 version; |
---|
21 | guint16 toolid; |
---|
22 | guint16 toolversion; |
---|
23 | guint16 flags; |
---|
24 | char name[AIM_MODULENAME_MAXLEN + 1]; |
---|
25 | int (*snachandler)(aim_session_t *sess, struct aim_module_s *mod, aim_frame_t *rx, aim_modsnac_t *snac, |
---|
26 | aim_bstream_t *bs); |
---|
27 | void (*shutdown)(aim_session_t *sess, struct aim_module_s *mod); |
---|
28 | void *priv; |
---|
29 | struct aim_module_s *next; |
---|
30 | } aim_module_t; |
---|
31 | |
---|
32 | int aim__registermodule(aim_session_t *sess, int (*modfirst)(aim_session_t *, aim_module_t *)); |
---|
33 | void aim__shutdownmodules(aim_session_t *sess); |
---|
34 | aim_module_t *aim__findmodulebygroup(aim_session_t *sess, guint16 group); |
---|
35 | |
---|
36 | int buddylist_modfirst(aim_session_t *sess, aim_module_t *mod); |
---|
37 | int admin_modfirst(aim_session_t *sess, aim_module_t *mod); |
---|
38 | int bos_modfirst(aim_session_t *sess, aim_module_t *mod); |
---|
39 | int search_modfirst(aim_session_t *sess, aim_module_t *mod); |
---|
40 | int stats_modfirst(aim_session_t *sess, aim_module_t *mod); |
---|
41 | int auth_modfirst(aim_session_t *sess, aim_module_t *mod); |
---|
42 | int msg_modfirst(aim_session_t *sess, aim_module_t *mod); |
---|
43 | int misc_modfirst(aim_session_t *sess, aim_module_t *mod); |
---|
44 | int chatnav_modfirst(aim_session_t *sess, aim_module_t *mod); |
---|
45 | int chat_modfirst(aim_session_t *sess, aim_module_t *mod); |
---|
46 | int locate_modfirst(aim_session_t *sess, aim_module_t *mod); |
---|
47 | int general_modfirst(aim_session_t *sess, aim_module_t *mod); |
---|
48 | int ssi_modfirst(aim_session_t *sess, aim_module_t *mod); |
---|
49 | int icq_modfirst(aim_session_t *sess, aim_module_t *mod); |
---|
50 | |
---|
51 | int aim_genericreq_n(aim_session_t *, aim_conn_t *conn, guint16 family, guint16 subtype); |
---|
52 | int aim_genericreq_n_snacid(aim_session_t *, aim_conn_t *conn, guint16 family, guint16 subtype); |
---|
53 | int aim_genericreq_l(aim_session_t *, aim_conn_t *conn, guint16 family, guint16 subtype, guint32 *); |
---|
54 | int aim_genericreq_s(aim_session_t *, aim_conn_t *conn, guint16 family, guint16 subtype, guint16 *); |
---|
55 | |
---|
56 | #define AIMBS_CURPOSPAIR(x) ((x)->data + (x)->offset), ((x)->len - (x)->offset) |
---|
57 | |
---|
58 | void aim_rxqueue_cleanbyconn(aim_session_t *sess, aim_conn_t *conn); |
---|
59 | int aim_recv(int fd, void *buf, size_t count); |
---|
60 | int aim_bstream_init(aim_bstream_t *bs, guint8 *data, int len); |
---|
61 | int aim_bstream_empty(aim_bstream_t *bs); |
---|
62 | int aim_bstream_curpos(aim_bstream_t *bs); |
---|
63 | int aim_bstream_setpos(aim_bstream_t *bs, int off); |
---|
64 | void aim_bstream_rewind(aim_bstream_t *bs); |
---|
65 | int aim_bstream_advance(aim_bstream_t *bs, int n); |
---|
66 | guint8 aimbs_get8(aim_bstream_t *bs); |
---|
67 | guint16 aimbs_get16(aim_bstream_t *bs); |
---|
68 | guint32 aimbs_get32(aim_bstream_t *bs); |
---|
69 | guint8 aimbs_getle8(aim_bstream_t *bs); |
---|
70 | guint16 aimbs_getle16(aim_bstream_t *bs); |
---|
71 | guint32 aimbs_getle32(aim_bstream_t *bs); |
---|
72 | int aimbs_put8(aim_bstream_t *bs, guint8 v); |
---|
73 | int aimbs_put16(aim_bstream_t *bs, guint16 v); |
---|
74 | int aimbs_put32(aim_bstream_t *bs, guint32 v); |
---|
75 | int aimbs_putle8(aim_bstream_t *bs, guint8 v); |
---|
76 | int aimbs_putle16(aim_bstream_t *bs, guint16 v); |
---|
77 | int aimbs_putle32(aim_bstream_t *bs, guint32 v); |
---|
78 | int aimbs_getrawbuf(aim_bstream_t *bs, guint8 *buf, int len); |
---|
79 | guint8 *aimbs_getraw(aim_bstream_t *bs, int len); |
---|
80 | char *aimbs_getstr(aim_bstream_t *bs, int len); |
---|
81 | int aimbs_putraw(aim_bstream_t *bs, const guint8 *v, int len); |
---|
82 | int aimbs_putbs(aim_bstream_t *bs, aim_bstream_t *srcbs, int len); |
---|
83 | |
---|
84 | int aim_get_command_rendezvous(aim_session_t *sess, aim_conn_t *conn); |
---|
85 | |
---|
86 | int aim_tx_sendframe(aim_session_t *sess, aim_frame_t *cur); |
---|
87 | flap_seqnum_t aim_get_next_txseqnum(aim_conn_t *); |
---|
88 | aim_frame_t *aim_tx_new(aim_session_t *sess, aim_conn_t *conn, guint8 framing, guint8 chan, int datalen); |
---|
89 | void aim_frame_destroy(aim_frame_t *); |
---|
90 | int aim_tx_enqueue(aim_session_t *, aim_frame_t *); |
---|
91 | int aim_tx_printqueue(aim_session_t *); |
---|
92 | void aim_tx_cleanqueue(aim_session_t *, aim_conn_t *); |
---|
93 | |
---|
94 | aim_rxcallback_t aim_callhandler(aim_session_t *sess, aim_conn_t *conn, u_short family, u_short type); |
---|
95 | |
---|
96 | /* |
---|
97 | * Generic SNAC structure. Rarely if ever used. |
---|
98 | */ |
---|
99 | typedef struct aim_snac_s { |
---|
100 | aim_snacid_t id; |
---|
101 | guint16 family; |
---|
102 | guint16 type; |
---|
103 | guint16 flags; |
---|
104 | void *data; |
---|
105 | time_t issuetime; |
---|
106 | struct aim_snac_s *next; |
---|
107 | } aim_snac_t; |
---|
108 | |
---|
109 | void aim_initsnachash(aim_session_t *sess); |
---|
110 | aim_snacid_t aim_cachesnac(aim_session_t *sess, const guint16 family, const guint16 type, const guint16 flags, |
---|
111 | const void *data, const int datalen); |
---|
112 | aim_snac_t *aim_remsnac(aim_session_t *, aim_snacid_t id); |
---|
113 | void aim_cleansnacs(aim_session_t *, int maxage); |
---|
114 | int aim_putsnac(aim_bstream_t *, guint16 family, guint16 type, guint16 flags, aim_snacid_t id); |
---|
115 | |
---|
116 | int aim_oft_buildheader(unsigned char *, struct aim_fileheader_t *); |
---|
117 | |
---|
118 | int aim_parse_unknown(aim_session_t *, aim_frame_t *, ...); |
---|
119 | |
---|
120 | /* Stored in ->priv of the service request SNAC for chats. */ |
---|
121 | struct chatsnacinfo { |
---|
122 | guint16 exchange; |
---|
123 | char name[128]; |
---|
124 | guint16 instance; |
---|
125 | }; |
---|
126 | |
---|
127 | /* these are used by aim_*_clientready */ |
---|
128 | #define AIM_TOOL_JAVA 0x0001 |
---|
129 | #define AIM_TOOL_MAC 0x0002 |
---|
130 | #define AIM_TOOL_WIN16 0x0003 |
---|
131 | #define AIM_TOOL_WIN32 0x0004 |
---|
132 | #define AIM_TOOL_MAC68K 0x0005 |
---|
133 | #define AIM_TOOL_MACPPC 0x0006 |
---|
134 | #define AIM_TOOL_NEWWIN 0x0010 |
---|
135 | struct aim_tool_version { |
---|
136 | guint16 group; |
---|
137 | guint16 version; |
---|
138 | guint16 tool; |
---|
139 | guint16 toolversion; |
---|
140 | }; |
---|
141 | |
---|
142 | /* |
---|
143 | * In SNACland, the terms 'family' and 'group' are synonymous -- the former |
---|
144 | * is my term, the latter is AOL's. |
---|
145 | */ |
---|
146 | struct snacgroup { |
---|
147 | guint16 group; |
---|
148 | struct snacgroup *next; |
---|
149 | }; |
---|
150 | |
---|
151 | struct snacpair { |
---|
152 | guint16 group; |
---|
153 | guint16 subtype; |
---|
154 | struct snacpair *next; |
---|
155 | }; |
---|
156 | |
---|
157 | struct rateclass { |
---|
158 | guint16 classid; |
---|
159 | guint32 windowsize; |
---|
160 | guint32 clear; |
---|
161 | guint32 alert; |
---|
162 | guint32 limit; |
---|
163 | guint32 disconnect; |
---|
164 | guint32 current; |
---|
165 | guint32 max; |
---|
166 | guint8 unknown[5]; /* only present in versions >= 3 */ |
---|
167 | struct snacpair *members; |
---|
168 | struct rateclass *next; |
---|
169 | }; |
---|
170 | |
---|
171 | /* |
---|
172 | * This is inside every connection. But it is a void * to anything |
---|
173 | * outside of libfaim. It should remain that way. It's called data |
---|
174 | * abstraction. Maybe you've heard of it. (Probably not if you're a |
---|
175 | * libfaim user.) |
---|
176 | * |
---|
177 | */ |
---|
178 | typedef struct aim_conn_inside_s { |
---|
179 | struct snacgroup *groups; |
---|
180 | struct rateclass *rates; |
---|
181 | } aim_conn_inside_t; |
---|
182 | |
---|
183 | void aim_conn_addgroup(aim_conn_t *conn, guint16 group); |
---|
184 | |
---|
185 | guint32 aim_getcap(aim_session_t *sess, aim_bstream_t *bs, int len); |
---|
186 | int aim_putcap(aim_bstream_t *bs, guint32 caps); |
---|
187 | |
---|
188 | int aim_cachecookie(aim_session_t *sess, aim_msgcookie_t *cookie); |
---|
189 | aim_msgcookie_t *aim_uncachecookie(aim_session_t *sess, guint8 *cookie, int type); |
---|
190 | aim_msgcookie_t *aim_mkcookie(guint8 *, int, void *); |
---|
191 | aim_msgcookie_t *aim_checkcookie(aim_session_t *sess, const unsigned char *, const int); |
---|
192 | int aim_freecookie(aim_session_t *sess, aim_msgcookie_t *cookie); |
---|
193 | int aim_cookie_free(aim_session_t *sess, aim_msgcookie_t *cookie); |
---|
194 | |
---|
195 | int aim_extractuserinfo(aim_session_t *sess, aim_bstream_t *bs, aim_userinfo_t *); |
---|
196 | |
---|
197 | int aim_chat_readroominfo(aim_bstream_t *bs, struct aim_chat_roominfo *outinfo); |
---|
198 | |
---|
199 | void aim_conn_close_rend(aim_session_t *sess, aim_conn_t *conn); |
---|
200 | void aim_conn_kill_rend(aim_session_t *sess, aim_conn_t *conn); |
---|
201 | |
---|
202 | void aim_conn_kill_chat(aim_session_t *sess, aim_conn_t *conn); |
---|
203 | |
---|
204 | /* These are all handled internally now. */ |
---|
205 | int aim_setversions(aim_session_t *sess, aim_conn_t *conn); |
---|
206 | int aim_reqrates(aim_session_t *, aim_conn_t *); |
---|
207 | int aim_rates_addparam(aim_session_t *, aim_conn_t *); |
---|
208 | |
---|
209 | #endif /* __AIM_INTERNAL_H__ */ |
---|