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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Feb 14 18:02:20 CST 2013


Author: file
Date: Thu Feb 14 18:02:16 2013
New Revision: 381520

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=381520
Log:
Dial all provided AORs with contacts, and also all provided explicit SIP URIs when creating an outgoing session.

Modified:
    team/file/pimp_sip_location/include/asterisk/res_sip.h
    team/file/pimp_sip_location/res/res_sip.exports.in
    team/file/pimp_sip_location/res/res_sip/sip_configuration.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=381520&r1=381519&r2=381520
==============================================================================
--- team/file/pimp_sip_location/include/asterisk/res_sip.h (original)
+++ team/file/pimp_sip_location/include/asterisk/res_sip.h Thu Feb 14 18:02:16 2013
@@ -183,6 +183,8 @@
         AST_STRING_FIELD(transport);
         /*! Outbound proxy to use */
         AST_STRING_FIELD(outbound_proxy);
+        /*! Explicit AORs to dial if none are specified */
+        AST_STRING_FIELD(aors);
 	);
 	/*! Identification information for this endpoint */
 	struct ast_party_id id;

Modified: team/file/pimp_sip_location/res/res_sip.exports.in
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_location/res/res_sip.exports.in?view=diff&rev=381520&r1=381519&r2=381520
==============================================================================
--- team/file/pimp_sip_location/res/res_sip.exports.in (original)
+++ team/file/pimp_sip_location/res/res_sip.exports.in Thu Feb 14 18:02:16 2013
@@ -25,6 +25,12 @@
 		LINKER_SYMBOL_PREFIXast_copy_pj_str;
 		LINKER_SYMBOL_PREFIXast_sip_get_sorcery;
 		LINKER_SYMBOL_PREFIXast_sip_create_dialog;
+		LINKER_SYMBOL_PREFIXast_sip_location_retrieve_aor;
+		LINKER_SYMBOL_PREFIXast_sip_location_retrieve_aor_contacts;
+		LINKER_SYMBOL_PREFIXast_sip_location_retrieve_contact;
+		LINKER_SYMBOL_PREFIXast_sip_location_add_contact;
+		LINKER_SYMBOL_PREFIXast_sip_location_update_contact;
+		LINKER_SYMBOL_PREFIXast_sip_location_delete_contact;
 		LINKER_SYMBOL_PREFIXpj_*;
 		LINKER_SYMBOL_PREFIXpjsip_*;
 		LINKER_SYMBOL_PREFIXpjmedia_*;

Modified: team/file/pimp_sip_location/res/res_sip/sip_configuration.c
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_location/res/res_sip/sip_configuration.c?view=diff&rev=381520&r1=381519&r2=381520
==============================================================================
--- team/file/pimp_sip_location/res/res_sip/sip_configuration.c (original)
+++ team/file/pimp_sip_location/res/res_sip/sip_configuration.c Thu Feb 14 18:02:16 2013
@@ -150,6 +150,7 @@
 	ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "timers", "yes", timers_handler, NULL, 0, 0);
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "timers_min_se", "90", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, min_se));
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "timers_sess_expires", "1800", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, sess_expires));
+	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "aors", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, aors));
 
 	if (ast_sip_initialize_sorcery_transport(sip_sorcery)) {
 		ast_log(LOG_ERROR, "Failed to register SIP transport support with sorcery\n");

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=381520&r1=381519&r2=381520
==============================================================================
--- team/file/pimp_sip_location/res/res_sip_session.c (original)
+++ team/file/pimp_sip_location/res/res_sip_session.c Thu Feb 14 18:02:16 2013
@@ -556,11 +556,35 @@
 	return 0;
 }
 
+/*! \brief Internal function which adds an AOR with container of contacts as outgoing legs on a session */
+static int sip_session_leg_add_aor(struct ast_sip_endpoint *endpoint, struct ast_sip_session *session, pjsip_timer_setting *timer, const char *aor_name)
+{
+	RAII_VAR(struct ast_sip_aor *, aor, ast_sip_location_retrieve_aor(aor_name), ao2_cleanup);
+	RAII_VAR(struct ao2_container *, contacts, NULL, ao2_cleanup);
+	struct ao2_iterator it_contacts;
+	struct ast_sip_contact *contact;
+
+	if (!aor) {
+		return -1;
+	} else if (!(contacts = ast_sip_location_retrieve_aor_contacts(aor))) {
+		/* The AOR is valid so we don't want to try this as a straight up URI */
+		return 0;
+	}
+
+	it_contacts = ao2_iterator_init(contacts, 0);
+	for (; (contact = ao2_iterator_next(&it_contacts)); ao2_ref(contact, -1)) {
+		sip_session_create_leg(endpoint, session, contact->uri, timer);
+	}
+	ao2_iterator_destroy(&it_contacts);
+
+	return 0;
+}
+
 struct ast_sip_session *ast_sip_session_create_outgoing(struct ast_sip_endpoint *endpoint, const char *location, const char *request_user)
 {
 	struct ast_sip_session *session;
 	pjsip_timer_setting timer;
-	RAII_VAR(struct ast_sip_aor *, aor, NULL, ao2_cleanup);
+	char *aor_name, *rest;
 
 	/* Create an outgoing session with no default inv_session, multiple may get added later */
 	if (!(session = ast_sip_session_alloc(endpoint, NULL))) {
@@ -571,9 +595,23 @@
 	timer.min_se = endpoint->min_se;
 	timer.sess_expires = endpoint->sess_expires;
 
-	sip_session_create_leg(endpoint, session, location, &timer);
-	sip_session_create_leg(endpoint, session, "sip:meh at 172.16.1.13", &timer);
-	sip_session_create_leg(endpoint, session, "sip:2000 at labs.asterisk.org", &timer);
+	/* If no location has been provided use the AOR list from the endpoint itself */
+	if (ast_strlen_zero(location)) {
+		location = endpoint->aors;
+	}
+
+	/* If the location is still empty we have nowhere to go */
+	if (ast_strlen_zero(location) || !(rest = ast_strdupa(location))) {
+		ao2_ref(session, -1);
+		return NULL;
+	}
+
+	while ((aor_name = strsep(&rest, ","))) {
+		/* If adding based on AOR fails try adding it straight up as a URI */
+		if (sip_session_leg_add_aor(endpoint, session, &timer, aor_name)) {
+			sip_session_create_leg(endpoint, session, aor_name, &timer);
+		}
+	}
 
 	/* If the end result of this attempt is no outgoing legs then kill the session */
 	if (!ao2_container_count(session->legs)) {




More information about the asterisk-commits mailing list