Skip to content

DOMAIN module

Domain module implements checks that based on domain table determine if a host part of an URI is “local” or not. A “local” domain is one that the proxy is responsible for.

Domain module operates in caching or non-caching mode depending on value of module parameter db_mode. In caching mode domain module reads the contents of domain table into cache memory when the module is loaded. After that domain table is re-read only when module is given domain:reload MI command. Any changes in domain table must thus be followed by “domain:reload” command in order to reflect them in module behavior. In non-caching mode domain module always queries domain table in the database.

Caching is implemented using a hash table. The size of the hash table is given by HASH_SIZE constant defined in domain_mod.h. Its “factory default” value is 128.

The module depends on the following modules (in the other words the listed modules must be loaded before this module):

  • database — Any database module

This is URL of the database to be used.

Default value is “mysql://opensipsro:opensipsro@localhost/opensips”

Setting db_url parameter
modparam("domain", "db_url", "mysql://ser:pass@db_host/ser")

Database mode: 0 means non-caching, 1 means caching.

Default value is 0 (non-caching).

db_mode example
modparam("domain", "db_mode", 1) # Use caching

Name of table containing names of local domains that the proxy is responsible for. Local users must have in their sip uri a host part that is equal to one of these domains.

Default value is “domain”.

Setting domain_table parameter
modparam("domain", "domain_table", "new_name")

Name of column containing domains in domain table.

Default value is “domain”.

Setting domain_col parameter
modparam("domain", "domain_col", "domain_name")

Name of column containing attributes in domain table.

Default value is “attrs”.

Setting attrs_col parameter
modparam("domain", "attrs_col", "attributes")

Name of the “accept_subdomain” column in the domain table. A positive value for the column means the domain accepts subdomains. A 0 value means it does not.

Default value is “accept_subdomain”.

Setting subdomain_col parameter
modparam("domain", "subdomain_col", "has_subdomain")

Checks based on domain table if host part of From header uri is one of the local domains that the proxy is responsible for. The argument is optional and if present it should contain a writable variable that will be populated with the attributes from the database.

This function can be used from REQUEST_ROUTE.

is_from_local usage
...
if (is_from_local()) {
...
};
...
if (is_from_local($var(attrs))) {
xlog("Domain attributes are $var(attrs)\n");
...
};
...

If called from route or failure route block, checks based on domain table if host part of Request-URI is one of the local domains that the proxy is responsible for. If called from branch route, the test is made on host part of URI of first branch, which thus must have been appended to the transaction before is_uri_host_local() is called. The argument is optional and if present it should contain a writable variable that will be populated with the attributes from the database.

This function can be used from REQUEST_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE.

is_uri_host_local usage
...
if (is_uri_host_local()) {
...
};
...
if (is_uri_host_local($var(attrs))) {
xlog("Domain attributes are $var(attrs)\n");
...
};

This function checks if the domain contained in the first parameter is local.

This function is a generalized form of the is_from_local() and is_uri_host_local() functions, being able to completely replace them and also extends them by allowing the domain to be taken from any of the above mentioned sources. The following equivalences exist:

  • is_domain_local($rd) is same as is_uri_host_local()
  • is_domain_local($fd) is same as is_from_local()

Parameters:

  • domain (string)
  • attrs_var (var, optional) - a writable variable that will be populated with the attributes from the database.

This function can be used from REQUEST_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE.

is_domain_local usage
...
if (is_domain_local($rd)) {
...
};
if (is_domain_local($fd)) {
...
};
if (is_domain_local($avp(some_avp_alias))) {
...
};
if (is_domain_local($avp(850))) {
...
};
if (is_domain_local($avp(some_avp))) {
...
};
if (is_domain_local($avp(some_avp), $avp(attrs))) {
xlog("Domain attributes are $avp(attrs)\n");
...
};
...

Replaces obsolete MI command: domain_reload.

Causes domain module to re-read the contents of domain table into cache memory.

Name: domain:reload

Parameters: none

MI FIFO Command Format:

Terminal window
opensips-cli -x mi domain:reload

