Module: sip-router
Branch: master
Commit: 9ebbbf3f53d88729add23980695ff84dace90342
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=9ebbbf3…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Wed Dec 8 00:20:44 2010 +0100
uac(k): stop trying to re-auth if first attempt fails
- don't do cascade authentication if server keeps sending 401 for new
attepts
- reported by Bernhard Suttner, part of FS#108
---
modules_k/uac/uac_reg.c | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/modules_k/uac/uac_reg.c b/modules_k/uac/uac_reg.c
index 8fb4e78..e8827a0 100644
--- a/modules_k/uac/uac_reg.c
+++ b/modules_k/uac/uac_reg.c
@@ -43,6 +43,7 @@
#define UAC_REG_DISABLED (1<<0)
#define UAC_REG_ONGOING (1<<1)
#define UAC_REG_ONLINE (1<<2)
+#define UAC_REG_AUTHSENT (1<<3)
#define MAX_UACH_SIZE 2048
@@ -470,7 +471,7 @@ void uac_reg_tm_callback( struct cell *t, int type, struct tmcb_params
*ps)
str2int(&c->expires->body, (unsigned int*)(&expires));
}
ri->timer_expires = ri->timer_expires + expires;
- ri->flags &= ~UAC_REG_ONGOING;
+ ri->flags &= ~(UAC_REG_ONGOING|UAC_REG_AUTHSENT);
ri->flags |= UAC_REG_ONLINE;
goto done;
}
@@ -484,6 +485,14 @@ void uac_reg_tm_callback( struct cell *t, int type, struct
tmcb_params *ps)
if(ps->code == 401)
{
+ if(ri->flags & UAC_REG_AUTHSENT)
+ {
+ LM_ERR("authentication failed for <%.*s>\n",
+ ri->l_uuid.len, ri->l_uuid.s);
+ ri->flags &= ~UAC_REG_ONGOING;
+ ri->flags |= UAC_REG_DISABLED;
+ goto done;
+ }
hdr = get_autenticate_hdr(ps->rpl, 401);
if (hdr==0)
{
@@ -552,6 +561,7 @@ void uac_reg_tm_callback( struct cell *t, int type, struct tmcb_params
*ps)
&s_turi, /* From */
(ri->auth_proxy.len)?&ri->auth_proxy:NULL /* outbound uri */
);
+ ri->flags |= UAC_REG_AUTHSENT;
if(ret<0)
goto done;
@@ -584,6 +594,8 @@ int uac_reg_update(reg_uac_t *reg, time_t tn)
return 2;
if(reg->timer_expires > tn + reg_timer_interval + 3)
return 3;
+ if(reg->flags&UAC_REG_DISABLED)
+ return 4;
reg->timer_expires = tn;
reg->flags |= UAC_REG_ONGOING;
reg->flags &= ~UAC_REG_ONLINE;