diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-06-15 15:16:16 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-06-15 15:16:16 +0000 |
commit | 2d67e23cfd2a4c3c29c6420403c11a81392be9a8 (patch) | |
tree | 885235a32c4b3ae97b391f225638f96dcc61c193 /channels | |
parent | 58ba4c9463889a31676d8e00e4ef59946669203d (diff) |
When dialing outbound, if we match a peer name, use it (who really cares?) (bug #1850)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@3215 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rwxr-xr-x | channels/chan_iax2.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 4c02f6555..1a6088cad 100755 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -1954,7 +1954,7 @@ static struct iax2_user *mysql_user(char *user) } #endif /* MYSQL_FRIENDS */ -static int create_addr(struct sockaddr_in *sin, int *capability, int *sendani, int *maxtime, char *peer, char *context, int *trunk, int *notransfer, char *secret, int seclen) +static int create_addr(struct sockaddr_in *sin, int *capability, int *sendani, int *maxtime, char *peer, char *context, int *trunk, int *notransfer, char *secret, int seclen, int *ofound) { struct ast_hostent ahp; struct hostent *hp; struct iax2_peer *p; @@ -2010,6 +2010,8 @@ static int create_addr(struct sockaddr_in *sin, int *capability, int *sendani, i p = NULL; } } + if (ofound) + *ofound = found; if (!p && !found) { hp = ast_gethostbyname(peer, &ahp); if (hp) { @@ -2117,7 +2119,7 @@ static int iax2_call(struct ast_channel *c, char *dest, int timeout) strsep(&stringp, ":"); portno = strsep(&stringp, ":"); } - if (create_addr(&sin, NULL, NULL, NULL, hname, context, NULL, NULL, storedsecret, sizeof(storedsecret) - 1)) { + if (create_addr(&sin, NULL, NULL, NULL, hname, context, NULL, NULL, storedsecret, sizeof(storedsecret) - 1, NULL)) { ast_log(LOG_WARNING, "No address associated with '%s'\n", hname); return -1; } @@ -5689,6 +5691,7 @@ static struct ast_channel *iax2_request(char *type, int format, void *data) int res; int sendani; int maxtime; + int found = 0; int fmt, native; struct sockaddr_in sin; char s[256]; @@ -5720,7 +5723,7 @@ static struct ast_channel *iax2_request(char *type, int format, void *data) } /* Populate our address from the given */ - if (create_addr(&sin, &capability, &sendani, &maxtime, hostname, NULL, &trunk, ¬ransfer, NULL, 0)) { + if (create_addr(&sin, &capability, &sendani, &maxtime, hostname, NULL, &trunk, ¬ransfer, NULL, 0, &found)) { return NULL; } if (portno) { @@ -5740,6 +5743,8 @@ static struct ast_channel *iax2_request(char *type, int format, void *data) iaxs[callno]->sendani = sendani; iaxs[callno]->maxtime = maxtime; iaxs[callno]->notransfer = notransfer; + if (found) + strncpy(iaxs[callno]->host, hostname, sizeof(iaxs[callno]->host) - 1); c = ast_iax2_new(callno, AST_STATE_DOWN, capability); ast_mutex_unlock(&iaxsl[callno]); if (c) { @@ -6483,7 +6488,7 @@ static int cache_get_callno_locked(char *data) host = st; } /* Populate our address from the given */ - if (create_addr(&sin, NULL, NULL, NULL, host, NULL, NULL, NULL, NULL, 0)) { + if (create_addr(&sin, NULL, NULL, NULL, host, NULL, NULL, NULL, NULL, 0, NULL)) { return -1; } ast_log(LOG_DEBUG, "host: %s, user: %s, password: %s, context: %s\n", host, username, password, context); |