summaryrefslogtreecommitdiff
path: root/res/res_pjsip_outbound_registration.c
diff options
context:
space:
mode:
Diffstat (limited to 'res/res_pjsip_outbound_registration.c')
-rw-r--r--res/res_pjsip_outbound_registration.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/res/res_pjsip_outbound_registration.c b/res/res_pjsip_outbound_registration.c
index b8f7112e4..1c00473fb 100644
--- a/res/res_pjsip_outbound_registration.c
+++ b/res/res_pjsip_outbound_registration.c
@@ -487,8 +487,8 @@ struct registration_response {
struct sip_outbound_registration_client_state *client_state;
/*! \brief The response message */
pjsip_rx_data *rdata;
- /*! \brief The response transaction */
- pjsip_transaction *tsx;
+ /*! \brief Request for which the response was received */
+ pjsip_tx_data *old_request;
};
/*! \brief Registration response structure destructor */
@@ -500,6 +500,10 @@ static void registration_response_destroy(void *obj)
pjsip_rx_data_free_cloned(response->rdata);
}
+ if (response->old_request) {
+ pjsip_tx_data_dec_ref(response->old_request);
+ }
+
ao2_cleanup(response->client_state);
}
@@ -558,8 +562,8 @@ static int handle_registration_response(void *data)
if (!response->client_state->auth_attempted &&
(response->code == 401 || response->code == 407)) {
pjsip_tx_data *tdata;
- if (!ast_sip_create_request_with_auth(&response->client_state->outbound_auths,
- response->rdata, response->tsx, &tdata)) {
+ if (!ast_sip_create_request_with_auth_from_old(&response->client_state->outbound_auths,
+ response->rdata, response->old_request, &tdata)) {
ao2_ref(response->client_state, +1);
response->client_state->auth_attempted = 1;
if (pjsip_regc_send(response->client_state->client, tdata) != PJ_SUCCESS) {
@@ -650,9 +654,12 @@ static void sip_outbound_registration_response_cb(struct pjsip_regc_cbparam *par
if (param->rdata) {
struct pjsip_retry_after_hdr *retry_after = pjsip_msg_find_hdr(param->rdata->msg_info.msg, PJSIP_H_RETRY_AFTER, NULL);
+ pjsip_transaction *tsx;
response->retry_after = retry_after ? retry_after->ivalue : 0;
- response->tsx = pjsip_rdata_get_tsx(param->rdata);
+ tsx = pjsip_rdata_get_tsx(param->rdata);
+ response->old_request = tsx->last_tx;
+ pjsip_tx_data_add_ref(response->old_request);
pjsip_rx_data_clone(param->rdata, 0, &response->rdata);
}