Changeset 5ebff60 for protocols/oscar/info.c
- Timestamp:
- 2015-02-20T22:50:54Z (9 years ago)
- Branches:
- master
- Children:
- 0b9daac, 3d45471, 7733b8c
- Parents:
- af359b4
- git-author:
- Indent <please@…> (19-02-15 05:47:20)
- git-committer:
- dequis <dx@…> (20-02-15 22:50:54)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/oscar/info.c
raf359b4 r5ebff60 3 3 * 4 4 * The functions here are responsible for requesting and parsing information- 5 * gathering SNACs. Or something like that. 5 * gathering SNACs. Or something like that. 6 6 * 7 7 */ … … 11 11 12 12 struct aim_priv_inforeq { 13 char sn[MAXSNLEN +1];13 char sn[MAXSNLEN + 1]; 14 14 guint16 infotype; 15 15 }; … … 21 21 aim_snacid_t snacid; 22 22 23 if (!sess || !conn || !sn) 23 if (!sess || !conn || !sn) { 24 24 return -EINVAL; 25 26 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 12+1+strlen(sn)))) 25 } 26 27 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 12 + 1 + strlen(sn)))) { 27 28 return -ENOMEM; 29 } 28 30 29 31 strncpy(privdata.sn, sn, sizeof(privdata.sn)); 30 32 privdata.infotype = infotype; 31 33 snacid = aim_cachesnac(sess, 0x0002, 0x0005, 0x0000, &privdata, sizeof(struct aim_priv_inforeq)); 32 34 33 35 aim_putsnac(&fr->data, 0x0002, 0x0005, 0x0000, snacid); 34 36 aimbs_put16(&fr->data, infotype); 35 37 aimbs_put8(&fr->data, strlen(sn)); 36 aimbs_putraw(&fr->data, (guint8 *) sn, strlen(sn));38 aimbs_putraw(&fr->data, (guint8 *) sn, strlen(sn)); 37 39 38 40 aim_tx_enqueue(sess, fr); … … 42 44 43 45 /* 44 * Capability blocks. 46 * Capability blocks. 45 47 * 46 48 * These are CLSIDs. They should actually be of the form: … … 59 61 * Chat is oddball. 60 62 */ 61 { AIM_CAPS_CHAT,62 {0x74, 0x8f, 0x24, 0x20, 0x62, 0x87, 0x11, 0xd1,63 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},63 { AIM_CAPS_CHAT, 64 { 0x74, 0x8f, 0x24, 0x20, 0x62, 0x87, 0x11, 0xd1, 65 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } }, 64 66 65 67 /* 66 68 * These are mostly in order. 67 69 */ 68 { AIM_CAPS_VOICE,69 {0x09, 0x46, 0x13, 0x41, 0x4c, 0x7f, 0x11, 0xd1,70 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},71 72 { AIM_CAPS_SENDFILE,73 {0x09, 0x46, 0x13, 0x43, 0x4c, 0x7f, 0x11, 0xd1,74 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},70 { AIM_CAPS_VOICE, 71 { 0x09, 0x46, 0x13, 0x41, 0x4c, 0x7f, 0x11, 0xd1, 72 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } }, 73 74 { AIM_CAPS_SENDFILE, 75 { 0x09, 0x46, 0x13, 0x43, 0x4c, 0x7f, 0x11, 0xd1, 76 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } }, 75 77 76 78 /* 77 79 * Advertised by the EveryBuddy client. 78 80 */ 79 { AIM_CAPS_ICQ,80 {0x09, 0x46, 0x13, 0x44, 0x4c, 0x7f, 0x11, 0xd1,81 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},82 83 { AIM_CAPS_IMIMAGE,84 {0x09, 0x46, 0x13, 0x45, 0x4c, 0x7f, 0x11, 0xd1,85 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},86 87 { AIM_CAPS_BUDDYICON,88 {0x09, 0x46, 0x13, 0x46, 0x4c, 0x7f, 0x11, 0xd1,89 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},90 91 { AIM_CAPS_SAVESTOCKS,92 {0x09, 0x46, 0x13, 0x47, 0x4c, 0x7f, 0x11, 0xd1,93 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},94 95 { AIM_CAPS_GETFILE,96 {0x09, 0x46, 0x13, 0x48, 0x4c, 0x7f, 0x11, 0xd1,97 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},98 99 100 101 102 103 104 105 106 { AIM_CAPS_ICQSERVERRELAY,107 {0x09, 0x46, 0x13, 0x49, 0x4c, 0x7f, 0x11, 0xd1,108 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},109 110 /* 111 * Indeed, there are two of these. The former appears to be correct, 112 * but in some versions of winaim, the second one is set. Either they 113 * forgot to fix endianness, or they made a typo. It really doesn't 81 { AIM_CAPS_ICQ, 82 { 0x09, 0x46, 0x13, 0x44, 0x4c, 0x7f, 0x11, 0xd1, 83 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } }, 84 85 { AIM_CAPS_IMIMAGE, 86 { 0x09, 0x46, 0x13, 0x45, 0x4c, 0x7f, 0x11, 0xd1, 87 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } }, 88 89 { AIM_CAPS_BUDDYICON, 90 { 0x09, 0x46, 0x13, 0x46, 0x4c, 0x7f, 0x11, 0xd1, 91 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } }, 92 93 { AIM_CAPS_SAVESTOCKS, 94 { 0x09, 0x46, 0x13, 0x47, 0x4c, 0x7f, 0x11, 0xd1, 95 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } }, 96 97 { AIM_CAPS_GETFILE, 98 { 0x09, 0x46, 0x13, 0x48, 0x4c, 0x7f, 0x11, 0xd1, 99 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } }, 100 101 /* 102 * Client supports channel 2 extended, TLV(0x2711) based messages. 103 * Currently used only by ICQ clients. ICQ clients and clones use this GUID 104 * as message format sign. Trillian client use another GUID in channel 2 105 * messages to implement its own message format (trillian doesn't use 106 * TLV(x2711) in SecureIM channel 2 messages!). 107 */ 108 { AIM_CAPS_ICQSERVERRELAY, 109 { 0x09, 0x46, 0x13, 0x49, 0x4c, 0x7f, 0x11, 0xd1, 110 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } }, 111 112 /* 113 * Indeed, there are two of these. The former appears to be correct, 114 * but in some versions of winaim, the second one is set. Either they 115 * forgot to fix endianness, or they made a typo. It really doesn't 114 116 * matter which. 115 117 */ 116 { AIM_CAPS_GAMES,117 {0x09, 0x46, 0x13, 0x4a, 0x4c, 0x7f, 0x11, 0xd1,118 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},119 { AIM_CAPS_GAMES2,120 {0x09, 0x46, 0x13, 0x4a, 0x4c, 0x7f, 0x11, 0xd1,121 0x22, 0x82, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},122 123 { AIM_CAPS_SENDBUDDYLIST,124 {0x09, 0x46, 0x13, 0x4b, 0x4c, 0x7f, 0x11, 0xd1,125 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},126 127 { AIM_CAPS_UTF8,128 {0x09, 0x46, 0x13, 0x4E, 0x4C, 0x7F, 0x11, 0xD1,129 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},130 131 { AIM_CAPS_ICQRTF,132 {0x97, 0xb1, 0x27, 0x51, 0x24, 0x3c, 0x43, 0x34,133 0xad, 0x22, 0xd6, 0xab, 0xf7, 0x3f, 0x14, 0x92}},134 135 { AIM_CAPS_ICQUNKNOWN,136 {0x2e, 0x7a, 0x64, 0x75, 0xfa, 0xdf, 0x4d, 0xc8,137 0x88, 0x6f, 0xea, 0x35, 0x95, 0xfd, 0xb6, 0xdf}},138 139 { AIM_CAPS_EMPTY,140 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,141 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},142 143 { AIM_CAPS_TRILLIANCRYPT,144 {0xf2, 0xe7, 0xc7, 0xf4, 0xfe, 0xad, 0x4d, 0xfb,145 0xb2, 0x35, 0x36, 0x79, 0x8b, 0xdf, 0x00, 0x00}},146 147 { AIM_CAPS_APINFO,148 {0xAA, 0x4A, 0x32, 0xB5, 0xF8, 0x84, 0x48, 0xc6,149 0xA3, 0xD7, 0x8C, 0x50, 0x97, 0x19, 0xFD, 0x5B}},150 151 { AIM_CAPS_INTEROP,152 {0x09, 0x46, 0x13, 0x4d, 0x4c, 0x7f, 0x11, 0xd1,153 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},154 155 { AIM_CAPS_ICHAT,156 {0x09, 0x46, 0x00, 0x00, 0x4c, 0x7f, 0x11, 0xd1,157 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},158 159 { AIM_CAPS_LAST}118 { AIM_CAPS_GAMES, 119 { 0x09, 0x46, 0x13, 0x4a, 0x4c, 0x7f, 0x11, 0xd1, 120 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } }, 121 { AIM_CAPS_GAMES2, 122 { 0x09, 0x46, 0x13, 0x4a, 0x4c, 0x7f, 0x11, 0xd1, 123 0x22, 0x82, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } }, 124 125 { AIM_CAPS_SENDBUDDYLIST, 126 { 0x09, 0x46, 0x13, 0x4b, 0x4c, 0x7f, 0x11, 0xd1, 127 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } }, 128 129 { AIM_CAPS_UTF8, 130 { 0x09, 0x46, 0x13, 0x4E, 0x4C, 0x7F, 0x11, 0xD1, 131 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } }, 132 133 { AIM_CAPS_ICQRTF, 134 { 0x97, 0xb1, 0x27, 0x51, 0x24, 0x3c, 0x43, 0x34, 135 0xad, 0x22, 0xd6, 0xab, 0xf7, 0x3f, 0x14, 0x92 } }, 136 137 { AIM_CAPS_ICQUNKNOWN, 138 { 0x2e, 0x7a, 0x64, 0x75, 0xfa, 0xdf, 0x4d, 0xc8, 139 0x88, 0x6f, 0xea, 0x35, 0x95, 0xfd, 0xb6, 0xdf } }, 140 141 { AIM_CAPS_EMPTY, 142 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 143 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }, 144 145 { AIM_CAPS_TRILLIANCRYPT, 146 { 0xf2, 0xe7, 0xc7, 0xf4, 0xfe, 0xad, 0x4d, 0xfb, 147 0xb2, 0x35, 0x36, 0x79, 0x8b, 0xdf, 0x00, 0x00 } }, 148 149 { AIM_CAPS_APINFO, 150 { 0xAA, 0x4A, 0x32, 0xB5, 0xF8, 0x84, 0x48, 0xc6, 151 0xA3, 0xD7, 0x8C, 0x50, 0x97, 0x19, 0xFD, 0x5B } }, 152 153 { AIM_CAPS_INTEROP, 154 { 0x09, 0x46, 0x13, 0x4d, 0x4c, 0x7f, 0x11, 0xd1, 155 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } }, 156 157 { AIM_CAPS_ICHAT, 158 { 0x09, 0x46, 0x00, 0x00, 0x4c, 0x7f, 0x11, 0xd1, 159 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } }, 160 161 { AIM_CAPS_LAST } 160 162 }; 161 163 … … 163 165 * This still takes a length parameter even with a bstream because capabilities 164 166 * are not naturally bounded. 165 * 167 * 166 168 */ 167 169 guint32 aim_getcap(aim_session_t *sess, aim_bstream_t *bs, int len) … … 190 192 /*REMOVEME :-) 191 193 g_strdup_printf("unknown capability: {%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n", 192 193 194 195 196 197 194 cap[0], cap[1], cap[2], cap[3], 195 cap[4], cap[5], 196 cap[6], cap[7], 197 cap[8], cap[9], 198 cap[10], cap[11], cap[12], cap[13], 199 cap[14], cap[15]); 198 200 */ 199 201 } … … 209 211 int i; 210 212 211 if (!bs) 213 if (!bs) { 212 214 return -EINVAL; 215 } 213 216 214 217 for (i = 0; aim_bstream_empty(bs); i++) { 215 218 216 if (aim_caps[i].flag == AIM_CAPS_LAST) 219 if (aim_caps[i].flag == AIM_CAPS_LAST) { 217 220 break; 218 219 if (caps & aim_caps[i].flag) 221 } 222 223 if (caps & aim_caps[i].flag) { 220 224 aimbs_putraw(bs, aim_caps[i].data, 0x10); 225 } 221 226 222 227 } … … 226 231 227 232 /* 228 * AIM is fairly regular about providing user info. This is a generic 233 * AIM is fairly regular about providing user info. This is a generic 229 234 * routine to extract it in its standard form. 230 235 */ … … 234 239 guint8 snlen; 235 240 236 if (!bs || !outinfo) 241 if (!bs || !outinfo) { 237 242 return -EINVAL; 243 } 238 244 239 245 /* Clear out old data first */ … … 241 247 242 248 /* 243 * Screen name. Stored as an unterminated string prepended with a 249 * Screen name. Stored as an unterminated string prepended with a 244 250 * byte containing its length. 245 251 */ 246 252 snlen = aimbs_get8(bs); 247 aimbs_getrawbuf(bs, (guint8 *) outinfo->sn, snlen);253 aimbs_getrawbuf(bs, (guint8 *) outinfo->sn, snlen); 248 254 249 255 /* … … 253 259 254 260 /* 255 * TLV Count. Unsigned short representing the number of 261 * TLV Count. Unsigned short representing the number of 256 262 * Type-Length-Value triples that follow. 257 263 */ 258 264 tlvcnt = aimbs_get16(bs); 259 265 260 /* 266 /* 261 267 * Parse out the Type-Length-Value triples as they're found. 262 268 */ … … 273 279 /* 274 280 * Type = 0x0001: User flags 275 * 281 * 276 282 * Specified as any of the following ORed together: 277 283 * 0x0001 Trial (user less than 60days) … … 279 285 * 0x0004 AOL Main Service user 280 286 * 0x0008 Unknown bit 4 281 * 0x0010 Free (AIM) user 287 * 0x0010 Free (AIM) user 282 288 * 0x0020 Away 283 289 * 0x0400 ActiveBuddy … … 289 295 } else if (type == 0x0002) { 290 296 /* 291 * Type = 0x0002: Member-Since date. 297 * Type = 0x0002: Member-Since date. 292 298 * 293 299 * The time/date that the user originally registered for … … 301 307 * Type = 0x0003: On-Since date. 302 308 * 303 * The time/date that the user started their current 309 * The time/date that the user started their current 304 310 * session, stored in time_t format. 305 311 */ … … 311 317 * Type = 0x0004: Idle time. 312 318 * 313 * Number of seconds since the user actively used the 319 * Number of seconds since the user actively used the 314 320 * service. 315 321 * 316 322 * Note that the client tells the server when to start 317 * counting idle times, so this may or may not be 323 * counting idle times, so this may or may not be 318 324 * related to reality. 319 325 */ … … 325 331 * Type = 0x0006: ICQ Online Status 326 332 * 327 * ICQ's Away/DND/etc "enriched" status. Some decoding 333 * ICQ's Away/DND/etc "enriched" status. Some decoding 328 334 * of values done by Scott <darkagl@pcnet.com> 329 335 */ … … 343 349 344 350 } else if (type == 0x000c) { 345 /* 351 /* 346 352 * Type = 0x000c 347 353 * … … 379 385 * Type = 0x0010: Session Length. (AOL) 380 386 * 381 * The duration, in seconds, of the user's current 387 * The duration, in seconds, of the user's current 382 388 * session. 383 389 * … … 393 399 /* 394 400 * Reaching here indicates that either AOL has 395 * added yet another TLV for us to deal with, 401 * added yet another TLV for us to deal with, 396 402 * or the parsing has gone Terribly Wrong. 397 403 * … … 429 435 tlvlist = aim_readtlvchain(bs); 430 436 431 if (aim_gettlv(tlvlist, 0x0001, 1)) 437 if (aim_gettlv(tlvlist, 0x0001, 1)) { 432 438 maxsiglen = aim_gettlv16(tlvlist, 0x0001, 1); 433 434 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) 439 } 440 441 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) { 435 442 ret = userfunc(sess, rx, maxsiglen); 443 } 436 444 437 445 aim_freetlvchain(&tlvlist); … … 459 467 } 460 468 461 inforeq = (struct aim_priv_inforeq *) origsnac->data;469 inforeq = (struct aim_priv_inforeq *) origsnac->data; 462 470 463 471 if ((inforeq->infotype != AIM_GETINFO_GENERALINFO) && 464 465 472 (inforeq->infotype != AIM_GETINFO_AWAYMESSAGE) && 473 (inforeq->infotype != AIM_GETINFO_CAPABILITIES)) { 466 474 imcb_error(sess->aux_data, "unknown infotype in request!"); 467 475 return 0; … … 472 480 tlvlist = aim_readtlvchain(bs); 473 481 474 /* 482 /* 475 483 * Depending on what informational text was requested, different 476 484 * TLVs will appear here. … … 481 489 if (inforeq->infotype == AIM_GETINFO_GENERALINFO) { 482 490 text_encoding = aim_gettlv_str(tlvlist, 0x0001, 1); 483 if ((tlv = aim_gettlv(tlvlist, 0x0002, 1))) {491 if ((tlv = aim_gettlv(tlvlist, 0x0002, 1))) { 484 492 text = g_new0(char, tlv->length); 485 493 memcpy(text, tlv->value, tlv->length); … … 488 496 } else if (inforeq->infotype == AIM_GETINFO_AWAYMESSAGE) { 489 497 text_encoding = aim_gettlv_str(tlvlist, 0x0003, 1); 490 if ((tlv = aim_gettlv(tlvlist, 0x0004, 1))) {498 if ((tlv = aim_gettlv(tlvlist, 0x0004, 1))) { 491 499 text = g_new0(char, tlv->length); 492 500 memcpy(text, tlv->value, tlv->length); … … 506 514 } 507 515 508 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) 516 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) { 509 517 ret = userfunc(sess, rx, &userinfo, inforeq->infotype, text_encoding, text, text_length); 518 } 510 519 511 520 g_free(text_encoding); … … 514 523 aim_freetlvchain(&tlvlist); 515 524 516 if (origsnac) 525 if (origsnac) { 517 526 g_free(origsnac->data); 527 } 518 528 g_free(origsnac); 519 529 … … 524 534 { 525 535 526 if (snac->subtype == 0x0003) 536 if (snac->subtype == 0x0003) { 527 537 return rights(sess, mod, rx, snac, bs); 528 else if (snac->subtype == 0x0006)538 } else if (snac->subtype == 0x0006) { 529 539 return userinfo(sess, mod, rx, snac, bs); 540 } 530 541 531 542 return 0;
Note: See TracChangeset
for help on using the changeset viewer.