[asterisk-commits] mmichelson: branch group/CCSS r226683 - in /team/group/CCSS: include/asterisk...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Nov 1 14:56:42 CST 2009


Author: mmichelson
Date: Sun Nov  1 14:56:37 2009
New Revision: 226683

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=226683
Log:
Create a mechanism which allows for a monitor
to request the current status of the agent.

The request is asynchronous, and multiple statuses
may be returned for a single request. This mechanism
is something that the ISDN implementation of the CC
monitor will require.


Modified:
    team/group/CCSS/include/asterisk/ccss.h
    team/group/CCSS/main/ccss.c
    team/group/CCSS/main/channel.c

Modified: team/group/CCSS/include/asterisk/ccss.h
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/include/asterisk/ccss.h?view=diff&rev=226683&r1=226682&r2=226683
==============================================================================
--- team/group/CCSS/include/asterisk/ccss.h (original)
+++ team/group/CCSS/include/asterisk/ccss.h Sun Nov  1 14:56:37 2009
@@ -499,14 +499,13 @@
 	 */
 	int (*suspend)(struct ast_cc_monitor *monitor, const int core_id);
 	/*!
-	 * Status request callback
-	 *
-	 * Return the current status of the monitored device, in the form
-	 * of an ast_device_state enum. The core is only concerned with whether
-	 * the state of the device is AST_DEVICE_NOT_INUSE. Other device states
-	 * are considered "busy" by the core.
-	 */
-	enum ast_device_state(*status_request)(struct ast_cc_monitor *monitor, const int core_id);
+	 * Status response callback
+	 *
+	 * Alert a monitor as to the status of the agent for which
+	 * the monitor had previously requested a status request.
+	 *
+	 */
+	int (*status_response)(struct ast_cc_monitor *monitor, const int core_id, enum ast_device_state devstate);
 	/*!
 	 * Unsuspend monitoring callback
 	 *
@@ -811,12 +810,12 @@
 	/*!
 	 * \brief Request the status of the agent's device
 	 *
-	 * The core will call this callback when the
-	 * CC_CALLEE_READY state is entered. In addition,
-	 * this callback is called through the public
-	 * ast_cc_agent_status_request function.
-	 */
-	enum ast_device_state (*status_request)(struct ast_cc_agent *agent);
+	 * Asynchronous request for the status of any caller
+	 * which may be a valid caller for the CC transaction.
+	 * Status responses should be made using the
+	 * ast_cc_status_response function.
+	 */
+	int (*status_request)(struct ast_cc_agent *agent);
 	/*!
 	 * \brief Begin monitoring a busy device
 	 *
@@ -987,6 +986,14 @@
 
 /* END STATE CHANGE API */
 
