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