[asterisk-commits] mmichelson: branch group/manager2 r103476 - in /team/group/manager2: apps/ in...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Feb 12 14:57:46 CST 2008
Author: mmichelson
Date: Tue Feb 12 14:57:45 2008
New Revision: 103476
URL: http://svn.digium.com/view/asterisk?view=rev&rev=103476
Log:
1. Move the definition of ast_event_iterator to event_defs.h so that its size will be known.
This will allow compilation to not fail if the structure is used in a file that includes
event.h. A similar tactic is used for the astobj2 ao2_iterator.
2. Created an enum of informational IE's for queues as well as a table that maps the IE's to their
payload type and their "name" for manager purposes.
3. Wrote a small res module that subscribes to AST_EVENT_INFO events and spits back the IE's to the
CLI as debug messages. Right now, there are problems here since some values printed appear to be bogus
and this will occasionally segfault. Will work out what the problem is soon.
Added:
team/group/manager2/include/asterisk/manager2.h (with props)
team/group/manager2/res/res_manager2.c (with props)
Modified:
team/group/manager2/apps/app_queue.c
team/group/manager2/include/asterisk/event_defs.h
team/group/manager2/main/event.c
Modified: team/group/manager2/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/group/manager2/apps/app_queue.c?view=diff&rev=103476&r1=103475&r2=103476
==============================================================================
--- team/group/manager2/apps/app_queue.c (original)
+++ team/group/manager2/apps/app_queue.c Tue Feb 12 14:57:45 2008
@@ -92,7 +92,7 @@
#include "asterisk/astobj2.h"
#include "asterisk/strings.h"
#include "asterisk/global_datastores.h"
-
+#include "asterisk/manager2.h"
/* Please read before modifying this file.
* There are three locks which are regularly used
* throughout this file, the queue list lock, the lock
@@ -712,6 +712,7 @@
while ((cur = ao2_iterator_next(&mem_iter))) {
char *interface;
char *slash_pos;
+ struct ast_event *event = NULL;
interface = ast_strdupa(cur->state_interface);
if ((slash_pos = strchr(interface, '/')))
if ((slash_pos = strchr(slash_pos + 1, '/')))
@@ -729,6 +730,19 @@
continue;
}
+ event = ast_event_new(AST_EVENT_INFO,
+ AST_EVENT_IE_INFO_QUEUE_NAME, AST_EVENT_IE_PLTYPE_STR, q->name,
+ AST_EVENT_IE_INFO_QUEUE_INTERFACE, AST_EVENT_IE_PLTYPE_STR, cur->interface,
+ AST_EVENT_IE_INFO_QUEUE_MEMBER_NAME, AST_EVENT_IE_PLTYPE_STR, cur->membername,
+ AST_EVENT_IE_INFO_QUEUE_MEMBERSHIP, AST_EVENT_IE_PLTYPE_STR, cur->dynamic ? "dynamic " : cur->realtime ? "realtime" : "static",
+ AST_EVENT_IE_INFO_QUEUE_PENALTY, AST_EVENT_IE_PLTYPE_UINT, cur->penalty,
+ AST_EVENT_IE_INFO_QUEUE_CALLS, AST_EVENT_IE_PLTYPE_UINT, cur->calls,
+ AST_EVENT_IE_INFO_QUEUE_LASTCALL, AST_EVENT_IE_PLTYPE_UINT, cur->lastcall,
+ AST_EVENT_IE_INFO_QUEUE_STATUS, AST_EVENT_IE_PLTYPE_STR, devstate2str(cur->status),
+ AST_EVENT_IE_INFO_QUEUE_PAUSED, AST_EVENT_IE_PLTYPE_UINT, cur->paused,
+ AST_EVENT_IE_END);
+ ast_event_queue(event);
+/*
manager_event(EVENT_FLAG_AGENT, "QueueMemberStatus",
"Queue: %s\r\n"
"Location: %s\r\n"
@@ -741,6 +755,7 @@
"Paused: %d\r\n",
q->name, cur->interface, cur->membername, cur->dynamic ? "dynamic" : cur->realtime ? "realtime" : "static",
cur->penalty, cur->calls, (int)cur->lastcall, cur->status, cur->paused);
+*/
}
ao2_ref(cur, -1);
}
Modified: team/group/manager2/include/asterisk/event_defs.h
URL: http://svn.digium.com/view/asterisk/team/group/manager2/include/asterisk/event_defs.h?view=diff&rev=103476&r1=103475&r2=103476
==============================================================================
--- team/group/manager2/include/asterisk/event_defs.h (original)
+++ team/group/manager2/include/asterisk/event_defs.h Tue Feb 12 14:57:45 2008
@@ -44,8 +44,10 @@
AST_EVENT_UNSUB = 0x04,
/*! The state of a device has changed */
AST_EVENT_DEVICE_STATE = 0x05,
+ /*! Informational events */
+ AST_EVENT_INFO = 0x06,
/*! Number of event types. This should be the last event type + 1 */
- AST_EVENT_TOTAL = 0x06,
+ AST_EVENT_TOTAL = 0x07,
};
/*! \brief Event Information Element types */
@@ -138,6 +140,15 @@
struct ast_event;
struct ast_event_ie;
struct ast_event_sub;
-struct ast_event_iterator;
+
+/*I had to define the ast_event_iterator structure
+ * fully here in this file so that its size could be
+ * known. It is designed not to be directly accessed though
+ */
+struct ast_event_iterator {
+ uint16_t event_len;
+ const struct ast_event *event;
+ struct ast_event_ie *ie;
+};
#endif /* AST_EVENT_DEFS_H */
Added: team/group/manager2/include/asterisk/manager2.h
URL: http://svn.digium.com/view/asterisk/team/group/manager2/include/asterisk/manager2.h?view=auto&rev=103476
==============================================================================
--- team/group/manager2/include/asterisk/manager2.h (added)
+++ team/group/manager2/include/asterisk/manager2.h Tue Feb 12 14:57:45 2008
@@ -1,0 +1,86 @@
+enum ast_event_info_ie_type {
+
+/* app_queue informational IE's */
+ /*! Queue's name, string */
+ AST_EVENT_IE_INFO_QUEUE_NAME,
+ /*! Member interface, string */
+ AST_EVENT_IE_INFO_QUEUE_INTERFACE,
+ /*! Member name, string */
+ AST_EVENT_IE_INFO_QUEUE_MEMBER_NAME,
+ /*! Member penalty, int */
+ AST_EVENT_IE_INFO_QUEUE_PENALTY,
+ /*! Number of calls taken, int */
+ AST_EVENT_IE_INFO_QUEUE_CALLS,
+ /*! Time of last call, int */
+ AST_EVENT_IE_INFO_QUEUE_LASTCALL,
+ /*! Member status, string */
+ AST_EVENT_IE_INFO_QUEUE_STATUS,
+ /*! Paused status, int */
+ AST_EVENT_IE_INFO_QUEUE_PAUSED,
+ /*! Queue caller's channel name, string */
+ AST_EVENT_IE_INFO_QUEUE_SOURCE_CHANNEL,
+ /*! Queue caller's callerid number, string */
+ AST_EVENT_IE_INFO_QUEUE_CALLERIDNUM,
+ /*! Queue caller's callerid name, string */
+ AST_EVENT_IE_INFO_QUEUE_CALLERIDNAME,
+ /*! Queue caller's position, int */
+ AST_EVENT_IE_INFO_QUEUE_POSITION,
+ /*! Number of callers in queue, int */
+ AST_EVENT_IE_INFO_QUEUE_COUNT,
+ /*! Uniqueid of queue caller's channel, string */
+ AST_EVENT_IE_INFO_QUEUE_SOURCE_UNIQUEID,
+ /*! Membership of queue member, string */
+ AST_EVENT_IE_INFO_QUEUE_MEMBERSHIP, /* static, dynamic, or realtime */
+ /*! Member channel name, string */
+ AST_EVENT_IE_INFO_QUEUE_DESTINATION_CHANNEL,
+ /*! Queue context, string */
+ AST_EVENT_IE_INFO_QUEUE_CONTEXT,
+ /*! Queue extension, string */
+ AST_EVENT_IE_INFO_QUEUE_EXTENSION,
+ /*! Queue dialplan priority, int */
+ AST_EVENT_IE_INFO_QUEUE_PRIORITY,
+ /*! Original position of queue caller, int */
+ AST_EVENT_IE_INFO_QUEUE_ORIGINAL_POSITION,
+ /*! Queue's holdtime, int */
+ AST_EVENT_IE_INFO_QUEUE_HOLDTIME,
+ /*! Amount of time spent talking to queue member, int */
+ AST_EVENT_IE_INFO_QUEUE_TALKTIME,
+ /*! Reason the call ended, int */
+ AST_EVENT_IE_INFO_QUEUE_REASON,
+ /*! Amount of time queue call rang, int */
+ AST_EVENT_IE_INFO_QUEUE_RINGTIME,
+ /*! Member channel's uniqueid, string */
+ AST_EVENT_IE_INFO_QUEUE_DESTINATION_UNIQUEID,
+};
+
+struct ast_event_info_ie_map {
+ enum ast_event_info_ie_type ie_type;
+ enum ast_event_ie_pltype pltype;
+ const char * name;
+} info_map[] = {
+ {AST_EVENT_IE_INFO_QUEUE_NAME, AST_EVENT_IE_PLTYPE_STR, "QueueName"},
+ {AST_EVENT_IE_INFO_QUEUE_INTERFACE, AST_EVENT_IE_PLTYPE_STR, "Interface"},
+ {AST_EVENT_IE_INFO_QUEUE_MEMBER_NAME, AST_EVENT_IE_PLTYPE_STR, "MemberName"},
+ {AST_EVENT_IE_INFO_QUEUE_CALLS, AST_EVENT_IE_PLTYPE_UINT, "Calls"},
+ {AST_EVENT_IE_INFO_QUEUE_LASTCALL, AST_EVENT_IE_PLTYPE_UINT, "LastCall"},
+ {AST_EVENT_IE_INFO_QUEUE_STATUS, AST_EVENT_IE_PLTYPE_STR, "Status"},
+ {AST_EVENT_IE_INFO_QUEUE_PAUSED, AST_EVENT_IE_PLTYPE_UINT, "Paused"},
+ {AST_EVENT_IE_INFO_QUEUE_SOURCE_CHANNEL, AST_EVENT_IE_PLTYPE_STR, "SourceChannel"},
+ {AST_EVENT_IE_INFO_QUEUE_CALLERIDNUM, AST_EVENT_IE_PLTYPE_STR, "CallerIDNumber"},
+ {AST_EVENT_IE_INFO_QUEUE_CALLERIDNAME, AST_EVENT_IE_PLTYPE_STR, "CallerIDName"},
+ {AST_EVENT_IE_INFO_QUEUE_POSITION, AST_EVENT_IE_PLTYPE_UINT, "Position"},
+ {AST_EVENT_IE_INFO_QUEUE_COUNT, AST_EVENT_IE_PLTYPE_UINT, "Count"},
+ {AST_EVENT_IE_INFO_QUEUE_SOURCE_UNIQUEID, AST_EVENT_IE_PLTYPE_STR, "SourceUniqueID"},
+ {AST_EVENT_IE_INFO_QUEUE_MEMBERSHIP, AST_EVENT_IE_PLTYPE_STR, "Membership"},
+ {AST_EVENT_IE_INFO_QUEUE_PENALTY, AST_EVENT_IE_PLTYPE_UINT, "Penalty"},
+ {AST_EVENT_IE_INFO_QUEUE_DESTINATION_CHANNEL, AST_EVENT_IE_PLTYPE_STR, "DestinationChannel"},
+ {AST_EVENT_IE_INFO_QUEUE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, "Context"},
+ {AST_EVENT_IE_INFO_QUEUE_EXTENSION, AST_EVENT_IE_PLTYPE_STR, "Extension"},
+ {AST_EVENT_IE_INFO_QUEUE_PRIORITY, AST_EVENT_IE_PLTYPE_UINT, "Priority"},
+ {AST_EVENT_IE_INFO_QUEUE_ORIGINAL_POSITION, AST_EVENT_IE_PLTYPE_UINT, "OriginalPosition"},
+ {AST_EVENT_IE_INFO_QUEUE_HOLDTIME, AST_EVENT_IE_PLTYPE_UINT, "HoldTime"},
+ {AST_EVENT_IE_INFO_QUEUE_TALKTIME, AST_EVENT_IE_PLTYPE_UINT, "TalkTime"},
+ {AST_EVENT_IE_INFO_QUEUE_REASON, AST_EVENT_IE_PLTYPE_STR, "Reason"},
+ {AST_EVENT_IE_INFO_QUEUE_RINGTIME, AST_EVENT_IE_PLTYPE_UINT, "RingTime"},
+ {AST_EVENT_IE_INFO_QUEUE_DESTINATION_UNIQUEID, AST_EVENT_IE_PLTYPE_STR, "DestinationUniqueID"},
+};
Propchange: team/group/manager2/include/asterisk/manager2.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: team/group/manager2/include/asterisk/manager2.h
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: team/group/manager2/include/asterisk/manager2.h
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: team/group/manager2/main/event.c
URL: http://svn.digium.com/view/asterisk/team/group/manager2/main/event.c?view=diff&rev=103476&r1=103475&r2=103476
==============================================================================
--- team/group/manager2/main/event.c (original)
+++ team/group/manager2/main/event.c Tue Feb 12 14:57:45 2008
@@ -77,12 +77,6 @@
AST_LIST_ENTRY(ast_event_ref) entry;
};
-struct ast_event_iterator {
- uint16_t event_len;
- const struct ast_event *event;
- struct ast_event_ie *ie;
-};
-
/*! \brief data shared between event dispatching threads */
static struct {
ast_cond_t cond;
Added: team/group/manager2/res/res_manager2.c
URL: http://svn.digium.com/view/asterisk/team/group/manager2/res/res_manager2.c?view=auto&rev=103476
==============================================================================
--- team/group/manager2/res/res_manager2.c (added)
+++ team/group/manager2/res/res_manager2.c Tue Feb 12 14:57:45 2008
@@ -1,0 +1,47 @@
+#include "asterisk.h"
+#include "asterisk/module.h"
+#include "asterisk/event.h"
+#include "asterisk/manager2.h"
+
+struct ast_event_sub *manager_sub;
+
+/*! \brief The handler for manager subscriptions
+ * In its rudimentary stage here, all this does is iterate
+ * through the IEs in the event and print them as debug messages
+ *
+ * \param event the event we have subscribed to
+ * \param ignore unused parameter, I suspect it will one day become a filter pointer
+ */
+static void info_cb(const struct ast_event *event, void *ignore)
+{
+ struct ast_event_iterator iter;
+ int res = 0;
+
+ for(ast_event_iterator_init(&iter, event); !res; res = ast_event_iterator_next(&iter)) {
+ enum ast_event_ie_type ie_type = ast_event_iterator_get_ie_type(&iter);
+ if (ie_type == AST_EVENT_IE_END)
+ break;
+ if (info_map[ie_type].pltype == AST_EVENT_IE_PLTYPE_STR)
+ ast_log(LOG_DEBUG, "%s: %s\r\n", info_map[ie_type].name, ast_event_iterator_get_ie_str(&iter));
+ else if (info_map[ie_type].pltype == AST_EVENT_IE_PLTYPE_UINT)
+ ast_log(LOG_DEBUG, "%s: %u\r\n", info_map[ie_type].name, ast_event_iterator_get_ie_uint(&iter));
+ }
+}
+
+static int unload_module(void)
+{
+ if (manager_sub)
+ ast_event_unsubscribe(manager_sub);
+ return 0;
+}
+
+static int load_module(void)
+{
+ manager_sub = ast_event_subscribe(AST_EVENT_INFO, info_cb, NULL, AST_EVENT_IE_END);
+ return AST_MODULE_LOAD_SUCCESS;
+}
+
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Manager",
+ .load = load_module,
+ .unload = unload_module,
+ );
Propchange: team/group/manager2/res/res_manager2.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: team/group/manager2/res/res_manager2.c
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: team/group/manager2/res/res_manager2.c
------------------------------------------------------------------------------
svn:mime-type = text/plain
More information about the asterisk-commits
mailing list