[asterisk-commits] kmoore: branch kmoore/pjsip_path_support r403394 - /team/kmoore/pjsip_path_su...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Dec 5 07:43:25 CST 2013


Author: kmoore
Date: Thu Dec  5 07:43:23 2013
New Revision: 403394

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=403394
Log:
Add Supported: path on outbound responses as well

Modified:
    team/kmoore/pjsip_path_support/res/res_pjsip_path.c

Modified: team/kmoore/pjsip_path_support/res/res_pjsip_path.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/res/res_pjsip_path.c?view=diff&rev=403394&r1=403393&r2=403394
==============================================================================
--- team/kmoore/pjsip_path_support/res/res_pjsip_path.c (original)
+++ team/kmoore/pjsip_path_support/res/res_pjsip_path.c Thu Dec  5 07:43:23 2013
@@ -191,19 +191,17 @@
  * \param session The session on which the INVITE response is to be sent
  * \param tdata The outbound INVITE response
  */
-static void path_outgoing_register_response(struct ast_sip_endpoint *endpoint, pjsip_tx_data *tdata)
+static void path_outgoing_response(struct ast_sip_endpoint *endpoint, pjsip_tx_data *tdata)
 {
 	struct pjsip_status_line status = tdata->msg->line.status;
 	pj_str_t path_dup;
 	pjsip_generic_string_hdr *path_hdr;
 	pjsip_contact_hdr *contact_hdr;
 	RAII_VAR(struct ast_sip_aor *, aor, NULL, ao2_cleanup);
+	pjsip_cseq_hdr *cseq = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_CSEQ, NULL);
+	const pj_str_t REGISTER_METHOD = {"REGISTER", 8};
 
 	if (!endpoint) {
-		return;
-	}
-
-	if (status.code != 200) {
 		return;
 	}
 
@@ -217,27 +215,29 @@
 		return;
 	}
 
-	if (path_get_string(tdata->pool, aor, contact_hdr->uri, &path_dup)) {
-		return;
-	}
-
-	path_hdr = pjsip_generic_string_hdr_create(tdata->pool, &path_name, &path_dup);
-	if (!path_hdr) {
-		return;
-	}
-
-	pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)path_hdr);
+	if (add_supported(tdata)) {
+		return;
+	}
+
+	if (pj_stristr(&REGISTER_METHOD, &cseq->method.name) && status.code == 200) {
+		if (path_get_string(tdata->pool, aor, contact_hdr->uri, &path_dup)) {
+			return;
+		}
+
+		path_hdr = pjsip_generic_string_hdr_create(tdata->pool, &path_name, &path_dup);
+		if (!path_hdr) {
+			return;
+		}
+
+		pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)path_hdr);
+	}
+
 }
 
 static struct ast_sip_supplement path_supplement = {
 	.priority = AST_SIP_SUPPLEMENT_PRIORITY_CHANNEL - 100,
 	.outgoing_request = path_outgoing_request,
-};
-
-static struct ast_sip_supplement path_register_supplement = {
-	.method = "REGISTER",
-	.priority = AST_SIP_SUPPLEMENT_PRIORITY_CHANNEL - 100,
-	.outgoing_response = path_outgoing_register_response,
+	.outgoing_response = path_outgoing_response,
 };
 
 static int load_module(void)
@@ -246,17 +246,11 @@
 		return AST_MODULE_LOAD_DECLINE;
 	}
 
-	if (ast_sip_register_supplement(&path_register_supplement)) {
-		ast_sip_unregister_supplement(&path_supplement);
-		return AST_MODULE_LOAD_DECLINE;
-	}
-
 	return AST_MODULE_LOAD_SUCCESS;
 }
 
 static int unload_module(void)
 {
-	ast_sip_unregister_supplement(&path_register_supplement);
 	ast_sip_unregister_supplement(&path_supplement);
 	return 0;
 }




More information about the asterisk-commits mailing list