changeset 8840:01c3db200c8f

[gaim-migrate @ 9607] Some good rendezvous fixes. Now if I could just find out why iTunes complains that it can't access my mp3 server when I sign on with Gaim... And 0 is a valid file descriptor. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Wed, 28 Apr 2004 04:38:12 +0000
parents ebbc39e0050d
children ea2e2119b135
files pixmaps/smileys/none/.cvsignore src/network.c src/protocols/rendezvous/mdns.c src/protocols/rendezvous/mdns_cache.c src/protocols/rendezvous/rendezvous.c
diffstat 5 files changed, 32 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pixmaps/smileys/none/.cvsignore	Wed Apr 28 04:38:12 2004 +0000
@@ -0,0 +1,3 @@
+Makefile.in
+Makefile
+.xvpics
--- a/src/network.c	Wed Apr 28 03:57:42 2004 +0000
+++ b/src/network.c	Wed Apr 28 04:38:12 2004 +0000
@@ -83,7 +83,7 @@
 	static char ip[16];
 	const char *tmp;
 
-	g_return_val_if_fail(fd > 0, NULL);
+	g_return_val_if_fail(fd >= 0, NULL);
 
 	len = sizeof(addr);
 	if (getsockname(fd, (struct sockaddr *) &addr, &len) == -1) {
@@ -106,7 +106,7 @@
 	static char ip[46];
 	const char *tmp = NULL;
 
-	if (fd != -1)
+	if (fd >= 0)
 		tmp = gaim_network_get_local_ip_from_fd(fd);
 
 	if (tmp)
--- a/src/protocols/rendezvous/mdns.c	Wed Apr 28 03:57:42 2004 +0000
+++ b/src/protocols/rendezvous/mdns.c	Wed Apr 28 04:38:12 2004 +0000
@@ -514,7 +514,12 @@
 static int
 mdns_getlength_rr(const ResourceRecord *rr)
 {
-	return mdns_getlength_name(rr->name) + 10 + rr->rdlength;
+	int rdlength = mdns_getlength_rr_rdata(rr->type, rr->rdata);
+
+	if ((rdlength == 0) && (rr->rdata != NULL))
+		rdlength = rr->rdlength;
+
+	return mdns_getlength_name(rr->name) + 10 + rdlength;
 }
 
 /**
@@ -808,9 +813,8 @@
 	int ret;
 	ResourceRecord *rr;
 
-	if ((name == NULL) || (strlen(name) > 255)) {
-		return -EINVAL;
-	}
+	g_return_val_if_fail(name != NULL, -EINVAL);
+	g_return_val_if_fail(strlen(name) <= 255, -EINVAL);
 
 	rr = (ResourceRecord *)g_malloc(sizeof(ResourceRecord));
 	rr->name = g_strdup(name);
@@ -833,9 +837,10 @@
 	int ret;
 	ResourceRecord *rr;
 
-	if ((name == NULL) || (strlen(name) > 255) || (domain == NULL) || (strlen(domain) > 255)) {
-		return -EINVAL;
-	}
+	g_return_val_if_fail(name != NULL, -EINVAL);
+	g_return_val_if_fail(strlen(name) <= 255, -EINVAL);
+	g_return_val_if_fail(domain != NULL, -EINVAL);
+	g_return_val_if_fail(strlen(domain) <= 255, -EINVAL);
 
 	rr = (ResourceRecord *)g_malloc(sizeof(ResourceRecord));
 	rr->name = g_strdup(name);
@@ -858,9 +863,8 @@
 	int ret;
 	ResourceRecord *rr;
 
-	if ((name == NULL) || (strlen(name) > 255)) {
-		return -EINVAL;
-	}
+	g_return_val_if_fail(name != NULL, -EINVAL);
+	g_return_val_if_fail(strlen(name) <= 255, -EINVAL);
 
 	rr = (ResourceRecord *)g_malloc(sizeof(ResourceRecord));
 	rr->name = g_strdup(name);
@@ -885,9 +889,8 @@
 	ResourceRecordRDataA *rdata;
 	int i;
 
-	if ((name == NULL) || (strlen(name) > 255)) {
-		return -EINVAL;
-	}
+	g_return_val_if_fail(name != NULL, -EINVAL);
+	g_return_val_if_fail(strlen(name) <= 255, -EINVAL);
 
 	rdata = g_malloc(16);
 	for (i = 0; i < 16; i++)
@@ -915,9 +918,8 @@
 	ResourceRecord *rr;
 	ResourceRecordRDataSRV *rdata;
 
-	if ((target == NULL) || (strlen(target) > 255)) {
-		return -EINVAL;
-	}
+	g_return_val_if_fail(name != NULL, -EINVAL);
+	g_return_val_if_fail(strlen(name) <= 255, -EINVAL);
 
 	rdata = g_malloc(sizeof(ResourceRecordRDataSRV));
 	rdata->port = port;
--- a/src/protocols/rendezvous/mdns_cache.c	Wed Apr 28 03:57:42 2004 +0000
+++ b/src/protocols/rendezvous/mdns_cache.c	Wed Apr 28 04:38:12 2004 +0000
@@ -84,6 +84,7 @@
 mdns_cache_remove_all()
 {
 	mdns_free_rrs(rrs);
+	rrs = NULL;
 }
 
 void
@@ -97,9 +98,9 @@
 
 	for (slist = rrs; slist != NULL; slist = slist->next) {
 		cur = slist->data;
-		if ((q->type == cur->type) && (!strcmp(q->name, cur->name))) {
+		if (((q->type == RENDEZVOUS_RRTYPE_ALL) || (q->type == cur->type)) && (!strcmp(q->name, cur->name))) {
 			printf("responding to cur->type=%d, cur->name=%s\n", cur->type, cur->name);
-			//mdns_send_rr(fd, cur);
+			mdns_send_rr(fd, cur);
 		}
 	}
 }
--- a/src/protocols/rendezvous/rendezvous.c	Wed Apr 28 03:57:42 2004 +0000
+++ b/src/protocols/rendezvous/rendezvous.c	Wed Apr 28 04:38:12 2004 +0000
@@ -487,12 +487,16 @@
 	GaimAccount *account = gaim_connection_get_account(gc);
 	const gchar *me;
 	gchar *myname, *mycomp;
-	const unsigned char *myip;
+	unsigned char myip[4];
 
 	me = gaim_account_get_username(account);
 	myname = g_strdup_printf("%s._presence._tcp.local", me);
 	mycomp = g_strdup_printf("%s.local", strchr(me, '@') + 1);
-	myip = gaim_network_ip_atoi(gaim_network_get_local_system_ip(rd->fd));
+	/* myip = gaim_network_ip_atoi(gaim_network_get_local_system_ip(-1)); */
+	myip[0] = 192;
+	myip[1] = 168;
+	myip[2] = 1;
+	myip[3] = 41;
 
 	mdns_advertise_a(rd->fd, mycomp, myip);
 	mdns_advertise_ptr(rd->fd, "_presence._tcp.local", myname);