]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 139281,175058,175089 via svnmerge from
authorTilghman Lesher <tilghman@meg.abyt.es>
Tue, 15 Sep 2009 21:53:03 +0000 (21:53 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Tue, 15 Sep 2009 21:53:03 +0000 (21:53 +0000)
https://origsvn.digium.com/svn/asterisk/trunk
(closes issue #13985)

................
  r139281 | phsultan | 2008-08-21 04:55:31 -0500 (Thu, 21 Aug 2008) | 5 lines

  Fix two memory leaks in chan_gtalk, thanks Eliel!
  (closes issue #13310)
  Reported by: eliel
  Patches:
        chan_gtalk.c.patch uploaded by eliel (license 64)
................
  r175058 | phsultan | 2009-02-12 04:31:36 -0600 (Thu, 12 Feb 2009) | 20 lines

  Merged revisions 175029 via svnmerge from
  https://origsvn.digium.com/svn/asterisk/branches/1.4

  ........
  r175029 | phsultan | 2009-02-12 11:16:21 +0100 (Thu, 12 Feb 2009) | 12 lines

  Set the initiator attribute to lowercase in our replies when receiving calls.

  This attribute contains a JID that identifies the initiator of the GoogleTalk
  voice session. The GoogleTalk client discards Asterisk's replies if the
  initiator attribute contains uppercase characters.

  (closes issue #13984)
  Reported by: jcovert
  Patches:
        chan_gtalk.2.patch uploaded by jcovert (license 551)
  Tested by: jcovert

  ........
................
  r175089 | phsultan | 2009-02-12 08:25:03 -0600 (Thu, 12 Feb 2009) | 6 lines

  Issue a warning message if our candidate's IP is the loopback address.

  (closes issue #13985)
  Reported by: jcovert
  Tested by: phsultan
................

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.1@218727 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_gtalk.c

index c8ba3319310b313088dd2eaeee7a369368985b8f..e1743666b884e034e97c046f6711bf3bfedfdc29 100644 (file)
@@ -43,6 +43,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include <sys/signal.h>
 #include <iksemel.h>
 #include <pthread.h>
+#include <ctype.h>
 
 #include "asterisk/lock.h"
 #include "asterisk/channel.h"
@@ -382,6 +383,7 @@ static int gtalk_invite(struct gtalk_pvt *p, char *to, char *from, char *sid, in
        int pref_codec = 0;
        int alreadysent = 0;
        int codecs_num = 0;
+       char *lowerto = NULL;
 
        iq = iks_new("iq");
        gtalk = iks_new("session");
@@ -428,7 +430,14 @@ static int gtalk_invite(struct gtalk_pvt *p, char *to, char *from, char *sid, in
 
        iks_insert_attrib(gtalk, "xmlns", "http://www.google.com/session");
        iks_insert_attrib(gtalk, "type",initiator ? "initiate": "accept");
-       iks_insert_attrib(gtalk, "initiator", initiator ? from : to);
+       /* put the initiator attribute to lower case if we receive the call 
+        * otherwise GoogleTalk won't establish the session */
+       if (!initiator) {
+               char c;
+               char *t = lowerto = ast_strdupa(to);
+               while (((c = *t) != '/') && (*t++ = tolower(c)));
+       }
+       iks_insert_attrib(gtalk, "initiator", initiator ? from : lowerto);
        iks_insert_attrib(gtalk, "id", sid);
        iks_insert_node(iq, gtalk);
        iks_insert_node(gtalk, dcodecs);
@@ -448,6 +457,8 @@ static int gtalk_invite(struct gtalk_pvt *p, char *to, char *from, char *sid, in
 static int gtalk_invite_response(struct gtalk_pvt *p, char *to , char *from, char *sid, int initiator)
 {
        iks *iq, *session, *transport;
+       char *lowerto = NULL;
+
        iq = iks_new("iq");
        session = iks_new("session");
        transport = iks_new("transport");
@@ -465,7 +476,14 @@ static int gtalk_invite_response(struct gtalk_pvt *p, char *to , char *from, cha
        ast_aji_increment_mid(p->parent->connection->mid);
        iks_insert_attrib(session, "type", "transport-accept");
        iks_insert_attrib(session, "id", sid);
-       iks_insert_attrib(session, "initiator", initiator ? from : to);
+       /* put the initiator attribute to lower case if we receive the call 
+        * otherwise GoogleTalk won't establish the session */
+       if (!initiator) {
+               char c;
+               char *t = lowerto = ast_strdupa(to);
+               while (((c = *t) != '/') && (*t++ = tolower(c)));
+       }
+       iks_insert_attrib(session, "initiator", initiator ? from : lowerto);
        iks_insert_attrib(session, "xmlns", "http://www.google.com/session");
        iks_insert_attrib(transport, "xmlns", "http://www.google.com/transport/p2p");
        iks_insert_node(iq,session);
@@ -761,6 +779,7 @@ static int gtalk_create_candidates(struct gtalk *client, struct gtalk_pvt *p, ch
        struct in_addr us;
        iks *iq, *gtalk, *candidate, *transport;
        char user[17], pass[17], preference[5], port[7];
+       char *lowerfrom = NULL;
 
 
        iq = iks_new("iq");
@@ -793,6 +812,9 @@ static int gtalk_create_candidates(struct gtalk *client, struct gtalk_pvt *p, ch
 
        ast_rtp_get_us(p->rtp, &sin);
        ast_find_ourip(&us, bindaddr);
+       if (!strcmp(ast_inet_ntoa(us), "127.0.0.1")) {
+               ast_log(LOG_WARNING, "Found a loopback IP on the system, check your network configuration or set the bindaddr attribute.");
+       }
 
        /* Setup our gtalk candidates */
        ast_copy_string(ours1->name, "rtp", sizeof(ours1->name));
@@ -839,7 +861,14 @@ static int gtalk_create_candidates(struct gtalk *client, struct gtalk_pvt *p, ch
                ast_aji_increment_mid(c->mid);
                iks_insert_attrib(gtalk, "type", "transport-info");
                iks_insert_attrib(gtalk, "id", sid);
-               iks_insert_attrib(gtalk, "initiator", (p->initiator) ? to : from);
+               /* put the initiator attribute to lower case if we receive the call 
+                * otherwise GoogleTalk won't establish the session */
+               if (!p->initiator) {
+                       char c;
+                       char *t = lowerfrom = ast_strdupa(from);
+                       while (((c = *t) != '/') && (*t++ = tolower(c)));
+               }
+               iks_insert_attrib(gtalk, "initiator", (p->initiator) ? to : lowerfrom);
                iks_insert_attrib(gtalk, "xmlns", GOOGLE_NS);
                iks_insert_attrib(candidate, "name", tmp->name);
                iks_insert_attrib(candidate, "address", tmp->ip);
@@ -1049,6 +1078,7 @@ static int gtalk_action(struct gtalk *client, struct gtalk_pvt *p, const char *a
 {
        iks *request, *session = NULL;
        int res = -1;
+       char *lowerthem = NULL;
 
        request = iks_new("iq");
        if (request) {
@@ -1061,7 +1091,14 @@ static int gtalk_action(struct gtalk *client, struct gtalk_pvt *p, const char *a
                if (session) {
                        iks_insert_attrib(session, "type", action);
                        iks_insert_attrib(session, "id", p->sid);
-                       iks_insert_attrib(session, "initiator", p->initiator ? p->us : p->them);
+                       /* put the initiator attribute to lower case if we receive the call 
+                        * otherwise GoogleTalk won't establish the session */
+                       if (!p->initiator) {
+                               char c;
+                               char *t = lowerthem = ast_strdupa(p->them);
+                               while (((c = *t) != '/') && (*t++ = tolower(c)));
+                       }
+                       iks_insert_attrib(session, "initiator", p->initiator ? p->us : lowerthem);
                        iks_insert_attrib(session, "xmlns", "http://www.google.com/session");
                        iks_insert_node(request, session);
                        ast_aji_send(client->connection, request);
@@ -1477,6 +1514,7 @@ static int gtalk_digit(struct ast_channel *ast, char digit, unsigned int duratio
        struct gtalk *client = p->parent;
        iks *iq, *gtalk, *dtmf;
        char buffer[2] = {digit, '\0'};
+       char *lowerthem = NULL;
        iq = iks_new("iq");
        gtalk = iks_new("gtalk");
        dtmf = iks_new("dtmf");
@@ -1495,7 +1533,14 @@ static int gtalk_digit(struct ast_channel *ast, char digit, unsigned int duratio
        ast_aji_increment_mid(client->connection->mid);
        iks_insert_attrib(gtalk, "xmlns", "http://jabber.org/protocol/gtalk");
        iks_insert_attrib(gtalk, "action", "session-info");
-       iks_insert_attrib(gtalk, "initiator", p->initiator ? p->us: p->them);
+       /* put the initiator attribute to lower case if we receive the call 
+        * otherwise GoogleTalk won't establish the session */
+       if (!p->initiator) {
+               char c;
+               char *t = lowerthem = ast_strdupa(p->them);
+               while (((c = *t) != '/') && (*t++ = tolower(c)));
+       }
+       iks_insert_attrib(gtalk, "initiator", p->initiator ? p->us: lowerthem);
        iks_insert_attrib(gtalk, "sid", p->sid);
        iks_insert_attrib(dtmf, "xmlns", "http://jabber.org/protocol/gtalk/info/dtmf");
        iks_insert_attrib(dtmf, "code", buffer);
@@ -1619,6 +1664,7 @@ static struct ast_channel *gtalk_request(const char *type, int format, void *dat
                client->connection = ast_aji_get_client(sender);
                if (!client->connection) {
                        ast_log(LOG_ERROR, "No XMPP client to talk to, us (partial JID) : %s\n", sender);
+                       ASTOBJ_UNREF(client, gtalk_member_destroy);
                        return NULL;
                }
        }
@@ -1960,6 +2006,7 @@ static int gtalk_load_config(void)
                                                ASTOBJ_UNLOCK(iterator);
                                        });
                                        ASTOBJ_CONTAINER_LINK(&gtalk_list, member);
+                                       ASTOBJ_UNREF(member, gtalk_member_destroy);
                                } else {
                                        ASTOBJ_UNLOCK(member);
                                        ASTOBJ_UNREF(member, gtalk_member_destroy);