[asterisk-commits] mmichelson: branch group/CCSS r229603 - /team/group/CCSS/channels/chan_sip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Nov 11 16:13:28 CST 2009


Author: mmichelson
Date: Wed Nov 11 16:13:24 2009
New Revision: 229603

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=229603
Log:
Add handler for SIP PUBLISH "initial" message.

Currently, I'm leaving out CC-specific things as
much as possible. I'll put a skeleton in there
to let me know where things should go once I get
to them. This also makes it clear to see how other
event packages would be handled.


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=229603&r1=229602&r2=229603
==============================================================================
--- team/group/CCSS/channels/chan_sip.c (original)
+++ team/group/CCSS/channels/chan_sip.c Wed Nov 11 16:13:24 2009
@@ -710,7 +710,8 @@
 	DIALOG_INFO_XML,
 	CPIM_PIDF_XML,
 	PIDF_XML,
-	MWI_NOTIFICATION
+	MWI_NOTIFICATION,
+	CALL_COMPLETION,
 };
 
 /*! \brief The number of media types in enum \ref media_type below. */
@@ -1716,7 +1717,7 @@
  * This structure lives in the event_specific_data
  * section of a sip_esc_entry for the CC ESC.
  */
-struct cc_esc_entry {
+struct cc_esc_data {
 	/*!
 	 * The current state of the device from which
 	 * we have received a PUBLISH.
@@ -1754,10 +1755,11 @@
  * using the entity ID of the incoming PUBLISH.
  */
 static struct event_state_compositor {
+	enum subscriptiontype event;
 	const char * name;
 	struct ao2_container **compositor;
 } event_state_compositors [] = {
-	{"call-completion", &cc_esc},
+	{CALL_COMPLETION, "call-completion", &cc_esc},
 };
 
 static const int ESC_MAX_BUCKETS = 37;
@@ -1807,17 +1809,43 @@
 	return entry;
 }
 
-static struct sip_esc_entry *create_esc_entry(const char *event)
+static int cc_esc_init(struct sip_esc_entry *sip_esc_entry, struct sip_request *req)
+{
+	struct cc_esc_data *cc_data = ast_calloc(1, sizeof(*cc_data));
+
+	if (!cc_data) {
+		return -1;
+	}
+
+	/* For CC, we can associate the incoming request with a CC core_id in one of two ways.
+	 * 1. The Request-URI will be one that we sent in a NOTIFY to let the phone know that
+	 * the called party has become available.
+	 * 2. The PUBLISH is sent in the SUBSCRIBE-NOTIFY dialog.
+	 * 
+	 * Since we're focusing for now specifically on SIP PUBLISH support, and not how it ties
+	 * in with CC specifically, I'm leaving this as a TODO XXX type thing.
+	 */
+
+	sip_esc_entry->event_specific_data = cc_data;
+
+	return 0;
+}
+
+static struct sip_esc_entry *create_esc_entry(struct event_state_compositor *esc, struct sip_request *req)
 {
 	struct sip_esc_entry *esc_entry;
-	struct event_state_compositor *esc = get_esc(event);
-
-	if (!esc) {
-		return NULL;
-	}
+	int res = -1;
 
 	if (!(esc_entry = ao2_alloc(sizeof(*esc_entry), esc_entry_destructor))) {
 		return NULL;
+	}
+
+	switch (esc->event) {
+	case CALL_COMPLETION:
+		res = cc_esc_init(esc_entry, req);
+		break;
+	default:
+		break;
 	}
 
 	ao2_link(*esc->compositor, esc_entry);
@@ -22432,19 +22460,28 @@
 
 static int handle_sip_publish_initial(struct sip_pvt *p, struct sip_request *req, struct event_state_compositor *esc)
 {
+	struct sip_esc_entry *esc_entry = create_esc_entry(esc, req);
+
+	if (!esc_entry) {
+		return -1;
+	}
+
+	ao2_ref(esc_entry, -1);
+	return 0;
+}
+
+static int handle_sip_publish_refresh(struct sip_pvt *p, struct sip_request *req, struct event_state_compositor *esc, const char * const eid)
+{
 	/* XXX STUB */
 	return 0;
 }
-static int handle_sip_publish_refresh(struct sip_pvt *p, struct sip_request *req, struct event_state_compositor *esc, const char * const eid)
+
+static int handle_sip_publish_modify(struct sip_pvt *p, struct sip_request *req, struct event_state_compositor *esc, const char * const eid)
 {
 	/* XXX STUB */
 	return 0;
 }
-static int handle_sip_publish_modify(struct sip_pvt *p, struct sip_request *req, struct event_state_compositor *esc, const char * const eid)
-{
-	/* XXX STUB */
-	return 0;
-}
+
 static int handle_sip_publish_remove(struct sip_pvt *p, struct sip_request *req, struct event_state_compositor *esc, const char * const eid)
 {
 	/* XXX STUB */




More information about the asterisk-commits mailing list