[asterisk-commits] mmichelson: branch group/CCSS r217444 - in /team/group/CCSS: include/asterisk...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Sep 9 13:37:35 CDT 2009
Author: mmichelson
Date: Wed Sep 9 13:37:32 2009
New Revision: 217444
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=217444
Log:
Get agent backend work committed. Now to handle
that XXX comment.
Modified:
team/group/CCSS/include/asterisk/ccss.h
team/group/CCSS/main/ccss.c
Modified: team/group/CCSS/include/asterisk/ccss.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/CCSS/include/asterisk/ccss.h?view=diff&rev=217444&r1=217443&r2=217444
==============================================================================
--- team/group/CCSS/include/asterisk/ccss.h (original)
+++ team/group/CCSS/include/asterisk/ccss.h Wed Sep 9 13:37:32 2009
@@ -736,6 +736,20 @@
/*!
* \since 1.6.4
+ * \brief Register a set of agent callbacks with the core
+ *
+ * This is made so that at agent creation time, the proper callbacks
+ * may be installed and the proper .init callback may be called for the
+ * monitor to establish private data.
+ *
+ * \param callbacks The callbacks used by the agent implementation
+ * \retval 0 Successfully registered
+ * \retval -1 Failure to register
+ */
+int ast_cc_agent_register(const struct ast_cc_agent_callbacks *callbacks);
+
+/*!
+ * \since 1.6.4
* \brief Initialize CCSS
*
* XXX This needs to be updated as more functionality is added.
Modified: team/group/CCSS/main/ccss.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/CCSS/main/ccss.c?view=diff&rev=217444&r1=217443&r2=217444
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Wed Sep 9 13:37:32 2009
@@ -70,10 +70,16 @@
};
AST_RWLIST_HEAD_STATIC(cc_monitor_backends, cc_monitor_backend);
+AST_RWLIST_HEAD_STATIC(cc_agent_backends, cc_agent_backend);
struct cc_monitor_backend {
AST_LIST_ENTRY(cc_monitor_backend) next;
const struct ast_cc_monitor_callbacks *callbacks;
+};
+
+struct cc_agent_backend {
+ AST_LIST_ENTRY(cc_agent_backend) next;
+ const struct ast_cc_agent_callbacks *callbacks;
};
/* XXX I'm making these defaults up right now with no real regard for
@@ -535,6 +541,23 @@
ast_assert(callbacks->destructor != NULL);
}
+static const struct ast_cc_agent_callbacks *find_agent_callbacks(const char * const type)
+{
+ struct cc_agent_backend *backend;
+ const struct ast_cc_agent_callbacks *callbacks = NULL;
+
+ AST_RWLIST_RDLOCK(&cc_agent_backends);
+ AST_RWLIST_TRAVERSE(&cc_agent_backends, backend, next) {
+ if (!strcmp(backend->callbacks->type, type)) {
+ ast_log(LOG_NOTICE, "Returning backend %s\n", backend->callbacks->type);
+ callbacks = backend->callbacks;
+ break;
+ }
+ }
+ AST_RWLIST_UNLOCK(&cc_agent_backends);
+ return callbacks;
+}
+
static struct ast_cc_agent *cc_agent_init(struct ast_channel *caller_chan,
const char * const caller_name, const int core_id,
struct ast_cc_interface_tree *interface_tree)
@@ -550,7 +573,10 @@
* For now, I'm keeping it simple by using only generic
* agents.
*/
- agent->callbacks = &generic_agent_callbacks;
+ if (!(agent->callbacks = find_agent_callbacks("generic"))) {
+ ast_free(agent);
+ return NULL;
+ }
check_callback_sanity(agent->callbacks);
if (!(agent->cc_params = ast_cc_config_params_init())) {
ast_free(agent);
@@ -1516,6 +1542,21 @@
return 0;
}
+int ast_cc_agent_register(const struct ast_cc_agent_callbacks *callbacks)
+{
+ struct cc_agent_backend *backend = ast_calloc(1, sizeof(*backend));
+
+ if (!backend) {
+ return -1;
+ }
+
+ backend->callbacks = callbacks;
+ AST_RWLIST_WRLOCK(&cc_agent_backends);
+ AST_RWLIST_INSERT_TAIL(&cc_agent_backends, backend, next);
+ AST_RWLIST_UNLOCK(&cc_agent_backends);
+ return 0;
+}
+
int ast_cc_monitor_announce_availability(struct ast_cc_monitor *monitor) {
return ast_taskprocessor_push(cc_core_taskprocessor, cc_devstate_change, monitor);
}
@@ -1547,6 +1588,7 @@
res |= ast_register_application2(cccancel_app, cccancel_exec, NULL, NULL, NULL);
res |= ast_cc_monitor_register(&extension_monitor_cbs);
res |= ast_cc_monitor_register(&generic_monitor_cbs);
+ res |= ast_cc_agent_register(&generic_agent_callbacks);
/* Root monitor doesn't care about the core id. The root monitor uses
* extension monitor callbacks since the gist of those will be to traverse
* their child links and call each of their children's callbacks
More information about the asterisk-commits
mailing list