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;
+ ast_debug(1, "Sending authenticated REGISTER to server '%s' from client '%s'\n",
+ server_uri, client_uri);
if (pjsip_regc_send(response->client_state->client, tdata) != PJ_SUCCESS) {
response->client_state->auth_attempted = 0;
ao2_cleanup(response->client_state);
response->client_state = client_state;
ao2_ref(response->client_state, +1);
+ pjsip_regc_get_info(client_state->client, &info);
+ ast_debug(1, "Received REGISTER response %d(%.*s) from server '%.*s' for client '%.*s\n",
+ param->code, (int) param->reason.slen, param->reason.ptr,
+ (int) info.server_uri.slen, info.server_uri.ptr,
+ (int) info.client_uri.slen, info.client_uri.ptr);
+
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);
}