Browse code

permissions: exported allow_trusted() to kemi

- related to #2509

Daniel-Constantin Mierla authored on 19/10/2020 09:01:12
Showing 3 changed files
... ...
@@ -1058,6 +1058,11 @@ static sr_kemi_t sr_kemi_permissions_exports[] = {
1058 1058
 		{ SR_KEMIP_STR, SR_KEMIP_INT, SR_KEMIP_NONE,
1059 1059
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
1060 1060
 	},
1061
+	{ str_init("permissions"), str_init("allow_trusted"),
1062
+		SR_KEMIP_INT, ki_allow_trusted,
1063
+		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
1064
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
1065
+	},
1061 1066
 
1062 1067
 	{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
1063 1068
 };
... ...
@@ -507,7 +507,7 @@ int allow_trusted(struct sip_msg* msg, char *src_ip, int proto, char *from_uri)
507 507
  * Checks based on request's source address, protocol, and From URI
508 508
  * if request can be trusted without authentication.
509 509
  */
510
-int allow_trusted_0(struct sip_msg* _msg, char* str1, char* str2)
510
+int ki_allow_trusted(sip_msg_t* _msg)
511 511
 {
512 512
 	str furi;
513 513
 	char furi_string[MAX_URI_SIZE+1];
... ...
@@ -530,6 +530,15 @@ int allow_trusted_0(struct sip_msg* _msg, char* str1, char* str2)
530 530
 			furi_string);
531 531
 }
532 532
 
533
+/*
534
+ * Checks based on request's source address, protocol, and From URI
535
+ * if request can be trusted without authentication.
536
+ */
537
+int allow_trusted_0(struct sip_msg* _msg, char* str1, char* str2)
538
+{
539
+	return ki_allow_trusted(_msg);
540
+}
541
+
533 542
 /*
534 543
  * Checks based on source address and protocol given in pvar arguments and
535 544
  * provided uri, if request can be trusted without authentication.
... ...
@@ -55,6 +55,10 @@ int reload_trusted_table(void);
55 55
  */
56 56
 void clean_trusted(void);
57 57
 
58
+/*
59
+ * Check if request comes from trusted ip address with matching from URI
60
+ */
61
+int ki_allow_trusted(sip_msg_t* _msg);
58 62
 
59 63
 /*
60 64
  * Check if request comes from trusted ip address with matching from URI