[svn-commits] mmichelson: branch group/CCSS r231231 - /team/group/CCSS/channels/chan_sip.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Nov 25 13:06:49 CST 2009


Author: mmichelson
Date: Wed Nov 25 13:06:48 2009
New Revision: 231231

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=231231
Log:
Start filling in agent callbacks.

Some of the more involved ones just have comments on
what should be done at this point. They'll be filled
in soon enough. Don't worry.


Modified:
    team/group/CCSS/channels/chan_sip.c

Modified: team/group/CCSS/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/channels/chan_sip.c?view=diff&rev=231231&r1=231230&r2=231231
==============================================================================
--- team/group/CCSS/channels/chan_sip.c (original)
+++ team/group/CCSS/channels/chan_sip.c Wed Nov 25 13:06:48 2009
@@ -2122,148 +2122,6 @@
 }
 
 
-static int sip_cc_agent_init(struct ast_cc_agent *agent, struct ast_channel *chan);
-static int sip_cc_agent_offer_cc(struct ast_cc_agent *agent, const char * const callee_interface);
-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_ack(struct ast_cc_agent *agent);
-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);
-static void sip_cc_agent_destructor(struct ast_cc_agent *agent);
-
-static struct ast_cc_agent_callbacks sip_cc_agent_callbacks = {
-	.type = "SIP",
-	.init = sip_cc_agent_init,
-	.offer_cc = sip_cc_agent_offer_cc,
-	.start_offer_timer = sip_cc_agent_start_offer_timer,
-	.stop_offer_timer = sip_cc_agent_stop_offer_timer,
-	.ack = sip_cc_agent_ack,
-	.status_request = sip_cc_agent_status_request,
-	.start_monitoring = sip_cc_agent_start_monitoring,
-	.callee_available = sip_cc_agent_recall,
-	.destructor = sip_cc_agent_destructor,
-};
-
-static int sip_cc_agent_init(struct ast_cc_agent *agent, struct ast_channel *chan)
-{
-	/* XXX STUB */
-	return 0;
-}
-
-static int sip_cc_agent_offer_cc(struct ast_cc_agent *agent, const char * const callee_interface)
-{
-	/* XXX STUB */
-	return 0;
-}
-
-static int sip_cc_agent_start_offer_timer(struct ast_cc_agent *agent)
-{
-	/* XXX STUB */
-	return 0;
-}
-
-static int sip_cc_agent_stop_offer_timer(struct ast_cc_agent *agent)
-{
-	/* XXX STUB */
-	return 0;
-}
-
-static void sip_cc_agent_ack(struct ast_cc_agent *agent)
-{
-	/* XXX STUB */
-}
-
-static int sip_cc_agent_status_request(struct ast_cc_agent *agent)
-{
-	/* XXX STUB */
-	return 0;
-}
-
-static int sip_cc_agent_start_monitoring(struct ast_cc_agent *agent)
-{
-	/* XXX STUB */
-	return 0;
-}
-
-static int sip_cc_agent_recall(struct ast_cc_agent *agent)
-{
-	/* XXX STUB */
-	return 0;
-}
-
-static void sip_cc_agent_destructor(struct ast_cc_agent *agent)
-{
-	/* XXX STUB */
-}
-
-static int sip_cc_monitor_init(struct ast_cc_monitor *monitor, const int core_id);
-static int sip_cc_monitor_request_cc(struct ast_cc_monitor *monitor, const int core_id, struct ast_cc_monitor_link *parent_link);
-static int sip_cc_monitor_suspend(struct ast_cc_monitor *monitor, const int core_id);
-static int sip_cc_monitor_status_response(struct ast_cc_monitor *monitor, const int core_id, enum ast_device_state devstate);
-static int sip_cc_monitor_unsuspend(struct ast_cc_monitor *monitor, const int core_id);
-static int sip_cc_monitor_cancel_available_timer(struct ast_cc_monitor *monitor, const int core_id, int *sched_id);
-static void sip_cc_monitor_destructor(void *monitor);
-static void sip_cc_monitor_instance_destructor(const int core_id);
-
-static struct ast_cc_monitor_callbacks sip_cc_monitor_callbacks = {
-	.type = "SIP",
-	.init = sip_cc_monitor_init,
-	.request_cc = sip_cc_monitor_request_cc,
-	.suspend = sip_cc_monitor_suspend,
-	.status_response = sip_cc_monitor_status_response,
-	.unsuspend = sip_cc_monitor_unsuspend,
-	.cancel_available_timer = sip_cc_monitor_cancel_available_timer,
-	.destructor = sip_cc_monitor_destructor,
-	.instance_destructor = sip_cc_monitor_instance_destructor,
-};
-
-static int sip_cc_monitor_init(struct ast_cc_monitor *monitor, const int core_id)
-{
-	/* XXX STUB */
-	return 0;
-}
-
-static int sip_cc_monitor_request_cc(struct ast_cc_monitor *monitor, const int core_id, struct ast_cc_monitor_link *parent_link)
-{
-	/* XXX STUB */
-	return 0;
-}
-
-static int sip_cc_monitor_suspend(struct ast_cc_monitor *monitor, const int core_id)
-{
-	/* XXX STUB */
-	return 0;
-}
-
-static int sip_cc_monitor_status_response(struct ast_cc_monitor *monitor, const int core_id, enum ast_device_state devstate)
-{
-	/* XXX STUB */
-	return 0;
-}
-
-static int sip_cc_monitor_unsuspend(struct ast_cc_monitor *monitor, const int core_id)
-{
-	/* XXX STUB */
-	return 0;
-}
-
-static int sip_cc_monitor_cancel_available_timer(struct ast_cc_monitor *monitor, const int core_id, int *sched_id)
-{
-	/* XXX STUB */
-	return 0;
-}
-
-static void sip_cc_monitor_destructor(void *monitor)
-{
-	/* XXX STUB */
-}
-
-static void sip_cc_monitor_instance_destructor(const int core_id)
-{
-	/* XXX STUB */
-}
-
 /*! \brief Struct to handle custom SIP notify requests. Dynamically allocated when needed */
 struct sip_notify {
 	struct ast_variable *headers;
@@ -3449,6 +3307,211 @@
  * and is for use with channels using SIP INFO DTMF.
  */
 static struct ast_channel_tech sip_tech_info;
+
+static int sip_cc_agent_init(struct ast_cc_agent *agent, struct ast_channel *chan);
+static int sip_cc_agent_offer_cc(struct ast_cc_agent *agent, const char * const callee_interface);
+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_ack(struct ast_cc_agent *agent);
+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);
+static void sip_cc_agent_destructor(struct ast_cc_agent *agent);
+
+static struct ast_cc_agent_callbacks sip_cc_agent_callbacks = {
+	.type = "SIP",
+	.init = sip_cc_agent_init,
+	.offer_cc = sip_cc_agent_offer_cc,
+	.start_offer_timer = sip_cc_agent_start_offer_timer,
+	.stop_offer_timer = sip_cc_agent_stop_offer_timer,
+	.ack = sip_cc_agent_ack,
+	.status_request = sip_cc_agent_status_request,
+	.start_monitoring = sip_cc_agent_start_monitoring,
+	.callee_available = sip_cc_agent_recall,
+	.destructor = sip_cc_agent_destructor,
+};
+
+struct sip_cc_agent_pvt {
+	int offer_timer_id;
+	/* A reference to the dialog with the caller
+	 * who is failing to reach his intended destination.
+	 */
+	struct sip_pvt *original_call;
+	/* A reference to the dialog which we will
+	 * be sending a NOTIFY on when it comes time
+	 * to send one
+	 */
+	struct sip_pvt *subscribe_pvt;
+	char is_available;
+};
+
+static int sip_cc_agent_init(struct ast_cc_agent *agent, struct ast_channel *chan)
+{
+	struct sip_cc_agent_pvt *agent_pvt = ast_calloc(1, sizeof(*agent_pvt));
+	struct sip_pvt *call_pvt = chan->tech_pvt;
+
+	if (!agent_pvt) {
+		return -1;
+	}
+
+	ast_assert(!strcmp(chan->tech->type, "SIP"));
+
+	agent_pvt->original_call = dialog_ref(call_pvt, "Get reference to original call dialog");
+	agent->private_data = agent_pvt;
+	return 0;
+}
+
+static int sip_cc_agent_offer_cc(struct ast_cc_agent *agent, const char * const callee_interface)
+{
+	/* SIP agents don't care about the callee interface. However, it is convenient to be able
+	 * to mark the original call as being able to offer CC, so we'll set a flag here. Further
+	 * responses sent to the caller will then have CC offers.
+	 */
+	return 0;
+}
+
+
+static int sip_offer_timer_expire(const void *data)
+{
+	struct ast_cc_agent *agent = (struct ast_cc_agent *) data;
+	struct sip_cc_agent_pvt *agent_pvt = agent->private_data;
+
+	agent_pvt->offer_timer_id = -1;
+
+	return ast_cc_failed(agent->core_id, "SIP agent offer timer expired");
+}
+
+static int sip_cc_agent_start_offer_timer(struct ast_cc_agent *agent)
+{
+	struct sip_cc_agent_pvt *agent_pvt = agent->private_data;
+	int when;
+
+	when = ast_get_cc_offer_timer(agent->cc_params) * 1000;
+	agent_pvt->offer_timer_id = ast_sched_add(sched, when, sip_offer_timer_expire, agent);
+	return 0;
+}
+
+static int sip_cc_agent_stop_offer_timer(struct ast_cc_agent *agent)
+{
+	struct sip_cc_agent_pvt *agent_pvt = agent->private_data;
+
+	AST_SCHED_DEL(sched, agent_pvt->offer_timer_id);
+	return 0;
+}
+
+static void sip_cc_agent_ack(struct ast_cc_agent *agent)
+{
+	struct sip_cc_agent_pvt *agent_pvt = agent->private_data;
+	
+	sip_pvt_lock(agent_pvt->subscribe_pvt);
+	transmit_response(agent_pvt->subscribe_pvt, "200 OK", &agent_pvt->subscribe_pvt->initreq);
+	sip_pvt_unlock(agent_pvt->subscribe_pvt);
+	/* XXX Need to send a NOTIFY here with the "queued" state. */
+}
+
+static int sip_cc_agent_status_request(struct ast_cc_agent *agent)
+{
+	/* XXX STUB */
+	return 0;
+}
+
+static int sip_cc_agent_start_monitoring(struct ast_cc_agent *agent)
+{
+	/* To start monitoring just means to wait for an incoming PUBLISH
+	 * to tell us that the caller has become available again. No special
+	 * action is needed
+	 */
+	return 0;
+}
+
+static int sip_cc_agent_recall(struct ast_cc_agent *agent)
+{
+	/* Here, we need to send a NOTIFY with the "open" state */
+	return 0;
+}
+
+static void sip_cc_agent_destructor(struct ast_cc_agent *agent)
+{
+	struct sip_cc_agent_pvt *agent_pvt = agent->private_data;
+
+	if (agent_pvt->offer_timer_id != -1) {
+		AST_SCHED_DEL(sched, agent_pvt->offer_timer_id);
+	}
+	/* As the agent, we don't need to send any sort of messages
+	 * on the sip_pvts for which we have references. We just need
+	 * to unref.
+	 */
+	agent_pvt->original_call = dialog_unref(agent_pvt->original_call, "SIP CC agent destructor: Remove ref to original call");
+	agent_pvt->subscribe_pvt = dialog_unref(agent_pvt->subscribe_pvt, "SIP CC agent destructor: Remove ref to subscription");
+	ast_free(agent_pvt);
+}
+
+static int sip_cc_monitor_init(struct ast_cc_monitor *monitor, const int core_id);
+static int sip_cc_monitor_request_cc(struct ast_cc_monitor *monitor, const int core_id, struct ast_cc_monitor_link *parent_link);
+static int sip_cc_monitor_suspend(struct ast_cc_monitor *monitor, const int core_id);
+static int sip_cc_monitor_status_response(struct ast_cc_monitor *monitor, const int core_id, enum ast_device_state devstate);
+static int sip_cc_monitor_unsuspend(struct ast_cc_monitor *monitor, const int core_id);
+static int sip_cc_monitor_cancel_available_timer(struct ast_cc_monitor *monitor, const int core_id, int *sched_id);
+static void sip_cc_monitor_destructor(void *monitor);
+static void sip_cc_monitor_instance_destructor(const int core_id);
+
+static struct ast_cc_monitor_callbacks sip_cc_monitor_callbacks = {
+	.type = "SIP",
+	.init = sip_cc_monitor_init,
+	.request_cc = sip_cc_monitor_request_cc,
+	.suspend = sip_cc_monitor_suspend,
+	.status_response = sip_cc_monitor_status_response,
+	.unsuspend = sip_cc_monitor_unsuspend,
+	.cancel_available_timer = sip_cc_monitor_cancel_available_timer,
+	.destructor = sip_cc_monitor_destructor,
+	.instance_destructor = sip_cc_monitor_instance_destructor,
+};
+
+static int sip_cc_monitor_init(struct ast_cc_monitor *monitor, const int core_id)
+{
+	/* XXX STUB */
+	return 0;
+}
+
+static int sip_cc_monitor_request_cc(struct ast_cc_monitor *monitor, const int core_id, struct ast_cc_monitor_link *parent_link)
+{
+	/* XXX STUB */
+	return 0;
+}
+
+static int sip_cc_monitor_suspend(struct ast_cc_monitor *monitor, const int core_id)
+{
+	/* XXX STUB */
+	return 0;
+}
+
+static int sip_cc_monitor_status_response(struct ast_cc_monitor *monitor, const int core_id, enum ast_device_state devstate)
+{
+	/* XXX STUB */
+	return 0;
+}
+
+static int sip_cc_monitor_unsuspend(struct ast_cc_monitor *monitor, const int core_id)
+{
+	/* XXX STUB */
+	return 0;
+}
+
+static int sip_cc_monitor_cancel_available_timer(struct ast_cc_monitor *monitor, const int core_id, int *sched_id)
+{
+	/* XXX STUB */
+	return 0;
+}
+
+static void sip_cc_monitor_destructor(void *monitor)
+{
+	/* XXX STUB */
+}
+
+static void sip_cc_monitor_instance_destructor(const int core_id)
+{
+	/* XXX STUB */
+}
 
 
 /*! \brief Working TLS connection configuration */




More information about the svn-commits mailing list