[asterisk-commits] file: branch file/pimp_sip_location r381308 - in /team/file/pimp_sip_location...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Feb 12 15:02:21 CST 2013


Author: file
Date: Tue Feb 12 15:02:17 2013
New Revision: 381308

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=381308
Log:
Don't require the caller of ast_sip_create_dialog to provide a transport selector and apply it.

Modified:
    team/file/pimp_sip_location/include/asterisk/res_sip.h
    team/file/pimp_sip_location/res/res_sip.c
    team/file/pimp_sip_location/res/res_sip_session.c

Modified: team/file/pimp_sip_location/include/asterisk/res_sip.h
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_location/include/asterisk/res_sip.h?view=diff&rev=381308&r1=381307&r2=381308
==============================================================================
--- team/file/pimp_sip_location/include/asterisk/res_sip.h (original)
+++ team/file/pimp_sip_location/include/asterisk/res_sip.h Tue Feb 12 15:02:17 2013
@@ -477,12 +477,11 @@
  * \param endpoint A pointer to the endpoint
  * \param location_name Optional name of the location to target, may even be an explicit SIP URI
  * \param request_user Optional user to place into the target URI
- * \param selector Populated transport selector information, should be applied to dialog afterwards
  *
  * \retval non-NULL success
  * \retval NULL failure
  */
- pjsip_dialog *ast_sip_create_dialog(const struct ast_sip_endpoint *endpoint, const char *location_name, const char *request_user, struct pjsip_tpselector *selector);
+ pjsip_dialog *ast_sip_create_dialog(const struct ast_sip_endpoint *endpoint, const char *location_name, const char *request_user);
 
 /*!
  * \brief General purpose method for sending a SIP request

Modified: team/file/pimp_sip_location/res/res_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_location/res/res_sip.c?view=diff&rev=381308&r1=381307&r2=381308
==============================================================================
--- team/file/pimp_sip_location/res/res_sip.c (original)
+++ team/file/pimp_sip_location/res/res_sip.c Tue Feb 12 15:02:17 2013
@@ -291,16 +291,14 @@
 
 
 
-pjsip_dialog *ast_sip_create_dialog(const struct ast_sip_endpoint *endpoint, const char *location_name, const char *request_user, pjsip_tpselector *selector)
+pjsip_dialog *ast_sip_create_dialog(const struct ast_sip_endpoint *endpoint, const char *location_name, const char *request_user)
 {
 	pj_str_t local_uri = pj_str("sip:temp at localhost"), remote_uri;
 	RAII_VAR(struct ast_sip_location *, location, NULL, ao2_cleanup);
 	pjsip_dialog *dlg = NULL;
 	const char *transport_name = endpoint->transport;
+	pjsip_tpselector selector = { .type = PJSIP_TPSELECTOR_NONE, };
 	const pj_str_t HCONTACT = { "Contact", 7 };
-
-	/* Ensure no selector is used unless explicitly required */
-	selector->type = PJSIP_TPSELECTOR_NONE;
 
 	if (!ast_strlen_zero(location_name) && (location = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "location", location_name))) {
 		pj_cstr(&remote_uri, location->uri);
@@ -324,18 +322,18 @@
 		}
 
 		if (transport->type == AST_SIP_TRANSPORT_UDP) {
-			selector->type = PJSIP_TPSELECTOR_TRANSPORT;
-			selector->u.transport = transport->state->transport;
+			selector.type = PJSIP_TPSELECTOR_TRANSPORT;
+			selector.u.transport = transport->state->transport;
 		} else if (transport->type == AST_SIP_TRANSPORT_TCP || transport->type == AST_SIP_TRANSPORT_TLS) {
-			selector->type = PJSIP_TPSELECTOR_LISTENER;
-			selector->u.listener = transport->state->factory;
+			selector.type = PJSIP_TPSELECTOR_LISTENER;
+			selector.u.listener = transport->state->factory;
 		} else {
 			pjsip_dlg_terminate(dlg);
 			return NULL;
 		}
 	}
 
-	if (sip_dialog_create_from(dlg->pool, &local_uri, "temp", &remote_uri, selector)) {
+	if (sip_dialog_create_from(dlg->pool, &local_uri, "temp", &remote_uri, &selector)) {
 		pjsip_dlg_terminate(dlg);
 		return NULL;
 	}
@@ -351,6 +349,13 @@
 		pjsip_sip_uri *target = pjsip_uri_get_uri(dlg->target);
 		pj_strdup2(dlg->pool, &target->user, request_user);
 	}
+
+	/* We have to temporarily bump up the sess_count here so the dialog is not prematurely destroyed */
+	dlg->sess_count++;
+
+	pjsip_dlg_set_transport(dlg, &selector);
+
+	dlg->sess_count--;
 
 	return dlg;
 }

Modified: team/file/pimp_sip_location/res/res_sip_session.c
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_location/res/res_sip_session.c?view=diff&rev=381308&r1=381307&r2=381308
==============================================================================
--- team/file/pimp_sip_location/res/res_sip_session.c (original)
+++ team/file/pimp_sip_location/res/res_sip_session.c Tue Feb 12 15:02:17 2013
@@ -480,14 +480,13 @@
 
 struct ast_sip_session *ast_sip_session_create_outgoing(struct ast_sip_endpoint *endpoint, const char *location, const char *request_user)
 {
-	pjsip_tpselector selector;
 	pjsip_dialog *dlg = NULL;
 	pjsip_inv_session *inv_session = NULL;
 	struct ast_sip_session *session = NULL;
 	pjmedia_sdp_session *offer = NULL;
 	pjsip_timer_setting timer;
 
-	if (!(dlg = ast_sip_create_dialog(endpoint, location, request_user, &selector))) {
+	if (!(dlg = ast_sip_create_dialog(endpoint, location, request_user))) {
 		return NULL;
 	}
 
@@ -495,8 +494,6 @@
 		pjsip_dlg_terminate(dlg);
 		return NULL;
 	}
-
-	pjsip_dlg_set_transport(dlg, &selector);
 
 	pjsip_timer_setting_default(&timer);
 	timer.min_se = endpoint->min_se;




More information about the asterisk-commits mailing list