Browse code

uac: added uac_reg_lookup_uri() - do lookup for user in the uri

Daniel-Constantin Mierla authored on 07/05/2021 06:00:34
Showing 1 changed files
... ...
@@ -102,6 +102,7 @@ static int w_restore_to(struct sip_msg* msg, char* p1, char* p2);
102 102
 static int w_uac_auth(struct sip_msg* msg, char* str, char* str2);
103 103
 static int w_uac_auth_mode(struct sip_msg* msg, char* pmode, char* str2);
104 104
 static int w_uac_reg_lookup(struct sip_msg* msg, char* src, char* dst);
105
+static int w_uac_reg_lookup_uri(struct sip_msg* msg, char* src, char* dst);
105 106
 static int w_uac_reg_status(struct sip_msg* msg, char* src, char* dst);
106 107
 static int w_uac_reg_request_to(struct sip_msg* msg, char* src, char* mode_s);
107 108
 static int w_uac_reg_enable(struct sip_msg* msg, char* pfilter, char* pval);
... ...
@@ -142,6 +143,8 @@ static cmd_export_t cmds[]={
142 143
 	{"uac_req_send",  (cmd_function)w_uac_req_send,   0, 0, 0, ANY_ROUTE},
143 144
 	{"uac_reg_lookup",  (cmd_function)w_uac_reg_lookup,  2, fixup_spve_pvar,
144 145
 		fixup_free_spve_pvar, ANY_ROUTE },
146
+	{"uac_reg_lookup_uri", (cmd_function)w_uac_reg_lookup_uri, 2, fixup_spve_pvar,
147
+		fixup_free_spve_pvar, ANY_ROUTE },
145 148
 	{"uac_reg_status",  (cmd_function)w_uac_reg_status,  1, fixup_spve_null, 0,
146 149
 		ANY_ROUTE },
147 150
 	{"uac_reg_request_to",  (cmd_function)w_uac_reg_request_to,  2,
... ...
@@ -666,6 +669,32 @@ static int ki_uac_reg_lookup(sip_msg_t* msg, str* userid, str* sdst)
666 669
 	return uac_reg_lookup(msg, userid, dpv, 0);
667 670
 }
668 671
 
672
+static int w_uac_reg_lookup_uri(struct sip_msg* msg, char* src, char* dst)
673
+{
674
+	pv_spec_t *dpv;
675
+	str sval;
676
+
677
+	if(fixup_get_svalue(msg, (gparam_t*)src, &sval)<0) {
678
+		LM_ERR("cannot get the uuid parameter\n");
679
+		return -1;
680
+	}
681
+
682
+	dpv = (pv_spec_t*)dst;
683
+
684
+	return uac_reg_lookup(msg, &sval, dpv, 1);
685
+}
686
+
687
+static int ki_uac_reg_lookup_uri(sip_msg_t* msg, str* userid, str* sdst)
688
+{
689
+	pv_spec_t *dpv = NULL;
690
+	dpv = pv_cache_get(sdst);
691
+	if(dpv==NULL) {
692
+		LM_ERR("cannot get pv spec for [%.*s]\n", sdst->len, sdst->s);
693
+		return -1;
694
+	}
695
+	return uac_reg_lookup(msg, userid, dpv, 1);
696
+}
697
+
669 698
 static int w_uac_reg_status(struct sip_msg* msg, char* src, char* p2)
670 699
 {
671 700
 	str sval;
... ...
@@ -827,6 +856,11 @@ static sr_kemi_t sr_kemi_uac_exports[] = {
827 856
 		{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE,
828 857
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
829 858
 	},
859
+	{ str_init("uac"), str_init("uac_reg_lookup_uri"),
860
+		SR_KEMIP_INT, ki_uac_reg_lookup_uri,
861
+		{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE,
862
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
863
+	},
830 864
 	{ str_init("uac"), str_init("uac_reg_status"),
831 865
 		SR_KEMIP_INT, ki_uac_reg_status,
832 866
 		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,