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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Dec 4 10:55:59 CST 2009


Author: mmichelson
Date: Fri Dec  4 10:55:55 2009
New Revision: 233090

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=233090
Log:
First step towards morphing the pidf validator into
a pidf validator and parser. I need to come up with the
necessary structures and function calls in order to facilitate
it all though.


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=233090&r1=233089&r2=233090
==============================================================================
--- team/group/CCSS/channels/chan_sip.c (original)
+++ team/group/CCSS/channels/chan_sip.c Fri Dec  4 10:55:55 2009
@@ -23435,10 +23435,11 @@
  * if you're not using a default namespace, you're probably a stupid jerk anyway.
  *
  * \param req The SIP request to check
+ * \param[out] pidf_doc The validated PIDF doc.
  * \retval FALSE The XML was malformed or the basic PIDF structure was marred
  * \retval TRUE The PIDF document is of a valid format
  */
-static int sip_pidf_validate(struct sip_request *req)
+static int sip_pidf_validate(struct sip_request *req, struct ast_xml_doc **pidf_doc)
 {
 	struct ast_xml_doc *doc;
 	int content_length;
@@ -23467,7 +23468,9 @@
 	}
 
 	res = pidf_validate_presence(doc);
-	ast_xml_close(doc);
+	if (res == TRUE) {
+		*pidf_doc = doc;
+	}
 	return res;
 }
 
@@ -23476,7 +23479,8 @@
 	const char *uri = REQ_OFFSET_TO_STR(req, rlPart2);
 	struct ast_cc_agent *agent = find_sip_cc_agent_by_notify_uri(uri);
 	struct sip_cc_agent_pvt *agent_pvt;
-
+	struct ast_xml_doc *pidf_doc;
+	
 	if (!agent) {
 		ast_log(LOG_WARNING, "Could not find agent using uri '%s'\n", uri);
 		transmit_response(pvt, "412 Conditional Request Failed", req);
@@ -23485,7 +23489,16 @@
 
 	agent_pvt = agent->private_data;
 
-	sip_pidf_validate(req);
+	if (sip_pidf_validate(req, &pidf_doc) == FALSE) {
+		/* XXX send an error response. What though? */
+	}
+
+	/* It's important to note that the PIDF validation routine has no knowledge
+	 * of what we specifically want in this instance. A valid PIDF document could
+	 * have no tuples, or it could have tuples whose status element has no basic
+	 * element contained within. While not violating the PIDF spec, these are
+	 * insufficient for our needs in this situation
+	 */
 
 	agent_pvt->is_available = FALSE;
 	/* It's possible to get a PUBLISH before we have sent a NOTIFY that a callee is
@@ -23494,6 +23507,7 @@
 	 * callback.
 	 */
 	ast_cc_agent_caller_busy(agent->core_id, "Received PUBLISH stating SIP caller is busy");
+	ast_xml_close(pidf_doc);
 	return 0;
 }
 




More information about the asterisk-commits mailing list