[asterisk-commits] qwell: branch qwell/system_registry r393306 - in /team/qwell/system_registry:...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Jul 1 09:36:11 CDT 2013
Author: qwell
Date: Mon Jul 1 09:36:05 2013
New Revision: 393306
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=393306
Log:
Refactor extraneous channel events
This change removes JitterBufStats, ChannelReload, and ChannelUpdate
and refactors the following events to travel over Stasis-Core:
* LocalBridge
* DAHDIChannel
* AlarmClear
* SpanAlarmClear
* Alarm
* SpanAlarm
* DNDState
* MCID
* SIPQualifyPeerDone
* SessionTimeout
Review: https://reviewboard.asterisk.org/r/2627/
(closes issue ASTERISK-21476)
........
Merged revisions 393284 from http://svn.asterisk.org/svn/asterisk/trunk
Modified:
team/qwell/system_registry/ (props changed)
team/qwell/system_registry/CHANGES
team/qwell/system_registry/apps/app_meetme.c
team/qwell/system_registry/apps/app_queue.c
team/qwell/system_registry/channels/chan_dahdi.c
team/qwell/system_registry/channels/chan_gtalk.c
team/qwell/system_registry/channels/chan_iax2.c
team/qwell/system_registry/channels/chan_sip.c
team/qwell/system_registry/channels/sig_analog.c
team/qwell/system_registry/channels/sig_pri.c
team/qwell/system_registry/channels/sip/include/sip.h
team/qwell/system_registry/configs/sip.conf.sample
team/qwell/system_registry/include/asterisk/json.h
team/qwell/system_registry/include/asterisk/stasis.h
team/qwell/system_registry/main/core_local.c
team/qwell/system_registry/main/json.c
team/qwell/system_registry/res/res_agi.c
Propchange: team/qwell/system_registry/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Jul 1 09:36:05 2013
@@ -1,1 +1,1 @@
-/trunk:1-393276
+/trunk:1-393305
Modified: team/qwell/system_registry/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/qwell/system_registry/CHANGES?view=diff&rev=393306&r1=393305&r2=393306
==============================================================================
--- team/qwell/system_registry/CHANGES (original)
+++ team/qwell/system_registry/CHANGES Mon Jul 1 09:36:05 2013
@@ -143,7 +143,7 @@
* The SIPqualifypeer action now acknowledges the request once it has established
that the request is against a known peer. It also issues a new event,
- 'SIPqualifypeerdone', once the qualify action has been completed.
+ 'SIPQualifyPeerDone', once the qualify action has been completed.
* The PlayDTMF action now supports an optional 'Duration' parameter. This
specifies the duration of the digit to be played, in milliseconds.
@@ -237,6 +237,20 @@
Events that reference channels (QueueCaller* and Agent*) will show
information about each channel. The (infamous) "Join" and "Leave" AMI
events have been changed to "QueueCallerJoin" and "QueueCallerLeave".
+
+ * The MCID AMI event now publishes a channel snapshot when available and
+ its non-channel-snapshot parameters now use either the "MCallerID" or
+ "MConnectedID" prefixes with Subaddr*, Name*, and Num* suffixes instead
+ of "CallerID" and "ConnectedID" to avoid confusion with similarly named
+ parameters in the channel snapshot.
+
+ * The "Agentlogin" and "Agentlogoff" events have been renamed "AgentLogin" and
+ "AgentLogoff" respectively.
+
+ * The "Channel" key used in the "AlarmClear", "Alarm", and "DNDState" has been
+ renamed "DAHDIChannel" since it does not convey an Asterisk channel name.
+
+ * "ChannelUpdate" events have been removed.
AGI (Asterisk Gateway Interface)
------------------
Modified: team/qwell/system_registry/apps/app_meetme.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/system_registry/apps/app_meetme.c?view=diff&rev=393306&r1=393305&r2=393306
==============================================================================
--- team/qwell/system_registry/apps/app_meetme.c (original)
+++ team/qwell/system_registry/apps/app_meetme.c Mon Jul 1 09:36:05 2013
@@ -1117,75 +1117,15 @@
15,
};
-/*!
- * \internal
- * \brief accessor for join message type
- * \since 12.0.0
- *
- * \retval pointer to the stasis message type
- * \retval NULL if not initialized
- */
-static struct stasis_message_type *meetme_join_type(void);
-
-/*!
- * \internal
- * \brief accessor for leave message type
- * \since 12.0.0
- *
- * \retval pointer to the stasis message type
- * \retval NULL if not initialized
- */
-static struct stasis_message_type *meetme_leave_type(void);
-
-/*!
- * \internal
- * \brief accessor for end message type
- * \since 12.0.0
- *
- * \retval pointer to the stasis message type
- * \retval NULL if not initialized
- */
-static struct stasis_message_type *meetme_end_type(void);
-
-/*!
- * \internal
- * \brief accessor for mute message type
- * \since 12.0.0
- *
- * \retval pointer to the stasis message type
- * \retval NULL if not initialized
- */
-static struct stasis_message_type *meetme_mute_type(void);
-
-/*!
- * \internal
- * \brief accessor for talking message type
- * \since 12.0.0
- *
- * \retval pointer to the stasis message type
- * \retval NULL if not initialized
- */
-static struct stasis_message_type *meetme_talking_type(void);
-
-/*!
- * \internal
- * \brief accessor for talk request message type
- * \since 12.0.0
- *
- * \retval pointer to the stasis message type
- * \retval NULL if not initialized
- */
-static struct stasis_message_type *meetme_talk_request_type(void);
-
/* Routes the various meetme message types to the meetme stasis callback function to turn them into events */
static struct stasis_message_router *meetme_event_message_router;
-STASIS_MESSAGE_TYPE_DEFN(meetme_join_type);
-STASIS_MESSAGE_TYPE_DEFN(meetme_leave_type);
-STASIS_MESSAGE_TYPE_DEFN(meetme_end_type);
-STASIS_MESSAGE_TYPE_DEFN(meetme_mute_type);
-STASIS_MESSAGE_TYPE_DEFN(meetme_talking_type);
-STASIS_MESSAGE_TYPE_DEFN(meetme_talk_request_type);
+STASIS_MESSAGE_TYPE_DEFN_LOCAL(meetme_join_type);
+STASIS_MESSAGE_TYPE_DEFN_LOCAL(meetme_leave_type);
+STASIS_MESSAGE_TYPE_DEFN_LOCAL(meetme_end_type);
+STASIS_MESSAGE_TYPE_DEFN_LOCAL(meetme_mute_type);
+STASIS_MESSAGE_TYPE_DEFN_LOCAL(meetme_talking_type);
+STASIS_MESSAGE_TYPE_DEFN_LOCAL(meetme_talk_request_type);
static void meetme_stasis_cb(void *data, struct stasis_subscription *sub,
struct stasis_topic *topic, struct stasis_message *message);
Modified: team/qwell/system_registry/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/system_registry/apps/app_queue.c?view=diff&rev=393306&r1=393305&r2=393306
==============================================================================
--- team/qwell/system_registry/apps/app_queue.c (original)
+++ team/qwell/system_registry/apps/app_queue.c Mon Jul 1 09:36:05 2013
@@ -1811,39 +1811,22 @@
new->opos = *pos;
}
-struct stasis_message_type *queue_caller_join_type(void);
-struct stasis_message_type *queue_caller_leave_type(void);
-struct stasis_message_type *queue_caller_abandon_type(void);
-
-struct stasis_message_type *queue_member_status_type(void);
-struct stasis_message_type *queue_member_added_type(void);
-struct stasis_message_type *queue_member_removed_type(void);
-struct stasis_message_type *queue_member_pause_type(void);
-struct stasis_message_type *queue_member_penalty_type(void);
-struct stasis_message_type *queue_member_ringinuse_type(void);
-
-struct stasis_message_type *queue_agent_called_type(void);
-struct stasis_message_type *queue_agent_connect_type(void);
-struct stasis_message_type *queue_agent_complete_type(void);
-struct stasis_message_type *queue_agent_dump_type(void);
-struct stasis_message_type *queue_agent_ringnoanswer_type(void);
-
-STASIS_MESSAGE_TYPE_DEFN(queue_caller_join_type);
-STASIS_MESSAGE_TYPE_DEFN(queue_caller_leave_type);
-STASIS_MESSAGE_TYPE_DEFN(queue_caller_abandon_type);
-
-STASIS_MESSAGE_TYPE_DEFN(queue_member_status_type);
-STASIS_MESSAGE_TYPE_DEFN(queue_member_added_type);
-STASIS_MESSAGE_TYPE_DEFN(queue_member_removed_type);
-STASIS_MESSAGE_TYPE_DEFN(queue_member_pause_type);
-STASIS_MESSAGE_TYPE_DEFN(queue_member_penalty_type);
-STASIS_MESSAGE_TYPE_DEFN(queue_member_ringinuse_type);
-
-STASIS_MESSAGE_TYPE_DEFN(queue_agent_called_type);
-STASIS_MESSAGE_TYPE_DEFN(queue_agent_connect_type);
-STASIS_MESSAGE_TYPE_DEFN(queue_agent_complete_type);
-STASIS_MESSAGE_TYPE_DEFN(queue_agent_dump_type);
-STASIS_MESSAGE_TYPE_DEFN(queue_agent_ringnoanswer_type);
+STASIS_MESSAGE_TYPE_DEFN_LOCAL(queue_caller_join_type);
+STASIS_MESSAGE_TYPE_DEFN_LOCAL(queue_caller_leave_type);
+STASIS_MESSAGE_TYPE_DEFN_LOCAL(queue_caller_abandon_type);
+
+STASIS_MESSAGE_TYPE_DEFN_LOCAL(queue_member_status_type);
+STASIS_MESSAGE_TYPE_DEFN_LOCAL(queue_member_added_type);
+STASIS_MESSAGE_TYPE_DEFN_LOCAL(queue_member_removed_type);
+STASIS_MESSAGE_TYPE_DEFN_LOCAL(queue_member_pause_type);
+STASIS_MESSAGE_TYPE_DEFN_LOCAL(queue_member_penalty_type);
+STASIS_MESSAGE_TYPE_DEFN_LOCAL(queue_member_ringinuse_type);
+
+STASIS_MESSAGE_TYPE_DEFN_LOCAL(queue_agent_called_type);
+STASIS_MESSAGE_TYPE_DEFN_LOCAL(queue_agent_connect_type);
+STASIS_MESSAGE_TYPE_DEFN_LOCAL(queue_agent_complete_type);
+STASIS_MESSAGE_TYPE_DEFN_LOCAL(queue_agent_dump_type);
+STASIS_MESSAGE_TYPE_DEFN_LOCAL(queue_agent_ringnoanswer_type);
static void queue_channel_manager_event(void *data,
struct stasis_subscription *sub, struct stasis_topic *topic,
Modified: team/qwell/system_registry/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/system_registry/channels/chan_dahdi.c?view=diff&rev=393306&r1=393305&r2=393306
==============================================================================
--- team/qwell/system_registry/channels/chan_dahdi.c (original)
+++ team/qwell/system_registry/channels/chan_dahdi.c Mon Jul 1 09:36:05 2013
@@ -131,6 +131,7 @@
#include "asterisk/data.h"
#include "asterisk/features_config.h"
#include "asterisk/bridging.h"
+#include "asterisk/stasis_channels.h"
/*** DOCUMENTATION
<application name="DAHDISendKeypadFacility" language="en_US">
@@ -296,6 +297,85 @@
<para>Similar to the CLI command "pri show spans".</para>
</description>
</manager>
+ <managerEvent language="en_US" name="AlarmClear">
+ <managerEventInstance class="EVENT_FLAG_SYSTEM">
+ <synopsis>Raised when an alarm is cleared on a DAHDI channel.</synopsis>
+ <syntax>
+ <parameter name="DAHDIChannel">
+ <para>The DAHDI channel on which the alarm was cleared.</para>
+ <note><para>This is not an Asterisk channel identifier.</para></note>
+ </parameter>
+ </syntax>
+ </managerEventInstance>
+ </managerEvent>
+ <managerEvent language="en_US" name="SpanAlarmClear">
+ <managerEventInstance class="EVENT_FLAG_SYSTEM">
+ <synopsis>Raised when an alarm is cleared on a DAHDI span.</synopsis>
+ <syntax>
+ <parameter name="Span">
+ <para>The span on which the alarm was cleared.</para>
+ </parameter>
+ </syntax>
+ </managerEventInstance>
+ </managerEvent>
+ <managerEvent language="en_US" name="DNDState">
+ <managerEventInstance class="EVENT_FLAG_SYSTEM">
+ <synopsis>Raised when the Do Not Disturb state is changed on a DAHDI channel.</synopsis>
+ <syntax>
+ <parameter name="DAHDIChannel">
+ <para>The DAHDI channel on which DND status changed.</para>
+ <note><para>This is not an Asterisk channel identifier.</para></note>
+ </parameter>
+ <parameter name="Status">
+ <enumlist>
+ <enum name="enabled"/>
+ <enum name="disabled"/>
+ </enumlist>
+ </parameter>
+ </syntax>
+ </managerEventInstance>
+ </managerEvent>
+ <managerEvent language="en_US" name="Alarm">
+ <managerEventInstance class="EVENT_FLAG_SYSTEM">
+ <synopsis>Raised when an alarm is set on a DAHDI channel.</synopsis>
+ <syntax>
+ <parameter name="DAHDIChannel">
+ <para>The channel on which the alarm occurred.</para>
+ <note><para>This is not an Asterisk channel identifier.</para></note>
+ </parameter>
+ <parameter name="Alarm">
+ <para>A textual description of the alarm that occurred.</para>
+ </parameter>
+ </syntax>
+ </managerEventInstance>
+ </managerEvent>
+ <managerEvent language="en_US" name="SpanAlarm">
+ <managerEventInstance class="EVENT_FLAG_SYSTEM">
+ <synopsis>Raised when an alarm is set on a DAHDI span.</synopsis>
+ <syntax>
+ <parameter name="Span">
+ <para>The span on which the alarm occurred.</para>
+ </parameter>
+ <parameter name="Alarm">
+ <para>A textual description of the alarm that occurred.</para>
+ </parameter>
+ </syntax>
+ </managerEventInstance>
+ </managerEvent>
+ <managerEvent language="en_US" name="DAHDIChannel">
+ <managerEventInstance class="EVENT_FLAG_CALL">
+ <synopsis>Raised when a DAHDI channel is created or an underlying technology is associated with a DAHDI channel.</synopsis>
+ <syntax>
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
+ <parameter name="DAHDISpan">
+ <para>The DAHDI span associated with this channel.</para>
+ </parameter>
+ <parameter name="DAHDIChannel">
+ <para>The DAHDI channel associated with this channel.</para>
+ </parameter>
+ </syntax>
+ </managerEventInstance>
+ </managerEvent>
***/
#define SMDI_MD_WAIT_TIMEOUT 1500 /* 1.5 seconds */
@@ -2270,6 +2350,50 @@
DEADLOCK_AVOIDANCE(&p->lock);
}
+static struct ast_manager_event_blob *dahdichannel_to_ami(struct stasis_message *msg)
+{
+ RAII_VAR(struct ast_str *, channel_string, NULL, ast_free);
+ struct ast_channel_blob *obj = stasis_message_data(msg);
+ struct ast_json *span, *channel;
+
+ channel_string = ast_manager_build_channel_state_string(obj->snapshot);
+ if (!channel_string) {
+ return NULL;
+ }
+
+ span = ast_json_object_get(obj->blob, "span");
+ channel = ast_json_object_get(obj->blob, "channel");
+
+ return ast_manager_event_blob_create(EVENT_FLAG_CALL, "DAHDIChannel",
+ "%s"
+ "DAHDISpan: %d\r\n"
+ "DAHDIChannel: %s\r\n",
+ ast_str_buffer(channel_string),
+ (unsigned int)ast_json_integer_get(span),
+ ast_json_string_get(channel));
+}
+
+STASIS_MESSAGE_TYPE_DEFN_LOCAL(dahdichannel_type,
+ .to_ami = dahdichannel_to_ami,
+ );
+
+/*! \brief Sends a DAHDIChannel channel blob used to produce DAHDIChannel AMI messages */
+static void publish_dahdichannel(struct ast_channel *chan, int span, const char *dahdi_channel)
+{
+ RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
+
+ ast_assert(dahdi_channel != NULL);
+
+ blob = ast_json_pack("{s: i, s: s}",
+ "span", span,
+ "channel", dahdi_channel);
+ if (!blob) {
+ return;
+ }
+
+ ast_channel_publish_blob(chan, dahdichannel_type(), blob);
+}
+
/*!
* \internal
* \brief Post an AMI DAHDI channel association event.
@@ -2294,20 +2418,7 @@
/* Real channel */
snprintf(ch_name, sizeof(ch_name), "%d", p->channel);
}
- /*** DOCUMENTATION
- <managerEventInstance>
- <synopsis>Raised when a DAHDI channel is created or an underlying technology is associated with a DAHDI channel.</synopsis>
- </managerEventInstance>
- ***/
- ast_manager_event(chan, EVENT_FLAG_CALL, "DAHDIChannel",
- "Channel: %s\r\n"
- "Uniqueid: %s\r\n"
- "DAHDISpan: %d\r\n"
- "DAHDIChannel: %s\r\n",
- ast_channel_name(chan),
- ast_channel_uniqueid(chan),
- p->span,
- ch_name);
+ publish_dahdichannel(chan, p->span, ch_name);
}
#ifdef HAVE_PRI
@@ -3956,6 +4067,37 @@
}
}
+static void publish_channel_alarm_clear(int channel)
+{
+ RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
+ RAII_VAR(struct ast_str *, dahdi_chan, ast_str_create(32), ast_free);
+ if (!dahdi_chan) {
+ return;
+ }
+
+ ast_str_set(&dahdi_chan, 0, "%d", channel);
+ ast_log(LOG_NOTICE, "Alarm cleared on channel DAHDI/%d\n", channel);
+ body = ast_json_pack("{s: s}", "DAHDIChannel", ast_str_buffer(dahdi_chan));
+ if (!body) {
+ return;
+ }
+
+ ast_manager_publish_event("AlarmClear", EVENT_FLAG_SYSTEM, body);
+}
+
+static void publish_span_alarm_clear(int span)
+{
+ RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
+
+ ast_log(LOG_NOTICE, "Alarm cleared on span %d\n", span);
+ body = ast_json_pack("{s: i}", "Span", span);
+ if (!body) {
+ return;
+ }
+
+ ast_manager_publish_event("SpanAlarmClear", EVENT_FLAG_SYSTEM, body);
+}
+
static void handle_clear_alarms(struct dahdi_pvt *p)
{
#if defined(HAVE_PRI)
@@ -3965,22 +4107,10 @@
#endif /* defined(HAVE_PRI) */
if (report_alarms & REPORT_CHANNEL_ALARMS) {
- ast_log(LOG_NOTICE, "Alarm cleared on channel %d\n", p->channel);
- /*** DOCUMENTATION
- <managerEventInstance>
- <synopsis>Raised when an alarm is cleared on a DAHDI channel.</synopsis>
- </managerEventInstance>
- ***/
- manager_event(EVENT_FLAG_SYSTEM, "AlarmClear", "Channel: %d\r\n", p->channel);
+ publish_channel_alarm_clear(p->channel);
}
if (report_alarms & REPORT_SPAN_ALARMS && p->manages_span_alarms) {
- ast_log(LOG_NOTICE, "Alarm cleared on span %d\n", p->span);
- /*** DOCUMENTATION
- <managerEventInstance>
- <synopsis>Raised when an alarm is cleared on a DAHDI span.</synopsis>
- </managerEventInstance>
- ***/
- manager_event(EVENT_FLAG_SYSTEM, "SpanAlarmClear", "Span: %d\r\n", p->span);
+ publish_span_alarm_clear(p->span);
}
}
@@ -8037,6 +8167,39 @@
}
}
+static void publish_span_alarm(int span, const char *alarm_txt)
+{
+ RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
+
+ body = ast_json_pack("{s: i, s: s}",
+ "Span", span,
+ "Alarm", alarm_txt);
+ if (!body) {
+ return;
+ }
+
+ ast_manager_publish_event("SpanAlarm", EVENT_FLAG_SYSTEM, body);
+}
+
+static void publish_channel_alarm(int channel, const char *alarm_txt)
+{
+ RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
+ RAII_VAR(struct ast_str *, dahdi_chan, ast_str_create(32), ast_free);
+ if (!dahdi_chan) {
+ return;
+ }
+
+ ast_str_set(&dahdi_chan, 0, "%d", channel);
+ body = ast_json_pack("{s: s, s: s}",
+ "DAHDIChannel", ast_str_buffer(dahdi_chan),
+ "Alarm", alarm_txt);
+ if (!body) {
+ return;
+ }
+
+ ast_manager_publish_event("Alarm", EVENT_FLAG_SYSTEM, body);
+}
+
static void handle_alarms(struct dahdi_pvt *p, int alms)
{
const char *alarm_str;
@@ -8050,28 +8213,12 @@
alarm_str = alarm2str(alms);
if (report_alarms & REPORT_CHANNEL_ALARMS) {
ast_log(LOG_WARNING, "Detected alarm on channel %d: %s\n", p->channel, alarm_str);
- /*** DOCUMENTATION
- <managerEventInstance>
- <synopsis>Raised when an alarm is set on a DAHDI channel.</synopsis>
- </managerEventInstance>
- ***/
- manager_event(EVENT_FLAG_SYSTEM, "Alarm",
- "Alarm: %s\r\n"
- "Channel: %d\r\n",
- alarm_str, p->channel);
+ publish_channel_alarm(p->channel, alarm_str);
}
if (report_alarms & REPORT_SPAN_ALARMS && p->manages_span_alarms) {
ast_log(LOG_WARNING, "Detected alarm on span %d: %s\n", p->span, alarm_str);
- /*** DOCUMENTATION
- <managerEventInstance>
- <synopsis>Raised when an alarm is set on a DAHDI span.</synopsis>
- </managerEventInstance>
- ***/
- manager_event(EVENT_FLAG_SYSTEM, "SpanAlarm",
- "Alarm: %s\r\n"
- "Span: %d\r\n",
- alarm_str, p->span);
+ publish_span_alarm(p->span, alarm_str);
}
}
@@ -10083,6 +10230,26 @@
return 0;
}
+static void publish_dnd_state(int channel, const char *status)
+{
+ RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
+ RAII_VAR(struct ast_str *, dahdichan, ast_str_create(32), ast_free);
+ if (!dahdichan) {
+ return;
+ }
+
+ ast_str_set(&dahdichan, 0, "%d", channel);
+
+ body = ast_json_pack("{s: s, s: s}",
+ "DAHDIChannel", ast_str_buffer(dahdichan),
+ "Status", status);
+ if (!body) {
+ return;
+ }
+
+ ast_manager_publish_event("DNDState", EVENT_FLAG_SYSTEM, body);
+}
+
/*! \brief enable or disable the chan_dahdi Do-Not-Disturb mode for a DAHDI channel
* \param dahdichan "Physical" DAHDI channel (e.g: DAHDI/5)
* \param flag on 1 to enable, 0 to disable, -1 return dnd value
@@ -10107,24 +10274,7 @@
ast_verb(3, "%s DND on channel %d\n",
flag? "Enabled" : "Disabled",
dahdichan->channel);
- /*** DOCUMENTATION
- <managerEventInstance>
- <synopsis>Raised when the Do Not Disturb state is changed on a DAHDI channel.</synopsis>
- <syntax>
- <parameter name="Status">
- <enumlist>
- <enum name="enabled"/>
- <enum name="disabled"/>
- </enumlist>
- </parameter>
- </syntax>
- </managerEventInstance>
- ***/
- manager_event(EVENT_FLAG_SYSTEM, "DNDState",
- "Channel: DAHDI/%d\r\n"
- "Status: %s\r\n", dahdichan->channel,
- flag? "enabled" : "disabled");
-
+ publish_dnd_state(dahdichan->channel, flag ? "enabled" : "disabled");
return 0;
}
@@ -17154,6 +17304,7 @@
ast_cond_destroy(&ss_thread_complete);
dahdi_tech.capabilities = ast_format_cap_destroy(dahdi_tech.capabilities);
+ STASIS_MESSAGE_TYPE_CLEANUP(dahdichannel_type);
return 0;
}
@@ -19154,6 +19305,10 @@
int y;
#endif /* defined(HAVE_PRI) || defined(HAVE_SS7) */
+ if (STASIS_MESSAGE_TYPE_INIT(dahdichannel_type)) {
+ return AST_MODULE_LOAD_FAILURE;
+ }
+
if (!(dahdi_tech.capabilities = ast_format_cap_alloc())) {
return AST_MODULE_LOAD_FAILURE;
}
Modified: team/qwell/system_registry/channels/chan_gtalk.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/system_registry/channels/chan_gtalk.c?view=diff&rev=393306&r1=393305&r2=393306
==============================================================================
--- team/qwell/system_registry/channels/chan_gtalk.c (original)
+++ team/qwell/system_registry/channels/chan_gtalk.c Mon Jul 1 09:36:05 2013
@@ -86,6 +86,7 @@
#include "asterisk/jabber.h"
#include "asterisk/jingle.h"
#include "asterisk/features.h"
+#include "asterisk/stasis_channels.h"
#define GOOGLE_CONFIG "gtalk.conf"
@@ -546,8 +547,6 @@
ast_debug(1, "Answer!\n");
ast_mutex_lock(&p->lock);
gtalk_invite(p, p->them, p->us,p->sid, 0);
- manager_event(EVENT_FLAG_SYSTEM, "ChannelUpdate", "Channel: %s\r\nChanneltype: %s\r\nGtalk-SID: %s\r\n",
- ast_channel_name(ast), "GTALK", p->sid);
ast_mutex_unlock(&p->lock);
return res;
}
@@ -1216,9 +1215,7 @@
ast_hangup(tmp);
tmp = NULL;
} else {
- manager_event(EVENT_FLAG_SYSTEM, "ChannelUpdate",
- "Channel: %s\r\nChanneltype: %s\r\nGtalk-SID: %s\r\n",
- i->owner ? ast_channel_name(i->owner) : "", "Gtalk", i->sid);
+ send_channel_update(i->owner, i->sid);
}
return tmp;
}
Modified: team/qwell/system_registry/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/system_registry/channels/chan_iax2.c?view=diff&rev=393306&r1=393305&r2=393306
==============================================================================
--- team/qwell/system_registry/channels/chan_iax2.c (original)
+++ team/qwell/system_registry/channels/chan_iax2.c Mon Jul 1 09:36:05 2013
@@ -1394,17 +1394,6 @@
reload_config(1);
}
-
-/*! \brief Send manager event at call setup to link between Asterisk channel name
- and IAX2 call identifiers */
-static void iax2_ami_channelupdate(struct chan_iax2_pvt *pvt)
-{
- manager_event(EVENT_FLAG_SYSTEM, "ChannelUpdate",
- "Channel: %s\r\nChanneltype: IAX2\r\nIAX2-callno-local: %d\r\nIAX2-callno-remote: %d\r\nIAX2-peer: %s\r\n",
- pvt->owner ? ast_channel_name(pvt->owner) : "",
- pvt->callno, pvt->peercallno, pvt->peer ? pvt->peer : "");
-}
-
static const struct ast_datastore_info iax2_variable_datastore_info = {
.type = "IAX2_VARIABLE",
.duplicate = iax2_dup_variable_datastore,
@@ -5554,10 +5543,6 @@
{
unsigned short callno = PTR_TO_CALLNO(ast_channel_tech_pvt(c));
ast_debug(1, "Answering IAX2 call\n");
- ast_mutex_lock(&iaxsl[callno]);
- if (iaxs[callno])
- iax2_ami_channelupdate(iaxs[callno]);
- ast_mutex_unlock(&iaxsl[callno]);
return send_command_locked(callno, AST_FRAME_CONTROL, AST_CONTROL_ANSWER, 0, NULL, 0, -1);
}
@@ -5680,7 +5665,6 @@
}
return NULL;
}
- iax2_ami_channelupdate(i);
if (!tmp) {
return NULL;
}
@@ -9358,23 +9342,6 @@
localpackets = jbinfo.frames_in;
}
ast_debug(3, "JB STATS:%s ping=%d ljitterms=%d ljbdelayms=%d ltotlost=%d lrecentlosspct=%d ldropped=%d looo=%d lrecvd=%d rjitterms=%d rjbdelayms=%d rtotlost=%d rrecentlosspct=%d rdropped=%d rooo=%d rrecvd=%d\n",
- ast_channel_name(iaxs[callno]->owner),
- iaxs[callno]->pingtime,
- localjitter,
- localdelay,
- locallost,
- locallosspct,
- localdropped,
- localooo,
- localpackets,
- iaxs[callno]->remote_rr.jitter,
- iaxs[callno]->remote_rr.delay,
- iaxs[callno]->remote_rr.losscnt,
- iaxs[callno]->remote_rr.losspct/1000,
- iaxs[callno]->remote_rr.dropped,
- iaxs[callno]->remote_rr.ooo,
- iaxs[callno]->remote_rr.packets);
- manager_event(EVENT_FLAG_REPORTING, "JitterBufStats", "Owner: %s\r\nPing: %d\r\nLocalJitter: %d\r\nLocalJBDelay: %d\r\nLocalTotalLost: %d\r\nLocalLossPercent: %d\r\nLocalDropped: %d\r\nLocalooo: %d\r\nLocalReceived: %d\r\nRemoteJitter: %d\r\nRemoteJBDelay: %d\r\nRemoteTotalLost: %d\r\nRemoteLossPercent: %d\r\nRemoteDropped: %d\r\nRemoteooo: %d\r\nRemoteReceived: %d\r\n",
ast_channel_name(iaxs[callno]->owner),
iaxs[callno]->pingtime,
localjitter,
Modified: team/qwell/system_registry/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/system_registry/channels/chan_sip.c?view=diff&rev=393306&r1=393305&r2=393306
==============================================================================
--- team/qwell/system_registry/channels/chan_sip.c (original)
+++ team/qwell/system_registry/channels/chan_sip.c Mon Jul 1 09:36:05 2013
@@ -297,6 +297,7 @@
#include "asterisk/stasis.h"
#include "asterisk/stasis_endpoints.h"
#include "asterisk/stasis_system.h"
+#include "asterisk/stasis_channels.h"
#include "asterisk/features_config.h"
/*** DOCUMENTATION
@@ -565,7 +566,7 @@
<para>Qualify a SIP peer.</para>
</description>
<see-also>
- <ref type="managerEvent">SIPqualifypeerdone</ref>
+ <ref type="managerEvent">SIPQualifyPeerDone</ref>
</see-also>
</manager>
<manager name="SIPshowregistry" language="en_US">
@@ -623,6 +624,37 @@
<para>Specifying a prefix of <literal>sip:</literal> will send the
message as a SIP MESSAGE request.</para>
</info>
+ <managerEvent language="en_US" name="SIPQualifyPeerDone">
+ <managerEventInstance class="EVENT_FLAG_CALL">
+ <synopsis>Raised when SIPQualifyPeer has finished qualifying the specified peer.</synopsis>
+ <syntax>
+ <parameter name="Peer">
+ <para>The name of the peer.</para>
+ </parameter>
+ <parameter name="ActionID">
+ <para>This is only included if an ActionID Header was sent with the action request, in which case it will be that ActionID.</para>
+ </parameter>
+ </syntax>
+ <see-also>
+ <ref type="manager">SIPqualifypeer</ref>
+ </see-also>
+ </managerEventInstance>
+ </managerEvent>
+ <managerEvent language="en_US" name="SessionTimeout">
+ <managerEventInstance class="EVENT_FLAG_CALL">
+ <synopsis>Raised when a SIP session times out.</synopsis>
+ <syntax>
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
+ <parameter name="Source">
+ <para>The source of the session timeout.</para>
+ <enumlist>
+ <enum name="RTPTimeout" />
+ <enum name="SIPSessionTimer" />
+ </enumlist>
+ </parameter>
+ </syntax>
+ </managerEventInstance>
+ </managerEvent>
***/
static int min_expiry = DEFAULT_MIN_EXPIRY; /*!< Minimum accepted registration time */
@@ -1043,6 +1075,11 @@
static struct sip_auth_container *authl = NULL;
/*! \brief Global authentication container protection while adjusting the references. */
AST_MUTEX_DEFINE_STATIC(authl_lock);
+
+static struct ast_manager_event_blob *session_timeout_to_ami(struct stasis_message *msg);
+STASIS_MESSAGE_TYPE_DEFN_LOCAL(session_timeout_type,
+ .to_ami = session_timeout_to_ami,
+ );
/* --- Sockets and networking --------------*/
@@ -8214,13 +8251,6 @@
append_history(i, "NewChan", "Channel %s - from %s", ast_channel_name(tmp), i->callid);
}
- /* Inform manager user about new channel and their SIP call ID */
- if (sip_cfg.callevents) {
- manager_event(EVENT_FLAG_SYSTEM, "ChannelUpdate",
- "Channel: %s\r\nUniqueid: %s\r\nChanneltype: %s\r\nSIPcallid: %s\r\nSIPfullcontact: %s\r\n",
- ast_channel_name(tmp), ast_channel_uniqueid(tmp), "SIP", i->callid, i->fullcontact);
- }
-
return tmp;
}
@@ -20014,6 +20044,21 @@
return 0;
}
+static void publish_qualify_peer_done(const char *id, const char *peer)
+{
+ RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
+
+ if (ast_strlen_zero(id)) {
+ body = ast_json_pack("{s: s}", "Peer", peer);
+ } else {
+ body = ast_json_pack("{s: s, s: s}", "Peer", peer, "ActionID", id);
+ }
+ if (!body) {
+ return;
+ }
+
+ ast_manager_publish_event("SIPQualifyPeerDone", EVENT_FLAG_CALL, body);
+}
/*! \brief Send qualify message to peer from cli or manager. Mostly for debugging. */
static char *_sip_qualify_peer(int type, int fd, struct mansession *s, const struct message *m, int argc, const char *argv[])
@@ -20026,41 +20071,15 @@
load_realtime = (argc == 5 && !strcmp(argv[4], "load")) ? TRUE : FALSE;
if ((peer = sip_find_peer(argv[3], NULL, load_realtime, FINDPEERS, FALSE, 0))) {
-
const char *id = astman_get_header(m,"ActionID");
- char idText[256] = "";
if (type != 0) {
astman_send_ack(s, m, "SIP peer found - will qualify");
}
- if (!ast_strlen_zero(id)) {
- snprintf(idText, sizeof(idText), "ActionID: %s\r\n", id);
- }
-
sip_poke_peer(peer, 1);
- /*** DOCUMENTATION
- <managerEventInstance>
- <synopsis>Raised when SIPqualifypeer has finished qualifying the specified peer.</synopsis>
- <syntax>
- <parameter name="Peer">
- <para>The name of the peer.</para>
- </parameter>
- <parameter name="ActionID">
- <para>This is only included if an ActionID Header was sent with the action request, in which case it will be that ActionID.</para>
- </parameter>
- </syntax>
- <see-also>
- <ref type="manager">SIPqualifypeer</ref>
- </see-also>
- </managerEventInstance>
- ***/
- manager_event(EVENT_FLAG_CALL, "SIPqualifypeerdone",
- "Peer: %s\r\n"
- "%s",
- argv[3],
- idText);
+ publish_qualify_peer_done(id, argv[3]);
sip_unref_peer(peer, "qualify: done with peer");
} else if (type == 0) {
@@ -20894,7 +20913,6 @@
ast_cli(a->fd, " From: Domain: %s\n", default_fromdomain);
}
ast_cli(a->fd, " Record SIP history: %s\n", AST_CLI_ONOFF(recordhistory));
- ast_cli(a->fd, " Call Events: %s\n", AST_CLI_ONOFF(sip_cfg.callevents));
ast_cli(a->fd, " Auth. Failure Events: %s\n", AST_CLI_ONOFF(global_authfailureevents));
ast_cli(a->fd, " T.38 support: %s\n", AST_CLI_YESNO(ast_test_flag(&global_flags[1], SIP_PAGE2_T38SUPPORT)));
@@ -23147,11 +23165,6 @@
if (!req->ignore && p->owner) {
if (!reinvite) {
ast_queue_control(p->owner, AST_CONTROL_ANSWER);
- if (sip_cfg.callevents) {
- manager_event(EVENT_FLAG_SYSTEM, "ChannelUpdate",
- "Channel: %s\r\nChanneltype: %s\r\nUniqueid: %s\r\nSIPcallid: %s\r\nSIPfullcontact: %s\r\nPeername: %s\r\n",
- ast_channel_name(p->owner), "SIP", ast_channel_uniqueid(p->owner), p->callid, p->fullcontact, p->peername);
- }
} else { /* RE-invite */
if (p->t38.state == T38_DISABLED || p->t38.state == T38_REJECTED) {
ast_queue_control(p->owner, AST_CONTROL_UPDATE_RTP_PEER);
@@ -28465,6 +28478,39 @@
return 0;
}
+static struct ast_manager_event_blob *session_timeout_to_ami(struct stasis_message *msg)
+{
+ RAII_VAR(struct ast_str *, channel_string, NULL, ast_free);
+ struct ast_channel_blob *obj = stasis_message_data(msg);
+ const char *source = ast_json_string_get(ast_json_object_get(obj->blob, "source"));
+
+ channel_string = ast_manager_build_channel_state_string(obj->snapshot);
+ if (!channel_string) {
+ return NULL;
+ }
+
+ return ast_manager_event_blob_create(EVENT_FLAG_CALL, "SessionTimeout",
+ "%s"
+ "Source: %s\r\n",
+ ast_str_buffer(channel_string), source);
+}
+
+/*! \brief Sends a session timeout channel blob used to produce SessionTimeout AMI messages */
+static void send_session_timeout(struct ast_channel *chan, const char *source)
+{
+ RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
+
+ ast_assert(chan != NULL);
+ ast_assert(source != NULL);
+
+ blob = ast_json_pack("{s: s}", "source", source);
+ if (!blob) {
+ return;
+ }
+
+ ast_channel_publish_blob(chan, session_timeout_type(), blob);
+}
+
/*!
* \brief helper function for the monitoring thread -- seems to be called with the assumption that the dialog is locked
*
@@ -28540,8 +28586,8 @@
}
ast_log(LOG_NOTICE, "Disconnecting call '%s' for lack of RTP activity in %ld seconds\n",
ast_channel_name(dialog->owner), (long) (t - dialog->lastrtprx));
- manager_event(EVENT_FLAG_CALL, "SessionTimeout", "Source: RTPTimeout\r\n"
- "Channel: %s\r\nUniqueid: %s\r\n", ast_channel_name(dialog->owner), ast_channel_uniqueid(dialog->owner));
+ send_session_timeout(dialog->owner, "RTPTimeout");
+
/* Issue a softhangup */
ast_softhangup_nolock(dialog->owner, AST_SOFTHANGUP_DEV);
ast_channel_unlock(dialog->owner);
@@ -28820,8 +28866,7 @@
sip_pvt_lock(p);
}
- manager_event(EVENT_FLAG_CALL, "SessionTimeout", "Source: SIPSessionTimer\r\n"
- "Channel: %s\r\nUniqueid: %s\r\n", ast_channel_name(p->owner), ast_channel_uniqueid(p->owner));
+ send_session_timeout(p->owner, "SIPSessionTimer");
ast_softhangup_nolock(p->owner, AST_SOFTHANGUP_DEV);
ast_channel_unlock(p->owner);
sip_pvt_unlock(p);
@@ -29558,10 +29603,6 @@
callid = ast_callid_unref(callid);
}
- if (sip_cfg.callevents)
- manager_event(EVENT_FLAG_SYSTEM, "ChannelUpdate",
- "Channel: %s\r\nChanneltype: %s\r\nSIPcallid: %s\r\nSIPfullcontact: %s\r\nPeername: %s\r\n",
- p->owner? ast_channel_name(p->owner) : "", "SIP", p->callid, p->fullcontact, p->peername);
sip_pvt_unlock(p);
if (!tmpc) {
dialog_unlink_all(p);
@@ -31167,7 +31208,6 @@
/* Misc settings for the channel */
global_relaxdtmf = FALSE;
- sip_cfg.callevents = DEFAULT_CALLEVENTS;
global_authfailureevents = FALSE;
global_t1 = DEFAULT_TIMER_T1;
global_timer_b = 64 * DEFAULT_TIMER_T1;
@@ -31648,8 +31688,6 @@
ast_log(LOG_WARNING, "Invalid qualifyfreq number '%s' at line %d of %s\n", v->value, v->lineno, config);
global_qualifyfreq = DEFAULT_QUALIFYFREQ;
}
- } else if (!strcasecmp(v->name, "callevents")) {
- sip_cfg.callevents = ast_true(v->value);
} else if (!strcasecmp(v->name, "authfailureevents")) {
global_authfailureevents = ast_true(v->value);
} else if (!strcasecmp(v->name, "maxcallbitrate")) {
@@ -32086,8 +32124,6 @@
notify_types = NULL;
}
- /* Done, tell the manager */
- manager_event(EVENT_FLAG_SYSTEM, "ChannelReload", "ChannelType: SIP\r\nReloadReason: %s\r\nRegistry_Count: %d\r\nPeer_Count: %d\r\n", channelreloadreason2txt(reason), registry_count, peer_count);
run_end = time(0);
ast_debug(4, "SIP reload_config done...Runtime= %d sec\n", (int)(run_end-run_start));
@@ -34066,6 +34102,10 @@
{
ast_verbose("SIP channel loading...\n");
+ if (STASIS_MESSAGE_TYPE_INIT(session_timeout_type)) {
+ return AST_MODULE_LOAD_FAILURE;
+ }
+
if (!(sip_tech.capabilities = ast_format_cap_alloc())) {
return AST_MODULE_LOAD_FAILURE;
}
@@ -34432,6 +34472,8 @@
ast_format_cap_destroy(sip_tech.capabilities);
sip_cfg.caps = ast_format_cap_destroy(sip_cfg.caps);
+ STASIS_MESSAGE_TYPE_CLEANUP(session_timeout_type);
+
return 0;
}
Modified: team/qwell/system_registry/channels/sig_analog.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/system_registry/channels/sig_analog.c?view=diff&rev=393306&r1=393305&r2=393306
==============================================================================
--- team/qwell/system_registry/channels/sig_analog.c (original)
+++ team/qwell/system_registry/channels/sig_analog.c Mon Jul 1 09:36:05 2013
@@ -2622,6 +2622,19 @@
return ast_pthread_create_detached(&threadid, NULL, __analog_ss_thread, p);
}
+static void analog_publish_channel_alarm_clear(int channel)
+{
+ RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
+
+ ast_log(LOG_NOTICE, "Alarm cleared on channel %d\n", channel);
+ body = ast_json_pack("{s: i}", "Channel", channel);
+ if (!body) {
+ return;
+ }
+
+ ast_manager_publish_event("AlarmClear", EVENT_FLAG_SYSTEM, body);
+}
+
static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_channel *ast)
{
int res, x;
@@ -3086,14 +3099,7 @@
break;
case ANALOG_EVENT_NOALARM:
analog_set_alarm(p, 0);
- ast_log(LOG_NOTICE, "Alarm cleared on channel %d\n", p->channel);
- /*** DOCUMENTATION
- <managerEventInstance>
- <synopsis>Raised when an Alarm is cleared on an Analog channel.</synopsis>
- </managerEventInstance>
- ***/
- manager_event(EVENT_FLAG_SYSTEM, "AlarmClear",
- "Channel: %d\r\n", p->channel);
+ analog_publish_channel_alarm_clear(p->channel);
break;
case ANALOG_EVENT_WINKFLASH:
if (p->inalarm) {
@@ -3735,9 +3741,7 @@
break;
case ANALOG_EVENT_NOALARM:
analog_set_alarm(i, 0);
- ast_log(LOG_NOTICE, "Alarm cleared on channel %d\n", i->channel);
- manager_event(EVENT_FLAG_SYSTEM, "AlarmClear",
- "Channel: %d\r\n", i->channel);
+ analog_publish_channel_alarm_clear(i->channel);
break;
case ANALOG_EVENT_ALARM:
analog_set_alarm(i, 1);
@@ -3940,6 +3944,26 @@
return 0;
}
+static void analog_publish_dnd_state(int channel, const char *status)
+{
+ RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
+ RAII_VAR(struct ast_str *, dahdichan, ast_str_create(32), ast_free);
+ if (!dahdichan) {
+ return;
+ }
+
+ ast_str_set(&dahdichan, 0, "DAHDI/%d", channel);
+
+ body = ast_json_pack("{s: s, s: s}",
+ "Channel", ast_str_buffer(dahdichan),
+ "Status", status);
+ if (!body) {
+ return;
+ }
+
+ ast_manager_publish_event("DNDState", EVENT_FLAG_SYSTEM, body);
+}
+
int analog_dnd(struct analog_pvt *p, int flag)
{
if (flag == -1) {
@@ -3951,23 +3975,7 @@
ast_verb(3, "%s DND on channel %d\n",
flag ? "Enabled" : "Disabled",
p->channel);
- /*** DOCUMENTATION
- <managerEventInstance>
- <synopsis>Raised when the Do Not Disturb state is changed on an Analog channel.</synopsis>
- <syntax>
- <parameter name="Status">
- <enumlist>
- <enum name="enabled"/>
- <enum name="disabled"/>
- </enumlist>
- </parameter>
- </syntax>
- </managerEventInstance>
- ***/
- manager_event(EVENT_FLAG_SYSTEM, "DNDState",
- "Channel: DAHDI/%d\r\n"
- "Status: %s\r\n", p->channel,
- flag ? "enabled" : "disabled");
+ analog_publish_dnd_state(p->channel, flag ? "enabled" : "disabled");
return 0;
}
Modified: team/qwell/system_registry/channels/sig_pri.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/system_registry/channels/sig_pri.c?view=diff&rev=393306&r1=393305&r2=393306
==============================================================================
--- team/qwell/system_registry/channels/sig_pri.c (original)
+++ team/qwell/system_registry/channels/sig_pri.c Mon Jul 1 09:36:05 2013
@@ -25,6 +25,68 @@
/*** MODULEINFO
<support_level>core</support_level>
+ ***/
+/*** DOCUMENTATION
+ <managerEvent language="en_US" name="MCID">
+ <managerEventInstance class="EVENT_FLAG_CALL">
+ <synopsis>Published when a malicious call ID request arrives.</synopsis>
+ <syntax>
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
+ <parameter name="MCallerIDNumValid">
+ </parameter>
+ <parameter name="MCallerIDNum">
+ </parameter>
+ <parameter name="MCallerIDton">
+ </parameter>
+ <parameter name="MCallerIDNumPlan">
+ </parameter>
+ <parameter name="MCallerIDNumPres">
+ </parameter>
+ <parameter name="MCallerIDNameValid">
+ </parameter>
+ <parameter name="MCallerIDName">
+ </parameter>
+ <parameter name="MCallerIDNameCharSet">
+ </parameter>
+ <parameter name="MCallerIDNamePres">
+ </parameter>
[... 813 lines stripped ...]
More information about the asterisk-commits
mailing list