Raise Registry AMI events on registration failures
authorMatthew Jordan <mjordan@digium.com>
Thu, 1 Aug 2013 00:07:59 +0000 (00:07 +0000)
committerMatthew Jordan <mjordan@digium.com>
Thu, 1 Aug 2013 00:07:59 +0000 (00:07 +0000)
This patch makes it so that all registration attempts that fail that
also permanently modify the registration state will raise an appropriate
AMI event.

Note that this patch was forward ported to trunk and the Stasis Core
message bus by mjordan.

(closes issue ASTERISK-21368)
Reported by: Dmitriy Serov
patches:
  chan_sip.c.diff uploaded by Demon (license 6479)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@395907 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index 8a68f7a..c0e4a62 100644 (file)
@@ -23667,6 +23667,7 @@ static int handle_response_register(struct sip_pvt *p, int resp, const char *res
                ast_log(LOG_WARNING, "Forbidden - wrong password on authentication for REGISTER for '%s' to '%s'\n", p->registry->username, p->registry->hostname);
                AST_SCHED_DEL_UNREF(sched, r->timeout, registry_unref(r, "reg ptr unref from handle_response_register 403"));
                r->regstate = REG_STATE_NOAUTH;
+               sip_publish_registry(r->username, r->hostname, regstate2str(r->regstate));
                pvt_set_needdestroy(p, "received 403 response");
                break;
        case 404:       /* Not found */
@@ -23675,6 +23676,7 @@ static int handle_response_register(struct sip_pvt *p, int resp, const char *res
                if (r->call)
                        r->call = dialog_unref(r->call, "unsetting registry->call pointer-- case 404");
                r->regstate = REG_STATE_REJECTED;
+               sip_publish_registry(r->username, r->hostname, regstate2str(r->regstate));
                AST_SCHED_DEL_UNREF(sched, r->timeout, registry_unref(r, "reg ptr unref from handle_response_register 404"));
                break;
        case 407:       /* Proxy auth */
@@ -23715,6 +23717,7 @@ static int handle_response_register(struct sip_pvt *p, int resp, const char *res
                if (r->call)
                        r->call = dialog_unref(r->call, "unsetting registry->call pointer-- case 479");
                r->regstate = REG_STATE_REJECTED;
+               sip_publish_registry(r->username, r->hostname, regstate2str(r->regstate));
                AST_SCHED_DEL_UNREF(sched, r->timeout, registry_unref(r, "reg ptr unref from handle_response_register 479"));
                break;
        case 200:       /* 200 OK */