aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-06-14 22:35:49 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-06-14 22:35:49 +0000
commit00a6d4e9cef4a8d232bfa30b5184f141bd7a6f09 (patch)
tree8f707463128cd444f91879ac49be420171f336f3 /channels
parent14b5684f6052d81033c87ce7aad43879218ef1a3 (diff)
Merged revisions 34159-34160 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2 ........ r34159 | kpfleming | 2006-06-14 17:17:37 -0500 (Wed, 14 Jun 2006) | 2 lines use existing dial string parser for strings supplied to iax2_devicestate, because they can be complete dial strings, not just device names ........ r34160 | kpfleming | 2006-06-14 17:22:21 -0500 (Wed, 14 Jun 2006) | 2 lines coding style cleanups on queue interface handling code that was committed for the last release ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@34161 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_iax2.c62
1 files changed, 25 insertions, 37 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 27560a29b..9a703a067 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -9509,51 +9509,39 @@ struct ast_custom_function iaxpeer_function = {
/*! \brief Part of the device state notification system ---*/
static int iax2_devicestate(void *data)
{
- char *dest = (char *) data;
+ struct parsed_dial_string pds;
+ char *tmp = ast_strdupa(data);
struct iax2_peer *p;
- int found = 0;
- char *ext, *host;
- char tmp[256];
int res = AST_DEVICE_INVALID;
- ast_copy_string(tmp, dest, sizeof(tmp));
- host = strchr(tmp, '@');
- if (host) {
- *host = '\0';
- host++;
- ext = tmp;
- } else {
- host = tmp;
- ext = NULL;
- }
-
+ parse_dial_string(tmp, &pds);
+ if (ast_strlen_zero(pds.peer))
+ return res;
+
if (option_debug > 2)
- ast_log(LOG_DEBUG, "Checking device state for device %s\n", dest);
+ ast_log(LOG_DEBUG, "Checking device state for device %s\n", pds.peer);
/* SLD: FIXME: second call to find_peer during registration */
- p = find_peer(host, 1);
- if (p) {
- found++;
- res = AST_DEVICE_UNAVAILABLE;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "iax2_devicestate(%s): Found peer. What's device state of %s? addr=%d, defaddr=%d maxms=%d, lastms=%d\n",
- host, dest, p->addr.sin_addr.s_addr, p->defaddr.sin_addr.s_addr, p->maxms, p->lastms);
-
- if ((p->addr.sin_addr.s_addr || p->defaddr.sin_addr.s_addr) &&
- (!p->maxms || ((p->lastms > -1) && (p->historicms <= p->maxms)))) {
- /* Peer is registered, or have default IP address
- and a valid registration */
- if (p->historicms == 0 || p->historicms <= p->maxms)
- /* let the core figure out whether it is in use or not */
- res = AST_DEVICE_UNKNOWN;
- }
- } else {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Devicestate: Can't find peer %s.\n", host);
- }
+ if (!(p = find_peer(pds.peer, 1)))
+ return res;
+
+ res = AST_DEVICE_UNAVAILABLE;
+ if (option_debug > 2)
+ ast_log(LOG_DEBUG, "iax2_devicestate: Found peer. What's device state of %s? addr=%d, defaddr=%d maxms=%d, lastms=%d\n",
+ pds.peer, p->addr.sin_addr.s_addr, p->defaddr.sin_addr.s_addr, p->maxms, p->lastms);
- if (p && ast_test_flag(p, IAX_TEMPONLY))
+ if ((p->addr.sin_addr.s_addr || p->defaddr.sin_addr.s_addr) &&
+ (!p->maxms || ((p->lastms > -1) && (p->historicms <= p->maxms)))) {
+ /* Peer is registered, or have default IP address
+ and a valid registration */
+ if (p->historicms == 0 || p->historicms <= p->maxms)
+ /* let the core figure out whether it is in use or not */
+ res = AST_DEVICE_UNKNOWN;
+ }
+
+ if (ast_test_flag(p, IAX_TEMPONLY))
destroy_peer(p);
+
return res;
}