diff options
author | dbrooks <dbrooks@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-03-31 17:36:07 +0000 |
---|---|---|
committer | dbrooks <dbrooks@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-03-31 17:36:07 +0000 |
commit | a1d2fc7ba50afb44161a919fb4a84b3e8fa4fc0d (patch) | |
tree | 413660f9ec6bc90fa23dfbfc77c5933677006ed0 | |
parent | 32a1f4566273874e61b02e84187e949dfafb8be2 (diff) |
Merged revisions 185363 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r185363 | dbrooks | 2009-03-31 11:46:57 -0500 (Tue, 31 Mar 2009) | 44 lines
Merged revisions 185362 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r185362 | dbrooks | 2009-03-31 11:37:12 -0500 (Tue, 31 Mar 2009) | 35 lines
Fix incorrect parsing in chan_gtalk when xmpp contains extra whitespaces
To drill into the xmpp to find the capabilities between channels, chan_gtalk
calls iks_child() and iks_next(). iks_child() and iks_next() are functions in
the iksemel xml parsing library that traverse xml nodes. The bug here is that
both iks_child() and iks_next() will return the next iks_struct node
*regardless* of type. chan_gtalk expects the next node to be of type IKS_TAG,
which in most cases, it is, but in this case (a call being made from the
Empathy IM client), there exists iks_struct nodes which are not IKS_TAG data
(they are extraneous whitespaces), and chan_gtalk doesn't handle that case,
so capabilities don't match, and a call cannot be made.
iks_first_tag() and iks_next_tag(), on the other hand, will not return the
very next iks_struct, but will check to see if the next iks_struct is of
type IKS_TAG. If it isn't, it will be skipped, and the next struct of type
IKS_TAG it finds will be returned. This assures that chan_gtalk will find
the iks_struct it is looking for.
This fix simply changes all calls to iks_child() and iks_next() to become
calls to iks_first_tag() and iks_next_tag(), which resolves the capability
matching.
The following is a payload listing from Empathy, which, due to the extraneous
whitespace, will not be parsed correctly by iksemel:
<iq from='dbrooksjab@235-22-24-10/Telepathy' to='astjab@235-22-24-10/asterisk' type='set' id='542757715704'> <session xmlns='http://www.google.com/session' initiator='dbrooksjab@235-22-24-10/Telepathy' type='initiate' id='1837267342'> <description xmlns='http://www.google.com/session/phone'> <payload-type clockrate='16000' name='speex' id='96'/>
<payload-type clockrate='8000' name='PCMA' id='8'/>
<payload-type clockrate='8000' name='PCMU' id='0'/>
<payload-type clockrate='90000' name='MPA' id='97'/>
<payload-type clockrate='16000' name='SIREN' id='98'/>
<payload-type clockrate='8000' name='telephone-event' id='99'/>
</description>
</session>
</iq>
Review: http://reviewboard.digium.com/r/181/
........
................
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.0@185426 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r-- | channels/chan_gtalk.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/channels/chan_gtalk.c b/channels/chan_gtalk.c index 175b3b75a..884438316 100644 --- a/channels/chan_gtalk.c +++ b/channels/chan_gtalk.c @@ -614,11 +614,11 @@ static int gtalk_is_answered(struct gtalk *client, ikspak *pak) } /* codec points to the first <payload-type/> tag */ - codec = iks_child(iks_child(iks_child(pak->x))); + codec = iks_first_tag(iks_first_tag(iks_first_tag(pak->x))); while (codec) { ast_rtp_set_m_type(tmp->rtp, atoi(iks_find_attrib(codec, "id"))); ast_rtp_set_rtpmap_type(tmp->rtp, atoi(iks_find_attrib(codec, "id")), "audio", iks_find_attrib(codec, "name"), 0); - codec = iks_next(codec); + codec = iks_next_tag(codec); } /* Now gather all of the codecs that we are asked for */ @@ -1201,12 +1201,12 @@ static int gtalk_newcall(struct gtalk *client, ikspak *pak) } /* codec points to the first <payload-type/> tag */ - codec = iks_child(iks_child(iks_child(pak->x))); + codec = iks_first_tag(iks_first_tag(iks_first_tag(pak->x))); while (codec) { ast_rtp_set_m_type(p->rtp, atoi(iks_find_attrib(codec, "id"))); ast_rtp_set_rtpmap_type(p->rtp, atoi(iks_find_attrib(codec, "id")), "audio", iks_find_attrib(codec, "name"), 0); - codec = iks_next(codec); + codec = iks_next_tag(codec); } /* Now gather all of the codecs that we are asked for */ @@ -1320,11 +1320,11 @@ static int gtalk_add_candidate(struct gtalk *client, ikspak *pak) traversenodes = pak->query; while(traversenodes) { if(!strcasecmp(iks_name(traversenodes), "session")) { - traversenodes = iks_child(traversenodes); + traversenodes = iks_first_tag(traversenodes); continue; } if(!strcasecmp(iks_name(traversenodes), "transport")) { - traversenodes = iks_child(traversenodes); + traversenodes = iks_first_tag(traversenodes); continue; } if(!strcasecmp(iks_name(traversenodes), "candidate")) { @@ -1363,7 +1363,7 @@ static int gtalk_add_candidate(struct gtalk *client, ikspak *pak) gtalk_update_stun(p->parent, p); newcandidate = NULL; } - traversenodes = iks_next(traversenodes); + traversenodes = iks_next_tag(traversenodes); } receipt = iks_new("iq"); |