Module: kamailio
Branch: master
Commit: 48524f0ce8934c4f6a46b38a1af1fff92078eb3d
URL:
https://github.com/kamailio/kamailio/commit/48524f0ce8934c4f6a46b38a1af1fff…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2018-07-12T15:58:13+02:00
permissions: exported allow_address_group() to kemi framework
---
Modified: src/modules/permissions/address.c
Modified: src/modules/permissions/address.h
Modified: src/modules/permissions/permissions.c
---
Diff:
https://github.com/kamailio/kamailio/commit/48524f0ce8934c4f6a46b38a1af1fff…
Patch:
https://github.com/kamailio/kamailio/commit/48524f0ce8934c4f6a46b38a1af1fff…
---
diff --git a/src/modules/permissions/address.c b/src/modules/permissions/address.c
index 141806edf0..cc447deaf6 100644
--- a/src/modules/permissions/address.c
+++ b/src/modules/permissions/address.c
@@ -565,50 +565,37 @@ int allow_source_address_group(struct sip_msg* _msg, char* _str1,
char* _str2)
* subnet table in any group. If yes, returns that group. If not returns -1.
* Port value 0 in cached address and group table matches any port.
*/
-int allow_address_group(struct sip_msg* _msg, char* _addr, char* _port)
+int ki_allow_address_group(sip_msg_t* _msg, str* _addr, int _port)
{
int group = -1;
- unsigned int port;
- str ips;
ip_addr_t *ipa;
- if (_addr==NULL
- || (fixup_get_svalue(_msg, (gparam_p)_addr, &ips) < 0)) {
- LM_ERR("cannot get value of address pvar\n");
- return -1;
- }
- if (_port==NULL
- || (fixup_get_ivalue(_msg, (gparam_p)_port, (int*)&port) < 0)) {
- LM_ERR("cannot get value of port pvar\n");
- return -1;
- }
-
- ipa=strtoipX(&ips);
+ ipa=strtoipX(_addr);
if ( ipa ) {
LM_DBG("looking for <%.*s, %u> in address table\n",
- ips.len, ips.s, port);
+ _addr->len, _addr->s, (unsigned int)_port);
if(addr_hash_table) {
group = find_group_in_addr_hash_table(*addr_hash_table,
- ipa, port);
+ ipa, (unsigned int)_port);
LM_DBG("Found address in group <%d>\n", group);
if (group != -1) return group;
}
if(subnet_table) {
LM_DBG("looking for <%.*s, %u> in subnet table\n",
- ips.len, ips.s, port);
+ _addr->len, _addr->s, _port);
group = find_group_in_subnet_table(*subnet_table,
- ipa, port);
+ ipa, (unsigned int)_port);
LM_DBG("Found a match of subnet in group <%d>\n", group);
}
} else {
LM_DBG("looking for <%.*s, %u> in domain_name table\n",
- ips.len, ips.s, port);
+ _addr->len, _addr->s, (unsigned int)_port);
if(domain_list_table) {
group = find_group_in_domain_name_table(*domain_list_table,
- &ips, port);
+ _addr, (unsigned int)_port);
LM_DBG("Found a match of domain_name in group <%d>\n", group);
}
}
@@ -616,3 +603,22 @@ int allow_address_group(struct sip_msg* _msg, char* _addr, char*
_port)
LM_DBG("Found <%d>\n", group);
return group;
}
+
+int allow_address_group(struct sip_msg* _msg, char* _addr, char* _port)
+{
+ int port;
+ str ips;
+
+ if (_addr==NULL
+ || (fixup_get_svalue(_msg, (gparam_p)_addr, &ips) < 0)) {
+ LM_ERR("cannot get value of address pvar\n");
+ return -1;
+ }
+ if (_port==NULL
+ || (fixup_get_ivalue(_msg, (gparam_p)_port, &port) < 0)) {
+ LM_ERR("cannot get value of port pvar\n");
+ return -1;
+ }
+
+ return ki_allow_address_group(_msg, &ips, port);
+}
\ No newline at end of file
diff --git a/src/modules/permissions/address.h b/src/modules/permissions/address.h
index cc4652a0bc..5693ce14ce 100644
--- a/src/modules/permissions/address.h
+++ b/src/modules/permissions/address.h
@@ -97,4 +97,6 @@ int ki_allow_source_address_group(sip_msg_t* _msg);
*/
int allow_address_group(struct sip_msg* _msg, char* _addr, char* _port);
+int ki_allow_address_group(sip_msg_t* _msg, str* _addr, int _port);
+
#endif /* ADDRESS_H */
diff --git a/src/modules/permissions/permissions.c
b/src/modules/permissions/permissions.c
index 822aad5e91..7f2194d595 100644
--- a/src/modules/permissions/permissions.c
+++ b/src/modules/permissions/permissions.c
@@ -1041,6 +1041,11 @@ static sr_kemi_t sr_kemi_permissions_exports[] = {
{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
},
+ { str_init("permissions"), str_init("allow_address_group"),
+ SR_KEMIP_INT, ki_allow_address_group,
+ { SR_KEMIP_STR, SR_KEMIP_INT, SR_KEMIP_NONE,
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
};