|
@@ -14,9 +14,9 @@ Edited by
|
|
|
|
|
|
Juha Heinanen
|
|
|
|
|
|
- Copyright © 2003 Miklos Tirpak
|
|
|
+ Copyright © 2003 Miklos Tirpak
|
|
|
|
|
|
- Copyright © 2006-2008 Juha Heinanen
|
|
|
+ Copyright © 2006-2008 Juha Heinanen
|
|
|
__________________________________________________________________
|
|
|
|
|
|
Table of Contents
|
|
@@ -250,7 +250,7 @@ Chapter 1. Admin Guide
|
|
|
|
|
|
Function for registration checking is called allow_register and the
|
|
|
algorithm is very similar to the algorithm described in Section 1.1,
|
|
|
- "Call Routing". The only difference is in the way how pairs are
|
|
|
+ “Call Routing�. The only difference is in the way how pairs are
|
|
|
created.
|
|
|
|
|
|
Instead of From header field the function uses To header field because
|
|
@@ -261,8 +261,8 @@ Chapter 1. Admin Guide
|
|
|
Thus, pairs used in matching will look like this: (To, Contact 1), (To,
|
|
|
Contact 2), (To, Contact 3), and so on..
|
|
|
|
|
|
- The algorithm of matching is same as described in Section 1.1, "Call
|
|
|
- Routing".
|
|
|
+ The algorithm of matching is same as described in Section 1.1, “Call
|
|
|
+ Routing�.
|
|
|
|
|
|
1.3. URI Permissions
|
|
|
|
|
@@ -291,16 +291,25 @@ Chapter 1. Admin Guide
|
|
|
|
|
|
1.4. Address Permissions
|
|
|
|
|
|
- The module can be used to determine if an address (IP address and port)
|
|
|
- matches any of the IP subnets stored in cached Kamailio database table.
|
|
|
- Port 0 in cached database table matches any port. IP address and port
|
|
|
- to be matched can be either taken from the request
|
|
|
+ The module can be used to determine if an address (IP address and port
|
|
|
+ or DNS domain name) matches any of the addresses stored in cached
|
|
|
+ Kamailio database table. IP addresses in the database table can be
|
|
|
+ subnet addresses. Port 0 in cached database table matches any port. The
|
|
|
+ address and port to be matched can be either taken from the request
|
|
|
(allow_source_address) or given as pvar arguments (allow_address).
|
|
|
|
|
|
- Addresses stored in cached database table can be grouped together into
|
|
|
- one or more groups specified by a group identifier (positive integer
|
|
|
- value, i.e., equal or greater than 1). Group identifier is given as
|
|
|
- argument to allow_address and allow_source_address functions.
|
|
|
+ Addresses stored in database table can be grouped together into one or
|
|
|
+ more groups specified by a group identifier (positive integer value,
|
|
|
+ i.e., equal or greater than 1). Group identifier is given as argument
|
|
|
+ to allow_address and allow_source_address functions. One group can
|
|
|
+ contain all of the three types of addresses: exact IP address, subnet
|
|
|
+ IP address or DNS domain name.
|
|
|
+
|
|
|
+ When matching is done if the argument is an IP, it is tried to be
|
|
|
+ matched with the records from that group that are of type exact IP or
|
|
|
+ subnet. If the argument is not an IP it is tried to be matched with the
|
|
|
+ records that are DNS domain names. No DNS lookup is performed, only
|
|
|
+ strict matching.
|
|
|
|
|
|
As a side effect of matching the address, non-NULL tag (see tag_col
|
|
|
module parameter) is added as value to peer_tag AVP if peer_tag_avp
|
|
@@ -378,7 +387,7 @@ Chapter 1. Admin Guide
|
|
|
specify full pathname then the directory in which is the main config
|
|
|
file is located will be used.
|
|
|
|
|
|
- Default value is "permissions.allow".
|
|
|
+ Default value is “permissions.allow�.
|
|
|
|
|
|
Example 1.1. Set default_allow_file parameter
|
|
|
...
|
|
@@ -391,7 +400,7 @@ modparam("permissions", "default_allow_file", "/etc/permissions.allow")
|
|
|
without parameters. If you don't specify full pathname then the
|
|
|
directory in which the main config file is located will be used.
|
|
|
|
|
|
- Default value is "permissions.deny".
|
|
|
+ Default value is “permissions.deny�.
|
|
|
|
|
|
Example 1.2. Set default_deny_file parameter
|
|
|
...
|
|
@@ -426,7 +435,7 @@ Note
|
|
|
|
|
|
Including leading dot.
|
|
|
|
|
|
- Default value is ".allow".
|
|
|
+ Default value is “.allow�.
|
|
|
|
|
|
Example 1.4. Set allow_suffix parameter
|
|
|
...
|
|
@@ -443,7 +452,7 @@ Note
|
|
|
|
|
|
Including leading dot.
|
|
|
|
|
|
- Default value is ".deny".
|
|
|
+ Default value is “.deny�.
|
|
|
|
|
|
Example 1.5. Set deny_suffix parameter
|
|
|
...
|
|
@@ -455,7 +464,7 @@ modparam("permissions", "deny_suffix", ".deny")
|
|
|
This is URL of the database to be used to store rules used by
|
|
|
allow_trusted function.
|
|
|
|
|
|
- Default value is "NULL".
|
|
|
+ Default value is “NULL�.
|
|
|
|
|
|
Example 1.6. Set db_url parameter
|
|
|
...
|
|
@@ -464,10 +473,10 @@ modparam("permissions", "db_url", "dbdriver://username:password@dbhost/dbname")
|
|
|
|
|
|
3.7. address_table (string)
|
|
|
|
|
|
- Name of database table containing IP subnet information used by
|
|
|
- allow_address and allow_source_address functions.
|
|
|
+ Name of database table containing IP subnets and DNS domain names used
|
|
|
+ by allow_address and allow_source_address functions.
|
|
|
|
|
|
- Default value is "address".
|
|
|
+ Default value is “address�.
|
|
|
|
|
|
Example 1.7. Set address_table parameter
|
|
|
...
|
|
@@ -479,7 +488,7 @@ modparam("permissions", "address_table", "addr")
|
|
|
Name of address table column containing group identifier of the
|
|
|
address.
|
|
|
|
|
|
- Default value is "grp".
|
|
|
+ Default value is “grp�.
|
|
|
|
|
|
Example 1.8. Set grp_col parameter
|
|
|
...
|
|
@@ -490,7 +499,7 @@ modparam("permissions", "grp_col", "group_id")
|
|
|
|
|
|
Name of address table column containing IP address part of the address.
|
|
|
|
|
|
- Default value is "ip_addr".
|
|
|
+ Default value is “ip_addr�.
|
|
|
|
|
|
Example 1.9. Set ip_addr_col parameter
|
|
|
...
|
|
@@ -502,7 +511,7 @@ modparam("permissions", "ip_addr_col", "ip_address")
|
|
|
Name of address table column containing network mask of the address.
|
|
|
Possible values are 0-32.
|
|
|
|
|
|
- Default value is "mask".
|
|
|
+ Default value is “mask�.
|
|
|
|
|
|
Example 1.10. Set mask_col parameter
|
|
|
...
|
|
@@ -513,7 +522,7 @@ modparam("permissions", "mask_col", "subnet_length")
|
|
|
|
|
|
Name of address table column containing port part of the address.
|
|
|
|
|
|
- Default value is "port".
|
|
|
+ Default value is “port�.
|
|
|
|
|
|
Example 1.11. Set port_col parameter
|
|
|
...
|
|
@@ -537,7 +546,7 @@ modparam("permissions", "db_mode", 1)
|
|
|
Name of database table containing matching rules used by allow_trusted
|
|
|
function.
|
|
|
|
|
|
- Default value is "trusted".
|
|
|
+ Default value is “trusted�.
|
|
|
|
|
|
Example 1.13. Set trusted_table parameter
|
|
|
...
|
|
@@ -549,7 +558,7 @@ modparam("permissions", "trusted_table", "pbx")
|
|
|
Name of trusted table column containing source IP address that is
|
|
|
matched against source IP address of received request.
|
|
|
|
|
|
- Default value is "src_ip".
|
|
|
+ Default value is “src_ip�.
|
|
|
|
|
|
Example 1.14. Set source_col parameter
|
|
|
...
|
|
@@ -560,10 +569,10 @@ modparam("permissions", "source_col", "source_ip_address")
|
|
|
|
|
|
Name of trusted table column containing transport protocol that is
|
|
|
matched against transport protocol of received request. Possible values
|
|
|
- that can be stored in proto_col are "any", "udp", "tcp", "tls", "sctp",
|
|
|
- and "none". Value "any" matches always and value "none" never.
|
|
|
+ that can be stored in proto_col are “any�, “udp�, “tcp�, “tls�, “sctp�,
|
|
|
+ and “none�. Value “any� matches always and value “none� never.
|
|
|
|
|
|
- Default value is "proto".
|
|
|
+ Default value is “proto�.
|
|
|
|
|
|
Example 1.15. Set proto_col parameter
|
|
|
...
|
|
@@ -575,7 +584,7 @@ modparam("permissions", "proto_col", "transport")
|
|
|
Name of trusted table column containing regular expression that is
|
|
|
matched against From URI.
|
|
|
|
|
|
- Default value is "from_pattern".
|
|
|
+ Default value is “from_pattern�.
|
|
|
|
|
|
Example 1.16. Set from_col parameter
|
|
|
...
|
|
@@ -588,7 +597,7 @@ modparam("permissions", "from_col", "regexp")
|
|
|
added as value to peer_tag AVP if peer_tag AVP has been defined and if
|
|
|
the address or peer matches.
|
|
|
|
|
|
- Default value is "tag".
|
|
|
+ Default value is “tag�.
|
|
|
|
|
|
Example 1.17. Set tag_col parameter
|
|
|
...
|
|
@@ -600,7 +609,7 @@ modparam("permissions", "tag_col", "peer_tag")
|
|
|
If defined, the AVP will be set as side effect of allow_trusted() call
|
|
|
to not NULL tag column value of the matching peer.
|
|
|
|
|
|
- Default value is "undefined".
|
|
|
+ Default value is “undefined�.
|
|
|
|
|
|
Example 1.18. Set peer_tag_avp parameter
|
|
|
...
|
|
@@ -613,7 +622,7 @@ modparam("permissions", "peer_tag_avp", "$avp(i:707)")
|
|
|
adds the tags of all matches to the avp. In addition the return value
|
|
|
of allow_trusted() is the number of matches.
|
|
|
|
|
|
- Default value is "0".
|
|
|
+ Default value is “0�.
|
|
|
|
|
|
Example 1.19. Set peer_tag_mode parameter
|
|
|
...
|
|
@@ -637,7 +646,7 @@ modparam("permissions", "peer_tag_mode", "1")
|
|
|
4.1. allow_routing()
|
|
|
|
|
|
Returns true if all pairs constructed as described in Section 1.1,
|
|
|
- "Call Routing" have appropriate permissions according to the
|
|
|
+ “Call Routing� have appropriate permissions according to the
|
|
|
configuration files. This function uses default configuration files
|
|
|
specified in default_allow_file and default_deny_file.
|
|
|
|
|
@@ -653,7 +662,7 @@ if (allow_routing()) {
|
|
|
4.2. allow_routing(basename)
|
|
|
|
|
|
Returns true if all pairs constructed as described in Section 1.1,
|
|
|
- "Call Routing" have appropriate permissions according to the
|
|
|
+ “Call Routing� have appropriate permissions according to the
|
|
|
configuration files given as parameters.
|
|
|
|
|
|
Meaning of the parameters is as follows:
|
|
@@ -676,7 +685,7 @@ if (allow_routing("basename")) {
|
|
|
4.3. allow_routing(allow_file,deny_file)
|
|
|
|
|
|
Returns true if all pairs constructed as described in Section 1.1,
|
|
|
- "Call Routing" have appropriate permissions according to the
|
|
|
+ “Call Routing� have appropriate permissions according to the
|
|
|
configuration files given as parameters.
|
|
|
|
|
|
Meaning of the parameters is as follows:
|
|
@@ -701,7 +710,7 @@ if (allow_routing("rules.allow", "rules.deny")) {
|
|
|
4.4. allow_register(basename)
|
|
|
|
|
|
The function returns true if all pairs constructed as described in
|
|
|
- Section 1.2, "Registration Permissions" have appropriate permissions
|
|
|
+ Section 1.2, “Registration Permissions� have appropriate permissions
|
|
|
according to the configuration files given as parameters.
|
|
|
|
|
|
Meaning of the parameters is as follows:
|
|
@@ -729,7 +738,7 @@ if (method=="REGISTER") {
|
|
|
4.5. allow_register(allow_file, deny_file)
|
|
|
|
|
|
The function returns true if all pairs constructed as described in
|
|
|
- Section 1.2, "Registration Permissions" have appropriate permissions
|
|
|
+ Section 1.2, “Registration Permissions� have appropriate permissions
|
|
|
according to the configuration files given as parameters.
|
|
|
|
|
|
Meaning of the parameters is as follows:
|
|
@@ -758,8 +767,8 @@ if (method=="REGISTER") {
|
|
|
|
|
|
4.6. allow_uri(basename, pvar)
|
|
|
|
|
|
- Returns true if the pair constructed as described in Section 1.3, "URI
|
|
|
- Permissions" have appropriate permissions according to the
|
|
|
+ Returns true if the pair constructed as described in Section 1.3, “URI
|
|
|
+ Permissions� have appropriate permissions according to the
|
|
|
configuration files specified by the parameter.
|
|
|
|
|
|
Meaning of the parameter is as follows:
|
|
@@ -785,11 +794,15 @@ if (allow_uri("basename", "$avp(i:705)") { // Check URI stored in $avp(i:705)
|
|
|
|
|
|
4.7. allow_address(group_id, ip_addr_pvar, port_pvar)
|
|
|
|
|
|
- Returns true if IP address and port given as values of pvar arguments
|
|
|
- belonging to a group given as group_id argument matches an IP subnet
|
|
|
- found in cached address table. Cached address table entry containing
|
|
|
- port value 0 matches any port. group_id argument can be an integer
|
|
|
- string or a pseudo variable.
|
|
|
+ Returns true if address and port given as values of pvar arguments
|
|
|
+ belonging to a group given as group_id argument matches an IP subnet or
|
|
|
+ a DNS domain name found in cached address table. When matching is done
|
|
|
+ if the argument is an IP, it is tried to be matched with the records
|
|
|
+ from that group that are of type exact IP or subnet. If the argument is
|
|
|
+ not an IP it is tried to be matched with the records that are DNS
|
|
|
+ domain names. No DNS lookup is performed, only strict matching. Cached
|
|
|
+ address table entry containing port value 0 matches any port. group_id
|
|
|
+ argument can be an integer string or a pseudo variable.
|
|
|
|
|
|
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
|
|
|
|
|
@@ -800,8 +813,10 @@ if (allow_uri("basename", "$avp(i:705)") { // Check URI stored in $avp(i:705)
|
|
|
if (!allow_address("1", "$si", "$sp")) {
|
|
|
sl_send_reply("403", "Forbidden");
|
|
|
};
|
|
|
-// Check IP address/port stored in AVPs i:704/i:705 is in group 2
|
|
|
-if (!allow_address("2", "$avp(i:704)", "$avp(i:705)") {
|
|
|
+// Check address/port stored in AVPs src_adr/src_port is in group 2
|
|
|
+$avp(dst_adr) = "sipdomain.com";
|
|
|
+$avp(dst_port) = "0";
|
|
|
+if (!allow_address("2", "$avp(dst_adr)", "$avp(dst_port)") {
|
|
|
sl_send_reply("403", "Forbidden");
|
|
|
};
|
|
|
...
|
|
@@ -862,8 +877,8 @@ if ($var(group) != -1) {
|
|
|
Checks based either on request's source address and transport protocol
|
|
|
or source address and transport protocol given in pvar arguments, and
|
|
|
From URI of request if request can be trusted without authentication.
|
|
|
- Returns 1 if a match is found as described in Section 1.5, "Trusted
|
|
|
- Requests" and -1 otherwise. If a match is found and peer_tag_avp has
|
|
|
+ Returns 1 if a match is found as described in Section 1.5, “Trusted
|
|
|
+ Requests� and -1 otherwise. If a match is found and peer_tag_avp has
|
|
|
been defined, adds a non-NULL tag column value of the matching peer to
|
|
|
AVP peer_tag_avp.
|
|
|
|