Replaces obsolete MI command: domain_dump.

Causes domain module to dump hash indexes and domain names in its cache memory.

Name: domain:dump

Parameters: none

MI FIFO Command Format:

Terminal window
opensips-cli -x mi domain:dump

There is an unlikely race condition on domain list update. If a process uses a table, which is reloaded at the same time twice through FIFO, the second reload will delete the original table still in use by the process.

The module provides is_domain_local API function for use by other OpenSIPS modules.

Checks if domain given in str* parameter is local.

The function returns 1 if domain is local and -1 if domain is not local or if an error occurred.

Top contributors by DevScore(1), authored commits(2) and lines added/removed(3)

#NameDevScoreCommitsLines++Lines—
1.Bogdan-Andrei Iancu (@bogdan-iancu)5642451569
2.Jan Janak (@janakj)33211036150
3.Juha Heinanen (@juha-h)3220726259
4.Razvan Crainea (@razvancrainea)241927094
5.Daniel-Constantin Mierla (@miconda)18167358
6.Liviu Chircu (@liviuchircu)1295585
7.Stefan Darius11540163
8.Vlad Patrascu (@rvlad-patrascu)9596124
9.Andrei Pelinescu-Onciul94186121
10.Dan Pascu (@danpascu)84237106

All remaining contributors: Henning Westerholt (@henningw), David Trihy, Elena-Ramona Modroiu, Peter Lemenkov (@lemenkov), Maksym Sobolyev (@sobomax), Jiri Kuthan (@jiriatipteldotorg), @coxx, Anca Vamanu, Konstantin Bokarius, Klaus Darilion, Stefan Darius, Norman Brandinger (@NormB), UnixDev, Andreas Granig, Edson Gellert Schubert, Ovidiu Sas (@ovidiusas), John Burke (@john08burke).

(1) DevScore = author_commits + author_lines_added / (project_lines_added / project_commits) + author_lines_deleted / (project_lines_deleted / project_commits)

(2) including any documentation-related commits, excluding merge commits

(3) ignoring whitespace edits, renamed files and auto-generated files

#NameCommit Activity
1.Stefan DariusJun 2026 - Jul 2026
2.Razvan Crainea (@razvancrainea)Jun 2011 - Jun 2026
3.Peter Lemenkov (@lemenkov)Jun 2018 - Jul 2025
4.Bogdan-Andrei Iancu (@bogdan-iancu)Oct 2005 - Jun 2025
5.Ovidiu Sas (@ovidiusas)May 2025 - May 2025
6.Liviu Chircu (@liviuchircu)Mar 2014 - May 2025
7.David TrihyMay 2025 - May 2025
8.Stefan DariusJul 2024 - Jul 2024
9.Maksym Sobolyev (@sobomax)Feb 2023 - Feb 2023
10.John Burke (@john08burke)Jan 2022 - Jan 2022

All remaining contributors: Vlad Patrascu (@rvlad-patrascu), @coxx, Anca Vamanu, UnixDev, Juha Heinanen (@juha-h), Henning Westerholt (@henningw), Daniel-Constantin Mierla (@miconda), Konstantin Bokarius, Edson Gellert Schubert, Elena-Ramona Modroiu, Dan Pascu (@danpascu), Norman Brandinger (@NormB), Andreas Granig, Klaus Darilion, Jan Janak (@janakj), Andrei Pelinescu-Onciul, Jiri Kuthan (@jiriatipteldotorg).

(1) including any documentation-related commits, excluding merge commits

Last edited by: Razvan Crainea (@razvancrainea), Bogdan-Andrei Iancu (@bogdan-iancu), Vlad Patrascu (@rvlad-patrascu), Peter Lemenkov (@lemenkov), Liviu Chircu (@liviuchircu), Daniel-Constantin Mierla (@miconda), Konstantin Bokarius, Edson Gellert Schubert, Juha Heinanen (@juha-h), Elena-Ramona Modroiu, Dan Pascu (@danpascu), Klaus Darilion, Jan Janak (@janakj).

All documentation files (i.e. .md extension) are licensed under the Creative Common License 4.0