]> andersk Git - libfaim.git/blame - utils/aimdebugd/icbm.c
- Fri Dec 15 20:41:15 UTC 2000
[libfaim.git] / utils / aimdebugd / icbm.c
CommitLineData
e5012450 1
2#include <faim/aim.h>
3
4int sendimtoclient(struct aim_session_t *sess, struct aim_conn_t *conn,
5 char *srcsn, u_int flags, char *msg)
6{
7 struct command_tx_struct *tx;
8 struct aimd_clientinfo *client = NULL;
9 struct aim_tlvlist_t *tlvlist = NULL;
10 struct aim_tlvlist_t *tlvlist2 = NULL;
11 int i = 0, y, z;
12 char *msgblock;
13
14 if (!(tx = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, strlen(msg)+256)))
15 return -1;
16
17 tx->lock = 1;
18
19 msgblock = malloc(strlen(msg)+128); /* ?? */
20 memset(msgblock, 0, strlen(msg)+128);
21
22 z = 0;
23 z += aimutil_put8(msgblock+z, 0x00);
24 z += aimutil_put8(msgblock+z, 0x00);
25
26 z += aimutil_put16(msgblock+z, 0x02);
27 z += aimutil_put8(msgblock+z, 0x00);
28 z += aimutil_put8(msgblock+z, 0x00);
29
30 z += aimutil_put8(msgblock+z, 0x00);
31 z += aimutil_put8(msgblock+z, 0x00);
32
33 z += aimutil_put16(msgblock+z, strlen(msg)+4);
34 /* flag words */
35 z += aimutil_put16(msgblock+z, 0x0000);
36 z += aimutil_put16(msgblock+z, 0x0000);
37
38 /* msg */
39 z += aimutil_putstr(msgblock+z, msg, strlen(msg));
40
41 /*
42 * SNAC header
43 */
44 i = 0;
45 i += aimutil_put16(tx->data+i, 0x0004);
46 i += aimutil_put16(tx->data+i, 0x0007);
47 i += aimutil_put16(tx->data+i, 0x0000);
48 i += aimutil_put16(tx->data+i, 0x0000);
49 i += aimutil_put16(tx->data+i, 0x0000);
50
51 /*
52 * Message cookie
53 */
54 for (y=0;y<8;y++)
55 i += aimutil_put8(tx->data+i+y, (u_char) random());
56
57 /*
58 * Channel ID
59 */
60 i += aimutil_put16(tx->data+i, 0x0001);
61
62 /*
63 * Source SN
64 */
65 i += aimutil_put8(tx->data+i, strlen(srcsn));
66 i += aimutil_putstr(tx->data+i, srcsn, strlen(srcsn));
67
68 /*
69 * Warning level
70 */
71 i += aimutil_put16(tx->data+i, 0x0000);
72
73 /* class */
3e2c7bcf 74 aim_addtlvtochain16(&tlvlist, 0x0001, AIM_FLAG_FREE | AIM_FLAG_UNCONFIRMED);
e5012450 75
76 /* member-since date */
77 aim_addtlvtochain32(&tlvlist, 0x0002, 0);
78
79 /* on-since date */
80 aim_addtlvtochain32(&tlvlist, 0x0003, 0);
81
82 /* idle-time */
83 aim_addtlvtochain16(&tlvlist, 0x0004, 0);
84
85 /* session length (AIM) */
86 aim_addtlvtochain16(&tlvlist, 0x000f, 0);
87
88 /* add msgblock to chain */
89 aim_addtlvtochain_str(&tlvlist2, 0x0002, msgblock, z);
90
91 i += aimutil_put16(tx->data+i, aim_counttlvchain(&tlvlist));
92 i += aim_writetlvchain(tx->data+i, tx->commandlen-i, &tlvlist);
93 tx->commandlen = aim_writetlvchain(tx->data+i, tx->commandlen-i, &tlvlist2)+i;
94
95
96 free(msgblock);
97 aim_freetlvchain(&tlvlist);
98
99 tx->lock = 0;
100
101 aim_tx_enqueue(sess, tx);
102
103 sess->snac_nextid++;
104
105 return 0;
106}
This page took 0.27577 seconds and 5 git commands to generate.