Browse code

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 authored on 29/10/2019 07:37:02
Showing 3 changed files
... ...
@@ -715,7 +715,7 @@ static int w_uac_reg_request_to(struct sip_msg* msg, char* src, char* pmode)
715 715
 		return -1;
716 716
 	}
717 717
 
718
-	if (imode > 1) {
718
+	if (imode > (UACREG_REQTO_MASK_USER|UACREG_REQTO_MASK_AUTH)) {
719 719
 		LM_ERR("invalid mode\n");
720 720
 		return -1;
721 721
 	}
... ...
@@ -1678,8 +1678,13 @@ int uac_reg_request_to(struct sip_msg *msg, str *src, unsigned int mode)
1678 1678
 	pv_value_t val;
1679 1679
 	struct action act;
1680 1680
 	struct run_act_ctx ra_ctx;
1681
+	unsigned int umode;
1682
+	unsigned int amode;
1681 1683
 
1682
-	switch(mode)
1684
+	umode = mode & UACREG_REQTO_MASK_USER;
1685
+	amode = mode & UACREG_REQTO_MASK_AUTH;
1686
+
1687
+	switch(umode)
1683 1688
 	{
1684 1689
 		case 0:
1685 1690
 			reg = reg_ht_get_byuuid(src);
... ...
@@ -1745,13 +1750,17 @@ int uac_reg_request_to(struct sip_msg *msg, str *src, unsigned int mode)
1745 1750
 		goto error;
1746 1751
 	}
1747 1752
 
1748
-	// Set auth_password
1749
-	val.rs = reg->auth_password;
1753
+	if(amode) {
1754
+		// set auth_ha1
1755
+		val.rs = reg->auth_ha1;
1756
+	} else {
1757
+		// set auth_password
1758
+		val.rs = reg->auth_password;
1759
+	}
1750 1760
 	if(pv_set_spec_value(msg, &auth_password_spec, 0, &val)!=0) {
1751
-		LM_ERR("error while setting auth_password\n");
1761
+		LM_ERR("error while setting auth password (mode: %d)\n", amode);
1752 1762
 		goto error;
1753 1763
 	}
1754
-
1755 1764
 	lock_release(reg->lock);
1756 1765
 	return 1;
1757 1766
 
... ...
@@ -25,6 +25,9 @@
25 25
 
26 26
 #define UACREG_TABLE_VERSION 4
27 27
 
28
+#define UACREG_REQTO_MASK_USER 1
29
+#define UACREG_REQTO_MASK_AUTH 2
30
+
28 31
 extern int reg_timer_interval;
29 32
 extern int reg_retry_interval;
30 33
 extern int reg_htable_size;