+/* BEGIN STATUS REQUEST/RESPONSE API */
+
+int ast_cc_status_request(int core_id);
+
+int ast_cc_status_response(int core_id, enum ast_device_state devstate);
+
+/* END STATUS REQUEST/RESPONSE API */
+
 /* BEGIN API FOR USE WITH/BY MONITORS */
 
 /*!

Modified: team/group/CCSS/main/ccss.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/main/ccss.c?view=diff&rev=226683&r1=226682&r2=226683
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Sun Nov  1 14:56:37 2009
@@ -790,7 +790,7 @@
 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, struct ast_cc_monitor_link *parent_link);
 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_status_response(struct ast_cc_monitor *monitor, const int core_id, enum ast_device_state devstate);
 static int cc_extension_monitor_unsuspend(struct ast_cc_monitor *monitor, const int core_id);
 static int cc_extension_monitor_cancel_available_timer(struct ast_cc_monitor *monitor, const int core_id, int *sched_id);
 static void cc_extension_monitor_destructor(void *monitor);
@@ -800,7 +800,7 @@
 	.init = cc_extension_monitor_init,
 	.request_cc = cc_extension_monitor_request_cc,
 	.suspend = cc_extension_monitor_suspend,
-	.status_request = cc_extension_monitor_status_request,
+	.status_response = cc_extension_monitor_status_response,
 	.unsuspend = cc_extension_monitor_unsuspend,
 	.cancel_available_timer = cc_extension_monitor_cancel_available_timer,
 	.destructor = cc_extension_monitor_destructor,
@@ -859,7 +859,7 @@
 	return 0;
 }
 
-static enum ast_device_state cc_extension_monitor_status_request(struct ast_cc_monitor *monitor, const int core_id)
+static int cc_extension_monitor_status_response(struct ast_cc_monitor *monitor, const int core_id, enum ast_device_state devstate)
 {
 	/* So, for an extension monitor, a status request involves traversing all child links that have
 	 * the proper core_id. As soon as ONE of them returns AST_DEVICE_NOT_INUSE, this means that as
@@ -869,11 +869,11 @@
 	struct ast_cc_monitor_link *link;
 
 	AST_LIST_TRAVERSE(&monitor->child_links, link, next_child) {
-		if (link->child->callbacks->status_request(link->child, core_id) == AST_DEVICE_NOT_INUSE) {
-			return AST_DEVICE_NOT_INUSE;
+		if (link->core_id == core_id) {
+			link->child->callbacks->status_response(link->child, core_id, devstate);
 		}
 	}
-	return AST_DEVICE_INUSE;
+	return 0;
 }
 
 static int cc_extension_monitor_unsuspend(struct ast_cc_monitor *monitor, const int core_id)
@@ -915,7 +915,7 @@
 static int cc_generic_monitor_init(struct ast_cc_monitor *monitor, const int core_id);
 static int cc_generic_monitor_request_cc(struct ast_cc_monitor *monitor, const int core_id, struct ast_cc_monitor_link *parent_link);
 static int cc_generic_monitor_suspend(struct ast_cc_monitor *monitor, const int core_id);
-static enum ast_device_state cc_generic_monitor_status_request(struct ast_cc_monitor *monitor, const int core_id);
+static int cc_generic_monitor_status_response(struct ast_cc_monitor *monitor, const int core_id, enum ast_device_state devstate);
 static int cc_generic_monitor_unsuspend(struct ast_cc_monitor *monitor, const int core_id);
 static int cc_generic_monitor_cancel_available_timer(struct ast_cc_monitor *monitor, const int core_id, int *sched_id);
 static void cc_generic_monitor_destructor(void *monitor);
@@ -925,7 +925,7 @@
 	.init = cc_generic_monitor_init,
 	.request_cc = cc_generic_monitor_request_cc,
 	.suspend = cc_generic_monitor_suspend,
-	.status_request = cc_generic_monitor_status_request,
+	.status_response = cc_generic_monitor_status_response,
 	.unsuspend = cc_generic_monitor_unsuspend,
 	.cancel_available_timer = cc_generic_monitor_cancel_available_timer,
 	.destructor = cc_generic_monitor_destructor,
@@ -1060,7 +1060,7 @@
 	enum ast_cc_service_type service = parent_link->service;
 	int when;
 
-	gen_mon_pvt->current_state = monitor->callbacks->status_request(monitor, core_id);
+	gen_mon_pvt->current_state = ast_device_state(monitor->interface->name);
 
 	/* We can monitor a device for one of two services, CCBS or CCNR.
 	 *
@@ -1108,16 +1108,20 @@
 		 * there is another link on which we may announce the availability.
 		 */
 		monitor->saved_link = NULL;
-		if (monitor->callbacks->status_request(monitor, core_id) == AST_DEVICE_NOT_INUSE) {
+		if (ast_device_state(monitor->interface->name) == AST_DEVICE_NOT_INUSE) {
 			ast_cc_monitor_announce_availability(monitor);
 		}
 	}
 	return 0;
 }
 
