- /* a mini TLV parser */
- {
- int curtlv = 0;
- int count_t4 = 0, count_t3 = 0, count_t2 = 0, count_t1 = 0;
-
- while (i+4 < command->commandlen)
- {
- if ((command->data[i] == 0x00) &&
- (command->data[i+1] == 0x01) )
- {
- if (count_t1 == 0)
- {
- /* t(0001) = class */
- if (command->data[i+3] != 0x02)
- printf("faim: userinfo: **warning: strange v(%x) for t(1)\n", command->data[i+3]);
- class = ((command->data[i+4]) << 8) & 0xFF00;
- class += (command->data[i+5]) & 0x00FF;
- }
- else
- printf("faim: icbm: unexpected extra TLV t(0001)\n");
- count_t1++;
- }
- else if ((command->data[i] == 0x00) &&
- (command->data[i+1] == 0x02))
- {
- if (count_t2 == 0)
- {
- /* t(0002) = member since date */
- if (command->data[i+3] != 0x04)
- printf("faim: userinfo: **warning: strange v(%x) for t(2)\n", command->data[i+3]);
-
- membersince = ((command->data[i+4]) << 24) & 0xFF000000;
- membersince += ((command->data[i+5]) << 16) & 0x00FF0000;
- membersince += ((command->data[i+6]) << 8) & 0x0000FF00;
- membersince += ((command->data[i+7]) ) & 0x000000FF;
- }
- else if (count_t2 == 1)
- {
- int biglen = 0, innerlen = 0;
- int j;
-
- /* message */
-
- /*
- * Check for message signature (0x0501). I still don't really
- * like this, but it is better than the old way, and it does
- * seem to be consistent as long as AOL doesn't do any more
- * big changes.
- */
- if ( (command->data[i+4] != 0x05) ||
- (command->data[i+5] != 0x01) )
- printf("faim: icbm: warning: message signature not present, trying to recover\n");
-
- biglen = ((command->data[i+2] << 8) + command->data[i+3]) & 0xffff;
-
- printf("faim: icbm: biglen = %02x\n", biglen);
-
- j = 0;
- while (j+3 < (biglen-6))
- {
- if ( (command->data[i+6+j+0] == 0x00) &&
- (command->data[i+6+j+1] == 0x00) &&
- (command->data[i+6+j+2] == 0x00) )
- {
-
- innerlen = (command->data[i+6+j]<<8) + command->data[i+6+j+1];
- break;
- }
- j++;
- }
- if (!innerlen)
- {
- printf("faim: icbm: unable to find holy zeros; skipping message\n");
- msglen = 0;
- msg = NULL;
- }
- else
- {
- printf("faim: icbm: innerlen = %d\n", innerlen);
-
- msglen = innerlen - 4;
- printf("faim: icbm: msglen = %u\n", msglen);
-
- msg = malloc(msglen +1);
- memcpy(msg, &(command->data[i+6+j+4+1]), msglen);
- msg[msglen] = '\0';
- }
- }
- else
- printf("faim: icbm: **warning: extra TLV t(0002)\n");
- count_t2++;
- }
- else if ((command->data[i] == 0x00) &&
- (command->data[i+1] == 0x03))
- {
- if (count_t3 == 0)
- {
- /* t(0003) = on since date */
- if (command->data[i+3] != 0x04)
- printf("faim: userinfo: **warning: strange v(%x) for t(3)\n", command->data[i+3]);
-
- onsince = ((command->data[i+4]) << 24) & 0xFF000000;
- onsince += ((command->data[i+5]) << 16) & 0x00FF0000;
- onsince += ((command->data[i+6]) << 8) & 0x0000FF00;
- onsince += ((command->data[i+7]) ) & 0x000000FF;
- }
- else if (count_t3 == 1)
- printf("faim: icbm: request for acknowledgment ignored\n");
- else
- printf("faim: icbm: unexpected extra TLV t(0003)\n");
- count_t3++;
- }
- else if ((command->data[i] == 0x00) &&
- (command->data[i+1] == 0x04) )
- {
- if (count_t4 == 0)
- {
- /* t(0004) = idle time */
- if (command->data[i+3] != 0x02)
- printf("faim: userinfo: **warning: strange v(%x) for t(4)\n", command->data[i+3]);
- idletime = ((command->data[i+4]) << 8) & 0xFF00;
- idletime += (command->data[i+5]) & 0x00FF;
- }
- else if ((count_t4 == 1) && (((command->data[i+2]<<8)+command->data[i+3])==0x0000))
- isautoreply = 1;
- else
- printf("faim: icbm: unexpected extra TLV t(0004)\n");
- count_t4++;
- }
- else if ((command->data[i] == 0x00) &&
- (command->data[i+1] == 0x0f))
- {
- /* t(000f) = unknown...usually from AIM3 users */
- if (command->data[i+3] != 0x04)
- printf("faim: userinfo: **warning: strange v(%x) for t(f)\n", command->data[i+3]);
- unknown_f = (command->data[i+4] << 24) & 0xff000000;
- unknown_f += (command->data[i+5] << 16) & 0x00ff0000;
- unknown_f += (command->data[i+6] << 8) & 0x0000ff00;
- unknown_f += (command->data[i+7]) & 0x000000ff;
- }
- else if ((command->data[i] == 0x00) &&
- (command->data[i+1] == 0x10))
- {
- /* t(0010) = unknown...usually from AOL users */
- if (command->data[i+3] != 0x04)
- printf("faim: userinfo: **warning: strange v(%x) for t(10)\n", command->data[i+3]);
- unknown_10 = (command->data[i+4] << 24) & 0xff000000;
- unknown_10 += (command->data[i+5] << 16) & 0x00ff0000;
- unknown_10 += (command->data[i+6] << 8) & 0x0000ff00;
- unknown_10 += (command->data[i+7]) & 0x000000ff;
- }
- else
- {
- printf("faim: userinfo: **warning: unexpected TLV t(%02x%02x) l(%02x%02x)\n", command->data[i], command->data[i+1], command->data[i+2], command->data[i+3]);
- }
- i += (2 + 2 + ((command->data[i+2] << 8) + command->data[i+3]));
- curtlv++;
- }
- }
-
-#if 0
- {
- /* detect if this is an auto-response or not */
- /* auto-responses can be detected by the presence of a *second* TLV with
- t(0004), but of zero length (and therefore no value portion) */
- struct aim_tlv_t *tsttlv = NULL;
- tsttlv = aim_grabtlv((u_char *) &(command->data[i]));
- if (tsttlv->type == 0x04)
- isautoreply = 1;
- aim_freetlv(&tsttlv);
- }
-