[asterisk-commits] kmoore: branch kmoore/pjsip_path_support r404999 - in /team/kmoore/pjsip_path...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Jan 6 13:11:43 CST 2014
Author: kmoore
Date: Mon Jan 6 13:11:40 2014
New Revision: 404999
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=404999
Log:
Wrap response creation and make the registrar use the wrapper
Modified:
team/kmoore/pjsip_path_support/include/asterisk/res_pjsip.h
team/kmoore/pjsip_path_support/res/res_pjsip.c
team/kmoore/pjsip_path_support/res/res_pjsip_registrar.c
Modified: team/kmoore/pjsip_path_support/include/asterisk/res_pjsip.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/include/asterisk/res_pjsip.h?view=diff&rev=404999&r1=404998&r2=404999
==============================================================================
--- team/kmoore/pjsip_path_support/include/asterisk/res_pjsip.h (original)
+++ team/kmoore/pjsip_path_support/include/asterisk/res_pjsip.h Mon Jan 6 13:11:40 2014
@@ -1251,6 +1251,22 @@
void (*callback)(void *token, pjsip_event *e));
/*!
+ * \brief General purpose method for creating a SIP response
+ *
+ * Its typical use would be to create responses for out of dialog
+ * requests.
+ *
+ * \param rdata The rdata from the incoming request.
+ * \param st_code The response code to transmit.
+ * \param contact The contact with which this request is associated.
+ * \param[out] tdata The newly-created response
+ * \retval 0 Success
+ * \retval -1 Failure
+ */
+int ast_sip_create_response(const pjsip_rx_data *rdata, int st_code,
+ struct ast_sip_contact *contact, pjsip_tx_data **p_tdata);
+
+/*!
* \brief Send a response to an out of dialog request
*
* \param endpt The pjsip_endpoint with which this response is associated
Modified: team/kmoore/pjsip_path_support/res/res_pjsip.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/res/res_pjsip.c?view=diff&rev=404999&r1=404998&r2=404999
==============================================================================
--- team/kmoore/pjsip_path_support/res/res_pjsip.c (original)
+++ team/kmoore/pjsip_path_support/res/res_pjsip.c Mon Jan 6 13:11:40 2014
@@ -2191,6 +2191,18 @@
return pjsip_endpt_send_response(endpt, res_addr, tdata, NULL, NULL);
}
+int ast_sip_create_response(const pjsip_rx_data *rdata, int st_code,
+ struct ast_sip_contact *contact, pjsip_tx_data **tdata)
+{
+ int res = pjsip_endpt_create_response(ast_sip_get_pjsip_endpoint(), rdata, st_code, NULL, tdata);
+
+ if (!res) {
+ ast_sip_mod_data_set((*tdata)->pool, (*tdata)->mod_data, supplement_module.id, MOD_DATA_CONTACT, ao2_bump(contact));
+ }
+
+ return res;
+}
+
static void remove_request_headers(pjsip_endpoint *endpt)
{
const pjsip_hdr *request_headers = pjsip_endpt_get_request_headers(endpt);
Modified: team/kmoore/pjsip_path_support/res/res_pjsip_registrar.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/res/res_pjsip_registrar.c?view=diff&rev=404999&r1=404998&r2=404999
==============================================================================
--- team/kmoore/pjsip_path_support/res/res_pjsip_registrar.c (original)
+++ team/kmoore/pjsip_path_support/res/res_pjsip_registrar.c Mon Jan 6 13:11:40 2014
@@ -417,6 +417,7 @@
pjsip_response_addr addr;
const char *aor_name = ast_sorcery_object_get_id(task_data->aor);
RAII_VAR(struct ast_str *, path_str, NULL, ast_free);
+ struct ast_sip_contact *response_contact;
/* Retrieve the current contacts, we'll need to know whether to update or not */
contacts = ast_sip_location_retrieve_aor_contacts(task_data->aor);
@@ -536,12 +537,16 @@
/* Update the contacts as things will probably have changed */
ao2_cleanup(contacts);
+
contacts = ast_sip_location_retrieve_aor_contacts(task_data->aor);
+ response_contact = ao2_callback(contacts, 0, NULL, NULL);
/* Send a response containing all of the contacts (including static) that are present on this AOR */
- if (pjsip_endpt_create_response(ast_sip_get_pjsip_endpoint(), task_data->rdata, 200, NULL, &tdata) != PJ_SUCCESS) {
- return PJ_TRUE;
- }
+ if (ast_sip_create_response(task_data->rdata, 200, response_contact, &tdata) != PJ_SUCCESS) {
+ ao2_cleanup(response_contact);
+ return PJ_TRUE;
+ }
+ ao2_cleanup(response_contact);
/* Add the date header to the response, some UAs use this to set their date and time */
registrar_add_date_header(tdata);
More information about the asterisk-commits
mailing list