From: Matthew Jordan Date: Tue, 10 Jul 2012 22:26:27 +0000 (+0000) Subject: Add some additional documentation for core AMI events X-Git-Tag: 11.0.0-beta1~134 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2ffae5745d6d68f1599f4dfbf0ead131cf5acc32;p=thirdparty%2Fasterisk.git Add some additional documentation for core AMI events This patch adds some basic documentation for a number of modules. This includes core source files in Asterisk (those in main), as well as chan_agent, chan_dahdi, chan_local, sig_analog, and sig_pri. The DTD has also been updated to allow referencing of AMI commands. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@369905 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/chan_agent.c b/channels/chan_agent.c index 2468b091e1..888f068315 100644 --- a/channels/chan_agent.c +++ b/channels/chan_agent.c @@ -2133,6 +2133,20 @@ static int login_exec(struct ast_channel *chan, const char *data) !ast_strlen_zero(p->moh) ? strlen(p->moh) + 1 : 0); if (p->loginstart == 0) time(&p->loginstart); + /*** DOCUMENTATION + + Raised when an Agent has logged in. + + + The name of the agent. + + + + AgentLogin + Agentlogoff + + + ***/ manager_event(EVENT_FLAG_AGENT, "Agentlogin", "Agent: %s\r\n" "Channel: %s\r\n" @@ -2225,6 +2239,17 @@ static int login_exec(struct ast_channel *chan, const char *data) logintime = time(NULL) - p->loginstart; p->loginstart = 0; ast_mutex_unlock(&p->lock); + /*** DOCUMENTATION + + Raised when an Agent has logged off. + + + + + Agentlogin + + + ***/ manager_event(EVENT_FLAG_AGENT, "Agentlogoff", "Agent: %s\r\n" "Logintime: %ld\r\n" diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c index 59841d1bd7..b15caa5bef 100644 --- a/channels/chan_dahdi.c +++ b/channels/chan_dahdi.c @@ -2175,6 +2175,11 @@ static void dahdi_ami_channel_event(struct dahdi_pvt *p, struct ast_channel *cha /* Real channel */ snprintf(ch_name, sizeof(ch_name), "%d", p->channel); } + /*** DOCUMENTATION + + Raised when a DAHDI channel is created or an underlying technology is associated with a DAHDI channel. + + ***/ ast_manager_event(chan, EVENT_FLAG_CALL, "DAHDIChannel", "Channel: %s\r\n" "Uniqueid: %s\r\n" @@ -3866,10 +3871,20 @@ static void handle_clear_alarms(struct dahdi_pvt *p) if (report_alarms & REPORT_CHANNEL_ALARMS) { ast_log(LOG_NOTICE, "Alarm cleared on channel %d\n", p->channel); + /*** DOCUMENTATION + + Raised when an alarm is cleared on a DAHDI channel. + + ***/ manager_event(EVENT_FLAG_SYSTEM, "AlarmClear", "Channel: %d\r\n", 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 + + Raised when an alarm is cleared on a DAHDI span. + + ***/ manager_event(EVENT_FLAG_SYSTEM, "SpanAlarmClear", "Span: %d\r\n", p->span); } } @@ -7972,6 +7987,11 @@ static void handle_alarms(struct dahdi_pvt *p, int alms) 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 + + Raised when an alarm is set on a DAHDI channel. + + ***/ manager_event(EVENT_FLAG_SYSTEM, "Alarm", "Alarm: %s\r\n" "Channel: %d\r\n", @@ -7980,6 +8000,11 @@ static void handle_alarms(struct dahdi_pvt *p, int alms) 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 + + Raised when an alarm is set on a DAHDI span. + + ***/ manager_event(EVENT_FLAG_SYSTEM, "SpanAlarm", "Alarm: %s\r\n" "Span: %d\r\n", @@ -10027,6 +10052,19 @@ static int dahdi_dnd(struct dahdi_pvt *dahdichan, int flag) ast_verb(3, "%s DND on channel %d\n", flag? "Enabled" : "Disabled", dahdichan->channel); + /*** DOCUMENTATION + + Raised when the Do Not Disturb state is changed on a DAHDI channel. + + + + + + + + + + ***/ manager_event(EVENT_FLAG_SYSTEM, "DNDState", "Channel: DAHDI/%d\r\n" "Status: %s\r\n", dahdichan->channel, diff --git a/channels/chan_local.c b/channels/chan_local.c index 5e72a6153c..20e46c9aa0 100644 --- a/channels/chan_local.c +++ b/channels/chan_local.c @@ -955,6 +955,31 @@ static int local_call(struct ast_channel *ast, const char *dest, int timeout) goto return_cleanup; } + /*** DOCUMENTATION + + Raised when two halves of a Local Channel form a bridge. + + + The name of the Local Channel half that bridges to another channel. + + + The name of the Local Channel half that executes the dialplan. + + + The context in the dialplan that Channel2 starts in. + + + The extension in the dialplan that Channel2 starts in. + + + + + + + + + + ***/ manager_event(EVENT_FLAG_CALL, "LocalBridge", "Channel1: %s\r\n" "Channel2: %s\r\n" diff --git a/channels/sig_analog.c b/channels/sig_analog.c index cf51e97270..e84bbc6f8c 100644 --- a/channels/sig_analog.c +++ b/channels/sig_analog.c @@ -3138,6 +3138,11 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_ case ANALOG_EVENT_NOALARM: analog_set_alarm(p, 0); ast_log(LOG_NOTICE, "Alarm cleared on channel %d\n", p->channel); + /*** DOCUMENTATION + + Raised when an Alarm is cleared on an Analog channel. + + ***/ manager_event(EVENT_FLAG_SYSTEM, "AlarmClear", "Channel: %d\r\n", p->channel); break; @@ -4013,6 +4018,19 @@ int analog_dnd(struct analog_pvt *p, int flag) ast_verb(3, "%s DND on channel %d\n", flag ? "Enabled" : "Disabled", p->channel); + /*** DOCUMENTATION + + Raised when the Do Not Disturb state is changed on an Analog channel. + + + + + + + + + + ***/ manager_event(EVENT_FLAG_SYSTEM, "DNDState", "Channel: DAHDI/%d\r\n" "Status: %s\r\n", p->channel, diff --git a/channels/sig_pri.c b/channels/sig_pri.c index 31438a9450..248999073a 100644 --- a/channels/sig_pri.c +++ b/channels/sig_pri.c @@ -5153,6 +5153,19 @@ static void sig_pri_moh_fsm_event(struct ast_channel *chan, struct sig_pri_chan */ static void sig_pri_ami_hold_event(struct ast_channel *chan, int is_held) { + /*** DOCUMENTATION + + Raised when a PRI channel is put on Hold. + + + + + + + + + + ***/ ast_manager_event(chan, EVENT_FLAG_CALL, "Hold", "Status: %s\r\n" "Channel: %s\r\n" diff --git a/doc/appdocsxml.dtd b/doc/appdocsxml.dtd index 59f91c33c2..d5815648e5 100644 --- a/doc/appdocsxml.dtd +++ b/doc/appdocsxml.dtd @@ -39,7 +39,7 @@ - + diff --git a/main/asterisk.c b/main/asterisk.c index d55f46a63d..0a801c1a66 100644 --- a/main/asterisk.c +++ b/main/asterisk.c @@ -1779,6 +1779,25 @@ static void really_quit(int num, shutdown_nice_t niceness, int restart) /* Called on exit */ ast_verb(0, "Asterisk %s ending (%d).\n", ast_active_channels() ? "uncleanly" : "cleanly", num); ast_debug(1, "Asterisk ending (%d).\n", num); + /*** DOCUMENTATION + + Raised when Asterisk is shutdown or restarted. + + + + + + + + + + + + + + + + ***/ manager_event(EVENT_FLAG_SYSTEM, "Shutdown", "Shutdown: %s\r\nRestart: %s\r\n", ast_active_channels() ? "Uncleanly" : "Cleanly", restart ? "True" : "False"); if (ast_socket > -1) { pthread_cancel(lthread); @@ -4105,6 +4124,11 @@ int main(int argc, char *argv[]) } ast_set_flag(&ast_options, AST_OPT_FLAG_FULLY_BOOTED); + /*** DOCUMENTATION + + Raised when all Asterisk initialization procedures have finished. + + ***/ manager_event(EVENT_FLAG_SYSTEM, "FullyBooted", "Status: Fully Booted\r\n"); ast_process_pending_reloads(); diff --git a/main/cdr.c b/main/cdr.c index 7847dc4562..295108d76b 100644 --- a/main/cdr.c +++ b/main/cdr.c @@ -1039,7 +1039,11 @@ int ast_cdr_setaccount(struct ast_channel *chan, const char *account) ast_copy_string(cdr->accountcode, ast_channel_accountcode(chan), sizeof(cdr->accountcode)); } } - + /*** DOCUMENTATION + + Raised when a CDR's AccountCode is changed. + + ***/ ast_manager_event(chan, EVENT_FLAG_CALL, "NewAccountCode", "Channel: %s\r\n" "Uniqueid: %s\r\n" @@ -1065,7 +1069,11 @@ int ast_cdr_setpeeraccount(struct ast_channel *chan, const char *account) ast_copy_string(cdr->peeraccount, ast_channel_peeraccount(chan), sizeof(cdr->peeraccount)); } } - + /*** DOCUMENTATION + + Raised when a CDR's PeerAccount is changed. + + ***/ ast_manager_event(chan, EVENT_FLAG_CALL, "NewPeerAccount", "Channel: %s\r\n" "Uniqueid: %s\r\n" diff --git a/main/channel.c b/main/channel.c index 0f4c3bc775..6b1f3063c8 100644 --- a/main/channel.c +++ b/main/channel.c @@ -1125,6 +1125,15 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char * a lot of data into this func to do it here! */ if (ast_get_channel_tech(tech) || (tech2 && ast_get_channel_tech(tech2))) { + /*** DOCUMENTATION + + Raised when a new channel is created. + + + + + + ***/ ast_manager_event(tmp, EVENT_FLAG_CALL, "Newchannel", "Channel: %s\r\n" "ChannelState: %d\r\n" @@ -1329,7 +1338,11 @@ int ast_queue_hangup(struct ast_channel *chan) /* Yeah, let's not change a lock-critical value without locking */ ast_channel_lock(chan); ast_channel_softhangup_internal_flag_add(chan, AST_SOFTHANGUP_DEV); - + /*** DOCUMENTATION + + Raised when a hangup is requested with no set cause. + + ***/ manager_event(EVENT_FLAG_CALL, "HangupRequest", "Channel: %s\r\n" "Uniqueid: %s\r\n", @@ -1357,7 +1370,14 @@ int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause) if (cause < 0) { f.data.uint32 = ast_channel_hangupcause(chan); } - + /*** DOCUMENTATION + + Raised when a hangup is requested with a specific cause code. + + + + + ***/ manager_event(EVENT_FLAG_CALL, "HangupRequest", "Channel: %s\r\n" "Uniqueid: %s\r\n" @@ -2545,6 +2565,14 @@ int ast_softhangup(struct ast_channel *chan, int cause) ast_channel_lock(chan); res = ast_softhangup_nolock(chan, cause); + /*** DOCUMENTATION + + Raised when a soft hangup is requested with a specific cause code. + + + + + ***/ manager_event(EVENT_FLAG_CALL, "SoftHangupRequest", "Channel: %s\r\n" "Uniqueid: %s\r\n" @@ -2707,6 +2735,19 @@ int ast_hangup(struct ast_channel *chan) ast_channel_unlock(chan); ast_cc_offer(chan); + /*** DOCUMENTATION + + Raised when a channel is hung up. + + + A numeric cause code for why the channel was hung up. + + + A description of why the channel was hung up. + + + + ***/ ast_manager_event(chan, EVENT_FLAG_CALL, "Hangup", "Channel: %s\r\n" "Uniqueid: %s\r\n" @@ -3522,6 +3563,31 @@ int ast_waitfordigit_full(struct ast_channel *c, int ms, int audiofd, int cmdfd) static void send_dtmf_event(struct ast_channel *chan, const char *direction, const char digit, const char *begin, const char *end) { + /*** DOCUMENTATION + + Raised when a DTMF digit has started or ended on a channel. + + + + + + + + + + + + + + + + + + + + + + ***/ ast_manager_event(chan, EVENT_FLAG_DTMF, "DTMF", "Channel: %s\r\n" @@ -6224,6 +6290,11 @@ int ast_channel_transfer_masquerade( */ static void __ast_change_name_nolink(struct ast_channel *chan, const char *newname) { + /*** DOCUMENTATION + + Raised when the name of a channel is changed. + + ***/ ast_manager_event(chan, EVENT_FLAG_CALL, "Rename", "Channel: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", ast_channel_name(chan), newname, ast_channel_uniqueid(chan)); ast_channel_name_set(chan, newname); } @@ -6471,6 +6542,16 @@ static void report_new_callerid(struct ast_channel *chan) int pres; pres = ast_party_id_presentation(&ast_channel_caller(chan)->id); + /*** DOCUMENTATION + + Raised when a channel receives new Caller ID information. + + + A description of the Caller ID presentation. + + + + ***/ ast_manager_event(chan, EVENT_FLAG_CALL, "NewCallerid", "Channel: %s\r\n" "CallerIDNum: %s\r\n" @@ -6665,6 +6746,25 @@ int ast_do_masquerade(struct ast_channel *original) chans[0] = clonechan; chans[1] = original; + /*** DOCUMENTATION + + Raised when a masquerade occurs between two channels, wherein the Clone channel's internal information replaces the Original channel's information. + + + The name of the channel whose information will be going into the Original channel. + + + The current state of the clone channel. + + + The name of the channel whose information will be replaced by the Clone channel's information. + + + The current state of the original channel. + + + + ***/ ast_manager_event_multichan(EVENT_FLAG_CALL, "Masquerade", 2, chans, "Clone: %s\r\n" "CloneState: %s\r\n" @@ -7058,6 +7158,31 @@ int ast_setstate(struct ast_channel *chan, enum ast_channel_state state) ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, name); /* setstate used to conditionally report Newchannel; this is no more */ + /*** DOCUMENTATION + + Raised when a channel's state changes. + + + A numeric code for the channel's current state, related to ChannelStateDesc + + + + + + + + + + + + + + + + + + + ***/ ast_manager_event(chan, EVENT_FLAG_CALL, "Newstate", "Channel: %s\r\n" "ChannelState: %d\r\n" @@ -7353,6 +7478,25 @@ int ast_channel_early_bridge(struct ast_channel *c0, struct ast_channel *c1) static void manager_bridge_event(int onoff, int type, struct ast_channel *c0, struct ast_channel *c1) { struct ast_channel *chans[2] = { c0, c1 }; + /*** DOCUMENTATION + + Raised when a bridge changes between two channels. + + + + + + + + + + + + + + + + ***/ ast_manager_event_multichan(EVENT_FLAG_CALL, "Bridge", 2, chans, "Bridgestate: %s\r\n" "Bridgetype: %s\r\n" diff --git a/main/features.c b/main/features.c index b602dbb98f..420cdaf79b 100644 --- a/main/features.c +++ b/main/features.c @@ -471,6 +471,42 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") FEATURE + + + Raised when a parked call times out. + + + + + + + + + + + + ParkedCall + + + + + + Raised when a parked call hangs up while in the parking lot. + + + + + + + + + + + + ParkedCall + + + ***/ #define DEFAULT_PARK_TIME 45000 /*!< ms */ @@ -1658,7 +1694,28 @@ static int park_call_full(struct ast_channel *chan, struct ast_channel *peer, st pu->context, pu->exten, pu->priority, (pu->parkingtime / 1000)); ast_cel_report_event(chan, AST_CEL_PARK_START, NULL, pu->parkinglot->name, peer); - + /*** DOCUMENTATION + + Raised when a call has been parked. + + + The parking lot extension. + + + The name of the parking lot. + + + The name of the channel that parked the call. + + + + Park + Park + ParkedCallTimeOut + ParkedCallGiveUp + + + ***/ ast_manager_event(chan, EVENT_FLAG_CALL, "ParkedCall", "Exten: %s\r\n" "Channel: %s\r\n" @@ -5417,6 +5474,20 @@ static int parked_call_exec(struct ast_channel *chan, const char *data) } ast_cel_report_event(pu->chan, AST_CEL_PARK_END, NULL, "UnParkedCall", chan); + /*** DOCUMENTATION + + Raised when a call has been unparked. + + + + + + + ParkedCall + ParkedCall + + + ***/ ast_manager_event(pu->chan, EVENT_FLAG_CALL, "UnParkedCall", "Exten: %s\r\n" "Channel: %s\r\n" @@ -7274,7 +7345,22 @@ static int action_bridge(struct mansession *s, const struct message *m) chans[0] = tmpchana; chans[1] = tmpchanb; - + /*** DOCUMENTATION + + Raised when a bridge is successfully created due to a manager action. + + + + + + + + + + Bridge + + + ***/ ast_manager_event_multichan(EVENT_FLAG_CALL, "BridgeAction", 2, chans, "Response: Success\r\n" "Channel1: %s\r\n" @@ -7702,6 +7788,15 @@ int ast_do_pickup(struct ast_channel *chan, struct ast_channel *target) } /* If you want UniqueIDs, set channelvars in manager.conf to CHANNEL(uniqueid) */ + /*** DOCUMENTATION + + Raised when a call pickup occurs. + + The name of the channel that initiated the pickup. + The name of the channel that is being picked up. + + + ***/ ast_manager_event_multichan(EVENT_FLAG_CALL, "Pickup", 2, chans, "Channel: %s\r\n" "TargetChannel: %s\r\n", @@ -7908,6 +8003,14 @@ static int bridge_exec(struct ast_channel *chan, const char *data) /* avoid bridge with ourselves */ if (!strcmp(ast_channel_name(chan), args.dest_chan)) { ast_log(LOG_WARNING, "Unable to bridge channel %s with itself\n", ast_channel_name(chan)); + /*** DOCUMENTATION + + Raised when an error occurs during bridge creation. + + Bridge + + + ***/ ast_manager_event(chan, EVENT_FLAG_CALL, "BridgeExec", "Response: Failed\r\n" "Reason: Unable to bridge channel to itself\r\n" @@ -7999,6 +8102,14 @@ static int bridge_exec(struct ast_channel *chan, const char *data) } /* Report that the bridge will be successfull */ + /*** DOCUMENTATION + + Raised when the bridge is created successfully. + + Bridge + + + ***/ ast_manager_event_multichan(EVENT_FLAG_CALL, "BridgeExec", 2, chans, "Response: Success\r\n" "Channel1: %s\r\n" diff --git a/main/loader.c b/main/loader.c index e9b92bbdad..b952137354 100644 --- a/main/loader.c +++ b/main/loader.c @@ -1162,6 +1162,19 @@ done: /* Tell manager clients that are aggressive at logging in that we're done loading modules. If there's a DNS problem in chan_sip, we might not even reach this */ + /*** DOCUMENTATION + + Raised when all dynamic modules have finished their initial loading. + + + + + + + + + + ***/ manager_event(EVENT_FLAG_SYSTEM, "ModuleLoadReport", "ModuleLoadStatus: Done\r\nModuleSelection: %s\r\nModuleCount: %d\r\n", preload_only ? "Preload" : "All", modulecount); return res; diff --git a/main/logger.c b/main/logger.c index ca2648190a..6d6227bfc4 100644 --- a/main/logger.c +++ b/main/logger.c @@ -793,6 +793,16 @@ static int reload_logger(int rotate, const char *altconf) AST_RWLIST_TRAVERSE(&logchannels, f, list) { if (f->disabled) { f->disabled = 0; /* Re-enable logging at reload */ + /*** DOCUMENTATION + + Raised when a logging channel is re-enabled after a reload operation. + + + The name of the logging channel. + + + + ***/ manager_event(EVENT_FLAG_SYSTEM, "LogChannel", "Channel: %s\r\nEnabled: Yes\r\n", f->filename); } if (f->fileptr && (f->fileptr != stdout) && (f->fileptr != stderr)) { @@ -1089,6 +1099,16 @@ static void logger_print_normal(struct logmsg *logmsg) fprintf(stderr, "Asterisk logging error: Out of disk space, can't log to log file %s\n", chan->filename); else fprintf(stderr, "Logger Warning: Unable to write to log file '%s': %s (disabled)\n", chan->filename, strerror(errno)); + /*** DOCUMENTATION + + Raised when a logging channel is disabled. + + + The name of the logging channel. + + + + ***/ manager_event(EVENT_FLAG_SYSTEM, "LogChannel", "Channel: %s\r\nEnabled: No\r\nReason: %d - %s\r\n", chan->filename, errno, strerror(errno)); chan->disabled = 1; } else if (res > 0) { diff --git a/main/manager.c b/main/manager.c index 3eb1133224..d70ac6d152 100644 --- a/main/manager.c +++ b/main/manager.c @@ -476,7 +476,34 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") Extension/Context/Priority or Application/Data + + OriginateResponse + + + + Raised in response to an Originate command. + + + + + + + + + + + + + + + + + + Originate + + + Execute Asterisk CLI Command. @@ -5535,7 +5562,11 @@ static int manager_state_cb(char *context, char *exten, struct ast_state_cb_info } ast_get_hint(hint, sizeof(hint), NULL, 0, NULL, context, exten); - + /*** DOCUMENTATION + + Raised when an extension state has changed. + + ***/ manager_event(EVENT_FLAG_CALL, "ExtensionStatus", "Exten: %s\r\nContext: %s\r\nHint: %s\r\nStatus: %d\r\n", exten, context, hint, state); return 0; } diff --git a/main/pbx.c b/main/pbx.c index 95f6fda628..cbfbafa696 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -4414,6 +4414,19 @@ static int pbx_extension_helper(struct ast_channel *c, struct ast_context *con, term_color(tmp3, passdata, COLOR_BRMAGENTA, 0, sizeof(tmp3)), "in new stack"); } + /*** DOCUMENTATION + + Raised when a channel enters a new context, extension, priority. + + + The application about to be executed. + + + The data to be passed to the application. + + + + ***/ manager_event(EVENT_FLAG_DIALPLAN, "Newexten", "Channel: %s\r\n" "Context: %s\r\n" @@ -10922,6 +10935,11 @@ int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const ast_verb(2, "Setting global variable '%s' to '%s'\n", name, value); newvariable = ast_var_assign(name, value); AST_LIST_INSERT_HEAD(headp, newvariable, entries); + /*** DOCUMENTATION + + Raised when a variable is set to a particular value. + + ***/ manager_event(EVENT_FLAG_DIALPLAN, "VarSet", "Channel: %s\r\n" "Variable: %s\r\n"