[asterisk-commits] mmichelson: branch group/CCSS r215153 - in /team/group/CCSS: include/asterisk...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Sep 1 13:39:30 CDT 2009
Author: mmichelson
Date: Tue Sep 1 13:39:27 2009
New Revision: 215153
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=215153
Log:
General progress.
* Started to fill in the monitor creation function and realized
that I need to do some more backend work first. The function is
still marked as a stub but there is some more fleshed out.
* Simplified the initial monitor setup. There was a lot of
room for confusing redundant code with the way it was set up
before.
* Started to define monitor callbacks, and wrote stubs
for extension monitor callbacks.
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=215153&r1=215152&r2=215153
==============================================================================
--- team/group/CCSS/include/asterisk/ccss.h (original)
+++ team/group/CCSS/include/asterisk/ccss.h Tue Sep 1 13:39:27 2009
@@ -458,58 +458,6 @@
};
/*!
- * \brief Relevant data for a device monitor
- *
- * Device monitors communicate directly with outside devices, and they have
- * specific duties to accomplish during operation of the core state machine.
- *
- * In addition, a device monitor will always be a "leaf" in the tree of
- * CCSS monitors, so they will only have parents, no children.
- */
-struct ast_cc_device_monitor_data {
- /*! We need to remember which type of service to request/was requested
- * by this specific device monitor so we don't cause problems downstream
- */
- enum ast_cc_service_type service_requested;
- /*! A device name, formatted in a way that is understood by ast_device_state*
- * functions.
- */
- const char *device_name;
- /*! A device monitor will have at least one extension monitor as a parent,
- * but if a device is dialed by multiple extensions, then it is possible
- * to have a list of multiple extension monitors as parents.
- */
- AST_LIST_HEAD(,ast_cc_monitor_link) parent_links;
- /*! Device monitor operations which will vary between implementations. Think
- * of this sort of like the ast_channel_tech structure
- */
- const struct device_monitor_cbs *callbacks;
- /*! Different implementations of device monitors will have to remember
- * different data in order to facilitate the service.
- */
- void *private_data;
-};
-
-struct ast_cc_extension_monitor_data {
- /*! List of extensions which have failed outstanding calls to this extension.
- * I find it unlikely that this will ever be largely populated. The root monitor
- * may also be the sole parent of an extension monitor, which makes this extension
- * monitor the "root" of a particular CC tree.
- */
- AST_LIST_HEAD(,ast_cc_monitor_link) parent_links;
- /*! List of downstream device monitors. This list will have multiple elements
- * in it for extensions which dial multiple devices.
- */
- AST_LIST_HEAD(,ast_cc_monitor_link) child_links;
- const char *extension;
- const char *context;
-};
-
-struct ast_cc_root_monitor_data {
- AST_LIST_HEAD(,ast_cc_monitor_link) child_links;
-};
-
-/*!
* \brief Structure that represents a CCSS monitor
* Both extension and device monitors will be represented
* with this structure. Information specific to each monitor
@@ -518,33 +466,31 @@
struct ast_cc_monitor {
/*! One of CCBS or CCNR. */
enum ast_cc_monitor_type type;
- /*! There are different types of monitors that each
- * need to do their own thing.
- */
- union {
- struct ast_cc_device_monitor_data device_data;
- struct ast_cc_extension_monitor_data extension_data;
- struct ast_cc_root_monitor_data root_data;
- } monitor_data;
- /*! The name of the device/extension being monitored */
- const char *name;
/*! The list of links to upstream extension monitors */
AST_LIST_HEAD(,ast_cc_monitor_link) parent_links;
- /*! Callback functions needed for specific device monitor
+ AST_LIST_HEAD(,ast_cc_monitor_link) child_links;
+ /*! Callback functions needed for specific monitor
* implementations
*/
- const struct ast_cc_device_monitor_callbacks *callbacks;
- /*! Data specific to a device monitor implementation */
+ const struct ast_cc_monitor_callbacks *callbacks;
+ /*! Data specific to a monitor implementation */
void *private_data;
-};
-
-struct ast_cc_device_monitor_callbacks {
+ /*! The name of the device/extension being monitored */
+ char name[1];
+};
+
+struct ast_cc_monitor_callbacks {
/* Allocate callback */
+ int (*init)(struct ast_cc_monitor *monitor, const int core_id);
/* Request CCSS callback */
+ int (*request_cc)(struct ast_cc_monitor *monitor, const int core_id);
/* Suspend monitoring callback */
+ int (*suspend)(struct ast_cc_monitor *monitor, const int core_id);
/* Status request callback */
+ enum ast_device_state(*status_request)(struct ast_cc_monitor *monitor, const int core_id);
/* Destroy callback (XXX handled in ao2 destructor?) */
- /* Pass status upstream callback */
+ void (*destructor)(struct ast_monitor *monitor, const int core_id);
+ /* Pass status upstream callback (XXX ???) */
};
struct ast_cc_agent {
Modified: team/group/CCSS/main/ccss.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/CCSS/main/ccss.c?view=diff&rev=215153&r1=215152&r2=215153
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Tue Sep 1 13:39:27 2009
@@ -90,6 +90,8 @@
.recall = cc_generic_agent_recall,
.destructor = cc_generic_agent_destructor,
};
+
+static struct ast_cc_monitor *root_monitor;
struct cc_generic_agent_pvt {
/*!
@@ -788,6 +790,24 @@
* 5. Profit
*/
+ struct cc_core_instance *core_instance;
+ struct cc_core_pending_offer *pending_offer;
+ struct cc_core_instance instance_finder = { .core_id = core_id };
+ struct cc_core_pending_offer offer_finder = { .core_id = core_id };
+
+ if (!(core_instance = ao2_find(cc_core_instances, &instance_finder, OBJ_POINTER))) {
+ return -1;
+ }
+
+ if (!(pending_offer = ao2_find(cc_core_pending_offers, &offer_finder, OBJ_POINTER))) {
+ ao2_ref(core_instance, -1);
+ return -1;
+ }
+
+ ast_assert(core_instance->monitor == NULL);
+
+ ao2_ref(core_instance, -1);
+ ao2_ref(pending_offer, -1);
/* STUB */
return 0;
}
@@ -956,6 +976,58 @@
return 0;
}
+static int cc_extension_monitor_init(struct ast_cc_monitor *monitor, const int core_id);
+static int cc_extension_monitor_request_cc(struct ast_cc_monitor *monitor, const int core_id);
+static int cc_extension_monitor_suspend(struct ast_cc_monitor *monitor, const int core_id);
+static enum ast_device_state cc_extension_monitor_status_request(struct ast_cc_monitor *monitor, const int core_id);
+static int cc_extension_monitor_unsuspend(struct ast_cc_monitor *monitor, const int core_id);
+static void cc_extension_monitor_destructor(struct ast_cc_monitor *monitor, const int core_id);
+
+static struct ast_cc_monitor_callbacks extension_monitor_cbs = {
+ .init = cc_extension_monitor_init,
+ .request_cc = cc_extension_monitor_request_cc,
+ .suspend = cc_extension_monitor_suspend,
+ .status_request = cc_extension_monitor_status_request,
+ .unsuspend = cc_extension_monitor_unsuspend,
+ .destructor = cc_extension_monitor_destructor,
+};
+
+static int cc_extension_monitor_init(struct ast_cc_monitor *monitor, const int core_id)
+{
+ /* STUB */
+ return 0;
+}
+
+static int cc_extension_monitor_request_cc(struct ast_cc_monitor *monitor, const int core_id)
+{
+ /* STUB */
+ return 0;
+}
+
+static int cc_extension_monitor_suspend(struct ast_cc_monitor *monitor, const int core_id)
+{
+ /* STUB */
+ return 0;
+}
+
+static enum ast_device_state cc_extension_monitor_status_request(struct ast_cc_monitor *monitor, const int core_id)
+{
+ /* STUB */
+ return AST_DEVICE_NOT_INUSE;
+}
+
+static int cc_extension_monitor_unsuspend(struct ast_cc_monitor *monitor, const int core_id)
+{
+ /* STUB */
+ return 0;
+}
+
+static void cc_extension_monitor_destructor(struct ast_cc_monitor *monitor, const int core_id)
+{
+ /* STUB */
+ return;
+}
+
int ast_cc_init(void)
{
int res;
@@ -977,6 +1049,11 @@
if (!(cc_sched_thread = ast_sched_thread_create())) {
return -1;
}
+ /*
+ if (!(root_monitor = cc_monitor_init(AST_CC_ROOT_MONITOR, "root", ))) {
+ return -1;
+ }
+ */
ast_log(LOG_NOTICE, "Successfully created CC sched_thread context\n");
res = ast_register_application2(ccreq_app, ccreq_exec, NULL, NULL, NULL);
res |= ast_register_application2(cccancel_app, cccancel_exec, NULL, NULL, NULL);
More information about the asterisk-commits
mailing list