Index: channels/chan_sip.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v retrieving revision 1.872 diff -u -r1.872 chan_sip.c --- channels/chan_sip.c 29 Sep 2005 17:41:00 -0000 1.872 +++ channels/chan_sip.c 3 Oct 2005 17:22:11 -0000 @@ -4870,6 +4870,10 @@ char *pidfstate = "--"; char *pidfnote= "Ready"; + memset(from, 0, sizeof(from)); + memset(to, 0, sizeof(to)); + memset(tmp, 0, sizeof(tmp)); + switch (state) { case (AST_EXTENSION_RINGING | AST_EXTENSION_INUSE): if (global_notifyringing) @@ -4922,7 +4926,6 @@ } } - memset(from, 0, sizeof(from)); ast_copy_string(from, get_header(&p->initreq, "From"), sizeof(from)); c = get_in_brackets(from); if (strncmp(c, "sip:", 4)) { @@ -4933,7 +4936,6 @@ *a = '\0'; mfrom = c; - memset(to, 0, sizeof(to)); ast_copy_string(to, get_header(&p->initreq, "To"), sizeof(to)); c = get_in_brackets(to); if (strncmp(c, "sip:", 4)) { @@ -4983,10 +4985,10 @@ break; case PIDF_XML: /* Eyebeam supports this format */ ast_build_string(&t, &maxbytes, "\n"); - ast_build_string(&t, &maxbytes, "\n", mfrom); + ast_build_string(&t, &maxbytes, "\n", mfrom); ast_build_string(&t, &maxbytes, "\n"); if (pidfstate[0] != '-') - ast_build_string(&t, &maxbytes, "%s\n", pidfstate); + ast_build_string(&t, &maxbytes, "\n", pidfstate); ast_build_string(&t, &maxbytes, "\n"); ast_build_string(&t, &maxbytes, "%s\n", pidfnote); /* Note */ ast_build_string(&t, &maxbytes, "\n", p->exten); /* Tuple start */ @@ -6212,6 +6214,8 @@ switch(state) { case AST_EXTENSION_DEACTIVATED: /* Retry after a while */ case AST_EXTENSION_REMOVED: /* Extension is gone */ + if (p->autokillid > -1) + sip_cancel_destroy(p); /* Remove subscription expiry for renewals */ sip_scheddestroy(p, 15000); /* Delete subscription in 15 secs */ ast_verbose(VERBOSE_PREFIX_2 "Extension state: Watcher for hint %s %s. Notify User %s\n", exten, state == AST_EXTENSION_DEACTIVATED ? "deactivated" : "removed", p->username); p->stateid = -1; @@ -11194,6 +11198,19 @@ } /*--- sip_devicestate: Part of PBX channel interface ---*/ + +/* Return values:--- + If we have qualify on and the device is not reachable, regardless of registration + state we return AST_DEVICE_UNAVAILABLE + + For peers with call limit: + not registred AST_DEVICE_UNAVAILABLE + registred, no call AST_DEVICE_NOT_INUSE + registred, call limit reached AST_DEVICE_BUSY + For peers without call limit: + not registred AST_DEVICE_UNAVAILABLE + registred AST_DEVICE_UNKNOWN +*/ static int sip_devicestate(void *data) { char *host; @@ -11210,7 +11227,7 @@ host = tmp + 1; if (option_debug > 2) - ast_log(LOG_DEBUG, "Checking device state for DNS host %s\n", host); + ast_log(LOG_DEBUG, "Checking device state for host %s\n", host); if ((p = find_peer(host, NULL, 1))) { if (p->addr.sin_addr.s_addr || p->defaddr.sin_addr.s_addr) { @@ -11221,7 +11238,7 @@ } else { /* qualify is not on, or the peer is responding properly */ /* check call limit */ - if (p->call_limit && (p->inUse >= p->call_limit)) + if (p->call_limit && p->inUse) res = AST_DEVICE_BUSY; else if (p->call_limit) res = AST_DEVICE_NOT_INUSE;