changeset 2675:e759254b29bb

[gaim-migrate @ 2688] This source code was developed using Microsoft Visual Studio 6.0. committer: Tailor Script <tailor@pidgin.im>
author Adam Fritzler <mid@auk.cx>
date Mon, 05 Nov 2001 12:25:22 +0000
parents de99ce38ad1f
children cfe797cf62ef
files src/protocols/oscar/aim.h src/protocols/oscar/aim_cbtypes.h src/protocols/oscar/aim_internal.h src/protocols/oscar/conn.c src/protocols/oscar/ft.c src/protocols/oscar/login.c src/protocols/oscar/misc.c src/protocols/oscar/oscar.c src/protocols/oscar/rxhandlers.c
diffstat 9 files changed, 336 insertions(+), 162 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/oscar/aim.h	Mon Nov 05 11:33:50 2001 +0000
+++ b/src/protocols/oscar/aim.h	Mon Nov 05 12:25:22 2001 +0000
@@ -565,15 +565,12 @@
 faim_export int aim_bos_setbuddylist(aim_session_t *, aim_conn_t *, const char *);
 faim_export int aim_bos_setprofile(aim_session_t *sess, aim_conn_t *conn, const char *profile, const char *awaymsg, fu16_t caps);
 faim_export int aim_bos_setgroupperm(aim_session_t *, aim_conn_t *, fu32_t mask);
-faim_export int aim_reqrates(aim_session_t *, aim_conn_t *);
-faim_export int aim_ratesack(aim_session_t *, aim_conn_t *);
 faim_export int aim_bos_setprivacyflags(aim_session_t *, aim_conn_t *, fu32_t);
 faim_export int aim_bos_reqpersonalinfo(aim_session_t *, aim_conn_t *);
 faim_export int aim_bos_reqservice(aim_session_t *, aim_conn_t *, fu16_t);
 faim_export int aim_bos_reqrights(aim_session_t *, aim_conn_t *);
 faim_export int aim_bos_reqbuddyrights(aim_session_t *, aim_conn_t *);
 faim_export int aim_bos_reqlocaterights(aim_session_t *, aim_conn_t *);
-faim_export int aim_setversions(aim_session_t *sess, aim_conn_t *conn);
 faim_export int aim_setdirectoryinfo(aim_session_t *sess, aim_conn_t *conn, const char *first, const char *middle, const char *last, const char *maiden, const char *nickname, const char *street, const char *city, const char *state, const char *zip, int country, fu16_t privacy);
 faim_export int aim_setuserinterests(aim_session_t *sess, aim_conn_t *conn, const char *interest1, const char *interest2, const char *interest3, const char *interest4, const char *interest5, fu16_t privacy);
 faim_export int aim_icq_setstatus(aim_session_t *sess, aim_conn_t *conn, fu16_t status);
--- a/src/protocols/oscar/aim_cbtypes.h	Mon Nov 05 11:33:50 2001 +0000
+++ b/src/protocols/oscar/aim_cbtypes.h	Mon Nov 05 12:25:22 2001 +0000
@@ -223,6 +223,7 @@
 #define AIM_CB_SPECIAL_CONNERR 0x0003
 #define AIM_CB_SPECIAL_CONNCOMPLETE 0x0004
 #define AIM_CB_SPECIAL_FLAPVER 0x0005
+#define AIM_CB_SPECIAL_CONNINITDONE 0x0006
 #define AIM_CB_SPECIAL_DEBUGCONN_CONNECT 0xe001
 #define AIM_CB_SPECIAL_UNKNOWN 0xffff
 #define AIM_CB_SPECIAL_DEFAULT AIM_CB_SPECIAL_UNKNOWN
--- a/src/protocols/oscar/aim_internal.h	Mon Nov 05 11:33:50 2001 +0000
+++ b/src/protocols/oscar/aim_internal.h	Mon Nov 05 12:25:22 2001 +0000
@@ -144,6 +144,26 @@
 	struct snacgroup *next;
 };
 
