[asterisk-commits] kmoore: branch kmoore/pjsip_path_support r404947 - in /team/kmoore/pjsip_path...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sun Jan 5 20:41:31 CST 2014
Author: kmoore
Date: Sun Jan 5 20:41:27 2014
New Revision: 404947
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=404947
Log:
Prepare for merge conflict resolution
Clean up and commit code based on Joshua's reviewboard comments that I
haven't been able to look at or test for the past two weeks in
preparation for wading through an abyss of merge conflicts so I can
actually feel productive tomorrow.
Modified:
team/kmoore/pjsip_path_support/channels/chan_pjsip.c
team/kmoore/pjsip_path_support/include/asterisk/res_pjsip.h
team/kmoore/pjsip_path_support/include/asterisk/res_pjsip_session.h
team/kmoore/pjsip_path_support/res/res_pjsip.c
team/kmoore/pjsip_path_support/res/res_pjsip/pjsip_options.c
team/kmoore/pjsip_path_support/res/res_pjsip_messaging.c
team/kmoore/pjsip_path_support/res/res_pjsip_mwi.c
team/kmoore/pjsip_path_support/res/res_pjsip_notify.c
team/kmoore/pjsip_path_support/res/res_pjsip_path.c
team/kmoore/pjsip_path_support/res/res_pjsip_session.c
Modified: team/kmoore/pjsip_path_support/channels/chan_pjsip.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/channels/chan_pjsip.c?view=diff&rev=404947&r1=404946&r2=404947
==============================================================================
--- team/kmoore/pjsip_path_support/channels/chan_pjsip.c (original)
+++ team/kmoore/pjsip_path_support/channels/chan_pjsip.c Sun Jan 5 20:41:27 2014
@@ -857,7 +857,7 @@
RAII_VAR(struct ast_sip_session *, session, data, ao2_cleanup);
struct pjsip_tx_data *tdata;
- if (ast_sip_create_request("INFO", session->inv_session->dlg, session->endpoint, NULL, &tdata)) {
+ if (ast_sip_create_request("INFO", session->inv_session->dlg, session->endpoint, NULL, NULL, &tdata)) {
ast_log(LOG_ERROR, "Could not create text video update INFO request\n");
return -1;
}
@@ -1255,7 +1255,7 @@
body.body_text = ast_str_buffer(body_text);
- if (ast_sip_create_request("INFO", session->inv_session->dlg, session->endpoint, NULL, &tdata)) {
+ if (ast_sip_create_request("INFO", session->inv_session->dlg, session->endpoint, NULL, NULL, &tdata)) {
ast_log(LOG_ERROR, "Could not create DTMF INFO request\n");
return -1;
}
@@ -1528,7 +1528,7 @@
return -1;
}
- if (!(session = ast_sip_session_create_outgoing(endpoint, args.aor, request_user, req_data->caps))) {
+ if (!(session = ast_sip_session_create_outgoing(endpoint, NULL, args.aor, request_user, req_data->caps))) {
req_data->cause = AST_CAUSE_NO_ROUTE_DESTINATION;
return -1;
}
@@ -1607,7 +1607,7 @@
ast_debug(3, "Sending in dialog SIP message\n");
- ast_sip_create_request("MESSAGE", data->session->inv_session->dlg, data->session->endpoint, NULL, &tdata);
+ ast_sip_create_request("MESSAGE", data->session->inv_session->dlg, data->session->endpoint, NULL, NULL, &tdata);
ast_sip_add_body(tdata, &body);
ast_sip_send_request(tdata, data->session->inv_session->dlg, data->session->endpoint, NULL, NULL);
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=404947&r1=404946&r2=404947
==============================================================================
--- team/kmoore/pjsip_path_support/include/asterisk/res_pjsip.h (original)
+++ team/kmoore/pjsip_path_support/include/asterisk/res_pjsip.h Sun Jan 5 20:41:27 2014
@@ -1199,18 +1199,17 @@
*
* \param method The method of the SIP request to send
* \param dlg Optional. If specified, the dialog on which to request the message.
- * \param endpoint Optional. If specified, the request will be created out-of-dialog
- * to the endpoint.
+ * \param endpoint Optional. If specified, the request will be created out-of-dialog to the endpoint.
* \param uri Optional. If specified, the request will be sent to this URI rather
- * this value.
* than one configured for the endpoint.
+ * \param contact The contact with which this request is associated for out-of-dialog requests.
* \param[out] tdata The newly-created request
* \retval 0 Success
* \retval -1 Failure
*/
int ast_sip_create_request(const char *method, struct pjsip_dialog *dlg,
struct ast_sip_endpoint *endpoint, const char *uri,
- pjsip_tx_data **tdata);
+ struct ast_sip_contact *contact, pjsip_tx_data **tdata);
/*!
* \brief General purpose method for sending a SIP request
@@ -1782,12 +1781,12 @@
* \brief Called on an outgoing SIP request
* This method is always called from a SIP servant thread.
*/
- void (*outgoing_request)(struct ast_sip_endpoint *endpoint, struct pjsip_tx_data *tdata);
+ void (*outgoing_request)(struct ast_sip_endpoint *endpoint, struct ast_sip_contact *contact, struct pjsip_tx_data *tdata);
/*!
* \brief Called on an outgoing SIP response
* This method is always called from a SIP servant thread.
*/
- void (*outgoing_response)(struct ast_sip_endpoint *endpoint, struct pjsip_tx_data *tdata);
+ void (*outgoing_response)(struct ast_sip_endpoint *endpoint, struct ast_sip_contact *contact, struct pjsip_tx_data *tdata);
/*! Next item in the list */
AST_LIST_ENTRY(ast_sip_supplement) next;
};
Modified: team/kmoore/pjsip_path_support/include/asterisk/res_pjsip_session.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/include/asterisk/res_pjsip_session.h?view=diff&rev=404947&r1=404946&r2=404947
==============================================================================
--- team/kmoore/pjsip_path_support/include/asterisk/res_pjsip_session.h (original)
+++ team/kmoore/pjsip_path_support/include/asterisk/res_pjsip_session.h Sun Jan 5 20:41:27 2014
@@ -98,6 +98,8 @@
char exten[AST_MAX_EXTENSION];
/* The endpoint with which Asterisk is communicating */
struct ast_sip_endpoint *endpoint;
+ /* The contact associated with this session */
+ struct ast_sip_contact *contact;
/* The PJSIP details of the session, which includes the dialog */
struct pjsip_inv_session *inv_session;
/* The Asterisk channel associated with the session */
@@ -330,9 +332,11 @@
* this reference when the session is destroyed.
*
* \param endpoint The endpoint that this session communicates with
+ * \param contact The contact associated with this session
* \param inv_session The PJSIP INVITE session data
*/
-struct ast_sip_session *ast_sip_session_alloc(struct ast_sip_endpoint *endpoint, pjsip_inv_session *inv);
+struct ast_sip_session *ast_sip_session_alloc(struct ast_sip_endpoint *endpoint,
+ struct ast_sip_contact *contact, pjsip_inv_session *inv);
/*!
* \brief Create a new outgoing SIP session
@@ -342,11 +346,14 @@
* this reference when the session is destroyed.
*
* \param endpoint The endpoint that this session uses for settings
- * \param location Optional name of the location to call, be it named location or explicit URI
+ * \param contact The contact that this session will communicate with
+ * \param location Name of the location to call, be it named location or explicit URI. Overrides contact if present.
* \param request_user Optional request user to place in the request URI if permitted
* \param req_caps The requested capabilities
*/
-struct ast_sip_session *ast_sip_session_create_outgoing(struct ast_sip_endpoint *endpoint, const char *location, const char *request_user, struct ast_format_cap *req_caps);
+struct ast_sip_session *ast_sip_session_create_outgoing(struct ast_sip_endpoint *endpoint,
+ struct ast_sip_contact *contact, const char *location, const char *request_user,
+ struct ast_format_cap *req_caps);
/*!
* \brief Defer local termination of a session until remote side terminates, or an amount of time passes
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=404947&r1=404946&r2=404947
==============================================================================
--- team/kmoore/pjsip_path_support/res/res_pjsip.c (original)
+++ team/kmoore/pjsip_path_support/res/res_pjsip.c Sun Jan 5 20:41:27 2014
@@ -1109,6 +1109,7 @@
</manager>
***/
+#define MOD_DATA_CONTACT "contact"
static pjsip_endpoint *ast_pjsip_endpoint;
@@ -1605,10 +1606,18 @@
return 0;
}
+static pj_bool_t supplement_on_rx_request(pjsip_rx_data *rdata);
+static pjsip_module supplement_module = {
+ .name = { "Out of dialog supplement hook", 29 },
+ .id = -1,
+ .priority = PJSIP_MOD_PRIORITY_APPLICATION - 1,
+ .on_rx_request = supplement_on_rx_request,
+};
+
static int create_out_of_dialog_request(const pjsip_method *method, struct ast_sip_endpoint *endpoint,
- const char *uri, pjsip_tx_data **tdata)
-{
- RAII_VAR(struct ast_sip_contact *, contact, NULL, ao2_cleanup);
+ const char *uri, struct ast_sip_contact *provided_contact, pjsip_tx_data **tdata)
+{
+ RAII_VAR(struct ast_sip_contact *, contact, ao2_bump(provided_contact), ao2_cleanup);
pj_str_t remote_uri;
pj_str_t from;
pj_pool_t *pool;
@@ -1620,7 +1629,9 @@
return -1;
}
- contact = ast_sip_location_retrieve_contact_from_aor_list(endpoint->aors);
+ if (!contact) {
+ contact = ast_sip_location_retrieve_contact_from_aor_list(endpoint->aors);
+ }
if (!contact || ast_strlen_zero(contact->uri)) {
ast_log(LOG_ERROR, "Unable to retrieve contact for endpoint %s\n",
ast_sorcery_object_get_id(endpoint));
@@ -1672,6 +1683,8 @@
return -1;
}
+ ast_sip_mod_data_set((*tdata)->pool, (*tdata)->mod_data, supplement_module.id, MOD_DATA_CONTACT, ao2_bump(contact));
+
/* We can release this pool since request creation copied all the necessary
* data into the outbound request's pool
*/
@@ -1681,7 +1694,7 @@
int ast_sip_create_request(const char *method, struct pjsip_dialog *dlg,
struct ast_sip_endpoint *endpoint, const char *uri,
- pjsip_tx_data **tdata)
+ struct ast_sip_contact *contact, pjsip_tx_data **tdata)
{
const pjsip_method *pmethod = get_pjsip_method(method);
@@ -1693,7 +1706,7 @@
if (dlg) {
return create_in_dialog_request(pmethod, dlg, tdata);
} else {
- return create_out_of_dialog_request(pmethod, endpoint, uri, tdata);
+ return create_out_of_dialog_request(pmethod, endpoint, uri, contact, tdata);
}
}
@@ -1819,6 +1832,7 @@
{
struct ast_sip_supplement *supplement;
struct send_request_data *req_data = send_request_data_alloc(endpoint, token, callback);
+ struct ast_sip_contact *contact = ast_sip_mod_data_get(tdata->mod_data, supplement_module.id, MOD_DATA_CONTACT);
if (!req_data) {
return -1;
@@ -1827,10 +1841,13 @@
AST_RWLIST_RDLOCK(&supplements);
AST_LIST_TRAVERSE(&supplements, supplement, next) {
if (supplement->outgoing_request && does_method_match(&tdata->msg->line.req.method.name, supplement->method)) {
- supplement->outgoing_request(endpoint, tdata);
+ supplement->outgoing_request(endpoint, contact, tdata);
}
}
AST_RWLIST_UNLOCK(&supplements);
+
+ ast_sip_mod_data_set(tdata->pool, tdata->mod_data, supplement_module.id, MOD_DATA_CONTACT, NULL);
+ ao2_cleanup(contact);
if (pjsip_endpt_send_request(ast_sip_get_pjsip_endpoint(), tdata, -1, req_data, send_request_cb) != PJ_SUCCESS) {
ast_log(LOG_ERROR, "Error attempting to send outbound %.*s request to endpoint %s\n",
@@ -2146,25 +2163,22 @@
return PJ_FALSE;
}
-static pjsip_module supplement_module = {
- .name = { "Out of dialog supplement hook", 29 },
- .id = -1,
- .priority = PJSIP_MOD_PRIORITY_APPLICATION - 1,
- .on_rx_request = supplement_on_rx_request,
-};
-
int ast_sip_send_response(pjsip_endpoint *endpt, pjsip_response_addr *res_addr, pjsip_tx_data *tdata, struct ast_sip_endpoint *sip_endpoint)
{
struct ast_sip_supplement *supplement;
pjsip_cseq_hdr *cseq = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_CSEQ, NULL);
+ struct ast_sip_contact *contact = ast_sip_mod_data_get(tdata->mod_data, supplement_module.id, MOD_DATA_CONTACT);
AST_RWLIST_RDLOCK(&supplements);
AST_LIST_TRAVERSE(&supplements, supplement, next) {
if (supplement->outgoing_response && does_method_match(&cseq->method.name, supplement->method)) {
- supplement->outgoing_response(sip_endpoint, tdata);
+ supplement->outgoing_response(sip_endpoint, NULL, tdata);
}
}
AST_RWLIST_UNLOCK(&supplements);
+
+ ast_sip_mod_data_set(tdata->pool, tdata->mod_data, supplement_module.id, MOD_DATA_CONTACT, NULL);
+ ao2_cleanup(contact);
return pjsip_endpt_send_response(endpt, res_addr, tdata, NULL, NULL);
}
Modified: team/kmoore/pjsip_path_support/res/res_pjsip/pjsip_options.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/res/res_pjsip/pjsip_options.c?view=diff&rev=404947&r1=404946&r2=404947
==============================================================================
--- team/kmoore/pjsip_path_support/res/res_pjsip/pjsip_options.c (original)
+++ team/kmoore/pjsip_path_support/res/res_pjsip/pjsip_options.c Sun Jan 5 20:41:27 2014
@@ -238,7 +238,7 @@
}
}
- if (ast_sip_create_request("OPTIONS", NULL, NULL, contact->uri, &tdata)) {
+ if (ast_sip_create_request("OPTIONS", NULL, NULL, NULL, contact, &tdata)) {
ast_log(LOG_ERROR, "Unable to create request to qualify contact %s\n",
contact->uri);
return -1;
Modified: team/kmoore/pjsip_path_support/res/res_pjsip_messaging.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/res/res_pjsip_messaging.c?view=diff&rev=404947&r1=404946&r2=404947
==============================================================================
--- team/kmoore/pjsip_path_support/res/res_pjsip_messaging.c (original)
+++ team/kmoore/pjsip_path_support/res/res_pjsip_messaging.c Sun Jan 5 20:41:27 2014
@@ -550,7 +550,7 @@
return -1;
}
- if (ast_sip_create_request("MESSAGE", NULL, endpoint, uri, &tdata)) {
+ if (ast_sip_create_request("MESSAGE", NULL, endpoint, uri, NULL, &tdata)) {
ast_log(LOG_ERROR, "PJSIP MESSAGE - Could not create request\n");
return -1;
}
Modified: team/kmoore/pjsip_path_support/res/res_pjsip_mwi.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/res/res_pjsip_mwi.c?view=diff&rev=404947&r1=404946&r2=404947
==============================================================================
--- team/kmoore/pjsip_path_support/res/res_pjsip_mwi.c (original)
+++ team/kmoore/pjsip_path_support/res/res_pjsip_mwi.c Sun Jan 5 20:41:27 2014
@@ -273,7 +273,7 @@
pjsip_event_hdr *event;
const pjsip_hdr *allow_events = pjsip_evsub_get_allow_events_hdr(NULL);
- if (ast_sip_create_request("NOTIFY", NULL, endpoint, contact->uri, &tdata)) {
+ if (ast_sip_create_request("NOTIFY", NULL, endpoint, NULL, contact, &tdata)) {
ast_log(LOG_WARNING, "Unable to create unsolicited NOTIFY request to endpoint %s URI %s\n", sub->id, contact->uri);
return 0;
}
Modified: team/kmoore/pjsip_path_support/res/res_pjsip_notify.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/res/res_pjsip_notify.c?view=diff&rev=404947&r1=404946&r2=404947
==============================================================================
--- team/kmoore/pjsip_path_support/res/res_pjsip_notify.c (original)
+++ team/kmoore/pjsip_path_support/res/res_pjsip_notify.c Sun Jan 5 20:41:27 2014
@@ -470,7 +470,7 @@
pjsip_tx_data *tdata;
if (ast_sip_create_request("NOTIFY", NULL, data->endpoint,
- contact->uri, &tdata)) {
+ NULL, contact, &tdata)) {
ast_log(LOG_WARNING, "SIP NOTIFY - Unable to create request for "
"contact %s\n", contact->uri);
return -1;
Modified: team/kmoore/pjsip_path_support/res/res_pjsip_path.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/res/res_pjsip_path.c?view=diff&rev=404947&r1=404946&r2=404947
==============================================================================
--- team/kmoore/pjsip_path_support/res/res_pjsip_path.c (original)
+++ team/kmoore/pjsip_path_support/res/res_pjsip_path.c Sun Jan 5 20:41:27 2014
@@ -86,17 +86,6 @@
return ast_sip_location_retrieve_aor(aor_name);
}
-/*! \brief Callback function for finding a contact */
-static int find_contact(void *obj, void *arg, void *data, int flags)
-{
- struct ast_sip_contact *contact = obj;
- pjsip_uri *uri = arg;
- pj_pool_t *pool = data;
- pjsip_uri *contact_uri = pjsip_parse_uri(pool, (char*)contact->uri, strlen(contact->uri), 0);
-
- return (pjsip_uri_cmp(PJSIP_URI_IN_CONTACT_HDR, uri, contact_uri) == PJ_SUCCESS) ? CMP_MATCH | CMP_STOP : 0;
-}
-
/*!
* \brief Get the path string associated with this endpoint and tdata
*
@@ -107,22 +96,9 @@
* \retval zero on success
* \retval non-zero on failure or no available path information
*/
-static int path_get_string(pj_pool_t *pool, struct ast_sip_aor *aor, pjsip_uri *contact_uri, pj_str_t *path_str)
-{
- RAII_VAR(struct ao2_container *, contacts, NULL, ao2_cleanup);
- RAII_VAR(struct ast_sip_contact *, contact, NULL, ao2_cleanup);
-
- contacts = ast_sip_location_retrieve_aor_contacts(aor);
- if (!contacts) {
- return -1;
- }
-
- contact = ao2_callback_data(contacts, 0, find_contact, pjsip_uri_get_uri(contact_uri), pool);
- if (!contact) {
- return -1;
- }
-
- if (ast_strlen_zero(contact->path)) {
+static int path_get_string(pj_pool_t *pool, struct ast_sip_contact *contact, pj_str_t *path_str)
+{
+ if (!contact || ast_strlen_zero(contact->path)) {
return -1;
}
@@ -153,13 +129,14 @@
/*!
* \internal
- * \brief Adds a path header to an outgoing INVITE request if
- * redirecting information is available.
- *
- * \param session The session on which the INVITE request is to be sent
- * \param tdata The outbound INVITE request
- */
-static void path_outgoing_request(struct ast_sip_endpoint *endpoint, pjsip_tx_data *tdata)
+ * \brief Adds a Route header to an outgoing request if
+ * path information is available.
+ *
+ * \param endpoint The endpoint with which this request is associated
+ * \param contact The contact to which this request is being sent
+ * \param tdata The outbound request
+ */
+static void path_outgoing_request(struct ast_sip_endpoint *endpoint, struct ast_sip_contact *contact, pjsip_tx_data *tdata)
{
pj_str_t path_dup;
pjsip_generic_string_hdr *route_hdr;
@@ -178,7 +155,7 @@
return;
}
- if (path_get_string(tdata->pool, aor, tdata->msg->line.req.uri, &path_dup)) {
+ if (path_get_string(tdata->pool, contact, &path_dup)) {
return;
}
@@ -192,17 +169,18 @@
static void path_session_outgoing_request(struct ast_sip_session *session, pjsip_tx_data *tdata)
{
- path_outgoing_request(session->endpoint, tdata);
+ path_outgoing_request(session->endpoint, session->contact, tdata);
}
/*!
* \internal
* \brief Adds a path header to an outgoing 2XX response
*
- * \param session The session on which the INVITE response is to be sent
+ * \param endpoint The endpoint to which the INVITE response is to be sent
+ * \param contact The contact to which the INVITE response is to be sent
* \param tdata The outbound INVITE response
*/
-static void path_outgoing_response(struct ast_sip_endpoint *endpoint, pjsip_tx_data *tdata)
+static void path_outgoing_response(struct ast_sip_endpoint *endpoint, struct ast_sip_contact *contact, pjsip_tx_data *tdata)
{
struct pjsip_status_line status = tdata->msg->line.status;
pj_str_t path_dup;
@@ -225,7 +203,7 @@
aor = find_aor(endpoint, contact_hdr->uri);
if (!aor || !aor->support_path || add_supported(tdata)
- || path_get_string(tdata->pool, aor, contact_hdr->uri, &path_dup)) {
+ || path_get_string(tdata->pool, contact, &path_dup)) {
return;
}
@@ -239,7 +217,7 @@
static void path_session_outgoing_response(struct ast_sip_session *session, pjsip_tx_data *tdata)
{
- path_outgoing_response(session->endpoint, tdata);
+ path_outgoing_response(session->endpoint, session->contact, tdata);
}
static struct ast_sip_supplement path_supplement = {
Modified: team/kmoore/pjsip_path_support/res/res_pjsip_session.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/res/res_pjsip_session.c?view=diff&rev=404947&r1=404946&r2=404947
==============================================================================
--- team/kmoore/pjsip_path_support/res/res_pjsip_session.c (original)
+++ team/kmoore/pjsip_path_support/res/res_pjsip_session.c Sun Jan 5 20:41:27 2014
@@ -1038,6 +1038,7 @@
}
ast_party_id_free(&session->id);
ao2_cleanup(session->endpoint);
+ ao2_cleanup(session->contact);
ast_format_cap_destroy(session->req_caps);
ast_format_cap_destroy(session->direct_media_cap);
@@ -1105,7 +1106,8 @@
return channel;
}
-struct ast_sip_session *ast_sip_session_alloc(struct ast_sip_endpoint *endpoint, pjsip_inv_session *inv_session)
+struct ast_sip_session *ast_sip_session_alloc(struct ast_sip_endpoint *endpoint,
+ struct ast_sip_contact *contact, pjsip_inv_session *inv_session)
{
RAII_VAR(struct ast_sip_session *, session, ao2_alloc(sizeof(*session), session_destructor), ao2_cleanup);
struct ast_sip_session_supplement *iter;
@@ -1133,10 +1135,9 @@
ast_sip_dialog_set_serializer(inv_session->dlg, session->serializer);
ast_sip_dialog_set_endpoint(inv_session->dlg, endpoint);
pjsip_dlg_inc_session(inv_session->dlg, &session_module);
- ao2_ref(session, +1);
- inv_session->mod_data[session_module.id] = session;
- ao2_ref(endpoint, +1);
- session->endpoint = endpoint;
+ inv_session->mod_data[session_module.id] = ao2_bump(session);
+ session->endpoint = ao2_bump(endpoint);
+ session->contact = ao2_bump(contact);
session->inv_session = inv_session;
session->req_caps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
@@ -1185,21 +1186,27 @@
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_format_cap *req_caps)
+struct ast_sip_session *ast_sip_session_create_outgoing(struct ast_sip_endpoint *endpoint,
+ struct ast_sip_contact *contact, const char *location, const char *request_user,
+ struct ast_format_cap *req_caps)
{
const char *uri = NULL;
- RAII_VAR(struct ast_sip_contact *, contact, NULL, ao2_cleanup);
+ RAII_VAR(struct ast_sip_contact *, found_contact, NULL, ao2_cleanup);
pjsip_timer_setting timer;
pjsip_dialog *dlg;
struct pjsip_inv_session *inv_session;
RAII_VAR(struct ast_sip_session *, session, NULL, ao2_cleanup);
/* If no location has been provided use the AOR list from the endpoint itself */
- location = S_OR(location, endpoint->aors);
-
- contact = ast_sip_location_retrieve_contact_from_aor_list(location);
- if (!contact || ast_strlen_zero(contact->uri)) {
- uri = location;
+ if (location || !contact) {
+ location = S_OR(location, endpoint->aors);
+
+ found_contact = ast_sip_location_retrieve_contact_from_aor_list(location);
+ if (!found_contact || ast_strlen_zero(found_contact->uri)) {
+ uri = location;
+ } else {
+ uri = found_contact->uri;
+ }
} else {
uri = contact->uri;
}
@@ -1231,7 +1238,7 @@
timer.sess_expires = endpoint->extensions.timer.sess_expires;
pjsip_timer_init_session(inv_session, &timer);
- if (!(session = ast_sip_session_alloc(endpoint, inv_session))) {
+ if (!(session = ast_sip_session_alloc(endpoint, contact, inv_session))) {
pjsip_inv_terminate(inv_session, 500, PJ_FALSE);
return NULL;
}
@@ -1527,7 +1534,7 @@
return;
}
- session = ast_sip_session_alloc(endpoint, inv_session);
+ session = ast_sip_session_alloc(endpoint, NULL, inv_session);
if (!session) {
if (pjsip_inv_initial_answer(inv_session, rdata, 500, NULL, NULL, &tdata) == PJ_SUCCESS) {
pjsip_inv_terminate(inv_session, 500, PJ_FALSE);
More information about the asterisk-commits
mailing list