Module: kamailio
Branch: master
Commit: 82a196ca567e9dbe89806626ee4d8dba7e9a7533
URL:
https://github.com/kamailio/kamailio/commit/82a196ca567e9dbe89806626ee4d8db…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2019-10-29T08:37:02+01:00
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)
---
Modified: src/modules/uac/uac.c
Modified: src/modules/uac/uac_reg.c
Modified: src/modules/uac/uac_reg.h
---
Diff:
https://github.com/kamailio/kamailio/commit/82a196ca567e9dbe89806626ee4d8db…
Patch:
https://github.com/kamailio/kamailio/commit/82a196ca567e9dbe89806626ee4d8db…
---
diff --git a/src/modules/uac/uac.c b/src/modules/uac/uac.c
index 7e39c46229..7692600b0f 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 fb45a4fd3d..907ed721fd 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 9dd9ab8cfe..6f6b5d7590 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;