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

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Nov 19 14:18:40 CST 2009


Author: mmichelson
Date: Thu Nov 19 14:18:36 2009
New Revision: 230503

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=230503
Log:
Hmm, forgot to commit this Monday apparently...

Skeleton for handling responses to PUBLISHes.
I'll fill in the definitions for the callbacks shortly.


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=230503&r1=230502&r2=230503
==============================================================================
--- team/group/CCSS/channels/chan_sip.c (original)
+++ team/group/CCSS/channels/chan_sip.c Thu Nov 19 14:18:36 2009
@@ -1697,18 +1697,6 @@
    	 * will use event specific data
    	 */
 	void *event_specific_data;
-	/* When we receive a response to an outgoing
-	 * publish, we need to match that response to
-	 * an EPA entry. The best identifier for this is
-	 * the callid.
-	 * XXX Is it necessary to consider branches
-	 * when identifying an EPA entry? If a proxy forks
-	 * our PUBLISH, then we could get multiple responses
-	 * with different branches. In such a case, the two
-	 * endpoints would respond to our PUBLISH with two
-	 * separate SIP-Etag headers. guh.
-	 */
-	char call_id[SIPBUFSIZE];
 };
 
 static int cc_epa_hash_fn(const void *obj, const int flags)
@@ -1769,30 +1757,6 @@
 		}
 	}
 	return NULL;
-}
-
-static int get_by_call_id(void *obj, void *arg, int flags)
-{
-	struct sip_epa_entry *epa_entry = obj;
-	const char *call_id = arg;
-
-	if (!strcmp(epa_entry->call_id, call_id)) {
-		return CMP_MATCH | CMP_STOP;
-	}
-	return 0;
-}
-
-static struct sip_epa_entry *get_epa_entry_by_call_id(char *call_id, const char * event)
-{
-	struct event_publication_agent *epa;
-	struct sip_epa_entry *epa_entry;
-
-	if (!(epa = get_epa(event))) {
-		return NULL;
-	}
-
-	epa_entry = ao2_callback(epa->entries, 0, get_by_call_id, call_id);
-	return epa_entry;
 }
 
 static int initialize_epas(void)
@@ -2327,6 +2291,11 @@
 	 */
 	struct offered_media offered_media[OFFERED_MEDIA_COUNT];
 	struct ast_cc_config_params *cc_params;
+	/* When we receive a response to a SIP PUBLISH, the only way we can associate the response with the
+	 * appropriate event publication agent entry is through the sip_pvt. Unfortunately, there is no piece of information
+	 * in the response that allows us to know which event package the response pertains to.
+	 */
+	struct sip_epa_entry *epa_entry;
 };
 
 
@@ -6363,6 +6332,11 @@
 	ast_string_field_free_memory(p);
 
 	ast_cc_config_params_destroy(p->cc_params);
+
+	if (p->epa_entry) {
+		ao2_ref(p->epa_entry, -1);
+		p->epa_entry = NULL;
+	}
 
 	if (p->socket.tcptls_session) {
 		ao2_ref(p->socket.tcptls_session, -1);
@@ -11781,6 +11755,10 @@
 		add_line(&req, body);
 	}
 
+	/* Bump refcount for sip_pvt's reference */
+	ao2_ref(epa_entry, +1);
+	pvt->epa_entry = epa_entry;
+
 	send_request(pvt, &req, XMIT_RELIABLE, INITIAL_CSEQ);
 
 	return 0;
@@ -18884,7 +18862,28 @@
 
 static void handle_response_publish(struct sip_pvt *p, int resp, const char *rest, struct sip_request *req, int seqno)
 {
-
+	struct sip_epa_entry *epa_entry = p->epa_entry;
+	struct event_publication_agent *epa;
+
+	ast_assert(epa_entry != NULL);
+
+	epa = get_epa(epa_entry->event);
+
+	ast_assert(epa != NULL);
+
+	if (resp == 200) {
+		/* The nominal case. Everything went well. Everybody is happy.
+		 * Each EPA will have a specific action to take as a result of this
+		 * development, so ... callbacks!
+		 */
+		epa->callbacks->handle_ok(p, req, epa_entry);
+	} else {
+		/* Rather than try to make individual callbacks for each error
+		 * type, there is just a single error callback. The callback
+		 * can distinguish between error messages and do what it needs to
+		 */
+		epa->callbacks->handle_error(p, resp, req, epa_entry);
+	}
 }
 
 /*! \brief Handle SIP response to INVITE dialogue */




More information about the svn-commits mailing list