+struct snacpair {
+	fu16_t group;
+	fu16_t subtype;
+	struct snacpair *next;
+};
+
+struct rateclass {
+	fu16_t classid;
+	fu32_t windowsize;
+	fu32_t clear;
+	fu32_t alert;
+	fu32_t limit;
+	fu32_t disconnect;
+	fu32_t current;
+	fu32_t max;
+	fu8_t unknown[5]; /* only present in versions >= 3 */
+	struct snacpair *members;
+	struct rateclass *next;
+};
+
 /*
  * This is inside every connection.  But it is a void * to anything
  * outside of libfaim.  It should remain that way.  It's called data
@@ -153,6 +173,7 @@
  */
 typedef struct aim_conn_inside_s {
 	struct snacgroup *groups;
+	struct rateclass *rates;
 } aim_conn_inside_t;
 
 faim_internal void aim_conn_addgroup(aim_conn_t *conn, fu16_t group);
@@ -178,6 +199,10 @@
 faim_internal void aim_conn_close_rend(aim_session_t *sess, aim_conn_t *conn);
 faim_internal void aim_conn_kill_rend(aim_session_t *sess, aim_conn_t *conn);
 
+/* These are all handled internally now. */
+faim_internal int aim_setversions(aim_session_t *sess, aim_conn_t *conn);
+faim_internal int aim_reqrates(aim_session_t *, aim_conn_t *);
+faim_internal int aim_ratesack(aim_session_t *, aim_conn_t *);
 
 #ifndef FAIM_INTERNAL_INSANE
 #define printf() printf called inside libfaim
--- a/src/protocols/oscar/conn.c	Mon Nov 05 11:33:50 2001 +0000
+++ b/src/protocols/oscar/conn.c	Mon Nov 05 12:25:22 2001 +0000
@@ -104,10 +104,11 @@
 	return NULL;
 }
 
-static struct snacgroup *connkill_snacgroups(struct snacgroup *sg)
+static void connkill_snacgroups(struct snacgroup **head)
 {
+	struct snacgroup *sg;
 
-	while (sg) {
+	for (sg = *head; sg; ) {
 		struct snacgroup *tmp;
 
 		tmp = sg->next;
@@ -115,7 +116,26 @@
 		sg = tmp;
 	}
 
-	return NULL;
+	*head = NULL;
+
+	return;
+}
+
+static void connkill_rates(struct rateclass **head)
+{
+	struct rateclass *rc;
+
+	for (rc = *head; rc; ) {
+		struct rateclass *tmp;
+
+		tmp = rc->next;
+		free(rc);
+		rc = tmp;
+	}
+
+	*head = NULL;
+
+	return;
 }
 
 static void connkill_real(aim_session_t *sess, aim_conn_t **deadconn)
@@ -144,7 +164,8 @@
 	if ((*deadconn)->inside) {
 		aim_conn_inside_t *inside = (aim_conn_inside_t *)(*deadconn)->inside;
 
-		inside->groups = connkill_snacgroups(inside->groups);
+		connkill_snacgroups(&inside->groups);
+		connkill_rates(&inside->rates);
 
 		free(inside);
 	}
--- a/src/protocols/oscar/ft.c	Mon Nov 05 11:33:50 2001 +0000
+++ b/src/protocols/oscar/ft.c	Mon Nov 05 12:25:22 2001 +0000
@@ -28,9 +28,6 @@
 };
 
 static int listenestablish(fu16_t portnum);
-#if 0
-static struct aim_fileheader_t *aim_oft_getfh(unsigned char *hdr);
-#endif
  
 /**
  * aim_handlerendconnect - call this to accept OFT connections and set up the required structures
--- a/src/protocols/oscar/login.c	Mon Nov 05 11:33:50 2001 +0000
+++ b/src/protocols/oscar/login.c	Mon Nov 05 12:25:22 2001 +0000
@@ -448,14 +448,18 @@
  *
  * This info probably doesn't even need to make it to the client.
  *
+ * We don't actually call the client here.  This starts off the connection
+ * initialization routine required by all AIM connections.  The next time
+ * the client is called is the CONNINITDONE callback, which should be 
+ * shortly after the rate information is acknowledged.
+ * 
  */
 static int hostonline(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
 {
-	aim_rxcallback_t userfunc;
-	int ret = 0;
 	fu16_t *families;
 	int famcount;
 
+
 	if (!(families = malloc(aim_bstream_empty(bs))))
 		return 0;
 
@@ -464,12 +468,20 @@
 		aim_conn_addgroup(rx->conn, families[famcount]);
 	}
 
-	if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
-		ret = userfunc(sess, rx, famcount, families);
-
 	free(families);
 
-	return ret; 
+
+	/*
+	 * Next step is in the Host Versions handler.
+	 *
+	 * Note that we must send this before we request rates, since
+	 * the format of the rate information depends on the versions we
+	 * give it.
+	 *
+	 */
+	aim_setversions(sess, rx->conn);
+
+	return 1; 
 }
 
 static int redirect(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
@@ -518,6 +530,40 @@
 	return ret;
 }
 
