]> andersk Git - libfaim.git/blob - src/auth.c
621c269c84594264f0dfc7fcd0489a9ab4686c99
[libfaim.git] / src / auth.c
1 /*
2   aim_auth.c
3
4   Deals with the authorizer.
5
6  */
7
8 #define FAIM_INTERNAL
9 #include <aim.h> 
10
11 /* this just pushes the passed cookie onto the passed connection -- NO SNAC! */
12 faim_export int aim_auth_sendcookie(struct aim_session_t *sess, 
13                                     struct aim_conn_t *conn, 
14                                     unsigned char *chipsahoy)
15 {
16   struct command_tx_struct *newpacket;
17   int curbyte=0;
18   
19   if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0001, 4+2+2+AIM_COOKIELEN)))
20     return -1;
21
22   newpacket->lock = 1;
23
24   curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
25   curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001);
26   curbyte += aimutil_put16(newpacket->data+curbyte, 0x0006);
27   curbyte += aimutil_put16(newpacket->data+curbyte, AIM_COOKIELEN);
28   memcpy(newpacket->data+curbyte, chipsahoy, AIM_COOKIELEN);
29
30   return aim_tx_enqueue(sess, newpacket);
31 }
32
33 faim_export unsigned long aim_auth_clientready(struct aim_session_t *sess,
34                                                struct aim_conn_t *conn)
35 {
36   struct aim_tool_version tools[] = {
37     {0x0001, 0x0003,    AIM_TOOL_NEWWIN, 0x0361},
38     {0x0007, 0x0001,    AIM_TOOL_NEWWIN, 0x0361},
39   };
40   int i,j;
41   struct command_tx_struct *newpacket;
42   int toolcount = sizeof(tools)/sizeof(struct aim_tool_version);
43
44   if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 1152)))
45     return -1;
46
47   newpacket->lock = 1;
48
49   i = aim_putsnac(newpacket->data, 0x0001, 0x0002, 0x0000, sess->snac_nextid);
50   aim_cachesnac(sess, 0x0001, 0x0002, 0x0000, NULL, 0);
51
52   for (j = 0; j < toolcount; j++) {
53     i += aimutil_put16(newpacket->data+i, tools[j].group);
54     i += aimutil_put16(newpacket->data+i, tools[j].version);
55     i += aimutil_put16(newpacket->data+i, tools[j].tool);
56     i += aimutil_put16(newpacket->data+i, tools[j].toolversion);
57   }
58
59   newpacket->commandlen = i;
60   newpacket->lock = 0;
61
62   aim_tx_enqueue(sess, newpacket);
63
64   return sess->snac_nextid;
65 }
66
67 faim_export unsigned long aim_auth_changepasswd(struct aim_session_t *sess,
68                                                 struct aim_conn_t *conn, 
69                                                 char *new, char *current)
70 {
71   struct command_tx_struct *newpacket;
72   int i;
73
74   if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10+4+strlen(current)+4+strlen(new))))
75     return -1;
76
77   newpacket->lock = 1;
78
79   i = aim_putsnac(newpacket->data, 0x0007, 0x0004, 0x0000, sess->snac_nextid);
80   aim_cachesnac(sess, 0x0007, 0x0004, 0x0000, NULL, 0);
81
82   /* new password TLV t(0002) */
83   i += aim_puttlv_str(newpacket->data+i, 0x0002, strlen(new), new);
84
85   /* current password TLV t(0012) */
86   i += aim_puttlv_str(newpacket->data+i, 0x0012, strlen(current), current);
87
88   aim_tx_enqueue(sess, newpacket);
89
90   return sess->snac_nextid;
91 }
92
93 faim_export unsigned long aim_auth_setversions(struct aim_session_t *sess,
94                                                struct aim_conn_t *conn)
95 {
96   struct command_tx_struct *newpacket;
97   int i;
98
99   if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10 + (4*2))))
100     return -1;
101
102   newpacket->lock = 1;
103
104   i = aim_putsnac(newpacket->data, 0x0001, 0x0017, 0x0000, sess->snac_nextid);
105   aim_cachesnac(sess, 0x0001, 0x0017, 0x0000, NULL, 0);
106
107   i += aimutil_put16(newpacket->data+i, 0x0001);
108   i += aimutil_put16(newpacket->data+i, 0x0003);
109
110   i += aimutil_put16(newpacket->data+i, 0x0007);
111   i += aimutil_put16(newpacket->data+i, 0x0001);
112
113   newpacket->commandlen = i;
114   newpacket->lock = 0;
115   aim_tx_enqueue(sess, newpacket);
116
117   return sess->snac_nextid;
118 }
119
120 /*
121  * Request account confirmation. 
122  *
123  * This will cause an email to be sent to the address associated with
124  * the account.  By following the instructions in the mail, you can
125  * get the TRIAL flag removed from your account.
126  *
127  */
128 faim_export unsigned long aim_auth_reqconfirm(struct aim_session_t *sess,
129                                               struct aim_conn_t *conn)
130 {
131   return aim_genericreq_n(sess, conn, 0x0007, 0x0006);
132 }
133
134 /*
135  * Request a bit of account info.
136  *
137  * The only known valid tag is 0x0011 (email address).
138  *
139  */ 
140 faim_export unsigned long aim_auth_getinfo(struct aim_session_t *sess,
141                                            struct aim_conn_t *conn,
142                                            unsigned short info)
143 {
144   struct command_tx_struct *newpacket;
145   int i;
146
147   if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10 + 4)))
148     return -1;
149
150   newpacket->lock = 1;
151
152   i = aim_putsnac(newpacket->data, 0x0007, 0x0002, 0x0000, sess->snac_nextid);
153   aim_cachesnac(sess, 0x0002, 0x0002, 0x0000, NULL, 0);
154
155   i += aimutil_put16(newpacket->data+i, info);
156   i += aimutil_put16(newpacket->data+i, 0x0000);
157
158   newpacket->commandlen = i;
159   newpacket->lock = 0;
160   aim_tx_enqueue(sess, newpacket);
161
162   return sess->snac_nextid;
163 }
164
165 faim_export unsigned long aim_auth_setemail(struct aim_session_t *sess,
166                                             struct aim_conn_t *conn, 
167                                             char *newemail)
168 {
169   struct command_tx_struct *newpacket;
170   int i;
171
172   if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10+2+2+strlen(newemail))))
173     return -1;
174
175   newpacket->lock = 1;
176
177   i = aim_putsnac(newpacket->data, 0x0007, 0x0004, 0x0000, sess->snac_nextid);
178   aim_cachesnac(sess, 0x0007, 0x0004, 0x0000, NULL, 0);
179
180   i += aim_puttlv_str(newpacket->data+i, 0x0011, strlen(newemail), newemail);
181
182   aim_tx_enqueue(sess, newpacket);
183
184   return sess->snac_nextid;
185 }
This page took 0.037502 seconds and 3 git commands to generate.