[svn-commits] mmichelson: branch 12 r399083 - in /branches/12: include/asterisk/ res/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Sep 13 09:49:54 CDT 2013


Author: mmichelson
Date: Fri Sep 13 09:49:51 2013
New Revision: 399083

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=399083
Log:
Create more accurate Contact headers for dialogs when we are the UAS.

(closes issue AST-1207)
reported by John Bigelow

Review: https://reviewboard.asterisk.org/r/2842


Modified:
    branches/12/include/asterisk/res_pjsip.h
    branches/12/res/res_pjsip.c
    branches/12/res/res_pjsip.exports.in
    branches/12/res/res_pjsip_pubsub.c
    branches/12/res/res_pjsip_session.c

Modified: branches/12/include/asterisk/res_pjsip.h
URL: http://svnview.digium.com/svn/asterisk/branches/12/include/asterisk/res_pjsip.h?view=diff&rev=399083&r1=399082&r2=399083
==============================================================================
--- branches/12/include/asterisk/res_pjsip.h (original)
+++ branches/12/include/asterisk/res_pjsip.h Fri Sep 13 09:49:51 2013
@@ -1188,7 +1188,7 @@
 };
 
 /*!
- * \brief General purpose method for creating a dialog with an endpoint
+ * \brief General purpose method for creating a UAC dialog with an endpoint
  *
  * \param endpoint A pointer to the endpoint
  * \param aor_name Optional name of the AOR to target, may even be an explicit SIP URI
@@ -1197,7 +1197,15 @@
  * \retval non-NULL success
  * \retval NULL failure
  */