+/* 
+ *  Request Rate Information.
+ * 
+ */
+faim_internal int aim_reqrates(aim_session_t *sess, aim_conn_t *conn)
+{
+	return aim_genericreq_n(sess, conn, 0x0001, 0x0006);
+}
+
+/* 
+ *  Rate Information Response Acknowledge.
+ *
+ */
+faim_internal int aim_ratesack(aim_session_t *sess, aim_conn_t *conn)
+{
+	aim_conn_inside_t *ins = (aim_conn_inside_t *)conn->inside;
+	aim_frame_t *fr;	
+	aim_snacid_t snacid;
+	struct rateclass *rc;
+
+	if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 512)))
+		return -ENOMEM; 
+
+	snacid = aim_cachesnac(sess, 0x0001, 0x0008, 0x0000, NULL, 0);
+	aim_putsnac(&fr->data, 0x0001, 0x0008, 0x0000, snacid);
+
+	for (rc = ins->rates; rc; rc = rc->next)
+		aimbs_put16(&fr->data, rc->classid);
+
+	aim_tx_enqueue(sess, fr);
+
+	return 0;
+}
+
 /*
  * The Rate Limiting System, An Abridged Guide to Nonsense.
  *
@@ -568,15 +614,144 @@
  * 
  */
 
-/* XXX parse this */
+static void rc_addclass(struct rateclass **head, struct rateclass *inrc)
+{
+	struct rateclass *rc, *rc2;
+
+	if (!(rc = malloc(sizeof(struct rateclass))))
+		return;
+
+	memcpy(rc, inrc, sizeof(struct rateclass));
+	rc->next = NULL;
+
+	for (rc2 = *head; rc2 && rc2->next; rc2 = rc2->next)
+		;
+
+	if (!rc2)
+		*head = rc;
+	else
+		rc2->next = rc;
+
+	return;
+}
+
+static struct rateclass *rc_findclass(struct rateclass **head, fu16_t id)
+{
+	struct rateclass *rc;
+
+	for (rc = *head; rc; rc = rc->next) {
+		if (rc->classid == id)
+			return rc;
+	}
+
+	return NULL;
+}
+
+static void rc_addpair(struct rateclass *rc, fu16_t group, fu16_t type)
+{
+	struct snacpair *sp, *sp2;
+
+	if (!(sp = malloc(sizeof(struct snacpair))))
+		return;
+	memset(sp, 0, sizeof(struct snacpair));
+
+	sp->group = group;
+	sp->subtype = type;
+	sp->next = NULL;
+
+	for (sp2 = rc->members; sp2 && sp2->next; sp2 = sp2->next)
+		;
+
+	if (!sp2)
+		rc->members = sp;
+	else
+		sp2->next = sp;
+
+	return;
+}
+
 static int rateresp(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
 {
+	aim_conn_inside_t *ins = (aim_conn_inside_t *)rx->conn->inside;
+	fu16_t numclasses, i;
 	aim_rxcallback_t userfunc;
 
-	if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
-		return userfunc(sess, rx);
+
+	/*
+	 * First are the parameters for each rate class.
+	 */
+	numclasses = aimbs_get16(bs);
+	for (i = 0; i < numclasses; i++) {
+		struct rateclass rc;
+
+		memset(&rc, 0, sizeof(struct rateclass));
+
+		rc.classid = aimbs_get16(bs);
+		rc.windowsize = aimbs_get32(bs);
+		rc.clear = aimbs_get32(bs);
+		rc.alert = aimbs_get32(bs);
+		rc.limit = aimbs_get32(bs);
+		rc.disconnect = aimbs_get32(bs);
+		rc.current = aimbs_get32(bs);
+		rc.max = aimbs_get32(bs);
+
+		/*
+		 * The server will send an extra five bytes of parameters
+		 * depending on the version we advertised in 1/17.  If we
+		 * didn't send 1/17 (evil!), then this will crash and you
+		 * die, as it will default to the old version but we have 
+		 * the new version hardcoded here. 
+		 */
+		if (mod->version >= 3)
+			aimbs_getrawbuf(bs, rc.unknown, sizeof(rc.unknown));
+
+		rc_addclass(&ins->rates, &rc);
+	}
 
-	return 0;
+	/*
+	 * Then the members of each class.
+	 */
+	for (i = 0; i < numclasses; i++) {
+		fu16_t classid, count;
+		struct rateclass *rc;
+		int j;
+
+		classid = aimbs_get16(bs);
+		count = aimbs_get16(bs);
+
+		rc = rc_findclass(&ins->rates, classid);
+
+		for (j = 0; j < count; j++) {
+			fu16_t group, subtype;
+
+			group = aimbs_get16(bs);
+			subtype = aimbs_get16(bs);
+
+			if (rc)
+				rc_addpair(rc, group, subtype);
+		}
+	}
+
+	/*
+	 * We don't pass the rate information up to the client, as it really
+	 * doesn't care.  The information is stored in the connection, however
+	 * so that we can do more fun stuff later (not really).
+	 */
+
+	/*
+	 * Last step in the conn init procedure is to acknowledge that we
+	 * agree to these draconian limitations.
+	 */
+	aim_ratesack(sess, rx->conn);
+
+	/*
+	 * Finally, tell the client it's ready to go...
+	 */
+	if ((userfunc = aim_callhandler(sess, rx->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE)))
+		userfunc(sess, rx);
+
+
+	return 1;
 }
 
 static int ratechange(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
@@ -780,22 +955,57 @@
 	return ret;
 }
 
+faim_internal int aim_setversions(aim_session_t *sess, aim_conn_t *conn)
+{
+	aim_conn_inside_t *ins = (aim_conn_inside_t *)conn->inside;
+	struct snacgroup *sg;
+	aim_frame_t *fr;
+	aim_snacid_t snacid;
+
+	if (!ins)
+		return -EINVAL;
+
+	if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 1152)))
+		return -ENOMEM;
+
+	snacid = aim_cachesnac(sess, 0x0001, 0x0017, 0x0000, NULL, 0);
+	aim_putsnac(&fr->data, 0x0001, 0x0017, 0x0000, snacid);
+
+	/*
+	 * Send only the versions that the server cares about (that it
+	 * marked as supporting in the server ready SNAC).  
+	 */
+	for (sg = ins->groups; sg; sg = sg->next) {
+		aim_module_t *mod;
+
+		if ((mod = aim__findmodulebygroup(sess, sg->group))) {
+			aimbs_put16(&fr->data, mod->family);
+			aimbs_put16(&fr->data, mod->version);
+		} else
+			faimdprintf(sess, 1, "aim_setversions: server supports group 0x%04x but we don't!\n", sg->group);
+	}
+
+	aim_tx_enqueue(sess, fr);
+
+	return 0;
+}
+
 static int hostversions(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
 {
-	aim_rxcallback_t userfunc;
 	int vercount;
 	fu8_t *versions;
-	int ret = 0;
 
+	/* This is frivolous. (Thank you SmarterChild.) */
 	vercount = aim_bstream_empty(bs)/4;
 	versions = aimbs_getraw(bs, aim_bstream_empty(bs));
-
-	if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
-		ret = userfunc(sess, rx, vercount, versions);
-
 	free(versions);
 
-	return ret;
+	/*
+	 * Now request rates.
+	 */
+	aim_reqrates(sess, rx->conn);
+
+	return 1;
 }
 
 /*
--- a/src/protocols/oscar/misc.c	Mon Nov 05 11:33:50 2001 +0000
+++ b/src/protocols/oscar/misc.c	Mon Nov 05 12:25:22 2001 +0000
@@ -253,43 +253,6 @@
 }
 
 /* 
- *  Request Rate Information.
- * 
- */
-faim_export int aim_reqrates(aim_session_t *sess, aim_conn_t *conn)
-{
-	return aim_genericreq_n(sess, conn, 0x0001, 0x0006);
-}
-
-/* 
- *  Rate Information Response Acknowledge.
- *
- */
-faim_export int aim_ratesack(aim_session_t *sess, aim_conn_t *conn)
-{
-	aim_frame_t *fr;	
-	aim_snacid_t snacid;
-
-	if(!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+10)))
-		return -ENOMEM; 
-
-	snacid = aim_cachesnac(sess, 0x0001, 0x0008, 0x0000, NULL, 0);
-	
-	aim_putsnac(&fr->data, 0x0001, 0x0008, 0x0000, snacid);
-
-	/* XXX store the rate info in the inside struct, make this dynamic */
-	aimbs_put16(&fr->data, 0x0001); 
-	aimbs_put16(&fr->data, 0x0002);
-	aimbs_put16(&fr->data, 0x0003);
-	aimbs_put16(&fr->data, 0x0004);
-	aimbs_put16(&fr->data, 0x0005);
-
-	aim_tx_enqueue(sess, fr);
-
-	return 0;
-}
-
-/* 
  * aim_bos_setprivacyflags()
  *
  * Sets privacy flags. Normally 0x03.
@@ -312,42 +275,6 @@
 	return aim_genericreq_n(sess, conn, 0x0001, 0x000e);
 }
 
-faim_export int aim_setversions(aim_session_t *sess, aim_conn_t *conn)
-{
-	aim_conn_inside_t *ins = (aim_conn_inside_t *)conn->inside;
-	struct snacgroup *sg;
-	aim_frame_t *fr;
-	aim_snacid_t snacid;
-
-	if (!ins)
-		return -EINVAL;
-
-	if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 1152)))
-		return -ENOMEM;
-
-	snacid = aim_cachesnac(sess, 0x0001, 0x0017, 0x0000, NULL, 0);
-	aim_putsnac(&fr->data, 0x0001, 0x0017, 0x0000, snacid);
-
-	/*
-	 * Send only the versions that the server cares about (that it
-	 * marked as supporting in the server ready SNAC).  
-	 */
-	for (sg = ins->groups; sg; sg = sg->next) {
-		aim_module_t *mod;
-
-		if ((mod = aim__findmodulebygroup(sess, sg->group))) {
-			aimbs_put16(&fr->data, mod->family);
-			aimbs_put16(&fr->data, mod->version);
-		} else
-			faimdprintf(sess, 1, "aim_setversions: server supports group 0x%04x but we don't!\n", sg->group);
-	}
-
-	aim_tx_enqueue(sess, fr);
-
-	return 0;
-}
-
-
 /*
  * aim_bos_reqservice(serviceid)
  *
--- a/src/protocols/oscar/oscar.c	Mon Nov 05 11:33:50 2001 +0000
+++ b/src/protocols/oscar/oscar.c	Mon Nov 05 12:25:22 2001 +0000
@@ -229,15 +229,16 @@
 static int gaim_parse_searcherror(aim_session_t *, aim_frame_t *, ...);
 static int gaim_parse_searchreply(aim_session_t *, aim_frame_t *, ...);
 static int gaim_bosrights        (aim_session_t *, aim_frame_t *, ...);
-static int rateresp_bos     (aim_session_t *, aim_frame_t *, ...);
-static int rateresp_auth    (aim_session_t *, aim_frame_t *, ...);
+static int conninitdone_bos      (aim_session_t *sess, aim_frame_t *fr, ...);
+static int conninitdone_admin    (aim_session_t *sess, aim_frame_t *fr, ...);
+static int conninitdone_chat     (aim_session_t *sess, aim_frame_t *fr, ...);
+static int conninitdone_chatnav  (aim_session_t *sess, aim_frame_t *fr, ...);
 static int gaim_parse_msgerr     (aim_session_t *, aim_frame_t *, ...);
 static int gaim_parse_buddyrights(aim_session_t *, aim_frame_t *, ...);
 static int gaim_parse_locerr     (aim_session_t *, aim_frame_t *, ...);
 static int gaim_icbm_param_info  (aim_session_t *, aim_frame_t *, ...);
 static int gaim_parse_genericerr (aim_session_t *, aim_frame_t *, ...);
 static int gaim_memrequest       (aim_session_t *,  aim_frame_t*, ...);
-static int server_ready_bos      (aim_session_t *,  aim_frame_t*, ...);
 static int gaim_selfinfo         (aim_session_t *,  aim_frame_t*, ...);
 
 static int gaim_directim_initiate  (aim_session_t *, aim_frame_t *, ...);
@@ -649,11 +650,9 @@
 		return 0;
 	}
 
+	aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_bos, 0);
 	aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, gaim_bosrights, 0);
-	aim_conn_addhandler(sess, bosconn, 0x0001, 0x0007, rateresp_bos, 0); /* rate info */
 	aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0);
