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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Oct 20 15:57:21 CDT 2009


Author: mmichelson
Date: Tue Oct 20 15:57:17 2009
New Revision: 224848

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=224848
Log:
State change requests are now completely internal, with APIs
allowing for channel drivers to advance matters. Scratch one item
off the list of things to do.


Modified:
    team/group/CCSS/include/asterisk/ccss.h
    team/group/CCSS/main/ccss.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=224848&r1=224847&r2=224848
==============================================================================
--- team/group/CCSS/include/asterisk/ccss.h (original)
+++ team/group/CCSS/include/asterisk/ccss.h Tue Oct 20 15:57:17 2009
@@ -38,44 +38,6 @@
 	AST_CC_CCNR,
 	/* Call Completion Not Logged In (currently SIP only) */
 	AST_CC_CCNL,
-};
-
-/*!
- * \since 1.6.4
- * \brief The states used in the CCSS core state machine
- *
- * For more information, see doc/CCSS_architecture.pdf
- */
-enum ast_cc_state {
-	/*! Entered when it is determined that CCSS may be used for the call */
-	CC_AVAILABLE,
-	/*! Entered when a CCSS agent has offered CCSS to a caller */
-	CC_CALLER_OFFERED,
-	/*! Entered when a CCSS agent confirms that a caller has
-	 * requested CCSS */
-	CC_CALLER_REQUESTED,
-	/*! Entered when a CCSS monitor confirms acknowledgment of an
-	 * outbound CCSS request */
-	CC_ACTIVE,
-	/*! Entered when a CCSS monitor alerts the core that the called party
-	 * has become available */
-	CC_CALLEE_READY,
-	/*! Entered when a CCSS agent alerts the core that the calling party
-	 * may not be recalled because he is unavailable
-	 */
-	CC_CALLER_BUSY,
-	/*! Entered when a CCSS agent alerts the core that the calling party
-	 * is attempting to recall the called party
-	 */
-	CC_RECALLING,
-	/*! Entered when an application alerts the core that the calling party's
-	 * recall attempt has had a call progress response indicated
-	 */
-	CC_COMPLETE,
-	/*! Entered any time that something goes wrong during the process, thus
-	 * resulting in the failure of the attempted CCSS transaction
-	 */
-	CC_FAILED,
 };
 
 /* XXX Several of these structures may be modified to be opaque, with
@@ -998,23 +960,6 @@
  */
 int ast_cc_failed(int core_id, const char * const debug);
 
-/*!
- * \since 1.6.4
- *
- * XXX In retrospect, I think it's a bad idea to expose the internals of the state machine.
- * Instead, what I want to do is to make individual API calls for each state change. The names
- * of the functions will more easily convey the use. Furthermore, it allows for the state machine
- * to be altered transparently. For initial code review, since this works, I'll leave it as is.
- *
- * \brief Request that the core change states
- * \param state The state to which we wish to change
- * \param core_id The unique identifier for this instance of the CCSS core state machine
- * \param debug Optional message explaining the reason for the state change
- * \retval 0 State change successfully queued
- * \retval -1 Unable to queue state change request
- */
-int ast_cc_request_state_change(enum ast_cc_state state, const int core_id, const char *debug);
-
 /* END STATE CHANGE 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=224848&r1=224847&r2=224848
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Tue Oct 20 15:57:17 2009
@@ -75,6 +75,53 @@
 /* The actual number of CC requests in the system */
 static int cc_request_count;
 
