[Freeswitch-svn] [commit] r5005 - in freeswitch/trunk: libs/iksemel/src libs/libdingaling/src src/mod/endpoints/mod_dingaling

Freeswitch SVN anthm at freeswitch.org
Mon Apr 23 15:03:06 EDT 2007


Author: anthm
Date: Mon Apr 23 15:03:06 2007
New Revision: 5005

Modified:
   freeswitch/trunk/libs/iksemel/src/iks.c
   freeswitch/trunk/libs/iksemel/src/io-posix.c
   freeswitch/trunk/libs/libdingaling/src/libdingaling.c
   freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c

Log:
update dingaling

Modified: freeswitch/trunk/libs/iksemel/src/iks.c
==============================================================================
--- freeswitch/trunk/libs/iksemel/src/iks.c	(original)
+++ freeswitch/trunk/libs/iksemel/src/iks.c	Mon Apr 23 15:03:06 2007
@@ -379,7 +379,7 @@
 iks_name (iks *x)
 {
 	if (x) {
-		if (IKS_TAG == x->type)
+		if (IKS_TAG == x->type) 
 			return IKS_TAG_NAME (x);
 		else
 			return IKS_ATTRIB_NAME (x);

Modified: freeswitch/trunk/libs/iksemel/src/io-posix.c
==============================================================================
--- freeswitch/trunk/libs/iksemel/src/io-posix.c	(original)
+++ freeswitch/trunk/libs/iksemel/src/io-posix.c	Mon Apr 23 15:03:06 2007
@@ -110,8 +110,36 @@
 	tv.tv_sec = timeout;
 	if (timeout != -1) tvptr = &tv; else tvptr = NULL;
 	if (select (sock + 1, &fds, NULL, NULL, tvptr) > 0) {
+		memset(buffer, 0, buf_len);
 		len = recv (sock, buffer, buf_len, 0);
 		if (len > 0) {
+			char *p, *e = NULL, *t = NULL;
+			for (p = buffer; p && *p; p++) {
+
+				if (*p == '>') {
+					e = p;
+					t = p+1;
+					if (*t == '<') {
+						continue;
+					}
+					while(t && *t) {
+						if (*t != ' ' && *t != '<') {
+							t = e = NULL;
+							break;
+						}
+						if (*t == '<') {
+							p = t;
+							*(p-1) = '>';
+							*e = ' ';
+							e = NULL;
+							break;
+						}
+
+						t++;
+
+					}
+				}
+			}
 			return len;
 		} else if (len <= 0) {
 			return -1;

Modified: freeswitch/trunk/libs/libdingaling/src/libdingaling.c
==============================================================================
--- freeswitch/trunk/libs/libdingaling/src/libdingaling.c	(original)
+++ freeswitch/trunk/libs/libdingaling/src/libdingaling.c	Mon Apr 23 15:03:06 2007
@@ -175,6 +175,7 @@
 typedef struct ldl_feature ldl_feature_t;
 
 #define FEATURE_DISCO "http://jabber.org/protocol/disco"
+#define FEATURE_DISCO_INFO "http://jabber.org/protocol/disco#info"
 #define FEATURE_VERSION "jabber:iq:version"
 #define FEATURE_VCARD "vcard-temp"
 #define FEATURE_VOICE "http://www.google.com/xmpp/protocol/voice/v1"
@@ -182,6 +183,7 @@
 
 static ldl_feature_t FEATURES[] = { 
 	{ FEATURE_DISCO, on_disco_default },
+	{ FEATURE_DISCO_INFO, on_disco_default },
 	{ FEATURE_VERSION, on_disco_default },
 	{ FEATURE_VCARD, on_vcard},
 	{ FEATURE_VOICE, on_disco_default },
@@ -414,11 +416,11 @@
 				dl_signal = LDL_SIGNAL_TRANSPORT_ACCEPT;
 			} else if (!strcasecmp(type, "reject")) {
 				dl_signal = LDL_SIGNAL_REJECT;
-			} else if (!strcasecmp(type, "transport-info")) {
+			} else if (!strcasecmp(type, "transport-info") || !strcasecmp(type, "candidates")) {
 				char *tid = iks_find_attrib(xml, "id");
 				dl_signal = LDL_SIGNAL_CANDIDATES;
 				tag = iks_child (xml);
-				
+				id = type;
 				if (tag && !strcasecmp(iks_name(tag), "transport")) {
 					tag = iks_child(tag);
 				}
@@ -560,7 +562,7 @@
 	} else if (pak->subtype == IKS_TYPE_GET) {
 		if ((iq = iks_new("iq"))) {
 			int all = 0;
-
+			
 			iks_insert_attrib(iq, "from", handle->login);
 			iks_insert_attrib(iq, "to", pak->from->full);
 			iks_insert_attrib(iq, "id", pak->id);
@@ -578,15 +580,32 @@
 			if (!(tag = iks_insert (query, "identity"))) {
 				goto fail;
 			}
-			
-			if (!strcasecmp(ns, FEATURE_DISCO) && !node) {
-				all++;
-			}
 
 			iks_insert_attrib(tag, "category", "gateway");
-			iks_insert_attrib(tag, "type", "voice");
+			//iks_insert_attrib(tag, "type", "voice");
 			iks_insert_attrib(tag, "name", "LibDingaLing");
-
+			
+			if (!strcasecmp(ns, FEATURE_DISCO_INFO)) {
+				if (!node) {
+					all++;
+				} else {
+					char *p;
+
+					if ((p = strstr(node, "caps#"))) {
+						char *what = p + 5;
+
+						if (!strcasecmp(what, "voice-v1")) {
+							if (!(tag = iks_insert (query, "feature"))) {
+								goto fail;
+							}
+							iks_insert_attrib(tag, "var", FEATURE_VOICE);
+							goto done;
+						}
+						
+					}
+				}
+			}
+			
 			for (x = 0; FEATURES[x].name; x++) {
 				if (all || !ns || !strcasecmp(ns, FEATURES[x].name)) {
 					if (!(tag = iks_insert (query, "feature"))) {
@@ -595,6 +614,9 @@
 					iks_insert_attrib(tag, "var", FEATURES[x].name);
 				}
 			}
+
+		done:
+
 			apr_queue_push(handle->queue, iq);
 			iq = NULL;
 			send = 1;
@@ -625,7 +647,7 @@
 	char *resource;
 	struct ldl_buffer *buffer;
 	ldl_signal_t dl_signal = LDL_SIGNAL_PRESENCE_IN;
-
+	
 
 
     if (type && *type) {
@@ -661,7 +683,7 @@
 		}
 	}
 
-	if (resource && strstr(resource, "talk") && (buffer = apr_hash_get(handle->probe_hash, id, APR_HASH_KEY_STRING))) {
+	if (resource && (strstr(resource, "talk") || strstr(resource, "telepathy")) && (buffer = apr_hash_get(handle->probe_hash, id, APR_HASH_KEY_STRING))) {
 		apr_cpystrn(buffer->buf, from, buffer->len);
 		fflush(stderr);
 		buffer->hit = 1;
@@ -1857,7 +1879,7 @@
 		iq = NULL;
 		sess = NULL;
 		id = 0;
-
+		
 		new_session_iq(session, &iq, &sess, &id, "transport-info");
 		tag = iks_insert(sess, "transport");
 		iks_insert_attrib(tag, "xmlns", "http://www.google.com/transport/p2p");

Modified: freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c	Mon Apr 23 15:03:06 2007
@@ -1700,12 +1700,20 @@
 				user = ldl_handle_get_login(mdl_profile->handle);
 			} else {
 				if (!user) {
-					if (strchr(outbound_profile->caller_id_number, '@')) {
-						snprintf(ubuf, sizeof(ubuf), "%s/talk", outbound_profile->caller_id_number);
+					char *id_num;
+					
+					if (!(id_num = outbound_profile->caller_id_number)) {
+						if (!(id_num = outbound_profile->caller_id_name)) {
+							id_num = "nobody";
+						}
+					}
+
+					if (strchr(id_num, '@')) {
+						snprintf(ubuf, sizeof(ubuf), "%s/talk", id_num);
 						user = ubuf;
 					} else {
-						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Invalid User!\n");
-						terminate_session(new_session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+						snprintf(ubuf, sizeof(ubuf), "%s@%s/talk", id_num, profile_name);
+						user = ubuf;
 					}
 				}
 			}
@@ -2871,14 +2879,27 @@
 
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "candidates %s:%d\n", candidates[x].address, candidates[x].port);
 
-				if (!strcasecmp(candidates[x].protocol, "udp") && (!strcasecmp(candidates[x].type, "local") || !strcasecmp(candidates[x].type, "stun")) && ((profile->lanaddr && lanaddr) || (strncasecmp(candidates[x].address, "10.", 3) && strncasecmp(candidates[x].address, "192.168.", 8) && strncasecmp(candidates[x].address, "127.", 4) && strncasecmp(candidates[x].address, "255.", 4) && strncasecmp(candidates[x].address, "0.", 2) && strncasecmp(candidates[x].address, "1.", 2) && strncasecmp(candidates[x].address, "2.", 2) && strncasecmp(candidates[x].address, "172.16.", 7) && strncasecmp(candidates[x].address, "172.17.", 7) && strncasecmp(candidates[x].address, "172.18.", 7) && strncasecmp(candidates[x].address, "172.19.", 7) && strncasecmp(candidates[x].address, "172.2", 5) && strncasecmp(candidates[x].address, "172.30.", 7) && strncasecmp(candidates[x].address, "172.31.", 7) && strncasecmp(candidates[x].address, "192.0.2.", 8) &&	// 192.0.0.0 - 192.0.127.255 is marked as reserved, should we filter all of them?
-																																															  strncasecmp
-																																															  (candidates
-																																															   [x].
-																																															   address,
-																																															   "169.254.",
-																																															   8)
-																																															  ))) {
+				// 192.0.0.0 - 192.0.127.255 is marked as reserved, should we filter all of them?
+				if (!strcasecmp(candidates[x].protocol, "udp") &&
+					(!strcasecmp(candidates[x].type, "local") || !strcasecmp(candidates[x].type, "stun")) &&
+					((profile->lanaddr &&
+					  lanaddr) || (strncasecmp(candidates[x].address, "10.", 3) &&
+								   strncasecmp(candidates[x].address, "192.168.", 8) &&
+								   strncasecmp(candidates[x].address, "127.", 4) &&
+								   strncasecmp(candidates[x].address, "255.", 4) &&
+								   strncasecmp(candidates[x].address, "0.", 2) &&
+								   strncasecmp(candidates[x].address, "1.", 2) &&
+								   strncasecmp(candidates[x].address, "2.", 2) &&
+								   strncasecmp(candidates[x].address, "172.16.", 7) &&
+								   strncasecmp(candidates[x].address, "172.17.", 7) &&
+								   strncasecmp(candidates[x].address, "172.18.", 7) &&
+								   strncasecmp(candidates[x].address, "172.19.", 7) &&
+								   strncasecmp(candidates[x].address, "172.2", 5) &&
+								   strncasecmp(candidates[x].address, "172.30.", 7) &&
+								   strncasecmp(candidates[x].address, "172.31.", 7) &&
+								   strncasecmp(candidates[x].address, "192.0.2.", 8) &&
+								   strncasecmp(candidates[x].address, "169.254.", 8)
+								   ))) {
 					ldl_payload_t payloads[5];
 
 					memset(payloads, 0, sizeof(payloads));
@@ -2890,6 +2911,11 @@
 						ldl_session_accept_candidate(dlsession, &candidates[x]);
 					}
 
+					if (!strcasecmp(subject, "candidates")) {
+						switch_set_flag_locked(tech_pvt, TFLAG_TRANSPORT_ACCEPT);
+						switch_set_flag_locked(tech_pvt, TFLAG_ANSWER);
+					}
+
 					if (lanaddr) {
 						switch_set_flag_locked(tech_pvt, TFLAG_LANADDR);
 					}



More information about the Freeswitch-svn mailing list