[Asterisk-cvs] asterisk/channels chan_iax2.c,1.353,1.354
markster
markster
Thu Oct 13 18:53:34 CDT 2005
Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv22729/channels
Modified Files:
chan_iax2.c
Log Message:
Fix naming on realtime peers (bug #5421)
Index: chan_iax2.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_iax2.c,v
retrieving revision 1.353
retrieving revision 1.354
diff -u -d -r1.353 -r1.354
--- chan_iax2.c 13 Oct 2005 18:27:53 -0000 1.353
+++ chan_iax2.c 13 Oct 2005 22:48:11 -0000 1.354
@@ -637,7 +637,7 @@
AST_MUTEX_DEFINE_STATIC(dpcache_lock);
static void reg_source_db(struct iax2_peer *p);
-static struct iax2_peer *realtime_peer(const char *peername);
+static struct iax2_peer *realtime_peer(const char *peername, struct sockaddr_in *sin);
static void destroy_peer(struct iax2_peer *peer);
static int ast_cli_netstats(int fd, int limit_fmt);
@@ -838,7 +838,7 @@
}
ast_mutex_unlock(&peerl.lock);
if(!peer && realtime)
- peer = realtime_peer(name);
+ peer = realtime_peer(name, NULL);
return peer;
}
@@ -860,6 +860,14 @@
}
if (lockpeer)
ast_mutex_unlock(&peerl.lock);
+ if (!peer) {
+ peer = realtime_peer(NULL, &sin);
+ if (peer) {
+ ast_copy_string(host, peer->name, len);
+ if (ast_test_flag(peer, IAX_TEMPONLY))
+ destroy_peer(peer);
+ }
+ }
return res;
}
@@ -2509,7 +2517,7 @@
static void destroy_user(struct iax2_user *user);
static int expire_registry(void *data);
-static struct iax2_peer *realtime_peer(const char *peername)
+static struct iax2_peer *realtime_peer(const char *peername, struct sockaddr_in *sin)
{
struct ast_variable *var;
struct ast_variable *tmp;
@@ -2517,7 +2525,15 @@
time_t regseconds, nowtime;
int dynamic=0;
- var = ast_load_realtime("iaxpeers", "name", peername, NULL);
+ if (peername)
+ var = ast_load_realtime("iaxpeers", "name", peername, NULL);
+ else {
+ char iabuf[INET_ADDRSTRLEN];
+ char porta[25];
+ ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr);
+ sprintf(porta, "%d", ntohs(sin->sin_port));
+ var = ast_load_realtime("iaxpeers", "ipaddr", iabuf, "port", porta, NULL);
+ }
if (!var)
return NULL;
@@ -5175,7 +5191,7 @@
if (!peer) {
/* We checked our list and didn't find one. It's unlikely, but possible,
that we're trying to authenticate *to* a realtime peer */
- if ((peer = realtime_peer(p->peer))) {
+ if ((peer = realtime_peer(p->peer, NULL))) {
res = authenticate(p->challenge, peer->secret,peer->outkey, authmethods, &ied, sin, &p->ecx, &p->dcx);
if (ast_test_flag(peer, IAX_TEMPONLY))
destroy_peer(peer);
More information about the svn-commits
mailing list