浏览代码

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)
Daniel-Constantin Mierla 5 年之前
父节点
当前提交
82a196ca56
共有 3 个文件被更改,包括 18 次插入6 次删除
  1. 1 1
      src/modules/uac/uac.c
  2. 14 5
      src/modules/uac/uac_reg.c
  3. 3 0
      src/modules/uac/uac_reg.h

+ 1 - 1
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;
 		return -1;
 	}
 	}
 
 
-	if (imode > 1) {
+	if (imode > (UACREG_REQTO_MASK_USER|UACREG_REQTO_MASK_AUTH)) {
 		LM_ERR("invalid mode\n");
 		LM_ERR("invalid mode\n");
 		return -1;
 		return -1;
 	}
 	}

+ 14 - 5
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;
 	pv_value_t val;
 	struct action act;
 	struct action act;
 	struct run_act_ctx ra_ctx;
 	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:
 		case 0:
 			reg = reg_ht_get_byuuid(src);
 			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;
 		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) {
 	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;
 		goto error;
 	}
 	}
-
 	lock_release(reg->lock);
 	lock_release(reg->lock);
 	return 1;
 	return 1;
 
 

+ 3 - 0
src/modules/uac/uac_reg.h

@@ -25,6 +25,9 @@
 
 
 #define UACREG_TABLE_VERSION 4
 #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_timer_interval;
 extern int reg_retry_interval;
 extern int reg_retry_interval;
 extern int reg_htable_size;
 extern int reg_htable_size;