diff options
author | Jason Parker <jparker@digium.com> | 2013-07-08 14:42:57 +0000 |
---|---|---|
committer | Jason Parker <jparker@digium.com> | 2013-07-08 14:42:57 +0000 |
commit | 7422581b6d4921cebfcf177fc63b2ef852fdef58 (patch) | |
tree | fd0fbaa5ca5cdef688476d46a942a8260bf756e9 /channels | |
parent | 30d379851e2d614d1b8bcc65fdb5952feb6d62de (diff) |
Move channel driver Registry manager events to core.
This also shuffles the stasis system topic and related handling.
(closes issue ASTERISK-21488)
Review: https://reviewboard.asterisk.org/r/2631/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@393804 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels')
-rw-r--r-- | channels/chan_iax2.c | 11 | ||||
-rw-r--r-- | channels/chan_sip.c | 13 |
2 files changed, 19 insertions, 5 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 23006364c..38b94ac33 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -103,6 +103,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/security_events.h" #include "asterisk/stasis_endpoints.h" #include "asterisk/bridging.h" +#include "asterisk/stasis.h" +#include "asterisk/stasis_system.h" #include "iax2/include/iax2.h" #include "iax2/include/firmware.h" @@ -8376,6 +8378,11 @@ static int complete_transfer(int callno, struct iax_ies *ies) return 0; } +static void iax2_publish_registry(const char *username, const char *domain, const char *status, const char *cause) +{ + ast_system_publish_registry("IAX2", username, domain, status, cause); +} + /*! \brief Acknowledgment received for OUR registration */ static int iax2_ack_registry(struct iax_ies *ies, struct sockaddr_in *sin, int callno) { @@ -8437,7 +8444,7 @@ static int iax2_ack_registry(struct iax_ies *ies, struct sockaddr_in *sin, int c } snprintf(ourip, sizeof(ourip), "%s:%d", ast_inet_ntoa(reg->us.sin_addr), ntohs(reg->us.sin_port)); ast_verb(3, "Registered IAX2 to '%s', who sees us as %s%s\n", ast_inet_ntoa(sin->sin_addr), ourip, msgstatus); - manager_event(EVENT_FLAG_SYSTEM, "Registry", "ChannelType: IAX2\r\nDomain: %s\r\nStatus: Registered\r\n", ast_inet_ntoa(sin->sin_addr)); + iax2_publish_registry(reg->username, ast_inet_ntoa(sin->sin_addr), "Registered", NULL); } reg->regstate = REG_STATE_REGISTERED; return 0; @@ -11179,8 +11186,8 @@ immediatedial: if (iaxs[fr->callno]->reg) { if (authdebug) { ast_log(LOG_NOTICE, "Registration of '%s' rejected: '%s' from: '%s'\n", iaxs[fr->callno]->reg->username, ies.cause ? ies.cause : "<unknown>", ast_inet_ntoa(sin.sin_addr)); - manager_event(EVENT_FLAG_SYSTEM, "Registry", "ChannelType: IAX2\r\nUsername: %s\r\nStatus: Rejected\r\nCause: %s\r\n", iaxs[fr->callno]->reg->username, ies.cause ? ies.cause : "<unknown>"); } + iax2_publish_registry(iaxs[fr->callno]->reg->username, ast_inet_ntoa(sin.sin_addr), "Rejected", S_OR(ies.cause, "<unknown>")); iaxs[fr->callno]->reg->regstate = REG_STATE_REJECTED; } /* Send ack immediately, before we destroy */ diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 9373a6435..3c1f97b05 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -294,7 +294,9 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/sip_api.h" #include "asterisk/app.h" #include "asterisk/bridging.h" +#include "asterisk/stasis.h" #include "asterisk/stasis_endpoints.h" +#include "asterisk/stasis_system.h" #include "asterisk/stasis_channels.h" #include "asterisk/features_config.h" @@ -15076,6 +15078,11 @@ static const char *regstate2str(enum sipregistrystate regstate) return map_x_s(regstatestrings, regstate, "Unknown"); } +static void sip_publish_registry(const char *username, const char *domain, const char *status) +{ + ast_system_publish_registry("SIP", username, domain, status, NULL); +} + /*! \brief Update registration with SIP Proxy. * Called from the scheduler when the previous registration expires, * so we don't have to cancel the pending event. @@ -15176,7 +15183,7 @@ static int sip_reg_timeout(const void *data) transmit_register(r, SIP_REGISTER, NULL, NULL); ast_log(LOG_NOTICE, " -- Registration for '%s@%s' timed out, trying again (Attempt #%d)\n", r->username, r->hostname, r->regattempts); } - manager_event(EVENT_FLAG_SYSTEM, "Registry", "ChannelType: SIP\r\nUsername: %s\r\nDomain: %s\r\nStatus: %s\r\n", r->username, r->hostname, regstate2str(r->regstate)); + sip_publish_registry(r->username, r->hostname, regstate2str(r->regstate)); registry_unref(r, "unreffing registry_unref r"); return 0; } @@ -23692,7 +23699,7 @@ static int handle_response_register(struct sip_pvt *p, int resp, const char *res r->regstate = REG_STATE_UNREGISTERED; transmit_register(r, SIP_REGISTER, NULL, NULL); } - manager_event(EVENT_FLAG_SYSTEM, "Registry", "ChannelType: SIP\r\nUsername: %s\r\nDomain: %s\r\nStatus: %s\r\n", r->username, r->hostname, regstate2str(r->regstate)); + sip_publish_registry(r->username, r->hostname, regstate2str(r->regstate)); break; case 479: /* SER: Not able to process the URI - address is wrong in register*/ ast_log(LOG_WARNING, "Got error 479 on register to %s@%s, giving up (check config)\n", p->registry->username, p->registry->hostname); @@ -23711,7 +23718,7 @@ static int handle_response_register(struct sip_pvt *p, int resp, const char *res r->regstate = REG_STATE_REGISTERED; r->regtime = ast_tvnow(); /* Reset time of last successful registration */ - manager_event(EVENT_FLAG_SYSTEM, "Registry", "ChannelType: SIP\r\nUsername: %s\r\nDomain: %s\r\nStatus: %s\r\n", r->username, r->hostname, regstate2str(r->regstate)); + sip_publish_registry(r->username, r->hostname, regstate2str(r->regstate)); r->regattempts = 0; ast_debug(1, "Registration successful\n"); if (r->timeout > -1) { |