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

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


Author: mmichelson
Date: Mon Nov 16 13:28:31 2009
New Revision: 230418

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=230418
Log:
* Create a stub for handling publish responses
* Add a method for finding an EPA entry by call-id when we receive
  a response to a PUBLISH


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=230418&r1=230417&r2=230418
==============================================================================
--- team/group/CCSS/channels/chan_sip.c (original)
+++ team/group/CCSS/channels/chan_sip.c Mon Nov 16 13:28:31 2009
@@ -1684,7 +1684,7 @@
    	 * sure to include the entity tag that we
    	 * received in the previous response.
    	 */
-	char entity_tag[30];
+	char entity_tag[SIPBUFSIZE];
 	/* The event package to which this
    	 * entry belongs.
    	 */
@@ -1697,6 +1697,18 @@
    	 * 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)
@@ -1757,6 +1769,30 @@
 		}
 	}
 	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)
@@ -3168,6 +3204,7 @@
 static int local_attended_transfer(struct sip_pvt *transferer, struct sip_dual *current, struct sip_request *req, int seqno, int *nounlock);
 
 /*------Response handling functions */
+static void handle_response_publish(struct sip_pvt *p, int resp, const char *rest, struct sip_request *req, int seqno);
 static void handle_response_invite(struct sip_pvt *p, int resp, const char *rest, struct sip_request *req, int seqno);
 static void handle_response_notify(struct sip_pvt *p, int resp, const char *rest, struct sip_request *req, int seqno);
 static void handle_response_refer(struct sip_pvt *p, int resp, const char *rest, struct sip_request *req, int seqno);
@@ -11717,6 +11754,7 @@
 	struct sip_request req;
 	char expires_str[10];
 
+	/* XXX Investigate the arguments to sip_alloc more thoroughly */
 	sip_alloc(NULL, NULL, 0, SIP_PUBLISH, NULL);
 
 	req.method = SIP_PUBLISH;
@@ -18842,6 +18880,11 @@
 	if ((p->authtries == MAX_AUTHTRIES) || do_proxy_auth(p, req, resp, SIP_UPDATE, 1)) {
 		ast_log(LOG_NOTICE, "Failed to authenticate on UPDATE to '%s'\n", get_header(&p->initreq, "From"));
 	}
+}
+
+static void handle_response_publish(struct sip_pvt *p, int resp, const char *rest, struct sip_request *req, int seqno)
+{
+
 }
 
 /*! \brief Handle SIP response to INVITE dialogue */
@@ -19810,6 +19853,11 @@
 				handle_response_subscribe(p, resp, rest, req, seqno);
 			else if (owner)
 				ast_queue_control(p->owner, AST_CONTROL_CONGESTION);
+			break;
+		case 412: /* Conditional Request Failed */
+			if (sipmethod == SIP_PUBLISH) {
+				handle_response_publish(p, resp, rest, req, seqno);
+			}
 			break;
 		case 423: /* Interval too brief */
 			if (sipmethod == SIP_REGISTER)




More information about the asterisk-commits mailing list