[asterisk-commits] tilghman: trunk r92999 - /trunk/res/res_agi.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Dec 14 11:29:27 CST 2007
Author: tilghman
Date: Fri Dec 14 11:29:27 2007
New Revision: 92999
URL: http://svn.digium.com/view/asterisk?view=rev&rev=92999
Log:
Publish the AGI events to manager.
Reported by: moy
Patch by: moy,tilghman
(Closes issue #11337)
Modified:
trunk/res/res_agi.c
Modified: trunk/res/res_agi.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_agi.c?view=diff&rev=92999&r1=92998&r2=92999
==============================================================================
--- trunk/res/res_agi.c (original)
+++ trunk/res/res_agi.c Fri Dec 14 11:29:27 2007
@@ -53,6 +53,7 @@
#include "asterisk/agi.h"
#include "asterisk/version.h"
#include "asterisk/speech.h"
+#include "asterisk/manager.h"
#define MAX_ARGS 128
#define AGI_NANDFS_RETRY 3
@@ -2150,7 +2151,15 @@
char *argv[MAX_ARGS];
int argc = MAX_ARGS, res;
agi_command *c;
-
+ const char *ami_res = "Unknown Result";
+ char *ami_cmd = ast_strdupa(buf);
+ int command_id = ast_random(), resultcode = 200;
+
+ manager_event(EVENT_FLAG_CALL, "AGIExec",
+ "SubEvent: Start\r\n"
+ "Channel: %s\r\n"
+ "CommandId: %d\r\n"
+ "Command: %s\r\n", chan->name, command_id, ami_cmd);
parse_args(buf, &argc, argv);
if ((c = find_command(argv, 0)) && (!dead || (dead && c->dead))) {
/* if this command wasnt registered by res_agi, be sure to usecount
@@ -2160,6 +2169,19 @@
res = c->handler(chan, agi, argc, argv);
if (c->mod != ast_module_info->self)
ast_module_unref(c->mod);
+ switch (res) {
+ case RESULT_SHOWUSAGE: ami_res = "Usage"; resultcode = 520; break;
+ case AST_PBX_KEEPALIVE: ami_res = "KeepAlive"; resultcode = 210; break;
+ case RESULT_FAILURE: ami_res = "Failure"; resultcode = -1; break;
+ case RESULT_SUCCESS: ami_res = "Success"; resultcode = 200; break;
+ }
+ manager_event(EVENT_FLAG_CALL, "AGIExec",
+ "SubEvent: End\r\n"
+ "Channel: %s\r\n"
+ "CommandId: %d\r\n"
+ "Command: %s\r\n"
+ "ResultCode: %d\r\n"
+ "Result: %s\r\n", chan->name, command_id, ami_cmd, resultcode, ami_res);
switch(res) {
case RESULT_SHOWUSAGE:
ast_agi_fdprintf(chan, agi->fd, "520-Invalid command syntax. Proper usage follows:\n");
@@ -2177,8 +2199,22 @@
}
} else if ((c = find_command(argv, 0))) {
ast_agi_fdprintf(chan, agi->fd, "511 Command Not Permitted on a dead channel\n");
+ manager_event(EVENT_FLAG_CALL, "AGIExec",
+ "SubEvent: End\r\n"
+ "Channel: %s\r\n"
+ "CommandId: %d\r\n"
+ "Command: %s\r\n"
+ "ResultCode: 511\r\n"
+ "Result: Command not permitted on a dead channel\r\n", chan->name, command_id, ami_cmd);
} else {
ast_agi_fdprintf(chan, agi->fd, "510 Invalid or unknown command\n");
+ manager_event(EVENT_FLAG_CALL, "AGIExec",
+ "SubEvent: End\r\n"
+ "Channel: %s\r\n"
+ "CommandId: %d\r\n"
+ "Command: %s\r\n"
+ "ResultCode: 510\r\n"
+ "Result: Invalid or unknown command\r\n", chan->name, command_id, ami_cmd);
}
return 0;
}
More information about the asterisk-commits
mailing list