diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-10-12 19:54:54 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-10-12 19:54:54 +0000 |
commit | d4039ba307a7b8402921e507bab4ba58cd712328 (patch) | |
tree | dcd8ba4517a269d6ec639d47984f46f18e441b6f | |
parent | 58c0d6affca50e37b2d367ce4b4da5471a30acfa (diff) |
Be careful!
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@3983 f38db490-d61c-443f-a65b-d21fe96a405b
-rwxr-xr-x | channels/chan_iax2.c | 50 | ||||
-rwxr-xr-x | channels/chan_sip.c | 24 |
2 files changed, 42 insertions, 32 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 49d1ca27f..0f9bf402e 100755 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -1983,8 +1983,8 @@ static int iax2_fixup(struct ast_channel *oldchannel, struct ast_channel *newcha return 0; } -static struct iax2_peer *build_peer(const char *name, struct ast_variable *v); -static struct iax2_user *build_user(const char *name, struct ast_variable *v); +static struct iax2_peer *build_peer(const char *name, struct ast_variable *v, int temponly); +static struct iax2_user *build_user(const char *name, struct ast_variable *v, int temponly); static void destroy_user(struct iax2_user *user); static void destroy_peer(struct iax2_peer *peer); @@ -1999,7 +1999,7 @@ static struct iax2_peer *realtime_peer(const char *peername) var = ast_load_realtime("iaxfriends", "name", peername, NULL); if (var) { /* Make sure it's not a user only... */ - peer = build_peer(peername, var); + peer = build_peer(peername, var, 1); if (peer) { /* Add some finishing touches, addresses, etc */ peer->temponly = 1; @@ -2048,7 +2048,7 @@ static struct iax2_user *realtime_user(const char *username) var = ast_load_realtime("iaxfriends", "name", username, NULL); if (var) { /* Make sure it's not a user only... */ - user = build_user(username, var); + user = build_user(username, var, 1); if (user) { /* Add some finishing touches, addresses, etc */ user->temponly = 1; @@ -6366,7 +6366,7 @@ static int get_auth_methods(char *value) return methods; } -static struct iax2_peer *build_peer(const char *name, struct ast_variable *v) +static struct iax2_peer *build_peer(const char *name, struct ast_variable *v, int temponly) { struct iax2_peer *peer; struct iax2_peer *prev; @@ -6376,14 +6376,17 @@ static struct iax2_peer *build_peer(const char *name, struct ast_variable *v) int found=0; prev = NULL; ast_mutex_lock(&peerl.lock); - peer = peerl.peers; - while(peer) { - if (!strcasecmp(peer->name, name)) { - break; + if (!temponly) { + peer = peerl.peers; + while(peer) { + if (!strcasecmp(peer->name, name)) { + break; + } + prev = peer; + peer = peer->next; } - prev = peer; - peer = peer->next; - } + } else + peer = NULL; if (peer) { found++; oldha = peer->ha; @@ -6538,7 +6541,7 @@ static struct iax2_peer *build_peer(const char *name, struct ast_variable *v) return peer; } -static struct iax2_user *build_user(const char *name, struct ast_variable *v) +static struct iax2_user *build_user(const char *name, struct ast_variable *v, int temponly) { struct iax2_user *prev, *user; struct iax2_context *con, *conl = NULL; @@ -6549,14 +6552,17 @@ static struct iax2_user *build_user(const char *name, struct ast_variable *v) prev = NULL; ast_mutex_lock(&userl.lock); - user = userl.users; - while(user) { - if (!strcasecmp(user->name, name)) { - break; + if (!temponly) { + user = userl.users; + while(user) { + if (!strcasecmp(user->name, name)) { + break; + } + prev = user; + user = user->next; } - prev = user; - user = user->next; - } + } else + user = NULL; if (user) { found++; oldha = user->ha; @@ -6933,7 +6939,7 @@ static int set_config(char *config_file, struct sockaddr_in* sin){ utype = ast_variable_retrieve(cfg, cat, "type"); if (utype) { if (!strcasecmp(utype, "user") || !strcasecmp(utype, "friend")) { - user = build_user(cat, ast_variable_browse(cfg, cat)); + user = build_user(cat, ast_variable_browse(cfg, cat), 0); if (user) { ast_mutex_lock(&userl.lock); user->next = userl.users; @@ -6942,7 +6948,7 @@ static int set_config(char *config_file, struct sockaddr_in* sin){ } } if (!strcasecmp(utype, "peer") || !strcasecmp(utype, "friend")) { - peer = build_peer(cat, ast_variable_browse(cfg, cat)); + peer = build_peer(cat, ast_variable_browse(cfg, cat), 0); if (peer) { ast_mutex_lock(&peerl.lock); peer->next = peerl.peers; diff --git a/channels/chan_sip.c b/channels/chan_sip.c index ccde563b1..83e885263 100755 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -1042,7 +1042,7 @@ static void update_peer(struct sip_peer *p, int expiry) realtime_update_peer(p->name, &p->addr, p->username, expiry); } -static struct sip_peer *build_peer(const char *name, struct ast_variable *v); +static struct sip_peer *build_peer(const char *name, struct ast_variable *v, int temponly); static struct sip_peer *realtime_peer(const char *peername, struct sockaddr_in *sin) { @@ -1060,7 +1060,7 @@ static struct sip_peer *realtime_peer(const char *peername, struct sockaddr_in * var = ast_load_realtime("sipfriends", "ipaddr", iabuf, NULL); if (var) { /* Make sure it's not a user only... */ - peer = build_peer(peername, var); + peer = build_peer(peername, var, 1); if (peer) { /* Add some finishing touches, addresses, etc */ peer->temponly = 1; @@ -8147,7 +8147,7 @@ static struct sip_peer *temp_peer(char *name) } /*--- build_peer: Build peer from config file ---*/ -static struct sip_peer *build_peer(const char *name, struct ast_variable *v) +static struct sip_peer *build_peer(const char *name, struct ast_variable *v, int temponly) { struct sip_peer *peer; struct sip_peer *prev; @@ -8157,13 +8157,17 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v) int found=0; prev = NULL; ast_mutex_lock(&peerl.lock); - peer = peerl.peers; - while(peer) { - if (!strcasecmp(peer->name, name)) { - break; + if (temponly) { + peer = NULL; + } else { + peer = peerl.peers; + while(peer) { + if (!strcasecmp(peer->name, name)) { + break; + } + prev = peer; + peer = peer->next; } - prev = peer; - peer = peer->next; } if (peer) { found++; @@ -8598,7 +8602,7 @@ static int reload_config(void) } } if (!strcasecmp(utype, "peer") || !strcasecmp(utype, "friend")) { - peer = build_peer(cat, ast_variable_browse(cfg, cat)); + peer = build_peer(cat, ast_variable_browse(cfg, cat), 0); if (peer) { ast_mutex_lock(&peerl.lock); peer->next = peerl.peers; |