uri_db Module

Jan Janak

FhG FOKUS

Edited by

Jan Janak

Edited by

Bogdan-Andrei Iancu

Edited by

Sergio Gutierrez

Edited by

Andreas Westermaier

overturn technologies GmbH
Revision History
Revision $Revision: 5611 $$Date: 2009-04-08 17:39:29 +0200 (Wed, 08 Apr 2009) $

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 (string)
1.3.2. db_table (string)
1.3.3. user_column (string)
1.3.4. domain_column (string)
1.3.5. uriuser_column (string)
1.3.6. use_uri_table (integer)
1.3.7. use_domain (integer)
1.4. Exported Functions
1.4.1. check_to()
1.4.2. check_from()
1.4.3. does_uri_exist()
1.4.4. get_auth_id(string, var, var)
1.5. Exported statistics
1.5.1. positive_checks
1.5.2. negative_checks

List of Examples

1.1. Set db_url parameter
1.2. Set uri_table parameter
1.3. Set user_column parameter
1.4. Set domain_column parameter
1.5. Set uriuser_column parameter
1.6. Set use_uri_table parameter
1.7. Set use_domain parameter
1.8. check_to usage
1.9. check_from usage
1.10. does_uri_exist usage
1.11. get_auth_id usage

Chapter 1. Admin Guide

1.1. Overview

Various checks related to SIP URI.

1.2. Dependencies

1.2.1. OpenSIPS Modules

The following modules must be loaded before this module:

  • a OpenSIPS database module .

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 (string)

URL of the database to be used.

If the db_url string is empty, the default database URL will be used.

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

Example 1.1. Set db_url parameter

...
modparam("uri_db", "db_url", "mysql://username:password@localhost/opensips")
...

1.3.2. db_table (string)

The DB table that should be used. Its possible to use the “subscriber” and “uri” table. If the “uri” table should be used, an additional parameter (Section 1.3.6, “use_uri_table (integer)”) must be set.

Default value is “subscriber”.

Example 1.2. Set uri_table parameter

...
modparam("uri_db", "db_table", "uri")
...

1.3.3. user_column (string)

Column holding usernames in the table.

Default value is “username”.

Example 1.3. Set user_column parameter

...
modparam("uri_db", "user_column", "username")
...

1.3.4. domain_column (string)

Column holding domain in the table.

Default value is “domain”.

Example 1.4. Set domain_column parameter

...
modparam("uri_db", "domain_column", "domain")
...

1.3.5. uriuser_column (string)

Column holding URI username in the table.

Default value is “uri_user”.

Example 1.5. Set uriuser_column parameter

...
modparam("uri_db", "uriuser_column", "uri_user")
...

1.3.6. use_uri_table (integer)

Specify if the “uri” table should be used for checkings instead of “subscriber” table. A non-zero value means true.

Default value is “0 (false)”.

Example 1.6. Set use_uri_table parameter

...
modparam("uri_db", "use_uri_table", 1)
...

1.3.7. use_domain (integer)

Specify if the domain part of the URI should be used to identify the users (along with username). This is useful in multi domain setups, a non-zero value means true.

This parameter is only evaluated for calls to “does_uri_exist”, all other functions checks the digest username and realm against the given username, if the “uri” table is used.

Default value is “0 (false)”.

Example 1.7. Set use_domain parameter

...
modparam("uri_db", "use_domain", 1)
...

1.4. Exported Functions

1.4.1.  check_to()

Check To username against URI table (if use_uri_table is set) or digest credentials (no DB backend required).

This function can be used from REQUEST_ROUTE.

Example 1.8. check_to usage

...
if (check_to()) {
	...
};
...

1.4.2.  check_from()

Check From username against URI table (if use_uri_table is set) or digest credentials (no DB backend required).

This function can be used from REQUEST_ROUTE.

Example 1.9. check_from usage

...
if (check_from()) {
	...
};
...

1.4.3.  does_uri_exist()

Check if username in the request URI belongs to an existing user.

As the checking is done against URI table (if use_uri_table is set) or subscriber table.

This function can be used from REQUEST_ROUTE.

Example 1.10. does_uri_exist usage

...
if (does_uri_exist()) {
	...
};
...

1.4.4.  get_auth_id(string, var, var)

Checks given uri-string username against URI table (if use_uri_table is set) or subscriber table (database backend required). Returns true if the user exists in the database, and sets the given variables to the authentication id and realm corresponding to the given uri.

This function can be used from REQUEST_ROUTE.

Example 1.11. get_auth_id usage

...
if (get_auth_id("$ru", "$avp(s:auth_id)", "$avp(s:auth_realm)")) {
	...
};
...

1.5. Exported statistics

Exported statistics are listed in the next sections.

1.5.1. positive_checks

Number of tests executed for which a positive match is returned.

1.5.2. negative_checks

Number of tests executed for which a negative match is returned. This includes no credentials found, or not match found in database.