-	aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_SERVERREADY, server_ready_bos, 0);
-	aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATEINFO, NULL, 0);
 	aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, gaim_handle_redirect, 0);
 	aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_RIGHTSINFO, gaim_parse_buddyrights, 0);
 	aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, gaim_parse_oncoming, 0);
@@ -857,30 +856,18 @@
 	return 1;
 }
 
-static int server_ready_auth(aim_session_t *sess, aim_frame_t *fr, ...) {
-
-	aim_setversions(sess, fr->conn);
-	aim_reqrates(sess, fr->conn);
-	debug_printf("done with AUTH ServerReady\n");
-
-	return 1;
-}
-
-static int server_ready_bos(aim_session_t *sess, aim_frame_t *fr, ...) {
-	aim_setversions(sess, fr->conn);
-	aim_reqrates(sess, fr->conn); /* request rate info */
-	debug_printf("done with BOS ServerReady\n");
-
-	return 1;
-}
-
-static int rateresp_chat(aim_session_t *sess, aim_frame_t *fr, ...) {
+static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) {
 	struct gaim_connection *gc = sess->aux_data;
 	struct chat_connection *chatcon;
 	static int id = 1;
 
-	aim_ratesack(sess, fr->conn);
+	aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN, gaim_chat_join, 0);
+	aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE, gaim_chat_leave, 0);
+	aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE, gaim_chat_info_update, 0);
+	aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_chat_incoming_msg, 0);
+
 	aim_clientready(sess, fr->conn);
