[asterisk-commits] file: branch file/pimp_sip_location r381428 - in /team/file/pimp_sip_location...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Feb 14 11:15:47 CST 2013
Author: file
Date: Thu Feb 14 11:15:43 2013
New Revision: 381428
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=381428
Log:
For testing purposes use the first contact when dialing an AOR.
Modified:
team/file/pimp_sip_location/include/asterisk/res_sip.h
team/file/pimp_sip_location/res/res_sip.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=381428&r1=381427&r2=381428
==============================================================================
--- team/file/pimp_sip_location/include/asterisk/res_sip.h (original)
+++ team/file/pimp_sip_location/include/asterisk/res_sip.h Thu Feb 14 11:15:43 2013
@@ -549,13 +549,13 @@
* \brief General purpose method for creating a dialog with an endpoint
*
* \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 aor_name Optional name of the AOR to target, may even be an explicit SIP URI
* \param request_user Optional user to place into the target URI
*
* \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);
+ pjsip_dialog *ast_sip_create_dialog(const struct ast_sip_endpoint *endpoint, const char *aor_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=381428&r1=381427&r2=381428
==============================================================================
--- team/file/pimp_sip_location/res/res_sip.c (original)
+++ team/file/pimp_sip_location/res/res_sip.c Thu Feb 14 11:15:43 2013
@@ -289,19 +289,31 @@
return 0;
}
-
-
-pjsip_dialog *ast_sip_create_dialog(const struct ast_sip_endpoint *endpoint, const char *location_name, const char *request_user)
+/*! \brief Callback function which simply returns immediately so we get the first contact in the list */
+static int grab_first_contact(void *obj, void *arg, int flags)
+{
+ return CMP_MATCH | CMP_STOP;
+}
+
+pjsip_dialog *ast_sip_create_dialog(const struct ast_sip_endpoint *endpoint, const char *aor_name, const char *request_user)
{
pj_str_t local_uri = pj_str("sip:temp at localhost"), remote_uri;
RAII_VAR(struct ast_sip_aor *, aor, NULL, ao2_cleanup);
RAII_VAR(struct ao2_container *, contacts, NULL, ao2_cleanup);
+ RAII_VAR(struct ast_sip_contact *, contact, NULL, ao2_cleanup);
pjsip_dialog *dlg = NULL;
const char *transport_name = endpoint->transport, *outbound_proxy = endpoint->outbound_proxy;
pjsip_tpselector selector = { .type = PJSIP_TPSELECTOR_NONE, };
const pj_str_t HCONTACT = { "Contact", 7 };
- pj_cstr(&remote_uri, location_name);
+ if ((aor = ast_sip_location_retrieve_aor(aor_name)) &&
+ (contacts = ast_sip_location_retrieve_aor_contacts(aor)) &&
+ (contact = ao2_callback(contacts, OBJ_NOLOCK, grab_first_contact, NULL))) {
+ pj_cstr(&remote_uri, contact->uri);
+ } else {
+ /* Treat the provided AOR as a SIP URI since none was found */
+ pj_cstr(&remote_uri, aor_name);
+ }
if (pjsip_dlg_create_uac(pjsip_ua_instance(), &local_uri, NULL, &remote_uri, NULL, &dlg) != PJ_SUCCESS) {
return NULL;
More information about the asterisk-commits
mailing list