-static enum ast_device_state cc_generic_monitor_status_request(struct ast_cc_monitor *monitor, const int core_id)
-{
-	return ast_device_state(monitor->interface->name);
+static int cc_generic_monitor_status_response(struct ast_cc_monitor *monitor, const int core_id, enum ast_device_state devstate)
+{
+	/* The generic monitor will never issue a status request of the other side's agent.
+	 * If this somehow gets called, something really fishy is going on.
+	 */
+	ast_log(LOG_WARNING, "Why has a generic monitor's status_response callback been called? CoreID is %d\n", core_id);
+	return 0;
 }
 
 static int cc_generic_monitor_unsuspend(struct ast_cc_monitor *monitor, const int core_id)
@@ -1126,7 +1130,7 @@
 	 * to see if the device is available. That way, if it is, we can trigger an
 	 * immediate state change
 	 */
-	if (monitor->callbacks->status_request(monitor, core_id) == AST_DEVICE_NOT_INUSE) {
+	if (ast_device_state(monitor->interface->name) == AST_DEVICE_NOT_INUSE) {
 		ast_cc_monitor_announce_availability(monitor);
 	}
 	return 0;
@@ -1816,7 +1820,7 @@
 static int cc_generic_agent_start_offer_timer(struct ast_cc_agent *agent);
 static int cc_generic_agent_stop_offer_timer(struct ast_cc_agent *agent);
 static void cc_generic_agent_ack(struct ast_cc_agent *agent);
-static enum ast_device_state cc_generic_agent_status_request(struct ast_cc_agent *agent);
+static int cc_generic_agent_status_request(struct ast_cc_agent *agent);
 static int cc_generic_agent_start_monitoring(struct ast_cc_agent *agent);
 static int cc_generic_agent_stop_monitoring(struct ast_cc_agent *agent);
 static int cc_generic_agent_recall(struct ast_cc_agent *agent);
@@ -1922,9 +1926,10 @@
 	return;
 }
 
-static enum ast_device_state cc_generic_agent_status_request(struct ast_cc_agent *agent)
-{
-	return ast_device_state(agent->interface);
+static int cc_generic_agent_status_request(struct ast_cc_agent *agent)
+{
+	ast_cc_status_response(agent->core_id, ast_device_state(agent->interface));
+	return 0;
 }
 
 static void generic_agent_devstate_cb(const struct ast_event *event, void *userdata)
@@ -2639,6 +2644,57 @@
 	return cc_request_state_change(CC_FAILED, core_id, debug);
 }
 
+static int cc_status_request(void *data)
+{
+	struct cc_core_instance *core_instance= data;
+	int res;
+
+	res = core_instance->agent->callbacks->status_request(core_instance->agent);
+	cc_unref(core_instance, "Status request finished. Unref core instance");
+	return res;
+}
+
+int ast_cc_status_request(int core_id)
+{
+	struct cc_core_instance *core_instance = find_cc_core_instance(core_id);
+
+	if (!core_instance) {
+		return -1;
+	}
+
+	return ast_taskprocessor_push(cc_core_taskprocessor, cc_status_request,
+			cc_ref(core_instance, "Ref core instance for status request callback"));
+}
+
+struct cc_status_response_args {
+	enum ast_device_state devstate;
+	struct cc_core_instance *core_instance;
+};
+
+static int cc_status_response(void *data)
+{
+	struct cc_status_response_args *args;
+	struct cc_core_instance *core_instance = args->core_instance;
+	enum ast_device_state devstate = args->devstate;
+	int res;
+
+	res = core_instance->monitor->callbacks->status_response(core_instance->monitor, core_instance->core_id, devstate);
+	cc_unref(core_instance, "Status response finished. Unref core instance");
+	return res;
+}
+
+int ast_cc_status_response(int core_id, enum ast_device_state devstate)
+{
+	struct cc_core_instance *core_instance = find_cc_core_instance(core_id);
+
+	if (!core_instance || !core_instance->monitor) {
+		return -1;
+	}
+
+	return ast_taskprocessor_push(cc_core_taskprocessor, cc_status_response,
+			cc_ref(core_instance, "Ref core instance for status response callback"));
+}
+
 static char *ccreq_app = "CallCompletionRequest";
 
 static int ccreq_exec(struct ast_channel *chan, const char *data)

Modified: team/group/CCSS/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/main/channel.c?view=diff&rev=226683&r1=226682&r2=226683
==============================================================================
--- team/group/CCSS/main/channel.c (original)
+++ team/group/CCSS/main/channel.c Sun Nov  1 14:56:37 2009
@@ -2228,6 +2228,7 @@
 			
 	ast_channel_unlock(chan);
 	if (ast_test_flag(chan, AST_FLAG_OFFER_CC)) {
+		ast_log(LOG_ERROR, "HEY!!!!\n");
 		ast_cc_offer(chan);
 	}
 	manager_event(EVENT_FLAG_CALL, "Hangup",




More information about the asterisk-commits mailing list