summaryrefslogtreecommitdiff
path: root/channels/chan_iax2.c
diff options
context:
space:
mode:
authorTilghman Lesher <tilghman@meg.abyt.es>2009-09-10 23:12:16 +0000
committerTilghman Lesher <tilghman@meg.abyt.es>2009-09-10 23:12:16 +0000
commit1b147b009412a42a3b8664dea5cb0b89b4e68ca2 (patch)
treec6351a62b78f82abfae16cece84d7b21c4c90fde /channels/chan_iax2.c
parent32352265c44eb65f9217df5bc29171932b24e152 (diff)
Make calltoken support work with realtime users and peers.
In the course of this, I also found that the results of ast_gethostbyname were being used incorrectly in both chan_iax2 and chan_sip, so both have been fixed. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@217916 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_iax2.c')
-rw-r--r--channels/chan_iax2.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index aa9ac1cbb..e88779be8 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -952,6 +952,7 @@ static AST_LIST_HEAD_STATIC(dpcache, iax2_dpcache);
static void reg_source_db(struct iax2_peer *p);
static struct iax2_peer *realtime_peer(const char *peername, struct sockaddr_in *sin);
+static struct iax2_user *realtime_user(const char *username, struct sockaddr_in *sin);
static int ast_cli_netstats(struct mansession *s, int fd, int limit_fmt);
static char *complete_iax2_peers(const char *line, const char *word, int pos, int state, uint64_t flags);
@@ -2033,7 +2034,11 @@ static int calltoken_required(struct sockaddr_in *sin, const char *name, int sub
/* ----- Case 2 ----- */
if ((subclass == IAX_COMMAND_NEW) && (user = find_user(find))) {
calltoken_required = user->calltoken_required;
- } else if ((subclass != IAX_COMMAND_NEW) && (peer = find_peer(find, 1))) {
+ } else if ((subclass == IAX_COMMAND_NEW) && (user = realtime_user(find, sin))) {
+ calltoken_required = user->calltoken_required;
+ } else if ((subclass != IAX_COMMAND_NEW) && (peer = find_peer(find, 0))) {
+ calltoken_required = peer->calltoken_required;
+ } else if ((subclass != IAX_COMMAND_NEW) && (peer = realtime_peer(find, sin))) {
calltoken_required = peer->calltoken_required;
}
@@ -4140,7 +4145,7 @@ static struct iax2_peer *realtime_peer(const char *peername, struct sockaddr_in
if (!strcasecmp(tmp->name, "host")) {
struct ast_hostent ahp;
struct hostent *hp;
- if (!(hp = ast_gethostbyname(tmp->value, &ahp)) || (memcmp(&hp->h_addr, &sin->sin_addr, sizeof(hp->h_addr)))) {
+ if (!(hp = ast_gethostbyname(tmp->value, &ahp)) || (memcmp(hp->h_addr, &sin->sin_addr, sizeof(hp->h_addr)))) {
/* No match */
ast_variables_destroy(var);
var = NULL;
@@ -4252,7 +4257,7 @@ static struct iax2_user *realtime_user(const char *username, struct sockaddr_in
if (!strcasecmp(tmp->name, "host")) {
struct ast_hostent ahp;
struct hostent *hp;
- if (!(hp = ast_gethostbyname(tmp->value, &ahp)) || (memcmp(&hp->h_addr, &sin->sin_addr, sizeof(hp->h_addr)))) {
+ if (!(hp = ast_gethostbyname(tmp->value, &ahp)) || (memcmp(hp->h_addr, &sin->sin_addr, sizeof(hp->h_addr)))) {
/* No match */
ast_variables_destroy(var);
var = NULL;