+
 	chatcon = find_oscar_chat_by_conn(gc, fr->conn);
 	chatcon->id = id;
 	chatcon->cnv = serv_got_joined_chat(gc, id++, chatcon->show);
@@ -888,35 +875,13 @@
 	return 1;
 }
 
-static int rateresp_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) {
-
-	aim_ratesack(sess, fr->conn);
-	aim_clientready(sess, fr->conn);
-	aim_chatnav_reqrights(sess, fr->conn);
-
-	return 1;
-}
-
-static int server_ready_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) {
-	debug_printf("chatnav: got server ready\n");
-	aim_conn_addhandler(sess, fr->conn, 0x0001, 0x0007, rateresp_chatnav, 0);
+static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) {
+
 	aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0);
-	aim_setversions(sess, fr->conn);
-	aim_reqrates(sess, fr->conn);
-
-	return 1;
-}
-
-static int server_ready_chat(aim_session_t *sess, aim_frame_t *fr, ...) {
-
-	debug_printf("chat: got server ready\n");
-	aim_conn_addhandler(sess, fr->conn, 0x0001, 0x0007, rateresp_chat, 0);
-	aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN, gaim_chat_join, 0);
-	aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE, gaim_chat_leave, 0);
-	aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE, gaim_chat_info_update, 0);
-	aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_chat_incoming_msg, 0);
-	aim_setversions(sess, fr->conn);
-	aim_reqrates(sess, fr->conn);
+
+	aim_clientready(sess, fr->conn);
+
+	aim_chatnav_reqrights(sess, fr->conn);
 
 	return 1;
 }