- pjsip_dialog *ast_sip_create_dialog(const struct ast_sip_endpoint *endpoint, const char *aor_name, const char *request_user);
+pjsip_dialog *ast_sip_create_dialog_uac(const struct ast_sip_endpoint *endpoint, const char *aor_name, const char *request_user);
+
+/*!
+ * \brief General purpose method for creating a UAS dialog with an endpoint
+ *
+ * \param endpoint A pointer to the endpoint
+ * \param rdata The request that is starting the dialog
+ */
+pjsip_dialog *ast_sip_create_dialog_uas(const struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata);
 
 /*!
  * \brief General purpose method for creating a SIP request

Modified: branches/12/res/res_pjsip.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/res/res_pjsip.c?view=diff&rev=399083&r1=399082&r2=399083
==============================================================================
--- branches/12/res/res_pjsip.c (original)
+++ branches/12/res/res_pjsip.c Fri Sep 13 09:49:51 2013
@@ -1324,7 +1324,7 @@
 	return 0;
 }
 
-pjsip_dialog *ast_sip_create_dialog(const struct ast_sip_endpoint *endpoint, const char *uri, const char *request_user)
+pjsip_dialog *ast_sip_create_dialog_uac(const struct ast_sip_endpoint *endpoint, const char *uri, const char *request_user)
 {
 	pj_str_t local_uri = { "sip:temp at temp", 13 }, remote_uri;
 	pjsip_dialog *dlg = NULL;
@@ -1382,6 +1382,38 @@
 	}
 
 	dlg->sess_count--;
+
+	return dlg;
+}
+
+pjsip_dialog *ast_sip_create_dialog_uas(const struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata)
+{
+	pjsip_dialog *dlg;
+	pj_str_t contact;
+	pjsip_transport_type_e type = rdata->tp_info.transport->key.type;
+	pj_status_t status;
+
+	contact.ptr = pj_pool_alloc(rdata->tp_info.pool, PJSIP_MAX_URL_SIZE);
+	contact.slen = pj_ansi_snprintf(contact.ptr, PJSIP_MAX_URL_SIZE,
+			"<%s:%s%.*s%s:%d%s%s>",
+			(pjsip_transport_get_flag_from_type(type) & PJSIP_TRANSPORT_SECURE) ? "sips" : "sip",
+			(type & PJSIP_TRANSPORT_IPV6) ? "[" : "",
+			(int)rdata->tp_info.transport->local_name.host.slen,
+			rdata->tp_info.transport->local_name.host.ptr,
+			(type & PJSIP_TRANSPORT_IPV6) ? "]" : "",
+			rdata->tp_info.transport->local_name.port,
+			(type != PJSIP_TRANSPORT_UDP && type != PJSIP_TRANSPORT_UDP6) ? ";transport=" : "",
+			(type != PJSIP_TRANSPORT_UDP && type != PJSIP_TRANSPORT_UDP6) ? pjsip_transport_get_type_name(type) : "");
+
+	status = pjsip_dlg_create_uas(pjsip_ua_instance(), rdata, &contact, &dlg);
+	if (status != PJ_SUCCESS) {
+		char err[PJ_ERR_MSG_SIZE];
+
+		pjsip_strerror(status, err, sizeof(err));
+		ast_log(LOG_ERROR, "Could not create dialog with endpoint %s. %s\n",
+				ast_sorcery_object_get_id(endpoint), err);
+		return NULL;
+	}
 
 	return dlg;
 }

Modified: branches/12/res/res_pjsip.exports.in
URL: http://svnview.digium.com/svn/asterisk/branches/12/res/res_pjsip.exports.in?view=diff&rev=399083&r1=399082&r2=399083
==============================================================================
--- branches/12/res/res_pjsip.exports.in (original)
+++ branches/12/res/res_pjsip.exports.in Fri Sep 13 09:49:51 2013
@@ -32,7 +32,8 @@
 		LINKER_SYMBOL_PREFIXast_sip_get_endpoints;
 		LINKER_SYMBOL_PREFIXast_copy_pj_str;
 		LINKER_SYMBOL_PREFIXast_sip_get_sorcery;
-		LINKER_SYMBOL_PREFIXast_sip_create_dialog;
+		LINKER_SYMBOL_PREFIXast_sip_create_dialog_uac;
+		LINKER_SYMBOL_PREFIXast_sip_create_dialog_uas;
 		LINKER_SYMBOL_PREFIXast_sip_location_retrieve_aor;
 		LINKER_SYMBOL_PREFIXast_sip_location_retrieve_first_aor_contact;
 		LINKER_SYMBOL_PREFIXast_sip_location_retrieve_contact_from_aor_list;

Modified: branches/12/res/res_pjsip_pubsub.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/res/res_pjsip_pubsub.c?view=diff&rev=399083&r1=399082&r2=399083
==============================================================================
--- branches/12/res/res_pjsip_pubsub.c (original)
+++ branches/12/res/res_pjsip_pubsub.c Fri Sep 13 09:49:51 2013
@@ -282,7 +282,7 @@
 	}
 	sub->role = role;
 	if (role == AST_SIP_NOTIFIER) {
-		pjsip_dlg_create_uas(pjsip_ua_instance(), rdata, NULL, &dlg);
+		dlg = ast_sip_create_dialog_uas(endpoint, rdata);
 	} else {
 		RAII_VAR(struct ast_sip_contact *, contact, NULL, ao2_cleanup);
 
@@ -293,7 +293,7 @@
 			ao2_ref(sub, -1);
 			return NULL;
 		}
-		dlg = ast_sip_create_dialog(endpoint, contact->uri, NULL);
+		dlg = ast_sip_create_dialog_uac(endpoint, contact->uri, NULL);
 	}
 	if (!dlg) {
 		ast_log(LOG_WARNING, "Unable to create dialog for SIP subscription\n");

Modified: branches/12/res/res_pjsip_session.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/res/res_pjsip_session.c?view=diff&rev=399083&r1=399082&r2=399083
==============================================================================
--- branches/12/res/res_pjsip_session.c (original)
+++ branches/12/res/res_pjsip_session.c Fri Sep 13 09:49:51 2013
@@ -1185,7 +1185,7 @@
 		return NULL;
 	}
 
-	if (!(dlg = ast_sip_create_dialog(endpoint, uri, request_user))) {
+	if (!(dlg = ast_sip_create_dialog_uac(endpoint, uri, request_user))) {
 		return NULL;
 	}
 
@@ -1337,7 +1337,8 @@
 		}
 		return NULL;
 	}
-	if (pjsip_dlg_create_uas(pjsip_ua_instance(), rdata, NULL, &dlg) != PJ_SUCCESS) {
+	dlg = ast_sip_create_dialog_uas(endpoint, rdata);
+	if (!dlg) {
 		pjsip_endpt_respond_stateless(ast_sip_get_pjsip_endpoint(), rdata, 500, NULL, NULL, NULL);
 		return NULL;
 	}




More information about the svn-commits mailing list