⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 family_auth.c

📁 Linux下的多协议即时通讯程序源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
		if (tmptlv != NULL)		{			info->cookielen = tmptlv->length;			info->cookie = tmptlv->value;		}	}	/*	 * The email address attached to this account	 *   Not available for ICQ or @mac.com logins.	 *   If you receive this TLV, then you are allowed to use	 *   family 0x0018 to check the status of your email.	 * XXX - Not really true!	 */	if (aim_tlv_gettlv(tlvlist, 0x0011, 1))		info->email = aim_tlv_getstr(tlvlist, 0x0011, 1);	/*	 * The registration status.  (Not real sure what it means.)	 *   Not available for ICQ or @mac.com logins.	 *	 *   1 = No disclosure	 *   2 = Limited disclosure	 *   3 = Full disclosure	 *	 * This has to do with whether your email address is available	 * to other users or not.  AFAIK, this feature is no longer used.	 *	 * Means you can use the admin family? (0x0007)	 *	 */	if (aim_tlv_gettlv(tlvlist, 0x0013, 1))		info->regstatus = aim_tlv_get16(tlvlist, 0x0013, 1);	if (aim_tlv_gettlv(tlvlist, 0x0040, 1))		info->latestbeta.build = aim_tlv_get32(tlvlist, 0x0040, 1);	if (aim_tlv_gettlv(tlvlist, 0x0041, 1))		info->latestbeta.url = aim_tlv_getstr(tlvlist, 0x0041, 1);	if (aim_tlv_gettlv(tlvlist, 0x0042, 1))		info->latestbeta.info = aim_tlv_getstr(tlvlist, 0x0042, 1);	if (aim_tlv_gettlv(tlvlist, 0x0043, 1))		info->latestbeta.name = aim_tlv_getstr(tlvlist, 0x0043, 1);#if 0	if (aim_tlv_gettlv(tlvlist, 0x0048, 1)) {		/* beta serial */	}#endif	if (aim_tlv_gettlv(tlvlist, 0x0044, 1))		info->latestrelease.build = aim_tlv_get32(tlvlist, 0x0044, 1);	if (aim_tlv_gettlv(tlvlist, 0x0045, 1))		info->latestrelease.url = aim_tlv_getstr(tlvlist, 0x0045, 1);	if (aim_tlv_gettlv(tlvlist, 0x0046, 1))		info->latestrelease.info = aim_tlv_getstr(tlvlist, 0x0046, 1);	if (aim_tlv_gettlv(tlvlist, 0x0047, 1))		info->latestrelease.name = aim_tlv_getstr(tlvlist, 0x0047, 1);#if 0	if (aim_tlv_gettlv(tlvlist, 0x0049, 1)) {		/* lastest release serial */	}#endif	/*	 * URL to change password.	 */	if (aim_tlv_gettlv(tlvlist, 0x0054, 1))		info->chpassurl = aim_tlv_getstr(tlvlist, 0x0054, 1);#if 0	/*	 * Unknown.  Seen on an @mac.com screen name with value of 0x003f	 */	if (aim_tlv_gettlv(tlvlist, 0x0055, 1)) {		/* Unhandled */	}#endif	od->authinfo = info;	if ((userfunc = aim_callhandler(od, snac ? snac->family : 0x0017, snac ? snac->subtype : 0x0003)))		ret = userfunc(od, conn, frame, info);	aim_tlvlist_free(tlvlist);	return ret;}#ifdef USE_XOR_FOR_ICQ/* * Subtype 0x0007 (kind of) - Send a fake type 0x0007 SNAC to the client * * This is a bit confusing. * * Normal SNAC login goes like this: *   - connect *   - server sends flap version *   - client sends flap version *   - client sends screen name (17/6) *   - server sends hash key (17/7) *   - client sends auth request (17/2 -- aim_send_login) *   - server yells * * XOR login (for ICQ) goes like this: *   - connect *   - server sends flap version *   - client sends auth request which contains flap version (aim_send_login) *   - server yells * * For the client API, we make them implement the most complicated version, * and for the simpler version, we fake it and make it look like the more * complicated process. * * This is done by giving the client a faked key, just so we can convince * them to call aim_send_login right away, which will detect the session * flag that says this is XOR login and ignore the key, sending an ICQ * login request instead of the normal SNAC one. * * As soon as AOL makes ICQ log in the same way as AIM, this is /gone/. * * XXX This may cause problems if the client relies on callbacks only * being called from the context of aim_rxdispatch()... * */static intgoddamnicq(OscarData *od, FlapConnection *conn, const char *sn){	FlapFrame frame;	aim_rxcallback_t userfunc;	if ((userfunc = aim_callhandler(od, 0x0017, 0x0007)))		userfunc(od, conn, &frame, "");	return 0;}#endif/* * Subtype 0x0006 * * In AIM 3.5 protocol, the first stage of login is to request login from the * Authorizer, passing it the screen name for verification.  If the name is * invalid, a 0017/0003 is spit back, with the standard error contents.  If * valid, a 0017/0007 comes back, which is the signal to send it the main * login command (0017/0002). * */intaim_request_login(OscarData *od, FlapConnection *conn, const char *sn){	FlapFrame *frame;	aim_snacid_t snacid;	GSList *tlvlist = NULL;	if (!od || !conn || !sn)		return -EINVAL;#ifdef USE_XOR_FOR_ICQ	if (isdigit(sn[0]))		return goddamnicq(od, conn, sn);#endif	frame = flap_frame_new(od, 0x02, 10+2+2+strlen(sn)+8);	snacid = aim_cachesnac(od, 0x0017, 0x0006, 0x0000, NULL, 0);	aim_putsnac(&frame->data, 0x0017, 0x0006, 0x0000, snacid);	aim_tlvlist_add_str(&tlvlist, 0x0001, sn);	/* Tell the server we support SecurID logins. */	aim_tlvlist_add_noval(&tlvlist, 0x004b);	/* Unknown.  Sent in recent WinAIM clients.*/	aim_tlvlist_add_noval(&tlvlist, 0x005a);	aim_tlvlist_write(&frame->data, &tlvlist);	aim_tlvlist_free(tlvlist);	flap_connection_send(conn, frame);	return 0;}/* * Subtype 0x0007 * * Middle handler for 0017/0007 SNACs.  Contains the auth key prefixed * by only its length in a two byte word. * * Calls the client, which should then use the value to call aim_send_login. * */static intkeyparse(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs){	int keylen, ret = 1;	aim_rxcallback_t userfunc;	char *keystr;	GSList *tlvlist;	gboolean truncate_pass;	keylen = byte_stream_get16(bs);	keystr = byte_stream_getstr(bs, keylen);	tlvlist = aim_tlvlist_read(bs);	/*	 * If the truncate_pass TLV exists then we should truncate the	 * user's password to 8 characters.  This flag is sent when you	 * try to log in with an AOL user's screen name.	 */	truncate_pass = aim_tlv_gettlv(tlvlist, 0x0026, 1) != NULL;	/* XXX - When GiantGrayPanda signed on AIM I got a thing asking me to register	 * for the netscape network.  This SNAC had a type 0x0058 TLV with length 10.	 * Data is 0x0007 0004 3e19 ae1e 0006 0004 0000 0005 */	if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))		ret = userfunc(od, conn, frame, keystr, (int)truncate_pass);	g_free(keystr);	aim_tlvlist_free(tlvlist);	return ret;}/** * Subtype 0x000a * * Receive SecurID request. */static intgot_securid_request(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs){	int ret = 0;	aim_rxcallback_t userfunc;	if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))		ret = userfunc(od, conn, frame);	return ret;}/** * Subtype 0x000b * * Send SecurID response. */intaim_auth_securid_send(OscarData *od, const char *securid){	FlapConnection *conn;	FlapFrame *frame;	aim_snacid_t snacid;	int len;	if (!od || !(conn = flap_connection_getbytype_all(od, SNAC_FAMILY_AUTH)) || !securid)		return -EINVAL;	len = strlen(securid);	frame = flap_frame_new(od, 0x02, 10+2+len);	snacid = aim_cachesnac(od, SNAC_FAMILY_AUTH, SNAC_SUBTYPE_AUTH_SECURID_RESPONSE, 0x0000, NULL, 0);	aim_putsnac(&frame->data, SNAC_FAMILY_AUTH, SNAC_SUBTYPE_AUTH_SECURID_RESPONSE, 0x0000, 0);	byte_stream_put16(&frame->data, len);	byte_stream_putstr(&frame->data, securid);	flap_connection_send(conn, frame);	return 0;}static voidauth_shutdown(OscarData *od, aim_module_t *mod){	if (od->authinfo != NULL)	{		free(od->authinfo->sn);		free(od->authinfo->bosip);		free(od->authinfo->errorurl);		free(od->authinfo->email);		free(od->authinfo->chpassurl);		free(od->authinfo->latestrelease.name);		free(od->authinfo->latestrelease.url);		free(od->authinfo->latestrelease.info);		free(od->authinfo->latestbeta.name);		free(od->authinfo->latestbeta.url);		free(od->authinfo->latestbeta.info);		free(od->authinfo);	}}static intsnachandler(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs){	if (snac->subtype == 0x0003)		return parse(od, conn, mod, frame, snac, bs);	else if (snac->subtype == 0x0007)		return keyparse(od, conn, mod, frame, snac, bs);	else if (snac->subtype == 0x000a)		return got_securid_request(od, conn, mod, frame, snac, bs);	return 0;}intauth_modfirst(OscarData *od, aim_module_t *mod){	mod->family = 0x0017;	mod->version = 0x0000;	mod->flags = 0;	strncpy(mod->name, "auth", sizeof(mod->name));	mod->snachandler = snachandler;	mod->shutdown = auth_shutdown;	return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -