[asterisk-commits] dvossel: branch dvossel/gtalk_fixup r291178 - /team/dvossel/gtalk_fixup/chann...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Oct 11 14:31:57 CDT 2010
Author: dvossel
Date: Mon Oct 11 14:31:54 2010
New Revision: 291178
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=291178
Log:
update to gtalk stun support
Modified:
team/dvossel/gtalk_fixup/channels/chan_gtalk.c
Modified: team/dvossel/gtalk_fixup/channels/chan_gtalk.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/gtalk_fixup/channels/chan_gtalk.c?view=diff&rev=291178&r1=291177&r2=291178
==============================================================================
--- team/dvossel/gtalk_fixup/channels/chan_gtalk.c (original)
+++ team/dvossel/gtalk_fixup/channels/chan_gtalk.c Mon Oct 11 14:31:54 2010
@@ -195,6 +195,7 @@
static struct gtalk_pvt *gtalk_alloc(struct gtalk *client, const char *us, const char *them, const char *sid);
static char *gtalk_do_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
static char *gtalk_show_channels(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
+static int gtalk_update_externip(void);
/*! \brief PBX interface structure for channel registration */
static const struct ast_channel_tech gtalk_tech = {
@@ -800,12 +801,10 @@
struct sockaddr_in sin = { 0, };
struct ast_sockaddr sin_tmp;
struct ast_sockaddr bindaddr_tmp;
- struct sockaddr_in dest;
struct ast_sockaddr us;
iks *iq, *gtalk, *candidate, *transport;
char user[17], pass[17], preference[5], port[7];
char *lowerfrom = NULL;
-
iq = iks_new("iq");
gtalk = iks_new("session");
@@ -822,12 +821,14 @@
iks_insert_attrib(transport, "xmlns",GOOGLE_TRANSPORT_NS);
iks_insert_node(iq, gtalk);
+
if (p->ctype == AJI_CLIENT_GMAIL) {
iks_insert_node(gtalk,candidate);
} else {
iks_insert_node(gtalk,transport);
iks_insert_node(gtalk,candidate);
}
+
for (; p; p = p->next) {
if (!strcasecmp(p->sid, sid))
break;
@@ -861,6 +862,10 @@
ours1->generation = 0;
p->ourcandidates = ours1;
+ /* XXX TODO this is a blocking action. We send a STUN request to the server
+ * and wait for the response. If blocking here is a problem the STUN requests/responses
+ * for the externip may need to be done differently. */
+ gtalk_update_externip();
if (!ast_strlen_zero(externip)) {
/* XXX We should really stun for this one not just go with externip XXX */
ast_copy_string(ours2->username, user, sizeof(ours2->username));
@@ -876,9 +881,6 @@
ours2 = NULL;
}
ours1 = NULL;
- dest.sin_addr = __ourip;
- dest.sin_port = sin.sin_port;
-
for (tmp = p->ourcandidates; tmp; tmp = tmp->next) {
snprintf(port, sizeof(port), "%d", tmp->port);
@@ -1332,13 +1334,18 @@
return 1;
}
-static int gtalk_get_externip(struct sockaddr_in *dst)
+static int gtalk_update_externip(void)
{
int sock;
char *newaddr;
struct sockaddr_in answer = { 0, };
+ struct sockaddr_in *dst;
struct ast_sockaddr tmp_dst;
+ if (!stunaddr.sin_addr.s_addr) {
+ return -1;
+ }
+ dst = &stunaddr;
sock = socket(AF_INET, SOCK_DGRAM, 0);
if (sock < 0) {
@@ -2210,9 +2217,7 @@
cat = ast_category_browse(cfg, cat);
}
- if (stunaddr.sin_addr.s_addr) {
- gtalk_get_externip(&stunaddr);
- }
+ gtalk_update_externip();
gtalk_free_candidates(global_candidates);
return 1;
}
More information about the asterisk-commits
mailing list