PDT module
Admin Guide
Section titled “Admin Guide”Overview
Section titled “Overview”This module translates a numerical prefix into a domain and updates accordingly the request URI.
The module looks up at the R-URI part of a message and if the user part begins with an established prefix it will update the URI. Updating the uri consists of: remove the prefix from the user part of the uri and keep the rest as the user part of the new uri. The host and port are changed with the domain matched for the leading prefix and the domain in From URI.
and the result will be:
prefix=123, domain(FROM)=siphub.org
entry in database: sdomain=siphub.org domain[123]=alpha.org domain[124]=beta.org domain[125]=gamma.org
The RURI will be updated in the following way"sip:12391001@mydomain.com => sip:91001@alpha.orgThe prefix could be prefixed by other digits. These digits will not be used to look up the domain (the classic example, 00 used for international calls, then follows the country prefix). For more information on this, see ‘prefix’ parameter.
- A sample config file is located in ’./doc/’.
- MySQL script to create the database needed by PDT is located in ’../../scripts/mysql/pdt-create.sql’ The database is loaded by OpenSIPS only at start up time and only cache is used to lookup domains. Check the MI Functions for adding/deleting prefix-domain pairs or reloading from database at runtime.
- Sample shell scripts to manage prefix-domain pairs are also located in ’./doc/’ (pdt_fifo_add.sh, pdt_fifo_delete.sh, pdt_fifo_list.sh).
Dependencies
Section titled “Dependencies”OpenSIPS Modules
Section titled “OpenSIPS Modules”The following modules must be loaded before this module:
- A OpenSIPS database module (e.g., mysql, dbtext).
External Libraries or Applications
Section titled “External Libraries or Applications”The following libraries or applications must be installed before running OpenSIPS with this module loaded:
- None.
Exported Parameters
Section titled “Exported Parameters”db_url (string)
Section titled “db_url (string)”URL of the database table to be used.
Default value is “mysql://opensips:opensipsrw@localhost/opensips”.
...modparam("pdt", "db_url", "dbdriver://username:password@dbhost/dbname")...db_table (string)
Section titled “db_table (string)”Table name.
Default value is “pdt”.
...modparam("pdt", "db_table", "pdt")...sdomain_column (string)
Section titled “sdomain_column (string)”Name of ‘sdomain’ column.
Default value is “sdomain”.
...modparam("pdt", "domain_column", "source_domain")...prefix_column (string)
Section titled “prefix_column (string)”Name of ‘prefix’ column.
Default value is “prefix”.
...modparam("pdt", "prefix_column", "prefix")...domain_column (string)
Section titled “domain_column (string)”Name of ‘domain’ column.
Default value is “domain”.
...modparam("pdt", "domain_column", "hostname")...prefix (string)
Section titled “prefix (string)”Default leading prefix who denotes what URI needs to be translated - if it is NULL the module will not check the R-URI against it and the PDT prefix is considered starting from the first digit. Otherwise, the module will check first if the R-URI starts with it and will skip it to look up the domain.
Default value is NULL.
...modparam("pdt", "prefix", "00")...char_list (string)
Section titled “char_list (string)”The list with characters allowed in prefix.
Default value is “0123456789”.
...modparam("pdt", "char_list", "0123456789*+")...check_domain (integer)
Section titled “check_domain (integer)”Module will check if destination domain is duplicated for same source domain (1 - check; 0 - don’t check).
Default value is 1.
...modparam("pdt", "check_domain", 0)...Exported Functions
Section titled “Exported Functions”prefix2domain(rewrite_mode, multidomain_mode)
Section titled “prefix2domain(rewrite_mode, multidomain_mode)”Build a new URI if it is necessary. Returns 1 when the translation was made or there was nothing to translate (user part of the URI is empty, it does not match the prefix parameter or there is no domain associated with a possible prefix from user part). Returns -1 in error cases.
The translation is done based on lookup up for a entry in the database where the sdomain equals the domain in FROM uri, and the prefix matches the beginning of the user part of the RURI. If such an entry is found, then the domain in RURI is updated with the domain of this entry (sdomain, prefix, domain).
There is also the possibility to have the translation of URI regardless of source domain. This can be achieved inserting in the database entries where sdomain has the value ”*”.
The “rewrite_mode” parameter specifies whether to strip or not the prefix from user part. The possible values are:
- 0: the prefix is removed along with the leading prefix.
- 1: only the leading prefix is removed.
- 2: the user part of the URI is not changed.
- $PV : any PV holding one of the above values.
The “multidomain_mode” parameter specifies the kind of multidomain support to use. The possible values are:
- 0 : Translation of URI regardless of source domain.
- 1 : Translation of URI using as source domain the domain in From-URI.
- 2 : Translation of URI using as source domain the domain in From-URI. In case there is no entry for the required sdomain, it tries the translation using ”*” as sdomain.
- $PV : any PV holding one of the above values.
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
...prefix2domain("2", "2");...$var(a) = 1;prefix2domain("$var(a)", "2");...prefix2domain(rewrite_mode)
Section titled “prefix2domain(rewrite_mode)”The same as prefix2domain(rewrite_mode, “0”), that is without multidomain support, translation of URI being done regardless of the source domain.
...prefix2domain("2");...prefix2domain()
Section titled “prefix2domain()”The same as prefix2domain(“0”, “0”).
...prefix2domain();...Exported MI Functions
Section titled “Exported MI Functions”The database is loaded by OpenSIPS at start up time. The module uses only the cache to look up domains. If you want to add or delete a new prefix-domain pair at runtime you have to use MI FIFO commands. All changes made via these commands are applied to database and the cache is updated correspondingly.
pdt_add
Section titled “pdt_add”Adds a new sdomain-prefix-domain entry.
Name: pdt_add
Parameters:
- sdomain : source domain
- prefix: prefix
- domain: domain corresponding to a pair of source domain and prefix
MI FIFO Command Format:
:pdt_add:_reply_fifo_file_ _sdomain_ _prefix_ _domain_ _empty_line_pdt_delete
Section titled “pdt_delete”Removes a sdomain-prefix-domain entry.
Name: pdt_delete
Parameters:
- sdomain : a source domain
- domain: a domain associated via a prefix with the source domain
MI FIFO Command Format:
:pdt_delete:_reply_fifo_file_ _sdomain_ _domain_ _empty_line_pdt_list
Section titled “pdt_list”Produces a listing of the entries prefixes/domains/sdomains.
Name: pdt_list
Parameters:
- sdomain : a source domain value.
- prefix : a prefix value
- domain: a domain value
”.” (dot) means NULL value
The comparison operation is ‘START WITH’ — if domain is ‘a’ then all domains starting with ‘a’ are listed.
MI FIFO Command Format:
:pdt_list:_reply_fifo_file_ _sdomain_ _prefix_ _domain_ _empty_line_Examples:
- “pdt_list siph 2 .” : Lists the entries where sdomain is starting with ‘siph’, prefix is starting with ‘2’ and domain is anything
- “pdt_list siph 2” : Lists the entries where sdomain is starting with ‘siph’, prefix is starting with ‘2’ and domain is anything
- “pdt_list . 2 open” : Lists the entries where sdomain is anything, prefix starts with ‘2’ and domain starts with ‘open’.
pdt_reload
Section titled “pdt_reload”Reload all sdomain-prefix-domain records from database.
Name: pdt_reload
Parameters:
- none
MI FIFO Command Format:
:pdt_reload:_reply_fifo_file_ _empty_line_Installation and Running
Section titled “Installation and Running”Example shell scripts for MI FIFO commands are placed in ’./doc/’ (pdt_fifo_add.sh, pdt_fifo_delete.sh, pdt_fifo_list.sh).
Contributors
Section titled “Contributors”By Commit Statistics
Section titled “By Commit Statistics”Top contributors by DevScore(1), authored commits(2) and lines added/removed(3)
| # | Name | DevScore | Commits | Lines++ | Lines— |
|---|---|---|---|---|---|
| 1. | Elena-Ramona Modroiu | 78 | 18 | 2280 | 2359 |
| 2. | Elena-Ramona Modroiu | 61 | 12 | 3466 | 1121 |
| 3. | Bogdan-Andrei Iancu (@bogdan-iancu) | 55 | 30 | 698 | 1135 |
| 4. | Daniel-Constantin Mierla (@miconda) | 15 | 13 | 61 | 38 |
| 5. | Jan Janak (@janakj) | 14 | 8 | 573 | 17 |
| 6. | Stefan Darius (@dariusstefan) | 11 | 4 | 523 | 61 |
| 7. | Henning Westerholt (@henningw) | 9 | 6 | 64 | 96 |
| 8. | Andrei Pelinescu-Onciul | 5 | 3 | 21 | 18 |
| 9. | Razvan Crainea (@razvancrainea) | 5 | 3 | 19 | 59 |
| 10. | Ancuta Onofrei | 5 | 1 | 117 | 132 |
All remaining contributors: Anca Vamanu, Konstantin Bokarius, Edson Gellert Schubert.
(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
By Commit Activity
Section titled “By Commit Activity”| # | Name | Commit Activity |
|---|---|---|
| 1. | Stefan Darius (@dariusstefan) | Jun 2026 - Jul 2026 |
| 2. | Razvan Crainea (@razvancrainea) | Dec 2010 - Jun 2026 |
| 3. | Bogdan-Andrei Iancu (@bogdan-iancu) | Nov 2003 - Apr 2011 |
| 4. | Anca Vamanu | Feb 2009 - Feb 2009 |
| 5. | Elena-Ramona Modroiu | Oct 2005 - Jun 2008 |
| 6. | Daniel-Constantin Mierla (@miconda) | Jul 2006 - Mar 2008 |
| 7. | Konstantin Bokarius | Mar 2008 - Mar 2008 |
| 8. | Edson Gellert Schubert | Feb 2008 - Feb 2008 |
| 9. | Henning Westerholt (@henningw) | May 2007 - Jan 2008 |
| 10. | Ancuta Onofrei | Sep 2007 - Sep 2007 |
All remaining contributors: Elena-Ramona Modroiu, Jan Janak (@janakj), Andrei Pelinescu-Onciul.
(1) including any documentation-related commits, excluding merge commits
Documentation
Section titled “Documentation”Contributors
Section titled “Contributors”Last edited by: Razvan Crainea (@razvancrainea), Bogdan-Andrei Iancu (@bogdan-iancu), Elena-Ramona Modroiu, Daniel-Constantin Mierla (@miconda), Konstantin Bokarius, Edson Gellert Schubert, Henning Westerholt (@henningw), Elena-Ramona Modroiu, Jan Janak (@janakj).
License
Section titled “License”All documentation files (i.e. .md extension) are licensed under the Creative Common License 4.0