ALIAS_DB Module


Table of Contents

1. Admin Guide
1.1. Overview
1.2. Dependencies
1.2.1. OpenSIPS Modules
1.2.2. External Libraries or Applications
1.3. Exported Parameters
1.3.1. db_url (str)
1.3.2. user_column (str)
1.3.3. domain_column (str)
1.3.4. alias_user_column (str)
1.3.5. alias_domain_column (str)
1.3.6. domain_prefix (str)
1.3.7. append_branches (int)
1.4. Exported Functions
1.4.1. alias_db_lookup(table_name, [flags])
1.4.2. alias_db_find(table_name, input_uri, output_var, [flags])
2. Frequently Asked Questions
3. Contributors
3.1. By Commit Statistics
3.2. By Commit Activity
4. Documentation
4.1. Contributors

List of Tables

3.1. Top contributors by DevScore(1), authored commits(2) and lines added/removed(3)
3.2. Most recently active contributors(1) to this module

List of Examples

1.1. Set db_url parameter
1.2. Set user_column parameter
1.3. Set domain_column parameter
1.4. Set alias_user_column parameter
1.5. Set alias_domain_column parameter
1.6. Set domain_prefix parameter
1.7. Set append_branches parameter
1.8. alias_db_lookup() usage
1.9. alias_db_find() usage

Chapter 1. Admin Guide

1.1. Overview

ALIAS_DB module can be used as an alternative for user aliases via usrloc. The main feature is that it does not store all adjacent data as for user location and always uses database for search (no memory caching).

Having no memory caching, search speed might decrease but provisioning is easier. With very fast databases like MySQL, speed penalty can be lowered. Also, search can be performed on different tables in the same script.

1.2. Dependencies

1.2.1. OpenSIPS Modules

The following modules must be loaded before this module:

  • database module (mysql, dbtext, ...).

1.2.2. External Libraries or Applications

The following libraries or applications must be installed before running OpenSIPS with this module loaded:

  • None.

1.3. Exported Parameters

1.3.1. db_url (str)

Database URL.

Default value is mysql://opensipsro:opensipsro@localhost/opensips.

Example 1.1. Set db_url parameter

...
modparam("alias_db", "db_url", "dbdriver://username:password@dbhost/dbname")
...

1.3.2. user_column (str)

Name of the column storing username.

Default value is username.

Example 1.2. Set user_column parameter

...
modparam("alias_db", "user_column", "susername")
...

1.3.3. domain_column (str)

Name of the column storing user's domain.

Default value is domain.

Example 1.3. Set domain_column parameter

...
modparam("alias_db", "domain_column", "sdomain")
...

1.3.4. alias_user_column (str)

Name of the column storing alias username.

Default value is alias_username.

Example 1.4. Set alias_user_column parameter

...
modparam("alias_db", "alias_user_column", "auser")
...

1.3.5. alias_domain_column (str)

Name of the column storing alias domain.

Default value is alias_domain.

Example 1.5. Set alias_domain_column parameter

...
modparam("alias_db", "alias_domain_column", "adomain")
...

1.3.6. domain_prefix (str)

Specifies the prefix to be stripped from the domain in R-URI before doing the search.

Default value is NULL.

Example 1.6. Set domain_prefix parameter

...
modparam("alias_db", "domain_prefix", "sip.")
...

1.3.7. append_branches (int)

If the alias resolves to many SIP IDs, the first is replacing the R-URI, the rest are added as branches.