+/*!
+ * \since 1.6.4
+ * \brief The states used in the CCSS core state machine
+ *
+ * For more information, see doc/CCSS_architecture.pdf
+ */
+enum cc_state {
+	/*! Entered when it is determined that CCSS may be used for the call */
+	CC_AVAILABLE,
+	/*! Entered when a CCSS agent has offered CCSS to a caller */
+	CC_CALLER_OFFERED,
+	/*! Entered when a CCSS agent confirms that a caller has
+	 * requested CCSS */
+	CC_CALLER_REQUESTED,
+	/*! Entered when a CCSS monitor confirms acknowledgment of an
+	 * outbound CCSS request */
+	CC_ACTIVE,
+	/*! Entered when a CCSS monitor alerts the core that the called party
+	 * has become available */
+	CC_CALLEE_READY,
+	/*! Entered when a CCSS agent alerts the core that the calling party
+	 * may not be recalled because he is unavailable
+	 */
+	CC_CALLER_BUSY,
+	/*! Entered when a CCSS agent alerts the core that the calling party
+	 * is attempting to recall the called party
+	 */
+	CC_RECALLING,
+	/*! Entered when an application alerts the core that the calling party's
+	 * recall attempt has had a call progress response indicated
+	 */
+	CC_COMPLETE,
+	/*! Entered any time that something goes wrong during the process, thus
+	 * resulting in the failure of the attempted CCSS transaction
+	 */
+	CC_FAILED,
+};
+/*!
+ * \brief Request that the core change states
+ * \param state The state to which we wish to change
+ * \param core_id The unique identifier for this instance of the CCSS core state machine
+ * \param debug Optional message explaining the reason for the state change
+ * \retval 0 State change successfully queued
+ * \retval -1 Unable to queue state change request
+ */
+static int cc_request_state_change(enum cc_state, int core_id, const char * debug);
+
 static struct ao2_container *cc_core_instances;
 
 struct cc_core_instance {
@@ -85,7 +132,7 @@
 	/*!
 	 * The current state for this instance of the CC core.
 	 */
-	enum ast_cc_state current_state;
+	enum cc_state current_state;
 	/*!
 	 * The CC agent in use for this call
 	 */
@@ -1822,7 +1869,7 @@
 	struct ast_cc_agent *agent = userdata;
 	struct ast_str *str = ast_str_alloca(128);
 	ast_str_set(&str, 0, "%s is no longer busy\n", agent->interface);
-	ast_cc_request_state_change(CC_ACTIVE, agent->core_id, ast_str_buffer(str));
+	cc_request_state_change(CC_ACTIVE, agent->core_id, ast_str_buffer(str));
 }
 
 static int cc_generic_agent_start_monitoring(struct ast_cc_agent *agent)
@@ -2144,7 +2191,7 @@
 
 	if (monitor->interface->monitor_class == AST_CC_ROOT_MONITOR) {
 		cc_unref(core_instance, "Unref core_instance from earlier ao2_find");
-		ast_cc_request_state_change(CC_CALLEE_READY, core_id, "Device being monitored has become available");
+		cc_request_state_change(CC_CALLEE_READY, core_id, "Device being monitored has become available");
 		return 0;
 	}
 
@@ -2224,7 +2271,7 @@
 }
 
 struct cc_state_change_args {
-	enum ast_cc_state state;
+	enum cc_state state;
 	int core_id;
 	char debug[1];
 };
