2 * -----------------------------------------------------------
3 * ProtoFAIM: v1.xx.xxplxx
4 * -----------------------------------------------------------
6 * This is ProtoFAIM v1.xx.xxplxx!!! Its nearly completely
7 * different than that ugly thing called v0. This app is
8 * compatible with the latest version of the libfaim library.
11 * ProtoFAIM should only be used for two things...
12 * 1) Testing the libfaim backend.
13 * 2) For reference on the libfaim API when developing clients.
15 * Its very ugly. Probably always will be. Nothing is more
16 * ugly than the backend itself, however.
18 * -----------------------------------------------------------
20 * I'm releasing this code and all it's associated linkage
21 * under the GNU General Public License. For more information,
22 * please refer to http://www.fsf.org. For any questions,
23 * please contact me at the address below.
26 * (c) 1998 Adam Fritzler, PST, afritz@iname.com
28 * The password algorithms
29 * (c) 1998 Brock Wilcox, awwaiid@iname.com
31 * THERE IS NO CODE FROM AOL'S AIM IN THIS CODE, NOR
32 * WAS THERE ANY DISASSEMBLAGE TO DEFINE PROTOCOL. All
33 * information was gained through painstakingly comparing
34 * TCP dumps while the AIM Java client was running. Nothing
35 * more than that, except for a lot of experimenting.
37 * -----------------------------------------------------------
49 int faimtest_parse_oncoming(struct aim_session_t *, struct command_rx_struct *, ...);
50 int faimtest_parse_offgoing(struct aim_session_t *, struct command_rx_struct *, ...);
51 int faimtest_parse_login_phase3d_f(struct aim_session_t *, struct command_rx_struct *, ...);
52 int faimtest_parse_authresp(struct aim_session_t *, struct command_rx_struct *, ...);
53 int faimtest_parse_incoming_im(struct aim_session_t *, struct command_rx_struct *command, ...);
54 int faimtest_parse_userinfo(struct aim_session_t *, struct command_rx_struct *command, ...);
55 int faimtest_handleredirect(struct aim_session_t *, struct command_rx_struct *command, ...);
56 int faimtest_authsvrready(struct aim_session_t *, struct command_rx_struct *command, ...);
57 int faimtest_pwdchngdone(struct aim_session_t *, struct command_rx_struct *command, ...);
58 int faimtest_serverready(struct aim_session_t *, struct command_rx_struct *command, ...);
59 int faimtest_parse_misses(struct aim_session_t *, struct command_rx_struct *command, ...);
60 int faimtest_parse_msgack(struct aim_session_t *, struct command_rx_struct *command, ...);
61 int faimtest_parse_motd(struct aim_session_t *, struct command_rx_struct *command, ...);
62 int faimtest_parse_login(struct aim_session_t *, struct command_rx_struct *command, ...);
63 int faimtest_chatnav_info(struct aim_session_t *, struct command_rx_struct *command, ...);
64 int faimtest_chat_incomingmsg(struct aim_session_t *sess, struct command_rx_struct *command, ...);
65 int faimtest_chat_infoupdate(struct aim_session_t *sess, struct command_rx_struct *command, ...);
66 int faimtest_chat_leave(struct aim_session_t *sess, struct command_rx_struct *command, ...);
67 int faimtest_chat_join(struct aim_session_t *sess, struct command_rx_struct *command, ...);
68 int faimtest_parse_connerr(struct aim_session_t *sess, struct command_rx_struct *command, ...);
69 int faimtest_debugconn_connect(struct aim_session_t *sess, struct command_rx_struct *command, ...);
71 int faimtest_directim_request(struct aim_session_t *sess, struct command_rx_struct *command, ...);
72 int faimtest_directim_initiate(struct aim_session_t *sess, struct command_rx_struct *command, ...);
73 int faimtest_directim_connect(struct aim_session_t *sess, struct command_rx_struct *command, ...);
74 int faimtest_directim_incoming(struct aim_session_t *sess, struct command_rx_struct *command, ...);
75 int faimtest_directim_disconnect(struct aim_session_t *sess, struct command_rx_struct *command, ...);
76 int faimtest_directim_typing(struct aim_session_t *sess, struct command_rx_struct *command, ...);
77 int faimtest_parse_ratechange(struct aim_session_t *sess, struct command_rx_struct *command, ...);
78 int faimtest_parse_evilnotify(struct aim_session_t *sess, struct command_rx_struct *command, ...);
79 int faimtest_parse_msgerr(struct aim_session_t *sess, struct command_rx_struct *command, ...);
80 int faimtest_parse_buddyrights(struct aim_session_t *sess, struct command_rx_struct *command, ...);
81 int faimtest_parse_locerr(struct aim_session_t *sess, struct command_rx_struct *command, ...);
83 static char *msgerrreasons[] = {
89 "Service unavailable",
90 "Service not defined",
92 "Not supported by host",
93 "Not supported by client",
98 "Busted SNAC payload",
99 "Insufficient rights",
100 "In local permit/deny",
102 "Too evil (receiver)",
103 "User temporarily unavailable",
109 static int msgerrreasonslen = 25;
111 int faimtest_reportinterval(struct aim_session_t *sess, struct command_rx_struct *command, ...)
114 printf("aim: minimum report interval: %d (seconds?)\n", aimutil_get16(command->data+10));
116 printf("aim: NULL minimum report interval!\n");
122 * This is really all thats needed to link against libfaim on win32.
124 * Note that this particular version of faimtest has never been tested
125 * on win32, but I'm fairly sure it should.
129 WORD wVersionRequested;
132 wVersionRequested = MAKEWORD(2,2);
133 return WSAStartup(wVersionRequested, &wsaData);
137 static char *screenname,*password,*server=NULL;
141 struct aim_session_t aimsess;
142 struct aim_conn_t *authconn = NULL, *waitingconn = NULL;
144 char *proxy, *proxyusername, *proxypass;
148 if ( !(screenname = getenv("SCREENNAME")) ||
149 !(password = getenv("PASSWORD")))
151 printf("Must specify SCREENAME and PASSWORD in environment.\n");
155 server = getenv("AUTHSERVER");
157 proxy = getenv("SOCKSPROXY");
158 proxyusername = getenv("SOCKSNAME");
159 proxypass = getenv("SOCKSPASS");
162 if (initwsa() != 0) {
163 printf("faimtest: could not initialize windows sockets\n");
168 aim_session_init(&aimsess);
171 aim_setupproxy(&aimsess, proxy, proxyusername, proxypass);
173 authconn = aim_newconn(&aimsess, AIM_CONN_TYPE_AUTH, server?server:FAIM_LOGIN_SERVER);
175 if (authconn == NULL) {
176 fprintf(stderr, "faimtest: internal connection error while in aim_login. bailing out.\n");
178 } else if (authconn->fd == -1) {
179 if (authconn->status & AIM_CONN_STATUS_RESOLVERR)
180 fprintf(stderr, "faimtest: could not resolve authorizer name\n");
181 else if (authconn->status & AIM_CONN_STATUS_CONNERR)
182 fprintf(stderr, "faimtest: could not connect to authorizer\n");
183 aim_conn_kill(&aimsess, &authconn);
187 aim_conn_addhandler(&aimsess, authconn, 0x0017, 0x0007, faimtest_parse_login, 0);
188 aim_conn_addhandler(&aimsess, authconn, 0x0017, 0x0003, faimtest_parse_authresp, 0);
190 aim_sendconnack(&aimsess, authconn);
191 aim_request_login(&aimsess, authconn, screenname);
193 aim_conn_addhandler(&aimsess, authconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_DEBUGCONN_CONNECT, faimtest_debugconn_connect, 0);
195 printf("faimtest: login request sent\n");
198 waitingconn = aim_select(&aimsess, NULL, &selstat);
202 keepgoing = 0; /* fall through and hit the aim_logoff() */
205 case 0: /* no events pending */
208 case 1: /* outgoing data pending */
209 aim_tx_flushqueue(&aimsess);
212 case 2: /* incoming data pending */
213 if (waitingconn->type == AIM_CONN_TYPE_RENDEZVOUS_OUT) {
214 if (aim_handlerendconnect(&aimsess, waitingconn) < 0) {
215 printf("connection error (rend)\n");
218 if (aim_get_command(&aimsess, waitingconn) >= 0) {
219 aim_rxdispatch(&aimsess);
221 printf("connection error\n");
222 aim_conn_kill(&aimsess, &waitingconn);
223 if (!aim_getconn_type(&aimsess, AIM_CONN_TYPE_BOS)) {
224 printf("major connetion error\n");
237 printf("AIM just decided we didn't need to be here anymore, closing up...\n");
239 /* close up all connections, dead or no */
240 aim_logoff(&aimsess);
246 int faimtest_rateresp(struct aim_session_t *sess, struct command_rx_struct *command, ...)
249 switch(command->conn->type) {
250 case AIM_CONN_TYPE_BOS: {
251 /* this is the new buddy list */
252 char buddies[] = "Buddy1&Buddy2&ThisHereIsAName2&";
253 /* this is the new profile */
254 char profile[] = "Hello";
256 aim_bos_ackrateresp(sess, command->conn); /* ack rate info response */
257 aim_bos_reqpersonalinfo(sess, command->conn);
258 aim_bos_reqlocaterights(sess, command->conn);
259 aim_bos_setprofile(sess, command->conn, profile, NULL, AIM_CAPS_BUDDYICON | AIM_CAPS_CHAT | AIM_CAPS_VOICE | AIM_CAPS_GETFILE | AIM_CAPS_SENDFILE | AIM_CAPS_IMIMAGE);
260 aim_bos_reqbuddyrights(sess, command->conn);
262 /* send the buddy list and profile (required, even if empty) */
263 aim_bos_setbuddylist(sess, command->conn, buddies);
265 /* dont really know what this does */
266 aim_addicbmparam(sess, command->conn);
267 aim_bos_reqicbmparaminfo(sess, command->conn);
269 aim_bos_reqrights(sess, command->conn);
270 /* set group permissions -- all user classes */
271 aim_bos_setgroupperm(sess, command->conn, AIM_FLAG_ALLUSERS);
272 aim_bos_setprivacyflags(sess, command->conn, AIM_PRIVFLAGS_ALLOWIDLE|AIM_PRIVFLAGS_ALLOWMEMBERSINCE);
278 printf("faimtest: got rate response for unhandled connection type %04x\n", command->conn->type);
285 int faimtest_serverready(struct aim_session_t *sess, struct command_rx_struct *command, ...)
287 switch (command->conn->type)
289 case AIM_CONN_TYPE_BOS:
291 aim_setversions(sess, command->conn);
292 aim_bos_reqrate(sess, command->conn); /* request rate info */
294 fprintf(stderr, "faimtest: done with BOS ServerReady\n");
297 case AIM_CONN_TYPE_CHATNAV:
298 fprintf(stderr, "faimtest: chatnav: got server ready\n");
299 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, faimtest_chatnav_info, 0);
300 aim_bos_reqrate(sess, command->conn);
301 aim_bos_ackrateresp(sess, command->conn);
302 aim_chatnav_clientready(sess, command->conn);
303 aim_chatnav_reqrights(sess, command->conn);
306 case AIM_CONN_TYPE_CHAT:
307 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN, faimtest_chat_join, 0);
308 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE, faimtest_chat_leave, 0);
309 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE, faimtest_chat_infoupdate, 0);
310 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, faimtest_chat_incomingmsg, 0);
311 aim_bos_reqrate(sess, command->conn);
312 aim_bos_ackrateresp(sess, command->conn);
313 aim_chat_clientready(sess, command->conn);
316 case AIM_CONN_TYPE_RENDEZVOUS: /* this is an overloaded function?? - mid */
317 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, faimtest_directim_incoming, 0);
318 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMDISCONNECT, faimtest_directim_disconnect, 0);
322 fprintf(stderr, "faimtest: unknown connection type on Server Ready\n");
327 int faimtest_parse_buddyrights(struct aim_session_t *sess, struct command_rx_struct *command, ...)
330 unsigned short maxbuddies, maxwatchers;
332 va_start(ap, command);
333 maxbuddies = va_arg(ap, unsigned short);
334 maxwatchers = va_arg(ap, unsigned short);
337 printf("faimtest: buddy list rights: Max buddies = %d / Max watchers = %d\n", maxbuddies, maxwatchers);
342 int faimtest_bosrights(struct aim_session_t *sess, struct command_rx_struct *command, ...)
344 unsigned short maxpermits, maxdenies;
347 va_start(ap, command);
348 maxpermits = va_arg(ap, unsigned short);
349 maxdenies = va_arg(ap, unsigned short);
352 printf("faimtest: BOS rights: Max permit = %d / Max deny = %d\n", maxpermits, maxdenies);
354 aim_bos_clientready(sess, command->conn);
356 printf("faimtest: officially connected to BOS.\n");
364 This, of course, handles Service Redirects from OSCAR.
366 Should get passed in the following:
367 struct command_rx_struct *command
370 the destination service ID
372 the IP address of the service's server
376 int faimtest_handleredirect(struct aim_session_t *sess, struct command_rx_struct *command, ...)
381 unsigned char *cookie;
383 va_start(ap, command);
384 serviceid = va_arg(ap, int);
385 ip = va_arg(ap, char *);
386 cookie = va_arg(ap, unsigned char *);
390 case 0x0007: /* Authorizer */
392 struct aim_conn_t *tstconn;
393 /* Open a connection to the Auth */
394 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, ip);
395 if ( (tstconn==NULL) || (tstconn->status >= AIM_CONN_STATUS_RESOLVERR) )
396 fprintf(stderr, "faimtest: unable to reconnect with authorizer\n");
398 /* Send the cookie to the Auth */
399 aim_auth_sendcookie(sess, tstconn, cookie);
403 case 0x000d: /* ChatNav */
405 struct aim_conn_t *tstconn = NULL;
406 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, ip);
407 if ( (tstconn==NULL) || (tstconn->status >= AIM_CONN_STATUS_RESOLVERR)) {
408 fprintf(stderr, "faimtest: unable to connect to chatnav server\n");
409 if (tstconn) aim_conn_kill(sess, &tstconn);
413 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_CTN, AIM_CB_SPECIAL_DEFAULT, aim_parse_unknown, 0);
414 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_GEN, AIM_CB_SPECIAL_DEFAULT, aim_parse_unknown, 0);
416 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, faimtest_serverready, 0);
417 aim_auth_sendcookie(sess, tstconn, cookie);
418 fprintf(stderr, "\achatnav: connected\n");
421 case 0x000e: /* Chat */
423 char *roomname = NULL;
424 struct aim_conn_t *tstconn = NULL;
426 roomname = va_arg(ap, char *);
428 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, ip);
429 if ( (tstconn==NULL) || (tstconn->status >= AIM_CONN_STATUS_RESOLVERR))
431 fprintf(stderr, "faimtest: unable to connect to chat server\n");
432 if (tstconn) aim_conn_kill(sess, &tstconn);
435 printf("faimtest: chat: connected\n");
438 * We must do this to attach the stored name to the connection!
440 aim_chat_attachname(tstconn, roomname);
442 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, faimtest_serverready, 0);
443 aim_auth_sendcookie(sess, tstconn, cookie);
447 printf("uh oh... got redirect for unknown service 0x%04x!!\n", serviceid);
456 int faimtest_parse_authresp(struct aim_session_t *sess, struct command_rx_struct *command, ...)
458 struct aim_conn_t *bosconn = NULL;
461 printf("Screen name: %s\n", sess->logininfo.screen_name);
466 if (sess->logininfo.errorcode)
468 printf("Login Error Code 0x%04x\n", sess->logininfo.errorcode);
469 printf("Error URL: %s\n", sess->logininfo.errorurl);
470 aim_conn_kill(sess, &command->conn);
471 exit(0); /* XXX: should return in order to let the above things get free()'d. */
474 printf("Reg status: %2d\n", sess->logininfo.regstatus);
475 printf("Email: %s\n", sess->logininfo.email);
476 printf("BOS IP: %s\n", sess->logininfo.BOSIP);
478 printf("Closing auth connection...\n");
479 aim_conn_kill(sess, &command->conn);
480 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, sess->logininfo.BOSIP);
481 if (bosconn == NULL) {
482 fprintf(stderr, "faimtest: could not connect to BOS: internal error\n");
483 } else if (bosconn->status != 0) {
484 fprintf(stderr, "faimtest: could not connect to BOS\n");
485 aim_conn_kill(sess, &bosconn);
487 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, faimtest_bosrights, 0);
488 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0007, faimtest_rateresp, 0); /* rate info */
489 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0);
490 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_SERVERREADY, faimtest_serverready, 0);
491 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATEINFO, NULL, 0);
492 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, faimtest_handleredirect, 0);
493 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_STS, AIM_CB_STS_SETREPORTINTERVAL, faimtest_reportinterval, 0);
494 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_RIGHTSINFO, faimtest_parse_buddyrights, 0);
495 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, faimtest_parse_oncoming, 0);
496 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, faimtest_parse_offgoing, 0);
497 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, faimtest_parse_incoming_im, 0);
498 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, faimtest_parse_locerr, 0);
499 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, faimtest_parse_misses, 0);
500 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, faimtest_parse_ratechange, 0);
501 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_EVIL, faimtest_parse_evilnotify, 0);
502 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, faimtest_parse_msgerr, 0);
503 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, faimtest_parse_userinfo, 0);
504 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, faimtest_parse_msgack, 0);
506 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_CTN, AIM_CB_CTN_DEFAULT, aim_parse_unknown, 0);
507 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_DEFAULT, aim_parse_unknown, 0);
508 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_MOTD, faimtest_parse_motd, 0);
510 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, faimtest_parse_connerr, 0);
512 aim_auth_sendcookie(sess, bosconn, sess->logininfo.cookie);
517 static void printuserflags(unsigned short flags)
519 if (flags & AIM_FLAG_UNCONFIRMED)
520 printf("UNCONFIRMED ");
521 if (flags & AIM_FLAG_ADMINISTRATOR)
522 printf("ADMINISTRATOR ");
523 if (flags & AIM_FLAG_AOL)
525 if (flags & AIM_FLAG_OSCAR_PAY)
526 printf("OSCAR_PAY ");
527 if (flags & AIM_FLAG_FREE)
529 if (flags & AIM_FLAG_AWAY)
531 if (flags & AIM_FLAG_UNKNOWN40)
533 if (flags & AIM_FLAG_UNKNOWN80)
534 printf("UNKNOWN80 ");
538 int faimtest_parse_userinfo(struct aim_session_t *sess, struct command_rx_struct *command, ...)
540 struct aim_userinfo_s *userinfo;
541 char *prof_encoding = NULL;
543 unsigned short inforeq = 0;
546 va_start(ap, command);
547 userinfo = va_arg(ap, struct aim_userinfo_s *);
548 prof_encoding = va_arg(ap, char *);
549 prof = va_arg(ap, char *);
550 inforeq = va_arg(ap, unsigned short);
553 printf("faimtest: userinfo: sn: %s\n", userinfo->sn);
554 printf("faimtest: userinfo: warnlevel: 0x%04x\n", userinfo->warnlevel);
555 printf("faimtest: userinfo: flags: 0x%04x = ", userinfo->flags);
556 printuserflags(userinfo->flags);
559 printf("faimtest: userinfo: membersince: %lu\n", userinfo->membersince);
560 printf("faimtest: userinfo: onlinesince: %lu\n", userinfo->onlinesince);
561 printf("faimtest: userinfo: idletime: 0x%04x\n", userinfo->idletime);
563 if (inforeq == AIM_GETINFO_GENERALINFO) {
564 printf("faimtest: userinfo: profile_encoding: %s\n", prof_encoding ? prof_encoding : "[none]");
565 printf("faimtest: userinfo: prof: %s\n", prof ? prof : "[none]");
566 } else if (inforeq == AIM_GETINFO_AWAYMESSAGE) {
567 printf("faimtest: userinfo: awaymsg_encoding: %s\n", prof_encoding ? prof_encoding : "[none]");
568 printf("faimtest: userinfo: awaymsg: %s\n", prof ? prof : "[none]");
570 printf("faimtest: userinfo: unknown info request\n");
576 * The user-level Incoming ICBM callback.
579 * struct command_rx_struct * command if you feel like doing it yourself
580 * char * srcsn the source name
582 * int warnlevel warning/evil level
584 * ulong membersince time_t of date of signup
585 * ulong onsince time_t of date of singon
586 * int idletime min (sec?) idle
587 * u_int icbmflags sets AIM_IMFLAGS_{AWAY,ACK}
590 int faimtest_parse_incoming_im(struct aim_session_t *sess, struct command_rx_struct *command, ...)
595 va_start(ap, command);
596 channel = va_arg(ap, int);
599 * Channel 1: Standard Message
602 struct aim_userinfo_s *userinfo;
606 u_short flag1, flag2;
608 userinfo = va_arg(ap, struct aim_userinfo_s *);
609 msg = va_arg(ap, char *);
610 icbmflags = va_arg(ap, u_int);
611 flag1 = va_arg(ap, u_short);
612 flag2 = va_arg(ap, u_short);
615 printf("faimtest: icbm: sn = \"%s\"\n", userinfo->sn);
616 printf("faimtest: icbm: warnlevel = 0x%04x\n", userinfo->warnlevel);
617 printf("faimtest: icbm: flags = 0x%04x = ", userinfo->flags);
618 printuserflags(userinfo->flags);
621 printf("faimtest: icbm: membersince = %lu\n", userinfo->membersince);
622 printf("faimtest: icbm: onlinesince = %lu\n", userinfo->onlinesince);
623 printf("faimtest: icbm: idletime = 0x%04x\n", userinfo->idletime);
624 printf("faimtest: icbm: capabilities = 0x%04x\n", userinfo->capabilities);
626 printf("faimtest: icbm: icbmflags = ");
627 if (icbmflags & AIM_IMFLAGS_AWAY)
629 if (icbmflags & AIM_IMFLAGS_ACK)
630 printf("ackrequest ");
633 printf("faimtest: icbm: encoding flags = {%04x, %04x}\n", flag1, flag2);
635 printf("faimtest: icbm: message: %s\n", msg);
640 while (msg[i] == '<') {
642 while (msg[i] != '>')
649 printf("tmpstr = %s\n", tmpstr);
651 if ( (strlen(tmpstr) >= 10) &&
652 (!strncmp(tmpstr, "disconnect", 10)) ) {
653 aim_send_im(sess, command->conn, "midendian", 0, "ta ta...");
655 } else if (strstr(tmpstr, "goodday")) {
656 printf("faimtest: icbm: sending response\n");
657 aim_send_im(sess, command->conn, userinfo->sn, AIM_IMFLAGS_ACK, "Good day to you too.");
658 } else if (strstr(tmpstr, "warnme")) {
659 printf("faimtest: icbm: sending non-anon warning\n");
660 aim_send_warning(sess, command->conn, userinfo->sn, 0);
661 } else if (strstr(tmpstr, "anonwarn")) {
662 printf("faimtest: icbm: sending anon warning\n");
663 aim_send_warning(sess, command->conn, userinfo->sn, AIM_WARN_ANON);
664 } else if (strstr(tmpstr, "setdirectoryinfo")) {
665 printf("faimtest: icbm: sending backwards profile data\n");
666 aim_setdirectoryinfo(sess, command->conn, "tsrif", "elddim", "tsal", "nediam", "emankcin", "teerts", "ytic", "etats", "piz", 0, 1);
667 } else if (strstr(tmpstr, "setinterests")) {
668 printf("faimtest: icbm: setting fun interests\n");
669 aim_setuserinterests(sess, command->conn, "interest1", "interest2", "interest3", "interest4", "interest5", 1);
670 } else if (!strncmp(tmpstr, "open chatnav", 12)) {
671 aim_bos_reqservice(sess, command->conn, AIM_CONN_TYPE_CHATNAV);
672 //aim_chat_join(sess, command->conn, "thishereisaname2_chat85");
673 } else if (!strncmp(tmpstr, "create", 6)) {
674 aim_chatnav_createroom(sess,aim_getconn_type(sess, AIM_CONN_TYPE_CHATNAV), (strlen(tmpstr) < 7)?"WorldDomination":tmpstr+7, 0x0004);
675 } else if (!strncmp(tmpstr, "close chatnav", 13)) {
676 struct aim_conn_t *chatnavconn;
677 chatnavconn = aim_getconn_type(sess, AIM_CONN_TYPE_CHATNAV);
678 aim_conn_kill(sess, &chatnavconn);
679 } else if (!strncmp(tmpstr, "join", 4)) {
680 aim_chat_join(sess, command->conn, 0x0004, "worlddomination");
681 } else if (!strncmp(tmpstr, "leave", 5))
682 aim_chat_leaveroom(sess, "worlddomination");
683 else if (!strncmp(tmpstr, "getinfo", 7)) {
684 aim_getinfo(sess, command->conn, "75784102", AIM_GETINFO_GENERALINFO);
685 aim_getinfo(sess, command->conn, "15853637", AIM_GETINFO_AWAYMESSAGE);
686 } else if (!strncmp(tmpstr, "open directim", 13)) {
687 struct aim_conn_t *newconn;
688 newconn = aim_directim_initiate(sess, command->conn, NULL, userinfo->sn);
689 //aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINITIATE, faimtest_directim_initiate, 0);
690 } else if (!strncmp(tmpstr, "reqsendmsg", 10)) {
691 aim_send_im(sess, command->conn, "vaxherder", 0, "sendmsg 7900");
692 } else if (!strncmp(tmpstr, "sendmsg", 7)) {
699 newbuf = malloc(i+1);
700 for (z = 0; z < i; z++) {
701 newbuf[z] = (z % 10)+0x30;
704 aim_send_im(sess, command->conn, userinfo->sn, 0, newbuf);
708 printf("unknown command.\n");
709 aim_add_buddy(sess, command->conn, userinfo->sn);
715 * Channel 2: Rendevous Request
717 else if (channel == 2) {
718 struct aim_userinfo_s *userinfo;
719 unsigned short reqclass;
721 reqclass = va_arg(ap, unsigned short);
723 case AIM_CAPS_VOICE: {
724 userinfo = va_arg(ap, struct aim_userinfo_s *);
727 printf("faimtest: voice invitation: source sn = %s\n", userinfo->sn);
728 printf("faimtest: voice invitation: \twarnlevel = 0x%04x\n", userinfo->warnlevel);
729 printf("faimtest: voice invitation: \tclass = 0x%04x = ", userinfo->flags);
730 printuserflags(userinfo->flags);
733 /* we dont get membersince on chat invites! */
734 printf("faimtest: voice invitation: \tonlinesince = %lu\n", userinfo->onlinesince);
735 printf("faimtest: voice invitation: \tidletime = 0x%04x\n", userinfo->idletime);
739 case AIM_CAPS_GETFILE: {
740 printf("faimtset: get file!\n");
743 case AIM_CAPS_SENDFILE: {
744 printf("faimtest: send file!\n");
747 case AIM_CAPS_CHAT: {
748 char *msg,*encoding,*lang;
749 struct aim_chat_roominfo *roominfo;
751 userinfo = va_arg(ap, struct aim_userinfo_s *);
752 roominfo = va_arg(ap, struct aim_chat_roominfo *);
753 msg = va_arg(ap, char *);
754 encoding = va_arg(ap, char *);
755 lang = va_arg(ap, char *);
758 printf("faimtest: chat invitation: source sn = %s\n", userinfo->sn);
759 printf("faimtest: chat invitation: \twarnlevel = 0x%04x\n", userinfo->warnlevel);
760 printf("faimtest: chat invitation: \tclass = 0x%04x = ", userinfo->flags);
761 printuserflags(userinfo->flags);
764 /* we dont get membersince on chat invites! */
765 printf("faimtest: chat invitation: \tonlinesince = %lu\n", userinfo->onlinesince);
766 printf("faimtest: chat invitation: \tidletime = 0x%04x\n", userinfo->idletime);
768 printf("faimtest: chat invitation: message = %s\n", msg);
769 printf("faimtest: chat invitation: room name = %s\n", roominfo->name);
770 printf("faimtest: chat invitation: encoding = %s\n", encoding);
771 printf("faimtest: chat invitation: language = %s\n", lang);
772 printf("faimtest: chat invitation: exchange = 0x%04x\n", roominfo->exchange);
773 printf("faimtest: chat invitation: instance = 0x%04x\n", roominfo->instance);
774 printf("faimtest: chat invitiation: autojoining %s...\n", roominfo->name);
776 * Automatically join room...
778 aim_chat_join(sess, command->conn, 0x0004, roominfo->name);
781 case AIM_CAPS_IMIMAGE: {
782 struct aim_directim_priv *priv;
783 struct aim_conn_t *newconn;
785 printf("faimtest: icbm: rendezvous imimage\n");
787 userinfo = va_arg(ap, struct aim_userinfo_s *);
788 priv = va_arg(ap, struct aim_directim_priv *);
791 printf("faimtest: OFT: DirectIM: request from %s (%s)\n", userinfo->sn, priv->ip);
793 if (!(newconn = aim_directim_connect(sess, command->conn, priv))) {
794 printf("faimtest: icbm: imimage: could not connect\n");
797 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, faimtest_directim_incoming, 0);
798 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMDISCONNECT, faimtest_directim_disconnect, 0);
799 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, faimtest_directim_typing, 0);
801 aim_send_im_direct(sess, newconn, "goodday");
803 printf("faimtest: OFT: DirectIM: connected to %s\n", userinfo->sn);
808 printf("faimtest: icbm: unknown reqclass (%d)\n", reqclass);
811 printf("faimtest does not support channels > 2 (chan = %02x)\n", channel);
812 printf("faimtest: icbm: done with ICBM handling\n");
818 int faimtest_directim_initiate(struct aim_session_t *sess, struct command_rx_struct *command, ...)
821 struct aim_directim_priv *priv;
822 struct aim_conn_t *newconn;
824 ap = va_start(ap, command);
825 newconn = va_arg(ap, struct aim_conn_t *);
828 priv = (struct aim_directim_priv *)newconn->priv;
830 printf("faimtest: OFT: DirectIM: intitiate success to %s\n", priv->ip);
832 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, faimtest_directim_incoming, 0);
833 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMDISCONNECT, faimtest_directim_disconnect, 0);
834 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, faimtest_directim_typing, 0);
836 aim_send_im_direct(sess, newconn, "goodday");
838 printf("faimtest: OFT: DirectIM: connected to %s\n", priv->sn);
844 int faimtest_directim_connect(struct aim_session_t *sess, struct command_rx_struct *command, ...)
847 struct aim_directim_priv *priv;
849 ap = va_start(ap, command);
850 priv = va_arg(ap, struct aim_directim_priv *);
854 printf("faimtest: directim_connect\n");
859 int faimtest_directim_incoming(struct aim_session_t *sess, struct command_rx_struct *command, ...)
862 char *sn = NULL, *msg = NULL;
863 struct aim_conn_t *conn;
865 ap = va_start(ap, command);
866 conn = va_arg(ap, struct aim_conn_t *);
867 sn = va_arg(ap, char *);
868 msg = va_arg(ap, char *);
871 printf("faimtest: Directim from %s: %s\n", sn, msg);
872 if (!strncmp(msg, "sendmsg", 7)) {
879 newbuf = malloc(i+1);
880 for (z = 0; z < i; z++) {
881 newbuf[z] = (z % 10)+0x30;
884 aim_send_im_direct(sess, conn, newbuf);
887 } else if (!strncmp(msg, "goodday", 7)) {
888 aim_send_im_direct(sess, conn, "Good day to you, too");
891 snprintf(newmsg, sizeof(newmsg), "unknown (%s)\n", msg);
892 aim_send_im_direct(sess, conn, newmsg);
897 int faimtest_directim_disconnect(struct aim_session_t *sess, struct command_rx_struct *command, ...)
899 printf("faimtest: directim_disconnect\n");
903 int faimtest_directim_typing(struct aim_session_t *sess, struct command_rx_struct *command, ...)
908 ap = va_start(ap, command);
909 sn = va_arg(ap, char *);
912 printf("faimtest: ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn);
916 int faimtest_authsvrready(struct aim_session_t *sess, struct command_rx_struct *command, ...)
918 printf("faimtest_authsvrready: called (contype: %d)\n", command->conn->type);
920 /* should just be able to tell it we're ready too... */
921 aim_auth_clientready(sess, command->conn);
925 * This is where you'd really begin changing your password.
926 * However, this callback may get called for reasons other
927 * than you wanting to change your password. You should
928 * probably check that before actually doing it.
930 aim_auth_changepasswd(sess, command->conn, "PWD1", "PWD2");
936 int faimtest_pwdchngdone(struct aim_session_t *sess, struct command_rx_struct *command, ...)
938 printf("PASSWORD CHANGE SUCCESSFUL!!!\n");
942 int faimtest_parse_oncoming(struct aim_session_t *sess, struct command_rx_struct *command, ...)
944 struct aim_userinfo_s *userinfo;
947 va_start(ap, command);
948 userinfo = va_arg(ap, struct aim_userinfo_s *);
951 printf("\n%s is now online (flags: %04x = %s%s%s%s%s%s%s%s) (caps = 0x%04x)\n",
952 userinfo->sn, userinfo->flags,
953 (userinfo->flags&AIM_FLAG_UNCONFIRMED)?" UNCONFIRMED":"",
954 (userinfo->flags&AIM_FLAG_ADMINISTRATOR)?" ADMINISTRATOR":"",
955 (userinfo->flags&AIM_FLAG_AOL)?" AOL":"",
956 (userinfo->flags&AIM_FLAG_OSCAR_PAY)?" OSCAR_PAY":"",
957 (userinfo->flags&AIM_FLAG_FREE)?" FREE":"",
958 (userinfo->flags&AIM_FLAG_AWAY)?" AWAY":"",
959 (userinfo->flags&AIM_FLAG_UNKNOWN40)?" UNKNOWN40":"",
960 (userinfo->flags&AIM_FLAG_UNKNOWN80)?" UNKNOWN80":"",
961 userinfo->capabilities);
965 int faimtest_parse_offgoing(struct aim_session_t *sess, struct command_rx_struct *command, ...)
970 va_start(ap, command);
971 sn = va_arg(ap, char *);
974 printf("\n%s has left\n", sn);
979 int faimtest_parse_motd(struct aim_session_t *sess, struct command_rx_struct *command, ...)
981 static char *codes[] = {
986 "Top o' the world!"};
987 static int codeslen = 5;
993 va_start(ap, command);
994 id = va_arg(ap, unsigned short);
995 msg = va_arg(ap, char *);
998 printf("faimtest: motd: %s (%d / %s)\n", msg, id,
999 (id < codeslen)?codes[id]:"unknown");
1004 int faimtest_parse_msgerr(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1008 unsigned short reason;
1010 va_start(ap, command);
1011 destsn = va_arg(ap, char *);
1012 reason = va_arg(ap, unsigned short);
1015 printf("faimtest: message to %s bounced (reason 0x%04x: %s)\n", destsn, reason, (reason<msgerrreasonslen)?msgerrreasons[reason]:"unknown");
1020 int faimtest_parse_locerr(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1024 unsigned short reason;
1026 va_start(ap, command);
1027 destsn = va_arg(ap, char *);
1028 reason = va_arg(ap, unsigned short);
1031 printf("faimtest: user information for %s unavailable (reason 0x%04x: %s)\n", destsn, reason, (reason<msgerrreasonslen)?msgerrreasons[reason]:"unknown");
1037 * Handles callbacks for AIM_CB_MISSED_CALL.
1039 int faimtest_parse_misses(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1041 static char *missedreasons[] = {
1043 "Message too large"};
1044 static int missedreasonslen = 2;
1047 unsigned short chan, nummissed, reason;
1048 struct aim_userinfo_s *userinfo;
1050 va_start(ap, command);
1051 chan = va_arg(ap, unsigned short);
1052 userinfo = va_arg(ap, struct aim_userinfo_s *);
1053 nummissed = va_arg(ap, unsigned short);
1054 reason = va_arg(ap, unsigned short);
1057 printf("faimtest: missed %d messages from %s (reason %d: %s)\n", nummissed, userinfo->sn, reason, (reason<missedreasonslen)?missedreasons[reason]:"unknown");
1062 int faimtest_parse_login(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1064 struct client_info_s info = {"faimtest (with SNAC login)", 4, 1, 2010, "us", "en", 0x0004, 0x0000, 0x0000004b}; /* 4.1.2010 */
1068 va_start(ap, command);
1069 key = va_arg(ap, char *);
1072 aim_send_login(sess, command->conn, screenname, password, &info, key);
1077 int faimtest_chat_join(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1080 struct aim_userinfo_s *userinfo;
1081 int count = 0, i = 0;
1083 va_start(ap, command);
1084 count = va_arg(ap, int);
1085 userinfo = va_arg(ap, struct aim_userinfo_s *);
1088 printf("faimtest: chat: %s: New occupants have joined:\n", (char *)command->conn->priv);
1090 printf("faimtest: chat: %s: \t%s\n", (char *)command->conn->priv, userinfo[i++].sn);
1095 int faimtest_chat_leave(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1098 struct aim_userinfo_s *userinfo;
1099 int count = 0, i = 0;
1101 va_start(ap, command);
1102 count = va_arg(ap, int);
1103 userinfo = va_arg(ap, struct aim_userinfo_s *);
1106 printf("faimtest: chat: %s: Some occupants have left:\n", (char *)command->conn->priv);
1108 printf("faimtest: chat: %s: \t%s\n", (char *)command->conn->priv, userinfo[i++].sn);
1113 int faimtest_chat_infoupdate(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1116 struct aim_userinfo_s *userinfo;
1117 struct aim_chat_roominfo *roominfo;
1121 unsigned short unknown_c9, unknown_d2, unknown_d5, maxmsglen;
1122 unsigned long creationtime;
1124 va_start(ap, command);
1125 roominfo = va_arg(ap, struct aim_chat_roominfo *);
1126 roomname = va_arg(ap, char *);
1127 usercount= va_arg(ap, int);
1128 userinfo = va_arg(ap, struct aim_userinfo_s *);
1129 roomdesc = va_arg(ap, char *);
1130 unknown_c9 = va_arg(ap, unsigned short);
1131 creationtime = va_arg(ap, unsigned long);
1132 maxmsglen = va_arg(ap, unsigned short);
1133 unknown_d2 = va_arg(ap, unsigned short);
1134 unknown_d5 = va_arg(ap, unsigned short);
1137 printf("faimtest: chat: %s: info update:\n", (char *)command->conn->priv);
1138 printf("faimtest: chat: %s: \tRoominfo: {%04x, %s, %04x}\n",
1139 (char *)command->conn->priv,
1142 roominfo->instance);
1143 printf("faimtest: chat: %s: \tRoomname: %s\n", (char *)command->conn->priv, roomname);
1144 printf("faimtest: chat: %s: \tRoomdesc: %s\n", (char *)command->conn->priv, roomdesc);
1145 printf("faimtest: chat: %s: \tOccupants: (%d)\n", (char *)command->conn->priv, usercount);
1148 while (i < usercount)
1149 printf("faimtest: chat: %s: \t\t%s\n", (char *)command->conn->priv, userinfo[i++].sn);
1151 printf("faimtest: chat: %s: \tUnknown_c9: 0x%04x\n", (char *)command->conn->priv, unknown_c9);
1152 printf("faimtest: chat: %s: \tCreation time: %lu (time_t)\n", (char *)command->conn->priv, creationtime);
1153 printf("faimtest: chat: %s: \tMax message length: %d bytes\n", (char *)command->conn->priv, maxmsglen);
1154 printf("faimtest: chat: %s: \tUnknown_d2: 0x%04x\n", (char *)command->conn->priv, unknown_d2);
1155 printf("faimtest: chat: %s: \tUnknown_d5: 0x%02x\n", (char *)command->conn->priv, unknown_d5);
1160 int faimtest_chat_incomingmsg(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1163 struct aim_userinfo_s *userinfo;
1167 va_start(ap, command);
1168 userinfo = va_arg(ap, struct aim_userinfo_s *);
1169 msg = va_arg(ap, char *);
1172 printf("faimtest: chat: %s: incoming msg from %s: %s\n", (char *)command->conn->priv, userinfo->sn, msg);
1175 * Do an echo for testing purposes. But not for ourselves ("oops!")
1177 if (strcmp(userinfo->sn, sess->logininfo.screen_name) != 0)
1179 sprintf(tmpbuf, "(%s said \"%s\")", userinfo->sn, msg);
1180 aim_chat_send_im(sess, command->conn, tmpbuf);
1186 int faimtest_chatnav_info(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1191 ap = va_start(ap, command);
1192 type = va_arg(ap, u_short);
1197 struct aim_chat_exchangeinfo *exchanges;
1198 int exchangecount,i = 0;
1200 maxrooms = va_arg(ap, u_char);
1201 exchangecount = va_arg(ap, int);
1202 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *);
1205 printf("faimtest: chat info: Chat Rights:\n");
1206 printf("faimtest: chat info: \tMax Concurrent Rooms: %d\n", maxrooms);
1208 printf("faimtest: chat info: \tExchange List: (%d total)\n", exchangecount);
1209 while (i < exchangecount) {
1210 printf("faimtest: chat info: \t\t%x: %s (%s/%s)\n",
1211 exchanges[i].number,
1213 exchanges[i].charset1,
1214 exchanges[i].lang1);
1221 char *fqcn, *name, *ck;
1222 unsigned short instance, flags, maxmsglen, maxoccupancy, unknown;
1223 unsigned char createperms;
1224 unsigned long createtime;
1226 fqcn = va_arg(ap, char *);
1227 instance = va_arg(ap, unsigned short);
1228 flags = va_arg(ap, unsigned short);
1229 createtime = va_arg(ap, unsigned long);
1230 maxmsglen = va_arg(ap, unsigned short);
1231 maxoccupancy = va_arg(ap, unsigned short);
1232 createperms = va_arg(ap, unsigned char);
1233 unknown = va_arg(ap, unsigned short);
1234 name = va_arg(ap, char *);
1235 ck = va_arg(ap, char *);
1238 printf("faimtest: recieved room create reply for %s\n", fqcn);
1243 printf("faimtest: chatnav info: unknown type (%04x)\n", type);
1248 int faimtest_parse_connerr(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1251 unsigned short code;
1254 ap = va_start(ap, command);
1255 code = va_arg(ap, unsigned short);
1256 msg = va_arg(ap, char *);
1259 printf("faimtest: connerr: Code 0x%04x: %s\n", code, msg);
1260 aim_conn_kill(sess, &command->conn); /* this will break the main loop */
1265 int faimtest_debugconn_connect(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1267 printf("faimtest: connecting to an aimdebugd!\n");
1269 /* convert the authorizer connection to a BOS connection */
1270 command->conn->type = AIM_CONN_TYPE_BOS;
1272 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, faimtest_parse_incoming_im, 0);
1274 /* tell the aimddebugd we're ready */
1275 aim_debugconn_sendconnect(sess, command->conn);
1277 /* go right into main loop (don't open a BOS connection, etc) */
1282 * Recieved in response to an IM sent with the AIM_IMFLAGS_ACK option.
1284 int faimtest_parse_msgack(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1287 unsigned short type;
1290 ap = va_start(ap, command);
1291 type = va_arg(ap, unsigned short);
1292 sn = va_arg(ap, char *);
1295 printf("faimtest: msgack: 0x%04x / %s\n", type, sn);
1300 int faimtest_parse_ratechange(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1303 unsigned long newrate;
1305 va_start(ap, command);
1306 newrate = va_arg(ap, unsigned long);
1309 printf("faimtest: ratechange: %lu\n", newrate);
1314 int faimtest_parse_evilnotify(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1319 va_start(ap, command);
1320 sn = va_arg(ap, char *);
1323 printf("faimtest: warning from: %s\n", sn);