summaryrefslogtreecommitdiff
path: root/res/res_pjsip_outbound_registration.c
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2015-11-20 13:03:35 -0600
committerGerrit Code Review <gerrit2@gerrit.digium.api>2015-11-20 13:03:35 -0600
commit5ec076b3b8590aad8dbc31afa341605eec7146bd (patch)
treeac90b903b2d197029da80106e2304685ecbbcc06 /res/res_pjsip_outbound_registration.c
parent66d9eab072815049d70d9fb8acd4780f6eba1576 (diff)
parenteaf898ac881585c23ac0fcb31c5369809c68b1bb (diff)
Merge "res_pjsip_outbound_registration.c: Fix 423 response handling."
Diffstat (limited to 'res/res_pjsip_outbound_registration.c')
-rw-r--r--res/res_pjsip_outbound_registration.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/res/res_pjsip_outbound_registration.c b/res/res_pjsip_outbound_registration.c
index 7b125334a..3921aa0b2 100644
--- a/res/res_pjsip_outbound_registration.c
+++ b/res/res_pjsip_outbound_registration.c
@@ -335,6 +335,8 @@ struct sip_outbound_registration_client_state {
unsigned int auth_rejection_permanent;
/*! \brief Determines whether SIP Path support should be advertised */
unsigned int support_path;
+ /*! CSeq number of last sent auth request. */
+ unsigned int auth_cseq;
/*! \brief Serializer for stuff and things */
struct ast_taskprocessor *serializer;
/*! \brief Configured authentication credentials */
@@ -758,15 +760,27 @@ static int handle_registration_response(void *data)
ast_debug(1, "Processing REGISTER response %d from server '%s' for client '%s'\n",
response->code, server_uri, client_uri);
- if (!response->client_state->auth_attempted &&
- (response->code == 401 || response->code == 407)) {
+ if ((response->code == 401 || response->code == 407)
+ && (!response->client_state->auth_attempted
+ || response->rdata->msg_info.cseq->cseq != response->client_state->auth_cseq)) {
+ int res;
+ pjsip_cseq_hdr *cseq_hdr;
pjsip_tx_data *tdata;
+
if (!ast_sip_create_request_with_auth(&response->client_state->outbound_auths,
response->rdata, response->old_request, &tdata)) {
response->client_state->auth_attempted = 1;
ast_debug(1, "Sending authenticated REGISTER to server '%s' from client '%s'\n",
server_uri, client_uri);
- if (registration_client_send(response->client_state, tdata) == PJ_SUCCESS) {
+ pjsip_tx_data_add_ref(tdata);
+ res = registration_client_send(response->client_state, tdata);
+
+ /* Save the cseq that actually got sent. */
+ cseq_hdr = (pjsip_cseq_hdr *) pjsip_msg_find_hdr(tdata->msg, PJSIP_H_CSEQ,
+ NULL);
+ response->client_state->auth_cseq = cseq_hdr->cseq;
+ pjsip_tx_data_dec_ref(tdata);
+ if (res == PJ_SUCCESS) {
ao2_ref(response, -1);
return 0;
}