Review Board 1.7.16


Workaround for Google Talk protocol change

Review Request #1312 - Created July 6, 2011 and submitted

Terry Wilson
1.8
Reviewers
asterisk-dev
dvossel
Asterisk
Calls from a GMail client now offer both a jingle session and the old-style session. This patch detects this and ignores the jingle session and uses the other session instead.

It looks like they are now trying to use the actual Jingle spec, so we will want to take a look at writing a parser for that once they start using it for both GTalk and Google Voice. There are some differences with the temporary one that chan_jingle uses.

This fix is a little hacky, but that is just how it goes until they actually switch to "Real Jingle" everywhere.
I made inbound and outbound GTalk and Google Voice calls and they all rang through.
/branches/1.8/channels/chan_gtalk.c
Revision 326513 New Change
[20] 1292 lines
[+20] [+] static int gtalk_newcall(struct gtalk *client, ikspak *pak)
1293
	ast_mutex_lock(&p->lock);
1293
	ast_mutex_lock(&p->lock);
1294
	ast_copy_string(p->them, pak->from->full, sizeof(p->them));
1294
	ast_copy_string(p->them, pak->from->full, sizeof(p->them));
1295
	ast_copy_string(p->sid, sid, sizeof(p->sid));
1295
	ast_copy_string(p->sid, sid, sizeof(p->sid));
1296

    
   
1296

   
1297
	/* codec points to the first <payload-type/> tag */
1297
	/* codec points to the first <payload-type/> tag */
1298
	codec = iks_first_tag(iks_first_tag(iks_first_tag(pak->x)));
1298
	codec = iks_first_tag(iks_first_tag(pak->query));
1299

    
   
1299

   
1300
	while (codec) {
1300
	while (codec) {
1301
		char *codec_id = iks_find_attrib(codec, "id");
1301
		char *codec_id = iks_find_attrib(codec, "id");
1302
		char *codec_name = iks_find_attrib(codec, "name");
1302
		char *codec_name = iks_find_attrib(codec, "name");
1303
		if (!codec_id || !codec_name) {
1303
		if (!codec_id || !codec_name) {
[+20] [20] 666 lines
[+20] [+] static char *gtalk_do_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
1970

    
   
1970

   
1971
static int gtalk_parser(void *data, ikspak *pak)
1971
static int gtalk_parser(void *data, ikspak *pak)
1972
{
1972
{
1973
	struct gtalk *client = ASTOBJ_REF((struct gtalk *) data);
1973
	struct gtalk *client = ASTOBJ_REF((struct gtalk *) data);
1974
	int res;
1974
	int res;

    
   
1975
	iks *tmp;

    
   
1976

   

    
   
1977
	if (!strcasecmp(iks_name(pak->query), "jin:jingle") && (tmp = iks_next(pak->query)) && !strcasecmp(iks_name(tmp), "ses:session")) {

    
   
1978
		ast_debug(1, "New method detected. Skipping jingle offer and using old gtalk method.\n");

    
   
1979
		pak->query = tmp;

    
   
1980
	}
1975

    
   
1981

   
1976
	if (!strcmp(S_OR(iks_find_attrib(pak->x, "type"), ""), "error")) {
1982
	if (!strcmp(S_OR(iks_find_attrib(pak->x, "type"), ""), "error")) {
1977
		ast_log(LOG_NOTICE, "Remote peer reported an error, trying to establish the call anyway\n");
1983
		ast_log(LOG_NOTICE, "Remote peer reported an error, trying to establish the call anyway\n");
1978
	}
1984
	}
1979

    
   
1985

   
[+20] [20] 169 lines
[+20] [+] static int gtalk_load_config(void)
2149
					ASTOBJ_CONTAINER_TRAVERSE(clients, 1, {
2155
					ASTOBJ_CONTAINER_TRAVERSE(clients, 1, {
2150
						ASTOBJ_WRLOCK(iterator);
2156
						ASTOBJ_WRLOCK(iterator);
2151
						ASTOBJ_WRLOCK(member);
2157
						ASTOBJ_WRLOCK(member);
2152
						member->connection = NULL;
2158
						member->connection = NULL;
2153
						iks_filter_add_rule(iterator->f, gtalk_parser, member, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_NS, GOOGLE_NS, IKS_RULE_DONE);
2159
						iks_filter_add_rule(iterator->f, gtalk_parser, member, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_NS, GOOGLE_NS, IKS_RULE_DONE);

    
   
2160
						iks_filter_add_rule(iterator->f, gtalk_parser, member, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_NS, GOOGLE_JINGLE_NS, IKS_RULE_DONE);
2154
						iks_filter_add_rule(iterator->f, gtalk_parser, member, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_NS, "http://jabber.org/protocol/gtalk", IKS_RULE_DONE);
2161
						iks_filter_add_rule(iterator->f, gtalk_parser, member, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_NS, "http://jabber.org/protocol/gtalk", IKS_RULE_DONE);
2155
						ASTOBJ_UNLOCK(member);
2162
						ASTOBJ_UNLOCK(member);
2156
						ASTOBJ_UNLOCK(iterator);
2163
						ASTOBJ_UNLOCK(iterator);
2157
					});
2164
					});
2158
					ASTOBJ_CONTAINER_LINK(&gtalk_list, member);
2165
					ASTOBJ_CONTAINER_LINK(&gtalk_list, member);
[+20] [20] 118 lines
/branches/1.8/include/asterisk/jingle.h
Revision 326513 New Change
 
  1. /branches/1.8/channels/chan_gtalk.c: Loading...
  2. /branches/1.8/include/asterisk/jingle.h: Loading...

https://reviewboard.asterisk.org/ runs on a server provided by Digium, Inc. and uses bandwidth donated to the open source Asterisk community by API Digital Communications in Huntsville, AL USA.
Please report problems with this site to asteriskteam@digium.com.