From 82a196ca567e9dbe89806626ee4d8dba7e9a7533 Mon Sep 17 00:00:00 2001 From: Daniel-Constantin Mierla Date: Tue, 29 Oct 2019 08:37:02 +0100 Subject: [PATCH] uac: extended use of mode param for uac_reg_request_to() - not it is interpreted as a bitwise set of flags - if first bit is set, then the match is done on username, otherwise on uuid (still backward compatible in this aspect) - if the second bit is set, fetch the auth_ha1 and set it in uac_auth() password avp; if not set, fetch the auth_password (like it was done so far) --- src/modules/uac/uac.c | 2 +- src/modules/uac/uac_reg.c | 19 ++++++++++++++----- src/modules/uac/uac_reg.h | 3 +++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/modules/uac/uac.c b/src/modules/uac/uac.c index 7e39c46229b..7692600b0fe 100644 --- a/src/modules/uac/uac.c +++ b/src/modules/uac/uac.c @@ -715,7 +715,7 @@ static int w_uac_reg_request_to(struct sip_msg* msg, char* src, char* pmode) return -1; } - if (imode > 1) { + if (imode > (UACREG_REQTO_MASK_USER|UACREG_REQTO_MASK_AUTH)) { LM_ERR("invalid mode\n"); return -1; } diff --git a/src/modules/uac/uac_reg.c b/src/modules/uac/uac_reg.c index fb45a4fd3d9..907ed721fde 100644 --- a/src/modules/uac/uac_reg.c +++ b/src/modules/uac/uac_reg.c @@ -1678,8 +1678,13 @@ int uac_reg_request_to(struct sip_msg *msg, str *src, unsigned int mode) pv_value_t val; struct action act; struct run_act_ctx ra_ctx; + unsigned int umode; + unsigned int amode; - switch(mode) + umode = mode & UACREG_REQTO_MASK_USER; + amode = mode & UACREG_REQTO_MASK_AUTH; + + switch(umode) { case 0: reg = reg_ht_get_byuuid(src); @@ -1745,13 +1750,17 @@ int uac_reg_request_to(struct sip_msg *msg, str *src, unsigned int mode) goto error; } - // Set auth_password - val.rs = reg->auth_password; + if(amode) { + // set auth_ha1 + val.rs = reg->auth_ha1; + } else { + // set auth_password + val.rs = reg->auth_password; + } if(pv_set_spec_value(msg, &auth_password_spec, 0, &val)!=0) { - LM_ERR("error while setting auth_password\n"); + LM_ERR("error while setting auth password (mode: %d)\n", amode); goto error; } - lock_release(reg->lock); return 1; diff --git a/src/modules/uac/uac_reg.h b/src/modules/uac/uac_reg.h index 9dd9ab8cfe5..6f6b5d7590c 100644 --- a/src/modules/uac/uac_reg.h +++ b/src/modules/uac/uac_reg.h @@ -25,6 +25,9 @@ #define UACREG_TABLE_VERSION 4 +#define UACREG_REQTO_MASK_USER 1 +#define UACREG_REQTO_MASK_AUTH 2 + extern int reg_timer_interval; extern int reg_retry_interval; extern int reg_htable_size;