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

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Nov 30 14:26:49 CST 2009


Author: mmichelson
Date: Mon Nov 30 14:26:46 2009
New Revision: 231599

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=231599
Log:
Create a function to transmit CC-related NOTIFY requests.

Up next, using the function!


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=231599&r1=231598&r2=231599
==============================================================================
--- team/group/CCSS/channels/chan_sip.c (original)
+++ team/group/CCSS/channels/chan_sip.c Mon Nov 30 14:26:46 2009
@@ -1722,6 +1722,19 @@
 	CC_OPEN,
 };
 
+enum sip_cc_notify_state {
+	CC_QUEUED,
+	CC_READY,
+};
+
+static struct {
+	enum sip_cc_notify_state state;
+	const char *state_string;
+} sip_cc_notify_state_map [] = {
+	{CC_QUEUED, "state: queued"},
+	{CC_READY, "state: ready"},
+};
+
 struct cc_epa_entry {
 	/* The core ID of the CC transaction
      * for which this EPA entry belongs. This
@@ -3343,6 +3356,12 @@
 	 * to send one
 	 */
 	struct sip_pvt *subscribe_pvt;
+	/* When we send a NOTIFY, we include a URI
+	 * that should be used by the caller when he
+	 * wishes to send a PUBLISH or INVITE to us.
+	 * We store that URI here.
+	 */
+	char notify_uri[SIPBUFSIZE];
 	char is_available;
 };
 
@@ -12448,6 +12467,26 @@
 	}
 }
 
+static int transmit_cc_notify(struct ast_cc_agent *agent, struct sip_pvt *subscription, enum sip_cc_notify_state state)
+{
+	struct sip_request req;
+	struct sip_cc_agent_pvt *agent_pvt = agent->private_data;
+	char state_str[64];
+
+	if (state < CC_QUEUED || state > CC_READY) {
+		ast_log(LOG_WARNING, "Invalid state provided for transmit_cc_notify (%d)\n", state);
+		return -1;
+	}
+
+	reqprep(&req, subscription, SIP_NOTIFY, 0, TRUE);
+	ast_copy_string(state_str, sip_cc_notify_state_map[state].state_string, sizeof(state_str));
+	generate_random_string(agent_pvt->notify_uri, sizeof(agent_pvt->notify_uri));
+	add_header(&req, "Content-Type", "application/call-completion");
+	add_header_contentLength(&req, strlen(state_str) + strlen(agent_pvt->notify_uri));
+	add_line(&req, state_str);
+	add_line(&req, agent_pvt->notify_uri);
+	return send_request(subscription, &req, XMIT_RELIABLE, subscription->ocseq);
+}
 
 /*! \brief Used in the SUBSCRIBE notification subsystem (RFC3265) */
 static int transmit_state_notify(struct sip_pvt *p, int state, int full, int timeout)




More information about the svn-commits mailing list