@@ -1050,8 +1015,7 @@
 			g_free(host);
 			return 1;
 		}
-		aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, server_ready_auth, 0);
-		aim_conn_addhandler(sess, tstconn, 0x0001, 0x0007, rateresp_auth, 0);
+		aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin, 0);
 		aim_conn_addhandler(sess, tstconn, 0x0007, 0x0003, gaim_info_change, 0);
 		aim_conn_addhandler(sess, tstconn, 0x0007, 0x0005, gaim_info_change, 0);
 		aim_conn_addhandler(sess, tstconn, 0x0007, 0x0007, gaim_account_confirm, 0);
@@ -1073,7 +1037,7 @@
 			g_free(host);
 			return 1;
 		}
-		aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, server_ready_chatnav, 0);
+		aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chatnav, 0);
 
 		tstconn->status |= AIM_CONN_STATUS_INPROGRESS;
 		tstconn->fd = proxy_connect(host, port, oscar_chatnav_connect, gc);
@@ -1101,7 +1065,8 @@
 			return 1;
 		}
 
-		aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, server_ready_chat, 0);
+		aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0);
+
 		ccon = g_new0(struct chat_connection, 1);
 		ccon->conn = tstconn;
 		ccon->gc = gc;
@@ -1934,10 +1899,9 @@
 	return 1;
 }
 
