]>
Commit | Line | Data |
---|---|---|
9de3ca7e | 1 | |
2 | /* | |
3 | * aim_misc.c | |
4 | * | |
5 | * TODO: Seperate a lot of this into an aim_bos.c. | |
6 | * | |
7 | * Other things... | |
8 | * | |
9 | * - Idle setting | |
10 | * | |
11 | * | |
12 | */ | |
13 | ||
a25832e6 | 14 | #include <faim/aim.h> |
9de3ca7e | 15 | |
16 | /* | |
17 | * aim_bos_setidle() | |
18 | * | |
19 | * Should set your current idle time in seconds. Idealy, OSCAR should | |
20 | * do this for us. But, it doesn't. The client must call this to set idle | |
21 | * time. | |
22 | * | |
23 | */ | |
a25832e6 | 24 | u_long aim_bos_setidle(struct aim_session_t *sess, |
25 | struct aim_conn_t *conn, | |
26 | u_long idletime) | |
9de3ca7e | 27 | { |
a25832e6 | 28 | return aim_genericreq_l(sess, conn, 0x0001, 0x0011, &idletime); |
9de3ca7e | 29 | } |
30 | ||
31 | ||
32 | /* | |
33 | * aim_bos_changevisibility(conn, changtype, namelist) | |
34 | * | |
35 | * Changes your visibility depending on changetype: | |
36 | * | |
37 | * AIM_VISIBILITYCHANGE_PERMITADD: Lets provided list of names see you | |
38 | * AIM_VISIBILITYCHANGE_PERMIDREMOVE: Removes listed names from permit list | |
39 | * AIM_VISIBILITYCHANGE_DENYADD: Hides you from provided list of names | |
40 | * AIM_VISIBILITYCHANGE_DENYREMOVE: Lets list see you again | |
41 | * | |
42 | * list should be a list of | |
43 | * screen names in the form "Screen Name One&ScreenNameTwo&" etc. | |
44 | * | |
45 | * Equivelents to options in WinAIM: | |
46 | * - Allow all users to contact me: Send an AIM_VISIBILITYCHANGE_DENYADD | |
47 | * with only your name on it. | |
48 | * - Allow only users on my Buddy List: Send an | |
49 | * AIM_VISIBILITYCHANGE_PERMITADD with the list the same as your | |
50 | * buddy list | |
51 | * - Allow only the uesrs below: Send an AIM_VISIBILITYCHANGE_PERMITADD | |
52 | * with everyone listed that you want to see you. | |
53 | * - Block all users: Send an AIM_VISIBILITYCHANGE_PERMITADD with only | |
54 | * yourself in the list | |
55 | * - Block the users below: Send an AIM_VISIBILITYCHANGE_DENYADD with | |
56 | * the list of users to be blocked | |
57 | * | |
58 | * | |
59 | */ | |
a25832e6 | 60 | u_long aim_bos_changevisibility(struct aim_session_t *sess, |
61 | struct aim_conn_t *conn, | |
62 | int changetype, char *denylist) | |
9de3ca7e | 63 | { |
5b79dc93 | 64 | struct command_tx_struct *newpacket; |
65 | int packlen = 0; | |
9de3ca7e | 66 | u_short subtype; |
67 | ||
68 | char *localcpy = NULL; | |
69 | char *tmpptr = NULL; | |
70 | int i,j; | |
71 | int listcount; | |
72 | ||
73 | if (!denylist) | |
74 | return 0; | |
75 | ||
9de3ca7e | 76 | localcpy = (char *) malloc(strlen(denylist)+1); |
77 | memcpy(localcpy, denylist, strlen(denylist)+1); | |
78 | ||
79 | listcount = aimutil_itemcnt(localcpy, '&'); | |
5b79dc93 | 80 | packlen = aimutil_tokslen(localcpy, 99, '&') + listcount + 9; |
9de3ca7e | 81 | |
b69540e3 | 82 | if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, packlen))) |
5b79dc93 | 83 | return -1; |
9de3ca7e | 84 | |
5b79dc93 | 85 | newpacket->lock = 1; |
9de3ca7e | 86 | |
87 | switch(changetype) | |
88 | { | |
89 | case AIM_VISIBILITYCHANGE_PERMITADD: subtype = 0x05; break; | |
90 | case AIM_VISIBILITYCHANGE_PERMITREMOVE: subtype = 0x06; break; | |
91 | case AIM_VISIBILITYCHANGE_DENYADD: subtype = 0x07; break; | |
92 | case AIM_VISIBILITYCHANGE_DENYREMOVE: subtype = 0x08; break; | |
93 | default: | |
5b79dc93 | 94 | free(newpacket->data); |
95 | free(newpacket); | |
9de3ca7e | 96 | return 0; |
97 | } | |
98 | ||
99 | /* We actually DO NOT send a SNAC ID with this one! */ | |
5b79dc93 | 100 | aim_putsnac(newpacket->data, 0x0009, subtype, 0x00, 0); |
9de3ca7e | 101 | |
102 | j = 10; /* the next byte */ | |
103 | ||
104 | for (i=0; (i < (listcount - 1)) && (i < 99); i++) | |
105 | { | |
106 | tmpptr = aimutil_itemidx(localcpy, i, '&'); | |
107 | ||
5b79dc93 | 108 | newpacket->data[j] = strlen(tmpptr); |
109 | memcpy(&(newpacket->data[j+1]), tmpptr, strlen(tmpptr)); | |
9de3ca7e | 110 | j += strlen(tmpptr)+1; |
111 | free(tmpptr); | |
112 | } | |
113 | free(localcpy); | |
114 | ||
5b79dc93 | 115 | newpacket->lock = 0; |
9de3ca7e | 116 | |
5b79dc93 | 117 | aim_tx_enqueue(sess, newpacket); |
9de3ca7e | 118 | |
a25832e6 | 119 | return (sess->snac_nextid); /* dont increment */ |
9de3ca7e | 120 | |
121 | } | |
122 | ||
123 | ||
124 | ||
125 | /* | |
126 | * aim_bos_setbuddylist(buddylist) | |
127 | * | |
128 | * This just builds the "set buddy list" command then queues it. | |
129 | * | |
130 | * buddy_list = "Screen Name One&ScreenNameTwo&"; | |
131 | * | |
5b79dc93 | 132 | * TODO: Clean this up. |
133 | * | |
134 | * XXX: I can't stress the TODO enough. | |
9de3ca7e | 135 | * |
136 | */ | |
a25832e6 | 137 | u_long aim_bos_setbuddylist(struct aim_session_t *sess, |
138 | struct aim_conn_t *conn, | |
139 | char *buddy_list) | |
9de3ca7e | 140 | { |
141 | int i, j; | |
142 | ||
5b79dc93 | 143 | struct command_tx_struct *newpacket; |
9de3ca7e | 144 | |
c78446b5 | 145 | int len = 0; |
9de3ca7e | 146 | |
147 | char *localcpy = NULL; | |
148 | char *tmpptr = NULL; | |
149 | ||
c78446b5 | 150 | len = 10; /* 10B SNAC headers */ |
9de3ca7e | 151 | |
c78446b5 | 152 | if (!buddy_list || !(localcpy = (char *) malloc(strlen(buddy_list)+1))) |
5b79dc93 | 153 | return -1; |
c78446b5 | 154 | strncpy(localcpy, buddy_list, strlen(buddy_list)+1); |
9de3ca7e | 155 | |
156 | i = 0; | |
157 | tmpptr = strtok(localcpy, "&"); | |
c78446b5 | 158 | while ((tmpptr != NULL) && (i < 150)) { |
9de3ca7e | 159 | #if debug > 0 |
c78446b5 | 160 | printf("---adding %d: %s (%d)\n", i, tmpptr, strlen(tmpptr)); |
9de3ca7e | 161 | #endif |
c78446b5 | 162 | len += 1+strlen(tmpptr); |
163 | i++; | |
164 | tmpptr = strtok(NULL, "&"); | |
165 | } | |
9de3ca7e | 166 | #if debug > 0 |
c78446b5 | 167 | printf("*** send buddy list len: %d (%x)\n", len, len); |
9de3ca7e | 168 | #endif |
9de3ca7e | 169 | |
c78446b5 | 170 | if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, len))) |
5b79dc93 | 171 | return -1; |
9de3ca7e | 172 | |
5b79dc93 | 173 | newpacket->lock = 1; |
174 | ||
c78446b5 | 175 | aim_putsnac(newpacket->data, 0x0003, 0x0004, 0x0000, 0); |
9de3ca7e | 176 | |
177 | j = 10; /* the next byte */ | |
178 | ||
c78446b5 | 179 | strncpy(localcpy, buddy_list, strlen(buddy_list)+1); |
9de3ca7e | 180 | i = 0; |
c78446b5 | 181 | tmpptr = strtok(localcpy, "&"); |
182 | while ((tmpptr != NULL) & (i < 150)) { | |
9de3ca7e | 183 | #if debug > 0 |
c78446b5 | 184 | printf("---adding %d: %s (%d)\n", i, tmpptr, strlen(tmpptr)); |
9de3ca7e | 185 | #endif |
c78446b5 | 186 | newpacket->data[j] = strlen(tmpptr); |
187 | memcpy(&(newpacket->data[j+1]), tmpptr, strlen(tmpptr)); | |
188 | j += 1+strlen(tmpptr); | |
189 | i++; | |
190 | tmpptr = strtok(NULL, "&"); | |
191 | } | |
9de3ca7e | 192 | |
5b79dc93 | 193 | newpacket->lock = 0; |
9de3ca7e | 194 | |
5b79dc93 | 195 | aim_tx_enqueue(sess, newpacket); |
9de3ca7e | 196 | |
c78446b5 | 197 | free(localcpy); |
198 | ||
199 | return (sess->snac_nextid); | |
9de3ca7e | 200 | } |
201 | ||
202 | /* | |
203 | * aim_bos_setprofile(profile) | |
204 | * | |
205 | * Gives BOS your profile. | |
206 | * | |
26af6789 | 207 | * |
9de3ca7e | 208 | */ |
a25832e6 | 209 | u_long aim_bos_setprofile(struct aim_session_t *sess, |
210 | struct aim_conn_t *conn, | |
0c20631f | 211 | char *profile, |
5b79dc93 | 212 | char *awaymsg, |
213 | unsigned int caps) | |
9de3ca7e | 214 | { |
5b79dc93 | 215 | struct command_tx_struct *newpacket; |
b69540e3 | 216 | int i = 0, tmp, caplen; |
0c20631f | 217 | |
b69540e3 | 218 | if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 1152+strlen(profile)+1+(awaymsg?strlen(awaymsg):0)))) |
5b79dc93 | 219 | return -1; |
9de3ca7e | 220 | |
5b79dc93 | 221 | i += aim_putsnac(newpacket->data, 0x0002, 0x004, 0x0000, sess->snac_nextid); |
222 | i += aim_puttlv_str(newpacket->data+i, 0x0001, strlen("text/x-aolrtf; charset=\"us-ascii\""), "text/x-aolrtf; charset=\"us-ascii\""); | |
223 | i += aim_puttlv_str(newpacket->data+i, 0x0002, strlen(profile), profile); | |
26af6789 | 224 | /* why do we send this twice? */ |
5b79dc93 | 225 | i += aim_puttlv_str(newpacket->data+i, 0x0003, strlen("text/x-aolrtf; charset=\"us-ascii\""), "text/x-aolrtf; charset=\"us-ascii\""); |
9de3ca7e | 226 | |
0c20631f | 227 | /* Away message -- we send this no matter what, even if its blank */ |
228 | if (awaymsg) | |
5b79dc93 | 229 | i += aim_puttlv_str(newpacket->data+i, 0x0004, strlen(awaymsg), awaymsg); |
0c20631f | 230 | else |
5b79dc93 | 231 | i += aim_puttlv_str(newpacket->data+i, 0x0004, 0x0000, NULL); |
26af6789 | 232 | |
233 | /* Capability information. */ | |
b69540e3 | 234 | |
235 | tmp = (i += aimutil_put16(newpacket->data+i, 0x0005)); | |
236 | i += aimutil_put16(newpacket->data+i, 0x0000); /* rewritten later */ | |
237 | i += (caplen = aim_putcap(newpacket->data+i, 512, caps)); | |
238 | aimutil_put16(newpacket->data+tmp, caplen); /* rewrite TLV size */ | |
239 | ||
5b79dc93 | 240 | newpacket->commandlen = i; |
241 | aim_tx_enqueue(sess, newpacket); | |
9de3ca7e | 242 | |
a25832e6 | 243 | return (sess->snac_nextid++); |
9de3ca7e | 244 | } |
245 | ||
246 | /* | |
247 | * aim_bos_setgroupperm(mask) | |
248 | * | |
98c88242 | 249 | * Set group permisson mask. Normally 0x1f (all classes). |
250 | * | |
251 | * The group permission mask allows you to keep users of a certain | |
252 | * class or classes from talking to you. The mask should be | |
253 | * a bitwise OR of all the user classes you want to see you. | |
9de3ca7e | 254 | * |
255 | */ | |
a25832e6 | 256 | u_long aim_bos_setgroupperm(struct aim_session_t *sess, |
257 | struct aim_conn_t *conn, | |
258 | u_long mask) | |
9de3ca7e | 259 | { |
a25832e6 | 260 | return aim_genericreq_l(sess, conn, 0x0009, 0x0004, &mask); |
9de3ca7e | 261 | } |
262 | ||
96f8b1ed | 263 | int aim_parse_bosrights(struct aim_session_t *sess, |
264 | struct command_rx_struct *command, ...) | |
265 | { | |
266 | rxcallback_t userfunc = NULL; | |
267 | int ret=1; | |
268 | struct aim_tlvlist_t *tlvlist; | |
269 | struct aim_tlv_t *tlv; | |
270 | unsigned short maxpermits = 0, maxdenies = 0; | |
271 | ||
272 | /* | |
273 | * TLVs follow | |
274 | */ | |
275 | if (!(tlvlist = aim_readtlvchain(command->data+10, command->commandlen-10))) | |
276 | return ret; | |
277 | ||
278 | /* | |
279 | * TLV type 0x0001: Maximum number of buddies on permit list. | |
280 | */ | |
281 | if ((tlv = aim_gettlv(tlvlist, 0x0001, 1))) { | |
282 | maxpermits = aimutil_get16(tlv->value); | |
283 | } | |
284 | ||
285 | /* | |
286 | * TLV type 0x0002: Maximum number of buddies on deny list. | |
287 | * | |
288 | */ | |
289 | if ((tlv = aim_gettlv(tlvlist, 0x0002, 1))) { | |
290 | maxdenies = aimutil_get16(tlv->value); | |
291 | } | |
292 | ||
293 | userfunc = aim_callhandler(command->conn, 0x0009, 0x0003); | |
294 | if (userfunc) | |
295 | ret = userfunc(sess, command, maxpermits, maxdenies); | |
296 | ||
297 | aim_freetlvchain(&tlvlist); | |
298 | ||
299 | return ret; | |
300 | } | |
301 | ||
9de3ca7e | 302 | /* |
303 | * aim_bos_clientready() | |
304 | * | |
305 | * Send Client Ready. | |
306 | * | |
307 | * TODO: Dynamisize. | |
308 | * | |
309 | */ | |
a25832e6 | 310 | u_long aim_bos_clientready(struct aim_session_t *sess, |
311 | struct aim_conn_t *conn) | |
9de3ca7e | 312 | { |
313 | u_char command_2[] = { | |
314 | /* placeholders for dynamic data */ | |
315 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | |
316 | 0xff, 0xff, | |
317 | /* real data */ | |
01b59e1e | 318 | 0x00, 0x01, |
319 | 0x00, 0x03, | |
320 | 0x00, 0x04, | |
c78446b5 | 321 | 0x07, 0xda, |
322 | ||
01b59e1e | 323 | 0x00, 0x02, |
324 | 0x00, 0x01, | |
325 | 0x00, 0x04, | |
326 | 0x00, 0x01, | |
327 | ||
328 | 0x00, 0x03, | |
329 | 0x00, 0x01, | |
330 | 0x00, 0x04, | |
c78446b5 | 331 | 0x00, 0x01, |
332 | ||
01b59e1e | 333 | 0x00, 0x04, |
334 | 0x00, 0x01, | |
335 | 0x00, 0x04, | |
336 | 0x00, 0x01, | |
337 | ||
338 | 0x00, 0x06, | |
339 | 0x00, 0x01, | |
340 | 0x00, 0x04, | |
341 | 0x00, 0x01, | |
342 | 0x00, 0x08, | |
343 | 0x00, 0x01, | |
344 | 0x00, 0x04, | |
345 | 0x00, 0x01, | |
346 | ||
347 | 0x00, 0x09, | |
348 | 0x00, 0x01, | |
349 | 0x00, 0x04, | |
350 | 0x00, 0x01, | |
351 | 0x00, 0x0a, | |
352 | 0x00, 0x01, | |
353 | 0x00, 0x04, | |
354 | 0x00, 0x01, | |
355 | ||
356 | 0x00, 0x0b, | |
357 | 0x00, 0x01, | |
358 | 0x00, 0x04, | |
9de3ca7e | 359 | 0x00, 0x01 |
360 | }; | |
361 | int command_2_len = 0x52; | |
5b79dc93 | 362 | struct command_tx_struct *newpacket; |
9de3ca7e | 363 | |
b69540e3 | 364 | if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, command_2_len))) |
5b79dc93 | 365 | return -1; |
366 | ||
367 | newpacket->lock = 1; | |
368 | ||
369 | memcpy(newpacket->data, command_2, command_2_len); | |
9de3ca7e | 370 | |
371 | /* This write over the dynamic parts of the byte block */ | |
5b79dc93 | 372 | aim_putsnac(newpacket->data, 0x0001, 0x0002, 0x0000, sess->snac_nextid); |
9de3ca7e | 373 | |
5b79dc93 | 374 | aim_tx_enqueue(sess, newpacket); |
9de3ca7e | 375 | |
a25832e6 | 376 | return (sess->snac_nextid++); |
9de3ca7e | 377 | } |
378 | ||
379 | /* | |
9de3ca7e | 380 | * Request Rate Information. |
381 | * | |
9de3ca7e | 382 | */ |
a25832e6 | 383 | u_long aim_bos_reqrate(struct aim_session_t *sess, |
384 | struct aim_conn_t *conn) | |
9de3ca7e | 385 | { |
a25832e6 | 386 | return aim_genericreq_n(sess, conn, 0x0001, 0x0006); |
9de3ca7e | 387 | } |
388 | ||
389 | /* | |
9de3ca7e | 390 | * Rate Information Response Acknowledge. |
391 | * | |
392 | */ | |
a25832e6 | 393 | u_long aim_bos_ackrateresp(struct aim_session_t *sess, |
394 | struct aim_conn_t *conn) | |
9de3ca7e | 395 | { |
5b79dc93 | 396 | struct command_tx_struct *newpacket; |
c78446b5 | 397 | int packlen = 20, i=0; |
9de3ca7e | 398 | |
c78446b5 | 399 | if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, packlen))) |
400 | return (sess->snac_nextid); | |
5b79dc93 | 401 | |
402 | newpacket->lock = 1; | |
9de3ca7e | 403 | |
c78446b5 | 404 | i = aim_putsnac(newpacket->data, 0x0001, 0x0008, 0x0000, 0); |
5b79dc93 | 405 | i += aimutil_put16(newpacket->data+i, 0x0001); |
406 | i += aimutil_put16(newpacket->data+i, 0x0002); | |
407 | i += aimutil_put16(newpacket->data+i, 0x0003); | |
408 | i += aimutil_put16(newpacket->data+i, 0x0004); | |
c78446b5 | 409 | i += aimutil_put16(newpacket->data+i, 0x0005); |
5b79dc93 | 410 | |
5b79dc93 | 411 | aim_tx_enqueue(sess, newpacket); |
9de3ca7e | 412 | |
c78446b5 | 413 | return (sess->snac_nextid); |
9de3ca7e | 414 | } |
415 | ||
416 | /* | |
417 | * aim_bos_setprivacyflags() | |
418 | * | |
419 | * Sets privacy flags. Normally 0x03. | |
420 | * | |
421 | * Bit 1: Allows other AIM users to see how long you've been idle. | |
98c88242 | 422 | * Bit 2: Allows other AIM users to see how long you've been a member. |
9de3ca7e | 423 | * |
424 | */ | |
a25832e6 | 425 | u_long aim_bos_setprivacyflags(struct aim_session_t *sess, |
426 | struct aim_conn_t *conn, | |
427 | u_long flags) | |
9de3ca7e | 428 | { |
a25832e6 | 429 | return aim_genericreq_l(sess, conn, 0x0001, 0x0014, &flags); |
9de3ca7e | 430 | } |
431 | ||
432 | /* | |
433 | * aim_bos_reqpersonalinfo() | |
434 | * | |
435 | * Requests the current user's information. Can't go generic on this one | |
436 | * because aparently it uses SNAC flags. | |
437 | * | |
438 | */ | |
a25832e6 | 439 | u_long aim_bos_reqpersonalinfo(struct aim_session_t *sess, |
440 | struct aim_conn_t *conn) | |
9de3ca7e | 441 | { |
c78446b5 | 442 | return aim_genericreq_n(sess, conn, 0x0001, 0x000e); |
9de3ca7e | 443 | } |
444 | ||
01b59e1e | 445 | u_long aim_setversions(struct aim_session_t *sess, |
446 | struct aim_conn_t *conn) | |
447 | { | |
5b79dc93 | 448 | struct command_tx_struct *newpacket; |
0c20631f | 449 | int i; |
01b59e1e | 450 | |
c78446b5 | 451 | if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10 + (4*12)))) |
5b79dc93 | 452 | return -1; |
453 | ||
454 | newpacket->lock = 1; | |
01b59e1e | 455 | |
5b79dc93 | 456 | i = aim_putsnac(newpacket->data, 0x0001, 0x0017, 0x0000, sess->snac_nextid); |
01b59e1e | 457 | |
5b79dc93 | 458 | i += aimutil_put16(newpacket->data+i, 0x0001); |
459 | i += aimutil_put16(newpacket->data+i, 0x0003); | |
26af6789 | 460 | |
5b79dc93 | 461 | i += aimutil_put16(newpacket->data+i, 0x0002); |
462 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
26af6789 | 463 | |
5b79dc93 | 464 | i += aimutil_put16(newpacket->data+i, 0x0003); |
465 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
26af6789 | 466 | |
5b79dc93 | 467 | i += aimutil_put16(newpacket->data+i, 0x0004); |
468 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
26af6789 | 469 | |
5b79dc93 | 470 | i += aimutil_put16(newpacket->data+i, 0x0006); |
471 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
26af6789 | 472 | |
5b79dc93 | 473 | i += aimutil_put16(newpacket->data+i, 0x0008); |
474 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
26af6789 | 475 | |
5b79dc93 | 476 | i += aimutil_put16(newpacket->data+i, 0x0009); |
477 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
26af6789 | 478 | |
5b79dc93 | 479 | i += aimutil_put16(newpacket->data+i, 0x000a); |
480 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
26af6789 | 481 | |
5b79dc93 | 482 | i += aimutil_put16(newpacket->data+i, 0x000b); |
483 | i += aimutil_put16(newpacket->data+i, 0x0002); | |
26af6789 | 484 | |
5b79dc93 | 485 | i += aimutil_put16(newpacket->data+i, 0x000c); |
486 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
26af6789 | 487 | |
c78446b5 | 488 | i += aimutil_put16(newpacket->data+i, 0x0013); |
489 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
490 | ||
5b79dc93 | 491 | i += aimutil_put16(newpacket->data+i, 0x0015); |
492 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
01b59e1e | 493 | |
494 | #if 0 | |
5b79dc93 | 495 | for (j = 0; j < 0x10; j++) { |
496 | i += aimutil_put16(newpacket->data+i, j); /* family */ | |
497 | i += aimutil_put16(newpacket->data+i, 0x0003); /* version */ | |
498 | } | |
01b59e1e | 499 | #endif |
5b79dc93 | 500 | newpacket->lock = 0; |
501 | aim_tx_enqueue(sess, newpacket); | |
01b59e1e | 502 | |
503 | return (sess->snac_nextid++); | |
504 | } | |
505 | ||
506 | ||
9de3ca7e | 507 | /* |
508 | * aim_bos_reqservice(serviceid) | |
509 | * | |
510 | * Service request. | |
511 | * | |
512 | */ | |
a25832e6 | 513 | u_long aim_bos_reqservice(struct aim_session_t *sess, |
514 | struct aim_conn_t *conn, | |
515 | u_short serviceid) | |
9de3ca7e | 516 | { |
a25832e6 | 517 | return aim_genericreq_s(sess, conn, 0x0001, 0x0004, &serviceid); |
9de3ca7e | 518 | } |
519 | ||
f0a7908e | 520 | /* |
521 | * aim_bos_nop() | |
522 | * | |
523 | * No-op. WinAIM sends these every 4min or so to keep | |
98c88242 | 524 | * the connection alive. Its not real necessary. |
f0a7908e | 525 | * |
526 | */ | |
527 | u_long aim_bos_nop(struct aim_session_t *sess, | |
528 | struct aim_conn_t *conn) | |
529 | { | |
530 | return aim_genericreq_n(sess, conn, 0x0001, 0x0016); | |
531 | } | |
532 | ||
9de3ca7e | 533 | /* |
534 | * aim_bos_reqrights() | |
535 | * | |
536 | * Request BOS rights. | |
537 | * | |
538 | */ | |
a25832e6 | 539 | u_long aim_bos_reqrights(struct aim_session_t *sess, |
540 | struct aim_conn_t *conn) | |
9de3ca7e | 541 | { |
a25832e6 | 542 | return aim_genericreq_n(sess, conn, 0x0009, 0x0002); |
9de3ca7e | 543 | } |
544 | ||
545 | /* | |
546 | * aim_bos_reqbuddyrights() | |
547 | * | |
548 | * Request Buddy List rights. | |
549 | * | |
550 | */ | |
a25832e6 | 551 | u_long aim_bos_reqbuddyrights(struct aim_session_t *sess, |
552 | struct aim_conn_t *conn) | |
9de3ca7e | 553 | { |
a25832e6 | 554 | return aim_genericreq_n(sess, conn, 0x0003, 0x0002); |
9de3ca7e | 555 | } |
556 | ||
98c88242 | 557 | /* |
558 | * aim_send_warning(struct aim_session_t *sess, | |
559 | * struct aim_conn_t *conn, char *destsn, int anon) | |
560 | * send a warning to destsn. | |
561 | * anon is anonymous or not; | |
562 | * AIM_WARN_ANON anonymous | |
563 | * | |
564 | * returns -1 on error (couldn't alloc packet), next snacid on success. | |
565 | * | |
566 | */ | |
567 | int aim_send_warning(struct aim_session_t *sess, struct aim_conn_t *conn, char *destsn, int anon) | |
568 | { | |
569 | struct command_tx_struct *newpacket; | |
570 | int curbyte; | |
571 | ||
572 | if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, strlen(destsn)+13))) | |
573 | return -1; | |
574 | ||
575 | newpacket->lock = 1; | |
576 | ||
577 | curbyte = 0; | |
578 | curbyte += aim_putsnac(newpacket->data+curbyte, | |
579 | 0x0004, 0x0008, 0x0000, sess->snac_nextid); | |
580 | ||
581 | curbyte += aimutil_put16(newpacket->data+curbyte, (anon & AIM_WARN_ANON)?1:0); | |
582 | ||
583 | curbyte += aimutil_put8(newpacket->data+curbyte, strlen(destsn)); | |
584 | ||
585 | curbyte += aimutil_putstr(newpacket->data+curbyte, destsn, strlen(destsn)); | |
586 | ||
587 | newpacket->commandlen = curbyte; | |
588 | newpacket->lock = 0; | |
589 | ||
590 | aim_tx_enqueue(sess, newpacket); | |
591 | ||
592 | return (sess->snac_nextid++); | |
593 | } | |
594 | ||
595 | ||
596 | ||
e5012450 | 597 | /* |
598 | * aim_debugconn_sendconnect() | |
599 | * | |
600 | * For aimdebugd. If you don't know what it is, you don't want to. | |
601 | */ | |
602 | u_long aim_debugconn_sendconnect(struct aim_session_t *sess, | |
603 | struct aim_conn_t *conn) | |
604 | { | |
605 | return aim_genericreq_n(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_DEBUGCONN_CONNECT); | |
606 | } | |
607 | ||
9de3ca7e | 608 | /* |
609 | * Generic routine for sending commands. | |
610 | * | |
611 | * | |
612 | * I know I can do this in a smarter way...but I'm not thinking straight | |
613 | * right now... | |
614 | * | |
615 | * I had one big function that handled all three cases, but then it broke | |
616 | * and I split it up into three. But then I fixed it. I just never went | |
617 | * back to the single. I don't see any advantage to doing it either way. | |
618 | * | |
619 | */ | |
a25832e6 | 620 | u_long aim_genericreq_n(struct aim_session_t *sess, |
621 | struct aim_conn_t *conn, | |
622 | u_short family, u_short subtype) | |
9de3ca7e | 623 | { |
5b79dc93 | 624 | struct command_tx_struct *newpacket; |
9de3ca7e | 625 | |
b69540e3 | 626 | if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10))) |
5b79dc93 | 627 | return 0; |
9de3ca7e | 628 | |
5b79dc93 | 629 | newpacket->lock = 1; |
9de3ca7e | 630 | |
5b79dc93 | 631 | aim_putsnac(newpacket->data, family, subtype, 0x0000, sess->snac_nextid); |
9de3ca7e | 632 | |
5b79dc93 | 633 | aim_tx_enqueue(sess, newpacket); |
a25832e6 | 634 | return (sess->snac_nextid++); |
9de3ca7e | 635 | } |
636 | ||
637 | /* | |
638 | * | |
639 | * | |
640 | */ | |
a25832e6 | 641 | u_long aim_genericreq_l(struct aim_session_t *sess, |
642 | struct aim_conn_t *conn, | |
643 | u_short family, u_short subtype, u_long *longdata) | |
9de3ca7e | 644 | { |
5b79dc93 | 645 | struct command_tx_struct *newpacket; |
9de3ca7e | 646 | u_long newlong; |
647 | ||
648 | /* If we don't have data, there's no reason to use this function */ | |
649 | if (!longdata) | |
a25832e6 | 650 | return aim_genericreq_n(sess, conn, family, subtype); |
9de3ca7e | 651 | |
b69540e3 | 652 | if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+sizeof(u_long)))) |
5b79dc93 | 653 | return -1; |
9de3ca7e | 654 | |
5b79dc93 | 655 | newpacket->lock = 1; |
9de3ca7e | 656 | |
5b79dc93 | 657 | aim_putsnac(newpacket->data, family, subtype, 0x0000, sess->snac_nextid); |
9de3ca7e | 658 | |
659 | /* copy in data */ | |
660 | newlong = htonl(*longdata); | |
5b79dc93 | 661 | memcpy(&(newpacket->data[10]), &newlong, sizeof(u_long)); |
9de3ca7e | 662 | |
5b79dc93 | 663 | aim_tx_enqueue(sess, newpacket); |
a25832e6 | 664 | return (sess->snac_nextid++); |
9de3ca7e | 665 | } |
666 | ||
a25832e6 | 667 | u_long aim_genericreq_s(struct aim_session_t *sess, |
668 | struct aim_conn_t *conn, | |
669 | u_short family, u_short subtype, u_short *shortdata) | |
9de3ca7e | 670 | { |
5b79dc93 | 671 | struct command_tx_struct *newpacket; |
9de3ca7e | 672 | u_short newshort; |
673 | ||
674 | /* If we don't have data, there's no reason to use this function */ | |
675 | if (!shortdata) | |
a25832e6 | 676 | return aim_genericreq_n(sess, conn, family, subtype); |
9de3ca7e | 677 | |
b69540e3 | 678 | if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+sizeof(u_short)))) |
5b79dc93 | 679 | return -1; |
9de3ca7e | 680 | |
5b79dc93 | 681 | newpacket->lock = 1; |
9de3ca7e | 682 | |
5b79dc93 | 683 | aim_putsnac(newpacket->data, family, subtype, 0x0000, sess->snac_nextid); |
9de3ca7e | 684 | |
685 | /* copy in data */ | |
686 | newshort = htons(*shortdata); | |
5b79dc93 | 687 | memcpy(&(newpacket->data[10]), &newshort, sizeof(u_short)); |
9de3ca7e | 688 | |
5b79dc93 | 689 | aim_tx_enqueue(sess, newpacket); |
a25832e6 | 690 | return (sess->snac_nextid++); |
9de3ca7e | 691 | } |
692 | ||
693 | /* | |
694 | * aim_bos_reqlocaterights() | |
695 | * | |
696 | * Request Location services rights. | |
697 | * | |
698 | */ | |
a25832e6 | 699 | u_long aim_bos_reqlocaterights(struct aim_session_t *sess, |
700 | struct aim_conn_t *conn) | |
9de3ca7e | 701 | { |
a25832e6 | 702 | return aim_genericreq_n(sess, conn, 0x0002, 0x0002); |
9de3ca7e | 703 | } |
704 | ||
705 | /* | |
e88ba395 | 706 | * aim_bos_reqicbmparaminfo() |
9de3ca7e | 707 | * |
708 | * Request ICBM parameter information. | |
709 | * | |
710 | */ | |
a25832e6 | 711 | u_long aim_bos_reqicbmparaminfo(struct aim_session_t *sess, |
712 | struct aim_conn_t *conn) | |
9de3ca7e | 713 | { |
a25832e6 | 714 | return aim_genericreq_n(sess, conn, 0x0004, 0x0004); |
9de3ca7e | 715 | } |
e88ba395 | 716 | |
c78446b5 | 717 | /* |
718 | * Add ICBM parameter? Huh? | |
719 | */ | |
720 | unsigned long aim_addicbmparam(struct aim_session_t *sess, | |
721 | struct aim_conn_t *conn) | |
722 | { | |
723 | struct command_tx_struct *newpacket; | |
724 | int packlen = 10+16, i=0; | |
725 | ||
726 | if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, packlen))) | |
727 | return (sess->snac_nextid); | |
728 | ||
729 | newpacket->lock = 1; | |
730 | ||
731 | i = aim_putsnac(newpacket->data, 0x0004, 0x0002, 0x0000, sess->snac_nextid); | |
732 | i += aimutil_put16(newpacket->data+i, 0x0000); | |
733 | i += aimutil_put16(newpacket->data+i, 0x0000); | |
734 | i += aimutil_put16(newpacket->data+i, 0x0003); | |
735 | i += aimutil_put16(newpacket->data+i, 0x1f40); | |
736 | i += aimutil_put16(newpacket->data+i, 0x03e7); | |
737 | i += aimutil_put16(newpacket->data+i, 0x03e7); | |
738 | i += aimutil_put16(newpacket->data+i, 0x0000); | |
739 | i += aimutil_put16(newpacket->data+i, 0x0000); | |
740 | ||
741 | aim_tx_enqueue(sess, newpacket); | |
742 | ||
743 | return (sess->snac_nextid); | |
744 | } |