[asterisk-commits] mmichelson: branch group/ccss_failure_response r296863 - in /team/group/ccss_...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Nov 30 18:04:10 CST 2010


Author: mmichelson
Date: Tue Nov 30 18:04:06 2010
New Revision: 296863

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=296863
Log:
Add a failure case to the CCSS core and handle it properly in chan_sip.c


Modified:
    team/group/ccss_failure_response/channels/chan_sip.c
    team/group/ccss_failure_response/include/asterisk/ccss.h
    team/group/ccss_failure_response/main/ccss.c

Modified: team/group/ccss_failure_response/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/group/ccss_failure_response/channels/chan_sip.c?view=diff&rev=296863&r1=296862&r2=296863
==============================================================================
--- team/group/ccss_failure_response/channels/chan_sip.c (original)
+++ team/group/ccss_failure_response/channels/chan_sip.c Tue Nov 30 18:04:06 2010
@@ -1601,7 +1601,7 @@
 static int sip_cc_agent_init(struct ast_cc_agent *agent, struct ast_channel *chan);
 static int sip_cc_agent_start_offer_timer(struct ast_cc_agent *agent);
 static int sip_cc_agent_stop_offer_timer(struct ast_cc_agent *agent);
-static void sip_cc_agent_respond(struct ast_cc_agent *agent);
+static void sip_cc_agent_respond(struct ast_cc_agent *agent, enum cc_agent_response_reason reason);
 static int sip_cc_agent_status_request(struct ast_cc_agent *agent);
 static int sip_cc_agent_start_monitoring(struct ast_cc_agent *agent);
 static int sip_cc_agent_recall(struct ast_cc_agent *agent);
@@ -1713,14 +1713,18 @@
 	return 0;
 }
 
-static void sip_cc_agent_respond(struct ast_cc_agent *agent)
+static void sip_cc_agent_respond(struct ast_cc_agent *agent, enum cc_agent_response_reason reason)
 {
 	struct sip_cc_agent_pvt *agent_pvt = agent->private_data;
 
 	sip_pvt_lock(agent_pvt->subscribe_pvt);
 	ast_set_flag(&agent_pvt->subscribe_pvt->flags[1], SIP_PAGE2_DIALOG_ESTABLISHED);
-	transmit_response(agent_pvt->subscribe_pvt, "200 OK", &agent_pvt->subscribe_pvt->initreq);
-	transmit_cc_notify(agent, agent_pvt->subscribe_pvt, CC_QUEUED);
+	if (reason == CC_AGENT_RESPONSE_SUCCESS) {
+		transmit_response(agent_pvt->subscribe_pvt, "200 OK", &agent_pvt->subscribe_pvt->initreq);
+		transmit_cc_notify(agent, agent_pvt->subscribe_pvt, CC_QUEUED);
+	} else {
+		transmit_response(agent_pvt->subscribe_pvt, "500 Internal Error", &agent_pvt->subscribe_pvt->initreq);
+	}
 	sip_pvt_unlock(agent_pvt->subscribe_pvt);
 	agent_pvt->is_available = TRUE;
 }

Modified: team/group/ccss_failure_response/include/asterisk/ccss.h
URL: http://svnview.digium.com/svn/asterisk/team/group/ccss_failure_response/include/asterisk/ccss.h?view=diff&rev=296863&r1=296862&r2=296863
==============================================================================
--- team/group/ccss_failure_response/include/asterisk/ccss.h (original)
+++ team/group/ccss_failure_response/include/asterisk/ccss.h Tue Nov 30 18:04:06 2010
@@ -858,6 +858,13 @@
 	char device_name[1];
 };
 
+enum cc_agent_response_reason {
+	CC_AGENT_RESPONSE_SUCCESS,
+	CC_AGENT_RESPONSE_FAILURE_SHORTTERM,
+	CC_AGENT_RESPONSE_FAILURE_LONGTERM,
+	/* XXX Can't recall what else */
+};
+
 struct ast_cc_agent_callbacks {
 	/*!
 	 * \brief Type of agent the callbacks belong to.
@@ -935,7 +942,7 @@
 	 * CC request from the caller by acknowledging receipt
 	 * of that request or rejecting it.
 	 */
-	void (*respond)(struct ast_cc_agent *agent);
+	void (*respond)(struct ast_cc_agent *agent, enum cc_agent_response_reason reason);
 	/*!
 	 * \brief Request the status of the agent's device.
 	 *

Modified: team/group/ccss_failure_response/main/ccss.c
URL: http://svnview.digium.com/svn/asterisk/team/group/ccss_failure_response/main/ccss.c?view=diff&rev=296863&r1=296862&r2=296863
==============================================================================
--- team/group/ccss_failure_response/main/ccss.c (original)
+++ team/group/ccss_failure_response/main/ccss.c Tue Nov 30 18:04:06 2010
@@ -2267,7 +2267,7 @@
 static int cc_generic_agent_init(struct ast_cc_agent *agent, struct ast_channel *chan);
 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_respond(struct ast_cc_agent *agent);
+static void cc_generic_agent_respond(struct ast_cc_agent *agent, enum cc_agent_response_reason reason);
 static int cc_generic_agent_status_request(struct ast_cc_agent *agent);
 static int cc_generic_agent_stop_ringing(struct ast_cc_agent *agent);
 static int cc_generic_agent_start_monitoring(struct ast_cc_agent *agent);
@@ -2403,7 +2403,7 @@
 	return 0;
 }
 
-static void cc_generic_agent_respond(struct ast_cc_agent *agent)
+static void cc_generic_agent_respond(struct ast_cc_agent *agent, enum cc_agent_response_reason reason)
 {
 	/* The generic agent doesn't have to do anything special to
 	 * acknowledge a CC request. Just return.
@@ -2806,7 +2806,7 @@
 	 *    call monitor's unsuspend callback.
 	 */
 	if (previous_state == CC_CALLER_REQUESTED) {
-		core_instance->agent->callbacks->respond(core_instance->agent);
+		core_instance->agent->callbacks->respond(core_instance->agent, CC_AGENT_RESPONSE_SUCCESS);
 		manager_event(EVENT_FLAG_CC, "CCRequestAcknowledged",
 			"CoreID: %d\r\n"
 			"Caller: %s\r\n",
@@ -2952,6 +2952,12 @@
 	if (!is_state_change_valid(core_instance->current_state, args->state, core_instance->agent)) {
 		ast_log_dynamic_level(cc_logger_level, "Core %d: Invalid state change requested. Cannot go from %s to %s\n",
 				args->core_id, cc_state_to_string(core_instance->current_state), cc_state_to_string(args->state));
+		if (args->state == CC_CALLER_REQUESTED) {
+			/* For out-of-order requests, we need to let the requester know that
+			 * we can't handle the request now.
+			 */
+			core_instance->agent->callbacks->respond(core_instance->agent, CC_AGENT_RESPONSE_FAILURE_SHORTTERM);
+		}
 		ast_free(args);
 		cc_unref(core_instance, "Unref core instance from when it was found earlier");
 		return -1;




More information about the asterisk-commits mailing list