Default value is 0 (0 - don't add branches; 1 - add branches).

Example 1.7. Set append_branches parameter

...
modparam("alias_db", "append_branches", 1)
...

1.4. Exported Functions

1.4.1.  alias_db_lookup(table_name, [flags])

The function takes the R-URI and search to see whether it is an alias or not. If it is an alias for a local user, the R-URI is replaced with user's SIP uri.

The function returns TRUE if R-URI is alias and it was replaced by user's SIP uri.

Meaning of the parameters is as follows:

  • table_name (string) - the name of the table to search for the alias

  • flags (string, optional) - set of character flags to control the alias lookup process:

    • d - do not use domain URI part in the alias lookup query (use only a username-based lookup). By default, both username and domain are used.

    • r - do reverse alias lookup - lookup for the alias mapped to the current URI (URI 2 alias translation); normally, the function looks up for the URI mapped to the alias (alias 2 URI translation).

This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.

Example 1.8. alias_db_lookup() usage

...
alias_db_lookup("dbaliases", "rd");
alias_db_lookup("dba_$(rU{s.substr,0,1})");
...

1.4.2.  alias_db_find(table_name, input_uri, output_var, [flags])

The function is very similar to alias_db_lookup(), but instead of using fixed input (RURI) and output (RURI) is able to get the input SIP URI from a pseudo-variable and place the result back also in a pseudo-variable.

The function is useful as the alias lookup does not affect the request itself (no RURI changes), can be used in a reply context (as it does not work with RURI only) and can be used for others URI than the RURI (To URI, From URI, custom URI).

The function returns TRUE if any alias mapping was found and returned.

Meaning of the parameters is as follows:

  • table_name (string) - the name of the table to search for the alias

  • input_uri (string) - a SIP URI to look up

  • output_var (var) - a variable to hold the SIP URI result

  • flags (string, optional) (optional) - set of flags (char based flags) to control the alias lookup process:

    • d - do not use domain URI part in the alias lookup query (use only a username-based lookup). By default, both username and domain are used.

    • r - do revers alias lookup - lookup for the alias mapped to the current URI (URI 2 alias translation); normally, the function looks up for the URI mapped to the alias (alias 2 URI translation).

This function can be used from REQUEST_ROUTE, BRANCH_ROUTE, LOCAL_ROUTE, STARTUP_ROUTE, FAILURE_ROUTE and ONREPLY_ROUTE.

Example 1.9. alias_db_find() usage

...
# do revers alias lookup and find the alias for the FROM URI
alias_db_find("dbaliases", $fu, $avp(from_alias), "r");
...

Chapter 2. Frequently Asked Questions

2.1.

What happened with old use_domain parameter

The global parameter (affecting the entire module) was replaced with a per lookup parameter (affecting only current lookup). See the "d" (do not used domain part) flag in the db_alias_lookup() and db_alias_find() functions.

2.2.

How can I report a bug?

Please follow the guidelines provided at: https://github.com/OpenSIPS/opensips/issues.

Chapter 3. Contributors

3.1. By Commit Statistics

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

 NameDevScoreCommitsLines ++Lines --
1. Bogdan-Andrei Iancu (@bogdan-iancu)3227216170
2. Daniel-Constantin Mierla (@miconda)15122864
3. Liviu Chircu (@liviuchircu)1294862
4. Razvan Crainea (@razvancrainea)86108
5. Henning Westerholt (@henningw)644849
6. Elena-Ramona Modroiu539239
7. Walter Doekes (@wdoekes)5377
8. Vlad Patrascu (@rvlad-patrascu)523888
9. Vladimir Romanov4122751
10. Sergey Khripchenko (@shripchenko)311822

All remaining contributors: Sergio Gutierrez, Konstantin Bokarius, Anca Vamanu, Dusan Klinec (@ph4r05), Peter Lemenkov (@lemenkov), 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. Regarding imported patches/code, we do our best to count the work on behalf of the proper owner, as per the "fix_authors" and "mod_renames" arrays in opensips/doc/build-contrib.sh. If you identify any patches/commits which do not get properly attributed to you, please submit a pull request which extends "fix_authors" and/or "mod_renames".

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

3.2. By Commit Activity

Table 3.2. Most recently active contributors(1) to this module

 NameCommit Activity
1. Walter Doekes (@wdoekes)Apr 2010 - Apr 2021
2. Bogdan-Andrei Iancu (@bogdan-iancu)Oct 2005 - Mar 2020
3. Razvan Crainea (@razvancrainea)Jun 2011 - Sep 2019
4. Liviu Chircu (@liviuchircu)Mar 2014 - Apr 2019
5. Vlad Patrascu (@rvlad-patrascu)May 2017 - Apr 2019
6. Peter Lemenkov (@lemenkov)Jun 2018 - Jun 2018
7. Dusan Klinec (@ph4r05)Dec 2015 - Dec 2015
8. Sergey Khripchenko (@shripchenko)Sep 2015 - Sep 2015
9. Anca VamanuSep 2009 - Sep 2009
10. Vladimir RomanovMay 2009 - May 2009

All remaining contributors: Sergio Gutierrez, Henning Westerholt (@henningw), Elena-Ramona Modroiu, Daniel-Constantin Mierla (@miconda), Konstantin Bokarius, Edson Gellert Schubert.

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

Chapter 4. Documentation

4.1. Contributors

Last edited by: Liviu Chircu (@liviuchircu), Peter Lemenkov (@lemenkov), Sergey Khripchenko (@shripchenko), Razvan Crainea (@razvancrainea), Walter Doekes (@wdoekes), Bogdan-Andrei Iancu (@bogdan-iancu), Sergio Gutierrez, Henning Westerholt (@henningw), Elena-Ramona Modroiu, Daniel-Constantin Mierla (@miconda), Konstantin Bokarius, Edson Gellert Schubert.

Documentation Copyrights:

Copyright © 2005-2009 Voice Sistem SRL