@@ -2250,7 +2297,8 @@
 		break;
 	case CC_CALLER_OFFERED:
 		if (core_instance->current_state != CC_AVAILABLE) {
-			ast_log(LOG_NOTICE, "Invalid state change request. Cannot go from %d to %d\n", core_instance->current_state, args->state);
+			ast_log(LOG_NOTICE, "Invalid state change request. Cannot go from %d to %d\n",
+					core_instance->current_state, args->state);
 			break;
 		}
 		if (core_instance->agent->callbacks->start_offer_timer(core_instance->agent)) {
@@ -2267,7 +2315,8 @@
 		 */
 		if (!(core_instance->current_state == CC_CALLER_OFFERED ||
 				(core_instance->current_state == CC_AVAILABLE && ast_test_flag(core_instance->agent, AST_CC_AGENT_SKIP_OFFER)))) {
-			ast_log(LOG_NOTICE, "Invalid state change request. Cannot go from %d to %d\n", core_instance->current_state, args->state);
+			ast_log(LOG_NOTICE, "Invalid state change request. Cannot go from %d to %d\n",
+					core_instance->current_state, args->state);
 		}
 		if (!ast_cc_request_within_limits()) {
 			ast_log(LOG_WARNING, "Cannot request CC since there is no more room for requests\n");
@@ -2293,23 +2342,25 @@
 			core_instance->agent->callbacks->stop_monitoring(core_instance->agent);
 			core_instance->monitor->callbacks->unsuspend(core_instance->monitor, core_instance->core_id);
 		} else {
-			ast_log(LOG_NOTICE, "Invalid state change request. Cannot go from %d to %d\n", core_instance->current_state, args->state);
+			ast_log(LOG_NOTICE, "Invalid state change request. Cannot go from %d to %d\n",
+					core_instance->current_state, args->state);
 		}
 		break;
 	case CC_CALLEE_READY:
 		/* Callee has become available, call agent's status request callback
 		 */
 		if (core_instance->current_state != CC_ACTIVE) {
-			ast_log(LOG_NOTICE, "Invalid state change request. Cannot go from %d to %d\n", core_instance->current_state, args->state);
+			ast_log(LOG_NOTICE, "Invalid state change request. Cannot go from %d to %d\n",
+					core_instance->current_state, args->state);
 			break;
 		}
 		core_instance->current_state = args->state;
 		if (core_instance->agent->callbacks->status_request(core_instance->agent) == AST_DEVICE_NOT_INUSE) {
 			ast_log(LOG_NOTICE, "Both parties are ready, let's try that recall\n");
-			ast_cc_request_state_change(CC_RECALLING, core_instance->core_id, "Both parties are available\n");
+			cc_request_state_change(CC_RECALLING, core_instance->core_id, "Both parties are available\n");
 		} else {
 			ast_log(LOG_NOTICE, "Caller has become busy, so we must begin monitoring him\n");
-			ast_cc_request_state_change(CC_CALLER_BUSY, core_instance->core_id, "Caller is busy\n");
+			cc_request_state_change(CC_CALLER_BUSY, core_instance->core_id, "Caller is busy\n");
 		}
 		break;
 	case CC_CALLER_BUSY:
@@ -2317,7 +2368,8 @@
 		 * and call monitor's suspend callback.
 		 */
 		if (core_instance->current_state != CC_CALLEE_READY) {
-			ast_log(LOG_NOTICE, "Invalid state change request. Cannot go from %d to %d\n", core_instance->current_state, args->state);
+			ast_log(LOG_NOTICE, "Invalid state change request. Cannot go from %d to %d\n",
+					core_instance->current_state, args->state);
 		}
 		core_instance->current_state = args->state;
 		core_instance->monitor->callbacks->suspend(core_instance->monitor, core_instance->core_id);
@@ -2327,7 +2379,8 @@
 		/* Both caller and callee are available, call agent's recall callback
 		 */
 		if (core_instance->current_state != CC_CALLEE_READY) {
-			ast_log(LOG_NOTICE, "Invalid state change request. Cannot go from %d to %d\n", core_instance->current_state, args->state);
+			ast_log(LOG_NOTICE, "Invalid state change request. Cannot go from %d to %d\n",
+					core_instance->current_state, args->state);
 		}
 		core_instance->current_state = args->state;
 		core_instance->monitor->callbacks->cancel_available_timer(core_instance->monitor, core_instance->core_id, NULL);
@@ -2337,7 +2390,8 @@
 		/* Recall has made progress, call agent and monitor destructor functions
 		 */
 		if (core_instance->current_state != CC_RECALLING) {
-			ast_log(LOG_NOTICE, "Invalid state change request. Cannot go from %d to %d\n", core_instance->current_state, args->state);
+			ast_log(LOG_NOTICE, "Invalid state change request. Cannot go from %d to %d\n",
+					core_instance->current_state, args->state);
 		}
 		core_instance->current_state = args->state;
 		ao2_t_unlink(cc_core_instances, core_instance, "Unlink core instance since CC recall has completed");
@@ -2357,7 +2411,7 @@
 	return 0;
 }
 
-int ast_cc_request_state_change(enum ast_cc_state state, const int core_id,
+int cc_request_state_change(enum cc_state state, const int core_id,
 		const char *debug)
 {
 	struct cc_state_change_args *args = ast_calloc(1, sizeof(*args) +
@@ -2385,18 +2439,18 @@
 		return res;
 	}
 
-	res = ast_cc_request_state_change(CC_CALLER_OFFERED, core_id, "Offer CC to caller");
+	res = cc_request_state_change(CC_CALLER_OFFERED, core_id, "Offer CC to caller");
 	return res;
 }
 
 int ast_cc_accept_request(int core_id, const char * const debug)
 {
-	return ast_cc_request_state_change(CC_CALLER_REQUESTED, core_id, debug);
+	return cc_request_state_change(CC_CALLER_REQUESTED, core_id, debug);
 }
 
 int ast_cc_request_acknowledged(int core_id, const char * const debug)
 {
-	return ast_cc_request_state_change(CC_ACTIVE, core_id, debug);
+	return cc_request_state_change(CC_ACTIVE, core_id, debug);
 }
 
 int ast_cc_monitor_announce_availability(struct ast_cc_monitor *monitor) {
@@ -2406,12 +2460,12 @@
 
 int ast_cc_completed(int core_id, const char * const debug)
 {
-	return ast_cc_request_state_change(CC_COMPLETE, core_id, debug);
+	return cc_request_state_change(CC_COMPLETE, core_id, debug);
 }
 
 int ast_cc_failed(int core_id, const char * const debug)
 {
-	return ast_cc_request_state_change(CC_FAILED, core_id, debug);
+	return cc_request_state_change(CC_FAILED, core_id, debug);
 }
 
 static char *ccreq_app = "CallCompletionRequest";




More information about the asterisk-commits mailing list