-static int rateresp_bos(aim_session_t *sess, aim_frame_t *fr, ...) {
+static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) {
 	struct gaim_connection *gc = sess->aux_data;
 
-	aim_ratesack(sess, fr->conn);
 	aim_bos_reqpersonalinfo(sess, fr->conn);
 	aim_bos_reqlocaterights(sess, fr->conn);
 	aim_bos_setprofile(sess, fr->conn, gc->user->user_info, NULL, gaim_caps);
@@ -1961,13 +1925,12 @@
 	return 1;
 }
 
-static int rateresp_auth(aim_session_t *sess, aim_frame_t *fr, ...) {
+static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) {
 	struct gaim_connection *gc = sess->aux_data;
 	struct oscar_data *od = gc->proto_data;
 
-	aim_ratesack(sess, fr->conn);
 	aim_clientready(sess, fr->conn);
-	debug_printf("connected to auth (admin)\n");
+	debug_printf("connected to admin\n");
 
 	if (od->chpass) {
 		debug_printf("changing password\n");
--- a/src/protocols/oscar/rxhandlers.c	Mon Nov 05 11:33:50 2001 +0000
+++ b/src/protocols/oscar/rxhandlers.c	Mon Nov 05 12:25:22 2001 +0000
@@ -370,6 +370,34 @@
 	return 1;
 }
 
+/*
+ * Some SNACs we do not allow to be hooked, for good reason.
+ */
+static int checkdisallowed(fu16_t group, fu16_t type)
+{
+	static const struct {
+		fu16_t group;
+		fu16_t type;
+	} dontuse[] = {
+		{0x0001, 0x0002},
+		{0x0001, 0x0003},
+		{0x0001, 0x0006},
+		{0x0001, 0x0007},
+		{0x0001, 0x0008},
+		{0x0001, 0x0017},
+		{0x0001, 0x0018},
+		{0x0000, 0x0000}
+	};
+	int i;
+
+	for (i = 0; dontuse[i].group != 0x0000; i++) {
+		if ((dontuse[i].group == group) && (dontuse[i].type == type))
+			return 1;
+	}
+
+	return 0;
+}
+
 faim_export int aim_conn_addhandler(aim_session_t *sess, aim_conn_t *conn, fu16_t family, fu16_t type, aim_rxcallback_t newhandler, fu16_t flags)
 {
 	struct aim_rxcblist_s *newcb;
@@ -379,6 +407,11 @@
 
 	faimdprintf(sess, 1, "aim_conn_addhandler: adding for %04x/%04x\n", family, type);
 
+	if (checkdisallowed(family, type)) {
+		faimdprintf(sess, 0, "aim_conn_addhandler: client tried to hook %x/%x -- BUG!!!\n", family, type);
+		return -1;
+	}
+
 	if (!(newcb = (struct aim_rxcblist_s *)calloc(1, sizeof(struct aim_rxcblist_s))))
 		return -1;